@animaapp/anima-sdk 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var As=Object.defineProperty,Cs=Object.defineProperties;var Es=Object.getOwnPropertyDescriptors;var kt=Object.getOwnPropertySymbols;var Os=Object.prototype.hasOwnProperty,Ns=Object.prototype.propertyIsEnumerable;var St=s=>{throw TypeError(s)},Tt=Math.pow,xt=(s,e,t)=>e in s?As(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e)=>{for(var t in e||(e={}))Os.call(e,t)&&xt(s,t,e[t]);if(kt)for(var t of kt(e))Ns.call(e,t)&&xt(s,t,e[t]);return s},_=(s,e)=>Cs(s,Es(e));var He=(s,e,t)=>e.has(s)||St("Cannot "+t);var C=(s,e,t)=>(He(s,e,"read from private field"),t?t.call(s):e.get(s)),Re=(s,e,t)=>e.has(s)?St("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Je=(s,e,t,r)=>(He(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t),me=(s,e,t)=>(He(s,e,"access private method"),t);var E=(s,e,t)=>new Promise((r,n)=>{var a=c=>{try{o(t.next(c))}catch(d){n(d)}},i=c=>{try{o(t.throw(c))}catch(d){n(d)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(s,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class se extends Error{constructor({name:e,reason:t,status:r,detail:n}){super(),this.name=e,this.message=t,this.detail=n,this.status=r}}const Xt="Figma Token Issue";class Kt extends Error{constructor({fileKey:e,reason:t,cause:r}){super(Xt),this.fileKey=e,this.reason=t,this.cause=r}}const Qt="Rate Limit Exceeded";class Yt extends Error{constructor({fileKey:e,cause:t}){super(Qt),this.fileKey=e,this.cause=t}}const es="Request Too Large";class ts extends Error{constructor({fileKey:e,cause:t}){super(es),this.fileKey=e,this.cause=t}}const ss="Not Found";class rs extends Error{constructor({fileKey:e,cause:t}){super(ss),this.fileKey=e,this.cause=t}}const ns=s=>s.message===ss,as="Unknown Figma API Exception";class is extends Error{constructor({fileKey:e,cause:t}){super(as),this.name="UnknownFigmaApiException",this.fileKey=e,this.cause=t}}const Is=s=>s.message===as,os=s=>s.message===Qt,cs=s=>[Xt,...["Invalid Figma token","Figma token expired"]].includes(s.message),us=s=>s.message===es,gt=(s,e)=>{var r;if(((r=s==null?void 0:s.cause)==null?void 0:r.message)==="Fetch Error"){const{err:n,status:a}=s.cause.body;if(a===403)return new Kt({fileKey:e,reason:n,cause:s});if(a===429)return new Yt({fileKey:e,cause:s});if(a===404)return new rs({fileKey:e,cause:s});if(a===400&&n.includes("Request too large"))return new ts({fileKey:e,cause:s})}return new is({fileKey:e,cause:s})},Rs=s=>ns(s)?"NotFound":os(s)?"RateLimitExceeded":cs(s)?"FigmaTokenIssue":us(s)?"RequestTooLarge":"UnknownFigmaApiException";var js=Object.defineProperty,Ps=Object.defineProperties,Ms=Object.getOwnPropertyDescriptors,At=Object.getOwnPropertySymbols,Zs=Object.prototype.hasOwnProperty,Fs=Object.prototype.propertyIsEnumerable,Ct=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),ds=s=>{throw TypeError(s)},Et=(s,e,t)=>e in s?js(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,$=(s,e)=>{for(var t in e||(e={}))Zs.call(e,t)&&Et(s,t,e[t]);if(At)for(var t of At(e))Fs.call(e,t)&&Et(s,t,e[t]);return s},yt=(s,e)=>Ps(s,Ms(e)),vt=(s,e,t)=>e.has(s)||ds("Cannot "+t),S=(s,e,t)=>(vt(s,e,"read from private field"),t?t.call(s):e.get(s)),D=(s,e,t)=>e.has(s)?ds("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),I=(s,e,t,r)=>(vt(s,e,"write to private field"),e.set(s,t),t),z=(s,e,t)=>(vt(s,e,"access private method"),t),N=(s,e,t)=>new Promise((r,n)=>{var a=c=>{try{o(t.next(c))}catch(d){n(d)}},i=c=>{try{o(t.throw(c))}catch(d){n(d)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,i);o((t=t.apply(s,e)).next())}),$s=(s,e,t)=>(e=s[Ct("asyncIterator")])?e.call(s):(s=s[Ct("iterator")](),e={},t=(r,n)=>(n=s[r])&&(e[r]=a=>new Promise((i,o,c)=>(a=n.call(s,a),c=a.done,Promise.resolve(a.value).then(d=>i({value:d,done:c}),o)))),t("next"),t("return"),e),Ls=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ds(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ye={exports:{}},Vs=Ye.exports,Ot;function Us(){return Ot||(Ot=1,(function(s,e){(function(t,r){s.exports=r()})(Vs,function(){var t=typeof Promise=="function",r=typeof self=="object"?self:Ls,n=typeof Symbol!="undefined",a=typeof Map!="undefined",i=typeof Set!="undefined",o=typeof WeakMap!="undefined",c=typeof WeakSet!="undefined",d=typeof DataView!="undefined",h=n&&typeof Symbol.iterator!="undefined",w=n&&typeof Symbol.toStringTag!="undefined",P=i&&typeof Set.prototype.entries=="function",U=a&&typeof Map.prototype.entries=="function",M=P&&Object.getPrototypeOf(new Set().entries()),L=U&&Object.getPrototypeOf(new Map().entries()),G=h&&typeof Array.prototype[Symbol.iterator]=="function",oe=G&&Object.getPrototypeOf([][Symbol.iterator]()),ee=h&&typeof String.prototype[Symbol.iterator]=="function",F=ee&&Object.getPrototypeOf(""[Symbol.iterator]()),te=8,Ie=-1;function fe(T){var he=typeof T;if(he!=="object")return he;if(T===null)return"null";if(T===r)return"global";if(Array.isArray(T)&&(w===!1||!(Symbol.toStringTag in T)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&T===window.location)return"Location";if(typeof window.document=="object"&&T===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&T===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&T===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&T instanceof window.HTMLElement){if(T.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(T.tagName==="TD")return"HTMLTableDataCellElement";if(T.tagName==="TH")return"HTMLTableHeaderCellElement"}}var ce=w&&T[Symbol.toStringTag];if(typeof ce=="string")return ce;var g=Object.getPrototypeOf(T);return g===RegExp.prototype?"RegExp":g===Date.prototype?"Date":t&&g===Promise.prototype?"Promise":i&&g===Set.prototype?"Set":a&&g===Map.prototype?"Map":c&&g===WeakSet.prototype?"WeakSet":o&&g===WeakMap.prototype?"WeakMap":d&&g===DataView.prototype?"DataView":a&&g===L?"Map Iterator":i&&g===M?"Set Iterator":G&&g===oe?"Array Iterator":ee&&g===F?"String Iterator":g===null?"Object":Object.prototype.toString.call(T).slice(te,Ie)}return fe})})(Ye)),Ye.exports}var Ws=Us();const qs=Ds(Ws),_t=typeof Buffer!="undefined",Bs=_t&&typeof Buffer.from!="undefined",zs=_t?(function(s){return Buffer.isBuffer(s)}):(function(){return!1}),Hs=Bs?(function(s){return Buffer.from(s)}):_t?(function(s){return new Buffer(s)}):(function(s){return s});function ge(s){return zs(s)?"Buffer":qs(s)}const Js=new Set(["Arguments","Array","Map","Object","Set"]);function Gs(s,e,t=null){switch(t||ge(s)){case"Arguments":case"Array":case"Object":return s[e];case"Map":return s.get(e);case"Set":return e}}function et(s){return Js.has(s)}function Nt(s,e,t,r=null){switch(r||ge(s)){case"Arguments":case"Array":case"Object":s[e]=t;break;case"Map":s.set(e,t);break;case"Set":s.add(t);break}return s}const Xs=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,Ks=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,Qs=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,Ge=Xs||Ks||Qs||Function("return this")();function Ys(s){return s.slice(0)}function er(s){return new Boolean(s.valueOf())}function tr(s){return new DataView(s.buffer)}function sr(s){return Hs(s)}function rr(s){return new Date(s.getTime())}function nr(s){return new Number(s)}function ar(s){return new RegExp(s.source,s.flags)}function ir(s){return new String(s)}function X(s,e){return Ge[e].from?Ge[e].from(s):new Ge[e](s)}function R(s){return s}function It(){return[]}function or(){return new Map}function cr(){return{}}function ur(){return new Set}const dr=new Map([["ArrayBuffer",Ys],["Boolean",er],["Buffer",sr],["DataView",tr],["Date",rr],["Number",nr],["RegExp",ar],["String",ir],["Float32Array",X],["Float64Array",X],["Int16Array",X],["Int32Array",X],["Int8Array",X],["Uint16Array",X],["Uint32Array",X],["Uint8Array",X],["Uint8ClampedArray",X],["Array Iterator",R],["Map Iterator",R],["Promise",R],["Set Iterator",R],["String Iterator",R],["function",R],["global",R],["WeakMap",R],["WeakSet",R],["boolean",R],["null",R],["number",R],["string",R],["symbol",R],["undefined",R],["Arguments",It],["Array",It],["Map",or],["Object",cr],["Set",ur]]);function lr(){}function tt(s,e=null,t=lr){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const r=e||ge(s),n=dr.get(r);if(r==="Object"){const a=t(s,r);if(a!==void 0)return a}return n?n(s,r):s}function ke(s,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,r=ge(s);if(!et(r))return st(s,null,null,null);const n=tt(s,r,t),a=new WeakMap([[s,n]]),i=new WeakSet([s]);return st(s,n,a,i)}function st(s,e,t,r,n){const a=ge(s),i=tt(s,a);if(!et(a))return i;let o;switch(a){case"Arguments":case"Array":o=Object.keys(s);break;case"Object":o=Object.keys(s),o.push(...Object.getOwnPropertySymbols(s));break;case"Map":case"Set":o=s.keys();break}for(let c of o){const d=Gs(s,c,a);if(r.has(d))Nt(e,c,t.get(d),a);else{const h=ge(d),w=tt(d,h);et(h)&&(t.set(d,w),r.add(d)),Nt(e,c,st(d,w,t,r),a)}}return e}const fr=s=>new Promise(e=>setTimeout(e,s));var Ze,ue,Fe,rt,ls;class hr{constructor({maxAttempts:e=3,func:t}){D(this,rt),D(this,Ze),D(this,ue),D(this,Fe),I(this,Ze,e),I(this,Fe,t),I(this,ue,0)}run(){return N(this,null,function*(){try{return yield S(this,Fe).call(this)}catch(e){if(I(this,ue,S(this,ue)+1),S(this,ue)>S(this,Ze))throw console.error("Max attempts reached"),e;const t=z(this,rt,ls).call(this);return yield fr(t),yield this.run()}})}}Ze=new WeakMap,ue=new WeakMap,Fe=new WeakMap,rt=new WeakSet,ls=function(){return S(this,ue)*1e3*1.5};function mr(){return typeof CompressionStream!="undefined"}function pr(s){return N(this,null,function*(){const e=new Blob([s]).stream().pipeThrough(new CompressionStream("gzip")),t=[];try{for(var r=$s(e),n,a,i;n=!(a=yield r.next()).done;n=!1){const o=a.value;t.push(o)}}catch(o){i=[o]}finally{try{n&&(a=r.return)&&(yield a.call(r))}finally{if(i)throw i[0]}}return yield gr(t)})}function gr(s){return N(this,null,function*(){const e=yield new Blob(s).arrayBuffer();return new Uint8Array(e)})}class yr extends Error{constructor({resource:e,api:t,args:r,cause:n}){if(super(`API Error on resource "${e}" at api "${t}"`),this.causeProperties={},this.name="API Error",this.resource=e,this.api=t,this.cause=n,this.args=r,n instanceof Error)for(const[i,o]of Object.entries(n))if(typeof Headers!="undefined"&&o instanceof Headers){const c={};o.forEach((d,h)=>{c[h]=d}),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 Rt extends Error{constructor({url:e,method:t,statusCode:r,requestHeaders:n,responseHeaders:a,body:i}){if(super("Fetch Error"),this.name="Fetch Error",this.url=e,this.method=t,this.statusNumber=r,this.requestHeaders=n,this.responseHeaders=a,i)try{const o=JSON.parse(i);this.body=o}catch(o){this.body=i}}}class xe extends Error{constructor(e={}){const{canceled:t=!1}=e;super("Abort Error"),this.name="Abort Error",this.canceled=t}}class vr extends Error{constructor(e){super(`Async API Error: ${JSON.stringify(e)}`),this.name="Async API Error",this.body=e}}class Xe extends Error{constructor(e){super(e),this.name="Request Validation Error"}}function fs(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function nt(){return Math.floor(Date.now()/1e3).toString()}const _r=300*1e3,br=1*1e3;var de,Z,q,at,it,Se;class wr{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){D(this,q),D(this,de),D(this,Z),this.baseAddress=t,I(this,de,e),I(this,Z,{}),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 I(this,Z,e),this}get(e){return N(this,arguments,function*(t,r={}){const{overrideBaseAddress:n,overrideDefaultHeaders:a}=r,i=n!=null?n:this.baseAddress;let o=a!=null?a:this.headers;const c=ke(S(this,Z));return I(this,Z,{}),c.extraHeaders&&(o=$($({},o),c.extraHeaders)),c.requestValidation&&(o=yt($({},o),{"X-Request-Nonce":fs(),"X-Request-Timestamp":nt()})),c.async?yield z(this,q,it).call(this,`${i}${t}`,c.async,{headers:o}):yield z(this,q,at).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return N(this,arguments,function*(r,n,a={}){const i=ke(S(this,Z));return I(this,Z,{}),z(this,q,Se).call(this,r,"POST",n,a,i)})}put(e,t){return N(this,arguments,function*(r,n,a={}){const i=ke(S(this,Z));return I(this,Z,{}),z(this,q,Se).call(this,r,"PUT",n,a,i)})}delete(e,t){return N(this,arguments,function*(r,n,a={}){const i=ke(S(this,Z));return I(this,Z,{}),z(this,q,Se).call(this,r,"DELETE",n,a,i)})}patch(e,t){return N(this,arguments,function*(r,n,a={}){const i=ke(S(this,Z));return I(this,Z,{}),z(this,q,Se).call(this,r,"PATCH",n,a,i)})}}de=new WeakMap,Z=new WeakMap,q=new WeakSet,at=function(s,e,t){return N(this,null,function*(){const r=()=>N(this,null,function*(){var c,d;try{return yield S(this,de).call(this,s,$($({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(h){throw h instanceof Error&&h.name==="AbortError"?new xe({canceled:(d=(c=e.abortSignal)==null?void 0:c.aborted)!=null?d:!1}):h}}),{headers:n}=t!=null?t:{},a=(c,d)=>{var h,w;return((h=c==null?void 0:c.headers)==null?void 0:h.get(d))||((w=c==null?void 0:c.headersObject)==null?void 0:w[d])||""},i=c=>N(this,null,function*(){var d;if(!c.ok){const w=yield c.text().catch();throw new Rt({url:s,method:(d=t==null?void 0:t.method)!=null?d:"GET",statusCode:c.status,requestHeaders:n,responseHeaders:c.headers,body:w})}if(e.requestValidation&&process.env.UI_TESTS!==!0)try{const w=a(c,"x-response-nonce"),P=n==null?void 0:n["X-Request-Nonce"];if(!w||w!==P)throw new Xe("Response nonce mismatch");const U=Number(a(c,"x-response-timestamp")),M=Number(nt()),L=3600*24;if(isNaN(U)||Math.abs(M-U)>L)throw new Xe("Invalid response timestamp")}catch(w){const P=w instanceof Error?w.message:"Request validation failed";throw new Xe(P)}let h=yield c.text();try{h=JSON.parse(h)}catch(w){}return h});if(e.retry){const c=yield new hr({maxAttempts:e.retry,func:r}).run();return yield i(c)}const o=yield r();return yield i(o)})},it=function(s,e,t){return N(this,null,function*(){var r,n;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>br,maxTimeout:c=_r}=e,d=`${s}/async`,h=`${s}/async/job`;let w;try{w=yield S(this,de).call(this,d,$($({},t),i&&{signal:i}))}catch(M){throw M instanceof Error&&M.name==="AbortError"?new xe({canceled:(r=i==null?void 0:i.aborted)!=null?r:!1}):M}if(!w.ok){const M=yield w.text().catch();throw new Rt({url:s,method:(n=t==null?void 0:t.method)!=null?n:"GET",statusCode:w.status,requestHeaders:this.headers,responseHeaders:w.headers,body:M})}const P=yield w.json(),{job_id:U}=P;if(!U)throw new Error("Job ID not found in response");return new Promise((M,L)=>N(this,null,function*(){const G=setTimeout(()=>{L(new Error("Job timed out"))},c),oe=(ee=0)=>N(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(G),S(this,de).call(this,`${h}/${U}/cancel`,{method:"POST",headers:this.headers}).then(()=>{L(new xe({canceled:!0}))}).catch(F=>{L(new xe({canceled:!1}))});return}try{const F=yield(yield S(this,de).call(this,`${h}/${U}`,{headers:this.headers})).json();if(F.status==="success"){clearTimeout(G);const te=F.response_json;M(te)}else if(F.status==="failed")clearTimeout(G),L(new vr(F.response_json));else{a&&a(F.response_json);const te=o(ee);setTimeout(()=>oe(ee+1),te)}}catch(F){L(F)}});oe()}))})},Se=function(s,e,t,r,n){return N(this,null,function*(){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=r,o=a!=null?a:this.baseAddress;let c=i!=null?i:this.headers;n.extraHeaders&&(c=$($({},c),n.extraHeaders)),n.requestValidation&&(c=yt($({},c),{"X-Request-Nonce":fs(),"X-Request-Timestamp":nt()}));let d=t;return typeof FormData!="undefined"&&t instanceof FormData?delete c["Content-Type"]:(d=r.skipBodyJsonStringify?t:JSON.stringify(t),n.compress&&mr()&&(c["Content-Encoding"]="gzip",d=yield pr(d))),n.async?yield z(this,q,it).call(this,`${o}${s}`,n.async,{method:e,headers:c,body:d}):yield z(this,q,at).call(this,`${o}${s}`,n,{method:e,headers:c,body:d})})};const jt=(s,e,t,r)=>s instanceof xe?s:new yr({resource:e,api:String(t),args:r,cause:s}),Ke=(s,e)=>new Proxy(e,{get(t,r){return(...n)=>{var a;for(const o of s.plugins){const c=(a=o.beforeApi)==null?void 0:a.call(o,{resource:t.resourceName,api:r,args:n});if(c!==void 0)return c}let i;try{i=t[r](...n)}catch(o){throw jt(o,t.resourceName,r,n)}return i instanceof Promise?i.catch(o=>{throw jt(o,t.resourceName,r,n)}):i}}});var Te;class kr{constructor(e){D(this,Te),this.resourceName="Files",I(this,Te,e)}get(e){return N(this,arguments,function*({fileKey:t,params:r={}}){const n=new URLSearchParams($({plugin_data:"857346721138427857"},r)).toString(),a=`v1/files/${t}?${n}`;return yield S(this,Te).get(a)})}getImageFills(e){return N(this,arguments,function*({fileKey:t}){var r,n;const a=`v1/files/${t}/images`;return(n=(r=(yield S(this,Te).get(a)).meta)==null?void 0:r.images)!=null?n:{}})}}Te=new WeakMap;const xr=(s,e,t)=>{const r=e.sort();return`${s}-${r.join("-")}-${t}`},Sr=s=>s?s.ts>Date.now()-1e3*30:!1;var B,ot,hs;class Tr{constructor(e){D(this,ot),D(this,B),this.resourceName="Images",I(this,B,e)}get(e){return N(this,arguments,function*({fileKey:t,nodeIds:r,format:n="jpg",scale:a}){const i=xr(t,r,n),o=S(this,B).cache.images.entries.get(i);if(Sr(o))return o.result;o&&S(this,B).cache.images.entries.delete(i);const c=S(this,B).cache.images.pendingRequests.get(i);if(c)return c;const d=z(this,ot,hs).call(this,i,t,r,n,a);S(this,B).cache.images.pendingRequests.set(i,d);try{return yield d}finally{S(this,B).cache.images.pendingRequests.delete(i)}})}}B=new WeakMap,ot=new WeakSet,hs=function(s,e,t,r,n){return N(this,null,function*(){const a=yield S(this,B).get(`v1/images/${e}?ids=${t}&format=${r}${n?`&scale=${n}`:""}`);return S(this,B).cache.images.entries.set(s,{result:a,ts:Date.now()}),a})};var $e;class Ar{constructor(e){D(this,$e),this.resourceName="Nodes",I(this,$e,e)}get(e){return N(this,arguments,function*({fileKey:t,nodeIds:r,params:n={}}){const a=yt($({},n),{ids:r.join(",")}),i=new URLSearchParams($({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield S(this,$e).get(o)})}}$e=new WeakMap;var re;class ms extends wr{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),D(this,re,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=Ke(this,new kr(this)),this.nodes=Ke(this,new Ar(this)),this.images=Ke(this,new Tr(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");I(this,re,e)}get token(){return S(this,re)}get headers(){const e={"Content-Type":"application/json"};return S(this,re).startsWith("figd_")?e["X-FIGMA-TOKEN"]=S(this,re):S(this,re).startsWith("figu_")&&(e.Authorization=`Bearer ${S(this,re)}`),e}}re=new WeakMap;const ps=a=>E(null,[a],function*({fileKey:s,authToken:e,figmaRestApi:t=new ms,params:r={},signal:n}){e&&(t.token=e);try{return yield t.withOptions({abortSignal:n}).files.get({fileKey:s,params:r})}catch(i){throw i instanceof Error&&i.name==="AbortError"?i:(console.error(i),gt(i,s))}}),Cr=i=>E(null,[i],function*({fileKey:s,authToken:e,nodeIds:t,figmaRestApi:r=new ms,params:n={},signal:a}){e&&(r.token=e);try{return(yield r.withOptions({abortSignal:a}).nodes.get({fileKey:s,nodeIds:t,params:u({},n)})).nodes}catch(o){throw o instanceof Error&&o.name==="AbortError"?o:gt(o,s)}}),bt=(s,e)=>{if(s.id===e)return s;if("children"in s)for(const t of s.children){const r=bt(t,e);if(r)return r}return null};var x;(function(s){s.assertEqual=n=>{};function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},s.getValidEnumValues=n=>{const a=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return s.objectValues(i)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},s.find=(n,a)=>{for(const i of n)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Pt;(function(s){s.mergeShapes=(e,t)=>u(u({},e),t)})(Pt||(Pt={}));const m=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ne=s=>{switch(typeof s){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(s)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(s)?m.array:s===null?m.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?m.promise:typeof Map!="undefined"&&s instanceof Map?m.map:typeof Set!="undefined"&&s instanceof Set?m.set:typeof Date!="undefined"&&s instanceof Date?m.date:m.object;default:return m.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"]);class Y extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return n(this),r}static assert(e){if(!(e instanceof Y))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}Y.create=s=>new Y(s);const ct=(s,e)=>{let t;switch(s.code){case l.invalid_type:s.received===m.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.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 s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case l.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case l.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.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 ${s.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let Er=ct;function Or(){return Er}const Nr=s=>{const{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],i=_(u({},n),{path:a});if(n.message!==void 0)return _(u({},n),{path:a,message:n.message});let o="";const c=r.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return _(u({},n),{path:a,message:o})};function f(s,e){const t=Or(),r=Nr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===ct?void 0:ct].filter(n=>!!n)});s.common.issues.push(r)}class j{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if(n.status==="aborted")return v;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return E(this,null,function*(){const r=[];for(const n of t){const a=yield n.key,i=yield n.value;r.push({key:a,value:i})}return j.mergeObjectSync(e,r)})}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:a,value:i}=n;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"||n.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),Ae=s=>({status:"dirty",value:s}),V=s=>({status:"valid",value:s}),Mt=s=>s.status==="aborted",Zt=s=>s.status==="dirty",ye=s=>s.status==="valid",Le=s=>typeof Promise!="undefined"&&s instanceof Promise;var p;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));class J{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ft=(s,e)=>{if(ye(e))return{success:!0,data:e.value};if(!s.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 Y(s.common.issues);return this._error=t,this._error}}};function b(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{var d,h;const{message:c}=s;return i.code==="invalid_enum_value"?{message:c!=null?c:o.defaultError}:typeof o.data=="undefined"?{message:(d=c!=null?c:r)!=null?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(h=c!=null?c:t)!=null?h:o.defaultError}},description:n}}class k{get description(){return this._def.description}_getType(e){return ne(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Le(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var a;const r={common:{issues:[],async:(a=t==null?void 0:t.async)!=null?a:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ne(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Ft(r,n)}"~validate"(e){var r,n;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ne(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return ye(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(n=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>ye(a)?{value:a.value}:{issues:t.common.issues})}parseAsync(e,t){return E(this,null,function*(){const r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return E(this,null,function*(){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ne(e)},n=this._parse({data:e,path:r.path,parent:r}),a=yield Le(n)?n:Promise.resolve(n);return Ft(r,a)})}refine(e,t){const r=n=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue(u({code:l.custom},r(n)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new be({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 ae.create(this,this._def)}nullable(){return we.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return qe.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return Ue.create(this,e,this._def)}transform(e){return new be(_(u({},b(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new ht(_(u({},b(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Yr(u({typeName:y.ZodBranded,type:this},b(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new mt(_(u({},b(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(_(u({},this._def),{description:e}))}pipe(e){return wt.create(this,e)}readonly(){return pt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ir=/^c[^\s-]{8,}$/i,Rr=/^[0-9a-z]+$/,jr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Pr=/^[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,Mr=/^[a-z0-9_-]{21}$/i,Zr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$r=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Qe;const Dr=/^(?:(?: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])$/,Vr=/^(?:(?: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])$/,Ur=/^(([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]))$/,Wr=/^(([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])$/,qr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Br=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gs="((\\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])))",zr=new RegExp(`^${gs}$`);function ys(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Hr(s){return new RegExp(`^${ys(s)}$`)}function Jr(s){let e=`${gs}T${ys(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Gr(s,e){return!!((e==="v4"||!e)&&Dr.test(s)||(e==="v6"||!e)&&Ur.test(s))}function Xr(s,e){if(!Zr.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch(t){return!1}}function Kr(s,e){return!!((e==="v4"||!e)&&Vr.test(s)||(e==="v6"||!e)&&Wr.test(s))}class K extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:m.string,received:a.parsedType}),v}const r=new j;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?f(n,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(n,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")$r.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"email",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Qe||(Qe=new RegExp(Lr,"u")),Qe.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"emoji",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Pr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"uuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Mr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"nanoid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ir.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"cuid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Rr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"cuid2",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")jr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"ulid",code:l.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){n=this._getOrReturnCtx(e,n),f(n,{validation:"url",code:l.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"regex",code:l.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Jr(a).test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?zr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Hr(a).test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:l.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Fr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"duration",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Gr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"ip",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Xr(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"jwt",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Kr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"cidr",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?qr.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"base64",code:l.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Br.test(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{validation:"base64url",code:l.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),u({validation:t,code:l.invalid_string},p.errToObj(r)))}_addCheck(e){return new K(_(u({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(u({kind:"email"},p.errToObj(e)))}url(e){return this._addCheck(u({kind:"url"},p.errToObj(e)))}emoji(e){return this._addCheck(u({kind:"emoji"},p.errToObj(e)))}uuid(e){return this._addCheck(u({kind:"uuid"},p.errToObj(e)))}nanoid(e){return this._addCheck(u({kind:"nanoid"},p.errToObj(e)))}cuid(e){return this._addCheck(u({kind:"cuid"},p.errToObj(e)))}cuid2(e){return this._addCheck(u({kind:"cuid2"},p.errToObj(e)))}ulid(e){return this._addCheck(u({kind:"ulid"},p.errToObj(e)))}base64(e){return this._addCheck(u({kind:"base64"},p.errToObj(e)))}base64url(e){return this._addCheck(u({kind:"base64url"},p.errToObj(e)))}jwt(e){return this._addCheck(u({kind:"jwt"},p.errToObj(e)))}ip(e){return this._addCheck(u({kind:"ip"},p.errToObj(e)))}cidr(e){return this._addCheck(u({kind:"cidr"},p.errToObj(e)))}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(u({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:!1,local:(r=e==null?void 0:e.local)!=null?r:!1},p.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(u({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},p.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(u({kind:"duration"},p.errToObj(e)))}regex(e,t){return this._addCheck(u({kind:"regex",regex:e},p.errToObj(t)))}includes(e,t){return this._addCheck(u({kind:"includes",value:e,position:t==null?void 0:t.position},p.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(u({kind:"startsWith",value:e},p.errToObj(t)))}endsWith(e,t){return this._addCheck(u({kind:"endsWith",value:e},p.errToObj(t)))}min(e,t){return this._addCheck(u({kind:"min",value:e},p.errToObj(t)))}max(e,t){return this._addCheck(u({kind:"max",value:e},p.errToObj(t)))}length(e,t){return this._addCheck(u({kind:"length",value:e},p.errToObj(t)))}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new K(_(u({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new K(_(u({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new K(_(u({},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}}K.create=s=>{var e;return new K(u({checks:[],typeName:y.ZodString,coerce:(e=s==null?void 0:s.coerce)!=null?e:!1},b(s)))};function Qr(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=Number.parseInt(s.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/Tt(10,n)}class ve extends k{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)!==m.number){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:m.number,received:a.parsedType}),v}let r;const n=new j;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Qr(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new ve(_(u({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]}))}_addCheck(e){return new ve(_(u({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ve.create=s=>new ve(u({checks:[],typeName:y.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1},b(s)));class Ee extends k{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)!==m.bigint)return this._getInvalidInput(e);let r;const n=new j;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:m.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new Ee(_(u({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]}))}_addCheck(e){return new Ee(_(u({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.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}}Ee.create=s=>{var e;return new Ee(u({checks:[],typeName:y.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!=null?e:!1},b(s)))};class ut extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.boolean,received:r.parsedType}),v}return V(e.data)}}ut.create=s=>new ut(u({typeName:y.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1},b(s)));class De extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_type,expected:m.date,received:a.parsedType}),v}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:l.invalid_date}),v}const r=new j;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),f(n,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De(_(u({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.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}}De.create=s=>new De(u({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:y.ZodDate},b(s)));class $t extends k{_parse(e){if(this._getType(e)!==m.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.symbol,received:r.parsedType}),v}return V(e.data)}}$t.create=s=>new $t(u({typeName:y.ZodSymbol},b(s)));class Lt extends k{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.undefined,received:r.parsedType}),v}return V(e.data)}}Lt.create=s=>new Lt(u({typeName:y.ZodUndefined},b(s)));class Dt extends k{_parse(e){if(this._getType(e)!==m.null){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.null,received:r.parsedType}),v}return V(e.data)}}Dt.create=s=>new Dt(u({typeName:y.ZodNull},b(s)));class Vt extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return V(e.data)}}Vt.create=s=>new Vt(u({typeName:y.ZodAny},b(s)));class dt extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return V(e.data)}}dt.create=s=>new dt(u({typeName:y.ZodUnknown},b(s)));class ie extends k{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:l.invalid_type,expected:m.never,received:t.parsedType}),v}}ie.create=s=>new ie(u({typeName:y.ZodNever},b(s)));class Ut extends k{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.void,received:r.parsedType}),v}return V(e.data)}}Ut.create=s=>new Ut(u({typeName:y.ZodVoid},b(s)));class H extends k{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==m.array)return f(t,{code:l.invalid_type,expected:m.array,received:t.parsedType}),v;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(f(t,{code:i?l.too_big:l.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(f(t,{code:l.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(f(t,{code:l.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new J(t,i,t.path,o)))).then(i=>j.mergeArray(r,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new J(t,i,t.path,o)));return j.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new H(_(u({},this._def),{minLength:{value:e,message:p.toString(t)}}))}max(e,t){return new H(_(u({},this._def),{maxLength:{value:e,message:p.toString(t)}}))}length(e,t){return new H(_(u({},this._def),{exactLength:{value:e,message:p.toString(t)}}))}nonempty(e){return this.min(1,e)}}H.create=(s,e)=>new H(u({type:s,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},b(e)));function pe(s){if(s instanceof O){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=ae.create(pe(r))}return new O(_(u({},s._def),{shape:()=>e}))}else return s instanceof H?new H(_(u({},s._def),{type:pe(s.element)})):s instanceof ae?ae.create(pe(s.unwrap())):s instanceof we?we.create(pe(s.unwrap())):s instanceof le?le.create(s.items.map(e=>pe(e))):s}class O extends k{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},this._cached}_parse(e){if(this._getType(e)!==m.object){const d=this._getOrReturnCtx(e);return f(d,{code:l.invalid_type,expected:m.object,received:d.parsedType}),v}const{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const d in n.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const h=a[d],w=n.data[d];c.push({key:{status:"valid",value:d},value:h._parse(new J(n,w,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof ie){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:n.data[h]}});else if(d==="strict")o.length>0&&(f(n,{code:l.unrecognized_keys,keys:o}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of o){const w=n.data[h];c.push({key:{status:"valid",value:h},value:d._parse(new J(n,w,n.path,h)),alwaysSet:h in n.data})}}return n.common.async?Promise.resolve().then(()=>E(this,null,function*(){const d=[];for(const h of c){const w=yield h.key,P=yield h.value;d.push({key:w,value:P,alwaysSet:h.alwaysSet})}return d})).then(d=>j.mergeObjectSync(r,d)):j.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new O(u(_(u({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,r)=>{var a,i,o,c;const n=(o=(i=(a=this._def).errorMap)==null?void 0:i.call(a,t,r).message)!=null?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=p.errToObj(e).message)!=null?c:n}:{message:n}}}:{}))}strip(){return new O(_(u({},this._def),{unknownKeys:"strip"}))}passthrough(){return new O(_(u({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new O(_(u({},this._def),{shape:()=>u(u({},this._def.shape()),e)}))}merge(e){return new O({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>u(u({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new O(_(u({},this._def),{catchall:e}))}pick(e){const t={};for(const r of x.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new O(_(u({},this._def),{shape:()=>t}))}omit(e){const t={};for(const r of x.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new O(_(u({},this._def),{shape:()=>t}))}deepPartial(){return pe(this)}partial(e){const t={};for(const r of x.objectKeys(this.shape)){const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new O(_(u({},this._def),{shape:()=>t}))}required(e){const t={};for(const r of x.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof ae;)a=a._def.innerType;t[r]=a}return new O(_(u({},this._def),{shape:()=>t}))}keyof(){return vs(x.objectKeys(this.shape))}}O.create=(s,e)=>new O(u({shape:()=>s,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},b(e)));O.strictCreate=(s,e)=>new O(u({shape:()=>s,unknownKeys:"strict",catchall:ie.create(),typeName:y.ZodObject},b(e)));O.lazycreate=(s,e)=>new O(u({shape:s,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},b(e)));class Ve extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(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 Y(o.ctx.common.issues));return f(t,{code:l.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(r.map(a=>E(this,null,function*(){const i=_(u({},t),{common:_(u({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(n);{let a;const i=[];for(const c of r){const d=_(u({},t),{common:_(u({},t.common),{issues:[]}),parent:null}),h=c._parseSync({data:t.data,path:t.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Y(c));return f(t,{code:l.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Ve.create=(s,e)=>new Ve(u({options:s,typeName:y.ZodUnion},b(e)));function lt(s,e){const t=ne(s),r=ne(e);if(s===e)return{valid:!0,data:s};if(t===m.object&&r===m.object){const n=x.objectKeys(e),a=x.objectKeys(s).filter(o=>n.indexOf(o)!==-1),i=u(u({},s),e);for(const o of a){const c=lt(s[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===m.array&&r===m.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],c=lt(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===m.date&&r===m.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Ue extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,i)=>{if(Mt(a)||Mt(i))return v;const o=lt(a.value,i.value);return o.valid?((Zt(a)||Zt(i))&&t.dirty(),{status:t.value,value:o.data}):(f(r,{code:l.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ue.create=(s,e,t)=>new Ue(u({left:s,right:e,typeName:y.ZodIntersection},b(t)));class le extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return f(r,{code:l.invalid_type,expected:m.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new J(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>j.mergeArray(t,i)):j.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new le(_(u({},this._def),{rest:e}))}}le.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new le(u({items:s,typeName:y.ZodTuple,rest:null},b(e)))};class We extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return f(r,{code:l.invalid_type,expected:m.object,received:r.parsedType}),v;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)n.push({key:a._parse(new J(r,o,r.path,o)),value:i._parse(new J(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?j.mergeObjectAsync(t,n):j.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof k?new We(u({keyType:e,valueType:t,typeName:y.ZodRecord},b(r))):new We(u({keyType:K.create(),valueType:e,typeName:y.ZodRecord},b(t)))}}class Wt extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return f(r,{code:l.invalid_type,expected:m.map,received:r.parsedType}),v;const n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,c],d)=>({key:n._parse(new J(r,o,r.path,[d,"key"])),value:a._parse(new J(r,c,r.path,[d,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(()=>E(this,null,function*(){for(const c of i){const d=yield c.key,h=yield c.value;if(d.status==="aborted"||h.status==="aborted")return v;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(d.value,h.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const d=c.key,h=c.value;if(d.status==="aborted"||h.status==="aborted")return v;(d.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(d.value,h.value)}return{status:t.value,value:o}}}}Wt.create=(s,e,t)=>new Wt(u({valueType:e,keyType:s,typeName:y.ZodMap},b(t)));class Oe extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return f(r,{code:l.invalid_type,expected:m.set,received:r.parsedType}),v;const n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(f(r,{code:l.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(f(r,{code:l.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const h of c){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),d.add(h.value)}return{status:t.value,value:d}}const o=[...r.data.values()].map((c,d)=>a._parse(new J(r,c,r.path,d)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Oe(_(u({},this._def),{minSize:{value:e,message:p.toString(t)}}))}max(e,t){return new Oe(_(u({},this._def),{maxSize:{value:e,message:p.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Oe.create=(s,e)=>new Oe(u({valueType:s,minSize:null,maxSize:null,typeName:y.ZodSet},b(e)));class qt extends k{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})}}qt.create=(s,e)=>new qt(u({getter:s,typeName:y.ZodLazy},b(e)));class ft extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}ft.create=(s,e)=>new ft(u({value:s,typeName:y.ZodLiteral},b(e)));function vs(s,e){return new _e(u({values:s,typeName:y.ZodEnum},b(e)))}class _e extends k{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:x.joinValues(r),received:t.parsedType,code:l.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:l.invalid_enum_value,options:r}),v}return V(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 _e.create(e,u(u({},this._def),t))}exclude(e,t=this._def){return _e.create(this.options.filter(r=>!e.includes(r)),u(u({},this._def),t))}}_e.create=vs;class Bt extends k{_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){const n=x.objectValues(t);return f(r,{expected:x.joinValues(n),received:r.parsedType,code:l.invalid_type}),v}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=x.objectValues(t);return f(r,{received:r.data,code:l.invalid_enum_value,options:n}),v}return V(e.data)}get enum(){return this._def.values}}Bt.create=(s,e)=>new Bt(u({values:s,typeName:y.ZodNativeEnum},b(e)));class qe extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return f(t,{code:l.invalid_type,expected:m.promise,received:t.parsedType}),v;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return V(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qe.create=(s,e)=>new qe(u({type:s,typeName:y.ZodPromise},b(e)));class be extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{f(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(o=>E(this,null,function*(){if(t.value==="aborted")return v;const c=yield this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?Ae(c.value):c}));{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?Ae(o.value):o}}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ye(i))return v;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ye(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):v);x.assertNever(n)}}be.create=(s,e,t)=>new be(u({schema:s,typeName:y.ZodEffects,effect:e},b(t)));be.createWithPreprocess=(s,e,t)=>new be(u({schema:e,effect:{type:"preprocess",transform:s},typeName:y.ZodEffects},b(t)));class ae extends k{_parse(e){return this._getType(e)===m.undefined?V(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ae.create=(s,e)=>new ae(u({innerType:s,typeName:y.ZodOptional},b(e)));class we extends k{_parse(e){return this._getType(e)===m.null?V(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}we.create=(s,e)=>new we(u({innerType:s,typeName:y.ZodNullable},b(e)));class ht extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ht.create=(s,e)=>new ht(u({innerType:s,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},b(e)));class mt extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r=_(u({},t),{common:_(u({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:r.data,path:r.path,parent:u({},r)});return Le(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}mt.create=(s,e)=>new mt(u({innerType:s,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},b(e)));class zt extends k{_parse(e){if(this._getType(e)!==m.nan){const r=this._getOrReturnCtx(e);return f(r,{code:l.invalid_type,expected:m.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}zt.create=s=>new zt(u({typeName:y.ZodNaN},b(s)));class Yr extends k{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class wt extends k{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return E(this,null,function*(){const a=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),Ae(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})});{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?v:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new wt({in:e,out:t,typeName:y.ZodPipeline})}}class pt extends k{_parse(e){const t=this._def.innerType._parse(e),r=n=>(ye(n)&&(n.value=Object.freeze(n.value)),n);return Le(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}}pt.create=(s,e)=>new pt(u({innerType:s,typeName:y.ZodReadonly},b(e)));var y;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(y||(y={}));const je=K.create,en=ve.create,W=ut.create,tn=dt.create;ie.create;const Ht=H.create,Pe=O.create,sn=Ve.create;Ue.create;le.create;const rn=We.create,Jt=ft.create,Me=_e.create;qe.create;ae.create;we.create;const nn=Pe({language:Me(["typescript","javascript"]).optional(),disableMarkedForExport:W().optional(),allowAutoSelectFirstNode:W().optional().default(!0),enableDisplayDataId:W().optional(),enableDisplayDataName:W().optional()}).and(sn([Pe({framework:Jt("react"),model:je().optional(),styling:Me(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:Me(["mui","antd","radix","shadcn","clean_react"]).optional(),responsivePages:Ht(Pe({name:je(),framesId:Ht(je())})).optional(),enableUILibraryTheming:W().optional(),enableCompactStructure:W().optional(),enableDisplayScreenModelId:W().optional(),enableGeneratePackageLock:W().optional(),enableAnimationsPreset:W().optional(),enableAutoSplit:W().optional(),autoSplitThreshold:en().optional(),url:je().url().optional(),codegenSettings:rn(tn()).optional()}),Pe({framework:Jt("html"),styling:Me(["plain_css","inline_styles","tailwind"]),enableTranslation:W().optional()})])),_s=s=>{const e=nn.safeParse(s);if(e.success===!1){const t=new Error("Invalid codegen settings");throw t.cause=e.error,t}return e.data},Gt=new Set(["FRAME","INSTANCE","COMPONENT","COMPONENT_SET","GROUP"]),bs=(s,e,t={allowAutoSelectFirstNode:!0})=>{const r=bt(s.document,e);if(!r)return{isValid:!1,reason:"There is no node with the given id"};if(r.type==="CANVAS"){const n=r.children.filter(a=>Gt.has(a.type));return n.length===0?{isValid:!1,reason:"Selected node is a page with no valid children"}:n.length===1?{isValid:!0,node:n[0],note:"Selected node is a page with a single valid children - returning it instead"}:t.allowAutoSelectFirstNode?{isValid:!0,node:n[0],note:"Selected node is a page with multiple valid children - returning the first one instead"}:{isValid:!1,reason:"Selected node is a page with multiple children"}}return Gt.has(r.type)?{isValid:!0,node:r}:{isValid:!1,reason:"Selected node type is not supported"}};var A,Ne,Q,ws,Ce;class an{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){Re(this,Q);Re(this,A);Re(this,Ne);Je(this,Ne,t),e&&(this.auth=e)}hasAuth(){return!!C(this,A)}set auth(e){Je(this,A,e)}get headers(){const e={"Content-Type":"application/json"};return C(this,A)&&(e.Authorization=`Bearer ${C(this,A).token}`,"teamId"in C(this,A)&&(e["X-Team-Id"]=C(this,A).teamId)),e}generateCode(n){return E(this,arguments,function*(e,t={},r){var c;const a=_s(e.settings);e.figmaToken&&(yield me(this,Q,ws).call(this,e.fileKey,e.figmaToken,e.nodesId,{allowAutoSelectFirstNode:(c=a.allowAutoSelectFirstNode)!=null?c:!0},r));let i=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(i!=null&&i.externalId||(i={externalId:C(this,A).userId}));const o={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,allowAutoSelectFirstNode:a.allowAutoSelectFirstNode,enableDisplayScreenModelId:a.enableDisplayScreenModelId,enableGeneratePackageLock:a.enableGeneratePackageLock,enableAnimationsPreset:a.enableAnimationsPreset,enableDisplayDataId:a.enableDisplayDataId,enableDisplayDataName:a.enableDisplayDataName,codegenSettings:a.codegenSettings,webhookUrl:e.webhookUrl};return me(this,Q,Ce).call(this,"/v1/codegen",o,t,"codegen",r)})}generateCodeFromWebsite(n){return E(this,arguments,function*(e,t={},r){let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));let i;if(e.mhtml)i={type:"mhtml",mhtml:e.mhtml,url:e.url};else if(e.url)i={type:"url",url:e.url};else throw new Error("Either 'url' or 'mhtml' must be provided");let o;e.experimental_useNewReactEngine&&(o="react-v2");const c={tracking:a,assetsStorage:e.assetsStorage,params:{input:i,conventions:{framework:e.settings.framework,language:e.settings.language,styling:e.settings.styling},assetsStorage:{type:"bundled"},engine:o}};return me(this,Q,Ce).call(this,"/v1/l2c",c,t,"l2c",r)})}generateCodeFromPrompt(n){return E(this,arguments,function*(e,t={},r){var o;let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));const i={tracking:a,assetsStorage:e.assetsStorage,params:u({prompt:e.prompt,images:e.images,conventions:{language:e.settings.language,framework:e.settings.framework,styling:e.settings.styling,uiLibrary:e.settings.uiLibrary}},(o=e.settings.codegenSettings)!=null?o:{}),webhookUrl:e.webhookUrl};return console.log("P2C Request Body:",JSON.stringify(i,null,2)),me(this,Q,Ce).call(this,"/v1/p2c",i,t,"p2c",r)})}generateLink2Code(n){return E(this,arguments,function*(e,t={},r){let a=e.tracking;C(this,A)&&"userId"in C(this,A)&&C(this,A).userId&&(a!=null&&a.externalId||(a={externalId:C(this,A).userId}));const i={tracking:a,assetsStorage:e.assetsStorage,params:e.params};return me(this,Q,Ce).call(this,"/v1/l2c",i,t,"l2c",r)})}}A=new WeakMap,Ne=new WeakMap,Q=new WeakSet,ws=function(e,t,r,n,a){return E(this,null,function*(){let i;try{i=yield ps({fileKey:e,authToken:t,params:{geometry:"paths"},signal:a})}catch(d){if(d instanceof Error&&d.name==="AbortError")throw d;return}const c=r.map(d=>bs(i,d,n)).find(d=>!d.isValid);if(c)throw new se({name:"Task Crashed",reason:c.reason})})},Ce=function(e,t,r,n,a){return E(this,null,function*(){var w,P,U,M,L,G,oe,ee,F,te,Ie;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const i={},o=yield fetch(`${C(this,Ne)}${e}`,{method:"POST",headers:_(u({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify(t),signal:a});if(!o.ok){const fe=yield o.text();let T;try{T=JSON.parse(fe)}catch(he){}throw((w=T==null?void 0:T.error)==null?void 0:w.name)==="ZodError"?(console.log("Zod validation error:",JSON.stringify(T.error.issues,null,2)),new se({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:T.error.issues,status:o.status})):typeof T=="object"?new se({name:`Error "${T}"`,reason:"Unknown",status:o.status}):new se({name:"HTTP error from Anima API",reason:fe,status:o.status})}if(!o.body)throw new se({name:"Stream Error",reason:"Response body is null",status:o.status});const c=o.body.getReader(),d=new TextDecoder;let h="";try{for(;;){const{done:fe,value:T}=yield c.read();if(fe)break;h+=d.decode(T,{stream:!0});const he=h.split(`
2
- `);h=he.pop()||"";for(const ce of he)if(!(!ce.trim()||ce.startsWith(":"))&&ce.startsWith("data: ")){let g;try{g=JSON.parse(ce.slice(6))}catch(vn){continue}switch(g.type){case"queueing":{typeof r=="function"?r(g):(P=r.onQueueing)==null||P.call(r,{sessionId:g.sessionId});break}case"start":{i.sessionId=g.sessionId,typeof r=="function"?r(g):(U=r.onStart)==null||U.call(r,{sessionId:g.sessionId});break}case"pre_codegen":{n==="codegen"&&(typeof r=="function"?r(g):(M=r.onPreCodegen)==null||M.call(r,{message:g.message}));break}case"assets_uploaded":{typeof r=="function"?r(g):(L=r.onAssetsUploaded)==null||L.call(r);break}case"assets_list":{i.assets=g.payload.assets,typeof r=="function"?r(g):(G=r.onAssetsList)==null||G.call(r,g.payload);break}case"figma_metadata":{n==="codegen"&&(i.figmaFileName=g.figmaFileName,i.figmaSelectedFrameName=g.figmaSelectedFrameName,typeof r=="function"?r(g):(oe=r.onFigmaMetadata)==null||oe.call(r,{figmaFileName:g.figmaFileName,figmaSelectedFrameName:g.figmaSelectedFrameName}));break}case"generating_code":{g.payload.status==="success"&&(i.files=g.payload.files),typeof r=="function"?r(g):(ee=r.onGeneratingCode)==null||ee.call(r,{status:g.payload.status,progress:g.payload.progress,files:g.payload.files});break}case"progress_messages_updated":{typeof r=="function"?r(g):(F=r.onProgressMessagesUpdated)==null||F.call(r,g.payload.progressMessages);break}case"job_status_updated":{typeof r=="function"?r(g):(te=r.onJobStatusUpdated)==null||te.call(r,g.payload.jobStatus);break}case"codegen_completed":case"generation_completed":{typeof r=="function"?r(g):(Ie=r.onCodegenCompleted)==null||Ie.call(r);break}case"error":throw new se({name:g.payload.errorName,reason:g.payload.reason});case"done":return i.tokenUsage=g.payload.tokenUsage,i.sessionId=g.payload.sessionId,i}}}}finally{c.cancel()}throw new se({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})};const on=s=>{var e;if(!s)return[!1,"",""];try{const t=new URL(s),r=t.pathname;if(t.origin!=="https://www.figma.com"&&t.origin!=="https://embed.figma.com")return[!1,"",""];const n=t.toString();if(s!==n)return[!1,"",""];const a=((e=t.searchParams.get("node-id"))!=null?e:"").replace(/-/g,":"),i=r.split("/")[2];return[(r.startsWith("/file/")&&t.searchParams.get("type")!=="whiteboard"||r.startsWith("/design/")||r.startsWith("/proto/"))&&i.length===22,i,a]}catch(t){return[!1,"",""]}},cn=({fileKey:s,nodeId:e,duplicate:t})=>{const r=new URL("https://www.figma.com");return r.pathname=`design/${s}`,t&&(r.pathname=`${r.pathname}/dummy/duplicate`),e&&r.searchParams.set("node-id",e.replace(":","-")),r};class un extends Error{constructor(e,t){super(e),this.response=t}}const dn=({files:s,screenPath:e="src/screens"})=>{const t={},r=new Set;function n(a){if(r.has(a)||!s[a])return;r.add(a),t[a]=s[a],ln(s[a].content).forEach(o=>{try{const c=fn(a,o);if(c.startsWith("src/")){const d=c.split("/").slice(0,-1).join("/");hn(s,d).forEach(w=>{r.has(w)||n(w)})}}catch(c){console.warn(`Failed to resolve import ${o} in ${a}:`,c)}})}return Object.entries(s).forEach(([a,i])=>{a.startsWith(e)?n(a):a.startsWith("src/")||(t[a]=i)}),t};function ln(s){const e=/import.*?["']([^"']+)["']/g,t=/export.*from\s+["']([^"']+)["']/g,r=[];let n;for(;(n=e.exec(s))!==null;)r.push(n[1]);for(;(n=t.exec(s))!==null;)r.push(n[1]);return[...new Set(r)]}function fn(s,e){if(!e.startsWith("."))return e;const t=s.split("/").slice(0,-1),r=e.split("/"),n=[...t];for(const a of r)a===".."?n.pop():a!=="."&&n.push(a);return n.join("/")}function hn(s,e){return Object.keys(s).filter(t=>t.startsWith(e))}function Be(s,e,t){return new ReadableStream({start(r){t.call(s,e,n=>{n.type==="error"||r.enqueue(n),(n.type==="aborted"||n.type==="error")&&r.close()}).then(n=>{r.enqueue({type:"done",payload:{tokenUsage:n.tokenUsage,sessionId:n.sessionId}}),r.close()}).catch(n=>{r.enqueue({type:"error",payload:{name:"name"in n?n.name:"Unknown error",message:"message"in n?n.message:"Unknown",status:"status"in n?n.status:void 0,detail:"detail"in n?n.detail:void 0,errorPayload:"payload"in n?n.payload:void 0}}),r.close()})}})}const ks=(s,e)=>Be(s,e,s.generateCode);function ze(s){return E(this,null,function*(){var i,o,c,d;const[e,t]=s.tee(),r=yield e.getReader().read();if(r.done||!r.value||r.value.type==="error"&&((i=r.value.payload)!=null&&i.status))return new Response(JSON.stringify(r.value),{status:((o=r.value)==null?void 0:o.type)==="error"&&(d=(c=r.value.payload)==null?void 0:c.status)!=null?d:500,headers:{"Content-Type":"application/json"}});const n=new TextEncoder,a=t.pipeThrough(new TransformStream({transform(h,w){const P=`event: ${h.type}
3
- data: ${JSON.stringify(h)}
1
+ "use strict";var Ta=Object.defineProperty,Ea=Object.defineProperties;var Aa=Object.getOwnPropertyDescriptors;var Dn=Object.getOwnPropertySymbols;var Ca=Object.prototype.hasOwnProperty,Oa=Object.prototype.propertyIsEnumerable;var Pn=e=>{throw TypeError(e)},Un=Math.pow,Mn=(e,t,n)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t)=>{for(var n in t||(t={}))Ca.call(t,n)&&Mn(e,n,t[n]);if(Dn)for(var n of Dn(t))Oa.call(t,n)&&Mn(e,n,t[n]);return e},b=(e,t)=>Ea(e,Aa(t));var Vt=(e,t,n)=>t.has(e)||Pn("Cannot "+n);var O=(e,t,n)=>(Vt(e,t,"read from private field"),n?n.call(e):t.get(e)),wt=(e,t,n)=>t.has(e)?Pn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Bt=(e,t,n,r)=>(Vt(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Le=(e,t,n)=>(Vt(e,t,"access private method"),n);var N=(e,t,n)=>new Promise((r,a)=>{var i=l=>{try{o(n.next(l))}catch(c){a(c)}},s=l=>{try{o(n.throw(l))}catch(c){a(c)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,s);o((n=n.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const Na=4,Vn=0,Bn=1,Ia=2;function Je(e){let t=e.length;for(;--t>=0;)e[t]=0}const Ra=0,kr=1,za=2,Za=3,Fa=258,Cn=29,gt=256,ct=gt+1+Cn,Me=30,On=19,Sr=2*ct+1,Ie=15,Ht=16,ja=7,Nn=256,Tr=16,Er=17,Ar=18,tn=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Et=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),La=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Cr=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$a=512,ue=new Array((ct+2)*2);Je(ue);const ot=new Array(Me*2);Je(ot);const dt=new Array($a);Je(dt);const ut=new Array(Fa-Za+1);Je(ut);const In=new Array(Cn);Je(In);const Nt=new Array(Me);Je(Nt);function Wt(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let Or,Nr,Ir;function qt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const Rr=e=>e<256?dt[e]:dt[256+(e>>>7)],ft=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},B=(e,t,n)=>{e.bi_valid>Ht-n?(e.bi_buf|=t<<e.bi_valid&65535,ft(e,e.bi_buf),e.bi_buf=t>>Ht-e.bi_valid,e.bi_valid+=n-Ht):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},ae=(e,t,n)=>{B(e,n[t*2],n[t*2+1])},zr=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},Da=e=>{e.bi_valid===16?(ft(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Ma=(e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let c,f,m,v,F,I,L=0;for(v=0;v<=Ie;v++)e.bl_count[v]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<Sr;c++)f=e.heap[c],v=n[n[f*2+1]*2+1]+1,v>l&&(v=l,L++),n[f*2+1]=v,!(f>r)&&(e.bl_count[v]++,F=0,f>=o&&(F=s[f-o]),I=n[f*2],e.opt_len+=I*(v+F),i&&(e.static_len+=I*(a[f*2+1]+F)));if(L!==0){do{for(v=l-1;e.bl_count[v]===0;)v--;e.bl_count[v]--,e.bl_count[v+1]+=2,e.bl_count[l]--,L-=2}while(L>0);for(v=l;v!==0;v--)for(f=e.bl_count[v];f!==0;)m=e.heap[--c],!(m>r)&&(n[m*2+1]!==v&&(e.opt_len+=(v-n[m*2+1])*n[m*2],n[m*2+1]=v),f--)}},Zr=(e,t,n)=>{const r=new Array(Ie+1);let a=0,i,s;for(i=1;i<=Ie;i++)a=a+n[i-1]<<1,r[i]=a;for(s=0;s<=t;s++){let o=e[s*2+1];o!==0&&(e[s*2]=zr(r[o]++,o))}},Pa=()=>{let e,t,n,r,a;const i=new Array(Ie+1);for(n=0,r=0;r<Cn-1;r++)for(In[r]=n,e=0;e<1<<tn[r];e++)ut[n++]=r;for(ut[n-1]=r,a=0,r=0;r<16;r++)for(Nt[r]=a,e=0;e<1<<Et[r];e++)dt[a++]=r;for(a>>=7;r<Me;r++)for(Nt[r]=a<<7,e=0;e<1<<Et[r]-7;e++)dt[256+a++]=r;for(t=0;t<=Ie;t++)i[t]=0;for(e=0;e<=143;)ue[e*2+1]=8,e++,i[8]++;for(;e<=255;)ue[e*2+1]=9,e++,i[9]++;for(;e<=279;)ue[e*2+1]=7,e++,i[7]++;for(;e<=287;)ue[e*2+1]=8,e++,i[8]++;for(Zr(ue,ct+1,i),e=0;e<Me;e++)ot[e*2+1]=5,ot[e*2]=zr(e,5);Or=new Wt(ue,tn,gt+1,ct,Ie),Nr=new Wt(ot,Et,0,Me,Ie),Ir=new Wt(new Array(0),La,0,On,ja)},Fr=e=>{let t;for(t=0;t<ct;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Me;t++)e.dyn_dtree[t*2]=0;for(t=0;t<On;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Nn*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},jr=e=>{e.bi_valid>8?ft(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Hn=(e,t,n,r)=>{const a=t*2,i=n*2;return e[a]<e[i]||e[a]===e[i]&&r[t]<=r[n]},Kt=(e,t,n)=>{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a<e.heap_len&&Hn(t,e.heap[a+1],e.heap[a],e.depth)&&a++,!Hn(t,r,e.heap[a],e.depth));)e.heap[n]=e.heap[a],n=a,a<<=1;e.heap[n]=r},Wn=(e,t,n)=>{let r,a,i=0,s,o;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+i++]&255,r+=(e.pending_buf[e.sym_buf+i++]&255)<<8,a=e.pending_buf[e.sym_buf+i++],r===0?ae(e,a,t):(s=ut[a],ae(e,s+gt+1,t),o=tn[s],o!==0&&(a-=In[s],B(e,a,o)),r--,s=Rr(r),ae(e,s,n),o=Et[s],o!==0&&(r-=Nt[s],B(e,r,o)));while(i<e.sym_next);ae(e,Nn,t)},nn=(e,t)=>{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,i=t.stat_desc.elems;let s,o,l=-1,c;for(e.heap_len=0,e.heap_max=Sr,s=0;s<i;s++)n[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):n[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,a&&(e.static_len-=r[c*2+1]);for(t.max_code=l,s=e.heap_len>>1;s>=1;s--)Kt(e,n,s);c=i;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Kt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,n[c*2]=n[s*2]+n[o*2],e.depth[c]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,n[s*2+1]=n[o*2+1]=c,e.heap[1]=c++,Kt(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Ma(e,t),Zr(n,l,e.bl_count)},qn=(e,t,n)=>{let r,a=-1,i,s=t[1],o=0,l=7,c=4;for(s===0&&(l=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)i=s,s=t[(r+1)*2+1],!(++o<l&&i===s)&&(o<c?e.bl_tree[i*2]+=o:i!==0?(i!==a&&e.bl_tree[i*2]++,e.bl_tree[Tr*2]++):o<=10?e.bl_tree[Er*2]++:e.bl_tree[Ar*2]++,o=0,a=i,s===0?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4))},Kn=(e,t,n)=>{let r,a=-1,i,s=t[1],o=0,l=7,c=4;for(s===0&&(l=138,c=3),r=0;r<=n;r++)if(i=s,s=t[(r+1)*2+1],!(++o<l&&i===s)){if(o<c)do ae(e,i,e.bl_tree);while(--o!==0);else i!==0?(i!==a&&(ae(e,i,e.bl_tree),o--),ae(e,Tr,e.bl_tree),B(e,o-3,2)):o<=10?(ae(e,Er,e.bl_tree),B(e,o-3,3)):(ae(e,Ar,e.bl_tree),B(e,o-11,7));o=0,a=i,s===0?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4)}},Ua=e=>{let t;for(qn(e,e.dyn_ltree,e.l_desc.max_code),qn(e,e.dyn_dtree,e.d_desc.max_code),nn(e,e.bl_desc),t=On-1;t>=3&&e.bl_tree[Cr[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},Va=(e,t,n,r)=>{let a;for(B(e,t-257,5),B(e,n-1,5),B(e,r-4,4),a=0;a<r;a++)B(e,e.bl_tree[Cr[a]*2+1],3);Kn(e,e.dyn_ltree,t-1),Kn(e,e.dyn_dtree,n-1)},Ba=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return Vn;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return Bn;for(n=32;n<gt;n++)if(e.dyn_ltree[n*2]!==0)return Bn;return Vn};let Jn=!1;const Ha=e=>{Jn||(Pa(),Jn=!0),e.l_desc=new qt(e.dyn_ltree,Or),e.d_desc=new qt(e.dyn_dtree,Nr),e.bl_desc=new qt(e.bl_tree,Ir),e.bi_buf=0,e.bi_valid=0,Fr(e)},Lr=(e,t,n,r)=>{B(e,(Ra<<1)+(r?1:0),3),jr(e),ft(e,n),ft(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Wa=e=>{B(e,kr<<1,3),ae(e,Nn,ue),Da(e)},qa=(e,t,n,r)=>{let a,i,s=0;e.level>0?(e.strm.data_type===Ia&&(e.strm.data_type=Ba(e)),nn(e,e.l_desc),nn(e,e.d_desc),s=Ua(e),a=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=a&&(a=i)):a=i=n+5,n+4<=a&&t!==-1?Lr(e,t,n,r):e.strategy===Na||i===a?(B(e,(kr<<1)+(r?1:0),3),Wn(e,ue,ot)):(B(e,(za<<1)+(r?1:0),3),Va(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),Wn(e,e.dyn_ltree,e.dyn_dtree)),Fr(e),r&&jr(e)},Ka=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(ut[n]+gt+1)*2]++,e.dyn_dtree[Rr(t)*2]++),e.sym_next===e.sym_end);var Ja=Ha,Ga=Lr,Xa=qa,Ya=Ka,Qa=Wa,ei={_tr_init:Ja,_tr_stored_block:Ga,_tr_flush_block:Xa,_tr_tally:Ya,_tr_align:Qa};const ti=(e,t,n,r)=>{let a=e&65535|0,i=e>>>16&65535|0,s=0;for(;n!==0;){s=n>2e3?2e3:n,n-=s;do a=a+t[r++]|0,i=i+a|0;while(--s);a%=65521,i%=65521}return a|i<<16|0};var $r=ti;const ni=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},ri=new Uint32Array(ni()),ai=(e,t,n,r)=>{const a=ri,i=r+n;e^=-1;for(let s=r;s<i;s++)e=e>>>8^a[(e^t[s])&255];return e^-1};var ge=ai,It={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Dr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ii,_tr_stored_block:rn,_tr_flush_block:si,_tr_tally:ke,_tr_align:oi}=ei,{Z_NO_FLUSH:Se,Z_PARTIAL_FLUSH:li,Z_FULL_FLUSH:ci,Z_FINISH:G,Z_BLOCK:Gn,Z_OK:$,Z_STREAM_END:Xn,Z_STREAM_ERROR:ie,Z_DATA_ERROR:di,Z_BUF_ERROR:Jt,Z_DEFAULT_COMPRESSION:ui,Z_FILTERED:fi,Z_HUFFMAN_ONLY:xt,Z_RLE:hi,Z_FIXED:_i,Z_DEFAULT_STRATEGY:pi,Z_UNKNOWN:mi,Z_DEFLATED:Dt}=Dr,gi=9,yi=15,vi=8,bi=29,wi=256,an=wi+1+bi,xi=30,ki=19,Si=2*an+1,Ti=15,x=3,xe=258,se=xe+x+1,Ei=32,Pe=42,Rn=57,sn=69,on=73,ln=91,cn=103,Re=113,et=666,P=1,Ge=2,Ze=3,Xe=4,Ai=3,ze=(e,t)=>(e.msg=It[t],t),Yn=e=>e*2-(e>4?9:0),we=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Ci=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=a?n-a:0;while(--t);t=a,r=t;do n=e.prev[--r],e.prev[r]=n>=a?n-a:0;while(--t)};let Oi=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,Te=Oi;const q=e=>{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},J=(e,t)=>{si(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,q(e.strm)},E=(e,t)=>{e.pending_buf[e.pending++]=t},Ye=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},dn=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),a===0?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),e.state.wrap===1?e.adler=$r(e.adler,t,a,n):e.state.wrap===2&&(e.adler=ge(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},Mr=(e,t)=>{let n=e.max_chain_length,r=e.strstart,a,i,s=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-se?e.strstart-(e.w_size-se):0,c=e.window,f=e.w_mask,m=e.prev,v=e.strstart+xe;let F=c[r+s-1],I=c[r+s];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(a=t,!(c[a+s]!==I||c[a+s-1]!==F||c[a]!==c[r]||c[++a]!==c[r+1])){r+=2,a++;do;while(c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&c[++r]===c[++a]&&r<v);if(i=xe-(v-r),r=v-xe,i>s){if(e.match_start=t,s=i,i>=o)break;F=c[r+s-1],I=c[r+s]}}while((t=m[t&f])>l&&--n!==0);return s<=e.lookahead?s:e.lookahead},Ue=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-se)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Ci(e),r+=t),e.strm.avail_in===0)break;if(n=dn(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=x)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=Te(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Te(e,e.ins_h,e.window[a+x-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<x)););}while(e.lookahead<se&&e.strm.avail_in!==0)},Pr=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,a,i,s=0,o=e.strm.avail_in;do{if(r=65535,i=e.bi_valid+42>>3,e.strm.avail_out<i||(i=e.strm.avail_out-i,a=e.strstart-e.block_start,r>a+e.strm.avail_in&&(r=a+e.strm.avail_in),r>i&&(r=i),r<n&&(r===0&&t!==G||t===Se||r!==a+e.strm.avail_in)))break;s=t===G&&r===a+e.strm.avail_in?1:0,rn(e,0,0,s),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,q(e.strm),a&&(a>r&&(a=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,r-=a),r&&(dn(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(s===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?Xe:t!==Se&&t!==G&&e.strm.avail_in===0&&e.strstart===e.block_start?Ge:(i=e.window_size-e.strstart,e.strm.avail_in>i&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(dn(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water<e.strstart&&(e.high_water=e.strstart),i=e.bi_valid+42>>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,n=i>e.w_size?e.w_size:i,a=e.strstart-e.block_start,(a>=n||(a||t===G)&&t!==Se&&e.strm.avail_in===0&&a<=i)&&(r=a>i?i:a,s=t===G&&e.strm.avail_in===0&&r===a?1:0,rn(e,e.block_start,r,s),e.block_start+=r,q(e.strm)),s?Ze:P)},Gt=(e,t)=>{let n,r;for(;;){if(e.lookahead<se){if(Ue(e),e.lookahead<se&&t===Se)return P;if(e.lookahead===0)break}if(n=0,e.lookahead>=x&&(e.ins_h=Te(e,e.ins_h,e.window[e.strstart+x-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-se&&(e.match_length=Mr(e,n)),e.match_length>=x)if(r=ke(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){e.match_length--;do e.strstart++,e.ins_h=Te(e,e.ins_h,e.window[e.strstart+x-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Te(e,e.ins_h,e.window[e.strstart+1]);else r=ke(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(J(e,!1),e.strm.avail_out===0))return P}return e.insert=e.strstart<x-1?e.strstart:x-1,t===G?(J(e,!0),e.strm.avail_out===0?Ze:Xe):e.sym_next&&(J(e,!1),e.strm.avail_out===0)?P:Ge},$e=(e,t)=>{let n,r,a;for(;;){if(e.lookahead<se){if(Ue(e),e.lookahead<se&&t===Se)return P;if(e.lookahead===0)break}if(n=0,e.lookahead>=x&&(e.ins_h=Te(e,e.ins_h,e.window[e.strstart+x-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=x-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-se&&(e.match_length=Mr(e,n),e.match_length<=5&&(e.strategy===fi||e.match_length===x&&e.strstart-e.match_start>4096)&&(e.match_length=x-1)),e.prev_length>=x&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-x,r=ke(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=Te(e,e.ins_h,e.window[e.strstart+x-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=x-1,e.strstart++,r&&(J(e,!1),e.strm.avail_out===0))return P}else if(e.match_available){if(r=ke(e,0,e.window[e.strstart-1]),r&&J(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return P}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ke(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<x-1?e.strstart:x-1,t===G?(J(e,!0),e.strm.avail_out===0?Ze:Xe):e.sym_next&&(J(e,!1),e.strm.avail_out===0)?P:Ge},Ni=(e,t)=>{let n,r,a,i;const s=e.window;for(;;){if(e.lookahead<=xe){if(Ue(e),e.lookahead<=xe&&t===Se)return P;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=x&&e.strstart>0&&(a=e.strstart-1,r=s[a],r===s[++a]&&r===s[++a]&&r===s[++a])){i=e.strstart+xe;do;while(r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&r===s[++a]&&a<i);e.match_length=xe-(i-a),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(n=ke(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ke(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(J(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===G?(J(e,!0),e.strm.avail_out===0?Ze:Xe):e.sym_next&&(J(e,!1),e.strm.avail_out===0)?P:Ge},Ii=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Ue(e),e.lookahead===0)){if(t===Se)return P;break}if(e.match_length=0,n=ke(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(J(e,!1),e.strm.avail_out===0))return P}return e.insert=0,t===G?(J(e,!0),e.strm.avail_out===0?Ze:Xe):e.sym_next&&(J(e,!1),e.strm.avail_out===0)?P:Ge};function ee(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const tt=[new ee(0,0,0,0,Pr),new ee(4,4,8,4,Gt),new ee(4,5,16,8,Gt),new ee(4,6,32,32,Gt),new ee(4,4,16,16,$e),new ee(8,16,32,32,$e),new ee(8,16,128,128,$e),new ee(8,32,128,256,$e),new ee(32,128,258,1024,$e),new ee(32,258,258,4096,$e)],Ri=e=>{e.window_size=2*e.w_size,we(e.head),e.max_lazy_match=tt[e.level].max_lazy,e.good_match=tt[e.level].good_length,e.nice_match=tt[e.level].nice_length,e.max_chain_length=tt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=x-1,e.match_available=0,e.ins_h=0};function zi(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Dt,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Si*2),this.dyn_dtree=new Uint16Array((2*xi+1)*2),this.bl_tree=new Uint16Array((2*ki+1)*2),we(this.dyn_ltree),we(this.dyn_dtree),we(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ti+1),this.heap=new Uint16Array(2*an+1),we(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*an+1),we(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const yt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Pe&&t.status!==Rn&&t.status!==sn&&t.status!==on&&t.status!==ln&&t.status!==cn&&t.status!==Re&&t.status!==et?1:0},Ur=e=>{if(yt(e))return ze(e,ie);e.total_in=e.total_out=0,e.data_type=mi;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Rn:t.wrap?Pe:Re,e.adler=t.wrap===2?0:1,t.last_flush=-2,ii(t),$},Vr=e=>{const t=Ur(e);return t===$&&Ri(e.state),t},Zi=(e,t)=>yt(e)||e.state.wrap!==2?ie:(e.state.gzhead=t,$),Br=(e,t,n,r,a,i)=>{if(!e)return ie;let s=1;if(t===ui&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),a<1||a>gi||n!==Dt||r<8||r>15||t<0||t>9||i<0||i>_i||r===8&&s!==1)return ze(e,ie);r===8&&(r=9);const o=new zi;return e.state=o,o.strm=e,o.status=Pe,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+x-1)/x),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=i,o.method=n,Vr(e)},Fi=(e,t)=>Br(e,t,Dt,yi,vi,pi),ji=(e,t)=>{if(yt(e)||t>Gn||t<0)return e?ze(e,ie):ie;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===et&&t!==G)return ze(e,e.avail_out===0?Jt:ie);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(q(e),e.avail_out===0)return n.last_flush=-1,$}else if(e.avail_in===0&&Yn(t)<=Yn(r)&&t!==G)return ze(e,Jt);if(n.status===et&&e.avail_in!==0)return ze(e,Jt);if(n.status===Pe&&n.wrap===0&&(n.status=Re),n.status===Pe){let a=Dt+(n.w_bits-8<<4)<<8,i=-1;if(n.strategy>=xt||n.level<2?i=0:n.level<6?i=1:n.level===6?i=2:i=3,a|=i<<6,n.strstart!==0&&(a|=Ei),a+=31-a%31,Ye(n,a),n.strstart!==0&&(Ye(n,e.adler>>>16),Ye(n,e.adler&65535)),e.adler=1,n.status=Re,q(e),n.pending!==0)return n.last_flush=-1,$}if(n.status===Rn){if(e.adler=0,E(n,31),E(n,139),E(n,8),n.gzhead)E(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),E(n,n.gzhead.time&255),E(n,n.gzhead.time>>8&255),E(n,n.gzhead.time>>16&255),E(n,n.gzhead.time>>24&255),E(n,n.level===9?2:n.strategy>=xt||n.level<2?4:0),E(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(E(n,n.gzhead.extra.length&255),E(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=ge(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=sn;else if(E(n,0),E(n,0),E(n,0),E(n,0),E(n,0),E(n,n.level===9?2:n.strategy>=xt||n.level<2?4:0),E(n,Ai),n.status=Re,q(e),n.pending!==0)return n.last_flush=-1,$}if(n.status===sn){if(n.gzhead.extra){let a=n.pending,i=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let o=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex+=o,q(e),n.pending!==0)return n.last_flush=-1,$;a=0,i-=o}let s=new Uint8Array(n.gzhead.extra);n.pending_buf.set(s.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex=0}n.status=on}if(n.status===on){if(n.gzhead.name){let a=n.pending,i;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a)),q(e),n.pending!==0)return n.last_flush=-1,$;a=0}n.gzindex<n.gzhead.name.length?i=n.gzhead.name.charCodeAt(n.gzindex++)&255:i=0,E(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex=0}n.status=ln}if(n.status===ln){if(n.gzhead.comment){let a=n.pending,i;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a)),q(e),n.pending!==0)return n.last_flush=-1,$;a=0}n.gzindex<n.gzhead.comment.length?i=n.gzhead.comment.charCodeAt(n.gzindex++)&255:i=0,E(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(e.adler=ge(e.adler,n.pending_buf,n.pending-a,a))}n.status=cn}if(n.status===cn){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(q(e),n.pending!==0))return n.last_flush=-1,$;E(n,e.adler&255),E(n,e.adler>>8&255),e.adler=0}if(n.status=Re,q(e),n.pending!==0)return n.last_flush=-1,$}if(e.avail_in!==0||n.lookahead!==0||t!==Se&&n.status!==et){let a=n.level===0?Pr(n,t):n.strategy===xt?Ii(n,t):n.strategy===hi?Ni(n,t):tt[n.level].func(n,t);if((a===Ze||a===Xe)&&(n.status=et),a===P||a===Ze)return e.avail_out===0&&(n.last_flush=-1),$;if(a===Ge&&(t===li?oi(n):t!==Gn&&(rn(n,0,0,!1),t===ci&&(we(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),q(e),e.avail_out===0))return n.last_flush=-1,$}return t!==G?$:n.wrap<=0?Xn:(n.wrap===2?(E(n,e.adler&255),E(n,e.adler>>8&255),E(n,e.adler>>16&255),E(n,e.adler>>24&255),E(n,e.total_in&255),E(n,e.total_in>>8&255),E(n,e.total_in>>16&255),E(n,e.total_in>>24&255)):(Ye(n,e.adler>>>16),Ye(n,e.adler&65535)),q(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?$:Xn)},Li=e=>{if(yt(e))return ie;const t=e.state.status;return e.state=null,t===Re?ze(e,di):$},$i=(e,t)=>{let n=t.length;if(yt(e))return ie;const r=e.state,a=r.wrap;if(a===2||a===1&&r.status!==Pe||r.lookahead)return ie;if(a===1&&(e.adler=$r(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){a===0&&(we(r.head),r.strstart=0,r.block_start=0,r.insert=0);let l=new Uint8Array(r.w_size);l.set(t.subarray(n-r.w_size,n),0),t=l,n=r.w_size}const i=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Ue(r);r.lookahead>=x;){let l=r.strstart,c=r.lookahead-(x-1);do r.ins_h=Te(r,r.ins_h,r.window[l+x-1]),r.prev[l&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=l,l++;while(--c);r.strstart=l,r.lookahead=x-1,Ue(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=x-1,r.match_available=0,e.next_in=s,e.input=o,e.avail_in=i,r.wrap=a,$};var Di=Fi,Mi=Br,Pi=Vr,Ui=Ur,Vi=Zi,Bi=ji,Hi=Li,Wi=$i,qi="pako deflate (from Nodeca project)",lt={deflateInit:Di,deflateInit2:Mi,deflateReset:Pi,deflateResetKeep:Ui,deflateSetHeader:Vi,deflate:Bi,deflateEnd:Hi,deflateSetDictionary:Wi,deflateInfo:qi};const Ki=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ji=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)Ki(n,r)&&(e[r]=n[r])}}return e},Gi=e=>{let t=0;for(let r=0,a=e.length;r<a;r++)t+=e[r].length;const n=new Uint8Array(t);for(let r=0,a=0,i=e.length;r<i;r++){let s=e[r];n.set(s,a),a+=s.length}return n},Hr={assign:Ji,flattenChunks:Gi};let Wr=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Wr=!1}const ht=new Uint8Array(256);for(let e=0;e<256;e++)ht[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ht[254]=ht[254]=1;var Xi=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,a,i,s=e.length,o=0;for(a=0;a<s;a++)n=e.charCodeAt(a),(n&64512)===55296&&a+1<s&&(r=e.charCodeAt(a+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),a++)),o+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(o),i=0,a=0;i<o;a++)n=e.charCodeAt(a),(n&64512)===55296&&a+1<s&&(r=e.charCodeAt(a+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),a++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|n&63):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|n&63):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|n&63);return t};const Yi=(e,t)=>{if(t<65534&&e.subarray&&Wr)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n};var Qi=(e,t)=>{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,a;const i=new Array(n*2);for(a=0,r=0;r<n;){let s=e[r++];if(s<128){i[a++]=s;continue}let o=ht[s];if(o>4){i[a++]=65533,r+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&r<n;)s=s<<6|e[r++]&63,o--;if(o>1){i[a++]=65533;continue}s<65536?i[a++]=s:(s-=65536,i[a++]=55296|s>>10&1023,i[a++]=56320|s&1023)}return Yi(i,a)},es=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+ht[e[n]]>t?n:t},qr={string2buf:Xi,buf2string:Qi,utf8border:es};function ts(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var ns=ts;const Kr=Object.prototype.toString,{Z_NO_FLUSH:rs,Z_SYNC_FLUSH:as,Z_FULL_FLUSH:is,Z_FINISH:ss,Z_OK:Rt,Z_STREAM_END:os,Z_DEFAULT_COMPRESSION:ls,Z_DEFAULT_STRATEGY:cs,Z_DEFLATED:ds}=Dr;function Mt(e){this.options=Hr.assign({level:ls,method:ds,chunkSize:16384,windowBits:15,memLevel:8,strategy:cs},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ns,this.strm.avail_out=0;let n=lt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Rt)throw new Error(It[n]);if(t.header&&lt.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=qr.string2buf(t.dictionary):Kr.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=lt.deflateSetDictionary(this.strm,r),n!==Rt)throw new Error(It[n]);this._dict_set=!0}}Mt.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,i;if(this.ended)return!1;for(t===~~t?i=t:i=t===!0?ss:rs,typeof e=="string"?n.input=qr.string2buf(e):Kr.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(i===as||i===is)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(a=lt.deflate(n,i),a===os)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=lt.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Rt;if(n.avail_out===0){this.onData(n.output);continue}if(i>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Mt.prototype.onData=function(e){this.chunks.push(e)};Mt.prototype.onEnd=function(e){e===Rt&&(this.result=Hr.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function us(e,t){const n=new Mt(t);if(n.push(e,!0),n.err)throw n.msg||It[n.err];return n.result}function fs(e,t){return t=t||{},t.gzip=!0,us(e,t)}var hs=fs,_s={gzip:hs};const{gzip:ps}=_s;var ms=ps;class ye extends Error{constructor({name:t,reason:n,status:r,detail:a}){super(),this.name=t,this.message=n,this.detail=a,this.status=r}}const Jr="Figma Token Issue";class Gr extends Error{constructor({fileKey:t,reason:n,cause:r}){super(Jr),this.fileKey=t,this.reason=n,this.cause=r}}const Xr="Rate Limit Exceeded";class Yr extends Error{constructor({fileKey:t,cause:n}){super(Xr),this.fileKey=t,this.cause=n}}const Qr="Request Too Large";class ea extends Error{constructor({fileKey:t,cause:n}){super(Qr),this.fileKey=t,this.cause=n}}const ta="Not Found";class na extends Error{constructor({fileKey:t,cause:n}){super(ta),this.fileKey=t,this.cause=n}}const ra=e=>e.message===ta,aa="Unknown Figma API Exception";class ia extends Error{constructor({fileKey:t,cause:n}){super(aa),this.name="UnknownFigmaApiException",this.fileKey=t,this.cause=n}}const gs=e=>e.message===aa,sa=e=>e.message===Xr,oa=e=>[Jr,...["Invalid Figma token","Figma token expired"]].includes(e.message),la=e=>e.message===Qr,zn=(e,t)=>{var r;if(((r=e==null?void 0:e.cause)==null?void 0:r.message)==="Fetch Error"){const{err:a,status:i}=e.cause.body;if(i===403)return new Gr({fileKey:t,reason:a,cause:e});if(i===429)return new Yr({fileKey:t,cause:e});if(i===404)return new na({fileKey:t,cause:e});if(i===400&&a.includes("Request too large"))return new ea({fileKey:t,cause:e})}return new ia({fileKey:t,cause:e})},ys=e=>ra(e)?"NotFound":sa(e)?"RateLimitExceeded":oa(e)?"FigmaTokenIssue":la(e)?"RequestTooLarge":"UnknownFigmaApiException";var vs=Object.defineProperty,bs=Object.defineProperties,ws=Object.getOwnPropertyDescriptors,Qn=Object.getOwnPropertySymbols,xs=Object.prototype.hasOwnProperty,ks=Object.prototype.propertyIsEnumerable,er=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ca=e=>{throw TypeError(e)},tr=(e,t,n)=>t in e?vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))xs.call(t,n)&&tr(e,n,t[n]);if(Qn)for(var n of Qn(t))ks.call(t,n)&&tr(e,n,t[n]);return e},Zn=(e,t)=>bs(e,ws(t)),Fn=(e,t,n)=>t.has(e)||ca("Cannot "+n),A=(e,t,n)=>(Fn(e,t,"read from private field"),n?n.call(e):t.get(e)),X=(e,t,n)=>t.has(e)?ca("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),D=(e,t,n,r)=>(Fn(e,t,"write to private field"),t.set(e,n),n),re=(e,t,n)=>(Fn(e,t,"access private method"),n),Z=(e,t,n)=>new Promise((r,a)=>{var i=l=>{try{o(n.next(l))}catch(c){a(c)}},s=l=>{try{o(n.throw(l))}catch(c){a(c)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,s);o((n=n.apply(e,t)).next())}),Ss=(e,t,n)=>(t=e[er("asyncIterator")])?t.call(e):(e=e[er("iterator")](),t={},n=(r,a)=>(a=e[r])&&(t[r]=i=>new Promise((s,o,l)=>(i=a.call(e,i),l=i.done,Promise.resolve(i.value).then(c=>s({value:c,done:l}),o)))),n("next"),n("return"),t),Ts=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Es(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var un={exports:{}},As=un.exports,nr;function Cs(){return nr||(nr=1,(function(e,t){(function(n,r){e.exports=r()})(As,function(){var n=typeof Promise=="function",r=typeof self=="object"?self:Ts,a=typeof Symbol!="undefined",i=typeof Map!="undefined",s=typeof Set!="undefined",o=typeof WeakMap!="undefined",l=typeof WeakSet!="undefined",c=typeof DataView!="undefined",f=a&&typeof Symbol.iterator!="undefined",m=a&&typeof Symbol.toStringTag!="undefined",v=s&&typeof Set.prototype.entries=="function",F=i&&typeof Map.prototype.entries=="function",I=v&&Object.getPrototypeOf(new Set().entries()),L=F&&Object.getPrototypeOf(new Map().entries()),ce=f&&typeof Array.prototype[Symbol.iterator]=="function",Ce=ce&&Object.getPrototypeOf([][Symbol.iterator]()),pe=f&&typeof String.prototype[Symbol.iterator]=="function",H=pe&&Object.getPrototypeOf(""[Symbol.iterator]()),me=8,vt=-1;function bt(R){var W=typeof R;if(W!=="object")return W;if(R===null)return"null";if(R===r)return"global";if(Array.isArray(R)&&(m===!1||!(Symbol.toStringTag in R)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&R===window.location)return"Location";if(typeof window.document=="object"&&R===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&R===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&R===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&R instanceof window.HTMLElement){if(R.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(R.tagName==="TD")return"HTMLTableDataCellElement";if(R.tagName==="TH")return"HTMLTableHeaderCellElement"}}var je=m&&R[Symbol.toStringTag];if(typeof je=="string")return je;var j=Object.getPrototypeOf(R);return j===RegExp.prototype?"RegExp":j===Date.prototype?"Date":n&&j===Promise.prototype?"Promise":s&&j===Set.prototype?"Set":i&&j===Map.prototype?"Map":l&&j===WeakSet.prototype?"WeakSet":o&&j===WeakMap.prototype?"WeakMap":c&&j===DataView.prototype?"DataView":i&&j===L?"Map Iterator":s&&j===I?"Set Iterator":ce&&j===Ce?"Array Iterator":pe&&j===H?"String Iterator":j===null?"Object":Object.prototype.toString.call(R).slice(me,vt)}return bt})})(un)),un.exports}var Os=Cs();const Ns=Es(Os),jn=typeof Buffer!="undefined",Is=jn&&typeof Buffer.from!="undefined",Rs=jn?(function(e){return Buffer.isBuffer(e)}):(function(){return!1}),zs=Is?(function(e){return Buffer.from(e)}):jn?(function(e){return new Buffer(e)}):(function(e){return e});function Ve(e){return Rs(e)?"Buffer":Ns(e)}const Zs=new Set(["Arguments","Array","Map","Object","Set"]);function Fs(e,t,n=null){switch(n||Ve(e)){case"Arguments":case"Array":case"Object":return e[t];case"Map":return e.get(t);case"Set":return t}}function fn(e){return Zs.has(e)}function rr(e,t,n,r=null){switch(r||Ve(e)){case"Arguments":case"Array":case"Object":e[t]=n;break;case"Map":e.set(t,n);break;case"Set":e.add(n);break}return e}const js=typeof globalThis!="undefined"&&globalThis!==null&&globalThis.Object===Object&&globalThis,Ls=typeof global!="undefined"&&global!==null&&global.Object===Object&&global,$s=typeof self!="undefined"&&self!==null&&self.Object===Object&&self,Xt=js||Ls||$s||Function("return this")();function Ds(e){return e.slice(0)}function Ms(e){return new Boolean(e.valueOf())}function Ps(e){return new DataView(e.buffer)}function Us(e){return zs(e)}function Vs(e){return new Date(e.getTime())}function Bs(e){return new Number(e)}function Hs(e){return new RegExp(e.source,e.flags)}function Ws(e){return new String(e)}function de(e,t){return Xt[t].from?Xt[t].from(e):new Xt[t](e)}function M(e){return e}function ar(){return[]}function qs(){return new Map}function Ks(){return{}}function Js(){return new Set}const Gs=new Map([["ArrayBuffer",Ds],["Boolean",Ms],["Buffer",Us],["DataView",Ps],["Date",Vs],["Number",Bs],["RegExp",Hs],["String",Ws],["Float32Array",de],["Float64Array",de],["Int16Array",de],["Int32Array",de],["Int8Array",de],["Uint16Array",de],["Uint32Array",de],["Uint8Array",de],["Uint8ClampedArray",de],["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",ar],["Array",ar],["Map",qs],["Object",Ks],["Set",Js]]);function Xs(){}function hn(e,t=null,n=Xs){arguments.length===2&&typeof t=="function"&&(n=t,t=null);const r=t||Ve(e),a=Gs.get(r);if(r==="Object"){const i=n(e,r);if(i!==void 0)return i}return a?a(e,r):e}function Qe(e,t={}){typeof t=="function"&&(t={customizer:t});const{customizer:n}=t,r=Ve(e);if(!fn(r))return _n(e,null,null,null);const a=hn(e,r,n),i=new WeakMap([[e,a]]),s=new WeakSet([e]);return _n(e,a,i,s)}function _n(e,t,n,r,a){const i=Ve(e),s=hn(e,i);if(!fn(i))return s;let o;switch(i){case"Arguments":case"Array":o=Object.keys(e);break;case"Object":o=Object.keys(e),o.push(...Object.getOwnPropertySymbols(e));break;case"Map":case"Set":o=e.keys();break}for(let l of o){const c=Fs(e,l,i);if(r.has(c))rr(t,l,n.get(c),i);else{const f=Ve(c),m=hn(c,f);fn(f)&&(n.set(c,m),r.add(c)),rr(t,l,_n(c,m,n,r),i)}}return t}const Ys=e=>new Promise(t=>setTimeout(t,e));var At,Oe,Ct,pn,da;class Qs{constructor({maxAttempts:t=3,func:n}){X(this,pn),X(this,At),X(this,Oe),X(this,Ct),D(this,At,t),D(this,Ct,n),D(this,Oe,0)}run(){return Z(this,null,function*(){try{return yield A(this,Ct).call(this)}catch(t){if(D(this,Oe,A(this,Oe)+1),A(this,Oe)>A(this,At))throw console.error("Max attempts reached"),t;const n=re(this,pn,da).call(this);return yield Ys(n),yield this.run()}})}}At=new WeakMap,Oe=new WeakMap,Ct=new WeakMap,pn=new WeakSet,da=function(){return A(this,Oe)*1e3*1.5};function eo(){return typeof CompressionStream!="undefined"}function to(e){return Z(this,null,function*(){const t=new Blob([e]).stream().pipeThrough(new CompressionStream("gzip")),n=[];try{for(var r=Ss(t),a,i,s;a=!(i=yield r.next()).done;a=!1){const o=i.value;n.push(o)}}catch(o){s=[o]}finally{try{a&&(i=r.return)&&(yield i.call(r))}finally{if(s)throw s[0]}}return yield no(n)})}function no(e){return Z(this,null,function*(){const t=yield new Blob(e).arrayBuffer();return new Uint8Array(t)})}class ro extends Error{constructor({resource:t,api:n,args:r,cause:a}){if(super(`API Error on resource "${t}" at api "${n}"`),this.causeProperties={},this.name="API Error",this.resource=t,this.api=n,this.cause=a,this.args=r,a instanceof Error)for(const[s,o]of Object.entries(a))if(typeof Headers!="undefined"&&o instanceof Headers){const l={};o.forEach((c,f)=>{l[f]=c}),this.causeProperties[s]=l}else this.causeProperties[s]=o;const i=this.causeProperties.body;i&&typeof i=="object"&&"code"in i&&(this.code=i.code)}}class ir extends Error{constructor({url:t,method:n,statusCode:r,requestHeaders:a,responseHeaders:i,body:s}){if(super("Fetch Error"),this.name="Fetch Error",this.url=t,this.method=n,this.statusNumber=r,this.requestHeaders=a,this.responseHeaders=i,s)try{const o=JSON.parse(s);this.body=o}catch(o){this.body=s}}}class nt extends Error{constructor(t={}){const{canceled:n=!1}=t;super("Abort Error"),this.name="Abort Error",this.canceled=n}}class ao extends Error{constructor(t){super(`Async API Error: ${JSON.stringify(t)}`),this.name="Async API Error",this.body=t}}class Yt extends Error{constructor(t){super(t),this.name="Request Validation Error"}}function ua(){return Array.from({length:32},()=>Math.floor(Math.random()*256).toString(16).padStart(2,"0")).join("")}function mn(){return Math.floor(Date.now()/1e3).toString()}const io=300*1e3,so=1*1e3;var Ne,V,te,gn,yn,rt;class oo{constructor({fetch:t=globalThis.fetch.bind(globalThis),baseAddress:n}){X(this,te),X(this,Ne),X(this,V),this.baseAddress=n,D(this,Ne,t),D(this,V,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(t){this.plugins.push(t)}removePlugin(t){this.plugins=this.plugins.filter(n=>n.name!==t)}withOptions(t={}){return D(this,V,t),this}get(t){return Z(this,arguments,function*(n,r={}){const{overrideBaseAddress:a,overrideDefaultHeaders:i}=r,s=a!=null?a:this.baseAddress;let o=i!=null?i:this.headers;const l=Qe(A(this,V));return D(this,V,{}),l.extraHeaders&&(o=K(K({},o),l.extraHeaders)),l.requestValidation&&(o=Zn(K({},o),{"X-Request-Nonce":ua(),"X-Request-Timestamp":mn()})),l.async?yield re(this,te,yn).call(this,`${s}${n}`,l.async,{headers:o}):yield re(this,te,gn).call(this,`${s}${n}`,l,{headers:o})})}post(t,n){return Z(this,arguments,function*(r,a,i={}){const s=Qe(A(this,V));return D(this,V,{}),re(this,te,rt).call(this,r,"POST",a,i,s)})}put(t,n){return Z(this,arguments,function*(r,a,i={}){const s=Qe(A(this,V));return D(this,V,{}),re(this,te,rt).call(this,r,"PUT",a,i,s)})}delete(t,n){return Z(this,arguments,function*(r,a,i={}){const s=Qe(A(this,V));return D(this,V,{}),re(this,te,rt).call(this,r,"DELETE",a,i,s)})}patch(t,n){return Z(this,arguments,function*(r,a,i={}){const s=Qe(A(this,V));return D(this,V,{}),re(this,te,rt).call(this,r,"PATCH",a,i,s)})}}Ne=new WeakMap,V=new WeakMap,te=new WeakSet,gn=function(e,t,n){return Z(this,null,function*(){const r=()=>Z(this,null,function*(){var l,c;try{return yield A(this,Ne).call(this,e,K(K({},n),t.abortSignal&&{signal:t.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new nt({canceled:(c=(l=t.abortSignal)==null?void 0:l.aborted)!=null?c:!1}):f}}),{headers:a}=n!=null?n:{},i=(l,c)=>{var f,m;return((f=l==null?void 0:l.headers)==null?void 0:f.get(c))||((m=l==null?void 0:l.headersObject)==null?void 0:m[c])||""},s=l=>Z(this,null,function*(){var c;if(!l.ok){const m=yield l.text().catch();throw new ir({url:e,method:(c=n==null?void 0:n.method)!=null?c:"GET",statusCode:l.status,requestHeaders:a,responseHeaders:l.headers,body:m})}if(t.requestValidation&&process.env.UI_TESTS!==!0)try{const m=i(l,"x-response-nonce"),v=a==null?void 0:a["X-Request-Nonce"];if(!m||m!==v)throw new Yt("Response nonce mismatch");const F=Number(i(l,"x-response-timestamp")),I=Number(mn()),L=3600*24;if(isNaN(F)||Math.abs(I-F)>L)throw new Yt("Invalid response timestamp")}catch(m){const v=m instanceof Error?m.message:"Request validation failed";throw new Yt(v)}let f=yield l.text();try{f=JSON.parse(f)}catch(m){}return f});if(t.retry){const l=yield new Qs({maxAttempts:t.retry,func:r}).run();return yield s(l)}const o=yield r();return yield s(o)})},yn=function(e,t,n){return Z(this,null,function*(){var r,a;const{onProgress:i,abortSignal:s,pollingInterval:o=()=>so,maxTimeout:l=io}=t,c=`${e}/async`,f=`${e}/async/job`;let m;try{m=yield A(this,Ne).call(this,c,K(K({},n),s&&{signal:s}))}catch(I){throw I instanceof Error&&I.name==="AbortError"?new nt({canceled:(r=s==null?void 0:s.aborted)!=null?r:!1}):I}if(!m.ok){const I=yield m.text().catch();throw new ir({url:e,method:(a=n==null?void 0:n.method)!=null?a:"GET",statusCode:m.status,requestHeaders:this.headers,responseHeaders:m.headers,body:I})}const v=yield m.json(),{job_id:F}=v;if(!F)throw new Error("Job ID not found in response");return new Promise((I,L)=>Z(this,null,function*(){const ce=setTimeout(()=>{L(new Error("Job timed out"))},l),Ce=(pe=0)=>Z(this,null,function*(){if(s!=null&&s.aborted){clearTimeout(ce),A(this,Ne).call(this,`${f}/${F}/cancel`,{method:"POST",headers:this.headers}).then(()=>{L(new nt({canceled:!0}))}).catch(H=>{L(new nt({canceled:!1}))});return}try{const H=yield(yield A(this,Ne).call(this,`${f}/${F}`,{headers:this.headers})).json();if(H.status==="success"){clearTimeout(ce);const me=H.response_json;I(me)}else if(H.status==="failed")clearTimeout(ce),L(new ao(H.response_json));else{i&&i(H.response_json);const me=o(pe);setTimeout(()=>Ce(pe+1),me)}}catch(H){L(H)}});Ce()}))})},rt=function(e,t,n,r,a){return Z(this,null,function*(){const{overrideBaseAddress:i,overrideDefaultHeaders:s}=r,o=i!=null?i:this.baseAddress;let l=s!=null?s:this.headers;a.extraHeaders&&(l=K(K({},l),a.extraHeaders)),a.requestValidation&&(l=Zn(K({},l),{"X-Request-Nonce":ua(),"X-Request-Timestamp":mn()}));let c=n;return typeof FormData!="undefined"&&n instanceof FormData?delete l["Content-Type"]:(c=r.skipBodyJsonStringify?n:JSON.stringify(n),a.compress&&eo()&&(l["Content-Encoding"]="gzip",c=yield to(c))),a.async?yield re(this,te,yn).call(this,`${o}${e}`,a.async,{method:t,headers:l,body:c}):yield re(this,te,gn).call(this,`${o}${e}`,a,{method:t,headers:l,body:c})})};const sr=(e,t,n,r)=>e instanceof nt?e:new ro({resource:t,api:String(n),args:r,cause:e}),Qt=(e,t)=>new Proxy(t,{get(n,r){return(...a)=>{var i;for(const o of e.plugins){const l=(i=o.beforeApi)==null?void 0:i.call(o,{resource:n.resourceName,api:r,args:a});if(l!==void 0)return l}let s;try{s=n[r](...a)}catch(o){throw sr(o,n.resourceName,r,a)}return s instanceof Promise?s.catch(o=>{throw sr(o,n.resourceName,r,a)}):s}}});var at;class lo{constructor(t){X(this,at),this.resourceName="Files",D(this,at,t)}get(t){return Z(this,arguments,function*({fileKey:n,params:r={}}){const a=new URLSearchParams(K({plugin_data:"857346721138427857"},r)).toString(),i=`v1/files/${n}?${a}`;return yield A(this,at).get(i)})}getImageFills(t){return Z(this,arguments,function*({fileKey:n}){var r,a;const i=`v1/files/${n}/images`;return(a=(r=(yield A(this,at).get(i)).meta)==null?void 0:r.images)!=null?a:{}})}}at=new WeakMap;const co=(e,t,n)=>{const r=t.sort();return`${e}-${r.join("-")}-${n}`},uo=e=>e?e.ts>Date.now()-1e3*30:!1;var ne,vn,fa;class fo{constructor(t){X(this,vn),X(this,ne),this.resourceName="Images",D(this,ne,t)}get(t){return Z(this,arguments,function*({fileKey:n,nodeIds:r,format:a="jpg",scale:i}){const s=co(n,r,a),o=A(this,ne).cache.images.entries.get(s);if(uo(o))return o.result;o&&A(this,ne).cache.images.entries.delete(s);const l=A(this,ne).cache.images.pendingRequests.get(s);if(l)return l;const c=re(this,vn,fa).call(this,s,n,r,a,i);A(this,ne).cache.images.pendingRequests.set(s,c);try{return yield c}finally{A(this,ne).cache.images.pendingRequests.delete(s)}})}}ne=new WeakMap,vn=new WeakSet,fa=function(e,t,n,r,a){return Z(this,null,function*(){const i=yield A(this,ne).get(`v1/images/${t}?ids=${n}&format=${r}${a?`&scale=${a}`:""}`);return A(this,ne).cache.images.entries.set(e,{result:i,ts:Date.now()}),i})};var Ot;class ho{constructor(t){X(this,Ot),this.resourceName="Nodes",D(this,Ot,t)}get(t){return Z(this,arguments,function*({fileKey:n,nodeIds:r,params:a={}}){const i=Zn(K({},a),{ids:r.join(",")}),s=new URLSearchParams(K({plugin_data:"857346721138427857"},i)).toString(),o=`v1/files/${n}/nodes?${s}`;return yield A(this,Ot).get(o)})}}Ot=new WeakMap;var ve;class ha extends oo{constructor({baseAddress:t="https://api.figma.com/",fetch:n=globalThis.fetch.bind(globalThis)}={}){super({fetch:n,baseAddress:t}),X(this,ve,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=Qt(this,new lo(this)),this.nodes=Qt(this,new ho(this)),this.images=Qt(this,new fo(this))}set token(t){if(!t.startsWith("figd_")&&!t.startsWith("figu_"))throw new Error("Invalid Figma access token");D(this,ve,t)}get token(){return A(this,ve)}get headers(){const t={"Content-Type":"application/json"};return A(this,ve).startsWith("figd_")?t["X-FIGMA-TOKEN"]=A(this,ve):A(this,ve).startsWith("figu_")&&(t.Authorization=`Bearer ${A(this,ve)}`),t}}ve=new WeakMap;const _a=i=>N(null,[i],function*({fileKey:e,authToken:t,figmaRestApi:n=new ha,params:r={},signal:a}){t&&(n.token=t);try{return yield n.withOptions({abortSignal:a}).files.get({fileKey:e,params:r})}catch(s){throw s instanceof Error&&s.name==="AbortError"?s:(console.error(s),zn(s,e))}}),_o=s=>N(null,[s],function*({fileKey:e,authToken:t,nodeIds:n,figmaRestApi:r=new ha,params:a={},signal:i}){t&&(r.token=t);try{return(yield r.withOptions({abortSignal:i}).nodes.get({fileKey:e,nodeIds:n,params:d({},a)})).nodes}catch(o){throw o instanceof Error&&o.name==="AbortError"?o:zn(o,e)}}),Ln=(e,t)=>{if(e.id===t)return e;if("children"in e)for(const n of e.children){const r=Ln(n,t);if(r)return r}return null};var T;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),s={};for(const o of i)s[o]=a[o];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},e.find=(a,i)=>{for(const s of a)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(T||(T={}));var or;(function(e){e.mergeShapes=(t,n)=>d(d({},t),n)})(or||(or={}));const _=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),be=e=>{switch(typeof e){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN(e)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(e)?_.array:e===null?_.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?_.promise:typeof Map!="undefined"&&e instanceof Map?_.map:typeof Set!="undefined"&&e instanceof Set?_.set:typeof Date!="undefined"&&e instanceof Date?_.date:_.object;default:return _.unknown}},u=T.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"]);class _e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let o=r,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(n(s))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return a(this),r}static assert(t){if(!(t instanceof _e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,T.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];n[i]=n[i]||[],n[i].push(t(a))}else r.push(t(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}_e.create=e=>new _e(e);const bn=(e,t)=>{let n;switch(e.code){case u.invalid_type:e.received===_.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,T.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${T.joinValues(e.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${T.joinValues(e.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${T.joinValues(e.options)}, received '${e.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:T.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case u.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case u.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=t.defaultError,T.assertNever(e)}return{message:n}};let po=bn;function mo(){return po}const go=e=>{const{data:t,path:n,errorMaps:r,issueData:a}=e,i=[...n,...a.path||[]],s=b(d({},a),{path:i});if(a.message!==void 0)return b(d({},a),{path:i,message:a.message});let o="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)o=c(s,{data:t,defaultError:o}).message;return b(d({},a),{path:i,message:o})};function h(e,t){const n=mo(),r=go({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===bn?void 0:bn].filter(a=>!!a)});e.common.issues.push(r)}class U{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const a of n){if(a.status==="aborted")return y;a.status==="dirty"&&t.dirty(),r.push(a.value)}return{status:t.value,value:r}}static mergeObjectAsync(t,n){return N(this,null,function*(){const r=[];for(const a of n){const i=yield a.key,s=yield a.value;r.push({key:i,value:s})}return U.mergeObjectSync(t,r)})}static mergeObjectSync(t,n){const r={};for(const a of n){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return y;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value!="undefined"||a.alwaysSet)&&(r[i.value]=s.value)}return{status:t.value,value:r}}}const y=Object.freeze({status:"aborted"}),it=e=>({status:"dirty",value:e}),Y=e=>({status:"valid",value:e}),lr=e=>e.status==="aborted",cr=e=>e.status==="dirty",Be=e=>e.status==="valid",zt=e=>typeof Promise!="undefined"&&e instanceof Promise;var p;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(p||(p={}));class le{constructor(t,n,r,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const dr=(e,t)=>{if(Be(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new _e(e.common.issues);return this._error=n,this._error}}};function w(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:a}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,o)=>{var c,f;const{message:l}=e;return s.code==="invalid_enum_value"?{message:l!=null?l:o.defaultError}:typeof o.data=="undefined"?{message:(c=l!=null?l:r)!=null?c:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(f=l!=null?l:n)!=null?f:o.defaultError}},description:a}}class k{get description(){return this._def.description}_getType(t){return be(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:be(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new U,ctx:{common:t.parent.common,data:t.data,parsedType:be(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(zt(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){var i;const r={common:{issues:[],async:(i=n==null?void 0:n.async)!=null?i:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:be(t)},a=this._parseSync({data:t,path:r.path,parent:r});return dr(r,a)}"~validate"(t){var r,a;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:be(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return Be(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(a=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>Be(i)?{value:i.value}:{issues:n.common.issues})}parseAsync(t,n){return N(this,null,function*(){const r=yield this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error})}safeParseAsync(t,n){return N(this,null,function*(){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:be(t)},a=this._parse({data:t,path:r.path,parent:r}),i=yield zt(a)?a:Promise.resolve(a);return dr(r,i)})}refine(t,n){const r=a=>typeof n=="string"||typeof n=="undefined"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,i)=>{const s=t(a),o=()=>i.addIssue(d({code:u.custom},r(a)));return typeof Promise!="undefined"&&s instanceof Promise?s.then(l=>l?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(t,n){return this._refinement((r,a)=>t(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(t){return new qe({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ee.create(this,this._def)}nullable(){return Ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return oe.create(this)}promise(){return $t.create(this,this._def)}or(t){return Ft.create([this,t],this._def)}and(t){return jt.create(this,t,this._def)}transform(t){return new qe(b(d({},w(this._def)),{schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:t}}))}default(t){const n=typeof t=="function"?t:()=>t;return new Tn(b(d({},w(this._def)),{innerType:this,defaultValue:n,typeName:g.ZodDefault}))}brand(){return new Mo(d({typeName:g.ZodBranded,type:this},w(this._def)))}catch(t){const n=typeof t=="function"?t:()=>t;return new En(b(d({},w(this._def)),{innerType:this,catchValue:n,typeName:g.ZodCatch}))}describe(t){const n=this.constructor;return new n(b(d({},this._def),{description:t}))}pipe(t){return $n.create(this,t)}readonly(){return An.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const yo=/^c[^\s-]{8,}$/i,vo=/^[0-9a-z]+$/,bo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,wo=/^[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,xo=/^[a-z0-9_-]{21}$/i,ko=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,So=/^[-+]?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)?)??$/,To=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Eo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let en;const Ao=/^(?:(?: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])$/,Co=/^(?:(?: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])$/,Oo=/^(([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]))$/,No=/^(([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])$/,Io=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ro=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pa="((\\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])))",zo=new RegExp(`^${pa}$`);function ma(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Zo(e){return new RegExp(`^${ma(e)}$`)}function Fo(e){let t=`${pa}T${ma(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function jo(e,t){return!!((t==="v4"||!t)&&Ao.test(e)||(t==="v6"||!t)&&Oo.test(e))}function Lo(e,t){if(!ko.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch(n){return!1}}function $o(e,t){return!!((t==="v4"||!t)&&Co.test(e)||(t==="v6"||!t)&&No.test(e))}class fe extends k{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==_.string){const i=this._getOrReturnCtx(t);return h(i,{code:u.invalid_type,expected:_.string,received:i.parsedType}),y}const r=new U;let a;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const s=t.data.length>i.value,o=t.data.length<i.value;(s||o)&&(a=this._getOrReturnCtx(t,a),s?h(a,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(a,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")To.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"email",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")en||(en=new RegExp(Eo,"u")),en.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"emoji",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")wo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"uuid",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")xo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"nanoid",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")yo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")vo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid2",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ulid",code:u.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch(s){a=this._getOrReturnCtx(t,a),h(a,{validation:"url",code:u.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"regex",code:u.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Fo(i).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?zo.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Zo(i).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:u.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?So.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"duration",code:u.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?jo(t.data,i.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ip",code:u.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Lo(t.data,i.alg)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"jwt",code:u.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?$o(t.data,i.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cidr",code:u.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Io.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64",code:u.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Ro.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64url",code:u.invalid_string,message:i.message}),r.dirty()):T.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(a=>t.test(a),d({validation:n,code:u.invalid_string},p.errToObj(r)))}_addCheck(t){return new fe(b(d({},this._def),{checks:[...this._def.checks,t]}))}email(t){return this._addCheck(d({kind:"email"},p.errToObj(t)))}url(t){return this._addCheck(d({kind:"url"},p.errToObj(t)))}emoji(t){return this._addCheck(d({kind:"emoji"},p.errToObj(t)))}uuid(t){return this._addCheck(d({kind:"uuid"},p.errToObj(t)))}nanoid(t){return this._addCheck(d({kind:"nanoid"},p.errToObj(t)))}cuid(t){return this._addCheck(d({kind:"cuid"},p.errToObj(t)))}cuid2(t){return this._addCheck(d({kind:"cuid2"},p.errToObj(t)))}ulid(t){return this._addCheck(d({kind:"ulid"},p.errToObj(t)))}base64(t){return this._addCheck(d({kind:"base64"},p.errToObj(t)))}base64url(t){return this._addCheck(d({kind:"base64url"},p.errToObj(t)))}jwt(t){return this._addCheck(d({kind:"jwt"},p.errToObj(t)))}ip(t){return this._addCheck(d({kind:"ip"},p.errToObj(t)))}cidr(t){return this._addCheck(d({kind:"cidr"},p.errToObj(t)))}datetime(t){var n,r;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck(d({kind:"datetime",precision:typeof(t==null?void 0:t.precision)=="undefined"?null:t==null?void 0:t.precision,offset:(n=t==null?void 0:t.offset)!=null?n:!1,local:(r=t==null?void 0:t.local)!=null?r:!1},p.errToObj(t==null?void 0:t.message)))}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck(d({kind:"time",precision:typeof(t==null?void 0:t.precision)=="undefined"?null:t==null?void 0:t.precision},p.errToObj(t==null?void 0:t.message)))}duration(t){return this._addCheck(d({kind:"duration"},p.errToObj(t)))}regex(t,n){return this._addCheck(d({kind:"regex",regex:t},p.errToObj(n)))}includes(t,n){return this._addCheck(d({kind:"includes",value:t,position:n==null?void 0:n.position},p.errToObj(n==null?void 0:n.message)))}startsWith(t,n){return this._addCheck(d({kind:"startsWith",value:t},p.errToObj(n)))}endsWith(t,n){return this._addCheck(d({kind:"endsWith",value:t},p.errToObj(n)))}min(t,n){return this._addCheck(d({kind:"min",value:t},p.errToObj(n)))}max(t,n){return this._addCheck(d({kind:"max",value:t},p.errToObj(n)))}length(t,n){return this._addCheck(d({kind:"length",value:t},p.errToObj(n)))}nonempty(t){return this.min(1,p.errToObj(t))}trim(){return new fe(b(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new fe(b(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new fe(b(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}fe.create=e=>{var t;return new fe(d({checks:[],typeName:g.ZodString,coerce:(t=e==null?void 0:e.coerce)!=null?t:!1},w(e)))};function Do(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,a=n>r?n:r,i=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return i%s/Un(10,a)}class He extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==_.number){const i=this._getOrReturnCtx(t);return h(i,{code:u.invalid_type,expected:_.number,received:i.parsedType}),y}let r;const a=new U;for(const i of this._def.checks)i.kind==="int"?T.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),h(r,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Do(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),h(r,{code:u.not_finite,message:i.message}),a.dirty()):T.assertNever(i);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,p.toString(n))}gt(t,n){return this.setLimit("min",t,!1,p.toString(n))}lte(t,n){return this.setLimit("max",t,!0,p.toString(n))}lt(t,n){return this.setLimit("max",t,!1,p.toString(n))}setLimit(t,n,r,a){return new He(b(d({},this._def),{checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:p.toString(a)}]}))}_addCheck(t){return new He(b(d({},this._def),{checks:[...this._def.checks,t]}))}int(t){return this._addCheck({kind:"int",message:p.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:p.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:p.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&T.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}He.create=e=>new He(d({checks:[],typeName:g.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1},w(e)));class _t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(i){return this._getInvalidInput(t)}if(this._getType(t)!==_.bigint)return this._getInvalidInput(t);let r;const a=new U;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),h(r,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):T.assertNever(i);return{status:a.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return h(n,{code:u.invalid_type,expected:_.bigint,received:n.parsedType}),y}gte(t,n){return this.setLimit("min",t,!0,p.toString(n))}gt(t,n){return this.setLimit("min",t,!1,p.toString(n))}lte(t,n){return this.setLimit("max",t,!0,p.toString(n))}lt(t,n){return this.setLimit("max",t,!1,p.toString(n))}setLimit(t,n,r,a){return new _t(b(d({},this._def),{checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:p.toString(a)}]}))}_addCheck(t){return new _t(b(d({},this._def),{checks:[...this._def.checks,t]}))}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:p.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}_t.create=e=>{var t;return new _t(d({checks:[],typeName:g.ZodBigInt,coerce:(t=e==null?void 0:e.coerce)!=null?t:!1},w(e)))};class wn extends k{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==_.boolean){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.boolean,received:r.parsedType}),y}return Y(t.data)}}wn.create=e=>new wn(d({typeName:g.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1},w(e)));class Zt extends k{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==_.date){const i=this._getOrReturnCtx(t);return h(i,{code:u.invalid_type,expected:_.date,received:i.parsedType}),y}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return h(i,{code:u.invalid_date}),y}const r=new U;let a;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):T.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Zt(b(d({},this._def),{checks:[...this._def.checks,t]}))}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:p.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:p.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Zt.create=e=>new Zt(d({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:g.ZodDate},w(e)));class ur extends k{_parse(t){if(this._getType(t)!==_.symbol){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.symbol,received:r.parsedType}),y}return Y(t.data)}}ur.create=e=>new ur(d({typeName:g.ZodSymbol},w(e)));class fr extends k{_parse(t){if(this._getType(t)!==_.undefined){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.undefined,received:r.parsedType}),y}return Y(t.data)}}fr.create=e=>new fr(d({typeName:g.ZodUndefined},w(e)));class hr extends k{_parse(t){if(this._getType(t)!==_.null){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.null,received:r.parsedType}),y}return Y(t.data)}}hr.create=e=>new hr(d({typeName:g.ZodNull},w(e)));class _r extends k{constructor(){super(...arguments),this._any=!0}_parse(t){return Y(t.data)}}_r.create=e=>new _r(d({typeName:g.ZodAny},w(e)));class xn extends k{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Y(t.data)}}xn.create=e=>new xn(d({typeName:g.ZodUnknown},w(e)));class Ae extends k{_parse(t){const n=this._getOrReturnCtx(t);return h(n,{code:u.invalid_type,expected:_.never,received:n.parsedType}),y}}Ae.create=e=>new Ae(d({typeName:g.ZodNever},w(e)));class pr extends k{_parse(t){if(this._getType(t)!==_.undefined){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.void,received:r.parsedType}),y}return Y(t.data)}}pr.create=e=>new pr(d({typeName:g.ZodVoid},w(e)));class oe extends k{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),a=this._def;if(n.parsedType!==_.array)return h(n,{code:u.invalid_type,expected:_.array,received:n.parsedType}),y;if(a.exactLength!==null){const s=n.data.length>a.exactLength.value,o=n.data.length<a.exactLength.value;(s||o)&&(h(n,{code:s?u.too_big:u.too_small,minimum:o?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(h(n,{code:u.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(h(n,{code:u.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,o)=>a.type._parseAsync(new le(n,s,n.path,o)))).then(s=>U.mergeArray(r,s));const i=[...n.data].map((s,o)=>a.type._parseSync(new le(n,s,n.path,o)));return U.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new oe(b(d({},this._def),{minLength:{value:t,message:p.toString(n)}}))}max(t,n){return new oe(b(d({},this._def),{maxLength:{value:t,message:p.toString(n)}}))}length(t,n){return new oe(b(d({},this._def),{exactLength:{value:t,message:p.toString(n)}}))}nonempty(t){return this.min(1,t)}}oe.create=(e,t)=>new oe(d({type:e,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray},w(t)));function De(e){if(e instanceof z){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ee.create(De(r))}return new z(b(d({},e._def),{shape:()=>t}))}else return e instanceof oe?new oe(b(d({},e._def),{type:De(e.element)})):e instanceof Ee?Ee.create(De(e.unwrap())):e instanceof Ke?Ke.create(De(e.unwrap())):e instanceof Fe?Fe.create(e.items.map(t=>De(t))):e}class z extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=T.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==_.object){const c=this._getOrReturnCtx(t);return h(c,{code:u.invalid_type,expected:_.object,received:c.parsedType}),y}const{status:r,ctx:a}=this._processInputParams(t),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ae&&this._def.unknownKeys==="strip"))for(const c in a.data)s.includes(c)||o.push(c);const l=[];for(const c of s){const f=i[c],m=a.data[c];l.push({key:{status:"valid",value:c},value:f._parse(new le(a,m,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Ae){const c=this._def.unknownKeys;if(c==="passthrough")for(const f of o)l.push({key:{status:"valid",value:f},value:{status:"valid",value:a.data[f]}});else if(c==="strict")o.length>0&&(h(a,{code:u.unrecognized_keys,keys:o}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const f of o){const m=a.data[f];l.push({key:{status:"valid",value:f},value:c._parse(new le(a,m,a.path,f)),alwaysSet:f in a.data})}}return a.common.async?Promise.resolve().then(()=>N(this,null,function*(){const c=[];for(const f of l){const m=yield f.key,v=yield f.value;c.push({key:m,value:v,alwaysSet:f.alwaysSet})}return c})).then(c=>U.mergeObjectSync(r,c)):U.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return p.errToObj,new z(d(b(d({},this._def),{unknownKeys:"strict"}),t!==void 0?{errorMap:(n,r)=>{var i,s,o,l;const a=(o=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(l=p.errToObj(t).message)!=null?l:a}:{message:a}}}:{}))}strip(){return new z(b(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new z(b(d({},this._def),{unknownKeys:"passthrough"}))}extend(t){return new z(b(d({},this._def),{shape:()=>d(d({},this._def.shape()),t)}))}merge(t){return new z({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>d(d({},this._def.shape()),t._def.shape()),typeName:g.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new z(b(d({},this._def),{catchall:t}))}pick(t){const n={};for(const r of T.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new z(b(d({},this._def),{shape:()=>n}))}omit(t){const n={};for(const r of T.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new z(b(d({},this._def),{shape:()=>n}))}deepPartial(){return De(this)}partial(t){const n={};for(const r of T.objectKeys(this.shape)){const a=this.shape[r];t&&!t[r]?n[r]=a:n[r]=a.optional()}return new z(b(d({},this._def),{shape:()=>n}))}required(t){const n={};for(const r of T.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ee;)i=i._def.innerType;n[r]=i}return new z(b(d({},this._def),{shape:()=>n}))}keyof(){return ga(T.objectKeys(this.shape))}}z.create=(e,t)=>new z(d({shape:()=>e,unknownKeys:"strip",catchall:Ae.create(),typeName:g.ZodObject},w(t)));z.strictCreate=(e,t)=>new z(d({shape:()=>e,unknownKeys:"strict",catchall:Ae.create(),typeName:g.ZodObject},w(t)));z.lazycreate=(e,t)=>new z(d({shape:e,unknownKeys:"strip",catchall:Ae.create(),typeName:g.ZodObject},w(t)));class Ft extends k{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function a(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const s=i.map(o=>new _e(o.ctx.common.issues));return h(n,{code:u.invalid_union,unionErrors:s}),y}if(n.common.async)return Promise.all(r.map(i=>N(this,null,function*(){const s=b(d({},n),{common:b(d({},n.common),{issues:[]}),parent:null});return{result:yield i._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}}))).then(a);{let i;const s=[];for(const l of r){const c=b(d({},n),{common:b(d({},n.common),{issues:[]}),parent:null}),f=l._parseSync({data:n.data,path:n.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new _e(l));return h(n,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}Ft.create=(e,t)=>new Ft(d({options:e,typeName:g.ZodUnion},w(t)));function kn(e,t){const n=be(e),r=be(t);if(e===t)return{valid:!0,data:e};if(n===_.object&&r===_.object){const a=T.objectKeys(t),i=T.objectKeys(e).filter(o=>a.indexOf(o)!==-1),s=d(d({},e),t);for(const o of i){const l=kn(e[o],t[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(n===_.array&&r===_.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const s=e[i],o=t[i],l=kn(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===_.date&&r===_.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class jt extends k{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),a=(i,s)=>{if(lr(i)||lr(s))return y;const o=kn(i.value,s.value);return o.valid?((cr(i)||cr(s))&&n.dirty(),{status:n.value,value:o.data}):(h(r,{code:u.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,s])=>a(i,s)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}jt.create=(e,t,n)=>new jt(d({left:e,right:t,typeName:g.ZodIntersection},w(n)));class Fe extends k{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==_.array)return h(r,{code:u.invalid_type,expected:_.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return h(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((s,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new le(r,s,r.path,o)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>U.mergeArray(n,s)):U.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new Fe(b(d({},this._def),{rest:t}))}}Fe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fe(d({items:e,typeName:g.ZodTuple,rest:null},w(t)))};class Lt extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==_.object)return h(r,{code:u.invalid_type,expected:_.object,received:r.parsedType}),y;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in r.data)a.push({key:i._parse(new le(r,o,r.path,o)),value:s._parse(new le(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?U.mergeObjectAsync(n,a):U.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof k?new Lt(d({keyType:t,valueType:n,typeName:g.ZodRecord},w(r))):new Lt(d({keyType:fe.create(),valueType:t,typeName:g.ZodRecord},w(n)))}}class mr extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==_.map)return h(r,{code:u.invalid_type,expected:_.map,received:r.parsedType}),y;const a=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([o,l],c)=>({key:a._parse(new le(r,o,r.path,[c,"key"])),value:i._parse(new le(r,l,r.path,[c,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(()=>N(this,null,function*(){for(const l of s){const c=yield l.key,f=yield l.value;if(c.status==="aborted"||f.status==="aborted")return y;(c.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(c.value,f.value)}return{status:n.value,value:o}}))}else{const o=new Map;for(const l of s){const c=l.key,f=l.value;if(c.status==="aborted"||f.status==="aborted")return y;(c.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(c.value,f.value)}return{status:n.value,value:o}}}}mr.create=(e,t,n)=>new mr(d({valueType:t,keyType:e,typeName:g.ZodMap},w(n)));class pt extends k{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==_.set)return h(r,{code:u.invalid_type,expected:_.set,received:r.parsedType}),y;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(h(r,{code:u.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(h(r,{code:u.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const i=this._def.valueType;function s(l){const c=new Set;for(const f of l){if(f.status==="aborted")return y;f.status==="dirty"&&n.dirty(),c.add(f.value)}return{status:n.value,value:c}}const o=[...r.data.values()].map((l,c)=>i._parse(new le(r,l,r.path,c)));return r.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(t,n){return new pt(b(d({},this._def),{minSize:{value:t,message:p.toString(n)}}))}max(t,n){return new pt(b(d({},this._def),{maxSize:{value:t,message:p.toString(n)}}))}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}pt.create=(e,t)=>new pt(d({valueType:e,minSize:null,maxSize:null,typeName:g.ZodSet},w(t)));class gr extends k{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}gr.create=(e,t)=>new gr(d({getter:e,typeName:g.ZodLazy},w(t)));class Sn extends k{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return h(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:t.data}}get value(){return this._def.value}}Sn.create=(e,t)=>new Sn(d({value:e,typeName:g.ZodLiteral},w(t)));function ga(e,t){return new We(d({values:e,typeName:g.ZodEnum},w(t)))}class We extends k{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return h(n,{expected:T.joinValues(r),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return h(n,{received:n.data,code:u.invalid_enum_value,options:r}),y}return Y(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return We.create(t,d(d({},this._def),n))}exclude(t,n=this._def){return We.create(this.options.filter(r=>!t.includes(r)),d(d({},this._def),n))}}We.create=ga;class yr extends k{_parse(t){const n=T.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==_.string&&r.parsedType!==_.number){const a=T.objectValues(n);return h(r,{expected:T.joinValues(a),received:r.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=T.objectValues(n);return h(r,{received:r.data,code:u.invalid_enum_value,options:a}),y}return Y(t.data)}get enum(){return this._def.values}}yr.create=(e,t)=>new yr(d({values:e,typeName:g.ZodNativeEnum},w(t)));class $t extends k{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==_.promise&&n.common.async===!1)return h(n,{code:u.invalid_type,expected:_.promise,received:n.parsedType}),y;const r=n.parsedType===_.promise?n.data:Promise.resolve(n.data);return Y(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}$t.create=(e,t)=>new $t(d({type:e,typeName:g.ZodPromise},w(t)));class qe extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),a=this._def.effect||null,i={addIssue:s=>{h(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const s=a.transform(r.data,i);if(r.common.async)return Promise.resolve(s).then(o=>N(this,null,function*(){if(n.value==="aborted")return y;const l=yield this._def.schema._parseAsync({data:o,path:r.path,parent:r});return l.status==="aborted"?y:l.status==="dirty"||n.value==="dirty"?it(l.value):l}));{if(n.value==="aborted")return y;const o=this._def.schema._parseSync({data:s,path:r.path,parent:r});return o.status==="aborted"?y:o.status==="dirty"||n.value==="dirty"?it(o.value):o}}if(a.type==="refinement"){const s=o=>{const l=a.refinement(o,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),s(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),s(o.value).then(()=>({status:n.value,value:o.value}))))}if(a.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Be(s))return y;const o=a.transform(s.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>Be(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:n.value,value:o})):y);T.assertNever(a)}}qe.create=(e,t,n)=>new qe(d({schema:e,typeName:g.ZodEffects,effect:t},w(n)));qe.createWithPreprocess=(e,t,n)=>new qe(d({schema:t,effect:{type:"preprocess",transform:e},typeName:g.ZodEffects},w(n)));class Ee extends k{_parse(t){return this._getType(t)===_.undefined?Y(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ee.create=(e,t)=>new Ee(d({innerType:e,typeName:g.ZodOptional},w(t)));class Ke extends k{_parse(t){return this._getType(t)===_.null?Y(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ke.create=(e,t)=>new Ke(d({innerType:e,typeName:g.ZodNullable},w(t)));class Tn extends k{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===_.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Tn.create=(e,t)=>new Tn(d({innerType:e,typeName:g.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default},w(t)));class En extends k{_parse(t){const{ctx:n}=this._processInputParams(t),r=b(d({},n),{common:b(d({},n.common),{issues:[]})}),a=this._def.innerType._parse({data:r.data,path:r.path,parent:d({},r)});return zt(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new _e(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new _e(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}En.create=(e,t)=>new En(d({innerType:e,typeName:g.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch},w(t)));class vr extends k{_parse(t){if(this._getType(t)!==_.nan){const r=this._getOrReturnCtx(t);return h(r,{code:u.invalid_type,expected:_.nan,received:r.parsedType}),y}return{status:"valid",value:t.data}}}vr.create=e=>new vr(d({typeName:g.ZodNaN},w(e)));class Mo extends k{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class $n extends k{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return N(this,null,function*(){const i=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?y:i.status==="dirty"?(n.dirty(),it(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})});{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(t,n){return new $n({in:t,out:n,typeName:g.ZodPipeline})}}class An extends k{_parse(t){const n=this._def.innerType._parse(t),r=a=>(Be(a)&&(a.value=Object.freeze(a.value)),a);return zt(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}}An.create=(e,t)=>new An(d({innerType:e,typeName:g.ZodReadonly},w(t)));var g;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(g||(g={}));const kt=fe.create,Po=He.create,Q=wn.create,Uo=xn.create;Ae.create;const br=oe.create,St=z.create,Vo=Ft.create;jt.create;Fe.create;const Bo=Lt.create,wr=Sn.create,Tt=We.create;$t.create;Ee.create;Ke.create;const Ho=St({language:Tt(["typescript","javascript"]).optional(),disableMarkedForExport:Q().optional(),allowAutoSelectFirstNode:Q().optional().default(!0),enableDisplayDataId:Q().optional(),enableDisplayDataName:Q().optional()}).and(Vo([St({framework:wr("react"),model:kt().optional(),styling:Tt(["plain_css","css_modules","styled_components","tailwind","sass","scss","inline_styles"]),uiLibrary:Tt(["mui","antd","radix","shadcn","clean_react"]).optional(),responsivePages:br(St({name:kt(),framesId:br(kt())})).optional(),enableUILibraryTheming:Q().optional(),enableCompactStructure:Q().optional(),enableDisplayScreenModelId:Q().optional(),enableGeneratePackageLock:Q().optional(),enableAnimationsPreset:Q().optional(),enableAutoSplit:Q().optional(),autoSplitThreshold:Po().optional(),url:kt().url().optional(),codegenSettings:Bo(Uo()).optional()}),St({framework:wr("html"),styling:Tt(["plain_css","inline_styles","tailwind"]),enableTranslation:Q().optional()})])),ya=e=>{const t=Ho.safeParse(e);if(t.success===!1){const n=new Error("Invalid codegen settings");throw n.cause=t.error,n}return t.data},xr=new Set(["FRAME","INSTANCE","COMPONENT","COMPONENT_SET","GROUP"]),va=(e,t,n={allowAutoSelectFirstNode:!0})=>{const r=Ln(e.document,t);if(!r)return{isValid:!1,reason:"There is no node with the given id"};if(r.type==="CANVAS"){const a=r.children.filter(i=>xr.has(i.type));return a.length===0?{isValid:!1,reason:"Selected node is a page with no valid children"}:a.length===1?{isValid:!0,node:a[0],note:"Selected node is a page with a single valid children - returning it instead"}:n.allowAutoSelectFirstNode?{isValid:!0,node:a[0],note:"Selected node is a page with multiple valid children - returning the first one instead"}:{isValid:!1,reason:"Selected node is a page with multiple children"}}return xr.has(r.type)?{isValid:!0,node:r}:{isValid:!1,reason:"Selected node type is not supported"}};var C,mt,he,ba,st;class Wo{constructor({auth:t,apiBaseAddress:n="https://public-api.animaapp.com"}={}){wt(this,he);wt(this,C);wt(this,mt);Bt(this,mt,n),t&&(this.auth=t)}hasAuth(){return!!O(this,C)}set auth(t){Bt(this,C,t)}get headers(){const t={"Content-Type":"application/json"};return O(this,C)&&(t.Authorization=`Bearer ${O(this,C).token}`,"teamId"in O(this,C)&&(t["X-Team-Id"]=O(this,C).teamId)),t}generateCode(a){return N(this,arguments,function*(t,n={},r){var c;let i;try{i=yield _a({fileKey:t.fileKey,authToken:t.figmaToken,params:{geometry:"paths"},signal:r})}catch(f){if(f instanceof Error&&f.name==="AbortError")throw f}const s=ya(t.settings);i&&(yield Le(this,he,ba).call(this,i,t.nodesId,{allowAutoSelectFirstNode:(c=s.allowAutoSelectFirstNode)!=null?c:!0}));let o=t.tracking;O(this,C)&&"userId"in O(this,C)&&O(this,C).userId&&(o!=null&&o.externalId||(o={externalId:O(this,C).userId}));const l={tracking:o,fileKey:t.fileKey,figmaToken:t.figmaToken,nodesId:t.nodesId,design:i,assetsStorage:t.assetsStorage,language:s.language,model:s.model,framework:s.framework,styling:s.styling,uiLibrary:s.uiLibrary,enableTranslation:s.enableTranslation,enableUILibraryTheming:s.enableUILibraryTheming,enableCompactStructure:s.enableCompactStructure,enableAutoSplit:s.enableAutoSplit,autoSplitThreshold:s.autoSplitThreshold,disableMarkedForExport:s.disableMarkedForExport,allowAutoSelectFirstNode:s.allowAutoSelectFirstNode,enableDisplayScreenModelId:s.enableDisplayScreenModelId,enableGeneratePackageLock:s.enableGeneratePackageLock,enableAnimationsPreset:s.enableAnimationsPreset,enableDisplayDataId:s.enableDisplayDataId,enableDisplayDataName:s.enableDisplayDataName,codegenSettings:s.codegenSettings,webhookUrl:t.webhookUrl,prompt:t.prompt,images:t.images};return Le(this,he,st).call(this,"/v1/codegen",l,n,"codegen",r)})}generateCodeFromWebsite(a){return N(this,arguments,function*(t,n={},r){let i=t.tracking;O(this,C)&&"userId"in O(this,C)&&O(this,C).userId&&(i!=null&&i.externalId||(i={externalId:O(this,C).userId}));let s;if(t.mhtml)s={type:"mhtml",mhtml:t.mhtml,url:t.url};else if(t.url)s={type:"url",url:t.url};else throw new Error("Either 'url' or 'mhtml' must be provided");let o;t.experimental_useNewReactEngine&&(o="react-v2");const l={tracking:i,assetsStorage:t.assetsStorage,prompt:t.prompt,images:t.images,params:{input:s,conventions:{framework:t.settings.framework,language:t.settings.language,styling:t.settings.styling},assetsStorage:{type:"bundled"},engine:o}};return Le(this,he,st).call(this,"/v1/l2c",l,n,"l2c",r)})}generateCodeFromPrompt(a){return N(this,arguments,function*(t,n={},r){var o;let i=t.tracking;O(this,C)&&"userId"in O(this,C)&&O(this,C).userId&&(i!=null&&i.externalId||(i={externalId:O(this,C).userId}));const s={tracking:i,assetsStorage:t.assetsStorage,params:d({prompt:t.prompt,images:t.images,conventions:{language:t.settings.language,framework:t.settings.framework,styling:t.settings.styling,uiLibrary:t.settings.uiLibrary}},(o=t.settings.codegenSettings)!=null?o:{}),webhookUrl:t.webhookUrl};return Le(this,he,st).call(this,"/v1/p2c",s,n,"p2c",r)})}generateLink2Code(a){return N(this,arguments,function*(t,n={},r){let i=t.tracking;O(this,C)&&"userId"in O(this,C)&&O(this,C).userId&&(i!=null&&i.externalId||(i={externalId:O(this,C).userId}));const s={tracking:i,assetsStorage:t.assetsStorage,params:t.params};return Le(this,he,st).call(this,"/v1/l2c",s,n,"l2c",r)})}}C=new WeakMap,mt=new WeakMap,he=new WeakSet,ba=function(t,n,r){return N(this,null,function*(){const i=n.map(s=>va(t,s,r)).find(s=>!s.isValid);if(i)throw new ye({name:"Task Crashed",reason:i.reason})})},st=function(t,n,r,a,i){return N(this,null,function*(){var v,F,I,L,ce,Ce,pe,H,me,vt,bt;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const s={},o=ms(JSON.stringify(n)),l=yield fetch(`${O(this,mt)}${t}`,{method:"POST",headers:b(d({},this.headers),{Accept:"text/event-stream","Content-Encoding":"gzip","Content-Type":"application/json"}),body:o,signal:i});if(!l.ok){const R=yield l.text();let W;try{W=JSON.parse(R)}catch(je){}throw((v=W==null?void 0:W.error)==null?void 0:v.name)==="ZodError"?(console.log("Zod validation error:",JSON.stringify(W.error.issues,null,2)),new ye({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:W.error.issues,status:l.status})):typeof W=="object"?new ye({name:`Error "${W}"`,reason:"Unknown",status:l.status}):new ye({name:"HTTP error from Anima API",reason:R,status:l.status})}if(!l.body)throw new ye({name:"Stream Error",reason:"Response body is null",status:l.status});const c=l.body.getReader(),f=new TextDecoder;let m="";try{for(;;){const{done:R,value:W}=yield c.read();if(R)break;m+=f.decode(W,{stream:!0});const je=m.split(`
2
+ `);m=je.pop()||"";for(const j of je)if(!(!j.trim()||j.startsWith(":"))&&j.startsWith("data: ")){let S;try{S=JSON.parse(j.slice(6))}catch(al){continue}switch(S.type){case"queueing":{typeof r=="function"?r(S):(F=r.onQueueing)==null||F.call(r,{sessionId:S.sessionId});break}case"start":{s.sessionId=S.sessionId,typeof r=="function"?r(S):(I=r.onStart)==null||I.call(r,{sessionId:S.sessionId});break}case"pre_codegen":{a==="codegen"&&(typeof r=="function"?r(S):(L=r.onPreCodegen)==null||L.call(r,{message:S.message}));break}case"assets_uploaded":{typeof r=="function"?r(S):(ce=r.onAssetsUploaded)==null||ce.call(r);break}case"assets_list":{s.assets=S.payload.assets,typeof r=="function"?r(S):(Ce=r.onAssetsList)==null||Ce.call(r,S.payload);break}case"figma_metadata":{a==="codegen"&&(s.figmaFileName=S.figmaFileName,s.figmaSelectedFrameName=S.figmaSelectedFrameName,typeof r=="function"?r(S):(pe=r.onFigmaMetadata)==null||pe.call(r,{figmaFileName:S.figmaFileName,figmaSelectedFrameName:S.figmaSelectedFrameName}));break}case"generating_code":{S.payload.status==="success"&&(s.files=S.payload.files),typeof r=="function"?r(S):(H=r.onGeneratingCode)==null||H.call(r,{status:S.payload.status,progress:S.payload.progress,files:S.payload.files});break}case"progress_messages_updated":{typeof r=="function"?r(S):(me=r.onProgressMessagesUpdated)==null||me.call(r,S.payload.progressMessages);break}case"job_status_updated":{typeof r=="function"?r(S):(vt=r.onJobStatusUpdated)==null||vt.call(r,S.payload.jobStatus);break}case"codegen_completed":case"generation_completed":{typeof r=="function"?r(S):(bt=r.onCodegenCompleted)==null||bt.call(r);break}case"error":throw new ye({name:S.payload.errorName,reason:S.payload.reason});case"done":return s.tokenUsage=S.payload.tokenUsage,s.sessionId=S.payload.sessionId,s}}}}finally{c.cancel()}throw new ye({name:"Connection",reason:"Connection closed before the 'done' message",status:500})})};const qo=e=>{var t;if(!e)return[!1,"",""];try{const n=new URL(e),r=n.pathname;if(n.origin!=="https://www.figma.com"&&n.origin!=="https://embed.figma.com")return[!1,"",""];const a=n.toString();if(e!==a)return[!1,"",""];const i=((t=n.searchParams.get("node-id"))!=null?t:"").replace(/-/g,":"),s=r.split("/")[2];return[(r.startsWith("/file/")&&n.searchParams.get("type")!=="whiteboard"||r.startsWith("/design/")||r.startsWith("/proto/"))&&s.length===22,s,i]}catch(n){return[!1,"",""]}},Ko=({fileKey:e,nodeId:t,duplicate:n})=>{const r=new URL("https://www.figma.com");return r.pathname=`design/${e}`,n&&(r.pathname=`${r.pathname}/dummy/duplicate`),t&&r.searchParams.set("node-id",t.replace(":","-")),r};class Jo extends Error{constructor(t,n){super(t),this.response=n}}const Go=({files:e,screenPath:t="src/screens"})=>{const n={},r=new Set;function a(i){if(r.has(i)||!e[i])return;r.add(i),n[i]=e[i],Xo(e[i].content).forEach(o=>{try{const l=Yo(i,o);if(l.startsWith("src/")){const c=l.split("/").slice(0,-1).join("/");Qo(e,c).forEach(m=>{r.has(m)||a(m)})}}catch(l){console.warn(`Failed to resolve import ${o} in ${i}:`,l)}})}return Object.entries(e).forEach(([i,s])=>{i.startsWith(t)?a(i):i.startsWith("src/")||(n[i]=s)}),n};function Xo(e){const t=/import.*?["']([^"']+)["']/g,n=/export.*from\s+["']([^"']+)["']/g,r=[];let a;for(;(a=t.exec(e))!==null;)r.push(a[1]);for(;(a=n.exec(e))!==null;)r.push(a[1]);return[...new Set(r)]}function Yo(e,t){if(!t.startsWith("."))return t;const n=e.split("/").slice(0,-1),r=t.split("/"),a=[...n];for(const i of r)i===".."?a.pop():i!=="."&&a.push(i);return a.join("/")}function Qo(e,t){return Object.keys(e).filter(n=>n.startsWith(t))}function Pt(e,t,n){return new ReadableStream({start(r){n.call(e,t,a=>{a.type==="error"||r.enqueue(a),(a.type==="aborted"||a.type==="error")&&r.close()}).then(a=>{r.enqueue({type:"done",payload:{tokenUsage:a.tokenUsage,sessionId:a.sessionId}}),r.close()}).catch(a=>{r.enqueue({type:"error",payload:{name:"name"in a?a.name:"Unknown error",message:"message"in a?a.message:"Unknown",status:"status"in a?a.status:void 0,detail:"detail"in a?a.detail:void 0,errorPayload:"payload"in a?a.payload:void 0}}),r.close()})}})}const wa=(e,t)=>Pt(e,t,e.generateCode);function Ut(e){return N(this,null,function*(){var s,o,l,c;const[t,n]=e.tee(),r=yield t.getReader().read();if(r.done||!r.value||r.value.type==="error"&&((s=r.value.payload)!=null&&s.status))return new Response(JSON.stringify(r.value),{status:((o=r.value)==null?void 0:o.type)==="error"&&(c=(l=r.value.payload)==null?void 0:l.status)!=null?c:500,headers:{"Content-Type":"application/json"}});const a=new TextEncoder,i=n.pipeThrough(new TransformStream({transform(f,m){const v=`event: ${f.type}
3
+ data: ${JSON.stringify(f)}
4
4
 
5
- `;w.enqueue(n.encode(P))}}));return new Response(a,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})})}const mn=(s,e)=>E(null,null,function*(){const t=ks(s,e);return ze(t)}),xs=(s,e)=>Be(s,e,s.generateCodeFromWebsite),pn=(s,e)=>E(null,null,function*(){const t=xs(s,e);return ze(t)}),Ss=(s,e)=>Be(s,e,s.generateCodeFromPrompt),gn=(s,e)=>E(null,null,function*(){const t=Ss(s,e);return ze(t)}),Ts=(s,e)=>Be(s,e,s.generateLink2Code),yn=(s,e)=>E(null,null,function*(){const t=Ts(s,e);return ze(t)});exports.Anima=an;exports.CodegenError=se;exports.FigmaTokenIssue=Kt;exports.NotFound=rs;exports.RateLimitExceeded=Yt;exports.RequestTooLarge=ts;exports.ResponseError=un;exports.UnknownFigmaApiException=is;exports.createCodeFromPromptResponseEventStream=gn;exports.createCodeFromPromptStream=Ss;exports.createCodeFromWebsiteResponseEventStream=pn;exports.createCodeFromWebsiteStream=xs;exports.createCodegenResponseEventStream=mn;exports.createCodegenStream=ks;exports.createLink2CodeResponseEventStream=yn;exports.createLink2CodeStream=Ts;exports.findChildrenNode=bt;exports.formatToFigmaLink=cn;exports.getFigmaApiErrorType=Rs;exports.getFigmaFile=ps;exports.getFileNodes=Cr;exports.getRelatedScreenFiles=dn;exports.isFigmaTokenIssue=cs;exports.isNodeCodegenCompatible=bs;exports.isNotFound=ns;exports.isRateLimitExceeded=os;exports.isRequestTooLarge=us;exports.isUnknownFigmaApiException=Is;exports.isValidFigmaUrl=on;exports.validateSettings=_s;exports.wrapFigmaApiError=gt;
5
+ `;m.enqueue(a.encode(v))}}));return new Response(i,{status:200,headers:{"Content-Type":"text/event-stream; charset=utf-8",Connection:"keep-alive","Cache-Control":"no-cache"}})})}const el=(e,t)=>N(null,null,function*(){const n=wa(e,t);return Ut(n)}),xa=(e,t)=>Pt(e,t,e.generateCodeFromWebsite),tl=(e,t)=>N(null,null,function*(){const n=xa(e,t);return Ut(n)}),ka=(e,t)=>Pt(e,t,e.generateCodeFromPrompt),nl=(e,t)=>N(null,null,function*(){const n=ka(e,t);return Ut(n)}),Sa=(e,t)=>Pt(e,t,e.generateLink2Code),rl=(e,t)=>N(null,null,function*(){const n=Sa(e,t);return Ut(n)});exports.Anima=Wo;exports.CodegenError=ye;exports.FigmaTokenIssue=Gr;exports.NotFound=na;exports.RateLimitExceeded=Yr;exports.RequestTooLarge=ea;exports.ResponseError=Jo;exports.UnknownFigmaApiException=ia;exports.createCodeFromPromptResponseEventStream=nl;exports.createCodeFromPromptStream=ka;exports.createCodeFromWebsiteResponseEventStream=tl;exports.createCodeFromWebsiteStream=xa;exports.createCodegenResponseEventStream=el;exports.createCodegenStream=wa;exports.createLink2CodeResponseEventStream=rl;exports.createLink2CodeStream=Sa;exports.findChildrenNode=Ln;exports.formatToFigmaLink=Ko;exports.getFigmaApiErrorType=ys;exports.getFigmaFile=_a;exports.getFileNodes=_o;exports.getRelatedScreenFiles=Go;exports.isFigmaTokenIssue=oa;exports.isNodeCodegenCompatible=va;exports.isNotFound=ra;exports.isRateLimitExceeded=sa;exports.isRequestTooLarge=la;exports.isUnknownFigmaApiException=gs;exports.isValidFigmaUrl=qo;exports.validateSettings=ya;exports.wrapFigmaApiError=zn;
6
6
  //# sourceMappingURL=index.cjs.map