@animaapp/anima-sdk 0.1.0 → 0.1.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.
@@ -1,20 +1,12 @@
1
1
 
2
- Debugger listening on ws://127.0.0.1:54329/cc812a76-dd33-4018-8d7a-e3ac85fd7843
3
- For help, see: https://nodejs.org/en/docs/inspector
4
- Debugger attached.
5
- Debugger listening on ws://127.0.0.1:54334/838f90be-0159-4abc-9bba-acedb6ee5a25
6
- For help, see: https://nodejs.org/en/docs/inspector
7
- Debugger attached.
8
- vite v6.0.11 building for production...
2
+ vite v6.0.11 building for production...
9
3
  transforming (1) src/index.ts✓ 13 modules transformed.
10
4
  rendering chunks (1)...
11
5
  [vite:dts] Start generate declaration files...
12
- computing gzip size (0)...computing gzip size (1)...dist/index.cjs 86.02 kB │ gzip: 23.00 kB │ map: 318.22 kB
6
+ computing gzip size (0)...computing gzip size (1)...dist/index.cjs 86.36 kB │ gzip: 23.10 kB │ map: 319.17 kB
13
7
  [vite:dts] Start rollup declaration files...
14
8
  Analysis will use the bundled TypeScript version 5.7.2
15
- [vite:dts] Declaration files built in 2033ms.
9
+ [vite:dts] Declaration files built in 1857ms.
16
10
  
17
- rendering chunks (1)...computing gzip size (1)...dist/index.js 122.50 kB │ gzip: 27.64 kB │ map: 331.96 kB
18
- ✓ built in 2.35s
19
- Waiting for the debugger to disconnect...
20
- Waiting for the debugger to disconnect...
11
+ rendering chunks (1)...computing gzip size (1)...dist/index.js 122.99 kB │ gzip: 27.75 kB │ map: 332.96 kB
12
+ ✓ built in 2.16s
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var kn=Object.defineProperty,Tn=Object.defineProperties;var Sn=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var En=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var Zt=n=>{throw TypeError(n)};var Rt=(n,e,t)=>e in n?kn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))En.call(e,t)&&Rt(n,t,e[t]);if(It)for(var t of It(e))An.call(e,t)&&Rt(n,t,e[t]);return n},g=(n,e)=>Tn(n,Sn(e));var Mt=(n,e,t)=>e.has(n)||Zt("Cannot "+t);var G=(n,e,t)=>(Mt(n,e,"read from private field"),t?t.call(n):e.get(n)),ot=(n,e,t)=>e.has(n)?Zt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ct=(n,e,t,r)=>(Mt(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);var F=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{o(t.next(c))}catch(u){s(u)}},i=c=>{try{o(t.throw(c))}catch(u){s(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _e extends Error{constructor({name:e,reason:t,status:r}){super(),this.name=`[Codegen Error] ${e}`,this.message=t,this.status=r}}var x;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var ht;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(ht||(ht={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),se=n=>{switch(typeof n){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(n)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(n)?p.array:n===null?p.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?p.promise:typeof Map!="undefined"&&n instanceof Map?p.map:typeof Set!="undefined"&&n instanceof Set?p.set:typeof Date!="undefined"&&n instanceof Date?p.date:p.object;default:return p.unknown}},l=x.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"]),On=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const ke=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===p.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:x.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case l.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(n)}return{message:t}};let qt=ke;function Cn(n){qt=n}function Qe(){return qt}const et=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i=g(d({},s),{path:a});if(s.message!==void 0)return g(d({},s),{path:a,message:s.message});let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return g(d({},s),{path:a,message:o})},Nn=[];function f(n,e){const t=Qe(),r=et({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ke?void 0:ke].filter(s=>!!s)});n.common.issues.push(r)}class I{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return F(this,null,function*(){const r=[];for(const s of t){const a=yield s.key,i=yield s.value;r.push({key:a,value:i})}return I.mergeObjectSync(e,r)})}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),we=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),pt=n=>n.status==="aborted",mt=n=>n.status==="dirty",ge=n=>n.status==="valid",Re=n=>typeof Promise!="undefined"&&n instanceof Promise;function tt(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Ht(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var m;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var Oe,Ce;class ee{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Pt=(n,e)=>{if(ge(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var c,u;const{message:h}=n;return i.code==="invalid_enum_value"?{message:h!=null?h:o.defaultError}:typeof o.data=="undefined"?{message:(c=h!=null?h:r)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=h!=null?h:t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class w{get description(){return this._def.description}_getType(e){return se(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Re(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Pt(s,a)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return ge(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((r=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>ge(a)?{value:a.value}:{issues:s.common.issues})}parseAsync(e,t){return F(this,null,function*(){const r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return F(this,null,function*(){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},s=this._parse({data:e,path:r.path,parent:r}),a=yield Re(s)?s:Promise.resolve(s);return Pt(r,a)})}refine(e,t){const r=s=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue(d({code:l.custom},r(s)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new J({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Q.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return Se.create(this,this._def)}or(e){return $e.create([this,e],this._def)}and(e){return Fe.create(this,e,this._def)}transform(e){return new J(g(d({},b(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new ze(g(d({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Et(d({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new Be(g(d({},b(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return He.create(this,e)}readonly(){return We.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const jn=/^c[^\s-]{8,}$/i,In=/^[0-9a-z]+$/,Rn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zn=/^[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,Mn=/^[a-z0-9_-]{21}$/i,Pn=/^[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)?)??$/,Fn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ln="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let dt;const Vn=/^(?:(?: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])$/,Dn=/^(?:(?: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])$/,Un=/^(([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]))$/,zn=/^(([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])$/,Bn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jt="((\\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])))",qn=new RegExp(`^${Jt}$`);function Gt(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Hn(n){return new RegExp(`^${Gt(n)}$`)}function Kt(n){let e=`${Jt}T${Gt(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Jn(n,e){return!!((e==="v4"||!e)&&Vn.test(n)||(e==="v6"||!e)&&Un.test(n))}function Gn(n,e){if(!Pn.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch(t){return!1}}function Kn(n,e){return!!((e==="v4"||!e)&&Dn.test(n)||(e==="v6"||!e)&&zn.test(n))}class q extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const r=new I;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?f(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")dt||(dt=new RegExp(Ln,"u")),dt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")jn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")In.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:l.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:l.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Kt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?qn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Hn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?$n.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Jn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Gn(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Kn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:l.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),d({validation:t,code:l.invalid_string},m.errToObj(r)))}_addCheck(e){return new q(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.errToObj(e)))}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1},m.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=n=>{var e;return new q(d({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};function Xn(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class de extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let r;const s=new I;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Xn(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,s){return new de(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(s)}]}))}_addCheck(e){return new de(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}de.create=n=>new de(d({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class ue extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let r;const s=new I;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,s){return new ue(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(s)}]}))}_addCheck(e){return new ue(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=n=>{var e;return new ue(d({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};class Ze extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.boolean,received:r.parsedType}),v}return M(e.data)}}Ze.create=n=>new Ze(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class ye extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_date}),v}const r=new I;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ye(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ye.create=n=>new ye(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate},b(n)));class nt extends w{_parse(e){if(this._getType(e)!==p.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.symbol,received:r.parsedType}),v}return M(e.data)}}nt.create=n=>new nt(d({typeName:y.ZodSymbol},b(n)));class Me extends w{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.undefined,received:r.parsedType}),v}return M(e.data)}}Me.create=n=>new Me(d({typeName:y.ZodUndefined},b(n)));class Pe extends w{_parse(e){if(this._getType(e)!==p.null){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.null,received:r.parsedType}),v}return M(e.data)}}Pe.create=n=>new Pe(d({typeName:y.ZodNull},b(n)));class Te extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}Te.create=n=>new Te(d({typeName:y.ZodAny},b(n)));class me extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}me.create=n=>new me(d({typeName:y.ZodUnknown},b(n)));class ae extends w{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}ae.create=n=>new ae(d({typeName:y.ZodNever},b(n)));class rt extends w{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.void,received:r.parsedType}),v}return M(e.data)}}rt.create=n=>new rt(d({typeName:y.ZodVoid},b(n)));class H extends w{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==p.array)return f(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),v;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(f(t,{code:i?l.too_big:l.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:l.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ee(t,i,t.path,o)))).then(i=>I.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ee(t,i,t.path,o)));return I.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new H(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new H(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new H(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}H.create=(n,e)=>new H(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function be(n){if(n instanceof S){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Q.create(be(r))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof H?new H(g(d({},n._def),{type:be(n.element)})):n instanceof Q?Q.create(be(n.unwrap())):n instanceof fe?fe.create(be(n.unwrap())):n instanceof te?te.create(n.items.map(e=>be(e))):n}class S extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return f(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),v}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ae&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const h=a[u],_=s.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new ee(s,_,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof ae){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(u==="strict")o.length>0&&(f(s,{code:l.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const _=s.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new ee(s,_,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(()=>F(this,null,function*(){const u=[];for(const h of c){const _=yield h.key,C=yield h.value;u.push({key:_,value:C,alwaysSet:h.alwaysSet})}return u})).then(u=>I.mergeObjectSync(r,u)):I.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new S(d(g(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}))}strip(){return new S(g(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new S(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new S(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S(g(d({},this._def),{catchall:e}))}pick(e){const t={};return x.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new S(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return x.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new S(g(d({},this._def),{shape:()=>t}))}deepPartial(){return be(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new S(g(d({},this._def),{shape:()=>t}))}required(e){const t={};return x.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Q;)a=a._def.innerType;t[r]=a}}),new S(g(d({},this._def),{shape:()=>t}))}keyof(){return Xt(x.objectKeys(this.shape))}}S.create=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strip",catchall:ae.create(),typeName:y.ZodObject},b(e)));S.strictCreate=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strict",catchall:ae.create(),typeName:y.ZodObject},b(e)));S.lazycreate=(n,e)=>new S(d({shape:n,unknownKeys:"strip",catchall:ae.create(),typeName:y.ZodObject},b(e)));class $e extends w{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new U(o.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(r.map(a=>F(this,null,function*(){const i=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(s);{let a;const i=[];for(const c of r){const u=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null}),h=c._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new U(c));return f(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}$e.create=(n,e)=>new $e(d({options:n,typeName:y.ZodUnion},b(e)));const re=n=>n instanceof Ve?re(n.schema):n instanceof J?re(n.innerType()):n instanceof De?[n.value]:n instanceof le?n.options:n instanceof Ue?x.objectValues(n.enum):n instanceof ze?re(n._def.innerType):n instanceof Me?[void 0]:n instanceof Pe?[null]:n instanceof Q?[void 0,...re(n.unwrap())]:n instanceof fe?[null,...re(n.unwrap())]:n instanceof Et||n instanceof We?re(n.unwrap()):n instanceof Be?re(n._def.innerType):[];class it extends w{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return f(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),v;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=re(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new it(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s},b(r)))}}function gt(n,e){const t=se(n),r=se(e);if(n===e)return{valid:!0,data:n};if(t===p.object&&r===p.object){const s=x.objectKeys(e),a=x.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=gt(n[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===p.array&&r===p.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],c=gt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===p.date&&r===p.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Fe extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(pt(a)||pt(i))return v;const o=gt(a.value,i.value);return o.valid?((mt(a)||mt(i))&&t.dirty(),{status:t.value,value:o.data}):(f(r,{code:l.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Fe.create=(n,e,t)=>new Fe(d({left:n,right:e,typeName:y.ZodIntersection},b(t)));class te extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return f(r,{code:l.invalid_type,expected:p.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new ee(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>I.mergeArray(t,i)):I.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new te(g(d({},this._def),{rest:e}))}}te.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new te(d({items:n,typeName:y.ZodTuple,rest:null},b(e)))};class Le extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:l.invalid_type,expected:p.object,received:r.parsedType}),v;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ee(r,o,r.path,o)),value:i._parse(new ee(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?I.mergeObjectAsync(t,s):I.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof w?new Le(d({keyType:e,valueType:t,typeName:y.ZodRecord},b(r))):new Le(d({keyType:q.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class st extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.map)return f(r,{code:l.invalid_type,expected:p.map,received:r.parsedType}),v;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,c],u)=>({key:s._parse(new ee(r,o,r.path,[u,"key"])),value:a._parse(new ee(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(()=>F(this,null,function*(){for(const c of i){const u=yield c.key,h=yield c.value;if(u.status==="aborted"||h.status==="aborted")return v;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return v;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}}}st.create=(n,e,t)=>new st(d({valueType:e,keyType:n,typeName:y.ZodMap},b(t)));class ve extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return f(r,{code:l.invalid_type,expected:p.set,received:r.parsedType}),v;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:l.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const h of c){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((c,u)=>a._parse(new ee(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new ve(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new ve(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ve.create=(n,e)=>new ve(d({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class xe extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return f(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),v;function r(o,c){return et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),ke].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),ke].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Se){const o=this;return M(function(...c){return F(this,null,function*(){const u=new U([]),h=yield o._def.args.parseAsync(c,a).catch(A=>{throw u.addIssue(r(c,A)),u}),_=yield Reflect.apply(i,this,h);return yield o._def.returns._def.type.parseAsync(_,a).catch(A=>{throw u.addIssue(s(_,A)),u})})})}else{const o=this;return M(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new U([r(c,u.error)]);const h=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(h,a);if(!_.success)throw new U([s(h,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xe(g(d({},this._def),{args:te.create(e).rest(me.create())}))}returns(e){return new xe(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new xe(d({args:e||te.create([]).rest(me.create()),returns:t||me.create(),typeName:y.ZodFunction},b(r)))}}class Ve extends w{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ve.create=(n,e)=>new Ve(d({getter:n,typeName:y.ZodLazy},b(e)));class De extends w{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}De.create=(n,e)=>new De(d({value:n,typeName:y.ZodLiteral},b(e)));function Xt(n,e){return new le(d({values:n,typeName:y.ZodEnum},b(e)))}class le extends w{constructor(){super(...arguments),Oe.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:x.joinValues(r),received:t.parsedType,code:l.invalid_type}),v}if(tt(this,Oe)||Ht(this,Oe,new Set(this._def.values)),!tt(this,Oe).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:r}),v}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return le.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return le.create(this.options.filter(r=>!e.includes(r)),d(d({},this._def),t))}}Oe=new WeakMap;le.create=Xt;class Ue extends w{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){const s=x.objectValues(t);return f(r,{expected:x.joinValues(s),received:r.parsedType,code:l.invalid_type}),v}if(tt(this,Ce)||Ht(this,Ce,new Set(x.getValidEnumValues(this._def.values))),!tt(this,Ce).has(e.data)){const s=x.objectValues(t);return f(r,{received:r.data,code:l.invalid_enum_value,options:s}),v}return M(e.data)}get enum(){return this._def.values}}Ce=new WeakMap;Ue.create=(n,e)=>new Ue(d({values:n,typeName:y.ZodNativeEnum},b(e)));class Se extends w{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),v;const r=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return M(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Se.create=(n,e)=>new Se(d({type:n,typeName:y.ZodPromise},b(e)));class J extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(o=>F(this,null,function*(){if(t.value==="aborted")return v;const c=yield this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?we(c.value):c}));{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?we(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ge(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ge(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(s)}}J.create=(n,e,t)=>new J(d({schema:n,typeName:y.ZodEffects,effect:e},b(t)));J.createWithPreprocess=(n,e,t)=>new J(d({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects},b(t)));class Q extends w{_parse(e){return this._getType(e)===p.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(n,e)=>new Q(d({innerType:n,typeName:y.ZodOptional},b(e)));class fe extends w{_parse(e){return this._getType(e)===p.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fe.create=(n,e)=>new fe(d({innerType:n,typeName:y.ZodNullable},b(e)));class ze extends w{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ze.create=(n,e)=>new ze(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class Be extends w{_parse(e){const{ctx:t}=this._processInputParams(e),r=g(d({},t),{common:g(d({},t.common),{issues:[]})}),s=this._def.innerType._parse({data:r.data,path:r.path,parent:d({},r)});return Re(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Be.create=(n,e)=>new Be(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class at extends w{_parse(e){if(this._getType(e)!==p.nan){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:p.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}at.create=n=>new at(d({typeName:y.ZodNaN},b(n)));const Yn=Symbol("zod_brand");class Et extends w{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class He extends w{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return F(this,null,function*(){const a=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),we(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})});{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new He({in:e,out:t,typeName:y.ZodPipeline})}}class We extends w{_parse(e){const t=this._def.innerType._parse(e),r=s=>(ge(s)&&(s.value=Object.freeze(s.value)),s);return Re(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}We.create=(n,e)=>new We(d({innerType:n,typeName:y.ZodReadonly},b(e)));function Yt(n,e={},t){return n?Te.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue(g(d({code:"custom"},u),{fatal:c}))}}):Te.create()}const Qn={object:S.lazycreate};var y;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(y||(y={}));const er=(n,e={message:`Input not instance of ${n.name}`})=>Yt(t=>t instanceof n,e),Qt=q.create,en=de.create,tr=at.create,nr=ue.create,tn=Ze.create,rr=ye.create,sr=nt.create,ar=Me.create,ir=Pe.create,or=Te.create,cr=me.create,dr=ae.create,ur=rt.create,lr=H.create,fr=S.create,hr=S.strictCreate,pr=$e.create,mr=it.create,gr=Fe.create,yr=te.create,vr=Le.create,_r=st.create,br=ve.create,wr=xe.create,xr=Ve.create,kr=De.create,Tr=le.create,Sr=Ue.create,Er=Se.create,$t=J.create,Ar=Q.create,Or=fe.create,Cr=J.createWithPreprocess,Nr=He.create,jr=()=>Qt().optional(),Ir=()=>en().optional(),Rr=()=>tn().optional(),Zr={string:n=>q.create(g(d({},n),{coerce:!0})),number:n=>de.create(g(d({},n),{coerce:!0})),boolean:n=>Ze.create(g(d({},n),{coerce:!0})),bigint:n=>ue.create(g(d({},n),{coerce:!0})),date:n=>ye.create(g(d({},n),{coerce:!0}))},Mr=v;var W=Object.freeze({__proto__:null,defaultErrorMap:ke,setErrorMap:Cn,getErrorMap:Qe,makeIssue:et,EMPTY_PATH:Nn,addIssueToContext:f,ParseStatus:I,INVALID:v,DIRTY:we,OK:M,isAborted:pt,isDirty:mt,isValid:ge,isAsync:Re,get util(){return x},get objectUtil(){return ht},ZodParsedType:p,getParsedType:se,ZodType:w,datetimeRegex:Kt,ZodString:q,ZodNumber:de,ZodBigInt:ue,ZodBoolean:Ze,ZodDate:ye,ZodSymbol:nt,ZodUndefined:Me,ZodNull:Pe,ZodAny:Te,ZodUnknown:me,ZodNever:ae,ZodVoid:rt,ZodArray:H,ZodObject:S,ZodUnion:$e,ZodDiscriminatedUnion:it,ZodIntersection:Fe,ZodTuple:te,ZodRecord:Le,ZodMap:st,ZodSet:ve,ZodFunction:xe,ZodLazy:Ve,ZodLiteral:De,ZodEnum:le,ZodNativeEnum:Ue,ZodPromise:Se,ZodEffects:J,ZodTransformer:J,ZodOptional:Q,ZodNullable:fe,ZodDefault:ze,ZodCatch:Be,ZodNaN:at,BRAND:Yn,ZodBranded:Et,ZodPipeline:He,ZodReadonly:We,custom:Yt,Schema:w,ZodSchema:w,late:Qn,get ZodFirstPartyTypeKind(){return y},coerce:Zr,any:or,array:lr,bigint:nr,boolean:tn,date:rr,discriminatedUnion:mr,effect:$t,enum:Tr,function:wr,instanceof:er,intersection:gr,lazy:xr,literal:kr,map:_r,nan:tr,nativeEnum:Sr,never:dr,null:ir,nullable:Or,number:en,object:fr,oboolean:Rr,onumber:Ir,optional:Ar,ostring:jr,pipeline:Nr,preprocess:Cr,promise:Er,record:vr,set:br,strictObject:hr,string:Qt,symbol:sr,transformer:$t,tuple:yr,undefined:ar,union:pr,unknown:cr,void:ur,NEVER:Mr,ZodIssueCode:l,quotelessJson:On,ZodError:U});const Pr=W.object({language:W.enum(["typescript","javascript"]).optional()}).and(W.union([W.object({framework:W.literal("react"),styling:W.enum(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:W.enum(["mui","antd","radix","shadcn"]).optional()}),W.object({framework:W.literal("html"),styling:W.enum(["plain_css","inline_styles"]),enableTranslation:W.boolean().optional()})])),nn=n=>{const e=Pr.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data},rn=n=>Object.entries(n).reduce((e,[t,r])=>(e[t]={content:r.code,isBinary:!1},e),{});var z,qe;class $r{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){ot(this,z);ot(this,qe);ct(this,qe,t),e&&(this.auth=e)}hasAuth(){return!!G(this,z)}set auth(e){ct(this,z,e)}get headers(){const e={"Content-Type":"application/json"};return G(this,z)&&(e.Authorization=`Bearer ${G(this,z).token}`,"teamId"in G(this,z)&&(e["X-Team-Id"]=G(this,z).teamId),"userId"in G(this,z)&&G(this,z).userId&&(e["X-User-Id"]=G(this,z).userId)),e}generateCode(r){return F(this,arguments,function*(e,t={}){var h,_,C,A,O,P;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const s={},a=nn(e.settings),i=yield fetch(`${G(this,qe)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,language:a.language,framework:a.framework,styling:a.styling,uiLibrary:a.uiLibrary,enableTranslation:a.enableTranslation})});if(!i.ok){let $;try{$=(yield i.json()).message||`HTTP error! status: ${i.status}`}catch(ie){$=`HTTP error! status: ${i.status}`}throw new _e({name:"HTTP Error",reason:$,status:i.status})}if(!i.body)throw new _e({name:"Stream Error",reason:"Response body is null",status:i.status});const o=i.body.getReader(),c=new TextDecoder;let u="";try{for(;;){const{done:$,value:ie}=yield o.read();if($)break;u+=c.decode(ie,{stream:!0});const oe=u.split(`
2
- `);u=oe.pop()||"";for(const R of oe)if(!(!R.trim()||R.startsWith(":"))&&R.startsWith("data: ")){let T;try{T=JSON.parse(R.slice(6))}catch(Je){continue}switch(T.type){case"start":{s.sessionId=T.sessionId,typeof t=="function"?t(T):(h=t.onStart)==null||h.call(t,{sessionId:T.sessionId});break}case"pre_codegen":{typeof t=="function"?t(T):(_=t.onPreCodegen)==null||_.call(t,{message:T.message});break}case"assets_uploaded":{typeof t=="function"?t(T):(C=t.onAssetsUploaded)==null||C.call(t);break}case"figma_metadata":{s.figmaFileName=T.figmaFileName,s.figmaSelectedFrameName=T.figmaSelectedFrameName,typeof t=="function"?t(T):(A=t.onFigmaMetadata)==null||A.call(t,{figmaFileName:T.figmaFileName,figmaSelectedFrameName:T.figmaSelectedFrameName});break}case"generating_code":{const Je=T.payload.files,Ge=rn(Je);T.payload.status==="success"&&(s.files=Ge),typeof t=="function"?t(T):(O=t.onGeneratingCode)==null||O.call(t,{status:T.payload.status,progress:T.payload.progress,files:Ge});break}case"codegen_completed":{typeof t=="function"?t(T):(P=t.onCodegenCompleted)==null||P.call(t);break}case"error":throw new _e({name:T.payload.errorName,reason:T.payload.reason});case"done":{if(!s.files)throw new _e({name:"Invalid response",reason:"No files found"});return s}}}}}finally{o.cancel()}throw new _e({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}z=new WeakMap,qe=new WeakMap;const Fr=n=>{var e;if(!n)return[!1,"",""];try{const t=new URL(n),r=t.pathname;if(t.origin!=="https://www.figma.com")return[!1,"",""];const s=((e=t.searchParams.get("node-id"))!=null?e:"").replace(/-/g,":"),a=r.split("/")[2];return[(r.startsWith("/file/")&&t.searchParams.get("type")!=="whiteboard"||r.startsWith("/design/"))&&a.length===22,a,s]}catch(t){return[!1,"",""]}},Lr=({fileKey:n,nodeId:e})=>{const t=new URL("https://www.figma.com");return t.pathname=`design/${n}`,e&&t.searchParams.set("node-id",e.replace(":","-")),t},sn="Figma Token Issue";class an extends Error{constructor({fileKey:e,reason:t}){super(sn),this.fileKey=e,this.reason=t}}const on="Rate Limit Exceeded";class cn extends Error{constructor({fileKey:e}){super(on),this.fileKey=e}}const dn="Not Found";class un extends Error{constructor({fileKey:e}){super(dn),this.fileKey=e}}const ln=n=>n.message===dn,fn="Unknown Figma API Exception";class hn extends Error{constructor({fileKey:e,cause:t}){super(fn),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Vr=n=>n.message===fn,pn=n=>n.message===on,mn=n=>[sn,...["Invalid Figma token","Figma token expired"]].includes(n.message),gn=(n,e)=>{var r,s;const t=((r=n==null?void 0:n.cause)==null?void 0:r.body)||n.body;throw(t==null?void 0:t.status)===403?new an({fileKey:e,reason:((s=n==null?void 0:n.cause)==null?void 0:s.body)||n.body}):(t==null?void 0:t.status)===429?new cn({fileKey:e}):(t==null?void 0:t.status)===404?new un({fileKey:e}):new hn({fileKey:e,cause:n})},Dr=n=>ln(n)?"NotFound":pn(n)?"RateLimitExceeded":mn(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var Ur=Object.defineProperty,zr=Object.defineProperties,Br=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,Wr=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable,Lt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),yn=n=>{throw TypeError(n)},Vt=(n,e,t)=>e in n?Ur(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))Wr.call(e,t)&&Vt(n,t,e[t]);if(Ft)for(var t of Ft(e))qr.call(e,t)&&Vt(n,t,e[t]);return n},At=(n,e)=>zr(n,Br(e)),Ot=(n,e,t)=>e.has(n)||yn("Cannot "+t),k=(n,e,t)=>(Ot(n,e,"read from private field"),t?t.call(n):e.get(n)),B=(n,e,t)=>e.has(n)?yn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,r)=>(Ot(n,e,"write to private field"),e.set(n,t),t),Y=(n,e,t)=>(Ot(n,e,"access private method"),t),E=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{o(t.next(c))}catch(u){s(u)}},i=c=>{try{o(t.throw(c))}catch(u){s(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())}),Hr=(n,e,t)=>(e=n[Lt("asyncIterator")])?e.call(n):(n=n[Lt("iterator")](),e={},t=(r,s)=>(s=n[r])&&(e[r]=a=>new Promise((i,o,c)=>(a=s.call(n,a),c=a.done,Promise.resolve(a.value).then(u=>i({value:u,done:c}),o)))),t("next"),t("return"),e),Jr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Gr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var yt={exports:{}},Kr=yt.exports,Dt;function Xr(){return Dt||(Dt=1,function(n,e){(function(t,r){n.exports=r()})(Kr,function(){var t=typeof Promise=="function",r=typeof self=="object"?self:Jr,s=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",h=s&&typeof Symbol.iterator!="undefined",_=s&&typeof Symbol.toStringTag!="undefined",C=i&&typeof Set.prototype.entries=="function",A=a&&typeof Map.prototype.entries=="function",O=C&&Object.getPrototypeOf(new Set().entries()),P=A&&Object.getPrototypeOf(new Map().entries()),$=h&&typeof Array.prototype[Symbol.iterator]=="function",ie=$&&Object.getPrototypeOf([][Symbol.iterator]()),oe=h&&typeof String.prototype[Symbol.iterator]=="function",R=oe&&Object.getPrototypeOf(""[Symbol.iterator]()),T=8,Je=-1;function Ge(N){var Nt=typeof N;if(Nt!=="object")return Nt;if(N===null)return"null";if(N===r)return"global";if(Array.isArray(N)&&(_===!1||!(Symbol.toStringTag in N)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&N===window.location)return"Location";if(typeof window.document=="object"&&N===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&N===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&N===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&N instanceof window.HTMLElement){if(N.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(N.tagName==="TD")return"HTMLTableDataCellElement";if(N.tagName==="TH")return"HTMLTableHeaderCellElement"}}var jt=_&&N[Symbol.toStringTag];if(typeof jt=="string")return jt;var V=Object.getPrototypeOf(N);return V===RegExp.prototype?"RegExp":V===Date.prototype?"Date":t&&V===Promise.prototype?"Promise":i&&V===Set.prototype?"Set":a&&V===Map.prototype?"Map":c&&V===WeakSet.prototype?"WeakSet":o&&V===WeakMap.prototype?"WeakMap":u&&V===DataView.prototype?"DataView":a&&V===P?"Map Iterator":i&&V===O?"Set Iterator":$&&V===ie?"Array Iterator":oe&&V===R?"String Iterator":V===null?"Object":Object.prototype.toString.call(N).slice(T,Je)}return Ge})}(yt)),yt.exports}var Yr=Xr();const Qr=Gr(Yr),Ct=typeof Buffer!="undefined",es=Ct&&typeof Buffer.from!="undefined",ts=Ct?function(n){return Buffer.isBuffer(n)}:function(){return!1},ns=es?function(n){return Buffer.from(n)}:Ct?function(n){return new Buffer(n)}:function(n){return n};function Ee(n){return ts(n)?"Buffer":Qr(n)}const rs=new Set(["Arguments","Array","Map","Object","Set"]);function ss(n,e,t=null){switch(t||Ee(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function vt(n){return rs.has(n)}function Ut(n,e,t,r=null){switch(r||Ee(n)){case"Arguments":case"Array":case"Object":n[e]=t;break;case"Map":n.set(e,t);break;case"Set":n.add(t);break}return n}const as=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,is=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,os=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,ut=as||is||os||Function("return this")();function cs(n){return n.slice(0)}function ds(n){return new Boolean(n.valueOf())}function us(n){return new DataView(n.buffer)}function ls(n){return ns(n)}function fs(n){return new Date(n.getTime())}function hs(n){return new Number(n)}function ps(n){return new RegExp(n.source,n.flags)}function ms(n){return new String(n)}function ne(n,e){return ut[e].from?ut[e].from(n):new ut[e](n)}function Z(n){return n}function zt(){return[]}function gs(){return new Map}function ys(){return{}}function vs(){return new Set}const _s=new Map([["ArrayBuffer",cs],["Boolean",ds],["Buffer",ls],["DataView",us],["Date",fs],["Number",hs],["RegExp",ps],["String",ms],["Float32Array",ne],["Float64Array",ne],["Int16Array",ne],["Int32Array",ne],["Int8Array",ne],["Uint16Array",ne],["Uint32Array",ne],["Uint8Array",ne],["Uint8ClampedArray",ne],["Array Iterator",Z],["Map Iterator",Z],["Promise",Z],["Set Iterator",Z],["String Iterator",Z],["function",Z],["global",Z],["WeakMap",Z],["WeakSet",Z],["boolean",Z],["null",Z],["number",Z],["string",Z],["symbol",Z],["undefined",Z],["Arguments",zt],["Array",zt],["Map",gs],["Object",ys],["Set",vs]]);function bs(){}function _t(n,e=null,t=bs){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const r=e||Ee(n),s=_s.get(r);if(r==="Object"){const a=t(n,r);if(a!==void 0)return a}return s?s(n,r):n}function Ae(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,r=Ee(n);if(!vt(r))return bt(n,null,null,null);const s=_t(n,r,t),a=new WeakMap([[n,s]]),i=new WeakSet([n]);return bt(n,s,a,i)}function bt(n,e,t,r,s){const a=Ee(n),i=_t(n,a);if(!vt(a))return i;let o;switch(a){case"Arguments":case"Array":o=Object.keys(n);break;case"Object":o=Object.keys(n),o.push(...Object.getOwnPropertySymbols(n));break;case"Map":case"Set":o=n.keys();break}for(let c of o){const u=ss(n,c,a);if(r.has(u))Ut(e,c,t.get(u),a);else{const h=Ee(u),_=_t(u,h);vt(h)&&(t.set(u,_),r.add(u)),Ut(e,c,bt(u,_,t,r),a)}}return e}const ws=n=>new Promise(e=>setTimeout(e,n));var Ke,he,Xe,wt,vn;class xs{constructor({maxAttempts:e=3,func:t}){B(this,wt),B(this,Ke),B(this,he),B(this,Xe),j(this,Ke,e),j(this,Xe,t),j(this,he,0)}run(){return E(this,null,function*(){try{return yield k(this,Xe).call(this)}catch(e){if(j(this,he,k(this,he)+1),k(this,he)>k(this,Ke))throw console.error("Max attempts reached"),e;const t=Y(this,wt,vn).call(this);return yield ws(t),yield this.run()}})}}Ke=new WeakMap,he=new WeakMap,Xe=new WeakMap,wt=new WeakSet,vn=function(){return k(this,he)*1e3*1.5};function ks(){return typeof CompressionStream!="undefined"}function Ts(n){return E(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var r=Hr(e),s,a,i;s=!(a=yield r.next()).done;s=!1){const o=a.value;t.push(o)}}catch(o){i=[o]}finally{try{s&&(a=r.return)&&(yield a.call(r))}finally{if(i)throw i[0]}}return yield Ss(t)})}function Ss(n){return E(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class Es extends Error{constructor({resource:e,api:t,args:r,cause:s}){if(super(`API Error on resource "${e}" at api "${t}"`),this.causeProperties={},this.name="API Error",this.resource=e,this.api=t,this.cause=s,this.args=r,s instanceof Error)for(const[i,o]of Object.entries(s))if(typeof Headers!="undefined"&&o instanceof Headers){const c={};o.forEach((u,h)=>{c[h]=u}),this.causeProperties[i]=c}else this.causeProperties[i]=o;const a=this.causeProperties.body;a&&typeof a=="object"&&"code"in a&&(this.code=a.code)}}class Bt extends Error{constructor({url:e,method:t,statusCode:r,requestHeaders:s,responseHeaders:a,body:i}){if(super("Fetch Error"),this.name="Fetch Error",this.url=e,this.method=t,this.statusNumber=r,this.requestHeaders=s,this.responseHeaders=a,i)try{const o=JSON.parse(i);this.body=o}catch(o){this.body=i}}}class Ne extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class As extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class lt extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function _n(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function xt(){return Math.floor(Date.now()/1e3).toString()}const Os=5*60*1e3,Cs=1*1e3;var pe,L,K,kt,Tt,je;class Ns{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){B(this,K),B(this,pe),B(this,L),this.baseAddress=t,j(this,pe,e),j(this,L,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(e){this.plugins.push(e)}removePlugin(e){this.plugins=this.plugins.filter(t=>t.name!==e)}withOptions(e={}){return j(this,L,e),this}get(e){return E(this,arguments,function*(t,r={}){const{overrideBaseAddress:s,overrideDefaultHeaders:a}=r,i=s!=null?s:this.baseAddress;let o=a!=null?a:this.headers;const c=Ae(k(this,L));return j(this,L,{}),c.extraHeaders&&(o=D(D({},o),c.extraHeaders)),c.requestValidation&&(o=At(D({},o),{"X-Request-Nonce":_n(),"X-Request-Timestamp":xt()})),c.async?yield Y(this,K,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield Y(this,K,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return E(this,arguments,function*(r,s,a={}){const i=Ae(k(this,L));return j(this,L,{}),Y(this,K,je).call(this,r,"POST",s,a,i)})}put(e,t){return E(this,arguments,function*(r,s,a={}){const i=Ae(k(this,L));return j(this,L,{}),Y(this,K,je).call(this,r,"PUT",s,a,i)})}delete(e,t){return E(this,arguments,function*(r,s,a={}){const i=Ae(k(this,L));return j(this,L,{}),Y(this,K,je).call(this,r,"DELETE",s,a,i)})}patch(e,t){return E(this,arguments,function*(r,s,a={}){const i=Ae(k(this,L));return j(this,L,{}),Y(this,K,je).call(this,r,"PATCH",s,a,i)})}}pe=new WeakMap,L=new WeakMap,K=new WeakSet,kt=function(n,e,t){return E(this,null,function*(){const r=()=>E(this,null,function*(){var c,u;try{return yield k(this,pe).call(this,n,D(D({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(h){throw h instanceof Error&&h.name==="AbortError"?new Ne({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):h}}),{headers:s}=t!=null?t:{},a=(c,u)=>{var h,_;return((h=c==null?void 0:c.headers)==null?void 0:h.get(u))||((_=c==null?void 0:c.headersObject)==null?void 0:_[u])||""},i=c=>E(this,null,function*(){var u;if(!c.ok){const _=yield c.text().catch();throw new Bt({url:n,method:(u=t==null?void 0:t.method)!=null?u:"GET",statusCode:c.status,requestHeaders:s,responseHeaders:c.headers,body:_})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const _=a(c,"x-response-nonce"),C=s==null?void 0:s["X-Request-Nonce"];if(!_||_!==C)throw new lt("Response nonce mismatch");const A=Number(a(c,"x-response-timestamp")),O=Number(xt()),P=60*60*24;if(isNaN(A)||Math.abs(O-A)>P)throw new lt("Invalid response timestamp")}catch(_){const C=_ instanceof Error?_.message:"Request validation failed";throw new lt(C)}let h=yield c.text();try{h=JSON.parse(h)}catch(_){}return h});if(e.retry){const c=yield new xs({maxAttempts:e.retry,func:r}).run();return yield i(c)}const o=yield r();return yield i(o)})},Tt=function(n,e,t){return E(this,null,function*(){var r,s;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Cs,maxTimeout:c=Os}=e,u=`${n}/async`,h=`${n}/async/job`;let _;try{_=yield k(this,pe).call(this,u,D(D({},t),i&&{signal:i}))}catch(O){throw O instanceof Error&&O.name==="AbortError"?new Ne({canceled:(r=i==null?void 0:i.aborted)!=null?r:!1}):O}if(!_.ok){const O=yield _.text().catch();throw new Bt({url:n,method:(s=t==null?void 0:t.method)!=null?s:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:O})}const C=yield _.json(),{job_id:A}=C;if(!A)throw new Error("Job ID not found in response");return new Promise((O,P)=>E(this,null,function*(){const $=setTimeout(()=>{P(new Error("Job timed out"))},c),ie=(oe=0)=>E(this,null,function*(){if(i!=null&&i.aborted){clearTimeout($),k(this,pe).call(this,`${h}/${A}/cancel`,{method:"POST",headers:this.headers}).then(()=>{P(new Ne({canceled:!0}))}).catch(R=>{P(new Ne({canceled:!1}))});return}try{const R=yield(yield k(this,pe).call(this,`${h}/${A}`,{headers:this.headers})).json();if(R.status==="success"){clearTimeout($);const T=R.response_json;O(T)}else if(R.status==="failed")clearTimeout($),P(new As(R.response_json));else{a&&a(R.response_json);const T=o(oe);setTimeout(()=>ie(oe+1),T)}}catch(R){P(R)}});ie()}))})},je=function(n,e,t,r,s){return E(this,null,function*(){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=r,o=a!=null?a:this.baseAddress;let c=i!=null?i:this.headers;s.extraHeaders&&(c=D(D({},c),s.extraHeaders)),s.requestValidation&&(c=At(D({},c),{"X-Request-Nonce":_n(),"X-Request-Timestamp":xt()}));let u=r.skipBodyJsonStringify?t:JSON.stringify(t);return s.compress&&ks()&&(c["Content-Encoding"]="gzip",u=yield Ts(u)),s.async?yield Y(this,K,Tt).call(this,`${o}${n}`,s.async,{method:e,headers:c,body:u}):yield Y(this,K,kt).call(this,`${o}${n}`,s,{method:e,headers:c,body:u})})};const Wt=(n,e,t,r)=>n instanceof Ne?n:new Es({resource:e,api:String(t),args:r,cause:n}),ft=(n,e)=>new Proxy(e,{get(t,r){return(...s)=>{var a;for(const o of n.plugins){const c=(a=o.beforeApi)==null?void 0:a.call(o,{resource:t.resourceName,api:r,args:s});if(c!==void 0)return c}let i;try{i=t[r](...s)}catch(o){throw Wt(o,t.resourceName,r,s)}return i instanceof Promise?i.catch(o=>{throw Wt(o,t.resourceName,r,s)}):i}}});var Ie;class js{constructor(e){B(this,Ie),this.resourceName="Files",j(this,Ie,e)}get(e){return E(this,arguments,function*({fileKey:t,params:r={}}){const s=new URLSearchParams(D({plugin_data:"857346721138427857"},r)).toString(),a=`v1/files/${t}?${s}`;return yield k(this,Ie).get(a)})}getImageFills(e){return E(this,arguments,function*({fileKey:t}){var r,s;const a=`v1/files/${t}/images`;return(s=(r=(yield k(this,Ie).get(a)).meta)==null?void 0:r.images)!=null?s:{}})}}Ie=new WeakMap;const Is=(n,e,t)=>{const r=e.sort();return`${n}-${r.join("-")}-${t}`},Rs=n=>n?n.ts>Date.now()-1e3*30:!1;var X,St,bn;class Zs{constructor(e){B(this,St),B(this,X),this.resourceName="Images",j(this,X,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:r,format:s="jpg",scale:a}){const i=Is(t,r,s),o=k(this,X).cache.images.entries.get(i);if(Rs(o))return o.result;o&&k(this,X).cache.images.entries.delete(i);const c=k(this,X).cache.images.pendingRequests.get(i);if(c)return c;const u=Y(this,St,bn).call(this,i,t,r,s,a);k(this,X).cache.images.pendingRequests.set(i,u);try{return yield u}finally{k(this,X).cache.images.pendingRequests.delete(i)}})}}X=new WeakMap,St=new WeakSet,bn=function(n,e,t,r,s){return E(this,null,function*(){const a=yield k(this,X).get(`v1/images/${e}?ids=${t}&format=${r}${s?`&scale=${s}`:""}`);return k(this,X).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var Ye;class Ms{constructor(e){B(this,Ye),this.resourceName="Nodes",j(this,Ye,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:r,params:s={}}){const a=At(D({},s),{ids:r.join(",")}),i=new URLSearchParams(D({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield k(this,Ye).get(o)})}}Ye=new WeakMap;var ce;class wn extends Ns{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),B(this,ce,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=ft(this,new js(this)),this.nodes=ft(this,new Ms(this)),this.images=ft(this,new Zs(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");j(this,ce,e)}get token(){return k(this,ce)}get headers(){const e={"Content-Type":"application/json"};return k(this,ce).startsWith("figd_")?e["X-FIGMA-TOKEN"]=k(this,ce):k(this,ce).startsWith("figu_")&&(e.Authorization=`Bearer ${k(this,ce)}`),e}}ce=new WeakMap;const Ps=s=>F(exports,[s],function*({fileKey:n,authToken:e,figmaRestApi:t=new wn,params:r={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:r})}catch(a){throw console.error(a),a}}),$s=a=>F(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:r=new wn,params:s={}}){e&&(r.token=e);try{return(yield r.nodes.get({fileKey:n,nodeIds:t,params:d({},s)})).nodes}catch(i){return gn(i,n)}}),xn=(n,e)=>new ReadableStream({start(t){n.generateCode(e,r=>{r.type==="error"?(console.log("NOT SURE IF THIS IS REACHABLE, ALL ERRORS ARE THROWING"),t.enqueue({type:"error",payload:{message:r.payload.reason}})):t.enqueue(r),(r.type==="aborted"||r.type==="error")&&t.close()}).then(r=>{t.enqueue({type:"done"}),t.close()}).catch(r=>{t.enqueue({type:"error",payload:{message:"message"in r?r.message:"Unknown",status:"status"in r?r.status:void 0}}),t.close()})}}),Fs=(n,e)=>F(exports,null,function*(){var o,c,u,h,_,C,A;const t=xn(n,e),[r,s]=t.tee(),a=yield r.getReader().read();if(a.done||!a.value||((o=a.value)==null?void 0:o.type)==="error"&&((u=(c=a.value)==null?void 0:c.payload)!=null&&u.status))return new Response(JSON.stringify(a.value),{status:((h=a.value)==null?void 0:h.type)==="error"&&(A=(C=(_=a.value)==null?void 0:_.payload)==null?void 0:C.status)!=null?A:500,headers:{"Content-Type":"application/json"}});const i=s.pipeThrough(new TransformStream({transform(O,P){const $=`event: ${O.type}
3
- data: ${JSON.stringify(O)}
1
+ "use strict";var kn=Object.defineProperty,Tn=Object.defineProperties;var Sn=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var En=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var Zt=n=>{throw TypeError(n)};var Rt=(n,e,t)=>e in n?kn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))En.call(e,t)&&Rt(n,t,e[t]);if(It)for(var t of It(e))An.call(e,t)&&Rt(n,t,e[t]);return n},g=(n,e)=>Tn(n,Sn(e));var Mt=(n,e,t)=>e.has(n)||Zt("Cannot "+t);var X=(n,e,t)=>(Mt(n,e,"read from private field"),t?t.call(n):e.get(n)),ot=(n,e,t)=>e.has(n)?Zt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ct=(n,e,t,s)=>(Mt(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);var P=(n,e,t)=>new Promise((s,r)=>{var a=c=>{try{o(t.next(c))}catch(u){r(u)}},i=c=>{try{o(t.throw(c))}catch(u){r(u)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qt=n=>Object.entries(n).reduce((e,[t,s])=>(e[t]={content:s.code,isBinary:!1},e),{});class be extends Error{constructor({name:e,reason:t,status:s}){super(),this.name=`[Codegen Error] ${e}`,this.message=t,this.status=s}}var x;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return n.objectValues(i)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},n.find=(r,a)=>{for(const i of r)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var ht;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(ht||(ht={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=n=>{switch(typeof n){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(n)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(n)?p.array:n===null?p.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?p.promise:typeof Map!="undefined"&&n instanceof Map?p.map:typeof Set!="undefined"&&n instanceof Set?p.set:typeof Date!="undefined"&&n instanceof Date?p.date:p.object;default:return p.unknown}},l=x.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"]),On=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return r(this),s}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const Te=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===p.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:x.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case l.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(n)}return{message:t}};let Ht=Te;function Cn(n){Ht=n}function Qe(){return Ht}const et=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],i=g(d({},r),{path:a});if(r.message!==void 0)return g(d({},r),{path:a,message:r.message});let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return g(d({},r),{path:a,message:o})},Nn=[];function f(n,e){const t=Qe(),s=et({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Te?void 0:Te].filter(r=>!!r)});n.common.issues.push(s)}class I{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return v;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static mergeObjectAsync(e,t){return P(this,null,function*(){const s=[];for(const r of t){const a=yield r.key,i=yield r.value;s.push({key:a,value:i})}return I.mergeObjectSync(e,s)})}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const v=Object.freeze({status:"aborted"}),xe=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),pt=n=>n.status==="aborted",mt=n=>n.status==="dirty",ye=n=>n.status==="valid",Ze=n=>typeof Promise!="undefined"&&n instanceof Promise;function tt(n,e,t,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Jt(n,e,t,s,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var m;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));var Ce,Ne;class ne{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Pt=(n,e)=>{if(ye(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var c,u;const{message:h}=n;return i.code==="invalid_enum_value"?{message:h!=null?h:o.defaultError}:typeof o.data=="undefined"?{message:(c=h!=null?h:s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=h!=null?h:t)!==null&&u!==void 0?u:o.defaultError}},description:r}}class w{get description(){return this._def.description}_getType(e){return oe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ze(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Pt(r,a)}"~validate"(e){var t,s;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:r});return ye(a)?{value:a.value}:{issues:r.common.issues}}catch(a){!((s=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||s===void 0)&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(a=>ye(a)?{value:a.value}:{issues:r.common.issues})}parseAsync(e,t){return P(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return P(this,null,function*(){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)},r=this._parse({data:e,path:s.path,parent:s}),a=yield Ze(r)?r:Promise.resolve(r);return Pt(s,a)})}refine(e,t){const s=r=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue(d({code:l.custom},s(r)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new G({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return te.create(this,this._def)}nullable(){return he.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this)}promise(){return Ee.create(this,this._def)}or(e){return Fe.create([this,e],this._def)}and(e){return Le.create(this,e,this._def)}transform(e){return new G(g(d({},b(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new Be(g(d({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Et(d({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new We(g(d({},b(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return Je.create(this,e)}readonly(){return qe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const jn=/^c[^\s-]{8,}$/i,In=/^[0-9a-z]+$/,Rn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zn=/^[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,Mn=/^[a-z0-9_-]{21}$/i,Pn=/^[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)?)??$/,Fn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ln="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let dt;const Vn=/^(?:(?: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])$/,Dn=/^(?:(?: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])$/,Un=/^(([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]))$/,zn=/^(([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])$/,Bn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Gt="((\\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])))",qn=new RegExp(`^${Gt}$`);function Kt(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Hn(n){return new RegExp(`^${Kt(n)}$`)}function Xt(n){let e=`${Gt}T${Kt(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Jn(n,e){return!!((e==="v4"||!e)&&Vn.test(n)||(e==="v6"||!e)&&Un.test(n))}function Gn(n,e){if(!Pn.test(n))return!1;try{const[t]=n.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||!r.typ||!r.alg||e&&r.alg!==e)}catch(t){return!1}}function Kn(n,e){return!!((e==="v4"||!e)&&Dn.test(n)||(e==="v6"||!e)&&zn.test(n))}class H extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const s=new I;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?f(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Fn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")dt||(dt=new RegExp(Ln,"u")),dt.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Zn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Mn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")jn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")In.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Rn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:l.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:l.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Xt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?qn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Hn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?$n.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Jn(e.data,a.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Gn(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"jwt",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Kn(e.data,a.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cidr",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Bn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Wn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64url",code:l.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),d({validation:t,code:l.invalid_string},m.errToObj(s)))}_addCheck(e){return new H(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.errToObj(e)))}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1},m.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new H(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new H(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new H(g(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}H.create=n=>{var e;return new H(d({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};function Xn(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class ue extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let s;const r=new I;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Xn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_finite,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,r){return new ue(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new ue(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ue.create=n=>new ue(d({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class le extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let s;const r=new I;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),f(s,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,r){return new le(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new le(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}le.create=n=>{var e;return new le(d({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};class Me extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),v}return M(e.data)}}Me.create=n=>new Me(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class ve extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_date}),v}const s=new I;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ve(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ve.create=n=>new ve(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate},b(n)));class nt extends w{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),v}return M(e.data)}}nt.create=n=>new nt(d({typeName:y.ZodSymbol},b(n)));class Pe extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),v}return M(e.data)}}Pe.create=n=>new Pe(d({typeName:y.ZodUndefined},b(n)));class $e extends w{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),v}return M(e.data)}}$e.create=n=>new $e(d({typeName:y.ZodNull},b(n)));class Se extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}Se.create=n=>new Se(d({typeName:y.ZodAny},b(n)));class ge extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}ge.create=n=>new ge(d({typeName:y.ZodUnknown},b(n)));class ce extends w{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}ce.create=n=>new ce(d({typeName:y.ZodNever},b(n)));class st extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),v}return M(e.data)}}st.create=n=>new st(d({typeName:y.ZodVoid},b(n)));class J extends w{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==p.array)return f(t,{code:l.invalid_type,expected:p.array,received:t.parsedType}),v;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(f(t,{code:i?l.too_big:l.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(f(t,{code:l.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(f(t,{code:l.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new ne(t,i,t.path,o)))).then(i=>I.mergeArray(s,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new ne(t,i,t.path,o)));return I.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new J(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new J(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new J(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}J.create=(n,e)=>new J(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function we(n){if(n instanceof S){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=te.create(we(s))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof J?new J(g(d({},n._def),{type:we(n.element)})):n instanceof te?te.create(we(n.unwrap())):n instanceof he?he.create(we(n.unwrap())):n instanceof se?se.create(n.items.map(e=>we(e))):n}class S extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return f(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),v}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ce&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const h=a[u],_=r.data[u];c.push({key:{status:"valid",value:u},value:h._parse(new ne(r,_,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof ce){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(u==="strict")o.length>0&&(f(r,{code:l.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of o){const _=r.data[h];c.push({key:{status:"valid",value:h},value:u._parse(new ne(r,_,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(()=>P(this,null,function*(){const u=[];for(const h of c){const _=yield h.key,N=yield h.value;u.push({key:_,value:N,alwaysSet:h.alwaysSet})}return u})).then(u=>I.mergeObjectSync(s,u)):I.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new S(d(g(d({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,s)=>{var r,a,i,o;const c=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}))}strip(){return new S(g(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new S(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new S(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S(g(d({},this._def),{catchall:e}))}pick(e){const t={};return x.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new S(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return x.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new S(g(d({},this._def),{shape:()=>t}))}deepPartial(){return we(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new S(g(d({},this._def),{shape:()=>t}))}required(e){const t={};return x.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof te;)a=a._def.innerType;t[s]=a}}),new S(g(d({},this._def),{shape:()=>t}))}keyof(){return Yt(x.objectKeys(this.shape))}}S.create=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strip",catchall:ce.create(),typeName:y.ZodObject},b(e)));S.strictCreate=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strict",catchall:ce.create(),typeName:y.ZodObject},b(e)));S.lazycreate=(n,e)=>new S(d({shape:n,unknownKeys:"strip",catchall:ce.create(),typeName:y.ZodObject},b(e)));class Fe extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new U(o.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(s.map(a=>P(this,null,function*(){const i=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(r);{let a;const i=[];for(const c of s){const u=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null}),h=c._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new U(c));return f(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Fe.create=(n,e)=>new Fe(d({options:n,typeName:y.ZodUnion},b(e)));const ie=n=>n instanceof De?ie(n.schema):n instanceof G?ie(n.innerType()):n instanceof Ue?[n.value]:n instanceof fe?n.options:n instanceof ze?x.objectValues(n.enum):n instanceof Be?ie(n._def.innerType):n instanceof Pe?[void 0]:n instanceof $e?[null]:n instanceof te?[void 0,...ie(n.unwrap())]:n instanceof he?[null,...ie(n.unwrap())]:n instanceof Et||n instanceof qe?ie(n.unwrap()):n instanceof We?ie(n._def.innerType):[];class it extends w{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return f(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),v;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const i=ie(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new it(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r},b(s)))}}function gt(n,e){const t=oe(n),s=oe(e);if(n===e)return{valid:!0,data:n};if(t===p.object&&s===p.object){const r=x.objectKeys(e),a=x.objectKeys(n).filter(o=>r.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=gt(n[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===p.array&&s===p.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],c=gt(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===p.date&&s===p.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Le extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(pt(a)||pt(i))return v;const o=gt(a.value,i.value);return o.valid?((mt(a)||mt(i))&&t.dirty(),{status:t.value,value:o.data}):(f(s,{code:l.invalid_intersection_types}),v)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Le.create=(n,e,t)=>new Le(d({left:n,right:e,typeName:y.ZodIntersection},b(t)));class se extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return f(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),v;if(s.data.length<this._def.items.length)return f(s,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&s.data.length>this._def.items.length&&(f(s,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new ne(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>I.mergeArray(t,i)):I.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new se(g(d({},this._def),{rest:e}))}}se.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new se(d({items:n,typeName:y.ZodTuple,rest:null},b(e)))};class Ve extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return f(s,{code:l.invalid_type,expected:p.object,received:s.parsedType}),v;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new ne(s,o,s.path,o)),value:i._parse(new ne(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?I.mergeObjectAsync(t,r):I.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof w?new Ve(d({keyType:e,valueType:t,typeName:y.ZodRecord},b(s))):new Ve(d({keyType:H.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class rt extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return f(s,{code:l.invalid_type,expected:p.map,received:s.parsedType}),v;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:r._parse(new ne(s,o,s.path,[u,"key"])),value:a._parse(new ne(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>P(this,null,function*(){for(const c of i){const u=yield c.key,h=yield c.value;if(u.status==="aborted"||h.status==="aborted")return v;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,h=c.value;if(u.status==="aborted"||h.status==="aborted")return v;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(u.value,h.value)}return{status:t.value,value:o}}}}rt.create=(n,e,t)=>new rt(d({valueType:e,keyType:n,typeName:y.ZodMap},b(t)));class _e extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return f(s,{code:l.invalid_type,expected:p.set,received:s.parsedType}),v;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(f(s,{code:l.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(f(s,{code:l.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const h of c){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new ne(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new _e(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new _e(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(n,e)=>new _e(d({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class ke extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return f(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),v;function s(o,c){return et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),Te].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function r(o,c){return et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),Te].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ee){const o=this;return M(function(...c){return P(this,null,function*(){const u=new U([]),h=yield o._def.args.parseAsync(c,a).catch(O=>{throw u.addIssue(s(c,O)),u}),_=yield Reflect.apply(i,this,h);return yield o._def.returns._def.type.parseAsync(_,a).catch(O=>{throw u.addIssue(r(_,O)),u})})})}else{const o=this;return M(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new U([s(c,u.error)]);const h=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(h,a);if(!_.success)throw new U([r(h,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ke(g(d({},this._def),{args:se.create(e).rest(ge.create())}))}returns(e){return new ke(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new ke(d({args:e||se.create([]).rest(ge.create()),returns:t||ge.create(),typeName:y.ZodFunction},b(s)))}}class De extends w{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}De.create=(n,e)=>new De(d({getter:n,typeName:y.ZodLazy},b(e)));class Ue extends w{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ue.create=(n,e)=>new Ue(d({value:n,typeName:y.ZodLiteral},b(e)));function Yt(n,e){return new fe(d({values:n,typeName:y.ZodEnum},b(e)))}class fe extends w{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{expected:x.joinValues(s),received:t.parsedType,code:l.invalid_type}),v}if(tt(this,Ce)||Jt(this,Ce,new Set(this._def.values)),!tt(this,Ce).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:s}),v}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return fe.create(this.options.filter(s=>!e.includes(s)),d(d({},this._def),t))}}Ce=new WeakMap;fe.create=Yt;class ze extends w{constructor(){super(...arguments),Ne.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){const r=x.objectValues(t);return f(s,{expected:x.joinValues(r),received:s.parsedType,code:l.invalid_type}),v}if(tt(this,Ne)||Jt(this,Ne,new Set(x.getValidEnumValues(this._def.values))),!tt(this,Ne).has(e.data)){const r=x.objectValues(t);return f(s,{received:s.data,code:l.invalid_enum_value,options:r}),v}return M(e.data)}get enum(){return this._def.values}}Ne=new WeakMap;ze.create=(n,e)=>new ze(d({values:n,typeName:y.ZodNativeEnum},b(e)));class Ee extends w{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),v;const s=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return M(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ee.create=(n,e)=>new Ee(d({type:n,typeName:y.ZodPromise},b(e)));class G extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{f(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(o=>P(this,null,function*(){if(t.value==="aborted")return v;const c=yield this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?xe(c.value):c}));{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?xe(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ye(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>ye(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(r)}}G.create=(n,e,t)=>new G(d({schema:n,typeName:y.ZodEffects,effect:e},b(t)));G.createWithPreprocess=(n,e,t)=>new G(d({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects},b(t)));class te extends w{_parse(e){return this._getType(e)===p.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}te.create=(n,e)=>new te(d({innerType:n,typeName:y.ZodOptional},b(e)));class he extends w{_parse(e){return this._getType(e)===p.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(n,e)=>new he(d({innerType:n,typeName:y.ZodNullable},b(e)));class Be extends w{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Be.create=(n,e)=>new Be(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class We extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=g(d({},t),{common:g(d({},t.common),{issues:[]})}),r=this._def.innerType._parse({data:s.data,path:s.path,parent:d({},s)});return Ze(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}We.create=(n,e)=>new We(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class at extends w{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return f(s,{code:l.invalid_type,expected:p.nan,received:s.parsedType}),v}return{status:"valid",value:e.data}}}at.create=n=>new at(d({typeName:y.ZodNaN},b(n)));const Yn=Symbol("zod_brand");class Et extends w{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Je extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return P(this,null,function*(){const a=yield this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),xe(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})});{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?v:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new Je({in:e,out:t,typeName:y.ZodPipeline})}}class qe extends w{_parse(e){const t=this._def.innerType._parse(e),s=r=>(ye(r)&&(r.value=Object.freeze(r.value)),r);return Ze(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}qe.create=(n,e)=>new qe(d({innerType:n,typeName:y.ZodReadonly},b(e)));function Qt(n,e={},t){return n?Se.create().superRefine((s,r)=>{var a,i;if(!n(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;r.addIssue(g(d({code:"custom"},u),{fatal:c}))}}):Se.create()}const Qn={object:S.lazycreate};var y;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(y||(y={}));const es=(n,e={message:`Input not instance of ${n.name}`})=>Qt(t=>t instanceof n,e),en=H.create,tn=ue.create,ts=at.create,ns=le.create,nn=Me.create,ss=ve.create,rs=nt.create,as=Pe.create,is=$e.create,os=Se.create,cs=ge.create,ds=ce.create,us=st.create,ls=J.create,fs=S.create,hs=S.strictCreate,ps=Fe.create,ms=it.create,gs=Le.create,ys=se.create,vs=Ve.create,_s=rt.create,bs=_e.create,ws=ke.create,xs=De.create,ks=Ue.create,Ts=fe.create,Ss=ze.create,Es=Ee.create,$t=G.create,As=te.create,Os=he.create,Cs=G.createWithPreprocess,Ns=Je.create,js=()=>en().optional(),Is=()=>tn().optional(),Rs=()=>nn().optional(),Zs={string:n=>H.create(g(d({},n),{coerce:!0})),number:n=>ue.create(g(d({},n),{coerce:!0})),boolean:n=>Me.create(g(d({},n),{coerce:!0})),bigint:n=>le.create(g(d({},n),{coerce:!0})),date:n=>ve.create(g(d({},n),{coerce:!0}))},Ms=v;var V=Object.freeze({__proto__:null,defaultErrorMap:Te,setErrorMap:Cn,getErrorMap:Qe,makeIssue:et,EMPTY_PATH:Nn,addIssueToContext:f,ParseStatus:I,INVALID:v,DIRTY:xe,OK:M,isAborted:pt,isDirty:mt,isValid:ye,isAsync:Ze,get util(){return x},get objectUtil(){return ht},ZodParsedType:p,getParsedType:oe,ZodType:w,datetimeRegex:Xt,ZodString:H,ZodNumber:ue,ZodBigInt:le,ZodBoolean:Me,ZodDate:ve,ZodSymbol:nt,ZodUndefined:Pe,ZodNull:$e,ZodAny:Se,ZodUnknown:ge,ZodNever:ce,ZodVoid:st,ZodArray:J,ZodObject:S,ZodUnion:Fe,ZodDiscriminatedUnion:it,ZodIntersection:Le,ZodTuple:se,ZodRecord:Ve,ZodMap:rt,ZodSet:_e,ZodFunction:ke,ZodLazy:De,ZodLiteral:Ue,ZodEnum:fe,ZodNativeEnum:ze,ZodPromise:Ee,ZodEffects:G,ZodTransformer:G,ZodOptional:te,ZodNullable:he,ZodDefault:Be,ZodCatch:We,ZodNaN:at,BRAND:Yn,ZodBranded:Et,ZodPipeline:Je,ZodReadonly:qe,custom:Qt,Schema:w,ZodSchema:w,late:Qn,get ZodFirstPartyTypeKind(){return y},coerce:Zs,any:os,array:ls,bigint:ns,boolean:nn,date:ss,discriminatedUnion:ms,effect:$t,enum:Ts,function:ws,instanceof:es,intersection:gs,lazy:xs,literal:ks,map:_s,nan:ts,nativeEnum:Ss,never:ds,null:is,nullable:Os,number:tn,object:fs,oboolean:Rs,onumber:Is,optional:As,ostring:js,pipeline:Ns,preprocess:Cs,promise:Es,record:vs,set:bs,strictObject:hs,string:en,symbol:rs,transformer:$t,tuple:ys,undefined:as,union:ps,unknown:cs,void:us,NEVER:Ms,ZodIssueCode:l,quotelessJson:On,ZodError:U});const Ps=V.object({language:V.enum(["typescript","javascript"]).optional()}).and(V.union([V.object({framework:V.literal("react"),model:V.string().optional(),styling:V.enum(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:V.enum(["mui","antd","radix","shadcn"]).optional(),enableUILibraryTheming:V.boolean().optional()}),V.object({framework:V.literal("html"),styling:V.enum(["plain_css","inline_styles"]),enableTranslation:V.boolean().optional()})])),sn=n=>{const e=Ps.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data};var B,He;class $s{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){ot(this,B);ot(this,He);ct(this,He,t),e&&(this.auth=e)}hasAuth(){return!!X(this,B)}set auth(e){ct(this,B,e)}get headers(){const e={"Content-Type":"application/json"};return X(this,B)&&(e.Authorization=`Bearer ${X(this,B).token}`,"teamId"in X(this,B)&&(e["X-Team-Id"]=X(this,B).teamId),"userId"in X(this,B)&&X(this,B).userId&&(e["X-User-Id"]=X(this,B).userId)),e}generateCode(s){return P(this,arguments,function*(e,t={}){var h,_,N,O,C,R,q;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const r={},a=sn(e.settings),i=yield fetch(`${X(this,He)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,assetsStorage:e.assetsStorage,language:a.language,model:a.model,framework:a.framework,styling:a.styling,uiLibrary:a.uiLibrary,enableTranslation:a.enableTranslation,enableUILibraryTheming:a.enableUILibraryTheming})});if(!i.ok){let z;try{z=(yield i.json()).message||`HTTP error! status: ${i.status}`}catch(re){z=`HTTP error! status: ${i.status}`}throw new be({name:"HTTP Error",reason:z,status:i.status})}if(!i.body)throw new be({name:"Stream Error",reason:"Response body is null",status:i.status});const o=i.body.getReader(),c=new TextDecoder;let u="";try{for(;;){const{done:z,value:re}=yield o.read();if(z)break;u+=c.decode(re,{stream:!0});const F=u.split(`
2
+ `);u=F.pop()||"";for(const K of F)if(!(!K.trim()||K.startsWith(":"))&&K.startsWith("data: ")){let T;try{T=JSON.parse(K.slice(6))}catch(Ge){continue}switch(T.type){case"start":{r.sessionId=T.sessionId,typeof t=="function"?t(T):(h=t.onStart)==null||h.call(t,{sessionId:T.sessionId});break}case"pre_codegen":{typeof t=="function"?t(T):(_=t.onPreCodegen)==null||_.call(t,{message:T.message});break}case"assets_uploaded":{typeof t=="function"?t(T):(N=t.onAssetsUploaded)==null||N.call(t);break}case"assets_list":{r.assets=T.payload.assets,typeof t=="function"?t(T):(O=t.onAssetsList)==null||O.call(t,T.payload);break}case"figma_metadata":{r.figmaFileName=T.figmaFileName,r.figmaSelectedFrameName=T.figmaSelectedFrameName,typeof t=="function"?t(T):(C=t.onFigmaMetadata)==null||C.call(t,{figmaFileName:T.figmaFileName,figmaSelectedFrameName:T.figmaSelectedFrameName});break}case"generating_code":{const Ge=T.payload.files,A=qt(Ge);T.payload.status==="success"&&(r.files=A),typeof t=="function"?t(T):(R=t.onGeneratingCode)==null||R.call(t,{status:T.payload.status,progress:T.payload.progress,files:A});break}case"codegen_completed":{typeof t=="function"?t(T):(q=t.onCodegenCompleted)==null||q.call(t);break}case"error":throw new be({name:T.payload.errorName,reason:T.payload.reason});case"done":{if(!r.files)throw new be({name:"Invalid response",reason:"No files found"});return r}}}}}finally{o.cancel()}throw new be({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}B=new WeakMap,He=new WeakMap;const Fs=n=>{var e;if(!n)return[!1,"",""];try{const t=new URL(n),s=t.pathname;if(t.origin!=="https://www.figma.com")return[!1,"",""];const r=((e=t.searchParams.get("node-id"))!=null?e:"").replace(/-/g,":"),a=s.split("/")[2];return[(s.startsWith("/file/")&&t.searchParams.get("type")!=="whiteboard"||s.startsWith("/design/"))&&a.length===22,a,r]}catch(t){return[!1,"",""]}},Ls=({fileKey:n,nodeId:e})=>{const t=new URL("https://www.figma.com");return t.pathname=`design/${n}`,e&&t.searchParams.set("node-id",e.replace(":","-")),t},rn="Figma Token Issue";class an extends Error{constructor({fileKey:e,reason:t}){super(rn),this.fileKey=e,this.reason=t}}const on="Rate Limit Exceeded";class cn extends Error{constructor({fileKey:e}){super(on),this.fileKey=e}}const dn="Not Found";class un extends Error{constructor({fileKey:e}){super(dn),this.fileKey=e}}const ln=n=>n.message===dn,fn="Unknown Figma API Exception";class hn extends Error{constructor({fileKey:e,cause:t}){super(fn),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Vs=n=>n.message===fn,pn=n=>n.message===on,mn=n=>[rn,...["Invalid Figma token","Figma token expired"]].includes(n.message),gn=(n,e)=>{var s,r;const t=((s=n==null?void 0:n.cause)==null?void 0:s.body)||n.body;throw(t==null?void 0:t.status)===403?new an({fileKey:e,reason:((r=n==null?void 0:n.cause)==null?void 0:r.body)||n.body}):(t==null?void 0:t.status)===429?new cn({fileKey:e}):(t==null?void 0:t.status)===404?new un({fileKey:e}):new hn({fileKey:e,cause:n})},Ds=n=>ln(n)?"NotFound":pn(n)?"RateLimitExceeded":mn(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var Us=Object.defineProperty,zs=Object.defineProperties,Bs=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,Ws=Object.prototype.hasOwnProperty,qs=Object.prototype.propertyIsEnumerable,Lt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),yn=n=>{throw TypeError(n)},Vt=(n,e,t)=>e in n?Us(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))Ws.call(e,t)&&Vt(n,t,e[t]);if(Ft)for(var t of Ft(e))qs.call(e,t)&&Vt(n,t,e[t]);return n},At=(n,e)=>zs(n,Bs(e)),Ot=(n,e,t)=>e.has(n)||yn("Cannot "+t),k=(n,e,t)=>(Ot(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>e.has(n)?yn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,s)=>(Ot(n,e,"write to private field"),e.set(n,t),t),ee=(n,e,t)=>(Ot(n,e,"access private method"),t),E=(n,e,t)=>new Promise((s,r)=>{var a=c=>{try{o(t.next(c))}catch(u){r(u)}},i=c=>{try{o(t.throw(c))}catch(u){r(u)}},o=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(n,e)).next())}),Hs=(n,e,t)=>(e=n[Lt("asyncIterator")])?e.call(n):(n=n[Lt("iterator")](),e={},t=(s,r)=>(r=n[s])&&(e[s]=a=>new Promise((i,o,c)=>(a=r.call(n,a),c=a.done,Promise.resolve(a.value).then(u=>i({value:u,done:c}),o)))),t("next"),t("return"),e),Js=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Gs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var yt={exports:{}},Ks=yt.exports,Dt;function Xs(){return Dt||(Dt=1,function(n,e){(function(t,s){n.exports=s()})(Ks,function(){var t=typeof Promise=="function",s=typeof self=="object"?self:Js,r=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",h=r&&typeof Symbol.iterator!="undefined",_=r&&typeof Symbol.toStringTag!="undefined",N=i&&typeof Set.prototype.entries=="function",O=a&&typeof Map.prototype.entries=="function",C=N&&Object.getPrototypeOf(new Set().entries()),R=O&&Object.getPrototypeOf(new Map().entries()),q=h&&typeof Array.prototype[Symbol.iterator]=="function",z=q&&Object.getPrototypeOf([][Symbol.iterator]()),re=h&&typeof String.prototype[Symbol.iterator]=="function",F=re&&Object.getPrototypeOf(""[Symbol.iterator]()),K=8,T=-1;function Ge(A){var Nt=typeof A;if(Nt!=="object")return Nt;if(A===null)return"null";if(A===s)return"global";if(Array.isArray(A)&&(_===!1||!(Symbol.toStringTag in A)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&A===window.location)return"Location";if(typeof window.document=="object"&&A===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&A===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&A===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&A instanceof window.HTMLElement){if(A.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(A.tagName==="TD")return"HTMLTableDataCellElement";if(A.tagName==="TH")return"HTMLTableHeaderCellElement"}}var jt=_&&A[Symbol.toStringTag];if(typeof jt=="string")return jt;var L=Object.getPrototypeOf(A);return L===RegExp.prototype?"RegExp":L===Date.prototype?"Date":t&&L===Promise.prototype?"Promise":i&&L===Set.prototype?"Set":a&&L===Map.prototype?"Map":c&&L===WeakSet.prototype?"WeakSet":o&&L===WeakMap.prototype?"WeakMap":u&&L===DataView.prototype?"DataView":a&&L===R?"Map Iterator":i&&L===C?"Set Iterator":q&&L===z?"Array Iterator":re&&L===F?"String Iterator":L===null?"Object":Object.prototype.toString.call(A).slice(K,T)}return Ge})}(yt)),yt.exports}var Ys=Xs();const Qs=Gs(Ys),Ct=typeof Buffer!="undefined",er=Ct&&typeof Buffer.from!="undefined",tr=Ct?function(n){return Buffer.isBuffer(n)}:function(){return!1},nr=er?function(n){return Buffer.from(n)}:Ct?function(n){return new Buffer(n)}:function(n){return n};function Ae(n){return tr(n)?"Buffer":Qs(n)}const sr=new Set(["Arguments","Array","Map","Object","Set"]);function rr(n,e,t=null){switch(t||Ae(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function vt(n){return sr.has(n)}function Ut(n,e,t,s=null){switch(s||Ae(n)){case"Arguments":case"Array":case"Object":n[e]=t;break;case"Map":n.set(e,t);break;case"Set":n.add(t);break}return n}const ar=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,ir=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,or=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,ut=ar||ir||or||Function("return this")();function cr(n){return n.slice(0)}function dr(n){return new Boolean(n.valueOf())}function ur(n){return new DataView(n.buffer)}function lr(n){return nr(n)}function fr(n){return new Date(n.getTime())}function hr(n){return new Number(n)}function pr(n){return new RegExp(n.source,n.flags)}function mr(n){return new String(n)}function ae(n,e){return ut[e].from?ut[e].from(n):new ut[e](n)}function Z(n){return n}function zt(){return[]}function gr(){return new Map}function yr(){return{}}function vr(){return new Set}const _r=new Map([["ArrayBuffer",cr],["Boolean",dr],["Buffer",lr],["DataView",ur],["Date",fr],["Number",hr],["RegExp",pr],["String",mr],["Float32Array",ae],["Float64Array",ae],["Int16Array",ae],["Int32Array",ae],["Int8Array",ae],["Uint16Array",ae],["Uint32Array",ae],["Uint8Array",ae],["Uint8ClampedArray",ae],["Array Iterator",Z],["Map Iterator",Z],["Promise",Z],["Set Iterator",Z],["String Iterator",Z],["function",Z],["global",Z],["WeakMap",Z],["WeakSet",Z],["boolean",Z],["null",Z],["number",Z],["string",Z],["symbol",Z],["undefined",Z],["Arguments",zt],["Array",zt],["Map",gr],["Object",yr],["Set",vr]]);function br(){}function _t(n,e=null,t=br){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Ae(n),r=_r.get(s);if(s==="Object"){const a=t(n,s);if(a!==void 0)return a}return r?r(n,s):n}function Oe(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Ae(n);if(!vt(s))return bt(n,null,null,null);const r=_t(n,s,t),a=new WeakMap([[n,r]]),i=new WeakSet([n]);return bt(n,r,a,i)}function bt(n,e,t,s,r){const a=Ae(n),i=_t(n,a);if(!vt(a))return i;let o;switch(a){case"Arguments":case"Array":o=Object.keys(n);break;case"Object":o=Object.keys(n),o.push(...Object.getOwnPropertySymbols(n));break;case"Map":case"Set":o=n.keys();break}for(let c of o){const u=rr(n,c,a);if(s.has(u))Ut(e,c,t.get(u),a);else{const h=Ae(u),_=_t(u,h);vt(h)&&(t.set(u,_),s.add(u)),Ut(e,c,bt(u,_,t,s),a)}}return e}const wr=n=>new Promise(e=>setTimeout(e,n));var Ke,pe,Xe,wt,vn;class xr{constructor({maxAttempts:e=3,func:t}){W(this,wt),W(this,Ke),W(this,pe),W(this,Xe),j(this,Ke,e),j(this,Xe,t),j(this,pe,0)}run(){return E(this,null,function*(){try{return yield k(this,Xe).call(this)}catch(e){if(j(this,pe,k(this,pe)+1),k(this,pe)>k(this,Ke))throw console.error("Max attempts reached"),e;const t=ee(this,wt,vn).call(this);return yield wr(t),yield this.run()}})}}Ke=new WeakMap,pe=new WeakMap,Xe=new WeakMap,wt=new WeakSet,vn=function(){return k(this,pe)*1e3*1.5};function kr(){return typeof CompressionStream!="undefined"}function Tr(n){return E(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var s=Hs(e),r,a,i;r=!(a=yield s.next()).done;r=!1){const o=a.value;t.push(o)}}catch(o){i=[o]}finally{try{r&&(a=s.return)&&(yield a.call(s))}finally{if(i)throw i[0]}}return yield Sr(t)})}function Sr(n){return E(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class Er extends Error{constructor({resource:e,api:t,args:s,cause:r}){if(super(`API Error on resource "${e}" at api "${t}"`),this.causeProperties={},this.name="API Error",this.resource=e,this.api=t,this.cause=r,this.args=s,r instanceof Error)for(const[i,o]of Object.entries(r))if(typeof Headers!="undefined"&&o instanceof Headers){const c={};o.forEach((u,h)=>{c[h]=u}),this.causeProperties[i]=c}else this.causeProperties[i]=o;const a=this.causeProperties.body;a&&typeof a=="object"&&"code"in a&&(this.code=a.code)}}class Bt extends Error{constructor({url:e,method:t,statusCode:s,requestHeaders:r,responseHeaders:a,body:i}){if(super("Fetch Error"),this.name="Fetch Error",this.url=e,this.method=t,this.statusNumber=s,this.requestHeaders=r,this.responseHeaders=a,i)try{const o=JSON.parse(i);this.body=o}catch(o){this.body=i}}}class je extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class Ar extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class lt extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function _n(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function xt(){return Math.floor(Date.now()/1e3).toString()}const Or=5*60*1e3,Cr=1*1e3;var me,$,Y,kt,Tt,Ie;class Nr{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){W(this,Y),W(this,me),W(this,$),this.baseAddress=t,j(this,me,e),j(this,$,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(e){this.plugins.push(e)}removePlugin(e){this.plugins=this.plugins.filter(t=>t.name!==e)}withOptions(e={}){return j(this,$,e),this}get(e){return E(this,arguments,function*(t,s={}){const{overrideBaseAddress:r,overrideDefaultHeaders:a}=s,i=r!=null?r:this.baseAddress;let o=a!=null?a:this.headers;const c=Oe(k(this,$));return j(this,$,{}),c.extraHeaders&&(o=D(D({},o),c.extraHeaders)),c.requestValidation&&(o=At(D({},o),{"X-Request-Nonce":_n(),"X-Request-Timestamp":xt()})),c.async?yield ee(this,Y,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield ee(this,Y,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(k(this,$));return j(this,$,{}),ee(this,Y,Ie).call(this,s,"POST",r,a,i)})}put(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(k(this,$));return j(this,$,{}),ee(this,Y,Ie).call(this,s,"PUT",r,a,i)})}delete(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(k(this,$));return j(this,$,{}),ee(this,Y,Ie).call(this,s,"DELETE",r,a,i)})}patch(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(k(this,$));return j(this,$,{}),ee(this,Y,Ie).call(this,s,"PATCH",r,a,i)})}}me=new WeakMap,$=new WeakMap,Y=new WeakSet,kt=function(n,e,t){return E(this,null,function*(){const s=()=>E(this,null,function*(){var c,u;try{return yield k(this,me).call(this,n,D(D({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(h){throw h instanceof Error&&h.name==="AbortError"?new je({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):h}}),{headers:r}=t!=null?t:{},a=(c,u)=>{var h,_;return((h=c==null?void 0:c.headers)==null?void 0:h.get(u))||((_=c==null?void 0:c.headersObject)==null?void 0:_[u])||""},i=c=>E(this,null,function*(){var u;if(!c.ok){const _=yield c.text().catch();throw new Bt({url:n,method:(u=t==null?void 0:t.method)!=null?u:"GET",statusCode:c.status,requestHeaders:r,responseHeaders:c.headers,body:_})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const _=a(c,"x-response-nonce"),N=r==null?void 0:r["X-Request-Nonce"];if(!_||_!==N)throw new lt("Response nonce mismatch");const O=Number(a(c,"x-response-timestamp")),C=Number(xt()),R=60*60*24;if(isNaN(O)||Math.abs(C-O)>R)throw new lt("Invalid response timestamp")}catch(_){const N=_ instanceof Error?_.message:"Request validation failed";throw new lt(N)}let h=yield c.text();try{h=JSON.parse(h)}catch(_){}return h});if(e.retry){const c=yield new xr({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},Tt=function(n,e,t){return E(this,null,function*(){var s,r;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Cr,maxTimeout:c=Or}=e,u=`${n}/async`,h=`${n}/async/job`;let _;try{_=yield k(this,me).call(this,u,D(D({},t),i&&{signal:i}))}catch(C){throw C instanceof Error&&C.name==="AbortError"?new je({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):C}if(!_.ok){const C=yield _.text().catch();throw new Bt({url:n,method:(r=t==null?void 0:t.method)!=null?r:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:C})}const N=yield _.json(),{job_id:O}=N;if(!O)throw new Error("Job ID not found in response");return new Promise((C,R)=>E(this,null,function*(){const q=setTimeout(()=>{R(new Error("Job timed out"))},c),z=(re=0)=>E(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(q),k(this,me).call(this,`${h}/${O}/cancel`,{method:"POST",headers:this.headers}).then(()=>{R(new je({canceled:!0}))}).catch(F=>{R(new je({canceled:!1}))});return}try{const F=yield(yield k(this,me).call(this,`${h}/${O}`,{headers:this.headers})).json();if(F.status==="success"){clearTimeout(q);const K=F.response_json;C(K)}else if(F.status==="failed")clearTimeout(q),R(new Ar(F.response_json));else{a&&a(F.response_json);const K=o(re);setTimeout(()=>z(re+1),K)}}catch(F){R(F)}});z()}))})},Ie=function(n,e,t,s,r){return E(this,null,function*(){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=s,o=a!=null?a:this.baseAddress;let c=i!=null?i:this.headers;r.extraHeaders&&(c=D(D({},c),r.extraHeaders)),r.requestValidation&&(c=At(D({},c),{"X-Request-Nonce":_n(),"X-Request-Timestamp":xt()}));let u=s.skipBodyJsonStringify?t:JSON.stringify(t);return r.compress&&kr()&&(c["Content-Encoding"]="gzip",u=yield Tr(u)),r.async?yield ee(this,Y,Tt).call(this,`${o}${n}`,r.async,{method:e,headers:c,body:u}):yield ee(this,Y,kt).call(this,`${o}${n}`,r,{method:e,headers:c,body:u})})};const Wt=(n,e,t,s)=>n instanceof je?n:new Er({resource:e,api:String(t),args:s,cause:n}),ft=(n,e)=>new Proxy(e,{get(t,s){return(...r)=>{var a;for(const o of n.plugins){const c=(a=o.beforeApi)==null?void 0:a.call(o,{resource:t.resourceName,api:s,args:r});if(c!==void 0)return c}let i;try{i=t[s](...r)}catch(o){throw Wt(o,t.resourceName,s,r)}return i instanceof Promise?i.catch(o=>{throw Wt(o,t.resourceName,s,r)}):i}}});var Re;class jr{constructor(e){W(this,Re),this.resourceName="Files",j(this,Re,e)}get(e){return E(this,arguments,function*({fileKey:t,params:s={}}){const r=new URLSearchParams(D({plugin_data:"857346721138427857"},s)).toString(),a=`v1/files/${t}?${r}`;return yield k(this,Re).get(a)})}getImageFills(e){return E(this,arguments,function*({fileKey:t}){var s,r;const a=`v1/files/${t}/images`;return(r=(s=(yield k(this,Re).get(a)).meta)==null?void 0:s.images)!=null?r:{}})}}Re=new WeakMap;const Ir=(n,e,t)=>{const s=e.sort();return`${n}-${s.join("-")}-${t}`},Rr=n=>n?n.ts>Date.now()-1e3*30:!1;var Q,St,bn;class Zr{constructor(e){W(this,St),W(this,Q),this.resourceName="Images",j(this,Q,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:s,format:r="jpg",scale:a}){const i=Ir(t,s,r),o=k(this,Q).cache.images.entries.get(i);if(Rr(o))return o.result;o&&k(this,Q).cache.images.entries.delete(i);const c=k(this,Q).cache.images.pendingRequests.get(i);if(c)return c;const u=ee(this,St,bn).call(this,i,t,s,r,a);k(this,Q).cache.images.pendingRequests.set(i,u);try{return yield u}finally{k(this,Q).cache.images.pendingRequests.delete(i)}})}}Q=new WeakMap,St=new WeakSet,bn=function(n,e,t,s,r){return E(this,null,function*(){const a=yield k(this,Q).get(`v1/images/${e}?ids=${t}&format=${s}${r?`&scale=${r}`:""}`);return k(this,Q).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var Ye;class Mr{constructor(e){W(this,Ye),this.resourceName="Nodes",j(this,Ye,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:s,params:r={}}){const a=At(D({},r),{ids:s.join(",")}),i=new URLSearchParams(D({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield k(this,Ye).get(o)})}}Ye=new WeakMap;var de;class wn extends Nr{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),W(this,de,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=ft(this,new jr(this)),this.nodes=ft(this,new Mr(this)),this.images=ft(this,new Zr(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");j(this,de,e)}get token(){return k(this,de)}get headers(){const e={"Content-Type":"application/json"};return k(this,de).startsWith("figd_")?e["X-FIGMA-TOKEN"]=k(this,de):k(this,de).startsWith("figu_")&&(e.Authorization=`Bearer ${k(this,de)}`),e}}de=new WeakMap;const Pr=r=>P(exports,[r],function*({fileKey:n,authToken:e,figmaRestApi:t=new wn,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:s})}catch(a){throw console.error(a),a}}),$r=a=>P(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:s=new wn,params:r={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:n,nodeIds:t,params:d({},r)})).nodes}catch(i){return gn(i,n)}}),xn=(n,e)=>new ReadableStream({start(t){n.generateCode(e,s=>{s.type==="error"?(console.log("NOT SURE IF THIS IS REACHABLE, ALL ERRORS ARE THROWING"),t.enqueue({type:"error",payload:{message:s.payload.reason}})):t.enqueue(s),(s.type==="aborted"||s.type==="error")&&t.close()}).then(s=>{t.enqueue({type:"done"}),t.close()}).catch(s=>{t.enqueue({type:"error",payload:{message:"message"in s?s.message:"Unknown",status:"status"in s?s.status:void 0}}),t.close()})}}),Fr=(n,e)=>P(exports,null,function*(){var c,u,h,_,N,O,C;const t=xn(n,e),[s,r]=t.tee(),a=yield s.getReader().read();if(a.done||!a.value||((c=a.value)==null?void 0:c.type)==="error"&&((h=(u=a.value)==null?void 0:u.payload)!=null&&h.status))return new Response(JSON.stringify(a.value),{status:((_=a.value)==null?void 0:_.type)==="error"&&(C=(O=(N=a.value)==null?void 0:N.payload)==null?void 0:O.status)!=null?C:500,headers:{"Content-Type":"application/json"}});const i=new TextEncoder,o=r.pipeThrough(new TransformStream({transform(R,q){const z=`event: ${R.type}
3
+ data: ${JSON.stringify(R)}
4
4
 
5
- `;P.enqueue($)}}));return new Response(i,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=$r;exports.CodegenError=_e;exports.FigmaTokenIssue=an;exports.NotFound=un;exports.RateLimitExceeded=cn;exports.UnknownFigmaApiException=hn;exports.convertCodegenFilesToAnimaFiles=rn;exports.createCodegenResponseEventStream=Fs;exports.createCodegenStream=xn;exports.formatToFigmaLink=Lr;exports.getFigmaApiErrorType=Dr;exports.getFigmaFile=Ps;exports.getFileNodes=$s;exports.handleFigmaApiError=gn;exports.isFigmaTokenIssue=mn;exports.isNotFound=ln;exports.isRateLimitExceeded=pn;exports.isUnknownFigmaApiException=Vr;exports.isValidFigmaUrl=Fr;exports.validateSettings=nn;
5
+ `;q.enqueue(i.encode(z))}}));return new Response(o,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=$s;exports.CodegenError=be;exports.FigmaTokenIssue=an;exports.NotFound=un;exports.RateLimitExceeded=cn;exports.UnknownFigmaApiException=hn;exports.convertCodegenFilesToAnimaFiles=qt;exports.createCodegenResponseEventStream=Fr;exports.createCodegenStream=xn;exports.formatToFigmaLink=Ls;exports.getFigmaApiErrorType=Ds;exports.getFigmaFile=Pr;exports.getFileNodes=$r;exports.handleFigmaApiError=gn;exports.isFigmaTokenIssue=mn;exports.isNotFound=ln;exports.isRateLimitExceeded=pn;exports.isUnknownFigmaApiException=Vs;exports.isValidFigmaUrl=Fs;exports.validateSettings=sn;
6
6
  //# sourceMappingURL=index.cjs.map