@typescape-ai/mcp 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.js +1 -1
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var Q4=Object.create;var{getPrototypeOf:X4,defineProperty:U0,getOwnPropertyNames:Y4}=Object;var W4=Object.prototype.hasOwnProperty;var J4=($,Q,X)=>{X=$!=null?Q4(X4($)):{};let W=Q||!$||!$.__esModule?U0(X,"default",{value:$,enumerable:!0}):X;for(let Y of Y4($))if(!W4.call(W,Y))U0(W,Y,{get:()=>$[Y],enumerable:!0});return W};var G4=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var p0=G4((J8,H6)=>{H6.exports={name:"@typescape-ai/mcp",version:"1.1.1",description:"Typescape MCP Server - Model Context Protocol integration for AI agents",type:"module",bin:{"typescape-mcp":"./dist/mcp.js"},files:["dist","README.md"],exports:{".":"./dist/mcp.js"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --outfile=dist/mcp.js --target=bun --bundle --minify",dev:"bun run --watch src/index.ts",test:"bun test",typecheck:"tsc --noEmit",lint:"eslint src",prepublishOnly:"bun run build"},dependencies:{},devDependencies:{"@modelcontextprotocol/sdk":"1.0.4","@types/bun":"1.1.14","@typescape/schemas":"workspace:*",zod:"4.3.0"},engines:{bun:">=1.0.0"},keywords:["typescape","mcp","model-context-protocol","ai","claude","review","bun"],repository:{type:"git",url:"https://github.com/voidserf/typescape-docs.git",directory:"apps/mcp"},license:"MIT"}});function F0(){let $=new Map;return{register(Q,X){$.set(Q.name,{definition:Q,handler:X})},getTools(){return Array.from($.values()).map((Q)=>Q.definition)},getHandler(Q){return $.get(Q)?.handler}}}class M extends Error{status;code;requestId;details;fixHint;constructor($,Q,X,W,Y,H){super(X);this.status=$;this.code=Q;this.requestId=W;this.details=Y;this.fixHint=H;this.name="ApiError"}}function D0($,Q){let W=$.replace(/\/$/,"");async function Y(H,z,q={}){let O=`${W}/v1${z}`;if(q.query&&Object.keys(q.query).length>0){let k=new URLSearchParams(q.query);O+=`?${k.toString()}`}let N={Authorization:`Bearer ${Q}`,Accept:"application/json",...q.headers};if(q.body!==void 0)N["Content-Type"]="application/json";let b;try{b=await fetch(O,{method:H,headers:N,body:q.body!==void 0?JSON.stringify(q.body):void 0})}catch(k){let P=k instanceof Error?k.message:String(k);throw new M(0,"network_error",`Network error: ${P}`,"unknown")}let I;if((b.headers.get("Content-Type")||"").includes("application/json"))try{I=await b.json()}catch{I={}}else I={};let m=I?.request_id||b.headers.get("X-Request-Id")||"unknown";if(!b.ok){let k=I,P=k.error?.code||"api_error",g=k.error?.message||`API request failed with status ${b.status}`;throw new M(b.status,P,g,m,k.error?.details,k.error?.fix_hint)}return{status:b.status,body:I,requestId:m}}return{async get(H,z){return Y("GET",H,z)},async post(H,z){return Y("POST",H,z)},request:Y}}var R;(function($){$.assertEqual=(Y)=>Y;function Q(Y){}$.assertIs=Q;function X(Y){throw Error()}$.assertNever=X,$.arrayToEnum=(Y)=>{let H={};for(let z of Y)H[z]=z;return H},$.getValidEnumValues=(Y)=>{let H=$.objectKeys(Y).filter((q)=>typeof Y[Y[q]]!=="number"),z={};for(let q of H)z[q]=Y[q];return $.objectValues(z)},$.objectValues=(Y)=>{return $.objectKeys(Y).map(function(H){return Y[H]})},$.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let H=[];for(let z in Y)if(Object.prototype.hasOwnProperty.call(Y,z))H.push(z);return H},$.find=(Y,H)=>{for(let z of Y)if(H(z))return z;return},$.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&isFinite(Y)&&Math.floor(Y)===Y;function W(Y,H=" | "){return Y.map((z)=>typeof z==="string"?`'${z}'`:z).join(H)}$.joinValues=W,$.jsonStringifyReplacer=(Y,H)=>{if(typeof H==="bigint")return H.toString();return H}})(R||(R={}));var Q0;(function($){$.mergeShapes=(Q,X)=>{return{...Q,...X}}})(Q0||(Q0={}));var F=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=($)=>{switch(typeof $){case"undefined":return F.undefined;case"string":return F.string;case"number":return isNaN($)?F.nan:F.number;case"boolean":return F.boolean;case"function":return F.function;case"bigint":return F.bigint;case"symbol":return F.symbol;case"object":if(Array.isArray($))return F.array;if($===null)return F.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return F.promise;if(typeof Map<"u"&&$ instanceof Map)return F.map;if(typeof Set<"u"&&$ instanceof Set)return F.set;if(typeof Date<"u"&&$ instanceof Date)return F.date;return F.object;default:return F.unknown}},j=R.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"]),H4=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class x extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};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(Y){return Y.message},X={_errors:[]},W=(Y)=>{for(let H of Y.issues)if(H.code==="invalid_union")H.unionErrors.map(W);else if(H.code==="invalid_return_type")W(H.returnTypeError);else if(H.code==="invalid_arguments")W(H.argumentsError);else if(H.path.length===0)X._errors.push(Q(H));else{let z=X,q=0;while(q<H.path.length){let O=H.path[q];if(q!==H.path.length-1)z[O]=z[O]||{_errors:[]};else z[O]=z[O]||{_errors:[]},z[O]._errors.push(Q(H));z=z[O],q++}}};return W(this),X}static assert($){if(!($ instanceof x))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(Q)=>Q.message){let Q={},X=[];for(let W of this.issues)if(W.path.length>0)Q[W.path[0]]=Q[W.path[0]]||[],Q[W.path[0]].push($(W));else X.push($(W));return{formErrors:X,fieldErrors:Q}}get formErrors(){return this.flatten()}}x.create=($)=>{return new x($)};var V1=($,Q)=>{let X;switch($.code){case j.invalid_type:if($.received===F.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case j.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,R.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:X=`Unrecognized key(s) in object: ${R.joinValues($.keys,", ")}`;break;case j.invalid_union:X="Invalid input";break;case j.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${R.joinValues($.options)}`;break;case j.invalid_enum_value:X=`Invalid enum value. Expected ${R.joinValues($.options)}, received '${$.received}'`;break;case j.invalid_arguments:X="Invalid function arguments";break;case j.invalid_return_type:X="Invalid function return type";break;case j.invalid_date:X="Invalid date";break;case j.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else R.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case j.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case j.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case j.custom:X="Invalid input";break;case j.invalid_intersection_types:X="Intersection results could not be merged";break;case j.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case j.not_finite:X="Number must be finite";break;default:X=Q.defaultError,R.assertNever($)}return{message:X}},S0=V1;function z4($){S0=$}function Z1(){return S0}var y1=($)=>{let{data:Q,path:X,errorMaps:W,issueData:Y}=$,H=[...X,...Y.path||[]],z={...Y,path:H};if(Y.message!==void 0)return{...Y,path:H,message:Y.message};let q="",O=W.filter((N)=>!!N).slice().reverse();for(let N of O)q=N(z,{data:Q,defaultError:q}).message;return{...Y,path:H,message:q}},B4=[];function U($,Q){let X=Z1(),W=y1({issueData:Q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===V1?void 0:V1].filter((Y)=>!!Y)});$.common.issues.push(W)}class h{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,Q){let X=[];for(let W of Q){if(W.status==="aborted")return _;if(W.status==="dirty")$.dirty();X.push(W.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,Q){let X=[];for(let W of Q){let Y=await W.key,H=await W.value;X.push({key:Y,value:H})}return h.mergeObjectSync($,X)}static mergeObjectSync($,Q){let X={};for(let W of Q){let{key:Y,value:H}=W;if(Y.status==="aborted")return _;if(H.status==="aborted")return _;if(Y.status==="dirty")$.dirty();if(H.status==="dirty")$.dirty();if(Y.value!=="__proto__"&&(typeof H.value<"u"||W.alwaysSet))X[Y.value]=H.value}return{status:$.value,value:X}}}var _=Object.freeze({status:"aborted"}),j1=($)=>({status:"dirty",value:$}),T=($)=>({status:"valid",value:$}),X0=($)=>$.status==="aborted",Y0=($)=>$.status==="dirty",J1=($)=>$.status==="valid",k1=($)=>typeof Promise<"u"&&$ instanceof Promise;function m1($,Q,X,W){if(X==="a"&&!W)throw TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!W:!Q.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?W:X==="a"?W.call($):W?W.value:Q.get($)}function _0($,Q,X,W,Y){if(W==="m")throw TypeError("Private method is not writable");if(W==="a"&&!Y)throw TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?Y.call($,X):Y?Y.value=X:Q.set($,X),X}var K;(function($){$.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},$.toString=(Q)=>typeof Q==="string"?Q:Q===null||Q===void 0?void 0:Q.message})(K||(K={}));var R1,f1;class n{constructor($,Q,X,W){this._cachedPath=[],this.parent=$,this.data=Q,this._path=X,this._key=W}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var K0=($,Q)=>{if(J1(Q))return{success:!0,data:Q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new x($.common.issues);return this._error=X,this._error}}}};function v($){if(!$)return{};let{errorMap:Q,invalid_type_error:X,required_error:W,description:Y}=$;if(Q&&(X||W))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:Y};return{errorMap:(z,q)=>{var O,N;let{message:b}=$;if(z.code==="invalid_enum_value")return{message:b!==null&&b!==void 0?b:q.defaultError};if(typeof q.data>"u")return{message:(O=b!==null&&b!==void 0?b:W)!==null&&O!==void 0?O:q.defaultError};if(z.code!=="invalid_type")return{message:q.defaultError};return{message:(N=b!==null&&b!==void 0?b:X)!==null&&N!==void 0?N:q.defaultError}},description:Y}}class A{get description(){return this._def.description}_getType($){return r($.data)}_getOrReturnCtx($,Q){return Q||{common:$.parent.common,data:$.data,parsedType:r($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new h,ctx:{common:$.parent.common,data:$.data,parsedType:r($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let Q=this._parse($);if(k1(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync($){let Q=this._parse($);return Promise.resolve(Q)}parse($,Q){let X=this.safeParse($,Q);if(X.success)return X.data;throw X.error}safeParse($,Q){var X;let W={common:{issues:[],async:(X=Q===null||Q===void 0?void 0:Q.async)!==null&&X!==void 0?X:!1,contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)},Y=this._parseSync({data:$,path:W.path,parent:W});return K0(W,Y)}"~validate"($){var Q,X;let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)};if(!this["~standard"].async)try{let Y=this._parseSync({data:$,path:[],parent:W});return J1(Y)?{value:Y.value}:{issues:W.common.issues}}catch(Y){if((X=(Q=Y===null||Y===void 0?void 0:Y.message)===null||Q===void 0?void 0:Q.toLowerCase())===null||X===void 0?void 0:X.includes("encountered"))this["~standard"].async=!0;W.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:W}).then((Y)=>J1(Y)?{value:Y.value}:{issues:W.common.issues})}async parseAsync($,Q){let X=await this.safeParseAsync($,Q);if(X.success)return X.data;throw X.error}async safeParseAsync($,Q){let X={common:{issues:[],contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap,async:!0},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)},W=this._parse({data:$,path:X.path,parent:X}),Y=await(k1(W)?W:Promise.resolve(W));return K0(X,Y)}refine($,Q){let X=(W)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(W);else return Q};return this._refinement((W,Y)=>{let H=$(W),z=()=>Y.addIssue({code:j.custom,...X(W)});if(typeof Promise<"u"&&H instanceof Promise)return H.then((q)=>{if(!q)return z(),!1;else return!0});if(!H)return z(),!1;else return!0})}refinement($,Q){return this._refinement((X,W)=>{if(!$(X))return W.addIssue(typeof Q==="function"?Q(X,W):Q),!1;else return!0})}_refinement($){return new y({schema:this,typeName:S.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 u.create(this,this._def)}nullable(){return e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return c.create(this)}promise(){return B1.create(this,this._def)}or($){return D1.create([this,$],this._def)}and($){return K1.create(this,$,this._def)}transform($){return new y({...v(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let Q=typeof $==="function"?$:()=>$;return new v1({...v(this._def),innerType:this,defaultValue:Q,typeName:S.ZodDefault})}brand(){return new c1({typeName:S.ZodBranded,type:this,...v(this._def)})}catch($){let Q=typeof $==="function"?$:()=>$;return new A1({...v(this._def),innerType:this,catchValue:Q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return h1.create(this,$)}readonly(){return b1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var w4=/^c[^\s-]{8,}$/i,q4=/^[0-9a-z]+$/,M4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j4=/^[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,O4=/^[a-z0-9_-]{21}$/i,V4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L4=/^[-+]?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)?)??$/,U4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",$0,D4=/^(?:(?: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])$/,K4=/^(?:(?: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])$/,N4=/^(([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]))$/,S4=/^(([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])$/,_4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,v4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,v0="((\\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])))",A4=new RegExp(`^${v0}$`);function A0($){let Q="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)Q=`${Q}\\.\\d{${$.precision}}`;else if($.precision==null)Q=`${Q}(\\.\\d+)?`;return Q}function b4($){return new RegExp(`^${A0($)}$`)}function b0($){let Q=`${v0}T${A0($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${X.join("|")})`,new RegExp(`^${Q}$`)}function R4($,Q){if((Q==="v4"||!Q)&&D4.test($))return!0;if((Q==="v6"||!Q)&&N4.test($))return!0;return!1}function f4($,Q){if(!V4.test($))return!1;try{let[X]=$.split("."),W=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Y=JSON.parse(atob(W));if(typeof Y!=="object"||Y===null)return!1;if(!Y.typ||!Y.alg)return!1;if(Q&&Y.alg!==Q)return!1;return!0}catch(X){return!1}}function k4($,Q){if((Q==="v4"||!Q)&&K4.test($))return!0;if((Q==="v6"||!Q)&&S4.test($))return!0;return!1}class l extends A{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==F.string){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.string,received:Y.parsedType}),_}let X=new h,W=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.length<Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="max"){if($.data.length>Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="length"){let H=$.data.length>Y.value,z=$.data.length<Y.value;if(H||z){if(W=this._getOrReturnCtx($,W),H)U(W,{code:j.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});else if(z)U(W,{code:j.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});X.dirty()}}else if(Y.kind==="email"){if(!U4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"email",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="emoji"){if(!$0)$0=new RegExp(F4,"u");if(!$0.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"emoji",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="uuid"){if(!j4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"uuid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="nanoid"){if(!O4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"nanoid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid"){if(!w4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid2"){if(!q4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid2",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ulid"){if(!M4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"ulid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="url")try{new URL($.data)}catch(H){W=this._getOrReturnCtx($,W),U(W,{validation:"url",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="regex"){if(Y.regex.lastIndex=0,!Y.regex.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"regex",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="trim")$.data=$.data.trim();else if(Y.kind==="includes"){if(!$.data.includes(Y.value,Y.position))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{includes:Y.value,position:Y.position},message:Y.message}),X.dirty()}else if(Y.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Y.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Y.kind==="startsWith"){if(!$.data.startsWith(Y.value))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{startsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="endsWith"){if(!$.data.endsWith(Y.value))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{endsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="datetime"){if(!b0(Y).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"datetime",message:Y.message}),X.dirty()}else if(Y.kind==="date"){if(!A4.test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"date",message:Y.message}),X.dirty()}else if(Y.kind==="time"){if(!b4(Y).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"time",message:Y.message}),X.dirty()}else if(Y.kind==="duration"){if(!L4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"duration",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ip"){if(!R4($.data,Y.version))W=this._getOrReturnCtx($,W),U(W,{validation:"ip",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="jwt"){if(!f4($.data,Y.alg))W=this._getOrReturnCtx($,W),U(W,{validation:"jwt",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cidr"){if(!k4($.data,Y.version))W=this._getOrReturnCtx($,W),U(W,{validation:"cidr",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64"){if(!_4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64url"){if(!v4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64url",code:j.invalid_string,message:Y.message}),X.dirty()}else R.assertNever(Y);return{status:X.value,value:$.data}}_regex($,Q,X){return this.refinement((W)=>$.test(W),{validation:Q,code:j.invalid_string,...K.errToObj(X)})}_addCheck($){return new l({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...K.errToObj($)})}url($){return this._addCheck({kind:"url",...K.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...K.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...K.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...K.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...K.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...K.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...K.errToObj($)})}base64($){return this._addCheck({kind:"base64",...K.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...K.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...K.errToObj($)})}ip($){return this._addCheck({kind:"ip",...K.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...K.errToObj($)})}datetime($){var Q,X;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,offset:(Q=$===null||$===void 0?void 0:$.offset)!==null&&Q!==void 0?Q:!1,local:(X=$===null||$===void 0?void 0:$.local)!==null&&X!==void 0?X:!1,...K.errToObj($===null||$===void 0?void 0:$.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($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,...K.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...K.errToObj($)})}regex($,Q){return this._addCheck({kind:"regex",regex:$,...K.errToObj(Q)})}includes($,Q){return this._addCheck({kind:"includes",value:$,position:Q===null||Q===void 0?void 0:Q.position,...K.errToObj(Q===null||Q===void 0?void 0:Q.message)})}startsWith($,Q){return this._addCheck({kind:"startsWith",value:$,...K.errToObj(Q)})}endsWith($,Q){return this._addCheck({kind:"endsWith",value:$,...K.errToObj(Q)})}min($,Q){return this._addCheck({kind:"min",value:$,...K.errToObj(Q)})}max($,Q){return this._addCheck({kind:"max",value:$,...K.errToObj(Q)})}length($,Q){return this._addCheck({kind:"length",value:$,...K.errToObj(Q)})}nonempty($){return this.min(1,K.errToObj($))}trim(){return new l({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new l({...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 $}}l.create=($)=>{var Q;return new l({checks:[],typeName:S.ZodString,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};function C4($,Q){let X=($.toString().split(".")[1]||"").length,W=(Q.toString().split(".")[1]||"").length,Y=X>W?X:W,H=parseInt($.toFixed(Y).replace(".","")),z=parseInt(Q.toFixed(Y).replace(".",""));return H%z/Math.pow(10,Y)}class X1 extends A{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($)!==F.number){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.number,received:Y.parsedType}),_}let X=void 0,W=new h;for(let Y of this._def.checks)if(Y.kind==="int"){if(!R.isInteger($.data))X=this._getOrReturnCtx($,X),U(X,{code:j.invalid_type,expected:"integer",received:"float",message:Y.message}),W.dirty()}else if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_small,minimum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),W.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),W.dirty()}else if(Y.kind==="multipleOf"){if(C4($.data,Y.value)!==0)X=this._getOrReturnCtx($,X),U(X,{code:j.not_multiple_of,multipleOf:Y.value,message:Y.message}),W.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),U(X,{code:j.not_finite,message:Y.message}),W.dirty()}else R.assertNever(Y);return{status:W.value,value:$.data}}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new X1({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new X1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:K.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(Q)})}finite($){return this._addCheck({kind:"finite",message:K.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.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"&&R.isInteger($.value))}get isFinite(){let $=null,Q=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(Q===null||X.value>Q)Q=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(Q)&&Number.isFinite($)}}X1.create=($)=>{return new X1({checks:[],typeName:S.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class Y1 extends A{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(Y){return this._getInvalidInput($)}if(this._getType($)!==F.bigint)return this._getInvalidInput($);let X=void 0,W=new h;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_small,type:"bigint",minimum:Y.value,inclusive:Y.inclusive,message:Y.message}),W.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),W.dirty()}else if(Y.kind==="multipleOf"){if($.data%Y.value!==BigInt(0))X=this._getOrReturnCtx($,X),U(X,{code:j.not_multiple_of,multipleOf:Y.value,message:Y.message}),W.dirty()}else R.assertNever(Y);return{status:W.value,value:$.data}}_getInvalidInput($){let Q=this._getOrReturnCtx($);return U(Q,{code:j.invalid_type,expected:F.bigint,received:Q.parsedType}),_}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new Y1({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new Y1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.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 $}}Y1.create=($)=>{var Q;return new Y1({checks:[],typeName:S.ZodBigInt,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};class L1 extends A{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==F.boolean){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.boolean,received:X.parsedType}),_}return T($.data)}}L1.create=($)=>{return new L1({typeName:S.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class G1 extends A{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==F.date){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.date,received:Y.parsedType}),_}if(isNaN($.data.getTime())){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_date}),_}let X=new h,W=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.getTime()<Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_small,message:Y.message,inclusive:!0,exact:!1,minimum:Y.value,type:"date"}),X.dirty()}else if(Y.kind==="max"){if($.data.getTime()>Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),X.dirty()}else R.assertNever(Y);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new G1({...this._def,checks:[...this._def.checks,$]})}min($,Q){return this._addCheck({kind:"min",value:$.getTime(),message:K.toString(Q)})}max($,Q){return this._addCheck({kind:"max",value:$.getTime(),message:K.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}}G1.create=($)=>{return new G1({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:S.ZodDate,...v($)})};class C1 extends A{_parse($){if(this._getType($)!==F.symbol){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.symbol,received:X.parsedType}),_}return T($.data)}}C1.create=($)=>{return new C1({typeName:S.ZodSymbol,...v($)})};class U1 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.undefined,received:X.parsedType}),_}return T($.data)}}U1.create=($)=>{return new U1({typeName:S.ZodUndefined,...v($)})};class F1 extends A{_parse($){if(this._getType($)!==F.null){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.null,received:X.parsedType}),_}return T($.data)}}F1.create=($)=>{return new F1({typeName:S.ZodNull,...v($)})};class H1 extends A{constructor(){super(...arguments);this._any=!0}_parse($){return T($.data)}}H1.create=($)=>{return new H1({typeName:S.ZodAny,...v($)})};class Q1 extends A{constructor(){super(...arguments);this._unknown=!0}_parse($){return T($.data)}}Q1.create=($)=>{return new Q1({typeName:S.ZodUnknown,...v($)})};class i extends A{_parse($){let Q=this._getOrReturnCtx($);return U(Q,{code:j.invalid_type,expected:F.never,received:Q.parsedType}),_}}i.create=($)=>{return new i({typeName:S.ZodNever,...v($)})};class E1 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.void,received:X.parsedType}),_}return T($.data)}}E1.create=($)=>{return new E1({typeName:S.ZodVoid,...v($)})};class c extends A{_parse($){let{ctx:Q,status:X}=this._processInputParams($),W=this._def;if(Q.parsedType!==F.array)return U(Q,{code:j.invalid_type,expected:F.array,received:Q.parsedType}),_;if(W.exactLength!==null){let H=Q.data.length>W.exactLength.value,z=Q.data.length<W.exactLength.value;if(H||z)U(Q,{code:H?j.too_big:j.too_small,minimum:z?W.exactLength.value:void 0,maximum:H?W.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:W.exactLength.message}),X.dirty()}if(W.minLength!==null){if(Q.data.length<W.minLength.value)U(Q,{code:j.too_small,minimum:W.minLength.value,type:"array",inclusive:!0,exact:!1,message:W.minLength.message}),X.dirty()}if(W.maxLength!==null){if(Q.data.length>W.maxLength.value)U(Q,{code:j.too_big,maximum:W.maxLength.value,type:"array",inclusive:!0,exact:!1,message:W.maxLength.message}),X.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((H,z)=>{return W.type._parseAsync(new n(Q,H,Q.path,z))})).then((H)=>{return h.mergeArray(X,H)});let Y=[...Q.data].map((H,z)=>{return W.type._parseSync(new n(Q,H,Q.path,z))});return h.mergeArray(X,Y)}get element(){return this._def.type}min($,Q){return new c({...this._def,minLength:{value:$,message:K.toString(Q)}})}max($,Q){return new c({...this._def,maxLength:{value:$,message:K.toString(Q)}})}length($,Q){return new c({...this._def,exactLength:{value:$,message:K.toString(Q)}})}nonempty($){return this.min(1,$)}}c.create=($,Q)=>{return new c({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...v(Q)})};function M1($){if($ instanceof E){let Q={};for(let X in $.shape){let W=$.shape[X];Q[X]=u.create(M1(W))}return new E({...$._def,shape:()=>Q})}else if($ instanceof c)return new c({...$._def,type:M1($.element)});else if($ instanceof u)return u.create(M1($.unwrap()));else if($ instanceof e)return e.create(M1($.unwrap()));else if($ instanceof a)return a.create($.items.map((Q)=>M1(Q)));else return $}class E extends A{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=R.objectKeys($);return this._cached={shape:$,keys:Q}}_parse($){if(this._getType($)!==F.object){let O=this._getOrReturnCtx($);return U(O,{code:j.invalid_type,expected:F.object,received:O.parsedType}),_}let{status:X,ctx:W}=this._processInputParams($),{shape:Y,keys:H}=this._getCached(),z=[];if(!(this._def.catchall instanceof i&&this._def.unknownKeys==="strip")){for(let O in W.data)if(!H.includes(O))z.push(O)}let q=[];for(let O of H){let N=Y[O],b=W.data[O];q.push({key:{status:"valid",value:O},value:N._parse(new n(W,b,W.path,O)),alwaysSet:O in W.data})}if(this._def.catchall instanceof i){let O=this._def.unknownKeys;if(O==="passthrough")for(let N of z)q.push({key:{status:"valid",value:N},value:{status:"valid",value:W.data[N]}});else if(O==="strict"){if(z.length>0)U(W,{code:j.unrecognized_keys,keys:z}),X.dirty()}else if(O==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let O=this._def.catchall;for(let N of z){let b=W.data[N];q.push({key:{status:"valid",value:N},value:O._parse(new n(W,b,W.path,N)),alwaysSet:N in W.data})}}if(W.common.async)return Promise.resolve().then(async()=>{let O=[];for(let N of q){let b=await N.key,I=await N.value;O.push({key:b,value:I,alwaysSet:N.alwaysSet})}return O}).then((O)=>{return h.mergeObjectSync(X,O)});else return h.mergeObjectSync(X,q)}get shape(){return this._def.shape()}strict($){return K.errToObj,new E({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(Q,X)=>{var W,Y,H,z;let q=(H=(Y=(W=this._def).errorMap)===null||Y===void 0?void 0:Y.call(W,Q,X).message)!==null&&H!==void 0?H:X.defaultError;if(Q.code==="unrecognized_keys")return{message:(z=K.errToObj($).message)!==null&&z!==void 0?z:q};return{message:q}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend($){return new E({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new E({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,Q){return this.augment({[$]:Q})}catchall($){return new E({...this._def,catchall:$})}pick($){let Q={};return R.objectKeys($).forEach((X)=>{if($[X]&&this.shape[X])Q[X]=this.shape[X]}),new E({...this._def,shape:()=>Q})}omit($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if(!$[X])Q[X]=this.shape[X]}),new E({...this._def,shape:()=>Q})}deepPartial(){return M1(this)}partial($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{let W=this.shape[X];if($&&!$[X])Q[X]=W;else Q[X]=W.optional()}),new E({...this._def,shape:()=>Q})}required($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if($&&!$[X])Q[X]=this.shape[X];else{let Y=this.shape[X];while(Y instanceof u)Y=Y._def.innerType;Q[X]=Y}}),new E({...this._def,shape:()=>Q})}keyof(){return R0(R.objectKeys(this.shape))}}E.create=($,Q)=>{return new E({shape:()=>$,unknownKeys:"strip",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};E.strictCreate=($,Q)=>{return new E({shape:()=>$,unknownKeys:"strict",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};E.lazycreate=($,Q)=>{return new E({shape:$,unknownKeys:"strip",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};class D1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=this._def.options;function W(Y){for(let z of Y)if(z.result.status==="valid")return z.result;for(let z of Y)if(z.result.status==="dirty")return Q.common.issues.push(...z.ctx.common.issues),z.result;let H=Y.map((z)=>new x(z.ctx.common.issues));return U(Q,{code:j.invalid_union,unionErrors:H}),_}if(Q.common.async)return Promise.all(X.map(async(Y)=>{let H={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:Q.data,path:Q.path,parent:H}),ctx:H}})).then(W);else{let Y=void 0,H=[];for(let q of X){let O={...Q,common:{...Q.common,issues:[]},parent:null},N=q._parseSync({data:Q.data,path:Q.path,parent:O});if(N.status==="valid")return N;else if(N.status==="dirty"&&!Y)Y={result:N,ctx:O};if(O.common.issues.length)H.push(O.common.issues)}if(Y)return Q.common.issues.push(...Y.ctx.common.issues),Y.result;let z=H.map((q)=>new x(q));return U(Q,{code:j.invalid_union,unionErrors:z}),_}}get options(){return this._def.options}}D1.create=($,Q)=>{return new D1({options:$,typeName:S.ZodUnion,...v(Q)})};var s=($)=>{if($ instanceof N1)return s($.schema);else if($ instanceof y)return s($.innerType());else if($ instanceof S1)return[$.value];else if($ instanceof W1)return $.options;else if($ instanceof _1)return R.objectValues($.enum);else if($ instanceof v1)return s($._def.innerType);else if($ instanceof U1)return[void 0];else if($ instanceof F1)return[null];else if($ instanceof u)return[void 0,...s($.unwrap())];else if($ instanceof e)return[null,...s($.unwrap())];else if($ instanceof c1)return s($.unwrap());else if($ instanceof b1)return s($.unwrap());else if($ instanceof A1)return s($._def.innerType);else return[]};class l1 extends A{_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.object)return U(Q,{code:j.invalid_type,expected:F.object,received:Q.parsedType}),_;let X=this.discriminator,W=Q.data[X],Y=this.optionsMap.get(W);if(!Y)return U(Q,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),_;if(Q.common.async)return Y._parseAsync({data:Q.data,path:Q.path,parent:Q});else return Y._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,X){let W=new Map;for(let Y of Q){let H=s(Y.shape[$]);if(!H.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let z of H){if(W.has(z))throw Error(`Discriminator property ${String($)} has duplicate value ${String(z)}`);W.set(z,Y)}}return new l1({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:Q,optionsMap:W,...v(X)})}}function W0($,Q){let X=r($),W=r(Q);if($===Q)return{valid:!0,data:$};else if(X===F.object&&W===F.object){let Y=R.objectKeys(Q),H=R.objectKeys($).filter((q)=>Y.indexOf(q)!==-1),z={...$,...Q};for(let q of H){let O=W0($[q],Q[q]);if(!O.valid)return{valid:!1};z[q]=O.data}return{valid:!0,data:z}}else if(X===F.array&&W===F.array){if($.length!==Q.length)return{valid:!1};let Y=[];for(let H=0;H<$.length;H++){let z=$[H],q=Q[H],O=W0(z,q);if(!O.valid)return{valid:!1};Y.push(O.data)}return{valid:!0,data:Y}}else if(X===F.date&&W===F.date&&+$===+Q)return{valid:!0,data:$};else return{valid:!1}}class K1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=(Y,H)=>{if(X0(Y)||X0(H))return _;let z=W0(Y.value,H.value);if(!z.valid)return U(X,{code:j.invalid_intersection_types}),_;if(Y0(Y)||Y0(H))Q.dirty();return{status:Q.value,value:z.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Y,H])=>W(Y,H));else return W(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}K1.create=($,Q,X)=>{return new K1({left:$,right:Q,typeName:S.ZodIntersection,...v(X)})};class a extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.array)return U(X,{code:j.invalid_type,expected:F.array,received:X.parsedType}),_;if(X.data.length<this._def.items.length)return U(X,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;if(!this._def.rest&&X.data.length>this._def.items.length)U(X,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let Y=[...X.data].map((H,z)=>{let q=this._def.items[z]||this._def.rest;if(!q)return null;return q._parse(new n(X,H,X.path,z))}).filter((H)=>!!H);if(X.common.async)return Promise.all(Y).then((H)=>{return h.mergeArray(Q,H)});else return h.mergeArray(Q,Y)}get items(){return this._def.items}rest($){return new a({...this._def,rest:$})}}a.create=($,Q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new a({items:$,typeName:S.ZodTuple,rest:null,...v(Q)})};class P1 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.object)return U(X,{code:j.invalid_type,expected:F.object,received:X.parsedType}),_;let W=[],Y=this._def.keyType,H=this._def.valueType;for(let z in X.data)W.push({key:Y._parse(new n(X,z,X.path,z)),value:H._parse(new n(X,X.data[z],X.path,z)),alwaysSet:z in X.data});if(X.common.async)return h.mergeObjectAsync(Q,W);else return h.mergeObjectSync(Q,W)}get element(){return this._def.valueType}static create($,Q,X){if(Q instanceof A)return new P1({keyType:$,valueType:Q,typeName:S.ZodRecord,...v(X)});return new P1({keyType:l.create(),valueType:$,typeName:S.ZodRecord,...v(Q)})}}class I1 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.map)return U(X,{code:j.invalid_type,expected:F.map,received:X.parsedType}),_;let W=this._def.keyType,Y=this._def.valueType,H=[...X.data.entries()].map(([z,q],O)=>{return{key:W._parse(new n(X,z,X.path,[O,"key"])),value:Y._parse(new n(X,q,X.path,[O,"value"]))}});if(X.common.async){let z=new Map;return Promise.resolve().then(async()=>{for(let q of H){let O=await q.key,N=await q.value;if(O.status==="aborted"||N.status==="aborted")return _;if(O.status==="dirty"||N.status==="dirty")Q.dirty();z.set(O.value,N.value)}return{status:Q.value,value:z}})}else{let z=new Map;for(let q of H){let{key:O,value:N}=q;if(O.status==="aborted"||N.status==="aborted")return _;if(O.status==="dirty"||N.status==="dirty")Q.dirty();z.set(O.value,N.value)}return{status:Q.value,value:z}}}}I1.create=($,Q,X)=>{return new I1({valueType:Q,keyType:$,typeName:S.ZodMap,...v(X)})};class z1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.set)return U(X,{code:j.invalid_type,expected:F.set,received:X.parsedType}),_;let W=this._def;if(W.minSize!==null){if(X.data.size<W.minSize.value)U(X,{code:j.too_small,minimum:W.minSize.value,type:"set",inclusive:!0,exact:!1,message:W.minSize.message}),Q.dirty()}if(W.maxSize!==null){if(X.data.size>W.maxSize.value)U(X,{code:j.too_big,maximum:W.maxSize.value,type:"set",inclusive:!0,exact:!1,message:W.maxSize.message}),Q.dirty()}let Y=this._def.valueType;function H(q){let O=new Set;for(let N of q){if(N.status==="aborted")return _;if(N.status==="dirty")Q.dirty();O.add(N.value)}return{status:Q.value,value:O}}let z=[...X.data.values()].map((q,O)=>Y._parse(new n(X,q,X.path,O)));if(X.common.async)return Promise.all(z).then((q)=>H(q));else return H(z)}min($,Q){return new z1({...this._def,minSize:{value:$,message:K.toString(Q)}})}max($,Q){return new z1({...this._def,maxSize:{value:$,message:K.toString(Q)}})}size($,Q){return this.min($,Q).max($,Q)}nonempty($){return this.min(1,$)}}z1.create=($,Q)=>{return new z1({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...v(Q)})};class O1 extends A{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.function)return U(Q,{code:j.invalid_type,expected:F.function,received:Q.parsedType}),_;function X(z,q){return y1({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,Z1(),V1].filter((O)=>!!O),issueData:{code:j.invalid_arguments,argumentsError:q}})}function W(z,q){return y1({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,Z1(),V1].filter((O)=>!!O),issueData:{code:j.invalid_return_type,returnTypeError:q}})}let Y={errorMap:Q.common.contextualErrorMap},H=Q.data;if(this._def.returns instanceof B1){let z=this;return T(async function(...q){let O=new x([]),N=await z._def.args.parseAsync(q,Y).catch((t)=>{throw O.addIssue(X(q,t)),O}),b=await Reflect.apply(H,this,N);return await z._def.returns._def.type.parseAsync(b,Y).catch((t)=>{throw O.addIssue(W(b,t)),O})})}else{let z=this;return T(function(...q){let O=z._def.args.safeParse(q,Y);if(!O.success)throw new x([X(q,O.error)]);let N=Reflect.apply(H,this,O.data),b=z._def.returns.safeParse(N,Y);if(!b.success)throw new x([W(N,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new O1({...this._def,args:a.create($).rest(Q1.create())})}returns($){return new O1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,Q,X){return new O1({args:$?$:a.create([]).rest(Q1.create()),returns:Q||Q1.create(),typeName:S.ZodFunction,...v(X)})}}class N1 extends A{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})}}N1.create=($,Q)=>{return new N1({getter:$,typeName:S.ZodLazy,...v(Q)})};class S1 extends A{_parse($){if($.data!==this._def.value){let Q=this._getOrReturnCtx($);return U(Q,{received:Q.data,code:j.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:$.data}}get value(){return this._def.value}}S1.create=($,Q)=>{return new S1({value:$,typeName:S.ZodLiteral,...v(Q)})};function R0($,Q){return new W1({values:$,typeName:S.ZodEnum,...v(Q)})}class W1 extends A{constructor(){super(...arguments);R1.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{expected:R.joinValues(X),received:Q.parsedType,code:j.invalid_type}),_}if(!m1(this,R1,"f"))_0(this,R1,new Set(this._def.values),"f");if(!m1(this,R1,"f").has($.data)){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{received:Q.data,code:j.invalid_enum_value,options:X}),_}return T($.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 W1.create($,{...this._def,...Q})}exclude($,Q=this._def){return W1.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...Q})}}R1=new WeakMap;W1.create=R0;class _1 extends A{constructor(){super(...arguments);f1.set(this,void 0)}_parse($){let Q=R.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==F.string&&X.parsedType!==F.number){let W=R.objectValues(Q);return U(X,{expected:R.joinValues(W),received:X.parsedType,code:j.invalid_type}),_}if(!m1(this,f1,"f"))_0(this,f1,new Set(R.getValidEnumValues(this._def.values)),"f");if(!m1(this,f1,"f").has($.data)){let W=R.objectValues(Q);return U(X,{received:X.data,code:j.invalid_enum_value,options:W}),_}return T($.data)}get enum(){return this._def.values}}f1=new WeakMap;_1.create=($,Q)=>{return new _1({values:$,typeName:S.ZodNativeEnum,...v(Q)})};class B1 extends A{unwrap(){return this._def.type}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.promise&&Q.common.async===!1)return U(Q,{code:j.invalid_type,expected:F.promise,received:Q.parsedType}),_;let X=Q.parsedType===F.promise?Q.data:Promise.resolve(Q.data);return T(X.then((W)=>{return this._def.type.parseAsync(W,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}B1.create=($,Q)=>{return new B1({type:$,typeName:S.ZodPromise,...v(Q)})};class y extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=this._def.effect||null,Y={addIssue:(H)=>{if(U(X,H),H.fatal)Q.abort();else Q.dirty()},get path(){return X.path}};if(Y.addIssue=Y.addIssue.bind(Y),W.type==="preprocess"){let H=W.transform(X.data,Y);if(X.common.async)return Promise.resolve(H).then(async(z)=>{if(Q.value==="aborted")return _;let q=await this._def.schema._parseAsync({data:z,path:X.path,parent:X});if(q.status==="aborted")return _;if(q.status==="dirty")return j1(q.value);if(Q.value==="dirty")return j1(q.value);return q});else{if(Q.value==="aborted")return _;let z=this._def.schema._parseSync({data:H,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")return j1(z.value);if(Q.value==="dirty")return j1(z.value);return z}}if(W.type==="refinement"){let H=(z)=>{let q=W.refinement(z,Y);if(X.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return z};if(X.common.async===!1){let z=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value),{status:Q.value,value:z.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((z)=>{if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value).then(()=>{return{status:Q.value,value:z.value}})})}if(W.type==="transform")if(X.common.async===!1){let H=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!J1(H))return H;let z=W.transform(H.value,Y);if(z instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:z}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((H)=>{if(!J1(H))return H;return Promise.resolve(W.transform(H.value,Y)).then((z)=>({status:Q.value,value:z}))});R.assertNever(W)}}y.create=($,Q,X)=>{return new y({schema:$,typeName:S.ZodEffects,effect:Q,...v(X)})};y.createWithPreprocess=($,Q,X)=>{return new y({schema:Q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...v(X)})};class u extends A{_parse($){if(this._getType($)===F.undefined)return T(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}u.create=($,Q)=>{return new u({innerType:$,typeName:S.ZodOptional,...v(Q)})};class e extends A{_parse($){if(this._getType($)===F.null)return T(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e.create=($,Q)=>{return new e({innerType:$,typeName:S.ZodNullable,...v(Q)})};class v1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;if(Q.parsedType===F.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}v1.create=($,Q)=>{return new v1({innerType:$,typeName:S.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...v(Q)})};class A1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X={...Q,common:{...Q.common,issues:[]}},W=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(k1(W))return W.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}});else return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}A1.create=($,Q)=>{return new A1({innerType:$,typeName:S.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...v(Q)})};class g1 extends A{_parse($){if(this._getType($)!==F.nan){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.nan,received:X.parsedType}),_}return{status:"valid",value:$.data}}}g1.create=($)=>{return new g1({typeName:S.ZodNaN,...v($)})};var E4=Symbol("zod_brand");class c1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;return this._def.type._parse({data:X,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class h1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return _;if(Y.status==="dirty")return Q.dirty(),j1(Y.value);else return this._def.out._parseAsync({data:Y.value,path:X.path,parent:X})})();else{let W=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return _;if(W.status==="dirty")return Q.dirty(),{status:"dirty",value:W.value};else return this._def.out._parseSync({data:W.value,path:X.path,parent:X})}}static create($,Q){return new h1({in:$,out:Q,typeName:S.ZodPipeline})}}class b1 extends A{_parse($){let Q=this._def.innerType._parse($),X=(W)=>{if(J1(W))W.value=Object.freeze(W.value);return W};return k1(Q)?Q.then((W)=>X(W)):X(Q)}unwrap(){return this._def.innerType}}b1.create=($,Q)=>{return new b1({innerType:$,typeName:S.ZodReadonly,...v(Q)})};function f0($,Q={},X){if($)return H1.create().superRefine((W,Y)=>{var H,z;if(!$(W)){let q=typeof Q==="function"?Q(W):typeof Q==="string"?{message:Q}:Q,O=(z=(H=q.fatal)!==null&&H!==void 0?H:X)!==null&&z!==void 0?z:!0,N=typeof q==="string"?{message:q}:q;Y.addIssue({code:"custom",...N,fatal:O})}});return H1.create()}var P4={object:E.lazycreate},S;(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"})(S||(S={}));var I4=($,Q={message:`Input not instance of ${$.name}`})=>f0((X)=>X instanceof $,Q),k0=l.create,C0=X1.create,g4=g1.create,h4=Y1.create,E0=L1.create,T4=G1.create,x4=C1.create,Z4=U1.create,y4=F1.create,m4=H1.create,l4=Q1.create,c4=i.create,u4=E1.create,n4=c.create,p4=E.create,d4=E.strictCreate,i4=D1.create,a4=l1.create,o4=K1.create,t4=a.create,s4=P1.create,r4=I1.create,e4=z1.create,$2=O1.create,Q2=N1.create,X2=S1.create,Y2=W1.create,W2=_1.create,J2=B1.create,N0=y.create,G2=u.create,H2=e.create,z2=y.createWithPreprocess,B2=h1.create,w2=()=>k0().optional(),q2=()=>C0().optional(),M2=()=>E0().optional(),j2={string:($)=>l.create({...$,coerce:!0}),number:($)=>X1.create({...$,coerce:!0}),boolean:($)=>L1.create({...$,coerce:!0}),bigint:($)=>Y1.create({...$,coerce:!0}),date:($)=>G1.create({...$,coerce:!0})},O2=_,G=Object.freeze({__proto__:null,defaultErrorMap:V1,setErrorMap:z4,getErrorMap:Z1,makeIssue:y1,EMPTY_PATH:B4,addIssueToContext:U,ParseStatus:h,INVALID:_,DIRTY:j1,OK:T,isAborted:X0,isDirty:Y0,isValid:J1,isAsync:k1,get util(){return R},get objectUtil(){return Q0},ZodParsedType:F,getParsedType:r,ZodType:A,datetimeRegex:b0,ZodString:l,ZodNumber:X1,ZodBigInt:Y1,ZodBoolean:L1,ZodDate:G1,ZodSymbol:C1,ZodUndefined:U1,ZodNull:F1,ZodAny:H1,ZodUnknown:Q1,ZodNever:i,ZodVoid:E1,ZodArray:c,ZodObject:E,ZodUnion:D1,ZodDiscriminatedUnion:l1,ZodIntersection:K1,ZodTuple:a,ZodRecord:P1,ZodMap:I1,ZodSet:z1,ZodFunction:O1,ZodLazy:N1,ZodLiteral:S1,ZodEnum:W1,ZodNativeEnum:_1,ZodPromise:B1,ZodEffects:y,ZodTransformer:y,ZodOptional:u,ZodNullable:e,ZodDefault:v1,ZodCatch:A1,ZodNaN:g1,BRAND:E4,ZodBranded:c1,ZodPipeline:h1,ZodReadonly:b1,custom:f0,Schema:A,ZodSchema:A,late:P4,get ZodFirstPartyTypeKind(){return S},coerce:j2,any:m4,array:n4,bigint:h4,boolean:E0,date:T4,discriminatedUnion:a4,effect:N0,enum:Y2,function:$2,instanceof:I4,intersection:o4,lazy:Q2,literal:X2,map:r4,nan:g4,nativeEnum:W2,never:c4,null:y4,nullable:H2,number:C0,object:p4,oboolean:M2,onumber:q2,optional:G2,ostring:w2,pipeline:B2,preprocess:z2,promise:J2,record:s4,set:e4,strictObject:d4,string:k0,symbol:x4,transformer:N0,tuple:t4,undefined:Z4,union:i4,unknown:l4,void:u4,NEVER:O2,ZodIssueCode:j,quotelessJson:H4,ZodError:x});var J0="2024-11-05",P0=[J0,"2024-10-07"],u1="2.0",I0=G.union([G.string(),G.number().int()]),g0=G.string(),p=G.object({_meta:G.optional(G.object({progressToken:G.optional(I0)}).passthrough())}).passthrough(),Z=G.object({method:G.string(),params:G.optional(p)}),T1=G.object({_meta:G.optional(G.object({}).passthrough())}).passthrough(),o=G.object({method:G.string(),params:G.optional(T1)}),d=G.object({_meta:G.optional(G.object({}).passthrough())}).passthrough(),n1=G.union([G.string(),G.number().int()]),V2=G.object({jsonrpc:G.literal(u1),id:n1}).merge(Z).strict(),L2=G.object({jsonrpc:G.literal(u1)}).merge(o).strict(),U2=G.object({jsonrpc:G.literal(u1),id:n1,result:d}).strict(),w1;(function($){$[$.ConnectionClosed=-1]="ConnectionClosed",$[$.RequestTimeout=-2]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(w1||(w1={}));var F2=G.object({jsonrpc:G.literal(u1),id:n1,error:G.object({code:G.number().int(),message:G.string(),data:G.optional(G.unknown())})}).strict(),h0=G.union([V2,L2,U2,F2]),p1=d.strict(),d1=o.extend({method:G.literal("notifications/cancelled"),params:T1.extend({requestId:n1,reason:G.string().optional()})}),T0=G.object({name:G.string(),version:G.string()}).passthrough(),D2=G.object({experimental:G.optional(G.object({}).passthrough()),sampling:G.optional(G.object({}).passthrough()),roots:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough())}).passthrough(),G0=Z.extend({method:G.literal("initialize"),params:p.extend({protocolVersion:G.string(),capabilities:D2,clientInfo:T0})}),K2=G.object({experimental:G.optional(G.object({}).passthrough()),logging:G.optional(G.object({}).passthrough()),prompts:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough()),resources:G.optional(G.object({subscribe:G.optional(G.boolean()),listChanged:G.optional(G.boolean())}).passthrough()),tools:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough())}).passthrough(),N2=d.extend({protocolVersion:G.string(),capabilities:K2,serverInfo:T0}),H0=o.extend({method:G.literal("notifications/initialized")}),i1=Z.extend({method:G.literal("ping")}),S2=G.object({progress:G.number(),total:G.optional(G.number())}).passthrough(),a1=o.extend({method:G.literal("notifications/progress"),params:T1.merge(S2).extend({progressToken:I0})}),o1=Z.extend({params:p.extend({cursor:G.optional(g0)}).optional()}),t1=d.extend({nextCursor:G.optional(g0)}),x0=G.object({uri:G.string(),mimeType:G.optional(G.string())}).passthrough(),Z0=x0.extend({text:G.string()}),y0=x0.extend({blob:G.string().base64()}),_2=G.object({uri:G.string(),name:G.string(),description:G.optional(G.string()),mimeType:G.optional(G.string())}).passthrough(),v2=G.object({uriTemplate:G.string(),name:G.string(),description:G.optional(G.string()),mimeType:G.optional(G.string())}).passthrough(),A2=o1.extend({method:G.literal("resources/list")}),b2=t1.extend({resources:G.array(_2)}),R2=o1.extend({method:G.literal("resources/templates/list")}),f2=t1.extend({resourceTemplates:G.array(v2)}),k2=Z.extend({method:G.literal("resources/read"),params:p.extend({uri:G.string()})}),C2=d.extend({contents:G.array(G.union([Z0,y0]))}),E2=o.extend({method:G.literal("notifications/resources/list_changed")}),P2=Z.extend({method:G.literal("resources/subscribe"),params:p.extend({uri:G.string()})}),I2=Z.extend({method:G.literal("resources/unsubscribe"),params:p.extend({uri:G.string()})}),g2=o.extend({method:G.literal("notifications/resources/updated"),params:T1.extend({uri:G.string()})}),h2=G.object({name:G.string(),description:G.optional(G.string()),required:G.optional(G.boolean())}).passthrough(),T2=G.object({name:G.string(),description:G.optional(G.string()),arguments:G.optional(G.array(h2))}).passthrough(),x2=o1.extend({method:G.literal("prompts/list")}),Z2=t1.extend({prompts:G.array(T2)}),y2=Z.extend({method:G.literal("prompts/get"),params:p.extend({name:G.string(),arguments:G.optional(G.record(G.string()))})}),s1=G.object({type:G.literal("text"),text:G.string()}).passthrough(),r1=G.object({type:G.literal("image"),data:G.string().base64(),mimeType:G.string()}).passthrough(),m0=G.object({type:G.literal("resource"),resource:G.union([Z0,y0])}).passthrough(),m2=G.object({role:G.enum(["user","assistant"]),content:G.union([s1,r1,m0])}).passthrough(),l2=d.extend({description:G.optional(G.string()),messages:G.array(m2)}),c2=o.extend({method:G.literal("notifications/prompts/list_changed")}),u2=G.object({name:G.string(),description:G.optional(G.string()),inputSchema:G.object({type:G.literal("object"),properties:G.optional(G.object({}).passthrough())}).passthrough()}).passthrough(),z0=o1.extend({method:G.literal("tools/list")}),n2=t1.extend({tools:G.array(u2)}),l0=d.extend({content:G.array(G.union([s1,r1,m0])),isError:G.boolean().default(!1).optional()}),l6=l0.or(d.extend({toolResult:G.unknown()})),B0=Z.extend({method:G.literal("tools/call"),params:p.extend({name:G.string(),arguments:G.optional(G.record(G.unknown()))})}),p2=o.extend({method:G.literal("notifications/tools/list_changed")}),c0=G.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),d2=Z.extend({method:G.literal("logging/setLevel"),params:p.extend({level:c0})}),i2=o.extend({method:G.literal("notifications/message"),params:T1.extend({level:c0,logger:G.optional(G.string()),data:G.unknown()})}),a2=G.object({name:G.string().optional()}).passthrough(),o2=G.object({hints:G.optional(G.array(a2)),costPriority:G.optional(G.number().min(0).max(1)),speedPriority:G.optional(G.number().min(0).max(1)),intelligencePriority:G.optional(G.number().min(0).max(1))}).passthrough(),t2=G.object({role:G.enum(["user","assistant"]),content:G.union([s1,r1])}).passthrough(),s2=Z.extend({method:G.literal("sampling/createMessage"),params:p.extend({messages:G.array(t2),systemPrompt:G.optional(G.string()),includeContext:G.optional(G.enum(["none","thisServer","allServers"])),temperature:G.optional(G.number()),maxTokens:G.number().int(),stopSequences:G.optional(G.array(G.string())),metadata:G.optional(G.object({}).passthrough()),modelPreferences:G.optional(o2)})}),w0=d.extend({model:G.string(),stopReason:G.optional(G.enum(["endTurn","stopSequence","maxTokens"]).or(G.string())),role:G.enum(["user","assistant"]),content:G.discriminatedUnion("type",[s1,r1])}),r2=G.object({type:G.literal("ref/resource"),uri:G.string()}).passthrough(),e2=G.object({type:G.literal("ref/prompt"),name:G.string()}).passthrough(),$6=Z.extend({method:G.literal("completion/complete"),params:p.extend({ref:G.union([e2,r2]),argument:G.object({name:G.string(),value:G.string()}).passthrough()})}),Q6=d.extend({completion:G.object({values:G.array(G.string()).max(100),total:G.optional(G.number().int()),hasMore:G.optional(G.boolean())}).passthrough()}),X6=G.object({uri:G.string().startsWith("file://"),name:G.optional(G.string())}).passthrough(),Y6=Z.extend({method:G.literal("roots/list")}),q0=d.extend({roots:G.array(X6)}),W6=o.extend({method:G.literal("notifications/roots/list_changed")}),c6=G.union([i1,G0,$6,d2,y2,x2,A2,R2,k2,P2,I2,B0,z0]),u6=G.union([d1,a1,H0,W6]),n6=G.union([p1,w0,q0]),p6=G.union([i1,s2,Y6]),d6=G.union([d1,a1,i2,g2,E2,p2,c2]),i6=G.union([p1,N2,Q6,l2,Z2,b2,f2,C2,l0,n2]);class x1 extends Error{constructor($,Q,X){super(`MCP error ${$}: ${Q}`);this.code=$,this.data=X}}var J6=60000;class M0{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.setNotificationHandler(d1,(Q)=>{let X=this._requestHandlerAbortControllers.get(Q.params.requestId);X===null||X===void 0||X.abort(Q.params.reason)}),this.setNotificationHandler(a1,(Q)=>{this._onprogress(Q)}),this.setRequestHandler(i1,(Q)=>({}))}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(Q)=>{this._onerror(Q)},this._transport.onmessage=(Q)=>{if(!("method"in Q))this._onresponse(Q);else if("id"in Q)this._onrequest(Q);else this._onnotification(Q)},await this._transport.start()}_onclose(){var $;let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new x1(w1.ConnectionClosed,"Connection closed");for(let W of Q.values())W(X)}_onerror($){var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,$)}_onnotification($){var Q;let X=(Q=this._notificationHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((W)=>this._onerror(Error(`Uncaught error in notification handler: ${W}`)))}_onrequest($){var Q,X;let W=(Q=this._requestHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackRequestHandler;if(W===void 0){(X=this._transport)===null||X===void 0||X.send({jsonrpc:"2.0",id:$.id,error:{code:w1.MethodNotFound,message:"Method not found"}}).catch((H)=>this._onerror(Error(`Failed to send an error response: ${H}`)));return}let Y=new AbortController;this._requestHandlerAbortControllers.set($.id,Y),Promise.resolve().then(()=>W($,{signal:Y.signal})).then((H)=>{var z;if(Y.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({result:H,jsonrpc:"2.0",id:$.id})},(H)=>{var z,q;if(Y.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(H.code)?H.code:w1.InternalError,message:(q=H.message)!==null&&q!==void 0?q:"Internal error"}})}).catch((H)=>this._onerror(Error(`Failed to send response: ${H}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:Q,...X}=$.params,W=this._progressHandlers.get(Number(Q));if(W===void 0){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}W(X)}_onresponse($){let Q=$.id,X=this._responseHandlers.get(Number(Q));if(X===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(Number(Q)),this._progressHandlers.delete(Number(Q)),"result"in $)X($);else{let W=new x1($.error.code,$.error.message,$.error.data);X(W)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,Q,X){return new Promise((W,Y)=>{var H,z,q,O;if(!this._transport){Y(Error("Not connected"));return}if(((H=this._options)===null||H===void 0?void 0:H.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(z=X===null||X===void 0?void 0:X.signal)===null||z===void 0||z.throwIfAborted();let N=this._requestMessageId++,b={...$,jsonrpc:"2.0",id:N};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(N,X.onprogress),b.params={...$.params,_meta:{progressToken:N}};let I=void 0;this._responseHandlers.set(N,(k)=>{var P;if(I!==void 0)clearTimeout(I);if((P=X===null||X===void 0?void 0:X.signal)===null||P===void 0?void 0:P.aborted)return;if(k instanceof Error)return Y(k);try{let g=Q.parse(k.result);W(g)}catch(g){Y(g)}});let t=(k)=>{var P;this._responseHandlers.delete(N),this._progressHandlers.delete(N),(P=this._transport)===null||P===void 0||P.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:N,reason:String(k)}}).catch((g)=>this._onerror(Error(`Failed to send cancellation: ${g}`))),Y(k)};(q=X===null||X===void 0?void 0:X.signal)===null||q===void 0||q.addEventListener("abort",()=>{var k;if(I!==void 0)clearTimeout(I);t((k=X===null||X===void 0?void 0:X.signal)===null||k===void 0?void 0:k.reason)});let m=(O=X===null||X===void 0?void 0:X.timeout)!==null&&O!==void 0?O:J6;I=setTimeout(()=>t(new x1(w1.RequestTimeout,"Request timed out",{timeout:m})),m),this._transport.send(b).catch((k)=>{if(I!==void 0)clearTimeout(I);Y(k)})})}async notification($){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let Q={...$,jsonrpc:"2.0"};await this._transport.send(Q)}setRequestHandler($,Q){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,Y)=>Promise.resolve(Q($.parse(W),Y)))}removeRequestHandler($){this._requestHandlers.delete($)}setNotificationHandler($,Q){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(Q($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}class j0 extends M0{constructor($,Q){super(Q);this._serverInfo=$,this._capabilities=Q.capabilities,this.setRequestHandler(G0,(X)=>this._oninitialize(X)),this.setNotificationHandler(H0,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}assertCapabilityForMethod($){var Q,X;switch($){case"sampling/createMessage":if(!((Q=this._clientCapabilities)===null||Q===void 0?void 0:Q.sampling))throw Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw 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 Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw 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:P0.includes(Q)?Q:J0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},p1)}async createMessage($,Q){return this.request({method:"sampling/createMessage",params:$},w0,Q)}async listRoots($,Q){return this.request({method:"roots/list",params:$},q0,Q)}async sendLoggingMessage($){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"})}}import n0 from"process";class O0{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
|
2
|
+
var Q4=Object.create;var{getPrototypeOf:X4,defineProperty:U0,getOwnPropertyNames:Y4}=Object;var W4=Object.prototype.hasOwnProperty;var J4=($,Q,X)=>{X=$!=null?Q4(X4($)):{};let W=Q||!$||!$.__esModule?U0(X,"default",{value:$,enumerable:!0}):X;for(let Y of Y4($))if(!W4.call(W,Y))U0(W,Y,{get:()=>$[Y],enumerable:!0});return W};var G4=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var p0=G4((J8,H6)=>{H6.exports={name:"@typescape-ai/mcp",version:"1.2.1",description:"Typescape MCP Server - Model Context Protocol integration for AI agents",type:"module",bin:{"typescape-mcp":"./dist/mcp.js"},files:["dist","README.md"],exports:{".":"./dist/mcp.js"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --outfile=dist/mcp.js --target=bun --bundle --minify",dev:"bun run --watch src/index.ts",test:"bun test",typecheck:"tsc --noEmit",lint:"eslint src",prepublishOnly:"bun run build"},dependencies:{},devDependencies:{"@modelcontextprotocol/sdk":"1.0.4","@types/bun":"1.1.14","@typescape/schemas":"workspace:*",zod:"4.3.0"},engines:{bun:">=1.0.0"},keywords:["typescape","mcp","model-context-protocol","ai","claude","review","bun"],repository:{type:"git",url:"https://github.com/voidserf/typescape-docs.git",directory:"apps/mcp"},license:"MIT"}});function F0(){let $=new Map;return{register(Q,X){$.set(Q.name,{definition:Q,handler:X})},getTools(){return Array.from($.values()).map((Q)=>Q.definition)},getHandler(Q){return $.get(Q)?.handler}}}class M extends Error{status;code;requestId;details;fixHint;constructor($,Q,X,W,Y,H){super(X);this.status=$;this.code=Q;this.requestId=W;this.details=Y;this.fixHint=H;this.name="ApiError"}}function D0($,Q){let W=$.replace(/\/$/,"");async function Y(H,z,q={}){let O=`${W}/v1${z}`;if(q.query&&Object.keys(q.query).length>0){let k=new URLSearchParams(q.query);O+=`?${k.toString()}`}let N={Authorization:`Bearer ${Q}`,Accept:"application/json",...q.headers};if(q.body!==void 0)N["Content-Type"]="application/json";let b;try{b=await fetch(O,{method:H,headers:N,body:q.body!==void 0?JSON.stringify(q.body):void 0})}catch(k){let P=k instanceof Error?k.message:String(k);throw new M(0,"network_error",`Network error: ${P}`,"unknown")}let I;if((b.headers.get("Content-Type")||"").includes("application/json"))try{I=await b.json()}catch{I={}}else I={};let m=I?.request_id||b.headers.get("X-Request-Id")||"unknown";if(!b.ok){let k=I,P=k.error?.code||"api_error",g=k.error?.message||`API request failed with status ${b.status}`;throw new M(b.status,P,g,m,k.error?.details,k.error?.fix_hint)}return{status:b.status,body:I,requestId:m}}return{async get(H,z){return Y("GET",H,z)},async post(H,z){return Y("POST",H,z)},request:Y}}var R;(function($){$.assertEqual=(Y)=>Y;function Q(Y){}$.assertIs=Q;function X(Y){throw Error()}$.assertNever=X,$.arrayToEnum=(Y)=>{let H={};for(let z of Y)H[z]=z;return H},$.getValidEnumValues=(Y)=>{let H=$.objectKeys(Y).filter((q)=>typeof Y[Y[q]]!=="number"),z={};for(let q of H)z[q]=Y[q];return $.objectValues(z)},$.objectValues=(Y)=>{return $.objectKeys(Y).map(function(H){return Y[H]})},$.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let H=[];for(let z in Y)if(Object.prototype.hasOwnProperty.call(Y,z))H.push(z);return H},$.find=(Y,H)=>{for(let z of Y)if(H(z))return z;return},$.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&isFinite(Y)&&Math.floor(Y)===Y;function W(Y,H=" | "){return Y.map((z)=>typeof z==="string"?`'${z}'`:z).join(H)}$.joinValues=W,$.jsonStringifyReplacer=(Y,H)=>{if(typeof H==="bigint")return H.toString();return H}})(R||(R={}));var Q0;(function($){$.mergeShapes=(Q,X)=>{return{...Q,...X}}})(Q0||(Q0={}));var F=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=($)=>{switch(typeof $){case"undefined":return F.undefined;case"string":return F.string;case"number":return isNaN($)?F.nan:F.number;case"boolean":return F.boolean;case"function":return F.function;case"bigint":return F.bigint;case"symbol":return F.symbol;case"object":if(Array.isArray($))return F.array;if($===null)return F.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return F.promise;if(typeof Map<"u"&&$ instanceof Map)return F.map;if(typeof Set<"u"&&$ instanceof Set)return F.set;if(typeof Date<"u"&&$ instanceof Date)return F.date;return F.object;default:return F.unknown}},j=R.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"]),H4=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class x extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};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(Y){return Y.message},X={_errors:[]},W=(Y)=>{for(let H of Y.issues)if(H.code==="invalid_union")H.unionErrors.map(W);else if(H.code==="invalid_return_type")W(H.returnTypeError);else if(H.code==="invalid_arguments")W(H.argumentsError);else if(H.path.length===0)X._errors.push(Q(H));else{let z=X,q=0;while(q<H.path.length){let O=H.path[q];if(q!==H.path.length-1)z[O]=z[O]||{_errors:[]};else z[O]=z[O]||{_errors:[]},z[O]._errors.push(Q(H));z=z[O],q++}}};return W(this),X}static assert($){if(!($ instanceof x))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(Q)=>Q.message){let Q={},X=[];for(let W of this.issues)if(W.path.length>0)Q[W.path[0]]=Q[W.path[0]]||[],Q[W.path[0]].push($(W));else X.push($(W));return{formErrors:X,fieldErrors:Q}}get formErrors(){return this.flatten()}}x.create=($)=>{return new x($)};var V1=($,Q)=>{let X;switch($.code){case j.invalid_type:if($.received===F.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case j.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,R.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:X=`Unrecognized key(s) in object: ${R.joinValues($.keys,", ")}`;break;case j.invalid_union:X="Invalid input";break;case j.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${R.joinValues($.options)}`;break;case j.invalid_enum_value:X=`Invalid enum value. Expected ${R.joinValues($.options)}, received '${$.received}'`;break;case j.invalid_arguments:X="Invalid function arguments";break;case j.invalid_return_type:X="Invalid function return type";break;case j.invalid_date:X="Invalid date";break;case j.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else R.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case j.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case j.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case j.custom:X="Invalid input";break;case j.invalid_intersection_types:X="Intersection results could not be merged";break;case j.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case j.not_finite:X="Number must be finite";break;default:X=Q.defaultError,R.assertNever($)}return{message:X}},S0=V1;function z4($){S0=$}function Z1(){return S0}var y1=($)=>{let{data:Q,path:X,errorMaps:W,issueData:Y}=$,H=[...X,...Y.path||[]],z={...Y,path:H};if(Y.message!==void 0)return{...Y,path:H,message:Y.message};let q="",O=W.filter((N)=>!!N).slice().reverse();for(let N of O)q=N(z,{data:Q,defaultError:q}).message;return{...Y,path:H,message:q}},B4=[];function U($,Q){let X=Z1(),W=y1({issueData:Q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===V1?void 0:V1].filter((Y)=>!!Y)});$.common.issues.push(W)}class h{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,Q){let X=[];for(let W of Q){if(W.status==="aborted")return _;if(W.status==="dirty")$.dirty();X.push(W.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,Q){let X=[];for(let W of Q){let Y=await W.key,H=await W.value;X.push({key:Y,value:H})}return h.mergeObjectSync($,X)}static mergeObjectSync($,Q){let X={};for(let W of Q){let{key:Y,value:H}=W;if(Y.status==="aborted")return _;if(H.status==="aborted")return _;if(Y.status==="dirty")$.dirty();if(H.status==="dirty")$.dirty();if(Y.value!=="__proto__"&&(typeof H.value<"u"||W.alwaysSet))X[Y.value]=H.value}return{status:$.value,value:X}}}var _=Object.freeze({status:"aborted"}),j1=($)=>({status:"dirty",value:$}),T=($)=>({status:"valid",value:$}),X0=($)=>$.status==="aborted",Y0=($)=>$.status==="dirty",J1=($)=>$.status==="valid",k1=($)=>typeof Promise<"u"&&$ instanceof Promise;function m1($,Q,X,W){if(X==="a"&&!W)throw TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!W:!Q.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?W:X==="a"?W.call($):W?W.value:Q.get($)}function _0($,Q,X,W,Y){if(W==="m")throw TypeError("Private method is not writable");if(W==="a"&&!Y)throw TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!Y:!Q.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?Y.call($,X):Y?Y.value=X:Q.set($,X),X}var K;(function($){$.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},$.toString=(Q)=>typeof Q==="string"?Q:Q===null||Q===void 0?void 0:Q.message})(K||(K={}));var R1,f1;class n{constructor($,Q,X,W){this._cachedPath=[],this.parent=$,this.data=Q,this._path=X,this._key=W}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var K0=($,Q)=>{if(J1(Q))return{success:!0,data:Q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new x($.common.issues);return this._error=X,this._error}}}};function v($){if(!$)return{};let{errorMap:Q,invalid_type_error:X,required_error:W,description:Y}=$;if(Q&&(X||W))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:Y};return{errorMap:(z,q)=>{var O,N;let{message:b}=$;if(z.code==="invalid_enum_value")return{message:b!==null&&b!==void 0?b:q.defaultError};if(typeof q.data>"u")return{message:(O=b!==null&&b!==void 0?b:W)!==null&&O!==void 0?O:q.defaultError};if(z.code!=="invalid_type")return{message:q.defaultError};return{message:(N=b!==null&&b!==void 0?b:X)!==null&&N!==void 0?N:q.defaultError}},description:Y}}class A{get description(){return this._def.description}_getType($){return r($.data)}_getOrReturnCtx($,Q){return Q||{common:$.parent.common,data:$.data,parsedType:r($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new h,ctx:{common:$.parent.common,data:$.data,parsedType:r($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let Q=this._parse($);if(k1(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync($){let Q=this._parse($);return Promise.resolve(Q)}parse($,Q){let X=this.safeParse($,Q);if(X.success)return X.data;throw X.error}safeParse($,Q){var X;let W={common:{issues:[],async:(X=Q===null||Q===void 0?void 0:Q.async)!==null&&X!==void 0?X:!1,contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)},Y=this._parseSync({data:$,path:W.path,parent:W});return K0(W,Y)}"~validate"($){var Q,X;let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)};if(!this["~standard"].async)try{let Y=this._parseSync({data:$,path:[],parent:W});return J1(Y)?{value:Y.value}:{issues:W.common.issues}}catch(Y){if((X=(Q=Y===null||Y===void 0?void 0:Y.message)===null||Q===void 0?void 0:Q.toLowerCase())===null||X===void 0?void 0:X.includes("encountered"))this["~standard"].async=!0;W.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:W}).then((Y)=>J1(Y)?{value:Y.value}:{issues:W.common.issues})}async parseAsync($,Q){let X=await this.safeParseAsync($,Q);if(X.success)return X.data;throw X.error}async safeParseAsync($,Q){let X={common:{issues:[],contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap,async:!0},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:r($)},W=this._parse({data:$,path:X.path,parent:X}),Y=await(k1(W)?W:Promise.resolve(W));return K0(X,Y)}refine($,Q){let X=(W)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(W);else return Q};return this._refinement((W,Y)=>{let H=$(W),z=()=>Y.addIssue({code:j.custom,...X(W)});if(typeof Promise<"u"&&H instanceof Promise)return H.then((q)=>{if(!q)return z(),!1;else return!0});if(!H)return z(),!1;else return!0})}refinement($,Q){return this._refinement((X,W)=>{if(!$(X))return W.addIssue(typeof Q==="function"?Q(X,W):Q),!1;else return!0})}_refinement($){return new y({schema:this,typeName:S.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 u.create(this,this._def)}nullable(){return e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return c.create(this)}promise(){return B1.create(this,this._def)}or($){return D1.create([this,$],this._def)}and($){return K1.create(this,$,this._def)}transform($){return new y({...v(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let Q=typeof $==="function"?$:()=>$;return new v1({...v(this._def),innerType:this,defaultValue:Q,typeName:S.ZodDefault})}brand(){return new c1({typeName:S.ZodBranded,type:this,...v(this._def)})}catch($){let Q=typeof $==="function"?$:()=>$;return new A1({...v(this._def),innerType:this,catchValue:Q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return h1.create(this,$)}readonly(){return b1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var w4=/^c[^\s-]{8,}$/i,q4=/^[0-9a-z]+$/,M4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j4=/^[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,O4=/^[a-z0-9_-]{21}$/i,V4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L4=/^[-+]?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)?)??$/,U4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",$0,D4=/^(?:(?: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])$/,K4=/^(?:(?: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])$/,N4=/^(([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]))$/,S4=/^(([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])$/,_4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,v4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,v0="((\\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])))",A4=new RegExp(`^${v0}$`);function A0($){let Q="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)Q=`${Q}\\.\\d{${$.precision}}`;else if($.precision==null)Q=`${Q}(\\.\\d+)?`;return Q}function b4($){return new RegExp(`^${A0($)}$`)}function b0($){let Q=`${v0}T${A0($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${X.join("|")})`,new RegExp(`^${Q}$`)}function R4($,Q){if((Q==="v4"||!Q)&&D4.test($))return!0;if((Q==="v6"||!Q)&&N4.test($))return!0;return!1}function f4($,Q){if(!V4.test($))return!1;try{let[X]=$.split("."),W=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Y=JSON.parse(atob(W));if(typeof Y!=="object"||Y===null)return!1;if(!Y.typ||!Y.alg)return!1;if(Q&&Y.alg!==Q)return!1;return!0}catch(X){return!1}}function k4($,Q){if((Q==="v4"||!Q)&&K4.test($))return!0;if((Q==="v6"||!Q)&&S4.test($))return!0;return!1}class l extends A{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==F.string){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.string,received:Y.parsedType}),_}let X=new h,W=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.length<Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="max"){if($.data.length>Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="length"){let H=$.data.length>Y.value,z=$.data.length<Y.value;if(H||z){if(W=this._getOrReturnCtx($,W),H)U(W,{code:j.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});else if(z)U(W,{code:j.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});X.dirty()}}else if(Y.kind==="email"){if(!U4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"email",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="emoji"){if(!$0)$0=new RegExp(F4,"u");if(!$0.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"emoji",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="uuid"){if(!j4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"uuid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="nanoid"){if(!O4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"nanoid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid"){if(!w4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid2"){if(!q4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid2",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ulid"){if(!M4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"ulid",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="url")try{new URL($.data)}catch(H){W=this._getOrReturnCtx($,W),U(W,{validation:"url",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="regex"){if(Y.regex.lastIndex=0,!Y.regex.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"regex",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="trim")$.data=$.data.trim();else if(Y.kind==="includes"){if(!$.data.includes(Y.value,Y.position))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{includes:Y.value,position:Y.position},message:Y.message}),X.dirty()}else if(Y.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Y.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Y.kind==="startsWith"){if(!$.data.startsWith(Y.value))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{startsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="endsWith"){if(!$.data.endsWith(Y.value))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:{endsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="datetime"){if(!b0(Y).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"datetime",message:Y.message}),X.dirty()}else if(Y.kind==="date"){if(!A4.test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"date",message:Y.message}),X.dirty()}else if(Y.kind==="time"){if(!b4(Y).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:j.invalid_string,validation:"time",message:Y.message}),X.dirty()}else if(Y.kind==="duration"){if(!L4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"duration",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ip"){if(!R4($.data,Y.version))W=this._getOrReturnCtx($,W),U(W,{validation:"ip",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="jwt"){if(!f4($.data,Y.alg))W=this._getOrReturnCtx($,W),U(W,{validation:"jwt",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cidr"){if(!k4($.data,Y.version))W=this._getOrReturnCtx($,W),U(W,{validation:"cidr",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64"){if(!_4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64",code:j.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64url"){if(!v4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64url",code:j.invalid_string,message:Y.message}),X.dirty()}else R.assertNever(Y);return{status:X.value,value:$.data}}_regex($,Q,X){return this.refinement((W)=>$.test(W),{validation:Q,code:j.invalid_string,...K.errToObj(X)})}_addCheck($){return new l({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...K.errToObj($)})}url($){return this._addCheck({kind:"url",...K.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...K.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...K.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...K.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...K.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...K.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...K.errToObj($)})}base64($){return this._addCheck({kind:"base64",...K.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...K.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...K.errToObj($)})}ip($){return this._addCheck({kind:"ip",...K.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...K.errToObj($)})}datetime($){var Q,X;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,offset:(Q=$===null||$===void 0?void 0:$.offset)!==null&&Q!==void 0?Q:!1,local:(X=$===null||$===void 0?void 0:$.local)!==null&&X!==void 0?X:!1,...K.errToObj($===null||$===void 0?void 0:$.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($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,...K.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...K.errToObj($)})}regex($,Q){return this._addCheck({kind:"regex",regex:$,...K.errToObj(Q)})}includes($,Q){return this._addCheck({kind:"includes",value:$,position:Q===null||Q===void 0?void 0:Q.position,...K.errToObj(Q===null||Q===void 0?void 0:Q.message)})}startsWith($,Q){return this._addCheck({kind:"startsWith",value:$,...K.errToObj(Q)})}endsWith($,Q){return this._addCheck({kind:"endsWith",value:$,...K.errToObj(Q)})}min($,Q){return this._addCheck({kind:"min",value:$,...K.errToObj(Q)})}max($,Q){return this._addCheck({kind:"max",value:$,...K.errToObj(Q)})}length($,Q){return this._addCheck({kind:"length",value:$,...K.errToObj(Q)})}nonempty($){return this.min(1,K.errToObj($))}trim(){return new l({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new l({...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 $}}l.create=($)=>{var Q;return new l({checks:[],typeName:S.ZodString,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};function C4($,Q){let X=($.toString().split(".")[1]||"").length,W=(Q.toString().split(".")[1]||"").length,Y=X>W?X:W,H=parseInt($.toFixed(Y).replace(".","")),z=parseInt(Q.toFixed(Y).replace(".",""));return H%z/Math.pow(10,Y)}class X1 extends A{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($)!==F.number){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.number,received:Y.parsedType}),_}let X=void 0,W=new h;for(let Y of this._def.checks)if(Y.kind==="int"){if(!R.isInteger($.data))X=this._getOrReturnCtx($,X),U(X,{code:j.invalid_type,expected:"integer",received:"float",message:Y.message}),W.dirty()}else if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_small,minimum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),W.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),W.dirty()}else if(Y.kind==="multipleOf"){if(C4($.data,Y.value)!==0)X=this._getOrReturnCtx($,X),U(X,{code:j.not_multiple_of,multipleOf:Y.value,message:Y.message}),W.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),U(X,{code:j.not_finite,message:Y.message}),W.dirty()}else R.assertNever(Y);return{status:W.value,value:$.data}}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new X1({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new X1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:K.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(Q)})}finite($){return this._addCheck({kind:"finite",message:K.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.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"&&R.isInteger($.value))}get isFinite(){let $=null,Q=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(Q===null||X.value>Q)Q=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(Q)&&Number.isFinite($)}}X1.create=($)=>{return new X1({checks:[],typeName:S.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class Y1 extends A{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(Y){return this._getInvalidInput($)}if(this._getType($)!==F.bigint)return this._getInvalidInput($);let X=void 0,W=new h;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_small,type:"bigint",minimum:Y.value,inclusive:Y.inclusive,message:Y.message}),W.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),U(X,{code:j.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),W.dirty()}else if(Y.kind==="multipleOf"){if($.data%Y.value!==BigInt(0))X=this._getOrReturnCtx($,X),U(X,{code:j.not_multiple_of,multipleOf:Y.value,message:Y.message}),W.dirty()}else R.assertNever(Y);return{status:W.value,value:$.data}}_getInvalidInput($){let Q=this._getOrReturnCtx($);return U(Q,{code:j.invalid_type,expected:F.bigint,received:Q.parsedType}),_}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new Y1({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new Y1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.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 $}}Y1.create=($)=>{var Q;return new Y1({checks:[],typeName:S.ZodBigInt,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};class L1 extends A{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==F.boolean){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.boolean,received:X.parsedType}),_}return T($.data)}}L1.create=($)=>{return new L1({typeName:S.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class G1 extends A{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==F.date){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_type,expected:F.date,received:Y.parsedType}),_}if(isNaN($.data.getTime())){let Y=this._getOrReturnCtx($);return U(Y,{code:j.invalid_date}),_}let X=new h,W=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.getTime()<Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_small,message:Y.message,inclusive:!0,exact:!1,minimum:Y.value,type:"date"}),X.dirty()}else if(Y.kind==="max"){if($.data.getTime()>Y.value)W=this._getOrReturnCtx($,W),U(W,{code:j.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),X.dirty()}else R.assertNever(Y);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new G1({...this._def,checks:[...this._def.checks,$]})}min($,Q){return this._addCheck({kind:"min",value:$.getTime(),message:K.toString(Q)})}max($,Q){return this._addCheck({kind:"max",value:$.getTime(),message:K.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}}G1.create=($)=>{return new G1({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:S.ZodDate,...v($)})};class C1 extends A{_parse($){if(this._getType($)!==F.symbol){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.symbol,received:X.parsedType}),_}return T($.data)}}C1.create=($)=>{return new C1({typeName:S.ZodSymbol,...v($)})};class U1 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.undefined,received:X.parsedType}),_}return T($.data)}}U1.create=($)=>{return new U1({typeName:S.ZodUndefined,...v($)})};class F1 extends A{_parse($){if(this._getType($)!==F.null){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.null,received:X.parsedType}),_}return T($.data)}}F1.create=($)=>{return new F1({typeName:S.ZodNull,...v($)})};class H1 extends A{constructor(){super(...arguments);this._any=!0}_parse($){return T($.data)}}H1.create=($)=>{return new H1({typeName:S.ZodAny,...v($)})};class Q1 extends A{constructor(){super(...arguments);this._unknown=!0}_parse($){return T($.data)}}Q1.create=($)=>{return new Q1({typeName:S.ZodUnknown,...v($)})};class i extends A{_parse($){let Q=this._getOrReturnCtx($);return U(Q,{code:j.invalid_type,expected:F.never,received:Q.parsedType}),_}}i.create=($)=>{return new i({typeName:S.ZodNever,...v($)})};class E1 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.void,received:X.parsedType}),_}return T($.data)}}E1.create=($)=>{return new E1({typeName:S.ZodVoid,...v($)})};class c extends A{_parse($){let{ctx:Q,status:X}=this._processInputParams($),W=this._def;if(Q.parsedType!==F.array)return U(Q,{code:j.invalid_type,expected:F.array,received:Q.parsedType}),_;if(W.exactLength!==null){let H=Q.data.length>W.exactLength.value,z=Q.data.length<W.exactLength.value;if(H||z)U(Q,{code:H?j.too_big:j.too_small,minimum:z?W.exactLength.value:void 0,maximum:H?W.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:W.exactLength.message}),X.dirty()}if(W.minLength!==null){if(Q.data.length<W.minLength.value)U(Q,{code:j.too_small,minimum:W.minLength.value,type:"array",inclusive:!0,exact:!1,message:W.minLength.message}),X.dirty()}if(W.maxLength!==null){if(Q.data.length>W.maxLength.value)U(Q,{code:j.too_big,maximum:W.maxLength.value,type:"array",inclusive:!0,exact:!1,message:W.maxLength.message}),X.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((H,z)=>{return W.type._parseAsync(new n(Q,H,Q.path,z))})).then((H)=>{return h.mergeArray(X,H)});let Y=[...Q.data].map((H,z)=>{return W.type._parseSync(new n(Q,H,Q.path,z))});return h.mergeArray(X,Y)}get element(){return this._def.type}min($,Q){return new c({...this._def,minLength:{value:$,message:K.toString(Q)}})}max($,Q){return new c({...this._def,maxLength:{value:$,message:K.toString(Q)}})}length($,Q){return new c({...this._def,exactLength:{value:$,message:K.toString(Q)}})}nonempty($){return this.min(1,$)}}c.create=($,Q)=>{return new c({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...v(Q)})};function M1($){if($ instanceof E){let Q={};for(let X in $.shape){let W=$.shape[X];Q[X]=u.create(M1(W))}return new E({...$._def,shape:()=>Q})}else if($ instanceof c)return new c({...$._def,type:M1($.element)});else if($ instanceof u)return u.create(M1($.unwrap()));else if($ instanceof e)return e.create(M1($.unwrap()));else if($ instanceof a)return a.create($.items.map((Q)=>M1(Q)));else return $}class E extends A{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=R.objectKeys($);return this._cached={shape:$,keys:Q}}_parse($){if(this._getType($)!==F.object){let O=this._getOrReturnCtx($);return U(O,{code:j.invalid_type,expected:F.object,received:O.parsedType}),_}let{status:X,ctx:W}=this._processInputParams($),{shape:Y,keys:H}=this._getCached(),z=[];if(!(this._def.catchall instanceof i&&this._def.unknownKeys==="strip")){for(let O in W.data)if(!H.includes(O))z.push(O)}let q=[];for(let O of H){let N=Y[O],b=W.data[O];q.push({key:{status:"valid",value:O},value:N._parse(new n(W,b,W.path,O)),alwaysSet:O in W.data})}if(this._def.catchall instanceof i){let O=this._def.unknownKeys;if(O==="passthrough")for(let N of z)q.push({key:{status:"valid",value:N},value:{status:"valid",value:W.data[N]}});else if(O==="strict"){if(z.length>0)U(W,{code:j.unrecognized_keys,keys:z}),X.dirty()}else if(O==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let O=this._def.catchall;for(let N of z){let b=W.data[N];q.push({key:{status:"valid",value:N},value:O._parse(new n(W,b,W.path,N)),alwaysSet:N in W.data})}}if(W.common.async)return Promise.resolve().then(async()=>{let O=[];for(let N of q){let b=await N.key,I=await N.value;O.push({key:b,value:I,alwaysSet:N.alwaysSet})}return O}).then((O)=>{return h.mergeObjectSync(X,O)});else return h.mergeObjectSync(X,q)}get shape(){return this._def.shape()}strict($){return K.errToObj,new E({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(Q,X)=>{var W,Y,H,z;let q=(H=(Y=(W=this._def).errorMap)===null||Y===void 0?void 0:Y.call(W,Q,X).message)!==null&&H!==void 0?H:X.defaultError;if(Q.code==="unrecognized_keys")return{message:(z=K.errToObj($).message)!==null&&z!==void 0?z:q};return{message:q}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend($){return new E({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new E({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,Q){return this.augment({[$]:Q})}catchall($){return new E({...this._def,catchall:$})}pick($){let Q={};return R.objectKeys($).forEach((X)=>{if($[X]&&this.shape[X])Q[X]=this.shape[X]}),new E({...this._def,shape:()=>Q})}omit($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if(!$[X])Q[X]=this.shape[X]}),new E({...this._def,shape:()=>Q})}deepPartial(){return M1(this)}partial($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{let W=this.shape[X];if($&&!$[X])Q[X]=W;else Q[X]=W.optional()}),new E({...this._def,shape:()=>Q})}required($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if($&&!$[X])Q[X]=this.shape[X];else{let Y=this.shape[X];while(Y instanceof u)Y=Y._def.innerType;Q[X]=Y}}),new E({...this._def,shape:()=>Q})}keyof(){return R0(R.objectKeys(this.shape))}}E.create=($,Q)=>{return new E({shape:()=>$,unknownKeys:"strip",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};E.strictCreate=($,Q)=>{return new E({shape:()=>$,unknownKeys:"strict",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};E.lazycreate=($,Q)=>{return new E({shape:$,unknownKeys:"strip",catchall:i.create(),typeName:S.ZodObject,...v(Q)})};class D1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=this._def.options;function W(Y){for(let z of Y)if(z.result.status==="valid")return z.result;for(let z of Y)if(z.result.status==="dirty")return Q.common.issues.push(...z.ctx.common.issues),z.result;let H=Y.map((z)=>new x(z.ctx.common.issues));return U(Q,{code:j.invalid_union,unionErrors:H}),_}if(Q.common.async)return Promise.all(X.map(async(Y)=>{let H={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:Q.data,path:Q.path,parent:H}),ctx:H}})).then(W);else{let Y=void 0,H=[];for(let q of X){let O={...Q,common:{...Q.common,issues:[]},parent:null},N=q._parseSync({data:Q.data,path:Q.path,parent:O});if(N.status==="valid")return N;else if(N.status==="dirty"&&!Y)Y={result:N,ctx:O};if(O.common.issues.length)H.push(O.common.issues)}if(Y)return Q.common.issues.push(...Y.ctx.common.issues),Y.result;let z=H.map((q)=>new x(q));return U(Q,{code:j.invalid_union,unionErrors:z}),_}}get options(){return this._def.options}}D1.create=($,Q)=>{return new D1({options:$,typeName:S.ZodUnion,...v(Q)})};var s=($)=>{if($ instanceof N1)return s($.schema);else if($ instanceof y)return s($.innerType());else if($ instanceof S1)return[$.value];else if($ instanceof W1)return $.options;else if($ instanceof _1)return R.objectValues($.enum);else if($ instanceof v1)return s($._def.innerType);else if($ instanceof U1)return[void 0];else if($ instanceof F1)return[null];else if($ instanceof u)return[void 0,...s($.unwrap())];else if($ instanceof e)return[null,...s($.unwrap())];else if($ instanceof c1)return s($.unwrap());else if($ instanceof b1)return s($.unwrap());else if($ instanceof A1)return s($._def.innerType);else return[]};class l1 extends A{_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.object)return U(Q,{code:j.invalid_type,expected:F.object,received:Q.parsedType}),_;let X=this.discriminator,W=Q.data[X],Y=this.optionsMap.get(W);if(!Y)return U(Q,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),_;if(Q.common.async)return Y._parseAsync({data:Q.data,path:Q.path,parent:Q});else return Y._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,X){let W=new Map;for(let Y of Q){let H=s(Y.shape[$]);if(!H.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let z of H){if(W.has(z))throw Error(`Discriminator property ${String($)} has duplicate value ${String(z)}`);W.set(z,Y)}}return new l1({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:Q,optionsMap:W,...v(X)})}}function W0($,Q){let X=r($),W=r(Q);if($===Q)return{valid:!0,data:$};else if(X===F.object&&W===F.object){let Y=R.objectKeys(Q),H=R.objectKeys($).filter((q)=>Y.indexOf(q)!==-1),z={...$,...Q};for(let q of H){let O=W0($[q],Q[q]);if(!O.valid)return{valid:!1};z[q]=O.data}return{valid:!0,data:z}}else if(X===F.array&&W===F.array){if($.length!==Q.length)return{valid:!1};let Y=[];for(let H=0;H<$.length;H++){let z=$[H],q=Q[H],O=W0(z,q);if(!O.valid)return{valid:!1};Y.push(O.data)}return{valid:!0,data:Y}}else if(X===F.date&&W===F.date&&+$===+Q)return{valid:!0,data:$};else return{valid:!1}}class K1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=(Y,H)=>{if(X0(Y)||X0(H))return _;let z=W0(Y.value,H.value);if(!z.valid)return U(X,{code:j.invalid_intersection_types}),_;if(Y0(Y)||Y0(H))Q.dirty();return{status:Q.value,value:z.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Y,H])=>W(Y,H));else return W(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}K1.create=($,Q,X)=>{return new K1({left:$,right:Q,typeName:S.ZodIntersection,...v(X)})};class a extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.array)return U(X,{code:j.invalid_type,expected:F.array,received:X.parsedType}),_;if(X.data.length<this._def.items.length)return U(X,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;if(!this._def.rest&&X.data.length>this._def.items.length)U(X,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let Y=[...X.data].map((H,z)=>{let q=this._def.items[z]||this._def.rest;if(!q)return null;return q._parse(new n(X,H,X.path,z))}).filter((H)=>!!H);if(X.common.async)return Promise.all(Y).then((H)=>{return h.mergeArray(Q,H)});else return h.mergeArray(Q,Y)}get items(){return this._def.items}rest($){return new a({...this._def,rest:$})}}a.create=($,Q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new a({items:$,typeName:S.ZodTuple,rest:null,...v(Q)})};class P1 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.object)return U(X,{code:j.invalid_type,expected:F.object,received:X.parsedType}),_;let W=[],Y=this._def.keyType,H=this._def.valueType;for(let z in X.data)W.push({key:Y._parse(new n(X,z,X.path,z)),value:H._parse(new n(X,X.data[z],X.path,z)),alwaysSet:z in X.data});if(X.common.async)return h.mergeObjectAsync(Q,W);else return h.mergeObjectSync(Q,W)}get element(){return this._def.valueType}static create($,Q,X){if(Q instanceof A)return new P1({keyType:$,valueType:Q,typeName:S.ZodRecord,...v(X)});return new P1({keyType:l.create(),valueType:$,typeName:S.ZodRecord,...v(Q)})}}class I1 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.map)return U(X,{code:j.invalid_type,expected:F.map,received:X.parsedType}),_;let W=this._def.keyType,Y=this._def.valueType,H=[...X.data.entries()].map(([z,q],O)=>{return{key:W._parse(new n(X,z,X.path,[O,"key"])),value:Y._parse(new n(X,q,X.path,[O,"value"]))}});if(X.common.async){let z=new Map;return Promise.resolve().then(async()=>{for(let q of H){let O=await q.key,N=await q.value;if(O.status==="aborted"||N.status==="aborted")return _;if(O.status==="dirty"||N.status==="dirty")Q.dirty();z.set(O.value,N.value)}return{status:Q.value,value:z}})}else{let z=new Map;for(let q of H){let{key:O,value:N}=q;if(O.status==="aborted"||N.status==="aborted")return _;if(O.status==="dirty"||N.status==="dirty")Q.dirty();z.set(O.value,N.value)}return{status:Q.value,value:z}}}}I1.create=($,Q,X)=>{return new I1({valueType:Q,keyType:$,typeName:S.ZodMap,...v(X)})};class z1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.set)return U(X,{code:j.invalid_type,expected:F.set,received:X.parsedType}),_;let W=this._def;if(W.minSize!==null){if(X.data.size<W.minSize.value)U(X,{code:j.too_small,minimum:W.minSize.value,type:"set",inclusive:!0,exact:!1,message:W.minSize.message}),Q.dirty()}if(W.maxSize!==null){if(X.data.size>W.maxSize.value)U(X,{code:j.too_big,maximum:W.maxSize.value,type:"set",inclusive:!0,exact:!1,message:W.maxSize.message}),Q.dirty()}let Y=this._def.valueType;function H(q){let O=new Set;for(let N of q){if(N.status==="aborted")return _;if(N.status==="dirty")Q.dirty();O.add(N.value)}return{status:Q.value,value:O}}let z=[...X.data.values()].map((q,O)=>Y._parse(new n(X,q,X.path,O)));if(X.common.async)return Promise.all(z).then((q)=>H(q));else return H(z)}min($,Q){return new z1({...this._def,minSize:{value:$,message:K.toString(Q)}})}max($,Q){return new z1({...this._def,maxSize:{value:$,message:K.toString(Q)}})}size($,Q){return this.min($,Q).max($,Q)}nonempty($){return this.min(1,$)}}z1.create=($,Q)=>{return new z1({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...v(Q)})};class O1 extends A{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.function)return U(Q,{code:j.invalid_type,expected:F.function,received:Q.parsedType}),_;function X(z,q){return y1({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,Z1(),V1].filter((O)=>!!O),issueData:{code:j.invalid_arguments,argumentsError:q}})}function W(z,q){return y1({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,Z1(),V1].filter((O)=>!!O),issueData:{code:j.invalid_return_type,returnTypeError:q}})}let Y={errorMap:Q.common.contextualErrorMap},H=Q.data;if(this._def.returns instanceof B1){let z=this;return T(async function(...q){let O=new x([]),N=await z._def.args.parseAsync(q,Y).catch((t)=>{throw O.addIssue(X(q,t)),O}),b=await Reflect.apply(H,this,N);return await z._def.returns._def.type.parseAsync(b,Y).catch((t)=>{throw O.addIssue(W(b,t)),O})})}else{let z=this;return T(function(...q){let O=z._def.args.safeParse(q,Y);if(!O.success)throw new x([X(q,O.error)]);let N=Reflect.apply(H,this,O.data),b=z._def.returns.safeParse(N,Y);if(!b.success)throw new x([W(N,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new O1({...this._def,args:a.create($).rest(Q1.create())})}returns($){return new O1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,Q,X){return new O1({args:$?$:a.create([]).rest(Q1.create()),returns:Q||Q1.create(),typeName:S.ZodFunction,...v(X)})}}class N1 extends A{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})}}N1.create=($,Q)=>{return new N1({getter:$,typeName:S.ZodLazy,...v(Q)})};class S1 extends A{_parse($){if($.data!==this._def.value){let Q=this._getOrReturnCtx($);return U(Q,{received:Q.data,code:j.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:$.data}}get value(){return this._def.value}}S1.create=($,Q)=>{return new S1({value:$,typeName:S.ZodLiteral,...v(Q)})};function R0($,Q){return new W1({values:$,typeName:S.ZodEnum,...v(Q)})}class W1 extends A{constructor(){super(...arguments);R1.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{expected:R.joinValues(X),received:Q.parsedType,code:j.invalid_type}),_}if(!m1(this,R1,"f"))_0(this,R1,new Set(this._def.values),"f");if(!m1(this,R1,"f").has($.data)){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{received:Q.data,code:j.invalid_enum_value,options:X}),_}return T($.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 W1.create($,{...this._def,...Q})}exclude($,Q=this._def){return W1.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...Q})}}R1=new WeakMap;W1.create=R0;class _1 extends A{constructor(){super(...arguments);f1.set(this,void 0)}_parse($){let Q=R.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==F.string&&X.parsedType!==F.number){let W=R.objectValues(Q);return U(X,{expected:R.joinValues(W),received:X.parsedType,code:j.invalid_type}),_}if(!m1(this,f1,"f"))_0(this,f1,new Set(R.getValidEnumValues(this._def.values)),"f");if(!m1(this,f1,"f").has($.data)){let W=R.objectValues(Q);return U(X,{received:X.data,code:j.invalid_enum_value,options:W}),_}return T($.data)}get enum(){return this._def.values}}f1=new WeakMap;_1.create=($,Q)=>{return new _1({values:$,typeName:S.ZodNativeEnum,...v(Q)})};class B1 extends A{unwrap(){return this._def.type}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.promise&&Q.common.async===!1)return U(Q,{code:j.invalid_type,expected:F.promise,received:Q.parsedType}),_;let X=Q.parsedType===F.promise?Q.data:Promise.resolve(Q.data);return T(X.then((W)=>{return this._def.type.parseAsync(W,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}B1.create=($,Q)=>{return new B1({type:$,typeName:S.ZodPromise,...v(Q)})};class y extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=this._def.effect||null,Y={addIssue:(H)=>{if(U(X,H),H.fatal)Q.abort();else Q.dirty()},get path(){return X.path}};if(Y.addIssue=Y.addIssue.bind(Y),W.type==="preprocess"){let H=W.transform(X.data,Y);if(X.common.async)return Promise.resolve(H).then(async(z)=>{if(Q.value==="aborted")return _;let q=await this._def.schema._parseAsync({data:z,path:X.path,parent:X});if(q.status==="aborted")return _;if(q.status==="dirty")return j1(q.value);if(Q.value==="dirty")return j1(q.value);return q});else{if(Q.value==="aborted")return _;let z=this._def.schema._parseSync({data:H,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")return j1(z.value);if(Q.value==="dirty")return j1(z.value);return z}}if(W.type==="refinement"){let H=(z)=>{let q=W.refinement(z,Y);if(X.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return z};if(X.common.async===!1){let z=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value),{status:Q.value,value:z.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((z)=>{if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value).then(()=>{return{status:Q.value,value:z.value}})})}if(W.type==="transform")if(X.common.async===!1){let H=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!J1(H))return H;let z=W.transform(H.value,Y);if(z instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:z}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((H)=>{if(!J1(H))return H;return Promise.resolve(W.transform(H.value,Y)).then((z)=>({status:Q.value,value:z}))});R.assertNever(W)}}y.create=($,Q,X)=>{return new y({schema:$,typeName:S.ZodEffects,effect:Q,...v(X)})};y.createWithPreprocess=($,Q,X)=>{return new y({schema:Q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...v(X)})};class u extends A{_parse($){if(this._getType($)===F.undefined)return T(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}u.create=($,Q)=>{return new u({innerType:$,typeName:S.ZodOptional,...v(Q)})};class e extends A{_parse($){if(this._getType($)===F.null)return T(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e.create=($,Q)=>{return new e({innerType:$,typeName:S.ZodNullable,...v(Q)})};class v1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;if(Q.parsedType===F.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}v1.create=($,Q)=>{return new v1({innerType:$,typeName:S.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...v(Q)})};class A1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X={...Q,common:{...Q.common,issues:[]}},W=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(k1(W))return W.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}});else return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}A1.create=($,Q)=>{return new A1({innerType:$,typeName:S.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...v(Q)})};class g1 extends A{_parse($){if(this._getType($)!==F.nan){let X=this._getOrReturnCtx($);return U(X,{code:j.invalid_type,expected:F.nan,received:X.parsedType}),_}return{status:"valid",value:$.data}}}g1.create=($)=>{return new g1({typeName:S.ZodNaN,...v($)})};var E4=Symbol("zod_brand");class c1 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;return this._def.type._parse({data:X,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class h1 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return _;if(Y.status==="dirty")return Q.dirty(),j1(Y.value);else return this._def.out._parseAsync({data:Y.value,path:X.path,parent:X})})();else{let W=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return _;if(W.status==="dirty")return Q.dirty(),{status:"dirty",value:W.value};else return this._def.out._parseSync({data:W.value,path:X.path,parent:X})}}static create($,Q){return new h1({in:$,out:Q,typeName:S.ZodPipeline})}}class b1 extends A{_parse($){let Q=this._def.innerType._parse($),X=(W)=>{if(J1(W))W.value=Object.freeze(W.value);return W};return k1(Q)?Q.then((W)=>X(W)):X(Q)}unwrap(){return this._def.innerType}}b1.create=($,Q)=>{return new b1({innerType:$,typeName:S.ZodReadonly,...v(Q)})};function f0($,Q={},X){if($)return H1.create().superRefine((W,Y)=>{var H,z;if(!$(W)){let q=typeof Q==="function"?Q(W):typeof Q==="string"?{message:Q}:Q,O=(z=(H=q.fatal)!==null&&H!==void 0?H:X)!==null&&z!==void 0?z:!0,N=typeof q==="string"?{message:q}:q;Y.addIssue({code:"custom",...N,fatal:O})}});return H1.create()}var P4={object:E.lazycreate},S;(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"})(S||(S={}));var I4=($,Q={message:`Input not instance of ${$.name}`})=>f0((X)=>X instanceof $,Q),k0=l.create,C0=X1.create,g4=g1.create,h4=Y1.create,E0=L1.create,T4=G1.create,x4=C1.create,Z4=U1.create,y4=F1.create,m4=H1.create,l4=Q1.create,c4=i.create,u4=E1.create,n4=c.create,p4=E.create,d4=E.strictCreate,i4=D1.create,a4=l1.create,o4=K1.create,t4=a.create,s4=P1.create,r4=I1.create,e4=z1.create,$2=O1.create,Q2=N1.create,X2=S1.create,Y2=W1.create,W2=_1.create,J2=B1.create,N0=y.create,G2=u.create,H2=e.create,z2=y.createWithPreprocess,B2=h1.create,w2=()=>k0().optional(),q2=()=>C0().optional(),M2=()=>E0().optional(),j2={string:($)=>l.create({...$,coerce:!0}),number:($)=>X1.create({...$,coerce:!0}),boolean:($)=>L1.create({...$,coerce:!0}),bigint:($)=>Y1.create({...$,coerce:!0}),date:($)=>G1.create({...$,coerce:!0})},O2=_,G=Object.freeze({__proto__:null,defaultErrorMap:V1,setErrorMap:z4,getErrorMap:Z1,makeIssue:y1,EMPTY_PATH:B4,addIssueToContext:U,ParseStatus:h,INVALID:_,DIRTY:j1,OK:T,isAborted:X0,isDirty:Y0,isValid:J1,isAsync:k1,get util(){return R},get objectUtil(){return Q0},ZodParsedType:F,getParsedType:r,ZodType:A,datetimeRegex:b0,ZodString:l,ZodNumber:X1,ZodBigInt:Y1,ZodBoolean:L1,ZodDate:G1,ZodSymbol:C1,ZodUndefined:U1,ZodNull:F1,ZodAny:H1,ZodUnknown:Q1,ZodNever:i,ZodVoid:E1,ZodArray:c,ZodObject:E,ZodUnion:D1,ZodDiscriminatedUnion:l1,ZodIntersection:K1,ZodTuple:a,ZodRecord:P1,ZodMap:I1,ZodSet:z1,ZodFunction:O1,ZodLazy:N1,ZodLiteral:S1,ZodEnum:W1,ZodNativeEnum:_1,ZodPromise:B1,ZodEffects:y,ZodTransformer:y,ZodOptional:u,ZodNullable:e,ZodDefault:v1,ZodCatch:A1,ZodNaN:g1,BRAND:E4,ZodBranded:c1,ZodPipeline:h1,ZodReadonly:b1,custom:f0,Schema:A,ZodSchema:A,late:P4,get ZodFirstPartyTypeKind(){return S},coerce:j2,any:m4,array:n4,bigint:h4,boolean:E0,date:T4,discriminatedUnion:a4,effect:N0,enum:Y2,function:$2,instanceof:I4,intersection:o4,lazy:Q2,literal:X2,map:r4,nan:g4,nativeEnum:W2,never:c4,null:y4,nullable:H2,number:C0,object:p4,oboolean:M2,onumber:q2,optional:G2,ostring:w2,pipeline:B2,preprocess:z2,promise:J2,record:s4,set:e4,strictObject:d4,string:k0,symbol:x4,transformer:N0,tuple:t4,undefined:Z4,union:i4,unknown:l4,void:u4,NEVER:O2,ZodIssueCode:j,quotelessJson:H4,ZodError:x});var J0="2024-11-05",P0=[J0,"2024-10-07"],u1="2.0",I0=G.union([G.string(),G.number().int()]),g0=G.string(),p=G.object({_meta:G.optional(G.object({progressToken:G.optional(I0)}).passthrough())}).passthrough(),Z=G.object({method:G.string(),params:G.optional(p)}),T1=G.object({_meta:G.optional(G.object({}).passthrough())}).passthrough(),o=G.object({method:G.string(),params:G.optional(T1)}),d=G.object({_meta:G.optional(G.object({}).passthrough())}).passthrough(),n1=G.union([G.string(),G.number().int()]),V2=G.object({jsonrpc:G.literal(u1),id:n1}).merge(Z).strict(),L2=G.object({jsonrpc:G.literal(u1)}).merge(o).strict(),U2=G.object({jsonrpc:G.literal(u1),id:n1,result:d}).strict(),w1;(function($){$[$.ConnectionClosed=-1]="ConnectionClosed",$[$.RequestTimeout=-2]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(w1||(w1={}));var F2=G.object({jsonrpc:G.literal(u1),id:n1,error:G.object({code:G.number().int(),message:G.string(),data:G.optional(G.unknown())})}).strict(),h0=G.union([V2,L2,U2,F2]),p1=d.strict(),d1=o.extend({method:G.literal("notifications/cancelled"),params:T1.extend({requestId:n1,reason:G.string().optional()})}),T0=G.object({name:G.string(),version:G.string()}).passthrough(),D2=G.object({experimental:G.optional(G.object({}).passthrough()),sampling:G.optional(G.object({}).passthrough()),roots:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough())}).passthrough(),G0=Z.extend({method:G.literal("initialize"),params:p.extend({protocolVersion:G.string(),capabilities:D2,clientInfo:T0})}),K2=G.object({experimental:G.optional(G.object({}).passthrough()),logging:G.optional(G.object({}).passthrough()),prompts:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough()),resources:G.optional(G.object({subscribe:G.optional(G.boolean()),listChanged:G.optional(G.boolean())}).passthrough()),tools:G.optional(G.object({listChanged:G.optional(G.boolean())}).passthrough())}).passthrough(),N2=d.extend({protocolVersion:G.string(),capabilities:K2,serverInfo:T0}),H0=o.extend({method:G.literal("notifications/initialized")}),i1=Z.extend({method:G.literal("ping")}),S2=G.object({progress:G.number(),total:G.optional(G.number())}).passthrough(),a1=o.extend({method:G.literal("notifications/progress"),params:T1.merge(S2).extend({progressToken:I0})}),o1=Z.extend({params:p.extend({cursor:G.optional(g0)}).optional()}),t1=d.extend({nextCursor:G.optional(g0)}),x0=G.object({uri:G.string(),mimeType:G.optional(G.string())}).passthrough(),Z0=x0.extend({text:G.string()}),y0=x0.extend({blob:G.string().base64()}),_2=G.object({uri:G.string(),name:G.string(),description:G.optional(G.string()),mimeType:G.optional(G.string())}).passthrough(),v2=G.object({uriTemplate:G.string(),name:G.string(),description:G.optional(G.string()),mimeType:G.optional(G.string())}).passthrough(),A2=o1.extend({method:G.literal("resources/list")}),b2=t1.extend({resources:G.array(_2)}),R2=o1.extend({method:G.literal("resources/templates/list")}),f2=t1.extend({resourceTemplates:G.array(v2)}),k2=Z.extend({method:G.literal("resources/read"),params:p.extend({uri:G.string()})}),C2=d.extend({contents:G.array(G.union([Z0,y0]))}),E2=o.extend({method:G.literal("notifications/resources/list_changed")}),P2=Z.extend({method:G.literal("resources/subscribe"),params:p.extend({uri:G.string()})}),I2=Z.extend({method:G.literal("resources/unsubscribe"),params:p.extend({uri:G.string()})}),g2=o.extend({method:G.literal("notifications/resources/updated"),params:T1.extend({uri:G.string()})}),h2=G.object({name:G.string(),description:G.optional(G.string()),required:G.optional(G.boolean())}).passthrough(),T2=G.object({name:G.string(),description:G.optional(G.string()),arguments:G.optional(G.array(h2))}).passthrough(),x2=o1.extend({method:G.literal("prompts/list")}),Z2=t1.extend({prompts:G.array(T2)}),y2=Z.extend({method:G.literal("prompts/get"),params:p.extend({name:G.string(),arguments:G.optional(G.record(G.string()))})}),s1=G.object({type:G.literal("text"),text:G.string()}).passthrough(),r1=G.object({type:G.literal("image"),data:G.string().base64(),mimeType:G.string()}).passthrough(),m0=G.object({type:G.literal("resource"),resource:G.union([Z0,y0])}).passthrough(),m2=G.object({role:G.enum(["user","assistant"]),content:G.union([s1,r1,m0])}).passthrough(),l2=d.extend({description:G.optional(G.string()),messages:G.array(m2)}),c2=o.extend({method:G.literal("notifications/prompts/list_changed")}),u2=G.object({name:G.string(),description:G.optional(G.string()),inputSchema:G.object({type:G.literal("object"),properties:G.optional(G.object({}).passthrough())}).passthrough()}).passthrough(),z0=o1.extend({method:G.literal("tools/list")}),n2=t1.extend({tools:G.array(u2)}),l0=d.extend({content:G.array(G.union([s1,r1,m0])),isError:G.boolean().default(!1).optional()}),l6=l0.or(d.extend({toolResult:G.unknown()})),B0=Z.extend({method:G.literal("tools/call"),params:p.extend({name:G.string(),arguments:G.optional(G.record(G.unknown()))})}),p2=o.extend({method:G.literal("notifications/tools/list_changed")}),c0=G.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),d2=Z.extend({method:G.literal("logging/setLevel"),params:p.extend({level:c0})}),i2=o.extend({method:G.literal("notifications/message"),params:T1.extend({level:c0,logger:G.optional(G.string()),data:G.unknown()})}),a2=G.object({name:G.string().optional()}).passthrough(),o2=G.object({hints:G.optional(G.array(a2)),costPriority:G.optional(G.number().min(0).max(1)),speedPriority:G.optional(G.number().min(0).max(1)),intelligencePriority:G.optional(G.number().min(0).max(1))}).passthrough(),t2=G.object({role:G.enum(["user","assistant"]),content:G.union([s1,r1])}).passthrough(),s2=Z.extend({method:G.literal("sampling/createMessage"),params:p.extend({messages:G.array(t2),systemPrompt:G.optional(G.string()),includeContext:G.optional(G.enum(["none","thisServer","allServers"])),temperature:G.optional(G.number()),maxTokens:G.number().int(),stopSequences:G.optional(G.array(G.string())),metadata:G.optional(G.object({}).passthrough()),modelPreferences:G.optional(o2)})}),w0=d.extend({model:G.string(),stopReason:G.optional(G.enum(["endTurn","stopSequence","maxTokens"]).or(G.string())),role:G.enum(["user","assistant"]),content:G.discriminatedUnion("type",[s1,r1])}),r2=G.object({type:G.literal("ref/resource"),uri:G.string()}).passthrough(),e2=G.object({type:G.literal("ref/prompt"),name:G.string()}).passthrough(),$6=Z.extend({method:G.literal("completion/complete"),params:p.extend({ref:G.union([e2,r2]),argument:G.object({name:G.string(),value:G.string()}).passthrough()})}),Q6=d.extend({completion:G.object({values:G.array(G.string()).max(100),total:G.optional(G.number().int()),hasMore:G.optional(G.boolean())}).passthrough()}),X6=G.object({uri:G.string().startsWith("file://"),name:G.optional(G.string())}).passthrough(),Y6=Z.extend({method:G.literal("roots/list")}),q0=d.extend({roots:G.array(X6)}),W6=o.extend({method:G.literal("notifications/roots/list_changed")}),c6=G.union([i1,G0,$6,d2,y2,x2,A2,R2,k2,P2,I2,B0,z0]),u6=G.union([d1,a1,H0,W6]),n6=G.union([p1,w0,q0]),p6=G.union([i1,s2,Y6]),d6=G.union([d1,a1,i2,g2,E2,p2,c2]),i6=G.union([p1,N2,Q6,l2,Z2,b2,f2,C2,l0,n2]);class x1 extends Error{constructor($,Q,X){super(`MCP error ${$}: ${Q}`);this.code=$,this.data=X}}var J6=60000;class M0{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.setNotificationHandler(d1,(Q)=>{let X=this._requestHandlerAbortControllers.get(Q.params.requestId);X===null||X===void 0||X.abort(Q.params.reason)}),this.setNotificationHandler(a1,(Q)=>{this._onprogress(Q)}),this.setRequestHandler(i1,(Q)=>({}))}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(Q)=>{this._onerror(Q)},this._transport.onmessage=(Q)=>{if(!("method"in Q))this._onresponse(Q);else if("id"in Q)this._onrequest(Q);else this._onnotification(Q)},await this._transport.start()}_onclose(){var $;let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new x1(w1.ConnectionClosed,"Connection closed");for(let W of Q.values())W(X)}_onerror($){var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,$)}_onnotification($){var Q;let X=(Q=this._notificationHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((W)=>this._onerror(Error(`Uncaught error in notification handler: ${W}`)))}_onrequest($){var Q,X;let W=(Q=this._requestHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackRequestHandler;if(W===void 0){(X=this._transport)===null||X===void 0||X.send({jsonrpc:"2.0",id:$.id,error:{code:w1.MethodNotFound,message:"Method not found"}}).catch((H)=>this._onerror(Error(`Failed to send an error response: ${H}`)));return}let Y=new AbortController;this._requestHandlerAbortControllers.set($.id,Y),Promise.resolve().then(()=>W($,{signal:Y.signal})).then((H)=>{var z;if(Y.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({result:H,jsonrpc:"2.0",id:$.id})},(H)=>{var z,q;if(Y.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(H.code)?H.code:w1.InternalError,message:(q=H.message)!==null&&q!==void 0?q:"Internal error"}})}).catch((H)=>this._onerror(Error(`Failed to send response: ${H}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:Q,...X}=$.params,W=this._progressHandlers.get(Number(Q));if(W===void 0){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}W(X)}_onresponse($){let Q=$.id,X=this._responseHandlers.get(Number(Q));if(X===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(Number(Q)),this._progressHandlers.delete(Number(Q)),"result"in $)X($);else{let W=new x1($.error.code,$.error.message,$.error.data);X(W)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,Q,X){return new Promise((W,Y)=>{var H,z,q,O;if(!this._transport){Y(Error("Not connected"));return}if(((H=this._options)===null||H===void 0?void 0:H.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(z=X===null||X===void 0?void 0:X.signal)===null||z===void 0||z.throwIfAborted();let N=this._requestMessageId++,b={...$,jsonrpc:"2.0",id:N};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(N,X.onprogress),b.params={...$.params,_meta:{progressToken:N}};let I=void 0;this._responseHandlers.set(N,(k)=>{var P;if(I!==void 0)clearTimeout(I);if((P=X===null||X===void 0?void 0:X.signal)===null||P===void 0?void 0:P.aborted)return;if(k instanceof Error)return Y(k);try{let g=Q.parse(k.result);W(g)}catch(g){Y(g)}});let t=(k)=>{var P;this._responseHandlers.delete(N),this._progressHandlers.delete(N),(P=this._transport)===null||P===void 0||P.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:N,reason:String(k)}}).catch((g)=>this._onerror(Error(`Failed to send cancellation: ${g}`))),Y(k)};(q=X===null||X===void 0?void 0:X.signal)===null||q===void 0||q.addEventListener("abort",()=>{var k;if(I!==void 0)clearTimeout(I);t((k=X===null||X===void 0?void 0:X.signal)===null||k===void 0?void 0:k.reason)});let m=(O=X===null||X===void 0?void 0:X.timeout)!==null&&O!==void 0?O:J6;I=setTimeout(()=>t(new x1(w1.RequestTimeout,"Request timed out",{timeout:m})),m),this._transport.send(b).catch((k)=>{if(I!==void 0)clearTimeout(I);Y(k)})})}async notification($){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let Q={...$,jsonrpc:"2.0"};await this._transport.send(Q)}setRequestHandler($,Q){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,Y)=>Promise.resolve(Q($.parse(W),Y)))}removeRequestHandler($){this._requestHandlers.delete($)}setNotificationHandler($,Q){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(Q($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}class j0 extends M0{constructor($,Q){super(Q);this._serverInfo=$,this._capabilities=Q.capabilities,this.setRequestHandler(G0,(X)=>this._oninitialize(X)),this.setNotificationHandler(H0,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}assertCapabilityForMethod($){var Q,X;switch($){case"sampling/createMessage":if(!((Q=this._clientCapabilities)===null||Q===void 0?void 0:Q.sampling))throw Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw 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 Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw 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:P0.includes(Q)?Q:J0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},p1)}async createMessage($,Q){return this.request({method:"sampling/createMessage",params:$},w0,Q)}async listRoots($,Q){return this.request({method:"roots/list",params:$},q0,Q)}async sendLoggingMessage($){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"})}}import n0 from"process";class O0{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
|
3
3
|
`);if($===-1)return null;let Q=this._buffer.toString("utf8",0,$);return this._buffer=this._buffer.subarray($+1),G6(Q)}clear(){this._buffer=void 0}}function G6($){return h0.parse(JSON.parse($))}function u0($){return JSON.stringify($)+`
|
|
4
4
|
`}class V0{constructor($=n0.stdin,Q=n0.stdout){this._stdin=$,this._stdout=Q,this._readBuffer=new O0,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{var W;(W=this.onerror)===null||W===void 0||W.call(this,X)}}async start(){if(this._started)throw 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 X=this._readBuffer.readMessage();if(X===null)break;($=this.onmessage)===null||$===void 0||$.call(this,X)}catch(X){(Q=this.onerror)===null||Q===void 0||Q.call(this,X)}}async close(){var $;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((Q)=>{let X=u0($);if(this._stdout.write(X))Q();else this._stdout.once("drain",Q)})}}var z6=await Promise.resolve().then(() => J4(p0(),1)),d0=z6.version;async function i0($){let Q=new j0({name:"typescape",version:d0},{capabilities:{tools:{}}});Q.setRequestHandler(z0,async()=>{return{tools:$.getTools().map((Y)=>({name:Y.name,description:Y.description,inputSchema:Y.inputSchema}))}}),Q.setRequestHandler(B0,async(W)=>{let{name:Y,arguments:H}=W.params,z=$.getHandler(Y);if(!z)return{content:[{type:"text",text:`Unknown tool: ${Y}`}],isError:!0};try{let q=await z(H||{});return{content:q.content.map((O)=>({type:O.type,text:O.text})),isError:q.isError}}catch(q){return{content:[{type:"text",text:`Error: ${q instanceof Error?q.message:String(q)}`}],isError:!0}}});let X=new V0;await Q.connect(X),console.error(`Typescape MCP server v${d0} started`)}var L0=["file","doc","pr","custom"],B6=new Set(L0),w6={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier (short slug, e.g. 'typescape'; not a GitHub path like 'org/repo')"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo"},title:{type:"string",description:"Session title (optional)"},participants:{type:"array",minItems:1,items:{type:"object",properties:{email:{type:"string"},name:{type:"string"},role:{type:"string",enum:["reviewer","approver","observer","owner"]},scopes:{type:"array",minItems:1,items:{type:"string",enum:["read","comment","approve","admin"]}}},required:["email","role","scopes"]},description:"Participants to invite (at least one required). Each must include email, role, and scopes."},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["repo_id","git_sha","file_path","participants"]},q6={type:"object",properties:{session_id:{type:"string",description:"ID of the session to supersede (the predecessor, e.g., sess_01HXYZ...)"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA for the new revision (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo (optional; defaults to predecessor's file_path)"},title:{type:"string",description:"Title for the new session (optional; defaults to predecessor's title)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","git_sha"]},M6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export (e.g., sess_01HXYZ...)"},schema:{type:"string",default:"v1",description:"Export schema version (default: v1)"},view:{type:"string",description:"Export view variant (optional). Values: redacted, response_matrix.v1, delta_review.v1"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id"]},j6={type:"object",properties:{repo_id:{type:"string",description:"Filter sessions by repository identifier (short slug, e.g. 'typescape'; optional)"},state:{type:"string",description:"Filter by session state: active, closed, archived (optional)"},file_paths:{type:"string",description:"Comma-separated list of file paths to filter by (optional)"},cursor:{type:"string",description:"Pagination cursor from previous response (optional)"},limit:{type:"number",description:"Maximum number of sessions to return (optional, default: 20)"},root_session_id:{type:"string",description:"Filter by supersede chain root session ID (optional, e.g., sess_...)"},supersedes_session_id:{type:"string",description:"Filter by immediate predecessor session ID (optional, e.g., sess_...)"},has_successor:{type:"boolean",description:"If true, return only sessions that have been superseded; if false, only chain heads (optional)"}},required:[]},O6={type:"object",properties:{session_id:{type:"string",description:"Session ID to retrieve (e.g., sess_01HXYZ...)"}},required:["session_id"]},V6={type:"object",properties:{session_id:{type:"string",description:"Session ID to render (e.g., sess_01HXYZ...)"},include_plaintext:{type:"boolean",description:"Include plaintext representation alongside HTML (optional, default: false)"}},required:["session_id"]},L6={type:"object",properties:{session_id:{type:"string",description:"Session ID to list threads for (e.g., sess_01HXYZ...)"},block_id:{type:"string",description:"Filter threads by block_id anchor (optional)"},status:{type:"string",description:"Filter threads by status: open, resolved, all (optional, default: all)"},cursor:{type:"string",description:"Pagination cursor from previous response (optional)"},limit:{type:"number",description:"Maximum number of threads to return (optional, default: 50)"}},required:["session_id"]},U6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export response matrix for (e.g., sess_01HXYZ...)"}},required:["session_id"]};function f($,Q){return{content:[{type:"text",text:JSON.stringify({...$,request_id:Q},null,2)}]}}function L($){let Q=$.status===0||$.status>=500||$.status===429;return{content:[{type:"text",text:JSON.stringify({error:{code:$.code,message:$.message,retryable:Q,request_id:$.requestId,...$.details?{details:$.details}:{},...$.fixHint?{fix_hint:$.fixHint}:{}}},null,2)}],isError:!0}}var F6={type:"object",properties:{source_type:{type:"string",enum:["git","upload"],description:"Source type for the review set"},title:{type:"string",description:"Review set title (optional)"},kind:{type:"string",enum:["review_set","release_bundle","packet"],description:"Kind of review set (optional, default: review_set)"},participants:{type:"array",items:{type:"object",properties:{email:{type:"string"},role:{type:"string"}},required:["email","role"]},description:"Participants to invite (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["source_type"]},D6={type:"object",properties:{review_set_id:{type:"string",description:"Review set ID to export"},schema:{type:"string",description:"Export schema version (optional, default: v1)"},view:{type:"string",description:"Export view variant (optional). Values: full, redacted, response_matrix.v1, etc."}},required:["review_set_id"]},K6={type:"object",properties:{source_type:{type:"string",enum:["git","upload"],description:"Source type for the review ref"},repo_id:{type:"string",description:"Repository identifier (required for git source_type; short slug, e.g. 'typescape')"},project_id:{type:"string",description:"Project identifier (required for upload source_type; omit for git)"},kind:{type:"string",enum:L0,description:"Review ref kind"},key:{type:"string",description:"Review ref key (e.g., file path, doc slug, PR number, custom name)"},head_session_id:{type:"string",description:"Session ID to use as the initial head (required, e.g., sess_01HXYZ...)"}},required:["source_type","kind","key","head_session_id"]},N6={type:"object",properties:{review_ref_id:{type:"string",description:"Review ref ID to resolve"}},required:["review_ref_id"]},S6={type:"object",properties:{review_ref_id:{type:"string",description:"Review ref ID to advance"},head_session_id:{type:"string",description:"New head session ID to advance to"},expected_head_session_id:{type:"string",description:"Expected current head for optimistic concurrency (optional)"}},required:["review_ref_id","head_session_id"]},_6={type:"object",properties:{session_id:{type:"string",description:"Session ID to request approval for"},approver_emails:{type:"array",items:{type:"string"},description:"Email addresses of approvers"},message:{type:"string",description:"Message to include with the approval request (optional)"},notify:{type:"object",properties:{email:{type:"boolean"},slack:{type:"boolean"}},description:"Notification channels (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","approver_emails"]},v6={type:"object",properties:{session_id:{type:"string",description:"Session ID to record decision for"},decision:{type:"string",enum:["approve","deny","abstain"],description:"Approval decision"},comment_md:{type:"string",description:"Comment in Markdown (optional)"},conditions:{type:"array",items:{type:"object",properties:{type:{type:"string"},description:{type:"string"}},required:["type"]},description:"Conditions for the approval (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","decision"]},A6={type:"object",properties:{session_id:{type:"string",description:"Session ID to get status for"},simulate:{type:"boolean",description:"Run policy evaluation without side effects (optional)"},wait:{type:"number",description:"Long-poll timeout in seconds (optional)"}},required:["session_id"]},b6={type:"object",properties:{session_id:{type:"string",description:"Session ID to run checks against"}},required:["session_id"]},R6={type:"object",properties:{session_id:{type:"string",description:"Session ID to create thread in (e.g., sess_01HXYZ...)"},body_md:{type:"string",description:"Thread body in Markdown"},block_id:{type:"string",description:"Block ID to anchor thread to (optional; omit for session-level)"},anchor:{type:"object",properties:{type:{type:"string",enum:["session","block","range"],description:"Anchor type (default: session if no block_id, block if block_id provided)"},start_offset:{type:"number",description:"Start offset for range anchor"},end_offset:{type:"number",description:"End offset for range anchor"}},description:"Anchor details (optional)"},severity:{type:"string",enum:["suggestion","needs_changes","blocking"],description:"Thread severity. Note: 'blocking' from automation is coerced to 'needs_changes' per Ch 11 L6250"},tags:{type:"array",items:{type:"string"},description:"Tags for categorization (optional)"},suggestion:{type:"object",properties:{type:{type:"string",enum:["replace","insert","delete"]}},description:"Suggested change (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","body_md"]},f6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to post comment to"},body_md:{type:"string",description:"Comment body in Markdown"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","thread_id","body_md"]},k6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to resolve"},disposition:{type:"object",properties:{state:{type:"string",enum:["accepted_change","rejected_wont_fix","deferred","duplicate","needs_more_info","answered_no_change"],description:"Disposition state"},rationale_md:{type:"string",description:"Rationale in Markdown (optional)"}},required:["state"],description:"Disposition to record with resolution (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id","thread_id"]},C6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to reopen"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id","thread_id"]},E6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to record disposition for"},state:{type:"string",enum:["undecided","accepted_change","rejected_wont_fix","deferred","duplicate","needs_more_info","answered_no_change"],description:"Disposition state"},rationale_md:{type:"string",description:"Rationale in Markdown (optional)"}},required:["session_id","thread_id","state"]},P6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to attach evidence to"},evidence_type:{type:"string",enum:["commit","proposed_change","pr","attestation","external_ticket","note"],description:"Evidence type (required). Determines which additional fields are relevant."},commit_sha:{type:"string",description:"Git commit SHA (for evidence_type=commit)"},repo_url:{type:"string",description:"Repository URL (for evidence_type=commit)"},message:{type:"string",description:"Commit message (for evidence_type=commit)"},proposed_change_id:{type:"string",description:"Proposed change ID (for evidence_type=proposed_change)"},patch_sha256:{type:"string",description:"Patch SHA256 (for evidence_type=proposed_change)"},pr_url:{type:"string",description:"PR URL (for evidence_type=pr)"},pr_number:{type:"number",description:"PR number (for evidence_type=pr)"},attestation_id:{type:"string",description:"Attestation ID (for evidence_type=attestation)"},attestor:{type:"string",description:"Attestor identity (optional, for attestation type)"},ticket_url:{type:"string",description:"Ticket URL (for evidence_type=external_ticket)"},ticket_id:{type:"string",description:"Ticket ID (for evidence_type=external_ticket)"},system:{type:"string",description:"Ticket system (for evidence_type=external_ticket)"},note_md:{type:"string",description:"Note text (for evidence_type=note)"},dedupe_key:{type:"string",description:"Optional idempotency/deduplication key for evidence attach"}},required:["session_id","thread_id","evidence_type"]};function a0($,Q){let X={name:"typescape_create_session",description:"Create a new Typescape review session for a Markdown file. Returns the session ID and any invitations sent. The agent must provide a concrete 40-hex Git SHA; no symbolic ref resolution is performed.",inputSchema:w6};$.register(X,async(D)=>{let J=D;if(!J.repo_id)return L(new M(400,"missing_param","Missing required parameter: repo_id","local"));if(!J.git_sha)return L(new M(400,"missing_param","Missing required parameter: git_sha","local"));if(!J.file_path)return L(new M(400,"missing_param","Missing required parameter: file_path","local"));if(!J.participants)return L(new M(400,"missing_param","Missing required parameter: participants","local"));if(J.participants.length===0)return L(new M(422,"invalid_argument","participants must have at least 1 item","local"));let B={repo_id:J.repo_id,git_sha:J.git_sha,file_path:J.file_path,participants:J.participants};if(J.title!==void 0)B.title=J.title;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;if(J.expected_version)w["If-Match"]=J.expected_version;try{let V=await Q.post("/sessions",{body:B,headers:w});return f({session:V.body.session,invitations:V.body.invitations??[]},V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}});let W={name:"typescape_supersede_session",description:"Create a new Typescape review session pinned to a newer revision, superseding an existing session. The predecessor becomes read-only and unresolved threads are carried forward to the new session. The agent must provide a concrete 40-hex Git SHA.",inputSchema:q6};$.register(W,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.git_sha)return L(new M(400,"missing_param","Missing required parameter: git_sha","local"));if(!/^[a-f0-9]{40}$/i.test(J.git_sha))return L(new M(400,"invalid_param",`Invalid git_sha format: must be a 40-character hex string, got "${J.git_sha}"`,"local"));let B={git_sha:J.git_sha.toLowerCase()};if(J.file_path!==void 0)B.file_path=J.file_path;if(J.title!==void 0)B.title=J.title;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;try{let V=await Q.post(`/sessions/${encodeURIComponent(J.session_id)}/supersede`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}});let Y={name:"typescape_export_feedback",description:"Export all feedback from a Typescape review session as structured JSON. Returns the full export document including threads, comments, and anchors.",inputSchema:M6};$.register(Y,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));let B={schema:J.schema||"v1"};if(J.view)B.view=J.view;let w={};if(J.expected_version)w["If-Match"]=J.expected_version;try{let V=await Q.get(`/sessions/${J.session_id}/export`,{query:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}});let H={name:"typescape_list_sessions",description:"List Typescape review sessions with optional filters. Returns paginated session summaries. Use cursor from previous response for pagination.",inputSchema:j6};$.register(H,async(D)=>{let J=D,B={};if(J.repo_id)B.repo_id=J.repo_id;if(J.state)B.state=J.state;if(J.file_paths)B.file_paths=J.file_paths;if(J.cursor)B.cursor=J.cursor;if(J.limit!==void 0)B.limit=String(J.limit);if(J.root_session_id)B.root_session_id=J.root_session_id;if(J.supersedes_session_id)B.supersedes_session_id=J.supersedes_session_id;if(J.has_successor!==void 0)B.has_successor=J.has_successor?"true":"false";try{let w=await Q.get("/sessions",{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}});let z={name:"typescape_get_session",description:"Get details of a specific Typescape review session. Returns full session metadata including participants, stats, and provenance.",inputSchema:O6};$.register(z,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${J.session_id}`);return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}});let q={name:"typescape_get_render",description:"Get the rendered content of a review session. Returns immutable block-level HTML structure with block_ids for anchoring.",inputSchema:V6},O=new Map;function N(D){let J=D.indexOf("#");if(J===-1)throw new M(500,"invalid_review_url","Review link URL is missing fragment token","local");return D.slice(J+1)}async function b(D){let J=O.get(D);if(J&&J.expiresAtMs>Date.now())return J.token;let B=await Q.get(`/sessions/${D}/participants`,{query:{role:"reviewer"}}),w=B.body.items?.[0]?.participant_id??null;if(!w)w=(await Q.get(`/sessions/${D}/participants`,{query:{limit:"1"}})).body.items?.[0]?.participant_id??null;if(!w)throw new M(422,"no_participants","No participants available to mint a render token",B.requestId);let V=await Q.post(`/sessions/${D}/links`,{body:{participant_id:w,scope:"read",single_use:!0,url_token_ttl_minutes:10}}),C=V.body.url;if(!C||typeof C!=="string")throw new M(500,"invalid_link_response","Failed to mint review link for render",V.requestId);let $1=await Q.post("/auth/exchange",{body:{url_token:N(C)}}),q1=$1.body.session_access_token,e1=$1.body.expires_in_seconds;if(!q1||typeof q1!=="string")throw new M(500,"token_exchange_failed","Failed to exchange review link for session access token",$1.requestId);let $4=typeof e1==="number"&&Number.isFinite(e1)?Math.max(0,Math.trunc(e1)-30)*1000:300000;return O.set(D,{token:q1,expiresAtMs:Date.now()+$4}),q1}$.register(q,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(J.include_plaintext)B.include_plaintext="true";try{let w=await b(J.session_id),V=await Q.get(`/sessions/${J.session_id}/render`,{query:B,headers:{Authorization:`Bearer ${w}`}});return f(V.body,V.requestId)}catch(w){if(w instanceof M)return L(w);throw w}});let I={name:"typescape_get_threads",description:"List threads (comments) for a review session. Optionally filter by block_id anchor or thread status. Returns paginated thread list with comments.",inputSchema:L6};$.register(I,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(J.block_id)B.block_id=J.block_id;if(J.status)B.status=J.status;if(J.cursor)B.cursor=J.cursor;if(J.limit!==void 0)B.limit=String(J.limit);try{let w=await Q.get(`/sessions/${J.session_id}/threads`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}});let t={name:"typescape_export_response_matrix",description:"Export the response matrix for a review session. Returns per-thread disposition and evidence summary.",inputSchema:U6};$.register(t,async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${J.session_id}/export`,{query:{schema:"v1",view:"response_matrix.v1"}});return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}}),$.register({name:"typescape_create_thread",description:"Create a new thread (comment) on a review session. Optionally anchor to a specific block_id. Agent-created threads are tagged source='automation'. Severity 'blocking' is coerced to 'needs_changes' for automation sources.",inputSchema:R6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.body_md)return L(new M(400,"missing_param","Missing required parameter: body_md","local"));let B={body_md:J.body_md,source:"automation"},w=typeof J.block_id==="string"?J.block_id.trim():void 0;if(w)B.block_id=w;if(J.anchor!==void 0)B.anchor=J.anchor;else if(w)B.anchor={type:"block"};if(J.severity!==void 0)B.severity=J.severity;if(J.tags!==void 0)B.tags=J.tags;if(J.suggestion!==void 0)B.suggestion=J.suggestion;let V={};if(J.idempotency_key)V["Idempotency-Key"]=J.idempotency_key;try{let C=await Q.post(`/sessions/${J.session_id}/threads`,{body:B,headers:V});return f(C.body,C.requestId)}catch(C){if(C instanceof M)return L(C);throw C}}),$.register({name:"typescape_post_comment",description:"Post a comment (reply) to an existing thread. Returns the created comment with its ID.",inputSchema:f6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.thread_id)return L(new M(400,"missing_param","Missing required parameter: thread_id","local"));if(!J.body_md)return L(new M(400,"missing_param","Missing required parameter: body_md","local"));let B={body_md:J.body_md,source:"automation"},w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;try{let V=await Q.post(`/sessions/${J.session_id}/threads/${J.thread_id}/comments`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_resolve_thread",description:"Resolve (close) a thread. Optionally include a disposition. Use expected_version for optimistic concurrency.",inputSchema:k6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.thread_id)return L(new M(400,"missing_param","Missing required parameter: thread_id","local"));let B={};if(J.disposition!==void 0)B.disposition=J.disposition;let w={};if(J.expected_version)w["If-Match"]=J.expected_version;try{let V=await Q.post(`/sessions/${J.session_id}/threads/${J.thread_id}/resolve`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_reopen_thread",description:"Reopen a previously resolved thread. Use expected_version for optimistic concurrency.",inputSchema:C6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.thread_id)return L(new M(400,"missing_param","Missing required parameter: thread_id","local"));let B={},w={};if(J.expected_version)w["If-Match"]=J.expected_version;try{let V=await Q.post(`/sessions/${J.session_id}/threads/${J.thread_id}/reopen`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_record_disposition",description:"Record a disposition (decision) on a thread. Dispositions track how feedback was addressed. Note: recording a resolving disposition may automatically resolve the thread.",inputSchema:E6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.thread_id)return L(new M(400,"missing_param","Missing required parameter: thread_id","local"));if(!J.state)return L(new M(400,"missing_param","Missing required parameter: state","local"));let B={state:J.state};if(J.rationale_md!==void 0)B.rationale_md=J.rationale_md;try{let w=await Q.post(`/sessions/${J.session_id}/threads/${J.thread_id}/dispositions`,{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}}),$.register({name:"typescape_attach_evidence",description:"Attach evidence to a thread. Evidence proves that feedback was addressed (e.g., commit SHA, proposed change, PR URL, or attestation).",inputSchema:P6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.thread_id)return L(new M(400,"missing_param","Missing required parameter: thread_id","local"));let B,w;if(J.evidence_type){B=J.evidence_type.trim(),w={};let C=["commit_sha","repo_url","message","proposed_change_id","patch_sha256","pr_url","pr_number","attestation_id","attestor","ticket_url","ticket_id","system","note_md"];for(let $1 of C)if(J[$1]!==void 0){let q1=$1==="note_md"?"text":$1;w[q1]=J[$1]}}else if(J.evidence)B=typeof J.evidence.type==="string"?J.evidence.type.trim():"",w={...J.evidence},delete w.type;else return L(new M(400,"missing_param","Missing required parameter: evidence_type","local"));if(!B)return L(new M(422,"invalid_argument","evidence_type is required","local"));let V={evidence_type:B,evidence_json:w};if(J.dedupe_key)V.dedupe_key=J.dedupe_key;try{let C=await Q.post(`/sessions/${J.session_id}/threads/${J.thread_id}/evidence`,{body:V});return f(C.body,C.requestId)}catch(C){if(C instanceof M)return L(C);throw C}});let m=null,k=300000;async function P(){let D=Date.now();if(m&&D-m.fetchedAt<k)return m.features;try{return m={features:(await Q.get("/me/capabilities")).body.features??{},fetchedAt:D},m.features}catch(J){if(J instanceof M)throw J;throw J}}function g(D){return{content:[{type:"text",text:JSON.stringify({error:{code:"feature_disabled",feature:D,message:`Feature '${D}' is not enabled on this server`,request_id:"local"}},null,2)}],isError:!0}}$.register({name:"typescape_create_review_set",description:"Create a new review set (multi-file review pack). Requires features.review_sets to be enabled.",inputSchema:F6},async(D)=>{let J=D;try{if(!(await P()).review_sets)return g("review_sets")}catch(V){if(V instanceof M)return L(V);throw V}if(!J.source_type)return L(new M(400,"missing_param","Missing required parameter: source_type","local"));let B={source_type:J.source_type};if(J.title!==void 0)B.title=J.title;if(J.kind!==void 0)B.kind=J.kind;if(J.participants!==void 0)B.participants=J.participants;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;try{let V=await Q.post("/review-sets",{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_export_review_set",description:"Export feedback from a review set. Requires features.review_sets to be enabled.",inputSchema:D6},async(D)=>{let J=D;try{if(!(await P()).review_sets)return g("review_sets")}catch(w){if(w instanceof M)return L(w);throw w}if(!J.review_set_id)return L(new M(400,"missing_param","Missing required parameter: review_set_id","local"));let B={schema:J.schema||"v1"};if(J.view)B.view=J.view;try{let w=await Q.get(`/review-sets/${encodeURIComponent(J.review_set_id)}/export`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}}),$.register({name:"typescape_create_review_ref",description:"Create a stable review reference that tracks HEAD session for doc/file/PR/custom keys. Always available (core primitive).",inputSchema:K6},async(D)=>{let J=D;if(!J.source_type)return L(new M(400,"missing_param","Missing required parameter: source_type","local"));if(!J.kind)return L(new M(400,"missing_param","Missing required parameter: kind","local"));if(!J.key)return L(new M(400,"missing_param","Missing required parameter: key","local"));if(!J.head_session_id)return L(new M(400,"missing_param","Missing required parameter: head_session_id","local"));let B=J.kind.trim().toLowerCase();if(!B6.has(B))return L(new M(400,"invalid_param",`Invalid parameter: kind must be one of ${L0.join(", ")}`,"local"));let w={source_type:J.source_type,kind:B,key:J.key,head_session_id:J.head_session_id};if(J.repo_id!==void 0)w.repo_id=J.repo_id;if(J.project_id!==void 0)w.project_id=J.project_id;try{let V=await Q.post("/review-refs",{body:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_resolve_review_ref",description:"Resolve a review ref to its current head session. Returns the head session ID and pinned content details.",inputSchema:N6},async(D)=>{let J=D;if(!J.review_ref_id)return L(new M(400,"missing_param","Missing required parameter: review_ref_id","local"));try{let B=await Q.get(`/review-refs/${encodeURIComponent(J.review_ref_id)}/resolve`);return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}}),$.register({name:"typescape_advance_review_ref",description:"Advance a review ref to a new head session. Use expected_head_session_id for optimistic concurrency.",inputSchema:S6},async(D)=>{let J=D;if(!J.review_ref_id)return L(new M(400,"missing_param","Missing required parameter: review_ref_id","local"));if(!J.head_session_id)return L(new M(400,"missing_param","Missing required parameter: head_session_id","local"));let B={head_session_id:J.head_session_id};if(J.expected_head_session_id!==void 0)B.expected_head_session_id=J.expected_head_session_id;try{let w=await Q.post(`/review-refs/${encodeURIComponent(J.review_ref_id)}/advance`,{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}}),$.register({name:"typescape_request_approval",description:"Request approval for a review session from specified approvers. Sends notifications via configured channels.",inputSchema:_6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.approver_emails||J.approver_emails.length===0)return L(new M(400,"missing_param","Missing required parameter: approver_emails","local"));let B={approver_emails:J.approver_emails};if(J.message!==void 0)B.message=J.message;if(J.notify!==void 0)B.notify=J.notify;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;try{let V=await Q.post(`/sessions/${encodeURIComponent(J.session_id)}/request-approval`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_decide_approval",description:"Record an approval decision (approve/deny/abstain) for a session. Requires a reviewer token with approve scope.",inputSchema:v6},async(D)=>{let J=D;if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));if(!J.decision)return L(new M(400,"missing_param","Missing required parameter: decision","local"));let B={decision:J.decision};if(J.comment_md!==void 0)B.comment_md=J.comment_md;if(J.conditions!==void 0)B.conditions=J.conditions;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;try{let V=await Q.post(`/sessions/${encodeURIComponent(J.session_id)}/approval`,{body:B,headers:w});return f(V.body,V.requestId)}catch(V){if(V instanceof M)return L(V);throw V}}),$.register({name:"typescape_get_status",description:"Get the policy verdict for a session. Returns pass/fail/needs_review with reasons. Requires features.policy to be enabled.",inputSchema:A6},async(D)=>{let J=D;try{if(!(await P()).policy)return g("policy")}catch(w){if(w instanceof M)return L(w);throw w}if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(J.simulate)B.simulate="true";if(J.wait!==void 0)B.wait=String(J.wait);try{let w=await Q.get(`/sessions/${encodeURIComponent(J.session_id)}/status`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof M)return L(w);throw w}}),$.register({name:"typescape_run_checks",description:"Trigger quality checks (DocLint-as-Threads) for a session. Returns the check run ID. Requires features.checks to be enabled.",inputSchema:b6},async(D)=>{let J=D;try{if(!(await P()).checks)return g("checks")}catch(B){if(B instanceof M)return L(B);throw B}if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.post(`/sessions/${encodeURIComponent(J.session_id)}/run-checks`,{body:{}});return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}});let t0={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Git commit SHA for the snapshot"}},required:["repo_id","git_sha"]};$.register({name:"typescape_get_snapshot",description:"Get corpus snapshot metadata for a Git repo at a specific commit. Returns snapshot status, config hash, and source type. Requires features.corpus_snapshots to be enabled.",inputSchema:t0},async(D)=>{let J=D;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof M)return L(B);throw B}if(!J.repo_id)return L(new M(400,"missing_param","Missing required parameter: repo_id","local"));if(!J.git_sha)return L(new M(400,"missing_param","Missing required parameter: git_sha","local"));try{let B=await Q.get(`/repos/${encodeURIComponent(J.repo_id)}/snapshots/${encodeURIComponent(J.git_sha)}`);return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}});let s0={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Git commit SHA for the snapshot"},path:{type:"string",description:"Target file path to query backlinks for"},anchor:{type:"string",description:"Optional anchor within the file to narrow backlinks"}},required:["repo_id","git_sha","path"]};$.register({name:"typescape_list_backlinks",description:"List inbound backlinks for a target file (and optional anchor) within a corpus snapshot. Returns deterministic, authoritative data. Requires features.corpus_snapshots to be enabled.",inputSchema:s0},async(D)=>{let J=D;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof M)return L(B);throw B}if(!J.repo_id)return L(new M(400,"missing_param","Missing required parameter: repo_id","local"));if(!J.git_sha)return L(new M(400,"missing_param","Missing required parameter: git_sha","local"));if(!J.path)return L(new M(400,"missing_param","Missing required parameter: path","local"));try{let B=new URLSearchParams({path:J.path});if(J.anchor)B.set("anchor",J.anchor);let w=await Q.get(`/repos/${encodeURIComponent(J.repo_id)}/snapshots/${encodeURIComponent(J.git_sha)}/backlinks?${B}`);return f(w.body,w.requestId)}catch(B){if(B instanceof M)return L(B);throw B}});let r0={type:"object",properties:{session_id:{type:"string",description:"Session identifier to compute impact radius for"}},required:["session_id"]};$.register({name:"typescape_get_impact",description:"Compute the impact radius for a session: which other files are affected by changes to the session's target file (via backlinks). Returns deterministic, authoritative data. Requires features.corpus_snapshots to be enabled.",inputSchema:r0},async(D)=>{let J=D;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof M)return L(B);throw B}if(!J.session_id)return L(new M(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${encodeURIComponent(J.session_id)}/impact`);return f(B.body,B.requestId)}catch(B){if(B instanceof M)return L(B);throw B}});let e0={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},file_path:{type:"string",description:"Optional file path to scope steering rules (returns only rules matching this path)"},format:{type:"string",enum:["structured","prompt_fragment"],description:'Output format: "structured" returns governed JSON rules (authoritative), "prompt_fragment" returns pre-computed Markdown text within token budget (may include non-authoritative assistive fields). Default: prompt_fragment.'},token_budget:{type:"number",description:"Maximum token count for prompt_fragment format (100-10000, default 2000)",minimum:100,maximum:1e4}},required:["repo_id"]};$.register({name:"typescape_get_steering",description:'Get active steering rules for a repository. format="structured" returns governed, human-approved rules (authoritative). format="prompt_fragment" returns pre-computed text within configured token budget. Requires steering to be enabled.',inputSchema:e0},async(D)=>{let J=D;try{if(!(await P()).steering)return g("steering")}catch(w){if(w instanceof M)return L(w);throw w}if(!J.repo_id)return L(new M(400,"missing_param","Missing required parameter: repo_id","local"));let B=J.format??"prompt_fragment";try{let w=new URLSearchParams({format:B==="structured"?"structured.v1":"prompt_fragment.v1"});if(J.file_path)w.set("file_path",J.file_path);if(J.token_budget!==void 0&&J.token_budget!==null)w.set("token_budget",String(J.token_budget));let V=await Q.get(`/repos/${encodeURIComponent(J.repo_id)}/steering-pack?${w}`),C=V.body;if(B==="prompt_fragment"&&C.prompt_fragment)C.non_authoritative=!0;return f(C,V.requestId)}catch(w){if(w instanceof M)return L(w);throw w}})}var o0={TYPESCAPE_API_KEY:"Operator API token for authenticating with the Typescape API",TYPESCAPE_BASE_URL:"Base URL of the Typescape API server (e.g., https://review.example.com)"};function I6(){let $=process.env.TYPESCAPE_API_KEY,Q=process.env.TYPESCAPE_BASE_URL,X=[];if(!$)X.push(`TYPESCAPE_API_KEY: ${o0.TYPESCAPE_API_KEY}`);if(!Q)X.push(`TYPESCAPE_BASE_URL: ${o0.TYPESCAPE_BASE_URL}`);if(X.length>0){console.error("Error: Missing required environment variables:");for(let W of X)console.error(` - ${W}`);process.exit(1)}return{apiKey:$,baseUrl:Q}}async function g6(){let{apiKey:$,baseUrl:Q}=I6(),X=D0(Q,$),W=F0();a0(W,X),await i0(W)}g6().catch(($)=>{console.error("Fatal error:",$ instanceof Error?$.message:String($)),process.exit(1)});
|