exodeui 6.0.9 → 6.0.10
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.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
`)return"hard-break"}return B===" "?"space":B===" "||B===" "||B===""||B==="\uFEFF"?"glue":B===""?"zero-width-break":B===""?"soft-hyphen":"text"}function dB(B,A,I,Q){const g=[];let C=null,E="",i=I,w=!1,o=0;for(const s of B){const h=HB(s,Q),a=h==="text"&&A;if(C!==null&&h===C&&a===w){E+=s,o+=s.length;continue}C!==null&&g.push({text:E,isWordLike:w,kind:C,start:i}),C=h,E=s,i=I+o,w=a,o+=s.length}return C!==null&&g.push({text:E,isWordLike:w,kind:C,start:i}),g}function KC(B){return B==="space"||B==="preserved-space"||B==="zero-width-break"||B==="hard-break"}const fB=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function bB(B,A){const I=B.texts[A];return I.startsWith("www.")?!0:fB.test(I)&&A+1<B.len&&B.kinds[A+1]==="text"&&B.texts[A+1]==="//"}function TB(B){return B.includes("?")&&(B.includes("://")||B.startsWith("www."))}function uB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),Q=B.kinds.slice(),g=B.starts.slice();for(let E=0;E<B.len;E++){if(Q[E]!=="text"||!bB(B,E))continue;let i=E+1;for(;i<B.len&&!KC(Q[i]);){A[E]+=A[i],I[E]=!0;const w=A[i].includes("?");if(Q[i]="text",A[i]="",i++,w)break}}let C=0;for(let E=0;E<A.length;E++){const i=A[E];i.length!==0&&(C!==E&&(A[C]=i,I[C]=I[E],Q[C]=Q[E],g[C]=g[E]),C++)}return A.length=C,I.length=C,Q.length=C,g.length=C,{len:C,texts:A,isWordLike:I,kinds:Q,starts:g}}function mB(B){const A=[],I=[],Q=[],g=[];for(let C=0;C<B.len;C++){const E=B.texts[C];if(A.push(E),I.push(B.isWordLike[C]),Q.push(B.kinds[C]),g.push(B.starts[C]),!TB(E))continue;const i=C+1;if(i>=B.len||KC(B.kinds[i]))continue;let w="";const o=B.starts[i];let s=i;for(;s<B.len&&!KC(B.kinds[s]);)w+=B.texts[s],s++;w.length>0&&(A.push(w),I.push(!0),Q.push("text"),g.push(o),C=s-1)}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}const xB=new Set([":","-","/","×",",",".","+","–","—"]),LQ=/^[A-Za-z0-9_]+[,:;]*$/,OB=/[,:;]+$/;function qQ(B){for(const A of B)if(YQ.test(A))return!0;return!1}function SC(B){if(B.length===0)return!1;for(const A of B)if(!(YQ.test(A)||xB.has(A)))return!1;return!0}function WB(B){const A=[],I=[],Q=[],g=[];for(let C=0;C<B.len;C++){const E=B.texts[C],i=B.kinds[C];if(i==="text"&&SC(E)&&qQ(E)){let w=E,o=C+1;for(;o<B.len&&B.kinds[o]==="text"&&SC(B.texts[o]);)w+=B.texts[o],o++;A.push(w),I.push(!0),Q.push("text"),g.push(B.starts[C]),C=o-1;continue}A.push(E),I.push(B.isWordLike[C]),Q.push(i),g.push(B.starts[C])}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}function ZB(B){const A=[],I=[],Q=[],g=[];for(let C=0;C<B.len;C++){const E=B.texts[C],i=B.kinds[C],w=B.isWordLike[C];if(i==="text"&&w&&LQ.test(E)){let o=E,s=C+1;for(;OB.test(o)&&s<B.len&&B.kinds[s]==="text"&&B.isWordLike[s]&&LQ.test(B.texts[s]);)o+=B.texts[s],s++;A.push(o),I.push(!0),Q.push("text"),g.push(B.starts[C]),C=s-1;continue}A.push(E),I.push(w),Q.push(i),g.push(B.starts[C])}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}function jB(B){const A=[],I=[],Q=[],g=[];for(let C=0;C<B.len;C++){const E=B.texts[C];if(B.kinds[C]==="text"&&E.includes("-")){const i=E.split("-");let w=i.length>1;for(let o=0;o<i.length;o++){const s=i[o];if(!w)break;(s.length===0||!qQ(s)||!SC(s))&&(w=!1)}if(w){let o=0;for(let s=0;s<i.length;s++){const h=i[s],a=s<i.length-1?`${h}-`:h;A.push(a),I.push(!0),Q.push("text"),g.push(B.starts[C]+o),o+=a.length}continue}}A.push(E),I.push(B.isWordLike[C]),Q.push(B.kinds[C]),g.push(B.starts[C])}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}function XB(B){const A=[],I=[],Q=[],g=[];let C=0;for(;C<B.len;){let E=B.texts[C],i=B.isWordLike[C],w=B.kinds[C],o=B.starts[C];if(w==="glue"){let s=E;const h=o;for(C++;C<B.len&&B.kinds[C]==="glue";)s+=B.texts[C],C++;if(C<B.len&&B.kinds[C]==="text")E=s+B.texts[C],i=B.isWordLike[C],w="text",o=h,C++;else{A.push(s),I.push(!1),Q.push("glue"),g.push(h);continue}}else C++;if(w==="text")for(;C<B.len&&B.kinds[C]==="glue";){let s="";for(;C<B.len&&B.kinds[C]==="glue";)s+=B.texts[C],C++;if(C<B.len&&B.kinds[C]==="text"){E+=s+B.texts[C],i=i||B.isWordLike[C],C++;continue}E+=s}A.push(E),I.push(i),Q.push(w),g.push(o)}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}function vB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),Q=B.kinds.slice(),g=B.starts.slice();for(let C=0;C<A.length-1;C++){if(Q[C]!=="text"||Q[C+1]!=="text"||!MI(A[C])||!MI(A[C+1]))continue;const E=nB(A[C]);E!==null&&(A[C]=E.head,A[C+1]=E.tail+A[C+1],g[C+1]=g[C]+E.head.length)}return{len:A.length,texts:A,isWordLike:I,kinds:Q,starts:g}}function PB(B,A,I){const Q=MB();let g=0;const C=[],E=[],i=[],w=[];for(const a of Q.segment(B))for(const G of dB(a.segment,a.isWordLike??!1,a.index,I)){const K=G.kind==="text";A.carryCJKAfterClosingQuote&&K&&g>0&&i[g-1]==="text"&&MI(G.text)&&MI(C[g-1])&&lQ(C[g-1])||K&&g>0&&i[g-1]==="text"&&rB(G.text)&&MI(C[g-1])||K&&g>0&&i[g-1]==="text"&&qB(C[g-1])?(C[g-1]+=G.text,E[g-1]=E[g-1]||G.isWordLike):K&&g>0&&i[g-1]==="text"&&G.isWordLike&&hC(G.text)&&LB(C[g-1])?(C[g-1]+=G.text,E[g-1]=!0):K&&!G.isWordLike&&g>0&&i[g-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&lB(C[g-1],G.text)||K&&!G.isWordLike&&g>0&&i[g-1]==="text"&&(eB(G.text)||G.text==="-"&&E[g-1])?C[g-1]+=G.text:(C[g]=G.text,E[g]=G.isWordLike,i[g]=G.kind,w[g]=G.start,g++)}for(let a=1;a<g;a++)i[a]==="text"&&!E[a]&&GC(C[a])&&i[a-1]==="text"&&(C[a-1]+=C[a],E[a-1]=E[a-1]||E[a],C[a]="");for(let a=g-2;a>=0;a--)if(i[a]==="text"&&!E[a]&&YB(C[a])){let G=a+1;for(;G<g&&C[G]==="";)G++;G<g&&i[G]==="text"&&(C[G]=C[a]+C[G],w[G]=w[a],C[a]="")}let o=0;for(let a=0;a<g;a++){const G=C[a];G.length!==0&&(o!==a&&(C[o]=G,E[o]=E[a],i[o]=i[a],w[o]=w[a]),o++)}C.length=o,E.length=o,i.length=o,w.length=o;const s=XB({len:o,texts:C,isWordLike:E,kinds:i,starts:w}),h=vB(ZB(jB(WB(mB(uB(s))))));for(let a=0;a<h.len-1;a++){const G=pB(h.texts[a]);G!==null&&(h.kinds[a]!=="space"&&h.kinds[a]!=="preserved-space"||h.kinds[a+1]!=="text"||!hC(h.texts[a+1])||(h.texts[a]=G.space,h.isWordLike[a]=!1,h.kinds[a]=h.kinds[a]==="preserved-space"?"preserved-space":"space",h.texts[a+1]=G.marks+h.texts[a+1],h.starts[a+1]=h.starts[a]+G.space.length))}return h}function VB(B,A){if(B.len===0)return[];if(!A.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}];const I=[];let Q=0;for(let g=0;g<B.len;g++)B.kinds[g]==="hard-break"&&(I.push({startSegmentIndex:Q,endSegmentIndex:g,consumedEndSegmentIndex:g+1}),Q=g+1);return Q<B.len&&I.push({startSegmentIndex:Q,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}),I}function zB(B,A,I="normal"){const Q=kB(I),g=Q.mode==="pre-wrap"?tB(B):yB(B);if(g.length===0)return{normalized:g,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const C=PB(g,A,Q);return{normalized:g,chunks:VB(C,Q),...C}}let lI=null;const pQ=new Map;let LI=null;const _B=new RegExp("\\p{Emoji_Presentation}","u"),$B=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let NC=null;const HQ=new Map;function kC(){if(lI!==null)return lI;if(typeof OffscreenCanvas<"u")return lI=new OffscreenCanvas(1,1).getContext("2d"),lI;if(typeof document<"u")return lI=document.createElement("canvas").getContext("2d"),lI;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function AE(B){let A=pQ.get(B);return A||(A=new Map,pQ.set(B,A)),A}function JI(B,A){let I=A.get(B);return I===void 0&&(I={width:kC().measureText(B).width,containsCJK:MI(B)},A.set(B,I)),I}function vI(){if(LI!==null)return LI;if(typeof navigator>"u")return LI={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},LI;const B=navigator.userAgent,I=navigator.vendor==="Apple Computer, Inc."&&B.includes("Safari/")&&!B.includes("Chrome/")&&!B.includes("Chromium/")&&!B.includes("CriOS/")&&!B.includes("FxiOS/")&&!B.includes("EdgiOS/"),Q=B.includes("Chrome/")||B.includes("Chromium/")||B.includes("CriOS/")||B.includes("Edg/");return LI={lineFitEpsilon:I?1/64:.005,carryCJKAfterClosingQuote:Q,preferPrefixWidthsForBreakableRuns:I,preferEarlySoftHyphenBreak:I},LI}function IE(B){const A=B.match(/(\d+(?:\.\d+)?)\s*px/);return A?parseFloat(A[1]):16}function yC(){return NC===null&&(NC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),NC}function gE(B){return _B.test(B)||B.includes("️")}function CE(B){return $B.test(B)}function QE(B,A){let I=HQ.get(B);if(I!==void 0)return I;const Q=kC();Q.font=B;const g=Q.measureText("😀").width;if(I=0,g>A+.5&&typeof document<"u"&&document.body!==null){const C=document.createElement("span");C.style.font=B,C.style.display="inline-block",C.style.visibility="hidden",C.style.position="absolute",C.textContent="😀",document.body.appendChild(C);const E=C.getBoundingClientRect().width;document.body.removeChild(C),g-E>.5&&(I=g-E)}return HQ.set(B,I),I}function BE(B){let A=0;const I=yC();for(const Q of I.segment(B))gE(Q.segment)&&A++;return A}function EE(B,A){return A.emojiCount===void 0&&(A.emojiCount=BE(B)),A.emojiCount}function cI(B,A,I){return I===0?A.width:A.width-EE(B,A)*I}function iE(B,A,I,Q){if(A.graphemeWidths!==void 0)return A.graphemeWidths;const g=[],C=yC();for(const E of C.segment(B)){const i=JI(E.segment,I);g.push(cI(E.segment,i,Q))}return A.graphemeWidths=g.length>1?g:null,A.graphemeWidths}function oE(B,A,I,Q){if(A.graphemePrefixWidths!==void 0)return A.graphemePrefixWidths;const g=[],C=yC();let E="";for(const i of C.segment(B)){E+=i.segment;const w=JI(E,I);g.push(cI(E,w,Q))}return A.graphemePrefixWidths=g.length>1?g:null,A.graphemePrefixWidths}function DE(B,A){const I=kC();I.font=B;const Q=AE(B),g=IE(B),C=A?QE(B,g):0;return{cache:Q,fontSize:g,emojiCorrection:C}}function kg(B){return B==="space"||B==="preserved-space"||B==="tab"||B==="zero-width-break"||B==="soft-hyphen"}function wE(B){return B==="space"}function sE(B,A){if(A<=0)return 0;const I=B%A;return Math.abs(I)<=1e-6?A:A-I}function tC(B,A,I,Q){return!Q||A===null?B[I]:A[I]-(I>0?A[I-1]:0)}function hE(B,A,I,Q,g,C){let E=0,i=A;for(;E<B.length;){const w=C?A+B[E]:i+B[E];if((E+1<B.length?w+g:w)>I+Q)break;i=w,E++}return{fitCount:E,fittedWidth:i}}function aE(B,A){return B.simpleLineWalkFastPath?GE(B,A):SE(B,A)}function GE(B,A){const{widths:I,kinds:Q,breakableWidths:g,breakablePrefixWidths:C}=B;if(I.length===0)return 0;const E=vI(),i=E.lineFitEpsilon;let w=0,o=0,s=!1;function h(a){const G=I[a];if(G>A&&g[a]!==null){const K=g[a],S=C[a]??null;o=0;for(let N=0;N<K.length;N++){const k=tC(K,S,N,E.preferPrefixWidthsForBreakableRuns);o>0&&o+k>A+i?(w++,o=k):(o===0&&w++,o+=k)}}else o=G,w++;s=!0}for(let a=0;a<I.length;a++){const G=I[a],K=Q[a];if(!s){h(a);continue}const S=o+G;if(S>A+i){if(wE(K))continue;o=0,s=!1,h(a);continue}o=S}return s?w:w+1}function KE(B,A,I){const{widths:Q,kinds:g,breakableWidths:C,breakablePrefixWidths:E}=B;if(Q.length===0)return 0;const i=vI(),w=i.lineFitEpsilon;let o=0,s=0,h=!1,a=0,G=0,K=-1,S=0;function N(){K=-1,S=0}function k(Y=a,l=G,O=s){o++,s=0,h=!1,N()}function t(Y,l){h=!0,a=Y+1,G=0,s=l}function J(Y,l,O){h=!0,a=Y,G=l+1,s=O}function R(Y,l){if(!h){t(Y,l);return}s+=l,a=Y+1,G=0}function e(Y,l){kg(g[Y])&&(K=Y+1,S=s-l)}function d(Y){p(Y,0)}function p(Y,l){const O=C[Y],z=E[Y]??null;for(let BA=l;BA<O.length;BA++){const AA=tC(O,z,BA,i.preferPrefixWidthsForBreakableRuns);if(!h){J(Y,BA,AA);continue}s+AA>A+w?(k(),J(Y,BA,AA)):(s+=AA,a=Y,G=BA+1)}h&&a===Y&&G===O.length&&(a=Y+1,G=0)}let c=0;for(;c<Q.length;){const Y=Q[c],l=g[c];if(!h){Y>A&&C[c]!==null?d(c):t(c,Y),e(c,Y),c++;continue}if(s+Y>A+w){if(kg(l)){R(c,Y),k(c+1,0,s-Y),c++;continue}if(K>=0){k(K,0,S);continue}if(Y>A&&C[c]!==null){k(),d(c),c++;continue}k();continue}R(c,Y),e(c,Y),c++}return h&&k(),o}function SE(B,A,I){if(B.simpleLineWalkFastPath)return KE(B,A);const{widths:Q,lineEndFitAdvances:g,lineEndPaintAdvances:C,kinds:E,breakableWidths:i,breakablePrefixWidths:w,discretionaryHyphenWidth:o,tabStopAdvance:s,chunks:h}=B;if(Q.length===0||h.length===0)return 0;const a=vI(),G=a.lineFitEpsilon;let K=0,S=0,N=!1,k=0,t=0,J=-1,R=0,e=0,d=null;function p(){J=-1,R=0,e=0,d=null}function c(f=k,m=t,x=S){K++,S=0,N=!1,p()}function Y(f,m){N=!0,k=f+1,t=0,S=m}function l(f,m,x){N=!0,k=f,t=m+1,S=x}function O(f,m){if(!N){Y(f,m);return}S+=m,k=f+1,t=0}function z(f,m){if(!kg(E[f]))return;const x=E[f]==="tab"?0:g[f],Z=E[f]==="tab"?m:C[f];J=f+1,R=S-m+x,e=S-m+Z,d=E[f]}function BA(f){AA(f,0)}function AA(f,m){const x=i[f],Z=w[f]??null;for(let U=m;U<x.length;U++){const r=tC(x,Z,U,a.preferPrefixWidthsForBreakableRuns);if(!N){l(f,U,r);continue}S+r>A+G?(c(),l(f,U,r)):(S+=r,k=f,t=U+1)}N&&k===f&&t===x.length&&(k=f+1,t=0)}function hA(f){if(d!=="soft-hyphen")return!1;const m=i[f];if(m===null)return!1;const x=a.preferPrefixWidthsForBreakableRuns?w[f]??m:m,Z=x!==m,{fitCount:U,fittedWidth:r}=hE(x,S,A,G,o,Z);return U===0?!1:(S=r,k=f,t=U,p(),U===m.length?(k=f+1,t=0,!0):(c(f,U,r+o),AA(f,U),!0))}function oA(f){K++,p()}for(let f=0;f<h.length;f++){const m=h[f];if(m.startSegmentIndex===m.endSegmentIndex){oA();continue}N=!1,S=0,m.startSegmentIndex,k=m.startSegmentIndex,t=0,p();let x=m.startSegmentIndex;for(;x<m.endSegmentIndex;){const Z=E[x],U=Z==="tab"?sE(S,s):Q[x];if(Z==="soft-hyphen"){N&&(k=x+1,t=0,J=x+1,R=S+o,e=S+o,d=Z),x++;continue}if(!N){U>A&&i[x]!==null?BA(x):Y(x,U),z(x,U),x++;continue}if(S+U>A+G){const b=S+(Z==="tab"?0:g[x]),L=S+(Z==="tab"?U:C[x]);if(d==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&R<=A+G){c(J,0,e);continue}if(d==="soft-hyphen"&&hA(x)){x++;continue}if(kg(Z)&&b<=A+G){O(x,U),c(x+1,0,L),x++;continue}if(J>=0&&R<=A+G){c(J,0,e);continue}if(U>A&&i[x]!==null){c(),BA(x),x++;continue}c();continue}O(x,U),z(x,U),x++}if(N){const Z=J===m.consumedEndSegmentIndex?e:S;c(m.consumedEndSegmentIndex,0,Z)}}return K}let FC=null;function NE(){return FC===null&&(FC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),FC}function kE(B){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function yE(B,A,I){const Q=NE(),g=vI(),{cache:C,emojiCorrection:E}=DE(A,CE(B.normalized)),i=cI("-",JI("-",C),E),o=cI(" ",JI(" ",C),E)*8;if(B.len===0)return kE();const s=[],h=[],a=[],G=[];let K=B.chunks.length<=1;const S=null,N=[],k=[],t=I?[]:null,J=Array.from({length:B.len}),R=Array.from({length:B.len});function e(c,Y,l,O,z,BA,AA,hA){z!=="text"&&z!=="space"&&z!=="zero-width-break"&&(K=!1),s.push(Y),h.push(l),a.push(O),G.push(z),N.push(AA),k.push(hA),t!==null&&t.push(c)}for(let c=0;c<B.len;c++){J[c]=s.length;const Y=B.texts[c],l=B.isWordLike[c],O=B.kinds[c],z=B.starts[c];if(O==="soft-hyphen"){e(Y,0,i,i,O,z,null,null),R[c]=s.length;continue}if(O==="hard-break"){e(Y,0,0,0,O,z,null,null),R[c]=s.length;continue}if(O==="tab"){e(Y,0,0,0,O,z,null,null),R[c]=s.length;continue}const BA=JI(Y,C);if(O==="text"&&BA.containsCJK){let f="",m=0;for(const x of Q.segment(Y)){const Z=x.segment;if(f.length===0){f=Z,m=x.index;continue}if(Ng.has(f)||nQ.has(Z)||XI.has(Z)||g.carryCJKAfterClosingQuote&&MI(Z)&&lQ(f)){f+=Z;continue}const U=JI(f,C),r=cI(f,U,E);e(f,r,r,r,"text",z+m,null,null),f=Z,m=x.index}if(f.length>0){const x=JI(f,C),Z=cI(f,x,E);e(f,Z,Z,Z,"text",z+m,null,null)}R[c]=s.length;continue}const AA=cI(Y,BA,E),hA=O==="space"||O==="preserved-space"||O==="zero-width-break"?0:AA,oA=O==="space"||O==="zero-width-break"?0:AA;if(l&&Y.length>1){const f=iE(Y,BA,C,E),m=g.preferPrefixWidthsForBreakableRuns?oE(Y,BA,C,E):null;e(Y,AA,hA,oA,O,z,f,m)}else e(Y,AA,hA,oA,O,z,null,null);R[c]=s.length}const d=tE(B.chunks,J,R),p=S===null?null:KB(B.normalized,S);return t!==null?{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:K,segLevels:p,breakableWidths:N,breakablePrefixWidths:k,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:d,segments:t}:{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:K,segLevels:p,breakableWidths:N,breakablePrefixWidths:k,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:d}}function tE(B,A,I){const Q=[];for(let g=0;g<B.length;g++){const C=B[g],E=C.startSegmentIndex<A.length?A[C.startSegmentIndex]:I[I.length-1]??0,i=C.endSegmentIndex<A.length?A[C.endSegmentIndex]:I[I.length-1]??0,w=C.consumedEndSegmentIndex<A.length?A[C.consumedEndSegmentIndex]:I[I.length-1]??0;Q.push({startSegmentIndex:E,endSegmentIndex:i,consumedEndSegmentIndex:w})}return Q}function FE(B,A,I,Q){const g=zB(B,vI(),Q==null?void 0:Q.whiteSpace);return yE(g,A,I)}function ME(B,A,I){return FE(B,A,!1,I)}function ii(B){return B}function JE(B,A,I){const Q=aE(B,A);return{lineCount:Q,height:Q*I}}const dQ=B=>B,cE=B=>B>0?1:0,RE=B=>B<1?0:1,fQ=B=>B*B,bQ=B=>B*(2-B),TQ=B=>B<.5?2*B*B:-1+(4-2*B)*B,UE=B=>B*B*B,eE=B=>--B*B*B+1,rE=B=>B<.5?4*B*B*B:(B-1)*(2*B-2)*(2*B-2)+1,YE=B=>B*B*B*B,nE=B=>1- --B*B*B*B,lE=B=>B<.5?8*B*B*B*B:1-8*--B*B*B*B,LE=B=>B*B*B*B*B,qE=B=>1+--B*B*B*B*B,pE=B=>B<.5?16*B*B*B*B*B:1+16*--B*B*B*B*B,HE=B=>1-Math.cos(B*Math.PI/2),dE=B=>Math.sin(B*Math.PI/2),fE=B=>-(Math.cos(Math.PI*B)-1)/2,bE=B=>B===0?0:Math.pow(2,10*(B-1)),TE=B=>B===1?1:1-Math.pow(2,-10*B),uE=B=>B===0?0:B===1?1:B<.5?Math.pow(2,20*B-10)/2:(2-Math.pow(2,-20*B+10))/2,mE=B=>1-Math.sqrt(1-B*B),xE=B=>Math.sqrt(1- --B*B),OE=B=>B<.5?(1-Math.sqrt(1-4*B*B))/2:(Math.sqrt(1-(-2*B+2)*(-2*B+2))+1)/2,yg=1.70158,tg=yg*1.525,uQ=yg+1,WE=B=>uQ*B*B*B-yg*B*B,ZE=B=>1+uQ*Math.pow(B-1,3)+yg*Math.pow(B-1,2),jE=B=>B<.5?Math.pow(2*B,2)*((tg+1)*2*B-tg)/2:(Math.pow(2*B-2,2)*((tg+1)*(B*2-2)+tg)+2)/2,mQ=2*Math.PI/3,xQ=2*Math.PI/4.5,XE=B=>B===0?0:B===1?1:-Math.pow(2,10*B-10)*Math.sin((B*10-10.75)*mQ),vE=B=>B===0?0:B===1?1:Math.pow(2,-10*B)*Math.sin((B*10-.75)*mQ)+1,PE=B=>B===0?0:B===1?1:B<.5?-(Math.pow(2,20*B-10)*Math.sin((20*B-11.125)*xQ))/2:Math.pow(2,-20*B+10)*Math.sin((20*B-11.125)*xQ)/2+1,Fg=B=>B<1/2.75?7.5625*B*B:B<2/2.75?7.5625*(B-=1.5/2.75)*B+.75:B<2.5/2.75?7.5625*(B-=2.25/2.75)*B+.9375:7.5625*(B-=2.625/2.75)*B+.984375,VE=B=>1-Fg(1-B),zE=Fg,_E=B=>B<.5?(1-Fg(1-2*B))/2:(1+Fg(2*B-1))/2,MC=new Map,PI=(B,A,I,Q)=>{const g=`${B},${A},${I},${Q}`;if(MC.has(g))return MC.get(g);const C=s=>(1-3*I+3*B)*s*s*s+(3*I-6*B)*s*s+3*B*s,E=s=>(1-3*Q+3*A)*s*s*s+(3*Q-6*A)*s*s+3*A*s,i=s=>3*(1-3*I+3*B)*s*s+2*(3*I-6*B)*s+3*B,w=s=>{let h=s;for(let a=0;a<8;a++){const G=C(h)-s;if(Math.abs(G)<1e-6)return h;const K=i(h);if(Math.abs(K)<1e-6)break;h=h-G/K}return h},o=s=>s===0?0:s===1?1:E(w(s));return MC.set(g,o),o},OQ=B=>{const A=B.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!A)return null;const[,I,Q,g,C]=A.map(Number);return PI(I,Q,g,C)},WQ={ease:PI(.25,.1,.25,1),"ease-in":PI(.42,0,1,1),"ease-out":PI(0,0,.58,1),"ease-in-out":PI(.42,0,.58,1)},Mg={Linear:dQ,EaseInQuad:fQ,EaseOutQuad:bQ,EaseInOutQuad:TQ,EaseInCubic:UE,EaseOutCubic:eE,EaseInOutCubic:rE,EaseInQuart:YE,EaseOutQuart:nE,EaseInOutQuart:lE,EaseInQuint:LE,EaseOutQuint:qE,EaseInOutQuint:pE,EaseInSine:HE,EaseOutSine:dE,EaseInOutSine:fE,EaseInExpo:bE,EaseOutExpo:TE,EaseInOutExpo:uE,EaseInCirc:mE,EaseOutCirc:xE,EaseInOutCirc:OE,EaseInBack:WE,EaseOutBack:ZE,EaseInOutBack:jE,EaseInElastic:XE,EaseOutElastic:vE,EaseInOutElastic:PE,EaseInBounce:VE,EaseOutBounce:zE,EaseInOutBounce:_E,EaseIn:fQ,EaseOut:bQ,EaseInOut:TQ,StepStart:cE,StepEnd:RE},$E=B=>{const A=B.trim(),I=A.toLowerCase();if(Mg[A])return Mg[A];const Q=Object.keys(Mg).find(C=>C.toLowerCase()===I);if(Q)return Mg[Q];const g=Object.keys(ZQ).find(C=>C.toLowerCase()===I);if(g){const C=OQ(ZQ[g].value);if(C)return C}if(WQ[I])return WQ[I];if(I.startsWith("cubic-bezier")){const C=OQ(A);if(C)return C}return dQ},ZQ={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}};class jQ{constructor(){gA(this,"artboard",null);gA(this,"objectStates",new Map);gA(this,"physicsEngine",null);gA(this,"activeStateMachine",null);gA(this,"inputs",new Map);gA(this,"inputNameMap",new Map);gA(this,"layerStates",new Map);gA(this,"pretextCache",new Map);gA(this,"pointerHistory",[]);gA(this,"MAX_HISTORY",200);gA(this,"imageCache",new Map);gA(this,"shadowBuffer",null);gA(this,"maskBuffer",null);gA(this,"maskCtx",null);gA(this,"lumaBuffer",null);gA(this,"lumaCtx",null);gA(this,"layout",{fit:"Contain",alignment:"Center"});gA(this,"onTrigger");gA(this,"onInputUpdate");gA(this,"onComponentChange");gA(this,"onToggle");gA(this,"onInputChange");gA(this,"onInputFocus");gA(this,"onInputBlur");gA(this,"justFiredTriggers",new Set);gA(this,"rootTransform",null);gA(this,"canvasWidth",0);gA(this,"canvasHeight",0);gA(this,"lastHoveredObjectId",null);gA(this,"_lastPointerPos",null);gA(this,"_prevPointerPos",null);gA(this,"focusedId",null);gA(this,"draggingSliderId",null);gA(this,"activeDropdownId",null);gA(this,"draggingListViewId",null);gA(this,"scrollOffset",{x:0,y:0});gA(this,"draggingBehaviors",new Set);gA(this,"objectVelocities",new Map);gA(this,"currentTime",0);gA(this,"frameCount",0);gA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});gA(this,"activeTriggers",new Map)}setTriggerCallback(A){this.onTrigger=A}setInputUpdateCallback(A){this.onInputUpdate=A}setComponentChangeCallback(A){this.onComponentChange=A}setToggleCallback(A){this.onToggle=A}setInputChangeCallback(A){this.onInputChange=A}setInputFocusCallback(A){this.onInputFocus=A}setInputBlurCallback(A){this.onInputBlur=A}updateConstraint(A,I,Q){var C;const g=(C=this.artboard)==null?void 0:C.objects.find(E=>E.id===A);g&&g.constraints&&g.constraints[I]&&(g.constraints[I]={...g.constraints[I],...Q},Q.useSpring===!1&&this.objectVelocities.delete(A))}setInternalInput(A,I){this.inputs.set(A,I),this.onInputUpdate&&this.onInputUpdate(A,I)}setLayout(A,I){this.layout={fit:A,alignment:I}}getActiveStateIds(A="Base Layer"){const I=this.layerStates.get(A);return I?I.currentStateIds:[]}getObjectState(A){return this.objectStates.get(A)}updateObjectOptions(A,I){const Q=this.objectStates.get(A);Q&&(Q.options={...Q.options,...I})}updateGraphData(A,I){if(!this.artboard)return;const Q=this.artboard.objects.find(g=>g.id===A||g.name===A);if(Q&&Q.geometry.type==="LineGraph"){const g=Q.geometry;!g.datasets||g.datasets.length===0?g.datasets=[{id:"default",label:"Runtime Data",data:I,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:g.datasets[0].data=I;const C=this.objectStates.get(Q.id);C&&C.geometry&&C.geometry.type==="LineGraph"&&(!C.geometry.datasets||C.geometry.datasets.length===0?C.geometry.datasets=JSON.parse(JSON.stringify(g.datasets)):C.geometry.datasets[0].data=[...I]),g.datasets[0].inputId&&this.updateInput(g.datasets[0].inputId,I)}else this.updateInput(A,I)}load(A){this.artboard=A,this.currentTime=0,this.loadFonts(),this.reset(),this.advance(0)}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this.artboard.objects.forEach(I=>{const Q=I.width??I.geometry.width??0,g=I.height??I.geometry.height??0,C=I.cornerRadius??I.corner_radius??I.geometry.corner_radius??I.geometry.cornerRadius??0;this.objectStates.set(I.id,{...I.transform,width:Q,height:g,cornerRadius:C,corner_radius:C,clipContent:I.clipContent??!1,autoLayout:I.autoLayout?JSON.parse(JSON.stringify(I.autoLayout)):void 0,layoutProps:I.layoutProps?JSON.parse(JSON.stringify(I.layoutProps)):void 0,opacity:I.opacity!==void 0?I.opacity:100,visible:I.visible!==void 0?I.visible:I.isVisible!==void 0?I.isVisible:!0,blendMode:I.blendMode||"Normal",style:JSON.parse(JSON.stringify(I.style||{})),geometry:JSON.parse(JSON.stringify(I.geometry||{})),options:I.options?JSON.parse(JSON.stringify(I.options)):{},masks:I.masks?JSON.parse(JSON.stringify(I.masks)):[]})}),this.artboard.objects.some(I=>{var Q;return(Q=I.physics)==null?void 0:Q.enabled})){this.physicsEngine=new wB;const I=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(I).then(()=>{var Q;this.physicsEngine&&((Q=this.artboard)==null||Q.objects.forEach(g=>{var C;if((C=g.physics)!=null&&C.enabled&&g.type==="Shape"){const E=this.objectStates.get(g.id);if(!E)return;const i=g.geometry.width||100,w=g.geometry.height||100;this.physicsEngine.createBody({id:g.id,type:g.geometry.type,x:E.x,y:E.y,width:i,height:w,rotation:E.rotation*(Math.PI/180),isStatic:g.physics.bodyType==="Static",mass:g.physics.mass,friction:g.physics.friction,restitution:g.physics.restitution,frictionAir:g.physics.frictionAir,density:g.physics.density,isSensor:g.physics.isSensor})}}))})}if(this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(I=>{this.inputs.set(I.id,I.value.value);const Q=this.inputNameMap.get(I.name)||[];Q.push(I.id),this.inputNameMap.set(I.name,Q)}),this.activeStateMachine.layers.forEach(I=>{const Q=I.states.find(g=>g.id===I.entryStateId);Q&&this.enterStates(I.name,[Q.id])}),this.evaluateTransitions()),!this.artboard.stateMachine&&this.artboard.animations.length>0){const I=this.artboard.animations.find(Q=>Q.name==="onLoad");I&&this.layerStates.set("intro",{currentStateIds:["onLoad"],animations:[{animation:I,state:{loop:!0}}],time:0,duration:I.duration})}this.updateAutoLayout(),this.loadFonts()}updateAutoLayout(){var I;if(!this.artboard)return;const A=new Map;if(this.artboard.objects.forEach(Q=>A.set(Q.id,Q)),(I=this.artboard.autoLayout)!=null&&I.enabled){const Q=this.artboard.objects.filter(C=>!C.parentId);RC(this.artboard,Q,C=>this.objectStates.get(C)).childUpdates.forEach(C=>{const E=this.objectStates.get(C.id);E&&(E.x=C.x,E.y=C.y,C.width!==void 0&&(E.width=C.width),C.height!==void 0&&(E.height=C.height))})}this.artboard.objects.forEach(Q=>{var g;if(Q.type==="Frame"&&((g=Q.autoLayout)!=null&&g.enabled)&&Q.children&&Q.children.length>0){const C=Q.children.map(w=>A.get(w)).filter(w=>!!w),E=this.objectStates.get(Q.id);if(!E)return;const i=RC(E,C,w=>this.objectStates.get(w));i.frameWidth!==void 0&&(E.width=i.frameWidth),i.frameHeight!==void 0&&(E.height=i.frameHeight),i.childUpdates.forEach(w=>{const o=this.objectStates.get(w.id);o&&(o.x=w.x,o.y=w.y,w.width!==void 0&&(o.width=w.width),w.height!==void 0&&(o.height=w.height))})}})}loadFonts(){if(!this.artboard)return;const A=new Set;if(this.artboard.objects.forEach(E=>{E.geometry&&E.geometry.type==="Text"&&E.geometry.fontFamily&&A.add(E.geometry.fontFamily)}),this.artboard.animations.forEach(E=>{E.tracks.forEach(i=>{(i.property==="geometry.fontFamily"||i.property==="fontFamily")&&i.keyframes.forEach(w=>{w.value&&typeof w.value=="string"&&A.add(w.value)})})}),A.size===0)return;let I="";A.forEach(E=>{const i=E.replace(/ /g,"+");I+=`&family=${i}:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900`});const Q="exodeui-google-fonts",g="exodeui-fontshare-fonts";if(I.length>0){const E=`https://fonts.googleapis.com/css2?display=swap${I}`;let i=document.getElementById(Q);i||(i=document.createElement("link"),i.id=Q,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}const C=[];if(A.forEach(E=>{E.toLowerCase().includes("clash display")&&C.push("clash-display@200,300,400,500,600,700")}),C.length>0){const E=`https://api.fontshare.com/v2/css?f[]=${C.join("&f[]=")}&display=swap`;let i=document.getElementById(g);i||(i=document.createElement("link"),i.id=g,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(A,I){if(I.length===0)return;const Q=this.layerStates.get(A);if(Q&&Q.currentStateIds.length===I.length&&I.every(i=>Q.currentStateIds.includes(i))&&this.justFiredTriggers.size===0)return;const g=[];let C=0;if(this.artboard&&this.activeStateMachine){const E=this.activeStateMachine.layers.find(i=>i.name===A);if(E)for(const i of I){const w=E.states.find(o=>o.id===i);if(w){let o=null;w.animationId&&(o=this.artboard.animations.find(s=>s.id===w.animationId)||null),o||(o=this.artboard.animations.find(s=>s.name===w.name||s.id===w.name||w.name==="Entry"&&s.name==="Rotate")||null),o&&(g.push({animation:o,state:w}),C=Math.max(C,o.duration))}}}this.layerStates.set(A,{currentStateIds:I,animations:g,time:0,duration:C})}setInputBool(A,I){this.updateInput(A,I)}setInputNumber(A,I){this.updateInput(A,I)}fireTrigger(A){this.updateInput(A,!0)}setInputText(A,I){this.updateInput(A,I)}setInputNumberArray(A,I){this.updateInput(A,I)}setInputStringArray(A,I){this.updateInput(A,I)}updateInput(A,I){var E,i,w;let Q;if(this.inputs.has(A)){const o=(E=this.activeStateMachine)==null?void 0:E.inputs.find(s=>s.id===A);o&&typeof o.value=="object"&&(Q=o.value.type)}else{const o=this.inputNameMap.get(A);if(o&&o.length>0){const s=(i=this.activeStateMachine)==null?void 0:i.inputs.find(h=>h.id===o[0]);s&&typeof s.value=="object"&&(Q=s.value.type)}}let g=I;Q==="Trigger"&&(I===1?g=!0:I===0&&(g=!1)),this.inputs.has(A)&&this.setInternalInput(A,g);const C=this.inputNameMap.get(A);C&&C.forEach(o=>this.setInternalInput(o,g)),Q==="Trigger"&&g===!0&&(this.justFiredTriggers.add(A),C&&C.forEach(o=>this.justFiredTriggers.add(o))),Array.isArray(g)&&((w=this.artboard)==null||w.objects.forEach(o=>{if(o.inputId===A||o.name===A){const s=this.objectStates.get(o.id);s&&s.options&&(o.type==="ListView"||o.variant==="listview"?s.options.items=g:(o.type==="Dropdown"||o.variant==="dropdown")&&(s.options.optionsList=g))}})),this.evaluateTransitions()}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(A=>{const I=this.layerStates.get(A.name);if(!I||I.currentStateIds.length===0)return;const Q=[];let g=!1;for(const C of I.currentStateIds){const E=A.states.find(w=>w.id===C);if(!E)continue;let i=!1;for(const w of E.transitions)this.checkConditions(w.conditions)&&(Q.push(w.targetStateId),i=!0,g=!0,w.conditions&&w.conditions.forEach(o=>{var h;const s=(h=this.activeStateMachine)==null?void 0:h.inputs.find(a=>a.id===o.inputId);if(s&&typeof s.value=="object"&&s.value.type==="Number"&&(this.setInternalInput(o.inputId,0),this.inputNameMap.has(s.name))){const a=this.inputNameMap.get(s.name);a==null||a.forEach(G=>this.setInternalInput(G,0))}}));i||Q.push(C)}if(!g){const C=this.findGlobalTransition(A,I.currentStateIds);C&&(Q.length=0,Q.push(C.targetStateId),g=!0,C.conditions&&C.conditions.forEach(E=>{var w;const i=(w=this.activeStateMachine)==null?void 0:w.inputs.find(o=>o.id===E.inputId);if(i&&typeof i.value=="object"&&i.value.type==="Number"&&(this.setInternalInput(E.inputId,0),this.inputNameMap.has(i.name))){const o=this.inputNameMap.get(i.name);o==null||o.forEach(s=>this.setInternalInput(s,0))}}))}if(g){const C=Array.from(new Set(Q));this.enterStates(A.name,C)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(A=>{var Q,g;this.setInternalInput(A,!1);const I=(Q=this.activeStateMachine)==null?void 0:Q.inputs.find(C=>C.id===A);I&&this.inputNameMap.has(I.name)&&((g=this.inputNameMap.get(I.name))==null||g.forEach(C=>this.setInternalInput(C,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(A,I){for(const Q of A.states)if(!(I.includes(Q.id)&&this.justFiredTriggers.size===0)){for(const C of Q.transitions)if(!(I.includes(C.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(C.conditions))return C}return null}checkConditions(A){return!A||A.length===0?!0:A.every(I=>{const Q=I.inputId,g=I.op,C=I.value,E=this.evaluateLogicTree(Q);if(E===void 0)return console.log(`[Engine] Condition Check Failed: Input ${Q} is undefined`),!1;let i=!1;switch(g){case"Equal":i=E==C;break;case"NotEqual":i=E!=C;break;case"GreaterThan":i=E>C;break;case"LessThan":i=E<C;break;case"GreaterEqual":i=E>=C;break;case"LessEqual":i=E<=C;break;case"IsTrue":i=E===!0;break;case"IsFalse":i=E===!1;break;default:i=!1}return i||this.justFiredTriggers.has(Q),i})}evaluateLogicTree(A,I,Q=new Set){var E,i,w;if(Q.has(A))return!1;Q.add(A);const g=(i=(E=this.activeStateMachine)==null?void 0:E.logicNodes)==null?void 0:i.find(o=>o.id===A);if(g){const o=(s,h)=>{const a=g.inputs.find(G=>G.id===s);return a?a.sourceId?this.evaluateLogicTree(a.sourceId,a.sourceHandleId,Q):a.value!==void 0?a.value:h:h};switch(g.op){case UI.AND:return o("a",!1)&&o("b",!1);case UI.OR:return o("a",!1)||o("b",!1);case UI.NOT:return!o("in",!1);case UI.XOR:return!!o("a",!1)!=!!o("b",!1);default:return 0}}let C=this.inputs.get(A);if(this.justFiredTriggers.has(A)&&(C=!0),I&&C!==void 0){const o=(w=this.activeStateMachine)==null?void 0:w.inputs.find(s=>s.id===A);if(o&&o.value.type==="Number"&&typeof C=="number"){const s=o.value.defaultValue??o.value.value;if(I==="source-greater")return C>s;if(I==="source-less")return C<s;if(I==="source-equal")return C===s}if(I==="source-true")return C===!0;if(I==="source-false")return C===!1;if(I==="source-fire")return this.justFiredTriggers.has(A)}return C!==void 0?C:0}advance(A){this.artboard&&(this.currentTime+=A,this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(A),this.artboard.objects.forEach(I=>{var Q;if((Q=I.physics)!=null&&Q.enabled){const g=this.physicsEngine.getPosition(I.id),C=this.physicsEngine.getRotation(I.id),E=this.objectStates.get(I.id);E&&g!==null&&C!==null&&(E.x=g.x,E.y=g.y,E.rotation=C*(180/Math.PI))}})),this.updateAutoLayout(),this.activeStateMachine&&(this.evaluateTransitions(),this.layerStates.forEach(I=>{I.animations.length>0&&(I.time+=A,I.time>I.duration&&(I.animations.some(g=>{var C;return((C=g.state)==null?void 0:C.loop)===!0})?I.time%=I.duration:I.time=I.duration),I.animations.forEach(Q=>{this.applyAnimation(Q.animation,I.time)}))})),this.solveConstraints(A),this.solveBehaviors(A),this.activeTriggers.forEach((I,Q)=>{var g,C,E,i,w,o,s;if(I.phase==="entry")I.time+=A,I.time>=I.animation.duration&&((E=(C=(g=this.artboard)==null?void 0:g.objects.find(h=>h.id===Q))==null?void 0:C.triggers)==null||E.find(h=>h.id===I.triggerId),I.phase="hold",I.elapsedHold=0,I.time=I.animation.duration),this.applyAnimation(I.animation,I.time);else if(I.phase==="hold"){const h=(o=(w=(i=this.artboard)==null?void 0:i.objects.find(G=>G.id===Q))==null?void 0:w.triggers)==null?void 0:o.find(G=>G.id===I.triggerId),a=(h==null?void 0:h.duration)||0;if(I.elapsedHold+=A*1e3,I.elapsedHold>=a)if(h!=null&&h.exitAnimationId){const G=(s=this.artboard)==null?void 0:s.animations.find(K=>K.id===h.exitAnimationId);G?(I.phase="exit",I.animation=G,I.time=0):this.activeTriggers.delete(Q)}else this.activeTriggers.delete(Q)}else I.phase==="exit"&&(I.time+=A,I.time>=I.animation.duration?this.activeTriggers.delete(Q):this.applyAnimation(I.animation,I.time))}))}solveConstraints(A){this.artboard&&this.artboard.objects.forEach(I=>{if(!I.constraints||I.constraints.length===0)return;const Q=this.objectStates.get(I.id);if(!Q)return;const g=this.getGlobalTransform(I.id);if(I.constraints.forEach(C=>{var i,w,o,s,h,a,G;const E=C.strength??1;if(C.type==="Translation"){const K=this.getGlobalTransform(C.targetId);if(K){if(C.useSpring){const N=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:k,y:t,vx:J,vy:R}=this.computeSpring(g.x,g.y,N.vx,N.vy,K.x,K.y,C,A);C.copyX&&(g.x=k),C.copyY&&(g.y=t),this.objectVelocities.set(I.id,{vx:J,vy:R})}else C.copyX&&(g.x=g.x+(K.x-g.x)*E),C.copyY&&(g.y=g.y+(K.y-g.y)*E);(i=C.limitX)!=null&&i.enabled&&(g.x=Math.max(C.limitX.min,Math.min(C.limitX.max,g.x))),(w=C.limitY)!=null&&w.enabled&&(g.y=Math.max(C.limitY.min,Math.min(C.limitY.max,g.y)))}}else if(C.type==="Rotation"){const K=this.getGlobalTransform(C.targetId);if(K){let N=(K.rotation+(C.offset||0)-g.rotation)%360;N>180&&(N-=360),N<-180&&(N+=360),g.rotation=g.rotation+N*E}}else if(C.type==="Scale"){const K=this.getGlobalTransform(C.targetId);K&&(C.copyX&&(g.scale_x=g.scale_x+(K.scale_x-g.scale_x)*E),C.copyY&&(g.scale_y=g.scale_y+(K.scale_y-g.scale_y)*E))}else if(C.type==="Transform"){const K=this.getGlobalTransform(C.targetId);if(K){g.x=g.x+(K.x-g.x)*E,g.y=g.y+(K.y-g.y)*E;let S=(K.rotation-g.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),g.rotation=g.rotation+S*E,g.scale_x=g.scale_x+(K.scale_x-g.scale_x)*E,g.scale_y=g.scale_y+(K.scale_y-g.scale_y)*E}}else if(C.type==="FollowPointer"){const K=((o=this._lastPointerPos)==null?void 0:o.x)??g.x,S=((s=this._lastPointerPos)==null?void 0:s.y)??g.y;if(C.useSpring){const k=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:t,y:J,vx:R,vy:e}=this.computeSpring(g.x,g.y,k.vx,k.vy,K,S,C,A);g.x=t,g.y=J,this.objectVelocities.set(I.id,{vx:R,vy:e})}else g.x=g.x+(K-g.x)*E,g.y=g.y+(S-g.y)*E;(h=C.limitX)!=null&&h.enabled&&(g.x=Math.max(C.limitX.min,Math.min(C.limitX.max,g.x))),(a=C.limitY)!=null&&a.enabled&&(g.y=Math.max(C.limitY.min,Math.min(C.limitY.max,g.y)))}else if(C.type==="Distance"){const K=this.getGlobalTransform(C.targetId);if(K){const S=g.x-K.x,N=g.y-K.y,k=Math.sqrt(S*S+N*N),t=C.distance||0;let J=k;switch(C.mode){case"exact":J=t;break;case"minimum":J=Math.max(t,k);break;case"maximum":J=Math.min(t,k);break;case"clamped":J=Math.max(0,Math.min(t,k));break}if(k>0){const R=g.x===K.x&&g.y===K.y?1:J/k;g.x=g.x+(K.x+S*R-g.x)*E,g.y=g.y+(K.y+N*R-g.y)*E}}}else if(C.type==="FollowPath"){const K=(G=this.artboard)==null?void 0:G.objects.find(S=>S.id===C.targetId);if(K){const S=this.getGlobalTransform(K.id);if(S){const N=(C.distance||0)/100,k=S.width||K.geometry.width||0,t=S.height||K.geometry.height||0,J=this.getPointOnPath(K.geometry,k,t,N),R=S.rotation*Math.PI/180,e=Math.cos(R),d=Math.sin(R),p=J.x*S.scale_x*e-J.y*S.scale_y*d,c=J.x*S.scale_x*d+J.y*S.scale_y*e,Y=S.x+p+(C.offsetX||0),l=S.y+c+(C.offsetY||0);if(g.x=g.x+(Y-g.x)*E,g.y=g.y+(l-g.y)*E,C.orient){let z=(J.angle*180/Math.PI+S.rotation+(C.offsetRotation||0)-g.rotation)%360;z>180&&(z-=360),z<-180&&(z+=360),g.rotation=g.rotation+z*E}}}}else if(C.type==="IK"){const K=this.getGlobalTransform(C.targetId);K&&this.solveIK(I,K,C.boneCount||2,E)}}),I.constraints.some(C=>C.type!=="IK")){const C=this.globalToLocal(I.parentId,g);Q.x=C.x,Q.y=C.y,Q.rotation=C.rotation,Q.scale_x=C.scale_x,Q.scale_y=C.scale_y}})}getGlobalTransform(A){var s;const I=this.objectStates.get(A);if(!I)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const Q=(s=this.artboard)==null?void 0:s.objects.find(h=>h.id===A);if(!Q||!Q.parentId)return{x:I.x,y:I.y,rotation:I.rotation,scale_x:I.scale_x??1,scale_y:I.scale_y??1};const g=this.getGlobalTransform(Q.parentId),C=g.rotation*Math.PI/180,E=Math.cos(C),i=Math.sin(C),w=g.x+(I.x*g.scale_x*E-I.y*g.scale_y*i),o=g.y+(I.x*g.scale_x*i+I.y*g.scale_y*E);return{x:w,y:o,rotation:g.rotation+I.rotation,scale_x:g.scale_x*(I.scale_x??1),scale_y:g.scale_y*(I.scale_y??1)}}globalToLocal(A,I){if(!A)return I;const Q=this.getGlobalTransform(A),g=Q.scale_x===0?0:1/Q.scale_x,C=Q.scale_y===0?0:1/Q.scale_y,E=-Q.rotation*Math.PI/180,i=Math.cos(E),w=Math.sin(E),o=I.x-Q.x,s=I.y-Q.y,h=(o*i-s*w)*g,a=(o*w+s*i)*C;return{x:h,y:a,rotation:I.rotation-Q.rotation,scale_x:I.scale_x/(Q.scale_x||1),scale_y:I.scale_y/(Q.scale_y||1)}}solveIK(A,I,Q,g){var o;const C=[];let E=A.id;for(let s=0;s<Q&&E;s++){const h=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===E);if(!h)break;C.push({id:E,local:this.objectStates.get(E),global:this.getGlobalTransform(E)}),E=h.parentId}if(C.length<2)return;const i=C.reverse(),w=5;for(let s=0;s<w;s++){const h=this.getGlobalTransform(A.id);for(let a=i.length-2;a>=0;a--){const G=i[a],K=this.getGlobalTransform(G.id),S=h.x-K.x,N=h.y-K.y,k=I.x-K.x,t=I.y-K.y,J=Math.sqrt(S*S+N*N),R=Math.sqrt(k*k+t*t);if(J>.001&&R>.001){const e=Math.atan2(N,S);let p=(Math.atan2(t,k)-e)*180/Math.PI;p*=g;const c=this.objectStates.get(G.id);c&&(c.rotation+=p)}}}}computeSpring(A,I,Q,g,C,E,i,w){const o=i.stiffness??100,s=i.damping??10,h=i.mass??1,a=-o*(A-C),G=-o*(I-E),K=-s*Q,S=-s*g,N=(a+K)/h,k=(G+S)/h,t=Q+N*w,J=g+k*w,R=A+t*w,e=I+J*w;return{x:R,y:e,vx:t,vy:J}}handlePointerInput(A,I,Q,g,C){if(!this.artboard)return;const E=this.calculateTransform(g,C,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),i=(I-E.tx)/E.scaleX-this.artboard.width/2,w=(Q-E.ty)/E.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:i,y:w},this.updateInput("mouseX",i),this.updateInput("mouseY",w),this.handlePointerEvent(A,i,w)}handleScroll(A,I){this.scrollOffset={x:A,y:I}}handlePointerEvent(A,I,Q){var w,o,s,h,a;if(!this.artboard)return;let g=null;const C=(G,K)=>{var R;let S=K;K==="click"?S="onClick":K==="down"?S="onPointerDown":K==="up"?S="onPointerUp":K==="blur"&&(S="onPointerLeave");const N=new Set([S]);K==="move"&&N.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),S==="onClick"&&N.add("click"),S==="onPointerDown"&&N.add("pointerDown"),S==="onPointerUp"&&N.add("pointerUp");const k=["button","toggle","toggle_button","dropdown","listview","inputbox","slider"];return!!(G.type==="Component"&&k.includes(G.variant)||k.includes((R=G.type)==null?void 0:R.toLowerCase())||(G.interactions||[]).some(e=>N.has(e.event))||(G.triggers||[]).some(e=>N.has(e.eventType)))};let E=null;for(let G=this.artboard.objects.length-1;G>=0;G--){const K=this.artboard.objects[G],S=this.objectStates.get(K.id);if(S&&S.visible!==!1&&S.opacity>0&&this.hitTest(K,I,Q)&&(E||(E=K),C(K,A))){g=K;break}}!g&&E&&(g=E),this.pointerHistory.push({x:I,y:Q,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const i=(g==null?void 0:g.id)||null;if(A==="move"){if(this.draggingSliderId){const G=this.artboard.objects.find(K=>K.id===this.draggingSliderId);G&&this.updateSliderValueFromPointer(G,I,Q);return}if(this.draggingListViewId){const G=this.artboard.objects.find(K=>K.id===this.draggingListViewId);G&&this.updateListViewScrollFromPointer(G);return}g&&g.type==="Component"&&g.variant==="listview"&&this.updateListViewHoverFromPointer(g,I,Q),i!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${i}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),i&&this.fireEventForObject(i,"onPointerEnter"),this.lastHoveredObjectId=i);return}if((A==="up"||A==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear()),A==="down"&&g&&((w=g.behaviors)!=null&&w.some(G=>G.type===q.Draggable))&&this.draggingBehaviors.add(i),this.activeDropdownId&&A==="down"){const G=this.artboard.objects.find(K=>K.id===this.activeDropdownId);if(G&&(G.type==="Dropdown"||G.variant==="dropdown")){const K=this.objectStates.get(G.id),S=(K==null?void 0:K.options)||G.options||{},N=G.geometry||{},k=N.width??G.width??200,t=N.height??G.height??40,J=S.optionsList||[],R=S.itemHeight||32,e=S.listPadding??4,d=J.length*R+e*2,p=this.getWorldTransform(G.id),c=k*Math.abs(p.scaleX),Y=t*Math.abs(p.scaleY),l=p.y+Y/2+4,O=Math.abs(I-p.x)<=c/2,z=Q>=l&&Q<=l+d*Math.abs(p.scaleY);if(O&&z){const BA=Math.abs(p.scaleY),AA=Q-(l+e*BA),hA=Math.floor(AA/(R*BA));if(hA>=0&&hA<J.length){const oA=J[hA];S.selectedOption=oA,S.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,oA),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:oA})}return}else i!==this.activeDropdownId&&(S.isOpen=!1,this.activeDropdownId=null)}}if(g){let G=g,K=g;for(;K&&K.parentId;){const N=this.artboard.objects.find(k=>k.id===K.parentId);if(N&&N.type==="Component"){G=N;break}K=N}let S=A;if(A==="click"?S="onClick":A==="down"?S="onPointerDown":A==="up"?S="onPointerUp":A==="blur"&&(S="onPointerLeave"),this.fireEventForObject(g.id,S),G!==g&&this.fireEventForObject(G.id,S),G.type==="Component"&&G.variant==="toggle_button"&&A==="down"){const N=this.objectStates.get(G.id),k=(N==null?void 0:N.options)||G.options||{};k.checked=!k.checked,G.inputId&&this.setInternalInput(G.inputId,k.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle_button",property:"checked",value:k.checked})}if(G.type==="Component"&&G.variant==="toggle"&&A==="down"){const N=this.objectStates.get(G.id),k=(N==null?void 0:N.options)||G.options||{};k.checked=!k.checked,G.inputId&&this.setInternalInput(G.inputId,k.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle",property:"checked",value:k.checked}),this.onToggle&&this.onToggle(G.name,k.checked)}if(G.type==="Component"&&G.variant==="dropdown"&&A==="down"){const N=this.objectStates.get(G.id),k=(N==null?void 0:N.options)||G.options||{},t=!k.isOpen;if(t&&this.activeDropdownId&&this.activeDropdownId!==G.id){const J=this.artboard.objects.find(R=>R.id===this.activeDropdownId);J&&J.options&&(J.options.isOpen=!1)}k.isOpen=t,this.activeDropdownId=t?G.id:null}if(g.type==="Component"&&g.variant==="button"&&A==="down"&&this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"button",property:"click",value:!0}),g.type==="Component"&&g.variant==="listview"&&A==="down"){this.draggingListViewId=g.id;const N=this.getListViewItemIndexAtPointer(g,I,Q);if(N!==null){const k=g.options||{};k.activeItemIndex=N;const t=this.objectStates.get(g.id);t&&t.options&&(t.options.activeItemIndex=N);const J=(k.items||[])[N],R=typeof J=="string"?J:J.label||J.value||N;t&&t.options&&(t.options.selectedValue=R),g.inputId&&this.setInternalInput(g.inputId,R),this.onComponentChange&&(this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"activeItemIndex",value:N}),this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"selected",value:R}))}}if(g.type==="Component"&&g.variant==="slider"&&A==="down"&&(this.draggingSliderId=g.id,this.updateSliderValueFromPointer(g,I,Q)),A==="click"){const N=(o=this.artboard)==null?void 0:o.objects.find(t=>t.id===g.id),k=this.focusedId;if((N==null?void 0:N.type)==="Component"&&N.variant==="inputbox"){if(this.focusedId=g.id,console.log(`[Engine] Focus set to: ${g.id}`),k!==this.focusedId){if(k){const t=(s=this.artboard)==null?void 0:s.objects.find(J=>J.id===k);t&&this.onInputBlur&&this.onInputBlur(t.name)}this.onInputFocus&&this.onInputFocus(N.name)}}else if(this.focusedId=null,k){const t=(h=this.artboard)==null?void 0:h.objects.find(J=>J.id===k);t&&this.onInputBlur&&this.onInputBlur(t.name)}}}else if(A==="click"){const G=this.focusedId;if(this.focusedId=null,G){const K=(a=this.artboard)==null?void 0:a.objects.find(S=>S.id===G);K&&this.onInputBlur&&this.onInputBlur(K.name)}}}handleKeyDown(A){if(!this.artboard||!this.focusedId)return;const I=this.artboard.objects.find(E=>E.id===this.focusedId);if(!I||I.type!=="Component"||I.variant!=="inputbox")return;const Q=I.options||{};let g=Q.text||"";if(A.key==="Backspace")g=g.slice(0,-1);else if(A.key==="Enter")if(Q.multiline)g+=`
|
|
6
6
|
`;else{this.focusedId=null;return}else if(A.key.length===1)g+=A.key;else return;Q.text=g;const C=I.geometry;C.textInputId&&this.updateInput(C.textInputId,g),this.onComponentChange&&this.onComponentChange({objectId:I.id,componentName:I.name,variant:"inputbox",property:"text",value:g}),this.onInputChange&&this.onInputChange(I.name,g),this.onInputUpdate&&this.onInputUpdate(this.focusedId,g)}fireEventForObject(A,I){if(!this.artboard)return;const Q=this.artboard.objects.find(o=>o.id===A);if(!Q)return;console.log(`[Engine] Firing event ${I} on ${Q.name}`);const g=new Set([I]);I==="onPointerEnter"&&g.add("hover"),I==="onPointerLeave"&&g.add("blur"),I==="onPointerDown"&&g.add("pointerDown"),I==="onPointerUp"&&g.add("pointerUp");const E=(Q.interactions||[]).find(o=>g.has(o.event));if(E)if(console.log(`[Engine] Interaction matched: ${I} (as ${E.event}) -> ${E.targetInputId}`),E.action==="setInput"){let o=E.value;o==="toggle"&&(o=!this.inputs.get(E.targetInputId)),this.updateInput(E.targetInputId,o)}else E.action==="fireTrigger"&&this.updateInput(E.targetInputId,!0);const w=(Q.triggers||[]).find(o=>g.has(o.eventType));if(w&&w.entryAnimationId){console.log(`[Engine] Trigger matched: ${I} (as ${w.eventType}) -> Animation ${w.entryAnimationId}`);const o=this.artboard.animations.find(s=>s.id===w.entryAnimationId);o&&(this.activeTriggers.set(Q.id,{triggerId:w.id,animation:o,time:0,phase:"entry",elapsedHold:0}),this.onTrigger&&this.onTrigger(w.name,o.name))}}getWorldTransform(A){var a;const I=this.objectStates.get(A);if(!I)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const Q=(a=this.artboard)==null?void 0:a.objects.find(G=>G.id===A);if(!Q||!Q.parentId)return{x:I.x,y:I.y,scaleX:I.scale_x??1,scaleY:I.scale_y??1,rotation:I.rotation??0};const g=this.getWorldTransform(Q.parentId),C=g.rotation*(Math.PI/180),E=Math.cos(C),i=Math.sin(C),w=I.x*g.scaleX,o=I.y*g.scaleY,s=g.x+(w*E-o*i),h=g.y+(w*i+o*E);return{x:s,y:h,scaleX:(I.scale_x??1)*g.scaleX,scaleY:(I.scale_y??1)*g.scaleY,rotation:g.rotation+(I.rotation??0)}}hitTest(A,I,Q){var J,R;if(!this.objectStates.get(A.id))return!1;const C=((J=A.geometry)==null?void 0:J.width)??A.width??100,E=((R=A.geometry)==null?void 0:R.height)??A.height??100,i=this.getWorldTransform(A.id),w=I-i.x,o=Q-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=w*h-o*a,K=w*a+o*h,S=i.scaleX,N=i.scaleY,k=C*Math.abs(S),t=E*Math.abs(N);return Math.abs(G)<=k/2&&Math.abs(K)<=t/2}updateSliderValueFromPointer(A,I,Q){var p;const g=this.objectStates.get(A.id);if(!g)return;const C=A.options||{},E=((p=A.geometry)==null?void 0:p.width)??A.width??200,i=this.getWorldTransform(A.id),w=I-i.x,o=Q-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=w*h-o*a,K=C.thumbWidth??16,S=E-K;let k=(G+S/2)/S;k=Math.max(0,Math.min(1,k));const t=C.min??0,J=C.max??100,R=C.step||1;let e=t+k*(J-t);R>0&&(e=Math.round(e/R)*R),e=Math.max(t,Math.min(J,e));const d=g.options||{};d.value!==e&&(g.options={...d,value:e},A.inputId&&this.setInternalInput(A.inputId,e),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:e}))}applyAnimation(A,I){A.tracks.forEach(Q=>{var w,o,s;const g=(w=this.artboard)==null?void 0:w.objects.find(h=>h.id===Q.object_id);if(((o=g==null?void 0:g.physics)==null?void 0:o.enabled)&&g.physics.bodyType!=="Static"&&(["x","y","rotation"].includes(Q.property)||Q.property.startsWith("transform.")))return;const E=this.objectStates.get(Q.object_id);if(!E)return;const i=this.interpolate(Q.keyframes,I);if(Q.property.includes(".")){const h=(Q.property||"").split(".");let a=E;for(let G=0;G<h.length-1;G++){if(typeof a[h[G]]!="object"||a[h[G]]===null){let K=g;for(let S=0;S<=G;S++)K=K?K[h[S]]:null;a[h[G]]=K?JSON.parse(JSON.stringify(K)):{}}a=a[h[G]]}a[h[h.length-1]]=i}else E[Q.property]=i;if(this.physicsEngine&&((s=g==null?void 0:g.physics)!=null&&s.enabled)&&g.physics.bodyType==="Static")if(Q.property==="x"||Q.property==="transform.x"){const h=this.physicsEngine.getPosition(Q.object_id);h&&this.physicsEngine.setPosition(Q.object_id,i,h.y)}else if(Q.property==="y"||Q.property==="transform.y"){const h=this.physicsEngine.getPosition(Q.object_id);h&&this.physicsEngine.setPosition(Q.object_id,h.x,i)}else(Q.property==="rotation"||Q.property==="transform.rotation")&&this.physicsEngine.setRotation(Q.object_id,i*(Math.PI/180))})}interpolate(A,I){if(A.length===0)return 0;let Q=A[0],g=A[A.length-1];if(I<=Q.time)return Q.value;if(I>=g.time)return g.value;for(let i=0;i<A.length-1;i++)if(I>=A[i].time&&I<A[i+1].time){Q=A[i],g=A[i+1];break}if(Math.abs(Q.time-I)<.005)return Q.value;if(Math.abs(g.time-I)<.005)return g.value;const C=g.time-Q.time;let E=(I-Q.time)/C;if(Q.easing&&(E=$E(Q.easing)(E)),typeof Q.value=="string"){if(Q.value.startsWith("#"))return this.interpolateColor(Q.value,g.value,E);const i=parseFloat(Q.value),w=parseFloat(g.value);return!isNaN(i)&&!isNaN(w)?Math.round(i+(w-i)*E).toString():Q.value}return Array.isArray(Q.value)&&Array.isArray(g.value)?Q.value.length===g.value.length?Q.value.map((i,w)=>{const o=g.value[w];return typeof i=="number"&&typeof o=="number"?i+(o-i)*E:E<.5?i:o}):E<.5?Q.value:g.value:typeof Q.value=="object"&&typeof g.value=="object"&&Q.value!==null&&g.value!==null?Q.value.type&&g.value.type?this.interpolateFill(Q.value,g.value,E):E<.5?Q.value:g.value:typeof Q.value=="number"&&typeof g.value=="number"?Q.value+(g.value-Q.value)*E:E<.5?Q.value:g.value}interpolateColor(A,I,Q){var K,S;const g=((S=(K=this.artboard)==null?void 0:K.tokens)==null?void 0:S.colors)||{},C=g[A]||A,E=g[I]||I,i=N=>{if(!N)return{r:0,g:0,b:0};const k=N.startsWith("#")?N.replace("#",""):"000000";return k.length===3?{r:parseInt(k[0]+k[0],16),g:parseInt(k[1]+k[1],16),b:parseInt(k[2]+k[2],16)}:{r:parseInt(k.substring(0,2),16),g:parseInt(k.substring(2,4),16),b:parseInt(k.substring(4,6),16)}},w=i(C),o=i(E),s=Math.round(w.r+(o.r-w.r)*Q),h=Math.round(w.g+(o.g-w.g)*Q),a=Math.round(w.b+(o.b-w.b)*Q),G=N=>{const k=Math.max(0,Math.min(255,N)).toString(16);return k.length===1?"0"+k:k};return`#${G(s)}${G(h)}${G(a)}`}interpolateStops(A,I,Q){return!A||!I||A.length!==I.length?Q<.5?A:I:A.map((g,C)=>{const E=I[C];return{offset:g.offset+(E.offset-g.offset)*Q,color:this.interpolateColor(g.color,E.color,Q),opacity:(g.opacity??1)+((E.opacity??1)-(g.opacity??1))*Q}})}interpolateFill(A,I,Q){if(!A||!I||A.type!==I.type)return Q<.5?A:I;const g={...A,opacity:(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*Q};return A.type==="Solid"?g.color=this.interpolateColor(A.color,I.color,Q):(A.type==="LinearGradient"||A.type==="RadialGradient")&&(A.start&&I.start&&(g.start=[A.start[0]+(I.start[0]-A.start[0])*Q,A.start[1]+(I.start[1]-A.start[1])*Q]),A.end&&I.end&&(g.end=[A.end[0]+(I.end[0]-A.end[0])*Q,A.end[1]+(I.end[1]-A.end[1])*Q]),A.center&&I.center&&(g.center=[A.center[0]+(I.center[0]-A.center[0])*Q,A.center[1]+(I.center[1]-A.center[1])*Q]),A.radius!==void 0&&I.radius!==void 0&&(g.radius=A.radius+(I.radius-A.radius)*Q),g.stops=this.interpolateStops(A.stops,I.stops,Q)),g}render(A,I,Q){if(this.canvasWidth=I,this.canvasHeight=Q,!this.artboard)return;A.clearRect(0,0,I,Q);const g=this.artboard.width,C=this.artboard.height,E=this.calculateTransform(I,Q,g,C,this.layout.fit,this.layout.alignment);if(A.save(),A.translate(Math.round(E.tx),Math.round(E.ty)),A.scale(E.scaleX,E.scaleY),A.translate(g/2,C/2),this.rootTransform=A.getTransform(),this.artboard.backgroundVisible!==!1&&(A.fillStyle=this.artboard.backgroundColor||"#000000",A.fillRect(-g/2,-C/2,g,C)),this.artboard.backgroundImage){const w=this.artboard.backgroundImage;let o=this.imageCache.get(w);if(o||(o=new Image,o.src=w,this.imageCache.set(w,o)),o.complete&&o.naturalWidth>0){A.save(),A.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const s=o.naturalWidth/o.naturalHeight,h=g/C;let a,G,K,S;h>s?(a=g,G=g/s):(G=C,a=C*s),K=-a/2,S=-G/2,A.drawImage(o,K,S,a,G),A.restore()}}A.beginPath(),A.rect(-g/2,-C/2,g,C),A.clip();const i=new Map;this.artboard.objects.forEach(w=>i.set(w.id,w)),this.artboard.objects.forEach(w=>{w.parentId||this.renderObject(A,w,i)}),A.restore()}calculateTransform(A,I,Q,g,C,E){let i=1,w=1,o=1;const s=Q/g,h=A/I;switch(C){case"Contain":h>s?o=I/g:o=A/Q,i=w=o;break;case"Cover":h>s?o=A/Q:o=I/g,i=w=o;break;case"Fill":i=A/Q,w=I/g;break;case"FitWidth":o=A/Q,i=w=o;break;case"FitHeight":o=I/g,i=w=o;break;case"None":i=w=1;break;case"ScaleDown":o=Math.min(A/Q,I/g),o>1&&(o=1),i=w=o;break;default:i=w=1;break}const a=Q*i,G=g*w;let K=0,S=0;return E.includes("Left")?K=0:E.includes("Right")?K=A-a:K=(A-a)/2,E.includes("Top")?S=0:E.includes("Bottom")?S=I-G:S=(I-G)/2,{scaleX:i,scaleY:w,tx:K,ty:S}}mapFontWeight(A){const I=A.toLowerCase();return I==="thin"||I==="100"?"100":I==="extralight"||I==="200"?"200":I==="light"||I==="300"?"300":I==="regular"||I==="normal"||I==="400"?"400":I==="medium"||I==="500"?"500":I==="semibold"||I==="600"?"600":I==="bold"||I==="700"?"700":I==="extrabold"||I==="800"?"800":I==="black"||I==="900"?"900":A}getFontLeadingFactor(A){const I=(A||"Inter").trim();for(const[Q,g]of Object.entries(this.fontLeadingFactors))if(I.toLowerCase()===Q.toLowerCase())return g;return .5}renderObject(A,I,Q){var O,z,BA,AA,hA,oA,f,m,x,Z;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(U,r,b,L,H)=>(this.drawRoundRect(A,U,r,b,L,H),A));const C=g.geometry?this.deepMerge(I.geometry,g.geometry):I.geometry,E=g.style?this.deepMerge(I.style,g.style):I.style;let i=(C==null?void 0:C.width)||((O=I.geometry)==null?void 0:O.width)||I.width||0,w=(C==null?void 0:C.height)||((z=I.geometry)==null?void 0:z.height)||I.height||0;if((i===0||w===0)&&(C!=null&&C.points)&&Array.isArray(C.points)&&C.points.length>0){let U=1/0,r=-1/0,b=1/0,L=-1/0;C.points.forEach(H=>{U=Math.min(U,H.x),r=Math.max(r,H.x),b=Math.min(b,H.y),L=Math.max(L,H.y)}),i===0&&(i=r-U),w===0&&(w=L-b)}const o=U=>{if(U)return U.corner_radius??U.cornerRadius},s=o(g)??o(E)??o(C)??o(I.style)??o(I.geometry)??0,h={...C,width:i,height:w};if(delete h.cornerRadius,h.corner_radius=s,g.visible===!1)return;const a=g.x,G=g.y;A.save();const K=E.blur||((BA=I.style)==null?void 0:BA.blur);K&&K.amount>0&&(A.filter=`blur(${K.amount}px)`);const S=A.globalAlpha,N=this.normalizeOpacity(g.opacity!==void 0?g.opacity:100);A.globalAlpha=S*N;const k=g.compositeOperation||g.blendMode;if(k&&k!=="Normal"){const U=k.toLowerCase();["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","copy","xor","multiply","screen"].includes(U)&&(A.globalCompositeOperation=U)}const t=A,J=g.masks||(I.maskedBy?[{maskId:I.maskedBy,inverted:I.maskInverted===!0,type:I.maskType||"alpha",opacity:I.maskOpacity!==void 0?I.maskOpacity/100:1,feather:I.maskFeather||0,isVisible:!0}]:[]);let R=!1;const e=J.filter(U=>U.isVisible!==!1&&Q.has(U.maskId));if(e.length>0){const U=e[0],r=Q.get(U.maskId),b=this.objectStates.get(r.id);b&&b.visible!==!1&&(R=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0})),this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),I.parentId&&this.applyAbsoluteTransform(this.maskCtx,I.parentId,Q),this.maskCtx.save(),this.maskCtx.globalAlpha=1,A=this.maskCtx)}A.translate(a,G),A.rotate(g.rotation*Math.PI/180);const d=g.skew_x||0,p=g.skew_y||0;(d!==0||p!==0)&&A.transform(1,Math.tan(p*Math.PI/180),Math.tan(d*Math.PI/180),1,0,0),A.scale(g.scale_x,g.scale_y);const c=I.liquidFill||((AA=I.style)==null?void 0:AA.liquidFill),Y=I.artEffect||((hA=I.style)==null?void 0:hA.artEffect);if(c&&c.enabled){A.save();const U=c.fillLevel??.5;A.beginPath();const r=w/2-w*U;A.rect(-i/2,r,i,w*U),A.clip(),A.fillStyle=c.color||"#3b82f6",A.globalAlpha=A.globalAlpha*(c.opacity??1)}const l=Y&&Y.enabled&&Y.type==="glitch";if(l){A.save();const r=(Y.intensity??.5)*10;A.shadowColor="rgba(255, 0, 0, 0.5)",A.shadowBlur=r,A.translate(r/2,0)}if(C.type==="Text"){let U=C.text||"";if(C.textInputId){const DA=this.inputs.get(C.textInputId);DA!==void 0&&(U=String(DA),g.geometry&&g.geometry.type==="Text"&&(g.geometry.text=U))}let r=U||"";C.segments&&Array.isArray(C.segments)&&(r=C.segments.map(DA=>DA&&DA.text?DA.text:"").join(""));const b=C.textCase||"none";b==="uppercase"?r=r.toUpperCase():b==="lowercase"?r=r.toLowerCase():b==="capitalize"&&(r=r.replace(/\b\w/g,DA=>DA.toUpperCase()));let L=((oA=C.fontWeight)==null?void 0:oA.toString())||"400",H="normal";L.toLowerCase().includes("italic")&&(H="italic",L=L.replace(/italic/gi,"").trim()||"400");const j=this.mapFontWeight(L),EA=Math.max(1,C.fontSize||16);A.font=`${H} ${j} ${EA}px "${C.fontFamily||"Inter"}", sans-serif`;const v=C.textVerticalAlign||"top";A.textBaseline="top";const V=C.textAlign||"left";A.textAlign=V;let QA=-i/2;V==="center"&&(QA=0),V==="right"&&(QA=i/2);const CA=C.letterSpacing||0,SA=C.paragraphSpacing||0,kA=(C.lineHeight||1.2)*EA,qA=Math.ceil(C.width||i||200)+10,MA=`${H} ${j} ${EA}px "${C.fontFamily||"Inter"}", sans-serif`,JA=DA=>{if(CA===0)return A.measureText(DA).width;let OA=0;for(let nA=0;nA<DA.length;nA++)OA+=A.measureText(DA[nA]).width+CA;return OA-CA},rA=`${r}|${MA}|${CA}|${SA}`;let pA=this.pretextCache.get(rA);if(!pA&&(pA=ME(r,MA),this.pretextCache.set(rA,pA),this.pretextCache.size>1e3)){const DA=this.pretextCache.keys().next().value;DA&&this.pretextCache.delete(DA)}const{height:xA}=JE(pA,qA,kA);let u=xA;const n=[],T=String(r||"").split(`
|
|
7
7
|
`);T.forEach((DA,OA)=>{const nA=String(DA||"").split(" ");let lA="";for(let zA=0;zA<nA.length;zA++){let gI=nA[zA];const VI=lA+gI+" ";if(JA(VI.trim())<=qA+10)lA=VI;else if(lA!=="")n.push({text:lA.trim(),isParaEnd:!1}),lA=gI+" ";else if(lA==="")n.push({text:gI.trim(),isParaEnd:!1}),lA="";else{let BI="";for(let EI=0;EI<gI.length;EI++){const qI=BI+gI[EI];JA(qI)>qA+10&&BI!==""?(n.push({text:BI,isParaEnd:!1}),BI=gI[EI]):BI=qI}lA=BI+" "}}n.push({text:lA.trim(),isParaEnd:OA<T.length-1})}),u=Math.max(u,n.length*kA+n.filter(DA=>DA.isParaEnd).length*SA);let IA=-u/2;const sA=this.getFontLeadingFactor(C.fontFamily||"Inter"),VA=(kA-EA)*sA;IA+=VA,w>0&&(v==="top"?IA=-w/2+VA:v==="middle"||v==="center"?IA=-u/2+VA:v==="bottom"&&(IA=w/2-u+VA));const fA=(DA,OA,nA,lA,zA)=>{var gI;if(CA===0&&(C.enableSegments!==!0||!C.segments||C.segments.length===0))lA?A.strokeText(DA,OA,nA):A.fillText(DA,OA,nA);else{const VI=JA(DA);let Jg=OA;V==="center"?Jg-=VI/2:V==="right"&&(Jg-=VI);let BI=Jg;const XQ=((gI=I.behaviors)==null?void 0:gI.filter(EI=>[q.Typewriter,q.Scramble,q.Wave,q.Bounce,q.GlitchText,q.TextTrail,q.Reveal3D,q.RevealSlide,q.RevealBlur,q.TextLiquid,q.TextVortex,q.TextExplosion,q.TextRain,q.TextGravity,q.TextElastic,q.TextMatrix,q.TextNeon,q.TextGlitch3D,q.TextDissolve,q.TextOrganic,q.TextBreathe,q.TextFloral,q.TextSmoke,q.TextVariable,q.TextMagnet,q.TextSpin,q.TextZing,q.TextPerspective,q.TextMirror].includes(EI.type)&&EI.enabled))||[];for(let EI=0;EI<DA.length;EI++){let qI=DA[EI];const RA=zA+EI;let CI=0,WA=0,pI=1,RI=1,zI=0,jA=1,_I=qI;if(XQ.forEach(aA=>{const iA=aA.settings||{},UA=iA.strength||1,HA=Date.now();if(aA.type===q.Typewriter){const W=iA.speed||1,_=iA.stagger||.05;this.currentTime*W-RA*_<0&&(jA=0)}else if(aA.type===q.Scramble){const W=iA.duration||1.5,_=Math.min(1,this.currentTime/W);if(Math.max(0,_-RA*.02)<1&&Math.random()<.3){const XA="$%#@!*&";_I=XA[Math.floor(Math.random()*XA.length)]}}else if(aA.type===q.Wave){const W=iA.amplitude||20,_=iA.frequency||1,X=iA.speed||1;WA+=Math.sin(this.currentTime*5*X+RA*_)*W*UA}else if(aA.type===q.Bounce){const W=iA.height||50,_=iA.stagger||.1,X=Math.max(0,this.currentTime%2-RA*_);X<1&&(WA-=Math.abs(Math.sin(X*Math.PI))*W*UA)}else if(aA.type===q.TextTrail){const W=iA.delay||5,_=Math.max(0,this.pointerHistory.length-1-RA*W),X=this.pointerHistory[_];if(X){const XA=(X.x-(g.x+BI))*UA,Qi=(X.y-(g.y+nA+WA))*UA;CI+=XA*.2,WA+=Qi*.2}}else if(aA.type===q.Reveal3D){const W=iA.speed||1,_=iA.stagger||.1,X=Math.max(0,Math.min(1,this.currentTime*W-RA*_));pI*=X,RI*=X,jA=X}else if(aA.type===q.RevealSlide){const W=iA.direction||"up",_=iA.distance||40,X=Math.max(0,Math.min(1,this.currentTime*1.5-RA*.05)),XA=(1-X)*_*UA;W==="up"?WA-=XA:W==="down"?WA+=XA:W==="left"?CI-=XA:W==="right"&&(CI+=XA),jA=X}else if(aA.type===q.RevealBlur){const W=Math.max(0,Math.min(1,this.currentTime*1.2-RA*.1));jA=W,CI+=(1-W)*5}else if(aA.type===q.TextLiquid){const W=iA.speed||1,_=iA.amplitude||10,X=Math.max(0,Math.sin(HA*.001*W+RA*.5));WA+=X*_*UA,RI*=1+X*.2}else if(aA.type===q.TextVortex){const W=iA.speed||1,_=iA.radius||50,X=HA*.002*W+RA*.2,XA=(1-(Math.sin(HA*.001)*.5+.5))*_;CI+=Math.cos(X)*XA*UA,WA+=Math.sin(X)*XA*UA}else if(aA.type===q.TextExplosion){const W=iA.force||1,_=this.currentTime%2;if(_<1){const X=(RA/DA.length-.5)*Math.PI*2,XA=_*100*W;CI+=Math.cos(X)*XA*UA,WA+=Math.sin(X)*XA*UA,jA=1-_}}else if(aA.type===q.TextRain){const W=iA.speed||1,_=iA.height||100,X=(HA*.001*W+RA*.1)%1;WA-=(1-X)*_*UA,jA=X>.1?1:X*10}else if(aA.type===q.TextGravity){const W=iA.gravity||9.8,_=this.currentTime%3/3,X=.5*W*Math.pow(_*10,2);X<100?WA+=X*UA:WA+=100*UA}else if(aA.type===q.TextMatrix){const W=iA.speed||1;if(Math.random()<.1*W){const X="0123456789ABCDEF!@#$%^&*";_I=X[Math.floor(Math.random()*X.length)]}jA=.3+(Math.sin(HA*.01*W+RA)+1)/2*.7}else if(aA.type===q.TextNeon){const W=Math.random()>.95?.5:1;jA=(.7+(Math.sin(HA*.005)+1)/2*.3)*W}else if(aA.type===q.TextDissolve){const W=iA.speed||1;Math.sin(RA*1.5+HA*.002*W)>.5&&(jA=0)}else if(aA.type===q.TextOrganic){const W=iA.speed||1,_=iA.amplitude||10;CI+=Math.sin(HA*.002*W+RA)*_*UA,WA+=Math.cos(HA*.0015*W+RA*.7)*_*UA}else if(aA.type===q.TextBreathe){const _=1+(Math.sin(HA*.003+RA*.2)+1)/2*.2*UA;pI*=_,RI*=_}else if(aA.type===q.TextSpin){const W=iA.speed||1;zI+=HA*.01*W+RA}else if(aA.type===q.TextMagnet){const W=this.pointerHistory[this.pointerHistory.length-1];if(W){const _=W.x-(g.x+BI),X=W.y-(g.y+nA);zI=Math.atan2(X,_)}}else if(aA.type===q.TextPerspective){const W=DA.length/2,_=(RA-W)/W,X=1-Math.abs(_)*.3*UA;pI*=X,RI*=X,CI+=_*20*UA}else if(aA.type===q.TextMirror)jA*=.8;else if(aA.type===q.TextFloral){const W=iA.speed||1,_=iA.stagger||.1,X=(HA*.001*W+RA*_)%2;X<1&&(pI*=X,RI*=X,zI+=X*Math.PI)}else if(aA.type===q.TextSmoke){const W=iA.speed||1,_=iA.height||50,X=(HA*5e-4*W+RA*.2)%1;WA-=X*_*UA,CI+=Math.sin(HA*.002+RA)*5*UA,jA=1-X}else if(aA.type===q.TextVariable){const W=iA.speed||1,_=iA.intensity||1.5,X=(Math.sin(HA*.004*W+RA*.3)+1)/2;pI*=1+X*(_-1)*UA}else if(aA.type===q.TextZing){const W=iA.speed||2,_=iA.distance||100,X=(HA*.002*W+RA*.05)%1;CI+=(1-X)*_*UA,jA=X}else if(aA.type===q.TextElastic){const W=iA.stiffness||.2,_=iA.damping||.1,X=Math.sin(HA*.01)*Math.exp(-HA*.001*_);RI*=1+X*W*UA}else if(aA.type===q.TextGlitch3D){const W=iA.intensity||5;Math.random()<.2&&(CI+=(Math.random()-.5)*W,WA+=(Math.random()-.5)*W,jA=.8)}else if(aA.type===q.GlitchText){const W=iA.intensity||5;Math.random()<.1&&(CI+=(Math.random()-.5)*W,WA+=(Math.random()-.5)*W,Math.random()<.05&&(jA=.5))}}),jA<=0){BI+=A.measureText(qI).width+CA;continue}if(C.enableSegments===!0&&C.segments&&C.segments.length>0){const aA=C.segments[RA%C.segments.length];if(aA){const iA=aA.fontSize||EA,UA=aA.fontFamily||C.fontFamily||"Inter",HA=aA.fontWeight||C.fontWeight||"400";A.font=`${H} ${this.mapFontWeight(HA.toString())} ${iA}px "${UA}", sans-serif`}}const Ci=A.globalAlpha;A.globalAlpha*=jA,A.save();const JC=A.measureText(_I).width;A.translate(BI+CI+JC/2,nA+WA),zI!==0&&A.rotate(zI),A.scale(pI,RI),lA?A.strokeText(_I,-JC/2,0):A.fillText(_I,-JC/2,0),A.restore(),A.globalAlpha=Ci,C.enableSegments===!0&&C.segments&&C.segments.length>0&&(A.font=`${H} ${this.mapFontWeight((C.fontWeight||"400").toString())} ${EA}px "${C.fontFamily||"Inter"}", sans-serif`),BI+=A.measureText(qI).width+CA}}};if(E.fill){const DA=A.globalAlpha,OA=this.createCanvasFill(A,E.fill,i,w);A.fillStyle=OA||E.fill.color||"#000000",A.globalAlpha=DA*this.normalizeOpacity(E.fill.opacity??100);let nA=0,lA=IA;n.forEach(zA=>{const gI=r.indexOf(zA.text,nA);gI!==-1&&(fA(zA.text,QA,lA,!1,gI),nA=gI+zA.text.length,lA+=kA+(zA.isParaEnd?SA:0))}),A.globalAlpha=DA}if(E.stroke&&E.stroke.width>0){const DA=A.globalAlpha;A.strokeStyle=E.stroke.color,A.lineWidth=E.stroke.width,A.globalAlpha=DA*this.normalizeOpacity(E.stroke.opacity??100);let OA=0,nA=IA;n.forEach(lA=>{const zA=r.indexOf(lA.text,OA);zA!==-1&&(fA(lA.text,QA,nA,!0,zA),OA=zA+lA.text.length,nA+=kA+(lA.isParaEnd?SA:0))}),A.globalAlpha=DA}}else if(C.type==="Image"){const U=C.src;if(U){let r=this.imageCache.get(U);r||(r=new Image,r.onload=()=>{},r.onerror=()=>{console.error(`[ExodeUI] Image load failed: ${U.substring(0,100)}${U.length>100?"...":""}`)},r.src=U,this.imageCache.set(U,r)),r.complete&&r.naturalWidth>0&&(s!==0?(A.save(),this.drawRoundRect(A,-i/2,-w/2,i,w,s),A.clip(),A.drawImage(r,-i/2,-w/2,i,w),A.restore()):A.drawImage(r,-i/2,-w/2,i,w))}}else if(C.type==="SVG"){const U=C.svgContent;if(U){const r=E.palette||[],b=I.id+"_"+r.join("_");let L=this.imageCache.get(b);if(!L){L=new Image;let H=U;C.colors&&C.colors.length>0&&r.length>0&&C.colors.forEach((v,V)=>{if(r[V]){const QA=v.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),CA=new RegExp(QA,"gi");H=H.replace(CA,r[V])}});const j=new Blob([H],{type:"image/svg+xml"}),EA=URL.createObjectURL(j);L.onload=()=>{this.artboard&&this.reset()},L.src=EA,this.imageCache.set(b,L)}L.complete&&L.naturalWidth>0&&(s!==0?(A.save(),this.drawRoundRect(A,-i/2,-w/2,i,w,s),A.clip(),A.drawImage(L,-i/2,-w/2,i,w),A.restore()):A.drawImage(L,-i/2,-w/2,i,w))}}else if(h.type==="LineGraph")this.renderLineGraph(A,h,i,w);else if(I.type==="Shape"){this.applyPath(A,h,i,w,s);const U=E.shadow;if(U&&U.isEnabled!==!1){let r=U.color||"#000000";(m=(f=this.artboard)==null?void 0:f.tokens)!=null&&m.colors&&this.artboard.tokens.colors[r]&&(r=this.artboard.tokens.colors[r]);const b=this.normalizeOpacity(U.opacity??100),L=U.spread||0,j=(U.blur||0)+L*1.5,EA=g.scale_x||1,v=g.scale_y||1,V=Math.abs(EA),QA=Math.abs(v),CA=(V+QA)/2,SA=j/CA,kA=(U.offsetX||0)/EA,qA=(U.offsetY||0)/v,MA=Math.max(SA*4,Math.abs(kA)+SA*2,Math.abs(qA)+SA*2),JA=Math.ceil(i+MA*2),rA=Math.ceil(w+MA*2),pA=window.devicePixelRatio||1,xA=Math.ceil(JA*pA),u=Math.ceil(rA*pA);(!this.shadowBuffer||this.shadowBuffer.width<xA||this.shadowBuffer.height<u)&&(this.shadowBuffer||(this.shadowBuffer=document.createElement("canvas")),this.shadowBuffer.width=Math.max(this.shadowBuffer.width,xA),this.shadowBuffer.height=Math.max(this.shadowBuffer.height,u));const n=this.shadowBuffer.getContext("2d",{willReadFrequently:!0});n.clearRect(0,0,xA,u),n.save(),n.setTransform(pA,0,0,pA,0,0),n.translate(JA/2,rA/2);let T=r;if(r.startsWith("#")){const IA=r.replace("#",""),sA=parseInt(IA.substring(0,2),16),VA=parseInt(IA.substring(2,4),16),fA=parseInt(IA.substring(4,6),16);T=`rgba(${sA}, ${VA}, ${fA}, ${b})`}else if(r.startsWith("rgba")){const IA=r.match(/[\d.]+/g);if(IA&&IA.length>=4){const sA=IA[0],VA=IA[1],fA=IA[2],DA=IA[3];T=`rgba(${sA}, ${VA}, ${fA}, ${parseFloat(DA)*b})`}}n.shadowColor=T,n.shadowBlur=SA*pA,n.shadowOffsetX=kA*pA,n.shadowOffsetY=qA*pA,n.fillStyle="#000000",n.beginPath(),this._tracePath(n,h,i,w,s),n.fill(),n.shadowColor="transparent",n.shadowBlur=0,n.globalCompositeOperation="destination-out",n.beginPath(),this._tracePath(n,h,i,w,s),n.fill(),n.restore(),A.drawImage(this.shadowBuffer,0,0,xA,u,-JA/2,-rA/2,JA,rA)}if(A.save(),E.blur&&E.blur.amount>0&&(A.filter=`blur(${E.blur.amount}px)`),E.fill){const r=A.globalAlpha,b=this.createCanvasFill(A,E.fill,i,w);b?A.fillStyle=b:A.fillStyle=E.fill.color||"transparent",A.globalAlpha=r*this.normalizeOpacity(E.fill.opacity??100),this.applyPath(A,h,i,w,s),A.fill(),A.globalAlpha=r}A.restore(),E.stroke&&E.stroke.width>0&&this.applyStrokeAlignment(A,E,h,i,w,s)}else if(I.type==="Frame"||I.type==="Group"&&!I.isStructuralGroup){const U=g.width??C.width??I.width??i,r=g.height??C.height??I.height??w,b=s;A.save();const L=E.shadow;if(L&&L.isEnabled!==!1){let H=L.color||"#000000";(Z=(x=this.artboard)==null?void 0:x.tokens)!=null&&Z.colors&&this.artboard.tokens.colors[H]&&(H=this.artboard.tokens.colors[H]);const j=this.normalizeOpacity(L.opacity??100),EA=L.spread||0,V=(L.blur||0)+EA*1.5,QA=g.scale_x||1,CA=g.scale_y||1,SA=Math.abs(QA),kA=Math.abs(CA),qA=(SA+kA)/2,MA=V/qA,JA=(L.offsetX||0)/QA,rA=(L.offsetY||0)/CA,pA=Math.max(MA*3,Math.abs(JA)+MA,Math.abs(rA)+MA),xA=Math.ceil(U+pA*2),u=Math.ceil(r+pA*2),n=window.devicePixelRatio||1,T=Math.ceil(xA*n),IA=Math.ceil(u*n);this.shadowBuffer||(this.shadowBuffer=document.createElement("canvas")),(this.shadowBuffer.width<T||this.shadowBuffer.height<IA)&&(this.shadowBuffer.width=Math.max(this.shadowBuffer.width,T),this.shadowBuffer.height=Math.max(this.shadowBuffer.height,IA));const sA=this.shadowBuffer.getContext("2d",{willReadFrequently:!0});sA.clearRect(0,0,T,IA),sA.save(),sA.setTransform(n,0,0,n,0,0),sA.translate(xA/2,u/2);let VA=H;if(H.startsWith("#")){const fA=H.replace("#",""),DA=parseInt(fA.substring(0,2),16),OA=parseInt(fA.substring(2,4),16),nA=parseInt(fA.substring(4,6),16);VA=`rgba(${DA}, ${OA}, ${nA}, ${j})`}else if(H.startsWith("rgba")){const fA=H.match(/[\d.]+/g);if(fA&&fA.length>=4){const DA=fA[0],OA=fA[1],nA=fA[2],lA=fA[3];VA=`rgba(${DA}, ${OA}, ${nA}, ${parseFloat(lA)*j})`}}sA.shadowColor=VA,sA.shadowBlur=MA*n,sA.shadowOffsetX=JA*n,sA.shadowOffsetY=rA*n,sA.fillStyle="#000000",sA.beginPath(),this.drawRoundRect(sA,-U/2,-r/2,U,r,b),sA.fill(),sA.shadowColor="transparent",sA.shadowBlur=0,sA.globalCompositeOperation="destination-out",sA.beginPath(),this.drawRoundRect(sA,-U/2,-r/2,U,r,b),sA.fill(),sA.restore(),A.drawImage(this.shadowBuffer,0,0,T,IA,-xA/2,-u/2,xA,u)}if(A.beginPath(),this.drawRoundRect(A,-U/2,-r/2,U,r,b),E.fill&&E.fill.type!=="None"){const H=A.globalAlpha,j=this.createCanvasFill(A,E.fill,U,r);A.fillStyle=j||E.fill.color||"transparent",A.globalAlpha=H*this.normalizeOpacity(E.fill.opacity??100),A.fill(),A.globalAlpha=H}if(A.restore(),E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1){const H={type:"Rectangle"};this.applyStrokeAlignment(A,E,H,U,r,b)}}else I.type==="Group"&&I.isStructuralGroup||(I.type==="Component"&&I.variant==="inputbox"?this.renderInputBox(A,I):I.type==="Component"&&I.variant==="button"?this.renderButton(A,I):I.type==="Component"&&I.variant==="toggle_button"?this.renderToggleButton(A,I):I.type==="Toggle"||I.type==="Component"&&I.variant==="toggle"?this.renderToggle(A,I):I.type==="Slider"||I.type==="Component"&&I.variant==="slider"?this.renderSlider(A,I):I.type==="Dropdown"||I.type==="Component"&&I.variant==="dropdown"?this.renderDropdown(A,I):(I.type==="ListView"||I.type==="Component"&&I.variant==="listview")&&this.renderListView(A,I));if(l&&A.restore(),c&&c.enabled&&A.restore(),I.children&&I.children.length>0){const r=I.type==="Frame",b=I.clipsContent!==void 0?I.clipsContent:I.clipContent!==void 0?I.clipContent:r;if(A.save(),b){A.beginPath();const H=g.width??(C==null?void 0:C.width)??I.width??0,j=g.height??(C==null?void 0:C.height)??I.height??0,EA=g.cornerRadius??(C==null?void 0:C.corner_radius)??I.cornerRadius??0;this.drawRoundRect(A,-H/2,-j/2,H,j,EA),A.clip()}let L=0;for(I.children.forEach(H=>{const j=Q.get(H);if(!j)return;const EA=this.objectStates.get(H),v=(EA==null?void 0:EA.geometry)||j.geometry;if(v&&v.isMask&&(EA==null?void 0:EA.visible)!==!1){const V=v.width||0,QA=v.height||0;this.applyObjectTransform(A,H);const CA=(EA==null?void 0:EA.corner_radius)??(v==null?void 0:v.corner_radius)??0;this.applyPath(A,v,V,QA,CA),A.clip(),L++}else this.renderObject(A,j,Q)});L>0;)A.restore(),L--;A.restore()}if(R){this.maskCtx.restore(),(g.masks||(I.maskedBy?[{maskId:I.maskedBy,inverted:I.maskInverted===!0,type:I.maskType||"alpha",opacity:I.maskOpacity!==void 0?I.maskOpacity/100:1,feather:I.maskFeather||0,isVisible:!0}]:[])).filter(L=>L.isVisible!==!1&&Q.has(L.maskId)).forEach(L=>{const H=Q.get(L.maskId),j=this.objectStates.get(H.id),EA=L.feather||0,v=L.inverted===!0,V=L.opacity!==void 0?typeof L.opacity=="number"?L.opacity:L.opacity/100:1;if((L.type||"alpha")==="luma"){(!this.lumaBuffer||this.lumaBuffer.width!==this.maskBuffer.width||this.lumaBuffer.height!==this.maskBuffer.height)&&(this.lumaBuffer=document.createElement("canvas"),this.lumaBuffer.width=this.maskBuffer.width,this.lumaBuffer.height=this.maskBuffer.height,this.lumaCtx=this.lumaBuffer.getContext("2d",{willReadFrequently:!0})),this.lumaCtx.clearRect(0,0,this.lumaBuffer.width,this.lumaBuffer.height),this.lumaCtx.save(),this.rootTransform&&this.lumaCtx.setTransform(this.rootTransform),this.applyAbsoluteTransform(this.lumaCtx,H.id,Q),EA>0&&(this.lumaCtx.filter=`blur(${EA}px)`),this.lumaCtx.globalAlpha=V;const CA=(j==null?void 0:j.width)||H.geometry.width||0,SA=(j==null?void 0:j.height)||H.geometry.height||0,kA=(j==null?void 0:j.corner_radius)??H.corner_radius??0;this.applyPath(this.lumaCtx,H.geometry,CA,SA,kA),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill(),this.lumaCtx.restore();const qA=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),MA=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,JA=qA.data;for(let rA=0;rA<JA.length;rA+=4){const pA=MA[rA],xA=MA[rA+1],u=MA[rA+2];let n=(.299*pA+.587*xA+.114*u)/255;v&&(n=1-n),JA[rA+3]*=n}this.maskCtx.putImageData(qA,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=v?"destination-out":"destination-in",EA>0&&(this.maskCtx.filter=`blur(${EA}px)`),this.maskCtx.globalAlpha=V,this.applyAbsoluteTransform(this.maskCtx,H.id,Q);const CA=(j==null?void 0:j.width)||H.geometry.width||0,SA=(j==null?void 0:j.height)||H.geometry.height||0,kA=(j==null?void 0:j.corner_radius)??H.corner_radius??0;this.applyPath(this.maskCtx,H.geometry,CA,SA,kA),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill(),this.maskCtx.restore()}}),t.save(),t.setTransform(1,0,0,1,0,0);const b=I.maskBlendMode||I.blendMode;b&&b!=="Normal"&&(t.globalCompositeOperation=b.toLowerCase()),t.drawImage(this.maskBuffer,0,0),t.restore(),t.restore()}else A.restore()}applyStrokeAlignment(A,I,Q,g,C,E){if(!I.stroke||I.stroke.width<=0||I.stroke.isEnabled===!1)return;const i=I.stroke,w=i.width,o=(i.alignment||"center").toLowerCase();if(A.save(),i.fill){const N=this.createCanvasFill(A,i.fill,g,C);N?A.strokeStyle=N:A.strokeStyle=i.color||"#000000"}else A.strokeStyle=i.color||"#000000";const s=A.globalAlpha;A.globalAlpha=s*this.normalizeOpacity(i.opacity??100),A.lineWidth=w,A.lineCap=i.lineCap||"round",A.lineJoin=i.lineJoin||"round",i.miterLimit!==void 0&&(A.miterLimit=i.miterLimit);const h=i.trimStart??0,a=i.trimEnd??1,G=i.trimOffset??0,K=i.dashOffset??0,S=i.dashArray||[];if(h!==0||a!==1||G!==0){const N=this.getPerimeter(Q,g,C);if(N>0){const k=Math.max(0,Math.min(1,h)),t=Math.max(0,Math.min(1,a));if(k<t){const J=N*(t-k),R=N-J,e=-(N*(k+G%1+K%1));A.setLineDash([J,R]),A.lineDashOffset=e}else A.setLineDash([0,N])}}else S.length>0&&(A.setLineDash(S),A.lineDashOffset=K);o==="inside"?(A.lineWidth=w*2,A.save(),this.applyPath(A,Q,g,C,E),A.clip(),A.stroke(),A.restore()):o==="outside"?(A.lineWidth=w*2,this.applyPath(A,Q,g,C,E),A.stroke(),A.save(),A.globalCompositeOperation="destination-out",this.applyPath(A,Q,g,C,E),A.fill(),A.restore()):(A.lineWidth=w,this.applyPath(A,Q,g,C,E),A.stroke()),A.restore()}getPerimeter(A,I,Q){switch(A.type){case"Rectangle":return(I+Q)*2;case"Ellipse":{const g=I/2,C=Q/2,E=Math.abs(A.sweepAngle??360),i=Math.PI*(3*(g+C)-Math.sqrt((3*g+C)*(g+3*C)));return E/360*i}case"Line":return A.length||Math.sqrt(I*I+Q*Q);case"Triangle":return I+Math.sqrt((I/2)**2+Q**2)*2;case"Polygon":{const g=A.sides||3,C=A.radius||Math.min(I,Q)/2;return 2*g*C*Math.sin(Math.PI/g)}case"Star":{const g=A.points||5,C=A.outer_radius||Math.min(I,Q)/2,E=A.inner_radius||C/2,i=Math.PI/g;return Math.sqrt(C*C+E*E-2*C*E*Math.cos(i))*g*2}case"Path":{const g=A.points||[];if(g.length<2)return A.length||0;let C=0;for(let E=1;E<g.length;E++){const i=g[E-1],w=g[E];if(i.out_x!==void 0||w.in_x!==void 0)C+=this.getBezierLength(i.x,i.y,i.out_x??i.x,i.out_y??i.y,w.in_x??w.x,w.in_y??w.y,w.x,w.y);else{const o=w.x-i.x,s=w.y-i.y;C+=Math.sqrt(o*o+s*s)}}if(A.is_closed){const E=g[g.length-1],i=g[0];if(E.out_x!==void 0||i.in_x!==void 0)C+=this.getBezierLength(E.x,E.y,E.out_x??E.x,E.out_y??E.y,i.in_x??i.x,i.in_y??i.y,i.x,i.y);else{const w=i.x-E.x,o=i.y-E.y;C+=Math.sqrt(w*w+o*o)}}return C}default:return(I+Q)*2}}getBezierLength(A,I,Q,g,C,E,i,w,o=10){let s=0,h=A,a=I;for(let G=1;G<=o;G++){const K=G/o,S=1-K,N=K*K,k=S*S,t=k*S,J=N*K,R=t*A+3*k*K*Q+3*S*N*C+J*i,e=t*I+3*k*K*g+3*S*N*E+J*w,d=R-h,p=e-a;s+=Math.sqrt(d*d+p*p),h=R,a=e}return s}getPointOnPath(A,I,Q,g){if(A.type==="Path"){const C=A.points||[];if(C.length<2)return{x:0,y:0,angle:0};let E=1/0,i=-1/0,w=1/0,o=-1/0;C.forEach(N=>{E=Math.min(E,N.x),i=Math.max(i,N.x),w=Math.min(w,N.y),o=Math.max(o,N.y)});const s=(E+i)/2,h=(w+o)/2,G=this.getPerimeter(A,I,Q)*g;let K=0;const S=[];for(let N=1;N<C.length;N++)S.push({p0:C[N-1],p1:C[N]});A.is_closed&&S.push({p0:C[C.length-1],p1:C[0]});for(const N of S){const k=N.p0,t=N.p1;let J=0;const R=k.out_x!==void 0||t.in_x!==void 0;if(R?J=this.getBezierLength(k.x,k.y,k.out_x??k.x,k.out_y??k.y,t.in_x??t.x,t.in_y??t.y,t.x,t.y):J=Math.sqrt((t.x-k.x)**2+(t.y-k.y)**2),K+J>=G||N===S[S.length-1]){const e=J===0?0:(G-K)/J;if(R)return this.getBezierPointAndAngle(e,k,t,s,h);{const d=k.x+(t.x-k.x)*e-s,p=k.y+(t.y-k.y)*e-h,c=Math.atan2(t.y-k.y,t.x-k.x);return{x:d,y:p,angle:c}}}K+=J}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(A,I,Q,g,C){const E=I.x,i=I.y,w=I.out_x??I.x,o=I.out_y??I.y,s=Q.in_x??Q.x,h=Q.in_y??Q.y,a=Q.x,G=Q.y,K=1-A,S=A*A,N=K*K,k=N*K,t=S*A,J=k*E+3*N*A*w+3*K*S*s+t*a-g,R=k*i+3*N*A*o+3*K*S*h+t*G-C,e=3*N*(w-E)+6*K*A*(s-w)+3*S*(a-s),d=3*N*(o-i)+6*K*A*(h-o)+3*S*(G-h),p=Math.atan2(d,e);return{x:J,y:R,angle:p}}applyAbsoluteTransform(A,I,Q){if(!Q.get(I))return;const C=[];let E=I;for(;E;){C.unshift(E);const i=Q.get(E);E=i==null?void 0:i.parentId}C.forEach(i=>{this.applyObjectTransform(A,i)})}applyObjectTransform(A,I){const Q=this.objectStates.get(I);if(!Q)return;A.translate(Q.x,Q.y),A.rotate(Q.rotation*Math.PI/180);const g=(Q.scale_x??1)*(Q.flip_x===!0?-1:1),C=(Q.scale_y??1)*(Q.flip_y===!0?-1:1);A.scale(g,C)}applyPath(A,I,Q,g,C){A.beginPath(),this._tracePath(A,I,Q,g,C)}_tracePath(A,I,Q,g,C){if(I.type==="Rectangle"){const E=C!==void 0?C:I.corner_radius??0;this.drawRoundRect(A,-Q/2,-g/2,Q,g,E)}else if(I.type==="Ellipse")A.ellipse(0,0,Q/2,g/2,0,0,Math.PI*2);else if(I.type==="Triangle")A.moveTo(0,-g/2),A.lineTo(Q/2,g/2),A.lineTo(-Q/2,g/2),A.closePath();else if(I.type==="Polygon"){const E=I.sides||3,i=I.radius||Math.min(Q,g)/2;for(let w=0;w<E;w++){const o=w*2*Math.PI/E-Math.PI/2,s=i*Math.cos(o),h=i*Math.sin(o);w===0?A.moveTo(s,h):A.lineTo(s,h)}A.closePath()}else if(I.type==="Star"){const E=I.inner_radius||20,i=I.outer_radius||50,w=I.points||5;for(let o=0;o<w*2;o++){const s=o*Math.PI/w-Math.PI/2,h=o%2===0?i:E,a=h*Math.cos(s),G=h*Math.sin(s);o===0?A.moveTo(a,G):A.lineTo(a,G)}A.closePath()}else if((I.type==="Path"||I.type==="Subtract"||I.type==="Union"||I.type==="Intersect"||I.type==="Exclude"||I.type==="BooleanOperation")&&I.points){let E=1/0,i=-1/0,w=1/0,o=-1/0;I.points.forEach(a=>{E=Math.min(E,a.x),i=Math.max(i,a.x),w=Math.min(w,a.y),o=Math.max(o,a.y)});const s=(E+i)/2,h=(w+o)/2;I.points.forEach((a,G)=>{if(G===0)A.moveTo(a.x-s,a.y-h);else{const K=I.points[G-1],S=(K.out_x??K.x)-s,N=(K.out_y??K.y)-h,k=(a.in_x??a.x)-s,t=(a.in_y??a.y)-h;A.bezierCurveTo(S,N,k,t,a.x-s,a.y-h)}}),I.is_closed&&A.closePath()}else if(I.points&&Array.isArray(I.points)){let E=1/0,i=-1/0,w=1/0,o=-1/0;I.points.forEach(a=>{E=Math.min(E,a.x),i=Math.max(i,a.x),w=Math.min(w,a.y),o=Math.max(o,a.y)});const s=(E+i)/2,h=(w+o)/2;I.points.forEach((a,G)=>{if(G===0)A.moveTo(a.x-s,a.y-h);else{const K=I.points[G-1];K.out_x!==void 0||a.in_x!==void 0?A.bezierCurveTo((K.out_x??K.x)-s,(K.out_y??K.y)-h,(a.in_x??a.x)-s,(a.in_y??a.y)-h,a.x-s,a.y-h):A.lineTo(a.x-s,a.y-h)}}),I.is_closed&&A.closePath()}}renderInputBox(A,I){var j,EA;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=((j=I.geometry)==null?void 0:j.width)||250,E=((EA=I.geometry)==null?void 0:EA.height)||45,i=this.focusedId===I.id,w=this.lastHoveredObjectId===I.id,o=g.previewState||"default",s=o!=="default"?o:i?"focused":w?"hovered":"default",h=g.label||{visible:!0,text:"Label"},a=g.helperText||{visible:!1,text:"Helper text"},G=g.leftIcon||{visible:!1},K=g.rightIcon||{visible:!1},S=g.multiline===!0,N=g.corner_radius??8,k=g.corners||{tl:N,tr:N,bl:N,br:N},t=[k.tl,k.tr,k.br,k.bl];let J=g.backgroundColor||"rgba(31, 41, 55, 1)",R=g.borderColor||"rgba(55, 65, 81, 1)",e=g.borderWidth??1.5,d=g.color||"#ffffff",p=g.placeholderColor||"rgba(156, 163, 175, 1)",c=g.fontSize||14;const Y=`${s}Style`,l=g[Y];if(l?(l.backgroundColor!==void 0&&(J=l.backgroundColor),l.borderColor!==void 0&&(R=l.borderColor),l.borderWidth!==void 0&&(e=l.borderWidth),l.color!==void 0&&(d=l.color),l.placeholderColor!==void 0&&(p=l.placeholderColor),l.fontSize!==void 0&&(c=l.fontSize)):s==="focused"?(R=g.focusBorderColor||"rgba(59, 130, 246, 1)",e=Math.max(e,2)):s==="hovered"||s==="hover"?(R=g.hoverBorderColor||R,J=g.hoverBackgroundColor||J):s==="disabled"?(J=g.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",R=g.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):s==="error"&&(R="rgba(239, 68, 68, 1)",e=Math.max(e,2)),A.beginPath(),this.drawRoundRect(A,-C/2,-E/2,C,E,t),A.fillStyle=J,A.fill(),e>0&&(A.strokeStyle=R,A.lineWidth=e,A.stroke(),s==="focused"||s==="focus")){A.save(),A.beginPath();const v=t.map(V=>V+2);this.drawRoundRect(A,-C/2-2,-E/2-2,C+4,E+4,v),A.strokeStyle="rgba(59, 130, 246, 0.3)",A.lineWidth=2,A.stroke(),A.restore()}const O=(v,V)=>{if(!v.visible||!v.svgPath)return;const QA=v.size||14,CA=v.offset??16,SA=v.color||"#ffffff",kA=V?-(C/2)+CA:C/2-CA,qA=v.svgPath;if(A.save(),A.translate(kA,0),!qA.startsWith("<svg")){const MA=new Path2D(qA),JA=QA/24;A.scale(JA,JA),A.translate(-12,-12),A.fillStyle=SA,A.fill(MA)}A.restore()};O(G,!0),O(K,!1);const z=g.text||"",BA=g.placeholder||"Enter text...",AA=!z,hA=z||BA,oA=AA?p:d,f=c,m=g.fontFamily||"Inter",x=g.fontWeight||400;A.font=`${x} ${f}px "${m}", sans-serif`,A.fillStyle=oA,A.textAlign="left",A.textBaseline=S?"top":"middle";const Z=g.inputPadding??16,U=G.visible?(G.offset??16)+(G.size||14)/2+8:Z,r=K.visible?(K.offset??16)+(K.size||14)/2+8:Z,b=-(C/2)+U,L=C-U-r,H=g.inputType==="password"?"•".repeat(hA.length):hA;if(A.save(),A.beginPath(),A.rect(b-2,-E/2+4,L+4,E-8),A.clip(),S){const v=H.split(`
|
|
8
|
-
`);let V=-E/2+Z;const QA=f*1.2;let CA=0;v.forEach((SA,kA)=>{const qA=SA.split(" ");let MA="";for(let JA=0;JA<qA.length;JA++){const rA=MA+qA[JA]+" ";A.measureText(rA).width>L&&JA>0?(A.fillText(MA,b,V),MA=qA[JA]+" ",V+=QA):MA=rA}A.fillText(MA,b,V),CA=A.measureText(MA).width,kA<v.length-1&&(V+=QA,CA=0)}),i&&!AA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(b+CA,V,1.5,f)}else{const V=A.measureText(H).width;let QA=0;if(V>L&&(QA=V-L),A.fillText(H,b-QA,0),i&&!AA&&Math.floor(performance.now()/500)%2===0){const SA=b+V-QA;A.fillRect(SA,-(f/2),1.5,f)}}if(A.restore(),h.visible!==!1){const v=h.text||"Label",V=h.fontSize||12,QA=h.color||"rgba(156, 163, 175, 1)",CA=h.offset??8;A.font=`600 ${V}px "${m}", sans-serif`,A.fillStyle=QA,A.textAlign="left",A.textBaseline="bottom";const SA=-(C/2),kA=-(E/2)-CA;A.fillText(v,SA,kA)}if(a.visible===!0){const v=a.text||"Helper text",V=a.fontSize||11,QA=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",CA=a.offset??6;A.font=`400 ${V}px "${m}", sans-serif`,A.fillStyle=QA,A.textAlign="left",A.textBaseline="top";const SA=-(C/2),kA=E/2+CA;A.fillText(v,SA,kA)}}renderSlider(A,I){const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.geometry)||I.geometry,C=(Q==null?void 0:Q.options)||I.options||{},E=g.width||200,i=C.value??50,w=C.min??0,s=(C.max??100)-w,h=s===0?0:(i-w)/s,a=C.trackHeight||4,G=C.trackRoundedness??2,K=C.trackShape??"Rectangle",S=C.trackPath||"",N=C.activeColor||"#3b82f6",k=C.inactiveColor||"#374151",t=C.thumbShape||"Ellipse",J=C.thumbWidth??16,R=C.thumbHeight??16,e=C.thumbRoundedness??0,d=C.thumbColor||"#ffffff",p=C.thumbPath||"",c=C.thumbIcon||"",Y=C.showValueTooltip??!1,l=C.tooltipBgColor||"#333333",O=C.tooltipColor||"#ffffff",z=C.tooltipOffsetX??0,BA=C.tooltipOffsetY??-25,AA=(U,r,b,L,H,j,EA)=>{if((U==="Custom"||U==="Icon")&&EA)try{const v=new Path2D(EA);if(A.save(),A.translate(r,b),U==="Icon"){const V=Math.min(L,H)/24;A.scale(V,V),A.translate(-12,-12)}A.fill(v),A.restore();return}catch(v){console.error("Error drawing slider shape in engine:",v)}if(A.beginPath(),U==="Ellipse")A.ellipse(r,b,L/2,H/2,0,0,Math.PI*2);else if(U==="Rectangle")this.drawRoundRect(A,r-L/2,b-H/2,L,H,j);else if(U==="Triangle")A.moveTo(r,b-H/2),A.lineTo(r+L/2,b+H/2),A.lineTo(r-L/2,b+H/2),A.closePath();else if(U==="Diamond")A.moveTo(r,b-H/2),A.lineTo(r+L/2,b),A.lineTo(r,b+H/2),A.lineTo(r-L/2,b),A.closePath();else if(U==="Polygon"){const v=I.geometry.sides||3,V=I.geometry.radius||Math.min(L,H)/2;for(let QA=0;QA<v;QA++){const CA=QA*2*Math.PI/v-Math.PI/2,SA=r+V*Math.cos(CA),kA=b+V*Math.sin(CA);QA===0?A.moveTo(SA,kA):A.lineTo(SA,kA)}A.closePath()}else if(U==="Star"){const V=Math.min(L,H)/2,QA=V/2;for(let CA=0;CA<5*2;CA++){const SA=CA%2===0?V:QA,kA=CA*Math.PI/5-Math.PI/2;A.lineTo(r+SA*Math.cos(kA),b+SA*Math.sin(kA))}A.closePath()}else U==="Line"&&(A.moveTo(r-L/2,b),A.lineTo(r+L/2,b));A.fill()};A.fillStyle=k,K==="Line"?(A.strokeStyle=k,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):AA(K,0,0,E,a,G,S);const hA=E-J,oA=-E/2+J/2+h*hA,f=oA- -E/2;if(f>0&&(A.fillStyle=N,K==="Line"?(A.strokeStyle=N,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(oA,0),A.stroke()):K==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,f,a,G),A.fill())),A.save(),A.translate(oA,0),A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4,A.shadowOffsetY=1,A.fillStyle=d,AA(t,0,0,J,R,e,t==="Icon"?c:p),A.restore(),Y){A.save(),A.translate(oA+z,BA);const U=Math.round(i).toString();A.font="10px Inter, sans-serif";const r=A.measureText(U),b=6,L=4,H=r.width+b*2,j=14+L;A.beginPath(),this.drawRoundRect(A,-H/2,-j/2,H,j,4),A.fillStyle=l,A.fill(),A.fillStyle=O,A.textAlign="center",A.textBaseline="middle",A.fillText(U,0,0),A.restore()}const m=C.label||{},x=C.helperText||{},Z=C.fontFamily||"Inter";if(m.visible!==!1){const U=m.text||"Label",r=m.fontSize||12,b=m.color||"rgba(156, 163, 175, 1)",L=m.offset??8;A.font=`600 ${r}px "${Z}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="bottom";const H=-(E/2),j=-(a/2)-L;A.fillText(U,H,j)}if(x.visible===!0){const U=x.text||"Helper text",r=x.fontSize||11,b=x.color||"rgba(156, 163, 175, 1)",L=x.offset??6;A.font=`400 ${r}px "${Z}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="top";const H=-(E/2),j=a/2+L;A.fillText(U,H,j)}}renderDropdown(A,I){var BA;const Q=this.objectStates.get(I.id);if(!Q)return;const g=Q.options||I.options||{},C=I.geometry.width||160,E=I.geometry.height||40,i=-C/2,w=-E/2,o=g.corner_radius??6,s=g.disabled||g.previewState==="disabled",h=this.lastHoveredObjectId===I.id||g.previewState==="hover",a=(g.isOpen||g.previewState==="active")&&!s;let G=g.backgroundColor,K=g.borderColor,S=g.color||"#333333";s?(G=g.disabledBackgroundColor||"#f3f4f6",K=g.disabledBorderColor||"#e5e7eb",S=g.disabledColor||"#9ca3af"):a?(G=g.activeBackgroundColor||G,K=g.activeBorderColor||K,S=g.activeColor||S):h&&(G=g.hoverBackgroundColor||G,K=g.hoverBorderColor||K,S=g.hoverColor||S),G||(G="#ffffff"),K||(K="#e5e7eb");const N=A.globalAlpha;A.globalAlpha=N*(g.opacity??1),this.drawRoundRect(A,i,w,C,E,o),A.fillStyle=this.createCanvasFill(A,typeof G=="string"?{type:"Solid",color:G}:G,C,E)||"#ffffff",A.fill();const k=g.borderWidth??1;k>0&&(A.strokeStyle=this.createCanvasFill(A,typeof K=="string"?{type:"Solid",color:K}:K,C,E)||"#e5e7eb",A.lineWidth=k,A.stroke());const t=12,J=g.chevronType||"chevron",R=g.chevronSize||16,e=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(J!=="none"){const AA=i+C-t-R/2;A.save(),A.translate(AA,0);const hA=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(hA*Math.PI/180),A.strokeStyle=e,A.fillStyle=e,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",J==="chevron")A.beginPath(),A.moveTo(-R/2,-R*.2),A.lineTo(0,R*.2),A.lineTo(R/2,-R*.2),A.stroke();else if(J==="custom"||J==="path"){const oA=a&&g.openIconPath||g.closedIconPath;if(oA){const f=new Path2D(oA);A.save();const m=R/24;A.scale(m,m),A.translate(-12,-12),A.fill(f),A.restore()}}A.restore()}const d=g.selectedOption||g.placeholder||"Select...",p=g.fontSize||14,c=g.fontWeight||400,Y=g.fontFamily||"Inter, sans-serif";A.font=`${c} ${p}px ${Y}`;const l=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":S;A.fillStyle=this.createCanvasFill(A,typeof l=="string"?{type:"Solid",color:l}:l,C,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const O=J==="none"?0:R+8,z=C-t*2-O;if(A.save(),A.beginPath(),A.rect(i+t,w,z,E),A.clip(),A.fillText(d,i+t,0),A.restore(),a&&!s){const AA=w+E+4,hA=g.optionsList||[],oA=g.itemHeight||32,f=g.listPadding??4,m=hA.length*oA+f*2,x=g.listCornerRadius??o;A.save();const Z=g.listShadow||{};A.shadowColor=typeof Z.color=="string"?Z.color:((BA=Z.color)==null?void 0:BA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=Z.blur??12,A.shadowOffsetY=Z.offsetY??6,A.beginPath(),this.drawRoundRect(A,i,AA,C,m,x),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},C,m)||"#ffffff",A.fill();const U=g.listBorderWidth??1;U>0&&(A.shadowColor="transparent",A.strokeStyle=this.createCanvasFill(A,typeof g.listBorderColor=="string"?{type:"Solid",color:g.listBorderColor}:g.listBorderColor||{type:"Solid",color:K},C,m)||"#e5e7eb",A.lineWidth=U,A.stroke()),A.restore();const r=g.itemFontSize||p,b=g.itemFontFamily||Y;A.font=`${c} ${r}px ${b}`,hA.forEach((L,H)=>{const j=AA+f+H*oA;if(L===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},C,oA)||"#f3f4f6",A.fillRect(i+U,j,C-U*2,oA),A.fillStyle=g.itemSelectedColor||g.activeColor||S||"#374151";else if(A.fillStyle=g.listTextColor||S||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const v=this._lastPointerPos.y-(AA+f),V=Math.floor(v/oA);H===V&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},C,oA)||"#f9fafb",A.fillRect(i+U,j,C-U*2,oA),A.fillStyle=g.itemHoverColor||S)}A.fillText(L,i+t,j+oA/2)})}A.globalAlpha=N}renderButton(A,I){var J,R,e,d;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=((J=I.geometry)==null?void 0:J.width)||120,E=((R=I.geometry)==null?void 0:R.height)||40,i=-C/2,w=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((e=g.hoverStyle)==null?void 0:e.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},K=o?((d=g.hoverStyle)==null?void 0:d.textColor)||G.color||"#ffffff":G.color||"#ffffff",S=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,w,C,E,s):h==="Ellipse"||h==="Circle"?A.ellipse(0,0,C/2,E/2,0,0,Math.PI*2):h==="Pill"&&this.drawRoundRect(A,i,w,C,E,E/2),A.fillStyle=a,A.fill();const N=G.fontSize||14,k=G.fontFamily||"Inter";A.font=`${G.fontWeight||400} ${N}px "${k}", sans-serif`,A.fillStyle=K,A.textAlign="center",A.textBaseline="middle";let t=0;if(S.enabled&&S.svgPath){const p=S.size||16,c=S.gap||8,Y=S.position==="left"?-(A.measureText(G.text||"").width/2+p/2+c/2):A.measureText(G.text||"").width/2+p/2+c/2;A.save(),A.translate(Y,0);const l=new Path2D(S.svgPath),O=p/24;A.scale(O,O),A.translate(-12,-12),A.fillStyle=S.color||K,A.fill(l),A.restore(),t=S.position==="left"?p/2+c/2:-(p/2+c/2)}A.fillText(G.text||"Button",t,0),A.restore()}renderToggleButton(A,I){var N,k;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=g.checked??!1,E=((N=I.geometry)==null?void 0:N.width)||120,i=((k=I.geometry)==null?void 0:k.height)||40,w=-E/2,o=-i/2,s=g.corner_radius??8,h=g.label||{},a=C?g.activeColor||"#3b82f6":g.inactiveColor||"#374151",G=C?g.activeTextColor||"#ffffff":g.inactiveTextColor||"#9ca3af";A.save(),A.beginPath(),this.drawRoundRect(A,w,o,E,i,s),A.fillStyle=a,A.fill();const K=h.fontSize||14,S=h.fontFamily||"Inter";A.font=`${h.fontWeight||600} ${K}px "${S}", sans-serif`,A.fillStyle=G,A.textAlign="center",A.textBaseline="middle",A.fillText(h.text||"Toggle",0,0),A.restore()}renderToggle(A,I){var t,J;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=((t=I.geometry)==null?void 0:t.width)||52,E=((J=I.geometry)==null?void 0:J.height)||30,i=-C/2,w=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,w,C,E,s),A.fillStyle=o?g.activeColor||"#10b981":g.inactiveColor||"#374151",g.disabled&&(A.globalAlpha*=.5),A.fill();const h=3,a=E-h*2,G=a/2,K=i+h,S=i+C-h-a,N=o?S:K,k=w+h;if(A.beginPath(),A.arc(N+G,k+G,G,0,Math.PI*2),A.fillStyle=g.knobColor||"#ffffff",A.fill(),g.disabled&&(A.globalAlpha*=2),g.label&&g.label.text){const R=g.label,e=R.fontSize||14,d=R.fontWeight||400,p=R.fontFamily||"Inter";A.font=`${d} ${e}px "${p}", sans-serif`,A.fillStyle=R.color||"#f3f4f6",A.textBaseline="middle";const c=R.gap||10;let Y=0,l=0;R.position==="left"?(A.textAlign="right",Y=i-c,l=0):R.position==="right"?(A.textAlign="left",Y=i+C+c,l=0):R.position==="top"?(A.textAlign="center",Y=0,l=w-c,A.textBaseline="bottom"):R.position==="bottom"?(A.textAlign="center",Y=0,l=w+E+c,A.textBaseline="top"):(A.textAlign="left",Y=i+C+c,l=0),A.fillText(R.text,Y,l)}}renderLineGraph(A,I,Q,g){let C=I.datasets||[];if((!C||C.length===0)&&(I.data||I.graphData)&&(C=[{id:"line-1",label:"Series 1",data:I.data||I.graphData||[],lineColor:I.lineColor||"#3b82f6",lineWidth:I.lineWidth||2,showArea:I.showArea||!1,areaColor:I.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:I.smoothing||!1,showPoints:I.showPoints!==void 0?I.showPoints:!0,pointSize:I.pointSize||6,pointFill:I.pointFill||"#ffffff",pointStrokeColor:I.pointStrokeColor||I.lineColor||"#3b82f6",pointStrokeWidth:I.pointStrokeWidth||2}]),!C||C.length===0||!C.some(S=>S.data&&S.data.length>=2)){A.save(),A.fillStyle="#6366f1",A.font="12px Inter, system-ui, sans-serif",A.textAlign="center",A.textBaseline="middle",A.fillText("NO DATA",0,0),A.restore();return}let E=1/0,i=-1/0,w=0;if(C.forEach(S=>{let N=S.data;if(S.isVarEnabled&&S.inputId){let k=this.inputs.get(S.inputId);if(k===void 0){const t=this.inputNameMap.get(S.inputId);t&&t.length>0&&(k=this.inputs.get(t[0]))}k&&Array.isArray(k)&&(N=k)}if(N&&N.length>0){const k=N.filter(t=>typeof t=="number"&&!isNaN(t));k.length>0&&(E=Math.min(E,...k),i=Math.max(i,...k),w=Math.max(w,N.length))}S._resolvedData=N}),w<2)return;const o=i-E,s=Q/(w-1),h=S=>{const N=o===0?.5:(S-E)/o;return g/2-N*g},a=S=>S*s-Q/2,G=I.axisColor||"#333333";if(I.showXAxis&&(A.beginPath(),A.strokeStyle=I.xAxisColor||G,A.lineWidth=1,A.moveTo(-Q/2,g/2),A.lineTo(Q/2,g/2),A.stroke()),I.showYAxis&&(A.beginPath(),A.strokeStyle=I.yAxisColor||G,A.lineWidth=1,A.moveTo(-Q/2,-g/2),A.lineTo(-Q/2,g/2),A.stroke()),A.fillStyle=I.axisLabelColor||"#333333",A.font=`${I.axisLabelFontSize||10}px Inter, sans-serif`,I.showXLabels){A.textAlign="center",A.textBaseline="top";for(let S=0;S<w;S++){const N=a(S);A.fillText(`${S+1}`,N,g/2+5)}}if(I.showYLabels){A.textAlign="right",A.textBaseline="middle";const S=-Q/2-5,N=(i+E)/2;A.fillText(i.toFixed(1),S,h(i)),A.fillText(N.toFixed(1),S,h(N)),A.fillText(E.toFixed(1),S,h(E))}const K=10;if(C.forEach(S=>{const N=S._resolvedData;if(!(!N||N.length<2)){if(S.showArea){if(A.beginPath(),A.moveTo(a(0),g/2),A.lineTo(a(0),h(N[0])),S.smoothing&&N.length>2)for(let t=0;t<N.length-1;t++){const J=N[t===0?t:t-1],R=N[t],e=N[t+1],d=N[t+1===N.length-1?t+1:t+2];for(let p=1;p<=K;p++){const c=p/K,Y=this._catmullRom(J,R,e,d,c);A.lineTo(a(t+c),h(Y))}}else for(let t=1;t<N.length;t++)A.lineTo(a(t),h(N[t]));A.lineTo(a(N.length-1),g/2),A.closePath();const k=A.globalAlpha;A.globalAlpha=k*(I.areaOpacity??.3),A.fillStyle=S.areaColor||"rgba(139, 92, 246, 0.2)",A.fill(),A.globalAlpha=k}if(A.beginPath(),A.strokeStyle=S.lineColor||"#3b82f6",A.lineWidth=S.lineWidth||2,A.lineJoin="round",A.lineCap="round",A.moveTo(a(0),h(N[0])),S.smoothing&&N.length>2)for(let k=0;k<N.length-1;k++){const t=N[k===0?k:k-1],J=N[k],R=N[k+1],e=N[k+1===N.length-1?k+1:k+2];for(let d=1;d<=K;d++){const p=d/K,c=this._catmullRom(t,J,R,e,p);A.lineTo(a(k+p),h(c))}}else for(let k=1;k<N.length;k++)A.lineTo(a(k),h(N[k]));A.stroke(),S.showPoints&&N.forEach((k,t)=>{const J=a(t),R=h(k);A.beginPath(),A.arc(J,R,(S.pointSize||6)/2,0,Math.PI*2),A.fillStyle=S.pointFill||"#ffffff",A.fill(),A.strokeStyle=S.pointStrokeColor||S.lineColor||"#3b82f6",A.lineWidth=S.pointStrokeWidth||1,A.stroke()})}}),I.showLegend&&C.length>0){const S=Q/2-10;let N=-g/2+15;const k=I.legendFontSize||10,t=k+5;A.font=`${k}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",C.forEach(J=>{const e=J.label||"Series",d=A.measureText(e).width;A.beginPath(),A.rect(S-d-8-5,N-(8/2+2),8,8),A.fillStyle=J.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(e,S,N),N+=t})}}_catmullRom(A,I,Q,g,C){const E=(Q-A)*.5,i=(g-I)*.5,w=C*C,o=C*w;return(2*I-2*Q+E+i)*o+(-3*I+3*Q-2*E-i)*w+E*C+I}normalizeOpacity(A){const I=typeof A=="number"?A:parseFloat(String(A))||100;return I>1?I/100:I}createCanvasFill(A,I,Q,g){var C,E,i;if(!I||I.type==="None")return null;if(I.type==="Solid"&&I.color){const w=I.color,s=(((E=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:E.colors)||{})[w]||w;return A.fillStyle=s,s}if((I.type==="LinearGradient"||I.type==="RadialGradient"||I.type==="AngularGradient"||I.type==="DiamondGradient")&&I.stops){const w=(o,s=100)=>{var R,e;const a=(((e=(R=this.artboard)==null?void 0:R.tokens)==null?void 0:e.colors)||{})[o]||o,G=this.normalizeOpacity(I.opacity??100),S=this.normalizeOpacity(s)*G;if(S>=1&&a.startsWith("#"))return a;const N=a.startsWith("#")?a.replace("#",""):"ffffff",k=parseInt(N.substring(0,2),16),t=parseInt(N.substring(2,4),16),J=parseInt(N.substring(4,6),16);return`rgba(${k}, ${t}, ${J}, ${S})`};if(I.type==="LinearGradient"){const o=(S,N,k)=>Array.isArray(S)?S[N]??(N===0?0:1):S&&typeof S=="object"?S[k]??(N===0?0:1):N===0?0:1,s=o(I.start,0,"x")*Q-Q/2,h=o(I.start,1,"y")*g-g/2,a=o(I.end,0,"x")*Q-Q/2,G=o(I.end,1,"y")*g-g/2,K=A.createLinearGradient(s,h,a,G);if(I.stops.forEach(S=>{const N=S.offset!==void 0?S.offset:S.pos!==void 0?S.pos:S.position!==void 0?S.position:0,k=w(S.color||"#000000",S.opacity??100);K.addColorStop(Math.max(0,Math.min(1,N)),k)}),I.gradientTransform&&K.setTransform){const[S,N,k,t,J,R]=I.gradientTransform;K.setTransform({a:S,b:N,c:k,d:t,e:J,f:R})}return K}else if(I.type==="RadialGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center,0,"x")*Q-Q/2,h=o(I.center,1,"y")*g-g/2,a=(I.radius??.5)*Math.max(Q,g),G=A.createRadialGradient(s,h,0,s,h,a);if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return G}else if(I.type==="AngularGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center||[.5,.5],0,"x")*Q-Q/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.degree||I.angle||0)*(Math.PI/180),G=(i=A.createConicGradient)==null?void 0:i.call(A,a,s,h);if(G){if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return G}}else if(I.type==="DiamondGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center||[.5,.5],0,"x")*Q-Q/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.radius??.5)*Math.max(Q,g);A.save(),A.translate(s,h),A.rotate(Math.PI/4);const G=A.createRadialGradient(0,0,0,0,0,a);if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return A.scale(1/Math.SQRT2,1/Math.SQRT2),A.fillStyle=G,A.restore(),G}}if(I.type==="Pattern"&&I.url){let w=this.imageCache.get(I.url);if(w||(w=new Image,w.src=I.url,this.imageCache.set(I.url,w)),w.complete&&w.naturalWidth>0){const o=A.createPattern(w,"repeat");if(o&&(I.scaleX!==void 0||I.offsetX!==void 0)){const s=new DOMMatrix,h=I.scaleX??1,a=I.scaleY??1,G=I.offsetX??0,K=I.offsetY??0,S=I.rotation??0;s.translateSelf(G,K),s.rotateSelf(S),s.scaleSelf(h,a),o.setTransform(s)}return o}}return I.color||null}drawRoundRect(A,I,Q,g,C,E){if(E===0||E===void 0||E===null){A.rect(I,Q,g,C);return}let i=E;if(typeof i=="string")try{i=JSON.parse(i)}catch{i=parseFloat(i)||0}let w=0,o=0,s=0,h=0;typeof i=="number"?w=o=s=h=i:Array.isArray(i)?i.length===1?w=o=s=h=i[0]:i.length===2?(w=s=i[0],o=h=i[1]):i.length===3?(w=i[0],o=h=i[1],s=i[2]):i.length>=4&&(w=i[0],o=i[1],s=i[2],h=i[3]):i&&typeof i=="object"&&(w=i.tl??i.corner_radius??i.cornerRadius??0,o=i.tr??i.corner_radius??i.cornerRadius??0,s=i.br??i.corner_radius??i.cornerRadius??0,h=i.bl??i.corner_radius??i.cornerRadius??0);const a=Math.min(Math.abs(g)/2,Math.abs(C)/2);if(w=Math.min(Math.max(0,w),a),o=Math.min(Math.max(0,o),a),s=Math.min(Math.max(0,s),a),h=Math.min(Math.max(0,h),a),A.roundRect){A.roundRect(I,Q,g,C,[w,o,s,h]);return}A.moveTo(I+w,Q),A.lineTo(I+g-o,Q),A.arcTo(I+g,Q,I+g,Q+o,o),A.lineTo(I+g,Q+C-s),A.arcTo(I+g,Q+C,I+g-s,Q+C,s),A.lineTo(I+h,Q+C),A.arcTo(I,Q+C,I,Q+C-h,h),A.lineTo(I,Q+w),A.arcTo(I,Q,I+w,Q,w),A.closePath()}renderListView(A,I){var AA,hA,oA,f;const Q=this.objectStates.get(I.id)||{},g=Q.options||I.options||{},C=Q.width!==void 0?Q.width:((AA=I.geometry)==null?void 0:AA.width)||200,E=Q.height!==void 0?Q.height:((hA=I.geometry)==null?void 0:hA.height)||300,i=-C/2,w=-E/2,o=Q.corner_radius!==void 0?Q.corner_radius:g.corner_radius??0,s=g.orientation||"vertical",h=g.items||[],a=g.itemGap??10,G=g.itemHeight??50,K=g.itemWidth??200,S=g.scrollOffset??0,N=g.padding??0,k=g.glassEffect!==!1,t=g.accentColor||"#3b82f6",J=g.itemTextColor||"#333333",R=g.itemBackgroundColor||"#ffffff",e=g.hoveredIndex??null,d=g.activeItemIndex??null,p=g.glowIntensity??0,c=g.glowColor||"#3b82f6",Y=typeof c=="string"?c:c.color||((f=(oA=c.stops)==null?void 0:oA[0])==null?void 0:f.color)||"#3b82f6",l=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=l,p>0&&(A.shadowColor=Y,A.shadowBlur=p*2,A.shadowOffsetX=0,A.shadowOffsetY=0),k){const m=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",x=this.createCanvasFill(A,m,C,E);A.fillStyle=x||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,C,E,o),A.fill();const Z=A.createLinearGradient(i,w,i+C,w+E);Z.addColorStop(0,"rgba(255, 255, 255, 0.15)"),Z.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),Z.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=Z,this.drawListViewRect(A,i,w,C,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,w,C,E,o),A.stroke()}else{const m=g.listBackgroundColor||"transparent",x=this.createCanvasFill(A,m,C,E);x&&(A.fillStyle=x,this.drawListViewRect(A,i,w,C,E,o),A.fill());const Z=g.borderWidth??0;Z>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=Z,this.drawListViewRect(A,i,w,C,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,w,C,E,o),A.clip();const O=typeof N=="number"?N:s==="vertical"?N[0]:N[3];let z=(s==="vertical"?w:i)+S+O;if(A.textBaseline="middle",h.forEach((m,x)=>{const Z=s==="vertical"?C:K,U=s==="vertical"?G:E,r=s==="vertical"?i:z,b=s==="vertical"?z:w,L=e===x,H=d===x;if(H){const QA=this.createCanvasFill(A,t,Z,U);A.fillStyle=QA||t;const CA=A.globalAlpha;A.globalAlpha=CA*.8,A.fillRect(r,b,Z,U),A.globalAlpha=CA}else if(L)A.fillStyle=k?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(r,b,Z,U);else if(R!=="transparent"){const QA=this.createCanvasFill(A,R,Z,U);A.fillStyle=QA||R,A.fillRect(r,b,Z,U)}if(H||L){const QA=this.createCanvasFill(A,t,s==="vertical"?3:Z,s==="vertical"?U:3);A.fillStyle=QA||t,s==="vertical"?A.fillRect(r,b,3,U):A.fillRect(r,b+U-3,Z,3)}const j=H?"#ffffff":k?"rgba(255, 255, 255, 0.9)":J;A.fillStyle=j,A.font=H||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const EA=typeof m=="string"?m:(m==null?void 0:m.label)||`Item ${x+1}`,v=r+(s==="vertical"?16:Z/2),V=b+U/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(EA,v,V),z+=(s==="vertical"?G:K)+a}),A.restore(),g.showScrollbar!==!1){const m=(h.length||0)*(s==="vertical"?G:K)+((h.length||0)-1)*a,x=s==="vertical"?E:C;if(m>x){const Z=x/m,U=x*Z,r=-S/m*x,b=g.scrollbarColor||"rgba(255,255,255,0.3)",L=g.scrollbarWidth||4;A.fillStyle=b,s==="vertical"?A.fillRect(i+C-L-2,w+r,L,U):A.fillRect(i+r,w+E-L-2,U,L)}}A.restore()}updateListViewScrollFromPointer(A){var N,k;if(!this._lastPointerPos||!this._prevPointerPos)return;const I=A.options||{},Q=I.orientation||"vertical",g=this._lastPointerPos.x-this._prevPointerPos.x,C=this._lastPointerPos.y-this._prevPointerPos.y;Q==="vertical"?I.scrollOffset=(I.scrollOffset||0)+C:I.scrollOffset=(I.scrollOffset||0)+g;const E=this.objectStates.get(A.id)||{},i=I.items||[],w=I.itemGap??10,o=I.itemHeight??50,s=I.itemWidth??200,h=E.width!==void 0?E.width:((N=A.geometry)==null?void 0:N.width)||200,a=E.height!==void 0?E.height:((k=A.geometry)==null?void 0:k.height)||300,G=(i.length||0)*(Q==="vertical"?o:s)+((i.length||0)-1)*w,S=Math.max(0,G-(Q==="vertical"?a:h)+(I.padding*2||0));I.scrollOffset>0&&(I.scrollOffset=0),I.scrollOffset<-S&&(I.scrollOffset=-S)}updateListViewHoverFromPointer(A,I,Q){const g=this.getListViewItemIndexAtPointer(A,I,Q),C=A.options||{};C.hoveredIndex!==g&&(C.hoveredIndex=g)}getListViewItemIndexAtPointer(A,I,Q){var O,z;const g=A.options||{},C=this.objectStates.get(A.id)||{},E=g.items||[];if(E.length===0)return null;const i=C.width!==void 0?C.width:((O=A.geometry)==null?void 0:O.width)||200,w=C.height!==void 0?C.height:((z=A.geometry)==null?void 0:z.height)||300,o=g.orientation||"vertical",s=g.itemGap??10,h=g.itemHeight??50,a=g.itemWidth??200,G=g.scrollOffset??0,K=g.padding??0,S=this.getWorldTransform(A.id),N=I-S.x,k=Q-S.y,t=-S.rotation*(Math.PI/180),J=Math.cos(t),R=Math.sin(t),e=N*J-k*R,d=N*R+k*J,p=-i/2,c=-w/2,Y=typeof K=="number"?K:o==="vertical"?K[0]:K[3];let l=(o==="vertical"?c:p)+G+Y;for(let BA=0;BA<E.length;BA++){const AA=o==="vertical"?i:a,hA=o==="vertical"?h:w,oA=o==="vertical"?p:l,f=o==="vertical"?l:c;if(e>=oA&&e<=oA+AA&&d>=f&&d<=f+hA)return BA;l+=(o==="vertical"?h:a)+s}return null}drawListViewRect(A,I,Q,g,C,E){A.beginPath(),this.drawRoundRect(A,I,Q,g,C,E),A.fill()}solveBehaviors(A){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:I,y:Q}=this._lastPointerPos;this.artboard.objects.forEach(g=>{if(!g.behaviors||g.behaviors.length===0)return;const C=this.objectStates.get(g.id);C&&g.behaviors.forEach(E=>{var a,G,K,S,N,k,t,J,R,e,d,p,c,Y,l,O,z,BA,AA,hA,oA,f,m,x,Z,U,r,b,L,H,j,EA,v,V,QA,CA,SA,kA,qA,MA,JA,rA,pA,xA;if(!E.enabled)return;const i=E.startTime||0,w=E.endTime||1/0;if(this.currentTime<i||this.currentTime>w)return;const o=C.x-I,s=C.y-Q,h=Math.sqrt(o*o+s*s);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${E.type} on ${g.name}`),E.type===q.Proximity){const u=((a=E.settings)==null?void 0:a.radius)||300,n=((G=E.settings)==null?void 0:G.falloff)||"smooth";let T=0;h<u&&(n==="linear"?T=1-h/u:T=Math.pow(1-h/u,2)),T>0&&E.sensors.forEach(IA=>{this.applyBehaviorSensor(C,IA,T,A,E.settings)})}else if(E.type===q.Magnetic){const u=((K=E.settings)==null?void 0:K.radius)||400,n=((S=E.settings)==null?void 0:S.strength)||.5;if(h<u&&h>5){const T=1-h/u,IA=o*T*n,sA=s*T*n;C.x-=IA*A*10,C.y-=sA*A*10}}else if(E.type===q.Repel){const u=((N=E.settings)==null?void 0:N.radius)||300,n=((k=E.settings)==null?void 0:k.strength)||1;if(h<u){const T=Math.pow(1-h/u,2);C.x+=o/(h||1)*T*60*n*A*5,C.y+=s/(h||1)*T*60*n*A*5}}else if(E.type===q.Orbit){const u=((t=E.settings)==null?void 0:t.speed)||1,n=((J=E.settings)==null?void 0:J.radius)||30,T=this.currentTime*u*Math.PI*2;C.x+=Math.cos(T)*n*A*5,C.y+=Math.sin(T)*n*A*5,C.rotation+=2*A*5}else if(E.type===q.Vortex){const u=((R=E.settings)==null?void 0:R.radius)||400,n=((e=E.settings)==null?void 0:e.speed)||2,T=((d=E.settings)==null?void 0:d.strength)||1;if(h<u){const IA=Math.pow(1-h/u,1.5),sA=this.currentTime*n*Math.PI*2,VA=Math.cos(sA)*30-o*.4,fA=Math.sin(sA)*30-s*.4;C.x+=VA*IA*T*A*5,C.y+=fA*IA*T*A*5,C.rotation+=5*IA*T*A*5,C.scale_x*=1-IA*.1*T*A,C.scale_y*=1-IA*.1*T*A}}else if(E.type===q.Fluid){const u=((p=E.settings)==null?void 0:p.radius)||300,n=((c=E.settings)==null?void 0:c.strength)||1;if(h<u){const T=Math.pow(1-h/u,1.2),IA=o/(h||1)*T*1.2*n,sA=s/(h||1)*T*1.2*n;C.x+=IA*10*A*5,C.y+=sA*10*A*5,C.scale_x*=1+T*.3*n*A,C.scale_y*=1+T*.3*n*A}}else if(E.type===q.Elastic){const u=((Y=E.settings)==null?void 0:Y.radius)||300,n=((l=E.settings)==null?void 0:l.strength)||1;if(h<u){const T=1-h/u;C.scale_x*=1+T*.4*n*A,C.scale_y*=1+T*.4*n*A}}else if(E.type===q.Holographic){const u=C.x-this.canvasWidth/2,n=C.y-this.canvasHeight/2,T=((O=E.settings)==null?void 0:O.factor)||25;if(C.x-=u/1e3*T*A*5,C.y-=n/1e3*T*A*5,C.style){const IA=1-Math.min(1,h/400);C.style.exposure=(C.style.exposure||1)+IA*.5*A}}else if(E.type===q.Sticky){const u=((z=E.settings)==null?void 0:z.radius)||80,n=((BA=E.settings)==null?void 0:BA.strength)||1;if(h<u){const T=Math.pow(1-h/u,2);C.x-=o*T*n*A*10,C.y-=s*T*n*A*10,C.scale_x*=1-T*.1*n*A,C.scale_y*=1-T*.1*n*A}}else if(E.type===q.Dilation){const u=((AA=E.settings)==null?void 0:AA.size)||120,n=((hA=E.settings)==null?void 0:hA.strength)||1;if(h<u){const T=1-h/u;C.scale_x*=1+T*.5*n*A,C.scale_y*=1+T*.5*n*A}}else if(E.type===q.Parallax){const u=((oA=E.settings)==null?void 0:oA.factor)||.05,n=this.canvasHeight/2,T=(this._lastPointerPos.y-n)*u;C.y+=T*A*10}else if(E.type===q.Noise||E.type===q.Float){const u=(((f=E.settings)==null?void 0:f.frequency)||((m=E.settings)==null?void 0:m.speed)||1)*.002,n=(((x=E.settings)==null?void 0:x.amplitude)||((Z=E.settings)==null?void 0:Z.range)||50)*(((U=E.settings)==null?void 0:U.strength)||1),T=Date.now();C.x+=Math.sin(T*u)*n*A,C.y+=Math.cos(T*u*.8)*n*A,C.rotation+=Math.sin(T*u*.5)*5*A}else if(E.type===q.Pulse){const u=(((r=E.settings)==null?void 0:r.speed)||1)*.005,n=(((b=E.settings)==null?void 0:b.scale)||1.2)-1,T=Math.sin(Date.now()*u),IA=((L=E.settings)==null?void 0:L.strength)||1;C.scale_x*=1+T*n*IA*A,C.scale_y*=1+T*n*IA*A,C.style&&(C.style.exposure=(C.style.exposure||1)+Math.max(0,T)*.1*IA*A)}else if(E.type===q.Draggable){const u=((H=E.settings)==null?void 0:H.radius)||150,n=this.draggingBehaviors.has(g.id);if(h<u||n){const T=((j=E.settings)==null?void 0:j.strength)||1,IA=n?1:Math.max(0,1-h/u);this.applyBehaviorSensor(C,uA.PositionX,IA*T,A,E.settings),this.applyBehaviorSensor(C,uA.PositionY,IA*T,A,E.settings)}}else if(E.type===q.Scroll){const u=((EA=E.settings)==null?void 0:EA.axis)||"vertical",n=((v=E.settings)==null?void 0:v.factor)||.5,T=((V=E.settings)==null?void 0:V.strength)||1;(u==="vertical"||u==="both")&&(C.y+=this.scrollOffset.y*n*T*A),(u==="horizontal"||u==="both")&&(C.x+=this.scrollOffset.x*n*T*A)}else if(E.type===q.LookAt){const u=((QA=E.settings)==null?void 0:QA.factor)||1,n=((CA=E.settings)==null?void 0:CA.strength)||1,T=Math.atan2(-s,-o)*(180/Math.PI),IA=C.rotation,sA=(T-IA+180)%360-180;C.rotation+=sA*u*n*A*10}else if(E.type===q.Glint||E.type===q.Scan){const u=(((SA=E.settings)==null?void 0:SA.speed)||1)*.004,n=((kA=E.settings)==null?void 0:kA.strength)||1,T=(Math.sin(Date.now()*u)+1)/2;C.style&&(C.style.exposure=(C.style.exposure||1)+T*n*A*5),C.x+=(T-.5)*20*n*A}else if(E.type===q.Ratchet){const u=((qA=E.settings)==null?void 0:qA.steps)||12,n=(((MA=E.settings)==null?void 0:MA.speed)||1)*30,T=Math.floor(C.rotation/(360/u))*(360/u);C.rotation=this.lerp(C.rotation,T+n*A,.1)}else if(E.type===q.Jitter&&h<300){const u=((JA=E.settings)==null?void 0:JA.strength)||1,n=(((rA=E.settings)==null?void 0:rA.intensity)||5)*u;C.x+=(Math.random()-.5)*n*A*60,C.y+=(Math.random()-.5)*n*A*60,C.rotation+=(Math.random()-.5)*n*A*120}else if(E.type===q.Follower){const u=(pA=E.settings)==null?void 0:pA.targetId;if(u){const n=this.objectStates.get(u);if(n){const T=((xA=E.settings)==null?void 0:xA.stiffness)||.1,IA=n.x-C.x,sA=n.y-C.y;C.x+=IA*T*A*60,C.y+=sA*T*A*60}}}else E.type===q.Wrap&&(C.x<0?C.x=this.canvasWidth:C.x>this.canvasWidth&&(C.x=0),C.y<0?C.y=this.canvasHeight:C.y>this.canvasHeight&&(C.y=0))})})}applyBehaviorSensor(A,I,Q,g,C){const E=(C==null?void 0:C.intensity)||(C==null?void 0:C.strength)||1,i=Q*E*g;switch(I){case uA.Scale:A.scale_x*=1+i*.5,A.scale_y*=1+i*.5;break;case uA.Opacity:A.opacity=Math.max(0,Math.min(100,A.opacity-i*100));break;case uA.RotateZ:A.rotation+=i*180;break;case uA.RotateX:A.rotate_x=(A.rotate_x||0)+i*180;break;case uA.RotateY:A.rotate_y=(A.rotate_y||0)+i*180;break;case uA.PositionX:A.x+=i*300;break;case uA.PositionY:A.y+=i*300;break;case uA.SkewX:A.skew_x=(A.skew_x||0)+i*45;break;case uA.Blur:A.style||(A.style={}),A.style.blur=Math.min(100,(A.style.blur||0)+i*50);break;case uA.Exposure:A.style||(A.style={}),A.style.exposure=(A.style.exposure||1)+i*2;break;case uA.HueShift:A.style||(A.style={}),A.style.hue=(A.style.hue||0)+i*360;break;case uA.CornerRadius:A.corner_radius=Math.min(200,(A.corner_radius||0)+i*100);break;case uA.LetterSpacing:A.geometry||(A.geometry={}),A.geometry.letterSpacing=(A.geometry.letterSpacing||0)+i*10;break}}lerp(A,I,Q){return A*(1-Q)+I*Q}deepMerge(A,I){if(!A)return I;if(!I)return A;if(typeof A!="object"||typeof I!="object"||A===null||I===null)return I;const Q={...A};for(const g in I)Object.prototype.hasOwnProperty.call(I,g)&&(I[g]&&typeof I[g]=="object"&&!Array.isArray(I[g])?Q[g]=this.deepMerge(A[g],I[g]):Q[g]=I[g]);return Q}}const Ai=NA.forwardRef(({artboard:B,src:A,className:I,style:Q,autoPlay:g=!0,fit:C="Contain",alignment:E="Center",onReady:i,onTrigger:w,onInputUpdate:o,onComponentChange:s,onToggle:h,onInputChange:a,onInputFocus:G,onInputBlur:K},S)=>{const N=NA.useRef(null),k=NA.useRef(new jQ),t=NA.useRef(),J=NA.useRef(0);NA.useImperativeHandle(S,()=>N.current),NA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),k.current.setLayout(C,E)},[C,E]),NA.useEffect(()=>{w&&k.current.setTriggerCallback(w)},[w]),NA.useEffect(()=>{o&&k.current.setInputUpdateCallback(o)},[o]),NA.useEffect(()=>{s&&k.current.setComponentChangeCallback(s)},[s]),NA.useEffect(()=>{h&&k.current.setToggleCallback(h)},[h]),NA.useEffect(()=>{a&&k.current.setInputChangeCallback(a)},[a]),NA.useEffect(()=>{G&&k.current.setInputFocusCallback(G)},[G]),NA.useEffect(()=>{K&&k.current.setInputBlurCallback(K)},[K]),NA.useEffect(()=>{(async()=>{const d=k.current;let p=B;if(!p&&A)try{p=await(await fetch(A)).json()}catch(c){console.error("Failed to load ExodeUI animation:",c);return}p&&(d.load(p),i&&i(d))})()},[B,A]),NA.useEffect(()=>{const e=k.current,d=N.current;if(!d)return;const p=d.getContext("2d");if(!p)return;const c=l=>{J.current||(J.current=l);const O=(l-J.current)/1e3;J.current=l,g&&e.advance(O);const z=window.devicePixelRatio||1,BA=d.getBoundingClientRect(),AA=Math.floor(BA.width*z),hA=Math.floor(BA.height*z);(d.width!==AA||d.height!==hA)&&(d.width=AA,d.height=hA),e.render(p,AA,hA),t.current=requestAnimationFrame(c)};t.current=requestAnimationFrame(c);const Y=()=>{e.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",Y,{passive:!0}),()=>{t.current&&cancelAnimationFrame(t.current),window.removeEventListener("scroll",Y)}},[g]);const R=(e,d)=>{const p=e.currentTarget.getBoundingClientRect(),c=e.clientX-p.left,Y=e.clientY-p.top,l=p.width,O=p.height;k.current.handlePointerInput(d,c,Y,l,O)};return _A.jsx("canvas",{ref:N,style:{width:"100%",height:"100%",outline:"none",...Q},className:I,tabIndex:0,onPointerDown:e=>{var d;R(e,"down"),(d=N.current)==null||d.focus()},onPointerUp:e=>R(e,"up"),onPointerMove:e=>R(e,"move"),onPointerLeave:e=>R(e,"blur"),onClick:e=>R(e,"click"),onKeyDown:e=>{e.key==="Backspace"||e.key==="Enter"||e.key,k.current.handleKeyDown(e.nativeEvent)}})});function Ii(){const[B,A]=NA.useState(null),I=NA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),Q=NA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=NA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),C=NA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=NA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=NA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=NA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=NA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=NA.useCallback((h,a)=>{B==null||B.updateGraphData(h,a)},[B]);return{setEngine:A,engine:B,setInputBool:I,setInputNumber:Q,fireTrigger:g,setInputText:C,setInputNumberArray:E,setInputStringArray:i,updateConstraint:o,updateGraphData:s,updateObjectOptions:w}}const gi="2.6.42";LA.BehaviorSensor=uA,LA.BehaviorType=q,LA.ConditionOp=cC,LA.ExodeUICanvas=Ai,LA.ExodeUIEngine=jQ,LA.LogicOp=UI,LA.VERSION=gi,LA.useExodeUI=Ii,Object.defineProperty(LA,Symbol.toStringTag,{value:"Module"})});
|
|
8
|
+
`);let V=-E/2+Z;const QA=f*1.2;let CA=0;v.forEach((SA,kA)=>{const qA=SA.split(" ");let MA="";for(let JA=0;JA<qA.length;JA++){const rA=MA+qA[JA]+" ";A.measureText(rA).width>L&&JA>0?(A.fillText(MA,b,V),MA=qA[JA]+" ",V+=QA):MA=rA}A.fillText(MA,b,V),CA=A.measureText(MA).width,kA<v.length-1&&(V+=QA,CA=0)}),i&&!AA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(b+CA,V,1.5,f)}else{const V=A.measureText(H).width;let QA=0;if(V>L&&(QA=V-L),A.fillText(H,b-QA,0),i&&!AA&&Math.floor(performance.now()/500)%2===0){const SA=b+V-QA;A.fillRect(SA,-(f/2),1.5,f)}}if(A.restore(),h.visible!==!1){const v=h.text||"Label",V=h.fontSize||12,QA=h.color||"rgba(156, 163, 175, 1)",CA=h.offset??8;A.font=`600 ${V}px "${m}", sans-serif`,A.fillStyle=QA,A.textAlign="left",A.textBaseline="bottom";const SA=-(C/2),kA=-(E/2)-CA;A.fillText(v,SA,kA)}if(a.visible===!0){const v=a.text||"Helper text",V=a.fontSize||11,QA=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",CA=a.offset??6;A.font=`400 ${V}px "${m}", sans-serif`,A.fillStyle=QA,A.textAlign="left",A.textBaseline="top";const SA=-(C/2),kA=E/2+CA;A.fillText(v,SA,kA)}}renderSlider(A,I){const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.geometry)||I.geometry,C=(Q==null?void 0:Q.options)||I.options||{},E=g.width||200,i=C.value??50,w=C.min??0,s=(C.max??100)-w,h=s===0?0:(i-w)/s,a=C.trackHeight||4,G=C.trackRoundedness??2,K=C.trackShape??"Rectangle",S=C.trackPath||"",N=C.activeColor||"#3b82f6",k=C.inactiveColor||"#374151",t=C.thumbShape||"Ellipse",J=C.thumbWidth??16,R=C.thumbHeight??16,e=C.thumbRoundedness??0,d=C.thumbColor||"#ffffff",p=C.thumbPath||"",c=C.thumbIcon||"",Y=C.showValueTooltip??!1,l=C.tooltipBgColor||"#333333",O=C.tooltipColor||"#ffffff",z=C.tooltipOffsetX??0,BA=C.tooltipOffsetY??-25,AA=(U,r,b,L,H,j,EA)=>{if((U==="Custom"||U==="Icon")&&EA)try{const v=new Path2D(EA);if(A.save(),A.translate(r,b),U==="Icon"){const V=Math.min(L,H)/24;A.scale(V,V),A.translate(-12,-12)}A.fill(v),A.restore();return}catch(v){console.error("Error drawing slider shape in engine:",v)}if(A.beginPath(),U==="Ellipse")A.ellipse(r,b,L/2,H/2,0,0,Math.PI*2);else if(U==="Rectangle")this.drawRoundRect(A,r-L/2,b-H/2,L,H,j);else if(U==="Triangle")A.moveTo(r,b-H/2),A.lineTo(r+L/2,b+H/2),A.lineTo(r-L/2,b+H/2),A.closePath();else if(U==="Diamond")A.moveTo(r,b-H/2),A.lineTo(r+L/2,b),A.lineTo(r,b+H/2),A.lineTo(r-L/2,b),A.closePath();else if(U==="Polygon"){const v=I.geometry.sides||3,V=I.geometry.radius||Math.min(L,H)/2;for(let QA=0;QA<v;QA++){const CA=QA*2*Math.PI/v-Math.PI/2,SA=r+V*Math.cos(CA),kA=b+V*Math.sin(CA);QA===0?A.moveTo(SA,kA):A.lineTo(SA,kA)}A.closePath()}else if(U==="Star"){const V=Math.min(L,H)/2,QA=V/2;for(let CA=0;CA<5*2;CA++){const SA=CA%2===0?V:QA,kA=CA*Math.PI/5-Math.PI/2;A.lineTo(r+SA*Math.cos(kA),b+SA*Math.sin(kA))}A.closePath()}else U==="Line"&&(A.moveTo(r-L/2,b),A.lineTo(r+L/2,b));A.fill()};A.fillStyle=k,K==="Line"?(A.strokeStyle=k,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):AA(K,0,0,E,a,G,S);const hA=E-J,oA=-E/2+J/2+h*hA,f=oA- -E/2;if(f>0&&(A.fillStyle=N,K==="Line"?(A.strokeStyle=N,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(oA,0),A.stroke()):K==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,f,a,G),A.fill())),A.save(),A.translate(oA,0),A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4,A.shadowOffsetY=1,A.fillStyle=d,AA(t,0,0,J,R,e,t==="Icon"?c:p),A.restore(),Y){A.save(),A.translate(oA+z,BA);const U=Math.round(i).toString();A.font="10px Inter, sans-serif";const r=A.measureText(U),b=6,L=4,H=r.width+b*2,j=14+L;A.beginPath(),this.drawRoundRect(A,-H/2,-j/2,H,j,4),A.fillStyle=l,A.fill(),A.fillStyle=O,A.textAlign="center",A.textBaseline="middle",A.fillText(U,0,0),A.restore()}const m=C.label||{},x=C.helperText||{},Z=C.fontFamily||"Inter";if(m.visible!==!1){const U=m.text||"Label",r=m.fontSize||12,b=m.color||"rgba(156, 163, 175, 1)",L=m.offset??8;A.font=`600 ${r}px "${Z}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="bottom";const H=-(E/2),j=-(a/2)-L;A.fillText(U,H,j)}if(x.visible===!0){const U=x.text||"Helper text",r=x.fontSize||11,b=x.color||"rgba(156, 163, 175, 1)",L=x.offset??6;A.font=`400 ${r}px "${Z}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="top";const H=-(E/2),j=a/2+L;A.fillText(U,H,j)}}renderDropdown(A,I){var BA;const Q=this.objectStates.get(I.id);if(!Q)return;const g=Q.options||I.options||{},C=I.geometry.width||160,E=I.geometry.height||40,i=-C/2,w=-E/2,o=g.corner_radius??6,s=g.disabled||g.previewState==="disabled",h=this.lastHoveredObjectId===I.id||g.previewState==="hover",a=(g.isOpen||g.previewState==="active")&&!s;let G=g.backgroundColor,K=g.borderColor,S=g.color||"#333333";s?(G=g.disabledBackgroundColor||"#f3f4f6",K=g.disabledBorderColor||"#e5e7eb",S=g.disabledColor||"#9ca3af"):a?(G=g.activeBackgroundColor||G,K=g.activeBorderColor||K,S=g.activeColor||S):h&&(G=g.hoverBackgroundColor||G,K=g.hoverBorderColor||K,S=g.hoverColor||S),G||(G="#ffffff"),K||(K="#e5e7eb");const N=A.globalAlpha;A.globalAlpha=N*(g.opacity??1),this.drawRoundRect(A,i,w,C,E,o),A.fillStyle=this.createCanvasFill(A,typeof G=="string"?{type:"Solid",color:G}:G,C,E)||"#ffffff",A.fill();const k=g.borderWidth??1;k>0&&(A.strokeStyle=this.createCanvasFill(A,typeof K=="string"?{type:"Solid",color:K}:K,C,E)||"#e5e7eb",A.lineWidth=k,A.stroke());const t=12,J=g.chevronType||"chevron",R=g.chevronSize||16,e=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(J!=="none"){const AA=i+C-t-R/2;A.save(),A.translate(AA,0);const hA=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(hA*Math.PI/180),A.strokeStyle=e,A.fillStyle=e,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",J==="chevron")A.beginPath(),A.moveTo(-R/2,-R*.2),A.lineTo(0,R*.2),A.lineTo(R/2,-R*.2),A.stroke();else if(J==="custom"||J==="path"){const oA=a&&g.openIconPath||g.closedIconPath;if(oA){const f=new Path2D(oA);A.save();const m=R/24;A.scale(m,m),A.translate(-12,-12),A.fill(f),A.restore()}}A.restore()}const d=g.selectedOption||g.placeholder||"Select...",p=g.fontSize||14,c=g.fontWeight||400,Y=g.fontFamily||"Inter, sans-serif";A.font=`${c} ${p}px ${Y}`;const l=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":S;A.fillStyle=this.createCanvasFill(A,typeof l=="string"?{type:"Solid",color:l}:l,C,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const O=J==="none"?0:R+8,z=C-t*2-O;if(A.save(),A.beginPath(),A.rect(i+t,w,z,E),A.clip(),A.fillText(d,i+t,0),A.restore(),a&&!s){const AA=w+E+4,hA=g.optionsList||[],oA=g.itemHeight||32,f=g.listPadding??4,m=hA.length*oA+f*2,x=g.listCornerRadius??o;A.save();const Z=g.listShadow||{};A.shadowColor=typeof Z.color=="string"?Z.color:((BA=Z.color)==null?void 0:BA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=Z.blur??12,A.shadowOffsetY=Z.offsetY??6,A.beginPath(),this.drawRoundRect(A,i,AA,C,m,x),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},C,m)||"#ffffff",A.fill();const U=g.listBorderWidth??1;U>0&&(A.shadowColor="transparent",A.strokeStyle=this.createCanvasFill(A,typeof g.listBorderColor=="string"?{type:"Solid",color:g.listBorderColor}:g.listBorderColor||{type:"Solid",color:K},C,m)||"#e5e7eb",A.lineWidth=U,A.stroke()),A.restore();const r=g.itemFontSize||p,b=g.itemFontFamily||Y;A.font=`${c} ${r}px ${b}`,hA.forEach((L,H)=>{const j=AA+f+H*oA;if(L===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},C,oA)||"#f3f4f6",A.fillRect(i+U,j,C-U*2,oA),A.fillStyle=g.itemSelectedColor||g.activeColor||S||"#374151";else if(A.fillStyle=g.listTextColor||S||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const v=this._lastPointerPos.y-(AA+f),V=Math.floor(v/oA);H===V&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},C,oA)||"#f9fafb",A.fillRect(i+U,j,C-U*2,oA),A.fillStyle=g.itemHoverColor||S)}A.fillText(L,i+t,j+oA/2)})}A.globalAlpha=N}renderButton(A,I){var J,R,e,d;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=((J=I.geometry)==null?void 0:J.width)||120,E=((R=I.geometry)==null?void 0:R.height)||40,i=-C/2,w=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((e=g.hoverStyle)==null?void 0:e.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},K=o?((d=g.hoverStyle)==null?void 0:d.textColor)||G.color||"#ffffff":G.color||"#ffffff",S=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,w,C,E,s):h==="Ellipse"||h==="Circle"?A.ellipse(0,0,C/2,E/2,0,0,Math.PI*2):h==="Pill"&&this.drawRoundRect(A,i,w,C,E,E/2),A.fillStyle=a,A.fill();const N=G.fontSize||14,k=G.fontFamily||"Inter";A.font=`${G.fontWeight||400} ${N}px "${k}", sans-serif`,A.fillStyle=K,A.textAlign="center",A.textBaseline="middle";let t=0;if(S.enabled&&S.svgPath){const p=S.size||16,c=S.gap||8,Y=S.position==="left"?-(A.measureText(G.text||"").width/2+p/2+c/2):A.measureText(G.text||"").width/2+p/2+c/2;A.save(),A.translate(Y,0);const l=new Path2D(S.svgPath),O=p/24;A.scale(O,O),A.translate(-12,-12),A.fillStyle=S.color||K,A.fill(l),A.restore(),t=S.position==="left"?p/2+c/2:-(p/2+c/2)}A.fillText(G.text||"Button",t,0),A.restore()}renderToggleButton(A,I){var N,k;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=g.checked??!1,E=((N=I.geometry)==null?void 0:N.width)||120,i=((k=I.geometry)==null?void 0:k.height)||40,w=-E/2,o=-i/2,s=g.corner_radius??8,h=g.label||{},a=C?g.activeColor||"#3b82f6":g.inactiveColor||"#374151",G=C?g.activeTextColor||"#ffffff":g.inactiveTextColor||"#9ca3af";A.save(),A.beginPath(),this.drawRoundRect(A,w,o,E,i,s),A.fillStyle=a,A.fill();const K=h.fontSize||14,S=h.fontFamily||"Inter";A.font=`${h.fontWeight||600} ${K}px "${S}", sans-serif`,A.fillStyle=G,A.textAlign="center",A.textBaseline="middle",A.fillText(h.text||"Toggle",0,0),A.restore()}renderToggle(A,I){var t,J;const Q=this.objectStates.get(I.id),g=(Q==null?void 0:Q.options)||I.options||{},C=((t=I.geometry)==null?void 0:t.width)||52,E=((J=I.geometry)==null?void 0:J.height)||30,i=-C/2,w=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,w,C,E,s),A.fillStyle=o?g.activeColor||"#10b981":g.inactiveColor||"#374151",g.disabled&&(A.globalAlpha*=.5),A.fill();const h=3,a=E-h*2,G=a/2,K=i+h,S=i+C-h-a,N=o?S:K,k=w+h;if(A.beginPath(),A.arc(N+G,k+G,G,0,Math.PI*2),A.fillStyle=g.knobColor||"#ffffff",A.fill(),g.disabled&&(A.globalAlpha*=2),g.label&&g.label.text){const R=g.label,e=R.fontSize||14,d=R.fontWeight||400,p=R.fontFamily||"Inter";A.font=`${d} ${e}px "${p}", sans-serif`,A.fillStyle=R.color||"#f3f4f6",A.textBaseline="middle";const c=R.gap||10;let Y=0,l=0;R.position==="left"?(A.textAlign="right",Y=i-c,l=0):R.position==="right"?(A.textAlign="left",Y=i+C+c,l=0):R.position==="top"?(A.textAlign="center",Y=0,l=w-c,A.textBaseline="bottom"):R.position==="bottom"?(A.textAlign="center",Y=0,l=w+E+c,A.textBaseline="top"):(A.textAlign="left",Y=i+C+c,l=0),A.fillText(R.text,Y,l)}}renderLineGraph(A,I,Q,g){let C=I.datasets||[];if((!C||C.length===0)&&(I.data||I.graphData)&&(C=[{id:"line-1",label:"Series 1",data:I.data||I.graphData||[],lineColor:I.lineColor||"#3b82f6",lineWidth:I.lineWidth||2,showArea:I.showArea||!1,areaColor:I.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:I.smoothing||!1,showPoints:I.showPoints!==void 0?I.showPoints:!0,pointSize:I.pointSize||6,pointFill:I.pointFill||"#ffffff",pointStrokeColor:I.pointStrokeColor||I.lineColor||"#3b82f6",pointStrokeWidth:I.pointStrokeWidth||2}]),!C||C.length===0||!C.some(S=>S.data&&S.data.length>=2)){A.save(),A.fillStyle="#6366f1",A.font="12px Inter, system-ui, sans-serif",A.textAlign="center",A.textBaseline="middle",A.fillText("NO DATA",0,0),A.restore();return}let E=1/0,i=-1/0,w=0;if(C.forEach(S=>{let N=S.data;if(S.isVarEnabled&&S.inputId){let k=this.inputs.get(S.inputId);if(k===void 0){const t=this.inputNameMap.get(S.inputId);t&&t.length>0&&(k=this.inputs.get(t[0]))}k&&Array.isArray(k)&&(N=k)}if(N&&N.length>0){const k=N.filter(t=>typeof t=="number"&&!isNaN(t));k.length>0&&(E=Math.min(E,...k),i=Math.max(i,...k),w=Math.max(w,N.length))}S._resolvedData=N}),w<2)return;const o=i-E,s=Q/(w-1),h=S=>{const N=o===0?.5:(S-E)/o;return g/2-N*g},a=S=>S*s-Q/2,G=I.axisColor||"#333333";if(I.showXAxis&&(A.beginPath(),A.strokeStyle=I.xAxisColor||G,A.lineWidth=1,A.moveTo(-Q/2,g/2),A.lineTo(Q/2,g/2),A.stroke()),I.showYAxis&&(A.beginPath(),A.strokeStyle=I.yAxisColor||G,A.lineWidth=1,A.moveTo(-Q/2,-g/2),A.lineTo(-Q/2,g/2),A.stroke()),A.fillStyle=I.axisLabelColor||"#333333",A.font=`${I.axisLabelFontSize||10}px Inter, sans-serif`,I.showXLabels){A.textAlign="center",A.textBaseline="top";for(let S=0;S<w;S++){const N=a(S);A.fillText(`${S+1}`,N,g/2+5)}}if(I.showYLabels){A.textAlign="right",A.textBaseline="middle";const S=-Q/2-5,N=(i+E)/2;A.fillText(i.toFixed(1),S,h(i)),A.fillText(N.toFixed(1),S,h(N)),A.fillText(E.toFixed(1),S,h(E))}const K=10;if(C.forEach(S=>{const N=S._resolvedData;if(!(!N||N.length<2)){if(S.showArea){if(A.beginPath(),A.moveTo(a(0),g/2),A.lineTo(a(0),h(N[0])),S.smoothing&&N.length>2)for(let t=0;t<N.length-1;t++){const J=N[t===0?t:t-1],R=N[t],e=N[t+1],d=N[t+1===N.length-1?t+1:t+2];for(let p=1;p<=K;p++){const c=p/K,Y=this._catmullRom(J,R,e,d,c);A.lineTo(a(t+c),h(Y))}}else for(let t=1;t<N.length;t++)A.lineTo(a(t),h(N[t]));A.lineTo(a(N.length-1),g/2),A.closePath();const k=A.globalAlpha;A.globalAlpha=k*(I.areaOpacity??.3),A.fillStyle=S.areaColor||"rgba(139, 92, 246, 0.2)",A.fill(),A.globalAlpha=k}if(A.beginPath(),A.strokeStyle=S.lineColor||"#3b82f6",A.lineWidth=S.lineWidth||2,A.lineJoin="round",A.lineCap="round",A.moveTo(a(0),h(N[0])),S.smoothing&&N.length>2)for(let k=0;k<N.length-1;k++){const t=N[k===0?k:k-1],J=N[k],R=N[k+1],e=N[k+1===N.length-1?k+1:k+2];for(let d=1;d<=K;d++){const p=d/K,c=this._catmullRom(t,J,R,e,p);A.lineTo(a(k+p),h(c))}}else for(let k=1;k<N.length;k++)A.lineTo(a(k),h(N[k]));A.stroke(),S.showPoints&&N.forEach((k,t)=>{const J=a(t),R=h(k);A.beginPath(),A.arc(J,R,(S.pointSize||6)/2,0,Math.PI*2),A.fillStyle=S.pointFill||"#ffffff",A.fill(),A.strokeStyle=S.pointStrokeColor||S.lineColor||"#3b82f6",A.lineWidth=S.pointStrokeWidth||1,A.stroke()})}}),I.showLegend&&C.length>0){const S=Q/2-10;let N=-g/2+15;const k=I.legendFontSize||10,t=k+5;A.font=`${k}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",C.forEach(J=>{const e=J.label||"Series",d=A.measureText(e).width;A.beginPath(),A.rect(S-d-8-5,N-(8/2+2),8,8),A.fillStyle=J.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(e,S,N),N+=t})}}_catmullRom(A,I,Q,g,C){const E=(Q-A)*.5,i=(g-I)*.5,w=C*C,o=C*w;return(2*I-2*Q+E+i)*o+(-3*I+3*Q-2*E-i)*w+E*C+I}normalizeOpacity(A){const I=typeof A=="number"?A:parseFloat(String(A))||100;return I>1?I/100:I}createCanvasFill(A,I,Q,g){var C,E,i;if(!I||I.type==="None")return null;if(I.type==="Solid"&&I.color){const w=I.color,s=(((E=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:E.colors)||{})[w]||w;return A.fillStyle=s,s}if((I.type==="LinearGradient"||I.type==="RadialGradient"||I.type==="AngularGradient"||I.type==="DiamondGradient")&&I.stops){const w=(o,s=100)=>{var R,e;const a=(((e=(R=this.artboard)==null?void 0:R.tokens)==null?void 0:e.colors)||{})[o]||o,G=this.normalizeOpacity(I.opacity??100),S=this.normalizeOpacity(s)*G;if(S>=1&&a.startsWith("#"))return a;const N=a.startsWith("#")?a.replace("#",""):"ffffff",k=parseInt(N.substring(0,2),16),t=parseInt(N.substring(2,4),16),J=parseInt(N.substring(4,6),16);return`rgba(${k}, ${t}, ${J}, ${S})`};if(I.type==="LinearGradient"){const o=(S,N,k)=>Array.isArray(S)?S[N]??(N===0?0:1):S&&typeof S=="object"?S[k]??(N===0?0:1):N===0?0:1,s=o(I.start,0,"x")*Q-Q/2,h=o(I.start,1,"y")*g-g/2,a=o(I.end,0,"x")*Q-Q/2,G=o(I.end,1,"y")*g-g/2,K=A.createLinearGradient(s,h,a,G);if(I.stops.forEach(S=>{const N=S.offset!==void 0?S.offset:S.pos!==void 0?S.pos:S.position!==void 0?S.position:0,k=w(S.color||"#000000",S.opacity??100);K.addColorStop(Math.max(0,Math.min(1,N)),k)}),I.gradientTransform&&K.setTransform){const[S,N,k,t,J,R]=I.gradientTransform;K.setTransform({a:S,b:N,c:k,d:t,e:J,f:R})}return K}else if(I.type==="RadialGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center,0,"x")*Q-Q/2,h=o(I.center,1,"y")*g-g/2,a=(I.radius??.5)*Math.max(Q,g),G=A.createRadialGradient(s,h,0,s,h,a);if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return G}else if(I.type==="AngularGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center||[.5,.5],0,"x")*Q-Q/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.degree||I.angle||0)*(Math.PI/180),G=(i=A.createConicGradient)==null?void 0:i.call(A,a,s,h);if(G){if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return G}}else if(I.type==="DiamondGradient"){const o=(K,S,N)=>Array.isArray(K)?K[S]??.5:K&&typeof K=="object"?K[N]??.5:.5,s=o(I.center||[.5,.5],0,"x")*Q-Q/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.radius??.5)*Math.max(Q,g);A.save(),A.translate(s,h),A.rotate(Math.PI/4);const G=A.createRadialGradient(0,0,0,0,0,a);if(I.stops.forEach(K=>{const S=K.offset!==void 0?K.offset:K.pos!==void 0?K.pos:K.position!==void 0?K.position:0,N=w(K.color||"#000000",K.opacity??100);G.addColorStop(Math.max(0,Math.min(1,S)),N)}),I.gradientTransform&&G.setTransform){const[K,S,N,k,t,J]=I.gradientTransform;G.setTransform({a:K,b:S,c:N,d:k,e:t,f:J})}return A.scale(1/Math.SQRT2,1/Math.SQRT2),A.fillStyle=G,A.restore(),G}}if(I.type==="Pattern"&&I.url){let w=this.imageCache.get(I.url);if(w||(w=new Image,w.src=I.url,this.imageCache.set(I.url,w)),w.complete&&w.naturalWidth>0){const o=A.createPattern(w,"repeat");if(o&&(I.scaleX!==void 0||I.offsetX!==void 0)){const s=new DOMMatrix,h=I.scaleX??1,a=I.scaleY??1,G=I.offsetX??0,K=I.offsetY??0,S=I.rotation??0;s.translateSelf(G,K),s.rotateSelf(S),s.scaleSelf(h,a),o.setTransform(s)}return o}}return I.color||null}drawRoundRect(A,I,Q,g,C,E){if(E===0||E===void 0||E===null){A.rect(I,Q,g,C);return}let i=E;if(typeof i=="string")try{i=JSON.parse(i)}catch{i=parseFloat(i)||0}let w=0,o=0,s=0,h=0;typeof i=="number"?w=o=s=h=i:Array.isArray(i)?i.length===1?w=o=s=h=i[0]:i.length===2?(w=s=i[0],o=h=i[1]):i.length===3?(w=i[0],o=h=i[1],s=i[2]):i.length>=4&&(w=i[0],o=i[1],s=i[2],h=i[3]):i&&typeof i=="object"&&(w=i.tl??i.corner_radius??i.cornerRadius??0,o=i.tr??i.corner_radius??i.cornerRadius??0,s=i.br??i.corner_radius??i.cornerRadius??0,h=i.bl??i.corner_radius??i.cornerRadius??0);const a=Math.min(Math.abs(g)/2,Math.abs(C)/2);if(w=Math.min(Math.max(0,w),a),o=Math.min(Math.max(0,o),a),s=Math.min(Math.max(0,s),a),h=Math.min(Math.max(0,h),a),A.roundRect){A.roundRect(I,Q,g,C,[w,o,s,h]);return}A.moveTo(I+w,Q),A.lineTo(I+g-o,Q),A.arcTo(I+g,Q,I+g,Q+o,o),A.lineTo(I+g,Q+C-s),A.arcTo(I+g,Q+C,I+g-s,Q+C,s),A.lineTo(I+h,Q+C),A.arcTo(I,Q+C,I,Q+C-h,h),A.lineTo(I,Q+w),A.arcTo(I,Q,I+w,Q,w),A.closePath()}renderListView(A,I){var AA,hA,oA,f;const Q=this.objectStates.get(I.id)||{},g=Q.options||I.options||{},C=Q.width!==void 0?Q.width:((AA=I.geometry)==null?void 0:AA.width)||200,E=Q.height!==void 0?Q.height:((hA=I.geometry)==null?void 0:hA.height)||300,i=-C/2,w=-E/2,o=Q.corner_radius!==void 0?Q.corner_radius:g.corner_radius??0,s=g.orientation||"vertical",h=g.items||[],a=g.itemGap??10,G=g.itemHeight??50,K=g.itemWidth??200,S=g.scrollOffset??0,N=g.padding??0,k=g.glassEffect!==!1,t=g.accentColor||"#3b82f6",J=g.itemTextColor||"#333333",R=g.itemBackgroundColor||"#ffffff",e=g.hoveredIndex??null,d=g.activeItemIndex??null,p=g.glowIntensity??0,c=g.glowColor||"#3b82f6",Y=typeof c=="string"?c:c.color||((f=(oA=c.stops)==null?void 0:oA[0])==null?void 0:f.color)||"#3b82f6",l=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=l,p>0&&(A.shadowColor=Y,A.shadowBlur=p*2,A.shadowOffsetX=0,A.shadowOffsetY=0),k){const m=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",x=this.createCanvasFill(A,m,C,E);A.fillStyle=x||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,C,E,o),A.fill();const Z=A.createLinearGradient(i,w,i+C,w+E);Z.addColorStop(0,"rgba(255, 255, 255, 0.15)"),Z.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),Z.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=Z,this.drawListViewRect(A,i,w,C,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,w,C,E,o),A.stroke()}else{const m=g.listBackgroundColor||"transparent",x=this.createCanvasFill(A,m,C,E);x&&(A.fillStyle=x,this.drawListViewRect(A,i,w,C,E,o),A.fill());const Z=g.borderWidth??0;Z>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=Z,this.drawListViewRect(A,i,w,C,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,w,C,E,o),A.clip();const O=typeof N=="number"?N:s==="vertical"?N[0]:N[3];let z=(s==="vertical"?w:i)+S+O;if(A.textBaseline="middle",h.forEach((m,x)=>{const Z=s==="vertical"?C:K,U=s==="vertical"?G:E,r=s==="vertical"?i:z,b=s==="vertical"?z:w,L=e===x,H=d===x;if(H){const QA=this.createCanvasFill(A,t,Z,U);A.fillStyle=QA||t;const CA=A.globalAlpha;A.globalAlpha=CA*.8,A.fillRect(r,b,Z,U),A.globalAlpha=CA}else if(L)A.fillStyle=k?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(r,b,Z,U);else if(R!=="transparent"){const QA=this.createCanvasFill(A,R,Z,U);A.fillStyle=QA||R,A.fillRect(r,b,Z,U)}if(H||L){const QA=this.createCanvasFill(A,t,s==="vertical"?3:Z,s==="vertical"?U:3);A.fillStyle=QA||t,s==="vertical"?A.fillRect(r,b,3,U):A.fillRect(r,b+U-3,Z,3)}const j=H?"#ffffff":k?"rgba(255, 255, 255, 0.9)":J;A.fillStyle=j,A.font=H||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const EA=typeof m=="string"?m:(m==null?void 0:m.label)||`Item ${x+1}`,v=r+(s==="vertical"?16:Z/2),V=b+U/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(EA,v,V),z+=(s==="vertical"?G:K)+a}),A.restore(),g.showScrollbar!==!1){const m=(h.length||0)*(s==="vertical"?G:K)+((h.length||0)-1)*a,x=s==="vertical"?E:C;if(m>x){const Z=x/m,U=x*Z,r=-S/m*x,b=g.scrollbarColor||"rgba(255,255,255,0.3)",L=g.scrollbarWidth||4;A.fillStyle=b,s==="vertical"?A.fillRect(i+C-L-2,w+r,L,U):A.fillRect(i+r,w+E-L-2,U,L)}}A.restore()}updateListViewScrollFromPointer(A){var N,k;if(!this._lastPointerPos||!this._prevPointerPos)return;const I=A.options||{},Q=I.orientation||"vertical",g=this._lastPointerPos.x-this._prevPointerPos.x,C=this._lastPointerPos.y-this._prevPointerPos.y;Q==="vertical"?I.scrollOffset=(I.scrollOffset||0)+C:I.scrollOffset=(I.scrollOffset||0)+g;const E=this.objectStates.get(A.id)||{},i=I.items||[],w=I.itemGap??10,o=I.itemHeight??50,s=I.itemWidth??200,h=E.width!==void 0?E.width:((N=A.geometry)==null?void 0:N.width)||200,a=E.height!==void 0?E.height:((k=A.geometry)==null?void 0:k.height)||300,G=(i.length||0)*(Q==="vertical"?o:s)+((i.length||0)-1)*w,S=Math.max(0,G-(Q==="vertical"?a:h)+(I.padding*2||0));I.scrollOffset>0&&(I.scrollOffset=0),I.scrollOffset<-S&&(I.scrollOffset=-S)}updateListViewHoverFromPointer(A,I,Q){const g=this.getListViewItemIndexAtPointer(A,I,Q),C=A.options||{};C.hoveredIndex!==g&&(C.hoveredIndex=g)}getListViewItemIndexAtPointer(A,I,Q){var O,z;const g=A.options||{},C=this.objectStates.get(A.id)||{},E=g.items||[];if(E.length===0)return null;const i=C.width!==void 0?C.width:((O=A.geometry)==null?void 0:O.width)||200,w=C.height!==void 0?C.height:((z=A.geometry)==null?void 0:z.height)||300,o=g.orientation||"vertical",s=g.itemGap??10,h=g.itemHeight??50,a=g.itemWidth??200,G=g.scrollOffset??0,K=g.padding??0,S=this.getWorldTransform(A.id),N=I-S.x,k=Q-S.y,t=-S.rotation*(Math.PI/180),J=Math.cos(t),R=Math.sin(t),e=N*J-k*R,d=N*R+k*J,p=-i/2,c=-w/2,Y=typeof K=="number"?K:o==="vertical"?K[0]:K[3];let l=(o==="vertical"?c:p)+G+Y;for(let BA=0;BA<E.length;BA++){const AA=o==="vertical"?i:a,hA=o==="vertical"?h:w,oA=o==="vertical"?p:l,f=o==="vertical"?l:c;if(e>=oA&&e<=oA+AA&&d>=f&&d<=f+hA)return BA;l+=(o==="vertical"?h:a)+s}return null}drawListViewRect(A,I,Q,g,C,E){A.beginPath(),this.drawRoundRect(A,I,Q,g,C,E),A.fill()}solveBehaviors(A){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:I,y:Q}=this._lastPointerPos;this.artboard.objects.forEach(g=>{if(!g.behaviors||g.behaviors.length===0)return;const C=this.objectStates.get(g.id);C&&g.behaviors.forEach(E=>{var a,G,K,S,N,k,t,J,R,e,d,p,c,Y,l,O,z,BA,AA,hA,oA,f,m,x,Z,U,r,b,L,H,j,EA,v,V,QA,CA,SA,kA,qA,MA,JA,rA,pA,xA;if(!E.enabled)return;const i=E.startTime||0,w=E.endTime||1/0;if(this.currentTime<i||this.currentTime>w)return;const o=C.x-I,s=C.y-Q,h=Math.sqrt(o*o+s*s);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${E.type} on ${g.name}`),E.type===q.Proximity){const u=((a=E.settings)==null?void 0:a.radius)||300,n=((G=E.settings)==null?void 0:G.falloff)||"smooth";let T=0;h<u&&(n==="linear"?T=1-h/u:T=Math.pow(1-h/u,2)),T>0&&E.sensors.forEach(IA=>{this.applyBehaviorSensor(C,IA,T,A,E.settings)})}else if(E.type===q.Magnetic){const u=((K=E.settings)==null?void 0:K.radius)||400,n=((S=E.settings)==null?void 0:S.strength)||.5;if(h<u&&h>5){const T=1-h/u,IA=o*T*n,sA=s*T*n;C.x-=IA*A*10,C.y-=sA*A*10}}else if(E.type===q.Repel){const u=((N=E.settings)==null?void 0:N.radius)||300,n=((k=E.settings)==null?void 0:k.strength)||1;if(h<u){const T=Math.pow(1-h/u,2);C.x+=o/(h||1)*T*60*n*A*5,C.y+=s/(h||1)*T*60*n*A*5}}else if(E.type===q.Orbit){const u=((t=E.settings)==null?void 0:t.speed)||1,n=((J=E.settings)==null?void 0:J.radius)||30,T=this.currentTime*u*Math.PI*2;C.x+=Math.cos(T)*n*A*5,C.y+=Math.sin(T)*n*A*5,C.rotation+=2*A*5}else if(E.type===q.Vortex){const u=((R=E.settings)==null?void 0:R.radius)||400,n=((e=E.settings)==null?void 0:e.speed)||2,T=((d=E.settings)==null?void 0:d.strength)||1;if(h<u){const IA=Math.pow(1-h/u,1.5),sA=this.currentTime*n*Math.PI*2,VA=Math.cos(sA)*30-o*.4,fA=Math.sin(sA)*30-s*.4;C.x+=VA*IA*T*A*5,C.y+=fA*IA*T*A*5,C.rotation+=5*IA*T*A*5,C.scale_x*=1-IA*.1*T*A,C.scale_y*=1-IA*.1*T*A}}else if(E.type===q.Fluid){const u=((p=E.settings)==null?void 0:p.radius)||300,n=((c=E.settings)==null?void 0:c.strength)||1;if(h<u){const T=Math.pow(1-h/u,1.2),IA=o/(h||1)*T*1.2*n,sA=s/(h||1)*T*1.2*n;C.x+=IA*10*A*5,C.y+=sA*10*A*5,C.scale_x*=1+T*.3*n*A,C.scale_y*=1+T*.3*n*A}}else if(E.type===q.Elastic){const u=((Y=E.settings)==null?void 0:Y.radius)||300,n=((l=E.settings)==null?void 0:l.strength)||1;if(h<u){const T=1-h/u;C.scale_x*=1+T*.4*n*A,C.scale_y*=1+T*.4*n*A}}else if(E.type===q.Holographic){const u=C.x-this.canvasWidth/2,n=C.y-this.canvasHeight/2,T=((O=E.settings)==null?void 0:O.factor)||25;if(C.x-=u/1e3*T*A*5,C.y-=n/1e3*T*A*5,C.style){const IA=1-Math.min(1,h/400);C.style.exposure=(C.style.exposure||1)+IA*.5*A}}else if(E.type===q.Sticky){const u=((z=E.settings)==null?void 0:z.radius)||80,n=((BA=E.settings)==null?void 0:BA.strength)||1;if(h<u){const T=Math.pow(1-h/u,2);C.x-=o*T*n*A*10,C.y-=s*T*n*A*10,C.scale_x*=1-T*.1*n*A,C.scale_y*=1-T*.1*n*A}}else if(E.type===q.Dilation){const u=((AA=E.settings)==null?void 0:AA.size)||120,n=((hA=E.settings)==null?void 0:hA.strength)||1;if(h<u){const T=1-h/u;C.scale_x*=1+T*.5*n*A,C.scale_y*=1+T*.5*n*A}}else if(E.type===q.Parallax){const u=((oA=E.settings)==null?void 0:oA.factor)||.05,n=this.canvasHeight/2,T=(this._lastPointerPos.y-n)*u;C.y+=T*A*10}else if(E.type===q.Noise||E.type===q.Float){const u=(((f=E.settings)==null?void 0:f.frequency)||((m=E.settings)==null?void 0:m.speed)||1)*.002,n=(((x=E.settings)==null?void 0:x.amplitude)||((Z=E.settings)==null?void 0:Z.range)||50)*(((U=E.settings)==null?void 0:U.strength)||1),T=Date.now();C.x+=Math.sin(T*u)*n*A,C.y+=Math.cos(T*u*.8)*n*A,C.rotation+=Math.sin(T*u*.5)*5*A}else if(E.type===q.Pulse){const u=(((r=E.settings)==null?void 0:r.speed)||1)*.005,n=(((b=E.settings)==null?void 0:b.scale)||1.2)-1,T=Math.sin(Date.now()*u),IA=((L=E.settings)==null?void 0:L.strength)||1;C.scale_x*=1+T*n*IA*A,C.scale_y*=1+T*n*IA*A,C.style&&(C.style.exposure=(C.style.exposure||1)+Math.max(0,T)*.1*IA*A)}else if(E.type===q.Draggable){const u=((H=E.settings)==null?void 0:H.radius)||150,n=this.draggingBehaviors.has(g.id);if(h<u||n){const T=((j=E.settings)==null?void 0:j.strength)||1,IA=n?1:Math.max(0,1-h/u);this.applyBehaviorSensor(C,uA.PositionX,IA*T,A,E.settings),this.applyBehaviorSensor(C,uA.PositionY,IA*T,A,E.settings)}}else if(E.type===q.Scroll){const u=((EA=E.settings)==null?void 0:EA.axis)||"vertical",n=((v=E.settings)==null?void 0:v.factor)||.5,T=((V=E.settings)==null?void 0:V.strength)||1;(u==="vertical"||u==="both")&&(C.y+=this.scrollOffset.y*n*T*A),(u==="horizontal"||u==="both")&&(C.x+=this.scrollOffset.x*n*T*A)}else if(E.type===q.LookAt){const u=((QA=E.settings)==null?void 0:QA.factor)||1,n=((CA=E.settings)==null?void 0:CA.strength)||1,T=Math.atan2(-s,-o)*(180/Math.PI),IA=C.rotation,sA=(T-IA+180)%360-180;C.rotation+=sA*u*n*A*10}else if(E.type===q.Glint||E.type===q.Scan){const u=(((SA=E.settings)==null?void 0:SA.speed)||1)*.004,n=((kA=E.settings)==null?void 0:kA.strength)||1,T=(Math.sin(Date.now()*u)+1)/2;C.style&&(C.style.exposure=(C.style.exposure||1)+T*n*A*5),C.x+=(T-.5)*20*n*A}else if(E.type===q.Ratchet){const u=((qA=E.settings)==null?void 0:qA.steps)||12,n=(((MA=E.settings)==null?void 0:MA.speed)||1)*30,T=Math.floor(C.rotation/(360/u))*(360/u);C.rotation=this.lerp(C.rotation,T+n*A,.1)}else if(E.type===q.Jitter&&h<300){const u=((JA=E.settings)==null?void 0:JA.strength)||1,n=(((rA=E.settings)==null?void 0:rA.intensity)||5)*u;C.x+=(Math.random()-.5)*n*A*60,C.y+=(Math.random()-.5)*n*A*60,C.rotation+=(Math.random()-.5)*n*A*120}else if(E.type===q.Follower){const u=(pA=E.settings)==null?void 0:pA.targetId;if(u){const n=this.objectStates.get(u);if(n){const T=((xA=E.settings)==null?void 0:xA.stiffness)||.1,IA=n.x-C.x,sA=n.y-C.y;C.x+=IA*T*A*60,C.y+=sA*T*A*60}}}else E.type===q.Wrap&&(C.x<0?C.x=this.canvasWidth:C.x>this.canvasWidth&&(C.x=0),C.y<0?C.y=this.canvasHeight:C.y>this.canvasHeight&&(C.y=0))})})}applyBehaviorSensor(A,I,Q,g,C){const E=(C==null?void 0:C.intensity)||(C==null?void 0:C.strength)||1,i=Q*E*g;switch(I){case uA.Scale:A.scale_x*=1+i*.5,A.scale_y*=1+i*.5;break;case uA.Opacity:A.opacity=Math.max(0,Math.min(100,A.opacity-i*100));break;case uA.RotateZ:A.rotation+=i*180;break;case uA.RotateX:A.rotate_x=(A.rotate_x||0)+i*180;break;case uA.RotateY:A.rotate_y=(A.rotate_y||0)+i*180;break;case uA.PositionX:A.x+=i*300;break;case uA.PositionY:A.y+=i*300;break;case uA.SkewX:A.skew_x=(A.skew_x||0)+i*45;break;case uA.Blur:A.style||(A.style={}),A.style.blur=Math.min(100,(A.style.blur||0)+i*50);break;case uA.Exposure:A.style||(A.style={}),A.style.exposure=(A.style.exposure||1)+i*2;break;case uA.HueShift:A.style||(A.style={}),A.style.hue=(A.style.hue||0)+i*360;break;case uA.CornerRadius:A.corner_radius=Math.min(200,(A.corner_radius||0)+i*100);break;case uA.LetterSpacing:A.geometry||(A.geometry={}),A.geometry.letterSpacing=(A.geometry.letterSpacing||0)+i*10;break}}lerp(A,I,Q){return A*(1-Q)+I*Q}deepMerge(A,I){if(!A)return I;if(!I)return A;if(typeof A!="object"||typeof I!="object"||A===null||I===null)return I;const Q={...A};for(const g in I)Object.prototype.hasOwnProperty.call(I,g)&&(I[g]&&typeof I[g]=="object"&&!Array.isArray(I[g])?Q[g]=this.deepMerge(A[g],I[g]):Q[g]=I[g]);return Q}}const Ai=NA.forwardRef(({artboard:B,src:A,className:I,style:Q,autoPlay:g=!0,fit:C="Contain",alignment:E="Center",onReady:i,onTrigger:w,onInputUpdate:o,onComponentChange:s,onToggle:h,onInputChange:a,onInputFocus:G,onInputBlur:K},S)=>{const N=NA.useRef(null),k=NA.useRef(new jQ),t=NA.useRef(),J=NA.useRef(0);NA.useImperativeHandle(S,()=>N.current),NA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),k.current.setLayout(C,E)},[C,E]),NA.useEffect(()=>{w&&k.current.setTriggerCallback(w)},[w]),NA.useEffect(()=>{o&&k.current.setInputUpdateCallback(o)},[o]),NA.useEffect(()=>{s&&k.current.setComponentChangeCallback(s)},[s]),NA.useEffect(()=>{h&&k.current.setToggleCallback(h)},[h]),NA.useEffect(()=>{a&&k.current.setInputChangeCallback(a)},[a]),NA.useEffect(()=>{G&&k.current.setInputFocusCallback(G)},[G]),NA.useEffect(()=>{K&&k.current.setInputBlurCallback(K)},[K]),NA.useEffect(()=>{(async()=>{const d=k.current;let p=B;if(!p&&A)try{p=await(await fetch(A)).json()}catch(c){console.error("Failed to load ExodeUI animation:",c);return}p&&(d.load(p),i&&i(d))})()},[B,A]),NA.useEffect(()=>{const e=k.current,d=N.current;if(!d)return;const p=d.getContext("2d");if(!p)return;const c=l=>{J.current||(J.current=l);const O=(l-J.current)/1e3;J.current=l,g&&e.advance(O);const z=window.devicePixelRatio||1,BA=d.getBoundingClientRect(),AA=Math.floor(BA.width*z),hA=Math.floor(BA.height*z);(d.width!==AA||d.height!==hA)&&(d.width=AA,d.height=hA),e.render(p,AA,hA),t.current=requestAnimationFrame(c)};t.current=requestAnimationFrame(c);const Y=()=>{e.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",Y,{passive:!0}),()=>{t.current&&cancelAnimationFrame(t.current),window.removeEventListener("scroll",Y)}},[g]);const R=(e,d)=>{const p=e.currentTarget.getBoundingClientRect(),c=e.clientX-p.left,Y=e.clientY-p.top,l=p.width,O=p.height;k.current.handlePointerInput(d,c,Y,l,O)};return _A.jsx("canvas",{ref:N,style:{width:"100%",height:"100%",outline:"none",...Q},className:I,tabIndex:0,onPointerDown:e=>{var d;R(e,"down"),(d=N.current)==null||d.focus()},onPointerUp:e=>R(e,"up"),onPointerMove:e=>R(e,"move"),onPointerLeave:e=>R(e,"blur"),onClick:e=>R(e,"click"),onKeyDown:e=>{e.key==="Backspace"||e.key==="Enter"||e.key,k.current.handleKeyDown(e.nativeEvent)}})});function Ii(){const[B,A]=NA.useState(null),I=NA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),Q=NA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=NA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),C=NA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=NA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=NA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=NA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=NA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=NA.useCallback((h,a)=>{B==null||B.updateGraphData(h,a)},[B]);return{setEngine:A,engine:B,setInputBool:I,setInputNumber:Q,fireTrigger:g,setInputText:C,setInputNumberArray:E,setInputStringArray:i,updateConstraint:o,updateGraphData:s,updateObjectOptions:w}}const gi="6.0.10";LA.BehaviorSensor=uA,LA.BehaviorType=q,LA.ConditionOp=cC,LA.ExodeUICanvas=Ai,LA.ExodeUIEngine=jQ,LA.LogicOp=UI,LA.VERSION=gi,LA.useExodeUI=Ii,Object.defineProperty(LA,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED