@f2c/mcp 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -296,7 +296,7 @@ Content-Type: ${x.type||"application/octet-stream"}\r
296
296
  ]))`;continue}else if(a[l]==="$"){v+=`($|(?=[\r
297
297
  ]))`;continue}}if(c.s&&a[l]==="."){v+=w?`${a[l]}\r
298
298
  `:`[${a[l]}\r
299
- ]`;continue}if(v+=a[l],a[l]==="\\")x=!0;else if(w&&a[l]==="]")w=!1;else if(!w&&a[l]==="[")w=!0}try{new RegExp(v)}catch{return console.warn(`Could not convert regex pattern at ${n.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),i.source}return v}function j6(i,n){if(n.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(n.target==="openApi3"&&i.keyType?._def.typeName===O.ZodEnum)return{type:"object",required:i.keyType._def.values,properties:i.keyType._def.values.reduce((a,v)=>({...a,[v]:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"properties",v]})??{}}),{}),additionalProperties:n.rejectedAdditionalProperties};let c={type:"object",additionalProperties:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]})??n.allowedAdditionalProperties};if(n.target==="openApi3")return c;if(i.keyType?._def.typeName===O.ZodString&&i.keyType._def.checks?.length){let{type:a,...v}=q6(i.keyType._def,n);return{...c,propertyNames:v}}else if(i.keyType?._def.typeName===O.ZodEnum)return{...c,propertyNames:{enum:i.keyType._def.values}};else if(i.keyType?._def.typeName===O.ZodBranded&&i.keyType._def.type._def.typeName===O.ZodString&&i.keyType._def.type._def.checks?.length){let{type:a,...v}=R6(i.keyType._def,n);return{...c,propertyNames:v}}return c}function IW(i,n){if(n.mapStrategy==="record")return j6(i,n);let c=T(i.keyType._def,{...n,currentPath:[...n.currentPath,"items","items","0"]})||{},a=T(i.valueType._def,{...n,currentPath:[...n.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[c,a],minItems:2,maxItems:2}}}function CW(i){let n=i.values,a=Object.keys(i.values).filter((x)=>{return typeof n[n[x]]!=="number"}).map((x)=>n[x]),v=Array.from(new Set(a.map((x)=>typeof x)));return{type:v.length===1?v[0]==="string"?"string":"number":["string","number"],enum:a}}function kW(){return{not:{}}}function TW(i){return i.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var W8={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hW(i,n){if(n.target==="openApi3")return gW(i,n);let c=i.options instanceof Map?Array.from(i.options.values()):i.options;if(c.every((a)=>(a._def.typeName in W8)&&(!a._def.checks||!a._def.checks.length))){let a=c.reduce((v,x)=>{let w=W8[x._def.typeName];return w&&!v.includes(w)?[...v,w]:v},[]);return{type:a.length>1?a:a[0]}}else if(c.every((a)=>a._def.typeName==="ZodLiteral"&&!a.description)){let a=c.reduce((v,x)=>{let w=typeof x._def.value;switch(w){case"string":case"number":case"boolean":return[...v,w];case"bigint":return[...v,"integer"];case"object":if(x._def.value===null)return[...v,"null"];case"symbol":case"undefined":case"function":default:return v}},[]);if(a.length===c.length){let v=a.filter((x,w,J)=>J.indexOf(x)===w);return{type:v.length>1?v:v[0],enum:c.reduce((x,w)=>{return x.includes(w._def.value)?x:[...x,w._def.value]},[])}}}else if(c.every((a)=>a._def.typeName==="ZodEnum"))return{type:"string",enum:c.reduce((a,v)=>[...a,...v._def.values.filter((x)=>!a.includes(x))],[])};return gW(i,n)}var gW=(i,n)=>{let c=(i.options instanceof Map?Array.from(i.options.values()):i.options).map((a,v)=>T(a._def,{...n,currentPath:[...n.currentPath,"anyOf",`${v}`]})).filter((a)=>!!a&&(!n.strictUnions||typeof a==="object"&&Object.keys(a).length>0));return c.length?{anyOf:c}:void 0};function oW(i,n){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(i.innerType._def.typeName)&&(!i.innerType._def.checks||!i.innerType._def.checks.length)){if(n.target==="openApi3")return{type:W8[i.innerType._def.typeName],nullable:!0};return{type:[W8[i.innerType._def.typeName],"null"]}}if(n.target==="openApi3"){let a=T(i.innerType._def,{...n,currentPath:[...n.currentPath]});if(a&&"$ref"in a)return{allOf:[a],nullable:!0};return a&&{...a,nullable:!0}}let c=T(i.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","0"]});return c&&{anyOf:[c,{type:"null"}]}}function ZW(i,n){let c={type:"number"};if(!i.checks)return c;for(let a of i.checks)switch(a.kind){case"int":c.type="integer",J9(c,"type",a.message,n);break;case"min":if(n.target==="jsonSchema7")if(a.inclusive)xi(c,"minimum",a.value,a.message,n);else xi(c,"exclusiveMinimum",a.value,a.message,n);else{if(!a.inclusive)c.exclusiveMinimum=!0;xi(c,"minimum",a.value,a.message,n)}break;case"max":if(n.target==="jsonSchema7")if(a.inclusive)xi(c,"maximum",a.value,a.message,n);else xi(c,"exclusiveMaximum",a.value,a.message,n);else{if(!a.inclusive)c.exclusiveMaximum=!0;xi(c,"maximum",a.value,a.message,n)}break;case"multipleOf":xi(c,"multipleOf",a.value,a.message,n);break}return c}I1();function yW(i,n){let c=n.target==="openAi",a={type:"object",properties:{}},v=[],x=i.shape();for(let J in x){let l=x[J];if(l===void 0||l._def===void 0)continue;let W=CL(l);if(W&&c){if(l instanceof cn)l=l._def.innerType;if(!l.isNullable())l=l.nullable();W=!1}let Y=T(l._def,{...n,currentPath:[...n.currentPath,"properties",J],propertyPath:[...n.currentPath,"properties",J]});if(Y===void 0)continue;if(a.properties[J]=Y,!W)v.push(J)}if(v.length)a.required=v;let w=IL(i,n);if(w!==void 0)a.additionalProperties=w;return a}function IL(i,n){if(i.catchall._def.typeName!=="ZodNever")return T(i.catchall._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]});switch(i.unknownKeys){case"passthrough":return n.allowedAdditionalProperties;case"strict":return n.rejectedAdditionalProperties;case"strip":return n.removeAdditionalStrategy==="strict"?n.allowedAdditionalProperties:n.rejectedAdditionalProperties}}function CL(i){try{return i.isOptional()}catch{return!0}}var sW=(i,n)=>{if(n.currentPath.toString()===n.propertyPath?.toString())return T(i.innerType._def,n);let c=T(i.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","1"]});return c?{anyOf:[{not:{}},c]}:{}};var dW=(i,n)=>{if(n.pipeStrategy==="input")return T(i.in._def,n);else if(n.pipeStrategy==="output")return T(i.out._def,n);let c=T(i.in._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),a=T(i.out._def,{...n,currentPath:[...n.currentPath,"allOf",c?"1":"0"]});return{allOf:[c,a].filter((v)=>v!==void 0)}};function rW(i,n){return T(i.type._def,n)}function tW(i,n){let a={type:"array",uniqueItems:!0,items:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"items"]})};if(i.minSize)xi(a,"minItems",i.minSize.value,i.minSize.message,n);if(i.maxSize)xi(a,"maxItems",i.maxSize.value,i.maxSize.message,n);return a}function eW(i,n){if(i.rest)return{type:"array",minItems:i.items.length,items:i.items.map((c,a)=>T(c._def,{...n,currentPath:[...n.currentPath,"items",`${a}`]})).reduce((c,a)=>a===void 0?c:[...c,a],[]),additionalItems:T(i.rest._def,{...n,currentPath:[...n.currentPath,"additionalItems"]})};else return{type:"array",minItems:i.items.length,maxItems:i.items.length,items:i.items.map((c,a)=>T(c._def,{...n,currentPath:[...n.currentPath,"items",`${a}`]})).reduce((c,a)=>a===void 0?c:[...c,a],[])}}function iY(){return{not:{}}}function nY(){return{}}var cY=(i,n)=>{return T(i.innerType._def,n)};var aY=(i,n,c)=>{switch(n){case O.ZodString:return q6(i,c);case O.ZodNumber:return ZW(i,c);case O.ZodObject:return yW(i,c);case O.ZodBigInt:return NW(i,c);case O.ZodBoolean:return RW();case O.ZodDate:return l9(i,c);case O.ZodUndefined:return iY();case O.ZodNull:return TW(c);case O.ZodArray:return AW(i,c);case O.ZodUnion:case O.ZodDiscriminatedUnion:return hW(i,c);case O.ZodIntersection:return uW(i,c);case O.ZodTuple:return eW(i,c);case O.ZodRecord:return j6(i,c);case O.ZodLiteral:return SW(i,c);case O.ZodEnum:return EW(i);case O.ZodNativeEnum:return CW(i);case O.ZodNullable:return oW(i,c);case O.ZodOptional:return sW(i,c);case O.ZodMap:return IW(i,c);case O.ZodSet:return tW(i,c);case O.ZodLazy:return()=>i.getter()._def;case O.ZodPromise:return rW(i,c);case O.ZodNaN:case O.ZodNever:return kW();case O.ZodEffects:return bW(i,c);case O.ZodAny:return OW();case O.ZodUnknown:return nY();case O.ZodDefault:return jW(i,c);case O.ZodBranded:return R6(i,c);case O.ZodReadonly:return cY(i,c);case O.ZodCatch:return qW(i,c);case O.ZodPipeline:return dW(i,c);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return((a)=>{return})(n)}};function T(i,n,c=!1){let a=n.seen.get(i);if(n.override){let J=n.override?.(i,n,a,c);if(J!==LW)return J}if(a&&!c){let J=kL(a,n);if(J!==void 0)return J}let v={def:i,path:n.currentPath,jsonSchema:void 0};n.seen.set(i,v);let x=aY(i,i.typeName,n),w=typeof x==="function"?T(x(),n):x;if(w)gL(i,n,w);if(n.postProcess){let J=n.postProcess(w,i,n);return v.jsonSchema=w,J}return v.jsonSchema=w,w}var kL=(i,n)=>{switch(n.$refStrategy){case"root":return{$ref:i.path.join("/")};case"relative":return{$ref:TL(n.currentPath,i.path)};case"none":case"seen":{if(i.path.length<n.currentPath.length&&i.path.every((c,a)=>n.currentPath[a]===c))return console.warn(`Recursive reference detected at ${n.currentPath.join("/")}! Defaulting to any`),{};return n.$refStrategy==="seen"?{}:void 0}}},TL=(i,n)=>{let c=0;for(;c<i.length&&c<n.length;c++)if(i[c]!==n[c])break;return[(i.length-c).toString(),...n.slice(c)].join("/")},gL=(i,n,c)=>{if(i.description){if(c.description=i.description,n.markdownDescription)c.markdownDescription=i.description}return c};var b6=(i,n)=>{let c=fW(n),a=typeof n==="object"&&n.definitions?Object.entries(n.definitions).reduce((l,[W,Y])=>({...l,[W]:T(Y._def,{...c,currentPath:[...c.basePath,c.definitionPath,W]},!0)??{}}),{}):void 0,v=typeof n==="string"?n:n?.nameStrategy==="title"?void 0:n?.name,x=T(i._def,v===void 0?c:{...c,currentPath:[...c.basePath,c.definitionPath,v]},!1)??{},w=typeof n==="object"&&n.name!==void 0&&n.nameStrategy==="title"?n.name:void 0;if(w!==void 0)x.title=w;let J=v===void 0?a?{...x,[c.definitionPath]:a}:x:{$ref:[...c.$refStrategy==="relative"?[]:c.basePath,c.definitionPath,v].join("/"),[c.definitionPath]:{...a,[v]:x}};if(c.target==="jsonSchema7")J.$schema="http://json-schema.org/draft-07/schema#";else if(c.target==="jsonSchema2019-09"||c.target==="openAi")J.$schema="https://json-schema.org/draft/2019-09/schema#";if(c.target==="openAi"&&(("anyOf"in J)||("oneOf"in J)||("allOf"in J)||("type"in J)&&Array.isArray(J.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return J};I1();C1();I1();var Y9;(function(i){i.Completable="McpCompletable"})(Y9||(Y9={}));class Y8 extends s{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;return this._def.type._parse({data:c,path:n.path,parent:n})}unwrap(){return this._def.type}}Y8.create=(i,n)=>{return new Y8({type:i,typeName:Y9.Completable,complete:n.complete,...hL(n)})};function hL(i){if(!i)return{};let{errorMap:n,invalid_type_error:c,required_error:a,description:v}=i;if(n&&(c||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:v};return{errorMap:(w,J)=>{var l,W;let{message:Y}=i;if(w.code==="invalid_enum_value")return{message:Y!==null&&Y!==void 0?Y:J.defaultError};if(typeof J.data==="undefined")return{message:(l=Y!==null&&Y!==void 0?Y:a)!==null&&l!==void 0?l:J.defaultError};if(w.code!=="invalid_type")return{message:J.defaultError};return{message:(W=Y!==null&&Y!==void 0?Y:c)!==null&&W!==void 0?W:J.defaultError}},description:v}}class X9{constructor(i,n){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new w9(i,n)}async connect(i){return await this.server.connect(i)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(_a.shape.method.value),this.server.assertCanSetRequestHandler(fa.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(_a,()=>({tools:Object.entries(this._registeredTools).filter(([,i])=>i.enabled).map(([i,n])=>{let c={name:i,description:n.description,inputSchema:n.inputSchema?b6(n.inputSchema,{strictUnions:!0}):oL,annotations:n.annotations};if(n.outputSchema)c.outputSchema=b6(n.outputSchema,{strictUnions:!0});return c})})),this.server.setRequestHandler(fa,async(i,n)=>{let c=this._registeredTools[i.params.name];if(!c)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} disabled`);let a;if(c.inputSchema){let v=await c.inputSchema.safeParseAsync(i.params.arguments);if(!v.success)throw new Vi(Xi.InvalidParams,`Invalid arguments for tool ${i.params.name}: ${v.error.message}`);let x=v.data,w=c.callback;try{a=await Promise.resolve(w(x,n))}catch(J){a={content:[{type:"text",text:J instanceof Error?J.message:String(J)}],isError:!0}}}else{let v=c.callback;try{a=await Promise.resolve(v(n))}catch(x){a={content:[{type:"text",text:x instanceof Error?x.message:String(x)}],isError:!0}}}if(c.outputSchema){if(!a.structuredContent)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} has an output schema but no structured content was provided`);let v=await c.outputSchema.safeParseAsync(a.structuredContent);if(!v.success)throw new Vi(Xi.InvalidParams,`Invalid structured content for tool ${i.params.name}: ${v.error.message}`)}return a}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(Oa.shape.method.value),this.server.setRequestHandler(Oa,async(i)=>{switch(i.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(i,i.params.ref);case"ref/resource":return this.handleResourceCompletion(i,i.params.ref);default:throw new Vi(Xi.InvalidParams,`Invalid completion reference: ${i.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(i,n){let c=this._registeredPrompts[n.name];if(!c)throw new Vi(Xi.InvalidParams,`Prompt ${n.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Prompt ${n.name} disabled`);if(!c.argsSchema)return E6;let a=c.argsSchema.shape[i.params.argument.name];if(!(a instanceof Y8))return E6;let x=await a._def.complete(i.params.argument.value);return xY(x)}async handleResourceCompletion(i,n){let c=Object.values(this._registeredResourceTemplates).find((x)=>x.resourceTemplate.uriTemplate.toString()===n.uri);if(!c){if(this._registeredResources[n.uri])return E6;throw new Vi(Xi.InvalidParams,`Resource template ${i.params.ref.uri} not found`)}let a=c.resourceTemplate.completeCallback(i.params.argument.name);if(!a)return E6;let v=await a(i.params.argument.value);return xY(v)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(Va.shape.method.value),this.server.assertCanSetRequestHandler(ma.shape.method.value),this.server.assertCanSetRequestHandler(Ka.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Va,async(i,n)=>{let c=Object.entries(this._registeredResources).filter(([v,x])=>x.enabled).map(([v,x])=>({uri:v,name:x.name,...x.metadata})),a=[];for(let v of Object.values(this._registeredResourceTemplates)){if(!v.resourceTemplate.listCallback)continue;let x=await v.resourceTemplate.listCallback(n);for(let w of x.resources)a.push({...w,...v.metadata})}return{resources:[...c,...a]}}),this.server.setRequestHandler(ma,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([n,c])=>({name:n,uriTemplate:c.resourceTemplate.uriTemplate.toString(),...c.metadata}))}}),this.server.setRequestHandler(Ka,async(i,n)=>{let c=new URL(i.params.uri),a=this._registeredResources[c.toString()];if(a){if(!a.enabled)throw new Vi(Xi.InvalidParams,`Resource ${c} disabled`);return a.readCallback(c,n)}for(let v of Object.values(this._registeredResourceTemplates)){let x=v.resourceTemplate.uriTemplate.match(c.toString());if(x)return v.readCallback(c,x,n)}throw new Vi(Xi.InvalidParams,`Resource ${c} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(Fa.shape.method.value),this.server.assertCanSetRequestHandler(Ua.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Fa,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,i])=>i.enabled).map(([i,n])=>{return{name:i,description:n.description,arguments:n.argsSchema?yL(n.argsSchema):void 0}})})),this.server.setRequestHandler(Ua,async(i,n)=>{let c=this._registeredPrompts[i.params.name];if(!c)throw new Vi(Xi.InvalidParams,`Prompt ${i.params.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Prompt ${i.params.name} disabled`);if(c.argsSchema){let a=await c.argsSchema.safeParseAsync(i.params.arguments);if(!a.success)throw new Vi(Xi.InvalidParams,`Invalid arguments for prompt ${i.params.name}: ${a.error.message}`);let v=a.data,x=c.callback;return await Promise.resolve(x(v,n))}else{let a=c.callback;return await Promise.resolve(a(n))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource(i,n,...c){let a;if(typeof c[0]==="object")a=c.shift();let v=c[0];if(typeof n==="string"){if(this._registeredResources[n])throw new Error(`Resource ${n} is already registered`);let x={name:i,metadata:a,readCallback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({uri:null}),update:(w)=>{if(typeof w.uri!=="undefined"&&w.uri!==n){if(delete this._registeredResources[n],w.uri)this._registeredResources[w.uri]=x}if(typeof w.name!=="undefined")x.name=w.name;if(typeof w.metadata!=="undefined")x.metadata=w.metadata;if(typeof w.callback!=="undefined")x.readCallback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResources[n]=x,this.setResourceRequestHandlers(),this.sendResourceListChanged(),x}else{if(this._registeredResourceTemplates[i])throw new Error(`Resource template ${i} is already registered`);let x={resourceTemplate:n,metadata:a,readCallback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==i){if(delete this._registeredResourceTemplates[i],w.name)this._registeredResourceTemplates[w.name]=x}if(typeof w.template!=="undefined")x.resourceTemplate=w.template;if(typeof w.metadata!=="undefined")x.metadata=w.metadata;if(typeof w.callback!=="undefined")x.readCallback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[i]=x,this.setResourceRequestHandlers(),this.sendResourceListChanged(),x}}_createRegisteredTool(i,n,c,a,v,x){let w={description:n,inputSchema:c===void 0?void 0:G.object(c),outputSchema:a===void 0?void 0:G.object(a),annotations:v,callback:x,enabled:!0,disable:()=>w.update({enabled:!1}),enable:()=>w.update({enabled:!0}),remove:()=>w.update({name:null}),update:(J)=>{if(typeof J.name!=="undefined"&&J.name!==i){if(delete this._registeredTools[i],J.name)this._registeredTools[J.name]=w}if(typeof J.description!=="undefined")w.description=J.description;if(typeof J.paramsSchema!=="undefined")w.inputSchema=G.object(J.paramsSchema);if(typeof J.callback!=="undefined")w.callback=J.callback;if(typeof J.annotations!=="undefined")w.annotations=J.annotations;if(typeof J.enabled!=="undefined")w.enabled=J.enabled;this.sendToolListChanged()}};return this._registeredTools[i]=w,this.setToolRequestHandlers(),this.sendToolListChanged(),w}tool(i,...n){if(this._registeredTools[i])throw new Error(`Tool ${i} is already registered`);let c,a,v,x;if(typeof n[0]==="string")c=n.shift();if(n.length>1){let J=n[0];if(vY(J)){if(a=n.shift(),n.length>1&&typeof n[0]==="object"&&n[0]!==null&&!vY(n[0]))x=n.shift()}else if(typeof J==="object"&&J!==null)x=n.shift()}let w=n[0];return this._createRegisteredTool(i,c,a,v,x,w)}registerTool(i,n,c){if(this._registeredTools[i])throw new Error(`Tool ${i} is already registered`);let{description:a,inputSchema:v,outputSchema:x,annotations:w}=n;return this._createRegisteredTool(i,a,v,x,w,c)}prompt(i,...n){if(this._registeredPrompts[i])throw new Error(`Prompt ${i} is already registered`);let c;if(typeof n[0]==="string")c=n.shift();let a;if(n.length>1)a=n.shift();let v=n[0],x={description:c,argsSchema:a===void 0?void 0:G.object(a),callback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==i){if(delete this._registeredPrompts[i],w.name)this._registeredPrompts[w.name]=x}if(typeof w.description!=="undefined")x.description=w.description;if(typeof w.argsSchema!=="undefined")x.argsSchema=G.object(w.argsSchema);if(typeof w.callback!=="undefined")x.callback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[i]=x,this.setPromptRequestHandlers(),this.sendPromptListChanged(),x}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 oL={type:"object"};function vY(i){if(typeof i!=="object"||i===null)return!1;return Object.keys(i).length===0||Object.values(i).some(ZL)}function ZL(i){return i!==null&&typeof i==="object"&&"parse"in i&&typeof i.parse==="function"&&"safeParse"in i&&typeof i.safeParse==="function"}function yL(i){return Object.entries(i.shape).map(([n,c])=>({name:n,description:c.description,required:!c.isOptional()}))}function xY(i){return{completion:{values:i.slice(0,100),total:i.length,hasMore:i.length>100}}}var E6={completion:{values:[],hasMore:!1}};function pY(i,n){let c=process.argv,a=`--${i}=`;for(let v of c)if(v.startsWith(a))return v.substring(a.length);return n}hn();var sL=Di("FigmaConfig",1),X8=pY("figma-api-key")||process.env.FIGMA_API_KEY||"",wY="F2C MCP",JY=process.env.FIGMA_VERSION||"0.0.1";sL.debug("DEFAULT_PERSONAL_TOKEN",X8);var lY=(i)=>{};var QY=(i)=>{lY(i)};var _9=null;async function M_(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!_9)try{_9=await Promise.resolve().then(() => (vX(),aX))}catch(i){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return _9.default}async function V_(i,n){return(await M_())(i,n)}var o4=V_;hn();var xX=Di("F2cApi",1);class pX{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=X8;async nodeToCode(i){let n={fileKey:i.fileKey,nodeIds:i.ids,personal_token:i.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:i.imgFormat||"png",scaleSize:i.scaleSize||2},format:"files"};if(i.format==="react-cssmodules")n.option.cssFramework="cssmodules";else if(i.format==="react-tailwind")n.option.cssFramework="tailwindcss";let c=this.opToUrl(`${this.f2cHost}/nodes`,n);return this.fetch(c,"json")}async fetch(i,n="json"){try{let c={method:"GET",headers:{"F2c-Api-Platform":"mcp"}};xX.debug("fetch",i);let a=await o4(i,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return n==="text"?await a.text():await a.json()}catch(c){throw xX.error("HTTP error",c),c}}opToUrl(i,n={}){if(Object.keys(n).length===0)return i;let c=new URL(i);for(let[a,v]of Object.entries(n))if(typeof v==="object"&&v!==null)for(let[x,w]of Object.entries(v))c.searchParams.append(`${a}[${x}]`,w);else c.searchParams.append(a,v);return c.toString()}}var wX=new pX;hn();var m_=Di("FigmaRestApi");class JX{figmaHost="https://api.figma.com/v1";personalToken=X8;async files(i){let n;if(i.ids)n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/nodes`,i);else n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}`,i);return this.fetch(n)}async images(i){let n=this.opToUrl(`${this.figmaHost}/images/${i.fileKey}`,i);return this.fetch(n)}async imageFills(i){let n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/images`,i);return this.fetch(n)}async meta(i){let n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/meta`,i);return this.fetch(n)}async fetch(i,n="json"){try{let c={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},a=await o4(i,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return n==="text"?await a.text():await a.json()}catch(c){throw m_.error("HTTP error",c),c}}opToUrl(i,n={},c=["fileKey","personalToken"]){if(Object.keys(n).length===0)return i;if(n.personalToken)this.personalToken=n.personalToken;let a=new URL(i);for(let[v,x]of Object.entries(n))if(!c.includes(v))a.searchParams.append(v,x);return a.toString()}}var lX=new JX;hn();var Ai={};x4(Ai,{void:()=>xf,util:()=>ai,unknown:()=>af,union:()=>lf,undefined:()=>e_,tuple:()=>Yf,transformer:()=>Ff,symbol:()=>t_,string:()=>VX,strictObject:()=>Jf,setErrorMap:()=>U_,set:()=>$f,record:()=>Xf,quotelessJson:()=>K_,promise:()=>Kf,preprocess:()=>Df,pipeline:()=>Lf,ostring:()=>_f,optional:()=>Uf,onumber:()=>ff,oboolean:()=>Of,objectUtil:()=>f9,object:()=>wf,number:()=>mX,nullable:()=>Bf,null:()=>nf,never:()=>vf,nativeEnum:()=>mf,nan:()=>s_,map:()=>zf,makeIssue:()=>F8,literal:()=>Mf,lazy:()=>Hf,late:()=>Z_,isValid:()=>nc,isDirty:()=>r6,isAsync:()=>y4,isAborted:()=>d6,intersection:()=>Wf,instanceof:()=>y_,getParsedType:()=>c1,getErrorMap:()=>Z4,function:()=>Gf,enum:()=>Vf,effect:()=>Ff,discriminatedUnion:()=>Qf,defaultErrorMap:()=>D1,datetimeRegex:()=>GX,date:()=>r_,custom:()=>MX,coerce:()=>Af,boolean:()=>KX,bigint:()=>d_,array:()=>pf,any:()=>cf,addIssueToContext:()=>R,ZodVoid:()=>L8,ZodUnknown:()=>cc,ZodUnion:()=>i0,ZodUndefined:()=>t4,ZodType:()=>ii,ZodTuple:()=>v1,ZodTransformer:()=>un,ZodSymbol:()=>D8,ZodString:()=>qn,ZodSet:()=>hc,ZodSchema:()=>ii,ZodRecord:()=>_8,ZodReadonly:()=>w0,ZodPromise:()=>oc,ZodPipeline:()=>A8,ZodParsedType:()=>N,ZodOptional:()=>bn,ZodObject:()=>$i,ZodNumber:()=>ac,ZodNullable:()=>_1,ZodNull:()=>e4,ZodNever:()=>a1,ZodNativeEnum:()=>v0,ZodNaN:()=>O8,ZodMap:()=>f8,ZodLiteral:()=>a0,ZodLazy:()=>c0,ZodIssueCode:()=>L,ZodIntersection:()=>n0,ZodFunction:()=>d4,ZodFirstPartyTypeKind:()=>h,ZodError:()=>di,ZodEnum:()=>xc,ZodEffects:()=>un,ZodDiscriminatedUnion:()=>e6,ZodDefault:()=>x0,ZodDate:()=>Tc,ZodCatch:()=>p0,ZodBranded:()=>i2,ZodBoolean:()=>r4,ZodBigInt:()=>vc,ZodArray:()=>jn,ZodAny:()=>gc,Schema:()=>ii,ParseStatus:()=>Ei,OK:()=>Pi,NEVER:()=>Nf,INVALID:()=>g,EMPTY_PATH:()=>B_,DIRTY:()=>kc,BRAND:()=>o_});var ai;(function(i){i.assertEqual=(v)=>{};function n(v){}i.assertIs=n;function c(v){throw new Error}i.assertNever=c,i.arrayToEnum=(v)=>{let x={};for(let w of v)x[w]=w;return x},i.getValidEnumValues=(v)=>{let x=i.objectKeys(v).filter((J)=>typeof v[v[J]]!=="number"),w={};for(let J of x)w[J]=v[J];return i.objectValues(w)},i.objectValues=(v)=>{return i.objectKeys(v).map(function(x){return v[x]})},i.objectKeys=typeof Object.keys==="function"?(v)=>Object.keys(v):(v)=>{let x=[];for(let w in v)if(Object.prototype.hasOwnProperty.call(v,w))x.push(w);return x},i.find=(v,x)=>{for(let w of v)if(x(w))return w;return},i.isInteger=typeof Number.isInteger==="function"?(v)=>Number.isInteger(v):(v)=>typeof v==="number"&&Number.isFinite(v)&&Math.floor(v)===v;function a(v,x=" | "){return v.map((w)=>typeof w==="string"?`'${w}'`:w).join(x)}i.joinValues=a,i.jsonStringifyReplacer=(v,x)=>{if(typeof x==="bigint")return x.toString();return x}})(ai||(ai={}));var f9;(function(i){i.mergeShapes=(n,c)=>{return{...n,...c}}})(f9||(f9={}));var N=ai.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),c1=(i)=>{switch(typeof i){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(i)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":if(Array.isArray(i))return N.array;if(i===null)return N.null;if(i.then&&typeof i.then==="function"&&i.catch&&typeof i.catch==="function")return N.promise;if(typeof Map!=="undefined"&&i instanceof Map)return N.map;if(typeof Set!=="undefined"&&i instanceof Set)return N.set;if(typeof Date!=="undefined"&&i instanceof Date)return N.date;return N.object;default:return N.unknown}};var L=ai.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"]),K_=(i)=>{return JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:")};class di extends Error{get errors(){return this.issues}constructor(i){super();this.issues=[],this.addIssue=(c)=>{this.issues=[...this.issues,c]},this.addIssues=(c=[])=>{this.issues=[...this.issues,...c]};let n=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,n);else this.__proto__=n;this.name="ZodError",this.issues=i}format(i){let n=i||function(v){return v.message},c={_errors:[]},a=(v)=>{for(let x of v.issues)if(x.code==="invalid_union")x.unionErrors.map(a);else if(x.code==="invalid_return_type")a(x.returnTypeError);else if(x.code==="invalid_arguments")a(x.argumentsError);else if(x.path.length===0)c._errors.push(n(x));else{let w=c,J=0;while(J<x.path.length){let l=x.path[J];if(J!==x.path.length-1)w[l]=w[l]||{_errors:[]};else w[l]=w[l]||{_errors:[]},w[l]._errors.push(n(x));w=w[l],J++}}};return a(this),c}static assert(i){if(!(i instanceof di))throw new Error(`Not a ZodError: ${i}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ai.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(i=(n)=>n.message){let n={},c=[];for(let a of this.issues)if(a.path.length>0)n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(i(a));else c.push(i(a));return{formErrors:c,fieldErrors:n}}get formErrors(){return this.flatten()}}di.create=(i)=>{return new di(i)};var F_=(i,n)=>{let c;switch(i.code){case L.invalid_type:if(i.received===N.undefined)c="Required";else c=`Expected ${i.expected}, received ${i.received}`;break;case L.invalid_literal:c=`Invalid literal value, expected ${JSON.stringify(i.expected,ai.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:c=`Unrecognized key(s) in object: ${ai.joinValues(i.keys,", ")}`;break;case L.invalid_union:c="Invalid input";break;case L.invalid_union_discriminator:c=`Invalid discriminator value. Expected ${ai.joinValues(i.options)}`;break;case L.invalid_enum_value:c=`Invalid enum value. Expected ${ai.joinValues(i.options)}, received '${i.received}'`;break;case L.invalid_arguments:c="Invalid function arguments";break;case L.invalid_return_type:c="Invalid function return type";break;case L.invalid_date:c="Invalid date";break;case L.invalid_string:if(typeof i.validation==="object")if("includes"in i.validation){if(c=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position==="number")c=`${c} at one or more positions greater than or equal to ${i.validation.position}`}else if("startsWith"in i.validation)c=`Invalid input: must start with "${i.validation.startsWith}"`;else if("endsWith"in i.validation)c=`Invalid input: must end with "${i.validation.endsWith}"`;else ai.assertNever(i.validation);else if(i.validation!=="regex")c=`Invalid ${i.validation}`;else c="Invalid";break;case L.too_small:if(i.type==="array")c=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`;else if(i.type==="string")c=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`;else if(i.type==="number")c=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`;else if(i.type==="date")c=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`;else c="Invalid input";break;case L.too_big:if(i.type==="array")c=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`;else if(i.type==="string")c=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`;else if(i.type==="number")c=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`;else if(i.type==="bigint")c=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`;else if(i.type==="date")c=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`;else c="Invalid input";break;case L.custom:c="Invalid input";break;case L.invalid_intersection_types:c="Intersection results could not be merged";break;case L.not_multiple_of:c=`Number must be a multiple of ${i.multipleOf}`;break;case L.not_finite:c="Number must be finite";break;default:c=n.defaultError,ai.assertNever(i)}return{message:c}},D1=F_;var QX=D1;function U_(i){QX=i}function Z4(){return QX}var F8=(i)=>{let{data:n,path:c,errorMaps:a,issueData:v}=i,x=[...c,...v.path||[]],w={...v,path:x};if(v.message!==void 0)return{...v,path:x,message:v.message};let J="",l=a.filter((W)=>!!W).slice().reverse();for(let W of l)J=W(w,{data:n,defaultError:J}).message;return{...v,path:x,message:J}},B_=[];function R(i,n){let c=Z4(),a=F8({issueData:n,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,c,c===D1?void 0:D1].filter((v)=>!!v)});i.common.issues.push(a)}class Ei{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(i,n){let c=[];for(let a of n){if(a.status==="aborted")return g;if(a.status==="dirty")i.dirty();c.push(a.value)}return{status:i.value,value:c}}static async mergeObjectAsync(i,n){let c=[];for(let a of n){let v=await a.key,x=await a.value;c.push({key:v,value:x})}return Ei.mergeObjectSync(i,c)}static mergeObjectSync(i,n){let c={};for(let a of n){let{key:v,value:x}=a;if(v.status==="aborted")return g;if(x.status==="aborted")return g;if(v.status==="dirty")i.dirty();if(x.status==="dirty")i.dirty();if(v.value!=="__proto__"&&(typeof x.value!=="undefined"||a.alwaysSet))c[v.value]=x.value}return{status:i.value,value:c}}}var g=Object.freeze({status:"aborted"}),kc=(i)=>({status:"dirty",value:i}),Pi=(i)=>({status:"valid",value:i}),d6=(i)=>i.status==="aborted",r6=(i)=>i.status==="dirty",nc=(i)=>i.status==="valid",y4=(i)=>typeof Promise!=="undefined"&&i instanceof Promise;var S;(function(i){i.errToObj=(n)=>typeof n==="string"?{message:n}:n||{},i.toString=(n)=>typeof n==="string"?n:n?.message})(S||(S={}));var t6=function(i,n,c,a){if(c==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n==="function"?i!==n||!a:!n.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?a:c==="a"?a.call(i):a?a.value:n.get(i)},XX=function(i,n,c,a,v){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!v)throw new TypeError("Private accessor was defined without a setter");if(typeof n==="function"?i!==n||!v:!n.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?v.call(i,c):v?v.value=c:n.set(i,c),c},U8,B8;class En{constructor(i,n,c,a){this._cachedPath=[],this.parent=i,this.data=n,this._path=c,this._key=a}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 WX=(i,n)=>{if(nc(n))return{success:!0,data:n.value};else{if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let c=new di(i.common.issues);return this._error=c,this._error}}}};function t(i){if(!i)return{};let{errorMap:n,invalid_type_error:c,required_error:a,description:v}=i;if(n&&(c||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:v};return{errorMap:(w,J)=>{let{message:l}=i;if(w.code==="invalid_enum_value")return{message:l??J.defaultError};if(typeof J.data==="undefined")return{message:l??a??J.defaultError};if(w.code!=="invalid_type")return{message:J.defaultError};return{message:l??c??J.defaultError}},description:v}}class ii{get description(){return this._def.description}_getType(i){return c1(i.data)}_getOrReturnCtx(i,n){return n||{common:i.parent.common,data:i.data,parsedType:c1(i.data),schemaErrorMap:this._def.errorMap,path:i.path,parent:i.parent}}_processInputParams(i){return{status:new Ei,ctx:{common:i.parent.common,data:i.data,parsedType:c1(i.data),schemaErrorMap:this._def.errorMap,path:i.path,parent:i.parent}}}_parseSync(i){let n=this._parse(i);if(y4(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(i){let n=this._parse(i);return Promise.resolve(n)}parse(i,n){let c=this.safeParse(i,n);if(c.success)return c.data;throw c.error}safeParse(i,n){let c={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)},a=this._parseSync({data:i,path:c.path,parent:c});return WX(c,a)}"~validate"(i){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)};if(!this["~standard"].async)try{let c=this._parseSync({data:i,path:[],parent:n});return nc(c)?{value:c.value}:{issues:n.common.issues}}catch(c){if(c?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;n.common={issues:[],async:!0}}return this._parseAsync({data:i,path:[],parent:n}).then((c)=>nc(c)?{value:c.value}:{issues:n.common.issues})}async parseAsync(i,n){let c=await this.safeParseAsync(i,n);if(c.success)return c.data;throw c.error}async safeParseAsync(i,n){let c={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)},a=this._parse({data:i,path:c.path,parent:c}),v=await(y4(a)?a:Promise.resolve(a));return WX(c,v)}refine(i,n){let c=(a)=>{if(typeof n==="string"||typeof n==="undefined")return{message:n};else if(typeof n==="function")return n(a);else return n};return this._refinement((a,v)=>{let x=i(a),w=()=>v.addIssue({code:L.custom,...c(a)});if(typeof Promise!=="undefined"&&x instanceof Promise)return x.then((J)=>{if(!J)return w(),!1;else return!0});if(!x)return w(),!1;else return!0})}refinement(i,n){return this._refinement((c,a)=>{if(!i(c))return a.addIssue(typeof n==="function"?n(c,a):n),!1;else return!0})}_refinement(i){return new un({schema:this,typeName:h.ZodEffects,effect:{type:"refinement",refinement:i}})}superRefine(i){return this._refinement(i)}constructor(i){this.spa=this.safeParseAsync,this._def=i,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:(n)=>this["~validate"](n)}}optional(){return bn.create(this,this._def)}nullable(){return _1.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jn.create(this)}promise(){return oc.create(this,this._def)}or(i){return i0.create([this,i],this._def)}and(i){return n0.create(this,i,this._def)}transform(i){return new un({...t(this._def),schema:this,typeName:h.ZodEffects,effect:{type:"transform",transform:i}})}default(i){let n=typeof i==="function"?i:()=>i;return new x0({...t(this._def),innerType:this,defaultValue:n,typeName:h.ZodDefault})}brand(){return new i2({typeName:h.ZodBranded,type:this,...t(this._def)})}catch(i){let n=typeof i==="function"?i:()=>i;return new p0({...t(this._def),innerType:this,catchValue:n,typeName:h.ZodCatch})}describe(i){return new this.constructor({...this._def,description:i})}pipe(i){return A8.create(this,i)}readonly(){return w0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var D_=/^c[^\s-]{8,}$/i,L_=/^[0-9a-z]+$/,__=/^[0-9A-HJKMNP-TV-Z]{26}$/i,f_=/^[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,O_=/^[a-z0-9_-]{21}$/i,A_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,N_=/^[-+]?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)?)??$/,R_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,q_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",O9,j_=/^(?:(?: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])$/,b_=/^(?:(?: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])$/,E_=/^(([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]))$/,u_=/^(([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])$/,S_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zX="((\\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])))",I_=new RegExp(`^${zX}$`);function $X(i){let n="[0-5]\\d";if(i.precision)n=`${n}\\.\\d{${i.precision}}`;else if(i.precision==null)n=`${n}(\\.\\d+)?`;let c=i.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${c}`}function C_(i){return new RegExp(`^${$X(i)}$`)}function GX(i){let n=`${zX}T${$X(i)}`,c=[];if(c.push(i.local?"Z?":"Z"),i.offset)c.push("([+-]\\d{2}:?\\d{2})");return n=`${n}(${c.join("|")})`,new RegExp(`^${n}$`)}function k_(i,n){if((n==="v4"||!n)&&j_.test(i))return!0;if((n==="v6"||!n)&&E_.test(i))return!0;return!1}function T_(i,n){if(!A_.test(i))return!1;try{let[c]=i.split("."),a=c.replace(/-/g,"+").replace(/_/g,"/").padEnd(c.length+(4-c.length%4)%4,"="),v=JSON.parse(atob(a));if(typeof v!=="object"||v===null)return!1;if("typ"in v&&v?.typ!=="JWT")return!1;if(!v.alg)return!1;if(n&&v.alg!==n)return!1;return!0}catch{return!1}}function g_(i,n){if((n==="v4"||!n)&&b_.test(i))return!0;if((n==="v6"||!n)&&u_.test(i))return!0;return!1}class qn extends ii{_parse(i){if(this._def.coerce)i.data=String(i.data);if(this._getType(i)!==N.string){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.string,received:v.parsedType}),g}let c=new Ei,a=void 0;for(let v of this._def.checks)if(v.kind==="min"){if(i.data.length<v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_small,minimum:v.value,type:"string",inclusive:!0,exact:!1,message:v.message}),c.dirty()}else if(v.kind==="max"){if(i.data.length>v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_big,maximum:v.value,type:"string",inclusive:!0,exact:!1,message:v.message}),c.dirty()}else if(v.kind==="length"){let x=i.data.length>v.value,w=i.data.length<v.value;if(x||w){if(a=this._getOrReturnCtx(i,a),x)R(a,{code:L.too_big,maximum:v.value,type:"string",inclusive:!0,exact:!0,message:v.message});else if(w)R(a,{code:L.too_small,minimum:v.value,type:"string",inclusive:!0,exact:!0,message:v.message});c.dirty()}}else if(v.kind==="email"){if(!R_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"email",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="emoji"){if(!O9)O9=new RegExp(q_,"u");if(!O9.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"emoji",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="uuid"){if(!f_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"uuid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="nanoid"){if(!O_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"nanoid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cuid"){if(!D_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"cuid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cuid2"){if(!L_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"cuid2",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="ulid"){if(!__.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"ulid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="url")try{new URL(i.data)}catch{a=this._getOrReturnCtx(i,a),R(a,{validation:"url",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="regex"){if(v.regex.lastIndex=0,!v.regex.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"regex",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="trim")i.data=i.data.trim();else if(v.kind==="includes"){if(!i.data.includes(v.value,v.position))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{includes:v.value,position:v.position},message:v.message}),c.dirty()}else if(v.kind==="toLowerCase")i.data=i.data.toLowerCase();else if(v.kind==="toUpperCase")i.data=i.data.toUpperCase();else if(v.kind==="startsWith"){if(!i.data.startsWith(v.value))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{startsWith:v.value},message:v.message}),c.dirty()}else if(v.kind==="endsWith"){if(!i.data.endsWith(v.value))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{endsWith:v.value},message:v.message}),c.dirty()}else if(v.kind==="datetime"){if(!GX(v).test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"datetime",message:v.message}),c.dirty()}else if(v.kind==="date"){if(!I_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"date",message:v.message}),c.dirty()}else if(v.kind==="time"){if(!C_(v).test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"time",message:v.message}),c.dirty()}else if(v.kind==="duration"){if(!N_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"duration",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="ip"){if(!k_(i.data,v.version))a=this._getOrReturnCtx(i,a),R(a,{validation:"ip",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="jwt"){if(!T_(i.data,v.alg))a=this._getOrReturnCtx(i,a),R(a,{validation:"jwt",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cidr"){if(!g_(i.data,v.version))a=this._getOrReturnCtx(i,a),R(a,{validation:"cidr",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="base64"){if(!S_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"base64",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="base64url"){if(!P_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"base64url",code:L.invalid_string,message:v.message}),c.dirty()}else ai.assertNever(v);return{status:c.value,value:i.data}}_regex(i,n,c){return this.refinement((a)=>i.test(a),{validation:n,code:L.invalid_string,...S.errToObj(c)})}_addCheck(i){return new qn({...this._def,checks:[...this._def.checks,i]})}email(i){return this._addCheck({kind:"email",...S.errToObj(i)})}url(i){return this._addCheck({kind:"url",...S.errToObj(i)})}emoji(i){return this._addCheck({kind:"emoji",...S.errToObj(i)})}uuid(i){return this._addCheck({kind:"uuid",...S.errToObj(i)})}nanoid(i){return this._addCheck({kind:"nanoid",...S.errToObj(i)})}cuid(i){return this._addCheck({kind:"cuid",...S.errToObj(i)})}cuid2(i){return this._addCheck({kind:"cuid2",...S.errToObj(i)})}ulid(i){return this._addCheck({kind:"ulid",...S.errToObj(i)})}base64(i){return this._addCheck({kind:"base64",...S.errToObj(i)})}base64url(i){return this._addCheck({kind:"base64url",...S.errToObj(i)})}jwt(i){return this._addCheck({kind:"jwt",...S.errToObj(i)})}ip(i){return this._addCheck({kind:"ip",...S.errToObj(i)})}cidr(i){return this._addCheck({kind:"cidr",...S.errToObj(i)})}datetime(i){if(typeof i==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:i});return this._addCheck({kind:"datetime",precision:typeof i?.precision==="undefined"?null:i?.precision,offset:i?.offset??!1,local:i?.local??!1,...S.errToObj(i?.message)})}date(i){return this._addCheck({kind:"date",message:i})}time(i){if(typeof i==="string")return this._addCheck({kind:"time",precision:null,message:i});return this._addCheck({kind:"time",precision:typeof i?.precision==="undefined"?null:i?.precision,...S.errToObj(i?.message)})}duration(i){return this._addCheck({kind:"duration",...S.errToObj(i)})}regex(i,n){return this._addCheck({kind:"regex",regex:i,...S.errToObj(n)})}includes(i,n){return this._addCheck({kind:"includes",value:i,position:n?.position,...S.errToObj(n?.message)})}startsWith(i,n){return this._addCheck({kind:"startsWith",value:i,...S.errToObj(n)})}endsWith(i,n){return this._addCheck({kind:"endsWith",value:i,...S.errToObj(n)})}min(i,n){return this._addCheck({kind:"min",value:i,...S.errToObj(n)})}max(i,n){return this._addCheck({kind:"max",value:i,...S.errToObj(n)})}length(i,n){return this._addCheck({kind:"length",value:i,...S.errToObj(n)})}nonempty(i){return this.min(1,S.errToObj(i))}trim(){return new qn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((i)=>i.kind==="datetime")}get isDate(){return!!this._def.checks.find((i)=>i.kind==="date")}get isTime(){return!!this._def.checks.find((i)=>i.kind==="time")}get isDuration(){return!!this._def.checks.find((i)=>i.kind==="duration")}get isEmail(){return!!this._def.checks.find((i)=>i.kind==="email")}get isURL(){return!!this._def.checks.find((i)=>i.kind==="url")}get isEmoji(){return!!this._def.checks.find((i)=>i.kind==="emoji")}get isUUID(){return!!this._def.checks.find((i)=>i.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((i)=>i.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((i)=>i.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((i)=>i.kind==="cuid2")}get isULID(){return!!this._def.checks.find((i)=>i.kind==="ulid")}get isIP(){return!!this._def.checks.find((i)=>i.kind==="ip")}get isCIDR(){return!!this._def.checks.find((i)=>i.kind==="cidr")}get isBase64(){return!!this._def.checks.find((i)=>i.kind==="base64")}get isBase64url(){return!!this._def.checks.find((i)=>i.kind==="base64url")}get minLength(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxLength(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}}qn.create=(i)=>{return new qn({checks:[],typeName:h.ZodString,coerce:i?.coerce??!1,...t(i)})};function h_(i,n){let c=(i.toString().split(".")[1]||"").length,a=(n.toString().split(".")[1]||"").length,v=c>a?c:a,x=Number.parseInt(i.toFixed(v).replace(".","")),w=Number.parseInt(n.toFixed(v).replace(".",""));return x%w/10**v}class ac extends ii{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(i){if(this._def.coerce)i.data=Number(i.data);if(this._getType(i)!==N.number){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.number,received:v.parsedType}),g}let c=void 0,a=new Ei;for(let v of this._def.checks)if(v.kind==="int"){if(!ai.isInteger(i.data))c=this._getOrReturnCtx(i,c),R(c,{code:L.invalid_type,expected:"integer",received:"float",message:v.message}),a.dirty()}else if(v.kind==="min"){if(v.inclusive?i.data<v.value:i.data<=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_small,minimum:v.value,type:"number",inclusive:v.inclusive,exact:!1,message:v.message}),a.dirty()}else if(v.kind==="max"){if(v.inclusive?i.data>v.value:i.data>=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_big,maximum:v.value,type:"number",inclusive:v.inclusive,exact:!1,message:v.message}),a.dirty()}else if(v.kind==="multipleOf"){if(h_(i.data,v.value)!==0)c=this._getOrReturnCtx(i,c),R(c,{code:L.not_multiple_of,multipleOf:v.value,message:v.message}),a.dirty()}else if(v.kind==="finite"){if(!Number.isFinite(i.data))c=this._getOrReturnCtx(i,c),R(c,{code:L.not_finite,message:v.message}),a.dirty()}else ai.assertNever(v);return{status:a.value,value:i.data}}gte(i,n){return this.setLimit("min",i,!0,S.toString(n))}gt(i,n){return this.setLimit("min",i,!1,S.toString(n))}lte(i,n){return this.setLimit("max",i,!0,S.toString(n))}lt(i,n){return this.setLimit("max",i,!1,S.toString(n))}setLimit(i,n,c,a){return new ac({...this._def,checks:[...this._def.checks,{kind:i,value:n,inclusive:c,message:S.toString(a)}]})}_addCheck(i){return new ac({...this._def,checks:[...this._def.checks,i]})}int(i){return this._addCheck({kind:"int",message:S.toString(i)})}positive(i){return this._addCheck({kind:"min",value:0,inclusive:!1,message:S.toString(i)})}negative(i){return this._addCheck({kind:"max",value:0,inclusive:!1,message:S.toString(i)})}nonpositive(i){return this._addCheck({kind:"max",value:0,inclusive:!0,message:S.toString(i)})}nonnegative(i){return this._addCheck({kind:"min",value:0,inclusive:!0,message:S.toString(i)})}multipleOf(i,n){return this._addCheck({kind:"multipleOf",value:i,message:S.toString(n)})}finite(i){return this._addCheck({kind:"finite",message:S.toString(i)})}safe(i){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:S.toString(i)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:S.toString(i)})}get minValue(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxValue(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}get isInt(){return!!this._def.checks.find((i)=>i.kind==="int"||i.kind==="multipleOf"&&ai.isInteger(i.value))}get isFinite(){let i=null,n=null;for(let c of this._def.checks)if(c.kind==="finite"||c.kind==="int"||c.kind==="multipleOf")return!0;else if(c.kind==="min"){if(n===null||c.value>n)n=c.value}else if(c.kind==="max"){if(i===null||c.value<i)i=c.value}return Number.isFinite(n)&&Number.isFinite(i)}}ac.create=(i)=>{return new ac({checks:[],typeName:h.ZodNumber,coerce:i?.coerce||!1,...t(i)})};class vc extends ii{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(i){if(this._def.coerce)try{i.data=BigInt(i.data)}catch{return this._getInvalidInput(i)}if(this._getType(i)!==N.bigint)return this._getInvalidInput(i);let c=void 0,a=new Ei;for(let v of this._def.checks)if(v.kind==="min"){if(v.inclusive?i.data<v.value:i.data<=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_small,type:"bigint",minimum:v.value,inclusive:v.inclusive,message:v.message}),a.dirty()}else if(v.kind==="max"){if(v.inclusive?i.data>v.value:i.data>=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_big,type:"bigint",maximum:v.value,inclusive:v.inclusive,message:v.message}),a.dirty()}else if(v.kind==="multipleOf"){if(i.data%v.value!==BigInt(0))c=this._getOrReturnCtx(i,c),R(c,{code:L.not_multiple_of,multipleOf:v.value,message:v.message}),a.dirty()}else ai.assertNever(v);return{status:a.value,value:i.data}}_getInvalidInput(i){let n=this._getOrReturnCtx(i);return R(n,{code:L.invalid_type,expected:N.bigint,received:n.parsedType}),g}gte(i,n){return this.setLimit("min",i,!0,S.toString(n))}gt(i,n){return this.setLimit("min",i,!1,S.toString(n))}lte(i,n){return this.setLimit("max",i,!0,S.toString(n))}lt(i,n){return this.setLimit("max",i,!1,S.toString(n))}setLimit(i,n,c,a){return new vc({...this._def,checks:[...this._def.checks,{kind:i,value:n,inclusive:c,message:S.toString(a)}]})}_addCheck(i){return new vc({...this._def,checks:[...this._def.checks,i]})}positive(i){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:S.toString(i)})}negative(i){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:S.toString(i)})}nonpositive(i){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:S.toString(i)})}nonnegative(i){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:S.toString(i)})}multipleOf(i,n){return this._addCheck({kind:"multipleOf",value:i,message:S.toString(n)})}get minValue(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxValue(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}}vc.create=(i)=>{return new vc({checks:[],typeName:h.ZodBigInt,coerce:i?.coerce??!1,...t(i)})};class r4 extends ii{_parse(i){if(this._def.coerce)i.data=Boolean(i.data);if(this._getType(i)!==N.boolean){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.boolean,received:c.parsedType}),g}return Pi(i.data)}}r4.create=(i)=>{return new r4({typeName:h.ZodBoolean,coerce:i?.coerce||!1,...t(i)})};class Tc extends ii{_parse(i){if(this._def.coerce)i.data=new Date(i.data);if(this._getType(i)!==N.date){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.date,received:v.parsedType}),g}if(Number.isNaN(i.data.getTime())){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_date}),g}let c=new Ei,a=void 0;for(let v of this._def.checks)if(v.kind==="min"){if(i.data.getTime()<v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_small,message:v.message,inclusive:!0,exact:!1,minimum:v.value,type:"date"}),c.dirty()}else if(v.kind==="max"){if(i.data.getTime()>v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_big,message:v.message,inclusive:!0,exact:!1,maximum:v.value,type:"date"}),c.dirty()}else ai.assertNever(v);return{status:c.value,value:new Date(i.data.getTime())}}_addCheck(i){return new Tc({...this._def,checks:[...this._def.checks,i]})}min(i,n){return this._addCheck({kind:"min",value:i.getTime(),message:S.toString(n)})}max(i,n){return this._addCheck({kind:"max",value:i.getTime(),message:S.toString(n)})}get minDate(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i!=null?new Date(i):null}get maxDate(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i!=null?new Date(i):null}}Tc.create=(i)=>{return new Tc({checks:[],coerce:i?.coerce||!1,typeName:h.ZodDate,...t(i)})};class D8 extends ii{_parse(i){if(this._getType(i)!==N.symbol){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.symbol,received:c.parsedType}),g}return Pi(i.data)}}D8.create=(i)=>{return new D8({typeName:h.ZodSymbol,...t(i)})};class t4 extends ii{_parse(i){if(this._getType(i)!==N.undefined){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.undefined,received:c.parsedType}),g}return Pi(i.data)}}t4.create=(i)=>{return new t4({typeName:h.ZodUndefined,...t(i)})};class e4 extends ii{_parse(i){if(this._getType(i)!==N.null){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.null,received:c.parsedType}),g}return Pi(i.data)}}e4.create=(i)=>{return new e4({typeName:h.ZodNull,...t(i)})};class gc extends ii{constructor(){super(...arguments);this._any=!0}_parse(i){return Pi(i.data)}}gc.create=(i)=>{return new gc({typeName:h.ZodAny,...t(i)})};class cc extends ii{constructor(){super(...arguments);this._unknown=!0}_parse(i){return Pi(i.data)}}cc.create=(i)=>{return new cc({typeName:h.ZodUnknown,...t(i)})};class a1 extends ii{_parse(i){let n=this._getOrReturnCtx(i);return R(n,{code:L.invalid_type,expected:N.never,received:n.parsedType}),g}}a1.create=(i)=>{return new a1({typeName:h.ZodNever,...t(i)})};class L8 extends ii{_parse(i){if(this._getType(i)!==N.undefined){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.void,received:c.parsedType}),g}return Pi(i.data)}}L8.create=(i)=>{return new L8({typeName:h.ZodVoid,...t(i)})};class jn extends ii{_parse(i){let{ctx:n,status:c}=this._processInputParams(i),a=this._def;if(n.parsedType!==N.array)return R(n,{code:L.invalid_type,expected:N.array,received:n.parsedType}),g;if(a.exactLength!==null){let x=n.data.length>a.exactLength.value,w=n.data.length<a.exactLength.value;if(x||w)R(n,{code:x?L.too_big:L.too_small,minimum:w?a.exactLength.value:void 0,maximum:x?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),c.dirty()}if(a.minLength!==null){if(n.data.length<a.minLength.value)R(n,{code:L.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),c.dirty()}if(a.maxLength!==null){if(n.data.length>a.maxLength.value)R(n,{code:L.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),c.dirty()}if(n.common.async)return Promise.all([...n.data].map((x,w)=>{return a.type._parseAsync(new En(n,x,n.path,w))})).then((x)=>{return Ei.mergeArray(c,x)});let v=[...n.data].map((x,w)=>{return a.type._parseSync(new En(n,x,n.path,w))});return Ei.mergeArray(c,v)}get element(){return this._def.type}min(i,n){return new jn({...this._def,minLength:{value:i,message:S.toString(n)}})}max(i,n){return new jn({...this._def,maxLength:{value:i,message:S.toString(n)}})}length(i,n){return new jn({...this._def,exactLength:{value:i,message:S.toString(n)}})}nonempty(i){return this.min(1,i)}}jn.create=(i,n)=>{return new jn({type:i,minLength:null,maxLength:null,exactLength:null,typeName:h.ZodArray,...t(n)})};function s4(i){if(i instanceof $i){let n={};for(let c in i.shape){let a=i.shape[c];n[c]=bn.create(s4(a))}return new $i({...i._def,shape:()=>n})}else if(i instanceof jn)return new jn({...i._def,type:s4(i.element)});else if(i instanceof bn)return bn.create(s4(i.unwrap()));else if(i instanceof _1)return _1.create(s4(i.unwrap()));else if(i instanceof v1)return v1.create(i.items.map((n)=>s4(n)));else return i}class $i extends ii{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let i=this._def.shape(),n=ai.objectKeys(i);return this._cached={shape:i,keys:n},this._cached}_parse(i){if(this._getType(i)!==N.object){let l=this._getOrReturnCtx(i);return R(l,{code:L.invalid_type,expected:N.object,received:l.parsedType}),g}let{status:c,ctx:a}=this._processInputParams(i),{shape:v,keys:x}=this._getCached(),w=[];if(!(this._def.catchall instanceof a1&&this._def.unknownKeys==="strip")){for(let l in a.data)if(!x.includes(l))w.push(l)}let J=[];for(let l of x){let W=v[l],Y=a.data[l];J.push({key:{status:"valid",value:l},value:W._parse(new En(a,Y,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof a1){let l=this._def.unknownKeys;if(l==="passthrough")for(let W of w)J.push({key:{status:"valid",value:W},value:{status:"valid",value:a.data[W]}});else if(l==="strict"){if(w.length>0)R(a,{code:L.unrecognized_keys,keys:w}),c.dirty()}else if(l==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let W of w){let Y=a.data[W];J.push({key:{status:"valid",value:W},value:l._parse(new En(a,Y,a.path,W)),alwaysSet:W in a.data})}}if(a.common.async)return Promise.resolve().then(async()=>{let l=[];for(let W of J){let Y=await W.key,z=await W.value;l.push({key:Y,value:z,alwaysSet:W.alwaysSet})}return l}).then((l)=>{return Ei.mergeObjectSync(c,l)});else return Ei.mergeObjectSync(c,J)}get shape(){return this._def.shape()}strict(i){return S.errToObj,new $i({...this._def,unknownKeys:"strict",...i!==void 0?{errorMap:(n,c)=>{let a=this._def.errorMap?.(n,c).message??c.defaultError;if(n.code==="unrecognized_keys")return{message:S.errToObj(i).message??a};return{message:a}}}:{}})}strip(){return new $i({...this._def,unknownKeys:"strip"})}passthrough(){return new $i({...this._def,unknownKeys:"passthrough"})}extend(i){return new $i({...this._def,shape:()=>({...this._def.shape(),...i})})}merge(i){return new $i({unknownKeys:i._def.unknownKeys,catchall:i._def.catchall,shape:()=>({...this._def.shape(),...i._def.shape()}),typeName:h.ZodObject})}setKey(i,n){return this.augment({[i]:n})}catchall(i){return new $i({...this._def,catchall:i})}pick(i){let n={};for(let c of ai.objectKeys(i))if(i[c]&&this.shape[c])n[c]=this.shape[c];return new $i({...this._def,shape:()=>n})}omit(i){let n={};for(let c of ai.objectKeys(this.shape))if(!i[c])n[c]=this.shape[c];return new $i({...this._def,shape:()=>n})}deepPartial(){return s4(this)}partial(i){let n={};for(let c of ai.objectKeys(this.shape)){let a=this.shape[c];if(i&&!i[c])n[c]=a;else n[c]=a.optional()}return new $i({...this._def,shape:()=>n})}required(i){let n={};for(let c of ai.objectKeys(this.shape))if(i&&!i[c])n[c]=this.shape[c];else{let v=this.shape[c];while(v instanceof bn)v=v._def.innerType;n[c]=v}return new $i({...this._def,shape:()=>n})}keyof(){return HX(ai.objectKeys(this.shape))}}$i.create=(i,n)=>{return new $i({shape:()=>i,unknownKeys:"strip",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};$i.strictCreate=(i,n)=>{return new $i({shape:()=>i,unknownKeys:"strict",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};$i.lazycreate=(i,n)=>{return new $i({shape:i,unknownKeys:"strip",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};class i0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=this._def.options;function a(v){for(let w of v)if(w.result.status==="valid")return w.result;for(let w of v)if(w.result.status==="dirty")return n.common.issues.push(...w.ctx.common.issues),w.result;let x=v.map((w)=>new di(w.ctx.common.issues));return R(n,{code:L.invalid_union,unionErrors:x}),g}if(n.common.async)return Promise.all(c.map(async(v)=>{let x={...n,common:{...n.common,issues:[]},parent:null};return{result:await v._parseAsync({data:n.data,path:n.path,parent:x}),ctx:x}})).then(a);else{let v=void 0,x=[];for(let J of c){let l={...n,common:{...n.common,issues:[]},parent:null},W=J._parseSync({data:n.data,path:n.path,parent:l});if(W.status==="valid")return W;else if(W.status==="dirty"&&!v)v={result:W,ctx:l};if(l.common.issues.length)x.push(l.common.issues)}if(v)return n.common.issues.push(...v.ctx.common.issues),v.result;let w=x.map((J)=>new di(J));return R(n,{code:L.invalid_union,unionErrors:w}),g}}get options(){return this._def.options}}i0.create=(i,n)=>{return new i0({options:i,typeName:h.ZodUnion,...t(n)})};var L1=(i)=>{if(i instanceof c0)return L1(i.schema);else if(i instanceof un)return L1(i.innerType());else if(i instanceof a0)return[i.value];else if(i instanceof xc)return i.options;else if(i instanceof v0)return ai.objectValues(i.enum);else if(i instanceof x0)return L1(i._def.innerType);else if(i instanceof t4)return[void 0];else if(i instanceof e4)return[null];else if(i instanceof bn)return[void 0,...L1(i.unwrap())];else if(i instanceof _1)return[null,...L1(i.unwrap())];else if(i instanceof i2)return L1(i.unwrap());else if(i instanceof w0)return L1(i.unwrap());else if(i instanceof p0)return L1(i._def.innerType);else return[]};class e6 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.object)return R(n,{code:L.invalid_type,expected:N.object,received:n.parsedType}),g;let c=this.discriminator,a=n.data[c],v=this.optionsMap.get(a);if(!v)return R(n,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[c]}),g;if(n.common.async)return v._parseAsync({data:n.data,path:n.path,parent:n});else return v._parseSync({data:n.data,path:n.path,parent:n})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(i,n,c){let a=new Map;for(let v of n){let x=L1(v.shape[i]);if(!x.length)throw new Error(`A discriminator value for key \`${i}\` could not be extracted from all schema options`);for(let w of x){if(a.has(w))throw new Error(`Discriminator property ${String(i)} has duplicate value ${String(w)}`);a.set(w,v)}}return new e6({typeName:h.ZodDiscriminatedUnion,discriminator:i,options:n,optionsMap:a,...t(c)})}}function A9(i,n){let c=c1(i),a=c1(n);if(i===n)return{valid:!0,data:i};else if(c===N.object&&a===N.object){let v=ai.objectKeys(n),x=ai.objectKeys(i).filter((J)=>v.indexOf(J)!==-1),w={...i,...n};for(let J of x){let l=A9(i[J],n[J]);if(!l.valid)return{valid:!1};w[J]=l.data}return{valid:!0,data:w}}else if(c===N.array&&a===N.array){if(i.length!==n.length)return{valid:!1};let v=[];for(let x=0;x<i.length;x++){let w=i[x],J=n[x],l=A9(w,J);if(!l.valid)return{valid:!1};v.push(l.data)}return{valid:!0,data:v}}else if(c===N.date&&a===N.date&&+i===+n)return{valid:!0,data:i};else return{valid:!1}}class n0 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i),a=(v,x)=>{if(d6(v)||d6(x))return g;let w=A9(v.value,x.value);if(!w.valid)return R(c,{code:L.invalid_intersection_types}),g;if(r6(v)||r6(x))n.dirty();return{status:n.value,value:w.data}};if(c.common.async)return Promise.all([this._def.left._parseAsync({data:c.data,path:c.path,parent:c}),this._def.right._parseAsync({data:c.data,path:c.path,parent:c})]).then(([v,x])=>a(v,x));else return a(this._def.left._parseSync({data:c.data,path:c.path,parent:c}),this._def.right._parseSync({data:c.data,path:c.path,parent:c}))}}n0.create=(i,n,c)=>{return new n0({left:i,right:n,typeName:h.ZodIntersection,...t(c)})};class v1 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.array)return R(c,{code:L.invalid_type,expected:N.array,received:c.parsedType}),g;if(c.data.length<this._def.items.length)return R(c,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;if(!this._def.rest&&c.data.length>this._def.items.length)R(c,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty();let v=[...c.data].map((x,w)=>{let J=this._def.items[w]||this._def.rest;if(!J)return null;return J._parse(new En(c,x,c.path,w))}).filter((x)=>!!x);if(c.common.async)return Promise.all(v).then((x)=>{return Ei.mergeArray(n,x)});else return Ei.mergeArray(n,v)}get items(){return this._def.items}rest(i){return new v1({...this._def,rest:i})}}v1.create=(i,n)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new v1({items:i,typeName:h.ZodTuple,rest:null,...t(n)})};class _8 extends ii{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.object)return R(c,{code:L.invalid_type,expected:N.object,received:c.parsedType}),g;let a=[],v=this._def.keyType,x=this._def.valueType;for(let w in c.data)a.push({key:v._parse(new En(c,w,c.path,w)),value:x._parse(new En(c,c.data[w],c.path,w)),alwaysSet:w in c.data});if(c.common.async)return Ei.mergeObjectAsync(n,a);else return Ei.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(i,n,c){if(n instanceof ii)return new _8({keyType:i,valueType:n,typeName:h.ZodRecord,...t(c)});return new _8({keyType:qn.create(),valueType:i,typeName:h.ZodRecord,...t(n)})}}class f8 extends ii{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.map)return R(c,{code:L.invalid_type,expected:N.map,received:c.parsedType}),g;let a=this._def.keyType,v=this._def.valueType,x=[...c.data.entries()].map(([w,J],l)=>{return{key:a._parse(new En(c,w,c.path,[l,"key"])),value:v._parse(new En(c,J,c.path,[l,"value"]))}});if(c.common.async){let w=new Map;return Promise.resolve().then(async()=>{for(let J of x){let l=await J.key,W=await J.value;if(l.status==="aborted"||W.status==="aborted")return g;if(l.status==="dirty"||W.status==="dirty")n.dirty();w.set(l.value,W.value)}return{status:n.value,value:w}})}else{let w=new Map;for(let J of x){let{key:l,value:W}=J;if(l.status==="aborted"||W.status==="aborted")return g;if(l.status==="dirty"||W.status==="dirty")n.dirty();w.set(l.value,W.value)}return{status:n.value,value:w}}}}f8.create=(i,n,c)=>{return new f8({valueType:n,keyType:i,typeName:h.ZodMap,...t(c)})};class hc extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.set)return R(c,{code:L.invalid_type,expected:N.set,received:c.parsedType}),g;let a=this._def;if(a.minSize!==null){if(c.data.size<a.minSize.value)R(c,{code:L.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()}if(a.maxSize!==null){if(c.data.size>a.maxSize.value)R(c,{code:L.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty()}let v=this._def.valueType;function x(J){let l=new Set;for(let W of J){if(W.status==="aborted")return g;if(W.status==="dirty")n.dirty();l.add(W.value)}return{status:n.value,value:l}}let w=[...c.data.values()].map((J,l)=>v._parse(new En(c,J,c.path,l)));if(c.common.async)return Promise.all(w).then((J)=>x(J));else return x(w)}min(i,n){return new hc({...this._def,minSize:{value:i,message:S.toString(n)}})}max(i,n){return new hc({...this._def,maxSize:{value:i,message:S.toString(n)}})}size(i,n){return this.min(i,n).max(i,n)}nonempty(i){return this.min(1,i)}}hc.create=(i,n)=>{return new hc({valueType:i,minSize:null,maxSize:null,typeName:h.ZodSet,...t(n)})};class d4 extends ii{constructor(){super(...arguments);this.validate=this.implement}_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.function)return R(n,{code:L.invalid_type,expected:N.function,received:n.parsedType}),g;function c(w,J){return F8({data:w,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Z4(),D1].filter((l)=>!!l),issueData:{code:L.invalid_arguments,argumentsError:J}})}function a(w,J){return F8({data:w,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Z4(),D1].filter((l)=>!!l),issueData:{code:L.invalid_return_type,returnTypeError:J}})}let v={errorMap:n.common.contextualErrorMap},x=n.data;if(this._def.returns instanceof oc){let w=this;return Pi(async function(...J){let l=new di([]),W=await w._def.args.parseAsync(J,v).catch(($)=>{throw l.addIssue(c(J,$)),l}),Y=await Reflect.apply(x,this,W);return await w._def.returns._def.type.parseAsync(Y,v).catch(($)=>{throw l.addIssue(a(Y,$)),l})})}else{let w=this;return Pi(function(...J){let l=w._def.args.safeParse(J,v);if(!l.success)throw new di([c(J,l.error)]);let W=Reflect.apply(x,this,l.data),Y=w._def.returns.safeParse(W,v);if(!Y.success)throw new di([a(W,Y.error)]);return Y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...i){return new d4({...this._def,args:v1.create(i).rest(cc.create())})}returns(i){return new d4({...this._def,returns:i})}implement(i){return this.parse(i)}strictImplement(i){return this.parse(i)}static create(i,n,c){return new d4({args:i?i:v1.create([]).rest(cc.create()),returns:n||cc.create(),typeName:h.ZodFunction,...t(c)})}}class c0 extends ii{get schema(){return this._def.getter()}_parse(i){let{ctx:n}=this._processInputParams(i);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}c0.create=(i,n)=>{return new c0({getter:i,typeName:h.ZodLazy,...t(n)})};class a0 extends ii{_parse(i){if(i.data!==this._def.value){let n=this._getOrReturnCtx(i);return R(n,{received:n.data,code:L.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:i.data}}get value(){return this._def.value}}a0.create=(i,n)=>{return new a0({value:i,typeName:h.ZodLiteral,...t(n)})};function HX(i,n){return new xc({values:i,typeName:h.ZodEnum,...t(n)})}class xc extends ii{constructor(){super(...arguments);U8.set(this,void 0)}_parse(i){if(typeof i.data!=="string"){let n=this._getOrReturnCtx(i),c=this._def.values;return R(n,{expected:ai.joinValues(c),received:n.parsedType,code:L.invalid_type}),g}if(!t6(this,U8,"f"))XX(this,U8,new Set(this._def.values),"f");if(!t6(this,U8,"f").has(i.data)){let n=this._getOrReturnCtx(i),c=this._def.values;return R(n,{received:n.data,code:L.invalid_enum_value,options:c}),g}return Pi(i.data)}get options(){return this._def.values}get enum(){let i={};for(let n of this._def.values)i[n]=n;return i}get Values(){let i={};for(let n of this._def.values)i[n]=n;return i}get Enum(){let i={};for(let n of this._def.values)i[n]=n;return i}extract(i,n=this._def){return xc.create(i,{...this._def,...n})}exclude(i,n=this._def){return xc.create(this.options.filter((c)=>!i.includes(c)),{...this._def,...n})}}U8=new WeakMap;xc.create=HX;class v0 extends ii{constructor(){super(...arguments);B8.set(this,void 0)}_parse(i){let n=ai.getValidEnumValues(this._def.values),c=this._getOrReturnCtx(i);if(c.parsedType!==N.string&&c.parsedType!==N.number){let a=ai.objectValues(n);return R(c,{expected:ai.joinValues(a),received:c.parsedType,code:L.invalid_type}),g}if(!t6(this,B8,"f"))XX(this,B8,new Set(ai.getValidEnumValues(this._def.values)),"f");if(!t6(this,B8,"f").has(i.data)){let a=ai.objectValues(n);return R(c,{received:c.data,code:L.invalid_enum_value,options:a}),g}return Pi(i.data)}get enum(){return this._def.values}}B8=new WeakMap;v0.create=(i,n)=>{return new v0({values:i,typeName:h.ZodNativeEnum,...t(n)})};class oc extends ii{unwrap(){return this._def.type}_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.promise&&n.common.async===!1)return R(n,{code:L.invalid_type,expected:N.promise,received:n.parsedType}),g;let c=n.parsedType===N.promise?n.data:Promise.resolve(n.data);return Pi(c.then((a)=>{return this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})}))}}oc.create=(i,n)=>{return new oc({type:i,typeName:h.ZodPromise,...t(n)})};class un extends ii{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===h.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(i){let{status:n,ctx:c}=this._processInputParams(i),a=this._def.effect||null,v={addIssue:(x)=>{if(R(c,x),x.fatal)n.abort();else n.dirty()},get path(){return c.path}};if(v.addIssue=v.addIssue.bind(v),a.type==="preprocess"){let x=a.transform(c.data,v);if(c.common.async)return Promise.resolve(x).then(async(w)=>{if(n.value==="aborted")return g;let J=await this._def.schema._parseAsync({data:w,path:c.path,parent:c});if(J.status==="aborted")return g;if(J.status==="dirty")return kc(J.value);if(n.value==="dirty")return kc(J.value);return J});else{if(n.value==="aborted")return g;let w=this._def.schema._parseSync({data:x,path:c.path,parent:c});if(w.status==="aborted")return g;if(w.status==="dirty")return kc(w.value);if(n.value==="dirty")return kc(w.value);return w}}if(a.type==="refinement"){let x=(w)=>{let J=a.refinement(w,v);if(c.common.async)return Promise.resolve(J);if(J instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return w};if(c.common.async===!1){let w=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(w.status==="aborted")return g;if(w.status==="dirty")n.dirty();return x(w.value),{status:n.value,value:w.value}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then((w)=>{if(w.status==="aborted")return g;if(w.status==="dirty")n.dirty();return x(w.value).then(()=>{return{status:n.value,value:w.value}})})}if(a.type==="transform")if(c.common.async===!1){let x=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(!nc(x))return x;let w=a.transform(x.value,v);if(w instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:w}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then((x)=>{if(!nc(x))return x;return Promise.resolve(a.transform(x.value,v)).then((w)=>({status:n.value,value:w}))});ai.assertNever(a)}}un.create=(i,n,c)=>{return new un({schema:i,typeName:h.ZodEffects,effect:n,...t(c)})};un.createWithPreprocess=(i,n,c)=>{return new un({schema:n,effect:{type:"preprocess",transform:i},typeName:h.ZodEffects,...t(c)})};class bn extends ii{_parse(i){if(this._getType(i)===N.undefined)return Pi(void 0);return this._def.innerType._parse(i)}unwrap(){return this._def.innerType}}bn.create=(i,n)=>{return new bn({innerType:i,typeName:h.ZodOptional,...t(n)})};class _1 extends ii{_parse(i){if(this._getType(i)===N.null)return Pi(null);return this._def.innerType._parse(i)}unwrap(){return this._def.innerType}}_1.create=(i,n)=>{return new _1({innerType:i,typeName:h.ZodNullable,...t(n)})};class x0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;if(n.parsedType===N.undefined)c=this._def.defaultValue();return this._def.innerType._parse({data:c,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}x0.create=(i,n)=>{return new x0({innerType:i,typeName:h.ZodDefault,defaultValue:typeof n.default==="function"?n.default:()=>n.default,...t(n)})};class p0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:c.data,path:c.path,parent:{...c}});if(y4(a))return a.then((v)=>{return{status:"valid",value:v.status==="valid"?v.value:this._def.catchValue({get error(){return new di(c.common.issues)},input:c.data})}});else return{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new di(c.common.issues)},input:c.data})}}removeCatch(){return this._def.innerType}}p0.create=(i,n)=>{return new p0({innerType:i,typeName:h.ZodCatch,catchValue:typeof n.catch==="function"?n.catch:()=>n.catch,...t(n)})};class O8 extends ii{_parse(i){if(this._getType(i)!==N.nan){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.nan,received:c.parsedType}),g}return{status:"valid",value:i.data}}}O8.create=(i)=>{return new O8({typeName:h.ZodNaN,...t(i)})};var o_=Symbol("zod_brand");class i2 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;return this._def.type._parse({data:c,path:n.path,parent:n})}unwrap(){return this._def.type}}class A8 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.common.async)return(async()=>{let v=await this._def.in._parseAsync({data:c.data,path:c.path,parent:c});if(v.status==="aborted")return g;if(v.status==="dirty")return n.dirty(),kc(v.value);else return this._def.out._parseAsync({data:v.value,path:c.path,parent:c})})();else{let a=this._def.in._parseSync({data:c.data,path:c.path,parent:c});if(a.status==="aborted")return g;if(a.status==="dirty")return n.dirty(),{status:"dirty",value:a.value};else return this._def.out._parseSync({data:a.value,path:c.path,parent:c})}}static create(i,n){return new A8({in:i,out:n,typeName:h.ZodPipeline})}}class w0 extends ii{_parse(i){let n=this._def.innerType._parse(i),c=(a)=>{if(nc(a))a.value=Object.freeze(a.value);return a};return y4(n)?n.then((a)=>c(a)):c(n)}unwrap(){return this._def.innerType}}w0.create=(i,n)=>{return new w0({innerType:i,typeName:h.ZodReadonly,...t(n)})};function YX(i,n){let c=typeof i==="function"?i(n):typeof i==="string"?{message:i}:i;return typeof c==="string"?{message:c}:c}function MX(i,n={},c){if(i)return gc.create().superRefine((a,v)=>{let x=i(a);if(x instanceof Promise)return x.then((w)=>{if(!w){let J=YX(n,a),l=J.fatal??c??!0;v.addIssue({code:"custom",...J,fatal:l})}});if(!x){let w=YX(n,a),J=w.fatal??c??!0;v.addIssue({code:"custom",...w,fatal:J})}return});return gc.create()}var Z_={object:$i.lazycreate},h;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(h||(h={}));var y_=(i,n={message:`Input not instance of ${i.name}`})=>MX((c)=>c instanceof i,n),VX=qn.create,mX=ac.create,s_=O8.create,d_=vc.create,KX=r4.create,r_=Tc.create,t_=D8.create,e_=t4.create,nf=e4.create,cf=gc.create,af=cc.create,vf=a1.create,xf=L8.create,pf=jn.create,wf=$i.create,Jf=$i.strictCreate,lf=i0.create,Qf=e6.create,Wf=n0.create,Yf=v1.create,Xf=_8.create,zf=f8.create,$f=hc.create,Gf=d4.create,Hf=c0.create,Mf=a0.create,Vf=xc.create,mf=v0.create,Kf=oc.create,Ff=un.create,Uf=bn.create,Bf=_1.create,Df=un.createWithPreprocess,Lf=A8.create,_f=()=>VX().optional(),ff=()=>mX().optional(),Of=()=>KX().optional(),Af={string:(i)=>qn.create({...i,coerce:!0}),number:(i)=>ac.create({...i,coerce:!0}),boolean:(i)=>r4.create({...i,coerce:!0}),bigint:(i)=>vc.create({...i,coerce:!0}),date:(i)=>Tc.create({...i,coerce:!0})};var Nf=g;var N8=Bi(require("fs")),pc=Bi(require("path")),N9=Bi(require("fs/promises"));hn();var Sn=Di("Downloader");class FX{op;assetsPath="";savePath="";setup(i){if(this.op=i,this.op.localPath)this.assetsPath=pc.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage(i,n){let{imgFormat:c}=this.op,a=this.assetsPath;try{if(!N8.default.existsSync(a))N8.default.mkdirSync(a,{recursive:!0});let v=`${n}.${c}`,x=pc.default.join(a,v),w=await o4(i);if(!w.ok)throw new Error(`下载失败: ${w.status} ${w.statusText}`);let J=await w.arrayBuffer();return N8.default.writeFileSync(x,new Uint8Array(J)),pc.default.join(pc.default.basename(a),v).replace(/\\/g,"/")}catch(v){throw Sn.error("图片下载错误:",v),v}}async downLoadImageAndReplaceContent(i){try{let n=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,c=i.match(n);if(!c)return i;let a=[...new Set(c)],v=new Map;await Promise.all(a.map(async(w)=>{let J=pc.default.basename(w),l=await this.downloadImage(w,J);v.set(w,l)}));let x=i;for(let[w,J]of v.entries()){let l=new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");x=x.replace(l,J)}return x}catch(n){throw Sn.error("内容处理错误:",n),n}}async checkLocalAndDownload(i){if(!this.op.localPath)return;await Promise.all(i.map(async(n)=>{n.content=await this.downLoadImageAndReplaceContent(n.content)}));for(let n of i)try{let c=await this.saveContentToFile(n.content,n.path);Sn.debug(`Successfully saved: ${c}`)}catch(c){Sn.error(`Failed to save file ${n.path}:`,c)}}async ensureDirectoryExists(i){if(!N8.default.existsSync(i))Sn.debug(`Creating directory: ${i}`),await N9.default.mkdir(i,{recursive:!0})}async saveContentToFile(i,n){try{let c=pc.default.join(this.savePath,n),a=pc.default.dirname(c);if(Sn.debug(`Full path: ${c}, directory: ${a}`),await this.ensureDirectoryExists(a),n.endsWith(".html"))Sn.debug("Wrapping content with HTML template"),i=this.wrapHtmlContent(i);return Sn.debug(`Writing ${i.length} bytes to file`),await N9.default.writeFile(c,i),Sn.info(`File saved: ${c}`),c}catch(c){throw Sn.error("File save error:",n,c),c}}wrapHtmlContent(i){return Sn.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
299
+ ]`;continue}if(v+=a[l],a[l]==="\\")x=!0;else if(w&&a[l]==="]")w=!1;else if(!w&&a[l]==="[")w=!0}try{new RegExp(v)}catch{return console.warn(`Could not convert regex pattern at ${n.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),i.source}return v}function j6(i,n){if(n.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(n.target==="openApi3"&&i.keyType?._def.typeName===O.ZodEnum)return{type:"object",required:i.keyType._def.values,properties:i.keyType._def.values.reduce((a,v)=>({...a,[v]:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"properties",v]})??{}}),{}),additionalProperties:n.rejectedAdditionalProperties};let c={type:"object",additionalProperties:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]})??n.allowedAdditionalProperties};if(n.target==="openApi3")return c;if(i.keyType?._def.typeName===O.ZodString&&i.keyType._def.checks?.length){let{type:a,...v}=q6(i.keyType._def,n);return{...c,propertyNames:v}}else if(i.keyType?._def.typeName===O.ZodEnum)return{...c,propertyNames:{enum:i.keyType._def.values}};else if(i.keyType?._def.typeName===O.ZodBranded&&i.keyType._def.type._def.typeName===O.ZodString&&i.keyType._def.type._def.checks?.length){let{type:a,...v}=R6(i.keyType._def,n);return{...c,propertyNames:v}}return c}function IW(i,n){if(n.mapStrategy==="record")return j6(i,n);let c=T(i.keyType._def,{...n,currentPath:[...n.currentPath,"items","items","0"]})||{},a=T(i.valueType._def,{...n,currentPath:[...n.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[c,a],minItems:2,maxItems:2}}}function CW(i){let n=i.values,a=Object.keys(i.values).filter((x)=>{return typeof n[n[x]]!=="number"}).map((x)=>n[x]),v=Array.from(new Set(a.map((x)=>typeof x)));return{type:v.length===1?v[0]==="string"?"string":"number":["string","number"],enum:a}}function kW(){return{not:{}}}function TW(i){return i.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var W8={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hW(i,n){if(n.target==="openApi3")return gW(i,n);let c=i.options instanceof Map?Array.from(i.options.values()):i.options;if(c.every((a)=>(a._def.typeName in W8)&&(!a._def.checks||!a._def.checks.length))){let a=c.reduce((v,x)=>{let w=W8[x._def.typeName];return w&&!v.includes(w)?[...v,w]:v},[]);return{type:a.length>1?a:a[0]}}else if(c.every((a)=>a._def.typeName==="ZodLiteral"&&!a.description)){let a=c.reduce((v,x)=>{let w=typeof x._def.value;switch(w){case"string":case"number":case"boolean":return[...v,w];case"bigint":return[...v,"integer"];case"object":if(x._def.value===null)return[...v,"null"];case"symbol":case"undefined":case"function":default:return v}},[]);if(a.length===c.length){let v=a.filter((x,w,J)=>J.indexOf(x)===w);return{type:v.length>1?v:v[0],enum:c.reduce((x,w)=>{return x.includes(w._def.value)?x:[...x,w._def.value]},[])}}}else if(c.every((a)=>a._def.typeName==="ZodEnum"))return{type:"string",enum:c.reduce((a,v)=>[...a,...v._def.values.filter((x)=>!a.includes(x))],[])};return gW(i,n)}var gW=(i,n)=>{let c=(i.options instanceof Map?Array.from(i.options.values()):i.options).map((a,v)=>T(a._def,{...n,currentPath:[...n.currentPath,"anyOf",`${v}`]})).filter((a)=>!!a&&(!n.strictUnions||typeof a==="object"&&Object.keys(a).length>0));return c.length?{anyOf:c}:void 0};function oW(i,n){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(i.innerType._def.typeName)&&(!i.innerType._def.checks||!i.innerType._def.checks.length)){if(n.target==="openApi3")return{type:W8[i.innerType._def.typeName],nullable:!0};return{type:[W8[i.innerType._def.typeName],"null"]}}if(n.target==="openApi3"){let a=T(i.innerType._def,{...n,currentPath:[...n.currentPath]});if(a&&"$ref"in a)return{allOf:[a],nullable:!0};return a&&{...a,nullable:!0}}let c=T(i.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","0"]});return c&&{anyOf:[c,{type:"null"}]}}function ZW(i,n){let c={type:"number"};if(!i.checks)return c;for(let a of i.checks)switch(a.kind){case"int":c.type="integer",J9(c,"type",a.message,n);break;case"min":if(n.target==="jsonSchema7")if(a.inclusive)xi(c,"minimum",a.value,a.message,n);else xi(c,"exclusiveMinimum",a.value,a.message,n);else{if(!a.inclusive)c.exclusiveMinimum=!0;xi(c,"minimum",a.value,a.message,n)}break;case"max":if(n.target==="jsonSchema7")if(a.inclusive)xi(c,"maximum",a.value,a.message,n);else xi(c,"exclusiveMaximum",a.value,a.message,n);else{if(!a.inclusive)c.exclusiveMaximum=!0;xi(c,"maximum",a.value,a.message,n)}break;case"multipleOf":xi(c,"multipleOf",a.value,a.message,n);break}return c}I1();function yW(i,n){let c=n.target==="openAi",a={type:"object",properties:{}},v=[],x=i.shape();for(let J in x){let l=x[J];if(l===void 0||l._def===void 0)continue;let W=CL(l);if(W&&c){if(l instanceof cn)l=l._def.innerType;if(!l.isNullable())l=l.nullable();W=!1}let Y=T(l._def,{...n,currentPath:[...n.currentPath,"properties",J],propertyPath:[...n.currentPath,"properties",J]});if(Y===void 0)continue;if(a.properties[J]=Y,!W)v.push(J)}if(v.length)a.required=v;let w=IL(i,n);if(w!==void 0)a.additionalProperties=w;return a}function IL(i,n){if(i.catchall._def.typeName!=="ZodNever")return T(i.catchall._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]});switch(i.unknownKeys){case"passthrough":return n.allowedAdditionalProperties;case"strict":return n.rejectedAdditionalProperties;case"strip":return n.removeAdditionalStrategy==="strict"?n.allowedAdditionalProperties:n.rejectedAdditionalProperties}}function CL(i){try{return i.isOptional()}catch{return!0}}var sW=(i,n)=>{if(n.currentPath.toString()===n.propertyPath?.toString())return T(i.innerType._def,n);let c=T(i.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","1"]});return c?{anyOf:[{not:{}},c]}:{}};var dW=(i,n)=>{if(n.pipeStrategy==="input")return T(i.in._def,n);else if(n.pipeStrategy==="output")return T(i.out._def,n);let c=T(i.in._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),a=T(i.out._def,{...n,currentPath:[...n.currentPath,"allOf",c?"1":"0"]});return{allOf:[c,a].filter((v)=>v!==void 0)}};function rW(i,n){return T(i.type._def,n)}function tW(i,n){let a={type:"array",uniqueItems:!0,items:T(i.valueType._def,{...n,currentPath:[...n.currentPath,"items"]})};if(i.minSize)xi(a,"minItems",i.minSize.value,i.minSize.message,n);if(i.maxSize)xi(a,"maxItems",i.maxSize.value,i.maxSize.message,n);return a}function eW(i,n){if(i.rest)return{type:"array",minItems:i.items.length,items:i.items.map((c,a)=>T(c._def,{...n,currentPath:[...n.currentPath,"items",`${a}`]})).reduce((c,a)=>a===void 0?c:[...c,a],[]),additionalItems:T(i.rest._def,{...n,currentPath:[...n.currentPath,"additionalItems"]})};else return{type:"array",minItems:i.items.length,maxItems:i.items.length,items:i.items.map((c,a)=>T(c._def,{...n,currentPath:[...n.currentPath,"items",`${a}`]})).reduce((c,a)=>a===void 0?c:[...c,a],[])}}function iY(){return{not:{}}}function nY(){return{}}var cY=(i,n)=>{return T(i.innerType._def,n)};var aY=(i,n,c)=>{switch(n){case O.ZodString:return q6(i,c);case O.ZodNumber:return ZW(i,c);case O.ZodObject:return yW(i,c);case O.ZodBigInt:return NW(i,c);case O.ZodBoolean:return RW();case O.ZodDate:return l9(i,c);case O.ZodUndefined:return iY();case O.ZodNull:return TW(c);case O.ZodArray:return AW(i,c);case O.ZodUnion:case O.ZodDiscriminatedUnion:return hW(i,c);case O.ZodIntersection:return uW(i,c);case O.ZodTuple:return eW(i,c);case O.ZodRecord:return j6(i,c);case O.ZodLiteral:return SW(i,c);case O.ZodEnum:return EW(i);case O.ZodNativeEnum:return CW(i);case O.ZodNullable:return oW(i,c);case O.ZodOptional:return sW(i,c);case O.ZodMap:return IW(i,c);case O.ZodSet:return tW(i,c);case O.ZodLazy:return()=>i.getter()._def;case O.ZodPromise:return rW(i,c);case O.ZodNaN:case O.ZodNever:return kW();case O.ZodEffects:return bW(i,c);case O.ZodAny:return OW();case O.ZodUnknown:return nY();case O.ZodDefault:return jW(i,c);case O.ZodBranded:return R6(i,c);case O.ZodReadonly:return cY(i,c);case O.ZodCatch:return qW(i,c);case O.ZodPipeline:return dW(i,c);case O.ZodFunction:case O.ZodVoid:case O.ZodSymbol:return;default:return((a)=>{return})(n)}};function T(i,n,c=!1){let a=n.seen.get(i);if(n.override){let J=n.override?.(i,n,a,c);if(J!==LW)return J}if(a&&!c){let J=kL(a,n);if(J!==void 0)return J}let v={def:i,path:n.currentPath,jsonSchema:void 0};n.seen.set(i,v);let x=aY(i,i.typeName,n),w=typeof x==="function"?T(x(),n):x;if(w)gL(i,n,w);if(n.postProcess){let J=n.postProcess(w,i,n);return v.jsonSchema=w,J}return v.jsonSchema=w,w}var kL=(i,n)=>{switch(n.$refStrategy){case"root":return{$ref:i.path.join("/")};case"relative":return{$ref:TL(n.currentPath,i.path)};case"none":case"seen":{if(i.path.length<n.currentPath.length&&i.path.every((c,a)=>n.currentPath[a]===c))return console.warn(`Recursive reference detected at ${n.currentPath.join("/")}! Defaulting to any`),{};return n.$refStrategy==="seen"?{}:void 0}}},TL=(i,n)=>{let c=0;for(;c<i.length&&c<n.length;c++)if(i[c]!==n[c])break;return[(i.length-c).toString(),...n.slice(c)].join("/")},gL=(i,n,c)=>{if(i.description){if(c.description=i.description,n.markdownDescription)c.markdownDescription=i.description}return c};var b6=(i,n)=>{let c=fW(n),a=typeof n==="object"&&n.definitions?Object.entries(n.definitions).reduce((l,[W,Y])=>({...l,[W]:T(Y._def,{...c,currentPath:[...c.basePath,c.definitionPath,W]},!0)??{}}),{}):void 0,v=typeof n==="string"?n:n?.nameStrategy==="title"?void 0:n?.name,x=T(i._def,v===void 0?c:{...c,currentPath:[...c.basePath,c.definitionPath,v]},!1)??{},w=typeof n==="object"&&n.name!==void 0&&n.nameStrategy==="title"?n.name:void 0;if(w!==void 0)x.title=w;let J=v===void 0?a?{...x,[c.definitionPath]:a}:x:{$ref:[...c.$refStrategy==="relative"?[]:c.basePath,c.definitionPath,v].join("/"),[c.definitionPath]:{...a,[v]:x}};if(c.target==="jsonSchema7")J.$schema="http://json-schema.org/draft-07/schema#";else if(c.target==="jsonSchema2019-09"||c.target==="openAi")J.$schema="https://json-schema.org/draft/2019-09/schema#";if(c.target==="openAi"&&(("anyOf"in J)||("oneOf"in J)||("allOf"in J)||("type"in J)&&Array.isArray(J.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return J};I1();C1();I1();var Y9;(function(i){i.Completable="McpCompletable"})(Y9||(Y9={}));class Y8 extends s{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;return this._def.type._parse({data:c,path:n.path,parent:n})}unwrap(){return this._def.type}}Y8.create=(i,n)=>{return new Y8({type:i,typeName:Y9.Completable,complete:n.complete,...hL(n)})};function hL(i){if(!i)return{};let{errorMap:n,invalid_type_error:c,required_error:a,description:v}=i;if(n&&(c||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:v};return{errorMap:(w,J)=>{var l,W;let{message:Y}=i;if(w.code==="invalid_enum_value")return{message:Y!==null&&Y!==void 0?Y:J.defaultError};if(typeof J.data==="undefined")return{message:(l=Y!==null&&Y!==void 0?Y:a)!==null&&l!==void 0?l:J.defaultError};if(w.code!=="invalid_type")return{message:J.defaultError};return{message:(W=Y!==null&&Y!==void 0?Y:c)!==null&&W!==void 0?W:J.defaultError}},description:v}}class X9{constructor(i,n){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new w9(i,n)}async connect(i){return await this.server.connect(i)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(_a.shape.method.value),this.server.assertCanSetRequestHandler(fa.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(_a,()=>({tools:Object.entries(this._registeredTools).filter(([,i])=>i.enabled).map(([i,n])=>{let c={name:i,description:n.description,inputSchema:n.inputSchema?b6(n.inputSchema,{strictUnions:!0}):oL,annotations:n.annotations};if(n.outputSchema)c.outputSchema=b6(n.outputSchema,{strictUnions:!0});return c})})),this.server.setRequestHandler(fa,async(i,n)=>{let c=this._registeredTools[i.params.name];if(!c)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} disabled`);let a;if(c.inputSchema){let v=await c.inputSchema.safeParseAsync(i.params.arguments);if(!v.success)throw new Vi(Xi.InvalidParams,`Invalid arguments for tool ${i.params.name}: ${v.error.message}`);let x=v.data,w=c.callback;try{a=await Promise.resolve(w(x,n))}catch(J){a={content:[{type:"text",text:J instanceof Error?J.message:String(J)}],isError:!0}}}else{let v=c.callback;try{a=await Promise.resolve(v(n))}catch(x){a={content:[{type:"text",text:x instanceof Error?x.message:String(x)}],isError:!0}}}if(c.outputSchema){if(!a.structuredContent)throw new Vi(Xi.InvalidParams,`Tool ${i.params.name} has an output schema but no structured content was provided`);let v=await c.outputSchema.safeParseAsync(a.structuredContent);if(!v.success)throw new Vi(Xi.InvalidParams,`Invalid structured content for tool ${i.params.name}: ${v.error.message}`)}return a}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(Oa.shape.method.value),this.server.setRequestHandler(Oa,async(i)=>{switch(i.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(i,i.params.ref);case"ref/resource":return this.handleResourceCompletion(i,i.params.ref);default:throw new Vi(Xi.InvalidParams,`Invalid completion reference: ${i.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(i,n){let c=this._registeredPrompts[n.name];if(!c)throw new Vi(Xi.InvalidParams,`Prompt ${n.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Prompt ${n.name} disabled`);if(!c.argsSchema)return E6;let a=c.argsSchema.shape[i.params.argument.name];if(!(a instanceof Y8))return E6;let x=await a._def.complete(i.params.argument.value);return xY(x)}async handleResourceCompletion(i,n){let c=Object.values(this._registeredResourceTemplates).find((x)=>x.resourceTemplate.uriTemplate.toString()===n.uri);if(!c){if(this._registeredResources[n.uri])return E6;throw new Vi(Xi.InvalidParams,`Resource template ${i.params.ref.uri} not found`)}let a=c.resourceTemplate.completeCallback(i.params.argument.name);if(!a)return E6;let v=await a(i.params.argument.value);return xY(v)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(Va.shape.method.value),this.server.assertCanSetRequestHandler(ma.shape.method.value),this.server.assertCanSetRequestHandler(Ka.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Va,async(i,n)=>{let c=Object.entries(this._registeredResources).filter(([v,x])=>x.enabled).map(([v,x])=>({uri:v,name:x.name,...x.metadata})),a=[];for(let v of Object.values(this._registeredResourceTemplates)){if(!v.resourceTemplate.listCallback)continue;let x=await v.resourceTemplate.listCallback(n);for(let w of x.resources)a.push({...w,...v.metadata})}return{resources:[...c,...a]}}),this.server.setRequestHandler(ma,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([n,c])=>({name:n,uriTemplate:c.resourceTemplate.uriTemplate.toString(),...c.metadata}))}}),this.server.setRequestHandler(Ka,async(i,n)=>{let c=new URL(i.params.uri),a=this._registeredResources[c.toString()];if(a){if(!a.enabled)throw new Vi(Xi.InvalidParams,`Resource ${c} disabled`);return a.readCallback(c,n)}for(let v of Object.values(this._registeredResourceTemplates)){let x=v.resourceTemplate.uriTemplate.match(c.toString());if(x)return v.readCallback(c,x,n)}throw new Vi(Xi.InvalidParams,`Resource ${c} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(Fa.shape.method.value),this.server.assertCanSetRequestHandler(Ua.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Fa,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,i])=>i.enabled).map(([i,n])=>{return{name:i,description:n.description,arguments:n.argsSchema?yL(n.argsSchema):void 0}})})),this.server.setRequestHandler(Ua,async(i,n)=>{let c=this._registeredPrompts[i.params.name];if(!c)throw new Vi(Xi.InvalidParams,`Prompt ${i.params.name} not found`);if(!c.enabled)throw new Vi(Xi.InvalidParams,`Prompt ${i.params.name} disabled`);if(c.argsSchema){let a=await c.argsSchema.safeParseAsync(i.params.arguments);if(!a.success)throw new Vi(Xi.InvalidParams,`Invalid arguments for prompt ${i.params.name}: ${a.error.message}`);let v=a.data,x=c.callback;return await Promise.resolve(x(v,n))}else{let a=c.callback;return await Promise.resolve(a(n))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource(i,n,...c){let a;if(typeof c[0]==="object")a=c.shift();let v=c[0];if(typeof n==="string"){if(this._registeredResources[n])throw new Error(`Resource ${n} is already registered`);let x={name:i,metadata:a,readCallback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({uri:null}),update:(w)=>{if(typeof w.uri!=="undefined"&&w.uri!==n){if(delete this._registeredResources[n],w.uri)this._registeredResources[w.uri]=x}if(typeof w.name!=="undefined")x.name=w.name;if(typeof w.metadata!=="undefined")x.metadata=w.metadata;if(typeof w.callback!=="undefined")x.readCallback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResources[n]=x,this.setResourceRequestHandlers(),this.sendResourceListChanged(),x}else{if(this._registeredResourceTemplates[i])throw new Error(`Resource template ${i} is already registered`);let x={resourceTemplate:n,metadata:a,readCallback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==i){if(delete this._registeredResourceTemplates[i],w.name)this._registeredResourceTemplates[w.name]=x}if(typeof w.template!=="undefined")x.resourceTemplate=w.template;if(typeof w.metadata!=="undefined")x.metadata=w.metadata;if(typeof w.callback!=="undefined")x.readCallback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[i]=x,this.setResourceRequestHandlers(),this.sendResourceListChanged(),x}}_createRegisteredTool(i,n,c,a,v,x){let w={description:n,inputSchema:c===void 0?void 0:G.object(c),outputSchema:a===void 0?void 0:G.object(a),annotations:v,callback:x,enabled:!0,disable:()=>w.update({enabled:!1}),enable:()=>w.update({enabled:!0}),remove:()=>w.update({name:null}),update:(J)=>{if(typeof J.name!=="undefined"&&J.name!==i){if(delete this._registeredTools[i],J.name)this._registeredTools[J.name]=w}if(typeof J.description!=="undefined")w.description=J.description;if(typeof J.paramsSchema!=="undefined")w.inputSchema=G.object(J.paramsSchema);if(typeof J.callback!=="undefined")w.callback=J.callback;if(typeof J.annotations!=="undefined")w.annotations=J.annotations;if(typeof J.enabled!=="undefined")w.enabled=J.enabled;this.sendToolListChanged()}};return this._registeredTools[i]=w,this.setToolRequestHandlers(),this.sendToolListChanged(),w}tool(i,...n){if(this._registeredTools[i])throw new Error(`Tool ${i} is already registered`);let c,a,v,x;if(typeof n[0]==="string")c=n.shift();if(n.length>1){let J=n[0];if(vY(J)){if(a=n.shift(),n.length>1&&typeof n[0]==="object"&&n[0]!==null&&!vY(n[0]))x=n.shift()}else if(typeof J==="object"&&J!==null)x=n.shift()}let w=n[0];return this._createRegisteredTool(i,c,a,v,x,w)}registerTool(i,n,c){if(this._registeredTools[i])throw new Error(`Tool ${i} is already registered`);let{description:a,inputSchema:v,outputSchema:x,annotations:w}=n;return this._createRegisteredTool(i,a,v,x,w,c)}prompt(i,...n){if(this._registeredPrompts[i])throw new Error(`Prompt ${i} is already registered`);let c;if(typeof n[0]==="string")c=n.shift();let a;if(n.length>1)a=n.shift();let v=n[0],x={description:c,argsSchema:a===void 0?void 0:G.object(a),callback:v,enabled:!0,disable:()=>x.update({enabled:!1}),enable:()=>x.update({enabled:!0}),remove:()=>x.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==i){if(delete this._registeredPrompts[i],w.name)this._registeredPrompts[w.name]=x}if(typeof w.description!=="undefined")x.description=w.description;if(typeof w.argsSchema!=="undefined")x.argsSchema=G.object(w.argsSchema);if(typeof w.callback!=="undefined")x.callback=w.callback;if(typeof w.enabled!=="undefined")x.enabled=w.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[i]=x,this.setPromptRequestHandlers(),this.sendPromptListChanged(),x}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 oL={type:"object"};function vY(i){if(typeof i!=="object"||i===null)return!1;return Object.keys(i).length===0||Object.values(i).some(ZL)}function ZL(i){return i!==null&&typeof i==="object"&&"parse"in i&&typeof i.parse==="function"&&"safeParse"in i&&typeof i.safeParse==="function"}function yL(i){return Object.entries(i.shape).map(([n,c])=>({name:n,description:c.description,required:!c.isOptional()}))}function xY(i){return{completion:{values:i.slice(0,100),total:i.length,hasMore:i.length>100}}}var E6={completion:{values:[],hasMore:!1}};function pY(i,n){let c=process.argv,a=`--${i}=`;for(let v of c)if(v.startsWith(a))return v.substring(a.length);return n}hn();var sL=Di("FigmaConfig",1),X8=pY("figma-api-key")||process.env.FIGMA_API_KEY||process.env.personalToken||"",wY="F2C MCP",JY=process.env.FIGMA_VERSION||"0.0.1";sL.debug("DEFAULT_PERSONAL_TOKEN",X8);var lY=(i)=>{};var QY=(i)=>{lY(i)};var _9=null;async function M_(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!_9)try{_9=await Promise.resolve().then(() => (vX(),aX))}catch(i){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return _9.default}async function V_(i,n){return(await M_())(i,n)}var o4=V_;hn();var xX=Di("F2cApi",1);class pX{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=X8;async nodeToCode(i){let n={fileKey:i.fileKey,nodeIds:i.ids,personal_token:i.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:i.imgFormat||"png",scaleSize:i.scaleSize||2},format:"files"};if(i.format==="react-cssmodules")n.option.cssFramework="cssmodules";else if(i.format==="react-tailwind")n.option.cssFramework="tailwindcss";let c=this.opToUrl(`${this.f2cHost}/nodes`,n);return this.fetch(c,"json")}async fetch(i,n="json"){try{let c={method:"GET",headers:{"F2c-Api-Platform":"mcp"}};xX.debug("fetch",i);let a=await o4(i,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return n==="text"?await a.text():await a.json()}catch(c){throw xX.error("HTTP error",c),c}}opToUrl(i,n={}){if(Object.keys(n).length===0)return i;let c=new URL(i);for(let[a,v]of Object.entries(n))if(typeof v==="object"&&v!==null)for(let[x,w]of Object.entries(v))c.searchParams.append(`${a}[${x}]`,w);else c.searchParams.append(a,v);return c.toString()}}var wX=new pX;hn();var m_=Di("FigmaRestApi");class JX{figmaHost="https://api.figma.com/v1";personalToken=X8;async files(i){let n;if(i.ids)n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/nodes`,i);else n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}`,i);return this.fetch(n)}async images(i){let n=this.opToUrl(`${this.figmaHost}/images/${i.fileKey}`,i);return this.fetch(n)}async imageFills(i){let n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/images`,i);return this.fetch(n)}async meta(i){let n=this.opToUrl(`${this.figmaHost}/files/${i.fileKey}/meta`,i);return this.fetch(n)}async fetch(i,n="json"){try{let c={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},a=await o4(i,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return n==="text"?await a.text():await a.json()}catch(c){throw m_.error("HTTP error",c),c}}opToUrl(i,n={},c=["fileKey","personalToken"]){if(Object.keys(n).length===0)return i;if(n.personalToken)this.personalToken=n.personalToken;let a=new URL(i);for(let[v,x]of Object.entries(n))if(!c.includes(v))a.searchParams.append(v,x);return a.toString()}}var lX=new JX;hn();var Ai={};x4(Ai,{void:()=>xf,util:()=>ai,unknown:()=>af,union:()=>lf,undefined:()=>e_,tuple:()=>Yf,transformer:()=>Ff,symbol:()=>t_,string:()=>VX,strictObject:()=>Jf,setErrorMap:()=>U_,set:()=>$f,record:()=>Xf,quotelessJson:()=>K_,promise:()=>Kf,preprocess:()=>Df,pipeline:()=>Lf,ostring:()=>_f,optional:()=>Uf,onumber:()=>ff,oboolean:()=>Of,objectUtil:()=>f9,object:()=>wf,number:()=>mX,nullable:()=>Bf,null:()=>nf,never:()=>vf,nativeEnum:()=>mf,nan:()=>s_,map:()=>zf,makeIssue:()=>F8,literal:()=>Mf,lazy:()=>Hf,late:()=>Z_,isValid:()=>nc,isDirty:()=>r6,isAsync:()=>y4,isAborted:()=>d6,intersection:()=>Wf,instanceof:()=>y_,getParsedType:()=>c1,getErrorMap:()=>Z4,function:()=>Gf,enum:()=>Vf,effect:()=>Ff,discriminatedUnion:()=>Qf,defaultErrorMap:()=>D1,datetimeRegex:()=>GX,date:()=>r_,custom:()=>MX,coerce:()=>Af,boolean:()=>KX,bigint:()=>d_,array:()=>pf,any:()=>cf,addIssueToContext:()=>R,ZodVoid:()=>L8,ZodUnknown:()=>cc,ZodUnion:()=>i0,ZodUndefined:()=>t4,ZodType:()=>ii,ZodTuple:()=>v1,ZodTransformer:()=>un,ZodSymbol:()=>D8,ZodString:()=>qn,ZodSet:()=>hc,ZodSchema:()=>ii,ZodRecord:()=>_8,ZodReadonly:()=>w0,ZodPromise:()=>oc,ZodPipeline:()=>A8,ZodParsedType:()=>N,ZodOptional:()=>bn,ZodObject:()=>$i,ZodNumber:()=>ac,ZodNullable:()=>_1,ZodNull:()=>e4,ZodNever:()=>a1,ZodNativeEnum:()=>v0,ZodNaN:()=>O8,ZodMap:()=>f8,ZodLiteral:()=>a0,ZodLazy:()=>c0,ZodIssueCode:()=>L,ZodIntersection:()=>n0,ZodFunction:()=>d4,ZodFirstPartyTypeKind:()=>h,ZodError:()=>di,ZodEnum:()=>xc,ZodEffects:()=>un,ZodDiscriminatedUnion:()=>e6,ZodDefault:()=>x0,ZodDate:()=>Tc,ZodCatch:()=>p0,ZodBranded:()=>i2,ZodBoolean:()=>r4,ZodBigInt:()=>vc,ZodArray:()=>jn,ZodAny:()=>gc,Schema:()=>ii,ParseStatus:()=>Ei,OK:()=>Pi,NEVER:()=>Nf,INVALID:()=>g,EMPTY_PATH:()=>B_,DIRTY:()=>kc,BRAND:()=>o_});var ai;(function(i){i.assertEqual=(v)=>{};function n(v){}i.assertIs=n;function c(v){throw new Error}i.assertNever=c,i.arrayToEnum=(v)=>{let x={};for(let w of v)x[w]=w;return x},i.getValidEnumValues=(v)=>{let x=i.objectKeys(v).filter((J)=>typeof v[v[J]]!=="number"),w={};for(let J of x)w[J]=v[J];return i.objectValues(w)},i.objectValues=(v)=>{return i.objectKeys(v).map(function(x){return v[x]})},i.objectKeys=typeof Object.keys==="function"?(v)=>Object.keys(v):(v)=>{let x=[];for(let w in v)if(Object.prototype.hasOwnProperty.call(v,w))x.push(w);return x},i.find=(v,x)=>{for(let w of v)if(x(w))return w;return},i.isInteger=typeof Number.isInteger==="function"?(v)=>Number.isInteger(v):(v)=>typeof v==="number"&&Number.isFinite(v)&&Math.floor(v)===v;function a(v,x=" | "){return v.map((w)=>typeof w==="string"?`'${w}'`:w).join(x)}i.joinValues=a,i.jsonStringifyReplacer=(v,x)=>{if(typeof x==="bigint")return x.toString();return x}})(ai||(ai={}));var f9;(function(i){i.mergeShapes=(n,c)=>{return{...n,...c}}})(f9||(f9={}));var N=ai.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),c1=(i)=>{switch(typeof i){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(i)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":if(Array.isArray(i))return N.array;if(i===null)return N.null;if(i.then&&typeof i.then==="function"&&i.catch&&typeof i.catch==="function")return N.promise;if(typeof Map!=="undefined"&&i instanceof Map)return N.map;if(typeof Set!=="undefined"&&i instanceof Set)return N.set;if(typeof Date!=="undefined"&&i instanceof Date)return N.date;return N.object;default:return N.unknown}};var L=ai.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"]),K_=(i)=>{return JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:")};class di extends Error{get errors(){return this.issues}constructor(i){super();this.issues=[],this.addIssue=(c)=>{this.issues=[...this.issues,c]},this.addIssues=(c=[])=>{this.issues=[...this.issues,...c]};let n=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,n);else this.__proto__=n;this.name="ZodError",this.issues=i}format(i){let n=i||function(v){return v.message},c={_errors:[]},a=(v)=>{for(let x of v.issues)if(x.code==="invalid_union")x.unionErrors.map(a);else if(x.code==="invalid_return_type")a(x.returnTypeError);else if(x.code==="invalid_arguments")a(x.argumentsError);else if(x.path.length===0)c._errors.push(n(x));else{let w=c,J=0;while(J<x.path.length){let l=x.path[J];if(J!==x.path.length-1)w[l]=w[l]||{_errors:[]};else w[l]=w[l]||{_errors:[]},w[l]._errors.push(n(x));w=w[l],J++}}};return a(this),c}static assert(i){if(!(i instanceof di))throw new Error(`Not a ZodError: ${i}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ai.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(i=(n)=>n.message){let n={},c=[];for(let a of this.issues)if(a.path.length>0)n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(i(a));else c.push(i(a));return{formErrors:c,fieldErrors:n}}get formErrors(){return this.flatten()}}di.create=(i)=>{return new di(i)};var F_=(i,n)=>{let c;switch(i.code){case L.invalid_type:if(i.received===N.undefined)c="Required";else c=`Expected ${i.expected}, received ${i.received}`;break;case L.invalid_literal:c=`Invalid literal value, expected ${JSON.stringify(i.expected,ai.jsonStringifyReplacer)}`;break;case L.unrecognized_keys:c=`Unrecognized key(s) in object: ${ai.joinValues(i.keys,", ")}`;break;case L.invalid_union:c="Invalid input";break;case L.invalid_union_discriminator:c=`Invalid discriminator value. Expected ${ai.joinValues(i.options)}`;break;case L.invalid_enum_value:c=`Invalid enum value. Expected ${ai.joinValues(i.options)}, received '${i.received}'`;break;case L.invalid_arguments:c="Invalid function arguments";break;case L.invalid_return_type:c="Invalid function return type";break;case L.invalid_date:c="Invalid date";break;case L.invalid_string:if(typeof i.validation==="object")if("includes"in i.validation){if(c=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position==="number")c=`${c} at one or more positions greater than or equal to ${i.validation.position}`}else if("startsWith"in i.validation)c=`Invalid input: must start with "${i.validation.startsWith}"`;else if("endsWith"in i.validation)c=`Invalid input: must end with "${i.validation.endsWith}"`;else ai.assertNever(i.validation);else if(i.validation!=="regex")c=`Invalid ${i.validation}`;else c="Invalid";break;case L.too_small:if(i.type==="array")c=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`;else if(i.type==="string")c=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`;else if(i.type==="number")c=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`;else if(i.type==="date")c=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`;else c="Invalid input";break;case L.too_big:if(i.type==="array")c=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`;else if(i.type==="string")c=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`;else if(i.type==="number")c=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`;else if(i.type==="bigint")c=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`;else if(i.type==="date")c=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`;else c="Invalid input";break;case L.custom:c="Invalid input";break;case L.invalid_intersection_types:c="Intersection results could not be merged";break;case L.not_multiple_of:c=`Number must be a multiple of ${i.multipleOf}`;break;case L.not_finite:c="Number must be finite";break;default:c=n.defaultError,ai.assertNever(i)}return{message:c}},D1=F_;var QX=D1;function U_(i){QX=i}function Z4(){return QX}var F8=(i)=>{let{data:n,path:c,errorMaps:a,issueData:v}=i,x=[...c,...v.path||[]],w={...v,path:x};if(v.message!==void 0)return{...v,path:x,message:v.message};let J="",l=a.filter((W)=>!!W).slice().reverse();for(let W of l)J=W(w,{data:n,defaultError:J}).message;return{...v,path:x,message:J}},B_=[];function R(i,n){let c=Z4(),a=F8({issueData:n,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,c,c===D1?void 0:D1].filter((v)=>!!v)});i.common.issues.push(a)}class Ei{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(i,n){let c=[];for(let a of n){if(a.status==="aborted")return g;if(a.status==="dirty")i.dirty();c.push(a.value)}return{status:i.value,value:c}}static async mergeObjectAsync(i,n){let c=[];for(let a of n){let v=await a.key,x=await a.value;c.push({key:v,value:x})}return Ei.mergeObjectSync(i,c)}static mergeObjectSync(i,n){let c={};for(let a of n){let{key:v,value:x}=a;if(v.status==="aborted")return g;if(x.status==="aborted")return g;if(v.status==="dirty")i.dirty();if(x.status==="dirty")i.dirty();if(v.value!=="__proto__"&&(typeof x.value!=="undefined"||a.alwaysSet))c[v.value]=x.value}return{status:i.value,value:c}}}var g=Object.freeze({status:"aborted"}),kc=(i)=>({status:"dirty",value:i}),Pi=(i)=>({status:"valid",value:i}),d6=(i)=>i.status==="aborted",r6=(i)=>i.status==="dirty",nc=(i)=>i.status==="valid",y4=(i)=>typeof Promise!=="undefined"&&i instanceof Promise;var S;(function(i){i.errToObj=(n)=>typeof n==="string"?{message:n}:n||{},i.toString=(n)=>typeof n==="string"?n:n?.message})(S||(S={}));var t6=function(i,n,c,a){if(c==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof n==="function"?i!==n||!a:!n.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?a:c==="a"?a.call(i):a?a.value:n.get(i)},XX=function(i,n,c,a,v){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!v)throw new TypeError("Private accessor was defined without a setter");if(typeof n==="function"?i!==n||!v:!n.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?v.call(i,c):v?v.value=c:n.set(i,c),c},U8,B8;class En{constructor(i,n,c,a){this._cachedPath=[],this.parent=i,this.data=n,this._path=c,this._key=a}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 WX=(i,n)=>{if(nc(n))return{success:!0,data:n.value};else{if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let c=new di(i.common.issues);return this._error=c,this._error}}}};function t(i){if(!i)return{};let{errorMap:n,invalid_type_error:c,required_error:a,description:v}=i;if(n&&(c||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:v};return{errorMap:(w,J)=>{let{message:l}=i;if(w.code==="invalid_enum_value")return{message:l??J.defaultError};if(typeof J.data==="undefined")return{message:l??a??J.defaultError};if(w.code!=="invalid_type")return{message:J.defaultError};return{message:l??c??J.defaultError}},description:v}}class ii{get description(){return this._def.description}_getType(i){return c1(i.data)}_getOrReturnCtx(i,n){return n||{common:i.parent.common,data:i.data,parsedType:c1(i.data),schemaErrorMap:this._def.errorMap,path:i.path,parent:i.parent}}_processInputParams(i){return{status:new Ei,ctx:{common:i.parent.common,data:i.data,parsedType:c1(i.data),schemaErrorMap:this._def.errorMap,path:i.path,parent:i.parent}}}_parseSync(i){let n=this._parse(i);if(y4(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(i){let n=this._parse(i);return Promise.resolve(n)}parse(i,n){let c=this.safeParse(i,n);if(c.success)return c.data;throw c.error}safeParse(i,n){let c={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)},a=this._parseSync({data:i,path:c.path,parent:c});return WX(c,a)}"~validate"(i){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)};if(!this["~standard"].async)try{let c=this._parseSync({data:i,path:[],parent:n});return nc(c)?{value:c.value}:{issues:n.common.issues}}catch(c){if(c?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;n.common={issues:[],async:!0}}return this._parseAsync({data:i,path:[],parent:n}).then((c)=>nc(c)?{value:c.value}:{issues:n.common.issues})}async parseAsync(i,n){let c=await this.safeParseAsync(i,n);if(c.success)return c.data;throw c.error}async safeParseAsync(i,n){let c={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:i,parsedType:c1(i)},a=this._parse({data:i,path:c.path,parent:c}),v=await(y4(a)?a:Promise.resolve(a));return WX(c,v)}refine(i,n){let c=(a)=>{if(typeof n==="string"||typeof n==="undefined")return{message:n};else if(typeof n==="function")return n(a);else return n};return this._refinement((a,v)=>{let x=i(a),w=()=>v.addIssue({code:L.custom,...c(a)});if(typeof Promise!=="undefined"&&x instanceof Promise)return x.then((J)=>{if(!J)return w(),!1;else return!0});if(!x)return w(),!1;else return!0})}refinement(i,n){return this._refinement((c,a)=>{if(!i(c))return a.addIssue(typeof n==="function"?n(c,a):n),!1;else return!0})}_refinement(i){return new un({schema:this,typeName:h.ZodEffects,effect:{type:"refinement",refinement:i}})}superRefine(i){return this._refinement(i)}constructor(i){this.spa=this.safeParseAsync,this._def=i,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:(n)=>this["~validate"](n)}}optional(){return bn.create(this,this._def)}nullable(){return _1.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jn.create(this)}promise(){return oc.create(this,this._def)}or(i){return i0.create([this,i],this._def)}and(i){return n0.create(this,i,this._def)}transform(i){return new un({...t(this._def),schema:this,typeName:h.ZodEffects,effect:{type:"transform",transform:i}})}default(i){let n=typeof i==="function"?i:()=>i;return new x0({...t(this._def),innerType:this,defaultValue:n,typeName:h.ZodDefault})}brand(){return new i2({typeName:h.ZodBranded,type:this,...t(this._def)})}catch(i){let n=typeof i==="function"?i:()=>i;return new p0({...t(this._def),innerType:this,catchValue:n,typeName:h.ZodCatch})}describe(i){return new this.constructor({...this._def,description:i})}pipe(i){return A8.create(this,i)}readonly(){return w0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var D_=/^c[^\s-]{8,}$/i,L_=/^[0-9a-z]+$/,__=/^[0-9A-HJKMNP-TV-Z]{26}$/i,f_=/^[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,O_=/^[a-z0-9_-]{21}$/i,A_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,N_=/^[-+]?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)?)??$/,R_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,q_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",O9,j_=/^(?:(?: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])$/,b_=/^(?:(?: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])$/,E_=/^(([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]))$/,u_=/^(([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])$/,S_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zX="((\\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])))",I_=new RegExp(`^${zX}$`);function $X(i){let n="[0-5]\\d";if(i.precision)n=`${n}\\.\\d{${i.precision}}`;else if(i.precision==null)n=`${n}(\\.\\d+)?`;let c=i.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${c}`}function C_(i){return new RegExp(`^${$X(i)}$`)}function GX(i){let n=`${zX}T${$X(i)}`,c=[];if(c.push(i.local?"Z?":"Z"),i.offset)c.push("([+-]\\d{2}:?\\d{2})");return n=`${n}(${c.join("|")})`,new RegExp(`^${n}$`)}function k_(i,n){if((n==="v4"||!n)&&j_.test(i))return!0;if((n==="v6"||!n)&&E_.test(i))return!0;return!1}function T_(i,n){if(!A_.test(i))return!1;try{let[c]=i.split("."),a=c.replace(/-/g,"+").replace(/_/g,"/").padEnd(c.length+(4-c.length%4)%4,"="),v=JSON.parse(atob(a));if(typeof v!=="object"||v===null)return!1;if("typ"in v&&v?.typ!=="JWT")return!1;if(!v.alg)return!1;if(n&&v.alg!==n)return!1;return!0}catch{return!1}}function g_(i,n){if((n==="v4"||!n)&&b_.test(i))return!0;if((n==="v6"||!n)&&u_.test(i))return!0;return!1}class qn extends ii{_parse(i){if(this._def.coerce)i.data=String(i.data);if(this._getType(i)!==N.string){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.string,received:v.parsedType}),g}let c=new Ei,a=void 0;for(let v of this._def.checks)if(v.kind==="min"){if(i.data.length<v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_small,minimum:v.value,type:"string",inclusive:!0,exact:!1,message:v.message}),c.dirty()}else if(v.kind==="max"){if(i.data.length>v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_big,maximum:v.value,type:"string",inclusive:!0,exact:!1,message:v.message}),c.dirty()}else if(v.kind==="length"){let x=i.data.length>v.value,w=i.data.length<v.value;if(x||w){if(a=this._getOrReturnCtx(i,a),x)R(a,{code:L.too_big,maximum:v.value,type:"string",inclusive:!0,exact:!0,message:v.message});else if(w)R(a,{code:L.too_small,minimum:v.value,type:"string",inclusive:!0,exact:!0,message:v.message});c.dirty()}}else if(v.kind==="email"){if(!R_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"email",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="emoji"){if(!O9)O9=new RegExp(q_,"u");if(!O9.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"emoji",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="uuid"){if(!f_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"uuid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="nanoid"){if(!O_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"nanoid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cuid"){if(!D_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"cuid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cuid2"){if(!L_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"cuid2",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="ulid"){if(!__.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"ulid",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="url")try{new URL(i.data)}catch{a=this._getOrReturnCtx(i,a),R(a,{validation:"url",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="regex"){if(v.regex.lastIndex=0,!v.regex.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"regex",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="trim")i.data=i.data.trim();else if(v.kind==="includes"){if(!i.data.includes(v.value,v.position))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{includes:v.value,position:v.position},message:v.message}),c.dirty()}else if(v.kind==="toLowerCase")i.data=i.data.toLowerCase();else if(v.kind==="toUpperCase")i.data=i.data.toUpperCase();else if(v.kind==="startsWith"){if(!i.data.startsWith(v.value))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{startsWith:v.value},message:v.message}),c.dirty()}else if(v.kind==="endsWith"){if(!i.data.endsWith(v.value))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:{endsWith:v.value},message:v.message}),c.dirty()}else if(v.kind==="datetime"){if(!GX(v).test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"datetime",message:v.message}),c.dirty()}else if(v.kind==="date"){if(!I_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"date",message:v.message}),c.dirty()}else if(v.kind==="time"){if(!C_(v).test(i.data))a=this._getOrReturnCtx(i,a),R(a,{code:L.invalid_string,validation:"time",message:v.message}),c.dirty()}else if(v.kind==="duration"){if(!N_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"duration",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="ip"){if(!k_(i.data,v.version))a=this._getOrReturnCtx(i,a),R(a,{validation:"ip",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="jwt"){if(!T_(i.data,v.alg))a=this._getOrReturnCtx(i,a),R(a,{validation:"jwt",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="cidr"){if(!g_(i.data,v.version))a=this._getOrReturnCtx(i,a),R(a,{validation:"cidr",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="base64"){if(!S_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"base64",code:L.invalid_string,message:v.message}),c.dirty()}else if(v.kind==="base64url"){if(!P_.test(i.data))a=this._getOrReturnCtx(i,a),R(a,{validation:"base64url",code:L.invalid_string,message:v.message}),c.dirty()}else ai.assertNever(v);return{status:c.value,value:i.data}}_regex(i,n,c){return this.refinement((a)=>i.test(a),{validation:n,code:L.invalid_string,...S.errToObj(c)})}_addCheck(i){return new qn({...this._def,checks:[...this._def.checks,i]})}email(i){return this._addCheck({kind:"email",...S.errToObj(i)})}url(i){return this._addCheck({kind:"url",...S.errToObj(i)})}emoji(i){return this._addCheck({kind:"emoji",...S.errToObj(i)})}uuid(i){return this._addCheck({kind:"uuid",...S.errToObj(i)})}nanoid(i){return this._addCheck({kind:"nanoid",...S.errToObj(i)})}cuid(i){return this._addCheck({kind:"cuid",...S.errToObj(i)})}cuid2(i){return this._addCheck({kind:"cuid2",...S.errToObj(i)})}ulid(i){return this._addCheck({kind:"ulid",...S.errToObj(i)})}base64(i){return this._addCheck({kind:"base64",...S.errToObj(i)})}base64url(i){return this._addCheck({kind:"base64url",...S.errToObj(i)})}jwt(i){return this._addCheck({kind:"jwt",...S.errToObj(i)})}ip(i){return this._addCheck({kind:"ip",...S.errToObj(i)})}cidr(i){return this._addCheck({kind:"cidr",...S.errToObj(i)})}datetime(i){if(typeof i==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:i});return this._addCheck({kind:"datetime",precision:typeof i?.precision==="undefined"?null:i?.precision,offset:i?.offset??!1,local:i?.local??!1,...S.errToObj(i?.message)})}date(i){return this._addCheck({kind:"date",message:i})}time(i){if(typeof i==="string")return this._addCheck({kind:"time",precision:null,message:i});return this._addCheck({kind:"time",precision:typeof i?.precision==="undefined"?null:i?.precision,...S.errToObj(i?.message)})}duration(i){return this._addCheck({kind:"duration",...S.errToObj(i)})}regex(i,n){return this._addCheck({kind:"regex",regex:i,...S.errToObj(n)})}includes(i,n){return this._addCheck({kind:"includes",value:i,position:n?.position,...S.errToObj(n?.message)})}startsWith(i,n){return this._addCheck({kind:"startsWith",value:i,...S.errToObj(n)})}endsWith(i,n){return this._addCheck({kind:"endsWith",value:i,...S.errToObj(n)})}min(i,n){return this._addCheck({kind:"min",value:i,...S.errToObj(n)})}max(i,n){return this._addCheck({kind:"max",value:i,...S.errToObj(n)})}length(i,n){return this._addCheck({kind:"length",value:i,...S.errToObj(n)})}nonempty(i){return this.min(1,S.errToObj(i))}trim(){return new qn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((i)=>i.kind==="datetime")}get isDate(){return!!this._def.checks.find((i)=>i.kind==="date")}get isTime(){return!!this._def.checks.find((i)=>i.kind==="time")}get isDuration(){return!!this._def.checks.find((i)=>i.kind==="duration")}get isEmail(){return!!this._def.checks.find((i)=>i.kind==="email")}get isURL(){return!!this._def.checks.find((i)=>i.kind==="url")}get isEmoji(){return!!this._def.checks.find((i)=>i.kind==="emoji")}get isUUID(){return!!this._def.checks.find((i)=>i.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((i)=>i.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((i)=>i.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((i)=>i.kind==="cuid2")}get isULID(){return!!this._def.checks.find((i)=>i.kind==="ulid")}get isIP(){return!!this._def.checks.find((i)=>i.kind==="ip")}get isCIDR(){return!!this._def.checks.find((i)=>i.kind==="cidr")}get isBase64(){return!!this._def.checks.find((i)=>i.kind==="base64")}get isBase64url(){return!!this._def.checks.find((i)=>i.kind==="base64url")}get minLength(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxLength(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}}qn.create=(i)=>{return new qn({checks:[],typeName:h.ZodString,coerce:i?.coerce??!1,...t(i)})};function h_(i,n){let c=(i.toString().split(".")[1]||"").length,a=(n.toString().split(".")[1]||"").length,v=c>a?c:a,x=Number.parseInt(i.toFixed(v).replace(".","")),w=Number.parseInt(n.toFixed(v).replace(".",""));return x%w/10**v}class ac extends ii{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(i){if(this._def.coerce)i.data=Number(i.data);if(this._getType(i)!==N.number){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.number,received:v.parsedType}),g}let c=void 0,a=new Ei;for(let v of this._def.checks)if(v.kind==="int"){if(!ai.isInteger(i.data))c=this._getOrReturnCtx(i,c),R(c,{code:L.invalid_type,expected:"integer",received:"float",message:v.message}),a.dirty()}else if(v.kind==="min"){if(v.inclusive?i.data<v.value:i.data<=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_small,minimum:v.value,type:"number",inclusive:v.inclusive,exact:!1,message:v.message}),a.dirty()}else if(v.kind==="max"){if(v.inclusive?i.data>v.value:i.data>=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_big,maximum:v.value,type:"number",inclusive:v.inclusive,exact:!1,message:v.message}),a.dirty()}else if(v.kind==="multipleOf"){if(h_(i.data,v.value)!==0)c=this._getOrReturnCtx(i,c),R(c,{code:L.not_multiple_of,multipleOf:v.value,message:v.message}),a.dirty()}else if(v.kind==="finite"){if(!Number.isFinite(i.data))c=this._getOrReturnCtx(i,c),R(c,{code:L.not_finite,message:v.message}),a.dirty()}else ai.assertNever(v);return{status:a.value,value:i.data}}gte(i,n){return this.setLimit("min",i,!0,S.toString(n))}gt(i,n){return this.setLimit("min",i,!1,S.toString(n))}lte(i,n){return this.setLimit("max",i,!0,S.toString(n))}lt(i,n){return this.setLimit("max",i,!1,S.toString(n))}setLimit(i,n,c,a){return new ac({...this._def,checks:[...this._def.checks,{kind:i,value:n,inclusive:c,message:S.toString(a)}]})}_addCheck(i){return new ac({...this._def,checks:[...this._def.checks,i]})}int(i){return this._addCheck({kind:"int",message:S.toString(i)})}positive(i){return this._addCheck({kind:"min",value:0,inclusive:!1,message:S.toString(i)})}negative(i){return this._addCheck({kind:"max",value:0,inclusive:!1,message:S.toString(i)})}nonpositive(i){return this._addCheck({kind:"max",value:0,inclusive:!0,message:S.toString(i)})}nonnegative(i){return this._addCheck({kind:"min",value:0,inclusive:!0,message:S.toString(i)})}multipleOf(i,n){return this._addCheck({kind:"multipleOf",value:i,message:S.toString(n)})}finite(i){return this._addCheck({kind:"finite",message:S.toString(i)})}safe(i){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:S.toString(i)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:S.toString(i)})}get minValue(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxValue(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}get isInt(){return!!this._def.checks.find((i)=>i.kind==="int"||i.kind==="multipleOf"&&ai.isInteger(i.value))}get isFinite(){let i=null,n=null;for(let c of this._def.checks)if(c.kind==="finite"||c.kind==="int"||c.kind==="multipleOf")return!0;else if(c.kind==="min"){if(n===null||c.value>n)n=c.value}else if(c.kind==="max"){if(i===null||c.value<i)i=c.value}return Number.isFinite(n)&&Number.isFinite(i)}}ac.create=(i)=>{return new ac({checks:[],typeName:h.ZodNumber,coerce:i?.coerce||!1,...t(i)})};class vc extends ii{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(i){if(this._def.coerce)try{i.data=BigInt(i.data)}catch{return this._getInvalidInput(i)}if(this._getType(i)!==N.bigint)return this._getInvalidInput(i);let c=void 0,a=new Ei;for(let v of this._def.checks)if(v.kind==="min"){if(v.inclusive?i.data<v.value:i.data<=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_small,type:"bigint",minimum:v.value,inclusive:v.inclusive,message:v.message}),a.dirty()}else if(v.kind==="max"){if(v.inclusive?i.data>v.value:i.data>=v.value)c=this._getOrReturnCtx(i,c),R(c,{code:L.too_big,type:"bigint",maximum:v.value,inclusive:v.inclusive,message:v.message}),a.dirty()}else if(v.kind==="multipleOf"){if(i.data%v.value!==BigInt(0))c=this._getOrReturnCtx(i,c),R(c,{code:L.not_multiple_of,multipleOf:v.value,message:v.message}),a.dirty()}else ai.assertNever(v);return{status:a.value,value:i.data}}_getInvalidInput(i){let n=this._getOrReturnCtx(i);return R(n,{code:L.invalid_type,expected:N.bigint,received:n.parsedType}),g}gte(i,n){return this.setLimit("min",i,!0,S.toString(n))}gt(i,n){return this.setLimit("min",i,!1,S.toString(n))}lte(i,n){return this.setLimit("max",i,!0,S.toString(n))}lt(i,n){return this.setLimit("max",i,!1,S.toString(n))}setLimit(i,n,c,a){return new vc({...this._def,checks:[...this._def.checks,{kind:i,value:n,inclusive:c,message:S.toString(a)}]})}_addCheck(i){return new vc({...this._def,checks:[...this._def.checks,i]})}positive(i){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:S.toString(i)})}negative(i){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:S.toString(i)})}nonpositive(i){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:S.toString(i)})}nonnegative(i){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:S.toString(i)})}multipleOf(i,n){return this._addCheck({kind:"multipleOf",value:i,message:S.toString(n)})}get minValue(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i}get maxValue(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i}}vc.create=(i)=>{return new vc({checks:[],typeName:h.ZodBigInt,coerce:i?.coerce??!1,...t(i)})};class r4 extends ii{_parse(i){if(this._def.coerce)i.data=Boolean(i.data);if(this._getType(i)!==N.boolean){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.boolean,received:c.parsedType}),g}return Pi(i.data)}}r4.create=(i)=>{return new r4({typeName:h.ZodBoolean,coerce:i?.coerce||!1,...t(i)})};class Tc extends ii{_parse(i){if(this._def.coerce)i.data=new Date(i.data);if(this._getType(i)!==N.date){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_type,expected:N.date,received:v.parsedType}),g}if(Number.isNaN(i.data.getTime())){let v=this._getOrReturnCtx(i);return R(v,{code:L.invalid_date}),g}let c=new Ei,a=void 0;for(let v of this._def.checks)if(v.kind==="min"){if(i.data.getTime()<v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_small,message:v.message,inclusive:!0,exact:!1,minimum:v.value,type:"date"}),c.dirty()}else if(v.kind==="max"){if(i.data.getTime()>v.value)a=this._getOrReturnCtx(i,a),R(a,{code:L.too_big,message:v.message,inclusive:!0,exact:!1,maximum:v.value,type:"date"}),c.dirty()}else ai.assertNever(v);return{status:c.value,value:new Date(i.data.getTime())}}_addCheck(i){return new Tc({...this._def,checks:[...this._def.checks,i]})}min(i,n){return this._addCheck({kind:"min",value:i.getTime(),message:S.toString(n)})}max(i,n){return this._addCheck({kind:"max",value:i.getTime(),message:S.toString(n)})}get minDate(){let i=null;for(let n of this._def.checks)if(n.kind==="min"){if(i===null||n.value>i)i=n.value}return i!=null?new Date(i):null}get maxDate(){let i=null;for(let n of this._def.checks)if(n.kind==="max"){if(i===null||n.value<i)i=n.value}return i!=null?new Date(i):null}}Tc.create=(i)=>{return new Tc({checks:[],coerce:i?.coerce||!1,typeName:h.ZodDate,...t(i)})};class D8 extends ii{_parse(i){if(this._getType(i)!==N.symbol){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.symbol,received:c.parsedType}),g}return Pi(i.data)}}D8.create=(i)=>{return new D8({typeName:h.ZodSymbol,...t(i)})};class t4 extends ii{_parse(i){if(this._getType(i)!==N.undefined){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.undefined,received:c.parsedType}),g}return Pi(i.data)}}t4.create=(i)=>{return new t4({typeName:h.ZodUndefined,...t(i)})};class e4 extends ii{_parse(i){if(this._getType(i)!==N.null){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.null,received:c.parsedType}),g}return Pi(i.data)}}e4.create=(i)=>{return new e4({typeName:h.ZodNull,...t(i)})};class gc extends ii{constructor(){super(...arguments);this._any=!0}_parse(i){return Pi(i.data)}}gc.create=(i)=>{return new gc({typeName:h.ZodAny,...t(i)})};class cc extends ii{constructor(){super(...arguments);this._unknown=!0}_parse(i){return Pi(i.data)}}cc.create=(i)=>{return new cc({typeName:h.ZodUnknown,...t(i)})};class a1 extends ii{_parse(i){let n=this._getOrReturnCtx(i);return R(n,{code:L.invalid_type,expected:N.never,received:n.parsedType}),g}}a1.create=(i)=>{return new a1({typeName:h.ZodNever,...t(i)})};class L8 extends ii{_parse(i){if(this._getType(i)!==N.undefined){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.void,received:c.parsedType}),g}return Pi(i.data)}}L8.create=(i)=>{return new L8({typeName:h.ZodVoid,...t(i)})};class jn extends ii{_parse(i){let{ctx:n,status:c}=this._processInputParams(i),a=this._def;if(n.parsedType!==N.array)return R(n,{code:L.invalid_type,expected:N.array,received:n.parsedType}),g;if(a.exactLength!==null){let x=n.data.length>a.exactLength.value,w=n.data.length<a.exactLength.value;if(x||w)R(n,{code:x?L.too_big:L.too_small,minimum:w?a.exactLength.value:void 0,maximum:x?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),c.dirty()}if(a.minLength!==null){if(n.data.length<a.minLength.value)R(n,{code:L.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),c.dirty()}if(a.maxLength!==null){if(n.data.length>a.maxLength.value)R(n,{code:L.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),c.dirty()}if(n.common.async)return Promise.all([...n.data].map((x,w)=>{return a.type._parseAsync(new En(n,x,n.path,w))})).then((x)=>{return Ei.mergeArray(c,x)});let v=[...n.data].map((x,w)=>{return a.type._parseSync(new En(n,x,n.path,w))});return Ei.mergeArray(c,v)}get element(){return this._def.type}min(i,n){return new jn({...this._def,minLength:{value:i,message:S.toString(n)}})}max(i,n){return new jn({...this._def,maxLength:{value:i,message:S.toString(n)}})}length(i,n){return new jn({...this._def,exactLength:{value:i,message:S.toString(n)}})}nonempty(i){return this.min(1,i)}}jn.create=(i,n)=>{return new jn({type:i,minLength:null,maxLength:null,exactLength:null,typeName:h.ZodArray,...t(n)})};function s4(i){if(i instanceof $i){let n={};for(let c in i.shape){let a=i.shape[c];n[c]=bn.create(s4(a))}return new $i({...i._def,shape:()=>n})}else if(i instanceof jn)return new jn({...i._def,type:s4(i.element)});else if(i instanceof bn)return bn.create(s4(i.unwrap()));else if(i instanceof _1)return _1.create(s4(i.unwrap()));else if(i instanceof v1)return v1.create(i.items.map((n)=>s4(n)));else return i}class $i extends ii{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let i=this._def.shape(),n=ai.objectKeys(i);return this._cached={shape:i,keys:n},this._cached}_parse(i){if(this._getType(i)!==N.object){let l=this._getOrReturnCtx(i);return R(l,{code:L.invalid_type,expected:N.object,received:l.parsedType}),g}let{status:c,ctx:a}=this._processInputParams(i),{shape:v,keys:x}=this._getCached(),w=[];if(!(this._def.catchall instanceof a1&&this._def.unknownKeys==="strip")){for(let l in a.data)if(!x.includes(l))w.push(l)}let J=[];for(let l of x){let W=v[l],Y=a.data[l];J.push({key:{status:"valid",value:l},value:W._parse(new En(a,Y,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof a1){let l=this._def.unknownKeys;if(l==="passthrough")for(let W of w)J.push({key:{status:"valid",value:W},value:{status:"valid",value:a.data[W]}});else if(l==="strict"){if(w.length>0)R(a,{code:L.unrecognized_keys,keys:w}),c.dirty()}else if(l==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let W of w){let Y=a.data[W];J.push({key:{status:"valid",value:W},value:l._parse(new En(a,Y,a.path,W)),alwaysSet:W in a.data})}}if(a.common.async)return Promise.resolve().then(async()=>{let l=[];for(let W of J){let Y=await W.key,z=await W.value;l.push({key:Y,value:z,alwaysSet:W.alwaysSet})}return l}).then((l)=>{return Ei.mergeObjectSync(c,l)});else return Ei.mergeObjectSync(c,J)}get shape(){return this._def.shape()}strict(i){return S.errToObj,new $i({...this._def,unknownKeys:"strict",...i!==void 0?{errorMap:(n,c)=>{let a=this._def.errorMap?.(n,c).message??c.defaultError;if(n.code==="unrecognized_keys")return{message:S.errToObj(i).message??a};return{message:a}}}:{}})}strip(){return new $i({...this._def,unknownKeys:"strip"})}passthrough(){return new $i({...this._def,unknownKeys:"passthrough"})}extend(i){return new $i({...this._def,shape:()=>({...this._def.shape(),...i})})}merge(i){return new $i({unknownKeys:i._def.unknownKeys,catchall:i._def.catchall,shape:()=>({...this._def.shape(),...i._def.shape()}),typeName:h.ZodObject})}setKey(i,n){return this.augment({[i]:n})}catchall(i){return new $i({...this._def,catchall:i})}pick(i){let n={};for(let c of ai.objectKeys(i))if(i[c]&&this.shape[c])n[c]=this.shape[c];return new $i({...this._def,shape:()=>n})}omit(i){let n={};for(let c of ai.objectKeys(this.shape))if(!i[c])n[c]=this.shape[c];return new $i({...this._def,shape:()=>n})}deepPartial(){return s4(this)}partial(i){let n={};for(let c of ai.objectKeys(this.shape)){let a=this.shape[c];if(i&&!i[c])n[c]=a;else n[c]=a.optional()}return new $i({...this._def,shape:()=>n})}required(i){let n={};for(let c of ai.objectKeys(this.shape))if(i&&!i[c])n[c]=this.shape[c];else{let v=this.shape[c];while(v instanceof bn)v=v._def.innerType;n[c]=v}return new $i({...this._def,shape:()=>n})}keyof(){return HX(ai.objectKeys(this.shape))}}$i.create=(i,n)=>{return new $i({shape:()=>i,unknownKeys:"strip",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};$i.strictCreate=(i,n)=>{return new $i({shape:()=>i,unknownKeys:"strict",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};$i.lazycreate=(i,n)=>{return new $i({shape:i,unknownKeys:"strip",catchall:a1.create(),typeName:h.ZodObject,...t(n)})};class i0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=this._def.options;function a(v){for(let w of v)if(w.result.status==="valid")return w.result;for(let w of v)if(w.result.status==="dirty")return n.common.issues.push(...w.ctx.common.issues),w.result;let x=v.map((w)=>new di(w.ctx.common.issues));return R(n,{code:L.invalid_union,unionErrors:x}),g}if(n.common.async)return Promise.all(c.map(async(v)=>{let x={...n,common:{...n.common,issues:[]},parent:null};return{result:await v._parseAsync({data:n.data,path:n.path,parent:x}),ctx:x}})).then(a);else{let v=void 0,x=[];for(let J of c){let l={...n,common:{...n.common,issues:[]},parent:null},W=J._parseSync({data:n.data,path:n.path,parent:l});if(W.status==="valid")return W;else if(W.status==="dirty"&&!v)v={result:W,ctx:l};if(l.common.issues.length)x.push(l.common.issues)}if(v)return n.common.issues.push(...v.ctx.common.issues),v.result;let w=x.map((J)=>new di(J));return R(n,{code:L.invalid_union,unionErrors:w}),g}}get options(){return this._def.options}}i0.create=(i,n)=>{return new i0({options:i,typeName:h.ZodUnion,...t(n)})};var L1=(i)=>{if(i instanceof c0)return L1(i.schema);else if(i instanceof un)return L1(i.innerType());else if(i instanceof a0)return[i.value];else if(i instanceof xc)return i.options;else if(i instanceof v0)return ai.objectValues(i.enum);else if(i instanceof x0)return L1(i._def.innerType);else if(i instanceof t4)return[void 0];else if(i instanceof e4)return[null];else if(i instanceof bn)return[void 0,...L1(i.unwrap())];else if(i instanceof _1)return[null,...L1(i.unwrap())];else if(i instanceof i2)return L1(i.unwrap());else if(i instanceof w0)return L1(i.unwrap());else if(i instanceof p0)return L1(i._def.innerType);else return[]};class e6 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.object)return R(n,{code:L.invalid_type,expected:N.object,received:n.parsedType}),g;let c=this.discriminator,a=n.data[c],v=this.optionsMap.get(a);if(!v)return R(n,{code:L.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[c]}),g;if(n.common.async)return v._parseAsync({data:n.data,path:n.path,parent:n});else return v._parseSync({data:n.data,path:n.path,parent:n})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(i,n,c){let a=new Map;for(let v of n){let x=L1(v.shape[i]);if(!x.length)throw new Error(`A discriminator value for key \`${i}\` could not be extracted from all schema options`);for(let w of x){if(a.has(w))throw new Error(`Discriminator property ${String(i)} has duplicate value ${String(w)}`);a.set(w,v)}}return new e6({typeName:h.ZodDiscriminatedUnion,discriminator:i,options:n,optionsMap:a,...t(c)})}}function A9(i,n){let c=c1(i),a=c1(n);if(i===n)return{valid:!0,data:i};else if(c===N.object&&a===N.object){let v=ai.objectKeys(n),x=ai.objectKeys(i).filter((J)=>v.indexOf(J)!==-1),w={...i,...n};for(let J of x){let l=A9(i[J],n[J]);if(!l.valid)return{valid:!1};w[J]=l.data}return{valid:!0,data:w}}else if(c===N.array&&a===N.array){if(i.length!==n.length)return{valid:!1};let v=[];for(let x=0;x<i.length;x++){let w=i[x],J=n[x],l=A9(w,J);if(!l.valid)return{valid:!1};v.push(l.data)}return{valid:!0,data:v}}else if(c===N.date&&a===N.date&&+i===+n)return{valid:!0,data:i};else return{valid:!1}}class n0 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i),a=(v,x)=>{if(d6(v)||d6(x))return g;let w=A9(v.value,x.value);if(!w.valid)return R(c,{code:L.invalid_intersection_types}),g;if(r6(v)||r6(x))n.dirty();return{status:n.value,value:w.data}};if(c.common.async)return Promise.all([this._def.left._parseAsync({data:c.data,path:c.path,parent:c}),this._def.right._parseAsync({data:c.data,path:c.path,parent:c})]).then(([v,x])=>a(v,x));else return a(this._def.left._parseSync({data:c.data,path:c.path,parent:c}),this._def.right._parseSync({data:c.data,path:c.path,parent:c}))}}n0.create=(i,n,c)=>{return new n0({left:i,right:n,typeName:h.ZodIntersection,...t(c)})};class v1 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.array)return R(c,{code:L.invalid_type,expected:N.array,received:c.parsedType}),g;if(c.data.length<this._def.items.length)return R(c,{code:L.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;if(!this._def.rest&&c.data.length>this._def.items.length)R(c,{code:L.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty();let v=[...c.data].map((x,w)=>{let J=this._def.items[w]||this._def.rest;if(!J)return null;return J._parse(new En(c,x,c.path,w))}).filter((x)=>!!x);if(c.common.async)return Promise.all(v).then((x)=>{return Ei.mergeArray(n,x)});else return Ei.mergeArray(n,v)}get items(){return this._def.items}rest(i){return new v1({...this._def,rest:i})}}v1.create=(i,n)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new v1({items:i,typeName:h.ZodTuple,rest:null,...t(n)})};class _8 extends ii{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.object)return R(c,{code:L.invalid_type,expected:N.object,received:c.parsedType}),g;let a=[],v=this._def.keyType,x=this._def.valueType;for(let w in c.data)a.push({key:v._parse(new En(c,w,c.path,w)),value:x._parse(new En(c,c.data[w],c.path,w)),alwaysSet:w in c.data});if(c.common.async)return Ei.mergeObjectAsync(n,a);else return Ei.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(i,n,c){if(n instanceof ii)return new _8({keyType:i,valueType:n,typeName:h.ZodRecord,...t(c)});return new _8({keyType:qn.create(),valueType:i,typeName:h.ZodRecord,...t(n)})}}class f8 extends ii{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.map)return R(c,{code:L.invalid_type,expected:N.map,received:c.parsedType}),g;let a=this._def.keyType,v=this._def.valueType,x=[...c.data.entries()].map(([w,J],l)=>{return{key:a._parse(new En(c,w,c.path,[l,"key"])),value:v._parse(new En(c,J,c.path,[l,"value"]))}});if(c.common.async){let w=new Map;return Promise.resolve().then(async()=>{for(let J of x){let l=await J.key,W=await J.value;if(l.status==="aborted"||W.status==="aborted")return g;if(l.status==="dirty"||W.status==="dirty")n.dirty();w.set(l.value,W.value)}return{status:n.value,value:w}})}else{let w=new Map;for(let J of x){let{key:l,value:W}=J;if(l.status==="aborted"||W.status==="aborted")return g;if(l.status==="dirty"||W.status==="dirty")n.dirty();w.set(l.value,W.value)}return{status:n.value,value:w}}}}f8.create=(i,n,c)=>{return new f8({valueType:n,keyType:i,typeName:h.ZodMap,...t(c)})};class hc extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.parsedType!==N.set)return R(c,{code:L.invalid_type,expected:N.set,received:c.parsedType}),g;let a=this._def;if(a.minSize!==null){if(c.data.size<a.minSize.value)R(c,{code:L.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()}if(a.maxSize!==null){if(c.data.size>a.maxSize.value)R(c,{code:L.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty()}let v=this._def.valueType;function x(J){let l=new Set;for(let W of J){if(W.status==="aborted")return g;if(W.status==="dirty")n.dirty();l.add(W.value)}return{status:n.value,value:l}}let w=[...c.data.values()].map((J,l)=>v._parse(new En(c,J,c.path,l)));if(c.common.async)return Promise.all(w).then((J)=>x(J));else return x(w)}min(i,n){return new hc({...this._def,minSize:{value:i,message:S.toString(n)}})}max(i,n){return new hc({...this._def,maxSize:{value:i,message:S.toString(n)}})}size(i,n){return this.min(i,n).max(i,n)}nonempty(i){return this.min(1,i)}}hc.create=(i,n)=>{return new hc({valueType:i,minSize:null,maxSize:null,typeName:h.ZodSet,...t(n)})};class d4 extends ii{constructor(){super(...arguments);this.validate=this.implement}_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.function)return R(n,{code:L.invalid_type,expected:N.function,received:n.parsedType}),g;function c(w,J){return F8({data:w,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Z4(),D1].filter((l)=>!!l),issueData:{code:L.invalid_arguments,argumentsError:J}})}function a(w,J){return F8({data:w,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Z4(),D1].filter((l)=>!!l),issueData:{code:L.invalid_return_type,returnTypeError:J}})}let v={errorMap:n.common.contextualErrorMap},x=n.data;if(this._def.returns instanceof oc){let w=this;return Pi(async function(...J){let l=new di([]),W=await w._def.args.parseAsync(J,v).catch(($)=>{throw l.addIssue(c(J,$)),l}),Y=await Reflect.apply(x,this,W);return await w._def.returns._def.type.parseAsync(Y,v).catch(($)=>{throw l.addIssue(a(Y,$)),l})})}else{let w=this;return Pi(function(...J){let l=w._def.args.safeParse(J,v);if(!l.success)throw new di([c(J,l.error)]);let W=Reflect.apply(x,this,l.data),Y=w._def.returns.safeParse(W,v);if(!Y.success)throw new di([a(W,Y.error)]);return Y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...i){return new d4({...this._def,args:v1.create(i).rest(cc.create())})}returns(i){return new d4({...this._def,returns:i})}implement(i){return this.parse(i)}strictImplement(i){return this.parse(i)}static create(i,n,c){return new d4({args:i?i:v1.create([]).rest(cc.create()),returns:n||cc.create(),typeName:h.ZodFunction,...t(c)})}}class c0 extends ii{get schema(){return this._def.getter()}_parse(i){let{ctx:n}=this._processInputParams(i);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}c0.create=(i,n)=>{return new c0({getter:i,typeName:h.ZodLazy,...t(n)})};class a0 extends ii{_parse(i){if(i.data!==this._def.value){let n=this._getOrReturnCtx(i);return R(n,{received:n.data,code:L.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:i.data}}get value(){return this._def.value}}a0.create=(i,n)=>{return new a0({value:i,typeName:h.ZodLiteral,...t(n)})};function HX(i,n){return new xc({values:i,typeName:h.ZodEnum,...t(n)})}class xc extends ii{constructor(){super(...arguments);U8.set(this,void 0)}_parse(i){if(typeof i.data!=="string"){let n=this._getOrReturnCtx(i),c=this._def.values;return R(n,{expected:ai.joinValues(c),received:n.parsedType,code:L.invalid_type}),g}if(!t6(this,U8,"f"))XX(this,U8,new Set(this._def.values),"f");if(!t6(this,U8,"f").has(i.data)){let n=this._getOrReturnCtx(i),c=this._def.values;return R(n,{received:n.data,code:L.invalid_enum_value,options:c}),g}return Pi(i.data)}get options(){return this._def.values}get enum(){let i={};for(let n of this._def.values)i[n]=n;return i}get Values(){let i={};for(let n of this._def.values)i[n]=n;return i}get Enum(){let i={};for(let n of this._def.values)i[n]=n;return i}extract(i,n=this._def){return xc.create(i,{...this._def,...n})}exclude(i,n=this._def){return xc.create(this.options.filter((c)=>!i.includes(c)),{...this._def,...n})}}U8=new WeakMap;xc.create=HX;class v0 extends ii{constructor(){super(...arguments);B8.set(this,void 0)}_parse(i){let n=ai.getValidEnumValues(this._def.values),c=this._getOrReturnCtx(i);if(c.parsedType!==N.string&&c.parsedType!==N.number){let a=ai.objectValues(n);return R(c,{expected:ai.joinValues(a),received:c.parsedType,code:L.invalid_type}),g}if(!t6(this,B8,"f"))XX(this,B8,new Set(ai.getValidEnumValues(this._def.values)),"f");if(!t6(this,B8,"f").has(i.data)){let a=ai.objectValues(n);return R(c,{received:c.data,code:L.invalid_enum_value,options:a}),g}return Pi(i.data)}get enum(){return this._def.values}}B8=new WeakMap;v0.create=(i,n)=>{return new v0({values:i,typeName:h.ZodNativeEnum,...t(n)})};class oc extends ii{unwrap(){return this._def.type}_parse(i){let{ctx:n}=this._processInputParams(i);if(n.parsedType!==N.promise&&n.common.async===!1)return R(n,{code:L.invalid_type,expected:N.promise,received:n.parsedType}),g;let c=n.parsedType===N.promise?n.data:Promise.resolve(n.data);return Pi(c.then((a)=>{return this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})}))}}oc.create=(i,n)=>{return new oc({type:i,typeName:h.ZodPromise,...t(n)})};class un extends ii{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===h.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(i){let{status:n,ctx:c}=this._processInputParams(i),a=this._def.effect||null,v={addIssue:(x)=>{if(R(c,x),x.fatal)n.abort();else n.dirty()},get path(){return c.path}};if(v.addIssue=v.addIssue.bind(v),a.type==="preprocess"){let x=a.transform(c.data,v);if(c.common.async)return Promise.resolve(x).then(async(w)=>{if(n.value==="aborted")return g;let J=await this._def.schema._parseAsync({data:w,path:c.path,parent:c});if(J.status==="aborted")return g;if(J.status==="dirty")return kc(J.value);if(n.value==="dirty")return kc(J.value);return J});else{if(n.value==="aborted")return g;let w=this._def.schema._parseSync({data:x,path:c.path,parent:c});if(w.status==="aborted")return g;if(w.status==="dirty")return kc(w.value);if(n.value==="dirty")return kc(w.value);return w}}if(a.type==="refinement"){let x=(w)=>{let J=a.refinement(w,v);if(c.common.async)return Promise.resolve(J);if(J instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return w};if(c.common.async===!1){let w=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(w.status==="aborted")return g;if(w.status==="dirty")n.dirty();return x(w.value),{status:n.value,value:w.value}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then((w)=>{if(w.status==="aborted")return g;if(w.status==="dirty")n.dirty();return x(w.value).then(()=>{return{status:n.value,value:w.value}})})}if(a.type==="transform")if(c.common.async===!1){let x=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(!nc(x))return x;let w=a.transform(x.value,v);if(w instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:w}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then((x)=>{if(!nc(x))return x;return Promise.resolve(a.transform(x.value,v)).then((w)=>({status:n.value,value:w}))});ai.assertNever(a)}}un.create=(i,n,c)=>{return new un({schema:i,typeName:h.ZodEffects,effect:n,...t(c)})};un.createWithPreprocess=(i,n,c)=>{return new un({schema:n,effect:{type:"preprocess",transform:i},typeName:h.ZodEffects,...t(c)})};class bn extends ii{_parse(i){if(this._getType(i)===N.undefined)return Pi(void 0);return this._def.innerType._parse(i)}unwrap(){return this._def.innerType}}bn.create=(i,n)=>{return new bn({innerType:i,typeName:h.ZodOptional,...t(n)})};class _1 extends ii{_parse(i){if(this._getType(i)===N.null)return Pi(null);return this._def.innerType._parse(i)}unwrap(){return this._def.innerType}}_1.create=(i,n)=>{return new _1({innerType:i,typeName:h.ZodNullable,...t(n)})};class x0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;if(n.parsedType===N.undefined)c=this._def.defaultValue();return this._def.innerType._parse({data:c,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}x0.create=(i,n)=>{return new x0({innerType:i,typeName:h.ZodDefault,defaultValue:typeof n.default==="function"?n.default:()=>n.default,...t(n)})};class p0 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:c.data,path:c.path,parent:{...c}});if(y4(a))return a.then((v)=>{return{status:"valid",value:v.status==="valid"?v.value:this._def.catchValue({get error(){return new di(c.common.issues)},input:c.data})}});else return{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new di(c.common.issues)},input:c.data})}}removeCatch(){return this._def.innerType}}p0.create=(i,n)=>{return new p0({innerType:i,typeName:h.ZodCatch,catchValue:typeof n.catch==="function"?n.catch:()=>n.catch,...t(n)})};class O8 extends ii{_parse(i){if(this._getType(i)!==N.nan){let c=this._getOrReturnCtx(i);return R(c,{code:L.invalid_type,expected:N.nan,received:c.parsedType}),g}return{status:"valid",value:i.data}}}O8.create=(i)=>{return new O8({typeName:h.ZodNaN,...t(i)})};var o_=Symbol("zod_brand");class i2 extends ii{_parse(i){let{ctx:n}=this._processInputParams(i),c=n.data;return this._def.type._parse({data:c,path:n.path,parent:n})}unwrap(){return this._def.type}}class A8 extends ii{_parse(i){let{status:n,ctx:c}=this._processInputParams(i);if(c.common.async)return(async()=>{let v=await this._def.in._parseAsync({data:c.data,path:c.path,parent:c});if(v.status==="aborted")return g;if(v.status==="dirty")return n.dirty(),kc(v.value);else return this._def.out._parseAsync({data:v.value,path:c.path,parent:c})})();else{let a=this._def.in._parseSync({data:c.data,path:c.path,parent:c});if(a.status==="aborted")return g;if(a.status==="dirty")return n.dirty(),{status:"dirty",value:a.value};else return this._def.out._parseSync({data:a.value,path:c.path,parent:c})}}static create(i,n){return new A8({in:i,out:n,typeName:h.ZodPipeline})}}class w0 extends ii{_parse(i){let n=this._def.innerType._parse(i),c=(a)=>{if(nc(a))a.value=Object.freeze(a.value);return a};return y4(n)?n.then((a)=>c(a)):c(n)}unwrap(){return this._def.innerType}}w0.create=(i,n)=>{return new w0({innerType:i,typeName:h.ZodReadonly,...t(n)})};function YX(i,n){let c=typeof i==="function"?i(n):typeof i==="string"?{message:i}:i;return typeof c==="string"?{message:c}:c}function MX(i,n={},c){if(i)return gc.create().superRefine((a,v)=>{let x=i(a);if(x instanceof Promise)return x.then((w)=>{if(!w){let J=YX(n,a),l=J.fatal??c??!0;v.addIssue({code:"custom",...J,fatal:l})}});if(!x){let w=YX(n,a),J=w.fatal??c??!0;v.addIssue({code:"custom",...w,fatal:J})}return});return gc.create()}var Z_={object:$i.lazycreate},h;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(h||(h={}));var y_=(i,n={message:`Input not instance of ${i.name}`})=>MX((c)=>c instanceof i,n),VX=qn.create,mX=ac.create,s_=O8.create,d_=vc.create,KX=r4.create,r_=Tc.create,t_=D8.create,e_=t4.create,nf=e4.create,cf=gc.create,af=cc.create,vf=a1.create,xf=L8.create,pf=jn.create,wf=$i.create,Jf=$i.strictCreate,lf=i0.create,Qf=e6.create,Wf=n0.create,Yf=v1.create,Xf=_8.create,zf=f8.create,$f=hc.create,Gf=d4.create,Hf=c0.create,Mf=a0.create,Vf=xc.create,mf=v0.create,Kf=oc.create,Ff=un.create,Uf=bn.create,Bf=_1.create,Df=un.createWithPreprocess,Lf=A8.create,_f=()=>VX().optional(),ff=()=>mX().optional(),Of=()=>KX().optional(),Af={string:(i)=>qn.create({...i,coerce:!0}),number:(i)=>ac.create({...i,coerce:!0}),boolean:(i)=>r4.create({...i,coerce:!0}),bigint:(i)=>vc.create({...i,coerce:!0}),date:(i)=>Tc.create({...i,coerce:!0})};var Nf=g;var N8=Bi(require("fs")),pc=Bi(require("path")),N9=Bi(require("fs/promises"));hn();var Sn=Di("Downloader");class FX{op;assetsPath="";savePath="";setup(i){if(this.op=i,this.op.localPath)this.assetsPath=pc.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage(i,n){let{imgFormat:c}=this.op,a=this.assetsPath;try{if(!N8.default.existsSync(a))N8.default.mkdirSync(a,{recursive:!0});let v=`${n}.${c}`,x=pc.default.join(a,v),w=await o4(i);if(!w.ok)throw new Error(`下载失败: ${w.status} ${w.statusText}`);let J=await w.arrayBuffer();return N8.default.writeFileSync(x,new Uint8Array(J)),pc.default.join(pc.default.basename(a),v).replace(/\\/g,"/")}catch(v){throw Sn.error("图片下载错误:",v),v}}async downLoadImageAndReplaceContent(i){try{let n=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,c=i.match(n);if(!c)return i;let a=[...new Set(c)],v=new Map;await Promise.all(a.map(async(w)=>{let J=pc.default.basename(w),l=await this.downloadImage(w,J);v.set(w,l)}));let x=i;for(let[w,J]of v.entries()){let l=new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");x=x.replace(l,J)}return x}catch(n){throw Sn.error("内容处理错误:",n),n}}async checkLocalAndDownload(i){if(!this.op.localPath)return;await Promise.all(i.map(async(n)=>{n.content=await this.downLoadImageAndReplaceContent(n.content)}));for(let n of i)try{let c=await this.saveContentToFile(n.content,n.path);Sn.debug(`Successfully saved: ${c}`)}catch(c){Sn.error(`Failed to save file ${n.path}:`,c)}}async ensureDirectoryExists(i){if(!N8.default.existsSync(i))Sn.debug(`Creating directory: ${i}`),await N9.default.mkdir(i,{recursive:!0})}async saveContentToFile(i,n){try{let c=pc.default.join(this.savePath,n),a=pc.default.dirname(c);if(Sn.debug(`Full path: ${c}, directory: ${a}`),await this.ensureDirectoryExists(a),n.endsWith(".html"))Sn.debug("Wrapping content with HTML template"),i=this.wrapHtmlContent(i);return Sn.debug(`Writing ${i.length} bytes to file`),await N9.default.writeFile(c,i),Sn.info(`File saved: ${c}`),c}catch(c){throw Sn.error("File save error:",n,c),c}}wrapHtmlContent(i){return Sn.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
300
300
  <html>
301
301
  <head>
302
302
  <meta charset="UTF-8">
@@ -317,5 +317,5 @@ ${v}. Convert the Tailwind to vanilla CSS if not already used in the codebase. D
317
317
 
318
318
  `)} Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]}}catch(c){return Rf.error("Tool execution error:",c),{content:[{type:"text",text:`Error: ${c.message}`}]}}}),i.tool("get_image","Generate an image for a given node or the currently selected node in the Figma desktop app. Use the nodeId parameter to specify a node id. If no node id is provided, the currently selected node will be used. If a URL is provided, extract the node id from the URL, for example, if given the URL https://figma.com/design/:fileKey/:fileName?node-id=1-2, the extracted nodeId would be 1:2. Also export Figma design images for visual verification and design fidelity validation. Essential for comparing generated code output against original designs, ensuring pixel-perfect implementation and catching visual discrepancies during the design-to-code process.",{fileKey:Ai.string().describe("Figma file identifier from the URL for accessing the design source"),ids:Ai.string().describe('Comma-separated node IDs to export. Use "Copy ID" from Figma context menu to get precise element references for comparison'),format:Ai.enum(["jpg","png","svg","pdf"]).optional().describe('Export format for verification: "png" for pixel-perfect comparison with transparency, "jpg" for quick previews, "svg" for scalable reference, "pdf" for print validation'),scale:Ai.number().optional().describe("Scale factor (1-4x) for high-resolution comparison. Use 2x+ for detailed fidelity checks on retina displays"),svg_include_id:Ai.boolean().optional().describe("Include element IDs in SVG for precise element mapping during code validation"),svg_simplify_stroke:Ai.boolean().optional().describe("Simplify stroke paths for cleaner reference images during visual comparison"),use_absolute_bounds:Ai.boolean().optional().describe("Use absolute positioning for accurate layout verification against implemented code"),version:Ai.string().optional().describe("Specific design version for consistent comparison baseline"),personalToken:Ai.string().optional().describe("Figma personal access token for authenticated access to design files")},async(n)=>{try{let c=await lX.images(n);return{content:[{type:"text",text:JSON.stringify(c)}]}}catch(c){return{content:[{type:"text",text:`Error: ${c.message}`}]}}})};var n2=new X9({name:wY,version:JY},{capabilities:{logging:{}}});QY(n2);UX(n2);UW(n2,3000);
319
319
 
320
- //# debugId=76183A8ECE8811AE64756E2164756E21
320
+ //# debugId=49C9CCFDE87060EA64756E2164756E21
321
321
  //# sourceMappingURL=streamable-http.js.map