@animaapp/anima-sdk 0.2.8 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,10 +3,10 @@
3
3
  transforming (1) src/index.ts✓ 14 modules transformed.
4
4
  rendering chunks (1)...
5
5
  [vite:dts] Start generate declaration files...
6
- computing gzip size (0)...computing gzip size (1)...dist/index.cjs 87.92 kB │ gzip: 23.66 kB │ map: 324.61 kB
6
+ computing gzip size (0)...computing gzip size (1)...dist/index.cjs 88.33 kB │ gzip: 23.70 kB │ map: 326.39 kB
7
7
  [vite:dts] Start rollup declaration files...
8
8
  Analysis will use the bundled TypeScript version 5.7.2
9
- [vite:dts] Declaration files built in 1794ms.
9
+ [vite:dts] Declaration files built in 2181ms.
10
10
  
11
- rendering chunks (1)...computing gzip size (1)...dist/index.js 125.18 kB │ gzip: 28.36 kB │ map: 338.62 kB
12
- ✓ built in 2.10s
11
+ rendering chunks (1)...computing gzip size (1)...dist/index.js 125.80 kB │ gzip: 28.43 kB │ map: 340.50 kB
12
+ ✓ built in 2.49s
@@ -0,0 +1,23 @@
1
+
2
+ Debugger listening on ws://127.0.0.1:55823/cf2752e1-9866-4cd5-a3d7-03e9c40ba57e
3
+ For help, see: https://nodejs.org/en/docs/inspector
4
+ Debugger attached.
5
+ Debugger listening on ws://127.0.0.1:55831/f454b5ca-94c5-4de9-8eef-11c7c666f990
6
+ For help, see: https://nodejs.org/en/docs/inspector
7
+ Debugger attached.
8
+ vite v6.0.11 building for production...
9
+ 
10
+ watching for file changes...
11
+ 
12
+ build started...
13
+ transforming (1) src/index.ts✓ 14 modules transformed.
14
+ rendering chunks (1)...
15
+ [vite:dts] Start generate declaration files...
16
+ computing gzip size (0)...computing gzip size (1)...dist/index.cjs 88.33 kB │ gzip: 23.70 kB │ map: 326.39 kB
17
+ rendering chunks (2)...[vite:dts] Start rollup declaration files...
18
+ Analysis will use the bundled TypeScript version 5.7.2
19
+ computing gzip size (2)...dist/index.js 125.80 kB │ gzip: 28.43 kB │ map: 340.50 kB
20
+ [vite:dts] Declaration files built in 2146ms.
21
+ 
22
+ built in 2411ms.
23
+ Waiting for the debugger to disconnect...
@@ -0,0 +1,21 @@
1
+
2
+ [?25l
3
+  RUN  v3.0.5 /Users/macabeus/ApenasMeu/anima/anima-sdk/sdk
4
+
5
+ [?2026h
6
+  ❯ src/utils/figma.spec.ts [queued]
7
+
8
+  Test Files 0 passed (1)
9
+  Tests 0 passed (0)
10
+  Start at 21:43:55
11
+  Duration 102ms
12
+ [?2026l ✓ src/utils/figma.spec.ts (2 tests) 2ms
13
+ ✓ # figma > .formatToFigmaLink > generates a link with file key and node id
14
+ ✓ # figma > .formatToFigmaLink > when the "duplicate" flag is enabled > generates a link including the '/duplicated' path
15
+
16
+  Test Files  1 passed (1)
17
+  Tests  2 passed (2)
18
+  Start at  21:43:55
19
+  Duration  234ms (transform 24ms, setup 0ms, collect 20ms, tests 2ms, environment 0ms, prepare 44ms)
20
+
21
+ [?25h
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var xn=Object.defineProperty,kn=Object.defineProperties;var Tn=Object.getOwnPropertyDescriptors;var jt=Object.getOwnPropertySymbols;var Sn=Object.prototype.hasOwnProperty,En=Object.prototype.propertyIsEnumerable;var Zt=n=>{throw TypeError(n)};var Rt=(n,e,t)=>e in n?xn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))Sn.call(e,t)&&Rt(n,t,e[t]);if(jt)for(var t of jt(e))En.call(e,t)&&Rt(n,t,e[t]);return n},g=(n,e)=>kn(n,Tn(e));var Mt=(n,e,t)=>e.has(n)||Zt("Cannot "+t);var B=(n,e,t)=>(Mt(n,e,"read from private field"),t?t.call(n):e.get(n)),ct=(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),dt=(n,e,t,s)=>(Mt(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);var $=(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"});class be extends Error{constructor({name:e,reason:t,status:s}){super(),this.name=`[Codegen Error] ${e}`,this.message=t,this.status=s}}var k;(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})(k||(k={}));var pt;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(pt||(pt={}));const p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=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=k.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"]),An=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,k.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,k.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${k.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}"`:k.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,k.assertNever(n)}return{message:t}};let qt=Te;function On(n){qt=n}function Qe(){return qt}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})},Cn=[];function h(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 R{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 $(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 R.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}),P=n=>({status:"valid",value:n}),mt=n=>n.status==="aborted",gt=n=>n.status==="dirty",ge=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 Ht(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,Ie;class Q{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(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 w(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:f}=n;return i.code==="invalid_enum_value"?{message:f!=null?f:o.defaultError}:typeof o.data=="undefined"?{message:(c=f!=null?f:s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f!=null?f:t)!==null&&u!==void 0?u:o.defaultError}},description:r}}class x{get description(){return this._def.description}_getType(e){return ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:ae(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:ae(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:ae(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:r});return ge(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=>ge(a)?{value:a.value}:{issues:r.common.issues})}parseAsync(e,t){return $(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return $(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:ae(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 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 Y.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.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 J(g(d({},w(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new We(g(d({},w(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new At(d({typeName:y.ZodBranded,type:this},w(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new Be(g(d({},w(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 In=/^c[^\s-]{8,}$/i,Nn=/^[0-9a-z]+$/,jn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rn=/^[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,Zn=/^[a-z0-9_-]{21}$/i,Mn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Pn=/^[-+]?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)?)??$/,$n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ut;const Ln=/^(?:(?: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])$/,Vn=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zn=/^([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])))",Bn=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 qn(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 Hn(n,e){return!!((e==="v4"||!e)&&Ln.test(n)||(e==="v6"||!e)&&Vn.test(n))}function Jn(n,e){if(!Mn.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 Gn(n,e){return!!((e==="v4"||!e)&&Dn.test(n)||(e==="v6"||!e)&&Un.test(n))}class q extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const s=new R;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),h(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),h(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?h(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")$n.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"email",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ut||(ut=new RegExp(Fn,"u")),ut.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"emoji",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Rn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"uuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Zn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"nanoid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")In.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Nn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid2",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")jn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(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),h(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),h(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),h(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),h(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),h(r,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Kt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Bn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?qn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Pn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"duration",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Hn(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"ip",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Jn(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"jwt",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Gn(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cidr",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?zn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Wn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64url",code:l.invalid_string,message:a.message}),s.dirty()):k.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 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,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 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},w(n)))};function Kn(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 de extends x{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 h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let s;const r=new R;for(const a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(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),h(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),h(s,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Kn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),h(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),h(s,{code:l.not_finite,message:a.message}),r.dirty()):k.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 de(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_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"&&k.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)}}de.create=n=>new de(d({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},w(n)));class ue extends x{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 R;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),h(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),h(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),h(s,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):k.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(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 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]}))}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},w(n)))};class Me extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),v}return P(e.data)}}Me.create=n=>new Me(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},w(n)));class ye extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),v}const s=new R;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),h(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),h(r,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):k.assertNever(a);return{status:s.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},w(n)));class nt extends x{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),v}return P(e.data)}}nt.create=n=>new nt(d({typeName:y.ZodSymbol},w(n)));class Pe extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),v}return P(e.data)}}Pe.create=n=>new Pe(d({typeName:y.ZodUndefined},w(n)));class $e extends x{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),v}return P(e.data)}}$e.create=n=>new $e(d({typeName:y.ZodNull},w(n)));class Se extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Se.create=n=>new Se(d({typeName:y.ZodAny},w(n)));class me extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}me.create=n=>new me(d({typeName:y.ZodUnknown},w(n)));class ie extends x{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}ie.create=n=>new ie(d({typeName:y.ZodNever},w(n)));class st extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),v}return P(e.data)}}st.create=n=>new st(d({typeName:y.ZodVoid},w(n)));class H extends x{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==p.array)return h(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)&&(h(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&&(h(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&&(h(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 Q(t,i,t.path,o)))).then(i=>R.mergeArray(s,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new Q(t,i,t.path,o)));return R.mergeArray(s,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},w(e)));function we(n){if(n instanceof S){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Y.create(we(s))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof H?new H(g(d({},n._def),{type:we(n.element)})):n instanceof Y?Y.create(we(n.unwrap())):n instanceof fe?fe.create(we(n.unwrap())):n instanceof ee?ee.create(n.items.map(e=>we(e))):n}class S extends x{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=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(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 ie&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const f=a[u],_=r.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Q(r,_,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof ie){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(u==="strict")o.length>0&&(h(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 f of o){const _=r.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Q(r,_,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(()=>$(this,null,function*(){const u=[];for(const f of c){const _=yield f.key,I=yield f.value;u.push({key:_,value:I,alwaysSet:f.alwaysSet})}return u})).then(u=>R.mergeObjectSync(s,u)):R.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 k.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 k.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 k.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 k.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof Y;)a=a._def.innerType;t[s]=a}}),new S(g(d({},this._def),{shape:()=>t}))}keyof(){return Xt(k.objectKeys(this.shape))}}S.create=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));S.strictCreate=(n,e)=>new S(d({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:y.ZodObject},w(e)));S.lazycreate=(n,e)=>new S(d({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));class Fe extends x{_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 h(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(s.map(a=>$(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}),f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,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 h(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},w(e)));const re=n=>n instanceof Ve?re(n.schema):n instanceof J?re(n.innerType()):n instanceof Ue?[n.value]:n instanceof le?n.options:n instanceof ze?k.objectValues(n.enum):n instanceof We?re(n._def.innerType):n instanceof Pe?[void 0]:n instanceof $e?[null]:n instanceof Y?[void 0,...re(n.unwrap())]:n instanceof fe?[null,...re(n.unwrap())]:n instanceof At||n instanceof qe?re(n.unwrap()):n instanceof Be?re(n._def.innerType):[];class it extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(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}):(h(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=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(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},w(s)))}}function yt(n,e){const t=ae(n),s=ae(e);if(n===e)return{valid:!0,data:n};if(t===p.object&&s===p.object){const r=k.objectKeys(e),a=k.objectKeys(n).filter(o=>r.indexOf(o)!==-1),i=d(d({},n),e);for(const o of a){const c=yt(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=yt(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 x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(mt(a)||mt(i))return v;const o=yt(a.value,i.value);return o.valid?((gt(a)||gt(i))&&t.dirty(),{status:t.value,value:o.data}):(h(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},w(t)));class ee extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),v;if(s.data.length<this._def.items.length)return h(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&&(h(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 Q(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ee(g(d({},this._def),{rest:e}))}}ee.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ee(d({items:n,typeName:y.ZodTuple,rest:null},w(e)))};class De extends x{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 h(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 Q(s,o,s.path,o)),value:i._parse(new Q(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,r):R.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof x?new De(d({keyType:e,valueType:t,typeName:y.ZodRecord},w(s))):new De(d({keyType:q.create(),valueType:e,typeName:y.ZodRecord},w(t)))}}class rt extends x{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 h(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 Q(s,o,s.path,[u,"key"])),value:a._parse(new Q(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>$(this,null,function*(){for(const c of i){const u=yield c.key,f=yield c.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}rt.create=(n,e,t)=>new rt(d({valueType:e,keyType:n,typeName:y.ZodMap},w(t)));class ve extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(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&&(h(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&&(h(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 f of c){if(f.status==="aborted")return v;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new Q(s,c,s.path,u)));return s.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},w(e)));class ke extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(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 P(function(...c){return $(this,null,function*(){const u=new U([]),f=yield o._def.args.parseAsync(c,a).catch(A=>{throw u.addIssue(s(c,A)),u}),_=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(_,a).catch(A=>{throw u.addIssue(r(_,A)),u})})})}else{const o=this;return P(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new U([s(c,u.error)]);const f=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(f,a);if(!_.success)throw new U([r(f,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ke(g(d({},this._def),{args:ee.create(e).rest(me.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||ee.create([]).rest(me.create()),returns:t||me.create(),typeName:y.ZodFunction},w(s)))}}class Ve extends x{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},w(e)));class Ue extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(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},w(e)));function Xt(n,e){return new le(d({values:n,typeName:y.ZodEnum},w(e)))}class le extends x{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 h(t,{expected:k.joinValues(s),received:t.parsedType,code:l.invalid_type}),v}if(tt(this,Ce)||Ht(this,Ce,new Set(this._def.values)),!tt(this,Ce).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{received:t.data,code:l.invalid_enum_value,options:s}),v}return P(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(s=>!e.includes(s)),d(d({},this._def),t))}}Ce=new WeakMap;le.create=Xt;class ze extends x{constructor(){super(...arguments),Ie.set(this,void 0)}_parse(e){const t=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==p.string&&s.parsedType!==p.number){const r=k.objectValues(t);return h(s,{expected:k.joinValues(r),received:s.parsedType,code:l.invalid_type}),v}if(tt(this,Ie)||Ht(this,Ie,new Set(k.getValidEnumValues(this._def.values))),!tt(this,Ie).has(e.data)){const r=k.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:r}),v}return P(e.data)}get enum(){return this._def.values}}Ie=new WeakMap;ze.create=(n,e)=>new ze(d({values:n,typeName:y.ZodNativeEnum},w(e)));class Ee extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(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 P(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},w(e)));class J extends x{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=>{h(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=>$(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(!ge(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=>ge(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);k.assertNever(r)}}J.create=(n,e,t)=>new J(d({schema:n,typeName:y.ZodEffects,effect:e},w(t)));J.createWithPreprocess=(n,e,t)=>new J(d({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects},w(t)));class Y extends x{_parse(e){return this._getType(e)===p.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y(d({innerType:n,typeName:y.ZodOptional},w(e)));class fe extends x{_parse(e){return this._getType(e)===p.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fe.create=(n,e)=>new fe(d({innerType:n,typeName:y.ZodNullable},w(e)));class We extends x{_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}}We.create=(n,e)=>new We(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},w(e)));class Be extends x{_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}}Be.create=(n,e)=>new Be(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},w(e)));class at extends x{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return h(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},w(n)));const Xn=Symbol("zod_brand");class At extends x{_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 x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return $(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 x{_parse(e){const t=this._def.innerType._parse(e),s=r=>(ge(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},w(e)));function Yt(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 Yn={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 Qn=(n,e={message:`Input not instance of ${n.name}`})=>Yt(t=>t instanceof n,e),Qt=q.create,en=de.create,es=at.create,ts=ue.create,tn=Me.create,ns=ye.create,ss=nt.create,rs=Pe.create,as=$e.create,is=Se.create,os=me.create,cs=ie.create,ds=st.create,us=H.create,ls=S.create,fs=S.strictCreate,hs=Fe.create,ps=it.create,ms=Le.create,gs=ee.create,ys=De.create,vs=rt.create,_s=ve.create,bs=ke.create,ws=Ve.create,xs=Ue.create,ks=le.create,Ts=ze.create,Ss=Ee.create,$t=J.create,Es=Y.create,As=fe.create,Os=J.createWithPreprocess,Cs=Je.create,Is=()=>Qt().optional(),Ns=()=>en().optional(),js=()=>tn().optional(),Rs={string:n=>q.create(g(d({},n),{coerce:!0})),number:n=>de.create(g(d({},n),{coerce:!0})),boolean:n=>Me.create(g(d({},n),{coerce:!0})),bigint:n=>ue.create(g(d({},n),{coerce:!0})),date:n=>ye.create(g(d({},n),{coerce:!0}))},Zs=v;var C=Object.freeze({__proto__:null,defaultErrorMap:Te,setErrorMap:On,getErrorMap:Qe,makeIssue:et,EMPTY_PATH:Cn,addIssueToContext:h,ParseStatus:R,INVALID:v,DIRTY:xe,OK:P,isAborted:mt,isDirty:gt,isValid:ge,isAsync:Ze,get util(){return k},get objectUtil(){return pt},ZodParsedType:p,getParsedType:ae,ZodType:x,datetimeRegex:Kt,ZodString:q,ZodNumber:de,ZodBigInt:ue,ZodBoolean:Me,ZodDate:ye,ZodSymbol:nt,ZodUndefined:Pe,ZodNull:$e,ZodAny:Se,ZodUnknown:me,ZodNever:ie,ZodVoid:st,ZodArray:H,ZodObject:S,ZodUnion:Fe,ZodDiscriminatedUnion:it,ZodIntersection:Le,ZodTuple:ee,ZodRecord:De,ZodMap:rt,ZodSet:ve,ZodFunction:ke,ZodLazy:Ve,ZodLiteral:Ue,ZodEnum:le,ZodNativeEnum:ze,ZodPromise:Ee,ZodEffects:J,ZodTransformer:J,ZodOptional:Y,ZodNullable:fe,ZodDefault:We,ZodCatch:Be,ZodNaN:at,BRAND:Xn,ZodBranded:At,ZodPipeline:Je,ZodReadonly:qe,custom:Yt,Schema:x,ZodSchema:x,late:Yn,get ZodFirstPartyTypeKind(){return y},coerce:Rs,any:is,array:us,bigint:ts,boolean:tn,date:ns,discriminatedUnion:ps,effect:$t,enum:ks,function:bs,instanceof:Qn,intersection:ms,lazy:ws,literal:xs,map:vs,nan:es,nativeEnum:Ts,never:cs,null:as,nullable:As,number:en,object:ls,oboolean:js,onumber:Ns,optional:Es,ostring:Is,pipeline:Cs,preprocess:Os,promise:Ss,record:ys,set:_s,strictObject:fs,string:Qt,symbol:ss,transformer:$t,tuple:gs,undefined:rs,union:hs,unknown:os,void:ds,NEVER:Zs,ZodIssueCode:l,quotelessJson:An,ZodError:U});const Ms=C.object({language:C.enum(["typescript","javascript"]).optional(),disableMarkedForExport:C.boolean().optional()}).and(C.union([C.object({framework:C.literal("react"),model:C.string().optional(),styling:C.enum(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:C.enum(["mui","antd","radix","shadcn"]).optional(),enableUILibraryTheming:C.boolean().optional(),enableCompactStructure:C.boolean().optional(),enableAutoSplit:C.boolean().optional(),autoSplitThreshold:C.number().optional()}),C.object({framework:C.literal("html"),styling:C.enum(["plain_css","inline_styles"]),enableTranslation:C.boolean().optional()})])),nn=n=>{const e=Ms.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data};var D,He;class Ps{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){ct(this,D);ct(this,He);dt(this,He,t),e&&(this.auth=e)}hasAuth(){return!!B(this,D)}set auth(e){dt(this,D,e)}get headers(){const e={"Content-Type":"application/json"};return B(this,D)&&(e.Authorization=`Bearer ${B(this,D).token}`,"teamId"in B(this,D)&&(e["X-Team-Id"]=B(this,D).teamId)),e}generateCode(s){return $(this,arguments,function*(e,t={}){var _,I,A,O,Z,W,te,oe;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const r={},a=nn(e.settings);let i=e.tracking;B(this,D)&&"userId"in B(this,D)&&B(this,D).userId&&(i!=null&&i.externalId||(i={externalId:B(this,D).userId}));const o=yield fetch(`${B(this,He)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({tracking:i,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,enableCompactStructure:a.enableCompactStructure,enableAutoSplit:a.enableAutoSplit,autoSplitThreshold:a.autoSplitThreshold,disableMarkedForExport:a.disableMarkedForExport})});if(!o.ok){let N;try{N=(yield o.json()).message||`HTTP error! status: ${o.status}`}catch(ne){N=`HTTP error! status: ${o.status}`}throw new be({name:"HTTP Error",reason:N,status:o.status})}if(!o.body)throw new be({name:"Stream Error",reason:"Response body is null",status:o.status});const c=o.body.getReader(),u=new TextDecoder;let f="";try{for(;;){const{done:N,value:ne}=yield c.read();if(N)break;f+=u.decode(ne,{stream:!0});const Ge=f.split(`
2
- `);f=Ge.pop()||"";for(const _e of Ge)if(!(!_e.trim()||_e.startsWith(":"))&&_e.startsWith("data: ")){let b;try{b=JSON.parse(_e.slice(6))}catch(ot){continue}switch(b.type){case"queueing":{typeof t=="function"?t(b):(_=t.onQueueing)==null||_.call(t);break}case"start":{r.sessionId=b.sessionId,typeof t=="function"?t(b):(I=t.onStart)==null||I.call(t,{sessionId:b.sessionId});break}case"pre_codegen":{typeof t=="function"?t(b):(A=t.onPreCodegen)==null||A.call(t,{message:b.message});break}case"assets_uploaded":{typeof t=="function"?t(b):(O=t.onAssetsUploaded)==null||O.call(t);break}case"assets_list":{r.assets=b.payload.assets,typeof t=="function"?t(b):(Z=t.onAssetsList)==null||Z.call(t,b.payload);break}case"figma_metadata":{r.figmaFileName=b.figmaFileName,r.figmaSelectedFrameName=b.figmaSelectedFrameName,typeof t=="function"?t(b):(W=t.onFigmaMetadata)==null||W.call(t,{figmaFileName:b.figmaFileName,figmaSelectedFrameName:b.figmaSelectedFrameName});break}case"generating_code":{b.payload.status==="success"&&(r.files=b.payload.files),typeof t=="function"?t(b):(te=t.onGeneratingCode)==null||te.call(t,{status:b.payload.status,progress:b.payload.progress,files:b.payload.files});break}case"codegen_completed":{typeof t=="function"?t(b):(oe=t.onCodegenCompleted)==null||oe.call(t);break}case"error":throw new be({name:b.payload.errorName,reason:b.payload.reason});case"done":{if(!r.files)throw new be({name:"Invalid response",reason:"No files found"});return r.tokenUsage=b.payload.tokenUsage,r}}}}}finally{c.cancel()}throw new be({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}D=new WeakMap,He=new WeakMap;const $s=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,"",""]}},Fs=({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};class Ls extends Error{constructor(e,t){super(e),this.response=t}}const Ds=({files:n,screenPath:e="src/screens"})=>{const t={},s=new Set;function r(a){if(s.has(a)||!n[a])return;s.add(a),t[a]=n[a],Vs(n[a].content).forEach(o=>{try{const c=Us(a,o);if(c.startsWith("src/")){const u=c.split("/").slice(0,-1).join("/");zs(n,u).forEach(_=>{s.has(_)||r(_)})}}catch(c){console.warn(`Failed to resolve import ${o} in ${a}:`,c)}})}return Object.entries(n).forEach(([a,i])=>{a.startsWith(e)?r(a):a.startsWith("src/")||(t[a]=i)}),t};function Vs(n){const e=/import.*?["']([^"']+)["']/g,t=/export.*from\s+["']([^"']+)["']/g,s=[];let r;for(;(r=e.exec(n))!==null;)s.push(r[1]);for(;(r=t.exec(n))!==null;)s.push(r[1]);return[...new Set(s)]}function Us(n,e){if(!e.startsWith("."))return e;const t=n.split("/").slice(0,-1),s=e.split("/"),r=[...t];for(const a of s)a===".."?r.pop():a!=="."&&r.push(a);return r.join("/")}function zs(n,e){return Object.keys(n).filter(t=>t.startsWith(e))}const sn="Figma Token Issue";class rn extends Error{constructor({fileKey:e,reason:t}){super(sn),this.fileKey=e,this.reason=t}}const an="Rate Limit Exceeded";class on extends Error{constructor({fileKey:e}){super(an),this.fileKey=e}}const cn="Not Found";class dn extends Error{constructor({fileKey:e}){super(cn),this.fileKey=e}}const un=n=>n.message===cn,ln="Unknown Figma API Exception";class fn extends Error{constructor({fileKey:e,cause:t}){super(ln),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Ws=n=>n.message===ln,hn=n=>n.message===an,pn=n=>[sn,...["Invalid Figma token","Figma token expired"]].includes(n.message),mn=(n,e)=>{var s,r,a,i;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 rn({fileKey:e,reason:(((a=(r=n==null?void 0:n.cause)==null?void 0:r.body)==null?void 0:a.reason)||((i=n.body)==null?void 0:i.reason)||"Access denied").toString()}):(t==null?void 0:t.status)===429?new on({fileKey:e}):(t==null?void 0:t.status)===404?new dn({fileKey:e}):new fn({fileKey:e,cause:n})},Bs=n=>un(n)?"NotFound":hn(n)?"RateLimitExceeded":pn(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var qs=Object.defineProperty,Hs=Object.defineProperties,Js=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,Gs=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable,Lt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),gn=n=>{throw TypeError(n)},Dt=(n,e,t)=>e in n?qs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,V=(n,e)=>{for(var t in e||(e={}))Gs.call(e,t)&&Dt(n,t,e[t]);if(Ft)for(var t of Ft(e))Ks.call(e,t)&&Dt(n,t,e[t]);return n},Ot=(n,e)=>Hs(n,Js(e)),Ct=(n,e,t)=>e.has(n)||gn("Cannot "+t),T=(n,e,t)=>(Ct(n,e,"read from private field"),t?t.call(n):e.get(n)),z=(n,e,t)=>e.has(n)?gn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),j=(n,e,t,s)=>(Ct(n,e,"write to private field"),e.set(n,t),t),X=(n,e,t)=>(Ct(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())}),Xs=(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),Ys=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Qs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var vt={exports:{}},er=vt.exports,Vt;function tr(){return Vt||(Vt=1,function(n,e){(function(t,s){n.exports=s()})(er,function(){var t=typeof Promise=="function",s=typeof self=="object"?self:Ys,r=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",f=r&&typeof Symbol.iterator!="undefined",_=r&&typeof Symbol.toStringTag!="undefined",I=i&&typeof Set.prototype.entries=="function",A=a&&typeof Map.prototype.entries=="function",O=I&&Object.getPrototypeOf(new Set().entries()),Z=A&&Object.getPrototypeOf(new Map().entries()),W=f&&typeof Array.prototype[Symbol.iterator]=="function",te=W&&Object.getPrototypeOf([][Symbol.iterator]()),oe=f&&typeof String.prototype[Symbol.iterator]=="function",N=oe&&Object.getPrototypeOf(""[Symbol.iterator]()),ne=8,Ge=-1;function _e(b){var ot=typeof b;if(ot!=="object")return ot;if(b===null)return"null";if(b===s)return"global";if(Array.isArray(b)&&(_===!1||!(Symbol.toStringTag in b)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&b===window.location)return"Location";if(typeof window.document=="object"&&b===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&b===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&b===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&b instanceof window.HTMLElement){if(b.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(b.tagName==="TD")return"HTMLTableDataCellElement";if(b.tagName==="TH")return"HTMLTableHeaderCellElement"}}var Nt=_&&b[Symbol.toStringTag];if(typeof Nt=="string")return Nt;var L=Object.getPrototypeOf(b);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===Z?"Map Iterator":i&&L===O?"Set Iterator":W&&L===te?"Array Iterator":oe&&L===N?"String Iterator":L===null?"Object":Object.prototype.toString.call(b).slice(ne,Ge)}return _e})}(vt)),vt.exports}var nr=tr();const sr=Qs(nr),It=typeof Buffer!="undefined",rr=It&&typeof Buffer.from!="undefined",ar=It?function(n){return Buffer.isBuffer(n)}:function(){return!1},ir=rr?function(n){return Buffer.from(n)}:It?function(n){return new Buffer(n)}:function(n){return n};function Ae(n){return ar(n)?"Buffer":sr(n)}const or=new Set(["Arguments","Array","Map","Object","Set"]);function cr(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 _t(n){return or.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 dr=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,ur=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,lr=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,lt=dr||ur||lr||Function("return this")();function fr(n){return n.slice(0)}function hr(n){return new Boolean(n.valueOf())}function pr(n){return new DataView(n.buffer)}function mr(n){return ir(n)}function gr(n){return new Date(n.getTime())}function yr(n){return new Number(n)}function vr(n){return new RegExp(n.source,n.flags)}function _r(n){return new String(n)}function se(n,e){return lt[e].from?lt[e].from(n):new lt[e](n)}function M(n){return n}function zt(){return[]}function br(){return new Map}function wr(){return{}}function xr(){return new Set}const kr=new Map([["ArrayBuffer",fr],["Boolean",hr],["Buffer",mr],["DataView",pr],["Date",gr],["Number",yr],["RegExp",vr],["String",_r],["Float32Array",se],["Float64Array",se],["Int16Array",se],["Int32Array",se],["Int8Array",se],["Uint16Array",se],["Uint32Array",se],["Uint8Array",se],["Uint8ClampedArray",se],["Array Iterator",M],["Map Iterator",M],["Promise",M],["Set Iterator",M],["String Iterator",M],["function",M],["global",M],["WeakMap",M],["WeakSet",M],["boolean",M],["null",M],["number",M],["string",M],["symbol",M],["undefined",M],["Arguments",zt],["Array",zt],["Map",br],["Object",wr],["Set",xr]]);function Tr(){}function bt(n,e=null,t=Tr){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Ae(n),r=kr.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(!_t(s))return wt(n,null,null,null);const r=bt(n,s,t),a=new WeakMap([[n,r]]),i=new WeakSet([n]);return wt(n,r,a,i)}function wt(n,e,t,s,r){const a=Ae(n),i=bt(n,a);if(!_t(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=cr(n,c,a);if(s.has(u))Ut(e,c,t.get(u),a);else{const f=Ae(u),_=bt(u,f);_t(f)&&(t.set(u,_),s.add(u)),Ut(e,c,wt(u,_,t,s),a)}}return e}const Sr=n=>new Promise(e=>setTimeout(e,n));var Ke,he,Xe,xt,yn;class Er{constructor({maxAttempts:e=3,func:t}){z(this,xt),z(this,Ke),z(this,he),z(this,Xe),j(this,Ke,e),j(this,Xe,t),j(this,he,0)}run(){return E(this,null,function*(){try{return yield T(this,Xe).call(this)}catch(e){if(j(this,he,T(this,he)+1),T(this,he)>T(this,Ke))throw console.error("Max attempts reached"),e;const t=X(this,xt,yn).call(this);return yield Sr(t),yield this.run()}})}}Ke=new WeakMap,he=new WeakMap,Xe=new WeakMap,xt=new WeakSet,yn=function(){return T(this,he)*1e3*1.5};function Ar(){return typeof CompressionStream!="undefined"}function Or(n){return E(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var s=Xs(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 Cr(t)})}function Cr(n){return E(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class Ir 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,f)=>{c[f]=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 Wt 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 Ne extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class Nr extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class ft extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function vn(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function kt(){return Math.floor(Date.now()/1e3).toString()}const jr=5*60*1e3,Rr=1*1e3;var pe,F,G,Tt,St,je;class Zr{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){z(this,G),z(this,pe),z(this,F),this.baseAddress=t,j(this,pe,e),j(this,F,{}),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,F,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(T(this,F));return j(this,F,{}),c.extraHeaders&&(o=V(V({},o),c.extraHeaders)),c.requestValidation&&(o=Ot(V({},o),{"X-Request-Nonce":vn(),"X-Request-Timestamp":kt()})),c.async?yield X(this,G,St).call(this,`${i}${t}`,c.async,{headers:o}):yield X(this,G,Tt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(T(this,F));return j(this,F,{}),X(this,G,je).call(this,s,"POST",r,a,i)})}put(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(T(this,F));return j(this,F,{}),X(this,G,je).call(this,s,"PUT",r,a,i)})}delete(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(T(this,F));return j(this,F,{}),X(this,G,je).call(this,s,"DELETE",r,a,i)})}patch(e,t){return E(this,arguments,function*(s,r,a={}){const i=Oe(T(this,F));return j(this,F,{}),X(this,G,je).call(this,s,"PATCH",r,a,i)})}}pe=new WeakMap,F=new WeakMap,G=new WeakSet,Tt=function(n,e,t){return E(this,null,function*(){const s=()=>E(this,null,function*(){var c,u;try{return yield T(this,pe).call(this,n,V(V({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ne({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:r}=t!=null?t:{},a=(c,u)=>{var f,_;return((f=c==null?void 0:c.headers)==null?void 0:f.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 Wt({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"),I=r==null?void 0:r["X-Request-Nonce"];if(!_||_!==I)throw new ft("Response nonce mismatch");const A=Number(a(c,"x-response-timestamp")),O=Number(kt()),Z=60*60*24;if(isNaN(A)||Math.abs(O-A)>Z)throw new ft("Invalid response timestamp")}catch(_){const I=_ instanceof Error?_.message:"Request validation failed";throw new ft(I)}let f=yield c.text();try{f=JSON.parse(f)}catch(_){}return f});if(e.retry){const c=yield new Er({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},St=function(n,e,t){return E(this,null,function*(){var s,r;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Rr,maxTimeout:c=jr}=e,u=`${n}/async`,f=`${n}/async/job`;let _;try{_=yield T(this,pe).call(this,u,V(V({},t),i&&{signal:i}))}catch(O){throw O instanceof Error&&O.name==="AbortError"?new Ne({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):O}if(!_.ok){const O=yield _.text().catch();throw new Wt({url:n,method:(r=t==null?void 0:t.method)!=null?r:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:O})}const I=yield _.json(),{job_id:A}=I;if(!A)throw new Error("Job ID not found in response");return new Promise((O,Z)=>E(this,null,function*(){const W=setTimeout(()=>{Z(new Error("Job timed out"))},c),te=(oe=0)=>E(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(W),T(this,pe).call(this,`${f}/${A}/cancel`,{method:"POST",headers:this.headers}).then(()=>{Z(new Ne({canceled:!0}))}).catch(N=>{Z(new Ne({canceled:!1}))});return}try{const N=yield(yield T(this,pe).call(this,`${f}/${A}`,{headers:this.headers})).json();if(N.status==="success"){clearTimeout(W);const ne=N.response_json;O(ne)}else if(N.status==="failed")clearTimeout(W),Z(new Nr(N.response_json));else{a&&a(N.response_json);const ne=o(oe);setTimeout(()=>te(oe+1),ne)}}catch(N){Z(N)}});te()}))})},je=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=V(V({},c),r.extraHeaders)),r.requestValidation&&(c=Ot(V({},c),{"X-Request-Nonce":vn(),"X-Request-Timestamp":kt()}));let u=s.skipBodyJsonStringify?t:JSON.stringify(t);return r.compress&&Ar()&&(c["Content-Encoding"]="gzip",u=yield Or(u)),r.async?yield X(this,G,St).call(this,`${o}${n}`,r.async,{method:e,headers:c,body:u}):yield X(this,G,Tt).call(this,`${o}${n}`,r,{method:e,headers:c,body:u})})};const Bt=(n,e,t,s)=>n instanceof Ne?n:new Ir({resource:e,api:String(t),args:s,cause:n}),ht=(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 Bt(o,t.resourceName,s,r)}return i instanceof Promise?i.catch(o=>{throw Bt(o,t.resourceName,s,r)}):i}}});var Re;class Mr{constructor(e){z(this,Re),this.resourceName="Files",j(this,Re,e)}get(e){return E(this,arguments,function*({fileKey:t,params:s={}}){const r=new URLSearchParams(V({plugin_data:"857346721138427857"},s)).toString(),a=`v1/files/${t}?${r}`;return yield T(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 T(this,Re).get(a)).meta)==null?void 0:s.images)!=null?r:{}})}}Re=new WeakMap;const Pr=(n,e,t)=>{const s=e.sort();return`${n}-${s.join("-")}-${t}`},$r=n=>n?n.ts>Date.now()-1e3*30:!1;var K,Et,_n;class Fr{constructor(e){z(this,Et),z(this,K),this.resourceName="Images",j(this,K,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:s,format:r="jpg",scale:a}){const i=Pr(t,s,r),o=T(this,K).cache.images.entries.get(i);if($r(o))return o.result;o&&T(this,K).cache.images.entries.delete(i);const c=T(this,K).cache.images.pendingRequests.get(i);if(c)return c;const u=X(this,Et,_n).call(this,i,t,s,r,a);T(this,K).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,K).cache.images.pendingRequests.delete(i)}})}}K=new WeakMap,Et=new WeakSet,_n=function(n,e,t,s,r){return E(this,null,function*(){const a=yield T(this,K).get(`v1/images/${e}?ids=${t}&format=${s}${r?`&scale=${r}`:""}`);return T(this,K).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var Ye;class Lr{constructor(e){z(this,Ye),this.resourceName="Nodes",j(this,Ye,e)}get(e){return E(this,arguments,function*({fileKey:t,nodeIds:s,params:r={}}){const a=Ot(V({},r),{ids:s.join(",")}),i=new URLSearchParams(V({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,Ye).get(o)})}}Ye=new WeakMap;var ce;class bn extends Zr{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),z(this,ce,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=ht(this,new Mr(this)),this.nodes=ht(this,new Lr(this)),this.images=ht(this,new Fr(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 T(this,ce)}get headers(){const e={"Content-Type":"application/json"};return T(this,ce).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,ce):T(this,ce).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,ce)}`),e}}ce=new WeakMap;const Dr=r=>$(exports,[r],function*({fileKey:n,authToken:e,figmaRestApi:t=new bn,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:s})}catch(a){throw console.error(a),a}}),Vr=a=>$(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:s=new bn,params:r={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:n,nodeIds:t,params:d({},r)})).nodes}catch(i){return mn(i,n)}}),wn=(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",payload:{tokenUsage:s.tokenUsage,sessionId:s.sessionId}}),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()})}}),Ur=(n,e)=>$(exports,null,function*(){var c,u,f,_,I,A,O;const t=wn(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"&&((f=(u=a.value)==null?void 0:u.payload)!=null&&f.status))return new Response(JSON.stringify(a.value),{status:((_=a.value)==null?void 0:_.type)==="error"&&(O=(A=(I=a.value)==null?void 0:I.payload)==null?void 0:A.status)!=null?O:500,headers:{"Content-Type":"application/json"}});const i=new TextEncoder,o=r.pipeThrough(new TransformStream({transform(Z,W){const te=`event: ${Z.type}
1
+ "use strict";var xn=Object.defineProperty,kn=Object.defineProperties;var Tn=Object.getOwnPropertyDescriptors;var Nt=Object.getOwnPropertySymbols;var Sn=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var Zt=n=>{throw TypeError(n)};var Rt=(n,e,t)=>e in n?xn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,d=(n,e)=>{for(var t in e||(e={}))Sn.call(e,t)&&Rt(n,t,e[t]);if(Nt)for(var t of Nt(e))An.call(e,t)&&Rt(n,t,e[t]);return n},g=(n,e)=>kn(n,Tn(e));var Mt=(n,e,t)=>e.has(n)||Zt("Cannot "+t);var H=(n,e,t)=>(Mt(n,e,"read from private field"),t?t.call(n):e.get(n)),dt=(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),ut=(n,e,t,s)=>(Mt(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);var F=(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"});class ae extends Error{constructor({name:e,reason:t,status:s,detail:r}){super(),this.name=e,this.message=t,this.detail=r,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 mt;(function(n){n.mergeShapes=(e,t)=>d(d({},e),t)})(mt||(mt={}));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"]),En=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class z 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 z))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()}}z.create=n=>new z(n);const Ae=(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=Ae;function On(n){qt=n}function et(){return qt}const tt=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})},Cn=[];function h(n,e){const t=et(),s=tt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ae?void 0:Ae].filter(r=>!!r)});n.common.issues.push(s)}class R{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 F(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 R.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"}),Te=n=>({status:"dirty",value:n}),P=n=>({status:"valid",value:n}),gt=n=>n.status==="aborted",yt=n=>n.status==="dirty",be=n=>n.status==="valid",Pe=n=>typeof Promise!="undefined"&&n instanceof Promise;function nt(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 Ht(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 je,Ne;class te{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(be(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 z(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:f}=n;return i.code==="invalid_enum_value"?{message:f!=null?f:o.defaultError}:typeof o.data=="undefined"?{message:(c=f!=null?f:s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f!=null?f: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 R,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(Pe(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 be(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=>be(a)?{value:a.value}:{issues:r.common.issues})}parseAsync(e,t){return F(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return F(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 Pe(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 ee.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return Oe.create(this,this._def)}or(e){return De.create([this,e],this._def)}and(e){return Ve.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 qe(g(d({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Ot(d({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new He(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 Ge.create(this,e)}readonly(){return Je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const In=/^c[^\s-]{8,}$/i,jn=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rn=/^[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,Zn=/^[a-z0-9_-]{21}$/i,Mn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Pn=/^[-+]?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)?)??$/,$n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let lt;const Ln=/^(?:(?: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])$/,Vn=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zn=/^([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])))",Bn=new RegExp(`^${Jt}$`);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 qn(n){return new RegExp(`^${Kt(n)}$`)}function Gt(n){let e=`${Jt}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 Hn(n,e){return!!((e==="v4"||!e)&&Ln.test(n)||(e==="v6"||!e)&&Vn.test(n))}function Jn(n,e){if(!Mn.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)&&Un.test(n))}class J extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),v}const s=new R;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),h(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),h(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?h(r,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(r,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")$n.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"email",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")lt||(lt=new RegExp(Fn,"u")),lt.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"emoji",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Rn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"uuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Zn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"nanoid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")In.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")jn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid2",code:l.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Nn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(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),h(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),h(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),h(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),h(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),h(r,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Gt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Bn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?qn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:l.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Pn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"duration",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Hn(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"ip",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Jn(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),h(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),h(r,{validation:"cidr",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?zn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64",code:l.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Wn.test(e.data)||(r=this._getOrReturnCtx(e,r),h(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 J(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 J(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new J(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new J(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}}J.create=n=>{var e;return new J(d({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};function Gn(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 fe 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 h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),v}let s;const r=new R;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(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),h(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),h(s,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Gn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),h(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),h(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 fe(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new fe(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)}}fe.create=n=>new fe(d({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class he 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 R;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),h(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),h(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),h(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 h(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 he(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(r)}]}))}_addCheck(e){return new he(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}}he.create=n=>{var e;return new he(d({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1},b(n)))};class $e extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),v}return P(e.data)}}$e.create=n=>new $e(d({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1},b(n)));class we 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 h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),v}const s=new R;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),h(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),h(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 we(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}}we.create=n=>new we(d({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate},b(n)));class st extends w{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),v}return P(e.data)}}st.create=n=>new st(d({typeName:y.ZodSymbol},b(n)));class Fe extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),v}return P(e.data)}}Fe.create=n=>new Fe(d({typeName:y.ZodUndefined},b(n)));class Le extends w{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),v}return P(e.data)}}Le.create=n=>new Le(d({typeName:y.ZodNull},b(n)));class Ee extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Ee.create=n=>new Ee(d({typeName:y.ZodAny},b(n)));class _e extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}_e.create=n=>new _e(d({typeName:y.ZodUnknown},b(n)));class ce extends w{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),v}}ce.create=n=>new ce(d({typeName:y.ZodNever},b(n)));class rt extends w{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),v}return P(e.data)}}rt.create=n=>new rt(d({typeName:y.ZodVoid},b(n)));class K extends w{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==p.array)return h(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)&&(h(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&&(h(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&&(h(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 te(t,i,t.path,o)))).then(i=>R.mergeArray(s,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new te(t,i,t.path,o)));return R.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new K(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new K(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new K(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}K.create=(n,e)=>new K(d({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function ke(n){if(n instanceof S){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=ee.create(ke(s))}return new S(g(d({},n._def),{shape:()=>e}))}else return n instanceof K?new K(g(d({},n._def),{type:ke(n.element)})):n instanceof ee?ee.create(ke(n.unwrap())):n instanceof me?me.create(ke(n.unwrap())):n instanceof ne?ne.create(n.items.map(e=>ke(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 h(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 f=a[u],_=r.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new te(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 f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(u==="strict")o.length>0&&(h(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 f of o){const _=r.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new te(r,_,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(()=>F(this,null,function*(){const u=[];for(const f of c){const _=yield f.key,j=yield f.value;u.push({key:_,value:j,alwaysSet:f.alwaysSet})}return u})).then(u=>R.mergeObjectSync(s,u)):R.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 ke(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 ee;)a=a._def.innerType;t[s]=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: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 De 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 z(o.ctx.common.issues));return h(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(s.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(r);{let a;const i=[];for(const c of s){const u=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null}),f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,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 z(c));return h(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}De.create=(n,e)=>new De(d({options:n,typeName:y.ZodUnion},b(e)));const ie=n=>n instanceof ze?ie(n.schema):n instanceof G?ie(n.innerType()):n instanceof We?[n.value]:n instanceof pe?n.options:n instanceof Be?x.objectValues(n.enum):n instanceof qe?ie(n._def.innerType):n instanceof Fe?[void 0]:n instanceof Le?[null]:n instanceof ee?[void 0,...ie(n.unwrap())]:n instanceof me?[null,...ie(n.unwrap())]:n instanceof Ot||n instanceof Je?ie(n.unwrap()):n instanceof He?ie(n._def.innerType):[];class ot extends w{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(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}):(h(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 ot(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r},b(s)))}}function vt(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=vt(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=vt(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 Ve extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(gt(a)||gt(i))return v;const o=vt(a.value,i.value);return o.valid?((yt(a)||yt(i))&&t.dirty(),{status:t.value,value:o.data}):(h(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}))}}Ve.create=(n,e,t)=>new Ve(d({left:n,right:e,typeName:y.ZodIntersection},b(t)));class ne extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),v;if(s.data.length<this._def.items.length)return h(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&&(h(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 te(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ne(g(d({},this._def),{rest:e}))}}ne.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ne(d({items:n,typeName:y.ZodTuple,rest:null},b(e)))};class Ue 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 h(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 te(s,o,s.path,o)),value:i._parse(new te(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,r):R.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof w?new Ue(d({keyType:e,valueType:t,typeName:y.ZodRecord},b(s))):new Ue(d({keyType:J.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class at 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 h(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 te(s,o,s.path,[u,"key"])),value:a._parse(new te(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>F(this,null,function*(){for(const c of i){const u=yield c.key,f=yield c.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}at.create=(n,e,t)=>new at(d({valueType:e,keyType:n,typeName:y.ZodMap},b(t)));class xe extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(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&&(h(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&&(h(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 f of c){if(f.status==="aborted")return v;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new te(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new xe(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new xe(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)}}xe.create=(n,e)=>new xe(d({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class Se extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),v;function s(o,c){return tt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,et(),Ae].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function r(o,c){return tt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,et(),Ae].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 Oe){const o=this;return P(function(...c){return F(this,null,function*(){const u=new z([]),f=yield o._def.args.parseAsync(c,a).catch(O=>{throw u.addIssue(s(c,O)),u}),_=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(_,a).catch(O=>{throw u.addIssue(r(_,O)),u})})})}else{const o=this;return P(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new z([s(c,u.error)]);const f=Reflect.apply(i,this,u.data),_=o._def.returns.safeParse(f,a);if(!_.success)throw new z([r(f,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Se(g(d({},this._def),{args:ne.create(e).rest(_e.create())}))}returns(e){return new Se(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 Se(d({args:e||ne.create([]).rest(_e.create()),returns:t||_e.create(),typeName:y.ZodFunction},b(s)))}}class ze 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})}}ze.create=(n,e)=>new ze(d({getter:n,typeName:y.ZodLazy},b(e)));class We extends w{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(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}}We.create=(n,e)=>new We(d({value:n,typeName:y.ZodLiteral},b(e)));function Xt(n,e){return new pe(d({values:n,typeName:y.ZodEnum},b(e)))}class pe extends w{constructor(){super(...arguments),je.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{expected:x.joinValues(s),received:t.parsedType,code:l.invalid_type}),v}if(nt(this,je)||Ht(this,je,new Set(this._def.values)),!nt(this,je).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{received:t.data,code:l.invalid_enum_value,options:s}),v}return P(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 pe.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return pe.create(this.options.filter(s=>!e.includes(s)),d(d({},this._def),t))}}je=new WeakMap;pe.create=Xt;class Be 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 h(s,{expected:x.joinValues(r),received:s.parsedType,code:l.invalid_type}),v}if(nt(this,Ne)||Ht(this,Ne,new Set(x.getValidEnumValues(this._def.values))),!nt(this,Ne).has(e.data)){const r=x.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:r}),v}return P(e.data)}get enum(){return this._def.values}}Ne=new WeakMap;Be.create=(n,e)=>new Be(d({values:n,typeName:y.ZodNativeEnum},b(e)));class Oe 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 h(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 P(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Oe.create=(n,e)=>new Oe(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=>{h(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=>F(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"?Te(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"?Te(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(!be(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=>be(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 ee extends w{_parse(e){return this._getType(e)===p.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(n,e)=>new ee(d({innerType:n,typeName:y.ZodOptional},b(e)));class me extends w{_parse(e){return this._getType(e)===p.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me(d({innerType:n,typeName:y.ZodNullable},b(e)));class qe 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}}qe.create=(n,e)=>new qe(d({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class He 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 Pe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}He.create=(n,e)=>new He(d({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class it extends w{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.nan,received:s.parsedType}),v}return{status:"valid",value:e.data}}}it.create=n=>new it(d({typeName:y.ZodNaN},b(n)));const Xn=Symbol("zod_brand");class Ot 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 Ge extends w{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return F(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(),Te(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 Ge({in:e,out:t,typeName:y.ZodPipeline})}}class Je extends w{_parse(e){const t=this._def.innerType._parse(e),s=r=>(be(r)&&(r.value=Object.freeze(r.value)),r);return Pe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}Je.create=(n,e)=>new Je(d({innerType:n,typeName:y.ZodReadonly},b(e)));function Yt(n,e={},t){return n?Ee.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}))}}):Ee.create()}const Yn={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 Qn=(n,e={message:`Input not instance of ${n.name}`})=>Yt(t=>t instanceof n,e),Qt=J.create,en=fe.create,es=it.create,ts=he.create,tn=$e.create,ns=we.create,ss=st.create,rs=Fe.create,as=Le.create,is=Ee.create,os=_e.create,cs=ce.create,ds=rt.create,us=K.create,ls=S.create,fs=S.strictCreate,hs=De.create,ps=ot.create,ms=Ve.create,gs=ne.create,ys=Ue.create,vs=at.create,_s=xe.create,bs=Se.create,ws=ze.create,xs=We.create,ks=pe.create,Ts=Be.create,Ss=Oe.create,$t=G.create,As=ee.create,Es=me.create,Os=G.createWithPreprocess,Cs=Ge.create,Is=()=>Qt().optional(),js=()=>en().optional(),Ns=()=>tn().optional(),Rs={string:n=>J.create(g(d({},n),{coerce:!0})),number:n=>fe.create(g(d({},n),{coerce:!0})),boolean:n=>$e.create(g(d({},n),{coerce:!0})),bigint:n=>he.create(g(d({},n),{coerce:!0})),date:n=>we.create(g(d({},n),{coerce:!0}))},Zs=v;var I=Object.freeze({__proto__:null,defaultErrorMap:Ae,setErrorMap:On,getErrorMap:et,makeIssue:tt,EMPTY_PATH:Cn,addIssueToContext:h,ParseStatus:R,INVALID:v,DIRTY:Te,OK:P,isAborted:gt,isDirty:yt,isValid:be,isAsync:Pe,get util(){return x},get objectUtil(){return mt},ZodParsedType:p,getParsedType:oe,ZodType:w,datetimeRegex:Gt,ZodString:J,ZodNumber:fe,ZodBigInt:he,ZodBoolean:$e,ZodDate:we,ZodSymbol:st,ZodUndefined:Fe,ZodNull:Le,ZodAny:Ee,ZodUnknown:_e,ZodNever:ce,ZodVoid:rt,ZodArray:K,ZodObject:S,ZodUnion:De,ZodDiscriminatedUnion:ot,ZodIntersection:Ve,ZodTuple:ne,ZodRecord:Ue,ZodMap:at,ZodSet:xe,ZodFunction:Se,ZodLazy:ze,ZodLiteral:We,ZodEnum:pe,ZodNativeEnum:Be,ZodPromise:Oe,ZodEffects:G,ZodTransformer:G,ZodOptional:ee,ZodNullable:me,ZodDefault:qe,ZodCatch:He,ZodNaN:it,BRAND:Xn,ZodBranded:Ot,ZodPipeline:Ge,ZodReadonly:Je,custom:Yt,Schema:w,ZodSchema:w,late:Yn,get ZodFirstPartyTypeKind(){return y},coerce:Rs,any:is,array:us,bigint:ts,boolean:tn,date:ns,discriminatedUnion:ps,effect:$t,enum:ks,function:bs,instanceof:Qn,intersection:ms,lazy:ws,literal:xs,map:vs,nan:es,nativeEnum:Ts,never:cs,null:as,nullable:Es,number:en,object:ls,oboolean:Ns,onumber:js,optional:As,ostring:Is,pipeline:Cs,preprocess:Os,promise:Ss,record:ys,set:_s,strictObject:fs,string:Qt,symbol:ss,transformer:$t,tuple:gs,undefined:rs,union:hs,unknown:os,void:ds,NEVER:Zs,ZodIssueCode:l,quotelessJson:En,ZodError:z});const Ms=I.object({language:I.enum(["typescript","javascript"]).optional(),disableMarkedForExport:I.boolean().optional()}).and(I.union([I.object({framework:I.literal("react"),model:I.string().optional(),styling:I.enum(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:I.enum(["mui","antd","radix","shadcn"]).optional(),enableUILibraryTheming:I.boolean().optional(),enableCompactStructure:I.boolean().optional(),enableAutoSplit:I.boolean().optional(),autoSplitThreshold:I.number().optional()}),I.object({framework:I.literal("html"),styling:I.enum(["plain_css","inline_styles"]),enableTranslation:I.boolean().optional()})])),nn=n=>{const e=Ms.safeParse(n);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data};var V,Ke;class Ps{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){dt(this,V);dt(this,Ke);ut(this,Ke,t),e&&(this.auth=e)}hasAuth(){return!!H(this,V)}set auth(e){ut(this,V,e)}get headers(){const e={"Content-Type":"application/json"};return H(this,V)&&(e.Authorization=`Bearer ${H(this,V).token}`,"teamId"in H(this,V)&&(e["X-Team-Id"]=H(this,V).teamId)),e}generateCode(s){return F(this,arguments,function*(e,t={}){var _,j,O,C,Z,B,se,de,D,ue;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const r={},a=nn(e.settings);let i=e.tracking;H(this,V)&&"userId"in H(this,V)&&H(this,V).userId&&(i!=null&&i.externalId||(i={externalId:H(this,V).userId}));const o=yield fetch(`${H(this,Ke)}/v1/codegen`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify({tracking:i,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,enableCompactStructure:a.enableCompactStructure,enableAutoSplit:a.enableAutoSplit,autoSplitThreshold:a.autoSplitThreshold,disableMarkedForExport:a.disableMarkedForExport})});if(!o.ok){const q=yield o.json().catch(()=>"HTTP error from Anima API");throw typeof q=="string"?new ae({name:q,reason:"Unknown",detail:{status:o.status},status:o.status}):typeof q!="object"?new ae({name:`Error "${q}"`,reason:"Unknown",detail:{status:o.status},status:o.status}):((_=q.error)==null?void 0:_.name)==="ZodError"?new ae({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:q.error.issues,status:o.status}):new ae({name:((j=q.error)==null?void 0:j.name)||"HTTP error from Anima API",reason:"Unknown",detail:{status:o.status},status:o.status})}if(!o.body)throw new ae({name:"Stream Error",reason:"Response body is null",status:o.status});const c=o.body.getReader(),u=new TextDecoder;let f="";try{for(;;){const{done:q,value:ct}=yield c.read();if(q)break;f+=u.decode(ct,{stream:!0});const E=f.split(`
2
+ `);f=E.pop()||"";for(const ge of E)if(!(!ge.trim()||ge.startsWith(":"))&&ge.startsWith("data: ")){let k;try{k=JSON.parse(ge.slice(6))}catch($){continue}switch(k.type){case"queueing":{typeof t=="function"?t(k):(O=t.onQueueing)==null||O.call(t);break}case"start":{r.sessionId=k.sessionId,typeof t=="function"?t(k):(C=t.onStart)==null||C.call(t,{sessionId:k.sessionId});break}case"pre_codegen":{typeof t=="function"?t(k):(Z=t.onPreCodegen)==null||Z.call(t,{message:k.message});break}case"assets_uploaded":{typeof t=="function"?t(k):(B=t.onAssetsUploaded)==null||B.call(t);break}case"assets_list":{r.assets=k.payload.assets,typeof t=="function"?t(k):(se=t.onAssetsList)==null||se.call(t,k.payload);break}case"figma_metadata":{r.figmaFileName=k.figmaFileName,r.figmaSelectedFrameName=k.figmaSelectedFrameName,typeof t=="function"?t(k):(de=t.onFigmaMetadata)==null||de.call(t,{figmaFileName:k.figmaFileName,figmaSelectedFrameName:k.figmaSelectedFrameName});break}case"generating_code":{k.payload.status==="success"&&(r.files=k.payload.files),typeof t=="function"?t(k):(D=t.onGeneratingCode)==null||D.call(t,{status:k.payload.status,progress:k.payload.progress,files:k.payload.files});break}case"codegen_completed":{typeof t=="function"?t(k):(ue=t.onCodegenCompleted)==null||ue.call(t);break}case"error":throw new ae({name:k.payload.errorName,reason:k.payload.reason});case"done":{if(!r.files)throw new ae({name:"Invalid response",reason:"No code generated"});return r.tokenUsage=k.payload.tokenUsage,r}}}}}finally{c.cancel()}throw new ae({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})}}V=new WeakMap,Ke=new WeakMap;const $s=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,"",""]}},Fs=({fileKey:n,nodeId:e,duplicate:t})=>{const s=new URL("https://www.figma.com");return s.pathname=`design/${n}`,t&&(s.pathname=`${s.pathname}/duplicate`),e&&s.searchParams.set("node-id",e.replace(":","-")),s};class Ls extends Error{constructor(e,t){super(e),this.response=t}}const Ds=({files:n,screenPath:e="src/screens"})=>{const t={},s=new Set;function r(a){if(s.has(a)||!n[a])return;s.add(a),t[a]=n[a],Vs(n[a].content).forEach(o=>{try{const c=Us(a,o);if(c.startsWith("src/")){const u=c.split("/").slice(0,-1).join("/");zs(n,u).forEach(_=>{s.has(_)||r(_)})}}catch(c){console.warn(`Failed to resolve import ${o} in ${a}:`,c)}})}return Object.entries(n).forEach(([a,i])=>{a.startsWith(e)?r(a):a.startsWith("src/")||(t[a]=i)}),t};function Vs(n){const e=/import.*?["']([^"']+)["']/g,t=/export.*from\s+["']([^"']+)["']/g,s=[];let r;for(;(r=e.exec(n))!==null;)s.push(r[1]);for(;(r=t.exec(n))!==null;)s.push(r[1]);return[...new Set(s)]}function Us(n,e){if(!e.startsWith("."))return e;const t=n.split("/").slice(0,-1),s=e.split("/"),r=[...t];for(const a of s)a===".."?r.pop():a!=="."&&r.push(a);return r.join("/")}function zs(n,e){return Object.keys(n).filter(t=>t.startsWith(e))}const sn="Figma Token Issue";class rn extends Error{constructor({fileKey:e,reason:t}){super(sn),this.fileKey=e,this.reason=t}}const an="Rate Limit Exceeded";class on extends Error{constructor({fileKey:e}){super(an),this.fileKey=e}}const cn="Not Found";class dn extends Error{constructor({fileKey:e}){super(cn),this.fileKey=e}}const un=n=>n.message===cn,ln="Unknown Figma API Exception";class fn extends Error{constructor({fileKey:e,cause:t}){super(ln),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Ws=n=>n.message===ln,hn=n=>n.message===an,pn=n=>[sn,...["Invalid Figma token","Figma token expired"]].includes(n.message),mn=(n,e)=>{var s,r,a,i;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 rn({fileKey:e,reason:(((a=(r=n==null?void 0:n.cause)==null?void 0:r.body)==null?void 0:a.reason)||((i=n.body)==null?void 0:i.reason)||"Access denied").toString()}):(t==null?void 0:t.status)===429?new on({fileKey:e}):(t==null?void 0:t.status)===404?new dn({fileKey:e}):new fn({fileKey:e,cause:n})},Bs=n=>un(n)?"NotFound":hn(n)?"RateLimitExceeded":pn(n)?"FigmaTokenIssue":"UnknownFigmaApiException";var qs=Object.defineProperty,Hs=Object.defineProperties,Js=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,Ks=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable,Lt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),gn=n=>{throw TypeError(n)},Dt=(n,e,t)=>e in n?qs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,U=(n,e)=>{for(var t in e||(e={}))Ks.call(e,t)&&Dt(n,t,e[t]);if(Ft)for(var t of Ft(e))Gs.call(e,t)&&Dt(n,t,e[t]);return n},Ct=(n,e)=>Hs(n,Js(e)),It=(n,e,t)=>e.has(n)||gn("Cannot "+t),T=(n,e,t)=>(It(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>e.has(n)?gn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),N=(n,e,t,s)=>(It(n,e,"write to private field"),e.set(n,t),t),Q=(n,e,t)=>(It(n,e,"access private method"),t),A=(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())}),Xs=(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),Ys=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Qs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var _t={exports:{}},er=_t.exports,Vt;function tr(){return Vt||(Vt=1,function(n,e){(function(t,s){n.exports=s()})(er,function(){var t=typeof Promise=="function",s=typeof self=="object"?self:Ys,r=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",u=typeof DataView!="undefined",f=r&&typeof Symbol.iterator!="undefined",_=r&&typeof Symbol.toStringTag!="undefined",j=i&&typeof Set.prototype.entries=="function",O=a&&typeof Map.prototype.entries=="function",C=j&&Object.getPrototypeOf(new Set().entries()),Z=O&&Object.getPrototypeOf(new Map().entries()),B=f&&typeof Array.prototype[Symbol.iterator]=="function",se=B&&Object.getPrototypeOf([][Symbol.iterator]()),de=f&&typeof String.prototype[Symbol.iterator]=="function",D=de&&Object.getPrototypeOf(""[Symbol.iterator]()),ue=8,q=-1;function ct(E){var ge=typeof E;if(ge!=="object")return ge;if(E===null)return"null";if(E===s)return"global";if(Array.isArray(E)&&(_===!1||!(Symbol.toStringTag in E)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&E===window.location)return"Location";if(typeof window.document=="object"&&E===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&E===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&E===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&E instanceof window.HTMLElement){if(E.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(E.tagName==="TD")return"HTMLTableDataCellElement";if(E.tagName==="TH")return"HTMLTableHeaderCellElement"}}var k=_&&E[Symbol.toStringTag];if(typeof k=="string")return k;var $=Object.getPrototypeOf(E);return $===RegExp.prototype?"RegExp":$===Date.prototype?"Date":t&&$===Promise.prototype?"Promise":i&&$===Set.prototype?"Set":a&&$===Map.prototype?"Map":c&&$===WeakSet.prototype?"WeakSet":o&&$===WeakMap.prototype?"WeakMap":u&&$===DataView.prototype?"DataView":a&&$===Z?"Map Iterator":i&&$===C?"Set Iterator":B&&$===se?"Array Iterator":de&&$===D?"String Iterator":$===null?"Object":Object.prototype.toString.call(E).slice(ue,q)}return ct})}(_t)),_t.exports}var nr=tr();const sr=Qs(nr),jt=typeof Buffer!="undefined",rr=jt&&typeof Buffer.from!="undefined",ar=jt?function(n){return Buffer.isBuffer(n)}:function(){return!1},ir=rr?function(n){return Buffer.from(n)}:jt?function(n){return new Buffer(n)}:function(n){return n};function Ce(n){return ar(n)?"Buffer":sr(n)}const or=new Set(["Arguments","Array","Map","Object","Set"]);function cr(n,e,t=null){switch(t||Ce(n)){case"Arguments":case"Array":case"Object":return n[e];case"Map":return n.get(e);case"Set":return e}}function bt(n){return or.has(n)}function Ut(n,e,t,s=null){switch(s||Ce(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 dr=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,ur=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,lr=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,ft=dr||ur||lr||Function("return this")();function fr(n){return n.slice(0)}function hr(n){return new Boolean(n.valueOf())}function pr(n){return new DataView(n.buffer)}function mr(n){return ir(n)}function gr(n){return new Date(n.getTime())}function yr(n){return new Number(n)}function vr(n){return new RegExp(n.source,n.flags)}function _r(n){return new String(n)}function re(n,e){return ft[e].from?ft[e].from(n):new ft[e](n)}function M(n){return n}function zt(){return[]}function br(){return new Map}function wr(){return{}}function xr(){return new Set}const kr=new Map([["ArrayBuffer",fr],["Boolean",hr],["Buffer",mr],["DataView",pr],["Date",gr],["Number",yr],["RegExp",vr],["String",_r],["Float32Array",re],["Float64Array",re],["Int16Array",re],["Int32Array",re],["Int8Array",re],["Uint16Array",re],["Uint32Array",re],["Uint8Array",re],["Uint8ClampedArray",re],["Array Iterator",M],["Map Iterator",M],["Promise",M],["Set Iterator",M],["String Iterator",M],["function",M],["global",M],["WeakMap",M],["WeakSet",M],["boolean",M],["null",M],["number",M],["string",M],["symbol",M],["undefined",M],["Arguments",zt],["Array",zt],["Map",br],["Object",wr],["Set",xr]]);function Tr(){}function wt(n,e=null,t=Tr){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Ce(n),r=kr.get(s);if(s==="Object"){const a=t(n,s);if(a!==void 0)return a}return r?r(n,s):n}function Ie(n,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Ce(n);if(!bt(s))return xt(n,null,null,null);const r=wt(n,s,t),a=new WeakMap([[n,r]]),i=new WeakSet([n]);return xt(n,r,a,i)}function xt(n,e,t,s,r){const a=Ce(n),i=wt(n,a);if(!bt(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=cr(n,c,a);if(s.has(u))Ut(e,c,t.get(u),a);else{const f=Ce(u),_=wt(u,f);bt(f)&&(t.set(u,_),s.add(u)),Ut(e,c,xt(u,_,t,s),a)}}return e}const Sr=n=>new Promise(e=>setTimeout(e,n));var Xe,ye,Ye,kt,yn;class Ar{constructor({maxAttempts:e=3,func:t}){W(this,kt),W(this,Xe),W(this,ye),W(this,Ye),N(this,Xe,e),N(this,Ye,t),N(this,ye,0)}run(){return A(this,null,function*(){try{return yield T(this,Ye).call(this)}catch(e){if(N(this,ye,T(this,ye)+1),T(this,ye)>T(this,Xe))throw console.error("Max attempts reached"),e;const t=Q(this,kt,yn).call(this);return yield Sr(t),yield this.run()}})}}Xe=new WeakMap,ye=new WeakMap,Ye=new WeakMap,kt=new WeakSet,yn=function(){return T(this,ye)*1e3*1.5};function Er(){return typeof CompressionStream!="undefined"}function Or(n){return A(this,null,function*(){const e=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var s=Xs(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 Cr(t)})}function Cr(n){return A(this,null,function*(){const e=yield new Blob(n).arrayBuffer();return new Uint8Array(e)})}class Ir 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,f)=>{c[f]=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 Wt 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 Re extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class jr extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class ht extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function vn(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function Tt(){return Math.floor(Date.now()/1e3).toString()}const Nr=5*60*1e3,Rr=1*1e3;var ve,L,X,St,At,Ze;class Zr{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){W(this,X),W(this,ve),W(this,L),this.baseAddress=t,N(this,ve,e),N(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 N(this,L,e),this}get(e){return A(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=Ie(T(this,L));return N(this,L,{}),c.extraHeaders&&(o=U(U({},o),c.extraHeaders)),c.requestValidation&&(o=Ct(U({},o),{"X-Request-Nonce":vn(),"X-Request-Timestamp":Tt()})),c.async?yield Q(this,X,At).call(this,`${i}${t}`,c.async,{headers:o}):yield Q(this,X,St).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ie(T(this,L));return N(this,L,{}),Q(this,X,Ze).call(this,s,"POST",r,a,i)})}put(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ie(T(this,L));return N(this,L,{}),Q(this,X,Ze).call(this,s,"PUT",r,a,i)})}delete(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ie(T(this,L));return N(this,L,{}),Q(this,X,Ze).call(this,s,"DELETE",r,a,i)})}patch(e,t){return A(this,arguments,function*(s,r,a={}){const i=Ie(T(this,L));return N(this,L,{}),Q(this,X,Ze).call(this,s,"PATCH",r,a,i)})}}ve=new WeakMap,L=new WeakMap,X=new WeakSet,St=function(n,e,t){return A(this,null,function*(){const s=()=>A(this,null,function*(){var c,u;try{return yield T(this,ve).call(this,n,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Re({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:r}=t!=null?t:{},a=(c,u)=>{var f,_;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((_=c==null?void 0:c.headersObject)==null?void 0:_[u])||""},i=c=>A(this,null,function*(){var u;if(!c.ok){const _=yield c.text().catch();throw new Wt({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"),j=r==null?void 0:r["X-Request-Nonce"];if(!_||_!==j)throw new ht("Response nonce mismatch");const O=Number(a(c,"x-response-timestamp")),C=Number(Tt()),Z=60*60*24;if(isNaN(O)||Math.abs(C-O)>Z)throw new ht("Invalid response timestamp")}catch(_){const j=_ instanceof Error?_.message:"Request validation failed";throw new ht(j)}let f=yield c.text();try{f=JSON.parse(f)}catch(_){}return f});if(e.retry){const c=yield new Ar({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},At=function(n,e,t){return A(this,null,function*(){var s,r;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Rr,maxTimeout:c=Nr}=e,u=`${n}/async`,f=`${n}/async/job`;let _;try{_=yield T(this,ve).call(this,u,U(U({},t),i&&{signal:i}))}catch(C){throw C instanceof Error&&C.name==="AbortError"?new Re({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):C}if(!_.ok){const C=yield _.text().catch();throw new Wt({url:n,method:(r=t==null?void 0:t.method)!=null?r:"GET",statusCode:_.status,requestHeaders:this.headers,responseHeaders:_.headers,body:C})}const j=yield _.json(),{job_id:O}=j;if(!O)throw new Error("Job ID not found in response");return new Promise((C,Z)=>A(this,null,function*(){const B=setTimeout(()=>{Z(new Error("Job timed out"))},c),se=(de=0)=>A(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(B),T(this,ve).call(this,`${f}/${O}/cancel`,{method:"POST",headers:this.headers}).then(()=>{Z(new Re({canceled:!0}))}).catch(D=>{Z(new Re({canceled:!1}))});return}try{const D=yield(yield T(this,ve).call(this,`${f}/${O}`,{headers:this.headers})).json();if(D.status==="success"){clearTimeout(B);const ue=D.response_json;C(ue)}else if(D.status==="failed")clearTimeout(B),Z(new jr(D.response_json));else{a&&a(D.response_json);const ue=o(de);setTimeout(()=>se(de+1),ue)}}catch(D){Z(D)}});se()}))})},Ze=function(n,e,t,s,r){return A(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=U(U({},c),r.extraHeaders)),r.requestValidation&&(c=Ct(U({},c),{"X-Request-Nonce":vn(),"X-Request-Timestamp":Tt()}));let u=s.skipBodyJsonStringify?t:JSON.stringify(t);return r.compress&&Er()&&(c["Content-Encoding"]="gzip",u=yield Or(u)),r.async?yield Q(this,X,At).call(this,`${o}${n}`,r.async,{method:e,headers:c,body:u}):yield Q(this,X,St).call(this,`${o}${n}`,r,{method:e,headers:c,body:u})})};const Bt=(n,e,t,s)=>n instanceof Re?n:new Ir({resource:e,api:String(t),args:s,cause:n}),pt=(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 Bt(o,t.resourceName,s,r)}return i instanceof Promise?i.catch(o=>{throw Bt(o,t.resourceName,s,r)}):i}}});var Me;class Mr{constructor(e){W(this,Me),this.resourceName="Files",N(this,Me,e)}get(e){return A(this,arguments,function*({fileKey:t,params:s={}}){const r=new URLSearchParams(U({plugin_data:"857346721138427857"},s)).toString(),a=`v1/files/${t}?${r}`;return yield T(this,Me).get(a)})}getImageFills(e){return A(this,arguments,function*({fileKey:t}){var s,r;const a=`v1/files/${t}/images`;return(r=(s=(yield T(this,Me).get(a)).meta)==null?void 0:s.images)!=null?r:{}})}}Me=new WeakMap;const Pr=(n,e,t)=>{const s=e.sort();return`${n}-${s.join("-")}-${t}`},$r=n=>n?n.ts>Date.now()-1e3*30:!1;var Y,Et,_n;class Fr{constructor(e){W(this,Et),W(this,Y),this.resourceName="Images",N(this,Y,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,format:r="jpg",scale:a}){const i=Pr(t,s,r),o=T(this,Y).cache.images.entries.get(i);if($r(o))return o.result;o&&T(this,Y).cache.images.entries.delete(i);const c=T(this,Y).cache.images.pendingRequests.get(i);if(c)return c;const u=Q(this,Et,_n).call(this,i,t,s,r,a);T(this,Y).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,Y).cache.images.pendingRequests.delete(i)}})}}Y=new WeakMap,Et=new WeakSet,_n=function(n,e,t,s,r){return A(this,null,function*(){const a=yield T(this,Y).get(`v1/images/${e}?ids=${t}&format=${s}${r?`&scale=${r}`:""}`);return T(this,Y).cache.images.entries.set(n,{result:a,ts:Date.now()}),a})};var Qe;class Lr{constructor(e){W(this,Qe),this.resourceName="Nodes",N(this,Qe,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,params:r={}}){const a=Ct(U({},r),{ids:s.join(",")}),i=new URLSearchParams(U({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,Qe).get(o)})}}Qe=new WeakMap;var le;class bn extends Zr{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),W(this,le,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=pt(this,new Mr(this)),this.nodes=pt(this,new Lr(this)),this.images=pt(this,new Fr(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");N(this,le,e)}get token(){return T(this,le)}get headers(){const e={"Content-Type":"application/json"};return T(this,le).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,le):T(this,le).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,le)}`),e}}le=new WeakMap;const Dr=r=>F(exports,[r],function*({fileKey:n,authToken:e,figmaRestApi:t=new bn,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:n,params:s})}catch(a){throw console.error(a),a}}),Vr=a=>F(exports,[a],function*({fileKey:n,authToken:e,nodeIds:t,figmaRestApi:s=new bn,params:r={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:n,nodeIds:t,params:d({},r)})).nodes}catch(i){return mn(i,n)}}),wn=(n,e)=>new ReadableStream({start(t){n.generateCode(e,s=>{s.type==="error"||t.enqueue(s),(s.type==="aborted"||s.type==="error")&&t.close()}).then(s=>{t.enqueue({type:"done",payload:{tokenUsage:s.tokenUsage,sessionId:s.sessionId}}),t.close()}).catch(s=>{t.enqueue({type:"error",payload:{name:"name"in s?s.name:"Unknown error",message:"message"in s?s.message:"Unknown",status:"status"in s?s.status:void 0,detail:"detail"in s?s.detail:void 0}}),t.close()})}}),Ur=(n,e)=>F(exports,null,function*(){var c,u,f,_,j,O,C;const t=wn(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"&&((f=(u=a.value)==null?void 0:u.payload)!=null&&f.status))return new Response(JSON.stringify(a.value),{status:((_=a.value)==null?void 0:_.type)==="error"&&(C=(O=(j=a.value)==null?void 0:j.payload)==null?void 0:O.status)!=null?C:500,headers:{"Content-Type":"application/json"}});const i=new TextEncoder,o=r.pipeThrough(new TransformStream({transform(Z,B){const se=`event: ${Z.type}
3
3
  data: ${JSON.stringify(Z)}
4
4
 
5
- `;W.enqueue(i.encode(te))}}));return new Response(o,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=Ps;exports.CodegenError=be;exports.FigmaTokenIssue=rn;exports.NotFound=dn;exports.RateLimitExceeded=on;exports.ResponseError=Ls;exports.UnknownFigmaApiException=fn;exports.createCodegenResponseEventStream=Ur;exports.createCodegenStream=wn;exports.formatToFigmaLink=Fs;exports.getFigmaApiErrorType=Bs;exports.getFigmaFile=Dr;exports.getFileNodes=Vr;exports.getRelatedScreenFiles=Ds;exports.handleFigmaApiError=mn;exports.isFigmaTokenIssue=pn;exports.isNotFound=un;exports.isRateLimitExceeded=hn;exports.isUnknownFigmaApiException=Ws;exports.isValidFigmaUrl=$s;exports.validateSettings=nn;
5
+ `;B.enqueue(i.encode(se))}}));return new Response(o,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})});exports.Anima=Ps;exports.CodegenError=ae;exports.FigmaTokenIssue=rn;exports.NotFound=dn;exports.RateLimitExceeded=on;exports.ResponseError=Ls;exports.UnknownFigmaApiException=fn;exports.createCodegenResponseEventStream=Ur;exports.createCodegenStream=wn;exports.formatToFigmaLink=Fs;exports.getFigmaApiErrorType=Bs;exports.getFigmaFile=Dr;exports.getFileNodes=Vr;exports.getRelatedScreenFiles=Ds;exports.handleFigmaApiError=mn;exports.isFigmaTokenIssue=pn;exports.isNotFound=un;exports.isRateLimitExceeded=hn;exports.isUnknownFigmaApiException=Ws;exports.isValidFigmaUrl=$s;exports.validateSettings=nn;
6
6
  //# sourceMappingURL=index.cjs.map