@kelceyp/swic 0.2.1 → 0.2.3

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.
@@ -166,7 +166,7 @@ ${q.comment}`:q.comment}this.doc.range[2]=q.offset;break}default:this.errors.pus
166
166
  `);if(A.length<3||A[0].trim()!==OO)return{bodyContent:r,isValid:!1,validationError:"Missing front matter delimiter"};let u=-1;for(let Q=1;Q<A.length;Q++)if(A[Q].trim()===OO){u=Q;break}if(u===-1)return{bodyContent:r,isValid:!1,validationError:"Missing closing front matter delimiter"};let m=A.slice(1,u).join(`
167
167
  `),S=A.slice(0,u+1).join(`
168
168
  `),I=A.slice(u+1).join(`
169
- `).trim(),D;try{D=TO.default.parse(m)}catch(Q){return{bodyContent:r,isValid:!1,validationError:`YAML parse error: ${Q.message}`}}if(!D.type)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"Missing required field: type"};let c=["prompt","doc","story-spec","story-tech-doc","subtask","review","feedback","feedback-review","retro"];if(!c.includes(D.type))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Invalid type: ${D.type}. Must be one of: ${c.join(", ")}`};if(!D.params)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"Missing required field: params"};if(typeof D.params!=="object"||Array.isArray(D.params))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"params must be an object"};let e=["string","number","boolean"],L={};for(let[Q,Hq]of Object.entries(D.params)){if(typeof Hq!=="object"||Array.isArray(Hq))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} definition must be an object`};let Pq=Hq;if(!Pq.type)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} missing type field`};if(!e.includes(Pq.type))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} has invalid type: ${Pq.type}. Must be one of: ${e.join(", ")}`};if(Pq.required!==void 0&&typeof Pq.required!=="boolean")return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} required field must be boolean`};L[Q]={type:Pq.type,required:Pq.required??!1,description:Pq.description,default:Pq.default}}return{rawFrontMatter:S,frontMatter:{type:D.type,params:L,synopsis:D.synopsis,...D},bodyContent:I,isValid:!0}},H=(r,A)=>{let u=r,m=0;for(let S of A){let I=u;switch(S.op){case"replaceOnce":u=u.replace(S.oldText,S.newText);break;case"replaceAll":{let D=S.oldText.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");u=u.replace(new RegExp(D,"g"),S.newText);break}case"replaceRegex":{let D=new RegExp(S.pattern,S.flags||"");u=u.replace(D,S.replacement);break}case"replaceAllContent":u=S.content;break}if(u!==I||S.op==="replaceAllContent")m++}return{content:u,applied:m}},h=async(r)=>{if(r.kind==="id"){let A=r.scope;if(!A){let S=iP(r.id);if(!S)w("INVALID_ID_FORMAT",`Invalid template ID format: ${r.id}`);A=S}if(!oP.validateIdForScope(r.id,A))w("INVALID_ID_FORMAT",`Invalid template ID format for ${A} scope: ${r.id}`);let m=(await T(A)).id[r.id];if(!m)w("TEMPLATE_NOT_FOUND",`Template not found: ${r.id}`);return{scope:A,path:m.path,id:r.id}}else{let A=O(r.path);if(!A.valid)w("INVALID_PATH_FORMAT",A.reason||"Invalid path format");let u=A.normalized;if(r.scope){let S=(await T(r.scope)).pathToId[u];if(!S)w("TEMPLATE_NOT_FOUND",`Template not found: ${u} in ${r.scope} scope`);return{scope:r.scope,path:u,id:S}}else{let S=(await T("project")).pathToId[u];if(S)return{scope:"project",path:u,id:S};let D=(await T("shared")).pathToId[u];if(D)return{scope:"shared",path:u,id:D};w("TEMPLATE_NOT_FOUND",`Template not found: ${u}`)}}},J=async(r)=>{let A=await T(r),u=r==="project"?"tpl":"stpl",m=new RegExp(`^${u}(\\d{3,})$`),S=0;for(let D of Object.keys(A.id)){let c=D.match(m);if(c){let e=parseInt(c[1],10);if(e>S)S=e}}let I=S+1;return`${u}${I.toString().padStart(3,"0")}`},k=(r,A,u)=>{if(A==="string")return String(r);if(A==="number"){if(typeof r==="number")return r;let m=parseFloat(String(r));if(isNaN(m))w("INVALID_PARAM_TYPE",`Parameter ${u} must be a valid number, got: ${r}`);return m}if(A==="boolean"){if(typeof r==="boolean")return r;let m=String(r).toLowerCase();if(m==="true"||m==="1")return!0;if(m==="false"||m==="0")return!1;w("INVALID_PARAM_TYPE",`Parameter ${u} must be a boolean (true/false/1/0), got: ${r}`)}return r},X=async(r)=>{let A=r.address.scope||"project",u=O(r.address.path);if(!u.valid)w("INVALID_PATH_FORMAT",u.reason||"Invalid path format");let m=u.normalized;if(oP.isTemplateId(m))w("INVALID_PATH_FORMAT","Cannot create template with ID pattern as path");let S=await T(A);if(S.pathToId[m])w("TEMPLATE_ALREADY_EXISTS",`Template already exists at path: ${m}`);let I=z(r.content);if(!I.isValid)w("TEMPLATE_INVALID",I.validationError||"Invalid front matter");let D=await J(A),c=P(A),e=j(A),L=SN(m);if(L&&L!==".")await e.ensureDir(L);return await c.writeText(m,r.content),S.id[D]={path:m,isValid:!0,params:I.frontMatter.params},S.pathToId[m]=D,await Y(A,S),{id:D,path:m}},l=async(r)=>{let A=await h(r),m=await P(A.scope).readText(A.path),S=z(m);return{address:r,content:m,frontMatter:S.frontMatter,bodyContent:S.bodyContent,path:A.path,id:A.id,isValid:S.isValid}},N=async(r,A)=>{let u=Array.from(new Map(r.map((m)=>[JSON.stringify(m),m])).values());return Promise.all(u.map((m)=>l(m)))},n=async(r,A)=>{let u=await h(r),m=P(u.scope),S=await m.readText(u.path),{content:I,applied:D}=H(S,A),c=z(I);await m.writeText(u.path,I);let e=await T(u.scope);if(e.id[u.id]){if(e.id[u.id].isValid=c.isValid,c.isValid&&c.frontMatter)e.id[u.id].params=c.frontMatter.params;await Y(u.scope,e)}return{applied:D}},R=async(r)=>{try{let A=await h(r),u=P(A.scope);try{await u.deleteFile(A.path)}catch(S){if(S.code==="NOT_FOUND"){let I=await T(A.scope);return delete I.id[A.id],delete I.pathToId[A.path],await Y(A.scope,I),{deleted:!1}}throw S}let m=await T(A.scope);return delete m.id[A.id],delete m.pathToId[A.path],await Y(A.scope,m),{deleted:!0}}catch(A){if(A.code==="TEMPLATE_NOT_FOUND")return{deleted:!1};throw A}};return Object.freeze({create:X,read:l,readMany:N,edit:n,delete:R,deleteMany:async(r)=>{let A=Array.from(new Map(r.map((m)=>[JSON.stringify(m),m])).values()),u=[];for(let m of A)u.push(await R(m));return u},list:async(r)=>{let{scope:A,pathPrefix:u,includeContent:m}=r||{};if(A){let S=await T(A),I=[];for(let[D,c]of Object.entries(S.id)){if(u&&!c.path.startsWith(u))continue;let e;if(m)try{let Q=await P(A).readText(c.path);e=z(Q).frontMatter?.synopsis}catch{}I.push({scope:A,id:D,path:c.path,synopsis:e,isValid:c.isValid})}return I.sort((D,c)=>D.path.localeCompare(c.path))}else{let S=await T("project"),I=await T("shared"),D=[],c=new Map;for(let e of Object.values(S.id)){if(!c.has(e.path))c.set(e.path,new Set);c.get(e.path).add("project")}for(let e of Object.values(I.id)){if(!c.has(e.path))c.set(e.path,new Set);c.get(e.path).add("shared")}for(let[e,L]of Object.entries(S.id)){if(u&&!L.path.startsWith(u))continue;let Q;if(m)try{let _q=await q.readText(L.path);Q=z(_q).frontMatter?.synopsis}catch{}let Hq=c.get(L.path),Pq=Hq&&Hq.size>1?"overrides":void 0;D.push({scope:"project",id:e,path:L.path,synopsis:Q,isValid:L.isValid,override:Pq})}for(let[e,L]of Object.entries(I.id)){if(u&&!L.path.startsWith(u))continue;let Q;if(m)try{let _q=await K.readText(L.path);Q=z(_q).frontMatter?.synopsis}catch{}let Hq=c.get(L.path),Pq=Hq&&Hq.size>1?"overridden":void 0;D.push({scope:"shared",id:e,path:L.path,synopsis:Q,isValid:L.isValid,override:Pq})}return D.sort((e,L)=>e.path.localeCompare(L.path))}},move:async(r,A,u)=>{let m=await h(r),S=u||m.scope,I=O(A);if(!I.valid)w("INVALID_PATH_FORMAT",I.reason||"Invalid destination path");let D=I.normalized;if(m.scope===S&&m.path===D)w("TEMPLATE_ALREADY_EXISTS","Source and destination are identical");if((await T(S)).pathToId[D])w("TEMPLATE_ALREADY_EXISTS",`Destination already exists: ${D}`);let L=await P(m.scope).readText(m.path),Q=await X({address:{kind:"path",scope:S,path:D},content:L});return await R(r),{oldId:m.id,newId:Q.id,oldPath:m.path,newPath:D,sourceScope:m.scope,destinationScope:S}},render:async(r,A)=>{let u=await h(r);if(!(await T(u.scope)).id[u.id].isValid)w("TEMPLATE_INVALID",`Template has invalid front matter: ${u.id}`);let D=await P(u.scope).readText(u.path),c=z(D);if(!c.isValid||!c.frontMatter)w("TEMPLATE_INVALID",`Template has invalid front matter: ${u.id}`);let e=c.frontMatter.params,L={};for(let[Pq,_q]of Object.entries(e)){if(_q.required&&!(Pq in A))w("MISSING_REQUIRED_PARAM",`Missing required parameter: ${Pq} for template ${u.id}`);let kq;if(Pq in A)kq=k(A[Pq],_q.type,Pq);else if(_q.default!==void 0)kq=_q.default;else continue;L[Pq]=kq}let Q=YO.default.create();return Q.registerHelper("helperMissing",function(){throw new Error("Custom helpers are not supported")}),Q.compile(c.bodyContent,{strict:!0,noEscape:!1,preventIndent:!1})(L)},getParameters:async(r)=>{let A=await h(r),m=(await T(A.scope)).id[A.id];if(!m.isValid)w("TEMPLATE_INVALID",`Template has invalid front matter: ${A.id}`);return m.params}})};var WO=b_(()=>{ev();YO=IK(Qw(),1),TO=IK(wO(),1)});import{resolve as pK,dirname as CN}from"path";import{homedir as pN}from"os";import{existsSync as lN}from"fs";var nN=(_=process.cwd())=>{let q=pK(_),f=pK("/"),K=pK(pN(),".swic");while(q!==f){let $=pK(q,".swic");if($===K)throw new Error("Not in a project directory (found ~/.swic instead). Run swic from within a project.");if(lN($))return $;q=CN(q)}throw new Error("Could not find .swic directory. Are you in a SWIC project?")},HO;var hO=b_(()=>{HO=Object.freeze({findProjectRoot:nN})});var XO={};_7(XO,{default:()=>IN});import{mkdirSync as JO}from"fs";import{resolve as kO}from"path";import{homedir as RN}from"os";var lK="docs",nK="templates",EN=".index.json",ZO=(_,q)=>{try{JO(_,{recursive:!0}),JO(q,{recursive:!0})}catch(f){let K=f instanceof Error?f.message:String(f);throw new Error(`Failed to create swic directories. Please check permissions.
169
+ `).trim(),D;try{D=TO.default.parse(m)}catch(Q){return{bodyContent:r,isValid:!1,validationError:`YAML parse error: ${Q.message}`}}if(!D.type)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"Missing required field: type"};let c=["prompt","doc","story-spec","story-tech-doc","subtask","review","feedback","feedback-review","retro"];if(!c.includes(D.type))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Invalid type: ${D.type}. Must be one of: ${c.join(", ")}`};if(!D.params)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"Missing required field: params"};if(typeof D.params!=="object"||Array.isArray(D.params))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:"params must be an object"};let e=["string","number","boolean"],L={};for(let[Q,Hq]of Object.entries(D.params)){if(typeof Hq!=="object"||Array.isArray(Hq))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} definition must be an object`};let Pq=Hq;if(!Pq.type)return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} missing type field`};if(!e.includes(Pq.type))return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} has invalid type: ${Pq.type}. Must be one of: ${e.join(", ")}`};if(Pq.required!==void 0&&typeof Pq.required!=="boolean")return{rawFrontMatter:S,bodyContent:I,isValid:!1,validationError:`Parameter ${Q} required field must be boolean`};L[Q]={type:Pq.type,required:Pq.required??!1,description:Pq.description,default:Pq.default}}return{rawFrontMatter:S,frontMatter:{type:D.type,params:L,synopsis:D.synopsis,...D},bodyContent:I,isValid:!0}},H=(r,A)=>{let u=r,m=0;for(let S of A){let I=u;switch(S.op){case"replaceOnce":u=u.replace(S.oldText,S.newText);break;case"replaceAll":{let D=S.oldText.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");u=u.replace(new RegExp(D,"g"),S.newText);break}case"replaceRegex":{let D=new RegExp(S.pattern,S.flags||"");u=u.replace(D,S.replacement);break}case"replaceAllContent":u=S.content;break}if(u!==I||S.op==="replaceAllContent")m++}return{content:u,applied:m}},h=async(r)=>{if(r.kind==="id"){let A=r.scope;if(!A){let S=iP(r.id);if(!S)w("INVALID_ID_FORMAT",`Invalid template ID format: ${r.id}`);A=S}if(!oP.validateIdForScope(r.id,A))w("INVALID_ID_FORMAT",`Invalid template ID format for ${A} scope: ${r.id}`);let m=(await T(A)).id[r.id];if(!m)w("TEMPLATE_NOT_FOUND",`Template not found: ${r.id}`);return{scope:A,path:m.path,id:r.id}}else{let A=O(r.path);if(!A.valid)w("INVALID_PATH_FORMAT",A.reason||"Invalid path format");let u=A.normalized;if(r.scope){let S=(await T(r.scope)).pathToId[u];if(!S)w("TEMPLATE_NOT_FOUND",`Template not found: ${u} in ${r.scope} scope`);return{scope:r.scope,path:u,id:S}}else{let S=(await T("project")).pathToId[u];if(S)return{scope:"project",path:u,id:S};let D=(await T("shared")).pathToId[u];if(D)return{scope:"shared",path:u,id:D};w("TEMPLATE_NOT_FOUND",`Template not found: ${u}`)}}},J=async(r)=>{let A=await T(r),u=r==="project"?"tpl":"stpl",m=new RegExp(`^${u}(\\d{3,})$`),S=0;for(let D of Object.keys(A.id)){let c=D.match(m);if(c){let e=parseInt(c[1],10);if(e>S)S=e}}let I=S+1;return`${u}${I.toString().padStart(3,"0")}`},k=(r,A,u)=>{if(A==="string")return String(r);if(A==="number"){if(typeof r==="number")return r;let m=parseFloat(String(r));if(isNaN(m))w("INVALID_PARAM_TYPE",`Parameter ${u} must be a valid number, got: ${r}`);return m}if(A==="boolean"){if(typeof r==="boolean")return r;let m=String(r).toLowerCase();if(m==="true"||m==="1")return!0;if(m==="false"||m==="0")return!1;w("INVALID_PARAM_TYPE",`Parameter ${u} must be a boolean (true/false/1/0), got: ${r}`)}return r},X=async(r)=>{let A=r.address.scope||"project",u=O(r.address.path);if(!u.valid)w("INVALID_PATH_FORMAT",u.reason||"Invalid path format");let m=u.normalized;if(oP.isTemplateId(m))w("INVALID_PATH_FORMAT","Cannot create template with ID pattern as path");let S=await T(A);if(S.pathToId[m])w("TEMPLATE_ALREADY_EXISTS",`Template already exists at path: ${m}`);let I=z(r.content);if(!I.isValid)w("TEMPLATE_INVALID",I.validationError||"Invalid front matter");let D=await J(A),c=P(A),e=j(A),L=SN(m);if(L&&L!==".")await e.ensureDir(L);return await c.writeText(m,r.content),S.id[D]={path:m,isValid:!0,params:I.frontMatter.params},S.pathToId[m]=D,await Y(A,S),{id:D,path:m}},l=async(r)=>{let A=await h(r),m=await P(A.scope).readText(A.path),S=z(m);return{address:r,content:m,frontMatter:S.frontMatter,bodyContent:S.bodyContent,path:A.path,id:A.id,isValid:S.isValid}},N=async(r,A)=>{let u=Array.from(new Map(r.map((m)=>[JSON.stringify(m),m])).values());return Promise.all(u.map((m)=>l(m)))},n=async(r,A)=>{let u=await h(r),m=P(u.scope),S=await m.readText(u.path),{content:I,applied:D}=H(S,A),c=z(I);await m.writeText(u.path,I);let e=await T(u.scope);if(e.id[u.id]){if(e.id[u.id].isValid=c.isValid,c.isValid&&c.frontMatter)e.id[u.id].params=c.frontMatter.params;await Y(u.scope,e)}return{applied:D}},R=async(r)=>{try{let A=await h(r),u=P(A.scope);try{await u.delete(A.path)}catch(S){if(S.code==="NOT_FOUND"){let I=await T(A.scope);return delete I.id[A.id],delete I.pathToId[A.path],await Y(A.scope,I),{deleted:!1}}throw S}let m=await T(A.scope);return delete m.id[A.id],delete m.pathToId[A.path],await Y(A.scope,m),{deleted:!0}}catch(A){if(A.code==="TEMPLATE_NOT_FOUND")return{deleted:!1};throw A}};return Object.freeze({create:X,read:l,readMany:N,edit:n,delete:R,deleteMany:async(r)=>{let A=Array.from(new Map(r.map((m)=>[JSON.stringify(m),m])).values()),u=[];for(let m of A)u.push(await R(m));return u},list:async(r)=>{let{scope:A,pathPrefix:u,includeContent:m}=r||{};if(A){let S=await T(A),I=[];for(let[D,c]of Object.entries(S.id)){if(u&&!c.path.startsWith(u))continue;let e;if(m)try{let Q=await P(A).readText(c.path);e=z(Q).frontMatter?.synopsis}catch{}I.push({scope:A,id:D,path:c.path,synopsis:e,isValid:c.isValid})}return I.sort((D,c)=>D.path.localeCompare(c.path))}else{let S=await T("project"),I=await T("shared"),D=[],c=new Map;for(let e of Object.values(S.id)){if(!c.has(e.path))c.set(e.path,new Set);c.get(e.path).add("project")}for(let e of Object.values(I.id)){if(!c.has(e.path))c.set(e.path,new Set);c.get(e.path).add("shared")}for(let[e,L]of Object.entries(S.id)){if(u&&!L.path.startsWith(u))continue;let Q;if(m)try{let _q=await q.readText(L.path);Q=z(_q).frontMatter?.synopsis}catch{}let Hq=c.get(L.path),Pq=Hq&&Hq.size>1?"overrides":void 0;D.push({scope:"project",id:e,path:L.path,synopsis:Q,isValid:L.isValid,override:Pq})}for(let[e,L]of Object.entries(I.id)){if(u&&!L.path.startsWith(u))continue;let Q;if(m)try{let _q=await K.readText(L.path);Q=z(_q).frontMatter?.synopsis}catch{}let Hq=c.get(L.path),Pq=Hq&&Hq.size>1?"overridden":void 0;D.push({scope:"shared",id:e,path:L.path,synopsis:Q,isValid:L.isValid,override:Pq})}return D.sort((e,L)=>e.path.localeCompare(L.path))}},move:async(r,A,u)=>{let m=await h(r),S=u||m.scope,I=O(A);if(!I.valid)w("INVALID_PATH_FORMAT",I.reason||"Invalid destination path");let D=I.normalized;if(m.scope===S&&m.path===D)w("TEMPLATE_ALREADY_EXISTS","Source and destination are identical");if((await T(S)).pathToId[D])w("TEMPLATE_ALREADY_EXISTS",`Destination already exists: ${D}`);let L=await P(m.scope).readText(m.path),Q=await X({address:{kind:"path",scope:S,path:D},content:L});return await R(r),{oldId:m.id,newId:Q.id,oldPath:m.path,newPath:D,sourceScope:m.scope,destinationScope:S}},render:async(r,A)=>{let u=await h(r);if(!(await T(u.scope)).id[u.id].isValid)w("TEMPLATE_INVALID",`Template has invalid front matter: ${u.id}`);let D=await P(u.scope).readText(u.path),c=z(D);if(!c.isValid||!c.frontMatter)w("TEMPLATE_INVALID",`Template has invalid front matter: ${u.id}`);let e=c.frontMatter.params,L={};for(let[Pq,_q]of Object.entries(e)){if(_q.required&&!(Pq in A))w("MISSING_REQUIRED_PARAM",`Missing required parameter: ${Pq} for template ${u.id}`);let kq;if(Pq in A)kq=k(A[Pq],_q.type,Pq);else if(_q.default!==void 0)kq=_q.default;else continue;L[Pq]=kq}let Q=YO.default.create();return Q.registerHelper("helperMissing",function(){throw new Error("Custom helpers are not supported")}),Q.compile(c.bodyContent,{strict:!0,noEscape:!1,preventIndent:!1})(L)},getParameters:async(r)=>{let A=await h(r),m=(await T(A.scope)).id[A.id];if(!m.isValid)w("TEMPLATE_INVALID",`Template has invalid front matter: ${A.id}`);return m.params}})};var WO=b_(()=>{ev();YO=IK(Qw(),1),TO=IK(wO(),1)});import{resolve as pK,dirname as CN}from"path";import{homedir as pN}from"os";import{existsSync as lN}from"fs";var nN=(_=process.cwd())=>{let q=pK(_),f=pK("/"),K=pK(pN(),".swic");while(q!==f){let $=pK(q,".swic");if($===K)throw new Error("Not in a project directory (found ~/.swic instead). Run swic from within a project.");if(lN($))return $;q=CN(q)}throw new Error("Could not find .swic directory. Are you in a SWIC project?")},HO;var hO=b_(()=>{HO=Object.freeze({findProjectRoot:nN})});var XO={};_7(XO,{default:()=>IN});import{mkdirSync as JO}from"fs";import{resolve as kO}from"path";import{homedir as RN}from"os";var lK="docs",nK="templates",EN=".index.json",ZO=(_,q)=>{try{JO(_,{recursive:!0}),JO(q,{recursive:!0})}catch(f){let K=f instanceof Error?f.message:String(f);throw new Error(`Failed to create swic directories. Please check permissions.
170
170
  Project: ${_}
171
171
  Shared: ${q}
172
172
  Error: ${K}`)}},gN=()=>{let _;try{_=HO.findProjectRoot()}catch{_=kO(process.cwd(),".swic")}let q=kO(RN(),".swic"),f=`${_}/${lK}`,K=`${q}/${lK}`,$=`${_}/${nK}`,P=`${q}/${nK}`;return ZO(f,K),ZO($,P),{projectDataDir:_,sharedDataDir:q}},dN=(_)=>{let{projectBoundaryDir:q,sharedBoundaryDir:f}=_,K=`${q}/${lK}`,$=`${f}/${lK}`,P=`${q}/${nK}`,j=`${f}/${nK}`,v=Uf.create({boundaryDir:K}),w=Uf.create({boundaryDir:$}),O=Ff.create({boundaryDir:K}),T=Ff.create({boundaryDir:$}),Y=Uf.create({boundaryDir:P}),z=Uf.create({boundaryDir:j}),H=Ff.create({boundaryDir:P}),h=Ff.create({boundaryDir:j}),J=cv.create({fileServiceByScope:{project:v,shared:w},folderServiceByScope:{project:O,shared:T},indexFilename:EN}),k=zO({projectFileService:Y,projectFolderService:H,sharedFileService:z,sharedFolderService:h});return Object.freeze({DocService:J,TemplateService:k})},aN,IN;var AO=b_(()=>{av();iv();Lv();WO();hO();aN=Object.freeze({createServices:dN,lazilyGetDataDirs:gN}),IN=aN});var W={};_7(W,{void:()=>NY,util:()=>Kq,unknown:()=>MY,union:()=>nY,undefined:()=>rY,tuple:()=>gY,transformer:()=>tY,symbol:()=>mY,string:()=>Y7,strictObject:()=>lY,setErrorMap:()=>xO,set:()=>IY,record:()=>dY,quotelessJson:()=>tO,promise:()=>LY,preprocess:()=>sY,pipeline:()=>BY,ostring:()=>UY,optional:()=>eY,onumber:()=>FY,oboolean:()=>QY,objectUtil:()=>DK,object:()=>pY,number:()=>T7,nullable:()=>xY,null:()=>bY,never:()=>SY,nativeEnum:()=>cY,nan:()=>AY,map:()=>aY,makeIssue:()=>gf,literal:()=>iY,lazy:()=>yY,late:()=>ZY,isValid:()=>B_,isDirty:()=>a6,isAsync:()=>e8,isAborted:()=>d6,intersection:()=>EY,instanceof:()=>XY,getParsedType:()=>V_,getErrorMap:()=>t8,function:()=>DY,enum:()=>oY,effect:()=>tY,discriminatedUnion:()=>RY,defaultErrorMap:()=>I_,datetimeRegex:()=>v7,date:()=>GY,custom:()=>O7,coerce:()=>qT,boolean:()=>z7,bigint:()=>uY,array:()=>CY,any:()=>VY,addIssueToContext:()=>t,ZodVoid:()=>af,ZodUnknown:()=>U_,ZodUnion:()=>Q8,ZodUndefined:()=>U8,ZodType:()=>$q,ZodTuple:()=>S_,ZodTransformer:()=>h_,ZodSymbol:()=>df,ZodString:()=>T_,ZodSet:()=>m8,ZodSchema:()=>$q,ZodRecord:()=>If,ZodReadonly:()=>jf,ZodPromise:()=>r8,ZodPipeline:()=>of,ZodParsedType:()=>o,ZodOptional:()=>W_,ZodObject:()=>bq,ZodNumber:()=>F_,ZodNullable:()=>y_,ZodNull:()=>F8,ZodNever:()=>M_,ZodNativeEnum:()=>$f,ZodNaN:()=>yf,ZodMap:()=>Df,ZodLiteral:()=>ff,ZodLazy:()=>_f,ZodIssueCode:()=>y,ZodIntersection:()=>qf,ZodFunction:()=>s8,ZodFirstPartyTypeKind:()=>i,ZodError:()=>eq,ZodEnum:()=>q8,ZodEffects:()=>h_,ZodDiscriminatedUnion:()=>I6,ZodDefault:()=>Kf,ZodDate:()=>u8,ZodCatch:()=>Pf,ZodBranded:()=>D6,ZodBoolean:()=>B8,ZodBigInt:()=>Q_,ZodArray:()=>z_,ZodAny:()=>G8,Schema:()=>$q,ParseStatus:()=>aq,OK:()=>yq,NEVER:()=>_T,INVALID:()=>U,EMPTY_PATH:()=>sO,DIRTY:()=>A8,BRAND:()=>kY});var Kq;(function(_){_.assertEqual=($)=>{};function q($){}_.assertIs=q;function f($){throw new Error}_.assertNever=f,_.arrayToEnum=($)=>{let P={};for(let j of $)P[j]=j;return P},_.getValidEnumValues=($)=>{let P=_.objectKeys($).filter((v)=>typeof $[$[v]]!=="number"),j={};for(let v of P)j[v]=$[v];return _.objectValues(j)},_.objectValues=($)=>{return _.objectKeys($).map(function(P){return $[P]})},_.objectKeys=typeof Object.keys==="function"?($)=>Object.keys($):($)=>{let P=[];for(let j in $)if(Object.prototype.hasOwnProperty.call($,j))P.push(j);return P},_.find=($,P)=>{for(let j of $)if(P(j))return j;return},_.isInteger=typeof Number.isInteger==="function"?($)=>Number.isInteger($):($)=>typeof $==="number"&&Number.isFinite($)&&Math.floor($)===$;function K($,P=" | "){return $.map((j)=>typeof j==="string"?`'${j}'`:j).join(P)}_.joinValues=K,_.jsonStringifyReplacer=($,P)=>{if(typeof P==="bigint")return P.toString();return P}})(Kq||(Kq={}));var DK;(function(_){_.mergeShapes=(q,f)=>{return{...q,...f}}})(DK||(DK={}));var o=Kq.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V_=(_)=>{switch(typeof _){case"undefined":return o.undefined;case"string":return o.string;case"number":return Number.isNaN(_)?o.nan:o.number;case"boolean":return o.boolean;case"function":return o.function;case"bigint":return o.bigint;case"symbol":return o.symbol;case"object":if(Array.isArray(_))return o.array;if(_===null)return o.null;if(_.then&&typeof _.then==="function"&&_.catch&&typeof _.catch==="function")return o.promise;if(typeof Map!=="undefined"&&_ instanceof Map)return o.map;if(typeof Set!=="undefined"&&_ instanceof Set)return o.set;if(typeof Date!=="undefined"&&_ instanceof Date)return o.date;return o.object;default:return o.unknown}};var y=Kq.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"]),tO=(_)=>{return JSON.stringify(_,null,2).replace(/"([^"]+)":/g,"$1:")};class eq extends Error{get errors(){return this.issues}constructor(_){super();this.issues=[],this.addIssue=(f)=>{this.issues=[...this.issues,f]},this.addIssues=(f=[])=>{this.issues=[...this.issues,...f]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=_}format(_){let q=_||function($){return $.message},f={_errors:[]},K=($)=>{for(let P of $.issues)if(P.code==="invalid_union")P.unionErrors.map(K);else if(P.code==="invalid_return_type")K(P.returnTypeError);else if(P.code==="invalid_arguments")K(P.argumentsError);else if(P.path.length===0)f._errors.push(q(P));else{let j=f,v=0;while(v<P.path.length){let w=P.path[v];if(v!==P.path.length-1)j[w]=j[w]||{_errors:[]};else j[w]=j[w]||{_errors:[]},j[w]._errors.push(q(P));j=j[w],v++}}};return K(this),f}static assert(_){if(!(_ instanceof eq))throw new Error(`Not a ZodError: ${_}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kq.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(_=(q)=>q.message){let q={},f=[];for(let K of this.issues)if(K.path.length>0){let $=K.path[0];q[$]=q[$]||[],q[$].push(_(K))}else f.push(_(K));return{formErrors:f,fieldErrors:q}}get formErrors(){return this.flatten()}}eq.create=(_)=>{return new eq(_)};var eO=(_,q)=>{let f;switch(_.code){case y.invalid_type:if(_.received===o.undefined)f="Required";else f=`Expected ${_.expected}, received ${_.received}`;break;case y.invalid_literal:f=`Invalid literal value, expected ${JSON.stringify(_.expected,Kq.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:f=`Unrecognized key(s) in object: ${Kq.joinValues(_.keys,", ")}`;break;case y.invalid_union:f="Invalid input";break;case y.invalid_union_discriminator:f=`Invalid discriminator value. Expected ${Kq.joinValues(_.options)}`;break;case y.invalid_enum_value:f=`Invalid enum value. Expected ${Kq.joinValues(_.options)}, received '${_.received}'`;break;case y.invalid_arguments:f="Invalid function arguments";break;case y.invalid_return_type:f="Invalid function return type";break;case y.invalid_date:f="Invalid date";break;case y.invalid_string:if(typeof _.validation==="object")if("includes"in _.validation){if(f=`Invalid input: must include "${_.validation.includes}"`,typeof _.validation.position==="number")f=`${f} at one or more positions greater than or equal to ${_.validation.position}`}else if("startsWith"in _.validation)f=`Invalid input: must start with "${_.validation.startsWith}"`;else if("endsWith"in _.validation)f=`Invalid input: must end with "${_.validation.endsWith}"`;else Kq.assertNever(_.validation);else if(_.validation!=="regex")f=`Invalid ${_.validation}`;else f="Invalid";break;case y.too_small:if(_.type==="array")f=`Array must contain ${_.exact?"exactly":_.inclusive?"at least":"more than"} ${_.minimum} element(s)`;else if(_.type==="string")f=`String must contain ${_.exact?"exactly":_.inclusive?"at least":"over"} ${_.minimum} character(s)`;else if(_.type==="number")f=`Number must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${_.minimum}`;else if(_.type==="bigint")f=`Number must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${_.minimum}`;else if(_.type==="date")f=`Date must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(_.minimum))}`;else f="Invalid input";break;case y.too_big:if(_.type==="array")f=`Array must contain ${_.exact?"exactly":_.inclusive?"at most":"less than"} ${_.maximum} element(s)`;else if(_.type==="string")f=`String must contain ${_.exact?"exactly":_.inclusive?"at most":"under"} ${_.maximum} character(s)`;else if(_.type==="number")f=`Number must be ${_.exact?"exactly":_.inclusive?"less than or equal to":"less than"} ${_.maximum}`;else if(_.type==="bigint")f=`BigInt must be ${_.exact?"exactly":_.inclusive?"less than or equal to":"less than"} ${_.maximum}`;else if(_.type==="date")f=`Date must be ${_.exact?"exactly":_.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(_.maximum))}`;else f="Invalid input";break;case y.custom:f="Invalid input";break;case y.invalid_intersection_types:f="Intersection results could not be merged";break;case y.not_multiple_of:f=`Number must be a multiple of ${_.multipleOf}`;break;case y.not_finite:f="Number must be finite";break;default:f=q.defaultError,Kq.assertNever(_)}return{message:f}},I_=eO;var f7=I_;function xO(_){f7=_}function t8(){return f7}var gf=(_)=>{let{data:q,path:f,errorMaps:K,issueData:$}=_,P=[...f,...$.path||[]],j={...$,path:P};if($.message!==void 0)return{...$,path:P,message:$.message};let v="",w=K.filter((O)=>!!O).slice().reverse();for(let O of w)v=O(j,{data:q,defaultError:v}).message;return{...$,path:P,message:v}},sO=[];function t(_,q){let f=t8(),K=gf({issueData:q,data:_.data,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,f,f===I_?void 0:I_].filter(($)=>!!$)});_.common.issues.push(K)}class aq{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(_,q){let f=[];for(let K of q){if(K.status==="aborted")return U;if(K.status==="dirty")_.dirty();f.push(K.value)}return{status:_.value,value:f}}static async mergeObjectAsync(_,q){let f=[];for(let K of q){let $=await K.key,P=await K.value;f.push({key:$,value:P})}return aq.mergeObjectSync(_,f)}static mergeObjectSync(_,q){let f={};for(let K of q){let{key:$,value:P}=K;if($.status==="aborted")return U;if(P.status==="aborted")return U;if($.status==="dirty")_.dirty();if(P.status==="dirty")_.dirty();if($.value!=="__proto__"&&(typeof P.value!=="undefined"||K.alwaysSet))f[$.value]=P.value}return{status:_.value,value:f}}}var U=Object.freeze({status:"aborted"}),A8=(_)=>({status:"dirty",value:_}),yq=(_)=>({status:"valid",value:_}),d6=(_)=>_.status==="aborted",a6=(_)=>_.status==="dirty",B_=(_)=>_.status==="valid",e8=(_)=>typeof Promise!=="undefined"&&_ instanceof Promise;var B;(function(_){_.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},_.toString=(q)=>typeof q==="string"?q:q?.message})(B||(B={}));class H_{constructor(_,q,f,K){this._cachedPath=[],this.parent=_,this.data=q,this._path=f,this._key=K}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var $7=(_,q)=>{if(B_(q))return{success:!0,data:q.value};else{if(!_.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let f=new eq(_.common.issues);return this._error=f,this._error}}}};function qq(_){if(!_)return{};let{errorMap:q,invalid_type_error:f,required_error:K,description:$}=_;if(q&&(f||K))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:$};return{errorMap:(j,v)=>{let{message:w}=_;if(j.code==="invalid_enum_value")return{message:w??v.defaultError};if(typeof v.data==="undefined")return{message:w??K??v.defaultError};if(j.code!=="invalid_type")return{message:v.defaultError};return{message:w??f??v.defaultError}},description:$}}class $q{get description(){return this._def.description}_getType(_){return V_(_.data)}_getOrReturnCtx(_,q){return q||{common:_.parent.common,data:_.data,parsedType:V_(_.data),schemaErrorMap:this._def.errorMap,path:_.path,parent:_.parent}}_processInputParams(_){return{status:new aq,ctx:{common:_.parent.common,data:_.data,parsedType:V_(_.data),schemaErrorMap:this._def.errorMap,path:_.path,parent:_.parent}}}_parseSync(_){let q=this._parse(_);if(e8(q))throw new Error("Synchronous parse encountered promise.");return q}_parseAsync(_){let q=this._parse(_);return Promise.resolve(q)}parse(_,q){let f=this.safeParse(_,q);if(f.success)return f.data;throw f.error}safeParse(_,q){let f={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:V_(_)},K=this._parseSync({data:_,path:f.path,parent:f});return $7(f,K)}"~validate"(_){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:V_(_)};if(!this["~standard"].async)try{let f=this._parseSync({data:_,path:[],parent:q});return B_(f)?{value:f.value}:{issues:q.common.issues}}catch(f){if(f?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:_,path:[],parent:q}).then((f)=>B_(f)?{value:f.value}:{issues:q.common.issues})}async parseAsync(_,q){let f=await this.safeParseAsync(_,q);if(f.success)return f.data;throw f.error}async safeParseAsync(_,q){let f={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:V_(_)},K=this._parse({data:_,path:f.path,parent:f}),$=await(e8(K)?K:Promise.resolve(K));return $7(f,$)}refine(_,q){let f=(K)=>{if(typeof q==="string"||typeof q==="undefined")return{message:q};else if(typeof q==="function")return q(K);else return q};return this._refinement((K,$)=>{let P=_(K),j=()=>$.addIssue({code:y.custom,...f(K)});if(typeof Promise!=="undefined"&&P instanceof Promise)return P.then((v)=>{if(!v)return j(),!1;else return!0});if(!P)return j(),!1;else return!0})}refinement(_,q){return this._refinement((f,K)=>{if(!_(f))return K.addIssue(typeof q==="function"?q(f,K):q),!1;else return!0})}_refinement(_){return new h_({schema:this,typeName:i.ZodEffects,effect:{type:"refinement",refinement:_}})}superRefine(_){return this._refinement(_)}constructor(_){this.spa=this.safeParseAsync,this._def=_,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:(q)=>this["~validate"](q)}}optional(){return W_.create(this,this._def)}nullable(){return y_.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z_.create(this)}promise(){return r8.create(this,this._def)}or(_){return Q8.create([this,_],this._def)}and(_){return qf.create(this,_,this._def)}transform(_){return new h_({...qq(this._def),schema:this,typeName:i.ZodEffects,effect:{type:"transform",transform:_}})}default(_){let q=typeof _==="function"?_:()=>_;return new Kf({...qq(this._def),innerType:this,defaultValue:q,typeName:i.ZodDefault})}brand(){return new D6({typeName:i.ZodBranded,type:this,...qq(this._def)})}catch(_){let q=typeof _==="function"?_:()=>_;return new Pf({...qq(this._def),innerType:this,catchValue:q,typeName:i.ZodCatch})}describe(_){return new this.constructor({...this._def,description:_})}pipe(_){return of.create(this,_)}readonly(){return jf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var BO=/^c[^\s-]{8,}$/i,UO=/^[0-9a-z]+$/,FO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,QO=/^[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,qY=/^[a-z0-9_-]{21}$/i,_Y=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fY=/^[-+]?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)?)??$/,$Y=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,KY="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",yK,PY=/^(?:(?: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])$/,jY=/^(?:(?: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])$/,vY=/^(([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]))$/,wY=/^(([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])$/,OY=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YY=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,P7="((\\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])))",TY=new RegExp(`^${P7}$`);function j7(_){let q="[0-5]\\d";if(_.precision)q=`${q}\\.\\d{${_.precision}}`;else if(_.precision==null)q=`${q}(\\.\\d+)?`;let f=_.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${f}`}function zY(_){return new RegExp(`^${j7(_)}$`)}function v7(_){let q=`${P7}T${j7(_)}`,f=[];if(f.push(_.local?"Z?":"Z"),_.offset)f.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${f.join("|")})`,new RegExp(`^${q}$`)}function WY(_,q){if((q==="v4"||!q)&&PY.test(_))return!0;if((q==="v6"||!q)&&vY.test(_))return!0;return!1}function HY(_,q){if(!_Y.test(_))return!1;try{let[f]=_.split(".");if(!f)return!1;let K=f.replace(/-/g,"+").replace(/_/g,"/").padEnd(f.length+(4-f.length%4)%4,"="),$=JSON.parse(atob(K));if(typeof $!=="object"||$===null)return!1;if("typ"in $&&$?.typ!=="JWT")return!1;if(!$.alg)return!1;if(q&&$.alg!==q)return!1;return!0}catch{return!1}}function hY(_,q){if((q==="v4"||!q)&&jY.test(_))return!0;if((q==="v6"||!q)&&wY.test(_))return!0;return!1}class T_ extends $q{_parse(_){if(this._def.coerce)_.data=String(_.data);if(this._getType(_)!==o.string){let $=this._getOrReturnCtx(_);return t($,{code:y.invalid_type,expected:o.string,received:$.parsedType}),U}let f=new aq,K=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(_.data.length<$.value)K=this._getOrReturnCtx(_,K),t(K,{code:y.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),f.dirty()}else if($.kind==="max"){if(_.data.length>$.value)K=this._getOrReturnCtx(_,K),t(K,{code:y.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!1,message:$.message}),f.dirty()}else if($.kind==="length"){let P=_.data.length>$.value,j=_.data.length<$.value;if(P||j){if(K=this._getOrReturnCtx(_,K),P)t(K,{code:y.too_big,maximum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});else if(j)t(K,{code:y.too_small,minimum:$.value,type:"string",inclusive:!0,exact:!0,message:$.message});f.dirty()}}else if($.kind==="email"){if(!$Y.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"email",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="emoji"){if(!yK)yK=new RegExp(KY,"u");if(!yK.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"emoji",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="uuid"){if(!QO.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"uuid",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="nanoid"){if(!qY.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"nanoid",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="cuid"){if(!BO.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"cuid",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="cuid2"){if(!UO.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"cuid2",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="ulid"){if(!FO.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"ulid",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="url")try{new URL(_.data)}catch{K=this._getOrReturnCtx(_,K),t(K,{validation:"url",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="regex"){if($.regex.lastIndex=0,!$.regex.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"regex",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="trim")_.data=_.data.trim();else if($.kind==="includes"){if(!_.data.includes($.value,$.position))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:{includes:$.value,position:$.position},message:$.message}),f.dirty()}else if($.kind==="toLowerCase")_.data=_.data.toLowerCase();else if($.kind==="toUpperCase")_.data=_.data.toUpperCase();else if($.kind==="startsWith"){if(!_.data.startsWith($.value))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:{startsWith:$.value},message:$.message}),f.dirty()}else if($.kind==="endsWith"){if(!_.data.endsWith($.value))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:{endsWith:$.value},message:$.message}),f.dirty()}else if($.kind==="datetime"){if(!v7($).test(_.data))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:"datetime",message:$.message}),f.dirty()}else if($.kind==="date"){if(!TY.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:"date",message:$.message}),f.dirty()}else if($.kind==="time"){if(!zY($).test(_.data))K=this._getOrReturnCtx(_,K),t(K,{code:y.invalid_string,validation:"time",message:$.message}),f.dirty()}else if($.kind==="duration"){if(!fY.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"duration",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="ip"){if(!WY(_.data,$.version))K=this._getOrReturnCtx(_,K),t(K,{validation:"ip",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="jwt"){if(!HY(_.data,$.alg))K=this._getOrReturnCtx(_,K),t(K,{validation:"jwt",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="cidr"){if(!hY(_.data,$.version))K=this._getOrReturnCtx(_,K),t(K,{validation:"cidr",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="base64"){if(!OY.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"base64",code:y.invalid_string,message:$.message}),f.dirty()}else if($.kind==="base64url"){if(!YY.test(_.data))K=this._getOrReturnCtx(_,K),t(K,{validation:"base64url",code:y.invalid_string,message:$.message}),f.dirty()}else Kq.assertNever($);return{status:f.value,value:_.data}}_regex(_,q,f){return this.refinement((K)=>_.test(K),{validation:q,code:y.invalid_string,...B.errToObj(f)})}_addCheck(_){return new T_({...this._def,checks:[...this._def.checks,_]})}email(_){return this._addCheck({kind:"email",...B.errToObj(_)})}url(_){return this._addCheck({kind:"url",...B.errToObj(_)})}emoji(_){return this._addCheck({kind:"emoji",...B.errToObj(_)})}uuid(_){return this._addCheck({kind:"uuid",...B.errToObj(_)})}nanoid(_){return this._addCheck({kind:"nanoid",...B.errToObj(_)})}cuid(_){return this._addCheck({kind:"cuid",...B.errToObj(_)})}cuid2(_){return this._addCheck({kind:"cuid2",...B.errToObj(_)})}ulid(_){return this._addCheck({kind:"ulid",...B.errToObj(_)})}base64(_){return this._addCheck({kind:"base64",...B.errToObj(_)})}base64url(_){return this._addCheck({kind:"base64url",...B.errToObj(_)})}jwt(_){return this._addCheck({kind:"jwt",...B.errToObj(_)})}ip(_){return this._addCheck({kind:"ip",...B.errToObj(_)})}cidr(_){return this._addCheck({kind:"cidr",...B.errToObj(_)})}datetime(_){if(typeof _==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:_});return this._addCheck({kind:"datetime",precision:typeof _?.precision==="undefined"?null:_?.precision,offset:_?.offset??!1,local:_?.local??!1,...B.errToObj(_?.message)})}date(_){return this._addCheck({kind:"date",message:_})}time(_){if(typeof _==="string")return this._addCheck({kind:"time",precision:null,message:_});return this._addCheck({kind:"time",precision:typeof _?.precision==="undefined"?null:_?.precision,...B.errToObj(_?.message)})}duration(_){return this._addCheck({kind:"duration",...B.errToObj(_)})}regex(_,q){return this._addCheck({kind:"regex",regex:_,...B.errToObj(q)})}includes(_,q){return this._addCheck({kind:"includes",value:_,position:q?.position,...B.errToObj(q?.message)})}startsWith(_,q){return this._addCheck({kind:"startsWith",value:_,...B.errToObj(q)})}endsWith(_,q){return this._addCheck({kind:"endsWith",value:_,...B.errToObj(q)})}min(_,q){return this._addCheck({kind:"min",value:_,...B.errToObj(q)})}max(_,q){return this._addCheck({kind:"max",value:_,...B.errToObj(q)})}length(_,q){return this._addCheck({kind:"length",value:_,...B.errToObj(q)})}nonempty(_){return this.min(1,B.errToObj(_))}trim(){return new T_({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T_({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T_({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((_)=>_.kind==="datetime")}get isDate(){return!!this._def.checks.find((_)=>_.kind==="date")}get isTime(){return!!this._def.checks.find((_)=>_.kind==="time")}get isDuration(){return!!this._def.checks.find((_)=>_.kind==="duration")}get isEmail(){return!!this._def.checks.find((_)=>_.kind==="email")}get isURL(){return!!this._def.checks.find((_)=>_.kind==="url")}get isEmoji(){return!!this._def.checks.find((_)=>_.kind==="emoji")}get isUUID(){return!!this._def.checks.find((_)=>_.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((_)=>_.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((_)=>_.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((_)=>_.kind==="cuid2")}get isULID(){return!!this._def.checks.find((_)=>_.kind==="ulid")}get isIP(){return!!this._def.checks.find((_)=>_.kind==="ip")}get isCIDR(){return!!this._def.checks.find((_)=>_.kind==="cidr")}get isBase64(){return!!this._def.checks.find((_)=>_.kind==="base64")}get isBase64url(){return!!this._def.checks.find((_)=>_.kind==="base64url")}get minLength(){let _=null;for(let q of this._def.checks)if(q.kind==="min"){if(_===null||q.value>_)_=q.value}return _}get maxLength(){let _=null;for(let q of this._def.checks)if(q.kind==="max"){if(_===null||q.value<_)_=q.value}return _}}T_.create=(_)=>{return new T_({checks:[],typeName:i.ZodString,coerce:_?.coerce??!1,...qq(_)})};function JY(_,q){let f=(_.toString().split(".")[1]||"").length,K=(q.toString().split(".")[1]||"").length,$=f>K?f:K,P=Number.parseInt(_.toFixed($).replace(".","")),j=Number.parseInt(q.toFixed($).replace(".",""));return P%j/10**$}class F_ extends $q{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(_){if(this._def.coerce)_.data=Number(_.data);if(this._getType(_)!==o.number){let $=this._getOrReturnCtx(_);return t($,{code:y.invalid_type,expected:o.number,received:$.parsedType}),U}let f=void 0,K=new aq;for(let $ of this._def.checks)if($.kind==="int"){if(!Kq.isInteger(_.data))f=this._getOrReturnCtx(_,f),t(f,{code:y.invalid_type,expected:"integer",received:"float",message:$.message}),K.dirty()}else if($.kind==="min"){if($.inclusive?_.data<$.value:_.data<=$.value)f=this._getOrReturnCtx(_,f),t(f,{code:y.too_small,minimum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),K.dirty()}else if($.kind==="max"){if($.inclusive?_.data>$.value:_.data>=$.value)f=this._getOrReturnCtx(_,f),t(f,{code:y.too_big,maximum:$.value,type:"number",inclusive:$.inclusive,exact:!1,message:$.message}),K.dirty()}else if($.kind==="multipleOf"){if(JY(_.data,$.value)!==0)f=this._getOrReturnCtx(_,f),t(f,{code:y.not_multiple_of,multipleOf:$.value,message:$.message}),K.dirty()}else if($.kind==="finite"){if(!Number.isFinite(_.data))f=this._getOrReturnCtx(_,f),t(f,{code:y.not_finite,message:$.message}),K.dirty()}else Kq.assertNever($);return{status:K.value,value:_.data}}gte(_,q){return this.setLimit("min",_,!0,B.toString(q))}gt(_,q){return this.setLimit("min",_,!1,B.toString(q))}lte(_,q){return this.setLimit("max",_,!0,B.toString(q))}lt(_,q){return this.setLimit("max",_,!1,B.toString(q))}setLimit(_,q,f,K){return new F_({...this._def,checks:[...this._def.checks,{kind:_,value:q,inclusive:f,message:B.toString(K)}]})}_addCheck(_){return new F_({...this._def,checks:[...this._def.checks,_]})}int(_){return this._addCheck({kind:"int",message:B.toString(_)})}positive(_){return this._addCheck({kind:"min",value:0,inclusive:!1,message:B.toString(_)})}negative(_){return this._addCheck({kind:"max",value:0,inclusive:!1,message:B.toString(_)})}nonpositive(_){return this._addCheck({kind:"max",value:0,inclusive:!0,message:B.toString(_)})}nonnegative(_){return this._addCheck({kind:"min",value:0,inclusive:!0,message:B.toString(_)})}multipleOf(_,q){return this._addCheck({kind:"multipleOf",value:_,message:B.toString(q)})}finite(_){return this._addCheck({kind:"finite",message:B.toString(_)})}safe(_){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:B.toString(_)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:B.toString(_)})}get minValue(){let _=null;for(let q of this._def.checks)if(q.kind==="min"){if(_===null||q.value>_)_=q.value}return _}get maxValue(){let _=null;for(let q of this._def.checks)if(q.kind==="max"){if(_===null||q.value<_)_=q.value}return _}get isInt(){return!!this._def.checks.find((_)=>_.kind==="int"||_.kind==="multipleOf"&&Kq.isInteger(_.value))}get isFinite(){let _=null,q=null;for(let f of this._def.checks)if(f.kind==="finite"||f.kind==="int"||f.kind==="multipleOf")return!0;else if(f.kind==="min"){if(q===null||f.value>q)q=f.value}else if(f.kind==="max"){if(_===null||f.value<_)_=f.value}return Number.isFinite(q)&&Number.isFinite(_)}}F_.create=(_)=>{return new F_({checks:[],typeName:i.ZodNumber,coerce:_?.coerce||!1,...qq(_)})};class Q_ extends $q{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(_){if(this._def.coerce)try{_.data=BigInt(_.data)}catch{return this._getInvalidInput(_)}if(this._getType(_)!==o.bigint)return this._getInvalidInput(_);let f=void 0,K=new aq;for(let $ of this._def.checks)if($.kind==="min"){if($.inclusive?_.data<$.value:_.data<=$.value)f=this._getOrReturnCtx(_,f),t(f,{code:y.too_small,type:"bigint",minimum:$.value,inclusive:$.inclusive,message:$.message}),K.dirty()}else if($.kind==="max"){if($.inclusive?_.data>$.value:_.data>=$.value)f=this._getOrReturnCtx(_,f),t(f,{code:y.too_big,type:"bigint",maximum:$.value,inclusive:$.inclusive,message:$.message}),K.dirty()}else if($.kind==="multipleOf"){if(_.data%$.value!==BigInt(0))f=this._getOrReturnCtx(_,f),t(f,{code:y.not_multiple_of,multipleOf:$.value,message:$.message}),K.dirty()}else Kq.assertNever($);return{status:K.value,value:_.data}}_getInvalidInput(_){let q=this._getOrReturnCtx(_);return t(q,{code:y.invalid_type,expected:o.bigint,received:q.parsedType}),U}gte(_,q){return this.setLimit("min",_,!0,B.toString(q))}gt(_,q){return this.setLimit("min",_,!1,B.toString(q))}lte(_,q){return this.setLimit("max",_,!0,B.toString(q))}lt(_,q){return this.setLimit("max",_,!1,B.toString(q))}setLimit(_,q,f,K){return new Q_({...this._def,checks:[...this._def.checks,{kind:_,value:q,inclusive:f,message:B.toString(K)}]})}_addCheck(_){return new Q_({...this._def,checks:[...this._def.checks,_]})}positive(_){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:B.toString(_)})}negative(_){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:B.toString(_)})}nonpositive(_){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:B.toString(_)})}nonnegative(_){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:B.toString(_)})}multipleOf(_,q){return this._addCheck({kind:"multipleOf",value:_,message:B.toString(q)})}get minValue(){let _=null;for(let q of this._def.checks)if(q.kind==="min"){if(_===null||q.value>_)_=q.value}return _}get maxValue(){let _=null;for(let q of this._def.checks)if(q.kind==="max"){if(_===null||q.value<_)_=q.value}return _}}Q_.create=(_)=>{return new Q_({checks:[],typeName:i.ZodBigInt,coerce:_?.coerce??!1,...qq(_)})};class B8 extends $q{_parse(_){if(this._def.coerce)_.data=Boolean(_.data);if(this._getType(_)!==o.boolean){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.boolean,received:f.parsedType}),U}return yq(_.data)}}B8.create=(_)=>{return new B8({typeName:i.ZodBoolean,coerce:_?.coerce||!1,...qq(_)})};class u8 extends $q{_parse(_){if(this._def.coerce)_.data=new Date(_.data);if(this._getType(_)!==o.date){let $=this._getOrReturnCtx(_);return t($,{code:y.invalid_type,expected:o.date,received:$.parsedType}),U}if(Number.isNaN(_.data.getTime())){let $=this._getOrReturnCtx(_);return t($,{code:y.invalid_date}),U}let f=new aq,K=void 0;for(let $ of this._def.checks)if($.kind==="min"){if(_.data.getTime()<$.value)K=this._getOrReturnCtx(_,K),t(K,{code:y.too_small,message:$.message,inclusive:!0,exact:!1,minimum:$.value,type:"date"}),f.dirty()}else if($.kind==="max"){if(_.data.getTime()>$.value)K=this._getOrReturnCtx(_,K),t(K,{code:y.too_big,message:$.message,inclusive:!0,exact:!1,maximum:$.value,type:"date"}),f.dirty()}else Kq.assertNever($);return{status:f.value,value:new Date(_.data.getTime())}}_addCheck(_){return new u8({...this._def,checks:[...this._def.checks,_]})}min(_,q){return this._addCheck({kind:"min",value:_.getTime(),message:B.toString(q)})}max(_,q){return this._addCheck({kind:"max",value:_.getTime(),message:B.toString(q)})}get minDate(){let _=null;for(let q of this._def.checks)if(q.kind==="min"){if(_===null||q.value>_)_=q.value}return _!=null?new Date(_):null}get maxDate(){let _=null;for(let q of this._def.checks)if(q.kind==="max"){if(_===null||q.value<_)_=q.value}return _!=null?new Date(_):null}}u8.create=(_)=>{return new u8({checks:[],coerce:_?.coerce||!1,typeName:i.ZodDate,...qq(_)})};class df extends $q{_parse(_){if(this._getType(_)!==o.symbol){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.symbol,received:f.parsedType}),U}return yq(_.data)}}df.create=(_)=>{return new df({typeName:i.ZodSymbol,...qq(_)})};class U8 extends $q{_parse(_){if(this._getType(_)!==o.undefined){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.undefined,received:f.parsedType}),U}return yq(_.data)}}U8.create=(_)=>{return new U8({typeName:i.ZodUndefined,...qq(_)})};class F8 extends $q{_parse(_){if(this._getType(_)!==o.null){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.null,received:f.parsedType}),U}return yq(_.data)}}F8.create=(_)=>{return new F8({typeName:i.ZodNull,...qq(_)})};class G8 extends $q{constructor(){super(...arguments);this._any=!0}_parse(_){return yq(_.data)}}G8.create=(_)=>{return new G8({typeName:i.ZodAny,...qq(_)})};class U_ extends $q{constructor(){super(...arguments);this._unknown=!0}_parse(_){return yq(_.data)}}U_.create=(_)=>{return new U_({typeName:i.ZodUnknown,...qq(_)})};class M_ extends $q{_parse(_){let q=this._getOrReturnCtx(_);return t(q,{code:y.invalid_type,expected:o.never,received:q.parsedType}),U}}M_.create=(_)=>{return new M_({typeName:i.ZodNever,...qq(_)})};class af extends $q{_parse(_){if(this._getType(_)!==o.undefined){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.void,received:f.parsedType}),U}return yq(_.data)}}af.create=(_)=>{return new af({typeName:i.ZodVoid,...qq(_)})};class z_ extends $q{_parse(_){let{ctx:q,status:f}=this._processInputParams(_),K=this._def;if(q.parsedType!==o.array)return t(q,{code:y.invalid_type,expected:o.array,received:q.parsedType}),U;if(K.exactLength!==null){let P=q.data.length>K.exactLength.value,j=q.data.length<K.exactLength.value;if(P||j)t(q,{code:P?y.too_big:y.too_small,minimum:j?K.exactLength.value:void 0,maximum:P?K.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:K.exactLength.message}),f.dirty()}if(K.minLength!==null){if(q.data.length<K.minLength.value)t(q,{code:y.too_small,minimum:K.minLength.value,type:"array",inclusive:!0,exact:!1,message:K.minLength.message}),f.dirty()}if(K.maxLength!==null){if(q.data.length>K.maxLength.value)t(q,{code:y.too_big,maximum:K.maxLength.value,type:"array",inclusive:!0,exact:!1,message:K.maxLength.message}),f.dirty()}if(q.common.async)return Promise.all([...q.data].map((P,j)=>{return K.type._parseAsync(new H_(q,P,q.path,j))})).then((P)=>{return aq.mergeArray(f,P)});let $=[...q.data].map((P,j)=>{return K.type._parseSync(new H_(q,P,q.path,j))});return aq.mergeArray(f,$)}get element(){return this._def.type}min(_,q){return new z_({...this._def,minLength:{value:_,message:B.toString(q)}})}max(_,q){return new z_({...this._def,maxLength:{value:_,message:B.toString(q)}})}length(_,q){return new z_({...this._def,exactLength:{value:_,message:B.toString(q)}})}nonempty(_){return this.min(1,_)}}z_.create=(_,q)=>{return new z_({type:_,minLength:null,maxLength:null,exactLength:null,typeName:i.ZodArray,...qq(q)})};function x8(_){if(_ instanceof bq){let q={};for(let f in _.shape){let K=_.shape[f];q[f]=W_.create(x8(K))}return new bq({..._._def,shape:()=>q})}else if(_ instanceof z_)return new z_({..._._def,type:x8(_.element)});else if(_ instanceof W_)return W_.create(x8(_.unwrap()));else if(_ instanceof y_)return y_.create(x8(_.unwrap()));else if(_ instanceof S_)return S_.create(_.items.map((q)=>x8(q)));else return _}class bq extends $q{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let _=this._def.shape(),q=Kq.objectKeys(_);return this._cached={shape:_,keys:q},this._cached}_parse(_){if(this._getType(_)!==o.object){let w=this._getOrReturnCtx(_);return t(w,{code:y.invalid_type,expected:o.object,received:w.parsedType}),U}let{status:f,ctx:K}=this._processInputParams(_),{shape:$,keys:P}=this._getCached(),j=[];if(!(this._def.catchall instanceof M_&&this._def.unknownKeys==="strip")){for(let w in K.data)if(!P.includes(w))j.push(w)}let v=[];for(let w of P){let O=$[w],T=K.data[w];v.push({key:{status:"valid",value:w},value:O._parse(new H_(K,T,K.path,w)),alwaysSet:w in K.data})}if(this._def.catchall instanceof M_){let w=this._def.unknownKeys;if(w==="passthrough")for(let O of j)v.push({key:{status:"valid",value:O},value:{status:"valid",value:K.data[O]}});else if(w==="strict"){if(j.length>0)t(K,{code:y.unrecognized_keys,keys:j}),f.dirty()}else if(w==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let O of j){let T=K.data[O];v.push({key:{status:"valid",value:O},value:w._parse(new H_(K,T,K.path,O)),alwaysSet:O in K.data})}}if(K.common.async)return Promise.resolve().then(async()=>{let w=[];for(let O of v){let T=await O.key,Y=await O.value;w.push({key:T,value:Y,alwaysSet:O.alwaysSet})}return w}).then((w)=>{return aq.mergeObjectSync(f,w)});else return aq.mergeObjectSync(f,v)}get shape(){return this._def.shape()}strict(_){return B.errToObj,new bq({...this._def,unknownKeys:"strict",..._!==void 0?{errorMap:(q,f)=>{let K=this._def.errorMap?.(q,f).message??f.defaultError;if(q.code==="unrecognized_keys")return{message:B.errToObj(_).message??K};return{message:K}}}:{}})}strip(){return new bq({...this._def,unknownKeys:"strip"})}passthrough(){return new bq({...this._def,unknownKeys:"passthrough"})}extend(_){return new bq({...this._def,shape:()=>({...this._def.shape(),..._})})}merge(_){return new bq({unknownKeys:_._def.unknownKeys,catchall:_._def.catchall,shape:()=>({...this._def.shape(),..._._def.shape()}),typeName:i.ZodObject})}setKey(_,q){return this.augment({[_]:q})}catchall(_){return new bq({...this._def,catchall:_})}pick(_){let q={};for(let f of Kq.objectKeys(_))if(_[f]&&this.shape[f])q[f]=this.shape[f];return new bq({...this._def,shape:()=>q})}omit(_){let q={};for(let f of Kq.objectKeys(this.shape))if(!_[f])q[f]=this.shape[f];return new bq({...this._def,shape:()=>q})}deepPartial(){return x8(this)}partial(_){let q={};for(let f of Kq.objectKeys(this.shape)){let K=this.shape[f];if(_&&!_[f])q[f]=K;else q[f]=K.optional()}return new bq({...this._def,shape:()=>q})}required(_){let q={};for(let f of Kq.objectKeys(this.shape))if(_&&!_[f])q[f]=this.shape[f];else{let $=this.shape[f];while($ instanceof W_)$=$._def.innerType;q[f]=$}return new bq({...this._def,shape:()=>q})}keyof(){return w7(Kq.objectKeys(this.shape))}}bq.create=(_,q)=>{return new bq({shape:()=>_,unknownKeys:"strip",catchall:M_.create(),typeName:i.ZodObject,...qq(q)})};bq.strictCreate=(_,q)=>{return new bq({shape:()=>_,unknownKeys:"strict",catchall:M_.create(),typeName:i.ZodObject,...qq(q)})};bq.lazycreate=(_,q)=>{return new bq({shape:_,unknownKeys:"strip",catchall:M_.create(),typeName:i.ZodObject,...qq(q)})};class Q8 extends $q{_parse(_){let{ctx:q}=this._processInputParams(_),f=this._def.options;function K($){for(let j of $)if(j.result.status==="valid")return j.result;for(let j of $)if(j.result.status==="dirty")return q.common.issues.push(...j.ctx.common.issues),j.result;let P=$.map((j)=>new eq(j.ctx.common.issues));return t(q,{code:y.invalid_union,unionErrors:P}),U}if(q.common.async)return Promise.all(f.map(async($)=>{let P={...q,common:{...q.common,issues:[]},parent:null};return{result:await $._parseAsync({data:q.data,path:q.path,parent:P}),ctx:P}})).then(K);else{let $=void 0,P=[];for(let v of f){let w={...q,common:{...q.common,issues:[]},parent:null},O=v._parseSync({data:q.data,path:q.path,parent:w});if(O.status==="valid")return O;else if(O.status==="dirty"&&!$)$={result:O,ctx:w};if(w.common.issues.length)P.push(w.common.issues)}if($)return q.common.issues.push(...$.ctx.common.issues),$.result;let j=P.map((v)=>new eq(v));return t(q,{code:y.invalid_union,unionErrors:j}),U}}get options(){return this._def.options}}Q8.create=(_,q)=>{return new Q8({options:_,typeName:i.ZodUnion,...qq(q)})};var D_=(_)=>{if(_ instanceof _f)return D_(_.schema);else if(_ instanceof h_)return D_(_.innerType());else if(_ instanceof ff)return[_.value];else if(_ instanceof q8)return _.options;else if(_ instanceof $f)return Kq.objectValues(_.enum);else if(_ instanceof Kf)return D_(_._def.innerType);else if(_ instanceof U8)return[void 0];else if(_ instanceof F8)return[null];else if(_ instanceof W_)return[void 0,...D_(_.unwrap())];else if(_ instanceof y_)return[null,...D_(_.unwrap())];else if(_ instanceof D6)return D_(_.unwrap());else if(_ instanceof jf)return D_(_.unwrap());else if(_ instanceof Pf)return D_(_._def.innerType);else return[]};class I6 extends $q{_parse(_){let{ctx:q}=this._processInputParams(_);if(q.parsedType!==o.object)return t(q,{code:y.invalid_type,expected:o.object,received:q.parsedType}),U;let f=this.discriminator,K=q.data[f],$=this.optionsMap.get(K);if(!$)return t(q,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[f]}),U;if(q.common.async)return $._parseAsync({data:q.data,path:q.path,parent:q});else return $._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(_,q,f){let K=new Map;for(let $ of q){let P=D_($.shape[_]);if(!P.length)throw new Error(`A discriminator value for key \`${_}\` could not be extracted from all schema options`);for(let j of P){if(K.has(j))throw new Error(`Discriminator property ${String(_)} has duplicate value ${String(j)}`);K.set(j,$)}}return new I6({typeName:i.ZodDiscriminatedUnion,discriminator:_,options:q,optionsMap:K,...qq(f)})}}function iK(_,q){let f=V_(_),K=V_(q);if(_===q)return{valid:!0,data:_};else if(f===o.object&&K===o.object){let $=Kq.objectKeys(q),P=Kq.objectKeys(_).filter((v)=>$.indexOf(v)!==-1),j={..._,...q};for(let v of P){let w=iK(_[v],q[v]);if(!w.valid)return{valid:!1};j[v]=w.data}return{valid:!0,data:j}}else if(f===o.array&&K===o.array){if(_.length!==q.length)return{valid:!1};let $=[];for(let P=0;P<_.length;P++){let j=_[P],v=q[P],w=iK(j,v);if(!w.valid)return{valid:!1};$.push(w.data)}return{valid:!0,data:$}}else if(f===o.date&&K===o.date&&+_===+q)return{valid:!0,data:_};else return{valid:!1}}class qf extends $q{_parse(_){let{status:q,ctx:f}=this._processInputParams(_),K=($,P)=>{if(d6($)||d6(P))return U;let j=iK($.value,P.value);if(!j.valid)return t(f,{code:y.invalid_intersection_types}),U;if(a6($)||a6(P))q.dirty();return{status:q.value,value:j.data}};if(f.common.async)return Promise.all([this._def.left._parseAsync({data:f.data,path:f.path,parent:f}),this._def.right._parseAsync({data:f.data,path:f.path,parent:f})]).then(([$,P])=>K($,P));else return K(this._def.left._parseSync({data:f.data,path:f.path,parent:f}),this._def.right._parseSync({data:f.data,path:f.path,parent:f}))}}qf.create=(_,q,f)=>{return new qf({left:_,right:q,typeName:i.ZodIntersection,...qq(f)})};class S_ extends $q{_parse(_){let{status:q,ctx:f}=this._processInputParams(_);if(f.parsedType!==o.array)return t(f,{code:y.invalid_type,expected:o.array,received:f.parsedType}),U;if(f.data.length<this._def.items.length)return t(f,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;if(!this._def.rest&&f.data.length>this._def.items.length)t(f,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let $=[...f.data].map((P,j)=>{let v=this._def.items[j]||this._def.rest;if(!v)return null;return v._parse(new H_(f,P,f.path,j))}).filter((P)=>!!P);if(f.common.async)return Promise.all($).then((P)=>{return aq.mergeArray(q,P)});else return aq.mergeArray(q,$)}get items(){return this._def.items}rest(_){return new S_({...this._def,rest:_})}}S_.create=(_,q)=>{if(!Array.isArray(_))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new S_({items:_,typeName:i.ZodTuple,rest:null,...qq(q)})};class If extends $q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(_){let{status:q,ctx:f}=this._processInputParams(_);if(f.parsedType!==o.object)return t(f,{code:y.invalid_type,expected:o.object,received:f.parsedType}),U;let K=[],$=this._def.keyType,P=this._def.valueType;for(let j in f.data)K.push({key:$._parse(new H_(f,j,f.path,j)),value:P._parse(new H_(f,f.data[j],f.path,j)),alwaysSet:j in f.data});if(f.common.async)return aq.mergeObjectAsync(q,K);else return aq.mergeObjectSync(q,K)}get element(){return this._def.valueType}static create(_,q,f){if(q instanceof $q)return new If({keyType:_,valueType:q,typeName:i.ZodRecord,...qq(f)});return new If({keyType:T_.create(),valueType:_,typeName:i.ZodRecord,...qq(q)})}}class Df extends $q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(_){let{status:q,ctx:f}=this._processInputParams(_);if(f.parsedType!==o.map)return t(f,{code:y.invalid_type,expected:o.map,received:f.parsedType}),U;let K=this._def.keyType,$=this._def.valueType,P=[...f.data.entries()].map(([j,v],w)=>{return{key:K._parse(new H_(f,j,f.path,[w,"key"])),value:$._parse(new H_(f,v,f.path,[w,"value"]))}});if(f.common.async){let j=new Map;return Promise.resolve().then(async()=>{for(let v of P){let w=await v.key,O=await v.value;if(w.status==="aborted"||O.status==="aborted")return U;if(w.status==="dirty"||O.status==="dirty")q.dirty();j.set(w.value,O.value)}return{status:q.value,value:j}})}else{let j=new Map;for(let v of P){let{key:w,value:O}=v;if(w.status==="aborted"||O.status==="aborted")return U;if(w.status==="dirty"||O.status==="dirty")q.dirty();j.set(w.value,O.value)}return{status:q.value,value:j}}}}Df.create=(_,q,f)=>{return new Df({valueType:q,keyType:_,typeName:i.ZodMap,...qq(f)})};class m8 extends $q{_parse(_){let{status:q,ctx:f}=this._processInputParams(_);if(f.parsedType!==o.set)return t(f,{code:y.invalid_type,expected:o.set,received:f.parsedType}),U;let K=this._def;if(K.minSize!==null){if(f.data.size<K.minSize.value)t(f,{code:y.too_small,minimum:K.minSize.value,type:"set",inclusive:!0,exact:!1,message:K.minSize.message}),q.dirty()}if(K.maxSize!==null){if(f.data.size>K.maxSize.value)t(f,{code:y.too_big,maximum:K.maxSize.value,type:"set",inclusive:!0,exact:!1,message:K.maxSize.message}),q.dirty()}let $=this._def.valueType;function P(v){let w=new Set;for(let O of v){if(O.status==="aborted")return U;if(O.status==="dirty")q.dirty();w.add(O.value)}return{status:q.value,value:w}}let j=[...f.data.values()].map((v,w)=>$._parse(new H_(f,v,f.path,w)));if(f.common.async)return Promise.all(j).then((v)=>P(v));else return P(j)}min(_,q){return new m8({...this._def,minSize:{value:_,message:B.toString(q)}})}max(_,q){return new m8({...this._def,maxSize:{value:_,message:B.toString(q)}})}size(_,q){return this.min(_,q).max(_,q)}nonempty(_){return this.min(1,_)}}m8.create=(_,q)=>{return new m8({valueType:_,minSize:null,maxSize:null,typeName:i.ZodSet,...qq(q)})};class s8 extends $q{constructor(){super(...arguments);this.validate=this.implement}_parse(_){let{ctx:q}=this._processInputParams(_);if(q.parsedType!==o.function)return t(q,{code:y.invalid_type,expected:o.function,received:q.parsedType}),U;function f(j,v){return gf({data:j,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,t8(),I_].filter((w)=>!!w),issueData:{code:y.invalid_arguments,argumentsError:v}})}function K(j,v){return gf({data:j,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,t8(),I_].filter((w)=>!!w),issueData:{code:y.invalid_return_type,returnTypeError:v}})}let $={errorMap:q.common.contextualErrorMap},P=q.data;if(this._def.returns instanceof r8){let j=this;return yq(async function(...v){let w=new eq([]),O=await j._def.args.parseAsync(v,$).catch((z)=>{throw w.addIssue(f(v,z)),w}),T=await Reflect.apply(P,this,O);return await j._def.returns._def.type.parseAsync(T,$).catch((z)=>{throw w.addIssue(K(T,z)),w})})}else{let j=this;return yq(function(...v){let w=j._def.args.safeParse(v,$);if(!w.success)throw new eq([f(v,w.error)]);let O=Reflect.apply(P,this,w.data),T=j._def.returns.safeParse(O,$);if(!T.success)throw new eq([K(O,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(..._){return new s8({...this._def,args:S_.create(_).rest(U_.create())})}returns(_){return new s8({...this._def,returns:_})}implement(_){return this.parse(_)}strictImplement(_){return this.parse(_)}static create(_,q,f){return new s8({args:_?_:S_.create([]).rest(U_.create()),returns:q||U_.create(),typeName:i.ZodFunction,...qq(f)})}}class _f extends $q{get schema(){return this._def.getter()}_parse(_){let{ctx:q}=this._processInputParams(_);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}_f.create=(_,q)=>{return new _f({getter:_,typeName:i.ZodLazy,...qq(q)})};class ff extends $q{_parse(_){if(_.data!==this._def.value){let q=this._getOrReturnCtx(_);return t(q,{received:q.data,code:y.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:_.data}}get value(){return this._def.value}}ff.create=(_,q)=>{return new ff({value:_,typeName:i.ZodLiteral,...qq(q)})};function w7(_,q){return new q8({values:_,typeName:i.ZodEnum,...qq(q)})}class q8 extends $q{_parse(_){if(typeof _.data!=="string"){let q=this._getOrReturnCtx(_),f=this._def.values;return t(q,{expected:Kq.joinValues(f),received:q.parsedType,code:y.invalid_type}),U}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(_.data)){let q=this._getOrReturnCtx(_),f=this._def.values;return t(q,{received:q.data,code:y.invalid_enum_value,options:f}),U}return yq(_.data)}get options(){return this._def.values}get enum(){let _={};for(let q of this._def.values)_[q]=q;return _}get Values(){let _={};for(let q of this._def.values)_[q]=q;return _}get Enum(){let _={};for(let q of this._def.values)_[q]=q;return _}extract(_,q=this._def){return q8.create(_,{...this._def,...q})}exclude(_,q=this._def){return q8.create(this.options.filter((f)=>!_.includes(f)),{...this._def,...q})}}q8.create=w7;class $f extends $q{_parse(_){let q=Kq.getValidEnumValues(this._def.values),f=this._getOrReturnCtx(_);if(f.parsedType!==o.string&&f.parsedType!==o.number){let K=Kq.objectValues(q);return t(f,{expected:Kq.joinValues(K),received:f.parsedType,code:y.invalid_type}),U}if(!this._cache)this._cache=new Set(Kq.getValidEnumValues(this._def.values));if(!this._cache.has(_.data)){let K=Kq.objectValues(q);return t(f,{received:f.data,code:y.invalid_enum_value,options:K}),U}return yq(_.data)}get enum(){return this._def.values}}$f.create=(_,q)=>{return new $f({values:_,typeName:i.ZodNativeEnum,...qq(q)})};class r8 extends $q{unwrap(){return this._def.type}_parse(_){let{ctx:q}=this._processInputParams(_);if(q.parsedType!==o.promise&&q.common.async===!1)return t(q,{code:y.invalid_type,expected:o.promise,received:q.parsedType}),U;let f=q.parsedType===o.promise?q.data:Promise.resolve(q.data);return yq(f.then((K)=>{return this._def.type.parseAsync(K,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}r8.create=(_,q)=>{return new r8({type:_,typeName:i.ZodPromise,...qq(q)})};class h_ extends $q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===i.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(_){let{status:q,ctx:f}=this._processInputParams(_),K=this._def.effect||null,$={addIssue:(P)=>{if(t(f,P),P.fatal)q.abort();else q.dirty()},get path(){return f.path}};if($.addIssue=$.addIssue.bind($),K.type==="preprocess"){let P=K.transform(f.data,$);if(f.common.async)return Promise.resolve(P).then(async(j)=>{if(q.value==="aborted")return U;let v=await this._def.schema._parseAsync({data:j,path:f.path,parent:f});if(v.status==="aborted")return U;if(v.status==="dirty")return A8(v.value);if(q.value==="dirty")return A8(v.value);return v});else{if(q.value==="aborted")return U;let j=this._def.schema._parseSync({data:P,path:f.path,parent:f});if(j.status==="aborted")return U;if(j.status==="dirty")return A8(j.value);if(q.value==="dirty")return A8(j.value);return j}}if(K.type==="refinement"){let P=(j)=>{let v=K.refinement(j,$);if(f.common.async)return Promise.resolve(v);if(v instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return j};if(f.common.async===!1){let j=this._def.schema._parseSync({data:f.data,path:f.path,parent:f});if(j.status==="aborted")return U;if(j.status==="dirty")q.dirty();return P(j.value),{status:q.value,value:j.value}}else return this._def.schema._parseAsync({data:f.data,path:f.path,parent:f}).then((j)=>{if(j.status==="aborted")return U;if(j.status==="dirty")q.dirty();return P(j.value).then(()=>{return{status:q.value,value:j.value}})})}if(K.type==="transform")if(f.common.async===!1){let P=this._def.schema._parseSync({data:f.data,path:f.path,parent:f});if(!B_(P))return U;let j=K.transform(P.value,$);if(j instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:j}}else return this._def.schema._parseAsync({data:f.data,path:f.path,parent:f}).then((P)=>{if(!B_(P))return U;return Promise.resolve(K.transform(P.value,$)).then((j)=>({status:q.value,value:j}))});Kq.assertNever(K)}}h_.create=(_,q,f)=>{return new h_({schema:_,typeName:i.ZodEffects,effect:q,...qq(f)})};h_.createWithPreprocess=(_,q,f)=>{return new h_({schema:q,effect:{type:"preprocess",transform:_},typeName:i.ZodEffects,...qq(f)})};class W_ extends $q{_parse(_){if(this._getType(_)===o.undefined)return yq(void 0);return this._def.innerType._parse(_)}unwrap(){return this._def.innerType}}W_.create=(_,q)=>{return new W_({innerType:_,typeName:i.ZodOptional,...qq(q)})};class y_ extends $q{_parse(_){if(this._getType(_)===o.null)return yq(null);return this._def.innerType._parse(_)}unwrap(){return this._def.innerType}}y_.create=(_,q)=>{return new y_({innerType:_,typeName:i.ZodNullable,...qq(q)})};class Kf extends $q{_parse(_){let{ctx:q}=this._processInputParams(_),f=q.data;if(q.parsedType===o.undefined)f=this._def.defaultValue();return this._def.innerType._parse({data:f,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}Kf.create=(_,q)=>{return new Kf({innerType:_,typeName:i.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...qq(q)})};class Pf extends $q{_parse(_){let{ctx:q}=this._processInputParams(_),f={...q,common:{...q.common,issues:[]}},K=this._def.innerType._parse({data:f.data,path:f.path,parent:{...f}});if(e8(K))return K.then(($)=>{return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new eq(f.common.issues)},input:f.data})}});else return{status:"valid",value:K.status==="valid"?K.value:this._def.catchValue({get error(){return new eq(f.common.issues)},input:f.data})}}removeCatch(){return this._def.innerType}}Pf.create=(_,q)=>{return new Pf({innerType:_,typeName:i.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...qq(q)})};class yf extends $q{_parse(_){if(this._getType(_)!==o.nan){let f=this._getOrReturnCtx(_);return t(f,{code:y.invalid_type,expected:o.nan,received:f.parsedType}),U}return{status:"valid",value:_.data}}}yf.create=(_)=>{return new yf({typeName:i.ZodNaN,...qq(_)})};var kY=Symbol("zod_brand");class D6 extends $q{_parse(_){let{ctx:q}=this._processInputParams(_),f=q.data;return this._def.type._parse({data:f,path:q.path,parent:q})}unwrap(){return this._def.type}}class of extends $q{_parse(_){let{status:q,ctx:f}=this._processInputParams(_);if(f.common.async)return(async()=>{let $=await this._def.in._parseAsync({data:f.data,path:f.path,parent:f});if($.status==="aborted")return U;if($.status==="dirty")return q.dirty(),A8($.value);else return this._def.out._parseAsync({data:$.value,path:f.path,parent:f})})();else{let K=this._def.in._parseSync({data:f.data,path:f.path,parent:f});if(K.status==="aborted")return U;if(K.status==="dirty")return q.dirty(),{status:"dirty",value:K.value};else return this._def.out._parseSync({data:K.value,path:f.path,parent:f})}}static create(_,q){return new of({in:_,out:q,typeName:i.ZodPipeline})}}class jf extends $q{_parse(_){let q=this._def.innerType._parse(_),f=(K)=>{if(B_(K))K.value=Object.freeze(K.value);return K};return e8(q)?q.then((K)=>f(K)):f(q)}unwrap(){return this._def.innerType}}jf.create=(_,q)=>{return new jf({innerType:_,typeName:i.ZodReadonly,...qq(q)})};function K7(_,q){let f=typeof _==="function"?_(q):typeof _==="string"?{message:_}:_;return typeof f==="string"?{message:f}:f}function O7(_,q={},f){if(_)return G8.create().superRefine((K,$)=>{let P=_(K);if(P instanceof Promise)return P.then((j)=>{if(!j){let v=K7(q,K),w=v.fatal??f??!0;$.addIssue({code:"custom",...v,fatal:w})}});if(!P){let j=K7(q,K),v=j.fatal??f??!0;$.addIssue({code:"custom",...j,fatal:v})}return});return G8.create()}var ZY={object:bq.lazycreate},i;(function(_){_.ZodString="ZodString",_.ZodNumber="ZodNumber",_.ZodNaN="ZodNaN",_.ZodBigInt="ZodBigInt",_.ZodBoolean="ZodBoolean",_.ZodDate="ZodDate",_.ZodSymbol="ZodSymbol",_.ZodUndefined="ZodUndefined",_.ZodNull="ZodNull",_.ZodAny="ZodAny",_.ZodUnknown="ZodUnknown",_.ZodNever="ZodNever",_.ZodVoid="ZodVoid",_.ZodArray="ZodArray",_.ZodObject="ZodObject",_.ZodUnion="ZodUnion",_.ZodDiscriminatedUnion="ZodDiscriminatedUnion",_.ZodIntersection="ZodIntersection",_.ZodTuple="ZodTuple",_.ZodRecord="ZodRecord",_.ZodMap="ZodMap",_.ZodSet="ZodSet",_.ZodFunction="ZodFunction",_.ZodLazy="ZodLazy",_.ZodLiteral="ZodLiteral",_.ZodEnum="ZodEnum",_.ZodEffects="ZodEffects",_.ZodNativeEnum="ZodNativeEnum",_.ZodOptional="ZodOptional",_.ZodNullable="ZodNullable",_.ZodDefault="ZodDefault",_.ZodCatch="ZodCatch",_.ZodPromise="ZodPromise",_.ZodBranded="ZodBranded",_.ZodPipeline="ZodPipeline",_.ZodReadonly="ZodReadonly"})(i||(i={}));var XY=(_,q={message:`Input not instance of ${_.name}`})=>O7((f)=>f instanceof _,q),Y7=T_.create,T7=F_.create,AY=yf.create,uY=Q_.create,z7=B8.create,GY=u8.create,mY=df.create,rY=U8.create,bY=F8.create,VY=G8.create,MY=U_.create,SY=M_.create,NY=af.create,CY=z_.create,pY=bq.create,lY=bq.strictCreate,nY=Q8.create,RY=I6.create,EY=qf.create,gY=S_.create,dY=If.create,aY=Df.create,IY=m8.create,DY=s8.create,yY=_f.create,iY=ff.create,oY=q8.create,cY=$f.create,LY=r8.create,tY=h_.create,eY=W_.create,xY=y_.create,sY=h_.createWithPreprocess,BY=of.create,UY=()=>Y7().optional(),FY=()=>T7().optional(),QY=()=>z7().optional(),qT={string:(_)=>T_.create({..._,coerce:!0}),number:(_)=>F_.create({..._,coerce:!0}),boolean:(_)=>B8.create({..._,coerce:!0}),bigint:(_)=>Q_.create({..._,coerce:!0}),date:(_)=>u8.create({..._,coerce:!0})};var _T=U;var oK="2025-06-18";var W7=[oK,"2025-03-26","2024-11-05","2024-10-07"],y6="2.0",H7=W.union([W.string(),W.number().int()]),h7=W.string(),fT=W.object({progressToken:W.optional(H7)}).passthrough(),K_=W.object({_meta:W.optional(fT)}).passthrough(),xq=W.object({method:W.string(),params:W.optional(K_)}),cf=W.object({_meta:W.optional(W.object({}).passthrough())}).passthrough(),N_=W.object({method:W.string(),params:W.optional(cf)}),P_=W.object({_meta:W.optional(W.object({}).passthrough())}).passthrough(),i6=W.union([W.string(),W.number().int()]),J7=W.object({jsonrpc:W.literal(y6),id:i6}).merge(xq).strict(),k7=(_)=>J7.safeParse(_).success,Z7=W.object({jsonrpc:W.literal(y6)}).merge(N_).strict(),X7=(_)=>Z7.safeParse(_).success,A7=W.object({jsonrpc:W.literal(y6),id:i6,result:P_}).strict(),cK=(_)=>A7.safeParse(_).success,Zq;(function(_){_[_.ConnectionClosed=-32000]="ConnectionClosed",_[_.RequestTimeout=-32001]="RequestTimeout",_[_.ParseError=-32700]="ParseError",_[_.InvalidRequest=-32600]="InvalidRequest",_[_.MethodNotFound=-32601]="MethodNotFound",_[_.InvalidParams=-32602]="InvalidParams",_[_.InternalError=-32603]="InternalError"})(Zq||(Zq={}));var u7=W.object({jsonrpc:W.literal(y6),id:i6,error:W.object({code:W.number().int(),message:W.string(),data:W.optional(W.unknown())})}).strict(),G7=(_)=>u7.safeParse(_).success,m7=W.union([J7,Z7,A7,u7]),o6=P_.strict(),c6=N_.extend({method:W.literal("notifications/cancelled"),params:cf.extend({requestId:i6,reason:W.string().optional()})}),$T=W.object({src:W.string(),mimeType:W.optional(W.string()),sizes:W.optional(W.array(W.string()))}).passthrough(),Lf=W.object({icons:W.array($T).optional()}).passthrough(),tf=W.object({name:W.string(),title:W.optional(W.string())}).passthrough(),r7=tf.extend({version:W.string(),websiteUrl:W.optional(W.string())}).merge(Lf),KT=W.object({experimental:W.optional(W.object({}).passthrough()),sampling:W.optional(W.object({}).passthrough()),elicitation:W.optional(W.object({}).passthrough()),roots:W.optional(W.object({listChanged:W.optional(W.boolean())}).passthrough())}).passthrough(),LK=xq.extend({method:W.literal("initialize"),params:K_.extend({protocolVersion:W.string(),capabilities:KT,clientInfo:r7})});var PT=W.object({experimental:W.optional(W.object({}).passthrough()),logging:W.optional(W.object({}).passthrough()),completions:W.optional(W.object({}).passthrough()),prompts:W.optional(W.object({listChanged:W.optional(W.boolean())}).passthrough()),resources:W.optional(W.object({subscribe:W.optional(W.boolean()),listChanged:W.optional(W.boolean())}).passthrough()),tools:W.optional(W.object({listChanged:W.optional(W.boolean())}).passthrough())}).passthrough(),jT=P_.extend({protocolVersion:W.string(),capabilities:PT,serverInfo:r7,instructions:W.optional(W.string())}),tK=N_.extend({method:W.literal("notifications/initialized")});var L6=xq.extend({method:W.literal("ping")}),vT=W.object({progress:W.number(),total:W.optional(W.number()),message:W.optional(W.string())}).passthrough(),t6=N_.extend({method:W.literal("notifications/progress"),params:cf.merge(vT).extend({progressToken:H7})}),e6=xq.extend({params:K_.extend({cursor:W.optional(h7)}).optional()}),x6=P_.extend({nextCursor:W.optional(h7)}),b7=W.object({uri:W.string(),mimeType:W.optional(W.string()),_meta:W.optional(W.object({}).passthrough())}).passthrough(),V7=b7.extend({text:W.string()}),eK=W.string().refine((_)=>{try{return atob(_),!0}catch(q){return!1}},{message:"Invalid Base64 string"}),M7=b7.extend({blob:eK}),S7=tf.extend({uri:W.string(),description:W.optional(W.string()),mimeType:W.optional(W.string()),_meta:W.optional(W.object({}).passthrough())}).merge(Lf),wT=tf.extend({uriTemplate:W.string(),description:W.optional(W.string()),mimeType:W.optional(W.string()),_meta:W.optional(W.object({}).passthrough())}).merge(Lf),s6=e6.extend({method:W.literal("resources/list")}),OT=x6.extend({resources:W.array(S7)}),B6=e6.extend({method:W.literal("resources/templates/list")}),YT=x6.extend({resourceTemplates:W.array(wT)}),U6=xq.extend({method:W.literal("resources/read"),params:K_.extend({uri:W.string()})}),TT=P_.extend({contents:W.array(W.union([V7,M7]))}),zT=N_.extend({method:W.literal("notifications/resources/list_changed")}),WT=xq.extend({method:W.literal("resources/subscribe"),params:K_.extend({uri:W.string()})}),HT=xq.extend({method:W.literal("resources/unsubscribe"),params:K_.extend({uri:W.string()})}),hT=N_.extend({method:W.literal("notifications/resources/updated"),params:cf.extend({uri:W.string()})}),JT=W.object({name:W.string(),description:W.optional(W.string()),required:W.optional(W.boolean())}).passthrough(),kT=tf.extend({description:W.optional(W.string()),arguments:W.optional(W.array(JT)),_meta:W.optional(W.object({}).passthrough())}).merge(Lf),F6=e6.extend({method:W.literal("prompts/list")}),ZT=x6.extend({prompts:W.array(kT)}),Q6=xq.extend({method:W.literal("prompts/get"),params:K_.extend({name:W.string(),arguments:W.optional(W.record(W.string()))})}),xK=W.object({type:W.literal("text"),text:W.string(),_meta:W.optional(W.object({}).passthrough())}).passthrough(),sK=W.object({type:W.literal("image"),data:eK,mimeType:W.string(),_meta:W.optional(W.object({}).passthrough())}).passthrough(),BK=W.object({type:W.literal("audio"),data:eK,mimeType:W.string(),_meta:W.optional(W.object({}).passthrough())}).passthrough(),XT=W.object({type:W.literal("resource"),resource:W.union([V7,M7]),_meta:W.optional(W.object({}).passthrough())}).passthrough(),AT=S7.extend({type:W.literal("resource_link")}),N7=W.union([xK,sK,BK,AT,XT]),uT=W.object({role:W.enum(["user","assistant"]),content:N7}).passthrough(),GT=P_.extend({description:W.optional(W.string()),messages:W.array(uT)}),mT=N_.extend({method:W.literal("notifications/prompts/list_changed")}),rT=W.object({title:W.optional(W.string()),readOnlyHint:W.optional(W.boolean()),destructiveHint:W.optional(W.boolean()),idempotentHint:W.optional(W.boolean()),openWorldHint:W.optional(W.boolean())}).passthrough(),bT=tf.extend({description:W.optional(W.string()),inputSchema:W.object({type:W.literal("object"),properties:W.optional(W.object({}).passthrough()),required:W.optional(W.array(W.string()))}).passthrough(),outputSchema:W.optional(W.object({type:W.literal("object"),properties:W.optional(W.object({}).passthrough()),required:W.optional(W.array(W.string()))}).passthrough()),annotations:W.optional(rT),_meta:W.optional(W.object({}).passthrough())}).merge(Lf),q$=e6.extend({method:W.literal("tools/list")}),VT=x6.extend({tools:W.array(bT)}),C7=P_.extend({content:W.array(N7).default([]),structuredContent:W.object({}).passthrough().optional(),isError:W.optional(W.boolean())}),VC=C7.or(P_.extend({toolResult:W.unknown()})),_$=xq.extend({method:W.literal("tools/call"),params:K_.extend({name:W.string(),arguments:W.optional(W.record(W.unknown()))})}),MT=N_.extend({method:W.literal("notifications/tools/list_changed")}),ef=W.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),UK=xq.extend({method:W.literal("logging/setLevel"),params:K_.extend({level:ef})}),ST=N_.extend({method:W.literal("notifications/message"),params:cf.extend({level:ef,logger:W.optional(W.string()),data:W.unknown()})}),NT=W.object({name:W.string().optional()}).passthrough(),CT=W.object({hints:W.optional(W.array(NT)),costPriority:W.optional(W.number().min(0).max(1)),speedPriority:W.optional(W.number().min(0).max(1)),intelligencePriority:W.optional(W.number().min(0).max(1))}).passthrough(),pT=W.object({role:W.enum(["user","assistant"]),content:W.union([xK,sK,BK])}).passthrough(),lT=xq.extend({method:W.literal("sampling/createMessage"),params:K_.extend({messages:W.array(pT),systemPrompt:W.optional(W.string()),includeContext:W.optional(W.enum(["none","thisServer","allServers"])),temperature:W.optional(W.number()),maxTokens:W.number().int(),stopSequences:W.optional(W.array(W.string())),metadata:W.optional(W.object({}).passthrough()),modelPreferences:W.optional(CT)})}),FK=P_.extend({model:W.string(),stopReason:W.optional(W.enum(["endTurn","stopSequence","maxTokens"]).or(W.string())),role:W.enum(["user","assistant"]),content:W.discriminatedUnion("type",[xK,sK,BK])}),nT=W.object({type:W.literal("boolean"),title:W.optional(W.string()),description:W.optional(W.string()),default:W.optional(W.boolean())}).passthrough(),RT=W.object({type:W.literal("string"),title:W.optional(W.string()),description:W.optional(W.string()),minLength:W.optional(W.number()),maxLength:W.optional(W.number()),format:W.optional(W.enum(["email","uri","date","date-time"]))}).passthrough(),ET=W.object({type:W.enum(["number","integer"]),title:W.optional(W.string()),description:W.optional(W.string()),minimum:W.optional(W.number()),maximum:W.optional(W.number())}).passthrough(),gT=W.object({type:W.literal("string"),title:W.optional(W.string()),description:W.optional(W.string()),enum:W.array(W.string()),enumNames:W.optional(W.array(W.string()))}).passthrough(),dT=W.union([nT,RT,ET,gT]),aT=xq.extend({method:W.literal("elicitation/create"),params:K_.extend({message:W.string(),requestedSchema:W.object({type:W.literal("object"),properties:W.record(W.string(),dT),required:W.optional(W.array(W.string()))}).passthrough()})}),QK=P_.extend({action:W.enum(["accept","decline","cancel"]),content:W.optional(W.record(W.string(),W.unknown()))}),IT=W.object({type:W.literal("ref/resource"),uri:W.string()}).passthrough();var DT=W.object({type:W.literal("ref/prompt"),name:W.string()}).passthrough(),f$=xq.extend({method:W.literal("completion/complete"),params:K_.extend({ref:W.union([DT,IT]),argument:W.object({name:W.string(),value:W.string()}).passthrough(),context:W.optional(W.object({arguments:W.optional(W.record(W.string(),W.string()))}))})}),yT=P_.extend({completion:W.object({values:W.array(W.string()).max(100),total:W.optional(W.number().int()),hasMore:W.optional(W.boolean())}).passthrough()}),iT=W.object({uri:W.string().startsWith("file://"),name:W.optional(W.string()),_meta:W.optional(W.object({}).passthrough())}).passthrough(),oT=xq.extend({method:W.literal("roots/list")}),qP=P_.extend({roots:W.array(iT)}),cT=N_.extend({method:W.literal("notifications/roots/list_changed")}),MC=W.union([L6,LK,f$,UK,Q6,F6,s6,B6,U6,WT,HT,_$,q$]),SC=W.union([c6,t6,tK,cT]),NC=W.union([o6,FK,QK,qP]),CC=W.union([L6,lT,aT,oT]),pC=W.union([c6,t6,ST,hT,zT,MT,mT]),lC=W.union([o6,jT,yT,GT,ZT,OT,YT,TT,C7,VT]);class Xq extends Error{constructor(_,q,f){super(`MCP error ${_}: ${q}`);this.code=_,this.data=f,this.name="McpError"}}var LT=60000;class _P{constructor(_){this._options=_,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(c6,(q)=>{let f=this._requestHandlerAbortControllers.get(q.params.requestId);f===null||f===void 0||f.abort(q.params.reason)}),this.setNotificationHandler(t6,(q)=>{this._onprogress(q)}),this.setRequestHandler(L6,(q)=>({}))}_setupTimeout(_,q,f,K,$=!1){this._timeoutInfo.set(_,{timeoutId:setTimeout(K,q),startTime:Date.now(),timeout:q,maxTotalTimeout:f,resetTimeoutOnProgress:$,onTimeout:K})}_resetTimeout(_){let q=this._timeoutInfo.get(_);if(!q)return!1;let f=Date.now()-q.startTime;if(q.maxTotalTimeout&&f>=q.maxTotalTimeout)throw this._timeoutInfo.delete(_),new Xq(Zq.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:q.maxTotalTimeout,totalElapsed:f});return clearTimeout(q.timeoutId),q.timeoutId=setTimeout(q.onTimeout,q.timeout),!0}_cleanupTimeout(_){let q=this._timeoutInfo.get(_);if(q)clearTimeout(q.timeoutId),this._timeoutInfo.delete(_)}async connect(_){var q,f,K;this._transport=_;let $=(q=this.transport)===null||q===void 0?void 0:q.onclose;this._transport.onclose=()=>{$===null||$===void 0||$(),this._onclose()};let P=(f=this.transport)===null||f===void 0?void 0:f.onerror;this._transport.onerror=(v)=>{P===null||P===void 0||P(v),this._onerror(v)};let j=(K=this._transport)===null||K===void 0?void 0:K.onmessage;this._transport.onmessage=(v,w)=>{if(j===null||j===void 0||j(v,w),cK(v)||G7(v))this._onresponse(v);else if(k7(v))this._onrequest(v,w);else if(X7(v))this._onnotification(v);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(v)}`))},await this._transport.start()}_onclose(){var _;let q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(_=this.onclose)===null||_===void 0||_.call(this);let f=new Xq(Zq.ConnectionClosed,"Connection closed");for(let K of q.values())K(f)}_onerror(_){var q;(q=this.onerror)===null||q===void 0||q.call(this,_)}_onnotification(_){var q;let f=(q=this._notificationHandlers.get(_.method))!==null&&q!==void 0?q:this.fallbackNotificationHandler;if(f===void 0)return;Promise.resolve().then(()=>f(_)).catch((K)=>this._onerror(new Error(`Uncaught error in notification handler: ${K}`)))}_onrequest(_,q){var f,K;let $=(f=this._requestHandlers.get(_.method))!==null&&f!==void 0?f:this.fallbackRequestHandler,P=this._transport;if($===void 0){P===null||P===void 0||P.send({jsonrpc:"2.0",id:_.id,error:{code:Zq.MethodNotFound,message:"Method not found"}}).catch((w)=>this._onerror(new Error(`Failed to send an error response: ${w}`)));return}let j=new AbortController;this._requestHandlerAbortControllers.set(_.id,j);let v={signal:j.signal,sessionId:P===null||P===void 0?void 0:P.sessionId,_meta:(K=_.params)===null||K===void 0?void 0:K._meta,sendNotification:(w)=>this.notification(w,{relatedRequestId:_.id}),sendRequest:(w,O,T)=>this.request(w,O,{...T,relatedRequestId:_.id}),authInfo:q===null||q===void 0?void 0:q.authInfo,requestId:_.id,requestInfo:q===null||q===void 0?void 0:q.requestInfo};Promise.resolve().then(()=>$(_,v)).then((w)=>{if(j.signal.aborted)return;return P===null||P===void 0?void 0:P.send({result:w,jsonrpc:"2.0",id:_.id})},(w)=>{var O;if(j.signal.aborted)return;return P===null||P===void 0?void 0:P.send({jsonrpc:"2.0",id:_.id,error:{code:Number.isSafeInteger(w.code)?w.code:Zq.InternalError,message:(O=w.message)!==null&&O!==void 0?O:"Internal error"}})}).catch((w)=>this._onerror(new Error(`Failed to send response: ${w}`))).finally(()=>{this._requestHandlerAbortControllers.delete(_.id)})}_onprogress(_){let{progressToken:q,...f}=_.params,K=Number(q),$=this._progressHandlers.get(K);if(!$){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(_)}`));return}let P=this._responseHandlers.get(K),j=this._timeoutInfo.get(K);if(j&&P&&j.resetTimeoutOnProgress)try{this._resetTimeout(K)}catch(v){P(v);return}$(f)}_onresponse(_){let q=Number(_.id),f=this._responseHandlers.get(q);if(f===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(_)}`));return}if(this._responseHandlers.delete(q),this._progressHandlers.delete(q),this._cleanupTimeout(q),cK(_))f(_);else{let K=new Xq(_.error.code,_.error.message,_.error.data);f(K)}}get transport(){return this._transport}async close(){var _;await((_=this._transport)===null||_===void 0?void 0:_.close())}request(_,q,f){let{relatedRequestId:K,resumptionToken:$,onresumptiontoken:P}=f!==null&&f!==void 0?f:{};return new Promise((j,v)=>{var w,O,T,Y,z,H;if(!this._transport){v(new Error("Not connected"));return}if(((w=this._options)===null||w===void 0?void 0:w.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod(_.method);(O=f===null||f===void 0?void 0:f.signal)===null||O===void 0||O.throwIfAborted();let h=this._requestMessageId++,J={..._,jsonrpc:"2.0",id:h};if(f===null||f===void 0?void 0:f.onprogress)this._progressHandlers.set(h,f.onprogress),J.params={..._.params,_meta:{...((T=_.params)===null||T===void 0?void 0:T._meta)||{},progressToken:h}};let k=(N)=>{var n;this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),(n=this._transport)===null||n===void 0||n.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(N)}},{relatedRequestId:K,resumptionToken:$,onresumptiontoken:P}).catch((R)=>this._onerror(new Error(`Failed to send cancellation: ${R}`))),v(N)};this._responseHandlers.set(h,(N)=>{var n;if((n=f===null||f===void 0?void 0:f.signal)===null||n===void 0?void 0:n.aborted)return;if(N instanceof Error)return v(N);try{let R=q.parse(N.result);j(R)}catch(R){v(R)}}),(Y=f===null||f===void 0?void 0:f.signal)===null||Y===void 0||Y.addEventListener("abort",()=>{var N;k((N=f===null||f===void 0?void 0:f.signal)===null||N===void 0?void 0:N.reason)});let X=(z=f===null||f===void 0?void 0:f.timeout)!==null&&z!==void 0?z:LT,l=()=>k(new Xq(Zq.RequestTimeout,"Request timed out",{timeout:X}));this._setupTimeout(h,X,f===null||f===void 0?void 0:f.maxTotalTimeout,l,(H=f===null||f===void 0?void 0:f.resetTimeoutOnProgress)!==null&&H!==void 0?H:!1),this._transport.send(J,{relatedRequestId:K,resumptionToken:$,onresumptiontoken:P}).catch((N)=>{this._cleanupTimeout(h),v(N)})})}async notification(_,q){var f,K;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(_.method),((K=(f=this._options)===null||f===void 0?void 0:f.debouncedNotificationMethods)!==null&&K!==void 0?K:[]).includes(_.method)&&!_.params&&!(q===null||q===void 0?void 0:q.relatedRequestId)){if(this._pendingDebouncedNotifications.has(_.method))return;this._pendingDebouncedNotifications.add(_.method),Promise.resolve().then(()=>{var v;if(this._pendingDebouncedNotifications.delete(_.method),!this._transport)return;let w={..._,jsonrpc:"2.0"};(v=this._transport)===null||v===void 0||v.send(w,q).catch((O)=>this._onerror(O))});return}let j={..._,jsonrpc:"2.0"};await this._transport.send(j,q)}setRequestHandler(_,q){let f=_.shape.method.value;this.assertRequestHandlerCapability(f),this._requestHandlers.set(f,(K,$)=>{return Promise.resolve(q(_.parse(K),$))})}removeRequestHandler(_){this._requestHandlers.delete(_)}assertCanSetRequestHandler(_){if(this._requestHandlers.has(_))throw new Error(`A request handler for ${_} already exists, which would be overridden`)}setNotificationHandler(_,q){this._notificationHandlers.set(_.shape.method.value,(f)=>Promise.resolve(q(_.parse(f))))}removeNotificationHandler(_){this._notificationHandlers.delete(_)}}function p7(_,q){return Object.entries(q).reduce((f,[K,$])=>{if($&&typeof $==="object")f[K]=f[K]?{...f[K],...$}:$;else f[K]=$;return f},{..._})}var n9=IK(l9(),1);class VP extends _P{constructor(_,q){var f;super(q);if(this._serverInfo=_,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ef.options.map((K,$)=>[K,$])),this.isMessageIgnored=(K,$)=>{let P=this._loggingLevels.get($);return P?this.LOG_LEVEL_SEVERITY.get(K)<this.LOG_LEVEL_SEVERITY.get(P):!1},this._capabilities=(f=q===null||q===void 0?void 0:q.capabilities)!==null&&f!==void 0?f:{},this._instructions=q===null||q===void 0?void 0:q.instructions,this.setRequestHandler(LK,(K)=>this._oninitialize(K)),this.setNotificationHandler(tK,()=>{var K;return(K=this.oninitialized)===null||K===void 0?void 0:K.call(this)}),this._capabilities.logging)this.setRequestHandler(UK,async(K,$)=>{var P;let j=$.sessionId||((P=$.requestInfo)===null||P===void 0?void 0:P.headers["mcp-session-id"])||void 0,{level:v}=K.params,w=ef.safeParse(v);if(w.success)this._loggingLevels.set(j,w.data);return{}})}registerCapabilities(_){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=p7(this._capabilities,_)}assertCapabilityForMethod(_){var q,f,K;switch(_){case"sampling/createMessage":if(!((q=this._clientCapabilities)===null||q===void 0?void 0:q.sampling))throw new Error(`Client does not support sampling (required for ${_})`);break;case"elicitation/create":if(!((f=this._clientCapabilities)===null||f===void 0?void 0:f.elicitation))throw new Error(`Client does not support elicitation (required for ${_})`);break;case"roots/list":if(!((K=this._clientCapabilities)===null||K===void 0?void 0:K.roots))throw new Error(`Client does not support listing roots (required for ${_})`);break;case"ping":break}}assertNotificationCapability(_){switch(_){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${_})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${_})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${_})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${_})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(_){switch(_){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${_})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${_})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${_})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${_})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${_})`);break;case"ping":case"initialize":break}}async _oninitialize(_){let q=_.params.protocolVersion;return this._clientCapabilities=_.params.capabilities,this._clientVersion=_.params.clientInfo,{protocolVersion:W7.includes(q)?q:oK,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},o6)}async createMessage(_,q){return this.request({method:"sampling/createMessage",params:_},FK,q)}async elicitInput(_,q){let f=await this.request({method:"elicitation/create",params:_},QK,q);if(f.action==="accept"&&f.content)try{let K=new n9.default,$=K.compile(_.requestedSchema);if(!$(f.content))throw new Xq(Zq.InvalidParams,`Elicitation response content does not match requested schema: ${K.errorsText($.errors)}`)}catch(K){if(K instanceof Xq)throw K;throw new Xq(Zq.InternalError,`Error validating elicitation response: ${K}`)}return f}async listRoots(_,q){return this.request({method:"roots/list",params:_},qP,q)}async sendLoggingMessage(_,q){if(this._capabilities.logging){if(!this.isMessageIgnored(_.level,q))return this.notification({method:"notifications/message",params:_})}}async sendResourceUpdated(_){return this.notification({method:"notifications/resources/updated",params:_})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var E9=Symbol("Let zodToJsonSchema decide on which parser to use");var R9={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},g9=(_)=>typeof _==="string"?{...R9,name:_}:{...R9,..._};var d9=(_)=>{let q=g9(_),f=q.name!==void 0?[...q.basePath,q.definitionPath,q.name]:q.basePath;return{...q,flags:{hasReferencedOpenAiAnyType:!1},currentPath:f,propertyPath:void 0,seen:new Map(Object.entries(q.definitions).map(([K,$])=>[$._def,{def:$._def,path:[...q.basePath,q.definitionPath,K],jsonSchema:void 0}]))}};function MP(_,q,f,K){if(!K?.errorMessages)return;if(f)_.errorMessage={..._.errorMessage,[q]:f}}function jq(_,q,f,K,$){_[q]=f,MP(_,q,K,$)}var u$=(_,q)=>{let f=0;for(;f<_.length&&f<q.length;f++)if(_[f]!==q[f])break;return[(_.length-f).toString(),...q.slice(f)].join("/")};function Gq(_){if(_.target!=="openAi")return{};let q=[..._.basePath,_.definitionPath,_.openAiAnyTypeName];return _.flags.hasReferencedOpenAiAnyType=!0,{$ref:_.$refStrategy==="relative"?u$(q,_.currentPath):q.join("/")}}function a9(_,q){let f={type:"array"};if(_.type?._def&&_.type?._def?.typeName!==i.ZodAny)f.items=F(_.type._def,{...q,currentPath:[...q.currentPath,"items"]});if(_.minLength)jq(f,"minItems",_.minLength.value,_.minLength.message,q);if(_.maxLength)jq(f,"maxItems",_.maxLength.value,_.maxLength.message,q);if(_.exactLength)jq(f,"minItems",_.exactLength.value,_.exactLength.message,q),jq(f,"maxItems",_.exactLength.value,_.exactLength.message,q);return f}function I9(_,q){let f={type:"integer",format:"int64"};if(!_.checks)return f;for(let K of _.checks)switch(K.kind){case"min":if(q.target==="jsonSchema7")if(K.inclusive)jq(f,"minimum",K.value,K.message,q);else jq(f,"exclusiveMinimum",K.value,K.message,q);else{if(!K.inclusive)f.exclusiveMinimum=!0;jq(f,"minimum",K.value,K.message,q)}break;case"max":if(q.target==="jsonSchema7")if(K.inclusive)jq(f,"maximum",K.value,K.message,q);else jq(f,"exclusiveMaximum",K.value,K.message,q);else{if(!K.inclusive)f.exclusiveMaximum=!0;jq(f,"maximum",K.value,K.message,q)}break;case"multipleOf":jq(f,"multipleOf",K.value,K.message,q);break}return f}function D9(){return{type:"boolean"}}function G$(_,q){return F(_.type._def,q)}var y9=(_,q)=>{return F(_.innerType._def,q)};function SP(_,q,f){let K=f??q.dateStrategy;if(Array.isArray(K))return{anyOf:K.map(($,P)=>SP(_,q,$))};switch(K){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return rW(_,q)}}var rW=(_,q)=>{let f={type:"integer",format:"unix-time"};if(q.target==="openApi3")return f;for(let K of _.checks)switch(K.kind){case"min":jq(f,"minimum",K.value,K.message,q);break;case"max":jq(f,"maximum",K.value,K.message,q);break}return f};function i9(_,q){return{...F(_.innerType._def,q),default:_.defaultValue()}}function o9(_,q){return q.effectStrategy==="input"?F(_.schema._def,q):Gq(q)}function c9(_){return{type:"string",enum:Array.from(_.values)}}var bW=(_)=>{if("type"in _&&_.type==="string")return!1;return"allOf"in _};function L9(_,q){let f=[F(_.left._def,{...q,currentPath:[...q.currentPath,"allOf","0"]}),F(_.right._def,{...q,currentPath:[...q.currentPath,"allOf","1"]})].filter((P)=>!!P),K=q.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,$=[];return f.forEach((P)=>{if(bW(P)){if($.push(...P.allOf),P.unevaluatedProperties===void 0)K=void 0}else{let j=P;if("additionalProperties"in P&&P.additionalProperties===!1){let{additionalProperties:v,...w}=P;j=w}else K=void 0;$.push(j)}}),$.length?{allOf:$,...K}:void 0}function t9(_,q){let f=typeof _.value;if(f!=="bigint"&&f!=="number"&&f!=="boolean"&&f!=="string")return{type:Array.isArray(_.value)?"array":"object"};if(q.target==="openApi3")return{type:f==="bigint"?"integer":f,enum:[_.value]};return{type:f==="bigint"?"integer":f,const:_.value}}var NP=void 0,J_={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(NP===void 0)NP=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return NP},uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function m$(_,q){let f={type:"string"};if(_.checks)for(let K of _.checks)switch(K.kind){case"min":jq(f,"minLength",typeof f.minLength==="number"?Math.max(f.minLength,K.value):K.value,K.message,q);break;case"max":jq(f,"maxLength",typeof f.maxLength==="number"?Math.min(f.maxLength,K.value):K.value,K.message,q);break;case"email":switch(q.emailStrategy){case"format:email":k_(f,"email",K.message,q);break;case"format:idn-email":k_(f,"idn-email",K.message,q);break;case"pattern:zod":cq(f,J_.email,K.message,q);break}break;case"url":k_(f,"uri",K.message,q);break;case"uuid":k_(f,"uuid",K.message,q);break;case"regex":cq(f,K.regex,K.message,q);break;case"cuid":cq(f,J_.cuid,K.message,q);break;case"cuid2":cq(f,J_.cuid2,K.message,q);break;case"startsWith":cq(f,RegExp(`^${CP(K.value,q)}`),K.message,q);break;case"endsWith":cq(f,RegExp(`${CP(K.value,q)}$`),K.message,q);break;case"datetime":k_(f,"date-time",K.message,q);break;case"date":k_(f,"date",K.message,q);break;case"time":k_(f,"time",K.message,q);break;case"duration":k_(f,"duration",K.message,q);break;case"length":jq(f,"minLength",typeof f.minLength==="number"?Math.max(f.minLength,K.value):K.value,K.message,q),jq(f,"maxLength",typeof f.maxLength==="number"?Math.min(f.maxLength,K.value):K.value,K.message,q);break;case"includes":{cq(f,RegExp(CP(K.value,q)),K.message,q);break}case"ip":{if(K.version!=="v6")k_(f,"ipv4",K.message,q);if(K.version!=="v4")k_(f,"ipv6",K.message,q);break}case"base64url":cq(f,J_.base64url,K.message,q);break;case"jwt":cq(f,J_.jwt,K.message,q);break;case"cidr":{if(K.version!=="v6")cq(f,J_.ipv4Cidr,K.message,q);if(K.version!=="v4")cq(f,J_.ipv6Cidr,K.message,q);break}case"emoji":cq(f,J_.emoji(),K.message,q);break;case"ulid":{cq(f,J_.ulid,K.message,q);break}case"base64":{switch(q.base64Strategy){case"format:binary":{k_(f,"binary",K.message,q);break}case"contentEncoding:base64":{jq(f,"contentEncoding","base64",K.message,q);break}case"pattern:zod":{cq(f,J_.base64,K.message,q);break}}break}case"nanoid":cq(f,J_.nanoid,K.message,q);case"toLowerCase":case"toUpperCase":case"trim":break;default:(($)=>{})(K)}return f}function CP(_,q){return q.patternStrategy==="escape"?MW(_):_}var VW=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function MW(_){let q="";for(let f=0;f<_.length;f++){if(!VW.has(_[f]))q+="\\";q+=_[f]}return q}function k_(_,q,f,K){if(_.format||_.anyOf?.some(($)=>$.format)){if(!_.anyOf)_.anyOf=[];if(_.format){if(_.anyOf.push({format:_.format,..._.errorMessage&&K.errorMessages&&{errorMessage:{format:_.errorMessage.format}}}),delete _.format,_.errorMessage){if(delete _.errorMessage.format,Object.keys(_.errorMessage).length===0)delete _.errorMessage}}_.anyOf.push({format:q,...f&&K.errorMessages&&{errorMessage:{format:f}}})}else jq(_,"format",q,f,K)}function cq(_,q,f,K){if(_.pattern||_.allOf?.some(($)=>$.pattern)){if(!_.allOf)_.allOf=[];if(_.pattern){if(_.allOf.push({pattern:_.pattern,..._.errorMessage&&K.errorMessages&&{errorMessage:{pattern:_.errorMessage.pattern}}}),delete _.pattern,_.errorMessage){if(delete _.errorMessage.pattern,Object.keys(_.errorMessage).length===0)delete _.errorMessage}}_.allOf.push({pattern:e9(q,K),...f&&K.errorMessages&&{errorMessage:{pattern:f}}})}else jq(_,"pattern",e9(q,K),f,K)}function e9(_,q){if(!q.applyRegexFlags||!_.flags)return _.source;let f={i:_.flags.includes("i"),m:_.flags.includes("m"),s:_.flags.includes("s")},K=f.i?_.source.toLowerCase():_.source,$="",P=!1,j=!1,v=!1;for(let w=0;w<K.length;w++){if(P){$+=K[w],P=!1;continue}if(f.i){if(j){if(K[w].match(/[a-z]/)){if(v)$+=K[w],$+=`${K[w-2]}-${K[w]}`.toUpperCase(),v=!1;else if(K[w+1]==="-"&&K[w+2]?.match(/[a-z]/))$+=K[w],v=!0;else $+=`${K[w]}${K[w].toUpperCase()}`;continue}}else if(K[w].match(/[a-z]/)){$+=`[${K[w]}${K[w].toUpperCase()}]`;continue}}if(f.m){if(K[w]==="^"){$+=`(^|(?<=[\r
@@ -175,7 +175,7 @@ Error: ${K}`)}},gN=()=>{let _;try{_=HO.findProjectRoot()}catch{_=kO(process.cwd(
175
175
  `:`[${K[w]}\r
176
176
  ]`;continue}if($+=K[w],K[w]==="\\")P=!0;else if(j&&K[w]==="]")j=!1;else if(!j&&K[w]==="[")j=!0}try{new RegExp($)}catch{return console.warn(`Could not convert regex pattern at ${q.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),_.source}return $}function r$(_,q){if(q.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(q.target==="openApi3"&&_.keyType?._def.typeName===i.ZodEnum)return{type:"object",required:_.keyType._def.values,properties:_.keyType._def.values.reduce((K,$)=>({...K,[$]:F(_.valueType._def,{...q,currentPath:[...q.currentPath,"properties",$]})??Gq(q)}),{}),additionalProperties:q.rejectedAdditionalProperties};let f={type:"object",additionalProperties:F(_.valueType._def,{...q,currentPath:[...q.currentPath,"additionalProperties"]})??q.allowedAdditionalProperties};if(q.target==="openApi3")return f;if(_.keyType?._def.typeName===i.ZodString&&_.keyType._def.checks?.length){let{type:K,...$}=m$(_.keyType._def,q);return{...f,propertyNames:$}}else if(_.keyType?._def.typeName===i.ZodEnum)return{...f,propertyNames:{enum:_.keyType._def.values}};else if(_.keyType?._def.typeName===i.ZodBranded&&_.keyType._def.type._def.typeName===i.ZodString&&_.keyType._def.type._def.checks?.length){let{type:K,...$}=G$(_.keyType._def,q);return{...f,propertyNames:$}}return f}function x9(_,q){if(q.mapStrategy==="record")return r$(_,q);let f=F(_.keyType._def,{...q,currentPath:[...q.currentPath,"items","items","0"]})||Gq(q),K=F(_.valueType._def,{...q,currentPath:[...q.currentPath,"items","items","1"]})||Gq(q);return{type:"array",maxItems:125,items:{type:"array",items:[f,K],minItems:2,maxItems:2}}}function s9(_){let q=_.values,K=Object.keys(_.values).filter((P)=>{return typeof q[q[P]]!=="number"}).map((P)=>q[P]),$=Array.from(new Set(K.map((P)=>typeof P)));return{type:$.length===1?$[0]==="string"?"string":"number":["string","number"],enum:K}}function B9(_){return _.target==="openAi"?void 0:{not:Gq({..._,currentPath:[..._.currentPath,"not"]})}}function U9(_){return _.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var sf={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Q9(_,q){if(q.target==="openApi3")return F9(_,q);let f=_.options instanceof Map?Array.from(_.options.values()):_.options;if(f.every((K)=>(K._def.typeName in sf)&&(!K._def.checks||!K._def.checks.length))){let K=f.reduce(($,P)=>{let j=sf[P._def.typeName];return j&&!$.includes(j)?[...$,j]:$},[]);return{type:K.length>1?K:K[0]}}else if(f.every((K)=>K._def.typeName==="ZodLiteral"&&!K.description)){let K=f.reduce(($,P)=>{let j=typeof P._def.value;switch(j){case"string":case"number":case"boolean":return[...$,j];case"bigint":return[...$,"integer"];case"object":if(P._def.value===null)return[...$,"null"];case"symbol":case"undefined":case"function":default:return $}},[]);if(K.length===f.length){let $=K.filter((P,j,v)=>v.indexOf(P)===j);return{type:$.length>1?$:$[0],enum:f.reduce((P,j)=>{return P.includes(j._def.value)?P:[...P,j._def.value]},[])}}}else if(f.every((K)=>K._def.typeName==="ZodEnum"))return{type:"string",enum:f.reduce((K,$)=>[...K,...$._def.values.filter((P)=>!K.includes(P))],[])};return F9(_,q)}var F9=(_,q)=>{let f=(_.options instanceof Map?Array.from(_.options.values()):_.options).map((K,$)=>F(K._def,{...q,currentPath:[...q.currentPath,"anyOf",`${$}`]})).filter((K)=>!!K&&(!q.strictUnions||typeof K==="object"&&Object.keys(K).length>0));return f.length?{anyOf:f}:void 0};function qv(_,q){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(_.innerType._def.typeName)&&(!_.innerType._def.checks||!_.innerType._def.checks.length)){if(q.target==="openApi3")return{type:sf[_.innerType._def.typeName],nullable:!0};return{type:[sf[_.innerType._def.typeName],"null"]}}if(q.target==="openApi3"){let K=F(_.innerType._def,{...q,currentPath:[...q.currentPath]});if(K&&"$ref"in K)return{allOf:[K],nullable:!0};return K&&{...K,nullable:!0}}let f=F(_.innerType._def,{...q,currentPath:[...q.currentPath,"anyOf","0"]});return f&&{anyOf:[f,{type:"null"}]}}function _v(_,q){let f={type:"number"};if(!_.checks)return f;for(let K of _.checks)switch(K.kind){case"int":f.type="integer",MP(f,"type",K.message,q);break;case"min":if(q.target==="jsonSchema7")if(K.inclusive)jq(f,"minimum",K.value,K.message,q);else jq(f,"exclusiveMinimum",K.value,K.message,q);else{if(!K.inclusive)f.exclusiveMinimum=!0;jq(f,"minimum",K.value,K.message,q)}break;case"max":if(q.target==="jsonSchema7")if(K.inclusive)jq(f,"maximum",K.value,K.message,q);else jq(f,"exclusiveMaximum",K.value,K.message,q);else{if(!K.inclusive)f.exclusiveMaximum=!0;jq(f,"maximum",K.value,K.message,q)}break;case"multipleOf":jq(f,"multipleOf",K.value,K.message,q);break}return f}function fv(_,q){let f=q.target==="openAi",K={type:"object",properties:{}},$=[],P=_.shape();for(let v in P){let w=P[v];if(w===void 0||w._def===void 0)continue;let O=NW(w);if(O&&f){if(w._def.typeName==="ZodOptional")w=w._def.innerType;if(!w.isNullable())w=w.nullable();O=!1}let T=F(w._def,{...q,currentPath:[...q.currentPath,"properties",v],propertyPath:[...q.currentPath,"properties",v]});if(T===void 0)continue;if(K.properties[v]=T,!O)$.push(v)}if($.length)K.required=$;let j=SW(_,q);if(j!==void 0)K.additionalProperties=j;return K}function SW(_,q){if(_.catchall._def.typeName!=="ZodNever")return F(_.catchall._def,{...q,currentPath:[...q.currentPath,"additionalProperties"]});switch(_.unknownKeys){case"passthrough":return q.allowedAdditionalProperties;case"strict":return q.rejectedAdditionalProperties;case"strip":return q.removeAdditionalStrategy==="strict"?q.allowedAdditionalProperties:q.rejectedAdditionalProperties}}function NW(_){try{return _.isOptional()}catch{return!0}}var $v=(_,q)=>{if(q.currentPath.toString()===q.propertyPath?.toString())return F(_.innerType._def,q);let f=F(_.innerType._def,{...q,currentPath:[...q.currentPath,"anyOf","1"]});return f?{anyOf:[{not:Gq(q)},f]}:Gq(q)};var Kv=(_,q)=>{if(q.pipeStrategy==="input")return F(_.in._def,q);else if(q.pipeStrategy==="output")return F(_.out._def,q);let f=F(_.in._def,{...q,currentPath:[...q.currentPath,"allOf","0"]}),K=F(_.out._def,{...q,currentPath:[...q.currentPath,"allOf",f?"1":"0"]});return{allOf:[f,K].filter(($)=>$!==void 0)}};function Pv(_,q){return F(_.type._def,q)}function jv(_,q){let K={type:"array",uniqueItems:!0,items:F(_.valueType._def,{...q,currentPath:[...q.currentPath,"items"]})};if(_.minSize)jq(K,"minItems",_.minSize.value,_.minSize.message,q);if(_.maxSize)jq(K,"maxItems",_.maxSize.value,_.maxSize.message,q);return K}function vv(_,q){if(_.rest)return{type:"array",minItems:_.items.length,items:_.items.map((f,K)=>F(f._def,{...q,currentPath:[...q.currentPath,"items",`${K}`]})).reduce((f,K)=>K===void 0?f:[...f,K],[]),additionalItems:F(_.rest._def,{...q,currentPath:[...q.currentPath,"additionalItems"]})};else return{type:"array",minItems:_.items.length,maxItems:_.items.length,items:_.items.map((f,K)=>F(f._def,{...q,currentPath:[...q.currentPath,"items",`${K}`]})).reduce((f,K)=>K===void 0?f:[...f,K],[])}}function wv(_){return{not:Gq(_)}}function Ov(_){return Gq(_)}var Yv=(_,q)=>{return F(_.innerType._def,q)};var Tv=(_,q,f)=>{switch(q){case i.ZodString:return m$(_,f);case i.ZodNumber:return _v(_,f);case i.ZodObject:return fv(_,f);case i.ZodBigInt:return I9(_,f);case i.ZodBoolean:return D9();case i.ZodDate:return SP(_,f);case i.ZodUndefined:return wv(f);case i.ZodNull:return U9(f);case i.ZodArray:return a9(_,f);case i.ZodUnion:case i.ZodDiscriminatedUnion:return Q9(_,f);case i.ZodIntersection:return L9(_,f);case i.ZodTuple:return vv(_,f);case i.ZodRecord:return r$(_,f);case i.ZodLiteral:return t9(_,f);case i.ZodEnum:return c9(_);case i.ZodNativeEnum:return s9(_);case i.ZodNullable:return qv(_,f);case i.ZodOptional:return $v(_,f);case i.ZodMap:return x9(_,f);case i.ZodSet:return jv(_,f);case i.ZodLazy:return()=>_.getter()._def;case i.ZodPromise:return Pv(_,f);case i.ZodNaN:case i.ZodNever:return B9(f);case i.ZodEffects:return o9(_,f);case i.ZodAny:return Gq(f);case i.ZodUnknown:return Ov(f);case i.ZodDefault:return i9(_,f);case i.ZodBranded:return G$(_,f);case i.ZodReadonly:return Yv(_,f);case i.ZodCatch:return y9(_,f);case i.ZodPipeline:return Kv(_,f);case i.ZodFunction:case i.ZodVoid:case i.ZodSymbol:return;default:return((K)=>{return})(q)}};function F(_,q,f=!1){let K=q.seen.get(_);if(q.override){let v=q.override?.(_,q,K,f);if(v!==E9)return v}if(K&&!f){let v=CW(K,q);if(v!==void 0)return v}let $={def:_,path:q.currentPath,jsonSchema:void 0};q.seen.set(_,$);let P=Tv(_,_.typeName,q),j=typeof P==="function"?F(P(),q):P;if(j)pW(_,q,j);if(q.postProcess){let v=q.postProcess(j,_,q);return $.jsonSchema=j,v}return $.jsonSchema=j,j}var CW=(_,q)=>{switch(q.$refStrategy){case"root":return{$ref:_.path.join("/")};case"relative":return{$ref:u$(q.currentPath,_.path)};case"none":case"seen":{if(_.path.length<q.currentPath.length&&_.path.every((f,K)=>q.currentPath[K]===f))return console.warn(`Recursive reference detected at ${q.currentPath.join("/")}! Defaulting to any`),Gq(q);return q.$refStrategy==="seen"?Gq(q):void 0}}},pW=(_,q,f)=>{if(_.description){if(f.description=_.description,q.markdownDescription)f.markdownDescription=_.description}return f};var b$=(_,q)=>{let f=d9(q),K=typeof q==="object"&&q.definitions?Object.entries(q.definitions).reduce((w,[O,T])=>({...w,[O]:F(T._def,{...f,currentPath:[...f.basePath,f.definitionPath,O]},!0)??Gq(f)}),{}):void 0,$=typeof q==="string"?q:q?.nameStrategy==="title"?void 0:q?.name,P=F(_._def,$===void 0?f:{...f,currentPath:[...f.basePath,f.definitionPath,$]},!1)??Gq(f),j=typeof q==="object"&&q.name!==void 0&&q.nameStrategy==="title"?q.name:void 0;if(j!==void 0)P.title=j;if(f.flags.hasReferencedOpenAiAnyType){if(!K)K={};if(!K[f.openAiAnyTypeName])K[f.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:f.$refStrategy==="relative"?"1":[...f.basePath,f.definitionPath,f.openAiAnyTypeName].join("/")}}}let v=$===void 0?K?{...P,[f.definitionPath]:K}:P:{$ref:[...f.$refStrategy==="relative"?[]:f.basePath,f.definitionPath,$].join("/"),[f.definitionPath]:{...K,[$]:P}};if(f.target==="jsonSchema7")v.$schema="http://json-schema.org/draft-07/schema#";else if(f.target==="jsonSchema2019-09"||f.target==="openAi")v.$schema="https://json-schema.org/draft/2019-09/schema#";if(f.target==="openAi"&&(("anyOf"in v)||("oneOf"in v)||("allOf"in v)||("type"in v)&&Array.isArray(v.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return v};var pP;(function(_){_.Completable="McpCompletable"})(pP||(pP={}));class Bf extends $q{_parse(_){let{ctx:q}=this._processInputParams(_),f=q.data;return this._def.type._parse({data:f,path:q.path,parent:q})}unwrap(){return this._def.type}}Bf.create=(_,q)=>{return new Bf({type:_,typeName:pP.Completable,complete:q.complete,...lW(q)})};function lW(_){if(!_)return{};let{errorMap:q,invalid_type_error:f,required_error:K,description:$}=_;if(q&&(f||K))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:$};return{errorMap:(j,v)=>{var w,O;let{message:T}=_;if(j.code==="invalid_enum_value")return{message:T!==null&&T!==void 0?T:v.defaultError};if(typeof v.data==="undefined")return{message:(w=T!==null&&T!==void 0?T:K)!==null&&w!==void 0?w:v.defaultError};if(j.code!=="invalid_type")return{message:v.defaultError};return{message:(O=T!==null&&T!==void 0?T:f)!==null&&O!==void 0?O:v.defaultError}},description:$}}class lP{constructor(_,q){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new VP(_,q)}async connect(_){return await this.server.connect(_)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(q$.shape.method.value),this.server.assertCanSetRequestHandler(_$.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(q$,()=>({tools:Object.entries(this._registeredTools).filter(([,_])=>_.enabled).map(([_,q])=>{let f={name:_,title:q.title,description:q.description,inputSchema:q.inputSchema?b$(q.inputSchema,{strictUnions:!0}):nW,annotations:q.annotations,_meta:q._meta};if(q.outputSchema)f.outputSchema=b$(q.outputSchema,{strictUnions:!0});return f})})),this.server.setRequestHandler(_$,async(_,q)=>{let f=this._registeredTools[_.params.name];if(!f)throw new Xq(Zq.InvalidParams,`Tool ${_.params.name} not found`);if(!f.enabled)throw new Xq(Zq.InvalidParams,`Tool ${_.params.name} disabled`);let K;if(f.inputSchema){let $=await f.inputSchema.safeParseAsync(_.params.arguments);if(!$.success)throw new Xq(Zq.InvalidParams,`Invalid arguments for tool ${_.params.name}: ${$.error.message}`);let P=$.data,j=f.callback;try{K=await Promise.resolve(j(P,q))}catch(v){K={content:[{type:"text",text:v instanceof Error?v.message:String(v)}],isError:!0}}}else{let $=f.callback;try{K=await Promise.resolve($(q))}catch(P){K={content:[{type:"text",text:P instanceof Error?P.message:String(P)}],isError:!0}}}if(f.outputSchema&&!K.isError){if(!K.structuredContent)throw new Xq(Zq.InvalidParams,`Tool ${_.params.name} has an output schema but no structured content was provided`);let $=await f.outputSchema.safeParseAsync(K.structuredContent);if(!$.success)throw new Xq(Zq.InvalidParams,`Invalid structured content for tool ${_.params.name}: ${$.error.message}`)}return K}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(f$.shape.method.value),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(f$,async(_)=>{switch(_.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(_,_.params.ref);case"ref/resource":return this.handleResourceCompletion(_,_.params.ref);default:throw new Xq(Zq.InvalidParams,`Invalid completion reference: ${_.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(_,q){let f=this._registeredPrompts[q.name];if(!f)throw new Xq(Zq.InvalidParams,`Prompt ${q.name} not found`);if(!f.enabled)throw new Xq(Zq.InvalidParams,`Prompt ${q.name} disabled`);if(!f.argsSchema)return V$;let K=f.argsSchema.shape[_.params.argument.name];if(!(K instanceof Bf))return V$;let P=await K._def.complete(_.params.argument.value,_.params.context);return Wv(P)}async handleResourceCompletion(_,q){let f=Object.values(this._registeredResourceTemplates).find((P)=>P.resourceTemplate.uriTemplate.toString()===q.uri);if(!f){if(this._registeredResources[q.uri])return V$;throw new Xq(Zq.InvalidParams,`Resource template ${_.params.ref.uri} not found`)}let K=f.resourceTemplate.completeCallback(_.params.argument.name);if(!K)return V$;let $=await K(_.params.argument.value,_.params.context);return Wv($)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(s6.shape.method.value),this.server.assertCanSetRequestHandler(B6.shape.method.value),this.server.assertCanSetRequestHandler(U6.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(s6,async(_,q)=>{let f=Object.entries(this._registeredResources).filter(([$,P])=>P.enabled).map(([$,P])=>({uri:$,name:P.name,...P.metadata})),K=[];for(let $ of Object.values(this._registeredResourceTemplates)){if(!$.resourceTemplate.listCallback)continue;let P=await $.resourceTemplate.listCallback(q);for(let j of P.resources)K.push({...$.metadata,...j})}return{resources:[...f,...K]}}),this.server.setRequestHandler(B6,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([q,f])=>({name:q,uriTemplate:f.resourceTemplate.uriTemplate.toString(),...f.metadata}))}}),this.server.setRequestHandler(U6,async(_,q)=>{let f=new URL(_.params.uri),K=this._registeredResources[f.toString()];if(K){if(!K.enabled)throw new Xq(Zq.InvalidParams,`Resource ${f} disabled`);return K.readCallback(f,q)}for(let $ of Object.values(this._registeredResourceTemplates)){let P=$.resourceTemplate.uriTemplate.match(f.toString());if(P)return $.readCallback(f,P,q)}throw new Xq(Zq.InvalidParams,`Resource ${f} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(F6.shape.method.value),this.server.assertCanSetRequestHandler(Q6.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(F6,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,_])=>_.enabled).map(([_,q])=>{return{name:_,title:q.title,description:q.description,arguments:q.argsSchema?EW(q.argsSchema):void 0}})})),this.server.setRequestHandler(Q6,async(_,q)=>{let f=this._registeredPrompts[_.params.name];if(!f)throw new Xq(Zq.InvalidParams,`Prompt ${_.params.name} not found`);if(!f.enabled)throw new Xq(Zq.InvalidParams,`Prompt ${_.params.name} disabled`);if(f.argsSchema){let K=await f.argsSchema.safeParseAsync(_.params.arguments);if(!K.success)throw new Xq(Zq.InvalidParams,`Invalid arguments for prompt ${_.params.name}: ${K.error.message}`);let $=K.data,P=f.callback;return await Promise.resolve(P($,q))}else{let K=f.callback;return await Promise.resolve(K(q))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource(_,q,...f){let K;if(typeof f[0]==="object")K=f.shift();let $=f[0];if(typeof q==="string"){if(this._registeredResources[q])throw new Error(`Resource ${q} is already registered`);let P=this._createRegisteredResource(_,void 0,q,K,$);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),P}else{if(this._registeredResourceTemplates[_])throw new Error(`Resource template ${_} is already registered`);let P=this._createRegisteredResourceTemplate(_,void 0,q,K,$);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),P}}registerResource(_,q,f,K){if(typeof q==="string"){if(this._registeredResources[q])throw new Error(`Resource ${q} is already registered`);let $=this._createRegisteredResource(_,f.title,q,f,K);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),$}else{if(this._registeredResourceTemplates[_])throw new Error(`Resource template ${_} is already registered`);let $=this._createRegisteredResourceTemplate(_,f.title,q,f,K);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),$}}_createRegisteredResource(_,q,f,K,$){let P={name:_,title:q,metadata:K,readCallback:$,enabled:!0,disable:()=>P.update({enabled:!1}),enable:()=>P.update({enabled:!0}),remove:()=>P.update({uri:null}),update:(j)=>{if(typeof j.uri!=="undefined"&&j.uri!==f){if(delete this._registeredResources[f],j.uri)this._registeredResources[j.uri]=P}if(typeof j.name!=="undefined")P.name=j.name;if(typeof j.title!=="undefined")P.title=j.title;if(typeof j.metadata!=="undefined")P.metadata=j.metadata;if(typeof j.callback!=="undefined")P.readCallback=j.callback;if(typeof j.enabled!=="undefined")P.enabled=j.enabled;this.sendResourceListChanged()}};return this._registeredResources[f]=P,P}_createRegisteredResourceTemplate(_,q,f,K,$){let P={resourceTemplate:f,title:q,metadata:K,readCallback:$,enabled:!0,disable:()=>P.update({enabled:!1}),enable:()=>P.update({enabled:!0}),remove:()=>P.update({name:null}),update:(j)=>{if(typeof j.name!=="undefined"&&j.name!==_){if(delete this._registeredResourceTemplates[_],j.name)this._registeredResourceTemplates[j.name]=P}if(typeof j.title!=="undefined")P.title=j.title;if(typeof j.template!=="undefined")P.resourceTemplate=j.template;if(typeof j.metadata!=="undefined")P.metadata=j.metadata;if(typeof j.callback!=="undefined")P.readCallback=j.callback;if(typeof j.enabled!=="undefined")P.enabled=j.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[_]=P,P}_createRegisteredPrompt(_,q,f,K,$){let P={title:q,description:f,argsSchema:K===void 0?void 0:W.object(K),callback:$,enabled:!0,disable:()=>P.update({enabled:!1}),enable:()=>P.update({enabled:!0}),remove:()=>P.update({name:null}),update:(j)=>{if(typeof j.name!=="undefined"&&j.name!==_){if(delete this._registeredPrompts[_],j.name)this._registeredPrompts[j.name]=P}if(typeof j.title!=="undefined")P.title=j.title;if(typeof j.description!=="undefined")P.description=j.description;if(typeof j.argsSchema!=="undefined")P.argsSchema=W.object(j.argsSchema);if(typeof j.callback!=="undefined")P.callback=j.callback;if(typeof j.enabled!=="undefined")P.enabled=j.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[_]=P,P}_createRegisteredTool(_,q,f,K,$,P,j,v){let w={title:q,description:f,inputSchema:K===void 0?void 0:W.object(K),outputSchema:$===void 0?void 0:W.object($),annotations:P,_meta:j,callback:v,enabled:!0,disable:()=>w.update({enabled:!1}),enable:()=>w.update({enabled:!0}),remove:()=>w.update({name:null}),update:(O)=>{if(typeof O.name!=="undefined"&&O.name!==_){if(delete this._registeredTools[_],O.name)this._registeredTools[O.name]=w}if(typeof O.title!=="undefined")w.title=O.title;if(typeof O.description!=="undefined")w.description=O.description;if(typeof O.paramsSchema!=="undefined")w.inputSchema=W.object(O.paramsSchema);if(typeof O.callback!=="undefined")w.callback=O.callback;if(typeof O.annotations!=="undefined")w.annotations=O.annotations;if(typeof O._meta!=="undefined")w._meta=O._meta;if(typeof O.enabled!=="undefined")w.enabled=O.enabled;this.sendToolListChanged()}};return this._registeredTools[_]=w,this.setToolRequestHandlers(),this.sendToolListChanged(),w}tool(_,...q){if(this._registeredTools[_])throw new Error(`Tool ${_} is already registered`);let f,K,$,P;if(typeof q[0]==="string")f=q.shift();if(q.length>1){let v=q[0];if(zv(v)){if(K=q.shift(),q.length>1&&typeof q[0]==="object"&&q[0]!==null&&!zv(q[0]))P=q.shift()}else if(typeof v==="object"&&v!==null)P=q.shift()}let j=q[0];return this._createRegisteredTool(_,void 0,f,K,$,P,void 0,j)}registerTool(_,q,f){if(this._registeredTools[_])throw new Error(`Tool ${_} is already registered`);let{title:K,description:$,inputSchema:P,outputSchema:j,annotations:v,_meta:w}=q;return this._createRegisteredTool(_,K,$,P,j,v,w,f)}prompt(_,...q){if(this._registeredPrompts[_])throw new Error(`Prompt ${_} is already registered`);let f;if(typeof q[0]==="string")f=q.shift();let K;if(q.length>1)K=q.shift();let $=q[0],P=this._createRegisteredPrompt(_,void 0,f,K,$);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),P}registerPrompt(_,q,f){if(this._registeredPrompts[_])throw new Error(`Prompt ${_} is already registered`);let{title:K,description:$,argsSchema:P}=q,j=this._createRegisteredPrompt(_,K,$,P,f);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),j}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(_,q){return this.server.sendLoggingMessage(_,q)}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var nW={type:"object",properties:{}};function zv(_){if(typeof _!=="object"||_===null)return!1;return Object.keys(_).length===0||Object.values(_).some(RW)}function RW(_){return _!==null&&typeof _==="object"&&"parse"in _&&typeof _.parse==="function"&&"safeParse"in _&&typeof _.safeParse==="function"}function EW(_){return Object.entries(_.shape).map(([q,f])=>({name:q,description:f.description,required:!f.isOptional()}))}function Wv(_){return{completion:{values:_.slice(0,100),total:_.length,hasMore:_.length>100}}}var V$={completion:{values:[],hasMore:!1}};import hv from"process";class nP{append(_){this._buffer=this._buffer?Buffer.concat([this._buffer,_]):_}readMessage(){if(!this._buffer)return null;let _=this._buffer.indexOf(`
177
177
  `);if(_===-1)return null;let q=this._buffer.toString("utf8",0,_).replace(/\r$/,"");return this._buffer=this._buffer.subarray(_+1),gW(q)}clear(){this._buffer=void 0}}function gW(_){return m7.parse(JSON.parse(_))}function Hv(_){return JSON.stringify(_)+`
178
- `}class RP{constructor(_=hv.stdin,q=hv.stdout){this._stdin=_,this._stdout=q,this._readBuffer=new nP,this._started=!1,this._ondata=(f)=>{this._readBuffer.append(f),this.processReadBuffer()},this._onerror=(f)=>{var K;(K=this.onerror)===null||K===void 0||K.call(this,f)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var _,q;while(!0)try{let f=this._readBuffer.readMessage();if(f===null)break;(_=this.onmessage)===null||_===void 0||_.call(this,f)}catch(f){(q=this.onerror)===null||q===void 0||q.call(this,f)}}async close(){var _;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),(_=this.onclose)===null||_===void 0||_.call(this)}send(_){return new Promise((q)=>{let f=Hv(_);if(this._stdout.write(f))q();else this._stdout.once("drain",q)})}}var EP={name:"@kelceyp/swic",version:"0.2.1",description:"Story Workflow Integration Controller - MCP server for managing stories, subtasks, and pipelines",type:"module",main:"dist/server/Server.js",bin:{"swic-mcp":"./dist/server/Server.js",swic:"./dist/cli/cli.js"},files:["dist/","README.md","LICENSE"],scripts:{"build-server":"bun run scripts/server/build-dist.ts","build-cli":"bun run scripts/cli/build-dist.ts",build:"bun run scripts/build-all.ts",prepublishOnly:"bun run build","test:e2e":"bash tests/e2e/run-e2e-tests.sh","test:e2e:build":"bash tests/e2e/build-test-image.sh","test:e2e:rebuild":"bash tests/e2e/build-test-image.sh && bash tests/e2e/run-e2e-tests.sh",lint:"eslint src scripts archive --ext .ts","lint:fix":"eslint src scripts archive --ext .ts --fix"},dependencies:{"@kelceyp/clibuilder":"^0.2.0","@modelcontextprotocol/sdk":"^1.0.0","@types/handlebars":"^4.0.40","@types/yaml":"^1.9.6",debug:"^4.4.3",handlebars:"^4.7.8",yaml:"^2.8.1"},devDependencies:{"@types/bun":"latest","@types/debug":"^4.1.12","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^8.46.2","@typescript-eslint/parser":"^8.46.2",esbuild:"^0.25.11",eslint:"8",typescript:"^5.0.0"},engines:{bun:">=1.0.0"},repository:{type:"git",url:"https://github.com/kelceyp/swic.git"},author:"Paul Kelcey",license:"MIT",keywords:["mcp","model-context-protocol","workflow","story-management","pipeline-orchestration","development-workflow","sdlc"]};var aW=(_)=>{let q={name:"doc_create",description:"Create a new doc with content. Returns the created doc ID.",inputSchema:{scope:W.enum(["project","shared"]).describe("Scope for the doc (project or shared)"),path:W.string().describe('Path for the doc (e.g., "auth/jwt-setup.md")'),content:W.string().describe("Content of the doc")}};return Object.freeze({definition:q,handler:async(K)=>{let{scope:$,path:P,content:j}=K,v=await _.DocService.create({address:{kind:"path",scope:$,path:P},content:j});return{content:[{type:"text",text:`Created doc: ${v.id} at ${v.path}`}]}}})},IW=Object.freeze({create:aW}),Jv=IW;var M$=(_)=>{let q;if(typeof _==="string")q=[_];else if(Array.isArray(_)){if(_.length===0)throw new Error("identifier array cannot be empty");q=_}else throw new Error("identifier must be a string or array of strings");for(let $ of q)if(typeof $!=="string"||$.trim().length===0)throw new Error("All identifiers must be non-empty strings");let f=q.map(($)=>$.trim()),K=[...new Set(f)];if(K.length===0)throw new Error("No valid identifiers provided");return K};wf();var LW=(_)=>{let q={name:"doc_delete",description:"Delete one or more docs. Idempotent - does not error if doc already deleted. Supports bulk operations by passing an array of identifiers.",inputSchema:{identifier:W.union([W.string().describe('Single doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),W.array(W.string()).describe("Array of doc IDs or paths for bulk delete")]).describe("doc identifier(s) - ID or path, single or array"),scope:W.enum(["project","shared"]).optional().describe("Optional scope. Auto-resolves if omitted (checks project first, then shared, or infers from ID prefix)")}};return Object.freeze({definition:q,handler:async(K)=>{let{identifier:$,scope:P}=K,j=M$($),v=await Promise.all(j.map(async(z)=>{let h=sq.isdocId(z)?{kind:"id",scope:P,id:z}:{kind:"path",scope:P,path:z},J=await _.DocService.read(h);return{identifier:z,address:h,doc:J}})),w=[];for(let z of v){let H=await _.DocService.deleteLatest(z.address);w.push({id:z.doc.id,deleted:H.deleted})}let O=w.filter((z)=>z.deleted),T=w.length-O.length,Y={deleted:O.map((z)=>z.id),alreadyDeleted:w.filter((z)=>!z.deleted).map((z)=>z.id),message:`Deleted ${O.length} doc${O.length!==1?"s":""}`+(T>0?`, ${T} ${T!==1?"were":"was"} already deleted`:"")};return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}})},tW=Object.freeze({create:LW}),Zv=tW;wf();var eW=(_)=>{let q={name:"doc_edit",description:"Edit doc content using text replacement operations. Uses last-write-wins semantics.",inputSchema:{identifier:W.string().describe('doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),scope:W.enum(["project","shared"]).optional().describe("Optional scope. Auto-resolves if omitted (checks project first, then shared, or infers from ID prefix)"),operation:W.discriminatedUnion("type",[W.object({type:W.literal("replaceOnce"),oldText:W.string(),newText:W.string()}),W.object({type:W.literal("replaceAll"),oldText:W.string(),newText:W.string()}),W.object({type:W.literal("replaceRegex"),pattern:W.string(),flags:W.string().optional(),replacement:W.string()}),W.object({type:W.literal("replaceAllContent"),content:W.string()})]).describe("Edit operation to perform")}};return Object.freeze({definition:q,handler:async(K)=>{let{identifier:$,scope:P,operation:j}=K,v;switch(j.type){case"replaceOnce":v={op:"replaceOnce",oldText:j.oldText,newText:j.newText};break;case"replaceAll":v={op:"replaceAll",oldText:j.oldText,newText:j.newText};break;case"replaceRegex":v={op:"replaceRegex",pattern:j.pattern,flags:j.flags||"",replacement:j.replacement};break;case"replaceAllContent":v={op:"replaceAllContent",content:j.content};break;default:throw new Error(`Unknown operation type: ${j.type}`)}let O=sq.isdocId($)?{kind:"id",scope:P,id:$}:{kind:"path",scope:P,path:$},T=await _.DocService.editLatest(O,[v]);return{content:[{type:"text",text:`Edited doc: ${$}
178
+ `}class RP{constructor(_=hv.stdin,q=hv.stdout){this._stdin=_,this._stdout=q,this._readBuffer=new nP,this._started=!1,this._ondata=(f)=>{this._readBuffer.append(f),this.processReadBuffer()},this._onerror=(f)=>{var K;(K=this.onerror)===null||K===void 0||K.call(this,f)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var _,q;while(!0)try{let f=this._readBuffer.readMessage();if(f===null)break;(_=this.onmessage)===null||_===void 0||_.call(this,f)}catch(f){(q=this.onerror)===null||q===void 0||q.call(this,f)}}async close(){var _;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),(_=this.onclose)===null||_===void 0||_.call(this)}send(_){return new Promise((q)=>{let f=Hv(_);if(this._stdout.write(f))q();else this._stdout.once("drain",q)})}}var EP={name:"@kelceyp/swic",version:"0.2.3",description:"Story Workflow Integration Controller - MCP server for managing stories, subtasks, and pipelines",type:"module",main:"dist/server/Server.js",bin:{"swic-mcp":"./dist/server/Server.js",swic:"./dist/cli/cli.js"},files:["dist/","README.md","LICENSE"],scripts:{"build-server":"bun run scripts/server/build-dist.ts","build-cli":"bun run scripts/cli/build-dist.ts",build:"bun run scripts/build-all.ts",prepublishOnly:"bun run build","test:e2e":"bash tests/e2e/run-e2e-tests.sh","test:e2e:build":"bash tests/e2e/build-test-image.sh","test:e2e:rebuild":"bash tests/e2e/build-test-image.sh && bash tests/e2e/run-e2e-tests.sh",lint:"eslint src scripts archive --ext .ts","lint:fix":"eslint src scripts archive --ext .ts --fix"},dependencies:{"@kelceyp/clibuilder":"^0.2.1","@modelcontextprotocol/sdk":"^1.0.0","@types/handlebars":"^4.0.40","@types/yaml":"^1.9.6",debug:"^4.4.3",handlebars:"^4.7.8",yaml:"^2.8.1"},devDependencies:{"@types/bun":"latest","@types/debug":"^4.1.12","@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^8.46.2","@typescript-eslint/parser":"^8.46.2",esbuild:"^0.25.11",eslint:"8",typescript:"^5.0.0"},engines:{bun:">=1.0.0"},repository:{type:"git",url:"https://github.com/kelceyp/swic.git"},author:"Paul Kelcey",license:"MIT",keywords:["mcp","model-context-protocol","workflow","story-management","pipeline-orchestration","development-workflow","sdlc"]};var aW=(_)=>{let q={name:"doc_create",description:"Create a new doc with content. Returns the created doc ID.",inputSchema:{scope:W.enum(["project","shared"]).describe("Scope for the doc (project or shared)"),path:W.string().describe('Path for the doc (e.g., "auth/jwt-setup.md")'),content:W.string().describe("Content of the doc")}};return Object.freeze({definition:q,handler:async(K)=>{let{scope:$,path:P,content:j}=K,v=await _.DocService.create({address:{kind:"path",scope:$,path:P},content:j});return{content:[{type:"text",text:`Created doc: ${v.id} at ${v.path}`}]}}})},IW=Object.freeze({create:aW}),Jv=IW;var M$=(_)=>{let q;if(typeof _==="string")q=[_];else if(Array.isArray(_)){if(_.length===0)throw new Error("identifier array cannot be empty");q=_}else throw new Error("identifier must be a string or array of strings");for(let $ of q)if(typeof $!=="string"||$.trim().length===0)throw new Error("All identifiers must be non-empty strings");let f=q.map(($)=>$.trim()),K=[...new Set(f)];if(K.length===0)throw new Error("No valid identifiers provided");return K};wf();var LW=(_)=>{let q={name:"doc_delete",description:"Delete one or more docs. Idempotent - does not error if doc already deleted. Supports bulk operations by passing an array of identifiers.",inputSchema:{identifier:W.union([W.string().describe('Single doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),W.array(W.string()).describe("Array of doc IDs or paths for bulk delete")]).describe("doc identifier(s) - ID or path, single or array"),scope:W.enum(["project","shared"]).optional().describe("Optional scope. Auto-resolves if omitted (checks project first, then shared, or infers from ID prefix)")}};return Object.freeze({definition:q,handler:async(K)=>{let{identifier:$,scope:P}=K,j=M$($),v=await Promise.all(j.map(async(z)=>{let h=sq.isdocId(z)?{kind:"id",scope:P,id:z}:{kind:"path",scope:P,path:z},J=await _.DocService.read(h);return{identifier:z,address:h,doc:J}})),w=[];for(let z of v){let H=await _.DocService.deleteLatest(z.address);w.push({id:z.doc.id,deleted:H.deleted})}let O=w.filter((z)=>z.deleted),T=w.length-O.length,Y={deleted:O.map((z)=>z.id),alreadyDeleted:w.filter((z)=>!z.deleted).map((z)=>z.id),message:`Deleted ${O.length} doc${O.length!==1?"s":""}`+(T>0?`, ${T} ${T!==1?"were":"was"} already deleted`:"")};return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}})},tW=Object.freeze({create:LW}),Zv=tW;wf();var eW=(_)=>{let q={name:"doc_edit",description:"Edit doc content using text replacement operations. Uses last-write-wins semantics.",inputSchema:{identifier:W.string().describe('doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),scope:W.enum(["project","shared"]).optional().describe("Optional scope. Auto-resolves if omitted (checks project first, then shared, or infers from ID prefix)"),operation:W.discriminatedUnion("type",[W.object({type:W.literal("replaceOnce"),oldText:W.string(),newText:W.string()}),W.object({type:W.literal("replaceAll"),oldText:W.string(),newText:W.string()}),W.object({type:W.literal("replaceRegex"),pattern:W.string(),flags:W.string().optional(),replacement:W.string()}),W.object({type:W.literal("replaceAllContent"),content:W.string()})]).describe("Edit operation to perform")}};return Object.freeze({definition:q,handler:async(K)=>{let{identifier:$,scope:P,operation:j}=K,v;switch(j.type){case"replaceOnce":v={op:"replaceOnce",oldText:j.oldText,newText:j.newText};break;case"replaceAll":v={op:"replaceAll",oldText:j.oldText,newText:j.newText};break;case"replaceRegex":v={op:"replaceRegex",pattern:j.pattern,flags:j.flags||"",replacement:j.replacement};break;case"replaceAllContent":v={op:"replaceAllContent",content:j.content};break;default:throw new Error(`Unknown operation type: ${j.type}`)}let O=sq.isdocId($)?{kind:"id",scope:P,id:$}:{kind:"path",scope:P,path:$},T=await _.DocService.editLatest(O,[v]);return{content:[{type:"text",text:`Edited doc: ${$}
179
179
  Applied: ${T.applied} edit operation(s)`}]}}})},xW=Object.freeze({create:eW}),Xv=xW;var sW=(_)=>{let q={name:"doc_list",description:"List docs with optional filtering. Returns structured JSON with doc metadata. When no scope specified, lists from both scopes with override detection.",inputSchema:{scope:W.enum(["project","shared"]).optional().describe("Optional scope filter. If omitted, lists from both scopes and detects overrides (project docs that shadow shared ones)"),pathPrefix:W.string().optional().describe('Optional path prefix filter (e.g., "auth/" to list only docs in auth namespace)'),includeContent:W.boolean().optional().default(!1).describe("Include synopsis from front matter in results")}};return Object.freeze({definition:q,handler:async(K)=>{let{scope:$,pathPrefix:P,includeContent:j}=K,v=await _.DocService.list({scope:$,pathPrefix:P,includeContent:j===!0}),w;if(!$){let T=v.filter((h)=>h.id.startsWith("doc")),Y=v.filter((h)=>h.id.startsWith("sdoc")),z=new Set(T.map((h)=>h.path)),H=new Set(Y.map((h)=>h.path));w=v.map((h)=>{let J=h.id.startsWith("doc"),k;if(J&&H.has(h.path))k="overrides";else if(!J&&z.has(h.path))k="overridden";return{id:h.id,path:h.path,scope:J?"project":"shared",override:k,synopsis:h.synopsis,modifiedAt:h.modifiedAt}})}else w=v.map((T)=>({id:T.id,path:T.path,scope:T.id.startsWith("doc")?"project":"shared",synopsis:T.synopsis,modifiedAt:T.modifiedAt}));w.sort((T,Y)=>T.path.localeCompare(Y.path));let O={docs:w,count:w.length};return{content:[{type:"text",text:JSON.stringify(O,null,2)}]}}})},BW=Object.freeze({create:sW}),Av=BW;wf();var UW=(_)=>{let q={name:"doc_move",description:"Move or rename a doc to a new path. Generates a new ID. Supports cross-scope moves.",inputSchema:{source:W.string().describe('Source doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),destination:W.string().describe("Destination path (not ID) for the doc"),sourceScope:W.enum(["project","shared"]).optional().describe("Optional. Source scope. Auto-resolves if omitted."),destinationScope:W.enum(["project","shared"]).optional().describe("Optional. Destination scope. Defaults to source scope if omitted.")}};return Object.freeze({definition:q,handler:async(K)=>{let{source:$,destination:P,sourceScope:j,destinationScope:v}=K,O=sq.isdocId($)?{kind:"id",scope:j,id:$}:{kind:"path",scope:j,path:$},T=await _.DocService.read(O),Y=T.id.startsWith("sdoc")?"shared":"project",z=v||Y,H=Y!==z;if(T.path===P&&Y===z)throw new Error("Source and destination are identical");try{throw await _.DocService.read({kind:"path",scope:z,path:P}),new Error(`Destination already exists: ${z} ${P}`)}catch(k){if(!(k.message.includes("No doc")||k.message.includes("not found")||k.message.includes("File or directory")))throw k}let h=await _.DocService.create({address:{kind:"path",path:P,scope:z},content:T.content});await _.DocService.deleteLatest(O,T.hash);let J={oldId:T.id,newId:h.id,oldPath:T.path,newPath:P,oldScope:Y,newScope:z,message:H?`Moved doc across scopes from ${Y} ${T.path} (${T.id}) to ${z} ${P} (new ID: ${h.id})`:`Moved doc from ${T.path} (${T.id}) to ${P} (new ID: ${h.id})`};return{content:[{type:"text",text:JSON.stringify(J,null,2)}]}}})},FW=Object.freeze({create:UW}),uv=FW;wf();var QW=(_)=>{let q={name:"doc_read",description:"Read one or more docs by ID or path. Returns content with optional metadata. Supports bulk operations by passing an array of identifiers.",inputSchema:{identifier:W.union([W.string().describe('Single doc ID (e.g., "doc001") or path (e.g., "auth/jwt-setup.md")'),W.array(W.string()).describe("Array of doc IDs or paths for bulk read")]).describe("doc identifier(s) - ID or path, single or array"),scope:W.enum(["project","shared"]).optional().describe("Optional scope. If omitted, auto-resolves (checks project first, then shared, or infers from ID prefix)"),includeMetadata:W.boolean().optional().default(!1).describe("Include ID and path metadata header for each doc")}};return Object.freeze({definition:q,handler:async(K)=>{let{identifier:$,scope:P,includeMetadata:j}=K,v=M$($),w=await Promise.all(v.map(async(Y)=>{let z=sq.isdocId(Y);return await _.DocService.read(z?{kind:"id",scope:P,id:Y}:{kind:"path",scope:P,path:Y})})),O=[];for(let Y=0;Y<w.length;Y++){let z=w[Y];if(j)O.push(`ID: ${z.id}`),O.push(`Path: ${z.path}`),O.push("---");let H=z.content;if(!H.endsWith(`
180
180
  `))H+=`
181
181
  `;if(O.push(H),Y<w.length-1)O.push("")}return{content:[{type:"text",text:O.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kelceyp/swic",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Story Workflow Integration Controller - MCP server for managing stories, subtasks, and pipelines",
5
5
  "type": "module",
6
6
  "main": "dist/server/Server.js",
@@ -25,7 +25,7 @@
25
25
  "lint:fix": "eslint src scripts archive --ext .ts --fix"
26
26
  },
27
27
  "dependencies": {
28
- "@kelceyp/clibuilder": "^0.2.0",
28
+ "@kelceyp/clibuilder": "^0.2.1",
29
29
  "@modelcontextprotocol/sdk": "^1.0.0",
30
30
  "@types/handlebars": "^4.0.40",
31
31
  "@types/yaml": "^1.9.6",