@animaapp/anima-sdk 0.4.3 → 0.4.4

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,d=(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 lt=(r,e,t)=>e.has(r)||Vt("Cannot "+t);var P=(r,e,t)=>(lt(r,e,"read from private field"),t?t.call(r):e.get(r)),Xe=(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),ft=(r,e,t,s)=>(lt(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t),Ye=(r,e,t)=>(lt(r,e,"access private method"),t);var C=(r,e,t)=>new Promise((s,n)=>{var a=c=>{try{o(t.next(c))}catch(u){n(u)}},i=c=>{try{o(t.throw(c))}catch(u){n(u)}},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 se 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,It=(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},jt=(r,e)=>Wr(r,Br(e)),Rt=(r,e,t)=>e.has(r)||hr("Cannot "+t),T=(r,e,t)=>(Rt(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),I=(r,e,t,s)=>(Rt(r,e,"write to private field"),e.set(r,t),t),X=(r,e,t)=>(Rt(r,e,"access private method"),t),A=(r,e,t)=>new Promise((s,n)=>{var a=c=>{try{o(t.next(c))}catch(u){n(u)}},i=c=>{try{o(t.throw(c))}catch(u){n(u)}},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(u=>i({value:u,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 yt={exports:{}},Xr=yt.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",u=typeof DataView!="undefined",f=n&&typeof Symbol.iterator!="undefined",v=n&&typeof Symbol.toStringTag!="undefined",O=i&&typeof Set.prototype.entries=="function",R=a&&typeof Map.prototype.entries=="function",L=O&&Object.getPrototypeOf(new Set().entries()),W=R&&Object.getPrototypeOf(new Map().entries()),te=f&&typeof Array.prototype[Symbol.iterator]=="function",he=te&&Object.getPrototypeOf([][Symbol.iterator]()),oe=f&&typeof String.prototype[Symbol.iterator]=="function",Z=oe&&Object.getPrototypeOf(""[Symbol.iterator]()),M=8,Oe=-1;function we(b){var ut=typeof b;if(ut!=="object")return ut;if(b===null)return"null";if(b===s)return"global";if(Array.isArray(b)&&(v===!1||!(Symbol.toStringTag in b)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&b===window.location)return"Location";if(typeof window.document=="object"&&b===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&b===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&b===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&b instanceof window.HTMLElement){if(b.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(b.tagName==="TD")return"HTMLTableDataCellElement";if(b.tagName==="TH")return"HTMLTableHeaderCellElement"}}var $t=v&&b[Symbol.toStringTag];if(typeof $t=="string")return $t;var D=Object.getPrototypeOf(b);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":u&&D===DataView.prototype?"DataView":a&&D===W?"Map Iterator":i&&D===L?"Set Iterator":te&&D===he?"Array Iterator":oe&&D===Z?"String Iterator":D===null?"Object":Object.prototype.toString.call(b).slice(M,Oe)}return we})}(yt)),yt.exports}var Qr=Yr();const es=Kr(Qr),Zt=typeof Buffer!="undefined",ts=Zt&&typeof Buffer.from!="undefined",rs=Zt?function(r){return Buffer.isBuffer(r)}:function(){return!1},ss=ts?function(r){return Buffer.from(r)}:Zt?function(r){return new Buffer(r)}:function(r){return r};function Se(r){return rs(r)?"Buffer":es(r)}const ns=new Set(["Arguments","Array","Map","Object","Set"]);function as(r,e,t=null){switch(t||Se(r)){case"Arguments":case"Array":case"Object":return r[e];case"Map":return r.get(e);case"Set":return e}}function vt(r){return ns.has(r)}function Bt(r,e,t,s=null){switch(s||Se(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,ht=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 re(r,e){return ht[e].from?ht[e].from(r):new ht[e](r)}function $(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",re],["Float64Array",re],["Int16Array",re],["Int32Array",re],["Int8Array",re],["Uint16Array",re],["Uint32Array",re],["Uint8Array",re],["Uint8ClampedArray",re],["Array Iterator",$],["Map Iterator",$],["Promise",$],["Set Iterator",$],["String Iterator",$],["function",$],["global",$],["WeakMap",$],["WeakSet",$],["boolean",$],["null",$],["number",$],["string",$],["symbol",$],["undefined",$],["Arguments",qt],["Array",qt],["Map",ys],["Object",vs],["Set",_s]]);function ws(){}function _t(r,e=null,t=ws){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Se(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 Ne(r,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Se(r);if(!vt(s))return bt(r,null,null,null);const n=_t(r,s,t),a=new WeakMap([[r,n]]),i=new WeakSet([r]);return bt(r,n,a,i)}function bt(r,e,t,s,n){const a=Se(r),i=_t(r,a);if(!vt(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 u=as(r,c,a);if(s.has(u))Bt(e,c,t.get(u),a);else{const f=Se(u),v=_t(u,f);vt(f)&&(t.set(u,v),s.add(u)),Bt(e,c,bt(u,v,t,s),a)}}return e}const xs=r=>new Promise(e=>setTimeout(e,r));var Qe,pe,et,wt,pr;class ks{constructor({maxAttempts:e=3,func:t}){B(this,wt),B(this,Qe),B(this,pe),B(this,et),I(this,Qe,e),I(this,et,t),I(this,pe,0)}run(){return A(this,null,function*(){try{return yield T(this,et).call(this)}catch(e){if(I(this,pe,T(this,pe)+1),T(this,pe)>T(this,Qe))throw console.error("Max attempts reached"),e;const t=X(this,wt,pr).call(this);return yield xs(t),yield this.run()}})}}Qe=new WeakMap,pe=new WeakMap,et=new WeakMap,wt=new WeakSet,pr=function(){return T(this,pe)*1e3*1.5};function Ts(){return typeof CompressionStream!="undefined"}function Ss(r){return A(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 A(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((u,f)=>{c[f]=u}),this.causeProperties[i]=c}else this.causeProperties[i]=o;const a=this.causeProperties.body;a&&typeof a=="object"&&"code"in a&&(this.code=a.code)}}class 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 Ie 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 pt 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 me,V,G,kt,Tt,je;class Is{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){B(this,G),B(this,me),B(this,V),this.baseAddress=t,I(this,me,e),I(this,V,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(e){this.plugins.push(e)}removePlugin(e){this.plugins=this.plugins.filter(t=>t.name!==e)}withOptions(e={}){return I(this,V,e),this}get(e){return A(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=Ne(T(this,V));return I(this,V,{}),c.extraHeaders&&(o=U(U({},o),c.extraHeaders)),c.requestValidation&&(o=jt(U({},o),{"X-Request-Nonce":mr(),"X-Request-Timestamp":xt()})),c.async?yield X(this,G,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield X(this,G,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"POST",n,a,i)})}put(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"PUT",n,a,i)})}delete(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"DELETE",n,a,i)})}patch(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"PATCH",n,a,i)})}}me=new WeakMap,V=new WeakMap,G=new WeakSet,kt=function(r,e,t){return A(this,null,function*(){const s=()=>A(this,null,function*(){var c,u;try{return yield T(this,me).call(this,r,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ie({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:n}=t!=null?t:{},a=(c,u)=>{var f,v;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((v=c==null?void 0:c.headersObject)==null?void 0:v[u])||""},i=c=>A(this,null,function*(){var u;if(!c.ok){const v=yield c.text().catch();throw new Ht({url:r,method:(u=t==null?void 0:t.method)!=null?u:"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"),O=n==null?void 0:n["X-Request-Nonce"];if(!v||v!==O)throw new pt("Response nonce mismatch");const R=Number(a(c,"x-response-timestamp")),L=Number(xt()),W=60*60*24;if(isNaN(R)||Math.abs(L-R)>W)throw new pt("Invalid response timestamp")}catch(v){const O=v instanceof Error?v.message:"Request validation failed";throw new pt(O)}let f=yield c.text();try{f=JSON.parse(f)}catch(v){}return f});if(e.retry){const c=yield new ks({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},Tt=function(r,e,t){return A(this,null,function*(){var s,n;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Ns,maxTimeout:c=Os}=e,u=`${r}/async`,f=`${r}/async/job`;let v;try{v=yield T(this,me).call(this,u,U(U({},t),i&&{signal:i}))}catch(L){throw L instanceof Error&&L.name==="AbortError"?new Ie({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):L}if(!v.ok){const L=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:L})}const O=yield v.json(),{job_id:R}=O;if(!R)throw new Error("Job ID not found in response");return new Promise((L,W)=>A(this,null,function*(){const te=setTimeout(()=>{W(new Error("Job timed out"))},c),he=(oe=0)=>A(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(te),T(this,me).call(this,`${f}/${R}/cancel`,{method:"POST",headers:this.headers}).then(()=>{W(new Ie({canceled:!0}))}).catch(Z=>{W(new Ie({canceled:!1}))});return}try{const Z=yield(yield T(this,me).call(this,`${f}/${R}`,{headers:this.headers})).json();if(Z.status==="success"){clearTimeout(te);const M=Z.response_json;L(M)}else if(Z.status==="failed")clearTimeout(te),W(new Cs(Z.response_json));else{a&&a(Z.response_json);const M=o(oe);setTimeout(()=>he(oe+1),M)}}catch(Z){W(Z)}});he()}))})},je=function(r,e,t,s,n){return A(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=jt(U({},c),{"X-Request-Nonce":mr(),"X-Request-Timestamp":xt()}));let u=t;return typeof FormData!="undefined"&&t instanceof FormData?delete c["Content-Type"]:(u=s.skipBodyJsonStringify?t:JSON.stringify(t),n.compress&&Ts()&&(c["Content-Encoding"]="gzip",u=yield Ss(u))),n.async?yield X(this,G,Tt).call(this,`${o}${r}`,n.async,{method:e,headers:c,body:u}):yield X(this,G,kt).call(this,`${o}${r}`,n,{method:e,headers:c,body:u})})};const Jt=(r,e,t,s)=>r instanceof Ie?r:new As({resource:e,api:String(t),args:s,cause:r}),mt=(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 Re;class js{constructor(e){B(this,Re),this.resourceName="Files",I(this,Re,e)}get(e){return A(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,Re).get(a)})}getImageFills(e){return A(this,arguments,function*({fileKey:t}){var s,n;const a=`v1/files/${t}/images`;return(n=(s=(yield T(this,Re).get(a)).meta)==null?void 0:s.images)!=null?n:{}})}}Re=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 K,St,gr;class Ms{constructor(e){B(this,St),B(this,K),this.resourceName="Images",I(this,K,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,format:n="jpg",scale:a}){const i=Rs(t,s,n),o=T(this,K).cache.images.entries.get(i);if(Zs(o))return o.result;o&&T(this,K).cache.images.entries.delete(i);const c=T(this,K).cache.images.pendingRequests.get(i);if(c)return c;const u=X(this,St,gr).call(this,i,t,s,n,a);T(this,K).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,K).cache.images.pendingRequests.delete(i)}})}}K=new WeakMap,St=new WeakSet,gr=function(r,e,t,s,n){return A(this,null,function*(){const a=yield T(this,K).get(`v1/images/${e}?ids=${t}&format=${s}${n?`&scale=${n}`:""}`);return T(this,K).cache.images.entries.set(r,{result:a,ts:Date.now()}),a})};var tt;class Ps{constructor(e){B(this,tt),this.resourceName="Nodes",I(this,tt,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,params:n={}}){const a=jt(U({},n),{ids:s.join(",")}),i=new URLSearchParams(U({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,tt).get(o)})}}tt=new WeakMap;var ce;class yr extends Is{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),B(this,ce,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=mt(this,new js(this)),this.nodes=mt(this,new Ps(this)),this.images=mt(this,new Ms(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");I(this,ce,e)}get token(){return T(this,ce)}get headers(){const e={"Content-Type":"application/json"};return T(this,ce).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,ce):T(this,ce).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,ce)}`),e}}ce=new WeakMap;const vr=n=>C(exports,[n],function*({fileKey:r,authToken:e,figmaRestApi:t=new yr,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:r,params:s})}catch(a){throw console.error(a),It(a,r)}}),$s=a=>C(exports,[a],function*({fileKey:r,authToken:e,nodeIds:t,figmaRestApi:s=new yr,params:n={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:r,nodeIds:t,params:d({},n)})).nodes}catch(i){throw It(i,r)}}),Mt=(r,e)=>{if(r.id===e)return r;if("children"in r)for(const t of r.children){const s=Mt(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 Et;(function(r){r.mergeShapes=(e,t)=>d(d({},e),t)})(Et||(Et={}));const p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return 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 Ee=(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=Ee;function Ls(r){_r=r}function rt(){return _r}const st=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i=g(d({},n),{path:a});if(n.message!==void 0)return g(d({},n),{path:a,message:n.message});let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return g(d({},n),{path:a,message:o})},Vs=[];function h(r,e){const t=rt(),s=st({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ee?void 0:Ee].filter(n=>!!n)});r.common.issues.push(s)}class j{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const 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 C(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 j.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"}),ke=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),At=r=>r.status==="aborted",Ct=r=>r.status==="dirty",ye=r=>r.status==="valid",Pe=r=>typeof Promise!="undefined"&&r instanceof Promise;function nt(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 Ze,Me;class Q{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(ye(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 w(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,u;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:(u=f!=null?f:t)!==null&&u!==void 0?u:o.defaultError}},description:n}}class x{get description(){return this._def.description}_getType(e){return ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const 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:ae(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:ae(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return ye(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=>ye(a)?{value:a.value}:{issues:n.common.issues})}parseAsync(e,t){return C(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return C(this,null,function*(){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},n=this._parse({data:e,path:s.path,parent:s}),a=yield Pe(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(d({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 J({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Y.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return Ce.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new J(g(d({},w(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new qe(g(d({},w(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Pt(d({typeName:y.ZodBranded,type:this},w(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new He(g(d({},w(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return Ke.create(this,e)}readonly(){return Je.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 gt;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 xr(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(`^${xr(r)}$`)}function kr(r){let e=`${wr}T${xr(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 q extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),_}const s=new j;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),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")gt||(gt=new RegExp(Gs,"u")),gt.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"?kr(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),d({validation:t,code:l.invalid_string},m.errToObj(s)))}_addCheck(e){return new q(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.errToObj(e)))}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1},m.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=r=>{var e;return new q(d({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(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 de extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),_}let s;const n=new j;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 de(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new de(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}de.create=r=>new de(d({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class ue extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let s;const n=new j;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 ue(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new ue(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=r=>{var e;return new ue(d({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(r)))};class $e extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),_}return F(e.data)}}$e.create=r=>new $e(d({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class ve extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),_}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),_}const s=new j;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 ve(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ve.create=r=>new ve(d({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate},w(r)));class at extends x{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),_}return F(e.data)}}at.create=r=>new at(d({typeName:y.ZodSymbol},w(r)));class Fe extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),_}return F(e.data)}}Fe.create=r=>new Fe(d({typeName:y.ZodUndefined},w(r)));class Le extends x{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),_}return F(e.data)}}Le.create=r=>new Le(d({typeName:y.ZodNull},w(r)));class Ae extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}}Ae.create=r=>new Ae(d({typeName:y.ZodAny},w(r)));class ge extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}}ge.create=r=>new ge(d({typeName:y.ZodUnknown},w(r)));class ie extends x{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}ie.create=r=>new ie(d({typeName:y.ZodNever},w(r)));class it extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),_}return F(e.data)}}it.create=r=>new it(d({typeName:y.ZodVoid},w(r)));class H extends x{_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 Q(t,i,t.path,o)))).then(i=>j.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new Q(t,i,t.path,o)));return j.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new H(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new H(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new H(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}H.create=(r,e)=>new H(d({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},w(e)));function xe(r){if(r instanceof E){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Y.create(xe(s))}return new E(g(d({},r._def),{shape:()=>e}))}else return r instanceof H?new H(g(d({},r._def),{type:xe(r.element)})):r instanceof Y?Y.create(xe(r.unwrap())):r instanceof fe?fe.create(xe(r.unwrap())):r instanceof ee?ee.create(r.items.map(e=>xe(e))):r}class E extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),_}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const u in n.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const f=a[u],v=n.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Q(n,v,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof ie){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(u==="strict")o.length>0&&(h(n,{code:l.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const v=n.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Q(n,v,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(()=>C(this,null,function*(){const u=[];for(const f of c){const v=yield f.key,O=yield f.value;u.push({key:v,value:O,alwaysSet:f.alwaysSet})}return u})).then(u=>j.mergeObjectSync(s,u)):j.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new E(d(g(d({},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(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new E(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new E(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new E(g(d({},this._def),{catchall:e}))}pick(e){const t={};return k.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new E(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return k.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new E(g(d({},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(d({},this._def),{shape:()=>t}))}required(e){const t={};return k.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof Y;)a=a._def.innerType;t[s]=a}}),new E(g(d({},this._def),{shape:()=>t}))}keyof(){return Tr(k.objectKeys(this.shape))}}E.create=(r,e)=>new E(d({shape:()=>r,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));E.strictCreate=(r,e)=>new E(d({shape:()=>r,unknownKeys:"strict",catchall:ie.create(),typeName:y.ZodObject},w(e)));E.lazycreate=(r,e)=>new E(d({shape:r,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));class Ve extends x{_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=>C(this,null,function*(){const i=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(n);{let a;const i=[];for(const c of s){const u=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null}),f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new z(c));return h(t,{code:l.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}Ve.create=(r,e)=>new Ve(d({options:r,typeName:y.ZodUnion},w(e)));const ne=r=>r instanceof ze?ne(r.schema):r instanceof J?ne(r.innerType()):r instanceof We?[r.value]:r instanceof le?r.options:r instanceof Be?k.objectValues(r.enum):r instanceof qe?ne(r._def.innerType):r instanceof Fe?[void 0]:r instanceof Le?[null]:r instanceof Y?[void 0,...ne(r.unwrap())]:r instanceof fe?[null,...ne(r.unwrap())]:r instanceof Pt||r instanceof Je?ne(r.unwrap()):r instanceof He?ne(r._def.innerType):[];class dt extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),_;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=ne(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 dt(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},w(s)))}}function Ot(r,e){const t=ae(r),s=ae(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=d(d({},r),e);for(const o of a){const c=Ot(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=Ot(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 De extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(At(a)||At(i))return _;const o=Ot(a.value,i.value);return o.valid?((Ct(a)||Ct(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}))}}De.create=(r,e,t)=>new De(d({left:r,right:e,typeName:y.ZodIntersection},w(t)));class ee extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),_;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 Q(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>j.mergeArray(t,i)):j.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ee(g(d({},this._def),{rest:e}))}}ee.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ee(d({items:r,typeName:y.ZodTuple,rest:null},w(e)))};class Ue extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return h(s,{code:l.invalid_type,expected:p.object,received:s.parsedType}),_;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new Q(s,o,s.path,o)),value:i._parse(new Q(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?j.mergeObjectAsync(t,n):j.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof x?new Ue(d({keyType:e,valueType:t,typeName:y.ZodRecord},w(s))):new Ue(d({keyType:q.create(),valueType:e,typeName:y.ZodRecord},w(t)))}}class ot extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return h(s,{code:l.invalid_type,expected:p.map,received:s.parsedType}),_;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:n._parse(new Q(s,o,s.path,[u,"key"])),value:a._parse(new Q(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>C(this,null,function*(){for(const c of i){const u=yield c.key,f=yield c.value;if(u.status==="aborted"||f.status==="aborted")return _;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return _;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}ot.create=(r,e,t)=>new ot(d({valueType:e,keyType:r,typeName:y.ZodMap},w(t)));class _e extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(s,{code:l.invalid_type,expected:p.set,received:s.parsedType}),_;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 u=new Set;for(const f of c){if(f.status==="aborted")return _;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new Q(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new _e(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new _e(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(r,e)=>new _e(d({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet},w(e)));class Te extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),_;function s(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function n(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ce){const o=this;return F(function(...c){return C(this,null,function*(){const u=new z([]),f=yield o._def.args.parseAsync(c,a).catch(R=>{throw u.addIssue(s(c,R)),u}),v=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(v,a).catch(R=>{throw u.addIssue(n(v,R)),u})})})}else{const o=this;return F(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new z([s(c,u.error)]);const f=Reflect.apply(i,this,u.data),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 Te(g(d({},this._def),{args:ee.create(e).rest(ge.create())}))}returns(e){return new Te(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Te(d({args:e||ee.create([]).rest(ge.create()),returns:t||ge.create(),typeName:y.ZodFunction},w(s)))}}class ze extends x{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ze.create=(r,e)=>new ze(d({getter:r,typeName:y.ZodLazy},w(e)));class We extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}We.create=(r,e)=>new We(d({value:r,typeName:y.ZodLiteral},w(e)));function Tr(r,e){return new le(d({values:r,typeName:y.ZodEnum},w(e)))}class le extends x{constructor(){super(...arguments),Ze.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(nt(this,Ze)||br(this,Ze,new Set(this._def.values)),!nt(this,Ze).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 F(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return le.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return le.create(this.options.filter(s=>!e.includes(s)),d(d({},this._def),t))}}Ze=new WeakMap;le.create=Tr;class Be extends x{constructor(){super(...arguments),Me.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(nt(this,Me)||br(this,Me,new Set(k.getValidEnumValues(this._def.values))),!nt(this,Me).has(e.data)){const n=k.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:n}),_}return F(e.data)}get enum(){return this._def.values}}Me=new WeakMap;Be.create=(r,e)=>new Be(d({values:r,typeName:y.ZodNativeEnum},w(e)));class Ce extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),_;const s=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return F(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(r,e)=>new Ce(d({type:r,typeName:y.ZodPromise},w(e)));class J extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),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=>C(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"?ke(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"?ke(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(!ye(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=>ye(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);k.assertNever(n)}}J.create=(r,e,t)=>new J(d({schema:r,typeName:y.ZodEffects,effect:e},w(t)));J.createWithPreprocess=(r,e,t)=>new J(d({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects},w(t)));class Y extends x{_parse(e){return this._getType(e)===p.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(r,e)=>new Y(d({innerType:r,typeName:y.ZodOptional},w(e)));class fe extends x{_parse(e){return this._getType(e)===p.null?F(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fe.create=(r,e)=>new fe(d({innerType:r,typeName:y.ZodNullable},w(e)));class qe extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qe.create=(r,e)=>new qe(d({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},w(e)));class He extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=g(d({},t),{common:g(d({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:s.data,path:s.path,parent:d({},s)});return Pe(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}}He.create=(r,e)=>new He(d({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},w(e)));class ct extends x{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.nan,received:s.parsedType}),_}return{status:"valid",value:e.data}}}ct.create=r=>new ct(d({typeName:y.ZodNaN},w(r)));const dn=Symbol("zod_brand");class Pt extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ke extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return C(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(),ke(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 Ke({in:e,out:t,typeName:y.ZodPipeline})}}class Je extends x{_parse(e){const t=this._def.innerType._parse(e),s=n=>(ye(n)&&(n.value=Object.freeze(n.value)),n);return Pe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}Je.create=(r,e)=>new Je(d({innerType:r,typeName:y.ZodReadonly},w(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?Ae.create().superRefine((s,n)=>{var a,i;const o=r(s);if(o instanceof Promise)return o.then(c=>{var u,f;if(!c){const v=Kt(e,s),O=(f=(u=v.fatal)!==null&&u!==void 0?u:t)!==null&&f!==void 0?f:!0;n.addIssue(g(d({code:"custom"},v),{fatal:O}))}});if(!o){const c=Kt(e,s),u=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0;n.addIssue(g(d({code:"custom"},c),{fatal:u}))}}):Ae.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=q.create,Ar=de.create,fn=ct.create,hn=ue.create,Cr=$e.create,pn=ve.create,mn=at.create,gn=Fe.create,yn=Le.create,vn=Ae.create,_n=ge.create,bn=ie.create,wn=it.create,xn=H.create,kn=E.create,Tn=E.strictCreate,Sn=Ve.create,En=dt.create,An=De.create,Cn=ee.create,On=Ue.create,Nn=ot.create,In=_e.create,jn=Te.create,Rn=ze.create,Zn=We.create,Mn=le.create,Pn=Be.create,$n=Ce.create,Xt=J.create,Fn=Y.create,Ln=fe.create,Vn=J.createWithPreprocess,Dn=Ke.create,Un=()=>Er().optional(),zn=()=>Ar().optional(),Wn=()=>Cr().optional(),Bn={string:r=>q.create(g(d({},r),{coerce:!0})),number:r=>de.create(g(d({},r),{coerce:!0})),boolean:r=>$e.create(g(d({},r),{coerce:!0})),bigint:r=>ue.create(g(d({},r),{coerce:!0})),date:r=>ve.create(g(d({},r),{coerce:!0}))},qn=_;var S=Object.freeze({__proto__:null,defaultErrorMap:Ee,setErrorMap:Ls,getErrorMap:rt,makeIssue:st,EMPTY_PATH:Vs,addIssueToContext:h,ParseStatus:j,INVALID:_,DIRTY:ke,OK:F,isAborted:At,isDirty:Ct,isValid:ye,isAsync:Pe,get util(){return k},get objectUtil(){return Et},ZodParsedType:p,getParsedType:ae,ZodType:x,datetimeRegex:kr,ZodString:q,ZodNumber:de,ZodBigInt:ue,ZodBoolean:$e,ZodDate:ve,ZodSymbol:at,ZodUndefined:Fe,ZodNull:Le,ZodAny:Ae,ZodUnknown:ge,ZodNever:ie,ZodVoid:it,ZodArray:H,ZodObject:E,ZodUnion:Ve,ZodDiscriminatedUnion:dt,ZodIntersection:De,ZodTuple:ee,ZodRecord:Ue,ZodMap:ot,ZodSet:_e,ZodFunction:Te,ZodLazy:ze,ZodLiteral:We,ZodEnum:le,ZodNativeEnum:Be,ZodPromise:Ce,ZodEffects:J,ZodTransformer:J,ZodOptional:Y,ZodNullable:fe,ZodDefault:qe,ZodCatch:He,ZodNaN:ct,BRAND:dn,ZodBranded:Pt,ZodPipeline:Ke,ZodReadonly:Je,custom:Sr,Schema:x,ZodSchema:x,late:un,get ZodFirstPartyTypeKind(){return y},coerce:Bn,any:vn,array:xn,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:kn,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()}).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()}),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)=>{const t=Mt(r.document,e);if(!t)return{isValid:!1,reason:"There is no node with the given id"};if(t.type==="CANVAS"){const s=t.children.filter(n=>Yt.has(n.type));return s.length===1?{isValid:!0,node:s[0],note:"Selected node is a page with a single valid children - returning it instead"}:{isValid:!1,reason:"Selected node is a page with multiple children"}}return Yt.has(t.type)?{isValid:!0,node:t}:{isValid:!1,reason:"Selected node type is not supported"}};var N,Ge,be,Ir,Nt;class Jn{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){Xe(this,be);Xe(this,N);Xe(this,Ge);ft(this,Ge,t),e&&(this.auth=e)}hasAuth(){return!!P(this,N)}set auth(e){ft(this,N,e)}get headers(){const e={"Content-Type":"application/json"};return P(this,N)&&(e.Authorization=`Bearer ${P(this,N).token}`,"teamId"in P(this,N)&&(e["X-Team-Id"]=P(this,N).teamId)),e}generateCode(s){return C(this,arguments,function*(e,t={}){e.figmaToken&&(yield Ye(this,be,Ir).call(this,e.fileKey,e.figmaToken,e.nodesId));const n=Or(e.settings);let a=e.tracking;P(this,N)&&"userId"in P(this,N)&&P(this,N).userId&&(a!=null&&a.externalId||(a={externalId:P(this,N).userId}));const i={tracking:a,fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,assetsStorage:e.assetsStorage,language:n.language,model:n.model,framework:n.framework,styling:n.styling,uiLibrary:n.uiLibrary,enableTranslation:n.enableTranslation,enableUILibraryTheming:n.enableUILibraryTheming,enableCompactStructure:n.enableCompactStructure,enableAutoSplit:n.enableAutoSplit,autoSplitThreshold:n.autoSplitThreshold,disableMarkedForExport:n.disableMarkedForExport,enableDisplayScreenModelId:n.enableDisplayScreenModelId,enableGeneratePackageLock:n.enableGeneratePackageLock};return Ye(this,be,Nt).call(this,"/v1/codegen",i,t,"codegen")})}generateLink2Code(s){return C(this,arguments,function*(e,t={}){let n=e.tracking;P(this,N)&&"userId"in P(this,N)&&P(this,N).userId&&(n!=null&&n.externalId||(n={externalId:P(this,N).userId}));const a={tracking:n,assetsStorage:e.assetsStorage,params:e.params};return Ye(this,be,Nt).call(this,"/v1/l2c",a,t,"l2c")})}}N=new WeakMap,Ge=new WeakMap,be=new WeakSet,Ir=function(e,t,s){return C(this,null,function*(){let n;try{n=yield vr({fileKey:e,authToken:t,params:{geometry:"paths"}})}catch(o){return}const i=s.map(o=>Nr(n,o)).find(o=>!o.isValid);if(i)throw new se({name:"Task Crashed",reason:i.reason})})},Nt=function(e,t,s,n){return C(this,null,function*(){var f,v,O,R,L,W,te,he,oe;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const a={},i=yield fetch(`${P(this,Ge)}${e}`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify(t)});if(!i.ok){const Z=yield i.text();let M;try{M=JSON.parse(Z)}catch(Oe){}throw((f=M==null?void 0:M.error)==null?void 0:f.name)==="ZodError"?new se({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:M.error.issues,status:i.status}):typeof M=="object"?new se({name:`Error "${M}"`,reason:"Unknown",status:i.status}):new se({name:"HTTP error from Anima API",reason:Z,status:i.status})}if(!i.body)throw new se({name:"Stream Error",reason:"Response body is null",status:i.status});const o=i.body.getReader(),c=new TextDecoder;let u="";try{for(;;){const{done:Z,value:M}=yield o.read();if(Z)break;u+=c.decode(M,{stream:!0});const Oe=u.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,d=(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 lt=(r,e,t)=>e.has(r)||Vt("Cannot "+t);var P=(r,e,t)=>(lt(r,e,"read from private field"),t?t.call(r):e.get(r)),Xe=(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),ft=(r,e,t,s)=>(lt(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t),Ye=(r,e,t)=>(lt(r,e,"access private method"),t);var C=(r,e,t)=>new Promise((s,n)=>{var a=c=>{try{o(t.next(c))}catch(u){n(u)}},i=c=>{try{o(t.throw(c))}catch(u){n(u)}},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 se 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,It=(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},jt=(r,e)=>Wr(r,Br(e)),Rt=(r,e,t)=>e.has(r)||hr("Cannot "+t),T=(r,e,t)=>(Rt(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),I=(r,e,t,s)=>(Rt(r,e,"write to private field"),e.set(r,t),t),X=(r,e,t)=>(Rt(r,e,"access private method"),t),A=(r,e,t)=>new Promise((s,n)=>{var a=c=>{try{o(t.next(c))}catch(u){n(u)}},i=c=>{try{o(t.throw(c))}catch(u){n(u)}},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(u=>i({value:u,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 yt={exports:{}},Xr=yt.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",u=typeof DataView!="undefined",f=n&&typeof Symbol.iterator!="undefined",v=n&&typeof Symbol.toStringTag!="undefined",O=i&&typeof Set.prototype.entries=="function",R=a&&typeof Map.prototype.entries=="function",L=O&&Object.getPrototypeOf(new Set().entries()),W=R&&Object.getPrototypeOf(new Map().entries()),te=f&&typeof Array.prototype[Symbol.iterator]=="function",he=te&&Object.getPrototypeOf([][Symbol.iterator]()),oe=f&&typeof String.prototype[Symbol.iterator]=="function",Z=oe&&Object.getPrototypeOf(""[Symbol.iterator]()),M=8,Oe=-1;function we(b){var ut=typeof b;if(ut!=="object")return ut;if(b===null)return"null";if(b===s)return"global";if(Array.isArray(b)&&(v===!1||!(Symbol.toStringTag in b)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&b===window.location)return"Location";if(typeof window.document=="object"&&b===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&b===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&b===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&b instanceof window.HTMLElement){if(b.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(b.tagName==="TD")return"HTMLTableDataCellElement";if(b.tagName==="TH")return"HTMLTableHeaderCellElement"}}var $t=v&&b[Symbol.toStringTag];if(typeof $t=="string")return $t;var D=Object.getPrototypeOf(b);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":u&&D===DataView.prototype?"DataView":a&&D===W?"Map Iterator":i&&D===L?"Set Iterator":te&&D===he?"Array Iterator":oe&&D===Z?"String Iterator":D===null?"Object":Object.prototype.toString.call(b).slice(M,Oe)}return we})}(yt)),yt.exports}var Qr=Yr();const es=Kr(Qr),Zt=typeof Buffer!="undefined",ts=Zt&&typeof Buffer.from!="undefined",rs=Zt?function(r){return Buffer.isBuffer(r)}:function(){return!1},ss=ts?function(r){return Buffer.from(r)}:Zt?function(r){return new Buffer(r)}:function(r){return r};function Se(r){return rs(r)?"Buffer":es(r)}const ns=new Set(["Arguments","Array","Map","Object","Set"]);function as(r,e,t=null){switch(t||Se(r)){case"Arguments":case"Array":case"Object":return r[e];case"Map":return r.get(e);case"Set":return e}}function vt(r){return ns.has(r)}function Bt(r,e,t,s=null){switch(s||Se(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,ht=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 re(r,e){return ht[e].from?ht[e].from(r):new ht[e](r)}function $(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",re],["Float64Array",re],["Int16Array",re],["Int32Array",re],["Int8Array",re],["Uint16Array",re],["Uint32Array",re],["Uint8Array",re],["Uint8ClampedArray",re],["Array Iterator",$],["Map Iterator",$],["Promise",$],["Set Iterator",$],["String Iterator",$],["function",$],["global",$],["WeakMap",$],["WeakSet",$],["boolean",$],["null",$],["number",$],["string",$],["symbol",$],["undefined",$],["Arguments",qt],["Array",qt],["Map",ys],["Object",vs],["Set",_s]]);function ws(){}function _t(r,e=null,t=ws){arguments.length===2&&typeof e=="function"&&(t=e,e=null);const s=e||Se(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 Ne(r,e={}){typeof e=="function"&&(e={customizer:e});const{customizer:t}=e,s=Se(r);if(!vt(s))return bt(r,null,null,null);const n=_t(r,s,t),a=new WeakMap([[r,n]]),i=new WeakSet([r]);return bt(r,n,a,i)}function bt(r,e,t,s,n){const a=Se(r),i=_t(r,a);if(!vt(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 u=as(r,c,a);if(s.has(u))Bt(e,c,t.get(u),a);else{const f=Se(u),v=_t(u,f);vt(f)&&(t.set(u,v),s.add(u)),Bt(e,c,bt(u,v,t,s),a)}}return e}const xs=r=>new Promise(e=>setTimeout(e,r));var Qe,pe,et,wt,pr;class ks{constructor({maxAttempts:e=3,func:t}){B(this,wt),B(this,Qe),B(this,pe),B(this,et),I(this,Qe,e),I(this,et,t),I(this,pe,0)}run(){return A(this,null,function*(){try{return yield T(this,et).call(this)}catch(e){if(I(this,pe,T(this,pe)+1),T(this,pe)>T(this,Qe))throw console.error("Max attempts reached"),e;const t=X(this,wt,pr).call(this);return yield xs(t),yield this.run()}})}}Qe=new WeakMap,pe=new WeakMap,et=new WeakMap,wt=new WeakSet,pr=function(){return T(this,pe)*1e3*1.5};function Ts(){return typeof CompressionStream!="undefined"}function Ss(r){return A(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 A(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((u,f)=>{c[f]=u}),this.causeProperties[i]=c}else this.causeProperties[i]=o;const a=this.causeProperties.body;a&&typeof a=="object"&&"code"in a&&(this.code=a.code)}}class 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 Ie 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 pt 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 me,V,G,kt,Tt,je;class Is{constructor({fetch:e=globalThis.fetch.bind(globalThis),baseAddress:t}){B(this,G),B(this,me),B(this,V),this.baseAddress=t,I(this,me,e),I(this,V,{}),this.plugins=[]}get headers(){throw new Error("Missing implementation")}addPlugin(e){this.plugins.push(e)}removePlugin(e){this.plugins=this.plugins.filter(t=>t.name!==e)}withOptions(e={}){return I(this,V,e),this}get(e){return A(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=Ne(T(this,V));return I(this,V,{}),c.extraHeaders&&(o=U(U({},o),c.extraHeaders)),c.requestValidation&&(o=jt(U({},o),{"X-Request-Nonce":mr(),"X-Request-Timestamp":xt()})),c.async?yield X(this,G,Tt).call(this,`${i}${t}`,c.async,{headers:o}):yield X(this,G,kt).call(this,`${i}${t}`,c,{headers:o})})}post(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"POST",n,a,i)})}put(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"PUT",n,a,i)})}delete(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"DELETE",n,a,i)})}patch(e,t){return A(this,arguments,function*(s,n,a={}){const i=Ne(T(this,V));return I(this,V,{}),X(this,G,je).call(this,s,"PATCH",n,a,i)})}}me=new WeakMap,V=new WeakMap,G=new WeakSet,kt=function(r,e,t){return A(this,null,function*(){const s=()=>A(this,null,function*(){var c,u;try{return yield T(this,me).call(this,r,U(U({},t),e.abortSignal&&{signal:e.abortSignal}))}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Ie({canceled:(u=(c=e.abortSignal)==null?void 0:c.aborted)!=null?u:!1}):f}}),{headers:n}=t!=null?t:{},a=(c,u)=>{var f,v;return((f=c==null?void 0:c.headers)==null?void 0:f.get(u))||((v=c==null?void 0:c.headersObject)==null?void 0:v[u])||""},i=c=>A(this,null,function*(){var u;if(!c.ok){const v=yield c.text().catch();throw new Ht({url:r,method:(u=t==null?void 0:t.method)!=null?u:"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"),O=n==null?void 0:n["X-Request-Nonce"];if(!v||v!==O)throw new pt("Response nonce mismatch");const R=Number(a(c,"x-response-timestamp")),L=Number(xt()),W=60*60*24;if(isNaN(R)||Math.abs(L-R)>W)throw new pt("Invalid response timestamp")}catch(v){const O=v instanceof Error?v.message:"Request validation failed";throw new pt(O)}let f=yield c.text();try{f=JSON.parse(f)}catch(v){}return f});if(e.retry){const c=yield new ks({maxAttempts:e.retry,func:s}).run();return yield i(c)}const o=yield s();return yield i(o)})},Tt=function(r,e,t){return A(this,null,function*(){var s,n;const{onProgress:a,abortSignal:i,pollingInterval:o=()=>Ns,maxTimeout:c=Os}=e,u=`${r}/async`,f=`${r}/async/job`;let v;try{v=yield T(this,me).call(this,u,U(U({},t),i&&{signal:i}))}catch(L){throw L instanceof Error&&L.name==="AbortError"?new Ie({canceled:(s=i==null?void 0:i.aborted)!=null?s:!1}):L}if(!v.ok){const L=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:L})}const O=yield v.json(),{job_id:R}=O;if(!R)throw new Error("Job ID not found in response");return new Promise((L,W)=>A(this,null,function*(){const te=setTimeout(()=>{W(new Error("Job timed out"))},c),he=(oe=0)=>A(this,null,function*(){if(i!=null&&i.aborted){clearTimeout(te),T(this,me).call(this,`${f}/${R}/cancel`,{method:"POST",headers:this.headers}).then(()=>{W(new Ie({canceled:!0}))}).catch(Z=>{W(new Ie({canceled:!1}))});return}try{const Z=yield(yield T(this,me).call(this,`${f}/${R}`,{headers:this.headers})).json();if(Z.status==="success"){clearTimeout(te);const M=Z.response_json;L(M)}else if(Z.status==="failed")clearTimeout(te),W(new Cs(Z.response_json));else{a&&a(Z.response_json);const M=o(oe);setTimeout(()=>he(oe+1),M)}}catch(Z){W(Z)}});he()}))})},je=function(r,e,t,s,n){return A(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=jt(U({},c),{"X-Request-Nonce":mr(),"X-Request-Timestamp":xt()}));let u=t;return typeof FormData!="undefined"&&t instanceof FormData?delete c["Content-Type"]:(u=s.skipBodyJsonStringify?t:JSON.stringify(t),n.compress&&Ts()&&(c["Content-Encoding"]="gzip",u=yield Ss(u))),n.async?yield X(this,G,Tt).call(this,`${o}${r}`,n.async,{method:e,headers:c,body:u}):yield X(this,G,kt).call(this,`${o}${r}`,n,{method:e,headers:c,body:u})})};const Jt=(r,e,t,s)=>r instanceof Ie?r:new As({resource:e,api:String(t),args:s,cause:r}),mt=(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 Re;class js{constructor(e){B(this,Re),this.resourceName="Files",I(this,Re,e)}get(e){return A(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,Re).get(a)})}getImageFills(e){return A(this,arguments,function*({fileKey:t}){var s,n;const a=`v1/files/${t}/images`;return(n=(s=(yield T(this,Re).get(a)).meta)==null?void 0:s.images)!=null?n:{}})}}Re=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 K,St,gr;class Ms{constructor(e){B(this,St),B(this,K),this.resourceName="Images",I(this,K,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,format:n="jpg",scale:a}){const i=Rs(t,s,n),o=T(this,K).cache.images.entries.get(i);if(Zs(o))return o.result;o&&T(this,K).cache.images.entries.delete(i);const c=T(this,K).cache.images.pendingRequests.get(i);if(c)return c;const u=X(this,St,gr).call(this,i,t,s,n,a);T(this,K).cache.images.pendingRequests.set(i,u);try{return yield u}finally{T(this,K).cache.images.pendingRequests.delete(i)}})}}K=new WeakMap,St=new WeakSet,gr=function(r,e,t,s,n){return A(this,null,function*(){const a=yield T(this,K).get(`v1/images/${e}?ids=${t}&format=${s}${n?`&scale=${n}`:""}`);return T(this,K).cache.images.entries.set(r,{result:a,ts:Date.now()}),a})};var tt;class Ps{constructor(e){B(this,tt),this.resourceName="Nodes",I(this,tt,e)}get(e){return A(this,arguments,function*({fileKey:t,nodeIds:s,params:n={}}){const a=jt(U({},n),{ids:s.join(",")}),i=new URLSearchParams(U({plugin_data:"857346721138427857"},a)).toString(),o=`v1/files/${t}/nodes?${i}`;return yield T(this,tt).get(o)})}}tt=new WeakMap;var ce;class yr extends Is{constructor({baseAddress:e="https://api.figma.com/",fetch:t=globalThis.fetch.bind(globalThis)}={}){super({fetch:t,baseAddress:e}),B(this,ce,""),this.cache={images:{entries:new Map,pendingRequests:new Map}},this.files=mt(this,new js(this)),this.nodes=mt(this,new Ps(this)),this.images=mt(this,new Ms(this))}set token(e){if(!e.startsWith("figd_")&&!e.startsWith("figu_"))throw new Error("Invalid Figma access token");I(this,ce,e)}get token(){return T(this,ce)}get headers(){const e={"Content-Type":"application/json"};return T(this,ce).startsWith("figd_")?e["X-FIGMA-TOKEN"]=T(this,ce):T(this,ce).startsWith("figu_")&&(e.Authorization=`Bearer ${T(this,ce)}`),e}}ce=new WeakMap;const vr=n=>C(exports,[n],function*({fileKey:r,authToken:e,figmaRestApi:t=new yr,params:s={}}){e&&(t.token=e);try{return yield t.files.get({fileKey:r,params:s})}catch(a){throw console.error(a),It(a,r)}}),$s=a=>C(exports,[a],function*({fileKey:r,authToken:e,nodeIds:t,figmaRestApi:s=new yr,params:n={}}){e&&(s.token=e);try{return(yield s.nodes.get({fileKey:r,nodeIds:t,params:d({},n)})).nodes}catch(i){throw It(i,r)}}),Mt=(r,e)=>{if(r.id===e)return r;if("children"in r)for(const t of r.children){const s=Mt(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 Et;(function(r){r.mergeShapes=(e,t)=>d(d({},e),t)})(Et||(Et={}));const p=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return 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 Ee=(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=Ee;function Ls(r){_r=r}function rt(){return _r}const st=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i=g(d({},n),{path:a});if(n.message!==void 0)return g(d({},n),{path:a,message:n.message});let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return g(d({},n),{path:a,message:o})},Vs=[];function h(r,e){const t=rt(),s=st({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ee?void 0:Ee].filter(n=>!!n)});r.common.issues.push(s)}class j{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const 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 C(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 j.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"}),ke=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),At=r=>r.status==="aborted",Ct=r=>r.status==="dirty",ye=r=>r.status==="valid",Pe=r=>typeof Promise!="undefined"&&r instanceof Promise;function nt(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 Ze,Me;class Q{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(ye(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 w(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,u;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:(u=f!=null?f:t)!==null&&u!==void 0?u:o.defaultError}},description:n}}class x{get description(){return this._def.description}_getType(e){return ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const 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:ae(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:ae(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return ye(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=>ye(a)?{value:a.value}:{issues:n.common.issues})}parseAsync(e,t){return C(this,null,function*(){const s=yield this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error})}safeParseAsync(e,t){return C(this,null,function*(){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},n=this._parse({data:e,path:s.path,parent:s}),a=yield Pe(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(d({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 J({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Y.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return H.create(this)}promise(){return Ce.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new J(g(d({},w(this._def)),{schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){const t=typeof e=="function"?e:()=>e;return new qe(g(d({},w(this._def)),{innerType:this,defaultValue:t,typeName:y.ZodDefault}))}brand(){return new Pt(d({typeName:y.ZodBranded,type:this},w(this._def)))}catch(e){const t=typeof e=="function"?e:()=>e;return new He(g(d({},w(this._def)),{innerType:this,catchValue:t,typeName:y.ZodCatch}))}describe(e){const t=this.constructor;return new t(g(d({},this._def),{description:e}))}pipe(e){return Ke.create(this,e)}readonly(){return Je.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 gt;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 xr(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(`^${xr(r)}$`)}function kr(r){let e=`${wr}T${xr(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 q extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.string,received:a.parsedType}),_}const s=new j;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),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")gt||(gt=new RegExp(Gs,"u")),gt.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"?kr(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),d({validation:t,code:l.invalid_string},m.errToObj(s)))}_addCheck(e){return new q(g(d({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(d({kind:"email"},m.errToObj(e)))}url(e){return this._addCheck(d({kind:"url"},m.errToObj(e)))}emoji(e){return this._addCheck(d({kind:"emoji"},m.errToObj(e)))}uuid(e){return this._addCheck(d({kind:"uuid"},m.errToObj(e)))}nanoid(e){return this._addCheck(d({kind:"nanoid"},m.errToObj(e)))}cuid(e){return this._addCheck(d({kind:"cuid"},m.errToObj(e)))}cuid2(e){return this._addCheck(d({kind:"cuid2"},m.errToObj(e)))}ulid(e){return this._addCheck(d({kind:"ulid"},m.errToObj(e)))}base64(e){return this._addCheck(d({kind:"base64"},m.errToObj(e)))}base64url(e){return this._addCheck(d({kind:"base64url"},m.errToObj(e)))}jwt(e){return this._addCheck(d({kind:"jwt"},m.errToObj(e)))}ip(e){return this._addCheck(d({kind:"ip"},m.errToObj(e)))}cidr(e){return this._addCheck(d({kind:"cidr"},m.errToObj(e)))}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(d({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1},m.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(d({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},m.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(d({kind:"duration"},m.errToObj(e)))}regex(e,t){return this._addCheck(d({kind:"regex",regex:e},m.errToObj(t)))}includes(e,t){return this._addCheck(d({kind:"includes",value:e,position:t==null?void 0:t.position},m.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(d({kind:"startsWith",value:e},m.errToObj(t)))}endsWith(e,t){return this._addCheck(d({kind:"endsWith",value:e},m.errToObj(t)))}min(e,t){return this._addCheck(d({kind:"min",value:e},m.errToObj(t)))}max(e,t){return this._addCheck(d({kind:"max",value:e},m.errToObj(t)))}length(e,t){return this._addCheck(d({kind:"length",value:e},m.errToObj(t)))}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}toLowerCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new q(g(d({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=r=>{var e;return new q(d({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(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 de extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.number,received:a.parsedType}),_}let s;const n=new j;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 de(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new de(g(d({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}de.create=r=>new de(d({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class ue extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(a){return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let s;const n=new j;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 ue(g(d({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]}))}_addCheck(e){return new ue(g(d({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=r=>{var e;return new ue(d({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1},w(r)))};class $e extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.boolean,received:s.parsedType}),_}return F(e.data)}}$e.create=r=>new $e(d({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1},w(r)));class ve extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_type,expected:p.date,received:a.parsedType}),_}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:l.invalid_date}),_}const s=new j;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 ve(g(d({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ve.create=r=>new ve(d({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate},w(r)));class at extends x{_parse(e){if(this._getType(e)!==p.symbol){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.symbol,received:s.parsedType}),_}return F(e.data)}}at.create=r=>new at(d({typeName:y.ZodSymbol},w(r)));class Fe extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.undefined,received:s.parsedType}),_}return F(e.data)}}Fe.create=r=>new Fe(d({typeName:y.ZodUndefined},w(r)));class Le extends x{_parse(e){if(this._getType(e)!==p.null){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.null,received:s.parsedType}),_}return F(e.data)}}Le.create=r=>new Le(d({typeName:y.ZodNull},w(r)));class Ae extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return F(e.data)}}Ae.create=r=>new Ae(d({typeName:y.ZodAny},w(r)));class ge extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return F(e.data)}}ge.create=r=>new ge(d({typeName:y.ZodUnknown},w(r)));class ie extends x{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:l.invalid_type,expected:p.never,received:t.parsedType}),_}}ie.create=r=>new ie(d({typeName:y.ZodNever},w(r)));class it extends x{_parse(e){if(this._getType(e)!==p.undefined){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.void,received:s.parsedType}),_}return F(e.data)}}it.create=r=>new it(d({typeName:y.ZodVoid},w(r)));class H extends x{_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 Q(t,i,t.path,o)))).then(i=>j.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new Q(t,i,t.path,o)));return j.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new H(g(d({},this._def),{minLength:{value:e,message:m.toString(t)}}))}max(e,t){return new H(g(d({},this._def),{maxLength:{value:e,message:m.toString(t)}}))}length(e,t){return new H(g(d({},this._def),{exactLength:{value:e,message:m.toString(t)}}))}nonempty(e){return this.min(1,e)}}H.create=(r,e)=>new H(d({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray},w(e)));function xe(r){if(r instanceof E){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Y.create(xe(s))}return new E(g(d({},r._def),{shape:()=>e}))}else return r instanceof H?new H(g(d({},r._def),{type:xe(r.element)})):r instanceof Y?Y.create(xe(r.unwrap())):r instanceof fe?fe.create(xe(r.unwrap())):r instanceof ee?ee.create(r.items.map(e=>xe(e))):r}class E extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(u,{code:l.invalid_type,expected:p.object,received:u.parsedType}),_}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const u in n.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const f=a[u],v=n.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Q(n,v,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof ie){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(u==="strict")o.length>0&&(h(n,{code:l.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const v=n.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Q(n,v,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(()=>C(this,null,function*(){const u=[];for(const f of c){const v=yield f.key,O=yield f.value;u.push({key:v,value:O,alwaysSet:f.alwaysSet})}return u})).then(u=>j.mergeObjectSync(s,u)):j.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new E(d(g(d({},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(d({},this._def),{unknownKeys:"strip"}))}passthrough(){return new E(g(d({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new E(g(d({},this._def),{shape:()=>d(d({},this._def.shape()),e)}))}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>d(d({},this._def.shape()),e._def.shape()),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new E(g(d({},this._def),{catchall:e}))}pick(e){const t={};return k.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new E(g(d({},this._def),{shape:()=>t}))}omit(e){const t={};return k.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new E(g(d({},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(d({},this._def),{shape:()=>t}))}required(e){const t={};return k.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof Y;)a=a._def.innerType;t[s]=a}}),new E(g(d({},this._def),{shape:()=>t}))}keyof(){return Tr(k.objectKeys(this.shape))}}E.create=(r,e)=>new E(d({shape:()=>r,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));E.strictCreate=(r,e)=>new E(d({shape:()=>r,unknownKeys:"strict",catchall:ie.create(),typeName:y.ZodObject},w(e)));E.lazycreate=(r,e)=>new E(d({shape:r,unknownKeys:"strip",catchall:ie.create(),typeName:y.ZodObject},w(e)));class Ve extends x{_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=>C(this,null,function*(){const i=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(n);{let a;const i=[];for(const c of s){const u=g(d({},t),{common:g(d({},t.common),{issues:[]}),parent:null}),f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new z(c));return h(t,{code:l.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}Ve.create=(r,e)=>new Ve(d({options:r,typeName:y.ZodUnion},w(e)));const ne=r=>r instanceof ze?ne(r.schema):r instanceof J?ne(r.innerType()):r instanceof We?[r.value]:r instanceof le?r.options:r instanceof Be?k.objectValues(r.enum):r instanceof qe?ne(r._def.innerType):r instanceof Fe?[void 0]:r instanceof Le?[null]:r instanceof Y?[void 0,...ne(r.unwrap())]:r instanceof fe?[null,...ne(r.unwrap())]:r instanceof Pt||r instanceof Je?ne(r.unwrap()):r instanceof He?ne(r._def.innerType):[];class dt extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(t,{code:l.invalid_type,expected:p.object,received:t.parsedType}),_;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=ne(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 dt(d({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},w(s)))}}function Ot(r,e){const t=ae(r),s=ae(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=d(d({},r),e);for(const o of a){const c=Ot(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=Ot(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 De extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(At(a)||At(i))return _;const o=Ot(a.value,i.value);return o.valid?((Ct(a)||Ct(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}))}}De.create=(r,e,t)=>new De(d({left:r,right:e,typeName:y.ZodIntersection},w(t)));class ee extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.array)return h(s,{code:l.invalid_type,expected:p.array,received:s.parsedType}),_;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 Q(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>j.mergeArray(t,i)):j.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ee(g(d({},this._def),{rest:e}))}}ee.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ee(d({items:r,typeName:y.ZodTuple,rest:null},w(e)))};class Ue extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.object)return h(s,{code:l.invalid_type,expected:p.object,received:s.parsedType}),_;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new Q(s,o,s.path,o)),value:i._parse(new Q(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?j.mergeObjectAsync(t,n):j.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof x?new Ue(d({keyType:e,valueType:t,typeName:y.ZodRecord},w(s))):new Ue(d({keyType:q.create(),valueType:e,typeName:y.ZodRecord},w(t)))}}class ot extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.map)return h(s,{code:l.invalid_type,expected:p.map,received:s.parsedType}),_;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:n._parse(new Q(s,o,s.path,[u,"key"])),value:a._parse(new Q(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(()=>C(this,null,function*(){for(const c of i){const u=yield c.key,f=yield c.value;if(u.status==="aborted"||f.status==="aborted")return _;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}))}else{const o=new Map;for(const c of i){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return _;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}ot.create=(r,e,t)=>new ot(d({valueType:e,keyType:r,typeName:y.ZodMap},w(t)));class _e extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==p.set)return h(s,{code:l.invalid_type,expected:p.set,received:s.parsedType}),_;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 u=new Set;for(const f of c){if(f.status==="aborted")return _;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new Q(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new _e(g(d({},this._def),{minSize:{value:e,message:m.toString(t)}}))}max(e,t){return new _e(g(d({},this._def),{maxSize:{value:e,message:m.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(r,e)=>new _e(d({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet},w(e)));class Te extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:l.invalid_type,expected:p.function,received:t.parsedType}),_;function s(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function n(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rt(),Ee].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ce){const o=this;return F(function(...c){return C(this,null,function*(){const u=new z([]),f=yield o._def.args.parseAsync(c,a).catch(R=>{throw u.addIssue(s(c,R)),u}),v=yield Reflect.apply(i,this,f);return yield o._def.returns._def.type.parseAsync(v,a).catch(R=>{throw u.addIssue(n(v,R)),u})})})}else{const o=this;return F(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new z([s(c,u.error)]);const f=Reflect.apply(i,this,u.data),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 Te(g(d({},this._def),{args:ee.create(e).rest(ge.create())}))}returns(e){return new Te(g(d({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Te(d({args:e||ee.create([]).rest(ge.create()),returns:t||ge.create(),typeName:y.ZodFunction},w(s)))}}class ze extends x{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ze.create=(r,e)=>new ze(d({getter:r,typeName:y.ZodLazy},w(e)));class We extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}We.create=(r,e)=>new We(d({value:r,typeName:y.ZodLiteral},w(e)));function Tr(r,e){return new le(d({values:r,typeName:y.ZodEnum},w(e)))}class le extends x{constructor(){super(...arguments),Ze.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(nt(this,Ze)||br(this,Ze,new Set(this._def.values)),!nt(this,Ze).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 F(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return le.create(e,d(d({},this._def),t))}exclude(e,t=this._def){return le.create(this.options.filter(s=>!e.includes(s)),d(d({},this._def),t))}}Ze=new WeakMap;le.create=Tr;class Be extends x{constructor(){super(...arguments),Me.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(nt(this,Me)||br(this,Me,new Set(k.getValidEnumValues(this._def.values))),!nt(this,Me).has(e.data)){const n=k.objectValues(t);return h(s,{received:s.data,code:l.invalid_enum_value,options:n}),_}return F(e.data)}get enum(){return this._def.values}}Me=new WeakMap;Be.create=(r,e)=>new Be(d({values:r,typeName:y.ZodNativeEnum},w(e)));class Ce extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(t,{code:l.invalid_type,expected:p.promise,received:t.parsedType}),_;const s=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return F(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(r,e)=>new Ce(d({type:r,typeName:y.ZodPromise},w(e)));class J extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),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=>C(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"?ke(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"?ke(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(!ye(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=>ye(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);k.assertNever(n)}}J.create=(r,e,t)=>new J(d({schema:r,typeName:y.ZodEffects,effect:e},w(t)));J.createWithPreprocess=(r,e,t)=>new J(d({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects},w(t)));class Y extends x{_parse(e){return this._getType(e)===p.undefined?F(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(r,e)=>new Y(d({innerType:r,typeName:y.ZodOptional},w(e)));class fe extends x{_parse(e){return this._getType(e)===p.null?F(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fe.create=(r,e)=>new fe(d({innerType:r,typeName:y.ZodNullable},w(e)));class qe extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===p.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qe.create=(r,e)=>new qe(d({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},w(e)));class He extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=g(d({},t),{common:g(d({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:s.data,path:s.path,parent:d({},s)});return Pe(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}}He.create=(r,e)=>new He(d({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},w(e)));class ct extends x{_parse(e){if(this._getType(e)!==p.nan){const s=this._getOrReturnCtx(e);return h(s,{code:l.invalid_type,expected:p.nan,received:s.parsedType}),_}return{status:"valid",value:e.data}}}ct.create=r=>new ct(d({typeName:y.ZodNaN},w(r)));const dn=Symbol("zod_brand");class Pt extends x{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ke extends x{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return C(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(),ke(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 Ke({in:e,out:t,typeName:y.ZodPipeline})}}class Je extends x{_parse(e){const t=this._def.innerType._parse(e),s=n=>(ye(n)&&(n.value=Object.freeze(n.value)),n);return Pe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}Je.create=(r,e)=>new Je(d({innerType:r,typeName:y.ZodReadonly},w(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?Ae.create().superRefine((s,n)=>{var a,i;const o=r(s);if(o instanceof Promise)return o.then(c=>{var u,f;if(!c){const v=Kt(e,s),O=(f=(u=v.fatal)!==null&&u!==void 0?u:t)!==null&&f!==void 0?f:!0;n.addIssue(g(d({code:"custom"},v),{fatal:O}))}});if(!o){const c=Kt(e,s),u=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0;n.addIssue(g(d({code:"custom"},c),{fatal:u}))}}):Ae.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=q.create,Ar=de.create,fn=ct.create,hn=ue.create,Cr=$e.create,pn=ve.create,mn=at.create,gn=Fe.create,yn=Le.create,vn=Ae.create,_n=ge.create,bn=ie.create,wn=it.create,xn=H.create,kn=E.create,Tn=E.strictCreate,Sn=Ve.create,En=dt.create,An=De.create,Cn=ee.create,On=Ue.create,Nn=ot.create,In=_e.create,jn=Te.create,Rn=ze.create,Zn=We.create,Mn=le.create,Pn=Be.create,$n=Ce.create,Xt=J.create,Fn=Y.create,Ln=fe.create,Vn=J.createWithPreprocess,Dn=Ke.create,Un=()=>Er().optional(),zn=()=>Ar().optional(),Wn=()=>Cr().optional(),Bn={string:r=>q.create(g(d({},r),{coerce:!0})),number:r=>de.create(g(d({},r),{coerce:!0})),boolean:r=>$e.create(g(d({},r),{coerce:!0})),bigint:r=>ue.create(g(d({},r),{coerce:!0})),date:r=>ve.create(g(d({},r),{coerce:!0}))},qn=_;var S=Object.freeze({__proto__:null,defaultErrorMap:Ee,setErrorMap:Ls,getErrorMap:rt,makeIssue:st,EMPTY_PATH:Vs,addIssueToContext:h,ParseStatus:j,INVALID:_,DIRTY:ke,OK:F,isAborted:At,isDirty:Ct,isValid:ye,isAsync:Pe,get util(){return k},get objectUtil(){return Et},ZodParsedType:p,getParsedType:ae,ZodType:x,datetimeRegex:kr,ZodString:q,ZodNumber:de,ZodBigInt:ue,ZodBoolean:$e,ZodDate:ve,ZodSymbol:at,ZodUndefined:Fe,ZodNull:Le,ZodAny:Ae,ZodUnknown:ge,ZodNever:ie,ZodVoid:it,ZodArray:H,ZodObject:E,ZodUnion:Ve,ZodDiscriminatedUnion:dt,ZodIntersection:De,ZodTuple:ee,ZodRecord:Ue,ZodMap:ot,ZodSet:_e,ZodFunction:Te,ZodLazy:ze,ZodLiteral:We,ZodEnum:le,ZodNativeEnum:Be,ZodPromise:Ce,ZodEffects:J,ZodTransformer:J,ZodOptional:Y,ZodNullable:fe,ZodDefault:qe,ZodCatch:He,ZodNaN:ct,BRAND:dn,ZodBranded:Pt,ZodPipeline:Ke,ZodReadonly:Je,custom:Sr,Schema:x,ZodSchema:x,late:un,get ZodFirstPartyTypeKind(){return y},coerce:Bn,any:vn,array:xn,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:kn,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()}),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=Mt(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 N,Ge,be,Ir,Nt;class Jn{constructor({auth:e,apiBaseAddress:t="https://public-api.animaapp.com"}={}){Xe(this,be);Xe(this,N);Xe(this,Ge);ft(this,Ge,t),e&&(this.auth=e)}hasAuth(){return!!P(this,N)}set auth(e){ft(this,N,e)}get headers(){const e={"Content-Type":"application/json"};return P(this,N)&&(e.Authorization=`Bearer ${P(this,N).token}`,"teamId"in P(this,N)&&(e["X-Team-Id"]=P(this,N).teamId)),e}generateCode(s){return C(this,arguments,function*(e,t={}){var o;const n=Or(e.settings);e.figmaToken&&(yield Ye(this,be,Ir).call(this,e.fileKey,e.figmaToken,e.nodesId,{allowAutoSelectFirstNode:(o=n.allowAutoSelectFirstNode)!=null?o:!0}));let a=e.tracking;P(this,N)&&"userId"in P(this,N)&&P(this,N).userId&&(a!=null&&a.externalId||(a={externalId:P(this,N).userId}));const i={tracking:a,fileKey:e.fileKey,figmaToken:e.figmaToken,nodesId:e.nodesId,assetsStorage:e.assetsStorage,language:n.language,model:n.model,framework:n.framework,styling:n.styling,uiLibrary:n.uiLibrary,enableTranslation:n.enableTranslation,enableUILibraryTheming:n.enableUILibraryTheming,enableCompactStructure:n.enableCompactStructure,enableAutoSplit:n.enableAutoSplit,autoSplitThreshold:n.autoSplitThreshold,disableMarkedForExport:n.disableMarkedForExport,allowAutoSelectFirstNode:n.allowAutoSelectFirstNode,enableDisplayScreenModelId:n.enableDisplayScreenModelId,enableGeneratePackageLock:n.enableGeneratePackageLock};return Ye(this,be,Nt).call(this,"/v1/codegen",i,t,"codegen")})}generateLink2Code(s){return C(this,arguments,function*(e,t={}){let n=e.tracking;P(this,N)&&"userId"in P(this,N)&&P(this,N).userId&&(n!=null&&n.externalId||(n={externalId:P(this,N).userId}));const a={tracking:n,assetsStorage:e.assetsStorage,params:e.params};return Ye(this,be,Nt).call(this,"/v1/l2c",a,t,"l2c")})}}N=new WeakMap,Ge=new WeakMap,be=new WeakSet,Ir=function(e,t,s,n){return C(this,null,function*(){let a;try{a=yield vr({fileKey:e,authToken:t,params:{geometry:"paths"}})}catch(c){return}const o=s.map(c=>Nr(a,c,n)).find(c=>!c.isValid);if(o)throw new se({name:"Task Crashed",reason:o.reason})})},Nt=function(e,t,s,n){return C(this,null,function*(){var f,v,O,R,L,W,te,he,oe;if(this.hasAuth()===!1)throw new Error('It needs to set "auth" before calling this method.');const a={},i=yield fetch(`${P(this,Ge)}${e}`,{method:"POST",headers:g(d({},this.headers),{Accept:"text/event-stream"}),body:JSON.stringify(t)});if(!i.ok){const Z=yield i.text();let M;try{M=JSON.parse(Z)}catch(Oe){}throw((f=M==null?void 0:M.error)==null?void 0:f.name)==="ZodError"?new se({name:"HTTP error from Anima API",reason:"Invalid body payload",detail:M.error.issues,status:i.status}):typeof M=="object"?new se({name:`Error "${M}"`,reason:"Unknown",status:i.status}):new se({name:"HTTP error from Anima API",reason:Z,status:i.status})}if(!i.body)throw new se({name:"Stream Error",reason:"Response body is null",status:i.status});const o=i.body.getReader(),c=new TextDecoder;let u="";try{for(;;){const{done:Z,value:M}=yield o.read();if(Z)break;u+=c.decode(M,{stream:!0});const Oe=u.split(`
2
2
  `);u=Oe.pop()||"";for(const we of Oe)if(!(!we.trim()||we.startsWith(":"))&&we.startsWith("data: ")){let b;try{b=JSON.parse(we.slice(6))}catch(ut){continue}switch(b.type){case"queueing":{typeof s=="function"?s(b):(v=s.onQueueing)==null||v.call(s);break}case"start":{a.sessionId=b.sessionId,typeof s=="function"?s(b):(O=s.onStart)==null||O.call(s,{sessionId:b.sessionId});break}case"pre_codegen":{n==="codegen"&&(typeof s=="function"?s(b):(R=s.onPreCodegen)==null||R.call(s,{message:b.message}));break}case"assets_uploaded":{typeof s=="function"?s(b):(L=s.onAssetsUploaded)==null||L.call(s);break}case"assets_list":{a.assets=b.payload.assets,typeof s=="function"?s(b):(W=s.onAssetsList)==null||W.call(s,b.payload);break}case"figma_metadata":{n==="codegen"&&(a.figmaFileName=b.figmaFileName,a.figmaSelectedFrameName=b.figmaSelectedFrameName,typeof s=="function"?s(b):(te=s.onFigmaMetadata)==null||te.call(s,{figmaFileName:b.figmaFileName,figmaSelectedFrameName:b.figmaSelectedFrameName}));break}case"generating_code":{b.payload.status==="success"&&(a.files=b.payload.files),typeof s=="function"?s(b):(he=s.onGeneratingCode)==null||he.call(s,{status:b.payload.status,progress:b.payload.progress,files:b.payload.files});break}case"codegen_completed":case"generation_completed":{typeof s=="function"?s(b):(oe=s.onCodegenCompleted)==null||oe.call(s);break}case"error":throw new se({name:b.payload.errorName,reason:b.payload.reason});case"done":{if(!a.files)throw new se({name:"Invalid response",reason:"No code generated"});return a.tokenUsage=b.payload.tokenUsage,a}}}}}finally{o.cancel()}throw new se({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 u=c.split("/").slice(0,-1).join("/");ta(r,u).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 C(this,null,function*(){var i,o,c,u;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"&&(u=(c=s.value.payload)==null?void 0:c.status)!=null?u:500,headers:{"Content-Type":"application/json"}});const n=new TextEncoder,a=t.pipeThrough(new TransformStream({transform(f,v){const O=`event: ${f.type}
3
3
  data: ${JSON.stringify(f)}
4
4