exodeui 6.0.23 → 6.0.24

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 CHANGED
@@ -2,4 +2,4 @@ export * from './ExodeUICanvas';
2
2
  export * from './types';
3
3
  export * from './engine';
4
4
  export * from './useExodeUI';
5
- export declare const VERSION = "6.0.22";
5
+ export declare const VERSION = "6.0.24";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  `).replace(/[\r\f]/g,`
3
3
  `):B.replace(/\r\n/g,`
4
4
  `)}let QC=null,kB;function NB(){return QC===null&&(QC=new Intl.Segmenter(kB,{granularity:"word"})),QC}const FB=new RegExp("\\p{Script=Arabic}","u"),ig=new RegExp("\\p{M}","u"),FQ=new RegExp("\\p{Nd}","u");function BC(B){return FB.test(B)}function tI(B){for(const A of B){const I=A.codePointAt(0);if(I>=19968&&I<=40959||I>=13312&&I<=19903||I>=131072&&I<=173791||I>=173824&&I<=177983||I>=177984&&I<=178207||I>=178208&&I<=183983||I>=183984&&I<=191471||I>=196608&&I<=201551||I>=63744&&I<=64255||I>=194560&&I<=195103||I>=12288&&I<=12351||I>=12352&&I<=12447||I>=12448&&I<=12543||I>=44032&&I<=55215||I>=65280&&I<=65519)return!0}return!1}const MQ=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),og=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),EC=new Set(["'","’"]),uI=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),MB=new Set([":",".","،","؛"]),eB=new Set(["၏"]),cB=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function JB(B){if(iC(B))return!0;let A=!1;for(const I of B){if(uI.has(I)){A=!0;continue}if(!(A&&ig.test(I)))return!1}return A}function RB(B){for(const A of B)if(!MQ.has(A)&&!uI.has(A))return!1;return B.length>0}function UB(B){if(iC(B))return!0;for(const A of B)if(!og.has(A)&&!EC.has(A)&&!ig.test(A))return!1;return B.length>0}function iC(B){let A=!1;for(const I of B)if(!(I==="\\"||ig.test(I))){if(og.has(I)||uI.has(I)||EC.has(I)){A=!0;continue}return!1}return A}function rB(B){const A=Array.from(B);let I=A.length;for(;I>0;){const C=A[I-1];if(ig.test(C)){I--;continue}if(og.has(C)||EC.has(C)){I--;continue}break}return I<=0||I===A.length?null:{head:A.slice(0,I).join(""),tail:A.slice(I).join("")}}function nB(B,A){if(B.length===0)return!1;for(const I of B)if(I!==A)return!1;return!0}function YB(B){return!BC(B)||B.length===0?!1:MB.has(B[B.length-1])}function lB(B){return B.length===0?!1:eB.has(B[B.length-1])}function LB(B){if(B.length<2||B[0]!==" ")return null;const A=B.slice(1);return new RegExp("^\\p{M}+$","u").test(A)?{space:" ",marks:A}:null}function eQ(B){for(let A=B.length-1;A>=0;A--){const I=B[A];if(cB.has(I))return!0;if(!uI.has(I))return!1}return!1}function qB(B,A){if(A.preserveOrdinarySpaces||A.preserveHardBreaks){if(B===" ")return"preserved-space";if(B===" ")return"tab";if(A.preserveHardBreaks&&B===`
5
- `)return"hard-break"}return B===" "?"space":B===" "||B===" "||B==="⁠"||B==="\uFEFF"?"glue":B==="​"?"zero-width-break":B==="­"?"soft-hyphen":"text"}function pB(B,A,I,C){const g=[];let Q=null,E="",i=I,w=!1,o=0;for(const s of B){const h=qB(s,C),a=h==="text"&&A;if(Q!==null&&h===Q&&a===w){E+=s,o+=s.length;continue}Q!==null&&g.push({text:E,isWordLike:w,kind:Q,start:i}),Q=h,E=s,i=I+o,w=a,o+=s.length}return Q!==null&&g.push({text:E,isWordLike:w,kind:Q,start:i}),g}function oC(B){return B==="space"||B==="preserved-space"||B==="zero-width-break"||B==="hard-break"}const HB=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function dB(B,A){const I=B.texts[A];return I.startsWith("www.")?!0:HB.test(I)&&A+1<B.len&&B.kinds[A+1]==="text"&&B.texts[A+1]==="//"}function fB(B){return B.includes("?")&&(B.includes("://")||B.startsWith("www."))}function bB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let E=0;E<B.len;E++){if(C[E]!=="text"||!dB(B,E))continue;let i=E+1;for(;i<B.len&&!oC(C[i]);){A[E]+=A[i],I[E]=!0;const w=A[i].includes("?");if(C[i]="text",A[i]="",i++,w)break}}let Q=0;for(let E=0;E<A.length;E++){const i=A[E];i.length!==0&&(Q!==E&&(A[Q]=i,I[Q]=I[E],C[Q]=C[E],g[Q]=g[E]),Q++)}return A.length=Q,I.length=Q,C.length=Q,g.length=Q,{len:Q,texts:A,isWordLike:I,kinds:C,starts:g}}function TB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q]),!fB(E))continue;const i=Q+1;if(i>=B.len||oC(B.kinds[i]))continue;let w="";const o=B.starts[i];let s=i;for(;s<B.len&&!oC(B.kinds[s]);)w+=B.texts[s],s++;w.length>0&&(A.push(w),I.push(!0),C.push("text"),g.push(o),Q=s-1)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}const uB=new Set([":","-","/","×",",",".","+","–","—"]),cQ=/^[A-Za-z0-9_]+[,:;]*$/,mB=/[,:;]+$/;function JQ(B){for(const A of B)if(FQ.test(A))return!0;return!1}function DC(B){if(B.length===0)return!1;for(const A of B)if(!(FQ.test(A)||uB.has(A)))return!1;return!0}function xB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q];if(i==="text"&&DC(E)&&JQ(E)){let w=E,o=Q+1;for(;o<B.len&&B.kinds[o]==="text"&&DC(B.texts[o]);)w+=B.texts[o],o++;A.push(w),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=o-1;continue}A.push(E),I.push(B.isWordLike[Q]),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function OB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q],w=B.isWordLike[Q];if(i==="text"&&w&&cQ.test(E)){let o=E,s=Q+1;for(;mB.test(o)&&s<B.len&&B.kinds[s]==="text"&&B.isWordLike[s]&&cQ.test(B.texts[s]);)o+=B.texts[s],s++;A.push(o),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=s-1;continue}A.push(E),I.push(w),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function WB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(B.kinds[Q]==="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||!JQ(s)||!DC(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),C.push("text"),g.push(B.starts[Q]+o),o+=a.length}continue}}A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function ZB(B){const A=[],I=[],C=[],g=[];let Q=0;for(;Q<B.len;){let E=B.texts[Q],i=B.isWordLike[Q],w=B.kinds[Q],o=B.starts[Q];if(w==="glue"){let s=E;const h=o;for(Q++;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text")E=s+B.texts[Q],i=B.isWordLike[Q],w="text",o=h,Q++;else{A.push(s),I.push(!1),C.push("glue"),g.push(h);continue}}else Q++;if(w==="text")for(;Q<B.len&&B.kinds[Q]==="glue";){let s="";for(;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text"){E+=s+B.texts[Q],i=i||B.isWordLike[Q],Q++;continue}E+=s}A.push(E),I.push(i),C.push(w),g.push(o)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function jB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let Q=0;Q<A.length-1;Q++){if(C[Q]!=="text"||C[Q+1]!=="text"||!tI(A[Q])||!tI(A[Q+1]))continue;const E=rB(A[Q]);E!==null&&(A[Q]=E.head,A[Q+1]=E.tail+A[Q+1],g[Q+1]=g[Q]+E.head.length)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function XB(B,A,I){const C=NB();let g=0;const Q=[],E=[],i=[],w=[];for(const a of C.segment(B))for(const G of pB(a.segment,a.isWordLike??!1,a.index,I)){const t=G.kind==="text";A.carryCJKAfterClosingQuote&&t&&g>0&&i[g-1]==="text"&&tI(G.text)&&tI(Q[g-1])&&eQ(Q[g-1])||t&&g>0&&i[g-1]==="text"&&RB(G.text)&&tI(Q[g-1])||t&&g>0&&i[g-1]==="text"&&lB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=E[g-1]||G.isWordLike):t&&g>0&&i[g-1]==="text"&&G.isWordLike&&BC(G.text)&&YB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=!0):t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&nB(Q[g-1],G.text)||t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&(JB(G.text)||G.text==="-"&&E[g-1])?Q[g-1]+=G.text:(Q[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]&&iC(Q[a])&&i[a-1]==="text"&&(Q[a-1]+=Q[a],E[a-1]=E[a-1]||E[a],Q[a]="");for(let a=g-2;a>=0;a--)if(i[a]==="text"&&!E[a]&&UB(Q[a])){let G=a+1;for(;G<g&&Q[G]==="";)G++;G<g&&i[G]==="text"&&(Q[G]=Q[a]+Q[G],w[G]=w[a],Q[a]="")}let o=0;for(let a=0;a<g;a++){const G=Q[a];G.length!==0&&(o!==a&&(Q[o]=G,E[o]=E[a],i[o]=i[a],w[o]=w[a]),o++)}Q.length=o,E.length=o,i.length=o,w.length=o;const s=ZB({len:o,texts:Q,isWordLike:E,kinds:i,starts:w}),h=jB(OB(WB(xB(TB(bB(s))))));for(let a=0;a<h.len-1;a++){const G=LB(h.texts[a]);G!==null&&(h.kinds[a]!=="space"&&h.kinds[a]!=="preserved-space"||h.kinds[a+1]!=="text"||!BC(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 C=0;for(let g=0;g<B.len;g++)B.kinds[g]==="hard-break"&&(I.push({startSegmentIndex:C,endSegmentIndex:g,consumedEndSegmentIndex:g+1}),C=g+1);return C<B.len&&I.push({startSegmentIndex:C,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}),I}function PB(B,A,I="normal"){const C=KB(I),g=C.mode==="pre-wrap"?yB(B):SB(B);if(g.length===0)return{normalized:g,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const Q=XB(g,A,C);return{normalized:g,chunks:vB(Q,C),...Q}}let JI=null;const RQ=new Map;let RI=null;const VB=new RegExp("\\p{Emoji_Presentation}","u"),zB=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let wC=null;const UQ=new Map;function sC(){if(JI!==null)return JI;if(typeof OffscreenCanvas<"u")return JI=new OffscreenCanvas(1,1).getContext("2d"),JI;if(typeof document<"u")return JI=document.createElement("canvas").getContext("2d"),JI;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function _B(B){let A=RQ.get(B);return A||(A=new Map,RQ.set(B,A)),A}function KI(B,A){let I=A.get(B);return I===void 0&&(I={width:sC().measureText(B).width,containsCJK:tI(B)},A.set(B,I)),I}function Dg(){if(RI!==null)return RI;if(typeof navigator>"u")return RI={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},RI;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/"),C=B.includes("Chrome/")||B.includes("Chromium/")||B.includes("CriOS/")||B.includes("Edg/");return RI={lineFitEpsilon:I?1/64:.005,carryCJKAfterClosingQuote:C,preferPrefixWidthsForBreakableRuns:I,preferEarlySoftHyphenBreak:I},RI}function $B(B){const A=B.match(/(\d+(?:\.\d+)?)\s*px/);return A?parseFloat(A[1]):16}function hC(){return wC===null&&(wC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),wC}function AE(B){return VB.test(B)||B.includes("️")}function IE(B){return zB.test(B)}function gE(B,A){let I=UQ.get(B);if(I!==void 0)return I;const C=sC();C.font=B;const g=C.measureText("😀").width;if(I=0,g>A+.5&&typeof document<"u"&&document.body!==null){const Q=document.createElement("span");Q.style.font=B,Q.style.display="inline-block",Q.style.visibility="hidden",Q.style.position="absolute",Q.textContent="😀",document.body.appendChild(Q);const E=Q.getBoundingClientRect().width;document.body.removeChild(Q),g-E>.5&&(I=g-E)}return UQ.set(B,I),I}function CE(B){let A=0;const I=hC();for(const C of I.segment(B))AE(C.segment)&&A++;return A}function QE(B,A){return A.emojiCount===void 0&&(A.emojiCount=CE(B)),A.emojiCount}function SI(B,A,I){return I===0?A.width:A.width-QE(B,A)*I}function BE(B,A,I,C){if(A.graphemeWidths!==void 0)return A.graphemeWidths;const g=[],Q=hC();for(const E of Q.segment(B)){const i=KI(E.segment,I);g.push(SI(E.segment,i,C))}return A.graphemeWidths=g.length>1?g:null,A.graphemeWidths}function EE(B,A,I,C){if(A.graphemePrefixWidths!==void 0)return A.graphemePrefixWidths;const g=[],Q=hC();let E="";for(const i of Q.segment(B)){E+=i.segment;const w=KI(E,I);g.push(SI(E,w,C))}return A.graphemePrefixWidths=g.length>1?g:null,A.graphemePrefixWidths}function iE(B,A){const I=sC();I.font=B;const C=_B(B),g=$B(B),Q=A?gE(B,g):0;return{cache:C,fontSize:g,emojiCorrection:Q}}function wg(B){return B==="space"||B==="preserved-space"||B==="tab"||B==="zero-width-break"||B==="soft-hyphen"}function oE(B,A){if(A<=0)return 0;const I=B%A;return Math.abs(I)<=1e-6?A:A-I}function rQ(B,A,I,C){return!C||A===null?B[I]:A[I]-(I>0?A[I-1]:0)}function DE(B,A,I,C,g,Q){let E=0,i=A;for(;E<B.length;){const w=Q?A+B[E]:i+B[E];if((E+1<B.length?w+g:w)>I+C)break;i=w,E++}return{fitCount:E,fittedWidth:i}}function wE(B,A,I){const{widths:C,kinds:g,breakableWidths:Q,breakablePrefixWidths:E}=B;if(C.length===0)return 0;const i=Dg(),w=i.lineFitEpsilon;let o=0,s=0,h=!1,a=0,G=0,t=0,K=0,S=-1,y=0;function N(){S=-1,y=0}function M(q=t,P=K,sA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:q,endGraphemeIndex:P,width:sA}),s=0,h=!1,N()}function e(q,P){h=!0,a=q,G=0,t=q+1,K=0,s=P}function Y(q,P,sA){h=!0,a=q,G=P,t=q,K=P+1,s=sA}function j(q,P){if(!h){e(q,P);return}s+=P,t=q+1,K=0}function l(q,P){wg(g[q])&&(S=q+1,y=s-P)}function r(q){v(q,0)}function v(q,P){const sA=Q[q],EA=E[q]??null;for(let T=P;T<sA.length;T++){const V=rQ(sA,EA,T,i.preferPrefixWidthsForBreakableRuns);if(!h){Y(q,T,V);continue}s+V>A+w?(M(),Y(q,T,V)):(s+=V,t=q,K=T+1)}h&&t===q&&K===sA.length&&(t=q+1,K=0)}let n=0;for(;n<C.length;){const q=C[n],P=g[n];if(!h){q>A&&Q[n]!==null?r(n):e(n,q),l(n,q),n++;continue}if(s+q>A+w){if(wg(P)){j(n,q),M(n+1,0,s-q),n++;continue}if(S>=0){M(S,0,y);continue}if(q>A&&Q[n]!==null){M(),r(n),n++;continue}M();continue}j(n,q),l(n,q),n++}return h&&M(),o}function sE(B,A,I){if(B.simpleLineWalkFastPath)return wE(B,A,I);const{widths:C,lineEndFitAdvances:g,lineEndPaintAdvances:Q,kinds:E,breakableWidths:i,breakablePrefixWidths:w,discretionaryHyphenWidth:o,tabStopAdvance:s,chunks:h}=B;if(C.length===0||h.length===0)return 0;const a=Dg(),G=a.lineFitEpsilon;let t=0,K=0,S=!1,y=0,N=0,M=0,e=0,Y=-1,j=0,l=0,r=null;function v(){Y=-1,j=0,l=0,r=null}function n(d=M,p=e,U=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:N,endSegmentIndex:d,endGraphemeIndex:p,width:U}),K=0,S=!1,v()}function q(d,p){S=!0,y=d,N=0,M=d+1,e=0,K=p}function P(d,p,U){S=!0,y=d,N=p,M=d,e=p+1,K=U}function sA(d,p){if(!S){q(d,p);return}K+=p,M=d+1,e=0}function EA(d,p){if(!wg(E[d]))return;const U=E[d]==="tab"?0:g[d],_=E[d]==="tab"?p:Q[d];Y=d+1,j=K-p+U,l=K-p+_,r=E[d]}function T(d){V(d,0)}function V(d,p){const U=i[d],_=w[d]??null;for(let f=p;f<U.length;f++){const $=rQ(U,_,f,a.preferPrefixWidthsForBreakableRuns);if(!S){P(d,f,$);continue}K+$>A+G?(n(),P(d,f,$)):(K+=$,M=d,e=f+1)}S&&M===d&&e===U.length&&(M=d+1,e=0)}function IA(d){if(r!=="soft-hyphen")return!1;const p=i[d];if(p===null)return!1;const U=a.preferPrefixWidthsForBreakableRuns?w[d]??p:p,_=U!==p,{fitCount:f,fittedWidth:$}=DE(U,K,A,G,o,_);return f===0?!1:(K=$,M=d,e=f,v(),f===p.length?(M=d+1,e=0,!0):(n(d,f,$+o),V(d,f),!0))}function x(d){t++,I==null||I({startSegmentIndex:d.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:d.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),v()}for(let d=0;d<h.length;d++){const p=h[d];if(p.startSegmentIndex===p.endSegmentIndex){x(p);continue}S=!1,K=0,y=p.startSegmentIndex,N=0,M=p.startSegmentIndex,e=0,v();let U=p.startSegmentIndex;for(;U<p.endSegmentIndex;){const _=E[U],f=_==="tab"?oE(K,s):C[U];if(_==="soft-hyphen"){S&&(M=U+1,e=0,Y=U+1,j=K+o,l=K+o,r=_),U++;continue}if(!S){f>A&&i[U]!==null?T(U):q(U,f),EA(U,f),U++;continue}if(K+f>A+G){const hA=K+(_==="tab"?0:g[U]),SA=K+(_==="tab"?f:Q[U]);if(r==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&j<=A+G){n(Y,0,l);continue}if(r==="soft-hyphen"&&IA(U)){U++;continue}if(wg(_)&&hA<=A+G){sA(U,f),n(U+1,0,SA),U++;continue}if(Y>=0&&j<=A+G){n(Y,0,l);continue}if(f>A&&i[U]!==null){n(),T(U),U++;continue}n();continue}sA(U,f),EA(U,f),U++}if(S){const _=Y===p.consumedEndSegmentIndex?l:K;n(p.consumedEndSegmentIndex,0,_)}}return t}let aC=null,nQ=new WeakMap;function YQ(){return aC===null&&(aC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),aC}function hE(B){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function aE(B,A,I){const C=YQ(),g=Dg(),{cache:Q,emojiCorrection:E}=iE(A,IE(B.normalized)),i=SI("-",KI("-",Q),E),o=SI(" ",KI(" ",Q),E)*8;if(B.len===0)return hE();const s=[],h=[],a=[],G=[];let t=B.chunks.length<=1;const K=[],S=[],y=[],N=I?[]:null,M=Array.from({length:B.len}),e=Array.from({length:B.len});function Y(r,v,n,q,P,sA,EA,T){P!=="text"&&P!=="space"&&P!=="zero-width-break"&&(t=!1),s.push(v),h.push(n),a.push(q),G.push(P),K==null||K.push(sA),S.push(EA),y.push(T),N!==null&&N.push(r)}for(let r=0;r<B.len;r++){M[r]=s.length;const v=B.texts[r],n=B.isWordLike[r],q=B.kinds[r],P=B.starts[r];if(q==="soft-hyphen"){Y(v,0,i,i,q,P,null,null),e[r]=s.length;continue}if(q==="hard-break"){Y(v,0,0,0,q,P,null,null),e[r]=s.length;continue}if(q==="tab"){Y(v,0,0,0,q,P,null,null),e[r]=s.length;continue}const sA=KI(v,Q);if(q==="text"&&sA.containsCJK){let IA="",x=0;for(const d of C.segment(v)){const p=d.segment;if(IA.length===0){IA=p,x=d.index;continue}if(og.has(IA)||MQ.has(p)||uI.has(p)||g.carryCJKAfterClosingQuote&&tI(p)&&eQ(IA)){IA+=p;continue}const U=KI(IA,Q),_=SI(IA,U,E);Y(IA,_,_,_,"text",P+x,null,null),IA=p,x=d.index}if(IA.length>0){const d=KI(IA,Q),p=SI(IA,d,E);Y(IA,p,p,p,"text",P+x,null,null)}e[r]=s.length;continue}const EA=SI(v,sA,E),T=q==="space"||q==="preserved-space"||q==="zero-width-break"?0:EA,V=q==="space"||q==="zero-width-break"?0:EA;if(n&&v.length>1){const IA=BE(v,sA,Q,E),x=g.preferPrefixWidthsForBreakableRuns?EE(v,sA,Q,E):null;Y(v,EA,T,V,q,P,IA,x)}else Y(v,EA,T,V,q,P,null,null);e[r]=s.length}const j=GE(B.chunks,M,e),l=K===null?null:aB(B.normalized,K);return N!==null?{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:l,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:j,segments:N}:{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:l,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:j}}function GE(B,A,I){const C=[];for(let g=0;g<B.length;g++){const Q=B[g],E=Q.startSegmentIndex<A.length?A[Q.startSegmentIndex]:I[I.length-1]??0,i=Q.endSegmentIndex<A.length?A[Q.endSegmentIndex]:I[I.length-1]??0,w=Q.consumedEndSegmentIndex<A.length?A[Q.consumedEndSegmentIndex]:I[I.length-1]??0;C.push({startSegmentIndex:E,endSegmentIndex:i,consumedEndSegmentIndex:w})}return C}function tE(B,A,I,C){const g=PB(B,Dg(),C==null?void 0:C.whiteSpace);return aE(g,A,I)}function KE(B,A,I){return tE(B,A,!0,I)}function Ei(B){return B}function lQ(B,A,I){let C=I.get(B);if(C!==void 0)return C;C=[];const g=YQ();for(const Q of g.segment(A[B]))C.push(Q.segment);return I.set(B,C),C}function SE(B){let A=nQ.get(B);return A!==void 0||(A=new Map,nQ.set(B,A)),A}function yE(B,A,I,C){return C>0&&B[C-1]==="soft-hyphen"&&!(A===C&&I>0)}function kE(B,A,I,C,g,Q,E){let i="";const w=yE(A,C,g,Q);for(let o=C;o<Q;o++)A[o]==="soft-hyphen"||A[o]==="hard-break"||(o===C&&g>0?i+=lQ(o,B,I).slice(g).join(""):i+=B[o]);return E>0?(w&&(i+="-"),i+=lQ(Q,B,I).slice(C===Q?g:0,E).join("")):w&&(i+="-"),i}function NE(B,A,I,C,g,Q,E){return{text:kE(B.segments,B.kinds,A,C,g,Q,E),width:I,start:{segmentIndex:C,graphemeIndex:g},end:{segmentIndex:Q,graphemeIndex:E}}}function FE(B,A,I){return NE(B,A,I.width,I.startSegmentIndex,I.startGraphemeIndex,I.endSegmentIndex,I.endGraphemeIndex)}function ME(B,A,I){const C=[];if(B.widths.length===0)return{lineCount:0,height:0,lines:C};const g=SE(B),Q=sE(B,A,E=>{C.push(FE(B,g,E))});return{lineCount:Q,height:Q*I,lines:C}}const LQ=B=>B,eE=B=>B>0?1:0,cE=B=>B<1?0:1,qQ=B=>B*B,pQ=B=>B*(2-B),HQ=B=>B<.5?2*B*B:-1+(4-2*B)*B,JE=B=>B*B*B,RE=B=>--B*B*B+1,UE=B=>B<.5?4*B*B*B:(B-1)*(2*B-2)*(2*B-2)+1,rE=B=>B*B*B*B,nE=B=>1- --B*B*B*B,YE=B=>B<.5?8*B*B*B*B:1-8*--B*B*B*B,lE=B=>B*B*B*B*B,LE=B=>1+--B*B*B*B*B,qE=B=>B<.5?16*B*B*B*B*B:1+16*--B*B*B*B*B,pE=B=>1-Math.cos(B*Math.PI/2),HE=B=>Math.sin(B*Math.PI/2),dE=B=>-(Math.cos(Math.PI*B)-1)/2,fE=B=>B===0?0:Math.pow(2,10*(B-1)),bE=B=>B===1?1:1-Math.pow(2,-10*B),TE=B=>B===0?0:B===1?1:B<.5?Math.pow(2,20*B-10)/2:(2-Math.pow(2,-20*B+10))/2,uE=B=>1-Math.sqrt(1-B*B),mE=B=>Math.sqrt(1- --B*B),xE=B=>B<.5?(1-Math.sqrt(1-4*B*B))/2:(Math.sqrt(1-(-2*B+2)*(-2*B+2))+1)/2,sg=1.70158,hg=sg*1.525,dQ=sg+1,OE=B=>dQ*B*B*B-sg*B*B,WE=B=>1+dQ*Math.pow(B-1,3)+sg*Math.pow(B-1,2),ZE=B=>B<.5?Math.pow(2*B,2)*((hg+1)*2*B-hg)/2:(Math.pow(2*B-2,2)*((hg+1)*(B*2-2)+hg)+2)/2,fQ=2*Math.PI/3,bQ=2*Math.PI/4.5,jE=B=>B===0?0:B===1?1:-Math.pow(2,10*B-10)*Math.sin((B*10-10.75)*fQ),XE=B=>B===0?0:B===1?1:Math.pow(2,-10*B)*Math.sin((B*10-.75)*fQ)+1,vE=B=>B===0?0:B===1?1:B<.5?-(Math.pow(2,20*B-10)*Math.sin((20*B-11.125)*bQ))/2:Math.pow(2,-20*B+10)*Math.sin((20*B-11.125)*bQ)/2+1,ag=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,PE=B=>1-ag(1-B),VE=ag,zE=B=>B<.5?(1-ag(1-2*B))/2:(1+ag(2*B-1))/2,GC=new Map,mI=(B,A,I,C)=>{const g=`${B},${A},${I},${C}`;if(GC.has(g))return GC.get(g);const Q=s=>(1-3*I+3*B)*s*s*s+(3*I-6*B)*s*s+3*B*s,E=s=>(1-3*C+3*A)*s*s*s+(3*C-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=Q(h)-s;if(Math.abs(G)<1e-6)return h;const t=i(h);if(Math.abs(t)<1e-6)break;h=h-G/t}return h},o=s=>s===0?0:s===1?1:E(w(s));return GC.set(g,o),o},TQ=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,C,g,Q]=A.map(Number);return mI(I,C,g,Q)},uQ={ease:mI(.25,.1,.25,1),"ease-in":mI(.42,0,1,1),"ease-out":mI(0,0,.58,1),"ease-in-out":mI(.42,0,.58,1)},Gg={Linear:LQ,EaseInQuad:qQ,EaseOutQuad:pQ,EaseInOutQuad:HQ,EaseInCubic:JE,EaseOutCubic:RE,EaseInOutCubic:UE,EaseInQuart:rE,EaseOutQuart:nE,EaseInOutQuart:YE,EaseInQuint:lE,EaseOutQuint:LE,EaseInOutQuint:qE,EaseInSine:pE,EaseOutSine:HE,EaseInOutSine:dE,EaseInExpo:fE,EaseOutExpo:bE,EaseInOutExpo:TE,EaseInCirc:uE,EaseOutCirc:mE,EaseInOutCirc:xE,EaseInBack:OE,EaseOutBack:WE,EaseInOutBack:ZE,EaseInElastic:jE,EaseOutElastic:XE,EaseInOutElastic:vE,EaseInBounce:PE,EaseOutBounce:VE,EaseInOutBounce:zE,EaseIn:qQ,EaseOut:pQ,EaseInOut:HQ,StepStart:eE,StepEnd:cE},_E=B=>{const A=B.trim(),I=A.toLowerCase();if(Gg[A])return Gg[A];const C=Object.keys(Gg).find(Q=>Q.toLowerCase()===I);if(C)return Gg[C];const g=Object.keys(mQ).find(Q=>Q.toLowerCase()===I);if(g){const Q=TQ(mQ[g].value);if(Q)return Q}if(uQ[I])return uQ[I];if(I.startsWith("cubic-bezier")){const Q=TQ(A);if(Q)return Q}return LQ},mQ={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 xQ{constructor(){tA(this,"artboard",null);tA(this,"objectStates",new Map);tA(this,"physicsEngine",null);tA(this,"activeStateMachine",null);tA(this,"inputs",new Map);tA(this,"inputNameMap",new Map);tA(this,"layerStates",new Map);tA(this,"pretextCache",new Map);tA(this,"pointerHistory",[]);tA(this,"MAX_HISTORY",200);tA(this,"imageCache",new Map);tA(this,"lastValidSvgImgMap",new Map);tA(this,"maskBuffer",null);tA(this,"maskCtx",null);tA(this,"lumaBuffer",null);tA(this,"lumaCtx",null);tA(this,"layout",{fit:"Contain",alignment:"Center"});tA(this,"onTrigger");tA(this,"onInputUpdate");tA(this,"onComponentChange");tA(this,"onToggle");tA(this,"onInputChange");tA(this,"onInputFocus");tA(this,"onInputBlur");tA(this,"onLog");tA(this,"justFiredTriggers",new Set);tA(this,"rootTransform",null);tA(this,"canvasWidth",0);tA(this,"canvasHeight",0);tA(this,"lastHoveredObjectId",null);tA(this,"_lastPointerPos",null);tA(this,"_prevPointerPos",null);tA(this,"focusedId",null);tA(this,"draggingSliderId",null);tA(this,"activeDropdownId",null);tA(this,"draggingListViewId",null);tA(this,"scrollOffset",{x:0,y:0});tA(this,"draggingBehaviors",new Set);tA(this,"objectVelocities",new Map);tA(this,"currentTime",0);tA(this,"frameCount",0);tA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});tA(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.22) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}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}setOnLogCallback(A){this.onLog=A}debugLog(A){this.onLog&&this.onLog(A)}setInputFocusCallback(A){this.onInputFocus=A}setInputBlurCallback(A){this.onInputBlur=A}updateConstraint(A,I,C){var Q;const g=(Q=this.artboard)==null?void 0:Q.objects.find(E=>E.id===A);g&&g.constraints&&g.constraints[I]&&(g.constraints[I]={...g.constraints[I],...C},C.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 C=this.objectStates.get(A);C&&(C.options={...C.options,...I})}updateGraphData(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(g=>g.id===A||g.name===A);if(C&&C.geometry.type==="LineGraph"){const g=C.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 Q=this.objectStates.get(C.id);Q&&Q.geometry&&Q.geometry.type==="LineGraph"&&(!Q.geometry.datasets||Q.geometry.datasets.length===0?Q.geometry.datasets=JSON.parse(JSON.stringify(g.datasets)):Q.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=>{var E,i,w,o;const C=I.width??((E=I.geometry)==null?void 0:E.width)??0,g=I.height??((i=I.geometry)==null?void 0:i.height)??0,Q=I.cornerRadius??I.corner_radius??((w=I.geometry)==null?void 0:w.corner_radius)??((o=I.geometry)==null?void 0:o.cornerRadius)??0;this.objectStates.set(I.id,{...I.transform,width:C,height:g,cornerRadius:Q,corner_radius:Q,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.transform.opacity!==void 0?I.transform.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 C;return(C=I.physics)==null?void 0:C.enabled})){this.physicsEngine=new oB;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 C;this.physicsEngine&&((C=this.artboard)==null||C.objects.forEach(g=>{var Q;if((Q=g.physics)!=null&&Q.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 C=this.inputNameMap.get(I.name)||[];C.push(I.id),this.inputNameMap.set(I.name,C)}),this.activeStateMachine.layers.forEach(I=>{const C=I.states.find(g=>g.id===I.entryStateId);C&&this.enterStates(I.name,[C.id])}),this.evaluateTransitions()),!this.artboard.stateMachine&&this.artboard.animations.length>0){const I=this.artboard.animations||[],C=I.find(g=>(g.name||"").toLowerCase()==="onload")||I[0];C&&(console.log(`[ExodeUI] Auto-starting fallback animation: ${C.name}`),this.layerStates.set("intro",{currentStateIds:["onLoad"],animations:[{animation:C,state:{loop:!0}}],time:0,duration:C.duration}))}this.updateAutoLayout(),this.loadFonts()}updateAutoLayout(){var g;if(!this.artboard)return;const A=new Map;this.artboard.objects.forEach(Q=>A.set(Q.id,Q));const I=.15,C=Q=>{Q.forEach(E=>{const i=this.objectStates.get(E.id);if(i){const w=Math.abs(i.x-E.x),o=Math.abs(i.y-E.y);w>20||o>20?(i.x+=(E.x-i.x)*I,i.y+=(E.y-i.y)*I):(i.x=E.x,i.y=E.y),E.width!==void 0&&(i.width=E.width),E.height!==void 0&&(i.height=E.height)}})};if((g=this.artboard.autoLayout)!=null&&g.enabled){const Q=this.artboard.objects.filter(i=>!i.parentId),E=SC(this.artboard,Q,i=>this.objectStates.get(i));C(E.childUpdates)}this.artboard.objects.forEach(Q=>{var E;if(Q.type==="Frame"&&((E=Q.autoLayout)!=null&&E.enabled)&&Q.children&&Q.children.length>0){const i=Q.children.map(s=>A.get(s)).filter(s=>!!s),w=this.objectStates.get(Q.id);if(!w)return;const o=SC(w,i,s=>this.objectStates.get(s));o.frameWidth!==void 0&&(w.width=o.frameWidth),o.frameHeight!==void 0&&(w.height=o.frameHeight),C(o.childUpdates)}})}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 C="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(C);i||(i=document.createElement("link"),i.id=C,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}const Q=[];if(A.forEach(E=>{E.toLowerCase().includes("clash display")&&Q.push("clash-display@200,300,400,500,600,700")}),Q.length>0){const E=`https://api.fontshare.com/v2/css?f[]=${Q.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 C=this.layerStates.get(A);if(C&&C.currentStateIds.length===I.length&&I.every(i=>C.currentStateIds.includes(i))&&this.justFiredTriggers.size===0)return;const g=[];let Q=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}),Q=Math.max(Q,o.duration))}}}this.layerStates.set(A,{currentStateIds:I,animations:g,time:0,duration:Q})}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 C;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"&&(C=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"&&(C=s.value.type)}}let g=I;C==="Trigger"&&(I===1?g=!0:I===0&&(g=!1)),this.inputs.has(A)&&this.setInternalInput(A,g);const Q=this.inputNameMap.get(A);Q&&Q.forEach(o=>this.setInternalInput(o,g)),C==="Trigger"&&g===!0&&(this.justFiredTriggers.add(A),Q&&Q.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 C=[];let g=!1;for(const Q of I.currentStateIds){const E=A.states.find(w=>w.id===Q);if(!E)continue;let i=!1;for(const w of E.transitions)this.checkConditions(w.conditions)&&(C.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||C.push(Q)}if(!g){const Q=this.findGlobalTransition(A,I.currentStateIds);Q&&(C.length=0,C.push(Q.targetStateId),g=!0,Q.conditions&&Q.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 Q=Array.from(new Set(C));this.enterStates(A.name,Q)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(A=>{var C,g;this.setInternalInput(A,!1);const I=(C=this.activeStateMachine)==null?void 0:C.inputs.find(Q=>Q.id===A);I&&this.inputNameMap.has(I.name)&&((g=this.inputNameMap.get(I.name))==null||g.forEach(Q=>this.setInternalInput(Q,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(A,I){for(const C of A.states)if(!(I.includes(C.id)&&this.justFiredTriggers.size===0)){for(const Q of C.transitions)if(!(I.includes(Q.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(Q.conditions))return Q}return null}checkConditions(A){return!A||A.length===0?!0:A.every(I=>{const C=I.inputId,g=I.op,Q=I.value,E=this.evaluateLogicTree(C);if(E===void 0)return console.log(`[Engine] Condition Check Failed: Input ${C} is undefined`),!1;let i=!1;switch(g){case"Equal":i=E==Q;break;case"NotEqual":i=E!=Q;break;case"GreaterThan":i=E>Q;break;case"LessThan":i=E<Q;break;case"GreaterEqual":i=E>=Q;break;case"LessEqual":i=E<=Q;break;case"IsTrue":i=E===!0;break;case"IsFalse":i=E===!1;break;default:i=!1}return i||this.justFiredTriggers.has(C),i})}evaluateLogicTree(A,I,C=new Set){var E,i,w;if(C.has(A))return!1;C.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,C):a.value!==void 0?a.value:h:h};switch(g.op){case NI.AND:return o("a",!1)&&o("b",!1);case NI.OR:return o("a",!1)||o("b",!1);case NI.NOT:return!o("in",!1);case NI.XOR:return!!o("a",!1)!=!!o("b",!1);default:return 0}}let Q=this.inputs.get(A);if(this.justFiredTriggers.has(A)&&(Q=!0),I&&Q!==void 0){const o=(w=this.activeStateMachine)==null?void 0:w.inputs.find(s=>s.id===A);if(o&&o.value.type==="Number"&&typeof Q=="number"){const s=o.value.defaultValue??o.value.value;if(I==="source-greater")return Q>s;if(I==="source-less")return Q<s;if(I==="source-equal")return Q===s}if(I==="source-true")return Q===!0;if(I==="source-false")return Q===!1;if(I==="source-fire")return this.justFiredTriggers.has(A)}return Q!==void 0?Q:0}advance(A){this.artboard&&(this.currentTime+=A,this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(A),this.artboard.objects.forEach(I=>{var C;if((C=I.physics)!=null&&C.enabled){const g=this.physicsEngine.getPosition(I.id),Q=this.physicsEngine.getRotation(I.id),E=this.objectStates.get(I.id);E&&g!==null&&Q!==null&&(E.x=g.x,E.y=g.y,E.rotation=Q*(180/Math.PI))}})),this.activeStateMachine&&(this.evaluateTransitions(),this.layerStates.forEach(I=>{I.animations.length>0&&(I.time+=A,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${I.time.toFixed(3)} / ${I.duration.toFixed(3)}`),I.time>I.duration&&(I.animations.some(g=>{var Q;return((Q=g.state)==null?void 0:Q.loop)===!0})?I.time%=I.duration:I.time=I.duration),I.animations.forEach(C=>{this.applyAnimation(C.animation,I.time)}))})),this.solveConstraints(A),this.solveBehaviors(A),this.activeTriggers.forEach((I,C)=>{var g,Q,E,i,w,o,s;if(I.phase==="entry")I.time+=A,I.time>=I.animation.duration&&((E=(Q=(g=this.artboard)==null?void 0:g.objects.find(h=>h.id===C))==null?void 0:Q.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===C))==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(t=>t.id===h.exitAnimationId);G?(I.phase="exit",I.animation=G,I.time=0):this.activeTriggers.delete(C)}else this.activeTriggers.delete(C)}else I.phase==="exit"&&(I.time+=A,I.time>=I.animation.duration?this.activeTriggers.delete(C):this.applyAnimation(I.animation,I.time))}))}solveConstraints(A){this.artboard&&this.artboard.objects.forEach(I=>{if(!I.constraints||I.constraints.length===0)return;const C=this.objectStates.get(I.id);if(!C)return;const g=this.getGlobalTransform(I.id);if(I.constraints.forEach(Q=>{var i,w,o,s,h,a,G;const E=Q.strength??1;if(Q.type==="Translation"){const t=this.getGlobalTransform(Q.targetId);if(t){if(Q.useSpring){const S=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:y,y:N,vx:M,vy:e}=this.computeSpring(g.x,g.y,S.vx,S.vy,t.x,t.y,Q,A);Q.copyX&&(g.x=y),Q.copyY&&(g.y=N),this.objectVelocities.set(I.id,{vx:M,vy:e})}else Q.copyX&&(g.x=g.x+(t.x-g.x)*E),Q.copyY&&(g.y=g.y+(t.y-g.y)*E);(i=Q.limitX)!=null&&i.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(w=Q.limitY)!=null&&w.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}}else if(Q.type==="Rotation"){const t=this.getGlobalTransform(Q.targetId);if(t){let S=(t.rotation+(Q.offset||0)-g.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),g.rotation=g.rotation+S*E}}else if(Q.type==="Scale"){const t=this.getGlobalTransform(Q.targetId);t&&(Q.copyX&&(g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E),Q.copyY&&(g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E))}else if(Q.type==="Transform"){const t=this.getGlobalTransform(Q.targetId);if(t){g.x=g.x+(t.x-g.x)*E,g.y=g.y+(t.y-g.y)*E;let K=(t.rotation-g.rotation)%360;K>180&&(K-=360),K<-180&&(K+=360),g.rotation=g.rotation+K*E,g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E,g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E}}else if(Q.type==="FollowPointer"){const t=((o=this._lastPointerPos)==null?void 0:o.x)??g.x,K=((s=this._lastPointerPos)==null?void 0:s.y)??g.y;if(Q.useSpring){const y=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:N,y:M,vx:e,vy:Y}=this.computeSpring(g.x,g.y,y.vx,y.vy,t,K,Q,A);g.x=N,g.y=M,this.objectVelocities.set(I.id,{vx:e,vy:Y})}else g.x=g.x+(t-g.x)*E,g.y=g.y+(K-g.y)*E;(h=Q.limitX)!=null&&h.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(a=Q.limitY)!=null&&a.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}else if(Q.type==="Distance"){const t=this.getGlobalTransform(Q.targetId);if(t){const K=g.x-t.x,S=g.y-t.y,y=Math.sqrt(K*K+S*S),N=Q.distance||0;let M=y;switch(Q.mode){case"exact":M=N;break;case"minimum":M=Math.max(N,y);break;case"maximum":M=Math.min(N,y);break;case"clamped":M=Math.max(0,Math.min(N,y));break}if(y>0){const e=g.x===t.x&&g.y===t.y?1:M/y;g.x=g.x+(t.x+K*e-g.x)*E,g.y=g.y+(t.y+S*e-g.y)*E}}}else if(Q.type==="FollowPath"){const t=(G=this.artboard)==null?void 0:G.objects.find(K=>K.id===Q.targetId);if(t){const K=this.getGlobalTransform(t.id);if(K){const S=(Q.distance||0)/100,y=K.width||t.geometry.width||0,N=K.height||t.geometry.height||0,M=this.getPointOnPath(t.geometry,y,N,S),e=K.rotation*Math.PI/180,Y=Math.cos(e),j=Math.sin(e),l=M.x*K.scale_x*Y-M.y*K.scale_y*j,r=M.x*K.scale_x*j+M.y*K.scale_y*Y,v=K.x+l+(Q.offsetX||0),n=K.y+r+(Q.offsetY||0);if(g.x=g.x+(v-g.x)*E,g.y=g.y+(n-g.y)*E,Q.orient){let P=(M.angle*180/Math.PI+K.rotation+(Q.offsetRotation||0)-g.rotation)%360;P>180&&(P-=360),P<-180&&(P+=360),g.rotation=g.rotation+P*E}}}}else if(Q.type==="IK"){const t=this.getGlobalTransform(Q.targetId);t&&this.solveIK(I,t,Q.boneCount||2,E)}}),I.constraints.some(Q=>Q.type!=="IK")){const Q=this.globalToLocal(I.parentId,g);C.x=Q.x,C.y=Q.y,C.rotation=Q.rotation,C.scale_x=Q.scale_x,C.scale_y=Q.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 C=(s=this.artboard)==null?void 0:s.objects.find(h=>h.id===A);if(!C||!C.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(C.parentId),Q=g.rotation*Math.PI/180,E=Math.cos(Q),i=Math.sin(Q),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 C=this.getGlobalTransform(A),g=C.scale_x===0?0:1/C.scale_x,Q=C.scale_y===0?0:1/C.scale_y,E=-C.rotation*Math.PI/180,i=Math.cos(E),w=Math.sin(E),o=I.x-C.x,s=I.y-C.y,h=(o*i-s*w)*g,a=(o*w+s*i)*Q;return{x:h,y:a,rotation:I.rotation-C.rotation,scale_x:I.scale_x/(C.scale_x||1),scale_y:I.scale_y/(C.scale_y||1)}}solveIK(A,I,C,g){var o;const Q=[];let E=A.id;for(let s=0;s<C&&E;s++){const h=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===E);if(!h)break;Q.push({id:E,local:this.objectStates.get(E),global:this.getGlobalTransform(E)}),E=h.parentId}if(Q.length<2)return;const i=Q.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],t=this.getGlobalTransform(G.id),K=h.x-t.x,S=h.y-t.y,y=I.x-t.x,N=I.y-t.y,M=Math.sqrt(K*K+S*S),e=Math.sqrt(y*y+N*N);if(M>.001&&e>.001){const Y=Math.atan2(S,K);let l=(Math.atan2(N,y)-Y)*180/Math.PI;l*=g;const r=this.objectStates.get(G.id);r&&(r.rotation+=l)}}}}computeSpring(A,I,C,g,Q,E,i,w){const o=i.stiffness??100,s=i.damping??10,h=i.mass??1,a=-o*(A-Q),G=-o*(I-E),t=-s*C,K=-s*g,S=(a+t)/h,y=(G+K)/h,N=C+S*w,M=g+y*w,e=A+N*w,Y=I+M*w;return{x:e,y:Y,vx:N,vy:M}}handlePointerInput(A,I,C,g,Q){if(!this.artboard)return;const E=this.calculateTransform(g,Q,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),i=(I-E.tx)/E.scaleX-this.artboard.width/2,w=(C-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,C){var w,o,s,h,a;if(!this.artboard)return;let g=null;const Q=(G,t)=>{var e;let K=t;t==="click"?K="onClick":t==="down"?K="onPointerDown":t==="up"?K="onPointerUp":t==="blur"&&(K="onPointerLeave");const S=new Set([K]);t==="move"&&S.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),K==="onClick"&&S.add("click"),K==="onPointerDown"&&S.add("pointerDown"),K==="onPointerUp"&&S.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider"];return!!(G.type==="Component"&&y.includes(G.variant)||y.includes((e=G.type)==null?void 0:e.toLowerCase())||(G.interactions||[]).some(Y=>S.has(Y.event))||(G.triggers||[]).some(Y=>S.has(Y.eventType)))};let E=null;for(let G=this.artboard.objects.length-1;G>=0;G--){const t=this.artboard.objects[G],K=this.objectStates.get(t.id);if(K&&K.visible!==!1&&K.opacity>0&&this.hitTest(t,I,C)&&(E||(E=t),Q(t,A))){g=t;break}}!g&&E&&(g=E),this.pointerHistory.push({x:I,y:C,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(t=>t.id===this.draggingSliderId);G&&this.updateSliderValueFromPointer(G,I,C);return}if(this.draggingListViewId){const G=this.artboard.objects.find(t=>t.id===this.draggingListViewId);G&&this.updateListViewScrollFromPointer(G);return}g&&g.type==="Component"&&g.variant==="listview"&&this.updateListViewHoverFromPointer(g,I,C),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===W.Draggable))&&this.draggingBehaviors.add(i),this.activeDropdownId&&A==="down"){const G=this.artboard.objects.find(t=>t.id===this.activeDropdownId);if(G&&(G.type==="Dropdown"||G.variant==="dropdown")){const t=this.objectStates.get(G.id),K=(t==null?void 0:t.options)||G.options||{},S=G.geometry||{},y=S.width??G.width??200,N=S.height??G.height??40,M=K.optionsList||[],e=K.itemHeight||32,Y=K.listPadding??4,j=M.length*e+Y*2,l=this.getWorldTransform(G.id),r=y*Math.abs(l.scaleX),v=N*Math.abs(l.scaleY),n=l.y+v/2+4,q=Math.abs(I-l.x)<=r/2,P=C>=n&&C<=n+j*Math.abs(l.scaleY);if(q&&P){const sA=Math.abs(l.scaleY),EA=C-(n+Y*sA),T=Math.floor(EA/(e*sA));if(T>=0&&T<M.length){const V=M[T];K.selectedOption=V,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,V),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:V})}return}else i!==this.activeDropdownId&&(K.isOpen=!1,this.activeDropdownId=null)}}if(g){let G=g,t=g;for(;t&&t.parentId;){const S=this.artboard.objects.find(y=>y.id===t.parentId);if(S&&S.type==="Component"){G=S;break}t=S}let K=A;if(A==="click"?K="onClick":A==="down"?K="onPointerDown":A==="up"?K="onPointerUp":A==="blur"&&(K="onPointerLeave"),this.fireEventForObject(g.id,K),G!==g&&this.fireEventForObject(G.id,K),G.type==="Component"&&G.variant==="toggle_button"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle_button",property:"checked",value:y.checked})}if(G.type==="Component"&&G.variant==="toggle"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(G.name,y.checked)}if(G.type==="Component"&&G.variant==="dropdown"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{},N=!y.isOpen;if(N&&this.activeDropdownId&&this.activeDropdownId!==G.id){const M=this.artboard.objects.find(e=>e.id===this.activeDropdownId);M&&M.options&&(M.options.isOpen=!1)}y.isOpen=N,this.activeDropdownId=N?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 S=this.getListViewItemIndexAtPointer(g,I,C);if(S!==null){const y=g.options||{};y.activeItemIndex=S;const N=this.objectStates.get(g.id);N&&N.options&&(N.options.activeItemIndex=S);const M=(y.items||[])[S],e=typeof M=="string"?M:M.label||M.value||S;N&&N.options&&(N.options.selectedValue=e),g.inputId&&this.setInternalInput(g.inputId,e),this.onComponentChange&&(this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"activeItemIndex",value:S}),this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"selected",value:e}))}}if(g.type==="Component"&&g.variant==="slider"&&A==="down"&&(this.draggingSliderId=g.id,this.updateSliderValueFromPointer(g,I,C)),A==="click"){const S=(o=this.artboard)==null?void 0:o.objects.find(N=>N.id===g.id),y=this.focusedId;if((S==null?void 0:S.type)==="Component"&&S.variant==="inputbox"){if(this.focusedId=g.id,console.log(`[Engine] Focus set to: ${g.id}`),y!==this.focusedId){if(y){const N=(s=this.artboard)==null?void 0:s.objects.find(M=>M.id===y);N&&this.onInputBlur&&this.onInputBlur(N.name)}this.onInputFocus&&this.onInputFocus(S.name)}}else if(this.focusedId=null,y){const N=(h=this.artboard)==null?void 0:h.objects.find(M=>M.id===y);N&&this.onInputBlur&&this.onInputBlur(N.name)}}}else if(A==="click"){const G=this.focusedId;if(this.focusedId=null,G){const t=(a=this.artboard)==null?void 0:a.objects.find(K=>K.id===G);t&&this.onInputBlur&&this.onInputBlur(t.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 C=I.options||{};let g=C.text||"";if(A.key==="Backspace")g=g.slice(0,-1);else if(A.key==="Enter")if(C.multiline)g+=`
5
+ `)return"hard-break"}return B===" "?"space":B===" "||B===" "||B==="⁠"||B==="\uFEFF"?"glue":B==="​"?"zero-width-break":B==="­"?"soft-hyphen":"text"}function pB(B,A,I,C){const g=[];let Q=null,E="",i=I,w=!1,o=0;for(const s of B){const h=qB(s,C),a=h==="text"&&A;if(Q!==null&&h===Q&&a===w){E+=s,o+=s.length;continue}Q!==null&&g.push({text:E,isWordLike:w,kind:Q,start:i}),Q=h,E=s,i=I+o,w=a,o+=s.length}return Q!==null&&g.push({text:E,isWordLike:w,kind:Q,start:i}),g}function oC(B){return B==="space"||B==="preserved-space"||B==="zero-width-break"||B==="hard-break"}const HB=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function dB(B,A){const I=B.texts[A];return I.startsWith("www.")?!0:HB.test(I)&&A+1<B.len&&B.kinds[A+1]==="text"&&B.texts[A+1]==="//"}function fB(B){return B.includes("?")&&(B.includes("://")||B.startsWith("www."))}function bB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let E=0;E<B.len;E++){if(C[E]!=="text"||!dB(B,E))continue;let i=E+1;for(;i<B.len&&!oC(C[i]);){A[E]+=A[i],I[E]=!0;const w=A[i].includes("?");if(C[i]="text",A[i]="",i++,w)break}}let Q=0;for(let E=0;E<A.length;E++){const i=A[E];i.length!==0&&(Q!==E&&(A[Q]=i,I[Q]=I[E],C[Q]=C[E],g[Q]=g[E]),Q++)}return A.length=Q,I.length=Q,C.length=Q,g.length=Q,{len:Q,texts:A,isWordLike:I,kinds:C,starts:g}}function TB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q]),!fB(E))continue;const i=Q+1;if(i>=B.len||oC(B.kinds[i]))continue;let w="";const o=B.starts[i];let s=i;for(;s<B.len&&!oC(B.kinds[s]);)w+=B.texts[s],s++;w.length>0&&(A.push(w),I.push(!0),C.push("text"),g.push(o),Q=s-1)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}const uB=new Set([":","-","/","×",",",".","+","–","—"]),cQ=/^[A-Za-z0-9_]+[,:;]*$/,mB=/[,:;]+$/;function JQ(B){for(const A of B)if(FQ.test(A))return!0;return!1}function DC(B){if(B.length===0)return!1;for(const A of B)if(!(FQ.test(A)||uB.has(A)))return!1;return!0}function xB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q];if(i==="text"&&DC(E)&&JQ(E)){let w=E,o=Q+1;for(;o<B.len&&B.kinds[o]==="text"&&DC(B.texts[o]);)w+=B.texts[o],o++;A.push(w),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=o-1;continue}A.push(E),I.push(B.isWordLike[Q]),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function OB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q],w=B.isWordLike[Q];if(i==="text"&&w&&cQ.test(E)){let o=E,s=Q+1;for(;mB.test(o)&&s<B.len&&B.kinds[s]==="text"&&B.isWordLike[s]&&cQ.test(B.texts[s]);)o+=B.texts[s],s++;A.push(o),I.push(!0),C.push("text"),g.push(B.starts[Q]),Q=s-1;continue}A.push(E),I.push(w),C.push(i),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function WB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q];if(B.kinds[Q]==="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||!JQ(s)||!DC(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),C.push("text"),g.push(B.starts[Q]+o),o+=a.length}continue}}A.push(E),I.push(B.isWordLike[Q]),C.push(B.kinds[Q]),g.push(B.starts[Q])}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function ZB(B){const A=[],I=[],C=[],g=[];let Q=0;for(;Q<B.len;){let E=B.texts[Q],i=B.isWordLike[Q],w=B.kinds[Q],o=B.starts[Q];if(w==="glue"){let s=E;const h=o;for(Q++;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text")E=s+B.texts[Q],i=B.isWordLike[Q],w="text",o=h,Q++;else{A.push(s),I.push(!1),C.push("glue"),g.push(h);continue}}else Q++;if(w==="text")for(;Q<B.len&&B.kinds[Q]==="glue";){let s="";for(;Q<B.len&&B.kinds[Q]==="glue";)s+=B.texts[Q],Q++;if(Q<B.len&&B.kinds[Q]==="text"){E+=s+B.texts[Q],i=i||B.isWordLike[Q],Q++;continue}E+=s}A.push(E),I.push(i),C.push(w),g.push(o)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function jB(B){const A=B.texts.slice(),I=B.isWordLike.slice(),C=B.kinds.slice(),g=B.starts.slice();for(let Q=0;Q<A.length-1;Q++){if(C[Q]!=="text"||C[Q+1]!=="text"||!tI(A[Q])||!tI(A[Q+1]))continue;const E=rB(A[Q]);E!==null&&(A[Q]=E.head,A[Q+1]=E.tail+A[Q+1],g[Q+1]=g[Q]+E.head.length)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function XB(B,A,I){const C=NB();let g=0;const Q=[],E=[],i=[],w=[];for(const a of C.segment(B))for(const G of pB(a.segment,a.isWordLike??!1,a.index,I)){const t=G.kind==="text";A.carryCJKAfterClosingQuote&&t&&g>0&&i[g-1]==="text"&&tI(G.text)&&tI(Q[g-1])&&eQ(Q[g-1])||t&&g>0&&i[g-1]==="text"&&RB(G.text)&&tI(Q[g-1])||t&&g>0&&i[g-1]==="text"&&lB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=E[g-1]||G.isWordLike):t&&g>0&&i[g-1]==="text"&&G.isWordLike&&BC(G.text)&&YB(Q[g-1])?(Q[g-1]+=G.text,E[g-1]=!0):t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&G.text.length===1&&G.text!=="-"&&G.text!=="—"&&nB(Q[g-1],G.text)||t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&(JB(G.text)||G.text==="-"&&E[g-1])?Q[g-1]+=G.text:(Q[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]&&iC(Q[a])&&i[a-1]==="text"&&(Q[a-1]+=Q[a],E[a-1]=E[a-1]||E[a],Q[a]="");for(let a=g-2;a>=0;a--)if(i[a]==="text"&&!E[a]&&UB(Q[a])){let G=a+1;for(;G<g&&Q[G]==="";)G++;G<g&&i[G]==="text"&&(Q[G]=Q[a]+Q[G],w[G]=w[a],Q[a]="")}let o=0;for(let a=0;a<g;a++){const G=Q[a];G.length!==0&&(o!==a&&(Q[o]=G,E[o]=E[a],i[o]=i[a],w[o]=w[a]),o++)}Q.length=o,E.length=o,i.length=o,w.length=o;const s=ZB({len:o,texts:Q,isWordLike:E,kinds:i,starts:w}),h=jB(OB(WB(xB(TB(bB(s))))));for(let a=0;a<h.len-1;a++){const G=LB(h.texts[a]);G!==null&&(h.kinds[a]!=="space"&&h.kinds[a]!=="preserved-space"||h.kinds[a+1]!=="text"||!BC(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 C=0;for(let g=0;g<B.len;g++)B.kinds[g]==="hard-break"&&(I.push({startSegmentIndex:C,endSegmentIndex:g,consumedEndSegmentIndex:g+1}),C=g+1);return C<B.len&&I.push({startSegmentIndex:C,endSegmentIndex:B.len,consumedEndSegmentIndex:B.len}),I}function PB(B,A,I="normal"){const C=KB(I),g=C.mode==="pre-wrap"?yB(B):SB(B);if(g.length===0)return{normalized:g,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const Q=XB(g,A,C);return{normalized:g,chunks:vB(Q,C),...Q}}let JI=null;const RQ=new Map;let RI=null;const VB=new RegExp("\\p{Emoji_Presentation}","u"),zB=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let wC=null;const UQ=new Map;function sC(){if(JI!==null)return JI;if(typeof OffscreenCanvas<"u")return JI=new OffscreenCanvas(1,1).getContext("2d"),JI;if(typeof document<"u")return JI=document.createElement("canvas").getContext("2d"),JI;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function _B(B){let A=RQ.get(B);return A||(A=new Map,RQ.set(B,A)),A}function KI(B,A){let I=A.get(B);return I===void 0&&(I={width:sC().measureText(B).width,containsCJK:tI(B)},A.set(B,I)),I}function Dg(){if(RI!==null)return RI;if(typeof navigator>"u")return RI={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},RI;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/"),C=B.includes("Chrome/")||B.includes("Chromium/")||B.includes("CriOS/")||B.includes("Edg/");return RI={lineFitEpsilon:I?1/64:.005,carryCJKAfterClosingQuote:C,preferPrefixWidthsForBreakableRuns:I,preferEarlySoftHyphenBreak:I},RI}function $B(B){const A=B.match(/(\d+(?:\.\d+)?)\s*px/);return A?parseFloat(A[1]):16}function hC(){return wC===null&&(wC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),wC}function AE(B){return VB.test(B)||B.includes("️")}function IE(B){return zB.test(B)}function gE(B,A){let I=UQ.get(B);if(I!==void 0)return I;const C=sC();C.font=B;const g=C.measureText("😀").width;if(I=0,g>A+.5&&typeof document<"u"&&document.body!==null){const Q=document.createElement("span");Q.style.font=B,Q.style.display="inline-block",Q.style.visibility="hidden",Q.style.position="absolute",Q.textContent="😀",document.body.appendChild(Q);const E=Q.getBoundingClientRect().width;document.body.removeChild(Q),g-E>.5&&(I=g-E)}return UQ.set(B,I),I}function CE(B){let A=0;const I=hC();for(const C of I.segment(B))AE(C.segment)&&A++;return A}function QE(B,A){return A.emojiCount===void 0&&(A.emojiCount=CE(B)),A.emojiCount}function SI(B,A,I){return I===0?A.width:A.width-QE(B,A)*I}function BE(B,A,I,C){if(A.graphemeWidths!==void 0)return A.graphemeWidths;const g=[],Q=hC();for(const E of Q.segment(B)){const i=KI(E.segment,I);g.push(SI(E.segment,i,C))}return A.graphemeWidths=g.length>1?g:null,A.graphemeWidths}function EE(B,A,I,C){if(A.graphemePrefixWidths!==void 0)return A.graphemePrefixWidths;const g=[],Q=hC();let E="";for(const i of Q.segment(B)){E+=i.segment;const w=KI(E,I);g.push(SI(E,w,C))}return A.graphemePrefixWidths=g.length>1?g:null,A.graphemePrefixWidths}function iE(B,A){const I=sC();I.font=B;const C=_B(B),g=$B(B),Q=A?gE(B,g):0;return{cache:C,fontSize:g,emojiCorrection:Q}}function wg(B){return B==="space"||B==="preserved-space"||B==="tab"||B==="zero-width-break"||B==="soft-hyphen"}function oE(B,A){if(A<=0)return 0;const I=B%A;return Math.abs(I)<=1e-6?A:A-I}function rQ(B,A,I,C){return!C||A===null?B[I]:A[I]-(I>0?A[I-1]:0)}function DE(B,A,I,C,g,Q){let E=0,i=A;for(;E<B.length;){const w=Q?A+B[E]:i+B[E];if((E+1<B.length?w+g:w)>I+C)break;i=w,E++}return{fitCount:E,fittedWidth:i}}function wE(B,A,I){const{widths:C,kinds:g,breakableWidths:Q,breakablePrefixWidths:E}=B;if(C.length===0)return 0;const i=Dg(),w=i.lineFitEpsilon;let o=0,s=0,h=!1,a=0,G=0,t=0,K=0,S=-1,y=0;function N(){S=-1,y=0}function M(q=t,P=K,sA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:q,endGraphemeIndex:P,width:sA}),s=0,h=!1,N()}function e(q,P){h=!0,a=q,G=0,t=q+1,K=0,s=P}function Y(q,P,sA){h=!0,a=q,G=P,t=q,K=P+1,s=sA}function j(q,P){if(!h){e(q,P);return}s+=P,t=q+1,K=0}function l(q,P){wg(g[q])&&(S=q+1,y=s-P)}function r(q){v(q,0)}function v(q,P){const sA=Q[q],EA=E[q]??null;for(let T=P;T<sA.length;T++){const V=rQ(sA,EA,T,i.preferPrefixWidthsForBreakableRuns);if(!h){Y(q,T,V);continue}s+V>A+w?(M(),Y(q,T,V)):(s+=V,t=q,K=T+1)}h&&t===q&&K===sA.length&&(t=q+1,K=0)}let n=0;for(;n<C.length;){const q=C[n],P=g[n];if(!h){q>A&&Q[n]!==null?r(n):e(n,q),l(n,q),n++;continue}if(s+q>A+w){if(wg(P)){j(n,q),M(n+1,0,s-q),n++;continue}if(S>=0){M(S,0,y);continue}if(q>A&&Q[n]!==null){M(),r(n),n++;continue}M();continue}j(n,q),l(n,q),n++}return h&&M(),o}function sE(B,A,I){if(B.simpleLineWalkFastPath)return wE(B,A,I);const{widths:C,lineEndFitAdvances:g,lineEndPaintAdvances:Q,kinds:E,breakableWidths:i,breakablePrefixWidths:w,discretionaryHyphenWidth:o,tabStopAdvance:s,chunks:h}=B;if(C.length===0||h.length===0)return 0;const a=Dg(),G=a.lineFitEpsilon;let t=0,K=0,S=!1,y=0,N=0,M=0,e=0,Y=-1,j=0,l=0,r=null;function v(){Y=-1,j=0,l=0,r=null}function n(d=M,p=e,U=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:N,endSegmentIndex:d,endGraphemeIndex:p,width:U}),K=0,S=!1,v()}function q(d,p){S=!0,y=d,N=0,M=d+1,e=0,K=p}function P(d,p,U){S=!0,y=d,N=p,M=d,e=p+1,K=U}function sA(d,p){if(!S){q(d,p);return}K+=p,M=d+1,e=0}function EA(d,p){if(!wg(E[d]))return;const U=E[d]==="tab"?0:g[d],_=E[d]==="tab"?p:Q[d];Y=d+1,j=K-p+U,l=K-p+_,r=E[d]}function T(d){V(d,0)}function V(d,p){const U=i[d],_=w[d]??null;for(let f=p;f<U.length;f++){const $=rQ(U,_,f,a.preferPrefixWidthsForBreakableRuns);if(!S){P(d,f,$);continue}K+$>A+G?(n(),P(d,f,$)):(K+=$,M=d,e=f+1)}S&&M===d&&e===U.length&&(M=d+1,e=0)}function IA(d){if(r!=="soft-hyphen")return!1;const p=i[d];if(p===null)return!1;const U=a.preferPrefixWidthsForBreakableRuns?w[d]??p:p,_=U!==p,{fitCount:f,fittedWidth:$}=DE(U,K,A,G,o,_);return f===0?!1:(K=$,M=d,e=f,v(),f===p.length?(M=d+1,e=0,!0):(n(d,f,$+o),V(d,f),!0))}function x(d){t++,I==null||I({startSegmentIndex:d.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:d.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),v()}for(let d=0;d<h.length;d++){const p=h[d];if(p.startSegmentIndex===p.endSegmentIndex){x(p);continue}S=!1,K=0,y=p.startSegmentIndex,N=0,M=p.startSegmentIndex,e=0,v();let U=p.startSegmentIndex;for(;U<p.endSegmentIndex;){const _=E[U],f=_==="tab"?oE(K,s):C[U];if(_==="soft-hyphen"){S&&(M=U+1,e=0,Y=U+1,j=K+o,l=K+o,r=_),U++;continue}if(!S){f>A&&i[U]!==null?T(U):q(U,f),EA(U,f),U++;continue}if(K+f>A+G){const hA=K+(_==="tab"?0:g[U]),SA=K+(_==="tab"?f:Q[U]);if(r==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&j<=A+G){n(Y,0,l);continue}if(r==="soft-hyphen"&&IA(U)){U++;continue}if(wg(_)&&hA<=A+G){sA(U,f),n(U+1,0,SA),U++;continue}if(Y>=0&&j<=A+G){n(Y,0,l);continue}if(f>A&&i[U]!==null){n(),T(U),U++;continue}n();continue}sA(U,f),EA(U,f),U++}if(S){const _=Y===p.consumedEndSegmentIndex?l:K;n(p.consumedEndSegmentIndex,0,_)}}return t}let aC=null,nQ=new WeakMap;function YQ(){return aC===null&&(aC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),aC}function hE(B){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function aE(B,A,I){const C=YQ(),g=Dg(),{cache:Q,emojiCorrection:E}=iE(A,IE(B.normalized)),i=SI("-",KI("-",Q),E),o=SI(" ",KI(" ",Q),E)*8;if(B.len===0)return hE();const s=[],h=[],a=[],G=[];let t=B.chunks.length<=1;const K=[],S=[],y=[],N=I?[]:null,M=Array.from({length:B.len}),e=Array.from({length:B.len});function Y(r,v,n,q,P,sA,EA,T){P!=="text"&&P!=="space"&&P!=="zero-width-break"&&(t=!1),s.push(v),h.push(n),a.push(q),G.push(P),K==null||K.push(sA),S.push(EA),y.push(T),N!==null&&N.push(r)}for(let r=0;r<B.len;r++){M[r]=s.length;const v=B.texts[r],n=B.isWordLike[r],q=B.kinds[r],P=B.starts[r];if(q==="soft-hyphen"){Y(v,0,i,i,q,P,null,null),e[r]=s.length;continue}if(q==="hard-break"){Y(v,0,0,0,q,P,null,null),e[r]=s.length;continue}if(q==="tab"){Y(v,0,0,0,q,P,null,null),e[r]=s.length;continue}const sA=KI(v,Q);if(q==="text"&&sA.containsCJK){let IA="",x=0;for(const d of C.segment(v)){const p=d.segment;if(IA.length===0){IA=p,x=d.index;continue}if(og.has(IA)||MQ.has(p)||uI.has(p)||g.carryCJKAfterClosingQuote&&tI(p)&&eQ(IA)){IA+=p;continue}const U=KI(IA,Q),_=SI(IA,U,E);Y(IA,_,_,_,"text",P+x,null,null),IA=p,x=d.index}if(IA.length>0){const d=KI(IA,Q),p=SI(IA,d,E);Y(IA,p,p,p,"text",P+x,null,null)}e[r]=s.length;continue}const EA=SI(v,sA,E),T=q==="space"||q==="preserved-space"||q==="zero-width-break"?0:EA,V=q==="space"||q==="zero-width-break"?0:EA;if(n&&v.length>1){const IA=BE(v,sA,Q,E),x=g.preferPrefixWidthsForBreakableRuns?EE(v,sA,Q,E):null;Y(v,EA,T,V,q,P,IA,x)}else Y(v,EA,T,V,q,P,null,null);e[r]=s.length}const j=GE(B.chunks,M,e),l=K===null?null:aB(B.normalized,K);return N!==null?{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:l,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:j,segments:N}:{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:l,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:j}}function GE(B,A,I){const C=[];for(let g=0;g<B.length;g++){const Q=B[g],E=Q.startSegmentIndex<A.length?A[Q.startSegmentIndex]:I[I.length-1]??0,i=Q.endSegmentIndex<A.length?A[Q.endSegmentIndex]:I[I.length-1]??0,w=Q.consumedEndSegmentIndex<A.length?A[Q.consumedEndSegmentIndex]:I[I.length-1]??0;C.push({startSegmentIndex:E,endSegmentIndex:i,consumedEndSegmentIndex:w})}return C}function tE(B,A,I,C){const g=PB(B,Dg(),C==null?void 0:C.whiteSpace);return aE(g,A,I)}function KE(B,A,I){return tE(B,A,!0,I)}function Ei(B){return B}function lQ(B,A,I){let C=I.get(B);if(C!==void 0)return C;C=[];const g=YQ();for(const Q of g.segment(A[B]))C.push(Q.segment);return I.set(B,C),C}function SE(B){let A=nQ.get(B);return A!==void 0||(A=new Map,nQ.set(B,A)),A}function yE(B,A,I,C){return C>0&&B[C-1]==="soft-hyphen"&&!(A===C&&I>0)}function kE(B,A,I,C,g,Q,E){let i="";const w=yE(A,C,g,Q);for(let o=C;o<Q;o++)A[o]==="soft-hyphen"||A[o]==="hard-break"||(o===C&&g>0?i+=lQ(o,B,I).slice(g).join(""):i+=B[o]);return E>0?(w&&(i+="-"),i+=lQ(Q,B,I).slice(C===Q?g:0,E).join("")):w&&(i+="-"),i}function NE(B,A,I,C,g,Q,E){return{text:kE(B.segments,B.kinds,A,C,g,Q,E),width:I,start:{segmentIndex:C,graphemeIndex:g},end:{segmentIndex:Q,graphemeIndex:E}}}function FE(B,A,I){return NE(B,A,I.width,I.startSegmentIndex,I.startGraphemeIndex,I.endSegmentIndex,I.endGraphemeIndex)}function ME(B,A,I){const C=[];if(B.widths.length===0)return{lineCount:0,height:0,lines:C};const g=SE(B),Q=sE(B,A,E=>{C.push(FE(B,g,E))});return{lineCount:Q,height:Q*I,lines:C}}const LQ=B=>B,eE=B=>B>0?1:0,cE=B=>B<1?0:1,qQ=B=>B*B,pQ=B=>B*(2-B),HQ=B=>B<.5?2*B*B:-1+(4-2*B)*B,JE=B=>B*B*B,RE=B=>--B*B*B+1,UE=B=>B<.5?4*B*B*B:(B-1)*(2*B-2)*(2*B-2)+1,rE=B=>B*B*B*B,nE=B=>1- --B*B*B*B,YE=B=>B<.5?8*B*B*B*B:1-8*--B*B*B*B,lE=B=>B*B*B*B*B,LE=B=>1+--B*B*B*B*B,qE=B=>B<.5?16*B*B*B*B*B:1+16*--B*B*B*B*B,pE=B=>1-Math.cos(B*Math.PI/2),HE=B=>Math.sin(B*Math.PI/2),dE=B=>-(Math.cos(Math.PI*B)-1)/2,fE=B=>B===0?0:Math.pow(2,10*(B-1)),bE=B=>B===1?1:1-Math.pow(2,-10*B),TE=B=>B===0?0:B===1?1:B<.5?Math.pow(2,20*B-10)/2:(2-Math.pow(2,-20*B+10))/2,uE=B=>1-Math.sqrt(1-B*B),mE=B=>Math.sqrt(1- --B*B),xE=B=>B<.5?(1-Math.sqrt(1-4*B*B))/2:(Math.sqrt(1-(-2*B+2)*(-2*B+2))+1)/2,sg=1.70158,hg=sg*1.525,dQ=sg+1,OE=B=>dQ*B*B*B-sg*B*B,WE=B=>1+dQ*Math.pow(B-1,3)+sg*Math.pow(B-1,2),ZE=B=>B<.5?Math.pow(2*B,2)*((hg+1)*2*B-hg)/2:(Math.pow(2*B-2,2)*((hg+1)*(B*2-2)+hg)+2)/2,fQ=2*Math.PI/3,bQ=2*Math.PI/4.5,jE=B=>B===0?0:B===1?1:-Math.pow(2,10*B-10)*Math.sin((B*10-10.75)*fQ),XE=B=>B===0?0:B===1?1:Math.pow(2,-10*B)*Math.sin((B*10-.75)*fQ)+1,vE=B=>B===0?0:B===1?1:B<.5?-(Math.pow(2,20*B-10)*Math.sin((20*B-11.125)*bQ))/2:Math.pow(2,-20*B+10)*Math.sin((20*B-11.125)*bQ)/2+1,ag=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,PE=B=>1-ag(1-B),VE=ag,zE=B=>B<.5?(1-ag(1-2*B))/2:(1+ag(2*B-1))/2,GC=new Map,mI=(B,A,I,C)=>{const g=`${B},${A},${I},${C}`;if(GC.has(g))return GC.get(g);const Q=s=>(1-3*I+3*B)*s*s*s+(3*I-6*B)*s*s+3*B*s,E=s=>(1-3*C+3*A)*s*s*s+(3*C-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=Q(h)-s;if(Math.abs(G)<1e-6)return h;const t=i(h);if(Math.abs(t)<1e-6)break;h=h-G/t}return h},o=s=>s===0?0:s===1?1:E(w(s));return GC.set(g,o),o},TQ=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,C,g,Q]=A.map(Number);return mI(I,C,g,Q)},uQ={ease:mI(.25,.1,.25,1),"ease-in":mI(.42,0,1,1),"ease-out":mI(0,0,.58,1),"ease-in-out":mI(.42,0,.58,1)},Gg={Linear:LQ,EaseInQuad:qQ,EaseOutQuad:pQ,EaseInOutQuad:HQ,EaseInCubic:JE,EaseOutCubic:RE,EaseInOutCubic:UE,EaseInQuart:rE,EaseOutQuart:nE,EaseInOutQuart:YE,EaseInQuint:lE,EaseOutQuint:LE,EaseInOutQuint:qE,EaseInSine:pE,EaseOutSine:HE,EaseInOutSine:dE,EaseInExpo:fE,EaseOutExpo:bE,EaseInOutExpo:TE,EaseInCirc:uE,EaseOutCirc:mE,EaseInOutCirc:xE,EaseInBack:OE,EaseOutBack:WE,EaseInOutBack:ZE,EaseInElastic:jE,EaseOutElastic:XE,EaseInOutElastic:vE,EaseInBounce:PE,EaseOutBounce:VE,EaseInOutBounce:zE,EaseIn:qQ,EaseOut:pQ,EaseInOut:HQ,StepStart:eE,StepEnd:cE},_E=B=>{const A=B.trim(),I=A.toLowerCase();if(Gg[A])return Gg[A];const C=Object.keys(Gg).find(Q=>Q.toLowerCase()===I);if(C)return Gg[C];const g=Object.keys(mQ).find(Q=>Q.toLowerCase()===I);if(g){const Q=TQ(mQ[g].value);if(Q)return Q}if(uQ[I])return uQ[I];if(I.startsWith("cubic-bezier")){const Q=TQ(A);if(Q)return Q}return LQ},mQ={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 xQ{constructor(){tA(this,"artboard",null);tA(this,"objectStates",new Map);tA(this,"physicsEngine",null);tA(this,"activeStateMachine",null);tA(this,"inputs",new Map);tA(this,"inputNameMap",new Map);tA(this,"layerStates",new Map);tA(this,"pretextCache",new Map);tA(this,"pointerHistory",[]);tA(this,"MAX_HISTORY",200);tA(this,"imageCache",new Map);tA(this,"lastValidSvgImgMap",new Map);tA(this,"maskBuffer",null);tA(this,"maskCtx",null);tA(this,"lumaBuffer",null);tA(this,"lumaCtx",null);tA(this,"layout",{fit:"Contain",alignment:"Center"});tA(this,"onTrigger");tA(this,"onInputUpdate");tA(this,"onComponentChange");tA(this,"onToggle");tA(this,"onInputChange");tA(this,"onInputFocus");tA(this,"onInputBlur");tA(this,"onLog");tA(this,"justFiredTriggers",new Set);tA(this,"rootTransform",null);tA(this,"canvasWidth",0);tA(this,"canvasHeight",0);tA(this,"lastHoveredObjectId",null);tA(this,"_lastPointerPos",null);tA(this,"_prevPointerPos",null);tA(this,"focusedId",null);tA(this,"draggingSliderId",null);tA(this,"activeDropdownId",null);tA(this,"draggingListViewId",null);tA(this,"scrollOffset",{x:0,y:0});tA(this,"draggingBehaviors",new Set);tA(this,"objectVelocities",new Map);tA(this,"currentTime",0);tA(this,"frameCount",0);tA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});tA(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.24) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}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}setOnLogCallback(A){this.onLog=A}debugLog(A){this.onLog&&this.onLog(A)}setInputFocusCallback(A){this.onInputFocus=A}setInputBlurCallback(A){this.onInputBlur=A}updateConstraint(A,I,C){var Q;const g=(Q=this.artboard)==null?void 0:Q.objects.find(E=>E.id===A);g&&g.constraints&&g.constraints[I]&&(g.constraints[I]={...g.constraints[I],...C},C.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 C=this.objectStates.get(A);C&&(C.options={...C.options,...I})}updateGraphData(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(g=>g.id===A||g.name===A);if(C&&C.geometry.type==="LineGraph"){const g=C.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 Q=this.objectStates.get(C.id);Q&&Q.geometry&&Q.geometry.type==="LineGraph"&&(!Q.geometry.datasets||Q.geometry.datasets.length===0?Q.geometry.datasets=JSON.parse(JSON.stringify(g.datasets)):Q.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=>{var E,i,w,o;const C=I.width??((E=I.geometry)==null?void 0:E.width)??0,g=I.height??((i=I.geometry)==null?void 0:i.height)??0,Q=I.cornerRadius??I.corner_radius??((w=I.geometry)==null?void 0:w.corner_radius)??((o=I.geometry)==null?void 0:o.cornerRadius)??0;this.objectStates.set(I.id,{...I.transform,width:C,height:g,cornerRadius:Q,corner_radius:Q,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.transform.opacity!==void 0?I.transform.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 C;return(C=I.physics)==null?void 0:C.enabled})){this.physicsEngine=new oB;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 C;this.physicsEngine&&((C=this.artboard)==null||C.objects.forEach(g=>{var Q;if((Q=g.physics)!=null&&Q.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 C=this.inputNameMap.get(I.name)||[];C.push(I.id),this.inputNameMap.set(I.name,C)}),this.activeStateMachine.layers.forEach(I=>{const C=I.states.find(g=>g.id===I.entryStateId);C&&this.enterStates(I.name,[C.id])}),this.evaluateTransitions()),!this.artboard.stateMachine&&this.artboard.animations.length>0){const I=this.artboard.animations||[],C=I.find(g=>(g.name||"").toLowerCase()==="onload")||I[0];C&&(console.log(`[ExodeUI] Auto-starting fallback animation: ${C.name}`),this.layerStates.set("intro",{currentStateIds:["onLoad"],animations:[{animation:C,state:{loop:!0}}],time:0,duration:C.duration}))}this.updateAutoLayout(),this.loadFonts()}updateAutoLayout(){var g;if(!this.artboard)return;const A=new Map;this.artboard.objects.forEach(Q=>A.set(Q.id,Q));const I=.15,C=Q=>{Q.forEach(E=>{const i=this.objectStates.get(E.id);if(i){const w=Math.abs(i.x-E.x),o=Math.abs(i.y-E.y);w>20||o>20?(i.x+=(E.x-i.x)*I,i.y+=(E.y-i.y)*I):(i.x=E.x,i.y=E.y),E.width!==void 0&&(i.width=E.width),E.height!==void 0&&(i.height=E.height)}})};if((g=this.artboard.autoLayout)!=null&&g.enabled){const Q=this.artboard.objects.filter(i=>!i.parentId),E=SC(this.artboard,Q,i=>this.objectStates.get(i));C(E.childUpdates)}this.artboard.objects.forEach(Q=>{var E;if(Q.type==="Frame"&&((E=Q.autoLayout)!=null&&E.enabled)&&Q.children&&Q.children.length>0){const i=Q.children.map(s=>A.get(s)).filter(s=>!!s),w=this.objectStates.get(Q.id);if(!w)return;const o=SC(w,i,s=>this.objectStates.get(s));o.frameWidth!==void 0&&(w.width=o.frameWidth),o.frameHeight!==void 0&&(w.height=o.frameHeight),C(o.childUpdates)}})}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 C="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(C);i||(i=document.createElement("link"),i.id=C,i.rel="stylesheet",document.head.appendChild(i)),i.href!==E&&(i.href=E)}const Q=[];if(A.forEach(E=>{E.toLowerCase().includes("clash display")&&Q.push("clash-display@200,300,400,500,600,700")}),Q.length>0){const E=`https://api.fontshare.com/v2/css?f[]=${Q.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 C=this.layerStates.get(A);if(C&&C.currentStateIds.length===I.length&&I.every(i=>C.currentStateIds.includes(i))&&this.justFiredTriggers.size===0)return;const g=[];let Q=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}),Q=Math.max(Q,o.duration))}}}this.layerStates.set(A,{currentStateIds:I,animations:g,time:0,duration:Q})}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 C;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"&&(C=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"&&(C=s.value.type)}}let g=I;C==="Trigger"&&(I===1?g=!0:I===0&&(g=!1)),this.inputs.has(A)&&this.setInternalInput(A,g);const Q=this.inputNameMap.get(A);Q&&Q.forEach(o=>this.setInternalInput(o,g)),C==="Trigger"&&g===!0&&(this.justFiredTriggers.add(A),Q&&Q.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 C=[];let g=!1;for(const Q of I.currentStateIds){const E=A.states.find(w=>w.id===Q);if(!E)continue;let i=!1;for(const w of E.transitions)this.checkConditions(w.conditions)&&(C.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||C.push(Q)}if(!g){const Q=this.findGlobalTransition(A,I.currentStateIds);Q&&(C.length=0,C.push(Q.targetStateId),g=!0,Q.conditions&&Q.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 Q=Array.from(new Set(C));this.enterStates(A.name,Q)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(A=>{var C,g;this.setInternalInput(A,!1);const I=(C=this.activeStateMachine)==null?void 0:C.inputs.find(Q=>Q.id===A);I&&this.inputNameMap.has(I.name)&&((g=this.inputNameMap.get(I.name))==null||g.forEach(Q=>this.setInternalInput(Q,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(A,I){for(const C of A.states)if(!(I.includes(C.id)&&this.justFiredTriggers.size===0)){for(const Q of C.transitions)if(!(I.includes(Q.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(Q.conditions))return Q}return null}checkConditions(A){return!A||A.length===0?!0:A.every(I=>{const C=I.inputId,g=I.op,Q=I.value,E=this.evaluateLogicTree(C);if(E===void 0)return console.log(`[Engine] Condition Check Failed: Input ${C} is undefined`),!1;let i=!1;switch(g){case"Equal":i=E==Q;break;case"NotEqual":i=E!=Q;break;case"GreaterThan":i=E>Q;break;case"LessThan":i=E<Q;break;case"GreaterEqual":i=E>=Q;break;case"LessEqual":i=E<=Q;break;case"IsTrue":i=E===!0;break;case"IsFalse":i=E===!1;break;default:i=!1}return i||this.justFiredTriggers.has(C),i})}evaluateLogicTree(A,I,C=new Set){var E,i,w;if(C.has(A))return!1;C.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,C):a.value!==void 0?a.value:h:h};switch(g.op){case NI.AND:return o("a",!1)&&o("b",!1);case NI.OR:return o("a",!1)||o("b",!1);case NI.NOT:return!o("in",!1);case NI.XOR:return!!o("a",!1)!=!!o("b",!1);default:return 0}}let Q=this.inputs.get(A);if(this.justFiredTriggers.has(A)&&(Q=!0),I&&Q!==void 0){const o=(w=this.activeStateMachine)==null?void 0:w.inputs.find(s=>s.id===A);if(o&&o.value.type==="Number"&&typeof Q=="number"){const s=o.value.defaultValue??o.value.value;if(I==="source-greater")return Q>s;if(I==="source-less")return Q<s;if(I==="source-equal")return Q===s}if(I==="source-true")return Q===!0;if(I==="source-false")return Q===!1;if(I==="source-fire")return this.justFiredTriggers.has(A)}return Q!==void 0?Q:0}advance(A){this.artboard&&(this.currentTime+=A,this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(A),this.artboard.objects.forEach(I=>{var C;if((C=I.physics)!=null&&C.enabled){const g=this.physicsEngine.getPosition(I.id),Q=this.physicsEngine.getRotation(I.id),E=this.objectStates.get(I.id);E&&g!==null&&Q!==null&&(E.x=g.x,E.y=g.y,E.rotation=Q*(180/Math.PI))}})),this.activeStateMachine&&(this.evaluateTransitions(),this.layerStates.forEach(I=>{I.animations.length>0&&(I.time+=A,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${I.time.toFixed(3)} / ${I.duration.toFixed(3)}`),I.time>I.duration&&(I.animations.some(g=>{var Q;return((Q=g.state)==null?void 0:Q.loop)===!0})?I.time%=I.duration:I.time=I.duration),I.animations.forEach(C=>{this.applyAnimation(C.animation,I.time)}))})),this.solveConstraints(A),this.solveBehaviors(A),this.activeTriggers.forEach((I,C)=>{var g,Q,E,i,w,o,s;if(I.phase==="entry")I.time+=A,I.time>=I.animation.duration&&((E=(Q=(g=this.artboard)==null?void 0:g.objects.find(h=>h.id===C))==null?void 0:Q.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===C))==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(t=>t.id===h.exitAnimationId);G?(I.phase="exit",I.animation=G,I.time=0):this.activeTriggers.delete(C)}else this.activeTriggers.delete(C)}else I.phase==="exit"&&(I.time+=A,I.time>=I.animation.duration?this.activeTriggers.delete(C):this.applyAnimation(I.animation,I.time))}))}solveConstraints(A){this.artboard&&this.artboard.objects.forEach(I=>{if(!I.constraints||I.constraints.length===0)return;const C=this.objectStates.get(I.id);if(!C)return;const g=this.getGlobalTransform(I.id);if(I.constraints.forEach(Q=>{var i,w,o,s,h,a,G;const E=Q.strength??1;if(Q.type==="Translation"){const t=this.getGlobalTransform(Q.targetId);if(t){if(Q.useSpring){const S=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:y,y:N,vx:M,vy:e}=this.computeSpring(g.x,g.y,S.vx,S.vy,t.x,t.y,Q,A);Q.copyX&&(g.x=y),Q.copyY&&(g.y=N),this.objectVelocities.set(I.id,{vx:M,vy:e})}else Q.copyX&&(g.x=g.x+(t.x-g.x)*E),Q.copyY&&(g.y=g.y+(t.y-g.y)*E);(i=Q.limitX)!=null&&i.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(w=Q.limitY)!=null&&w.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}}else if(Q.type==="Rotation"){const t=this.getGlobalTransform(Q.targetId);if(t){let S=(t.rotation+(Q.offset||0)-g.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),g.rotation=g.rotation+S*E}}else if(Q.type==="Scale"){const t=this.getGlobalTransform(Q.targetId);t&&(Q.copyX&&(g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E),Q.copyY&&(g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E))}else if(Q.type==="Transform"){const t=this.getGlobalTransform(Q.targetId);if(t){g.x=g.x+(t.x-g.x)*E,g.y=g.y+(t.y-g.y)*E;let K=(t.rotation-g.rotation)%360;K>180&&(K-=360),K<-180&&(K+=360),g.rotation=g.rotation+K*E,g.scale_x=g.scale_x+(t.scale_x-g.scale_x)*E,g.scale_y=g.scale_y+(t.scale_y-g.scale_y)*E}}else if(Q.type==="FollowPointer"){const t=((o=this._lastPointerPos)==null?void 0:o.x)??g.x,K=((s=this._lastPointerPos)==null?void 0:s.y)??g.y;if(Q.useSpring){const y=this.objectVelocities.get(I.id)||{vx:0,vy:0},{x:N,y:M,vx:e,vy:Y}=this.computeSpring(g.x,g.y,y.vx,y.vy,t,K,Q,A);g.x=N,g.y=M,this.objectVelocities.set(I.id,{vx:e,vy:Y})}else g.x=g.x+(t-g.x)*E,g.y=g.y+(K-g.y)*E;(h=Q.limitX)!=null&&h.enabled&&(g.x=Math.max(Q.limitX.min,Math.min(Q.limitX.max,g.x))),(a=Q.limitY)!=null&&a.enabled&&(g.y=Math.max(Q.limitY.min,Math.min(Q.limitY.max,g.y)))}else if(Q.type==="Distance"){const t=this.getGlobalTransform(Q.targetId);if(t){const K=g.x-t.x,S=g.y-t.y,y=Math.sqrt(K*K+S*S),N=Q.distance||0;let M=y;switch(Q.mode){case"exact":M=N;break;case"minimum":M=Math.max(N,y);break;case"maximum":M=Math.min(N,y);break;case"clamped":M=Math.max(0,Math.min(N,y));break}if(y>0){const e=g.x===t.x&&g.y===t.y?1:M/y;g.x=g.x+(t.x+K*e-g.x)*E,g.y=g.y+(t.y+S*e-g.y)*E}}}else if(Q.type==="FollowPath"){const t=(G=this.artboard)==null?void 0:G.objects.find(K=>K.id===Q.targetId);if(t){const K=this.getGlobalTransform(t.id);if(K){const S=(Q.distance||0)/100,y=K.width||t.geometry.width||0,N=K.height||t.geometry.height||0,M=this.getPointOnPath(t.geometry,y,N,S),e=K.rotation*Math.PI/180,Y=Math.cos(e),j=Math.sin(e),l=M.x*K.scale_x*Y-M.y*K.scale_y*j,r=M.x*K.scale_x*j+M.y*K.scale_y*Y,v=K.x+l+(Q.offsetX||0),n=K.y+r+(Q.offsetY||0);if(g.x=g.x+(v-g.x)*E,g.y=g.y+(n-g.y)*E,Q.orient){let P=(M.angle*180/Math.PI+K.rotation+(Q.offsetRotation||0)-g.rotation)%360;P>180&&(P-=360),P<-180&&(P+=360),g.rotation=g.rotation+P*E}}}}else if(Q.type==="IK"){const t=this.getGlobalTransform(Q.targetId);t&&this.solveIK(I,t,Q.boneCount||2,E)}}),I.constraints.some(Q=>Q.type!=="IK")){const Q=this.globalToLocal(I.parentId,g);C.x=Q.x,C.y=Q.y,C.rotation=Q.rotation,C.scale_x=Q.scale_x,C.scale_y=Q.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 C=(s=this.artboard)==null?void 0:s.objects.find(h=>h.id===A);if(!C||!C.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(C.parentId),Q=g.rotation*Math.PI/180,E=Math.cos(Q),i=Math.sin(Q),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 C=this.getGlobalTransform(A),g=C.scale_x===0?0:1/C.scale_x,Q=C.scale_y===0?0:1/C.scale_y,E=-C.rotation*Math.PI/180,i=Math.cos(E),w=Math.sin(E),o=I.x-C.x,s=I.y-C.y,h=(o*i-s*w)*g,a=(o*w+s*i)*Q;return{x:h,y:a,rotation:I.rotation-C.rotation,scale_x:I.scale_x/(C.scale_x||1),scale_y:I.scale_y/(C.scale_y||1)}}solveIK(A,I,C,g){var o;const Q=[];let E=A.id;for(let s=0;s<C&&E;s++){const h=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===E);if(!h)break;Q.push({id:E,local:this.objectStates.get(E),global:this.getGlobalTransform(E)}),E=h.parentId}if(Q.length<2)return;const i=Q.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],t=this.getGlobalTransform(G.id),K=h.x-t.x,S=h.y-t.y,y=I.x-t.x,N=I.y-t.y,M=Math.sqrt(K*K+S*S),e=Math.sqrt(y*y+N*N);if(M>.001&&e>.001){const Y=Math.atan2(S,K);let l=(Math.atan2(N,y)-Y)*180/Math.PI;l*=g;const r=this.objectStates.get(G.id);r&&(r.rotation+=l)}}}}computeSpring(A,I,C,g,Q,E,i,w){const o=i.stiffness??100,s=i.damping??10,h=i.mass??1,a=-o*(A-Q),G=-o*(I-E),t=-s*C,K=-s*g,S=(a+t)/h,y=(G+K)/h,N=C+S*w,M=g+y*w,e=A+N*w,Y=I+M*w;return{x:e,y:Y,vx:N,vy:M}}handlePointerInput(A,I,C,g,Q){if(!this.artboard)return;const E=this.calculateTransform(g,Q,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),i=(I-E.tx)/E.scaleX-this.artboard.width/2,w=(C-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,C){var w,o,s,h,a;if(!this.artboard)return;let g=null;const Q=(G,t)=>{var e;let K=t;t==="click"?K="onClick":t==="down"?K="onPointerDown":t==="up"?K="onPointerUp":t==="blur"&&(K="onPointerLeave");const S=new Set([K]);t==="move"&&S.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),K==="onClick"&&S.add("click"),K==="onPointerDown"&&S.add("pointerDown"),K==="onPointerUp"&&S.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider"];return!!(G.type==="Component"&&y.includes(G.variant)||y.includes((e=G.type)==null?void 0:e.toLowerCase())||(G.interactions||[]).some(Y=>S.has(Y.event))||(G.triggers||[]).some(Y=>S.has(Y.eventType)))};let E=null;for(let G=this.artboard.objects.length-1;G>=0;G--){const t=this.artboard.objects[G],K=this.objectStates.get(t.id);if(K&&K.visible!==!1&&K.opacity>0&&this.hitTest(t,I,C)&&(E||(E=t),Q(t,A))){g=t;break}}!g&&E&&(g=E),this.pointerHistory.push({x:I,y:C,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(t=>t.id===this.draggingSliderId);G&&this.updateSliderValueFromPointer(G,I,C);return}if(this.draggingListViewId){const G=this.artboard.objects.find(t=>t.id===this.draggingListViewId);G&&this.updateListViewScrollFromPointer(G);return}g&&g.type==="Component"&&g.variant==="listview"&&this.updateListViewHoverFromPointer(g,I,C),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===W.Draggable))&&this.draggingBehaviors.add(i),this.activeDropdownId&&A==="down"){const G=this.artboard.objects.find(t=>t.id===this.activeDropdownId);if(G&&(G.type==="Dropdown"||G.variant==="dropdown")){const t=this.objectStates.get(G.id),K=(t==null?void 0:t.options)||G.options||{},S=G.geometry||{},y=S.width??G.width??200,N=S.height??G.height??40,M=K.optionsList||[],e=K.itemHeight||32,Y=K.listPadding??4,j=M.length*e+Y*2,l=this.getWorldTransform(G.id),r=y*Math.abs(l.scaleX),v=N*Math.abs(l.scaleY),n=l.y+v/2+4,q=Math.abs(I-l.x)<=r/2,P=C>=n&&C<=n+j*Math.abs(l.scaleY);if(q&&P){const sA=Math.abs(l.scaleY),EA=C-(n+Y*sA),T=Math.floor(EA/(e*sA));if(T>=0&&T<M.length){const V=M[T];K.selectedOption=V,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,V),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:V})}return}else i!==this.activeDropdownId&&(K.isOpen=!1,this.activeDropdownId=null)}}if(g){let G=g,t=g;for(;t&&t.parentId;){const S=this.artboard.objects.find(y=>y.id===t.parentId);if(S&&S.type==="Component"){G=S;break}t=S}let K=A;if(A==="click"?K="onClick":A==="down"?K="onPointerDown":A==="up"?K="onPointerUp":A==="blur"&&(K="onPointerLeave"),this.fireEventForObject(g.id,K),G!==g&&this.fireEventForObject(G.id,K),G.type==="Component"&&G.variant==="toggle_button"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle_button",property:"checked",value:y.checked})}if(G.type==="Component"&&G.variant==="toggle"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{};y.checked=!y.checked,G.inputId&&this.setInternalInput(G.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(G.name,y.checked)}if(G.type==="Component"&&G.variant==="dropdown"&&A==="down"){const S=this.objectStates.get(G.id),y=(S==null?void 0:S.options)||G.options||{},N=!y.isOpen;if(N&&this.activeDropdownId&&this.activeDropdownId!==G.id){const M=this.artboard.objects.find(e=>e.id===this.activeDropdownId);M&&M.options&&(M.options.isOpen=!1)}y.isOpen=N,this.activeDropdownId=N?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 S=this.getListViewItemIndexAtPointer(g,I,C);if(S!==null){const y=g.options||{};y.activeItemIndex=S;const N=this.objectStates.get(g.id);N&&N.options&&(N.options.activeItemIndex=S);const M=(y.items||[])[S],e=typeof M=="string"?M:M.label||M.value||S;N&&N.options&&(N.options.selectedValue=e),g.inputId&&this.setInternalInput(g.inputId,e),this.onComponentChange&&(this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"activeItemIndex",value:S}),this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"selected",value:e}))}}if(g.type==="Component"&&g.variant==="slider"&&A==="down"&&(this.draggingSliderId=g.id,this.updateSliderValueFromPointer(g,I,C)),A==="click"){const S=(o=this.artboard)==null?void 0:o.objects.find(N=>N.id===g.id),y=this.focusedId;if((S==null?void 0:S.type)==="Component"&&S.variant==="inputbox"){if(this.focusedId=g.id,console.log(`[Engine] Focus set to: ${g.id}`),y!==this.focusedId){if(y){const N=(s=this.artboard)==null?void 0:s.objects.find(M=>M.id===y);N&&this.onInputBlur&&this.onInputBlur(N.name)}this.onInputFocus&&this.onInputFocus(S.name)}}else if(this.focusedId=null,y){const N=(h=this.artboard)==null?void 0:h.objects.find(M=>M.id===y);N&&this.onInputBlur&&this.onInputBlur(N.name)}}}else if(A==="click"){const G=this.focusedId;if(this.focusedId=null,G){const t=(a=this.artboard)==null?void 0:a.objects.find(K=>K.id===G);t&&this.onInputBlur&&this.onInputBlur(t.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 C=I.options||{};let g=C.text||"";if(A.key==="Backspace")g=g.slice(0,-1);else if(A.key==="Enter")if(C.multiline)g+=`
6
6
  `;else{this.focusedId=null;return}else if(A.key.length===1)g+=A.key;else return;C.text=g;const Q=I.geometry;Q.textInputId&&this.updateInput(Q.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 C=this.artboard.objects.find(o=>o.id===A);if(!C)return;console.log(`[Engine] Firing event ${I} on ${C.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=(C.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=(C.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(C.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 C=(a=this.artboard)==null?void 0:a.objects.find(G=>G.id===A);if(!C||!C.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(C.parentId),Q=g.rotation*(Math.PI/180),E=Math.cos(Q),i=Math.sin(Q),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,C){var M,e;if(!this.objectStates.get(A.id))return!1;const Q=((M=A.geometry)==null?void 0:M.width)??A.width??100,E=((e=A.geometry)==null?void 0:e.height)??A.height??100,i=this.getWorldTransform(A.id),w=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=w*h-o*a,t=w*a+o*h,K=i.scaleX,S=i.scaleY,y=Q*Math.abs(K),N=E*Math.abs(S);return Math.abs(G)<=y/2&&Math.abs(t)<=N/2}updateSliderValueFromPointer(A,I,C){var l;const g=this.objectStates.get(A.id);if(!g)return;const Q=A.options||{},E=((l=A.geometry)==null?void 0:l.width)??A.width??200,i=this.getWorldTransform(A.id),w=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=w*h-o*a,t=Q.thumbWidth??16,K=E-t;let y=(G+K/2)/K;y=Math.max(0,Math.min(1,y));const N=Q.min??0,M=Q.max??100,e=Q.step||1;let Y=N+y*(M-N);e>0&&(Y=Math.round(Y/e)*e),Y=Math.max(N,Math.min(M,Y));const j=g.options||{};j.value!==Y&&(g.options={...j,value:Y},A.inputId&&this.setInternalInput(A.inputId,Y),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:Y}))}applyAnimation(A,I){A.tracks.forEach(C=>{var o,s,h;const g=(o=this.artboard)==null?void 0:o.objects.find(a=>a.id===C.object_id),Q=((s=g==null?void 0:g.physics)==null?void 0:s.enabled)&&g.physics.bodyType!=="Static";let E=C.property;if(E.startsWith("transform."))E=E.replace("transform.","");else if(E.startsWith("geometry.")){const a=E.replace("geometry.","");["width","height","corner_radius","cornerRadius"].includes(a)&&(E=a)}if(Q&&["x","y","rotation","opacity"].includes(E))return;const i=this.objectStates.get(C.object_id);if(!i){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${C.object_id} not found in state`);return}const w=this.interpolate(C.keyframes,I);if(this.frameCount%480===0){const a=(g==null?void 0:g.name)||C.object_id;this.debugLog(`Applying ${E} = ${typeof w=="object"?"OBJ":w} to ${a}`)}if(E.includes(".")){const a=(E||"").split(".");let G=i;for(let t=0;t<a.length-1;t++){if(typeof G[a[t]]!="object"||G[a[t]]===null){let K=g;for(let S=0;S<=t;S++)K=K?K[a[S]]:null;G[a[t]]=K?JSON.parse(JSON.stringify(K)):{}}G=G[a[t]]}G[a[a.length-1]]=w}else i[E]=w;if(this.physicsEngine&&((h=g==null?void 0:g.physics)!=null&&h.enabled)&&g.physics.bodyType==="Static")if(E==="x"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,w,a.y)}else if(E==="y"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,a.x,w)}else E==="rotation"&&this.physicsEngine.setRotation(C.object_id,w*(Math.PI/180))})}interpolate(A,I){if(A.length===0)return 0;let C=A[0],g=A[A.length-1];if(I<=C.time)return C.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){C=A[i],g=A[i+1];break}if(Math.abs(C.time-I)<.005)return C.value;if(Math.abs(g.time-I)<.005)return g.value;const Q=g.time-C.time;let E=(I-C.time)/Q;if(C.easing&&(E=_E(C.easing)(E)),typeof C.value=="string"){if(C.value.startsWith("#"))return this.interpolateColor(C.value,g.value,E);const i=parseFloat(C.value),w=parseFloat(g.value);return!isNaN(i)&&!isNaN(w)?Math.round(i+(w-i)*E).toString():C.value}return Array.isArray(C.value)&&Array.isArray(g.value)?C.value.length===g.value.length?C.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?C.value:g.value:typeof C.value=="object"&&typeof g.value=="object"&&C.value!==null&&g.value!==null?C.value.width!==void 0&&C.value.color!==void 0?this.interpolateStroke(C.value,g.value,E):C.value.type&&g.value.type?this.interpolateFill(C.value,g.value,E):E<.5?C.value:g.value:typeof C.value=="number"&&typeof g.value=="number"?C.value+(g.value-C.value)*E:E<.5?C.value:g.value}interpolateColor(A,I,C){var t,K;const g=((K=(t=this.artboard)==null?void 0:t.tokens)==null?void 0:K.colors)||{},Q=g[A]||A,E=g[I]||I,i=S=>{if(!S)return{r:0,g:0,b:0};const y=S.startsWith("#")?S.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},w=i(Q),o=i(E),s=Math.round(w.r+(o.r-w.r)*C),h=Math.round(w.g+(o.g-w.g)*C),a=Math.round(w.b+(o.b-w.b)*C),G=S=>{const y=Math.max(0,Math.min(255,S)).toString(16);return y.length===1?"0"+y:y};return`#${G(s)}${G(h)}${G(a)}`}interpolateStops(A,I,C){return!A||!I||A.length!==I.length?C<.5?A:I:A.map((g,Q)=>{const E=I[Q];return{offset:g.offset+(E.offset-g.offset)*C,color:this.interpolateColor(g.color,E.color,C),opacity:(g.opacity??1)+((E.opacity??1)-(g.opacity??1))*C}})}interpolateFill(A,I,C){if(!A||!I||A.type!==I.type)return C<.5?A:I;const g={...A,opacity:(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C};return A.type==="Solid"?g.color=this.interpolateColor(A.color,I.color,C):(A.type==="LinearGradient"||A.type==="RadialGradient")&&(A.start&&I.start&&(g.start=[A.start[0]+(I.start[0]-A.start[0])*C,A.start[1]+(I.start[1]-A.start[1])*C]),A.end&&I.end&&(g.end=[A.end[0]+(I.end[0]-A.end[0])*C,A.end[1]+(I.end[1]-A.end[1])*C]),A.center&&I.center&&(g.center=[A.center[0]+(I.center[0]-A.center[0])*C,A.center[1]+(I.center[1]-A.center[1])*C]),A.radius!==void 0&&I.radius!==void 0&&(g.radius=A.radius+(I.radius-A.radius)*C),g.stops=this.interpolateStops(A.stops,I.stops,C)),g}interpolateStroke(A,I,C){if(!A||!I)return C<.5?A:I;const g={...A};return g.width=(A.width??0)+((I.width??0)-(A.width??0))*C,g.opacity=(A.opacity??1)+((I.opacity??1)-(A.opacity??1))*C,A.fill&&I.fill?g.fill=this.interpolateFill(A.fill,I.fill,C):A.color&&I.color&&A.color.startsWith("#")&&I.color.startsWith("#")&&(g.color=this.interpolateColor(A.color,I.color,C)),g.trimStart=(A.trimStart??0)+((I.trimStart??0)-(A.trimStart??0))*C,g.trimEnd=(A.trimEnd??1)+((I.trimEnd??1)-(A.trimEnd??1))*C,g.trimOffset=(A.trimOffset??0)+((I.trimOffset??0)-(A.trimOffset??0))*C,g.dashOffset=(A.dashOffset??0)+((I.dashOffset??0)-(A.dashOffset??0))*C,g}render(A,I,C){if(this.canvasWidth=I,this.canvasHeight=C,!this.artboard)return;A.clearRect(0,0,I,C);const g=this.artboard.width,Q=this.artboard.height,E=this.calculateTransform(I,C,g,Q,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,Q/2),this.rootTransform=A.getTransform(),this.artboard.backgroundVisible!==!1&&(A.fillStyle=this.artboard.backgroundColor||"#000000",A.fillRect(-g/2,-Q/2,g,Q)),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/Q;let a,G,t,K;h>s?(a=g,G=g/s):(G=Q,a=Q*s),t=-a/2,K=-G/2,A.drawImage(o,t,K,a,G),A.restore()}}A.beginPath(),A.rect(-g/2,-Q/2,g,Q),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,C,g,Q,E){let i=1,w=1,o=1;const s=C/g,h=A/I;switch(Q){case"Contain":h>s?o=I/g:o=A/C,i=w=o;break;case"Cover":h>s?o=A/C:o=I/g,i=w=o;break;case"Fill":i=A/C,w=I/g;break;case"FitWidth":o=A/C,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/C,I/g),o>1&&(o=1),i=w=o;break;default:i=w=1;break}const a=C*i,G=g*w;let t=0,K=0;return E.includes("Left")?t=0:E.includes("Right")?t=A-a:t=(A-a)/2,E.includes("Top")?K=0:E.includes("Bottom")?K=I-G:K=(I-G)/2,{scaleX:i,scaleY:w,tx:t,ty:K}}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[C,g]of Object.entries(this.fontLeadingFactors))if(I.toLowerCase()===C.toLowerCase())return g;return .5}renderObject(A,I,C){var x,d,p,U,_,f,$,hA,SA,FA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(u,O,L,R,m)=>(this.drawRoundRect(A,u,O,L,R,m),A));const Q=g.geometry?this.deepMerge(I.geometry,g.geometry):I.geometry,E=g.style?this.deepMerge(I.style,g.style):I.style;let i=(Q==null?void 0:Q.width)||((x=I.geometry)==null?void 0:x.width)||I.width||0,w=(Q==null?void 0:Q.height)||((d=I.geometry)==null?void 0:d.height)||I.height||0;if((i===0||w===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let u=1/0,O=-1/0,L=1/0,R=-1/0;Q.points.forEach(m=>{u=Math.min(u,m.x),O=Math.max(O,m.x),L=Math.min(L,m.y),R=Math.max(R,m.y)}),i===0&&(i=O-u),w===0&&(w=R-L)}const o=u=>{if(u)return u.corner_radius??u.cornerRadius},s=o(g)??o(E)??o(Q)??o(I.style)??o(I.geometry)??0,h={...Q,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 t=[],K=E.blur||((p=I.style)==null?void 0:p.blur);K&&K.amount>0&&t.push(`blur(${K.amount}px)`);const S=((U=Q==null?void 0:Q.type)==null?void 0:U.toLowerCase().includes("image"))||((_=I.type)==null?void 0:_.toLowerCase().includes("image")),y=E.adjustments&&Object.keys(E.adjustments).length>0?E.adjustments:null,N=Q!=null&&Q.adjustments&&Object.keys(Q.adjustments).length>0?Q.adjustments:null,M=S?N||y:y||N,e=S&&!M?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:M;if(g&&e&&(g.geometry=g.geometry||{},g.geometry.adjustments={...e}),e){const u=(e.exposure||0)/100,O=e.contrast||0,L=1+(e.saturation||0)/100,R=(e.temperature||0)/200,m=(e.tint||0)/200,Z=(e.highlights||0)/500,GA=(e.shadows||0)/500;let gA="",DA="SourceGraphic";if(u!==0&&(gA+=`
7
7
  <feComponentTransfer in="${DA}" result="exposure">
8
8
  <feFuncR type="linear" slope="1" intercept="${u}"/>
@@ -19,4 +19,4 @@
19
19
  0 ${CA} 0 0 ${1-CA}
20
20
  0 0 ${CA} 0 ${1-CA}
21
21
  0 0 0 1 0"/>`,DA="invert"}if(R!==0||m!==0||Z!==0||GA!==0){const CA=1+Z+GA,F=CA*(1+R-m/2),b=CA*(1+m),H=CA*(1-R-m/2),iA=e.shadows*.1/255,UA=[F,0,0,0,iA,0,b,0,0,iA,0,0,H,0,iA,0,0,0,1,0].join(" ");gA+=`<feColorMatrix in="${DA}" type="matrix" values="${UA}" result="advanced"/>`,DA="advanced"}if(e.blur&&(gA+=`<feGaussianBlur in="${DA}" stdDeviation="${e.blur}" result="blur"/>`,DA="blur"),gA){const CA=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${gA}</filter></svg>`,F=btoa(CA);t.push(`url('data:image/svg+xml;base64,${F}#f')`)}}t.length>0?A.filter=t.join(" "):A.filter="none",A.imageSmoothingEnabled=!0,A.imageSmoothingQuality="high";const Y=A.globalAlpha,j=this.normalizeOpacity(g.opacity!==void 0?g.opacity:100);A.globalAlpha=Y*j;const l=g.compositeOperation||g.blendMode;if(l&&l!=="Normal"){const u=l.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 r=A,v=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 n=!1;const q=v.filter(u=>u.isVisible!==!1&&C.has(u.maskId));if(q.length>0){const u=q[0],O=C.get(u.maskId),L=this.objectStates.get(O.id);L&&L.visible!==!1&&(n=!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&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),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,C),this.maskCtx.save(),this.maskCtx.globalAlpha=1,A=this.maskCtx,A.filter=r.filter)}A.translate(Math.round(a),Math.round(G)),A.rotate(g.rotation*Math.PI/180);const P=g.skew_x||0,sA=g.skew_y||0;(P!==0||sA!==0)&&A.transform(1,Math.tan(sA*Math.PI/180),Math.tan(P*Math.PI/180),1,0,0),A.scale((g.scale_x??1)*(g.flip_x===!0?-1:1),(g.scale_y??1)*(g.flip_y===!0?-1:1));const EA=E.shadow;if(EA&&EA.isEnabled!==!1){let u=EA.color||"#000000";($=(f=this.artboard)==null?void 0:f.tokens)!=null&&$.colors&&this.artboard.tokens.colors[u]&&(u=this.artboard.tokens.colors[u]);const O=this.normalizeOpacity(EA.opacity??100),L=EA.spread||0,m=(EA.blur||0)+L*1.5;let Z=u;if(u.startsWith("#")){const DA=u.replace("#",""),kA=parseInt(DA.substring(0,2),16),CA=parseInt(DA.substring(2,4),16),F=parseInt(DA.substring(4,6),16);Z=`rgba(${kA}, ${CA}, ${F}, ${O})`}else if(u.startsWith("rgba")){const DA=u.match(/[\d.]+/g);if(DA&&DA.length>=4){const kA=DA[0],CA=DA[1],F=DA[2],b=DA[3];Z=`rgba(${kA}, ${CA}, ${F}, ${parseFloat(b)*O})`}}const GA=A.getTransform(),gA=Math.sqrt(GA.a*GA.a+GA.b*GA.b)||1;A.shadowColor=Z,A.shadowBlur=m*gA,A.shadowOffsetX=(EA.offsetX||0)*gA,A.shadowOffsetY=(EA.offsetY||0)*gA}const T=I.liquidFill||((hA=I.style)==null?void 0:hA.liquidFill),V=I.artEffect||((SA=I.style)==null?void 0:SA.artEffect);if(T&&T.enabled){A.save();const u=T.fillLevel??.5;A.beginPath();const O=w/2-w*u;A.rect(-i/2,O,i,w*u),A.clip(),A.fillStyle=T.color||"#3b82f6",A.globalAlpha=A.globalAlpha*(T.opacity??1)}const IA=V&&V.enabled&&V.type==="glitch";if(IA){A.save();const O=(V.intensity??.5)*10,L=A.getTransform(),R=Math.sqrt(L.a*L.a+L.b*L.b)||1;A.shadowColor="rgba(255, 0, 0, 0.5)",A.shadowBlur=O*R,A.translate(O/2,0)}if(Q.type==="Text")this._renderText(A,I,h,E,g,i,w);else if(Q.type==="Image"){const u=Q.src;if(u){let O=this.imageCache.get(u);O||(O=new Image,O.onload=()=>{},O.onerror=()=>{console.error(`[ExodeUI] Image load failed: ${u.substring(0,100)}${u.length>100?"...":""}`)},O.src=u,this.imageCache.set(u,O));const L=E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1,R=(((FA=E.stroke)==null?void 0:FA.alignment)||"center").toLowerCase();if(L&&(R==="outside"||R==="center")&&this.applyStrokeAlignment(A,E,h,i,w,s),E.fill&&E.fill.type!=="None"){A.save();const m=A.globalAlpha,Z=this.createCanvasFill(A,E.fill,i,w);A.fillStyle=Z||E.fill.color||"transparent",A.globalAlpha=m*this.normalizeOpacity(E.fill.opacity??100),s!==0?(this.drawRoundRect(A,-i/2,-w/2,i,w,s),A.fill()):A.fillRect(-i/2,-w/2,i,w),A.globalAlpha=m,A.restore()}O.complete&&O.naturalWidth>0?(s!==0?(A.save(),this.drawRoundRect(A,-i/2,-w/2,i,w,s),A.clip(),A.drawImage(O,-i/2,-w/2,i,w),A.restore()):A.drawImage(O,-i/2,-w/2,i,w),L&&R==="inside"&&this.applyStrokeAlignment(A,E,h,i,w,s)):L&&R==="inside"&&this.applyStrokeAlignment(A,E,h,i,w,s)}}else if(Q.type==="SVG"){const u=Q.svgContent;if(u){const O=E.palette||[],L=E.fill,R=E.stroke,m=L?this.normalizeOpacity(L.opacity??100):1,Z=(L==null?void 0:L.type)==="Solid"&&(!R||R.isEnabled===!1||R.type==="Solid"&&R.color===L.color),GA=L&&L.type!=="None"?Z?"monochrome":L.type==="Solid"?(L.color||"")+"|opacity:"+m:JSON.stringify(L.stops||[])+"|opacity:"+m:"",gA=R&&R.isEnabled!==!1&&(R.width||0)>0?Z?["monochrome",R.width||0,R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):[R.width||0,R.fill?R.fill.type==="Solid"?R.fill.color||"":JSON.stringify(R.fill.stops||[]):R.color||"",R.opacity??1,R.lineCap||"",R.lineJoin||"",(R.dashArray||[]).join(","),R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):"nostroke",DA=[I.id,O.join("_"),GA,gA,g.opacity??100,g.visible!==!1?"v":"h"].join("_");let kA=this.imageCache.get(DA);if(!kA){kA=new Image,kA.crossOrigin="anonymous";let F=u;if(Q.colors&&Q.colors.length>0&&O.length>0&&Q.colors.forEach((BA,z)=>{if(O[z]){const AA=BA.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),oA=new RegExp(AA,"gi");F=F.replace(oA,O[z])}}),L&&L.type&&L.type!=="None"){if(L.type==="Solid"&&L.color){const BA=Z?"#FFFFFF":L.color,z=Z?1:this.normalizeOpacity(L.opacity??100);F=F.replace(/\bfill\s*=\s*["'][^"']*["']/gi,AA=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(AA)?AA:`fill="${BA}"`),F=F.replace(/fill\s*:\s*[^;"')]+/gi,AA=>/fill\s*:\s*(none|transparent)/i.test(AA)?AA:`fill:${BA}`),z<1&&(F=F.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${z}"`),F=F.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${z}`),F.match(/\bfill-opacity\s*=/i)||(F=F.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${z}">`),F=F.replace(/<\/svg>/i,"</g></svg>")))}else if(L.type==="LinearGradient"||L.type==="RadialGradient"||L.type==="Linear"||L.type==="Radial"){const BA="exode-fill",z=this.normalizeOpacity(L.opacity??100),AA=(L.stops||[]).map(QA=>{const X=QA.offset!==void 0?QA.offset:QA.pos??0,aA=this.normalizeOpacity(QA.opacity??100)*z;return`<stop offset="${X*100}%" stop-color="${QA.color||"#000"}" stop-opacity="${aA}"/>`}).join("");let oA="";if(L.type==="LinearGradient"||L.type==="Linear"){const QA=(TA,RA)=>Array.isArray(TA)?TA[RA]??(RA===0?0:1):TA&&typeof TA=="object"?TA[RA===0?"x":"y"]??(RA===0?0:1):RA===0?0:1,X=QA(L.start,0)*100,aA=QA(L.start,1)*100,yA=QA(L.end,0)*100,YA=QA(L.end,1)*100;oA=`<linearGradient id="${BA}" x1="${X}%" y1="${aA}%" x2="${yA}%" y2="${YA}%" gradientUnits="objectBoundingBox">${AA}</linearGradient>`}else{const QA=(YA,TA)=>Array.isArray(YA)?YA[TA]??.5:YA&&typeof YA=="object"?YA[TA===0?"x":"y"]??.5:.5,X=QA(L.center,0)*100,aA=QA(L.center,1)*100,yA=(L.radius??.5)*100;oA=`<radialGradient id="${BA}" cx="${X}%" cy="${aA}%" r="${yA}%" gradientUnits="objectBoundingBox">${AA}</radialGradient>`}/<defs>/i.test(F)?F=F.replace(/<defs>/i,`<defs>${oA}`):F=F.replace(/<svg([^>]*)>/i,`<svg$1><defs>${oA}</defs>`),F=F.replace(/\bfill\s*=\s*["'][^"']*["']/gi,QA=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(QA)?QA:`fill="url(#${BA})"`),F=F.replace(/fill\s*:\s*[^;"')]+/gi,QA=>/fill\s*:\s*(none|transparent)/i.test(QA)?QA:`fill:url(#${BA})`)}}const b=(BA,z,AA=1)=>{const oA=(BA.stops||[]).map(YA=>{const TA=YA.offset!==void 0?YA.offset:YA.pos??0,RA=this.normalizeOpacity(YA.opacity??100)*AA;return`<stop offset="${TA*100}%" stop-color="${YA.color||"#000"}" stop-opacity="${RA}"/>`}).join(""),QA=(YA,TA,RA=.5)=>Array.isArray(YA)?YA[TA]??RA:YA&&typeof YA=="object"?YA[TA===0?"x":"y"]??RA:RA;if(BA.type==="LinearGradient"||BA.type==="Linear"){const YA=QA(BA.start,0,0)*100,TA=QA(BA.start,1,0)*100,RA=QA(BA.end,0,1)*100,$A=QA(BA.end,1,1)*100;return`<linearGradient id="${z}" x1="${YA}%" y1="${TA}%" x2="${RA}%" y2="${$A}%" gradientUnits="objectBoundingBox">${oA}</linearGradient>`}const X=QA(BA.center,0,.5)*100,aA=QA(BA.center,1,.5)*100,yA=(BA.radius??.5)*100;return`<radialGradient id="${z}" cx="${X}%" cy="${aA}%" r="${yA}%" gradientUnits="objectBoundingBox">${oA}</radialGradient>`},H=(BA,z)=>/<defs>/i.test(BA)?BA.replace(/<defs>/i,`<defs>${z}`):BA.replace(/(<svg[^>]*>)/i,`$1<defs>${z}</defs>`);if(R&&R.isEnabled!==!1&&(R.width||0)>0){const BA=R.width||1,z=Z?1:this.normalizeOpacity(R.opacity??100),AA=Z?"#FFFFFF":R.color||(L==null?void 0:L.color)||"#000000";let oA="";const QA=R.fill;if(QA&&QA.type){if(QA.type==="Solid")oA=QA.color||R.color||"#000000";else if(QA.type==="LinearGradient"||QA.type==="RadialGradient"||QA.type==="Linear"||QA.type==="Radial"){const RA="exode-stroke";F=H(F,b(QA,RA,z)),oA=`url(#${RA})`}}oA||(oA=AA),F.match(/\bstroke\s*=/i)?F=F.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,RA=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(RA)?RA:`stroke="${oA}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${oA}"`),F=F.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${oA}`),F.match(/\bstroke-width\s*=/i)?F=F.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${BA}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${BA}"`),F=F.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${BA}`),F.match(/\bstroke-opacity\s*=/i)?F=F.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${z}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${z}"`),F=F.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${z}`),R.lineCap&&(F=F.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${R.lineCap}"`),F=F.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${R.lineCap}`)),R.lineJoin&&(F=F.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${R.lineJoin}"`),F=F.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${R.lineJoin}`));const X=R.trimStart??0,aA=R.trimEnd??1,yA=R.trimOffset??0,YA=R.dashOffset??0,TA=X!==0||aA!==1||yA!==0||YA!==0;if(TA){const RA=Math.max(0,Math.min(1,X)),$A=Math.max(0,Math.min(1,aA));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${I.name||I.id}, Start: ${RA}, End: ${$A}`);let tg=Q.width||i||100,Kg=Q.height||w||100;const xI=u.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(xI){const kI=parseFloat(xI[1]),UI=parseFloat(xI[2]);!isNaN(kI)&&!isNaN(UI)&&(tg=kI,Kg=UI)}const yI=(tg+Kg)*2,OI=(yA%1+1)%1,oI=(YA%1+1)%1;let QI="",DI=0;if(RA>=$A)QI=`0 ${yI}`,DI=0;else{const kI=yI*($A-RA),UI=yI-kI;DI=-(yI*(RA+OI+oI)),QI=`${kI} ${UI}`}F.match(/\bstroke-dasharray\s*=/i)?F=F.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${QI}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${QI}"`),F=F.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${QI}`),F.match(/\bstroke-dashoffset\s*=/i)?F=F.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${DI}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${DI}"`),F=F.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${DI}`)}else if(R.dashArray&&R.dashArray.length>0){const RA=R.dashArray.join(" ");F=F.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${RA}"`),F=F.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${RA}`),R.dashOffset&&(F=F.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${R.dashOffset}"`),F=F.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${R.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(u)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(u)){let RA="",$A="";if(TA){const yI=Q.width||i||100,OI=Q.height||w||100,oI=(yI+OI)*2,QI=Math.max(0,Math.min(1,X)),DI=Math.max(0,Math.min(1,aA)),kI=(yA%1+1)%1,UI=(YA%1+1)%1;if(QI>=DI)RA=` stroke-dasharray="0 ${oI}"`,$A=' stroke-dashoffset="0"';else{const OQ=oI*(DI-QI),gi=oI-OQ,Ci=-(oI*(QI+kI+UI));RA=` stroke-dasharray="${OQ} ${gi}"`,$A=` stroke-dashoffset="${Ci}"`}}else(NA=R.dashArray)!=null&&NA.length&&(RA=` stroke-dasharray="${R.dashArray.join(" ")}"`,R.dashOffset&&($A=` stroke-dashoffset="${R.dashOffset}"`));const tg=R.lineCap?` stroke-linecap="${R.lineCap}"`:"",Kg=R.lineJoin?` stroke-linejoin="${R.lineJoin}"`:"",xI=`stroke="${oA}" stroke-width="${BA}" stroke-opacity="${z}"${tg}${Kg}${RA}${$A}`;F=F.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(yI,OI,oI)=>`${OI}${oI}<g ${xI}>`),F=F.replace(/<\/svg>/i,"</g></svg>")}}else R&&R.isEnabled===!1&&(F=F.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),F=F.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const iA=new Blob([F],{type:"image/svg+xml"}),UA=URL.createObjectURL(iA);kA.onload=()=>{if(URL.revokeObjectURL(UA),this.frameCount%900===0){const BA=this.imageCache.get(DA);BA&&this.debugLog(`SVG Payload Ready: ${I.name||I.id} (${BA.naturalWidth}x${BA.naturalHeight})`)}},kA.onerror=()=>{URL.revokeObjectURL(UA),this.debugLog(`SVG Error: Failed to load payload for ${I.name||I.id}`)},kA.src=UA,this.imageCache.set(DA,kA)}let CA=null;if(kA.complete&&kA.naturalWidth>0?(CA=kA,this.lastValidSvgImgMap.set(I.id,kA)):CA=this.lastValidSvgImgMap.get(I.id)||null,CA&&CA.complete&&CA.naturalWidth>0){const F=Math.max(1,i),b=Math.max(1,w);if(Z&&(L==null?void 0:L.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=F,this.maskBuffer.height=b,this.maskCtx.clearRect(0,0,F,b),this.maskCtx.drawImage(CA,0,0,F,b),this.maskCtx.globalCompositeOperation="source-in";const H=L.color||"#000000",iA=this.normalizeOpacity(L.opacity??100);this.maskCtx.fillStyle=H,this.maskCtx.globalAlpha=iA,this.maskCtx.fillRect(0,0,F,b),A.drawImage(this.maskBuffer,-F/2,-b/2,F,b)}else s!==0?(A.save(),this.drawRoundRect(A,-F/2,-b/2,F,b,s),A.clip(),A.drawImage(CA,-F/2,-b/2,F,b),A.restore()):A.drawImage(CA,-F/2,-b/2,F,b)}}}else if(h.type==="LineGraph")this.renderLineGraph(A,h,i,w);else if(I.type==="Shape"){if(this.applyPath(A,h,i,w,s),A.save(),E.blur&&E.blur.amount>0&&(A.filter=`blur(${E.blur.amount}px)`),E.fill){const u=A.globalAlpha,O=this.createCanvasFill(A,E.fill,i,w);O?A.fillStyle=O:A.fillStyle=typeof E.fill=="string"?E.fill:E.fill.color||"transparent",A.globalAlpha=u*this.normalizeOpacity(E.fill.opacity??100),this.applyPath(A,h,i,w,s),A.fill(),A.globalAlpha=u}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??Q.width??I.width??i,O=g.height??Q.height??I.height??w,L=s;if(A.save(),A.beginPath(),this.drawRoundRect(A,-u/2,-O/2,u,O,L),E.fill&&E.fill.type!=="None"){const R=A.globalAlpha,m=this.createCanvasFill(A,E.fill,u,O);A.fillStyle=m||E.fill.color||"transparent",A.globalAlpha=R*this.normalizeOpacity(E.fill.opacity??100),A.fill(),A.globalAlpha=R}if(A.restore(),E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1){const R={type:"Rectangle"};this.applyStrokeAlignment(A,E,R,u,O,L)}}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(IA&&A.restore(),T&&T.enabled&&A.restore(),I.children&&I.children.length>0){const O=I.type==="Frame",L=I.clipsContent!==void 0?I.clipsContent:I.clipContent!==void 0?I.clipContent:O;if(A.save(),L){A.beginPath();const m=g.width??(Q==null?void 0:Q.width)??I.width??0,Z=g.height??(Q==null?void 0:Q.height)??I.height??0,GA=g.cornerRadius??(Q==null?void 0:Q.corner_radius)??I.cornerRadius??0;this.drawRoundRect(A,-m/2,-Z/2,m,Z,GA),A.clip()}let R=0;for(I.children.forEach(m=>{const Z=C.get(m);if(!Z)return;const GA=this.objectStates.get(m),gA=(GA==null?void 0:GA.geometry)||Z.geometry;if(gA&&gA.isMask&&(GA==null?void 0:GA.visible)!==!1){const DA=gA.width||0,kA=gA.height||0;this.applyObjectTransform(A,m);const CA=(GA==null?void 0:GA.corner_radius)??(gA==null?void 0:gA.corner_radius)??0;this.applyPath(A,gA,DA,kA,CA),A.clip(),R++}else this.renderObject(A,Z,C)});R>0;)A.restore(),R--;A.restore()}if(n){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(R=>R.isVisible!==!1&&C.has(R.maskId)).forEach(R=>{const m=C.get(R.maskId),Z=this.objectStates.get(m.id),GA=R.feather||0,gA=R.inverted===!0,DA=R.opacity!==void 0?typeof R.opacity=="number"?R.opacity:R.opacity/100:1;if((R.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&&(this.lumaCtx.imageSmoothingEnabled=!0,this.lumaCtx.imageSmoothingQuality="high")),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,m.id,C),GA>0&&(this.lumaCtx.filter=`blur(${GA}px)`),this.lumaCtx.globalAlpha=DA;const CA=(Z==null?void 0:Z.width)||m.geometry.width||0,F=(Z==null?void 0:Z.height)||m.geometry.height||0,b=(Z==null?void 0:Z.corner_radius)??m.corner_radius??0;if(m.geometry.type==="Text"){const BA=Z!=null&&Z.geometry?this.deepMerge(m.geometry,Z.geometry):m.geometry,z=Z!=null&&Z.style?this.deepMerge(m.style,Z.style):m.style;this._renderText(this.lumaCtx,m,{...BA,width:CA,height:F,corner_radius:b},z,Z,CA,F,!0)}else if(m.geometry.type==="Image"){const BA=m.geometry.src;if(BA){let z=this.imageCache.get(BA);z||(z=new Image,z.src=BA,this.imageCache.set(BA,z)),z.complete&&z.naturalWidth>0?this.lumaCtx.drawImage(z,-CA/2,-F/2,CA,F):(this.applyPath(this.lumaCtx,m.geometry,CA,F,b),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(m.geometry.type==="SVG"){const BA=m.geometry.svgContent;if(BA){const z=`__lumamask_${m.id}`;let AA=this.imageCache.get(z);if(!AA){AA=new Image;const oA=new Blob([BA],{type:"image/svg+xml"});AA.src=URL.createObjectURL(oA),AA.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(z,AA)}AA.complete&&AA.naturalWidth>0?this.lumaCtx.drawImage(AA,-CA/2,-F/2,CA,F):(this.applyPath(this.lumaCtx,m.geometry,CA,F,b),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,m.geometry,CA,F,b),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const H=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),iA=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,UA=H.data;for(let BA=0;BA<UA.length;BA+=4){const z=iA[BA],AA=iA[BA+1],oA=iA[BA+2];let QA=(.299*z+.587*AA+.114*oA)/255;gA&&(QA=1-QA),UA[BA+3]*=QA}this.maskCtx.putImageData(H,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=gA?"destination-out":"destination-in",GA>0&&(this.maskCtx.filter=`blur(${GA}px)`),this.maskCtx.globalAlpha=DA,this.applyAbsoluteTransform(this.maskCtx,m.id,C);const CA=(Z==null?void 0:Z.width)||m.geometry.width||0,F=(Z==null?void 0:Z.height)||m.geometry.height||0,b=(Z==null?void 0:Z.corner_radius)??m.corner_radius??0;if(m.geometry.type==="Text"){const H=Z!=null&&Z.geometry?this.deepMerge(m.geometry,Z.geometry):m.geometry,iA=Z!=null&&Z.style?this.deepMerge(m.style,Z.style):m.style;this._renderText(this.maskCtx,m,{...H,width:CA,height:F,corner_radius:b},iA,Z,CA,F,!0)}else if(m.geometry.type==="Image"){const H=m.geometry.src;if(H){let iA=this.imageCache.get(H);iA||(iA=new Image,iA.src=H,this.imageCache.set(H,iA)),iA.complete&&iA.naturalWidth>0?this.maskCtx.drawImage(iA,-CA/2,-F/2,CA,F):(this.applyPath(this.maskCtx,m.geometry,CA,F,b),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(m.geometry.type==="SVG"){const H=m.geometry.svgContent;if(H){const iA=`__alphamask_${m.id}`;let UA=this.imageCache.get(iA);if(!UA){UA=new Image;const BA=new Blob([H],{type:"image/svg+xml"});UA.src=URL.createObjectURL(BA),UA.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(iA,UA)}UA.complete&&UA.naturalWidth>0?this.maskCtx.drawImage(UA,-CA/2,-F/2,CA,F):(this.applyPath(this.maskCtx,m.geometry,CA,F,b),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,m.geometry,CA,F,b),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),r.save(),r.setTransform(1,0,0,1,0,0);const L=I.maskBlendMode||I.blendMode;L&&L!=="Normal"&&(r.globalCompositeOperation=L.toLowerCase()),r.drawImage(this.maskBuffer,0,0),r.restore(),r.restore()}else A.restore()}_renderText(A,I,C,g,Q,E,i,w=!1,o=!1){var p;let s=C.text||"";if(C.textInputId&&!w){const U=this.inputs.get(C.textInputId);U!==void 0&&(s=String(U),Q.geometry&&Q.geometry.type==="Text"&&(Q.geometry.text=s))}let h=s||"";if(C.segments&&Array.isArray(C.segments)){const U=C.segments.map(_=>_&&_.text?_.text:"").join("");U!==h&&U.toUpperCase()===(s||"").toUpperCase()?h=s||"":h=U}let a=((p=C.fontWeight)==null?void 0:p.toString())||"400",G="normal";a.toLowerCase().includes("italic")&&(G="italic",a=a.replace(/italic/gi,"").trim()||"400");const t=this.mapFontWeight(a),K=Math.max(1,C.fontSize||16);let S=C.fontFamily||"Inter";const y=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];y.forEach(U=>{const _=new RegExp(`[\\s-]${U}$`,"i");_.test(S)&&(S=S.replace(_,"").trim())}),A.font=`${G} ${t} ${K}px "${S}", sans-serif`;const N=C.textVerticalAlign||"top";A.textBaseline="top";const M=C.textAlign||"left";A.textAlign=M;const e=C.letterSpacing||0,Y=C.paragraphSpacing||0,j=(C.lineHeight||1.2)*K,l=Math.ceil(C.width||E||200)+.5,r=`${G} ${t} ${K}px "${S}", sans-serif`,v=U=>{if(e===0)return A.measureText(U).width;let _=0;for(let f=0;f<U.length;f++)_+=A.measureText(U[f]).width+e;return _-e},n=`${h}|${r}|${e}|${Y}`;let q=this.pretextCache.get(n);if(!q&&(q=KE(h,r),this.pretextCache.set(n,q),this.pretextCache.size>1e3)){const U=this.pretextCache.keys().next().value;U&&this.pretextCache.delete(U)}const P=q?ME(q,l,j):{height:0,lines:[]},sA=(P==null?void 0:P.height)??0,EA=(P==null?void 0:P.lines)??[];let T=sA;const V=this.getFontLeadingFactor(C.fontFamily||"Inter"),IA=(j-K)*V;let x=Math.round(-T/2);i>0&&(N==="top"?x=Math.round(-i/2):N==="middle"||N==="center"?x=Math.round(-T/2):N==="bottom"&&(x=Math.round(i/2-T))),x+=IA;const d=(U,_,f,$,hA)=>{var FA,NA,u;const SA=(!w||o)&&(I.behaviors||[]).some(O=>O.enabled&&(O.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(O.type)));if(e===0&&!SA&&(C.enableSegments!==!0||!C.segments||C.segments.length===0))$?A.strokeText(U,_,f):A.fillText(U,_,f);else{const O=v(U);let L=_;M==="center"?L-=O/2:M==="right"&&(L-=O);let R=L;const m=w&&!o?[]:((FA=I.behaviors)==null?void 0:FA.filter(Z=>[W.Typewriter,W.Scramble,W.Wave,W.Bounce,W.GlitchText,W.TextTrail,W.Reveal3D,W.RevealSlide,W.RevealBlur,W.TextLiquid,W.TextVortex,W.TextExplosion,W.TextRain,W.TextGravity,W.TextElastic,W.TextMatrix,W.TextNeon,W.TextGlitch3D,W.TextDissolve,W.TextOrganic,W.TextBreathe,W.TextFloral,W.TextSmoke,W.TextVariable,W.TextMagnet,W.TextSpin,W.TextZing,W.TextPerspective,W.TextMirror].includes(Z.type)&&Z.enabled))||[];for(let Z=0;Z<U.length;Z++){let GA=U[Z];const gA=hA+Z;let DA=0,kA=0,CA=1,F=1,b=0,H=1,iA=GA;if(m.forEach(z=>{const AA=z.settings||{},oA=AA.strength||1,QA=Date.now();if(z.type===W.Typewriter)this.currentTime*(AA.speed||1)-gA*(AA.stagger||.05)<0&&(H=0);else if(z.type===W.Scramble)Math.max(0,Math.min(1,this.currentTime/(AA.duration||1.5))-gA*.02)<1&&Math.random()<.3&&(iA="$%#@!*&"[Math.floor(Math.random()*7)]);else if(z.type===W.Wave)kA+=Math.sin(this.currentTime*5*(AA.speed||1)+gA*(AA.frequency||1))*(AA.amplitude||20)*oA;else if(z.type===W.Bounce){const X=Math.max(0,this.currentTime%2-gA*(AA.stagger||.1));X<1&&(kA-=Math.abs(Math.sin(X*Math.PI))*(AA.height||50)*oA)}else if(z.type===W.TextTrail){const X=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-gA*(AA.delay||5))];X&&(DA+=(X.x-(Q.x+R))*oA*.2,kA+=(X.y-(Q.y+f+kA))*oA*.2)}else if(z.type===W.Reveal3D){const X=Math.max(0,Math.min(1,this.currentTime*(AA.speed||1)-gA*(AA.stagger||.1)));CA*=X,F*=X,H=X}else if(z.type===W.RevealSlide){const X=Math.max(0,Math.min(1,this.currentTime*1.5-gA*.05)),aA=(1-X)*(AA.distance||40)*oA,yA=AA.direction||"up";yA==="up"?kA-=aA:yA==="down"?kA+=aA:yA==="left"?DA-=aA:yA==="right"&&(DA+=aA),H=X}else if(z.type===W.RevealBlur){const X=Math.max(0,Math.min(1,this.currentTime*1.2-gA*.1));H=X,DA+=(1-X)*5}else if(z.type===W.TextLiquid){const X=Math.max(0,Math.sin(QA*.001*(AA.speed||1)+gA*.5));kA+=X*(AA.amplitude||10)*oA,F*=1+X*.2}else if(z.type===W.TextVortex){const X=QA*.002*(AA.speed||1)+gA*.2,aA=(1-(Math.sin(QA*.001)*.5+.5))*(AA.radius||50);DA+=Math.cos(X)*aA*oA,kA+=Math.sin(X)*aA*oA}else if(z.type===W.TextExplosion){const X=AA.force||1,aA=this.currentTime%2;if(aA<1){const yA=(gA/U.length-.5)*Math.PI*2,YA=aA*100*X;DA+=Math.cos(yA)*YA*oA,kA+=Math.sin(yA)*YA*oA,H=1-aA}}else if(z.type===W.TextRain){const X=AA.speed||1,aA=AA.height||100,yA=(QA*.001*X+gA*.1)%1;kA-=(1-yA)*aA*oA,H=yA>.1?1:yA*10}else if(z.type===W.TextGravity){const X=AA.gravity||9.8,aA=this.currentTime%3/3,yA=.5*X*Math.pow(aA*10,2);yA<100?kA+=yA*oA:kA+=100*oA}else if(z.type===W.TextMatrix){const X=AA.speed||1;if(Math.random()<.1*X){const yA="0123456789ABCDEF!@#$%^&*";iA=yA[Math.floor(Math.random()*yA.length)]}H=.3+(Math.sin(QA*.01*X+gA)+1)/2*.7}else if(z.type===W.TextNeon){const X=Math.random()>.95?.5:1;H=(.7+(Math.sin(QA*.005)+1)/2*.3)*X}else if(z.type===W.TextDissolve)Math.sin(gA*1.5+QA*.002*(AA.speed||1))>.5&&(H=0);else if(z.type===W.TextOrganic){const X=AA.speed||1,aA=AA.amplitude||10;DA+=Math.sin(QA*.002*X+gA)*aA*oA,kA+=Math.cos(QA*.0015*X+gA*.7)*aA*oA}else if(z.type===W.TextBreathe){const aA=1+(Math.sin(QA*.003+gA*.2)+1)/2*.2*oA;CA*=aA,F*=aA}else if(z.type===W.TextSpin){const X=AA.speed||1;b+=QA*.01*X+gA}else if(z.type===W.TextMagnet){const X=this.pointerHistory[this.pointerHistory.length-1];if(X){const aA=X.x-(Q.x+R),yA=X.y-(Q.y+f);b=Math.atan2(yA,aA)}}else if(z.type===W.TextPerspective){const X=U.length/2,aA=(gA-X)/X,yA=1-Math.abs(aA)*.3*oA;CA*=yA,F*=yA,DA+=aA*20*oA}else if(z.type===W.TextMirror)H*=.8;else if(z.type===W.TextFloral){const X=AA.speed||1,aA=AA.stagger||.1,yA=(QA*.001*X+gA*aA)%2;yA<1&&(CA*=yA,F*=yA,b+=yA*Math.PI)}else if(z.type===W.TextSmoke){const X=AA.speed||1,aA=AA.height||50,yA=(QA*5e-4*X+gA*.2)%1;kA-=yA*aA*oA,DA+=Math.sin(QA*.002+gA)*5*oA,H=1-yA}else if(z.type===W.TextVariable){const X=AA.speed||1,aA=AA.intensity||1.5,yA=(Math.sin(QA*.004*X+gA*.3)+1)/2;CA*=1+yA*(aA-1)*oA}else if(z.type===W.TextZing){const X=AA.speed||2,aA=AA.distance||100,yA=(QA*.002*X+gA*.05)%1;DA+=(1-yA)*aA*oA,H=yA}else if(z.type===W.TextElastic){const X=AA.stiffness||.2,aA=AA.damping||.1,yA=Math.sin(QA*.01)*Math.exp(-QA*.001*aA);F*=1+yA*X*oA}else if(z.type===W.TextGlitch3D){const X=AA.intensity||5;Math.random()<.2&&(DA+=(Math.random()-.5)*X,kA+=(Math.random()-.5)*X,H=.8)}else if(z.type===W.GlitchText){const X=AA.intensity||5;Math.random()<.1&&(DA+=(Math.random()-.5)*X,kA+=(Math.random()-.5)*X,Math.random()<.05&&(H=.5))}}),H<=0){R+=A.measureText(GA).width+e;continue}if(C.enableSegments===!0&&((NA=C.segments)==null?void 0:NA.length)>0){let z=0,AA=null;for(const oA of C.segments){if(gA<z+(oA.text||"").length){AA=oA;break}z+=(oA.text||"").length}if(AA){let oA=AA.fontFamily||C.fontFamily||"Inter";y.forEach(QA=>{const X=new RegExp(`[\\s-]${QA}$`,"i");X.test(oA)&&(oA=oA.replace(X,"").trim())}),A.font=`${G} ${this.mapFontWeight((AA.fontWeight||C.fontWeight||"400").toString())} ${AA.fontSize||K}px "${oA}", sans-serif`}}const UA=A.globalAlpha;A.globalAlpha*=H,A.save();const BA=A.measureText(iA).width;if(A.translate(R+DA+BA/2,f+kA),b!==0&&A.rotate(b),A.scale(CA,F),w||o){const z=o?"#000000":this.createCanvasFill(A,g.fill,E,i);A.fillStyle=z||g.fill.color||"#ffffff",A.fillText(iA,-BA/2,0)}else $?A.strokeText(iA,-BA/2,0):A.fillText(iA,-BA/2,0);A.restore(),A.globalAlpha=UA,C.enableSegments===!0&&((u=C.segments)==null?void 0:u.length)>0&&(A.font=`${G} ${this.mapFontWeight((C.fontWeight||"400").toString())} ${K}px "${C.fontFamily||"Inter"}", sans-serif`),R+=A.measureText(GA).width+e}}};if(w){let U=0,_=x;(EA||[]).forEach(f=>{let $=-E/2;M==="center"?$=0:M==="right"&&($=E/2),d(f.text,$,_,!1,U),U+=(f.text||"").length+1,_+=j})}else if(o){let U=0,_=x;(EA||[]).forEach(f=>{let $=-E/2;M==="center"?$=0:M==="right"&&($=E/2),d(f.text,$,_,!1,U),U+=(f.text||"").length+1,_+=j})}else{if(g.fill){const U=A.globalAlpha,_=this.createCanvasFill(A,g.fill,E,i);A.fillStyle=_||g.fill.color||"#000000",A.globalAlpha=U*this.normalizeOpacity(g.fill.opacity??100);let f=0,$=x;(EA||[]).forEach(hA=>{let SA=Math.round(-E/2);M==="center"?SA=0:M==="right"&&(SA=Math.round(E/2)),d(hA.text,SA,$,!1,f),f+=(hA.text||"").length+1,$+=j}),A.globalAlpha=U}if(g.stroke&&g.stroke.width>0){const U=A.globalAlpha;A.strokeStyle=g.stroke.color,A.lineWidth=g.stroke.width,A.globalAlpha=U*this.normalizeOpacity(g.stroke.opacity??100);let _=0,f=x;(EA||[]).forEach($=>{let hA=Math.round(-E/2);M==="center"?hA=0:M==="right"&&(hA=Math.round(E/2)),d($.text,hA,f,!0,_),_+=($.text||"").length+1,f+=j}),A.globalAlpha=U}}}applyStrokeAlignment(A,I,C,g,Q,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 S=this.createCanvasFill(A,i.fill,g,Q);S?A.strokeStyle=S: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,t=i.dashOffset??0,K=i.dashArray||[];if(h!==0||a!==1||G!==0){const S=this.getPerimeter(C,g,Q);if(S>0){const y=Math.max(0,Math.min(1,h)),N=Math.max(0,Math.min(1,a));if(y<N){const M=S*(N-y),e=S-M,Y=-(S*(y+G%1+t%1));A.setLineDash([M,e]),A.lineDashOffset=Y}else A.setLineDash([0,S])}}else K.length>0&&(A.setLineDash(K),A.lineDashOffset=t);C.type==="Line"||g===0||Q===0?(this.applyPath(A,C,g,Q,E),A.stroke()):o==="inside"?(A.lineWidth=w*2,A.save(),this.applyPath(A,C,g,Q,E),A.clip(),A.stroke(),A.restore()):o==="outside"?(A.lineWidth=w*2,this.applyPath(A,C,g,Q,E),A.stroke(),A.save(),A.globalCompositeOperation="destination-out",this.applyPath(A,C,g,Q,E),A.fill(),A.restore()):(A.lineWidth=w,this.applyPath(A,C,g,Q,E),A.stroke()),A.restore()}getPerimeter(A,I,C){switch(A.type){case"Rectangle":return(I+C)*2;case"Ellipse":{const g=I/2,Q=C/2,E=Math.abs(A.sweepAngle??360),i=A.ratio||0,w=Math.PI*(3*(g+Q)-Math.sqrt((3*g+Q)*(g+3*Q)));if(E>=360&&i<=0)return w;let o=E/360*w;if(i>0){const s=Math.PI*(3*(g*i+Q*i)-Math.sqrt((3*g*i+Q*i)*(g*i+3*Q*i)));o+=E/360*s,E<360&&(o+=2*Math.sqrt((g-g*i)**2+(Q-Q*i)**2))}else E<360&&(o+=g+Q);return o}case"Line":return A.length||Math.sqrt(I*I+C*C);case"Triangle":return I+Math.sqrt((I/2)**2+C**2)*2;case"Polygon":{const g=A.sides||3,Q=A.radius||Math.min(I,C)/2;return 2*g*Q*Math.sin(Math.PI/g)}case"Star":{const g=A.points||5,Q=A.outer_radius||Math.min(I,C)/2,E=A.inner_radius||Q/2,i=Math.PI/g;return Math.sqrt(Q*Q+E*E-2*Q*E*Math.cos(i))*g*2}case"Path":{const g=A.points||[];if(g.length<2)return A.length||0;let Q=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)Q+=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;Q+=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)Q+=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;Q+=Math.sqrt(w*w+o*o)}}return Q}default:return(I+C)*2}}getBezierLength(A,I,C,g,Q,E,i,w,o=10){let s=0,h=A,a=I;for(let G=1;G<=o;G++){const t=G/o,K=1-t,S=t*t,y=K*K,N=y*K,M=S*t,e=N*A+3*y*t*C+3*K*S*Q+M*i,Y=N*I+3*y*t*g+3*K*S*E+M*w,j=e-h,l=Y-a;s+=Math.sqrt(j*j+l*l),h=e,a=Y}return s}getPointOnPath(A,I,C,g){if(A.type==="Path"){const Q=A.points||[];if(Q.length<2)return{x:0,y:0,angle:0};let E=1/0,i=-1/0,w=1/0,o=-1/0;Q.forEach(S=>{E=Math.min(E,S.x),i=Math.max(i,S.x),w=Math.min(w,S.y),o=Math.max(o,S.y)});const s=(E+i)/2,h=(w+o)/2,G=this.getPerimeter(A,I,C)*g;let t=0;const K=[];for(let S=1;S<Q.length;S++)K.push({p0:Q[S-1],p1:Q[S]});A.is_closed&&K.push({p0:Q[Q.length-1],p1:Q[0]});for(const S of K){const y=S.p0,N=S.p1;let M=0;const e=y.out_x!==void 0||N.in_x!==void 0;if(e?M=this.getBezierLength(y.x,y.y,y.out_x??y.x,y.out_y??y.y,N.in_x??N.x,N.in_y??N.y,N.x,N.y):M=Math.sqrt((N.x-y.x)**2+(N.y-y.y)**2),t+M>=G||S===K[K.length-1]){const Y=M===0?0:(G-t)/M;if(e)return this.getBezierPointAndAngle(Y,y,N,s,h);{const j=y.x+(N.x-y.x)*Y-s,l=y.y+(N.y-y.y)*Y-h,r=Math.atan2(N.y-y.y,N.x-y.x);return{x:j,y:l,angle:r}}}t+=M}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(A,I,C,g,Q){const E=I.x,i=I.y,w=I.out_x??I.x,o=I.out_y??I.y,s=C.in_x??C.x,h=C.in_y??C.y,a=C.x,G=C.y,t=1-A,K=A*A,S=t*t,y=S*t,N=K*A,M=y*E+3*S*A*w+3*t*K*s+N*a-g,e=y*i+3*S*A*o+3*t*K*h+N*G-Q,Y=3*S*(w-E)+6*t*A*(s-w)+3*K*(a-s),j=3*S*(o-i)+6*t*A*(h-o)+3*K*(G-h),l=Math.atan2(j,Y);return{x:M,y:e,angle:l}}applyAbsoluteTransform(A,I,C){if(!C.get(I))return;const Q=[];let E=I;for(;E;){Q.unshift(E);const i=C.get(E);E=i==null?void 0:i.parentId}Q.forEach(i=>{this.applyObjectTransform(A,i)})}applyObjectTransform(A,I){const C=this.objectStates.get(I);if(!C)return;A.translate(C.x,C.y),A.rotate(C.rotation*Math.PI/180);const g=(C.scale_x??1)*(C.flip_x===!0?-1:1),Q=(C.scale_y??1)*(C.flip_y===!0?-1:1);A.scale(g,Q)}applyPath(A,I,C,g,Q){A.beginPath(),this._tracePath(A,I,C,g,Q)}_tracePath(A,I,C,g,Q){if(I.type==="Rectangle"||I.type==="Image"){const E=Q!==void 0?Q:I.corner_radius??0;this.drawRoundRect(A,-C/2,-g/2,C,g,E)}else if(I.type==="Line")A.moveTo(-C/2,0),A.lineTo(C/2,0);else if(I.type==="Ellipse"){const{startAngle:E=0,sweepAngle:i=360,ratio:w=0}=I,o=C/2,s=g/2,h=E*Math.PI/180,a=i*Math.PI/180,G=h+a;i>=360&&w<=0?A.ellipse(0,0,o,s,0,0,Math.PI*2):(A.ellipse(0,0,o,s,0,h,G,!1),w>0?A.ellipse(0,0,o*w,s*w,0,G,h,!0):A.lineTo(0,0),A.closePath())}else if(I.type==="Triangle")A.moveTo(0,-g/2),A.lineTo(C/2,g/2),A.lineTo(-C/2,g/2),A.closePath();else if(I.type==="Polygon"){const E=I.sides||3,i=I.radius||Math.min(C,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 t=I.points[G-1],K=(t.out_x??t.x)-s,S=(t.out_y??t.y)-h,y=(a.in_x??a.x)-s,N=(a.in_y??a.y)-h;A.bezierCurveTo(K,S,y,N,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 t=I.points[G-1];t.out_x!==void 0||a.in_x!==void 0?A.bezierCurveTo((t.out_x??t.x)-s,(t.out_y??t.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 SA,FA;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((SA=I.geometry)==null?void 0:SA.width)||250,E=((FA=I.geometry)==null?void 0:FA.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},t=g.rightIcon||{visible:!1},K=g.multiline===!0,S=g.corner_radius??8,y=g.corners||{tl:S,tr:S,bl:S,br:S},N=[y.tl,y.tr,y.br,y.bl];let M=g.backgroundColor||"rgba(31, 41, 55, 1)",e=g.borderColor||"rgba(55, 65, 81, 1)",Y=g.borderWidth??1.5,j=g.color||"#ffffff",l=g.placeholderColor||"rgba(156, 163, 175, 1)",r=g.fontSize||14;const v=`${s}Style`,n=g[v];if(n?(n.backgroundColor!==void 0&&(M=n.backgroundColor),n.borderColor!==void 0&&(e=n.borderColor),n.borderWidth!==void 0&&(Y=n.borderWidth),n.color!==void 0&&(j=n.color),n.placeholderColor!==void 0&&(l=n.placeholderColor),n.fontSize!==void 0&&(r=n.fontSize)):s==="focused"?(e=g.focusBorderColor||"rgba(59, 130, 246, 1)",Y=Math.max(Y,2)):s==="hovered"||s==="hover"?(e=g.hoverBorderColor||e,M=g.hoverBackgroundColor||M):s==="disabled"?(M=g.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",e=g.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):s==="error"&&(e="rgba(239, 68, 68, 1)",Y=Math.max(Y,2)),A.beginPath(),this.drawRoundRect(A,-Q/2,-E/2,Q,E,N),A.fillStyle=M,A.fill(),Y>0&&(A.strokeStyle=e,A.lineWidth=Y,A.stroke(),s==="focused"||s==="focus")){A.save(),A.beginPath();const NA=N.map(u=>u+2);this.drawRoundRect(A,-Q/2-2,-E/2-2,Q+4,E+4,NA),A.strokeStyle="rgba(59, 130, 246, 0.3)",A.lineWidth=2,A.stroke(),A.restore()}const q=(NA,u)=>{if(!NA.visible||!NA.svgPath)return;const O=NA.size||14,L=NA.offset??16,R=NA.color||"#ffffff",m=u?-(Q/2)+L:Q/2-L,Z=NA.svgPath;if(A.save(),A.translate(m,0),!Z.startsWith("<svg")){const GA=new Path2D(Z),gA=O/24;A.scale(gA,gA),A.translate(-12,-12),A.fillStyle=R,A.fill(GA)}A.restore()};q(G,!0),q(t,!1);const P=g.text||"",sA=g.placeholder||"Enter text...",EA=!P,T=P||sA,V=EA?l:j,IA=r,x=g.fontFamily||"Inter",d=g.fontWeight||400;A.font=`${d} ${IA}px "${x}", sans-serif`,A.fillStyle=V,A.textAlign="left",A.textBaseline=K?"top":"middle";const p=g.inputPadding??16,U=G.visible?(G.offset??16)+(G.size||14)/2+8:p,_=t.visible?(t.offset??16)+(t.size||14)/2+8:p,f=-(Q/2)+U,$=Q-U-_,hA=g.inputType==="password"?"•".repeat(T.length):T;if(A.save(),A.beginPath(),A.rect(f-2,-E/2+4,$+4,E-8),A.clip(),K){const NA=hA.split(`
22
- `);let u=-E/2+p;const O=IA*1.2;let L=0;NA.forEach((R,m)=>{const Z=R.split(" ");let GA="";for(let gA=0;gA<Z.length;gA++){const DA=GA+Z[gA]+" ";A.measureText(DA).width>$&&gA>0?(A.fillText(GA,f,u),GA=Z[gA]+" ",u+=O):GA=DA}A.fillText(GA,f,u),L=A.measureText(GA).width,m<NA.length-1&&(u+=O,L=0)}),i&&!EA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(f+L,u,1.5,IA)}else{const u=A.measureText(hA).width;let O=0;if(u>$&&(O=u-$),A.fillText(hA,f-O,0),i&&!EA&&Math.floor(performance.now()/500)%2===0){const R=f+u-O;A.fillRect(R,-(IA/2),1.5,IA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",u=h.fontSize||12,O=h.color||"rgba(156, 163, 175, 1)",L=h.offset??8;A.font=`600 ${u}px "${x}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="bottom";const R=-(Q/2),m=-(E/2)-L;A.fillText(NA,R,m)}if(a.visible===!0){const NA=a.text||"Helper text",u=a.fontSize||11,O=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",L=a.offset??6;A.font=`400 ${u}px "${x}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="top";const R=-(Q/2),m=E/2+L;A.fillText(NA,R,m)}}renderSlider(A,I){const C=this.objectStates.get(I.id),g=(C==null?void 0:C.geometry)||I.geometry,Q=(C==null?void 0:C.options)||I.options||{},E=g.width||200,i=Q.value??50,w=Q.min??0,s=(Q.max??100)-w,h=s===0?0:(i-w)/s,a=Q.trackHeight||4,G=Q.trackRoundedness??2,t=Q.trackShape??"Rectangle",K=Q.trackPath||"",S=Q.activeColor||"#3b82f6",y=Q.inactiveColor||"#374151",N=Q.thumbShape||"Ellipse",M=Q.thumbWidth??16,e=Q.thumbHeight??16,Y=Q.thumbRoundedness??0,j=Q.thumbColor||"#ffffff",l=Q.thumbPath||"",r=Q.thumbIcon||"",v=Q.showValueTooltip??!1,n=Q.tooltipBgColor||"#333333",q=Q.tooltipColor||"#ffffff",P=Q.tooltipOffsetX??0,sA=Q.tooltipOffsetY??-25,EA=(f,$,hA,SA,FA,NA,u)=>{if((f==="Custom"||f==="Icon")&&u)try{const O=new Path2D(u);if(A.save(),A.translate($,hA),f==="Icon"){const L=Math.min(SA,FA)/24;A.scale(L,L),A.translate(-12,-12)}A.fill(O),A.restore();return}catch(O){console.error("Error drawing slider shape in engine:",O)}if(A.beginPath(),f==="Ellipse")A.ellipse($,hA,SA/2,FA/2,0,0,Math.PI*2);else if(f==="Rectangle")this.drawRoundRect(A,$-SA/2,hA-FA/2,SA,FA,NA);else if(f==="Triangle")A.moveTo($,hA-FA/2),A.lineTo($+SA/2,hA+FA/2),A.lineTo($-SA/2,hA+FA/2),A.closePath();else if(f==="Diamond")A.moveTo($,hA-FA/2),A.lineTo($+SA/2,hA),A.lineTo($,hA+FA/2),A.lineTo($-SA/2,hA),A.closePath();else if(f==="Polygon"){const O=I.geometry.sides||3,L=I.geometry.radius||Math.min(SA,FA)/2;for(let R=0;R<O;R++){const m=R*2*Math.PI/O-Math.PI/2,Z=$+L*Math.cos(m),GA=hA+L*Math.sin(m);R===0?A.moveTo(Z,GA):A.lineTo(Z,GA)}A.closePath()}else if(f==="Star"){const L=Math.min(SA,FA)/2,R=L/2;for(let m=0;m<5*2;m++){const Z=m%2===0?L:R,GA=m*Math.PI/5-Math.PI/2;A.lineTo($+Z*Math.cos(GA),hA+Z*Math.sin(GA))}A.closePath()}else f==="Line"&&(A.moveTo($-SA/2,hA),A.lineTo($+SA/2,hA));A.fill()};A.fillStyle=y,t==="Line"?(A.strokeStyle=y,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):EA(t,0,0,E,a,G,K);const T=E-M,V=-E/2+M/2+h*T,IA=V- -E/2;IA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(V,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,IA,a,G),A.fill())),A.save(),A.translate(V,0);const x=A.getTransform(),d=Math.sqrt(x.a*x.a+x.b*x.b)||1;if(A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4*d,A.shadowOffsetY=1*d,A.fillStyle=j,EA(N,0,0,M,e,Y,N==="Icon"?r:l),A.restore(),v){A.save(),A.translate(V+P,sA);const f=Math.round(i).toString();A.font="10px Inter, sans-serif";const $=A.measureText(f),hA=6,SA=4,FA=$.width+hA*2,NA=14+SA;A.beginPath(),this.drawRoundRect(A,-FA/2,-NA/2,FA,NA,4),A.fillStyle=n,A.fill(),A.fillStyle=q,A.textAlign="center",A.textBaseline="middle",A.fillText(f,0,0),A.restore()}const p=Q.label||{},U=Q.helperText||{},_=Q.fontFamily||"Inter";if(p.visible!==!1){const f=p.text||"Label",$=p.fontSize||12,hA=p.color||"rgba(156, 163, 175, 1)",SA=p.offset??8;A.font=`600 ${$}px "${_}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="bottom";const FA=-(E/2),NA=-(a/2)-SA;A.fillText(f,FA,NA)}if(U.visible===!0){const f=U.text||"Helper text",$=U.fontSize||11,hA=U.color||"rgba(156, 163, 175, 1)",SA=U.offset??6;A.font=`400 ${$}px "${_}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="top";const FA=-(E/2),NA=a/2+SA;A.fillText(f,FA,NA)}}renderDropdown(A,I){var sA;const C=this.objectStates.get(I.id);if(!C)return;const g=C.options||I.options||{},Q=I.geometry.width||160,E=I.geometry.height||40,i=-Q/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,t=g.borderColor,K=g.color||"#333333";s?(G=g.disabledBackgroundColor||"#f3f4f6",t=g.disabledBorderColor||"#e5e7eb",K=g.disabledColor||"#9ca3af"):a?(G=g.activeBackgroundColor||G,t=g.activeBorderColor||t,K=g.activeColor||K):h&&(G=g.hoverBackgroundColor||G,t=g.hoverBorderColor||t,K=g.hoverColor||K),G||(G="#ffffff"),t||(t="#e5e7eb");const S=A.globalAlpha;A.globalAlpha=S*(g.opacity??1),this.drawRoundRect(A,i,w,Q,E,o),A.fillStyle=this.createCanvasFill(A,typeof G=="string"?{type:"Solid",color:G}:G,Q,E)||"#ffffff",A.fill();const y=g.borderWidth??1;y>0&&(A.strokeStyle=this.createCanvasFill(A,typeof t=="string"?{type:"Solid",color:t}:t,Q,E)||"#e5e7eb",A.lineWidth=y,A.stroke());const N=12,M=g.chevronType||"chevron",e=g.chevronSize||16,Y=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(M!=="none"){const EA=i+Q-N-e/2;A.save(),A.translate(EA,0);const T=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(T*Math.PI/180),A.strokeStyle=Y,A.fillStyle=Y,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",M==="chevron")A.beginPath(),A.moveTo(-e/2,-e*.2),A.lineTo(0,e*.2),A.lineTo(e/2,-e*.2),A.stroke();else if(M==="custom"||M==="path"){const V=a&&g.openIconPath||g.closedIconPath;if(V){const IA=new Path2D(V);A.save();const x=e/24;A.scale(x,x),A.translate(-12,-12),A.fill(IA),A.restore()}}A.restore()}const j=g.selectedOption||g.placeholder||"Select...",l=g.fontSize||14,r=g.fontWeight||400,v=g.fontFamily||"Inter, sans-serif";A.font=`${r} ${l}px ${v}`;const n=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":K;A.fillStyle=this.createCanvasFill(A,typeof n=="string"?{type:"Solid",color:n}:n,Q,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const q=M==="none"?0:e+8,P=Q-N*2-q;if(A.save(),A.beginPath(),A.rect(i+N,w,P,E),A.clip(),A.fillText(j,i+N,0),A.restore(),a&&!s){const EA=w+E+4,T=g.optionsList||[],V=g.itemHeight||32,IA=g.listPadding??4,x=T.length*V+IA*2,d=g.listCornerRadius??o;A.save();const p=g.listShadow||{},U=A.getTransform(),_=Math.sqrt(U.a*U.a+U.b*U.b)||1;A.shadowColor=typeof p.color=="string"?p.color:((sA=p.color)==null?void 0:sA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=(p.blur??12)*_,A.shadowOffsetY=(p.offsetY??6)*_,A.shadowOffsetX=(p.offsetX??0)*_,A.beginPath(),this.drawRoundRect(A,i,EA,Q,x,d),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,x)||"#ffffff",A.fill();const f=g.listBorderWidth??1;f>0&&(A.shadowColor="transparent",A.strokeStyle=this.createCanvasFill(A,typeof g.listBorderColor=="string"?{type:"Solid",color:g.listBorderColor}:g.listBorderColor||{type:"Solid",color:t},Q,x)||"#e5e7eb",A.lineWidth=f,A.stroke()),A.restore();const $=g.itemFontSize||l,hA=g.itemFontFamily||v;A.font=`${r} ${$}px ${hA}`,T.forEach((SA,FA)=>{const NA=EA+IA+FA*V;if(SA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,V)||"#f3f4f6",A.fillRect(i+f,NA,Q-f*2,V),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const O=this._lastPointerPos.y-(EA+IA),L=Math.floor(O/V);FA===L&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,V)||"#f9fafb",A.fillRect(i+f,NA,Q-f*2,V),A.fillStyle=g.itemHoverColor||K)}A.fillText(SA,i+N,NA+V/2)})}A.globalAlpha=S}renderButton(A,I){var M,e,Y,j;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((M=I.geometry)==null?void 0:M.width)||120,E=((e=I.geometry)==null?void 0:e.height)||40,i=-Q/2,w=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((Y=g.hoverStyle)==null?void 0:Y.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},t=o?((j=g.hoverStyle)==null?void 0:j.textColor)||G.color||"#ffffff":G.color||"#ffffff",K=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,w,Q,E,s):h==="Ellipse"||h==="Circle"?A.ellipse(0,0,Q/2,E/2,0,0,Math.PI*2):h==="Pill"&&this.drawRoundRect(A,i,w,Q,E,E/2),A.fillStyle=a,A.fill();const S=G.fontSize||14,y=G.fontFamily||"Inter";A.font=`${G.fontWeight||400} ${S}px "${y}", sans-serif`,A.fillStyle=t,A.textAlign="center",A.textBaseline="middle";let N=0;if(K.enabled&&K.svgPath){const l=K.size||16,r=K.gap||8,v=K.position==="left"?-(A.measureText(G.text||"").width/2+l/2+r/2):A.measureText(G.text||"").width/2+l/2+r/2;A.save(),A.translate(v,0);const n=new Path2D(K.svgPath),q=l/24;A.scale(q,q),A.translate(-12,-12),A.fillStyle=K.color||t,A.fill(n),A.restore(),N=K.position==="left"?l/2+r/2:-(l/2+r/2)}A.fillText(G.text||"Button",N,0),A.restore()}renderToggleButton(A,I){var S,y;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=g.checked??!1,E=((S=I.geometry)==null?void 0:S.width)||120,i=((y=I.geometry)==null?void 0:y.height)||40,w=-E/2,o=-i/2,s=g.corner_radius??8,h=g.label||{},a=Q?g.activeColor||"#3b82f6":g.inactiveColor||"#374151",G=Q?g.activeTextColor||"#ffffff":g.inactiveTextColor||"#9ca3af";A.save(),A.beginPath(),this.drawRoundRect(A,w,o,E,i,s),A.fillStyle=a,A.fill();const t=h.fontSize||14,K=h.fontFamily||"Inter";A.font=`${h.fontWeight||600} ${t}px "${K}", sans-serif`,A.fillStyle=G,A.textAlign="center",A.textBaseline="middle",A.fillText(h.text||"Toggle",0,0),A.restore()}renderToggle(A,I){var N,M;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((N=I.geometry)==null?void 0:N.width)||52,E=((M=I.geometry)==null?void 0:M.height)||30,i=-Q/2,w=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,w,Q,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,t=i+h,K=i+Q-h-a,S=o?K:t,y=w+h;if(A.beginPath(),A.arc(S+G,y+G,G,0,Math.PI*2),A.fillStyle=g.knobColor||"#ffffff",A.fill(),g.disabled&&(A.globalAlpha*=2),g.label&&g.label.text){const e=g.label,Y=e.fontSize||14,j=e.fontWeight||400,l=e.fontFamily||"Inter";A.font=`${j} ${Y}px "${l}", sans-serif`,A.fillStyle=e.color||"#f3f4f6",A.textBaseline="middle";const r=e.gap||10;let v=0,n=0;e.position==="left"?(A.textAlign="right",v=i-r,n=0):e.position==="right"?(A.textAlign="left",v=i+Q+r,n=0):e.position==="top"?(A.textAlign="center",v=0,n=w-r,A.textBaseline="bottom"):e.position==="bottom"?(A.textAlign="center",v=0,n=w+E+r,A.textBaseline="top"):(A.textAlign="left",v=i+Q+r,n=0),A.fillText(e.text,v,n)}}renderLineGraph(A,I,C,g){let Q=I.datasets||[];if((!Q||Q.length===0)&&(I.data||I.graphData)&&(Q=[{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}]),!Q||Q.length===0||!Q.some(K=>K.data&&K.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(Q.forEach(K=>{let S=K.data;if(K.isVarEnabled&&K.inputId){let y=this.inputs.get(K.inputId);if(y===void 0){const N=this.inputNameMap.get(K.inputId);N&&N.length>0&&(y=this.inputs.get(N[0]))}y&&Array.isArray(y)&&(S=y)}if(S&&S.length>0){const y=S.filter(N=>typeof N=="number"&&!isNaN(N));y.length>0&&(E=Math.min(E,...y),i=Math.max(i,...y),w=Math.max(w,S.length))}K._resolvedData=S}),w<2)return;const o=i-E,s=C/(w-1),h=K=>{const S=o===0?.5:(K-E)/o;return g/2-S*g},a=K=>K*s-C/2,G=I.axisColor||"#333333";if(I.showXAxis&&(A.beginPath(),A.strokeStyle=I.xAxisColor||G,A.lineWidth=1,A.moveTo(-C/2,g/2),A.lineTo(C/2,g/2),A.stroke()),I.showYAxis&&(A.beginPath(),A.strokeStyle=I.yAxisColor||G,A.lineWidth=1,A.moveTo(-C/2,-g/2),A.lineTo(-C/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 K=0;K<w;K++){const S=a(K);A.fillText(`${K+1}`,S,g/2+5)}}if(I.showYLabels){A.textAlign="right",A.textBaseline="middle";const K=-C/2-5,S=(i+E)/2;A.fillText(i.toFixed(1),K,h(i)),A.fillText(S.toFixed(1),K,h(S)),A.fillText(E.toFixed(1),K,h(E))}const t=10;if(Q.forEach(K=>{const S=K._resolvedData;if(!(!S||S.length<2)){if(K.showArea){if(A.beginPath(),A.moveTo(a(0),g/2),A.lineTo(a(0),h(S[0])),K.smoothing&&S.length>2)for(let N=0;N<S.length-1;N++){const M=S[N===0?N:N-1],e=S[N],Y=S[N+1],j=S[N+1===S.length-1?N+1:N+2];for(let l=1;l<=t;l++){const r=l/t,v=this._catmullRom(M,e,Y,j,r);A.lineTo(a(N+r),h(v))}}else for(let N=1;N<S.length;N++)A.lineTo(a(N),h(S[N]));A.lineTo(a(S.length-1),g/2),A.closePath();const y=A.globalAlpha;A.globalAlpha=y*(I.areaOpacity??.3),A.fillStyle=K.areaColor||"rgba(139, 92, 246, 0.2)",A.fill(),A.globalAlpha=y}if(A.beginPath(),A.strokeStyle=K.lineColor||"#3b82f6",A.lineWidth=K.lineWidth||2,A.lineJoin="round",A.lineCap="round",A.moveTo(a(0),h(S[0])),K.smoothing&&S.length>2)for(let y=0;y<S.length-1;y++){const N=S[y===0?y:y-1],M=S[y],e=S[y+1],Y=S[y+1===S.length-1?y+1:y+2];for(let j=1;j<=t;j++){const l=j/t,r=this._catmullRom(N,M,e,Y,l);A.lineTo(a(y+l),h(r))}}else for(let y=1;y<S.length;y++)A.lineTo(a(y),h(S[y]));A.stroke(),K.showPoints&&S.forEach((y,N)=>{const M=a(N),e=h(y);A.beginPath(),A.arc(M,e,(K.pointSize||6)/2,0,Math.PI*2),A.fillStyle=K.pointFill||"#ffffff",A.fill(),A.strokeStyle=K.pointStrokeColor||K.lineColor||"#3b82f6",A.lineWidth=K.pointStrokeWidth||1,A.stroke()})}}),I.showLegend&&Q.length>0){const K=C/2-10;let S=-g/2+15;const y=I.legendFontSize||10,N=y+5;A.font=`${y}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",Q.forEach(M=>{const Y=M.label||"Series",j=A.measureText(Y).width;A.beginPath(),A.rect(K-j-8-5,S-(8/2+2),8,8),A.fillStyle=M.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(Y,K,S),S+=N})}}_catmullRom(A,I,C,g,Q){const E=(C-A)*.5,i=(g-I)*.5,w=Q*Q,o=Q*w;return(2*I-2*C+E+i)*o+(-3*I+3*C-2*E-i)*w+E*Q+I}normalizeOpacity(A){const I=typeof A=="number"?A:parseFloat(String(A));return isNaN(I)?1:I>1?Math.min(1,I/100):Math.max(0,Math.min(1,I))}createCanvasFill(A,I,C,g){var Q,E,i;if(!I||I.type==="None")return null;if(typeof I=="string")return I;if(I.type==="Solid"&&I.color){const w=I.color,s=(((E=(Q=this.artboard)==null?void 0:Q.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 e,Y;const a=(((Y=(e=this.artboard)==null?void 0:e.tokens)==null?void 0:Y.colors)||{})[o]||o,G=this.normalizeOpacity(I.opacity??100),K=this.normalizeOpacity(s)*G;if(K>=1&&a.startsWith("#"))return a;const S=a.startsWith("#")?a.replace("#",""):"ffffff",y=parseInt(S.substring(0,2),16),N=parseInt(S.substring(2,4),16),M=parseInt(S.substring(4,6),16);return`rgba(${y}, ${N}, ${M}, ${K})`};if(I.type==="LinearGradient"){const o=(K,S,y)=>Array.isArray(K)?K[S]??(S===0?0:1):K&&typeof K=="object"?K[y]??(S===0?0:1):S===0?0:1,s=o(I.start,0,"x")*C-C/2,h=o(I.start,1,"y")*g-g/2,a=o(I.end,0,"x")*C-C/2,G=o(I.end,1,"y")*g-g/2,t=A.createLinearGradient(s,h,a,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,y=w(K.color||"#000000",K.opacity??100);t.addColorStop(Math.max(0,Math.min(1,S)),y)}),I.gradientTransform&&t.setTransform){const[K,S,y,N,M,e]=I.gradientTransform;t.setTransform({a:K,b:S,c:y,d:N,e:M,f:e})}return t}else if(I.type==="RadialGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center,0,"x")*C-C/2,h=o(I.center,1,"y")*g-g/2,a=(I.radius??.5)*Math.max(C,g),G=A.createRadialGradient(s,h,0,s,h,a);if(I.stops.forEach(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}return G}else if(I.type==="AngularGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center||[.5,.5],0,"x")*C-C/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(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}return G}}else if(I.type==="DiamondGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center||[.5,.5],0,"x")*C-C/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.radius??.5)*Math.max(C,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(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}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,t=I.offsetY??0,K=I.rotation??0;s.translateSelf(G,t),s.rotateSelf(K),s.scaleSelf(h,a),o.setTransform(s)}return o}}return I.color||null}drawRoundRect(A,I,C,g,Q,E){if(E===0||E===void 0||E===null){A.rect(I,C,g,Q);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(Q)/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,C,g,Q,[w,o,s,h]);return}A.moveTo(I+w,C),A.lineTo(I+g-o,C),A.arcTo(I+g,C,I+g,C+o,o),A.lineTo(I+g,C+Q-s),A.arcTo(I+g,C+Q,I+g-s,C+Q,s),A.lineTo(I+h,C+Q),A.arcTo(I,C+Q,I,C+Q-h,h),A.lineTo(I,C+w),A.arcTo(I,C,I+w,C,w),A.closePath()}renderListView(A,I){var EA,T,V,IA;const C=this.objectStates.get(I.id)||{},g=C.options||I.options||{},Q=C.width!==void 0?C.width:((EA=I.geometry)==null?void 0:EA.width)||200,E=C.height!==void 0?C.height:((T=I.geometry)==null?void 0:T.height)||300,i=-Q/2,w=-E/2,o=C.corner_radius!==void 0?C.corner_radius:g.corner_radius??0,s=g.orientation||"vertical",h=g.items||[],a=g.itemGap??10,G=g.itemHeight??50,t=g.itemWidth??200,K=g.scrollOffset??0,S=g.padding??0,y=g.glassEffect!==!1,N=g.accentColor||"#3b82f6",M=g.itemTextColor||"#333333",e=g.itemBackgroundColor||"#ffffff",Y=g.hoveredIndex??null,j=g.activeItemIndex??null,l=g.glowIntensity??0,r=g.glowColor||"#3b82f6",v=typeof r=="string"?r:r.color||((IA=(V=r.stops)==null?void 0:V[0])==null?void 0:IA.color)||"#3b82f6",n=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=n,l>0){const x=A.getTransform(),d=Math.sqrt(x.a*x.a+x.b*x.b)||1;A.shadowColor=v,A.shadowBlur=l*2*d,A.shadowOffsetX=0,A.shadowOffsetY=0}if(y){const x=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",d=this.createCanvasFill(A,x,Q,E);A.fillStyle=d||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,Q,E,o),A.fill();const p=A.createLinearGradient(i,w,i+Q,w+E);p.addColorStop(0,"rgba(255, 255, 255, 0.15)"),p.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),p.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=p,this.drawListViewRect(A,i,w,Q,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,w,Q,E,o),A.stroke()}else{const x=g.listBackgroundColor||"transparent",d=this.createCanvasFill(A,x,Q,E);d&&(A.fillStyle=d,this.drawListViewRect(A,i,w,Q,E,o),A.fill());const p=g.borderWidth??0;p>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=p,this.drawListViewRect(A,i,w,Q,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,w,Q,E,o),A.clip();const q=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let P=(s==="vertical"?w:i)+K+q;if(A.textBaseline="middle",h.forEach((x,d)=>{const p=s==="vertical"?Q:t,U=s==="vertical"?G:E,_=s==="vertical"?i:P,f=s==="vertical"?P:w,$=Y===d,hA=j===d;if(hA){const O=this.createCanvasFill(A,N,p,U);A.fillStyle=O||N;const L=A.globalAlpha;A.globalAlpha=L*.8,A.fillRect(_,f,p,U),A.globalAlpha=L}else if($)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(_,f,p,U);else if(e!=="transparent"){const O=this.createCanvasFill(A,e,p,U);A.fillStyle=O||e,A.fillRect(_,f,p,U)}if(hA||$){const O=this.createCanvasFill(A,N,s==="vertical"?3:p,s==="vertical"?U:3);A.fillStyle=O||N,s==="vertical"?A.fillRect(_,f,3,U):A.fillRect(_,f+U-3,p,3)}const SA=hA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":M;A.fillStyle=SA,A.font=hA||$?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const FA=typeof x=="string"?x:(x==null?void 0:x.label)||`Item ${d+1}`,NA=_+(s==="vertical"?16:p/2),u=f+U/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(FA,NA,u),P+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const x=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,d=s==="vertical"?E:Q;if(x>d){const p=d/x,U=d*p,_=-K/x*d,f=g.scrollbarColor||"rgba(255,255,255,0.3)",$=g.scrollbarWidth||4;A.fillStyle=f,s==="vertical"?A.fillRect(i+Q-$-2,w+_,$,U):A.fillRect(i+_,w+E-$-2,U,$)}}A.restore()}updateListViewScrollFromPointer(A){var S,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const I=A.options||{},C=I.orientation||"vertical",g=this._lastPointerPos.x-this._prevPointerPos.x,Q=this._lastPointerPos.y-this._prevPointerPos.y;C==="vertical"?I.scrollOffset=(I.scrollOffset||0)+Q: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:((S=A.geometry)==null?void 0:S.width)||200,a=E.height!==void 0?E.height:((y=A.geometry)==null?void 0:y.height)||300,G=(i.length||0)*(C==="vertical"?o:s)+((i.length||0)-1)*w,K=Math.max(0,G-(C==="vertical"?a:h)+(I.padding*2||0));I.scrollOffset>0&&(I.scrollOffset=0),I.scrollOffset<-K&&(I.scrollOffset=-K)}updateListViewHoverFromPointer(A,I,C){const g=this.getListViewItemIndexAtPointer(A,I,C),Q=A.options||{};Q.hoveredIndex!==g&&(Q.hoveredIndex=g)}getListViewItemIndexAtPointer(A,I,C){var q,P;const g=A.options||{},Q=this.objectStates.get(A.id)||{},E=g.items||[];if(E.length===0)return null;const i=Q.width!==void 0?Q.width:((q=A.geometry)==null?void 0:q.width)||200,w=Q.height!==void 0?Q.height:((P=A.geometry)==null?void 0:P.height)||300,o=g.orientation||"vertical",s=g.itemGap??10,h=g.itemHeight??50,a=g.itemWidth??200,G=g.scrollOffset??0,t=g.padding??0,K=this.getWorldTransform(A.id),S=I-K.x,y=C-K.y,N=-K.rotation*(Math.PI/180),M=Math.cos(N),e=Math.sin(N),Y=S*M-y*e,j=S*e+y*M,l=-i/2,r=-w/2,v=typeof t=="number"?t:o==="vertical"?t[0]:t[3];let n=(o==="vertical"?r:l)+G+v;for(let sA=0;sA<E.length;sA++){const EA=o==="vertical"?i:a,T=o==="vertical"?h:w,V=o==="vertical"?l:n,IA=o==="vertical"?n:r;if(Y>=V&&Y<=V+EA&&j>=IA&&j<=IA+T)return sA;n+=(o==="vertical"?h:a)+s}return null}drawListViewRect(A,I,C,g,Q,E){A.beginPath(),this.drawRoundRect(A,I,C,g,Q,E),A.fill()}solveBehaviors(A){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:I,y:C}=this._lastPointerPos;this.artboard.objects.forEach(g=>{if(!g.behaviors||g.behaviors.length===0)return;const Q=this.objectStates.get(g.id);Q&&g.behaviors.forEach(E=>{var a,G,t,K,S,y,N,M,e,Y,j,l,r,v,n,q,P,sA,EA,T,V,IA,x,d,p,U,_,f,$,hA,SA,FA,NA,u,O,L,R,m,Z,GA,gA,DA,kA,CA;if(!E.enabled)return;const i=E.startTime||0,w=E.endTime||1/0;if(this.currentTime<i||this.currentTime>w)return;const o=Q.x-I,s=Q.y-C,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===W.Proximity){const F=((a=E.settings)==null?void 0:a.radius)||300,b=((G=E.settings)==null?void 0:G.falloff)||"smooth";let H=0;h<F&&(b==="linear"?H=1-h/F:H=Math.pow(1-h/F,2)),H>0&&E.sensors.forEach(iA=>{this.applyBehaviorSensor(Q,iA,H,A,E.settings)})}else if(E.type===W.Magnetic){const F=((t=E.settings)==null?void 0:t.radius)||400,b=((K=E.settings)==null?void 0:K.strength)||.5;if(h<F&&h>5){const H=1-h/F,iA=o*H*b,UA=s*H*b;Q.x-=iA*A*10,Q.y-=UA*A*10}}else if(E.type===W.Repel){const F=((S=E.settings)==null?void 0:S.radius)||300,b=((y=E.settings)==null?void 0:y.strength)||1;if(h<F){const H=Math.pow(1-h/F,2);Q.x+=o/(h||1)*H*60*b*A*5,Q.y+=s/(h||1)*H*60*b*A*5}}else if(E.type===W.Orbit){const F=((N=E.settings)==null?void 0:N.speed)||1,b=((M=E.settings)==null?void 0:M.radius)||30,H=this.currentTime*F*Math.PI*2;Q.x+=Math.cos(H)*b*A*5,Q.y+=Math.sin(H)*b*A*5,Q.rotation+=2*A*5}else if(E.type===W.Vortex){const F=((e=E.settings)==null?void 0:e.radius)||400,b=((Y=E.settings)==null?void 0:Y.speed)||2,H=((j=E.settings)==null?void 0:j.strength)||1;if(h<F){const iA=Math.pow(1-h/F,1.5),UA=this.currentTime*b*Math.PI*2,BA=Math.cos(UA)*30-o*.4,z=Math.sin(UA)*30-s*.4;Q.x+=BA*iA*H*A*5,Q.y+=z*iA*H*A*5,Q.rotation+=5*iA*H*A*5,Q.scale_x*=1-iA*.1*H*A,Q.scale_y*=1-iA*.1*H*A}}else if(E.type===W.Fluid){const F=((l=E.settings)==null?void 0:l.radius)||300,b=((r=E.settings)==null?void 0:r.strength)||1;if(h<F){const H=Math.pow(1-h/F,1.2),iA=o/(h||1)*H*1.2*b,UA=s/(h||1)*H*1.2*b;Q.x+=iA*10*A*5,Q.y+=UA*10*A*5,Q.scale_x*=1+H*.3*b*A,Q.scale_y*=1+H*.3*b*A}}else if(E.type===W.Elastic){const F=((v=E.settings)==null?void 0:v.radius)||300,b=((n=E.settings)==null?void 0:n.strength)||1;if(h<F){const H=1-h/F;Q.scale_x*=1+H*.4*b*A,Q.scale_y*=1+H*.4*b*A}}else if(E.type===W.Holographic){const F=Q.x-this.canvasWidth/2,b=Q.y-this.canvasHeight/2,H=((q=E.settings)==null?void 0:q.factor)||25;if(Q.x-=F/1e3*H*A*5,Q.y-=b/1e3*H*A*5,Q.style){const iA=1-Math.min(1,h/400);Q.style.exposure=(Q.style.exposure||1)+iA*.5*A}}else if(E.type===W.Sticky){const F=((P=E.settings)==null?void 0:P.radius)||80,b=((sA=E.settings)==null?void 0:sA.strength)||1;if(h<F){const H=Math.pow(1-h/F,2);Q.x-=o*H*b*A*10,Q.y-=s*H*b*A*10,Q.scale_x*=1-H*.1*b*A,Q.scale_y*=1-H*.1*b*A}}else if(E.type===W.Dilation){const F=((EA=E.settings)==null?void 0:EA.size)||120,b=((T=E.settings)==null?void 0:T.strength)||1;if(h<F){const H=1-h/F;Q.scale_x*=1+H*.5*b*A,Q.scale_y*=1+H*.5*b*A}}else if(E.type===W.Parallax){const F=((V=E.settings)==null?void 0:V.factor)||.05,b=this.canvasHeight/2,H=(this._lastPointerPos.y-b)*F;Q.y+=H*A*10}else if(E.type===W.Noise||E.type===W.Float){const F=(((IA=E.settings)==null?void 0:IA.frequency)||((x=E.settings)==null?void 0:x.speed)||1)*.002,b=(((d=E.settings)==null?void 0:d.amplitude)||((p=E.settings)==null?void 0:p.range)||50)*(((U=E.settings)==null?void 0:U.strength)||1),H=Date.now();Q.x+=Math.sin(H*F)*b*A,Q.y+=Math.cos(H*F*.8)*b*A,Q.rotation+=Math.sin(H*F*.5)*5*A}else if(E.type===W.Pulse){const F=(((_=E.settings)==null?void 0:_.speed)||1)*.005,b=(((f=E.settings)==null?void 0:f.scale)||1.2)-1,H=Math.sin(Date.now()*F),iA=(($=E.settings)==null?void 0:$.strength)||1;Q.scale_x*=1+H*b*iA*A,Q.scale_y*=1+H*b*iA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,H)*.1*iA*A)}else if(E.type===W.Draggable){const F=((hA=E.settings)==null?void 0:hA.radius)||150,b=this.draggingBehaviors.has(g.id);if(h<F||b){const H=((SA=E.settings)==null?void 0:SA.strength)||1,iA=b?1:Math.max(0,1-h/F);this.applyBehaviorSensor(Q,uA.PositionX,iA*H,A,E.settings),this.applyBehaviorSensor(Q,uA.PositionY,iA*H,A,E.settings)}}else if(E.type===W.Scroll){const F=((FA=E.settings)==null?void 0:FA.axis)||"vertical",b=((NA=E.settings)==null?void 0:NA.factor)||.5,H=((u=E.settings)==null?void 0:u.strength)||1;(F==="vertical"||F==="both")&&(Q.y+=this.scrollOffset.y*b*H*A),(F==="horizontal"||F==="both")&&(Q.x+=this.scrollOffset.x*b*H*A)}else if(E.type===W.LookAt){const F=((O=E.settings)==null?void 0:O.factor)||1,b=((L=E.settings)==null?void 0:L.strength)||1,H=Math.atan2(-s,-o)*(180/Math.PI),iA=Q.rotation,UA=(H-iA+180)%360-180;Q.rotation+=UA*F*b*A*10}else if(E.type===W.Glint||E.type===W.Scan){const F=(((R=E.settings)==null?void 0:R.speed)||1)*.004,b=((m=E.settings)==null?void 0:m.strength)||1,H=(Math.sin(Date.now()*F)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+H*b*A*5),Q.x+=(H-.5)*20*b*A}else if(E.type===W.Ratchet){const F=((Z=E.settings)==null?void 0:Z.steps)||12,b=(((GA=E.settings)==null?void 0:GA.speed)||1)*30,H=Math.floor(Q.rotation/(360/F))*(360/F);Q.rotation=this.lerp(Q.rotation,H+b*A,.1)}else if(E.type===W.Jitter&&h<300){const F=((gA=E.settings)==null?void 0:gA.strength)||1,b=(((DA=E.settings)==null?void 0:DA.intensity)||5)*F;Q.x+=(Math.random()-.5)*b*A*60,Q.y+=(Math.random()-.5)*b*A*60,Q.rotation+=(Math.random()-.5)*b*A*120}else if(E.type===W.Follower){const F=(kA=E.settings)==null?void 0:kA.targetId;if(F){const b=this.objectStates.get(F);if(b){const H=((CA=E.settings)==null?void 0:CA.stiffness)||.1,iA=b.x-Q.x,UA=b.y-Q.y;Q.x+=iA*H*A*60,Q.y+=UA*H*A*60}}}else E.type===W.Wrap&&(Q.x<0?Q.x=this.canvasWidth:Q.x>this.canvasWidth&&(Q.x=0),Q.y<0?Q.y=this.canvasHeight:Q.y>this.canvasHeight&&(Q.y=0))})})}applyBehaviorSensor(A,I,C,g,Q){const E=(Q==null?void 0:Q.intensity)||(Q==null?void 0:Q.strength)||1,i=C*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,C){return A*(1-C)+I*C}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 C={...A};for(const g in I)Object.prototype.hasOwnProperty.call(I,g)&&(I[g]&&typeof I[g]=="object"&&!Array.isArray(I[g])?C[g]=this.deepMerge(A[g],I[g]):C[g]=I[g]);return C}}const $E=JA.forwardRef(({artboard:B,src:A,className:I,style:C,autoPlay:g=!0,fit:Q="Contain",alignment:E="Center",onReady:i,onTrigger:w,onInputUpdate:o,onComponentChange:s,onToggle:h,onInputChange:a,onInputFocus:G,onInputBlur:t,onLog:K},S)=>{const y=JA.useRef(null),N=JA.useRef(new xQ),M=JA.useRef(),e=JA.useRef(0),Y=JA.useRef(null);JA.useImperativeHandle(S,()=>y.current),JA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),N.current.setLayout(Q,E)},[Q,E]),JA.useEffect(()=>{w&&N.current.setTriggerCallback(w)},[w]),JA.useEffect(()=>{o&&N.current.setInputUpdateCallback(o)},[o]),JA.useEffect(()=>{s&&N.current.setComponentChangeCallback(s)},[s]),JA.useEffect(()=>{h&&N.current.setToggleCallback(h)},[h]),JA.useEffect(()=>{a&&N.current.setInputChangeCallback(a)},[a]),JA.useEffect(()=>{G&&N.current.setInputFocusCallback(G)},[G]),JA.useEffect(()=>{t&&N.current.setInputBlurCallback(t)},[t]),JA.useEffect(()=>{(async()=>{const r=N.current;let v=B;if(!v&&A)try{v=await(await fetch(A)).json()}catch(n){console.error("Failed to load ExodeUI animation:",n);return}if(v){const n=v.id||v.name||"default";Y.current!==n&&(r.load(v),Y.current=n,e.current=0),i&&i(r)}})()},[B,A]),JA.useEffect(()=>{const l=N.current,r=y.current;if(!r)return;const v=r.getContext("2d");if(!v)return;v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",K&&l.setOnLogCallback(K);const n=P=>{e.current||(e.current=P);const sA=(P-e.current)/1e3;e.current=P,g&&l.advance(sA);const EA=window.devicePixelRatio||1,T=r.getBoundingClientRect(),V=Math.floor(T.width*EA),IA=Math.floor(T.height*EA);(r.width!==V||r.height!==IA)&&(r.width=V,r.height=IA),l.render(v,V,IA),M.current=requestAnimationFrame(n)};M.current=requestAnimationFrame(n);const q=()=>{l.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",q,{passive:!0}),()=>{M.current&&cancelAnimationFrame(M.current),window.removeEventListener("scroll",q)}},[g]);const j=(l,r)=>{const v=l.currentTarget.getBoundingClientRect(),n=l.clientX-v.left,q=l.clientY-v.top,P=v.width,sA=v.height;N.current.handlePointerInput(r,n,q,P,sA)};return ZA.jsx("canvas",{ref:y,style:{width:"100%",height:"100%",outline:"none",...C},className:I,tabIndex:0,onPointerDown:l=>{var r;j(l,"down"),(r=y.current)==null||r.focus()},onPointerUp:l=>j(l,"up"),onPointerMove:l=>j(l,"move"),onPointerLeave:l=>j(l,"blur"),onClick:l=>j(l,"click"),onKeyDown:l=>{l.key==="Backspace"||l.key==="Enter"||l.key,N.current.handleKeyDown(l.nativeEvent)}})});function Ai(){const[B,A]=JA.useState(null),I=JA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=JA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=JA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=JA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=JA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=JA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=JA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=JA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=JA.useCallback((h,a)=>{B==null||B.updateGraphData(h,a)},[B]);return{setEngine:A,engine:B,setInputBool:I,setInputNumber:C,fireTrigger:g,setInputText:Q,setInputNumberArray:E,setInputStringArray:i,updateConstraint:o,updateGraphData:s,updateObjectOptions:w}}const Ii="6.0.22";HA.BehaviorSensor=uA,HA.BehaviorType=W,HA.ConditionOp=tC,HA.ExodeUICanvas=$E,HA.ExodeUIEngine=xQ,HA.LogicOp=NI,HA.VERSION=Ii,HA.useExodeUI=Ai,Object.defineProperty(HA,Symbol.toStringTag,{value:"Module"})});
22
+ `);let u=-E/2+p;const O=IA*1.2;let L=0;NA.forEach((R,m)=>{const Z=R.split(" ");let GA="";for(let gA=0;gA<Z.length;gA++){const DA=GA+Z[gA]+" ";A.measureText(DA).width>$&&gA>0?(A.fillText(GA,f,u),GA=Z[gA]+" ",u+=O):GA=DA}A.fillText(GA,f,u),L=A.measureText(GA).width,m<NA.length-1&&(u+=O,L=0)}),i&&!EA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(f+L,u,1.5,IA)}else{const u=A.measureText(hA).width;let O=0;if(u>$&&(O=u-$),A.fillText(hA,f-O,0),i&&!EA&&Math.floor(performance.now()/500)%2===0){const R=f+u-O;A.fillRect(R,-(IA/2),1.5,IA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",u=h.fontSize||12,O=h.color||"rgba(156, 163, 175, 1)",L=h.offset??8;A.font=`600 ${u}px "${x}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="bottom";const R=-(Q/2),m=-(E/2)-L;A.fillText(NA,R,m)}if(a.visible===!0){const NA=a.text||"Helper text",u=a.fontSize||11,O=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",L=a.offset??6;A.font=`400 ${u}px "${x}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="top";const R=-(Q/2),m=E/2+L;A.fillText(NA,R,m)}}renderSlider(A,I){const C=this.objectStates.get(I.id),g=(C==null?void 0:C.geometry)||I.geometry,Q=(C==null?void 0:C.options)||I.options||{},E=g.width||200,i=Q.value??50,w=Q.min??0,s=(Q.max??100)-w,h=s===0?0:(i-w)/s,a=Q.trackHeight||4,G=Q.trackRoundedness??2,t=Q.trackShape??"Rectangle",K=Q.trackPath||"",S=Q.activeColor||"#3b82f6",y=Q.inactiveColor||"#374151",N=Q.thumbShape||"Ellipse",M=Q.thumbWidth??16,e=Q.thumbHeight??16,Y=Q.thumbRoundedness??0,j=Q.thumbColor||"#ffffff",l=Q.thumbPath||"",r=Q.thumbIcon||"",v=Q.showValueTooltip??!1,n=Q.tooltipBgColor||"#333333",q=Q.tooltipColor||"#ffffff",P=Q.tooltipOffsetX??0,sA=Q.tooltipOffsetY??-25,EA=(f,$,hA,SA,FA,NA,u)=>{if((f==="Custom"||f==="Icon")&&u)try{const O=new Path2D(u);if(A.save(),A.translate($,hA),f==="Icon"){const L=Math.min(SA,FA)/24;A.scale(L,L),A.translate(-12,-12)}A.fill(O),A.restore();return}catch(O){console.error("Error drawing slider shape in engine:",O)}if(A.beginPath(),f==="Ellipse")A.ellipse($,hA,SA/2,FA/2,0,0,Math.PI*2);else if(f==="Rectangle")this.drawRoundRect(A,$-SA/2,hA-FA/2,SA,FA,NA);else if(f==="Triangle")A.moveTo($,hA-FA/2),A.lineTo($+SA/2,hA+FA/2),A.lineTo($-SA/2,hA+FA/2),A.closePath();else if(f==="Diamond")A.moveTo($,hA-FA/2),A.lineTo($+SA/2,hA),A.lineTo($,hA+FA/2),A.lineTo($-SA/2,hA),A.closePath();else if(f==="Polygon"){const O=I.geometry.sides||3,L=I.geometry.radius||Math.min(SA,FA)/2;for(let R=0;R<O;R++){const m=R*2*Math.PI/O-Math.PI/2,Z=$+L*Math.cos(m),GA=hA+L*Math.sin(m);R===0?A.moveTo(Z,GA):A.lineTo(Z,GA)}A.closePath()}else if(f==="Star"){const L=Math.min(SA,FA)/2,R=L/2;for(let m=0;m<5*2;m++){const Z=m%2===0?L:R,GA=m*Math.PI/5-Math.PI/2;A.lineTo($+Z*Math.cos(GA),hA+Z*Math.sin(GA))}A.closePath()}else f==="Line"&&(A.moveTo($-SA/2,hA),A.lineTo($+SA/2,hA));A.fill()};A.fillStyle=y,t==="Line"?(A.strokeStyle=y,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):EA(t,0,0,E,a,G,K);const T=E-M,V=-E/2+M/2+h*T,IA=V- -E/2;IA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(V,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,IA,a,G),A.fill())),A.save(),A.translate(V,0);const x=A.getTransform(),d=Math.sqrt(x.a*x.a+x.b*x.b)||1;if(A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4*d,A.shadowOffsetY=1*d,A.fillStyle=j,EA(N,0,0,M,e,Y,N==="Icon"?r:l),A.restore(),v){A.save(),A.translate(V+P,sA);const f=Math.round(i).toString();A.font="10px Inter, sans-serif";const $=A.measureText(f),hA=6,SA=4,FA=$.width+hA*2,NA=14+SA;A.beginPath(),this.drawRoundRect(A,-FA/2,-NA/2,FA,NA,4),A.fillStyle=n,A.fill(),A.fillStyle=q,A.textAlign="center",A.textBaseline="middle",A.fillText(f,0,0),A.restore()}const p=Q.label||{},U=Q.helperText||{},_=Q.fontFamily||"Inter";if(p.visible!==!1){const f=p.text||"Label",$=p.fontSize||12,hA=p.color||"rgba(156, 163, 175, 1)",SA=p.offset??8;A.font=`600 ${$}px "${_}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="bottom";const FA=-(E/2),NA=-(a/2)-SA;A.fillText(f,FA,NA)}if(U.visible===!0){const f=U.text||"Helper text",$=U.fontSize||11,hA=U.color||"rgba(156, 163, 175, 1)",SA=U.offset??6;A.font=`400 ${$}px "${_}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="top";const FA=-(E/2),NA=a/2+SA;A.fillText(f,FA,NA)}}renderDropdown(A,I){var sA;const C=this.objectStates.get(I.id);if(!C)return;const g=C.options||I.options||{},Q=I.geometry.width||160,E=I.geometry.height||40,i=-Q/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,t=g.borderColor,K=g.color||"#333333";s?(G=g.disabledBackgroundColor||"#f3f4f6",t=g.disabledBorderColor||"#e5e7eb",K=g.disabledColor||"#9ca3af"):a?(G=g.activeBackgroundColor||G,t=g.activeBorderColor||t,K=g.activeColor||K):h&&(G=g.hoverBackgroundColor||G,t=g.hoverBorderColor||t,K=g.hoverColor||K),G||(G="#ffffff"),t||(t="#e5e7eb");const S=A.globalAlpha;A.globalAlpha=S*(g.opacity??1),this.drawRoundRect(A,i,w,Q,E,o),A.fillStyle=this.createCanvasFill(A,typeof G=="string"?{type:"Solid",color:G}:G,Q,E)||"#ffffff",A.fill();const y=g.borderWidth??1;y>0&&(A.strokeStyle=this.createCanvasFill(A,typeof t=="string"?{type:"Solid",color:t}:t,Q,E)||"#e5e7eb",A.lineWidth=y,A.stroke());const N=12,M=g.chevronType||"chevron",e=g.chevronSize||16,Y=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(M!=="none"){const EA=i+Q-N-e/2;A.save(),A.translate(EA,0);const T=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(T*Math.PI/180),A.strokeStyle=Y,A.fillStyle=Y,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",M==="chevron")A.beginPath(),A.moveTo(-e/2,-e*.2),A.lineTo(0,e*.2),A.lineTo(e/2,-e*.2),A.stroke();else if(M==="custom"||M==="path"){const V=a&&g.openIconPath||g.closedIconPath;if(V){const IA=new Path2D(V);A.save();const x=e/24;A.scale(x,x),A.translate(-12,-12),A.fill(IA),A.restore()}}A.restore()}const j=g.selectedOption||g.placeholder||"Select...",l=g.fontSize||14,r=g.fontWeight||400,v=g.fontFamily||"Inter, sans-serif";A.font=`${r} ${l}px ${v}`;const n=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":K;A.fillStyle=this.createCanvasFill(A,typeof n=="string"?{type:"Solid",color:n}:n,Q,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const q=M==="none"?0:e+8,P=Q-N*2-q;if(A.save(),A.beginPath(),A.rect(i+N,w,P,E),A.clip(),A.fillText(j,i+N,0),A.restore(),a&&!s){const EA=w+E+4,T=g.optionsList||[],V=g.itemHeight||32,IA=g.listPadding??4,x=T.length*V+IA*2,d=g.listCornerRadius??o;A.save();const p=g.listShadow||{},U=A.getTransform(),_=Math.sqrt(U.a*U.a+U.b*U.b)||1;A.shadowColor=typeof p.color=="string"?p.color:((sA=p.color)==null?void 0:sA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=(p.blur??12)*_,A.shadowOffsetY=(p.offsetY??6)*_,A.shadowOffsetX=(p.offsetX??0)*_,A.beginPath(),this.drawRoundRect(A,i,EA,Q,x,d),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,x)||"#ffffff",A.fill();const f=g.listBorderWidth??1;f>0&&(A.shadowColor="transparent",A.strokeStyle=this.createCanvasFill(A,typeof g.listBorderColor=="string"?{type:"Solid",color:g.listBorderColor}:g.listBorderColor||{type:"Solid",color:t},Q,x)||"#e5e7eb",A.lineWidth=f,A.stroke()),A.restore();const $=g.itemFontSize||l,hA=g.itemFontFamily||v;A.font=`${r} ${$}px ${hA}`,T.forEach((SA,FA)=>{const NA=EA+IA+FA*V;if(SA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,V)||"#f3f4f6",A.fillRect(i+f,NA,Q-f*2,V),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const O=this._lastPointerPos.y-(EA+IA),L=Math.floor(O/V);FA===L&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,V)||"#f9fafb",A.fillRect(i+f,NA,Q-f*2,V),A.fillStyle=g.itemHoverColor||K)}A.fillText(SA,i+N,NA+V/2)})}A.globalAlpha=S}renderButton(A,I){var M,e,Y,j;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((M=I.geometry)==null?void 0:M.width)||120,E=((e=I.geometry)==null?void 0:e.height)||40,i=-Q/2,w=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((Y=g.hoverStyle)==null?void 0:Y.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},t=o?((j=g.hoverStyle)==null?void 0:j.textColor)||G.color||"#ffffff":G.color||"#ffffff",K=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,w,Q,E,s):h==="Ellipse"||h==="Circle"?A.ellipse(0,0,Q/2,E/2,0,0,Math.PI*2):h==="Pill"&&this.drawRoundRect(A,i,w,Q,E,E/2),A.fillStyle=a,A.fill();const S=G.fontSize||14,y=G.fontFamily||"Inter";A.font=`${G.fontWeight||400} ${S}px "${y}", sans-serif`,A.fillStyle=t,A.textAlign="center",A.textBaseline="middle";let N=0;if(K.enabled&&K.svgPath){const l=K.size||16,r=K.gap||8,v=K.position==="left"?-(A.measureText(G.text||"").width/2+l/2+r/2):A.measureText(G.text||"").width/2+l/2+r/2;A.save(),A.translate(v,0);const n=new Path2D(K.svgPath),q=l/24;A.scale(q,q),A.translate(-12,-12),A.fillStyle=K.color||t,A.fill(n),A.restore(),N=K.position==="left"?l/2+r/2:-(l/2+r/2)}A.fillText(G.text||"Button",N,0),A.restore()}renderToggleButton(A,I){var S,y;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=g.checked??!1,E=((S=I.geometry)==null?void 0:S.width)||120,i=((y=I.geometry)==null?void 0:y.height)||40,w=-E/2,o=-i/2,s=g.corner_radius??8,h=g.label||{},a=Q?g.activeColor||"#3b82f6":g.inactiveColor||"#374151",G=Q?g.activeTextColor||"#ffffff":g.inactiveTextColor||"#9ca3af";A.save(),A.beginPath(),this.drawRoundRect(A,w,o,E,i,s),A.fillStyle=a,A.fill();const t=h.fontSize||14,K=h.fontFamily||"Inter";A.font=`${h.fontWeight||600} ${t}px "${K}", sans-serif`,A.fillStyle=G,A.textAlign="center",A.textBaseline="middle",A.fillText(h.text||"Toggle",0,0),A.restore()}renderToggle(A,I){var N,M;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((N=I.geometry)==null?void 0:N.width)||52,E=((M=I.geometry)==null?void 0:M.height)||30,i=-Q/2,w=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,w,Q,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,t=i+h,K=i+Q-h-a,S=o?K:t,y=w+h;if(A.beginPath(),A.arc(S+G,y+G,G,0,Math.PI*2),A.fillStyle=g.knobColor||"#ffffff",A.fill(),g.disabled&&(A.globalAlpha*=2),g.label&&g.label.text){const e=g.label,Y=e.fontSize||14,j=e.fontWeight||400,l=e.fontFamily||"Inter";A.font=`${j} ${Y}px "${l}", sans-serif`,A.fillStyle=e.color||"#f3f4f6",A.textBaseline="middle";const r=e.gap||10;let v=0,n=0;e.position==="left"?(A.textAlign="right",v=i-r,n=0):e.position==="right"?(A.textAlign="left",v=i+Q+r,n=0):e.position==="top"?(A.textAlign="center",v=0,n=w-r,A.textBaseline="bottom"):e.position==="bottom"?(A.textAlign="center",v=0,n=w+E+r,A.textBaseline="top"):(A.textAlign="left",v=i+Q+r,n=0),A.fillText(e.text,v,n)}}renderLineGraph(A,I,C,g){let Q=I.datasets||[];if((!Q||Q.length===0)&&(I.data||I.graphData)&&(Q=[{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}]),!Q||Q.length===0||!Q.some(K=>K.data&&K.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(Q.forEach(K=>{let S=K.data;if(K.isVarEnabled&&K.inputId){let y=this.inputs.get(K.inputId);if(y===void 0){const N=this.inputNameMap.get(K.inputId);N&&N.length>0&&(y=this.inputs.get(N[0]))}y&&Array.isArray(y)&&(S=y)}if(S&&S.length>0){const y=S.filter(N=>typeof N=="number"&&!isNaN(N));y.length>0&&(E=Math.min(E,...y),i=Math.max(i,...y),w=Math.max(w,S.length))}K._resolvedData=S}),w<2)return;const o=i-E,s=C/(w-1),h=K=>{const S=o===0?.5:(K-E)/o;return g/2-S*g},a=K=>K*s-C/2,G=I.axisColor||"#333333";if(I.showXAxis&&(A.beginPath(),A.strokeStyle=I.xAxisColor||G,A.lineWidth=1,A.moveTo(-C/2,g/2),A.lineTo(C/2,g/2),A.stroke()),I.showYAxis&&(A.beginPath(),A.strokeStyle=I.yAxisColor||G,A.lineWidth=1,A.moveTo(-C/2,-g/2),A.lineTo(-C/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 K=0;K<w;K++){const S=a(K);A.fillText(`${K+1}`,S,g/2+5)}}if(I.showYLabels){A.textAlign="right",A.textBaseline="middle";const K=-C/2-5,S=(i+E)/2;A.fillText(i.toFixed(1),K,h(i)),A.fillText(S.toFixed(1),K,h(S)),A.fillText(E.toFixed(1),K,h(E))}const t=10;if(Q.forEach(K=>{const S=K._resolvedData;if(!(!S||S.length<2)){if(K.showArea){if(A.beginPath(),A.moveTo(a(0),g/2),A.lineTo(a(0),h(S[0])),K.smoothing&&S.length>2)for(let N=0;N<S.length-1;N++){const M=S[N===0?N:N-1],e=S[N],Y=S[N+1],j=S[N+1===S.length-1?N+1:N+2];for(let l=1;l<=t;l++){const r=l/t,v=this._catmullRom(M,e,Y,j,r);A.lineTo(a(N+r),h(v))}}else for(let N=1;N<S.length;N++)A.lineTo(a(N),h(S[N]));A.lineTo(a(S.length-1),g/2),A.closePath();const y=A.globalAlpha;A.globalAlpha=y*(I.areaOpacity??.3),A.fillStyle=K.areaColor||"rgba(139, 92, 246, 0.2)",A.fill(),A.globalAlpha=y}if(A.beginPath(),A.strokeStyle=K.lineColor||"#3b82f6",A.lineWidth=K.lineWidth||2,A.lineJoin="round",A.lineCap="round",A.moveTo(a(0),h(S[0])),K.smoothing&&S.length>2)for(let y=0;y<S.length-1;y++){const N=S[y===0?y:y-1],M=S[y],e=S[y+1],Y=S[y+1===S.length-1?y+1:y+2];for(let j=1;j<=t;j++){const l=j/t,r=this._catmullRom(N,M,e,Y,l);A.lineTo(a(y+l),h(r))}}else for(let y=1;y<S.length;y++)A.lineTo(a(y),h(S[y]));A.stroke(),K.showPoints&&S.forEach((y,N)=>{const M=a(N),e=h(y);A.beginPath(),A.arc(M,e,(K.pointSize||6)/2,0,Math.PI*2),A.fillStyle=K.pointFill||"#ffffff",A.fill(),A.strokeStyle=K.pointStrokeColor||K.lineColor||"#3b82f6",A.lineWidth=K.pointStrokeWidth||1,A.stroke()})}}),I.showLegend&&Q.length>0){const K=C/2-10;let S=-g/2+15;const y=I.legendFontSize||10,N=y+5;A.font=`${y}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",Q.forEach(M=>{const Y=M.label||"Series",j=A.measureText(Y).width;A.beginPath(),A.rect(K-j-8-5,S-(8/2+2),8,8),A.fillStyle=M.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(Y,K,S),S+=N})}}_catmullRom(A,I,C,g,Q){const E=(C-A)*.5,i=(g-I)*.5,w=Q*Q,o=Q*w;return(2*I-2*C+E+i)*o+(-3*I+3*C-2*E-i)*w+E*Q+I}normalizeOpacity(A){const I=typeof A=="number"?A:parseFloat(String(A));return isNaN(I)?1:I>1?Math.min(1,I/100):Math.max(0,Math.min(1,I))}createCanvasFill(A,I,C,g){var Q,E,i;if(!I||I.type==="None")return null;if(typeof I=="string")return I;if(I.type==="Solid"&&I.color){const w=I.color,s=(((E=(Q=this.artboard)==null?void 0:Q.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 e,Y;const a=(((Y=(e=this.artboard)==null?void 0:e.tokens)==null?void 0:Y.colors)||{})[o]||o,G=this.normalizeOpacity(I.opacity??100),K=this.normalizeOpacity(s)*G;if(K>=1&&a.startsWith("#"))return a;const S=a.startsWith("#")?a.replace("#",""):"ffffff",y=parseInt(S.substring(0,2),16),N=parseInt(S.substring(2,4),16),M=parseInt(S.substring(4,6),16);return`rgba(${y}, ${N}, ${M}, ${K})`};if(I.type==="LinearGradient"){const o=(K,S,y)=>Array.isArray(K)?K[S]??(S===0?0:1):K&&typeof K=="object"?K[y]??(S===0?0:1):S===0?0:1,s=o(I.start,0,"x")*C-C/2,h=o(I.start,1,"y")*g-g/2,a=o(I.end,0,"x")*C-C/2,G=o(I.end,1,"y")*g-g/2,t=A.createLinearGradient(s,h,a,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,y=w(K.color||"#000000",K.opacity??100);t.addColorStop(Math.max(0,Math.min(1,S)),y)}),I.gradientTransform&&t.setTransform){const[K,S,y,N,M,e]=I.gradientTransform;t.setTransform({a:K,b:S,c:y,d:N,e:M,f:e})}return t}else if(I.type==="RadialGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center,0,"x")*C-C/2,h=o(I.center,1,"y")*g-g/2,a=(I.radius??.5)*Math.max(C,g),G=A.createRadialGradient(s,h,0,s,h,a);if(I.stops.forEach(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}return G}else if(I.type==="AngularGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center||[.5,.5],0,"x")*C-C/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(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}return G}}else if(I.type==="DiamondGradient"){const o=(t,K,S)=>Array.isArray(t)?t[K]??.5:t&&typeof t=="object"?t[S]??.5:.5,s=o(I.center||[.5,.5],0,"x")*C-C/2,h=o(I.center||[.5,.5],1,"y")*g-g/2,a=(I.radius??.5)*Math.max(C,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(t=>{const K=t.offset!==void 0?t.offset:t.pos!==void 0?t.pos:t.position!==void 0?t.position:0,S=w(t.color||"#000000",t.opacity??100);G.addColorStop(Math.max(0,Math.min(1,K)),S)}),I.gradientTransform&&G.setTransform){const[t,K,S,y,N,M]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:N,f:M})}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,t=I.offsetY??0,K=I.rotation??0;s.translateSelf(G,t),s.rotateSelf(K),s.scaleSelf(h,a),o.setTransform(s)}return o}}return I.color||null}drawRoundRect(A,I,C,g,Q,E){if(E===0||E===void 0||E===null){A.rect(I,C,g,Q);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(Q)/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,C,g,Q,[w,o,s,h]);return}A.moveTo(I+w,C),A.lineTo(I+g-o,C),A.arcTo(I+g,C,I+g,C+o,o),A.lineTo(I+g,C+Q-s),A.arcTo(I+g,C+Q,I+g-s,C+Q,s),A.lineTo(I+h,C+Q),A.arcTo(I,C+Q,I,C+Q-h,h),A.lineTo(I,C+w),A.arcTo(I,C,I+w,C,w),A.closePath()}renderListView(A,I){var EA,T,V,IA;const C=this.objectStates.get(I.id)||{},g=C.options||I.options||{},Q=C.width!==void 0?C.width:((EA=I.geometry)==null?void 0:EA.width)||200,E=C.height!==void 0?C.height:((T=I.geometry)==null?void 0:T.height)||300,i=-Q/2,w=-E/2,o=C.corner_radius!==void 0?C.corner_radius:g.corner_radius??0,s=g.orientation||"vertical",h=g.items||[],a=g.itemGap??10,G=g.itemHeight??50,t=g.itemWidth??200,K=g.scrollOffset??0,S=g.padding??0,y=g.glassEffect!==!1,N=g.accentColor||"#3b82f6",M=g.itemTextColor||"#333333",e=g.itemBackgroundColor||"#ffffff",Y=g.hoveredIndex??null,j=g.activeItemIndex??null,l=g.glowIntensity??0,r=g.glowColor||"#3b82f6",v=typeof r=="string"?r:r.color||((IA=(V=r.stops)==null?void 0:V[0])==null?void 0:IA.color)||"#3b82f6",n=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=n,l>0){const x=A.getTransform(),d=Math.sqrt(x.a*x.a+x.b*x.b)||1;A.shadowColor=v,A.shadowBlur=l*2*d,A.shadowOffsetX=0,A.shadowOffsetY=0}if(y){const x=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",d=this.createCanvasFill(A,x,Q,E);A.fillStyle=d||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,Q,E,o),A.fill();const p=A.createLinearGradient(i,w,i+Q,w+E);p.addColorStop(0,"rgba(255, 255, 255, 0.15)"),p.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),p.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=p,this.drawListViewRect(A,i,w,Q,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,w,Q,E,o),A.stroke()}else{const x=g.listBackgroundColor||"transparent",d=this.createCanvasFill(A,x,Q,E);d&&(A.fillStyle=d,this.drawListViewRect(A,i,w,Q,E,o),A.fill());const p=g.borderWidth??0;p>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=p,this.drawListViewRect(A,i,w,Q,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,w,Q,E,o),A.clip();const q=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let P=(s==="vertical"?w:i)+K+q;if(A.textBaseline="middle",h.forEach((x,d)=>{const p=s==="vertical"?Q:t,U=s==="vertical"?G:E,_=s==="vertical"?i:P,f=s==="vertical"?P:w,$=Y===d,hA=j===d;if(hA){const O=this.createCanvasFill(A,N,p,U);A.fillStyle=O||N;const L=A.globalAlpha;A.globalAlpha=L*.8,A.fillRect(_,f,p,U),A.globalAlpha=L}else if($)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(_,f,p,U);else if(e!=="transparent"){const O=this.createCanvasFill(A,e,p,U);A.fillStyle=O||e,A.fillRect(_,f,p,U)}if(hA||$){const O=this.createCanvasFill(A,N,s==="vertical"?3:p,s==="vertical"?U:3);A.fillStyle=O||N,s==="vertical"?A.fillRect(_,f,3,U):A.fillRect(_,f+U-3,p,3)}const SA=hA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":M;A.fillStyle=SA,A.font=hA||$?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const FA=typeof x=="string"?x:(x==null?void 0:x.label)||`Item ${d+1}`,NA=_+(s==="vertical"?16:p/2),u=f+U/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(FA,NA,u),P+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const x=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,d=s==="vertical"?E:Q;if(x>d){const p=d/x,U=d*p,_=-K/x*d,f=g.scrollbarColor||"rgba(255,255,255,0.3)",$=g.scrollbarWidth||4;A.fillStyle=f,s==="vertical"?A.fillRect(i+Q-$-2,w+_,$,U):A.fillRect(i+_,w+E-$-2,U,$)}}A.restore()}updateListViewScrollFromPointer(A){var S,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const I=A.options||{},C=I.orientation||"vertical",g=this._lastPointerPos.x-this._prevPointerPos.x,Q=this._lastPointerPos.y-this._prevPointerPos.y;C==="vertical"?I.scrollOffset=(I.scrollOffset||0)+Q: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:((S=A.geometry)==null?void 0:S.width)||200,a=E.height!==void 0?E.height:((y=A.geometry)==null?void 0:y.height)||300,G=(i.length||0)*(C==="vertical"?o:s)+((i.length||0)-1)*w,K=Math.max(0,G-(C==="vertical"?a:h)+(I.padding*2||0));I.scrollOffset>0&&(I.scrollOffset=0),I.scrollOffset<-K&&(I.scrollOffset=-K)}updateListViewHoverFromPointer(A,I,C){const g=this.getListViewItemIndexAtPointer(A,I,C),Q=A.options||{};Q.hoveredIndex!==g&&(Q.hoveredIndex=g)}getListViewItemIndexAtPointer(A,I,C){var q,P;const g=A.options||{},Q=this.objectStates.get(A.id)||{},E=g.items||[];if(E.length===0)return null;const i=Q.width!==void 0?Q.width:((q=A.geometry)==null?void 0:q.width)||200,w=Q.height!==void 0?Q.height:((P=A.geometry)==null?void 0:P.height)||300,o=g.orientation||"vertical",s=g.itemGap??10,h=g.itemHeight??50,a=g.itemWidth??200,G=g.scrollOffset??0,t=g.padding??0,K=this.getWorldTransform(A.id),S=I-K.x,y=C-K.y,N=-K.rotation*(Math.PI/180),M=Math.cos(N),e=Math.sin(N),Y=S*M-y*e,j=S*e+y*M,l=-i/2,r=-w/2,v=typeof t=="number"?t:o==="vertical"?t[0]:t[3];let n=(o==="vertical"?r:l)+G+v;for(let sA=0;sA<E.length;sA++){const EA=o==="vertical"?i:a,T=o==="vertical"?h:w,V=o==="vertical"?l:n,IA=o==="vertical"?n:r;if(Y>=V&&Y<=V+EA&&j>=IA&&j<=IA+T)return sA;n+=(o==="vertical"?h:a)+s}return null}drawListViewRect(A,I,C,g,Q,E){A.beginPath(),this.drawRoundRect(A,I,C,g,Q,E),A.fill()}solveBehaviors(A){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:I,y:C}=this._lastPointerPos;this.artboard.objects.forEach(g=>{if(!g.behaviors||g.behaviors.length===0)return;const Q=this.objectStates.get(g.id);Q&&g.behaviors.forEach(E=>{var a,G,t,K,S,y,N,M,e,Y,j,l,r,v,n,q,P,sA,EA,T,V,IA,x,d,p,U,_,f,$,hA,SA,FA,NA,u,O,L,R,m,Z,GA,gA,DA,kA,CA;if(!E.enabled)return;const i=E.startTime||0,w=E.endTime||1/0;if(this.currentTime<i||this.currentTime>w)return;const o=Q.x-I,s=Q.y-C,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===W.Proximity){const F=((a=E.settings)==null?void 0:a.radius)||300,b=((G=E.settings)==null?void 0:G.falloff)||"smooth";let H=0;h<F&&(b==="linear"?H=1-h/F:H=Math.pow(1-h/F,2)),H>0&&E.sensors.forEach(iA=>{this.applyBehaviorSensor(Q,iA,H,A,E.settings)})}else if(E.type===W.Magnetic){const F=((t=E.settings)==null?void 0:t.radius)||400,b=((K=E.settings)==null?void 0:K.strength)||.5;if(h<F&&h>5){const H=1-h/F,iA=o*H*b,UA=s*H*b;Q.x-=iA*A*10,Q.y-=UA*A*10}}else if(E.type===W.Repel){const F=((S=E.settings)==null?void 0:S.radius)||300,b=((y=E.settings)==null?void 0:y.strength)||1;if(h<F){const H=Math.pow(1-h/F,2);Q.x+=o/(h||1)*H*60*b*A*5,Q.y+=s/(h||1)*H*60*b*A*5}}else if(E.type===W.Orbit){const F=((N=E.settings)==null?void 0:N.speed)||1,b=((M=E.settings)==null?void 0:M.radius)||30,H=this.currentTime*F*Math.PI*2;Q.x+=Math.cos(H)*b*A*5,Q.y+=Math.sin(H)*b*A*5,Q.rotation+=2*A*5}else if(E.type===W.Vortex){const F=((e=E.settings)==null?void 0:e.radius)||400,b=((Y=E.settings)==null?void 0:Y.speed)||2,H=((j=E.settings)==null?void 0:j.strength)||1;if(h<F){const iA=Math.pow(1-h/F,1.5),UA=this.currentTime*b*Math.PI*2,BA=Math.cos(UA)*30-o*.4,z=Math.sin(UA)*30-s*.4;Q.x+=BA*iA*H*A*5,Q.y+=z*iA*H*A*5,Q.rotation+=5*iA*H*A*5,Q.scale_x*=1-iA*.1*H*A,Q.scale_y*=1-iA*.1*H*A}}else if(E.type===W.Fluid){const F=((l=E.settings)==null?void 0:l.radius)||300,b=((r=E.settings)==null?void 0:r.strength)||1;if(h<F){const H=Math.pow(1-h/F,1.2),iA=o/(h||1)*H*1.2*b,UA=s/(h||1)*H*1.2*b;Q.x+=iA*10*A*5,Q.y+=UA*10*A*5,Q.scale_x*=1+H*.3*b*A,Q.scale_y*=1+H*.3*b*A}}else if(E.type===W.Elastic){const F=((v=E.settings)==null?void 0:v.radius)||300,b=((n=E.settings)==null?void 0:n.strength)||1;if(h<F){const H=1-h/F;Q.scale_x*=1+H*.4*b*A,Q.scale_y*=1+H*.4*b*A}}else if(E.type===W.Holographic){const F=Q.x-this.canvasWidth/2,b=Q.y-this.canvasHeight/2,H=((q=E.settings)==null?void 0:q.factor)||25;if(Q.x-=F/1e3*H*A*5,Q.y-=b/1e3*H*A*5,Q.style){const iA=1-Math.min(1,h/400);Q.style.exposure=(Q.style.exposure||1)+iA*.5*A}}else if(E.type===W.Sticky){const F=((P=E.settings)==null?void 0:P.radius)||80,b=((sA=E.settings)==null?void 0:sA.strength)||1;if(h<F){const H=Math.pow(1-h/F,2);Q.x-=o*H*b*A*10,Q.y-=s*H*b*A*10,Q.scale_x*=1-H*.1*b*A,Q.scale_y*=1-H*.1*b*A}}else if(E.type===W.Dilation){const F=((EA=E.settings)==null?void 0:EA.size)||120,b=((T=E.settings)==null?void 0:T.strength)||1;if(h<F){const H=1-h/F;Q.scale_x*=1+H*.5*b*A,Q.scale_y*=1+H*.5*b*A}}else if(E.type===W.Parallax){const F=((V=E.settings)==null?void 0:V.factor)||.05,b=this.canvasHeight/2,H=(this._lastPointerPos.y-b)*F;Q.y+=H*A*10}else if(E.type===W.Noise||E.type===W.Float){const F=(((IA=E.settings)==null?void 0:IA.frequency)||((x=E.settings)==null?void 0:x.speed)||1)*.002,b=(((d=E.settings)==null?void 0:d.amplitude)||((p=E.settings)==null?void 0:p.range)||50)*(((U=E.settings)==null?void 0:U.strength)||1),H=Date.now();Q.x+=Math.sin(H*F)*b*A,Q.y+=Math.cos(H*F*.8)*b*A,Q.rotation+=Math.sin(H*F*.5)*5*A}else if(E.type===W.Pulse){const F=(((_=E.settings)==null?void 0:_.speed)||1)*.005,b=(((f=E.settings)==null?void 0:f.scale)||1.2)-1,H=Math.sin(Date.now()*F),iA=(($=E.settings)==null?void 0:$.strength)||1;Q.scale_x*=1+H*b*iA*A,Q.scale_y*=1+H*b*iA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,H)*.1*iA*A)}else if(E.type===W.Draggable){const F=((hA=E.settings)==null?void 0:hA.radius)||150,b=this.draggingBehaviors.has(g.id);if(h<F||b){const H=((SA=E.settings)==null?void 0:SA.strength)||1,iA=b?1:Math.max(0,1-h/F);this.applyBehaviorSensor(Q,uA.PositionX,iA*H,A,E.settings),this.applyBehaviorSensor(Q,uA.PositionY,iA*H,A,E.settings)}}else if(E.type===W.Scroll){const F=((FA=E.settings)==null?void 0:FA.axis)||"vertical",b=((NA=E.settings)==null?void 0:NA.factor)||.5,H=((u=E.settings)==null?void 0:u.strength)||1;(F==="vertical"||F==="both")&&(Q.y+=this.scrollOffset.y*b*H*A),(F==="horizontal"||F==="both")&&(Q.x+=this.scrollOffset.x*b*H*A)}else if(E.type===W.LookAt){const F=((O=E.settings)==null?void 0:O.factor)||1,b=((L=E.settings)==null?void 0:L.strength)||1,H=Math.atan2(-s,-o)*(180/Math.PI),iA=Q.rotation,UA=(H-iA+180)%360-180;Q.rotation+=UA*F*b*A*10}else if(E.type===W.Glint||E.type===W.Scan){const F=(((R=E.settings)==null?void 0:R.speed)||1)*.004,b=((m=E.settings)==null?void 0:m.strength)||1,H=(Math.sin(Date.now()*F)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+H*b*A*5),Q.x+=(H-.5)*20*b*A}else if(E.type===W.Ratchet){const F=((Z=E.settings)==null?void 0:Z.steps)||12,b=(((GA=E.settings)==null?void 0:GA.speed)||1)*30,H=Math.floor(Q.rotation/(360/F))*(360/F);Q.rotation=this.lerp(Q.rotation,H+b*A,.1)}else if(E.type===W.Jitter&&h<300){const F=((gA=E.settings)==null?void 0:gA.strength)||1,b=(((DA=E.settings)==null?void 0:DA.intensity)||5)*F;Q.x+=(Math.random()-.5)*b*A*60,Q.y+=(Math.random()-.5)*b*A*60,Q.rotation+=(Math.random()-.5)*b*A*120}else if(E.type===W.Follower){const F=(kA=E.settings)==null?void 0:kA.targetId;if(F){const b=this.objectStates.get(F);if(b){const H=((CA=E.settings)==null?void 0:CA.stiffness)||.1,iA=b.x-Q.x,UA=b.y-Q.y;Q.x+=iA*H*A*60,Q.y+=UA*H*A*60}}}else E.type===W.Wrap&&(Q.x<0?Q.x=this.canvasWidth:Q.x>this.canvasWidth&&(Q.x=0),Q.y<0?Q.y=this.canvasHeight:Q.y>this.canvasHeight&&(Q.y=0))})})}applyBehaviorSensor(A,I,C,g,Q){const E=(Q==null?void 0:Q.intensity)||(Q==null?void 0:Q.strength)||1,i=C*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,C){return A*(1-C)+I*C}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 C={...A};for(const g in I)Object.prototype.hasOwnProperty.call(I,g)&&(I[g]&&typeof I[g]=="object"&&!Array.isArray(I[g])?C[g]=this.deepMerge(A[g],I[g]):C[g]=I[g]);return C}}const $E=JA.forwardRef(({artboard:B,src:A,className:I,style:C,autoPlay:g=!0,fit:Q="Contain",alignment:E="Center",onReady:i,onTrigger:w,onInputUpdate:o,onComponentChange:s,onToggle:h,onInputChange:a,onInputFocus:G,onInputBlur:t,onLog:K},S)=>{const y=JA.useRef(null),N=JA.useRef(new xQ),M=JA.useRef(),e=JA.useRef(0),Y=JA.useRef(null);JA.useImperativeHandle(S,()=>y.current),JA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),N.current.setLayout(Q,E)},[Q,E]),JA.useEffect(()=>{w&&N.current.setTriggerCallback(w)},[w]),JA.useEffect(()=>{o&&N.current.setInputUpdateCallback(o)},[o]),JA.useEffect(()=>{s&&N.current.setComponentChangeCallback(s)},[s]),JA.useEffect(()=>{h&&N.current.setToggleCallback(h)},[h]),JA.useEffect(()=>{a&&N.current.setInputChangeCallback(a)},[a]),JA.useEffect(()=>{G&&N.current.setInputFocusCallback(G)},[G]),JA.useEffect(()=>{t&&N.current.setInputBlurCallback(t)},[t]),JA.useEffect(()=>{(async()=>{const r=N.current;let v=B;if(!v&&A)try{v=await(await fetch(A)).json()}catch(n){console.error("Failed to load ExodeUI animation:",n);return}if(v){const n=v.id||v.name||"default";Y.current!==n&&(r.load(v),Y.current=n,e.current=0),i&&i(r)}})()},[B,A]),JA.useEffect(()=>{const l=N.current,r=y.current;if(!r)return;const v=r.getContext("2d");if(!v)return;v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",K&&l.setOnLogCallback(K);const n=P=>{e.current||(e.current=P);const sA=(P-e.current)/1e3;e.current=P,g&&l.advance(sA);const EA=window.devicePixelRatio||1,T=r.getBoundingClientRect(),V=Math.floor(T.width*EA),IA=Math.floor(T.height*EA);(r.width!==V||r.height!==IA)&&(r.width=V,r.height=IA),l.render(v,V,IA),M.current=requestAnimationFrame(n)};M.current=requestAnimationFrame(n);const q=()=>{l.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",q,{passive:!0}),()=>{M.current&&cancelAnimationFrame(M.current),window.removeEventListener("scroll",q)}},[g]);const j=(l,r)=>{const v=l.currentTarget.getBoundingClientRect(),n=l.clientX-v.left,q=l.clientY-v.top,P=v.width,sA=v.height;N.current.handlePointerInput(r,n,q,P,sA)};return ZA.jsx("canvas",{ref:y,style:{width:"100%",height:"100%",outline:"none",...C},className:I,tabIndex:0,onPointerDown:l=>{var r;j(l,"down"),(r=y.current)==null||r.focus()},onPointerUp:l=>j(l,"up"),onPointerMove:l=>j(l,"move"),onPointerLeave:l=>j(l,"blur"),onClick:l=>j(l,"click"),onKeyDown:l=>{l.key==="Backspace"||l.key==="Enter"||l.key,N.current.handleKeyDown(l.nativeEvent)}})});function Ai(){const[B,A]=JA.useState(null),I=JA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=JA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=JA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=JA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=JA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=JA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=JA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=JA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=JA.useCallback((h,a)=>{B==null||B.updateGraphData(h,a)},[B]);return{setEngine:A,engine:B,setInputBool:I,setInputNumber:C,fireTrigger:g,setInputText:Q,setInputNumberArray:E,setInputStringArray:i,updateConstraint:o,updateGraphData:s,updateObjectOptions:w}}const Ii="6.0.24";HA.BehaviorSensor=uA,HA.BehaviorType=W,HA.ConditionOp=tC,HA.ExodeUICanvas=$E,HA.ExodeUIEngine=xQ,HA.LogicOp=NI,HA.VERSION=Ii,HA.useExodeUI=Ai,Object.defineProperty(HA,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -6547,7 +6547,7 @@ class Ei {
6547
6547
  });
6548
6548
  // Trigger Management
6549
6549
  tA(this, "activeTriggers", /* @__PURE__ */ new Map());
6550
- console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.22) - SVG Fill & Gradient Parity Active", "color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)");
6550
+ console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.24) - SVG Fill & Gradient Parity Active", "color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)");
6551
6551
  }
6552
6552
  setTriggerCallback(A) {
6553
6553
  this.onTrigger = A;
@@ -9365,7 +9365,7 @@ function si() {
9365
9365
  updateObjectOptions: w
9366
9366
  };
9367
9367
  }
9368
- const hi = "6.0.22";
9368
+ const hi = "6.0.24";
9369
9369
  export {
9370
9370
  TA as BehaviorSensor,
9371
9371
  Z as BehaviorType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodeui",
3
- "version": "6.0.23",
3
+ "version": "6.0.24",
4
4
  "description": "React Runtime for ExodeUI Animation Engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",