@animaapp/anima-sdk 0.5.0 → 0.6.0

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