@f2c/mcp 0.2.2 → 0.2.5
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/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +35 -9
- package/dist/cli.js.map +19 -21
- package/dist/cli.mjs +8 -0
- package/dist/stdio.d.mts +2 -0
- package/dist/stdio.d.ts +2 -0
- package/dist/stdio.js +35 -9
- package/dist/stdio.js.map +19 -21
- package/dist/stdio.mjs +7 -0
- package/dist/streamable-http.js +104 -78
- package/dist/streamable-http.js.map +25 -25
- package/dist/streamableHttp.d.mts +2 -0
- package/dist/streamableHttp.d.ts +2 -0
- package/dist/streamableHttp.js +83 -0
- package/dist/streamableHttp.mjs +83 -0
- package/package.json +16 -23
package/dist/stdio.js
CHANGED
@@ -1,10 +1,36 @@
|
|
1
|
-
var z1=Object.create;var{getPrototypeOf:V1,defineProperty:N2,getOwnPropertyNames:A1}=Object;var b1=Object.prototype.hasOwnProperty;var O2=($,W,X)=>{X=$!=null?z1(V1($)):{};let H=W||!$||!$.__esModule?N2(X,"default",{value:$,enumerable:!0}):X;for(let Q of A1($))if(!b1.call(H,Q))N2(H,Q,{get:()=>$[Q],enumerable:!0});return H};var E4=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var N1=($,W)=>{for(var X in W)N2($,X,{get:W[X],enumerable:!0,configurable:!0,set:(H)=>W[X]=()=>H})};var J={};N1(J,{void:()=>WW,util:()=>U,unknown:()=>e1,union:()=>JW,undefined:()=>a1,tuple:()=>wW,transformer:()=>OW,symbol:()=>r1,string:()=>s2,strictObject:()=>QW,setErrorMap:()=>q1,set:()=>MW,record:()=>BW,quotelessJson:()=>O1,promise:()=>NW,preprocess:()=>UW,pipeline:()=>LW,ostring:()=>KW,optional:()=>_W,onumber:()=>FW,oboolean:()=>SW,objectUtil:()=>_2,object:()=>HW,number:()=>e2,nullable:()=>qW,null:()=>t1,never:()=>$W,nativeEnum:()=>bW,nan:()=>p1,map:()=>DW,makeIssue:()=>S$,literal:()=>VW,lazy:()=>zW,late:()=>i1,isValid:()=>a,isDirty:()=>h$,isAsync:()=>B$,isAborted:()=>x$,intersection:()=>GW,instanceof:()=>c1,getParsedType:()=>u,getErrorMap:()=>w$,function:()=>jW,enum:()=>AW,effect:()=>OW,discriminatedUnion:()=>YW,defaultErrorMap:()=>d,datetimeRegex:()=>r2,date:()=>o1,custom:()=>t2,coerce:()=>EW,boolean:()=>$0,bigint:()=>d1,array:()=>XW,any:()=>s1,addIssueToContext:()=>z,ZodVoid:()=>f$,ZodUnknown:()=>t,ZodUnion:()=>A$,ZodUndefined:()=>z$,ZodType:()=>q,ZodTuple:()=>c,ZodTransformer:()=>x,ZodSymbol:()=>v$,ZodString:()=>g,ZodSet:()=>Y$,ZodSchema:()=>q,ZodRecord:()=>k$,ZodReadonly:()=>L$,ZodPromise:()=>G$,ZodPipeline:()=>C$,ZodParsedType:()=>j,ZodOptional:()=>k,ZodObject:()=>K,ZodNumber:()=>s,ZodNullable:()=>r,ZodNull:()=>V$,ZodNever:()=>i,ZodNativeEnum:()=>_$,ZodNaN:()=>P$,ZodMap:()=>I$,ZodLiteral:()=>O$,ZodLazy:()=>N$,ZodIssueCode:()=>D,ZodIntersection:()=>b$,ZodFunction:()=>M$,ZodFirstPartyTypeKind:()=>M,ZodError:()=>f,ZodEnum:()=>$$,ZodEffects:()=>x,ZodDiscriminatedUnion:()=>l$,ZodDefault:()=>q$,ZodDate:()=>Q$,ZodCatch:()=>U$,ZodBranded:()=>m$,ZodBoolean:()=>j$,ZodBigInt:()=>e,ZodArray:()=>T,ZodAny:()=>J$,Schema:()=>q,ParseStatus:()=>E,OK:()=>R,NEVER:()=>RW,INVALID:()=>b,EMPTY_PATH:()=>U1,DIRTY:()=>H$,BRAND:()=>u1});var U;(function($){$.assertEqual=(Q)=>{};function W(Q){}$.assertIs=W;function X(Q){throw new Error}$.assertNever=X,$.arrayToEnum=(Q)=>{let Y={};for(let G of Q)Y[G]=G;return Y},$.getValidEnumValues=(Q)=>{let Y=$.objectKeys(Q).filter((w)=>typeof Q[Q[w]]!=="number"),G={};for(let w of Y)G[w]=Q[w];return $.objectValues(G)},$.objectValues=(Q)=>{return $.objectKeys(Q).map(function(Y){return Q[Y]})},$.objectKeys=typeof Object.keys==="function"?(Q)=>Object.keys(Q):(Q)=>{let Y=[];for(let G in Q)if(Object.prototype.hasOwnProperty.call(Q,G))Y.push(G);return Y},$.find=(Q,Y)=>{for(let G of Q)if(Y(G))return G;return},$.isInteger=typeof Number.isInteger==="function"?(Q)=>Number.isInteger(Q):(Q)=>typeof Q==="number"&&Number.isFinite(Q)&&Math.floor(Q)===Q;function H(Q,Y=" | "){return Q.map((G)=>typeof G==="string"?`'${G}'`:G).join(Y)}$.joinValues=H,$.jsonStringifyReplacer=(Q,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(U||(U={}));var _2;(function($){$.mergeShapes=(W,X)=>{return{...W,...X}}})(_2||(_2={}));var j=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),u=($)=>{switch(typeof $){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN($)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":if(Array.isArray($))return j.array;if($===null)return j.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return j.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return j.map;if(typeof Set!=="undefined"&&$ instanceof Set)return j.set;if(typeof Date!=="undefined"&&$ instanceof Date)return j.date;return j.object;default:return j.unknown}};var D=U.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"]),O1=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class f 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 W=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,W);else this.__proto__=W;this.name="ZodError",this.issues=$}format($){let W=$||function(Q){return Q.message},X={_errors:[]},H=(Q)=>{for(let Y of Q.issues)if(Y.code==="invalid_union")Y.unionErrors.map(H);else if(Y.code==="invalid_return_type")H(Y.returnTypeError);else if(Y.code==="invalid_arguments")H(Y.argumentsError);else if(Y.path.length===0)X._errors.push(W(Y));else{let G=X,w=0;while(w<Y.path.length){let B=Y.path[w];if(w!==Y.path.length-1)G[B]=G[B]||{_errors:[]};else G[B]=G[B]||{_errors:[]},G[B]._errors.push(W(Y));G=G[B],w++}}};return H(this),X}static assert($){if(!($ instanceof f))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(W)=>W.message){let W={},X=[];for(let H of this.issues)if(H.path.length>0)W[H.path[0]]=W[H.path[0]]||[],W[H.path[0]].push($(H));else X.push($(H));return{formErrors:X,fieldErrors:W}}get formErrors(){return this.flatten()}}f.create=($)=>{return new f($)};var _1=($,W)=>{let X;switch($.code){case D.invalid_type:if($.received===j.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case D.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,U.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:X=`Unrecognized key(s) in object: ${U.joinValues($.keys,", ")}`;break;case D.invalid_union:X="Invalid input";break;case D.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${U.joinValues($.options)}`;break;case D.invalid_enum_value:X=`Invalid enum value. Expected ${U.joinValues($.options)}, received '${$.received}'`;break;case D.invalid_arguments:X="Invalid function arguments";break;case D.invalid_return_type:X="Invalid function return type";break;case D.invalid_date:X="Invalid date";break;case D.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 U.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case D.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 D.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 D.custom:X="Invalid input";break;case D.invalid_intersection_types:X="Intersection results could not be merged";break;case D.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case D.not_finite:X="Number must be finite";break;default:X=W.defaultError,U.assertNever($)}return{message:X}},d=_1;var u2=d;function q1($){u2=$}function w$(){return u2}var S$=($)=>{let{data:W,path:X,errorMaps:H,issueData:Q}=$,Y=[...X,...Q.path||[]],G={...Q,path:Y};if(Q.message!==void 0)return{...Q,path:Y,message:Q.message};let w="",B=H.filter((V)=>!!V).slice().reverse();for(let V of B)w=V(G,{data:W,defaultError:w}).message;return{...Q,path:Y,message:w}},U1=[];function z($,W){let X=w$(),H=S$({issueData:W,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===d?void 0:d].filter((Q)=>!!Q)});$.common.issues.push(H)}class E{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,W){let X=[];for(let H of W){if(H.status==="aborted")return b;if(H.status==="dirty")$.dirty();X.push(H.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,W){let X=[];for(let H of W){let Q=await H.key,Y=await H.value;X.push({key:Q,value:Y})}return E.mergeObjectSync($,X)}static mergeObjectSync($,W){let X={};for(let H of W){let{key:Q,value:Y}=H;if(Q.status==="aborted")return b;if(Y.status==="aborted")return b;if(Q.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(Q.value!=="__proto__"&&(typeof Y.value!=="undefined"||H.alwaysSet))X[Q.value]=Y.value}return{status:$.value,value:X}}}var b=Object.freeze({status:"aborted"}),H$=($)=>({status:"dirty",value:$}),R=($)=>({status:"valid",value:$}),x$=($)=>$.status==="aborted",h$=($)=>$.status==="dirty",a=($)=>$.status==="valid",B$=($)=>typeof Promise!=="undefined"&&$ instanceof Promise;var A;(function($){$.errToObj=(W)=>typeof W==="string"?{message:W}:W||{},$.toString=(W)=>typeof W==="string"?W:W?.message})(A||(A={}));var Z$=function($,W,X,H){if(X==="a"&&!H)throw new TypeError("Private accessor was defined without a getter");if(typeof W==="function"?$!==W||!H:!W.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?H:X==="a"?H.call($):H?H.value:W.get($)},p2=function($,W,X,H,Q){if(H==="m")throw new TypeError("Private method is not writable");if(H==="a"&&!Q)throw new TypeError("Private accessor was defined without a setter");if(typeof W==="function"?$!==W||!Q:!W.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return H==="a"?Q.call($,X):Q?Q.value=X:W.set($,X),X},E$,R$;class y{constructor($,W,X,H){this._cachedPath=[],this.parent=$,this.data=W,this._path=X,this._key=H}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var i2=($,W)=>{if(a(W))return{success:!0,data:W.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new f($.common.issues);return this._error=X,this._error}}}};function O($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:H,description:Q}=$;if(W&&(X||H))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(G,w)=>{let{message:B}=$;if(G.code==="invalid_enum_value")return{message:B??w.defaultError};if(typeof w.data==="undefined")return{message:B??H??w.defaultError};if(G.code!=="invalid_type")return{message:w.defaultError};return{message:B??X??w.defaultError}},description:Q}}class q{get description(){return this._def.description}_getType($){return u($.data)}_getOrReturnCtx($,W){return W||{common:$.parent.common,data:$.data,parsedType:u($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new E,ctx:{common:$.parent.common,data:$.data,parsedType:u($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let W=this._parse($);if(B$(W))throw new Error("Synchronous parse encountered promise.");return W}_parseAsync($){let W=this._parse($);return Promise.resolve(W)}parse($,W){let X=this.safeParse($,W);if(X.success)return X.data;throw X.error}safeParse($,W){let X={common:{issues:[],async:W?.async??!1,contextualErrorMap:W?.errorMap},path:W?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:u($)},H=this._parseSync({data:$,path:X.path,parent:X});return i2(X,H)}"~validate"($){let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:u($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:W});return a(X)?{value:X.value}:{issues:W.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;W.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:W}).then((X)=>a(X)?{value:X.value}:{issues:W.common.issues})}async parseAsync($,W){let X=await this.safeParseAsync($,W);if(X.success)return X.data;throw X.error}async safeParseAsync($,W){let X={common:{issues:[],contextualErrorMap:W?.errorMap,async:!0},path:W?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:u($)},H=this._parse({data:$,path:X.path,parent:X}),Q=await(B$(H)?H:Promise.resolve(H));return i2(X,Q)}refine($,W){let X=(H)=>{if(typeof W==="string"||typeof W==="undefined")return{message:W};else if(typeof W==="function")return W(H);else return W};return this._refinement((H,Q)=>{let Y=$(H),G=()=>Q.addIssue({code:D.custom,...X(H)});if(typeof Promise!=="undefined"&&Y instanceof Promise)return Y.then((w)=>{if(!w)return G(),!1;else return!0});if(!Y)return G(),!1;else return!0})}refinement($,W){return this._refinement((X,H)=>{if(!$(X))return H.addIssue(typeof W==="function"?W(X,H):W),!1;else return!0})}_refinement($){return new x({schema:this,typeName:M.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:(W)=>this["~validate"](W)}}optional(){return k.create(this,this._def)}nullable(){return r.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return T.create(this)}promise(){return G$.create(this,this._def)}or($){return A$.create([this,$],this._def)}and($){return b$.create(this,$,this._def)}transform($){return new x({...O(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:$}})}default($){let W=typeof $==="function"?$:()=>$;return new q$({...O(this._def),innerType:this,defaultValue:W,typeName:M.ZodDefault})}brand(){return new m$({typeName:M.ZodBranded,type:this,...O(this._def)})}catch($){let W=typeof $==="function"?$:()=>$;return new U$({...O(this._def),innerType:this,catchValue:W,typeName:M.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return C$.create(this,$)}readonly(){return L$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var L1=/^c[^\s-]{8,}$/i,K1=/^[0-9a-z]+$/,F1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S1=/^[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,E1=/^[a-z0-9_-]{21}$/i,R1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v1=/^[-+]?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)?)??$/,f1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,k1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",q2,I1=/^(?:(?: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])$/,P1=/^(?:(?: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])$/,C1=/^(([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]))$/,g1=/^(([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])$/,T1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,y1=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,d2="((\\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])))",x1=new RegExp(`^${d2}$`);function o2($){let W="[0-5]\\d";if($.precision)W=`${W}\\.\\d{${$.precision}}`;else if($.precision==null)W=`${W}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${W})${X}`}function h1($){return new RegExp(`^${o2($)}$`)}function r2($){let W=`${d2}T${o2($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return W=`${W}(${X.join("|")})`,new RegExp(`^${W}$`)}function Z1($,W){if((W==="v4"||!W)&&I1.test($))return!0;if((W==="v6"||!W)&&C1.test($))return!0;return!1}function l1($,W){if(!R1.test($))return!1;try{let[X]=$.split("."),H=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Q=JSON.parse(atob(H));if(typeof Q!=="object"||Q===null)return!1;if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(W&&Q.alg!==W)return!1;return!0}catch{return!1}}function m1($,W){if((W==="v4"||!W)&&P1.test($))return!0;if((W==="v6"||!W)&&g1.test($))return!0;return!1}class g extends q{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==j.string){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.string,received:Q.parsedType}),b}let X=new E,H=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.length<Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if($.data.length>Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="length"){let Y=$.data.length>Q.value,G=$.data.length<Q.value;if(Y||G){if(H=this._getOrReturnCtx($,H),Y)z(H,{code:D.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});else if(G)z(H,{code:D.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});X.dirty()}}else if(Q.kind==="email"){if(!f1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"email",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="emoji"){if(!q2)q2=new RegExp(k1,"u");if(!q2.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"emoji",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="uuid"){if(!S1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"uuid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="nanoid"){if(!E1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"nanoid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid"){if(!L1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"cuid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid2"){if(!K1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"cuid2",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ulid"){if(!F1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"ulid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="url")try{new URL($.data)}catch{H=this._getOrReturnCtx($,H),z(H,{validation:"url",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="regex"){if(Q.regex.lastIndex=0,!Q.regex.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"regex",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="trim")$.data=$.data.trim();else if(Q.kind==="includes"){if(!$.data.includes(Q.value,Q.position))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{includes:Q.value,position:Q.position},message:Q.message}),X.dirty()}else if(Q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Q.kind==="startsWith"){if(!$.data.startsWith(Q.value))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{startsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="endsWith"){if(!$.data.endsWith(Q.value))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{endsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="datetime"){if(!r2(Q).test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"datetime",message:Q.message}),X.dirty()}else if(Q.kind==="date"){if(!x1.test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"date",message:Q.message}),X.dirty()}else if(Q.kind==="time"){if(!h1(Q).test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"time",message:Q.message}),X.dirty()}else if(Q.kind==="duration"){if(!v1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"duration",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ip"){if(!Z1($.data,Q.version))H=this._getOrReturnCtx($,H),z(H,{validation:"ip",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="jwt"){if(!l1($.data,Q.alg))H=this._getOrReturnCtx($,H),z(H,{validation:"jwt",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cidr"){if(!m1($.data,Q.version))H=this._getOrReturnCtx($,H),z(H,{validation:"cidr",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64"){if(!T1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"base64",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64url"){if(!y1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"base64url",code:D.invalid_string,message:Q.message}),X.dirty()}else U.assertNever(Q);return{status:X.value,value:$.data}}_regex($,W,X){return this.refinement((H)=>$.test(H),{validation:W,code:D.invalid_string,...A.errToObj(X)})}_addCheck($){return new g({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...A.errToObj($)})}url($){return this._addCheck({kind:"url",...A.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...A.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...A.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...A.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...A.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...A.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...A.errToObj($)})}base64($){return this._addCheck({kind:"base64",...A.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...A.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...A.errToObj($)})}ip($){return this._addCheck({kind:"ip",...A.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...A.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision==="undefined"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...A.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision==="undefined"?null:$?.precision,...A.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...A.errToObj($)})}regex($,W){return this._addCheck({kind:"regex",regex:$,...A.errToObj(W)})}includes($,W){return this._addCheck({kind:"includes",value:$,position:W?.position,...A.errToObj(W?.message)})}startsWith($,W){return this._addCheck({kind:"startsWith",value:$,...A.errToObj(W)})}endsWith($,W){return this._addCheck({kind:"endsWith",value:$,...A.errToObj(W)})}min($,W){return this._addCheck({kind:"min",value:$,...A.errToObj(W)})}max($,W){return this._addCheck({kind:"max",value:$,...A.errToObj(W)})}length($,W){return this._addCheck({kind:"length",value:$,...A.errToObj(W)})}nonempty($){return this.min(1,A.errToObj($))}trim(){return new g({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new g({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new g({...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 W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxLength(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}g.create=($)=>{return new g({checks:[],typeName:M.ZodString,coerce:$?.coerce??!1,...O($)})};function n1($,W){let X=($.toString().split(".")[1]||"").length,H=(W.toString().split(".")[1]||"").length,Q=X>H?X:H,Y=Number.parseInt($.toFixed(Q).replace(".","")),G=Number.parseInt(W.toFixed(Q).replace(".",""));return Y%G/10**Q}class s extends q{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==j.number){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.number,received:Q.parsedType}),b}let X=void 0,H=new E;for(let Q of this._def.checks)if(Q.kind==="int"){if(!U.isInteger($.data))X=this._getOrReturnCtx($,X),z(X,{code:D.invalid_type,expected:"integer",received:"float",message:Q.message}),H.dirty()}else if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_small,minimum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),H.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_big,maximum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),H.dirty()}else if(Q.kind==="multipleOf"){if(n1($.data,Q.value)!==0)X=this._getOrReturnCtx($,X),z(X,{code:D.not_multiple_of,multipleOf:Q.value,message:Q.message}),H.dirty()}else if(Q.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),z(X,{code:D.not_finite,message:Q.message}),H.dirty()}else U.assertNever(Q);return{status:H.value,value:$.data}}gte($,W){return this.setLimit("min",$,!0,A.toString(W))}gt($,W){return this.setLimit("min",$,!1,A.toString(W))}lte($,W){return this.setLimit("max",$,!0,A.toString(W))}lt($,W){return this.setLimit("max",$,!1,A.toString(W))}setLimit($,W,X,H){return new s({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:A.toString(H)}]})}_addCheck($){return new s({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:A.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:A.toString(W)})}finite($){return this._addCheck({kind:"finite",message:A.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString($)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&U.isInteger($.value))}get isFinite(){let $=null,W=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(W===null||X.value>W)W=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(W)&&Number.isFinite($)}}s.create=($)=>{return new s({checks:[],typeName:M.ZodNumber,coerce:$?.coerce||!1,...O($)})};class e extends q{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==j.bigint)return this._getInvalidInput($);let X=void 0,H=new E;for(let Q of this._def.checks)if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_small,type:"bigint",minimum:Q.value,inclusive:Q.inclusive,message:Q.message}),H.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_big,type:"bigint",maximum:Q.value,inclusive:Q.inclusive,message:Q.message}),H.dirty()}else if(Q.kind==="multipleOf"){if($.data%Q.value!==BigInt(0))X=this._getOrReturnCtx($,X),z(X,{code:D.not_multiple_of,multipleOf:Q.value,message:Q.message}),H.dirty()}else U.assertNever(Q);return{status:H.value,value:$.data}}_getInvalidInput($){let W=this._getOrReturnCtx($);return z(W,{code:D.invalid_type,expected:j.bigint,received:W.parsedType}),b}gte($,W){return this.setLimit("min",$,!0,A.toString(W))}gt($,W){return this.setLimit("min",$,!1,A.toString(W))}lte($,W){return this.setLimit("max",$,!0,A.toString(W))}lt($,W){return this.setLimit("max",$,!1,A.toString(W))}setLimit($,W,X,H){return new e({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:A.toString(H)}]})}_addCheck($){return new e({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:A.toString(W)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}e.create=($)=>{return new e({checks:[],typeName:M.ZodBigInt,coerce:$?.coerce??!1,...O($)})};class j$ extends q{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==j.boolean){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.boolean,received:X.parsedType}),b}return R($.data)}}j$.create=($)=>{return new j$({typeName:M.ZodBoolean,coerce:$?.coerce||!1,...O($)})};class Q$ extends q{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==j.date){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.date,received:Q.parsedType}),b}if(Number.isNaN($.data.getTime())){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_date}),b}let X=new E,H=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.getTime()<Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_small,message:Q.message,inclusive:!0,exact:!1,minimum:Q.value,type:"date"}),X.dirty()}else if(Q.kind==="max"){if($.data.getTime()>Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_big,message:Q.message,inclusive:!0,exact:!1,maximum:Q.value,type:"date"}),X.dirty()}else U.assertNever(Q);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new Q$({...this._def,checks:[...this._def.checks,$]})}min($,W){return this._addCheck({kind:"min",value:$.getTime(),message:A.toString(W)})}max($,W){return this._addCheck({kind:"max",value:$.getTime(),message:A.toString(W)})}get minDate(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $!=null?new Date($):null}}Q$.create=($)=>{return new Q$({checks:[],coerce:$?.coerce||!1,typeName:M.ZodDate,...O($)})};class v$ extends q{_parse($){if(this._getType($)!==j.symbol){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.symbol,received:X.parsedType}),b}return R($.data)}}v$.create=($)=>{return new v$({typeName:M.ZodSymbol,...O($)})};class z$ extends q{_parse($){if(this._getType($)!==j.undefined){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.undefined,received:X.parsedType}),b}return R($.data)}}z$.create=($)=>{return new z$({typeName:M.ZodUndefined,...O($)})};class V$ extends q{_parse($){if(this._getType($)!==j.null){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.null,received:X.parsedType}),b}return R($.data)}}V$.create=($)=>{return new V$({typeName:M.ZodNull,...O($)})};class J$ extends q{constructor(){super(...arguments);this._any=!0}_parse($){return R($.data)}}J$.create=($)=>{return new J$({typeName:M.ZodAny,...O($)})};class t extends q{constructor(){super(...arguments);this._unknown=!0}_parse($){return R($.data)}}t.create=($)=>{return new t({typeName:M.ZodUnknown,...O($)})};class i extends q{_parse($){let W=this._getOrReturnCtx($);return z(W,{code:D.invalid_type,expected:j.never,received:W.parsedType}),b}}i.create=($)=>{return new i({typeName:M.ZodNever,...O($)})};class f$ extends q{_parse($){if(this._getType($)!==j.undefined){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.void,received:X.parsedType}),b}return R($.data)}}f$.create=($)=>{return new f$({typeName:M.ZodVoid,...O($)})};class T extends q{_parse($){let{ctx:W,status:X}=this._processInputParams($),H=this._def;if(W.parsedType!==j.array)return z(W,{code:D.invalid_type,expected:j.array,received:W.parsedType}),b;if(H.exactLength!==null){let Y=W.data.length>H.exactLength.value,G=W.data.length<H.exactLength.value;if(Y||G)z(W,{code:Y?D.too_big:D.too_small,minimum:G?H.exactLength.value:void 0,maximum:Y?H.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:H.exactLength.message}),X.dirty()}if(H.minLength!==null){if(W.data.length<H.minLength.value)z(W,{code:D.too_small,minimum:H.minLength.value,type:"array",inclusive:!0,exact:!1,message:H.minLength.message}),X.dirty()}if(H.maxLength!==null){if(W.data.length>H.maxLength.value)z(W,{code:D.too_big,maximum:H.maxLength.value,type:"array",inclusive:!0,exact:!1,message:H.maxLength.message}),X.dirty()}if(W.common.async)return Promise.all([...W.data].map((Y,G)=>{return H.type._parseAsync(new y(W,Y,W.path,G))})).then((Y)=>{return E.mergeArray(X,Y)});let Q=[...W.data].map((Y,G)=>{return H.type._parseSync(new y(W,Y,W.path,G))});return E.mergeArray(X,Q)}get element(){return this._def.type}min($,W){return new T({...this._def,minLength:{value:$,message:A.toString(W)}})}max($,W){return new T({...this._def,maxLength:{value:$,message:A.toString(W)}})}length($,W){return new T({...this._def,exactLength:{value:$,message:A.toString(W)}})}nonempty($){return this.min(1,$)}}T.create=($,W)=>{return new T({type:$,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...O(W)})};function D$($){if($ instanceof K){let W={};for(let X in $.shape){let H=$.shape[X];W[X]=k.create(D$(H))}return new K({...$._def,shape:()=>W})}else if($ instanceof T)return new T({...$._def,type:D$($.element)});else if($ instanceof k)return k.create(D$($.unwrap()));else if($ instanceof r)return r.create(D$($.unwrap()));else if($ instanceof c)return c.create($.items.map((W)=>D$(W)));else return $}class K extends q{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),W=U.objectKeys($);return this._cached={shape:$,keys:W},this._cached}_parse($){if(this._getType($)!==j.object){let B=this._getOrReturnCtx($);return z(B,{code:D.invalid_type,expected:j.object,received:B.parsedType}),b}let{status:X,ctx:H}=this._processInputParams($),{shape:Q,keys:Y}=this._getCached(),G=[];if(!(this._def.catchall instanceof i&&this._def.unknownKeys==="strip")){for(let B in H.data)if(!Y.includes(B))G.push(B)}let w=[];for(let B of Y){let V=Q[B],_=H.data[B];w.push({key:{status:"valid",value:B},value:V._parse(new y(H,_,H.path,B)),alwaysSet:B in H.data})}if(this._def.catchall instanceof i){let B=this._def.unknownKeys;if(B==="passthrough")for(let V of G)w.push({key:{status:"valid",value:V},value:{status:"valid",value:H.data[V]}});else if(B==="strict"){if(G.length>0)z(H,{code:D.unrecognized_keys,keys:G}),X.dirty()}else if(B==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let B=this._def.catchall;for(let V of G){let _=H.data[V];w.push({key:{status:"valid",value:V},value:B._parse(new y(H,_,H.path,V)),alwaysSet:V in H.data})}}if(H.common.async)return Promise.resolve().then(async()=>{let B=[];for(let V of w){let _=await V.key,P=await V.value;B.push({key:_,value:P,alwaysSet:V.alwaysSet})}return B}).then((B)=>{return E.mergeObjectSync(X,B)});else return E.mergeObjectSync(X,w)}get shape(){return this._def.shape()}strict($){return A.errToObj,new K({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(W,X)=>{let H=this._def.errorMap?.(W,X).message??X.defaultError;if(W.code==="unrecognized_keys")return{message:A.errToObj($).message??H};return{message:H}}}:{}})}strip(){return new K({...this._def,unknownKeys:"strip"})}passthrough(){return new K({...this._def,unknownKeys:"passthrough"})}extend($){return new K({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new K({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:M.ZodObject})}setKey($,W){return this.augment({[$]:W})}catchall($){return new K({...this._def,catchall:$})}pick($){let W={};for(let X of U.objectKeys($))if($[X]&&this.shape[X])W[X]=this.shape[X];return new K({...this._def,shape:()=>W})}omit($){let W={};for(let X of U.objectKeys(this.shape))if(!$[X])W[X]=this.shape[X];return new K({...this._def,shape:()=>W})}deepPartial(){return D$(this)}partial($){let W={};for(let X of U.objectKeys(this.shape)){let H=this.shape[X];if($&&!$[X])W[X]=H;else W[X]=H.optional()}return new K({...this._def,shape:()=>W})}required($){let W={};for(let X of U.objectKeys(this.shape))if($&&!$[X])W[X]=this.shape[X];else{let Q=this.shape[X];while(Q instanceof k)Q=Q._def.innerType;W[X]=Q}return new K({...this._def,shape:()=>W})}keyof(){return a2(U.objectKeys(this.shape))}}K.create=($,W)=>{return new K({shape:()=>$,unknownKeys:"strip",catchall:i.create(),typeName:M.ZodObject,...O(W)})};K.strictCreate=($,W)=>{return new K({shape:()=>$,unknownKeys:"strict",catchall:i.create(),typeName:M.ZodObject,...O(W)})};K.lazycreate=($,W)=>{return new K({shape:$,unknownKeys:"strip",catchall:i.create(),typeName:M.ZodObject,...O(W)})};class A$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=this._def.options;function H(Q){for(let G of Q)if(G.result.status==="valid")return G.result;for(let G of Q)if(G.result.status==="dirty")return W.common.issues.push(...G.ctx.common.issues),G.result;let Y=Q.map((G)=>new f(G.ctx.common.issues));return z(W,{code:D.invalid_union,unionErrors:Y}),b}if(W.common.async)return Promise.all(X.map(async(Q)=>{let Y={...W,common:{...W.common,issues:[]},parent:null};return{result:await Q._parseAsync({data:W.data,path:W.path,parent:Y}),ctx:Y}})).then(H);else{let Q=void 0,Y=[];for(let w of X){let B={...W,common:{...W.common,issues:[]},parent:null},V=w._parseSync({data:W.data,path:W.path,parent:B});if(V.status==="valid")return V;else if(V.status==="dirty"&&!Q)Q={result:V,ctx:B};if(B.common.issues.length)Y.push(B.common.issues)}if(Q)return W.common.issues.push(...Q.ctx.common.issues),Q.result;let G=Y.map((w)=>new f(w));return z(W,{code:D.invalid_union,unionErrors:G}),b}}get options(){return this._def.options}}A$.create=($,W)=>{return new A$({options:$,typeName:M.ZodUnion,...O(W)})};var o=($)=>{if($ instanceof N$)return o($.schema);else if($ instanceof x)return o($.innerType());else if($ instanceof O$)return[$.value];else if($ instanceof $$)return $.options;else if($ instanceof _$)return U.objectValues($.enum);else if($ instanceof q$)return o($._def.innerType);else if($ instanceof z$)return[void 0];else if($ instanceof V$)return[null];else if($ instanceof k)return[void 0,...o($.unwrap())];else if($ instanceof r)return[null,...o($.unwrap())];else if($ instanceof m$)return o($.unwrap());else if($ instanceof L$)return o($.unwrap());else if($ instanceof U$)return o($._def.innerType);else return[]};class l$ extends q{_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.object)return z(W,{code:D.invalid_type,expected:j.object,received:W.parsedType}),b;let X=this.discriminator,H=W.data[X],Q=this.optionsMap.get(H);if(!Q)return z(W,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),b;if(W.common.async)return Q._parseAsync({data:W.data,path:W.path,parent:W});else return Q._parseSync({data:W.data,path:W.path,parent:W})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,W,X){let H=new Map;for(let Q of W){let Y=o(Q.shape[$]);if(!Y.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let G of Y){if(H.has(G))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(G)}`);H.set(G,Q)}}return new l$({typeName:M.ZodDiscriminatedUnion,discriminator:$,options:W,optionsMap:H,...O(X)})}}function U2($,W){let X=u($),H=u(W);if($===W)return{valid:!0,data:$};else if(X===j.object&&H===j.object){let Q=U.objectKeys(W),Y=U.objectKeys($).filter((w)=>Q.indexOf(w)!==-1),G={...$,...W};for(let w of Y){let B=U2($[w],W[w]);if(!B.valid)return{valid:!1};G[w]=B.data}return{valid:!0,data:G}}else if(X===j.array&&H===j.array){if($.length!==W.length)return{valid:!1};let Q=[];for(let Y=0;Y<$.length;Y++){let G=$[Y],w=W[Y],B=U2(G,w);if(!B.valid)return{valid:!1};Q.push(B.data)}return{valid:!0,data:Q}}else if(X===j.date&&H===j.date&&+$===+W)return{valid:!0,data:$};else return{valid:!1}}class b$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($),H=(Q,Y)=>{if(x$(Q)||x$(Y))return b;let G=U2(Q.value,Y.value);if(!G.valid)return z(X,{code:D.invalid_intersection_types}),b;if(h$(Q)||h$(Y))W.dirty();return{status:W.value,value:G.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(([Q,Y])=>H(Q,Y));else return H(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}b$.create=($,W,X)=>{return new b$({left:$,right:W,typeName:M.ZodIntersection,...O(X)})};class c extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.array)return z(X,{code:D.invalid_type,expected:j.array,received:X.parsedType}),b;if(X.data.length<this._def.items.length)return z(X,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;if(!this._def.rest&&X.data.length>this._def.items.length)z(X,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W.dirty();let Q=[...X.data].map((Y,G)=>{let w=this._def.items[G]||this._def.rest;if(!w)return null;return w._parse(new y(X,Y,X.path,G))}).filter((Y)=>!!Y);if(X.common.async)return Promise.all(Q).then((Y)=>{return E.mergeArray(W,Y)});else return E.mergeArray(W,Q)}get items(){return this._def.items}rest($){return new c({...this._def,rest:$})}}c.create=($,W)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new c({items:$,typeName:M.ZodTuple,rest:null,...O(W)})};class k$ extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.object)return z(X,{code:D.invalid_type,expected:j.object,received:X.parsedType}),b;let H=[],Q=this._def.keyType,Y=this._def.valueType;for(let G in X.data)H.push({key:Q._parse(new y(X,G,X.path,G)),value:Y._parse(new y(X,X.data[G],X.path,G)),alwaysSet:G in X.data});if(X.common.async)return E.mergeObjectAsync(W,H);else return E.mergeObjectSync(W,H)}get element(){return this._def.valueType}static create($,W,X){if(W instanceof q)return new k$({keyType:$,valueType:W,typeName:M.ZodRecord,...O(X)});return new k$({keyType:g.create(),valueType:$,typeName:M.ZodRecord,...O(W)})}}class I$ extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.map)return z(X,{code:D.invalid_type,expected:j.map,received:X.parsedType}),b;let H=this._def.keyType,Q=this._def.valueType,Y=[...X.data.entries()].map(([G,w],B)=>{return{key:H._parse(new y(X,G,X.path,[B,"key"])),value:Q._parse(new y(X,w,X.path,[B,"value"]))}});if(X.common.async){let G=new Map;return Promise.resolve().then(async()=>{for(let w of Y){let B=await w.key,V=await w.value;if(B.status==="aborted"||V.status==="aborted")return b;if(B.status==="dirty"||V.status==="dirty")W.dirty();G.set(B.value,V.value)}return{status:W.value,value:G}})}else{let G=new Map;for(let w of Y){let{key:B,value:V}=w;if(B.status==="aborted"||V.status==="aborted")return b;if(B.status==="dirty"||V.status==="dirty")W.dirty();G.set(B.value,V.value)}return{status:W.value,value:G}}}}I$.create=($,W,X)=>{return new I$({valueType:W,keyType:$,typeName:M.ZodMap,...O(X)})};class Y$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.set)return z(X,{code:D.invalid_type,expected:j.set,received:X.parsedType}),b;let H=this._def;if(H.minSize!==null){if(X.data.size<H.minSize.value)z(X,{code:D.too_small,minimum:H.minSize.value,type:"set",inclusive:!0,exact:!1,message:H.minSize.message}),W.dirty()}if(H.maxSize!==null){if(X.data.size>H.maxSize.value)z(X,{code:D.too_big,maximum:H.maxSize.value,type:"set",inclusive:!0,exact:!1,message:H.maxSize.message}),W.dirty()}let Q=this._def.valueType;function Y(w){let B=new Set;for(let V of w){if(V.status==="aborted")return b;if(V.status==="dirty")W.dirty();B.add(V.value)}return{status:W.value,value:B}}let G=[...X.data.values()].map((w,B)=>Q._parse(new y(X,w,X.path,B)));if(X.common.async)return Promise.all(G).then((w)=>Y(w));else return Y(G)}min($,W){return new Y$({...this._def,minSize:{value:$,message:A.toString(W)}})}max($,W){return new Y$({...this._def,maxSize:{value:$,message:A.toString(W)}})}size($,W){return this.min($,W).max($,W)}nonempty($){return this.min(1,$)}}Y$.create=($,W)=>{return new Y$({valueType:$,minSize:null,maxSize:null,typeName:M.ZodSet,...O(W)})};class M$ extends q{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.function)return z(W,{code:D.invalid_type,expected:j.function,received:W.parsedType}),b;function X(G,w){return S$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,w$(),d].filter((B)=>!!B),issueData:{code:D.invalid_arguments,argumentsError:w}})}function H(G,w){return S$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,w$(),d].filter((B)=>!!B),issueData:{code:D.invalid_return_type,returnTypeError:w}})}let Q={errorMap:W.common.contextualErrorMap},Y=W.data;if(this._def.returns instanceof G$){let G=this;return R(async function(...w){let B=new f([]),V=await G._def.args.parseAsync(w,Q).catch((W$)=>{throw B.addIssue(X(w,W$)),B}),_=await Reflect.apply(Y,this,V);return await G._def.returns._def.type.parseAsync(_,Q).catch((W$)=>{throw B.addIssue(H(_,W$)),B})})}else{let G=this;return R(function(...w){let B=G._def.args.safeParse(w,Q);if(!B.success)throw new f([X(w,B.error)]);let V=Reflect.apply(Y,this,B.data),_=G._def.returns.safeParse(V,Q);if(!_.success)throw new f([H(V,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new M$({...this._def,args:c.create($).rest(t.create())})}returns($){return new M$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,W,X){return new M$({args:$?$:c.create([]).rest(t.create()),returns:W||t.create(),typeName:M.ZodFunction,...O(X)})}}class N$ extends q{get schema(){return this._def.getter()}_parse($){let{ctx:W}=this._processInputParams($);return this._def.getter()._parse({data:W.data,path:W.path,parent:W})}}N$.create=($,W)=>{return new N$({getter:$,typeName:M.ZodLazy,...O(W)})};class O$ extends q{_parse($){if($.data!==this._def.value){let W=this._getOrReturnCtx($);return z(W,{received:W.data,code:D.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:$.data}}get value(){return this._def.value}}O$.create=($,W)=>{return new O$({value:$,typeName:M.ZodLiteral,...O(W)})};function a2($,W){return new $$({values:$,typeName:M.ZodEnum,...O(W)})}class $$ extends q{constructor(){super(...arguments);E$.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let W=this._getOrReturnCtx($),X=this._def.values;return z(W,{expected:U.joinValues(X),received:W.parsedType,code:D.invalid_type}),b}if(!Z$(this,E$,"f"))p2(this,E$,new Set(this._def.values),"f");if(!Z$(this,E$,"f").has($.data)){let W=this._getOrReturnCtx($),X=this._def.values;return z(W,{received:W.data,code:D.invalid_enum_value,options:X}),b}return R($.data)}get options(){return this._def.values}get enum(){let $={};for(let W of this._def.values)$[W]=W;return $}get Values(){let $={};for(let W of this._def.values)$[W]=W;return $}get Enum(){let $={};for(let W of this._def.values)$[W]=W;return $}extract($,W=this._def){return $$.create($,{...this._def,...W})}exclude($,W=this._def){return $$.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...W})}}E$=new WeakMap;$$.create=a2;class _$ extends q{constructor(){super(...arguments);R$.set(this,void 0)}_parse($){let W=U.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==j.string&&X.parsedType!==j.number){let H=U.objectValues(W);return z(X,{expected:U.joinValues(H),received:X.parsedType,code:D.invalid_type}),b}if(!Z$(this,R$,"f"))p2(this,R$,new Set(U.getValidEnumValues(this._def.values)),"f");if(!Z$(this,R$,"f").has($.data)){let H=U.objectValues(W);return z(X,{received:X.data,code:D.invalid_enum_value,options:H}),b}return R($.data)}get enum(){return this._def.values}}R$=new WeakMap;_$.create=($,W)=>{return new _$({values:$,typeName:M.ZodNativeEnum,...O(W)})};class G$ extends q{unwrap(){return this._def.type}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.promise&&W.common.async===!1)return z(W,{code:D.invalid_type,expected:j.promise,received:W.parsedType}),b;let X=W.parsedType===j.promise?W.data:Promise.resolve(W.data);return R(X.then((H)=>{return this._def.type.parseAsync(H,{path:W.path,errorMap:W.common.contextualErrorMap})}))}}G$.create=($,W)=>{return new G$({type:$,typeName:M.ZodPromise,...O(W)})};class x extends q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:W,ctx:X}=this._processInputParams($),H=this._def.effect||null,Q={addIssue:(Y)=>{if(z(X,Y),Y.fatal)W.abort();else W.dirty()},get path(){return X.path}};if(Q.addIssue=Q.addIssue.bind(Q),H.type==="preprocess"){let Y=H.transform(X.data,Q);if(X.common.async)return Promise.resolve(Y).then(async(G)=>{if(W.value==="aborted")return b;let w=await this._def.schema._parseAsync({data:G,path:X.path,parent:X});if(w.status==="aborted")return b;if(w.status==="dirty")return H$(w.value);if(W.value==="dirty")return H$(w.value);return w});else{if(W.value==="aborted")return b;let G=this._def.schema._parseSync({data:Y,path:X.path,parent:X});if(G.status==="aborted")return b;if(G.status==="dirty")return H$(G.value);if(W.value==="dirty")return H$(G.value);return G}}if(H.type==="refinement"){let Y=(G)=>{let w=H.refinement(G,Q);if(X.common.async)return Promise.resolve(w);if(w instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return G};if(X.common.async===!1){let G=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(G.status==="aborted")return b;if(G.status==="dirty")W.dirty();return Y(G.value),{status:W.value,value:G.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((G)=>{if(G.status==="aborted")return b;if(G.status==="dirty")W.dirty();return Y(G.value).then(()=>{return{status:W.value,value:G.value}})})}if(H.type==="transform")if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!a(Y))return Y;let G=H.transform(Y.value,Q);if(G instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:W.value,value:G}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(!a(Y))return Y;return Promise.resolve(H.transform(Y.value,Q)).then((G)=>({status:W.value,value:G}))});U.assertNever(H)}}x.create=($,W,X)=>{return new x({schema:$,typeName:M.ZodEffects,effect:W,...O(X)})};x.createWithPreprocess=($,W,X)=>{return new x({schema:W,effect:{type:"preprocess",transform:$},typeName:M.ZodEffects,...O(X)})};class k extends q{_parse($){if(this._getType($)===j.undefined)return R(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}k.create=($,W)=>{return new k({innerType:$,typeName:M.ZodOptional,...O(W)})};class r extends q{_parse($){if(this._getType($)===j.null)return R(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}r.create=($,W)=>{return new r({innerType:$,typeName:M.ZodNullable,...O(W)})};class q$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;if(W.parsedType===j.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:W.path,parent:W})}removeDefault(){return this._def.innerType}}q$.create=($,W)=>{return new q$({innerType:$,typeName:M.ZodDefault,defaultValue:typeof W.default==="function"?W.default:()=>W.default,...O(W)})};class U$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X={...W,common:{...W.common,issues:[]}},H=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(B$(H))return H.then((Q)=>{return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new f(X.common.issues)},input:X.data})}});else return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new f(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}U$.create=($,W)=>{return new U$({innerType:$,typeName:M.ZodCatch,catchValue:typeof W.catch==="function"?W.catch:()=>W.catch,...O(W)})};class P$ extends q{_parse($){if(this._getType($)!==j.nan){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.nan,received:X.parsedType}),b}return{status:"valid",value:$.data}}}P$.create=($)=>{return new P$({typeName:M.ZodNaN,...O($)})};var u1=Symbol("zod_brand");class m$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}}class C$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Q=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return b;if(Q.status==="dirty")return W.dirty(),H$(Q.value);else return this._def.out._parseAsync({data:Q.value,path:X.path,parent:X})})();else{let H=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(H.status==="aborted")return b;if(H.status==="dirty")return W.dirty(),{status:"dirty",value:H.value};else return this._def.out._parseSync({data:H.value,path:X.path,parent:X})}}static create($,W){return new C$({in:$,out:W,typeName:M.ZodPipeline})}}class L$ extends q{_parse($){let W=this._def.innerType._parse($),X=(H)=>{if(a(H))H.value=Object.freeze(H.value);return H};return B$(W)?W.then((H)=>X(H)):X(W)}unwrap(){return this._def.innerType}}L$.create=($,W)=>{return new L$({innerType:$,typeName:M.ZodReadonly,...O(W)})};function c2($,W){let X=typeof $==="function"?$(W):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function t2($,W={},X){if($)return J$.create().superRefine((H,Q)=>{let Y=$(H);if(Y instanceof Promise)return Y.then((G)=>{if(!G){let w=c2(W,H),B=w.fatal??X??!0;Q.addIssue({code:"custom",...w,fatal:B})}});if(!Y){let G=c2(W,H),w=G.fatal??X??!0;Q.addIssue({code:"custom",...G,fatal:w})}return});return J$.create()}var i1={object:K.lazycreate},M;(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"})(M||(M={}));var c1=($,W={message:`Input not instance of ${$.name}`})=>t2((X)=>X instanceof $,W),s2=g.create,e2=s.create,p1=P$.create,d1=e.create,$0=j$.create,o1=Q$.create,r1=v$.create,a1=z$.create,t1=V$.create,s1=J$.create,e1=t.create,$W=i.create,WW=f$.create,XW=T.create,HW=K.create,QW=K.strictCreate,JW=A$.create,YW=l$.create,GW=b$.create,wW=c.create,BW=k$.create,DW=I$.create,MW=Y$.create,jW=M$.create,zW=N$.create,VW=O$.create,AW=$$.create,bW=_$.create,NW=G$.create,OW=x.create,_W=k.create,qW=r.create,UW=x.createWithPreprocess,LW=C$.create,KW=()=>s2().optional(),FW=()=>e2().optional(),SW=()=>$0().optional(),EW={string:($)=>g.create({...$,coerce:!0}),number:($)=>s.create({...$,coerce:!0}),boolean:($)=>j$.create({...$,coerce:!0}),bigint:($)=>e.create({...$,coerce:!0}),date:($)=>Q$.create({...$,coerce:!0})};var RW=b;var L2="2025-03-26",W0=[L2,"2024-11-05","2024-10-07"],n$="2.0",X0=J.union([J.string(),J.number().int()]),H0=J.string(),vW=J.object({progressToken:J.optional(X0)}).passthrough(),h=J.object({_meta:J.optional(vW)}).passthrough(),I=J.object({method:J.string(),params:J.optional(h)}),g$=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),p=J.object({method:J.string(),params:J.optional(g$)}),Z=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),u$=J.union([J.string(),J.number().int()]),Q0=J.object({jsonrpc:J.literal(n$),id:u$}).merge(I).strict(),J0=($)=>Q0.safeParse($).success,Y0=J.object({jsonrpc:J.literal(n$)}).merge(p).strict(),G0=($)=>Y0.safeParse($).success,w0=J.object({jsonrpc:J.literal(n$),id:u$,result:Z}).strict(),K2=($)=>w0.safeParse($).success,F;(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(F||(F={}));var B0=J.object({jsonrpc:J.literal(n$),id:u$,error:J.object({code:J.number().int(),message:J.string(),data:J.optional(J.unknown())})}).strict(),D0=($)=>B0.safeParse($).success,M0=J.union([Q0,Y0,w0,B0]),i$=Z.strict(),c$=p.extend({method:J.literal("notifications/cancelled"),params:g$.extend({requestId:u$,reason:J.string().optional()})}),j0=J.object({name:J.string(),version:J.string()}).passthrough(),fW=J.object({experimental:J.optional(J.object({}).passthrough()),sampling:J.optional(J.object({}).passthrough()),roots:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),p$=I.extend({method:J.literal("initialize"),params:h.extend({protocolVersion:J.string(),capabilities:fW,clientInfo:j0})}),W6=($)=>p$.safeParse($).success,kW=J.object({experimental:J.optional(J.object({}).passthrough()),logging:J.optional(J.object({}).passthrough()),completions:J.optional(J.object({}).passthrough()),prompts:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough()),resources:J.optional(J.object({subscribe:J.optional(J.boolean()),listChanged:J.optional(J.boolean())}).passthrough()),tools:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),IW=Z.extend({protocolVersion:J.string(),capabilities:kW,serverInfo:j0,instructions:J.optional(J.string())}),F2=p.extend({method:J.literal("notifications/initialized")});var d$=I.extend({method:J.literal("ping")}),PW=J.object({progress:J.number(),total:J.optional(J.number()),message:J.optional(J.string())}).passthrough(),o$=p.extend({method:J.literal("notifications/progress"),params:g$.merge(PW).extend({progressToken:X0})}),r$=I.extend({params:h.extend({cursor:J.optional(H0)}).optional()}),a$=Z.extend({nextCursor:J.optional(H0)}),z0=J.object({uri:J.string(),mimeType:J.optional(J.string())}).passthrough(),V0=z0.extend({text:J.string()}),A0=z0.extend({blob:J.string().base64()}),CW=J.object({uri:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),gW=J.object({uriTemplate:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),t$=r$.extend({method:J.literal("resources/list")}),TW=a$.extend({resources:J.array(CW)}),s$=r$.extend({method:J.literal("resources/templates/list")}),yW=a$.extend({resourceTemplates:J.array(gW)}),e$=I.extend({method:J.literal("resources/read"),params:h.extend({uri:J.string()})}),xW=Z.extend({contents:J.array(J.union([V0,A0]))}),hW=p.extend({method:J.literal("notifications/resources/list_changed")}),ZW=I.extend({method:J.literal("resources/subscribe"),params:h.extend({uri:J.string()})}),lW=I.extend({method:J.literal("resources/unsubscribe"),params:h.extend({uri:J.string()})}),mW=p.extend({method:J.literal("notifications/resources/updated"),params:g$.extend({uri:J.string()})}),nW=J.object({name:J.string(),description:J.optional(J.string()),required:J.optional(J.boolean())}).passthrough(),uW=J.object({name:J.string(),description:J.optional(J.string()),arguments:J.optional(J.array(nW))}).passthrough(),$2=r$.extend({method:J.literal("prompts/list")}),iW=a$.extend({prompts:J.array(uW)}),W2=I.extend({method:J.literal("prompts/get"),params:h.extend({name:J.string(),arguments:J.optional(J.record(J.string()))})}),X2=J.object({type:J.literal("text"),text:J.string()}).passthrough(),H2=J.object({type:J.literal("image"),data:J.string().base64(),mimeType:J.string()}).passthrough(),Q2=J.object({type:J.literal("audio"),data:J.string().base64(),mimeType:J.string()}).passthrough(),b0=J.object({type:J.literal("resource"),resource:J.union([V0,A0])}).passthrough(),cW=J.object({role:J.enum(["user","assistant"]),content:J.union([X2,H2,Q2,b0])}).passthrough(),pW=Z.extend({description:J.optional(J.string()),messages:J.array(cW)}),dW=p.extend({method:J.literal("notifications/prompts/list_changed")}),oW=J.object({title:J.optional(J.string()),readOnlyHint:J.optional(J.boolean()),destructiveHint:J.optional(J.boolean()),idempotentHint:J.optional(J.boolean()),openWorldHint:J.optional(J.boolean())}).passthrough(),rW=J.object({name:J.string(),description:J.optional(J.string()),inputSchema:J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough(),outputSchema:J.optional(J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough()),annotations:J.optional(oW)}).passthrough(),J2=r$.extend({method:J.literal("tools/list")}),aW=a$.extend({tools:J.array(rW)}),N0=Z.extend({content:J.array(J.union([X2,H2,Q2,b0])).default([]),structuredContent:J.object({}).passthrough().optional(),isError:J.optional(J.boolean())}),X6=N0.or(Z.extend({toolResult:J.unknown()})),Y2=I.extend({method:J.literal("tools/call"),params:h.extend({name:J.string(),arguments:J.optional(J.record(J.unknown()))})}),tW=p.extend({method:J.literal("notifications/tools/list_changed")}),O0=J.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),sW=I.extend({method:J.literal("logging/setLevel"),params:h.extend({level:O0})}),eW=p.extend({method:J.literal("notifications/message"),params:g$.extend({level:O0,logger:J.optional(J.string()),data:J.unknown()})}),$4=J.object({name:J.string().optional()}).passthrough(),W4=J.object({hints:J.optional(J.array($4)),costPriority:J.optional(J.number().min(0).max(1)),speedPriority:J.optional(J.number().min(0).max(1)),intelligencePriority:J.optional(J.number().min(0).max(1))}).passthrough(),X4=J.object({role:J.enum(["user","assistant"]),content:J.union([X2,H2,Q2])}).passthrough(),H4=I.extend({method:J.literal("sampling/createMessage"),params:h.extend({messages:J.array(X4),systemPrompt:J.optional(J.string()),includeContext:J.optional(J.enum(["none","thisServer","allServers"])),temperature:J.optional(J.number()),maxTokens:J.number().int(),stopSequences:J.optional(J.array(J.string())),metadata:J.optional(J.object({}).passthrough()),modelPreferences:J.optional(W4)})}),S2=Z.extend({model:J.string(),stopReason:J.optional(J.enum(["endTurn","stopSequence","maxTokens"]).or(J.string())),role:J.enum(["user","assistant"]),content:J.discriminatedUnion("type",[X2,H2,Q2])}),Q4=J.object({type:J.literal("ref/resource"),uri:J.string()}).passthrough(),J4=J.object({type:J.literal("ref/prompt"),name:J.string()}).passthrough(),G2=I.extend({method:J.literal("completion/complete"),params:h.extend({ref:J.union([J4,Q4]),argument:J.object({name:J.string(),value:J.string()}).passthrough()})}),Y4=Z.extend({completion:J.object({values:J.array(J.string()).max(100),total:J.optional(J.number().int()),hasMore:J.optional(J.boolean())}).passthrough()}),G4=J.object({uri:J.string().startsWith("file://"),name:J.optional(J.string())}).passthrough(),w4=I.extend({method:J.literal("roots/list")}),E2=Z.extend({roots:J.array(G4)}),B4=p.extend({method:J.literal("notifications/roots/list_changed")}),H6=J.union([d$,p$,G2,sW,W2,$2,t$,s$,e$,ZW,lW,Y2,J2]),Q6=J.union([c$,o$,F2,B4]),J6=J.union([i$,S2,E2]),Y6=J.union([d$,H4,w4]),G6=J.union([c$,o$,eW,mW,hW,tW,dW]),w6=J.union([i$,IW,Y4,pW,iW,TW,yW,xW,N0,aW]);class S extends Error{constructor($,W,X){super(`MCP error ${$}: ${W}`);this.code=$,this.data=X,this.name="McpError"}}var D4=60000;class R2{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(c$,(W)=>{let X=this._requestHandlerAbortControllers.get(W.params.requestId);X===null||X===void 0||X.abort(W.params.reason)}),this.setNotificationHandler(o$,(W)=>{this._onprogress(W)}),this.setRequestHandler(d$,(W)=>({}))}_setupTimeout($,W,X,H,Q=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(H,W),startTime:Date.now(),timeout:W,maxTotalTimeout:X,resetTimeoutOnProgress:Q,onTimeout:H})}_resetTimeout($){let W=this._timeoutInfo.get($);if(!W)return!1;let X=Date.now()-W.startTime;if(W.maxTotalTimeout&&X>=W.maxTotalTimeout)throw this._timeoutInfo.delete($),new S(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:W.maxTotalTimeout,totalElapsed:X});return clearTimeout(W.timeoutId),W.timeoutId=setTimeout(W.onTimeout,W.timeout),!0}_cleanupTimeout($){let W=this._timeoutInfo.get($);if(W)clearTimeout(W.timeoutId),this._timeoutInfo.delete($)}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(W)=>{this._onerror(W)},this._transport.onmessage=(W,X)=>{if(K2(W)||D0(W))this._onresponse(W);else if(J0(W))this._onrequest(W,X);else if(G0(W))this._onnotification(W);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(W)}`))},await this._transport.start()}_onclose(){var $;let W=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new S(F.ConnectionClosed,"Connection closed");for(let H of W.values())H(X)}_onerror($){var W;(W=this.onerror)===null||W===void 0||W.call(this,$)}_onnotification($){var W;let X=(W=this._notificationHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((H)=>this._onerror(new Error(`Uncaught error in notification handler: ${H}`)))}_onrequest($,W){var X,H,Q,Y;let G=(X=this._requestHandlers.get($.method))!==null&&X!==void 0?X:this.fallbackRequestHandler;if(G===void 0){(H=this._transport)===null||H===void 0||H.send({jsonrpc:"2.0",id:$.id,error:{code:F.MethodNotFound,message:"Method not found"}}).catch((V)=>this._onerror(new Error(`Failed to send an error response: ${V}`)));return}let w=new AbortController;this._requestHandlerAbortControllers.set($.id,w);let B={signal:w.signal,sessionId:(Q=this._transport)===null||Q===void 0?void 0:Q.sessionId,_meta:(Y=$.params)===null||Y===void 0?void 0:Y._meta,sendNotification:(V)=>this.notification(V,{relatedRequestId:$.id}),sendRequest:(V,_,P)=>this.request(V,_,{...P,relatedRequestId:$.id}),authInfo:W===null||W===void 0?void 0:W.authInfo,requestId:$.id};Promise.resolve().then(()=>G($,B)).then((V)=>{var _;if(w.signal.aborted)return;return(_=this._transport)===null||_===void 0?void 0:_.send({result:V,jsonrpc:"2.0",id:$.id})},(V)=>{var _,P;if(w.signal.aborted)return;return(_=this._transport)===null||_===void 0?void 0:_.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(V.code)?V.code:F.InternalError,message:(P=V.message)!==null&&P!==void 0?P:"Internal error"}})}).catch((V)=>this._onerror(new Error(`Failed to send response: ${V}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:W,...X}=$.params,H=Number(W),Q=this._progressHandlers.get(H);if(!Q){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let Y=this._responseHandlers.get(H),G=this._timeoutInfo.get(H);if(G&&Y&&G.resetTimeoutOnProgress)try{this._resetTimeout(H)}catch(w){Y(w);return}Q(X)}_onresponse($){let W=Number($.id),X=this._responseHandlers.get(W);if(X===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),K2($))X($);else{let H=new S($.error.code,$.error.message,$.error.data);X(H)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,W,X){let{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}=X!==null&&X!==void 0?X:{};return new Promise((G,w)=>{var B,V,_,P,W$,b2;if(!this._transport){w(new Error("Not connected"));return}if(((B=this._options)===null||B===void 0?void 0:B.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(V=X===null||X===void 0?void 0:X.signal)===null||V===void 0||V.throwIfAborted();let n=this._requestMessageId++,l2={...$,jsonrpc:"2.0",id:n};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(n,X.onprogress),l2.params={...$.params,_meta:{...((_=$.params)===null||_===void 0?void 0:_._meta)||{},progressToken:n}};let m2=(C)=>{var X$;this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),(X$=this._transport)===null||X$===void 0||X$.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:n,reason:String(C)}},{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}).catch((F$)=>this._onerror(new Error(`Failed to send cancellation: ${F$}`))),w(C)};this._responseHandlers.set(n,(C)=>{var X$;if((X$=X===null||X===void 0?void 0:X.signal)===null||X$===void 0?void 0:X$.aborted)return;if(C instanceof Error)return w(C);try{let F$=W.parse(C.result);G(F$)}catch(F$){w(F$)}}),(P=X===null||X===void 0?void 0:X.signal)===null||P===void 0||P.addEventListener("abort",()=>{var C;m2((C=X===null||X===void 0?void 0:X.signal)===null||C===void 0?void 0:C.reason)});let n2=(W$=X===null||X===void 0?void 0:X.timeout)!==null&&W$!==void 0?W$:D4,j1=()=>m2(new S(F.RequestTimeout,"Request timed out",{timeout:n2}));this._setupTimeout(n,n2,X===null||X===void 0?void 0:X.maxTotalTimeout,j1,(b2=X===null||X===void 0?void 0:X.resetTimeoutOnProgress)!==null&&b2!==void 0?b2:!1),this._transport.send(l2,{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}).catch((C)=>{this._cleanupTimeout(n),w(C)})})}async notification($,W){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability($.method);let X={...$,jsonrpc:"2.0"};await this._transport.send(X,W)}setRequestHandler($,W){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(H,Q)=>{return Promise.resolve(W($.parse(H),Q))})}removeRequestHandler($){this._requestHandlers.delete($)}assertCanSetRequestHandler($){if(this._requestHandlers.has($))throw new Error(`A request handler for ${$} already exists, which would be overridden`)}setNotificationHandler($,W){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(W($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}function _0($,W){return Object.entries(W).reduce((X,[H,Q])=>{if(Q&&typeof Q==="object")X[H]=X[H]?{...X[H],...Q}:Q;else X[H]=Q;return X},{...$})}class v2 extends R2{constructor($,W){var X;super(W);this._serverInfo=$,this._capabilities=(X=W===null||W===void 0?void 0:W.capabilities)!==null&&X!==void 0?X:{},this._instructions=W===null||W===void 0?void 0:W.instructions,this.setRequestHandler(p$,(H)=>this._oninitialize(H)),this.setNotificationHandler(F2,()=>{var H;return(H=this.oninitialized)===null||H===void 0?void 0:H.call(this)})}registerCapabilities($){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=_0(this._capabilities,$)}assertCapabilityForMethod($){var W,X;switch($){case"sampling/createMessage":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.sampling))throw new 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 new Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let W=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:W0.includes(W)?W:L2,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},i$)}async createMessage($,W){return this.request({method:"sampling/createMessage",params:$},S2,W)}async listRoots($,W){return this.request({method:"roots/list",params:$},E2,W)}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"})}}var U0=Symbol("Let zodToJsonSchema decide on which parser to use");var q0={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},L0=($)=>typeof $==="string"?{...q0,name:$}:{...q0,...$};var K0=($)=>{let W=L0($),X=W.name!==void 0?[...W.basePath,W.definitionPath,W.name]:W.basePath;return{...W,currentPath:X,propertyPath:void 0,seen:new Map(Object.entries(W.definitions).map(([H,Q])=>[Q._def,{def:Q._def,path:[...W.basePath,W.definitionPath,H],jsonSchema:void 0}]))}};function f2($,W,X,H){if(!H?.errorMessages)return;if(X)$.errorMessage={...$.errorMessage,[W]:X}}function L($,W,X,H,Q){$[W]=X,f2($,W,H,Q)}function F0(){return{}}function S0($,W){let X={type:"array"};if($.type?._def&&$.type?._def?.typeName!==M.ZodAny)X.items=N($.type._def,{...W,currentPath:[...W.currentPath,"items"]});if($.minLength)L(X,"minItems",$.minLength.value,$.minLength.message,W);if($.maxLength)L(X,"maxItems",$.maxLength.value,$.maxLength.message,W);if($.exactLength)L(X,"minItems",$.exactLength.value,$.exactLength.message,W),L(X,"maxItems",$.exactLength.value,$.exactLength.message,W);return X}function E0($,W){let X={type:"integer",format:"int64"};if(!$.checks)return X;for(let H of $.checks)switch(H.kind){case"min":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"minimum",H.value,H.message,W);else L(X,"exclusiveMinimum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMinimum=!0;L(X,"minimum",H.value,H.message,W)}break;case"max":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"maximum",H.value,H.message,W);else L(X,"exclusiveMaximum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMaximum=!0;L(X,"maximum",H.value,H.message,W)}break;case"multipleOf":L(X,"multipleOf",H.value,H.message,W);break}return X}function R0(){return{type:"boolean"}}function w2($,W){return N($.type._def,W)}var v0=($,W)=>{return N($.innerType._def,W)};function k2($,W,X){let H=X??W.dateStrategy;if(Array.isArray(H))return{anyOf:H.map((Q,Y)=>k2($,W,Q))};switch(H){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return M4($,W)}}var M4=($,W)=>{let X={type:"integer",format:"unix-time"};if(W.target==="openApi3")return X;for(let H of $.checks)switch(H.kind){case"min":L(X,"minimum",H.value,H.message,W);break;case"max":L(X,"maximum",H.value,H.message,W);break}return X};function f0($,W){return{...N($.innerType._def,W),default:$.defaultValue()}}function k0($,W){return W.effectStrategy==="input"?N($.schema._def,W):{}}function I0($){return{type:"string",enum:Array.from($.values)}}var j4=($)=>{if("type"in $&&$.type==="string")return!1;return"allOf"in $};function P0($,W){let X=[N($.left._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),N($.right._def,{...W,currentPath:[...W.currentPath,"allOf","1"]})].filter((Y)=>!!Y),H=W.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,Q=[];return X.forEach((Y)=>{if(j4(Y)){if(Q.push(...Y.allOf),Y.unevaluatedProperties===void 0)H=void 0}else{let G=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:w,...B}=Y;G=B}else H=void 0;Q.push(G)}}),Q.length?{allOf:Q,...H}:void 0}function C0($,W){let X=typeof $.value;if(X!=="bigint"&&X!=="number"&&X!=="boolean"&&X!=="string")return{type:Array.isArray($.value)?"array":"object"};if(W.target==="openApi3")return{type:X==="bigint"?"integer":X,enum:[$.value]};return{type:X==="bigint"?"integer":X,const:$.value}}var I2=void 0,l={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(I2===void 0)I2=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return I2},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function B2($,W){let X={type:"string"};if($.checks)for(let H of $.checks)switch(H.kind){case"min":L(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,H.value):H.value,H.message,W);break;case"max":L(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,H.value):H.value,H.message,W);break;case"email":switch(W.emailStrategy){case"format:email":m(X,"email",H.message,W);break;case"format:idn-email":m(X,"idn-email",H.message,W);break;case"pattern:zod":v(X,l.email,H.message,W);break}break;case"url":m(X,"uri",H.message,W);break;case"uuid":m(X,"uuid",H.message,W);break;case"regex":v(X,H.regex,H.message,W);break;case"cuid":v(X,l.cuid,H.message,W);break;case"cuid2":v(X,l.cuid2,H.message,W);break;case"startsWith":v(X,RegExp(`^${P2(H.value,W)}`),H.message,W);break;case"endsWith":v(X,RegExp(`${P2(H.value,W)}$`),H.message,W);break;case"datetime":m(X,"date-time",H.message,W);break;case"date":m(X,"date",H.message,W);break;case"time":m(X,"time",H.message,W);break;case"duration":m(X,"duration",H.message,W);break;case"length":L(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,H.value):H.value,H.message,W),L(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,H.value):H.value,H.message,W);break;case"includes":{v(X,RegExp(P2(H.value,W)),H.message,W);break}case"ip":{if(H.version!=="v6")m(X,"ipv4",H.message,W);if(H.version!=="v4")m(X,"ipv6",H.message,W);break}case"base64url":v(X,l.base64url,H.message,W);break;case"jwt":v(X,l.jwt,H.message,W);break;case"cidr":{if(H.version!=="v6")v(X,l.ipv4Cidr,H.message,W);if(H.version!=="v4")v(X,l.ipv6Cidr,H.message,W);break}case"emoji":v(X,l.emoji(),H.message,W);break;case"ulid":{v(X,l.ulid,H.message,W);break}case"base64":{switch(W.base64Strategy){case"format:binary":{m(X,"binary",H.message,W);break}case"contentEncoding:base64":{L(X,"contentEncoding","base64",H.message,W);break}case"pattern:zod":{v(X,l.base64,H.message,W);break}}break}case"nanoid":v(X,l.nanoid,H.message,W);case"toLowerCase":case"toUpperCase":case"trim":break;default:((Q)=>{})(H)}return X}function P2($,W){return W.patternStrategy==="escape"?V4($):$}var z4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function V4($){let W="";for(let X=0;X<$.length;X++){if(!z4.has($[X]))W+="\\";W+=$[X]}return W}function m($,W,X,H){if($.format||$.anyOf?.some((Q)=>Q.format)){if(!$.anyOf)$.anyOf=[];if($.format){if($.anyOf.push({format:$.format,...$.errorMessage&&H.errorMessages&&{errorMessage:{format:$.errorMessage.format}}}),delete $.format,$.errorMessage){if(delete $.errorMessage.format,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.anyOf.push({format:W,...X&&H.errorMessages&&{errorMessage:{format:X}}})}else L($,"format",W,X,H)}function v($,W,X,H){if($.pattern||$.allOf?.some((Q)=>Q.pattern)){if(!$.allOf)$.allOf=[];if($.pattern){if($.allOf.push({pattern:$.pattern,...$.errorMessage&&H.errorMessages&&{errorMessage:{pattern:$.errorMessage.pattern}}}),delete $.pattern,$.errorMessage){if(delete $.errorMessage.pattern,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.allOf.push({pattern:g0(W,H),...X&&H.errorMessages&&{errorMessage:{pattern:X}}})}else L($,"pattern",g0(W,H),X,H)}function g0($,W){if(!W.applyRegexFlags||!$.flags)return $.source;let X={i:$.flags.includes("i"),m:$.flags.includes("m"),s:$.flags.includes("s")},H=X.i?$.source.toLowerCase():$.source,Q="",Y=!1,G=!1,w=!1;for(let B=0;B<H.length;B++){if(Y){Q+=H[B],Y=!1;continue}if(X.i){if(G){if(H[B].match(/[a-z]/)){if(w)Q+=H[B],Q+=`${H[B-2]}-${H[B]}`.toUpperCase(),w=!1;else if(H[B+1]==="-"&&H[B+2]?.match(/[a-z]/))Q+=H[B],w=!0;else Q+=`${H[B]}${H[B].toUpperCase()}`;continue}}else if(H[B].match(/[a-z]/)){Q+=`[${H[B]}${H[B].toUpperCase()}]`;continue}}if(X.m){if(H[B]==="^"){Q+=`(^|(?<=[\r
|
2
|
-
]))`;continue}else if(
|
3
|
-
]))`;continue}}if(
|
4
|
-
`:`[${
|
5
|
-
]`;continue}if(Q+=H[B],H[B]==="\\")Y=!0;else if(G&&H[B]==="]")G=!1;else if(!G&&H[B]==="[")G=!0}try{new RegExp(Q)}catch{return console.warn(`Could not convert regex pattern at ${W.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return Q}function D2($,W){if(W.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(W.target==="openApi3"&&$.keyType?._def.typeName===M.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((H,Q)=>({...H,[Q]:N($.valueType._def,{...W,currentPath:[...W.currentPath,"properties",Q]})??{}}),{}),additionalProperties:W.rejectedAdditionalProperties};let X={type:"object",additionalProperties:N($.valueType._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]})??W.allowedAdditionalProperties};if(W.target==="openApi3")return X;if($.keyType?._def.typeName===M.ZodString&&$.keyType._def.checks?.length){let{type:H,...Q}=B2($.keyType._def,W);return{...X,propertyNames:Q}}else if($.keyType?._def.typeName===M.ZodEnum)return{...X,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===M.ZodBranded&&$.keyType._def.type._def.typeName===M.ZodString&&$.keyType._def.type._def.checks?.length){let{type:H,...Q}=w2($.keyType._def,W);return{...X,propertyNames:Q}}return X}function T0($,W){if(W.mapStrategy==="record")return D2($,W);let X=N($.keyType._def,{...W,currentPath:[...W.currentPath,"items","items","0"]})||{},H=N($.valueType._def,{...W,currentPath:[...W.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[X,H],minItems:2,maxItems:2}}}function y0($){let W=$.values,H=Object.keys($.values).filter((Y)=>{return typeof W[W[Y]]!=="number"}).map((Y)=>W[Y]),Q=Array.from(new Set(H.map((Y)=>typeof Y)));return{type:Q.length===1?Q[0]==="string"?"string":"number":["string","number"],enum:H}}function x0(){return{not:{}}}function h0($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var T$={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function l0($,W){if(W.target==="openApi3")return Z0($,W);let X=$.options instanceof Map?Array.from($.options.values()):$.options;if(X.every((H)=>(H._def.typeName in T$)&&(!H._def.checks||!H._def.checks.length))){let H=X.reduce((Q,Y)=>{let G=T$[Y._def.typeName];return G&&!Q.includes(G)?[...Q,G]:Q},[]);return{type:H.length>1?H:H[0]}}else if(X.every((H)=>H._def.typeName==="ZodLiteral"&&!H.description)){let H=X.reduce((Q,Y)=>{let G=typeof Y._def.value;switch(G){case"string":case"number":case"boolean":return[...Q,G];case"bigint":return[...Q,"integer"];case"object":if(Y._def.value===null)return[...Q,"null"];case"symbol":case"undefined":case"function":default:return Q}},[]);if(H.length===X.length){let Q=H.filter((Y,G,w)=>w.indexOf(Y)===G);return{type:Q.length>1?Q:Q[0],enum:X.reduce((Y,G)=>{return Y.includes(G._def.value)?Y:[...Y,G._def.value]},[])}}}else if(X.every((H)=>H._def.typeName==="ZodEnum"))return{type:"string",enum:X.reduce((H,Q)=>[...H,...Q._def.values.filter((Y)=>!H.includes(Y))],[])};return Z0($,W)}var Z0=($,W)=>{let X=($.options instanceof Map?Array.from($.options.values()):$.options).map((H,Q)=>N(H._def,{...W,currentPath:[...W.currentPath,"anyOf",`${Q}`]})).filter((H)=>!!H&&(!W.strictUnions||typeof H==="object"&&Object.keys(H).length>0));return X.length?{anyOf:X}:void 0};function m0($,W){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(W.target==="openApi3")return{type:T$[$.innerType._def.typeName],nullable:!0};return{type:[T$[$.innerType._def.typeName],"null"]}}if(W.target==="openApi3"){let H=N($.innerType._def,{...W,currentPath:[...W.currentPath]});if(H&&"$ref"in H)return{allOf:[H],nullable:!0};return H&&{...H,nullable:!0}}let X=N($.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","0"]});return X&&{anyOf:[X,{type:"null"}]}}function n0($,W){let X={type:"number"};if(!$.checks)return X;for(let H of $.checks)switch(H.kind){case"int":X.type="integer",f2(X,"type",H.message,W);break;case"min":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"minimum",H.value,H.message,W);else L(X,"exclusiveMinimum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMinimum=!0;L(X,"minimum",H.value,H.message,W)}break;case"max":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"maximum",H.value,H.message,W);else L(X,"exclusiveMaximum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMaximum=!0;L(X,"maximum",H.value,H.message,W)}break;case"multipleOf":L(X,"multipleOf",H.value,H.message,W);break}return X}function u0($,W){let X=W.target==="openAi",H={type:"object",properties:{}},Q=[],Y=$.shape();for(let w in Y){let B=Y[w];if(B===void 0||B._def===void 0)continue;let V=b4(B);if(V&&X){if(B instanceof k)B=B._def.innerType;if(!B.isNullable())B=B.nullable();V=!1}let _=N(B._def,{...W,currentPath:[...W.currentPath,"properties",w],propertyPath:[...W.currentPath,"properties",w]});if(_===void 0)continue;if(H.properties[w]=_,!V)Q.push(w)}if(Q.length)H.required=Q;let G=A4($,W);if(G!==void 0)H.additionalProperties=G;return H}function A4($,W){if($.catchall._def.typeName!=="ZodNever")return N($.catchall._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return W.allowedAdditionalProperties;case"strict":return W.rejectedAdditionalProperties;case"strip":return W.removeAdditionalStrategy==="strict"?W.allowedAdditionalProperties:W.rejectedAdditionalProperties}}function b4($){try{return $.isOptional()}catch{return!0}}var i0=($,W)=>{if(W.currentPath.toString()===W.propertyPath?.toString())return N($.innerType._def,W);let X=N($.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","1"]});return X?{anyOf:[{not:{}},X]}:{}};var c0=($,W)=>{if(W.pipeStrategy==="input")return N($.in._def,W);else if(W.pipeStrategy==="output")return N($.out._def,W);let X=N($.in._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),H=N($.out._def,{...W,currentPath:[...W.currentPath,"allOf",X?"1":"0"]});return{allOf:[X,H].filter((Q)=>Q!==void 0)}};function p0($,W){return N($.type._def,W)}function d0($,W){let H={type:"array",uniqueItems:!0,items:N($.valueType._def,{...W,currentPath:[...W.currentPath,"items"]})};if($.minSize)L(H,"minItems",$.minSize.value,$.minSize.message,W);if($.maxSize)L(H,"maxItems",$.maxSize.value,$.maxSize.message,W);return H}function o0($,W){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((X,H)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${H}`]})).reduce((X,H)=>H===void 0?X:[...X,H],[]),additionalItems:N($.rest._def,{...W,currentPath:[...W.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((X,H)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${H}`]})).reduce((X,H)=>H===void 0?X:[...X,H],[])}}function r0(){return{not:{}}}function a0(){return{}}var t0=($,W)=>{return N($.innerType._def,W)};var s0=($,W,X)=>{switch(W){case M.ZodString:return B2($,X);case M.ZodNumber:return n0($,X);case M.ZodObject:return u0($,X);case M.ZodBigInt:return E0($,X);case M.ZodBoolean:return R0();case M.ZodDate:return k2($,X);case M.ZodUndefined:return r0();case M.ZodNull:return h0(X);case M.ZodArray:return S0($,X);case M.ZodUnion:case M.ZodDiscriminatedUnion:return l0($,X);case M.ZodIntersection:return P0($,X);case M.ZodTuple:return o0($,X);case M.ZodRecord:return D2($,X);case M.ZodLiteral:return C0($,X);case M.ZodEnum:return I0($);case M.ZodNativeEnum:return y0($);case M.ZodNullable:return m0($,X);case M.ZodOptional:return i0($,X);case M.ZodMap:return T0($,X);case M.ZodSet:return d0($,X);case M.ZodLazy:return()=>$.getter()._def;case M.ZodPromise:return p0($,X);case M.ZodNaN:case M.ZodNever:return x0();case M.ZodEffects:return k0($,X);case M.ZodAny:return F0();case M.ZodUnknown:return a0();case M.ZodDefault:return f0($,X);case M.ZodBranded:return w2($,X);case M.ZodReadonly:return t0($,X);case M.ZodCatch:return v0($,X);case M.ZodPipeline:return c0($,X);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return((H)=>{return})(W)}};function N($,W,X=!1){let H=W.seen.get($);if(W.override){let w=W.override?.($,W,H,X);if(w!==U0)return w}if(H&&!X){let w=N4(H,W);if(w!==void 0)return w}let Q={def:$,path:W.currentPath,jsonSchema:void 0};W.seen.set($,Q);let Y=s0($,$.typeName,W),G=typeof Y==="function"?N(Y(),W):Y;if(G)_4($,W,G);if(W.postProcess){let w=W.postProcess(G,$,W);return Q.jsonSchema=G,w}return Q.jsonSchema=G,G}var N4=($,W)=>{switch(W.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:O4(W.currentPath,$.path)};case"none":case"seen":{if($.path.length<W.currentPath.length&&$.path.every((X,H)=>W.currentPath[H]===X))return console.warn(`Recursive reference detected at ${W.currentPath.join("/")}! Defaulting to any`),{};return W.$refStrategy==="seen"?{}:void 0}}},O4=($,W)=>{let X=0;for(;X<$.length&&X<W.length;X++)if($[X]!==W[X])break;return[($.length-X).toString(),...W.slice(X)].join("/")},_4=($,W,X)=>{if($.description){if(X.description=$.description,W.markdownDescription)X.markdownDescription=$.description}return X};var M2=($,W)=>{let X=K0(W),H=typeof W==="object"&&W.definitions?Object.entries(W.definitions).reduce((B,[V,_])=>({...B,[V]:N(_._def,{...X,currentPath:[...X.basePath,X.definitionPath,V]},!0)??{}}),{}):void 0,Q=typeof W==="string"?W:W?.nameStrategy==="title"?void 0:W?.name,Y=N($._def,Q===void 0?X:{...X,currentPath:[...X.basePath,X.definitionPath,Q]},!1)??{},G=typeof W==="object"&&W.name!==void 0&&W.nameStrategy==="title"?W.name:void 0;if(G!==void 0)Y.title=G;let w=Q===void 0?H?{...Y,[X.definitionPath]:H}:Y:{$ref:[...X.$refStrategy==="relative"?[]:X.basePath,X.definitionPath,Q].join("/"),[X.definitionPath]:{...H,[Q]:Y}};if(X.target==="jsonSchema7")w.$schema="http://json-schema.org/draft-07/schema#";else if(X.target==="jsonSchema2019-09"||X.target==="openAi")w.$schema="https://json-schema.org/draft/2019-09/schema#";if(X.target==="openAi"&&(("anyOf"in w)||("oneOf"in w)||("allOf"in w)||("type"in w)&&Array.isArray(w.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return w};var C2;(function($){$.Completable="McpCompletable"})(C2||(C2={}));class y$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}}y$.create=($,W)=>{return new y$({type:$,typeName:C2.Completable,complete:W.complete,...q4(W)})};function q4($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:H,description:Q}=$;if(W&&(X||H))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(G,w)=>{var B,V;let{message:_}=$;if(G.code==="invalid_enum_value")return{message:_!==null&&_!==void 0?_:w.defaultError};if(typeof w.data==="undefined")return{message:(B=_!==null&&_!==void 0?_:H)!==null&&B!==void 0?B:w.defaultError};if(G.code!=="invalid_type")return{message:w.defaultError};return{message:(V=_!==null&&_!==void 0?_:X)!==null&&V!==void 0?V:w.defaultError}},description:Q}}class g2{constructor($,W){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new v2($,W)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(J2.shape.method.value),this.server.assertCanSetRequestHandler(Y2.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(J2,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,W])=>{let X={name:$,description:W.description,inputSchema:W.inputSchema?M2(W.inputSchema,{strictUnions:!0}):U4,annotations:W.annotations};if(W.outputSchema)X.outputSchema=M2(W.outputSchema,{strictUnions:!0});return X})})),this.server.setRequestHandler(Y2,async($,W)=>{let X=this._registeredTools[$.params.name];if(!X)throw new S(F.InvalidParams,`Tool ${$.params.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Tool ${$.params.name} disabled`);let H;if(X.inputSchema){let Q=await X.inputSchema.safeParseAsync($.params.arguments);if(!Q.success)throw new S(F.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${Q.error.message}`);let Y=Q.data,G=X.callback;try{H=await Promise.resolve(G(Y,W))}catch(w){H={content:[{type:"text",text:w instanceof Error?w.message:String(w)}],isError:!0}}}else{let Q=X.callback;try{H=await Promise.resolve(Q(W))}catch(Y){H={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(X.outputSchema){if(!H.structuredContent)throw new S(F.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let Q=await X.outputSchema.safeParseAsync(H.structuredContent);if(!Q.success)throw new S(F.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${Q.error.message}`)}return H}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(G2.shape.method.value),this.server.setRequestHandler(G2,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new S(F.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,W){let X=this._registeredPrompts[W.name];if(!X)throw new S(F.InvalidParams,`Prompt ${W.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Prompt ${W.name} disabled`);if(!X.argsSchema)return j2;let H=X.argsSchema.shape[$.params.argument.name];if(!(H instanceof y$))return j2;let Y=await H._def.complete($.params.argument.value);return $1(Y)}async handleResourceCompletion($,W){let X=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===W.uri);if(!X){if(this._registeredResources[W.uri])return j2;throw new S(F.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let H=X.resourceTemplate.completeCallback($.params.argument.name);if(!H)return j2;let Q=await H($.params.argument.value);return $1(Q)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(t$.shape.method.value),this.server.assertCanSetRequestHandler(s$.shape.method.value),this.server.assertCanSetRequestHandler(e$.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(t$,async($,W)=>{let X=Object.entries(this._registeredResources).filter(([Q,Y])=>Y.enabled).map(([Q,Y])=>({uri:Q,name:Y.name,...Y.metadata})),H=[];for(let Q of Object.values(this._registeredResourceTemplates)){if(!Q.resourceTemplate.listCallback)continue;let Y=await Q.resourceTemplate.listCallback(W);for(let G of Y.resources)H.push({...G,...Q.metadata})}return{resources:[...X,...H]}}),this.server.setRequestHandler(s$,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([W,X])=>({name:W,uriTemplate:X.resourceTemplate.uriTemplate.toString(),...X.metadata}))}}),this.server.setRequestHandler(e$,async($,W)=>{let X=new URL($.params.uri),H=this._registeredResources[X.toString()];if(H){if(!H.enabled)throw new S(F.InvalidParams,`Resource ${X} disabled`);return H.readCallback(X,W)}for(let Q of Object.values(this._registeredResourceTemplates)){let Y=Q.resourceTemplate.uriTemplate.match(X.toString());if(Y)return Q.readCallback(X,Y,W)}throw new S(F.InvalidParams,`Resource ${X} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler($2.shape.method.value),this.server.assertCanSetRequestHandler(W2.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler($2,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,W])=>{return{name:$,description:W.description,arguments:W.argsSchema?K4(W.argsSchema):void 0}})})),this.server.setRequestHandler(W2,async($,W)=>{let X=this._registeredPrompts[$.params.name];if(!X)throw new S(F.InvalidParams,`Prompt ${$.params.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Prompt ${$.params.name} disabled`);if(X.argsSchema){let H=await X.argsSchema.safeParseAsync($.params.arguments);if(!H.success)throw new S(F.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${H.error.message}`);let Q=H.data,Y=X.callback;return await Promise.resolve(Y(Q,W))}else{let H=X.callback;return await Promise.resolve(H(W))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,W,...X){let H;if(typeof X[0]==="object")H=X.shift();let Q=X[0];if(typeof W==="string"){if(this._registeredResources[W])throw new Error(`Resource ${W} is already registered`);let Y={name:$,metadata:H,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(G)=>{if(typeof G.uri!=="undefined"&&G.uri!==W){if(delete this._registeredResources[W],G.uri)this._registeredResources[G.uri]=Y}if(typeof G.name!=="undefined")Y.name=G.name;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResources[W]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let Y={resourceTemplate:W,metadata:H,readCallback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredResourceTemplates[$],G.name)this._registeredResourceTemplates[G.name]=Y}if(typeof G.template!=="undefined")Y.resourceTemplate=G.template;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}_createRegisteredTool($,W,X,H,Q,Y){let G={description:W,inputSchema:X===void 0?void 0:J.object(X),outputSchema:H===void 0?void 0:J.object(H),annotations:Q,callback:Y,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==$){if(delete this._registeredTools[$],w.name)this._registeredTools[w.name]=G}if(typeof w.description!=="undefined")G.description=w.description;if(typeof w.paramsSchema!=="undefined")G.inputSchema=J.object(w.paramsSchema);if(typeof w.callback!=="undefined")G.callback=w.callback;if(typeof w.annotations!=="undefined")G.annotations=w.annotations;if(typeof w.enabled!=="undefined")G.enabled=w.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool($,...W){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let X,H,Q,Y;if(typeof W[0]==="string")X=W.shift();if(W.length>1){let w=W[0];if(e0(w)){if(H=W.shift(),W.length>1&&typeof W[0]==="object"&&W[0]!==null&&!e0(W[0]))Y=W.shift()}else if(typeof w==="object"&&w!==null)Y=W.shift()}let G=W[0];return this._createRegisteredTool($,X,H,Q,Y,G)}registerTool($,W,X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:H,inputSchema:Q,outputSchema:Y,annotations:G}=W;return this._createRegisteredTool($,H,Q,Y,G,X)}prompt($,...W){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let X;if(typeof W[0]==="string")X=W.shift();let H;if(W.length>1)H=W.shift();let Q=W[0],Y={description:X,argsSchema:H===void 0?void 0:J.object(H),callback:Q,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredPrompts[$],G.name)this._registeredPrompts[G.name]=Y}if(typeof G.description!=="undefined")Y.description=G.description;if(typeof G.argsSchema!=="undefined")Y.argsSchema=J.object(G.argsSchema);if(typeof G.callback!=="undefined")Y.callback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=Y,this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var U4={type:"object"};function e0($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(L4)}function L4($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function K4($){return Object.entries($.shape).map(([W,X])=>({name:W,description:X.description,required:!X.isOptional()}))}function $1($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var j2={completion:{values:[],hasMore:!1}};var W1=process.argv.find(($)=>$.startsWith("--figma-api-key=")),F4=W1?W1.split("=")[1]:"",z2=F4||process.env.personalToken||process.env.FIGMA_API_KEY||"",X1="F2C MCP",H1=process.env.FIGMA_VERSION||"0.0.1";class Q1{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=z2;async nodeToCode($){let W={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")W.option.cssFramework="cssmodules";else if($.format==="react-tailwind")W.option.cssFramework="tailwindcss";let X=this.opToUrl(`${this.f2cHost}/nodes`,W);return this.fetch(X,"json")}async fetch($,W="json"){try{let H=await fetch($,{method:"GET"});if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);return W==="text"?await H.text():await H.json()}catch(X){throw console.error("HTTP error",X),X}}opToUrl($,W={}){if(Object.keys(W).length===0)return $;let X=new URL($);for(let[H,Q]of Object.entries(W))if(typeof Q==="object"&&Q!==null)for(let[Y,G]of Object.entries(Q))X.searchParams.append(`${H}[${Y}]`,G);else X.searchParams.append(H,Q);return X.toString()}}var J1=new Q1;var V2=O2(require("fs")),K$=O2(require("path"));class Y1{imgFormat="png";setImgFormat($){this.imgFormat=$}async downloadImage($,W){try{if(!V2.default.existsSync(W.localPath))V2.default.mkdirSync(W.localPath,{recursive:!0});let X=`${W.fileName}.${this.imgFormat}`,H=K$.default.join(W.localPath,X),Q=await fetch($);if(!Q.ok)throw new Error(`下载失败: ${Q.status} ${Q.statusText}`);let Y=await Q.arrayBuffer();return V2.default.writeFileSync(H,new Uint8Array(Y)),K$.default.join(K$.default.basename(W.localPath),X).replace(/\\/g,"/")}catch(X){throw console.error("图片下载错误:",X),X}}async processContent($,W){W=K$.default.join(W,"images");try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,H=$.match(X);if(!H)return $;let Q=$;for(let Y of H){let G=K$.default.basename(Y),w=await this.downloadImage(Y,{localPath:W,fileName:G});Q=Q.replace(Y,w)}return Q}catch(X){throw console.error("内容处理错误:",X),X}}}var T2=new Y1;var G1=($)=>{$.tool("figma_to_code","Transform Figma designs into production-ready code. This tool converts selected Figma nodes into HTML, React with CSS Modules, or React with Tailwind CSS, enabling seamless design-to-code workflow.",{fileKey:J.string().describe("The Figma file identifier found in the file URL (e.g., https://www.figma.com/file/XXXXXXXXXXXX/). Extract the XXXXXXXXXXXX portion as the fileKey."),ids:J.string().describe('Comma-separated list of Figma node IDs for conversion. To obtain node IDs, select elements in Figma, right-click and select "Copy/Paste as" → "Copy ID".'),format:J.enum(["html","react-cssmodules","react-tailwind"]).default("html").describe('Specify the output format: "html" generates semantic HTML/CSS, "react-cssmodules" creates React components with scoped CSS modules, "react-tailwind" produces React components with utility-first Tailwind classes.'),personalToken:J.string().optional().describe("Figma personal access token for API authentication.The parameters are not required when the tool is called."),localPath:J.string().optional().describe("Absolute path for image asset storage. Directory will be created if non-existent. Path must follow OS-specific format without special character escaping."),imgFormat:J.enum(["png","jpg","svg"]).default("png").describe('Export format for image assets: "png" for lossless quality, "jpg" for compressed files, or "svg" for vector graphics.'),scaleSize:J.number().min(1).max(4).default(2).describe("Image export scale factor (1-4). Higher values yield better quality at the cost of larger file sizes.")},async(W,X)=>{console.log(X);try{let H=await J1.nodeToCode(W)||[];if(W.localPath)T2.setImgFormat(W.imgFormat),await Promise.all(H.map(async(Q)=>{Q.content=await T2.processContent(Q.content,W.localPath)}));return{content:[{type:"text",text:JSON.stringify(H)}]}}catch(H){return console.error("Tool execution error:",H),{content:[{type:"text",text:`Error: ${H.message}`}]}}})};class w1{figmaHost="https://api.figma.com/v1";personalToken=z2;async files($){let W;if($.ids)W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(W)}async images($){let W=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(W)}async imageFills($){let W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(W)}async meta($){let W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(W)}async fetch($,W="json"){try{let X={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},H=await fetch($,X);if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);return W==="text"?await H.text():await H.json()}catch(X){throw console.error("HTTP error",X),X}}opToUrl($,W={},X=["fileKey","personalToken"]){if(Object.keys(W).length===0)return $;if(W.personalToken)this.personalToken=W.personalToken;let H=new URL($);for(let[Q,Y]of Object.entries(W))if(!X.includes(Q))H.searchParams.append(Q,Y);return H.toString()}}var y2=new w1;var B1=($)=>{$.tool("figma_get_file_data","Get detailed information about a Figma file",{fileKey:J.string().describe("Unique identifier of the Figma file"),ids:J.string().describe("List of node IDs to retrieve, comma separated"),personalToken:J.string().optional().describe("Your Figma personal access token, The parameters are not required when the tool is called."),version:J.string().optional().describe("Specify the version to return"),depth:J.number().optional().describe("Specify the depth of nodes to return"),geometry:J.enum(["paths"]).optional().describe("Specify whether to include geometry path data"),plugin_data:J.string().optional().describe("Specify plugin data to return"),branch_data:J.boolean().optional().describe("Specify whether to return branch data")},async(W)=>{try{let X=await y2.files(W);return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return{content:[{type:"text",text:`Error: ${X.message}`}]}}}),$.tool("figma_get_images","Get images of Figma nodes",{fileKey:J.string().describe("Unique identifier of the Figma file"),ids:J.string().describe("Node IDs to get images for, comma separated"),format:J.enum(["jpg","png","svg","pdf"]).optional().describe("Image format, e.g., png, jpg, svg"),scale:J.number().optional().describe("Image scale factor"),svg_include_id:J.boolean().optional().describe("Whether SVG includes ID"),svg_simplify_stroke:J.boolean().optional().describe("Whether to simplify SVG strokes"),use_absolute_bounds:J.boolean().optional().describe("Whether to use absolute bounds"),version:J.string().optional().describe("Specify the version to return"),personalToken:J.string().optional().describe("Your Figma personal access token, The parameters are not required when the tool is called.")},async(W)=>{try{let X=await y2.images(W);return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return{content:[{type:"text",text:`Error: ${X.message}`}]}}})};var A2=new g2({name:X1,version:H1},{capabilities:{logging:{}}});B1(A2);G1(A2);var h2=O2(require("node:process"));class x2{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
var E2=Object.create;var{getPrototypeOf:b2,defineProperty:L1,getOwnPropertyNames:v2}=Object;var k2=Object.prototype.hasOwnProperty;var c0=($,X,W)=>{W=$!=null?E2(b2($)):{};let Q=X||!$||!$.__esModule?L1(W,"default",{value:$,enumerable:!0}):W;for(let H of v2($))if(!k2.call(Q,H))L1(Q,H,{get:()=>$[H],enumerable:!0});return Q};var l6=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var n6=($,X)=>{for(var W in X)L1($,W,{get:X[W],enumerable:!0,configurable:!0,set:(Q)=>X[W]=()=>Q})};var F1=($,X)=>()=>($&&(X=$($=0)),X);function I2($){s1=$}function u0(){return s1}function A($,X){let W=u0(),Q=p0({issueData:X,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,W,W===V0?void 0:V0].filter((H)=>!!H)});$.common.issues.push(Q)}class E{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,X){let W=[];for(let Q of X){if(Q.status==="aborted")return U;if(Q.status==="dirty")$.dirty();W.push(Q.value)}return{status:$.value,value:W}}static async mergeObjectAsync($,X){let W=[];for(let Q of X){let H=await Q.key,Y=await Q.value;W.push({key:H,value:Y})}return E.mergeObjectSync($,W)}static mergeObjectSync($,X){let W={};for(let Q of X){let{key:H,value:Y}=Q;if(H.status==="aborted")return U;if(Y.status==="aborted")return U;if(H.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(H.value!=="__proto__"&&(typeof Y.value!=="undefined"||Q.alwaysSet))W[H.value]=Y.value}return{status:$.value,value:W}}}function i0($,X,W,Q){if(W==="a"&&!Q)throw new TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!Q:!X.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?Q:W==="a"?Q.call($):Q?Q.value:X.get($)}function e1($,X,W,Q,H){if(Q==="m")throw new TypeError("Private method is not writable");if(Q==="a"&&!H)throw new TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!H:!X.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Q==="a"?H.call($,W):H?H.value=W:X.set($,W),W}class y{constructor($,X,W,Q){this._cachedPath=[],this.parent=$,this.data=X,this._path=W,this._key=Q}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}}function N($){if(!$)return{};let{errorMap:X,invalid_type_error:W,required_error:Q,description:H}=$;if(X&&(W||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:H};return{errorMap:(G,B)=>{var w,M;let{message:q}=$;if(G.code==="invalid_enum_value")return{message:q!==null&&q!==void 0?q:B.defaultError};if(typeof B.data==="undefined")return{message:(w=q!==null&&q!==void 0?q:Q)!==null&&w!==void 0?w:B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:(M=q!==null&&q!==void 0?q:W)!==null&&M!==void 0?M:B.defaultError}},description:H}}class K{get description(){return this._def.description}_getType($){return t($.data)}_getOrReturnCtx($,X){return X||{common:$.parent.common,data:$.data,parsedType:t($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new E,ctx:{common:$.parent.common,data:$.data,parsedType:t($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let X=this._parse($);if(k0(X))throw new Error("Synchronous parse encountered promise.");return X}_parseAsync($){let X=this._parse($);return Promise.resolve(X)}parse($,X){let W=this.safeParse($,X);if(W.success)return W.data;throw W.error}safeParse($,X){var W;let Q={common:{issues:[],async:(W=X===null||X===void 0?void 0:X.async)!==null&&W!==void 0?W:!1,contextualErrorMap:X===null||X===void 0?void 0:X.errorMap},path:(X===null||X===void 0?void 0:X.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)},H=this._parseSync({data:$,path:Q.path,parent:Q});return r1(Q,H)}"~validate"($){var X,W;let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)};if(!this["~standard"].async)try{let H=this._parseSync({data:$,path:[],parent:Q});return J0(H)?{value:H.value}:{issues:Q.common.issues}}catch(H){if((W=(X=H===null||H===void 0?void 0:H.message)===null||X===void 0?void 0:X.toLowerCase())===null||W===void 0?void 0:W.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:Q}).then((H)=>J0(H)?{value:H.value}:{issues:Q.common.issues})}async parseAsync($,X){let W=await this.safeParseAsync($,X);if(W.success)return W.data;throw W.error}async safeParseAsync($,X){let W={common:{issues:[],contextualErrorMap:X===null||X===void 0?void 0:X.errorMap,async:!0},path:(X===null||X===void 0?void 0:X.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)},Q=this._parse({data:$,path:W.path,parent:W}),H=await(k0(Q)?Q:Promise.resolve(Q));return r1(W,H)}refine($,X){let W=(Q)=>{if(typeof X==="string"||typeof X==="undefined")return{message:X};else if(typeof X==="function")return X(Q);else return X};return this._refinement((Q,H)=>{let Y=$(Q),G=()=>H.addIssue({code:D.custom,...W(Q)});if(typeof Promise!=="undefined"&&Y instanceof Promise)return Y.then((B)=>{if(!B)return G(),!1;else return!0});if(!Y)return G(),!1;else return!0})}refinement($,X){return this._refinement((W,Q)=>{if(!$(W))return Q.addIssue(typeof X==="function"?X(W,Q):X),!1;else return!0})}_refinement($){return new T({schema:this,typeName:z.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:(X)=>this["~validate"](X)}}optional(){return I.create(this,this._def)}nullable(){return s.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return h.create(this)}promise(){return w0.create(this,this._def)}or($){return U0.create([this,$],this._def)}and($){return K0.create(this,$,this._def)}transform($){return new T({...N(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:$}})}default($){let X=typeof $==="function"?$:()=>$;return new S0({...N(this._def),innerType:this,defaultValue:X,typeName:z.ZodDefault})}brand(){return new o0({typeName:z.ZodBranded,type:this,...N(this._def)})}catch($){let X=typeof $==="function"?$:()=>$;return new _0({...N(this._def),innerType:this,catchValue:X,typeName:z.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return g0.create(this,$)}readonly(){return R0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function X$($){let X="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)X=`${X}\\.\\d{${$.precision}}`;else if($.precision==null)X=`${X}(\\.\\d+)?`;return X}function r2($){return new RegExp(`^${X$($)}$`)}function W$($){let X=`${$$}T${X$($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return X=`${X}(${W.join("|")})`,new RegExp(`^${X}$`)}function a2($,X){if((X==="v4"||!X)&&n2.test($))return!0;if((X==="v6"||!X)&&u2.test($))return!0;return!1}function t2($,X){if(!y2.test($))return!1;try{let[W]=$.split("."),Q=W.replace(/-/g,"+").replace(/_/g,"/").padEnd(W.length+(4-W.length%4)%4,"="),H=JSON.parse(atob(Q));if(typeof H!=="object"||H===null)return!1;if(!H.typ||!H.alg)return!1;if(X&&H.alg!==X)return!1;return!0}catch(W){return!1}}function s2($,X){if((X==="v4"||!X)&&c2.test($))return!0;if((X==="v6"||!X)&&p2.test($))return!0;return!1}function e2($,X){let W=($.toString().split(".")[1]||"").length,Q=(X.toString().split(".")[1]||"").length,H=W>Q?W:Q,Y=parseInt($.toFixed(H).replace(".","")),G=parseInt(X.toFixed(H).replace(".",""));return Y%G/Math.pow(10,H)}function z0($){if($ instanceof S){let X={};for(let W in $.shape){let Q=$.shape[W];X[W]=I.create(z0(Q))}return new S({...$._def,shape:()=>X})}else if($ instanceof h)return new h({...$._def,type:z0($.element)});else if($ instanceof I)return I.create(z0($.unwrap()));else if($ instanceof s)return s.create(z0($.unwrap()));else if($ instanceof i)return i.create($.items.map((X)=>z0(X)));else return $}function b1($,X){let W=t($),Q=t(X);if($===X)return{valid:!0,data:$};else if(W===V.object&&Q===V.object){let H=F.objectKeys(X),Y=F.objectKeys($).filter((B)=>H.indexOf(B)!==-1),G={...$,...X};for(let B of Y){let w=b1($[B],X[B]);if(!w.valid)return{valid:!1};G[B]=w.data}return{valid:!0,data:G}}else if(W===V.array&&Q===V.array){if($.length!==X.length)return{valid:!1};let H=[];for(let Y=0;Y<$.length;Y++){let G=$[Y],B=X[Y],w=b1(G,B);if(!w.valid)return{valid:!1};H.push(w.data)}return{valid:!0,data:H}}else if(W===V.date&&Q===V.date&&+$===+X)return{valid:!0,data:$};else return{valid:!1}}function Q$($,X){return new W0({values:$,typeName:z.ZodEnum,...N(X)})}function a1($,X){let W=typeof $==="function"?$(X):typeof $==="string"?{message:$}:$;return typeof W==="string"?{message:W}:W}function H$($,X={},W){if($)return G0.create().superRefine((Q,H)=>{var Y,G;let B=$(Q);if(B instanceof Promise)return B.then((w)=>{var M,q;if(!w){let b=a1(X,Q),r=(q=(M=b.fatal)!==null&&M!==void 0?M:W)!==null&&q!==void 0?q:!0;H.addIssue({code:"custom",...b,fatal:r})}});if(!B){let w=a1(X,Q),M=(G=(Y=w.fatal)!==null&&Y!==void 0?Y:W)!==null&&G!==void 0?G:!0;H.addIssue({code:"custom",...w,fatal:M})}return});return G0.create()}var F,_1,V,t=($)=>{switch(typeof $){case"undefined":return V.undefined;case"string":return V.string;case"number":return isNaN($)?V.nan:V.number;case"boolean":return V.boolean;case"function":return V.function;case"bigint":return V.bigint;case"symbol":return V.symbol;case"object":if(Array.isArray($))return V.array;if($===null)return V.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return V.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return V.map;if(typeof Set!=="undefined"&&$ instanceof Set)return V.set;if(typeof Date!=="undefined"&&$ instanceof Date)return V.date;return V.object;default:return V.unknown}},D,C2=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")},C,V0=($,X)=>{let W;switch($.code){case D.invalid_type:if($.received===V.undefined)W="Required";else W=`Expected ${$.expected}, received ${$.received}`;break;case D.invalid_literal:W=`Invalid literal value, expected ${JSON.stringify($.expected,F.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:W=`Unrecognized key(s) in object: ${F.joinValues($.keys,", ")}`;break;case D.invalid_union:W="Invalid input";break;case D.invalid_union_discriminator:W=`Invalid discriminator value. Expected ${F.joinValues($.options)}`;break;case D.invalid_enum_value:W=`Invalid enum value. Expected ${F.joinValues($.options)}, received '${$.received}'`;break;case D.invalid_arguments:W="Invalid function arguments";break;case D.invalid_return_type:W="Invalid function return type";break;case D.invalid_date:W="Invalid date";break;case D.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(W=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")W=`${W} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)W=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)W=`Invalid input: must end with "${$.validation.endsWith}"`;else F.assertNever($.validation);else if($.validation!=="regex")W=`Invalid ${$.validation}`;else W="Invalid";break;case D.too_small:if($.type==="array")W=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")W=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")W=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")W=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else W="Invalid input";break;case D.too_big:if($.type==="array")W=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")W=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")W=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")W=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")W=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else W="Invalid input";break;case D.custom:W="Invalid input";break;case D.invalid_intersection_types:W="Intersection results could not be merged";break;case D.not_multiple_of:W=`Number must be a multiple of ${$.multipleOf}`;break;case D.not_finite:W="Number must be finite";break;default:W=X.defaultError,F.assertNever($)}return{message:W}},s1,p0=($)=>{let{data:X,path:W,errorMaps:Q,issueData:H}=$,Y=[...W,...H.path||[]],G={...H,path:Y};if(H.message!==void 0)return{...H,path:Y,message:H.message};let B="",w=Q.filter((M)=>!!M).slice().reverse();for(let M of w)B=M(G,{data:X,defaultError:B}).message;return{...H,path:Y,message:B}},P2,U,M0=($)=>({status:"dirty",value:$}),v=($)=>({status:"valid",value:$}),R1=($)=>$.status==="aborted",E1=($)=>$.status==="dirty",J0=($)=>$.status==="valid",k0=($)=>typeof Promise!=="undefined"&&$ instanceof Promise,j,b0,v0,r1=($,X)=>{if(J0(X))return{success:!0,data:X.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let W=new C($.common.issues);return this._error=W,this._error}}}},f2,T2,g2,x2,h2,y2,Z2,m2,l2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",S1,n2,c2,u2,p2,i2,d2,$$="((\\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])))",o2,x,$0,X0,j0,Y0,C0,q0,O0,G0,e,p,I0,h,S,U0,a=($)=>{if($ instanceof N0)return a($.schema);else if($ instanceof T)return a($.innerType());else if($ instanceof L0)return[$.value];else if($ instanceof W0)return $.options;else if($ instanceof F0)return F.objectValues($.enum);else if($ instanceof S0)return a($._def.innerType);else if($ instanceof q0)return[void 0];else if($ instanceof O0)return[null];else if($ instanceof I)return[void 0,...a($.unwrap())];else if($ instanceof s)return[null,...a($.unwrap())];else if($ instanceof o0)return a($.unwrap());else if($ instanceof R0)return a($.unwrap());else if($ instanceof _0)return a($._def.innerType);else return[]},d0,K0,i,P0,f0,B0,A0,N0,L0,W0,F0,w0,T,I,s,S0,_0,T0,$4,o0,g0,R0,X4,z,W4=($,X={message:`Input not instance of ${$.name}`})=>H$((W)=>W instanceof $,X),J$,Y$,Q4,H4,G$,J4,Y4,G4,B4,w4,D4,z4,M4,A4,V4,j4,q4,O4,U4,K4,N4,L4,F4,S4,_4,R4,E4,b4,v4,t1,k4,C4,I4,P4,f4=()=>J$().optional(),T4=()=>Y$().optional(),g4=()=>G$().optional(),x4,h4,J;var d=F1(()=>{(function($){$.assertEqual=(H)=>H;function X(H){}$.assertIs=X;function W(H){throw new Error}$.assertNever=W,$.arrayToEnum=(H)=>{let Y={};for(let G of H)Y[G]=G;return Y},$.getValidEnumValues=(H)=>{let Y=$.objectKeys(H).filter((B)=>typeof H[H[B]]!=="number"),G={};for(let B of Y)G[B]=H[B];return $.objectValues(G)},$.objectValues=(H)=>{return $.objectKeys(H).map(function(Y){return H[Y]})},$.objectKeys=typeof Object.keys==="function"?(H)=>Object.keys(H):(H)=>{let Y=[];for(let G in H)if(Object.prototype.hasOwnProperty.call(H,G))Y.push(G);return Y},$.find=(H,Y)=>{for(let G of H)if(Y(G))return G;return},$.isInteger=typeof Number.isInteger==="function"?(H)=>Number.isInteger(H):(H)=>typeof H==="number"&&isFinite(H)&&Math.floor(H)===H;function Q(H,Y=" | "){return H.map((G)=>typeof G==="string"?`'${G}'`:G).join(Y)}$.joinValues=Q,$.jsonStringifyReplacer=(H,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(F||(F={}));(function($){$.mergeShapes=(X,W)=>{return{...X,...W}}})(_1||(_1={}));V=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=F.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"]);C=class C extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(W)=>{this.issues=[...this.issues,W]},this.addIssues=(W=[])=>{this.issues=[...this.issues,...W]};let X=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,X);else this.__proto__=X;this.name="ZodError",this.issues=$}format($){let X=$||function(H){return H.message},W={_errors:[]},Q=(H)=>{for(let Y of H.issues)if(Y.code==="invalid_union")Y.unionErrors.map(Q);else if(Y.code==="invalid_return_type")Q(Y.returnTypeError);else if(Y.code==="invalid_arguments")Q(Y.argumentsError);else if(Y.path.length===0)W._errors.push(X(Y));else{let G=W,B=0;while(B<Y.path.length){let w=Y.path[B];if(B!==Y.path.length-1)G[w]=G[w]||{_errors:[]};else G[w]=G[w]||{_errors:[]},G[w]._errors.push(X(Y));G=G[w],B++}}};return Q(this),W}static assert($){if(!($ instanceof C))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(X)=>X.message){let X={},W=[];for(let Q of this.issues)if(Q.path.length>0)X[Q.path[0]]=X[Q.path[0]]||[],X[Q.path[0]].push($(Q));else W.push($(Q));return{formErrors:W,fieldErrors:X}}get formErrors(){return this.flatten()}};C.create=($)=>{return new C($)};s1=V0;P2=[];U=Object.freeze({status:"aborted"});(function($){$.errToObj=(X)=>typeof X==="string"?{message:X}:X||{},$.toString=(X)=>typeof X==="string"?X:X===null||X===void 0?void 0:X.message})(j||(j={}));f2=/^c[^\s-]{8,}$/i,T2=/^[0-9a-z]+$/,g2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,x2=/^[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,h2=/^[a-z0-9_-]{21}$/i,y2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Z2=/^[-+]?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)?)??$/,m2=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,n2=/^(?:(?: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])$/,c2=/^(?:(?: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])$/,u2=/^(([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]))$/,p2=/^(([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])$/,i2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,d2=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,o2=new RegExp(`^${$$}$`);x=class x extends K{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==V.string){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.string,received:H.parsedType}),U}let W=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.length<H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),W.dirty()}else if(H.kind==="max"){if($.data.length>H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),W.dirty()}else if(H.kind==="length"){let Y=$.data.length>H.value,G=$.data.length<H.value;if(Y||G){if(Q=this._getOrReturnCtx($,Q),Y)A(Q,{code:D.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});else if(G)A(Q,{code:D.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});W.dirty()}}else if(H.kind==="email"){if(!m2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"email",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="emoji"){if(!S1)S1=new RegExp(l2,"u");if(!S1.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"emoji",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="uuid"){if(!x2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"uuid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="nanoid"){if(!h2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"nanoid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cuid"){if(!f2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cuid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cuid2"){if(!T2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cuid2",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="ulid"){if(!g2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"ulid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="url")try{new URL($.data)}catch(Y){Q=this._getOrReturnCtx($,Q),A(Q,{validation:"url",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="regex"){if(H.regex.lastIndex=0,!H.regex.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"regex",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="trim")$.data=$.data.trim();else if(H.kind==="includes"){if(!$.data.includes(H.value,H.position))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{includes:H.value,position:H.position},message:H.message}),W.dirty()}else if(H.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(H.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(H.kind==="startsWith"){if(!$.data.startsWith(H.value))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{startsWith:H.value},message:H.message}),W.dirty()}else if(H.kind==="endsWith"){if(!$.data.endsWith(H.value))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{endsWith:H.value},message:H.message}),W.dirty()}else if(H.kind==="datetime"){if(!W$(H).test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"datetime",message:H.message}),W.dirty()}else if(H.kind==="date"){if(!o2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"date",message:H.message}),W.dirty()}else if(H.kind==="time"){if(!r2(H).test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"time",message:H.message}),W.dirty()}else if(H.kind==="duration"){if(!Z2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"duration",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="ip"){if(!a2($.data,H.version))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"ip",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="jwt"){if(!t2($.data,H.alg))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"jwt",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cidr"){if(!s2($.data,H.version))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cidr",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="base64"){if(!i2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"base64",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="base64url"){if(!d2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"base64url",code:D.invalid_string,message:H.message}),W.dirty()}else F.assertNever(H);return{status:W.value,value:$.data}}_regex($,X,W){return this.refinement((Q)=>$.test(Q),{validation:X,code:D.invalid_string,...j.errToObj(W)})}_addCheck($){return new x({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...j.errToObj($)})}url($){return this._addCheck({kind:"url",...j.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...j.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...j.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...j.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...j.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...j.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...j.errToObj($)})}base64($){return this._addCheck({kind:"base64",...j.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...j.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...j.errToObj($)})}ip($){return this._addCheck({kind:"ip",...j.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...j.errToObj($)})}datetime($){var X,W;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)==="undefined"?null:$===null||$===void 0?void 0:$.precision,offset:(X=$===null||$===void 0?void 0:$.offset)!==null&&X!==void 0?X:!1,local:(W=$===null||$===void 0?void 0:$.local)!==null&&W!==void 0?W:!1,...j.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)==="undefined"?null:$===null||$===void 0?void 0:$.precision,...j.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...j.errToObj($)})}regex($,X){return this._addCheck({kind:"regex",regex:$,...j.errToObj(X)})}includes($,X){return this._addCheck({kind:"includes",value:$,position:X===null||X===void 0?void 0:X.position,...j.errToObj(X===null||X===void 0?void 0:X.message)})}startsWith($,X){return this._addCheck({kind:"startsWith",value:$,...j.errToObj(X)})}endsWith($,X){return this._addCheck({kind:"endsWith",value:$,...j.errToObj(X)})}min($,X){return this._addCheck({kind:"min",value:$,...j.errToObj(X)})}max($,X){return this._addCheck({kind:"max",value:$,...j.errToObj(X)})}length($,X){return this._addCheck({kind:"length",value:$,...j.errToObj(X)})}nonempty($){return this.min(1,j.errToObj($))}trim(){return new x({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new x({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new x({...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 X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxLength(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}};x.create=($)=>{var X;return new x({checks:[],typeName:z.ZodString,coerce:(X=$===null||$===void 0?void 0:$.coerce)!==null&&X!==void 0?X:!1,...N($)})};$0=class $0 extends K{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($)!==V.number){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.number,received:H.parsedType}),U}let W=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="int"){if(!F.isInteger($.data))W=this._getOrReturnCtx($,W),A(W,{code:D.invalid_type,expected:"integer",received:"float",message:H.message}),Q.dirty()}else if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_small,minimum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_big,maximum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if(e2($.data,H.value)!==0)W=this._getOrReturnCtx($,W),A(W,{code:D.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else if(H.kind==="finite"){if(!Number.isFinite($.data))W=this._getOrReturnCtx($,W),A(W,{code:D.not_finite,message:H.message}),Q.dirty()}else F.assertNever(H);return{status:Q.value,value:$.data}}gte($,X){return this.setLimit("min",$,!0,j.toString(X))}gt($,X){return this.setLimit("min",$,!1,j.toString(X))}lte($,X){return this.setLimit("max",$,!0,j.toString(X))}lt($,X){return this.setLimit("max",$,!1,j.toString(X))}setLimit($,X,W,Q){return new $0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:W,message:j.toString(Q)}]})}_addCheck($){return new $0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:j.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.toString($)})}multipleOf($,X){return this._addCheck({kind:"multipleOf",value:$,message:j.toString(X)})}finite($){return this._addCheck({kind:"finite",message:j.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.toString($)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&F.isInteger($.value))}get isFinite(){let $=null,X=null;for(let W of this._def.checks)if(W.kind==="finite"||W.kind==="int"||W.kind==="multipleOf")return!0;else if(W.kind==="min"){if(X===null||W.value>X)X=W.value}else if(W.kind==="max"){if($===null||W.value<$)$=W.value}return Number.isFinite(X)&&Number.isFinite($)}};$0.create=($)=>{return new $0({checks:[],typeName:z.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...N($)})};X0=class X0 extends K{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(H){return this._getInvalidInput($)}if(this._getType($)!==V.bigint)return this._getInvalidInput($);let W=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_small,type:"bigint",minimum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_big,type:"bigint",maximum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if($.data%H.value!==BigInt(0))W=this._getOrReturnCtx($,W),A(W,{code:D.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else F.assertNever(H);return{status:Q.value,value:$.data}}_getInvalidInput($){let X=this._getOrReturnCtx($);return A(X,{code:D.invalid_type,expected:V.bigint,received:X.parsedType}),U}gte($,X){return this.setLimit("min",$,!0,j.toString(X))}gt($,X){return this.setLimit("min",$,!1,j.toString(X))}lte($,X){return this.setLimit("max",$,!0,j.toString(X))}lt($,X){return this.setLimit("max",$,!1,j.toString(X))}setLimit($,X,W,Q){return new X0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:W,message:j.toString(Q)}]})}_addCheck($){return new X0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.toString($)})}multipleOf($,X){return this._addCheck({kind:"multipleOf",value:$,message:j.toString(X)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}};X0.create=($)=>{var X;return new X0({checks:[],typeName:z.ZodBigInt,coerce:(X=$===null||$===void 0?void 0:$.coerce)!==null&&X!==void 0?X:!1,...N($)})};j0=class j0 extends K{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==V.boolean){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.boolean,received:W.parsedType}),U}return v($.data)}};j0.create=($)=>{return new j0({typeName:z.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...N($)})};Y0=class Y0 extends K{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==V.date){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.date,received:H.parsedType}),U}if(isNaN($.data.getTime())){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_date}),U}let W=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.getTime()<H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_small,message:H.message,inclusive:!0,exact:!1,minimum:H.value,type:"date"}),W.dirty()}else if(H.kind==="max"){if($.data.getTime()>H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_big,message:H.message,inclusive:!0,exact:!1,maximum:H.value,type:"date"}),W.dirty()}else F.assertNever(H);return{status:W.value,value:new Date($.data.getTime())}}_addCheck($){return new Y0({...this._def,checks:[...this._def.checks,$]})}min($,X){return this._addCheck({kind:"min",value:$.getTime(),message:j.toString(X)})}max($,X){return this._addCheck({kind:"max",value:$.getTime(),message:j.toString(X)})}get minDate(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $!=null?new Date($):null}};Y0.create=($)=>{return new Y0({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:z.ZodDate,...N($)})};C0=class C0 extends K{_parse($){if(this._getType($)!==V.symbol){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.symbol,received:W.parsedType}),U}return v($.data)}};C0.create=($)=>{return new C0({typeName:z.ZodSymbol,...N($)})};q0=class q0 extends K{_parse($){if(this._getType($)!==V.undefined){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.undefined,received:W.parsedType}),U}return v($.data)}};q0.create=($)=>{return new q0({typeName:z.ZodUndefined,...N($)})};O0=class O0 extends K{_parse($){if(this._getType($)!==V.null){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.null,received:W.parsedType}),U}return v($.data)}};O0.create=($)=>{return new O0({typeName:z.ZodNull,...N($)})};G0=class G0 extends K{constructor(){super(...arguments);this._any=!0}_parse($){return v($.data)}};G0.create=($)=>{return new G0({typeName:z.ZodAny,...N($)})};e=class e extends K{constructor(){super(...arguments);this._unknown=!0}_parse($){return v($.data)}};e.create=($)=>{return new e({typeName:z.ZodUnknown,...N($)})};p=class p extends K{_parse($){let X=this._getOrReturnCtx($);return A(X,{code:D.invalid_type,expected:V.never,received:X.parsedType}),U}};p.create=($)=>{return new p({typeName:z.ZodNever,...N($)})};I0=class I0 extends K{_parse($){if(this._getType($)!==V.undefined){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.void,received:W.parsedType}),U}return v($.data)}};I0.create=($)=>{return new I0({typeName:z.ZodVoid,...N($)})};h=class h extends K{_parse($){let{ctx:X,status:W}=this._processInputParams($),Q=this._def;if(X.parsedType!==V.array)return A(X,{code:D.invalid_type,expected:V.array,received:X.parsedType}),U;if(Q.exactLength!==null){let Y=X.data.length>Q.exactLength.value,G=X.data.length<Q.exactLength.value;if(Y||G)A(X,{code:Y?D.too_big:D.too_small,minimum:G?Q.exactLength.value:void 0,maximum:Y?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),W.dirty()}if(Q.minLength!==null){if(X.data.length<Q.minLength.value)A(X,{code:D.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),W.dirty()}if(Q.maxLength!==null){if(X.data.length>Q.maxLength.value)A(X,{code:D.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),W.dirty()}if(X.common.async)return Promise.all([...X.data].map((Y,G)=>{return Q.type._parseAsync(new y(X,Y,X.path,G))})).then((Y)=>{return E.mergeArray(W,Y)});let H=[...X.data].map((Y,G)=>{return Q.type._parseSync(new y(X,Y,X.path,G))});return E.mergeArray(W,H)}get element(){return this._def.type}min($,X){return new h({...this._def,minLength:{value:$,message:j.toString(X)}})}max($,X){return new h({...this._def,maxLength:{value:$,message:j.toString(X)}})}length($,X){return new h({...this._def,exactLength:{value:$,message:j.toString(X)}})}nonempty($){return this.min(1,$)}};h.create=($,X)=>{return new h({type:$,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...N(X)})};S=class S extends K{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(),X=F.objectKeys($);return this._cached={shape:$,keys:X}}_parse($){if(this._getType($)!==V.object){let w=this._getOrReturnCtx($);return A(w,{code:D.invalid_type,expected:V.object,received:w.parsedType}),U}let{status:W,ctx:Q}=this._processInputParams($),{shape:H,keys:Y}=this._getCached(),G=[];if(!(this._def.catchall instanceof p&&this._def.unknownKeys==="strip")){for(let w in Q.data)if(!Y.includes(w))G.push(w)}let B=[];for(let w of Y){let M=H[w],q=Q.data[w];B.push({key:{status:"valid",value:w},value:M._parse(new y(Q,q,Q.path,w)),alwaysSet:w in Q.data})}if(this._def.catchall instanceof p){let w=this._def.unknownKeys;if(w==="passthrough")for(let M of G)B.push({key:{status:"valid",value:M},value:{status:"valid",value:Q.data[M]}});else if(w==="strict"){if(G.length>0)A(Q,{code:D.unrecognized_keys,keys:G}),W.dirty()}else if(w==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let M of G){let q=Q.data[M];B.push({key:{status:"valid",value:M},value:w._parse(new y(Q,q,Q.path,M)),alwaysSet:M in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let w=[];for(let M of B){let q=await M.key,b=await M.value;w.push({key:q,value:b,alwaysSet:M.alwaysSet})}return w}).then((w)=>{return E.mergeObjectSync(W,w)});else return E.mergeObjectSync(W,B)}get shape(){return this._def.shape()}strict($){return j.errToObj,new S({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(X,W)=>{var Q,H,Y,G;let B=(Y=(H=(Q=this._def).errorMap)===null||H===void 0?void 0:H.call(Q,X,W).message)!==null&&Y!==void 0?Y:W.defaultError;if(X.code==="unrecognized_keys")return{message:(G=j.errToObj($).message)!==null&&G!==void 0?G:B};return{message:B}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend($){return new S({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new S({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:z.ZodObject})}setKey($,X){return this.augment({[$]:X})}catchall($){return new S({...this._def,catchall:$})}pick($){let X={};return F.objectKeys($).forEach((W)=>{if($[W]&&this.shape[W])X[W]=this.shape[W]}),new S({...this._def,shape:()=>X})}omit($){let X={};return F.objectKeys(this.shape).forEach((W)=>{if(!$[W])X[W]=this.shape[W]}),new S({...this._def,shape:()=>X})}deepPartial(){return z0(this)}partial($){let X={};return F.objectKeys(this.shape).forEach((W)=>{let Q=this.shape[W];if($&&!$[W])X[W]=Q;else X[W]=Q.optional()}),new S({...this._def,shape:()=>X})}required($){let X={};return F.objectKeys(this.shape).forEach((W)=>{if($&&!$[W])X[W]=this.shape[W];else{let H=this.shape[W];while(H instanceof I)H=H._def.innerType;X[W]=H}}),new S({...this._def,shape:()=>X})}keyof(){return Q$(F.objectKeys(this.shape))}};S.create=($,X)=>{return new S({shape:()=>$,unknownKeys:"strip",catchall:p.create(),typeName:z.ZodObject,...N(X)})};S.strictCreate=($,X)=>{return new S({shape:()=>$,unknownKeys:"strict",catchall:p.create(),typeName:z.ZodObject,...N(X)})};S.lazycreate=($,X)=>{return new S({shape:$,unknownKeys:"strip",catchall:p.create(),typeName:z.ZodObject,...N(X)})};U0=class U0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=this._def.options;function Q(H){for(let G of H)if(G.result.status==="valid")return G.result;for(let G of H)if(G.result.status==="dirty")return X.common.issues.push(...G.ctx.common.issues),G.result;let Y=H.map((G)=>new C(G.ctx.common.issues));return A(X,{code:D.invalid_union,unionErrors:Y}),U}if(X.common.async)return Promise.all(W.map(async(H)=>{let Y={...X,common:{...X.common,issues:[]},parent:null};return{result:await H._parseAsync({data:X.data,path:X.path,parent:Y}),ctx:Y}})).then(Q);else{let H=void 0,Y=[];for(let B of W){let w={...X,common:{...X.common,issues:[]},parent:null},M=B._parseSync({data:X.data,path:X.path,parent:w});if(M.status==="valid")return M;else if(M.status==="dirty"&&!H)H={result:M,ctx:w};if(w.common.issues.length)Y.push(w.common.issues)}if(H)return X.common.issues.push(...H.ctx.common.issues),H.result;let G=Y.map((B)=>new C(B));return A(X,{code:D.invalid_union,unionErrors:G}),U}}get options(){return this._def.options}};U0.create=($,X)=>{return new U0({options:$,typeName:z.ZodUnion,...N(X)})};d0=class d0 extends K{_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.object)return A(X,{code:D.invalid_type,expected:V.object,received:X.parsedType}),U;let W=this.discriminator,Q=X.data[W],H=this.optionsMap.get(Q);if(!H)return A(X,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[W]}),U;if(X.common.async)return H._parseAsync({data:X.data,path:X.path,parent:X});else return H._parseSync({data:X.data,path:X.path,parent:X})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,X,W){let Q=new Map;for(let H of X){let Y=a(H.shape[$]);if(!Y.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let G of Y){if(Q.has(G))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(G)}`);Q.set(G,H)}}return new d0({typeName:z.ZodDiscriminatedUnion,discriminator:$,options:X,optionsMap:Q,...N(W)})}};K0=class K0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($),Q=(H,Y)=>{if(R1(H)||R1(Y))return U;let G=b1(H.value,Y.value);if(!G.valid)return A(W,{code:D.invalid_intersection_types}),U;if(E1(H)||E1(Y))X.dirty();return{status:X.value,value:G.data}};if(W.common.async)return Promise.all([this._def.left._parseAsync({data:W.data,path:W.path,parent:W}),this._def.right._parseAsync({data:W.data,path:W.path,parent:W})]).then(([H,Y])=>Q(H,Y));else return Q(this._def.left._parseSync({data:W.data,path:W.path,parent:W}),this._def.right._parseSync({data:W.data,path:W.path,parent:W}))}};K0.create=($,X,W)=>{return new K0({left:$,right:X,typeName:z.ZodIntersection,...N(W)})};i=class i extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.array)return A(W,{code:D.invalid_type,expected:V.array,received:W.parsedType}),U;if(W.data.length<this._def.items.length)return A(W,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;if(!this._def.rest&&W.data.length>this._def.items.length)A(W,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),X.dirty();let H=[...W.data].map((Y,G)=>{let B=this._def.items[G]||this._def.rest;if(!B)return null;return B._parse(new y(W,Y,W.path,G))}).filter((Y)=>!!Y);if(W.common.async)return Promise.all(H).then((Y)=>{return E.mergeArray(X,Y)});else return E.mergeArray(X,H)}get items(){return this._def.items}rest($){return new i({...this._def,rest:$})}};i.create=($,X)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new i({items:$,typeName:z.ZodTuple,rest:null,...N(X)})};P0=class P0 extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.object)return A(W,{code:D.invalid_type,expected:V.object,received:W.parsedType}),U;let Q=[],H=this._def.keyType,Y=this._def.valueType;for(let G in W.data)Q.push({key:H._parse(new y(W,G,W.path,G)),value:Y._parse(new y(W,W.data[G],W.path,G)),alwaysSet:G in W.data});if(W.common.async)return E.mergeObjectAsync(X,Q);else return E.mergeObjectSync(X,Q)}get element(){return this._def.valueType}static create($,X,W){if(X instanceof K)return new P0({keyType:$,valueType:X,typeName:z.ZodRecord,...N(W)});return new P0({keyType:x.create(),valueType:$,typeName:z.ZodRecord,...N(X)})}};f0=class f0 extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.map)return A(W,{code:D.invalid_type,expected:V.map,received:W.parsedType}),U;let Q=this._def.keyType,H=this._def.valueType,Y=[...W.data.entries()].map(([G,B],w)=>{return{key:Q._parse(new y(W,G,W.path,[w,"key"])),value:H._parse(new y(W,B,W.path,[w,"value"]))}});if(W.common.async){let G=new Map;return Promise.resolve().then(async()=>{for(let B of Y){let w=await B.key,M=await B.value;if(w.status==="aborted"||M.status==="aborted")return U;if(w.status==="dirty"||M.status==="dirty")X.dirty();G.set(w.value,M.value)}return{status:X.value,value:G}})}else{let G=new Map;for(let B of Y){let{key:w,value:M}=B;if(w.status==="aborted"||M.status==="aborted")return U;if(w.status==="dirty"||M.status==="dirty")X.dirty();G.set(w.value,M.value)}return{status:X.value,value:G}}}};f0.create=($,X,W)=>{return new f0({valueType:X,keyType:$,typeName:z.ZodMap,...N(W)})};B0=class B0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.set)return A(W,{code:D.invalid_type,expected:V.set,received:W.parsedType}),U;let Q=this._def;if(Q.minSize!==null){if(W.data.size<Q.minSize.value)A(W,{code:D.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),X.dirty()}if(Q.maxSize!==null){if(W.data.size>Q.maxSize.value)A(W,{code:D.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),X.dirty()}let H=this._def.valueType;function Y(B){let w=new Set;for(let M of B){if(M.status==="aborted")return U;if(M.status==="dirty")X.dirty();w.add(M.value)}return{status:X.value,value:w}}let G=[...W.data.values()].map((B,w)=>H._parse(new y(W,B,W.path,w)));if(W.common.async)return Promise.all(G).then((B)=>Y(B));else return Y(G)}min($,X){return new B0({...this._def,minSize:{value:$,message:j.toString(X)}})}max($,X){return new B0({...this._def,maxSize:{value:$,message:j.toString(X)}})}size($,X){return this.min($,X).max($,X)}nonempty($){return this.min(1,$)}};B0.create=($,X)=>{return new B0({valueType:$,minSize:null,maxSize:null,typeName:z.ZodSet,...N(X)})};A0=class A0 extends K{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.function)return A(X,{code:D.invalid_type,expected:V.function,received:X.parsedType}),U;function W(G,B){return p0({data:G,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,u0(),V0].filter((w)=>!!w),issueData:{code:D.invalid_arguments,argumentsError:B}})}function Q(G,B){return p0({data:G,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,u0(),V0].filter((w)=>!!w),issueData:{code:D.invalid_return_type,returnTypeError:B}})}let H={errorMap:X.common.contextualErrorMap},Y=X.data;if(this._def.returns instanceof w0){let G=this;return v(async function(...B){let w=new C([]),M=await G._def.args.parseAsync(B,H).catch((r)=>{throw w.addIssue(W(B,r)),w}),q=await Reflect.apply(Y,this,M);return await G._def.returns._def.type.parseAsync(q,H).catch((r)=>{throw w.addIssue(Q(q,r)),w})})}else{let G=this;return v(function(...B){let w=G._def.args.safeParse(B,H);if(!w.success)throw new C([W(B,w.error)]);let M=Reflect.apply(Y,this,w.data),q=G._def.returns.safeParse(M,H);if(!q.success)throw new C([Q(M,q.error)]);return q.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new A0({...this._def,args:i.create($).rest(e.create())})}returns($){return new A0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,X,W){return new A0({args:$?$:i.create([]).rest(e.create()),returns:X||e.create(),typeName:z.ZodFunction,...N(W)})}};N0=class N0 extends K{get schema(){return this._def.getter()}_parse($){let{ctx:X}=this._processInputParams($);return this._def.getter()._parse({data:X.data,path:X.path,parent:X})}};N0.create=($,X)=>{return new N0({getter:$,typeName:z.ZodLazy,...N(X)})};L0=class L0 extends K{_parse($){if($.data!==this._def.value){let X=this._getOrReturnCtx($);return A(X,{received:X.data,code:D.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:$.data}}get value(){return this._def.value}};L0.create=($,X)=>{return new L0({value:$,typeName:z.ZodLiteral,...N(X)})};W0=class W0 extends K{constructor(){super(...arguments);b0.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let X=this._getOrReturnCtx($),W=this._def.values;return A(X,{expected:F.joinValues(W),received:X.parsedType,code:D.invalid_type}),U}if(!i0(this,b0,"f"))e1(this,b0,new Set(this._def.values),"f");if(!i0(this,b0,"f").has($.data)){let X=this._getOrReturnCtx($),W=this._def.values;return A(X,{received:X.data,code:D.invalid_enum_value,options:W}),U}return v($.data)}get options(){return this._def.values}get enum(){let $={};for(let X of this._def.values)$[X]=X;return $}get Values(){let $={};for(let X of this._def.values)$[X]=X;return $}get Enum(){let $={};for(let X of this._def.values)$[X]=X;return $}extract($,X=this._def){return W0.create($,{...this._def,...X})}exclude($,X=this._def){return W0.create(this.options.filter((W)=>!$.includes(W)),{...this._def,...X})}};b0=new WeakMap;W0.create=Q$;F0=class F0 extends K{constructor(){super(...arguments);v0.set(this,void 0)}_parse($){let X=F.getValidEnumValues(this._def.values),W=this._getOrReturnCtx($);if(W.parsedType!==V.string&&W.parsedType!==V.number){let Q=F.objectValues(X);return A(W,{expected:F.joinValues(Q),received:W.parsedType,code:D.invalid_type}),U}if(!i0(this,v0,"f"))e1(this,v0,new Set(F.getValidEnumValues(this._def.values)),"f");if(!i0(this,v0,"f").has($.data)){let Q=F.objectValues(X);return A(W,{received:W.data,code:D.invalid_enum_value,options:Q}),U}return v($.data)}get enum(){return this._def.values}};v0=new WeakMap;F0.create=($,X)=>{return new F0({values:$,typeName:z.ZodNativeEnum,...N(X)})};w0=class w0 extends K{unwrap(){return this._def.type}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.promise&&X.common.async===!1)return A(X,{code:D.invalid_type,expected:V.promise,received:X.parsedType}),U;let W=X.parsedType===V.promise?X.data:Promise.resolve(X.data);return v(W.then((Q)=>{return this._def.type.parseAsync(Q,{path:X.path,errorMap:X.common.contextualErrorMap})}))}};w0.create=($,X)=>{return new w0({type:$,typeName:z.ZodPromise,...N(X)})};T=class T extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:X,ctx:W}=this._processInputParams($),Q=this._def.effect||null,H={addIssue:(Y)=>{if(A(W,Y),Y.fatal)X.abort();else X.dirty()},get path(){return W.path}};if(H.addIssue=H.addIssue.bind(H),Q.type==="preprocess"){let Y=Q.transform(W.data,H);if(W.common.async)return Promise.resolve(Y).then(async(G)=>{if(X.value==="aborted")return U;let B=await this._def.schema._parseAsync({data:G,path:W.path,parent:W});if(B.status==="aborted")return U;if(B.status==="dirty")return M0(B.value);if(X.value==="dirty")return M0(B.value);return B});else{if(X.value==="aborted")return U;let G=this._def.schema._parseSync({data:Y,path:W.path,parent:W});if(G.status==="aborted")return U;if(G.status==="dirty")return M0(G.value);if(X.value==="dirty")return M0(G.value);return G}}if(Q.type==="refinement"){let Y=(G)=>{let B=Q.refinement(G,H);if(W.common.async)return Promise.resolve(B);if(B instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return G};if(W.common.async===!1){let G=this._def.schema._parseSync({data:W.data,path:W.path,parent:W});if(G.status==="aborted")return U;if(G.status==="dirty")X.dirty();return Y(G.value),{status:X.value,value:G.value}}else return this._def.schema._parseAsync({data:W.data,path:W.path,parent:W}).then((G)=>{if(G.status==="aborted")return U;if(G.status==="dirty")X.dirty();return Y(G.value).then(()=>{return{status:X.value,value:G.value}})})}if(Q.type==="transform")if(W.common.async===!1){let Y=this._def.schema._parseSync({data:W.data,path:W.path,parent:W});if(!J0(Y))return Y;let G=Q.transform(Y.value,H);if(G instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:X.value,value:G}}else return this._def.schema._parseAsync({data:W.data,path:W.path,parent:W}).then((Y)=>{if(!J0(Y))return Y;return Promise.resolve(Q.transform(Y.value,H)).then((G)=>({status:X.value,value:G}))});F.assertNever(Q)}};T.create=($,X,W)=>{return new T({schema:$,typeName:z.ZodEffects,effect:X,...N(W)})};T.createWithPreprocess=($,X,W)=>{return new T({schema:X,effect:{type:"preprocess",transform:$},typeName:z.ZodEffects,...N(W)})};I=class I extends K{_parse($){if(this._getType($)===V.undefined)return v(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};I.create=($,X)=>{return new I({innerType:$,typeName:z.ZodOptional,...N(X)})};s=class s extends K{_parse($){if(this._getType($)===V.null)return v(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};s.create=($,X)=>{return new s({innerType:$,typeName:z.ZodNullable,...N(X)})};S0=class S0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;if(X.parsedType===V.undefined)W=this._def.defaultValue();return this._def.innerType._parse({data:W,path:X.path,parent:X})}removeDefault(){return this._def.innerType}};S0.create=($,X)=>{return new S0({innerType:$,typeName:z.ZodDefault,defaultValue:typeof X.default==="function"?X.default:()=>X.default,...N(X)})};_0=class _0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W={...X,common:{...X.common,issues:[]}},Q=this._def.innerType._parse({data:W.data,path:W.path,parent:{...W}});if(k0(Q))return Q.then((H)=>{return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new C(W.common.issues)},input:W.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new C(W.common.issues)},input:W.data})}}removeCatch(){return this._def.innerType}};_0.create=($,X)=>{return new _0({innerType:$,typeName:z.ZodCatch,catchValue:typeof X.catch==="function"?X.catch:()=>X.catch,...N(X)})};T0=class T0 extends K{_parse($){if(this._getType($)!==V.nan){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.nan,received:W.parsedType}),U}return{status:"valid",value:$.data}}};T0.create=($)=>{return new T0({typeName:z.ZodNaN,...N($)})};$4=Symbol("zod_brand");o0=class o0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;return this._def.type._parse({data:W,path:X.path,parent:X})}unwrap(){return this._def.type}};g0=class g0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.common.async)return(async()=>{let H=await this._def.in._parseAsync({data:W.data,path:W.path,parent:W});if(H.status==="aborted")return U;if(H.status==="dirty")return X.dirty(),M0(H.value);else return this._def.out._parseAsync({data:H.value,path:W.path,parent:W})})();else{let Q=this._def.in._parseSync({data:W.data,path:W.path,parent:W});if(Q.status==="aborted")return U;if(Q.status==="dirty")return X.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:W.path,parent:W})}}static create($,X){return new g0({in:$,out:X,typeName:z.ZodPipeline})}};R0=class R0 extends K{_parse($){let X=this._def.innerType._parse($),W=(Q)=>{if(J0(Q))Q.value=Object.freeze(Q.value);return Q};return k0(X)?X.then((Q)=>W(Q)):W(X)}unwrap(){return this._def.innerType}};R0.create=($,X)=>{return new R0({innerType:$,typeName:z.ZodReadonly,...N(X)})};X4={object:S.lazycreate};(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"})(z||(z={}));J$=x.create,Y$=$0.create,Q4=T0.create,H4=X0.create,G$=j0.create,J4=Y0.create,Y4=C0.create,G4=q0.create,B4=O0.create,w4=G0.create,D4=e.create,z4=p.create,M4=I0.create,A4=h.create,V4=S.create,j4=S.strictCreate,q4=U0.create,O4=d0.create,U4=K0.create,K4=i.create,N4=P0.create,L4=f0.create,F4=B0.create,S4=A0.create,_4=N0.create,R4=L0.create,E4=W0.create,b4=F0.create,v4=w0.create,t1=T.create,k4=I.create,C4=s.create,I4=T.createWithPreprocess,P4=g0.create,x4={string:($)=>x.create({...$,coerce:!0}),number:($)=>$0.create({...$,coerce:!0}),boolean:($)=>j0.create({...$,coerce:!0}),bigint:($)=>X0.create({...$,coerce:!0}),date:($)=>Y0.create({...$,coerce:!0})},h4=U,J=Object.freeze({__proto__:null,defaultErrorMap:V0,setErrorMap:I2,getErrorMap:u0,makeIssue:p0,EMPTY_PATH:P2,addIssueToContext:A,ParseStatus:E,INVALID:U,DIRTY:M0,OK:v,isAborted:R1,isDirty:E1,isValid:J0,isAsync:k0,get util(){return F},get objectUtil(){return _1},ZodParsedType:V,getParsedType:t,ZodType:K,datetimeRegex:W$,ZodString:x,ZodNumber:$0,ZodBigInt:X0,ZodBoolean:j0,ZodDate:Y0,ZodSymbol:C0,ZodUndefined:q0,ZodNull:O0,ZodAny:G0,ZodUnknown:e,ZodNever:p,ZodVoid:I0,ZodArray:h,ZodObject:S,ZodUnion:U0,ZodDiscriminatedUnion:d0,ZodIntersection:K0,ZodTuple:i,ZodRecord:P0,ZodMap:f0,ZodSet:B0,ZodFunction:A0,ZodLazy:N0,ZodLiteral:L0,ZodEnum:W0,ZodNativeEnum:F0,ZodPromise:w0,ZodEffects:T,ZodTransformer:T,ZodOptional:I,ZodNullable:s,ZodDefault:S0,ZodCatch:_0,ZodNaN:T0,BRAND:$4,ZodBranded:o0,ZodPipeline:g0,ZodReadonly:R0,custom:H$,Schema:K,ZodSchema:K,late:X4,get ZodFirstPartyTypeKind(){return z},coerce:x4,any:w4,array:A4,bigint:H4,boolean:G$,date:J4,discriminatedUnion:O4,effect:t1,enum:E4,function:S4,instanceof:W4,intersection:U4,lazy:_4,literal:R4,map:L4,nan:Q4,nativeEnum:b4,never:z4,null:B4,nullable:C4,number:Y$,object:V4,oboolean:g4,onumber:T4,optional:k4,ostring:f4,pipeline:P4,preprocess:I4,promise:v4,record:N4,set:F4,strictObject:j4,string:J$,symbol:Y4,transformer:t1,tuple:K4,undefined:G4,union:q4,unknown:D4,void:M4,NEVER:h4,ZodIssueCode:D,quotelessJson:C2,ZodError:C})});var v1="2025-03-26",B$,r0="2.0",w$,D$,y4,Z,P,x0,o,m,a0,z$,M$=($)=>z$.safeParse($).success,A$,V$=($)=>A$.safeParse($).success,j$,k1=($)=>j$.safeParse($).success,_,q$,O$=($)=>q$.safeParse($).success,U$,t0,s0,K$,Z4,e0,i6=($)=>e0.safeParse($).success,m4,l4,C1,$1,n4,X1,W1,Q1,N$,L$,F$,c4,u4,H1,p4,J1,i4,Y1,d4,o4,r4,a4,t4,s4,e4,G1,$6,B1,w1,D1,z1,S$,X6,W6,Q6,H6,J6,M1,Y6,_$,d6,A1,G6,R$,B6,w6,D6,z6,M6,A6,I1,V6,j6,V1,q6,O6,U6,P1,K6,o6,r6,a6,t6,s6,e6,R;var h0=F1(()=>{d();B$=[v1,"2024-11-05","2024-10-07"],w$=J.union([J.string(),J.number().int()]),D$=J.string(),y4=J.object({progressToken:J.optional(w$)}).passthrough(),Z=J.object({_meta:J.optional(y4)}).passthrough(),P=J.object({method:J.string(),params:J.optional(Z)}),x0=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),o=J.object({method:J.string(),params:J.optional(x0)}),m=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),a0=J.union([J.string(),J.number().int()]),z$=J.object({jsonrpc:J.literal(r0),id:a0}).merge(P).strict(),A$=J.object({jsonrpc:J.literal(r0)}).merge(o).strict(),j$=J.object({jsonrpc:J.literal(r0),id:a0,result:m}).strict();(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(_||(_={}));q$=J.object({jsonrpc:J.literal(r0),id:a0,error:J.object({code:J.number().int(),message:J.string(),data:J.optional(J.unknown())})}).strict(),U$=J.union([z$,A$,j$,q$]),t0=m.strict(),s0=o.extend({method:J.literal("notifications/cancelled"),params:x0.extend({requestId:a0,reason:J.string().optional()})}),K$=J.object({name:J.string(),version:J.string()}).passthrough(),Z4=J.object({experimental:J.optional(J.object({}).passthrough()),sampling:J.optional(J.object({}).passthrough()),roots:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),e0=P.extend({method:J.literal("initialize"),params:Z.extend({protocolVersion:J.string(),capabilities:Z4,clientInfo:K$})}),m4=J.object({experimental:J.optional(J.object({}).passthrough()),logging:J.optional(J.object({}).passthrough()),completions:J.optional(J.object({}).passthrough()),prompts:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough()),resources:J.optional(J.object({subscribe:J.optional(J.boolean()),listChanged:J.optional(J.boolean())}).passthrough()),tools:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),l4=m.extend({protocolVersion:J.string(),capabilities:m4,serverInfo:K$,instructions:J.optional(J.string())}),C1=o.extend({method:J.literal("notifications/initialized")}),$1=P.extend({method:J.literal("ping")}),n4=J.object({progress:J.number(),total:J.optional(J.number()),message:J.optional(J.string())}).passthrough(),X1=o.extend({method:J.literal("notifications/progress"),params:x0.merge(n4).extend({progressToken:w$})}),W1=P.extend({params:Z.extend({cursor:J.optional(D$)}).optional()}),Q1=m.extend({nextCursor:J.optional(D$)}),N$=J.object({uri:J.string(),mimeType:J.optional(J.string())}).passthrough(),L$=N$.extend({text:J.string()}),F$=N$.extend({blob:J.string().base64()}),c4=J.object({uri:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),u4=J.object({uriTemplate:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),H1=W1.extend({method:J.literal("resources/list")}),p4=Q1.extend({resources:J.array(c4)}),J1=W1.extend({method:J.literal("resources/templates/list")}),i4=Q1.extend({resourceTemplates:J.array(u4)}),Y1=P.extend({method:J.literal("resources/read"),params:Z.extend({uri:J.string()})}),d4=m.extend({contents:J.array(J.union([L$,F$]))}),o4=o.extend({method:J.literal("notifications/resources/list_changed")}),r4=P.extend({method:J.literal("resources/subscribe"),params:Z.extend({uri:J.string()})}),a4=P.extend({method:J.literal("resources/unsubscribe"),params:Z.extend({uri:J.string()})}),t4=o.extend({method:J.literal("notifications/resources/updated"),params:x0.extend({uri:J.string()})}),s4=J.object({name:J.string(),description:J.optional(J.string()),required:J.optional(J.boolean())}).passthrough(),e4=J.object({name:J.string(),description:J.optional(J.string()),arguments:J.optional(J.array(s4))}).passthrough(),G1=W1.extend({method:J.literal("prompts/list")}),$6=Q1.extend({prompts:J.array(e4)}),B1=P.extend({method:J.literal("prompts/get"),params:Z.extend({name:J.string(),arguments:J.optional(J.record(J.string()))})}),w1=J.object({type:J.literal("text"),text:J.string()}).passthrough(),D1=J.object({type:J.literal("image"),data:J.string().base64(),mimeType:J.string()}).passthrough(),z1=J.object({type:J.literal("audio"),data:J.string().base64(),mimeType:J.string()}).passthrough(),S$=J.object({type:J.literal("resource"),resource:J.union([L$,F$])}).passthrough(),X6=J.object({role:J.enum(["user","assistant"]),content:J.union([w1,D1,z1,S$])}).passthrough(),W6=m.extend({description:J.optional(J.string()),messages:J.array(X6)}),Q6=o.extend({method:J.literal("notifications/prompts/list_changed")}),H6=J.object({title:J.optional(J.string()),readOnlyHint:J.optional(J.boolean()),destructiveHint:J.optional(J.boolean()),idempotentHint:J.optional(J.boolean()),openWorldHint:J.optional(J.boolean())}).passthrough(),J6=J.object({name:J.string(),description:J.optional(J.string()),inputSchema:J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough(),outputSchema:J.optional(J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough()),annotations:J.optional(H6)}).passthrough(),M1=W1.extend({method:J.literal("tools/list")}),Y6=Q1.extend({tools:J.array(J6)}),_$=m.extend({content:J.array(J.union([w1,D1,z1,S$])).default([]),structuredContent:J.object({}).passthrough().optional(),isError:J.optional(J.boolean())}),d6=_$.or(m.extend({toolResult:J.unknown()})),A1=P.extend({method:J.literal("tools/call"),params:Z.extend({name:J.string(),arguments:J.optional(J.record(J.unknown()))})}),G6=o.extend({method:J.literal("notifications/tools/list_changed")}),R$=J.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),B6=P.extend({method:J.literal("logging/setLevel"),params:Z.extend({level:R$})}),w6=o.extend({method:J.literal("notifications/message"),params:x0.extend({level:R$,logger:J.optional(J.string()),data:J.unknown()})}),D6=J.object({name:J.string().optional()}).passthrough(),z6=J.object({hints:J.optional(J.array(D6)),costPriority:J.optional(J.number().min(0).max(1)),speedPriority:J.optional(J.number().min(0).max(1)),intelligencePriority:J.optional(J.number().min(0).max(1))}).passthrough(),M6=J.object({role:J.enum(["user","assistant"]),content:J.union([w1,D1,z1])}).passthrough(),A6=P.extend({method:J.literal("sampling/createMessage"),params:Z.extend({messages:J.array(M6),systemPrompt:J.optional(J.string()),includeContext:J.optional(J.enum(["none","thisServer","allServers"])),temperature:J.optional(J.number()),maxTokens:J.number().int(),stopSequences:J.optional(J.array(J.string())),metadata:J.optional(J.object({}).passthrough()),modelPreferences:J.optional(z6)})}),I1=m.extend({model:J.string(),stopReason:J.optional(J.enum(["endTurn","stopSequence","maxTokens"]).or(J.string())),role:J.enum(["user","assistant"]),content:J.discriminatedUnion("type",[w1,D1,z1])}),V6=J.object({type:J.literal("ref/resource"),uri:J.string()}).passthrough(),j6=J.object({type:J.literal("ref/prompt"),name:J.string()}).passthrough(),V1=P.extend({method:J.literal("completion/complete"),params:Z.extend({ref:J.union([j6,V6]),argument:J.object({name:J.string(),value:J.string()}).passthrough()})}),q6=m.extend({completion:J.object({values:J.array(J.string()).max(100),total:J.optional(J.number().int()),hasMore:J.optional(J.boolean())}).passthrough()}),O6=J.object({uri:J.string().startsWith("file://"),name:J.optional(J.string())}).passthrough(),U6=P.extend({method:J.literal("roots/list")}),P1=m.extend({roots:J.array(O6)}),K6=o.extend({method:J.literal("notifications/roots/list_changed")}),o6=J.union([$1,e0,V1,B6,B1,G1,H1,J1,Y1,r4,a4,A1,M1]),r6=J.union([s0,X1,C1,K6]),a6=J.union([t0,I1,P1]),t6=J.union([$1,A6,U6]),s6=J.union([s0,X1,w6,t4,o4,G6,Q6]),e6=J.union([t0,l4,q6,W6,$6,p4,i4,d4,_$,Y6]);R=class R extends Error{constructor($,X,W){super(`MCP error ${$}: ${X}`);this.code=$,this.data=W,this.name="McpError"}}});function T6(){let $=process.argv.join(" ");return $.includes("streamable-http.js")||$.includes("streamable-http.ts")}class D2{context;level;constructor($,X=1){this.context=$,this.level=X}setLevel($){this.level=$}log(...$){if(w2)console.log(...$);else console.error(...$)}logWarn(...$){if(w2)console.warn(...$);else console.error(...$)}debug(...$){if(this.level<=0)this.log(`[DEBUG] [${this.context}]`,...$)}info(...$){if(this.level<=1)this.log(`[INFO] [${this.context}]`,...$)}warn(...$){if(this.level<=2)this.logWarn(`[WARN] [${this.context}]`,...$)}error(...$){if(this.level<=3)console.error(`[ERROR] [${this.context}]`,...$)}}var w2,g=($,X=1)=>new D2($,X);var D0=F1(()=>{w2=T6()});h0();var N6=60000;class f1{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(s0,(X)=>{let W=this._requestHandlerAbortControllers.get(X.params.requestId);W===null||W===void 0||W.abort(X.params.reason)}),this.setNotificationHandler(X1,(X)=>{this._onprogress(X)}),this.setRequestHandler($1,(X)=>({}))}_setupTimeout($,X,W,Q,H=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(Q,X),startTime:Date.now(),timeout:X,maxTotalTimeout:W,resetTimeoutOnProgress:H,onTimeout:Q})}_resetTimeout($){let X=this._timeoutInfo.get($);if(!X)return!1;let W=Date.now()-X.startTime;if(X.maxTotalTimeout&&W>=X.maxTotalTimeout)throw this._timeoutInfo.delete($),new R(_.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:X.maxTotalTimeout,totalElapsed:W});return clearTimeout(X.timeoutId),X.timeoutId=setTimeout(X.onTimeout,X.timeout),!0}_cleanupTimeout($){let X=this._timeoutInfo.get($);if(X)clearTimeout(X.timeoutId),this._timeoutInfo.delete($)}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(X)=>{this._onerror(X)},this._transport.onmessage=(X,W)=>{if(k1(X)||O$(X))this._onresponse(X);else if(M$(X))this._onrequest(X,W);else if(V$(X))this._onnotification(X);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(X)}`))},await this._transport.start()}_onclose(){var $;let X=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let W=new R(_.ConnectionClosed,"Connection closed");for(let Q of X.values())Q(W)}_onerror($){var X;(X=this.onerror)===null||X===void 0||X.call(this,$)}_onnotification($){var X;let W=(X=this._notificationHandlers.get($.method))!==null&&X!==void 0?X:this.fallbackNotificationHandler;if(W===void 0)return;Promise.resolve().then(()=>W($)).catch((Q)=>this._onerror(new Error(`Uncaught error in notification handler: ${Q}`)))}_onrequest($,X){var W,Q,H,Y;let G=(W=this._requestHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackRequestHandler;if(G===void 0){(Q=this._transport)===null||Q===void 0||Q.send({jsonrpc:"2.0",id:$.id,error:{code:_.MethodNotFound,message:"Method not found"}}).catch((M)=>this._onerror(new Error(`Failed to send an error response: ${M}`)));return}let B=new AbortController;this._requestHandlerAbortControllers.set($.id,B);let w={signal:B.signal,sessionId:(H=this._transport)===null||H===void 0?void 0:H.sessionId,_meta:(Y=$.params)===null||Y===void 0?void 0:Y._meta,sendNotification:(M)=>this.notification(M,{relatedRequestId:$.id}),sendRequest:(M,q,b)=>this.request(M,q,{...b,relatedRequestId:$.id}),authInfo:X===null||X===void 0?void 0:X.authInfo,requestId:$.id};Promise.resolve().then(()=>G($,w)).then((M)=>{var q;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({result:M,jsonrpc:"2.0",id:$.id})},(M)=>{var q,b;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(M.code)?M.code:_.InternalError,message:(b=M.message)!==null&&b!==void 0?b:"Internal error"}})}).catch((M)=>this._onerror(new Error(`Failed to send response: ${M}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:X,...W}=$.params,Q=Number(X),H=this._progressHandlers.get(Q);if(!H){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let Y=this._responseHandlers.get(Q),G=this._timeoutInfo.get(Q);if(G&&Y&&G.resetTimeoutOnProgress)try{this._resetTimeout(Q)}catch(B){Y(B);return}H(W)}_onresponse($){let X=Number($.id),W=this._responseHandlers.get(X);if(W===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(X),this._progressHandlers.delete(X),this._cleanupTimeout(X),k1($))W($);else{let Q=new R($.error.code,$.error.message,$.error.data);W(Q)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,X,W){let{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}=W!==null&&W!==void 0?W:{};return new Promise((G,B)=>{var w,M,q,b,r,N1;if(!this._transport){B(new Error("Not connected"));return}if(((w=this._options)===null||w===void 0?void 0:w.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(M=W===null||W===void 0?void 0:W.signal)===null||M===void 0||M.throwIfAborted();let u=this._requestMessageId++,i1={...$,jsonrpc:"2.0",id:u};if(W===null||W===void 0?void 0:W.onprogress)this._progressHandlers.set(u,W.onprogress),i1.params={...$.params,_meta:{...((q=$.params)===null||q===void 0?void 0:q._meta)||{},progressToken:u}};let d1=(f)=>{var H0;this._responseHandlers.delete(u),this._progressHandlers.delete(u),this._cleanupTimeout(u),(H0=this._transport)===null||H0===void 0||H0.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:u,reason:String(f)}},{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((E0)=>this._onerror(new Error(`Failed to send cancellation: ${E0}`))),B(f)};this._responseHandlers.set(u,(f)=>{var H0;if((H0=W===null||W===void 0?void 0:W.signal)===null||H0===void 0?void 0:H0.aborted)return;if(f instanceof Error)return B(f);try{let E0=X.parse(f.result);G(E0)}catch(E0){B(E0)}}),(b=W===null||W===void 0?void 0:W.signal)===null||b===void 0||b.addEventListener("abort",()=>{var f;d1((f=W===null||W===void 0?void 0:W.signal)===null||f===void 0?void 0:f.reason)});let o1=(r=W===null||W===void 0?void 0:W.timeout)!==null&&r!==void 0?r:N6,R2=()=>d1(new R(_.RequestTimeout,"Request timed out",{timeout:o1}));this._setupTimeout(u,o1,W===null||W===void 0?void 0:W.maxTotalTimeout,R2,(N1=W===null||W===void 0?void 0:W.resetTimeoutOnProgress)!==null&&N1!==void 0?N1:!1),this._transport.send(i1,{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((f)=>{this._cleanupTimeout(u),B(f)})})}async notification($,X){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability($.method);let W={...$,jsonrpc:"2.0"};await this._transport.send(W,X)}setRequestHandler($,X){let W=$.shape.method.value;this.assertRequestHandlerCapability(W),this._requestHandlers.set(W,(Q,H)=>{return Promise.resolve(X($.parse(Q),H))})}removeRequestHandler($){this._requestHandlers.delete($)}assertCanSetRequestHandler($){if(this._requestHandlers.has($))throw new Error(`A request handler for ${$} already exists, which would be overridden`)}setNotificationHandler($,X){this._notificationHandlers.set($.shape.method.value,(W)=>Promise.resolve(X($.parse(W))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}function E$($,X){return Object.entries(X).reduce((W,[Q,H])=>{if(H&&typeof H==="object")W[Q]=W[Q]?{...W[Q],...H}:H;else W[Q]=H;return W},{...$})}h0();class T1 extends f1{constructor($,X){var W;super(X);this._serverInfo=$,this._capabilities=(W=X===null||X===void 0?void 0:X.capabilities)!==null&&W!==void 0?W:{},this._instructions=X===null||X===void 0?void 0:X.instructions,this.setRequestHandler(e0,(Q)=>this._oninitialize(Q)),this.setNotificationHandler(C1,()=>{var Q;return(Q=this.oninitialized)===null||Q===void 0?void 0:Q.call(this)})}registerCapabilities($){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=E$(this._capabilities,$)}assertCapabilityForMethod($){var X,W;switch($){case"sampling/createMessage":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.sampling))throw new Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.roots))throw new Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let X=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:B$.includes(X)?X:v1,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},t0)}async createMessage($,X){return this.request({method:"sampling/createMessage",params:$},I1,X)}async listRoots($,X){return this.request({method:"roots/list",params:$},P1,X)}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"})}}var v$=Symbol("Let zodToJsonSchema decide on which parser to use");var b$={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},k$=($)=>typeof $==="string"?{...b$,name:$}:{...b$,...$};var C$=($)=>{let X=k$($),W=X.name!==void 0?[...X.basePath,X.definitionPath,X.name]:X.basePath;return{...X,currentPath:W,propertyPath:void 0,seen:new Map(Object.entries(X.definitions).map(([Q,H])=>[H._def,{def:H._def,path:[...X.basePath,X.definitionPath,Q],jsonSchema:void 0}]))}};function g1($,X,W,Q){if(!Q?.errorMessages)return;if(W)$.errorMessage={...$.errorMessage,[X]:W}}function L($,X,W,Q,H){$[X]=W,g1($,X,Q,H)}d();function I$(){return{}}d();function P$($,X){let W={type:"array"};if($.type?._def&&$.type?._def?.typeName!==z.ZodAny)W.items=O($.type._def,{...X,currentPath:[...X.currentPath,"items"]});if($.minLength)L(W,"minItems",$.minLength.value,$.minLength.message,X);if($.maxLength)L(W,"maxItems",$.maxLength.value,$.maxLength.message,X);if($.exactLength)L(W,"minItems",$.exactLength.value,$.exactLength.message,X),L(W,"maxItems",$.exactLength.value,$.exactLength.message,X);return W}function f$($,X){let W={type:"integer",format:"int64"};if(!$.checks)return W;for(let Q of $.checks)switch(Q.kind){case"min":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"minimum",Q.value,Q.message,X);else L(W,"exclusiveMinimum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMinimum=!0;L(W,"minimum",Q.value,Q.message,X)}break;case"max":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"maximum",Q.value,Q.message,X);else L(W,"exclusiveMaximum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMaximum=!0;L(W,"maximum",Q.value,Q.message,X)}break;case"multipleOf":L(W,"multipleOf",Q.value,Q.message,X);break}return W}function T$(){return{type:"boolean"}}function j1($,X){return O($.type._def,X)}var g$=($,X)=>{return O($.innerType._def,X)};function x1($,X,W){let Q=W??X.dateStrategy;if(Array.isArray(Q))return{anyOf:Q.map((H,Y)=>x1($,X,H))};switch(Q){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return L6($,X)}}var L6=($,X)=>{let W={type:"integer",format:"unix-time"};if(X.target==="openApi3")return W;for(let Q of $.checks)switch(Q.kind){case"min":L(W,"minimum",Q.value,Q.message,X);break;case"max":L(W,"maximum",Q.value,Q.message,X);break}return W};function x$($,X){return{...O($.innerType._def,X),default:$.defaultValue()}}function h$($,X){return X.effectStrategy==="input"?O($.schema._def,X):{}}function y$($){return{type:"string",enum:Array.from($.values)}}var F6=($)=>{if("type"in $&&$.type==="string")return!1;return"allOf"in $};function Z$($,X){let W=[O($.left._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),O($.right._def,{...X,currentPath:[...X.currentPath,"allOf","1"]})].filter((Y)=>!!Y),Q=X.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,H=[];return W.forEach((Y)=>{if(F6(Y)){if(H.push(...Y.allOf),Y.unevaluatedProperties===void 0)Q=void 0}else{let G=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:B,...w}=Y;G=w}else Q=void 0;H.push(G)}}),H.length?{allOf:H,...Q}:void 0}function m$($,X){let W=typeof $.value;if(W!=="bigint"&&W!=="number"&&W!=="boolean"&&W!=="string")return{type:Array.isArray($.value)?"array":"object"};if(X.target==="openApi3")return{type:W==="bigint"?"integer":W,enum:[$.value]};return{type:W==="bigint"?"integer":W,const:$.value}}d();var h1=void 0,l={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(h1===void 0)h1=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return h1},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function q1($,X){let W={type:"string"};if($.checks)for(let Q of $.checks)switch(Q.kind){case"min":L(W,"minLength",typeof W.minLength==="number"?Math.max(W.minLength,Q.value):Q.value,Q.message,X);break;case"max":L(W,"maxLength",typeof W.maxLength==="number"?Math.min(W.maxLength,Q.value):Q.value,Q.message,X);break;case"email":switch(X.emailStrategy){case"format:email":n(W,"email",Q.message,X);break;case"format:idn-email":n(W,"idn-email",Q.message,X);break;case"pattern:zod":k(W,l.email,Q.message,X);break}break;case"url":n(W,"uri",Q.message,X);break;case"uuid":n(W,"uuid",Q.message,X);break;case"regex":k(W,Q.regex,Q.message,X);break;case"cuid":k(W,l.cuid,Q.message,X);break;case"cuid2":k(W,l.cuid2,Q.message,X);break;case"startsWith":k(W,RegExp(`^${y1(Q.value,X)}`),Q.message,X);break;case"endsWith":k(W,RegExp(`${y1(Q.value,X)}$`),Q.message,X);break;case"datetime":n(W,"date-time",Q.message,X);break;case"date":n(W,"date",Q.message,X);break;case"time":n(W,"time",Q.message,X);break;case"duration":n(W,"duration",Q.message,X);break;case"length":L(W,"minLength",typeof W.minLength==="number"?Math.max(W.minLength,Q.value):Q.value,Q.message,X),L(W,"maxLength",typeof W.maxLength==="number"?Math.min(W.maxLength,Q.value):Q.value,Q.message,X);break;case"includes":{k(W,RegExp(y1(Q.value,X)),Q.message,X);break}case"ip":{if(Q.version!=="v6")n(W,"ipv4",Q.message,X);if(Q.version!=="v4")n(W,"ipv6",Q.message,X);break}case"base64url":k(W,l.base64url,Q.message,X);break;case"jwt":k(W,l.jwt,Q.message,X);break;case"cidr":{if(Q.version!=="v6")k(W,l.ipv4Cidr,Q.message,X);if(Q.version!=="v4")k(W,l.ipv6Cidr,Q.message,X);break}case"emoji":k(W,l.emoji(),Q.message,X);break;case"ulid":{k(W,l.ulid,Q.message,X);break}case"base64":{switch(X.base64Strategy){case"format:binary":{n(W,"binary",Q.message,X);break}case"contentEncoding:base64":{L(W,"contentEncoding","base64",Q.message,X);break}case"pattern:zod":{k(W,l.base64,Q.message,X);break}}break}case"nanoid":k(W,l.nanoid,Q.message,X);case"toLowerCase":case"toUpperCase":case"trim":break;default:((H)=>{})(Q)}return W}function y1($,X){return X.patternStrategy==="escape"?_6($):$}var S6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function _6($){let X="";for(let W=0;W<$.length;W++){if(!S6.has($[W]))X+="\\";X+=$[W]}return X}function n($,X,W,Q){if($.format||$.anyOf?.some((H)=>H.format)){if(!$.anyOf)$.anyOf=[];if($.format){if($.anyOf.push({format:$.format,...$.errorMessage&&Q.errorMessages&&{errorMessage:{format:$.errorMessage.format}}}),delete $.format,$.errorMessage){if(delete $.errorMessage.format,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.anyOf.push({format:X,...W&&Q.errorMessages&&{errorMessage:{format:W}}})}else L($,"format",X,W,Q)}function k($,X,W,Q){if($.pattern||$.allOf?.some((H)=>H.pattern)){if(!$.allOf)$.allOf=[];if($.pattern){if($.allOf.push({pattern:$.pattern,...$.errorMessage&&Q.errorMessages&&{errorMessage:{pattern:$.errorMessage.pattern}}}),delete $.pattern,$.errorMessage){if(delete $.errorMessage.pattern,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.allOf.push({pattern:l$(X,Q),...W&&Q.errorMessages&&{errorMessage:{pattern:W}}})}else L($,"pattern",l$(X,Q),W,Q)}function l$($,X){if(!X.applyRegexFlags||!$.flags)return $.source;let W={i:$.flags.includes("i"),m:$.flags.includes("m"),s:$.flags.includes("s")},Q=W.i?$.source.toLowerCase():$.source,H="",Y=!1,G=!1,B=!1;for(let w=0;w<Q.length;w++){if(Y){H+=Q[w],Y=!1;continue}if(W.i){if(G){if(Q[w].match(/[a-z]/)){if(B)H+=Q[w],H+=`${Q[w-2]}-${Q[w]}`.toUpperCase(),B=!1;else if(Q[w+1]==="-"&&Q[w+2]?.match(/[a-z]/))H+=Q[w],B=!0;else H+=`${Q[w]}${Q[w].toUpperCase()}`;continue}}else if(Q[w].match(/[a-z]/)){H+=`[${Q[w]}${Q[w].toUpperCase()}]`;continue}}if(W.m){if(Q[w]==="^"){H+=`(^|(?<=[\r
|
2
|
+
]))`;continue}else if(Q[w]==="$"){H+=`($|(?=[\r
|
3
|
+
]))`;continue}}if(W.s&&Q[w]==="."){H+=G?`${Q[w]}\r
|
4
|
+
`:`[${Q[w]}\r
|
5
|
+
]`;continue}if(H+=Q[w],Q[w]==="\\")Y=!0;else if(G&&Q[w]==="]")G=!1;else if(!G&&Q[w]==="[")G=!0}try{new RegExp(H)}catch{return console.warn(`Could not convert regex pattern at ${X.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return H}function O1($,X){if(X.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(X.target==="openApi3"&&$.keyType?._def.typeName===z.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((Q,H)=>({...Q,[H]:O($.valueType._def,{...X,currentPath:[...X.currentPath,"properties",H]})??{}}),{}),additionalProperties:X.rejectedAdditionalProperties};let W={type:"object",additionalProperties:O($.valueType._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]})??X.allowedAdditionalProperties};if(X.target==="openApi3")return W;if($.keyType?._def.typeName===z.ZodString&&$.keyType._def.checks?.length){let{type:Q,...H}=q1($.keyType._def,X);return{...W,propertyNames:H}}else if($.keyType?._def.typeName===z.ZodEnum)return{...W,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===z.ZodBranded&&$.keyType._def.type._def.typeName===z.ZodString&&$.keyType._def.type._def.checks?.length){let{type:Q,...H}=j1($.keyType._def,X);return{...W,propertyNames:H}}return W}function n$($,X){if(X.mapStrategy==="record")return O1($,X);let W=O($.keyType._def,{...X,currentPath:[...X.currentPath,"items","items","0"]})||{},Q=O($.valueType._def,{...X,currentPath:[...X.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[W,Q],minItems:2,maxItems:2}}}function c$($){let X=$.values,Q=Object.keys($.values).filter((Y)=>{return typeof X[X[Y]]!=="number"}).map((Y)=>X[Y]),H=Array.from(new Set(Q.map((Y)=>typeof Y)));return{type:H.length===1?H[0]==="string"?"string":"number":["string","number"],enum:Q}}function u$(){return{not:{}}}function p$($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var y0={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function d$($,X){if(X.target==="openApi3")return i$($,X);let W=$.options instanceof Map?Array.from($.options.values()):$.options;if(W.every((Q)=>(Q._def.typeName in y0)&&(!Q._def.checks||!Q._def.checks.length))){let Q=W.reduce((H,Y)=>{let G=y0[Y._def.typeName];return G&&!H.includes(G)?[...H,G]:H},[]);return{type:Q.length>1?Q:Q[0]}}else if(W.every((Q)=>Q._def.typeName==="ZodLiteral"&&!Q.description)){let Q=W.reduce((H,Y)=>{let G=typeof Y._def.value;switch(G){case"string":case"number":case"boolean":return[...H,G];case"bigint":return[...H,"integer"];case"object":if(Y._def.value===null)return[...H,"null"];case"symbol":case"undefined":case"function":default:return H}},[]);if(Q.length===W.length){let H=Q.filter((Y,G,B)=>B.indexOf(Y)===G);return{type:H.length>1?H:H[0],enum:W.reduce((Y,G)=>{return Y.includes(G._def.value)?Y:[...Y,G._def.value]},[])}}}else if(W.every((Q)=>Q._def.typeName==="ZodEnum"))return{type:"string",enum:W.reduce((Q,H)=>[...Q,...H._def.values.filter((Y)=>!Q.includes(Y))],[])};return i$($,X)}var i$=($,X)=>{let W=($.options instanceof Map?Array.from($.options.values()):$.options).map((Q,H)=>O(Q._def,{...X,currentPath:[...X.currentPath,"anyOf",`${H}`]})).filter((Q)=>!!Q&&(!X.strictUnions||typeof Q==="object"&&Object.keys(Q).length>0));return W.length?{anyOf:W}:void 0};function o$($,X){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(X.target==="openApi3")return{type:y0[$.innerType._def.typeName],nullable:!0};return{type:[y0[$.innerType._def.typeName],"null"]}}if(X.target==="openApi3"){let Q=O($.innerType._def,{...X,currentPath:[...X.currentPath]});if(Q&&"$ref"in Q)return{allOf:[Q],nullable:!0};return Q&&{...Q,nullable:!0}}let W=O($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","0"]});return W&&{anyOf:[W,{type:"null"}]}}function r$($,X){let W={type:"number"};if(!$.checks)return W;for(let Q of $.checks)switch(Q.kind){case"int":W.type="integer",g1(W,"type",Q.message,X);break;case"min":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"minimum",Q.value,Q.message,X);else L(W,"exclusiveMinimum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMinimum=!0;L(W,"minimum",Q.value,Q.message,X)}break;case"max":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"maximum",Q.value,Q.message,X);else L(W,"exclusiveMaximum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMaximum=!0;L(W,"maximum",Q.value,Q.message,X)}break;case"multipleOf":L(W,"multipleOf",Q.value,Q.message,X);break}return W}d();function a$($,X){let W=X.target==="openAi",Q={type:"object",properties:{}},H=[],Y=$.shape();for(let B in Y){let w=Y[B];if(w===void 0||w._def===void 0)continue;let M=E6(w);if(M&&W){if(w instanceof I)w=w._def.innerType;if(!w.isNullable())w=w.nullable();M=!1}let q=O(w._def,{...X,currentPath:[...X.currentPath,"properties",B],propertyPath:[...X.currentPath,"properties",B]});if(q===void 0)continue;if(Q.properties[B]=q,!M)H.push(B)}if(H.length)Q.required=H;let G=R6($,X);if(G!==void 0)Q.additionalProperties=G;return Q}function R6($,X){if($.catchall._def.typeName!=="ZodNever")return O($.catchall._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return X.allowedAdditionalProperties;case"strict":return X.rejectedAdditionalProperties;case"strip":return X.removeAdditionalStrategy==="strict"?X.allowedAdditionalProperties:X.rejectedAdditionalProperties}}function E6($){try{return $.isOptional()}catch{return!0}}var t$=($,X)=>{if(X.currentPath.toString()===X.propertyPath?.toString())return O($.innerType._def,X);let W=O($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","1"]});return W?{anyOf:[{not:{}},W]}:{}};var s$=($,X)=>{if(X.pipeStrategy==="input")return O($.in._def,X);else if(X.pipeStrategy==="output")return O($.out._def,X);let W=O($.in._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),Q=O($.out._def,{...X,currentPath:[...X.currentPath,"allOf",W?"1":"0"]});return{allOf:[W,Q].filter((H)=>H!==void 0)}};function e$($,X){return O($.type._def,X)}function $2($,X){let Q={type:"array",uniqueItems:!0,items:O($.valueType._def,{...X,currentPath:[...X.currentPath,"items"]})};if($.minSize)L(Q,"minItems",$.minSize.value,$.minSize.message,X);if($.maxSize)L(Q,"maxItems",$.maxSize.value,$.maxSize.message,X);return Q}function X2($,X){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((W,Q)=>O(W._def,{...X,currentPath:[...X.currentPath,"items",`${Q}`]})).reduce((W,Q)=>Q===void 0?W:[...W,Q],[]),additionalItems:O($.rest._def,{...X,currentPath:[...X.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((W,Q)=>O(W._def,{...X,currentPath:[...X.currentPath,"items",`${Q}`]})).reduce((W,Q)=>Q===void 0?W:[...W,Q],[])}}function W2(){return{not:{}}}function Q2(){return{}}var H2=($,X)=>{return O($.innerType._def,X)};var J2=($,X,W)=>{switch(X){case z.ZodString:return q1($,W);case z.ZodNumber:return r$($,W);case z.ZodObject:return a$($,W);case z.ZodBigInt:return f$($,W);case z.ZodBoolean:return T$();case z.ZodDate:return x1($,W);case z.ZodUndefined:return W2();case z.ZodNull:return p$(W);case z.ZodArray:return P$($,W);case z.ZodUnion:case z.ZodDiscriminatedUnion:return d$($,W);case z.ZodIntersection:return Z$($,W);case z.ZodTuple:return X2($,W);case z.ZodRecord:return O1($,W);case z.ZodLiteral:return m$($,W);case z.ZodEnum:return y$($);case z.ZodNativeEnum:return c$($);case z.ZodNullable:return o$($,W);case z.ZodOptional:return t$($,W);case z.ZodMap:return n$($,W);case z.ZodSet:return $2($,W);case z.ZodLazy:return()=>$.getter()._def;case z.ZodPromise:return e$($,W);case z.ZodNaN:case z.ZodNever:return u$();case z.ZodEffects:return h$($,W);case z.ZodAny:return I$();case z.ZodUnknown:return Q2();case z.ZodDefault:return x$($,W);case z.ZodBranded:return j1($,W);case z.ZodReadonly:return H2($,W);case z.ZodCatch:return g$($,W);case z.ZodPipeline:return s$($,W);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return((Q)=>{return})(X)}};function O($,X,W=!1){let Q=X.seen.get($);if(X.override){let B=X.override?.($,X,Q,W);if(B!==v$)return B}if(Q&&!W){let B=b6(Q,X);if(B!==void 0)return B}let H={def:$,path:X.currentPath,jsonSchema:void 0};X.seen.set($,H);let Y=J2($,$.typeName,X),G=typeof Y==="function"?O(Y(),X):Y;if(G)k6($,X,G);if(X.postProcess){let B=X.postProcess(G,$,X);return H.jsonSchema=G,B}return H.jsonSchema=G,G}var b6=($,X)=>{switch(X.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:v6(X.currentPath,$.path)};case"none":case"seen":{if($.path.length<X.currentPath.length&&$.path.every((W,Q)=>X.currentPath[Q]===W))return console.warn(`Recursive reference detected at ${X.currentPath.join("/")}! Defaulting to any`),{};return X.$refStrategy==="seen"?{}:void 0}}},v6=($,X)=>{let W=0;for(;W<$.length&&W<X.length;W++)if($[W]!==X[W])break;return[($.length-W).toString(),...X.slice(W)].join("/")},k6=($,X,W)=>{if($.description){if(W.description=$.description,X.markdownDescription)W.markdownDescription=$.description}return W};var U1=($,X)=>{let W=C$(X),Q=typeof X==="object"&&X.definitions?Object.entries(X.definitions).reduce((w,[M,q])=>({...w,[M]:O(q._def,{...W,currentPath:[...W.basePath,W.definitionPath,M]},!0)??{}}),{}):void 0,H=typeof X==="string"?X:X?.nameStrategy==="title"?void 0:X?.name,Y=O($._def,H===void 0?W:{...W,currentPath:[...W.basePath,W.definitionPath,H]},!1)??{},G=typeof X==="object"&&X.name!==void 0&&X.nameStrategy==="title"?X.name:void 0;if(G!==void 0)Y.title=G;let B=H===void 0?Q?{...Y,[W.definitionPath]:Q}:Y:{$ref:[...W.$refStrategy==="relative"?[]:W.basePath,W.definitionPath,H].join("/"),[W.definitionPath]:{...Q,[H]:Y}};if(W.target==="jsonSchema7")B.$schema="http://json-schema.org/draft-07/schema#";else if(W.target==="jsonSchema2019-09"||W.target==="openAi")B.$schema="https://json-schema.org/draft/2019-09/schema#";if(W.target==="openAi"&&(("anyOf"in B)||("oneOf"in B)||("allOf"in B)||("type"in B)&&Array.isArray(B.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return B};d();h0();d();var Z1;(function($){$.Completable="McpCompletable"})(Z1||(Z1={}));class Z0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;return this._def.type._parse({data:W,path:X.path,parent:X})}unwrap(){return this._def.type}}Z0.create=($,X)=>{return new Z0({type:$,typeName:Z1.Completable,complete:X.complete,...C6(X)})};function C6($){if(!$)return{};let{errorMap:X,invalid_type_error:W,required_error:Q,description:H}=$;if(X&&(W||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:H};return{errorMap:(G,B)=>{var w,M;let{message:q}=$;if(G.code==="invalid_enum_value")return{message:q!==null&&q!==void 0?q:B.defaultError};if(typeof B.data==="undefined")return{message:(w=q!==null&&q!==void 0?q:Q)!==null&&w!==void 0?w:B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:(M=q!==null&&q!==void 0?q:W)!==null&&M!==void 0?M:B.defaultError}},description:H}}class m1{constructor($,X){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new T1($,X)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(M1.shape.method.value),this.server.assertCanSetRequestHandler(A1.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(M1,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,X])=>{let W={name:$,description:X.description,inputSchema:X.inputSchema?U1(X.inputSchema,{strictUnions:!0}):I6,annotations:X.annotations};if(X.outputSchema)W.outputSchema=U1(X.outputSchema,{strictUnions:!0});return W})})),this.server.setRequestHandler(A1,async($,X)=>{let W=this._registeredTools[$.params.name];if(!W)throw new R(_.InvalidParams,`Tool ${$.params.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Tool ${$.params.name} disabled`);let Q;if(W.inputSchema){let H=await W.inputSchema.safeParseAsync($.params.arguments);if(!H.success)throw new R(_.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${H.error.message}`);let Y=H.data,G=W.callback;try{Q=await Promise.resolve(G(Y,X))}catch(B){Q={content:[{type:"text",text:B instanceof Error?B.message:String(B)}],isError:!0}}}else{let H=W.callback;try{Q=await Promise.resolve(H(X))}catch(Y){Q={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(W.outputSchema){if(!Q.structuredContent)throw new R(_.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let H=await W.outputSchema.safeParseAsync(Q.structuredContent);if(!H.success)throw new R(_.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${H.error.message}`)}return Q}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(V1.shape.method.value),this.server.setRequestHandler(V1,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new R(_.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,X){let W=this._registeredPrompts[X.name];if(!W)throw new R(_.InvalidParams,`Prompt ${X.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Prompt ${X.name} disabled`);if(!W.argsSchema)return K1;let Q=W.argsSchema.shape[$.params.argument.name];if(!(Q instanceof Z0))return K1;let Y=await Q._def.complete($.params.argument.value);return G2(Y)}async handleResourceCompletion($,X){let W=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===X.uri);if(!W){if(this._registeredResources[X.uri])return K1;throw new R(_.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let Q=W.resourceTemplate.completeCallback($.params.argument.name);if(!Q)return K1;let H=await Q($.params.argument.value);return G2(H)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(H1.shape.method.value),this.server.assertCanSetRequestHandler(J1.shape.method.value),this.server.assertCanSetRequestHandler(Y1.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(H1,async($,X)=>{let W=Object.entries(this._registeredResources).filter(([H,Y])=>Y.enabled).map(([H,Y])=>({uri:H,name:Y.name,...Y.metadata})),Q=[];for(let H of Object.values(this._registeredResourceTemplates)){if(!H.resourceTemplate.listCallback)continue;let Y=await H.resourceTemplate.listCallback(X);for(let G of Y.resources)Q.push({...G,...H.metadata})}return{resources:[...W,...Q]}}),this.server.setRequestHandler(J1,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([X,W])=>({name:X,uriTemplate:W.resourceTemplate.uriTemplate.toString(),...W.metadata}))}}),this.server.setRequestHandler(Y1,async($,X)=>{let W=new URL($.params.uri),Q=this._registeredResources[W.toString()];if(Q){if(!Q.enabled)throw new R(_.InvalidParams,`Resource ${W} disabled`);return Q.readCallback(W,X)}for(let H of Object.values(this._registeredResourceTemplates)){let Y=H.resourceTemplate.uriTemplate.match(W.toString());if(Y)return H.readCallback(W,Y,X)}throw new R(_.InvalidParams,`Resource ${W} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(G1.shape.method.value),this.server.assertCanSetRequestHandler(B1.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(G1,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,X])=>{return{name:$,description:X.description,arguments:X.argsSchema?f6(X.argsSchema):void 0}})})),this.server.setRequestHandler(B1,async($,X)=>{let W=this._registeredPrompts[$.params.name];if(!W)throw new R(_.InvalidParams,`Prompt ${$.params.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Prompt ${$.params.name} disabled`);if(W.argsSchema){let Q=await W.argsSchema.safeParseAsync($.params.arguments);if(!Q.success)throw new R(_.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${Q.error.message}`);let H=Q.data,Y=W.callback;return await Promise.resolve(Y(H,X))}else{let Q=W.callback;return await Promise.resolve(Q(X))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,X,...W){let Q;if(typeof W[0]==="object")Q=W.shift();let H=W[0];if(typeof X==="string"){if(this._registeredResources[X])throw new Error(`Resource ${X} is already registered`);let Y={name:$,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(G)=>{if(typeof G.uri!=="undefined"&&G.uri!==X){if(delete this._registeredResources[X],G.uri)this._registeredResources[G.uri]=Y}if(typeof G.name!=="undefined")Y.name=G.name;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResources[X]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let Y={resourceTemplate:X,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredResourceTemplates[$],G.name)this._registeredResourceTemplates[G.name]=Y}if(typeof G.template!=="undefined")Y.resourceTemplate=G.template;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}_createRegisteredTool($,X,W,Q,H,Y){let G={description:X,inputSchema:W===void 0?void 0:J.object(W),outputSchema:Q===void 0?void 0:J.object(Q),annotations:H,callback:Y,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(B)=>{if(typeof B.name!=="undefined"&&B.name!==$){if(delete this._registeredTools[$],B.name)this._registeredTools[B.name]=G}if(typeof B.description!=="undefined")G.description=B.description;if(typeof B.paramsSchema!=="undefined")G.inputSchema=J.object(B.paramsSchema);if(typeof B.callback!=="undefined")G.callback=B.callback;if(typeof B.annotations!=="undefined")G.annotations=B.annotations;if(typeof B.enabled!=="undefined")G.enabled=B.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool($,...X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let W,Q,H,Y;if(typeof X[0]==="string")W=X.shift();if(X.length>1){let B=X[0];if(Y2(B)){if(Q=X.shift(),X.length>1&&typeof X[0]==="object"&&X[0]!==null&&!Y2(X[0]))Y=X.shift()}else if(typeof B==="object"&&B!==null)Y=X.shift()}let G=X[0];return this._createRegisteredTool($,W,Q,H,Y,G)}registerTool($,X,W){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:Q,inputSchema:H,outputSchema:Y,annotations:G}=X;return this._createRegisteredTool($,Q,H,Y,G,W)}prompt($,...X){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let W;if(typeof X[0]==="string")W=X.shift();let Q;if(X.length>1)Q=X.shift();let H=X[0],Y={description:W,argsSchema:Q===void 0?void 0:J.object(Q),callback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredPrompts[$],G.name)this._registeredPrompts[G.name]=Y}if(typeof G.description!=="undefined")Y.description=G.description;if(typeof G.argsSchema!=="undefined")Y.argsSchema=J.object(G.argsSchema);if(typeof G.callback!=="undefined")Y.callback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=Y,this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var I6={type:"object"};function Y2($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(P6)}function P6($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function f6($){return Object.entries($.shape).map(([X,W])=>({name:X,description:W.description,required:!W.isOptional()}))}function G2($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var K1={completion:{values:[],hasMore:!1}};function B2($,X){let W=process.argv,Q=`--${$}=`;for(let H of W)if(H.startsWith(Q))return H.substring(Q.length);return X}D0();var x6=g("FigmaConfig",1),m0=B2("figma-api-key")||process.env.FIGMA_API_KEY||"",z2="F2C MCP",M2=process.env.FIGMA_VERSION||"0.0.1";x6.debug("DEFAULT_PERSONAL_TOKEN",m0);D0();var A2=g("F2cApi",1);class V2{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=m0;async nodeToCode($){let X={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")X.option.cssFramework="cssmodules";else if($.format==="react-tailwind")X.option.cssFramework="tailwindcss";let W=this.opToUrl(`${this.f2cHost}/nodes`,X);return this.fetch(W,"json")}async fetch($,X="json"){try{let W={method:"GET"};A2.debug("fetch",$);let Q=await fetch($,W);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return X==="text"?await Q.text():await Q.json()}catch(W){throw A2.error("HTTP error",W),W}}opToUrl($,X={}){if(Object.keys(X).length===0)return $;let W=new URL($);for(let[Q,H]of Object.entries(X))if(typeof H==="object"&&H!==null)for(let[Y,G]of Object.entries(H))W.searchParams.append(`${Q}[${Y}]`,G);else W.searchParams.append(Q,H);return W.toString()}}var j2=new V2;D0();d();var l0=c0(require("fs")),Q0=c0(require("path")),l1=c0(require("fs/promises"));D0();var c=g("Downloader");class q2{op;assetsPath="";savePath="";setup($){if(this.op=$,this.op.localPath)this.assetsPath=Q0.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage($,X){let{imgFormat:W}=this.op,Q=this.assetsPath;try{if(!l0.default.existsSync(Q))l0.default.mkdirSync(Q,{recursive:!0});let H=`${X}.${W}`,Y=Q0.default.join(Q,H),G=await fetch($);if(!G.ok)throw new Error(`下载失败: ${G.status} ${G.statusText}`);let B=await G.arrayBuffer();return l0.default.writeFileSync(Y,new Uint8Array(B)),Q0.default.join(Q0.default.basename(Q),H).replace(/\\/g,"/")}catch(H){throw c.error("图片下载错误:",H),H}}async downLoadImageAndReplaceContent($){try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,W=$.match(X);if(!W)return $;let Q=[...new Set(W)],H=new Map;await Promise.all(Q.map(async(G)=>{let B=Q0.default.basename(G),w=await this.downloadImage(G,B);H.set(G,w)}));let Y=$;for(let[G,B]of H.entries()){let w=new RegExp(G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");Y=Y.replace(w,B)}return Y}catch(X){throw c.error("内容处理错误:",X),X}}async checkLocalAndDownload($){if(!this.op.localPath)return;await Promise.all($.map(async(X)=>{X.content=await this.downLoadImageAndReplaceContent(X.content)}));for(let X of $)try{let W=await this.saveContentToFile(X.content,X.path);c.debug(`Successfully saved: ${W}`)}catch(W){c.error(`Failed to save file ${X.path}:`,W)}}async ensureDirectoryExists($){if(!l0.default.existsSync($))c.debug(`Creating directory: ${$}`),await l1.default.mkdir($,{recursive:!0})}async saveContentToFile($,X){try{let W=Q0.default.join(this.savePath,X),Q=Q0.default.dirname(W);if(c.debug(`Full path: ${W}, directory: ${Q}`),await this.ensureDirectoryExists(Q),X.endsWith(".html"))c.debug("Wrapping content with HTML template"),$=this.wrapHtmlContent($);return c.debug(`Writing ${$.length} bytes to file`),await l1.default.writeFile(W,$),c.info(`File saved: ${W}`),W}catch(W){throw c.error("File save error:",X,W),W}}wrapHtmlContent($){return c.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<meta charset="UTF-8">
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
10
|
+
<title>F2C Generated</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
${$}
|
14
|
+
</body>
|
15
|
+
</html>`}}var n1=new q2;var h6=g("F2cTool"),O2=($)=>{$.tool("figma_to_code","Transform Figma designs into production-ready code. This tool converts selected Figma nodes into HTML,enabling seamless design-to-code workflow.",{fileKey:J.string().describe("The Figma file identifier found in the file URL (e.g., https://www.figma.com/file/XXXXXXXXXXXX/). Extract the XXXXXXXXXXXX portion as the fileKey."),ids:J.string().describe('Comma-separated list of Figma node IDs for conversion. To obtain node IDs, select elements in Figma, right-click and select "Copy/Paste as" → "Copy ID".'),personalToken:J.string().optional().describe("Figma personal access token for API authentication.The parameters are not required when the tool is called."),localPath:J.string().optional().describe("Absolute path for image asset storage. Directory will be created if non-existent. Path must follow OS-specific format without special character escaping. When set, all static resources will be saved to the images directory under this path."),imgFormat:J.enum(["png","jpg","svg"]).default("png").describe('Export format for image assets: "png" for lossless quality, "jpg" for compressed files, or "svg" for vector graphics.'),scaleSize:J.number().min(1).max(4).default(2).describe("Image export scale factor (1-4). Higher values yield better quality at the cost of larger file sizes.")},async(X)=>{n1.setup({...X,format:"html"});try{let W=await j2.nodeToCode({...X,format:"react-tailwind"})||[];if(await n1.checkLocalAndDownload(W),!W)return{content:[{type:"text",text:"Failed to generate any code. Please check if the provided Figma node IDs are correct or if the nodes can be converted to code."}]};let Q=Array.isArray(W)?W:[W];if(Q.length===0)return{content:[{type:"text",text:"Conversion succeeded but no files were generated. Please check if the selected Figma nodes contain convertible content."}]};let H=Q.map((G,B)=>`${B+1}. ${G.path}`).join(`
|
16
|
+
`);if(X.localPath)return{content:[{type:"text",text:`# Files Saved Locally
|
17
|
+
|
18
|
+
## Save Location
|
19
|
+
${X.localPath}
|
20
|
+
|
21
|
+
## Generated Files
|
22
|
+
${H}. Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]};let Y=Q.map((G,B)=>{let w=G.path.split(".").pop()||"";return`## File ${B+1}: ${G.path}
|
23
|
+
\`\`\`${w}
|
24
|
+
${G.content}
|
25
|
+
\`\`\``}).join(`
|
26
|
+
|
27
|
+
`);return{content:[{type:"text",text:`# Generated Files Summary
|
28
|
+
${H}
|
29
|
+
|
30
|
+
# File Details
|
31
|
+
${Y}. Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]}}catch(W){return h6.error("Tool execution error:",W),{content:[{type:"text",text:`Error: ${W.message}`}]}}})};D0();var y6=g("FigmaRestApi");class U2{figmaHost="https://api.figma.com/v1";personalToken=m0;async files($){let X;if($.ids)X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(X)}async images($){let X=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(X)}async imageFills($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(X)}async meta($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(X)}async fetch($,X="json"){try{let W={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},Q=await fetch($,W);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return X==="text"?await Q.text():await Q.json()}catch(W){throw y6.error("HTTP error",W),W}}opToUrl($,X={},W=["fileKey","personalToken"]){if(Object.keys(X).length===0)return $;if(X.personalToken)this.personalToken=X.personalToken;let Q=new URL($);for(let[H,Y]of Object.entries(X))if(!W.includes(H))Q.searchParams.append(H,Y);return Q.toString()}}var K2=new U2;d();var N2=($)=>{$.tool("figma_get_images","Get images of Figma nodes",{fileKey:J.string().describe("Unique identifier of the Figma file"),ids:J.string().describe("Node IDs to get images for, comma separated"),format:J.enum(["jpg","png","svg","pdf"]).optional().describe("Image format, e.g., png, jpg, svg"),scale:J.number().optional().describe("Image scale factor"),svg_include_id:J.boolean().optional().describe("Whether SVG includes ID"),svg_simplify_stroke:J.boolean().optional().describe("Whether to simplify SVG strokes"),use_absolute_bounds:J.boolean().optional().describe("Whether to use absolute bounds"),version:J.string().optional().describe("Specify the version to return"),personalToken:J.string().optional().describe("Your Figma personal access token, The parameters are not required when the tool is called.")},async(X)=>{try{let W=await K2.images(X);return{content:[{type:"text",text:JSON.stringify(W)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}]}}})};var L2=($)=>{};var F2=($)=>{L2($)};var n0=new m1({name:z2,version:M2},{capabilities:{logging:{}}});F2(n0);N2(n0);O2(n0);var u1=c0(require("node:process"));h0();class c1{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
32
|
+
`);if($===-1)return null;let X=this._buffer.toString("utf8",0,$).replace(/\r$/,"");return this._buffer=this._buffer.subarray($+1),Z6(X)}clear(){this._buffer=void 0}}function Z6($){return U$.parse(JSON.parse($))}function S2($){return JSON.stringify($)+`
|
33
|
+
`}class p1{constructor($=u1.default.stdin,X=u1.default.stdout){this._stdin=$,this._stdout=X,this._readBuffer=new c1,this._started=!1,this._ondata=(W)=>{this._readBuffer.append(W),this.processReadBuffer()},this._onerror=(W)=>{var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,W)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,X;while(!0)try{let W=this._readBuffer.readMessage();if(W===null)break;($=this.onmessage)===null||$===void 0||$.call(this,W)}catch(W){(X=this.onerror)===null||X===void 0||X.call(this,W)}}async close(){var $;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((X)=>{let W=S2($);if(this._stdout.write(W))X();else this._stdout.once("drain",X)})}}D0();var m6=g("StdioTransport");async function _2($){try{let X=new p1;await $.connect(X)}catch(X){m6.info(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32000,message:`Server startup failed: ${X.message}`}})),process.exit(1)}}_2(n0);
|
34
|
+
|
35
|
+
//# debugId=4BDFE662267DA2DD64756E2164756E21
|
10
36
|
//# sourceMappingURL=stdio.js.map
|