exodeui 6.0.21 → 6.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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(L=t,P=K,wA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:L,endGraphemeIndex:P,width:wA}),s=0,h=!1,N()}function e(L,P){h=!0,a=L,G=0,t=L+1,K=0,s=P}function Y(L,P,wA){h=!0,a=L,G=P,t=L,K=P+1,s=wA}function j(L,P){if(!h){e(L,P);return}s+=P,t=L+1,K=0}function l(L,P){wg(g[L])&&(S=L+1,y=s-P)}function r(L){v(L,0)}function v(L,P){const wA=Q[L],EA=E[L]??null;for(let u=P;u<wA.length;u++){const z=rQ(wA,EA,u,i.preferPrefixWidthsForBreakableRuns);if(!h){Y(L,u,z);continue}s+z>A+w?(M(),Y(L,u,z)):(s+=z,t=L,K=u+1)}h&&t===L&&K===wA.length&&(t=L+1,K=0)}let n=0;for(;n<C.length;){const L=C[n],P=g[n];if(!h){L>A&&Q[n]!==null?r(n):e(n,L),l(n,L),n++;continue}if(s+L>A+w){if(wg(P)){j(n,L),M(n+1,0,s-L),n++;continue}if(S>=0){M(S,0,y);continue}if(L>A&&Q[n]!==null){M(),r(n),n++;continue}M();continue}j(n,L),l(n,L),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(p=M,d=e,R=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:N,endSegmentIndex:p,endGraphemeIndex:d,width:R}),K=0,S=!1,v()}function L(p,d){S=!0,y=p,N=0,M=p+1,e=0,K=d}function P(p,d,R){S=!0,y=p,N=d,M=p,e=d+1,K=R}function wA(p,d){if(!S){L(p,d);return}K+=d,M=p+1,e=0}function EA(p,d){if(!wg(E[p]))return;const R=E[p]==="tab"?0:g[p],m=E[p]==="tab"?d:Q[p];Y=p+1,j=K-d+R,l=K-d+m,r=E[p]}function u(p){z(p,0)}function z(p,d){const R=i[p],m=w[p]??null;for(let b=d;b<R.length;b++){const AA=rQ(R,m,b,a.preferPrefixWidthsForBreakableRuns);if(!S){P(p,b,AA);continue}K+AA>A+G?(n(),P(p,b,AA)):(K+=AA,M=p,e=b+1)}S&&M===p&&e===R.length&&(M=p+1,e=0)}function IA(p){if(r!=="soft-hyphen")return!1;const d=i[p];if(d===null)return!1;const R=a.preferPrefixWidthsForBreakableRuns?w[p]??d:d,m=R!==d,{fitCount:b,fittedWidth:AA}=DE(R,K,A,G,o,m);return b===0?!1:(K=AA,M=p,e=b,v(),b===d.length?(M=p+1,e=0,!0):(n(p,b,AA+o),z(p,b),!0))}function Z(p){t++,I==null||I({startSegmentIndex:p.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:p.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),v()}for(let p=0;p<h.length;p++){const d=h[p];if(d.startSegmentIndex===d.endSegmentIndex){Z(d);continue}S=!1,K=0,y=d.startSegmentIndex,N=0,M=d.startSegmentIndex,e=0,v();let R=d.startSegmentIndex;for(;R<d.endSegmentIndex;){const m=E[R],b=m==="tab"?oE(K,s):C[R];if(m==="soft-hyphen"){S&&(M=R+1,e=0,Y=R+1,j=K+o,l=K+o,r=m),R++;continue}if(!S){b>A&&i[R]!==null?u(R):L(R,b),EA(R,b),R++;continue}if(K+b>A+G){const sA=K+(m==="tab"?0:g[R]),kA=K+(m==="tab"?b:Q[R]);if(r==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&j<=A+G){n(Y,0,l);continue}if(r==="soft-hyphen"&&IA(R)){R++;continue}if(wg(m)&&sA<=A+G){wA(R,b),n(R+1,0,kA),R++;continue}if(Y>=0&&j<=A+G){n(Y,0,l);continue}if(b>A&&i[R]!==null){n(),u(R),R++;continue}n();continue}wA(R,b),EA(R,b),R++}if(S){const m=Y===d.consumedEndSegmentIndex?l:K;n(d.consumedEndSegmentIndex,0,m)}}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,L,P,wA,EA,u){P!=="text"&&P!=="space"&&P!=="zero-width-break"&&(t=!1),s.push(v),h.push(n),a.push(L),G.push(P),K==null||K.push(wA),S.push(EA),y.push(u),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],L=B.kinds[r],P=B.starts[r];if(L==="soft-hyphen"){Y(v,0,i,i,L,P,null,null),e[r]=s.length;continue}if(L==="hard-break"){Y(v,0,0,0,L,P,null,null),e[r]=s.length;continue}if(L==="tab"){Y(v,0,0,0,L,P,null,null),e[r]=s.length;continue}const wA=KI(v,Q);if(L==="text"&&wA.containsCJK){let IA="",Z=0;for(const p of C.segment(v)){const d=p.segment;if(IA.length===0){IA=d,Z=p.index;continue}if(og.has(IA)||MQ.has(d)||uI.has(d)||g.carryCJKAfterClosingQuote&&tI(d)&&eQ(IA)){IA+=d;continue}const R=KI(IA,Q),m=SI(IA,R,E);Y(IA,m,m,m,"text",P+Z,null,null),IA=d,Z=p.index}if(IA.length>0){const p=KI(IA,Q),d=SI(IA,p,E);Y(IA,d,d,d,"text",P+Z,null,null)}e[r]=s.length;continue}const EA=SI(v,wA,E),u=L==="space"||L==="preserved-space"||L==="zero-width-break"?0:EA,z=L==="space"||L==="zero-width-break"?0:EA;if(n&&v.length>1){const IA=BE(v,wA,Q,E),Z=g.preferPrefixWidthsForBreakableRuns?EE(v,wA,Q,E):null;Y(v,EA,u,z,L,P,IA,Z)}else Y(v,EA,u,z,L,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(){GA(this,"artboard",null);GA(this,"objectStates",new Map);GA(this,"physicsEngine",null);GA(this,"activeStateMachine",null);GA(this,"inputs",new Map);GA(this,"inputNameMap",new Map);GA(this,"layerStates",new Map);GA(this,"pretextCache",new Map);GA(this,"pointerHistory",[]);GA(this,"MAX_HISTORY",200);GA(this,"imageCache",new Map);GA(this,"lastValidSvgImgMap",new Map);GA(this,"maskBuffer",null);GA(this,"maskCtx",null);GA(this,"lumaBuffer",null);GA(this,"lumaCtx",null);GA(this,"layout",{fit:"Contain",alignment:"Center"});GA(this,"onTrigger");GA(this,"onInputUpdate");GA(this,"onComponentChange");GA(this,"onToggle");GA(this,"onInputChange");GA(this,"onInputFocus");GA(this,"onInputBlur");GA(this,"onLog");GA(this,"justFiredTriggers",new Set);GA(this,"rootTransform",null);GA(this,"canvasWidth",0);GA(this,"canvasHeight",0);GA(this,"lastHoveredObjectId",null);GA(this,"_lastPointerPos",null);GA(this,"_prevPointerPos",null);GA(this,"focusedId",null);GA(this,"draggingSliderId",null);GA(this,"activeDropdownId",null);GA(this,"draggingListViewId",null);GA(this,"scrollOffset",{x:0,y:0});GA(this,"draggingBehaviors",new Set);GA(this,"objectVelocities",new Map);GA(this,"currentTime",0);GA(this,"frameCount",0);GA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});GA(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.21) - 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===O.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,L=Math.abs(I-l.x)<=r/2,P=C>=n&&C<=n+j*Math.abs(l.scaleY);if(L&&P){const wA=Math.abs(l.scaleY),EA=C-(n+Y*wA),u=Math.floor(EA/(e*wA));if(u>=0&&u<M.length){const z=M[u];K.selectedOption=z,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,z),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:z})}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(L=t,P=K,wA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:L,endGraphemeIndex:P,width:wA}),s=0,h=!1,N()}function e(L,P){h=!0,a=L,G=0,t=L+1,K=0,s=P}function Y(L,P,wA){h=!0,a=L,G=P,t=L,K=P+1,s=wA}function j(L,P){if(!h){e(L,P);return}s+=P,t=L+1,K=0}function l(L,P){wg(g[L])&&(S=L+1,y=s-P)}function r(L){v(L,0)}function v(L,P){const wA=Q[L],EA=E[L]??null;for(let u=P;u<wA.length;u++){const z=rQ(wA,EA,u,i.preferPrefixWidthsForBreakableRuns);if(!h){Y(L,u,z);continue}s+z>A+w?(M(),Y(L,u,z)):(s+=z,t=L,K=u+1)}h&&t===L&&K===wA.length&&(t=L+1,K=0)}let n=0;for(;n<C.length;){const L=C[n],P=g[n];if(!h){L>A&&Q[n]!==null?r(n):e(n,L),l(n,L),n++;continue}if(s+L>A+w){if(wg(P)){j(n,L),M(n+1,0,s-L),n++;continue}if(S>=0){M(S,0,y);continue}if(L>A&&Q[n]!==null){M(),r(n),n++;continue}M();continue}j(n,L),l(n,L),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(p=M,d=e,R=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:N,endSegmentIndex:p,endGraphemeIndex:d,width:R}),K=0,S=!1,v()}function L(p,d){S=!0,y=p,N=0,M=p+1,e=0,K=d}function P(p,d,R){S=!0,y=p,N=d,M=p,e=d+1,K=R}function wA(p,d){if(!S){L(p,d);return}K+=d,M=p+1,e=0}function EA(p,d){if(!wg(E[p]))return;const R=E[p]==="tab"?0:g[p],m=E[p]==="tab"?d:Q[p];Y=p+1,j=K-d+R,l=K-d+m,r=E[p]}function u(p){z(p,0)}function z(p,d){const R=i[p],m=w[p]??null;for(let b=d;b<R.length;b++){const AA=rQ(R,m,b,a.preferPrefixWidthsForBreakableRuns);if(!S){P(p,b,AA);continue}K+AA>A+G?(n(),P(p,b,AA)):(K+=AA,M=p,e=b+1)}S&&M===p&&e===R.length&&(M=p+1,e=0)}function IA(p){if(r!=="soft-hyphen")return!1;const d=i[p];if(d===null)return!1;const R=a.preferPrefixWidthsForBreakableRuns?w[p]??d:d,m=R!==d,{fitCount:b,fittedWidth:AA}=DE(R,K,A,G,o,m);return b===0?!1:(K=AA,M=p,e=b,v(),b===d.length?(M=p+1,e=0,!0):(n(p,b,AA+o),z(p,b),!0))}function Z(p){t++,I==null||I({startSegmentIndex:p.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:p.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),v()}for(let p=0;p<h.length;p++){const d=h[p];if(d.startSegmentIndex===d.endSegmentIndex){Z(d);continue}S=!1,K=0,y=d.startSegmentIndex,N=0,M=d.startSegmentIndex,e=0,v();let R=d.startSegmentIndex;for(;R<d.endSegmentIndex;){const m=E[R],b=m==="tab"?oE(K,s):C[R];if(m==="soft-hyphen"){S&&(M=R+1,e=0,Y=R+1,j=K+o,l=K+o,r=m),R++;continue}if(!S){b>A&&i[R]!==null?u(R):L(R,b),EA(R,b),R++;continue}if(K+b>A+G){const sA=K+(m==="tab"?0:g[R]),kA=K+(m==="tab"?b:Q[R]);if(r==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&j<=A+G){n(Y,0,l);continue}if(r==="soft-hyphen"&&IA(R)){R++;continue}if(wg(m)&&sA<=A+G){wA(R,b),n(R+1,0,kA),R++;continue}if(Y>=0&&j<=A+G){n(Y,0,l);continue}if(b>A&&i[R]!==null){n(),u(R),R++;continue}n();continue}wA(R,b),EA(R,b),R++}if(S){const m=Y===d.consumedEndSegmentIndex?l:K;n(d.consumedEndSegmentIndex,0,m)}}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,L,P,wA,EA,u){P!=="text"&&P!=="space"&&P!=="zero-width-break"&&(t=!1),s.push(v),h.push(n),a.push(L),G.push(P),K==null||K.push(wA),S.push(EA),y.push(u),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],L=B.kinds[r],P=B.starts[r];if(L==="soft-hyphen"){Y(v,0,i,i,L,P,null,null),e[r]=s.length;continue}if(L==="hard-break"){Y(v,0,0,0,L,P,null,null),e[r]=s.length;continue}if(L==="tab"){Y(v,0,0,0,L,P,null,null),e[r]=s.length;continue}const wA=KI(v,Q);if(L==="text"&&wA.containsCJK){let IA="",Z=0;for(const p of C.segment(v)){const d=p.segment;if(IA.length===0){IA=d,Z=p.index;continue}if(og.has(IA)||MQ.has(d)||uI.has(d)||g.carryCJKAfterClosingQuote&&tI(d)&&eQ(IA)){IA+=d;continue}const R=KI(IA,Q),m=SI(IA,R,E);Y(IA,m,m,m,"text",P+Z,null,null),IA=d,Z=p.index}if(IA.length>0){const p=KI(IA,Q),d=SI(IA,p,E);Y(IA,d,d,d,"text",P+Z,null,null)}e[r]=s.length;continue}const EA=SI(v,wA,E),u=L==="space"||L==="preserved-space"||L==="zero-width-break"?0:EA,z=L==="space"||L==="zero-width-break"?0:EA;if(n&&v.length>1){const IA=BE(v,wA,Q,E),Z=g.preferPrefixWidthsForBreakableRuns?EE(v,wA,Q,E):null;Y(v,EA,u,z,L,P,IA,Z)}else Y(v,EA,u,z,L,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(){GA(this,"artboard",null);GA(this,"objectStates",new Map);GA(this,"physicsEngine",null);GA(this,"activeStateMachine",null);GA(this,"inputs",new Map);GA(this,"inputNameMap",new Map);GA(this,"layerStates",new Map);GA(this,"pretextCache",new Map);GA(this,"pointerHistory",[]);GA(this,"MAX_HISTORY",200);GA(this,"imageCache",new Map);GA(this,"lastValidSvgImgMap",new Map);GA(this,"maskBuffer",null);GA(this,"maskCtx",null);GA(this,"lumaBuffer",null);GA(this,"lumaCtx",null);GA(this,"layout",{fit:"Contain",alignment:"Center"});GA(this,"onTrigger");GA(this,"onInputUpdate");GA(this,"onComponentChange");GA(this,"onToggle");GA(this,"onInputChange");GA(this,"onInputFocus");GA(this,"onInputBlur");GA(this,"onLog");GA(this,"justFiredTriggers",new Set);GA(this,"rootTransform",null);GA(this,"canvasWidth",0);GA(this,"canvasHeight",0);GA(this,"lastHoveredObjectId",null);GA(this,"_lastPointerPos",null);GA(this,"_prevPointerPos",null);GA(this,"focusedId",null);GA(this,"draggingSliderId",null);GA(this,"activeDropdownId",null);GA(this,"draggingListViewId",null);GA(this,"scrollOffset",{x:0,y:0});GA(this,"draggingBehaviors",new Set);GA(this,"objectVelocities",new Map);GA(this,"currentTime",0);GA(this,"frameCount",0);GA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});GA(this,"activeTriggers",new Map);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===O.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,L=Math.abs(I-l.x)<=r/2,P=C>=n&&C<=n+j*Math.abs(l.scaleY);if(L&&P){const wA=Math.abs(l.scaleY),EA=C-(n+Y*wA),u=Math.floor(EA/(e*wA));if(u>=0&&u<M.length){const z=M[u];K.selectedOption=z,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,z),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:z})}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 Z,p,d,R,m,b,AA,sA,kA,HA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(f,W,H,U,x)=>(this.drawRoundRect(A,f,W,H,U,x),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)||((Z=I.geometry)==null?void 0:Z.width)||I.width||0,w=(Q==null?void 0:Q.height)||((p=I.geometry)==null?void 0:p.height)||I.height||0;if((i===0||w===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let f=1/0,W=-1/0,H=1/0,U=-1/0;Q.points.forEach(x=>{f=Math.min(f,x.x),W=Math.max(W,x.x),H=Math.min(H,x.y),U=Math.max(U,x.y)}),i===0&&(i=W-f),w===0&&(w=U-H)}const o=f=>{if(f)return f.corner_radius??f.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||((d=I.style)==null?void 0:d.blur);K&&K.amount>0&&t.push(`blur(${K.amount}px)`);const S=((R=Q==null?void 0:Q.type)==null?void 0:R.toLowerCase().includes("image"))||((m=I.type)==null?void 0:m.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 f=(e.exposure||0)/100,W=e.contrast||0,H=1+(e.saturation||0)/100,U=(e.temperature||0)/200,x=(e.tint||0)/200,V=(e.highlights||0)/500,aA=(e.shadows||0)/500;let gA="",KA="SourceGraphic";if(f!==0&&(gA+=`
|
|
7
7
|
<feComponentTransfer in="${KA}" result="exposure">
|
|
8
8
|
<feFuncR type="linear" slope="1" intercept="${f}"/>
|
|
@@ -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"/>`,KA="invert"}if(U!==0||x!==0||V!==0||aA!==0){const CA=1+V+aA,F=CA*(1+U-x/2),T=CA*(1+x),q=CA*(1-U-x/2),iA=e.shadows*.1/255,RA=[F,0,0,0,iA,0,T,0,0,iA,0,0,q,0,iA,0,0,0,1,0].join(" ");gA+=`<feColorMatrix in="${KA}" type="matrix" values="${RA}" result="advanced"/>`,KA="advanced"}if(e.blur&&(gA+=`<feGaussianBlur in="${KA}" stdDeviation="${e.blur}" result="blur"/>`,KA="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 f=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(f)&&(A.globalCompositeOperation=f)}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 L=v.filter(f=>f.isVisible!==!1&&C.has(f.maskId));if(L.length>0){const f=L[0],W=C.get(f.maskId),H=this.objectStates.get(W.id);H&&H.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,wA=g.skew_y||0;(P!==0||wA!==0)&&A.transform(1,Math.tan(wA*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 f=EA.color||"#000000";(AA=(b=this.artboard)==null?void 0:b.tokens)!=null&&AA.colors&&this.artboard.tokens.colors[f]&&(f=this.artboard.tokens.colors[f]);const W=this.normalizeOpacity(EA.opacity??100),H=EA.spread||0,x=(EA.blur||0)+H*1.5;let V=f;if(f.startsWith("#")){const aA=f.replace("#",""),gA=parseInt(aA.substring(0,2),16),KA=parseInt(aA.substring(2,4),16),yA=parseInt(aA.substring(4,6),16);V=`rgba(${gA}, ${KA}, ${yA}, ${W})`}else if(f.startsWith("rgba")){const aA=f.match(/[\d.]+/g);if(aA&&aA.length>=4){const gA=aA[0],KA=aA[1],yA=aA[2],CA=aA[3];V=`rgba(${gA}, ${KA}, ${yA}, ${parseFloat(CA)*W})`}}A.shadowColor=V,A.shadowBlur=x,A.shadowOffsetX=EA.offsetX||0,A.shadowOffsetY=EA.offsetY||0}const u=I.liquidFill||((sA=I.style)==null?void 0:sA.liquidFill),z=I.artEffect||((kA=I.style)==null?void 0:kA.artEffect);if(u&&u.enabled){A.save();const f=u.fillLevel??.5;A.beginPath();const W=w/2-w*f;A.rect(-i/2,W,i,w*f),A.clip(),A.fillStyle=u.color||"#3b82f6",A.globalAlpha=A.globalAlpha*(u.opacity??1)}const IA=z&&z.enabled&&z.type==="glitch";if(IA){A.save();const W=(z.intensity??.5)*10;A.shadowColor="rgba(255, 0, 0, 0.5)",A.shadowBlur=W,A.translate(W/2,0)}if(Q.type==="Text")this._renderText(A,I,h,E,g,i,w);else if(Q.type==="Image"){const f=Q.src;if(f){let W=this.imageCache.get(f);W||(W=new Image,W.onload=()=>{},W.onerror=()=>{console.error(`[ExodeUI] Image load failed: ${f.substring(0,100)}${f.length>100?"...":""}`)},W.src=f,this.imageCache.set(f,W));const H=E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1,U=(((HA=E.stroke)==null?void 0:HA.alignment)||"center").toLowerCase();if(H&&(U==="outside"||U==="center")&&this.applyStrokeAlignment(A,E,h,i,w,s),E.fill&&E.fill.type!=="None"){A.save();const x=A.globalAlpha,V=this.createCanvasFill(A,E.fill,i,w);A.fillStyle=V||E.fill.color||"transparent",A.globalAlpha=x*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=x,A.restore()}W.complete&&W.naturalWidth>0?(s!==0?(A.save(),this.drawRoundRect(A,-i/2,-w/2,i,w,s),A.clip(),A.drawImage(W,-i/2,-w/2,i,w),A.restore()):A.drawImage(W,-i/2,-w/2,i,w),H&&U==="inside"&&this.applyStrokeAlignment(A,E,h,i,w,s)):H&&U==="inside"&&this.applyStrokeAlignment(A,E,h,i,w,s)}}else if(Q.type==="SVG"){const f=Q.svgContent;if(f){const W=E.palette||[],H=E.fill,U=E.stroke,x=H?this.normalizeOpacity(H.opacity??100):1,V=(H==null?void 0:H.type)==="Solid"&&(!U||U.isEnabled===!1||U.type==="Solid"&&U.color===H.color),aA=H&&H.type!=="None"?V?"monochrome":H.type==="Solid"?(H.color||"")+"|opacity:"+x:JSON.stringify(H.stops||[])+"|opacity:"+x:"",gA=U&&U.isEnabled!==!1&&(U.width||0)>0?V?["monochrome",U.width||0,U.trimStart??0,U.trimEnd??1,U.trimOffset??0,U.dashOffset??0].join("|"):[U.width||0,U.fill?U.fill.type==="Solid"?U.fill.color||"":JSON.stringify(U.fill.stops||[]):U.color||"",U.opacity??1,U.lineCap||"",U.lineJoin||"",(U.dashArray||[]).join(","),U.trimStart??0,U.trimEnd??1,U.trimOffset??0,U.dashOffset??0].join("|"):"nostroke",KA=[I.id,W.join("_"),aA,gA,g.opacity??100,g.visible!==!1?"v":"h"].join("_");let yA=this.imageCache.get(KA);if(!yA){yA=new Image,yA.crossOrigin="anonymous";let F=f;if(Q.colors&&Q.colors.length>0&&W.length>0&&Q.colors.forEach((BA,_)=>{if(W[_]){const $=BA.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),oA=new RegExp($,"gi");F=F.replace(oA,W[_])}}),H&&H.type&&H.type!=="None"){if(H.type==="Solid"&&H.color){const BA=V?"#FFFFFF":H.color,_=V?1:this.normalizeOpacity(H.opacity??100);F=F.replace(/\bfill\s*=\s*["'][^"']*["']/gi,$=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test($)?$:`fill="${BA}"`),F=F.replace(/fill\s*:\s*[^;"')]+/gi,$=>/fill\s*:\s*(none|transparent)/i.test($)?$:`fill:${BA}`),_<1&&(F=F.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${_}"`),F=F.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${_}`),F.match(/\bfill-opacity\s*=/i)||(F=F.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${_}">`),F=F.replace(/<\/svg>/i,"</g></svg>")))}else if(H.type==="LinearGradient"||H.type==="RadialGradient"||H.type==="Linear"||H.type==="Radial"){const BA="exode-fill",_=this.normalizeOpacity(H.opacity??100),$=(H.stops||[]).map(QA=>{const X=QA.offset!==void 0?QA.offset:QA.pos??0,hA=this.normalizeOpacity(QA.opacity??100)*_;return`<stop offset="${X*100}%" stop-color="${QA.color||"#000"}" stop-opacity="${hA}"/>`}).join("");let oA="";if(H.type==="LinearGradient"||H.type==="Linear"){const QA=(TA,JA)=>Array.isArray(TA)?TA[JA]??(JA===0?0:1):TA&&typeof TA=="object"?TA[JA===0?"x":"y"]??(JA===0?0:1):JA===0?0:1,X=QA(H.start,0)*100,hA=QA(H.start,1)*100,SA=QA(H.end,0)*100,nA=QA(H.end,1)*100;oA=`<linearGradient id="${BA}" x1="${X}%" y1="${hA}%" x2="${SA}%" y2="${nA}%" gradientUnits="objectBoundingBox">${$}</linearGradient>`}else{const QA=(nA,TA)=>Array.isArray(nA)?nA[TA]??.5:nA&&typeof nA=="object"?nA[TA===0?"x":"y"]??.5:.5,X=QA(H.center,0)*100,hA=QA(H.center,1)*100,SA=(H.radius??.5)*100;oA=`<radialGradient id="${BA}" cx="${X}%" cy="${hA}%" r="${SA}%" gradientUnits="objectBoundingBox">${$}</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 T=(BA,_,$=1)=>{const oA=(BA.stops||[]).map(nA=>{const TA=nA.offset!==void 0?nA.offset:nA.pos??0,JA=this.normalizeOpacity(nA.opacity??100)*$;return`<stop offset="${TA*100}%" stop-color="${nA.color||"#000"}" stop-opacity="${JA}"/>`}).join(""),QA=(nA,TA,JA=.5)=>Array.isArray(nA)?nA[TA]??JA:nA&&typeof nA=="object"?nA[TA===0?"x":"y"]??JA:JA;if(BA.type==="LinearGradient"||BA.type==="Linear"){const nA=QA(BA.start,0,0)*100,TA=QA(BA.start,1,0)*100,JA=QA(BA.end,0,1)*100,$A=QA(BA.end,1,1)*100;return`<linearGradient id="${_}" x1="${nA}%" y1="${TA}%" x2="${JA}%" y2="${$A}%" gradientUnits="objectBoundingBox">${oA}</linearGradient>`}const X=QA(BA.center,0,.5)*100,hA=QA(BA.center,1,.5)*100,SA=(BA.radius??.5)*100;return`<radialGradient id="${_}" cx="${X}%" cy="${hA}%" r="${SA}%" gradientUnits="objectBoundingBox">${oA}</radialGradient>`},q=(BA,_)=>/<defs>/i.test(BA)?BA.replace(/<defs>/i,`<defs>${_}`):BA.replace(/(<svg[^>]*>)/i,`$1<defs>${_}</defs>`);if(U&&U.isEnabled!==!1&&(U.width||0)>0){const BA=U.width||1,_=V?1:this.normalizeOpacity(U.opacity??100),$=V?"#FFFFFF":U.color||(H==null?void 0:H.color)||"#000000";let oA="";const QA=U.fill;if(QA&&QA.type){if(QA.type==="Solid")oA=QA.color||U.color||"#000000";else if(QA.type==="LinearGradient"||QA.type==="RadialGradient"||QA.type==="Linear"||QA.type==="Radial"){const JA="exode-stroke";F=q(F,T(QA,JA,_)),oA=`url(#${JA})`}}oA||(oA=$),F.match(/\bstroke\s*=/i)?F=F.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,JA=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(JA)?JA:`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="${_}"`):F=F.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${_}"`),F=F.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${_}`),U.lineCap&&(F=F.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${U.lineCap}"`),F=F.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${U.lineCap}`)),U.lineJoin&&(F=F.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${U.lineJoin}"`),F=F.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${U.lineJoin}`));const X=U.trimStart??0,hA=U.trimEnd??1,SA=U.trimOffset??0,nA=U.dashOffset??0,TA=X!==0||hA!==1||SA!==0||nA!==0;if(TA){const JA=Math.max(0,Math.min(1,X)),$A=Math.max(0,Math.min(1,hA));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${I.name||I.id}, Start: ${JA}, End: ${$A}`);let tg=Q.width||i||100,Kg=Q.height||w||100;const xI=f.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=(SA%1+1)%1,oI=(nA%1+1)%1;let QI="",DI=0;if(JA>=$A)QI=`0 ${yI}`,DI=0;else{const kI=yI*($A-JA),UI=yI-kI;DI=-(yI*(JA+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(U.dashArray&&U.dashArray.length>0){const JA=U.dashArray.join(" ");F=F.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${JA}"`),F=F.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${JA}`),U.dashOffset&&(F=F.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${U.dashOffset}"`),F=F.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${U.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(f)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(f)){let JA="",$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,hA)),kI=(SA%1+1)%1,UI=(nA%1+1)%1;if(QI>=DI)JA=` stroke-dasharray="0 ${oI}"`,$A=' stroke-dashoffset="0"';else{const OQ=oI*(DI-QI),gi=oI-OQ,Ci=-(oI*(QI+kI+UI));JA=` stroke-dasharray="${OQ} ${gi}"`,$A=` stroke-dashoffset="${Ci}"`}}else(NA=U.dashArray)!=null&&NA.length&&(JA=` stroke-dasharray="${U.dashArray.join(" ")}"`,U.dashOffset&&($A=` stroke-dashoffset="${U.dashOffset}"`));const tg=U.lineCap?` stroke-linecap="${U.lineCap}"`:"",Kg=U.lineJoin?` stroke-linejoin="${U.lineJoin}"`:"",xI=`stroke="${oA}" stroke-width="${BA}" stroke-opacity="${_}"${tg}${Kg}${JA}${$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 U&&U.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"}),RA=URL.createObjectURL(iA);yA.onload=()=>{if(URL.revokeObjectURL(RA),this.frameCount%900===0){const BA=this.imageCache.get(KA);BA&&this.debugLog(`SVG Payload Ready: ${I.name||I.id} (${BA.naturalWidth}x${BA.naturalHeight})`)}},yA.onerror=()=>{URL.revokeObjectURL(RA),this.debugLog(`SVG Error: Failed to load payload for ${I.name||I.id}`)},yA.src=RA,this.imageCache.set(KA,yA)}let CA=null;if(yA.complete&&yA.naturalWidth>0?(CA=yA,this.lastValidSvgImgMap.set(I.id,yA)):CA=this.lastValidSvgImgMap.get(I.id)||null,CA&&CA.complete&&CA.naturalWidth>0){const F=Math.max(1,i),T=Math.max(1,w);if(V&&(H==null?void 0:H.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=F,this.maskBuffer.height=T,this.maskCtx.clearRect(0,0,F,T),this.maskCtx.drawImage(CA,0,0,F,T),this.maskCtx.globalCompositeOperation="source-in";const q=H.color||"#000000",iA=this.normalizeOpacity(H.opacity??100);this.maskCtx.fillStyle=q,this.maskCtx.globalAlpha=iA,this.maskCtx.fillRect(0,0,F,T),A.drawImage(this.maskBuffer,-F/2,-T/2,F,T)}else s!==0?(A.save(),this.drawRoundRect(A,-F/2,-T/2,F,T,s),A.clip(),A.drawImage(CA,-F/2,-T/2,F,T),A.restore()):A.drawImage(CA,-F/2,-T/2,F,T)}}}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 f=A.globalAlpha,W=this.createCanvasFill(A,E.fill,i,w);W?A.fillStyle=W:A.fillStyle=typeof E.fill=="string"?E.fill:E.fill.color||"transparent",A.globalAlpha=f*this.normalizeOpacity(E.fill.opacity??100),this.applyPath(A,h,i,w,s),A.fill(),A.globalAlpha=f}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 f=g.width??Q.width??I.width??i,W=g.height??Q.height??I.height??w,H=s;if(A.save(),A.beginPath(),this.drawRoundRect(A,-f/2,-W/2,f,W,H),E.fill&&E.fill.type!=="None"){const U=A.globalAlpha,x=this.createCanvasFill(A,E.fill,f,W);A.fillStyle=x||E.fill.color||"transparent",A.globalAlpha=U*this.normalizeOpacity(E.fill.opacity??100),A.fill(),A.globalAlpha=U}if(A.restore(),E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1){const U={type:"Rectangle"};this.applyStrokeAlignment(A,E,U,f,W,H)}}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(),u&&u.enabled&&A.restore(),I.children&&I.children.length>0){const W=I.type==="Frame",H=I.clipsContent!==void 0?I.clipsContent:I.clipContent!==void 0?I.clipContent:W;if(A.save(),H){A.beginPath();const x=g.width??(Q==null?void 0:Q.width)??I.width??0,V=g.height??(Q==null?void 0:Q.height)??I.height??0,aA=g.cornerRadius??(Q==null?void 0:Q.corner_radius)??I.cornerRadius??0;this.drawRoundRect(A,-x/2,-V/2,x,V,aA),A.clip()}let U=0;for(I.children.forEach(x=>{const V=C.get(x);if(!V)return;const aA=this.objectStates.get(x),gA=(aA==null?void 0:aA.geometry)||V.geometry;if(gA&&gA.isMask&&(aA==null?void 0:aA.visible)!==!1){const KA=gA.width||0,yA=gA.height||0;this.applyObjectTransform(A,x);const CA=(aA==null?void 0:aA.corner_radius)??(gA==null?void 0:gA.corner_radius)??0;this.applyPath(A,gA,KA,yA,CA),A.clip(),U++}else this.renderObject(A,V,C)});U>0;)A.restore(),U--;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(U=>U.isVisible!==!1&&C.has(U.maskId)).forEach(U=>{const x=C.get(U.maskId),V=this.objectStates.get(x.id),aA=U.feather||0,gA=U.inverted===!0,KA=U.opacity!==void 0?typeof U.opacity=="number"?U.opacity:U.opacity/100:1;if((U.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,x.id,C),aA>0&&(this.lumaCtx.filter=`blur(${aA}px)`),this.lumaCtx.globalAlpha=KA;const CA=(V==null?void 0:V.width)||x.geometry.width||0,F=(V==null?void 0:V.height)||x.geometry.height||0,T=(V==null?void 0:V.corner_radius)??x.corner_radius??0;if(x.geometry.type==="Text"){const BA=V!=null&&V.geometry?this.deepMerge(x.geometry,V.geometry):x.geometry,_=V!=null&&V.style?this.deepMerge(x.style,V.style):x.style;this._renderText(this.lumaCtx,x,{...BA,width:CA,height:F,corner_radius:T},_,V,CA,F,!0)}else if(x.geometry.type==="Image"){const BA=x.geometry.src;if(BA){let _=this.imageCache.get(BA);_||(_=new Image,_.src=BA,this.imageCache.set(BA,_)),_.complete&&_.naturalWidth>0?this.lumaCtx.drawImage(_,-CA/2,-F/2,CA,F):(this.applyPath(this.lumaCtx,x.geometry,CA,F,T),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(x.geometry.type==="SVG"){const BA=x.geometry.svgContent;if(BA){const _=`__lumamask_${x.id}`;let $=this.imageCache.get(_);if(!$){$=new Image;const oA=new Blob([BA],{type:"image/svg+xml"});$.src=URL.createObjectURL(oA),$.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(_,$)}$.complete&&$.naturalWidth>0?this.lumaCtx.drawImage($,-CA/2,-F/2,CA,F):(this.applyPath(this.lumaCtx,x.geometry,CA,F,T),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,x.geometry,CA,F,T),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const q=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),iA=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,RA=q.data;for(let BA=0;BA<RA.length;BA+=4){const _=iA[BA],$=iA[BA+1],oA=iA[BA+2];let QA=(.299*_+.587*$+.114*oA)/255;gA&&(QA=1-QA),RA[BA+3]*=QA}this.maskCtx.putImageData(q,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=gA?"destination-out":"destination-in",aA>0&&(this.maskCtx.filter=`blur(${aA}px)`),this.maskCtx.globalAlpha=KA,this.applyAbsoluteTransform(this.maskCtx,x.id,C);const CA=(V==null?void 0:V.width)||x.geometry.width||0,F=(V==null?void 0:V.height)||x.geometry.height||0,T=(V==null?void 0:V.corner_radius)??x.corner_radius??0;if(x.geometry.type==="Text"){const q=V!=null&&V.geometry?this.deepMerge(x.geometry,V.geometry):x.geometry,iA=V!=null&&V.style?this.deepMerge(x.style,V.style):x.style;this._renderText(this.maskCtx,x,{...q,width:CA,height:F,corner_radius:T},iA,V,CA,F,!0)}else if(x.geometry.type==="Image"){const q=x.geometry.src;if(q){let iA=this.imageCache.get(q);iA||(iA=new Image,iA.src=q,this.imageCache.set(q,iA)),iA.complete&&iA.naturalWidth>0?this.maskCtx.drawImage(iA,-CA/2,-F/2,CA,F):(this.applyPath(this.maskCtx,x.geometry,CA,F,T),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(x.geometry.type==="SVG"){const q=x.geometry.svgContent;if(q){const iA=`__alphamask_${x.id}`;let RA=this.imageCache.get(iA);if(!RA){RA=new Image;const BA=new Blob([q],{type:"image/svg+xml"});RA.src=URL.createObjectURL(BA),RA.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(iA,RA)}RA.complete&&RA.naturalWidth>0?this.maskCtx.drawImage(RA,-CA/2,-F/2,CA,F):(this.applyPath(this.maskCtx,x.geometry,CA,F,T),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,x.geometry,CA,F,T),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),r.save(),r.setTransform(1,0,0,1,0,0);const H=I.maskBlendMode||I.blendMode;H&&H!=="Normal"&&(r.globalCompositeOperation=H.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 d;let s=C.text||"";if(C.textInputId&&!w){const R=this.inputs.get(C.textInputId);R!==void 0&&(s=String(R),Q.geometry&&Q.geometry.type==="Text"&&(Q.geometry.text=s))}let h=s||"";if(C.segments&&Array.isArray(C.segments)){const R=C.segments.map(m=>m&&m.text?m.text:"").join("");R!==h&&R.toUpperCase()===(s||"").toUpperCase()?h=s||"":h=R}let a=((d=C.fontWeight)==null?void 0:d.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(R=>{const m=new RegExp(`[\\s-]${R}$`,"i");m.test(S)&&(S=S.replace(m,"").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=R=>{if(e===0)return A.measureText(R).width;let m=0;for(let b=0;b<R.length;b++)m+=A.measureText(R[b]).width+e;return m-e},n=`${h}|${r}|${e}|${Y}`;let L=this.pretextCache.get(n);if(!L&&(L=KE(h,r),this.pretextCache.set(n,L),this.pretextCache.size>1e3)){const R=this.pretextCache.keys().next().value;R&&this.pretextCache.delete(R)}const P=L?ME(L,l,j):{height:0,lines:[]},wA=(P==null?void 0:P.height)??0,EA=(P==null?void 0:P.lines)??[];let u=wA;const z=this.getFontLeadingFactor(C.fontFamily||"Inter"),IA=(j-K)*z;let Z=Math.round(-u/2);i>0&&(N==="top"?Z=Math.round(-i/2):N==="middle"||N==="center"?Z=Math.round(-u/2):N==="bottom"&&(Z=Math.round(i/2-u))),Z+=IA;const p=(R,m,b,AA,sA)=>{var HA,NA,f;const kA=(!w||o)&&(I.behaviors||[]).some(W=>W.enabled&&(W.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(W.type)));if(e===0&&!kA&&(C.enableSegments!==!0||!C.segments||C.segments.length===0))AA?A.strokeText(R,m,b):A.fillText(R,m,b);else{const W=v(R);let H=m;M==="center"?H-=W/2:M==="right"&&(H-=W);let U=H;const x=w&&!o?[]:((HA=I.behaviors)==null?void 0:HA.filter(V=>[O.Typewriter,O.Scramble,O.Wave,O.Bounce,O.GlitchText,O.TextTrail,O.Reveal3D,O.RevealSlide,O.RevealBlur,O.TextLiquid,O.TextVortex,O.TextExplosion,O.TextRain,O.TextGravity,O.TextElastic,O.TextMatrix,O.TextNeon,O.TextGlitch3D,O.TextDissolve,O.TextOrganic,O.TextBreathe,O.TextFloral,O.TextSmoke,O.TextVariable,O.TextMagnet,O.TextSpin,O.TextZing,O.TextPerspective,O.TextMirror].includes(V.type)&&V.enabled))||[];for(let V=0;V<R.length;V++){let aA=R[V];const gA=sA+V;let KA=0,yA=0,CA=1,F=1,T=0,q=1,iA=aA;if(x.forEach(_=>{const $=_.settings||{},oA=$.strength||1,QA=Date.now();if(_.type===O.Typewriter)this.currentTime*($.speed||1)-gA*($.stagger||.05)<0&&(q=0);else if(_.type===O.Scramble)Math.max(0,Math.min(1,this.currentTime/($.duration||1.5))-gA*.02)<1&&Math.random()<.3&&(iA="$%#@!*&"[Math.floor(Math.random()*7)]);else if(_.type===O.Wave)yA+=Math.sin(this.currentTime*5*($.speed||1)+gA*($.frequency||1))*($.amplitude||20)*oA;else if(_.type===O.Bounce){const X=Math.max(0,this.currentTime%2-gA*($.stagger||.1));X<1&&(yA-=Math.abs(Math.sin(X*Math.PI))*($.height||50)*oA)}else if(_.type===O.TextTrail){const X=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-gA*($.delay||5))];X&&(KA+=(X.x-(Q.x+U))*oA*.2,yA+=(X.y-(Q.y+b+yA))*oA*.2)}else if(_.type===O.Reveal3D){const X=Math.max(0,Math.min(1,this.currentTime*($.speed||1)-gA*($.stagger||.1)));CA*=X,F*=X,q=X}else if(_.type===O.RevealSlide){const X=Math.max(0,Math.min(1,this.currentTime*1.5-gA*.05)),hA=(1-X)*($.distance||40)*oA,SA=$.direction||"up";SA==="up"?yA-=hA:SA==="down"?yA+=hA:SA==="left"?KA-=hA:SA==="right"&&(KA+=hA),q=X}else if(_.type===O.RevealBlur){const X=Math.max(0,Math.min(1,this.currentTime*1.2-gA*.1));q=X,KA+=(1-X)*5}else if(_.type===O.TextLiquid){const X=Math.max(0,Math.sin(QA*.001*($.speed||1)+gA*.5));yA+=X*($.amplitude||10)*oA,F*=1+X*.2}else if(_.type===O.TextVortex){const X=QA*.002*($.speed||1)+gA*.2,hA=(1-(Math.sin(QA*.001)*.5+.5))*($.radius||50);KA+=Math.cos(X)*hA*oA,yA+=Math.sin(X)*hA*oA}else if(_.type===O.TextExplosion){const X=$.force||1,hA=this.currentTime%2;if(hA<1){const SA=(gA/R.length-.5)*Math.PI*2,nA=hA*100*X;KA+=Math.cos(SA)*nA*oA,yA+=Math.sin(SA)*nA*oA,q=1-hA}}else if(_.type===O.TextRain){const X=$.speed||1,hA=$.height||100,SA=(QA*.001*X+gA*.1)%1;yA-=(1-SA)*hA*oA,q=SA>.1?1:SA*10}else if(_.type===O.TextGravity){const X=$.gravity||9.8,hA=this.currentTime%3/3,SA=.5*X*Math.pow(hA*10,2);SA<100?yA+=SA*oA:yA+=100*oA}else if(_.type===O.TextMatrix){const X=$.speed||1;if(Math.random()<.1*X){const SA="0123456789ABCDEF!@#$%^&*";iA=SA[Math.floor(Math.random()*SA.length)]}q=.3+(Math.sin(QA*.01*X+gA)+1)/2*.7}else if(_.type===O.TextNeon){const X=Math.random()>.95?.5:1;q=(.7+(Math.sin(QA*.005)+1)/2*.3)*X}else if(_.type===O.TextDissolve)Math.sin(gA*1.5+QA*.002*($.speed||1))>.5&&(q=0);else if(_.type===O.TextOrganic){const X=$.speed||1,hA=$.amplitude||10;KA+=Math.sin(QA*.002*X+gA)*hA*oA,yA+=Math.cos(QA*.0015*X+gA*.7)*hA*oA}else if(_.type===O.TextBreathe){const hA=1+(Math.sin(QA*.003+gA*.2)+1)/2*.2*oA;CA*=hA,F*=hA}else if(_.type===O.TextSpin){const X=$.speed||1;T+=QA*.01*X+gA}else if(_.type===O.TextMagnet){const X=this.pointerHistory[this.pointerHistory.length-1];if(X){const hA=X.x-(Q.x+U),SA=X.y-(Q.y+b);T=Math.atan2(SA,hA)}}else if(_.type===O.TextPerspective){const X=R.length/2,hA=(gA-X)/X,SA=1-Math.abs(hA)*.3*oA;CA*=SA,F*=SA,KA+=hA*20*oA}else if(_.type===O.TextMirror)q*=.8;else if(_.type===O.TextFloral){const X=$.speed||1,hA=$.stagger||.1,SA=(QA*.001*X+gA*hA)%2;SA<1&&(CA*=SA,F*=SA,T+=SA*Math.PI)}else if(_.type===O.TextSmoke){const X=$.speed||1,hA=$.height||50,SA=(QA*5e-4*X+gA*.2)%1;yA-=SA*hA*oA,KA+=Math.sin(QA*.002+gA)*5*oA,q=1-SA}else if(_.type===O.TextVariable){const X=$.speed||1,hA=$.intensity||1.5,SA=(Math.sin(QA*.004*X+gA*.3)+1)/2;CA*=1+SA*(hA-1)*oA}else if(_.type===O.TextZing){const X=$.speed||2,hA=$.distance||100,SA=(QA*.002*X+gA*.05)%1;KA+=(1-SA)*hA*oA,q=SA}else if(_.type===O.TextElastic){const X=$.stiffness||.2,hA=$.damping||.1,SA=Math.sin(QA*.01)*Math.exp(-QA*.001*hA);F*=1+SA*X*oA}else if(_.type===O.TextGlitch3D){const X=$.intensity||5;Math.random()<.2&&(KA+=(Math.random()-.5)*X,yA+=(Math.random()-.5)*X,q=.8)}else if(_.type===O.GlitchText){const X=$.intensity||5;Math.random()<.1&&(KA+=(Math.random()-.5)*X,yA+=(Math.random()-.5)*X,Math.random()<.05&&(q=.5))}}),q<=0){U+=A.measureText(aA).width+e;continue}if(C.enableSegments===!0&&((NA=C.segments)==null?void 0:NA.length)>0){let _=0,$=null;for(const oA of C.segments){if(gA<_+(oA.text||"").length){$=oA;break}_+=(oA.text||"").length}if($){let oA=$.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(($.fontWeight||C.fontWeight||"400").toString())} ${$.fontSize||K}px "${oA}", sans-serif`}}const RA=A.globalAlpha;A.globalAlpha*=q,A.save();const BA=A.measureText(iA).width;if(A.translate(U+KA+BA/2,b+yA),T!==0&&A.rotate(T),A.scale(CA,F),w||o){const _=o?"#000000":this.createCanvasFill(A,g.fill,E,i);A.fillStyle=_||g.fill.color||"#ffffff",A.fillText(iA,-BA/2,0)}else AA?A.strokeText(iA,-BA/2,0):A.fillText(iA,-BA/2,0);A.restore(),A.globalAlpha=RA,C.enableSegments===!0&&((f=C.segments)==null?void 0:f.length)>0&&(A.font=`${G} ${this.mapFontWeight((C.fontWeight||"400").toString())} ${K}px "${C.fontFamily||"Inter"}", sans-serif`),U+=A.measureText(aA).width+e}}};if(w){let R=0,m=Z;(EA||[]).forEach(b=>{let AA=-E/2;M==="center"?AA=0:M==="right"&&(AA=E/2),p(b.text,AA,m,!1,R),R+=(b.text||"").length+1,m+=j})}else if(o){let R=0,m=Z;(EA||[]).forEach(b=>{let AA=-E/2;M==="center"?AA=0:M==="right"&&(AA=E/2),p(b.text,AA,m,!1,R),R+=(b.text||"").length+1,m+=j})}else{if(g.fill){const R=A.globalAlpha,m=this.createCanvasFill(A,g.fill,E,i);A.fillStyle=m||g.fill.color||"#000000",A.globalAlpha=R*this.normalizeOpacity(g.fill.opacity??100);let b=0,AA=Z;(EA||[]).forEach(sA=>{let kA=Math.round(-E/2);M==="center"?kA=0:M==="right"&&(kA=Math.round(E/2)),p(sA.text,kA,AA,!1,b),b+=(sA.text||"").length+1,AA+=j}),A.globalAlpha=R}if(g.stroke&&g.stroke.width>0){const R=A.globalAlpha;A.strokeStyle=g.stroke.color,A.lineWidth=g.stroke.width,A.globalAlpha=R*this.normalizeOpacity(g.stroke.opacity??100);let m=0,b=Z;(EA||[]).forEach(AA=>{let sA=Math.round(-E/2);M==="center"?sA=0:M==="right"&&(sA=Math.round(E/2)),p(AA.text,sA,b,!0,m),m+=(AA.text||"").length+1,b+=j}),A.globalAlpha=R}}}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 kA,HA;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((kA=I.geometry)==null?void 0:kA.width)||250,E=((HA=I.geometry)==null?void 0:HA.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(f=>f+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 L=(NA,f)=>{if(!NA.visible||!NA.svgPath)return;const W=NA.size||14,H=NA.offset??16,U=NA.color||"#ffffff",x=f?-(Q/2)+H:Q/2-H,V=NA.svgPath;if(A.save(),A.translate(x,0),!V.startsWith("<svg")){const aA=new Path2D(V),gA=W/24;A.scale(gA,gA),A.translate(-12,-12),A.fillStyle=U,A.fill(aA)}A.restore()};L(G,!0),L(t,!1);const P=g.text||"",wA=g.placeholder||"Enter text...",EA=!P,u=P||wA,z=EA?l:j,IA=r,Z=g.fontFamily||"Inter",p=g.fontWeight||400;A.font=`${p} ${IA}px "${Z}", sans-serif`,A.fillStyle=z,A.textAlign="left",A.textBaseline=K?"top":"middle";const d=g.inputPadding??16,R=G.visible?(G.offset??16)+(G.size||14)/2+8:d,m=t.visible?(t.offset??16)+(t.size||14)/2+8:d,b=-(Q/2)+R,AA=Q-R-m,sA=g.inputType==="password"?"•".repeat(u.length):u;if(A.save(),A.beginPath(),A.rect(b-2,-E/2+4,AA+4,E-8),A.clip(),K){const NA=sA.split(`
|
|
22
|
-
`);let f=-E/2+d;const W=IA*1.2;let H=0;NA.forEach((U,x)=>{const V=U.split(" ");let aA="";for(let gA=0;gA<V.length;gA++){const KA=aA+V[gA]+" ";A.measureText(KA).width>AA&&gA>0?(A.fillText(aA,b,f),aA=V[gA]+" ",f+=W):aA=KA}A.fillText(aA,b,f),H=A.measureText(aA).width,x<NA.length-1&&(f+=W,H=0)}),i&&!EA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(b+H,f,1.5,IA)}else{const f=A.measureText(sA).width;let W=0;if(f>AA&&(W=f-AA),A.fillText(sA,b-W,0),i&&!EA&&Math.floor(performance.now()/500)%2===0){const U=b+f-W;A.fillRect(U,-(IA/2),1.5,IA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",f=h.fontSize||12,W=h.color||"rgba(156, 163, 175, 1)",H=h.offset??8;A.font=`600 ${f}px "${Z}", sans-serif`,A.fillStyle=W,A.textAlign="left",A.textBaseline="bottom";const U=-(Q/2),x=-(E/2)-H;A.fillText(NA,U,x)}if(a.visible===!0){const NA=a.text||"Helper text",f=a.fontSize||11,W=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",H=a.offset??6;A.font=`400 ${f}px "${Z}", sans-serif`,A.fillStyle=W,A.textAlign="left",A.textBaseline="top";const U=-(Q/2),x=E/2+H;A.fillText(NA,U,x)}}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",L=Q.tooltipColor||"#ffffff",P=Q.tooltipOffsetX??0,wA=Q.tooltipOffsetY??-25,EA=(R,m,b,AA,sA,kA,HA)=>{if((R==="Custom"||R==="Icon")&&HA)try{const NA=new Path2D(HA);if(A.save(),A.translate(m,b),R==="Icon"){const f=Math.min(AA,sA)/24;A.scale(f,f),A.translate(-12,-12)}A.fill(NA),A.restore();return}catch(NA){console.error("Error drawing slider shape in engine:",NA)}if(A.beginPath(),R==="Ellipse")A.ellipse(m,b,AA/2,sA/2,0,0,Math.PI*2);else if(R==="Rectangle")this.drawRoundRect(A,m-AA/2,b-sA/2,AA,sA,kA);else if(R==="Triangle")A.moveTo(m,b-sA/2),A.lineTo(m+AA/2,b+sA/2),A.lineTo(m-AA/2,b+sA/2),A.closePath();else if(R==="Diamond")A.moveTo(m,b-sA/2),A.lineTo(m+AA/2,b),A.lineTo(m,b+sA/2),A.lineTo(m-AA/2,b),A.closePath();else if(R==="Polygon"){const NA=I.geometry.sides||3,f=I.geometry.radius||Math.min(AA,sA)/2;for(let W=0;W<NA;W++){const H=W*2*Math.PI/NA-Math.PI/2,U=m+f*Math.cos(H),x=b+f*Math.sin(H);W===0?A.moveTo(U,x):A.lineTo(U,x)}A.closePath()}else if(R==="Star"){const f=Math.min(AA,sA)/2,W=f/2;for(let H=0;H<5*2;H++){const U=H%2===0?f:W,x=H*Math.PI/5-Math.PI/2;A.lineTo(m+U*Math.cos(x),b+U*Math.sin(x))}A.closePath()}else R==="Line"&&(A.moveTo(m-AA/2,b),A.lineTo(m+AA/2,b));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 u=E-M,z=-E/2+M/2+h*u,IA=z- -E/2;if(IA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(z,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,IA,a,G),A.fill())),A.save(),A.translate(z,0),A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4,A.shadowOffsetY=1,A.fillStyle=j,EA(N,0,0,M,e,Y,N==="Icon"?r:l),A.restore(),v){A.save(),A.translate(z+P,wA);const R=Math.round(i).toString();A.font="10px Inter, sans-serif";const m=A.measureText(R),b=6,AA=4,sA=m.width+b*2,kA=14+AA;A.beginPath(),this.drawRoundRect(A,-sA/2,-kA/2,sA,kA,4),A.fillStyle=n,A.fill(),A.fillStyle=L,A.textAlign="center",A.textBaseline="middle",A.fillText(R,0,0),A.restore()}const Z=Q.label||{},p=Q.helperText||{},d=Q.fontFamily||"Inter";if(Z.visible!==!1){const R=Z.text||"Label",m=Z.fontSize||12,b=Z.color||"rgba(156, 163, 175, 1)",AA=Z.offset??8;A.font=`600 ${m}px "${d}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="bottom";const sA=-(E/2),kA=-(a/2)-AA;A.fillText(R,sA,kA)}if(p.visible===!0){const R=p.text||"Helper text",m=p.fontSize||11,b=p.color||"rgba(156, 163, 175, 1)",AA=p.offset??6;A.font=`400 ${m}px "${d}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="top";const sA=-(E/2),kA=a/2+AA;A.fillText(R,sA,kA)}}renderDropdown(A,I){var wA;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 u=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(u*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 z=a&&g.openIconPath||g.closedIconPath;if(z){const IA=new Path2D(z);A.save();const Z=e/24;A.scale(Z,Z),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 L=M==="none"?0:e+8,P=Q-N*2-L;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,u=g.optionsList||[],z=g.itemHeight||32,IA=g.listPadding??4,Z=u.length*z+IA*2,p=g.listCornerRadius??o;A.save();const d=g.listShadow||{};A.shadowColor=typeof d.color=="string"?d.color:((wA=d.color)==null?void 0:wA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=d.blur??12,A.shadowOffsetY=d.offsetY??6,A.beginPath(),this.drawRoundRect(A,i,EA,Q,Z,p),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,Z)||"#ffffff",A.fill();const R=g.listBorderWidth??1;R>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,Z)||"#e5e7eb",A.lineWidth=R,A.stroke()),A.restore();const m=g.itemFontSize||l,b=g.itemFontFamily||v;A.font=`${r} ${m}px ${b}`,u.forEach((AA,sA)=>{const kA=EA+IA+sA*z;if(AA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,z)||"#f3f4f6",A.fillRect(i+R,kA,Q-R*2,z),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const NA=this._lastPointerPos.y-(EA+IA),f=Math.floor(NA/z);sA===f&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,z)||"#f9fafb",A.fillRect(i+R,kA,Q-R*2,z),A.fillStyle=g.itemHoverColor||K)}A.fillText(AA,i+N,kA+z/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),L=l/24;A.scale(L,L),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,u,z,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:((u=I.geometry)==null?void 0:u.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=(z=r.stops)==null?void 0:z[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&&(A.shadowColor=v,A.shadowBlur=l*2,A.shadowOffsetX=0,A.shadowOffsetY=0),y){const Z=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",p=this.createCanvasFill(A,Z,Q,E);A.fillStyle=p||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,Q,E,o),A.fill();const d=A.createLinearGradient(i,w,i+Q,w+E);d.addColorStop(0,"rgba(255, 255, 255, 0.15)"),d.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),d.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=d,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 Z=g.listBackgroundColor||"transparent",p=this.createCanvasFill(A,Z,Q,E);p&&(A.fillStyle=p,this.drawListViewRect(A,i,w,Q,E,o),A.fill());const d=g.borderWidth??0;d>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=d,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 L=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let P=(s==="vertical"?w:i)+K+L;if(A.textBaseline="middle",h.forEach((Z,p)=>{const d=s==="vertical"?Q:t,R=s==="vertical"?G:E,m=s==="vertical"?i:P,b=s==="vertical"?P:w,AA=Y===p,sA=j===p;if(sA){const W=this.createCanvasFill(A,N,d,R);A.fillStyle=W||N;const H=A.globalAlpha;A.globalAlpha=H*.8,A.fillRect(m,b,d,R),A.globalAlpha=H}else if(AA)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(m,b,d,R);else if(e!=="transparent"){const W=this.createCanvasFill(A,e,d,R);A.fillStyle=W||e,A.fillRect(m,b,d,R)}if(sA||AA){const W=this.createCanvasFill(A,N,s==="vertical"?3:d,s==="vertical"?R:3);A.fillStyle=W||N,s==="vertical"?A.fillRect(m,b,3,R):A.fillRect(m,b+R-3,d,3)}const kA=sA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":M;A.fillStyle=kA,A.font=sA||AA?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const HA=typeof Z=="string"?Z:(Z==null?void 0:Z.label)||`Item ${p+1}`,NA=m+(s==="vertical"?16:d/2),f=b+R/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(HA,NA,f),P+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const Z=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,p=s==="vertical"?E:Q;if(Z>p){const d=p/Z,R=p*d,m=-K/Z*p,b=g.scrollbarColor||"rgba(255,255,255,0.3)",AA=g.scrollbarWidth||4;A.fillStyle=b,s==="vertical"?A.fillRect(i+Q-AA-2,w+m,AA,R):A.fillRect(i+m,w+E-AA-2,R,AA)}}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 L,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:((L=A.geometry)==null?void 0:L.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 wA=0;wA<E.length;wA++){const EA=o==="vertical"?i:a,u=o==="vertical"?h:w,z=o==="vertical"?l:n,IA=o==="vertical"?n:r;if(Y>=z&&Y<=z+EA&&j>=IA&&j<=IA+u)return wA;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,L,P,wA,EA,u,z,IA,Z,p,d,R,m,b,AA,sA,kA,HA,NA,f,W,H,U,x,V,aA,gA,KA,yA,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===O.Proximity){const F=((a=E.settings)==null?void 0:a.radius)||300,T=((G=E.settings)==null?void 0:G.falloff)||"smooth";let q=0;h<F&&(T==="linear"?q=1-h/F:q=Math.pow(1-h/F,2)),q>0&&E.sensors.forEach(iA=>{this.applyBehaviorSensor(Q,iA,q,A,E.settings)})}else if(E.type===O.Magnetic){const F=((t=E.settings)==null?void 0:t.radius)||400,T=((K=E.settings)==null?void 0:K.strength)||.5;if(h<F&&h>5){const q=1-h/F,iA=o*q*T,RA=s*q*T;Q.x-=iA*A*10,Q.y-=RA*A*10}}else if(E.type===O.Repel){const F=((S=E.settings)==null?void 0:S.radius)||300,T=((y=E.settings)==null?void 0:y.strength)||1;if(h<F){const q=Math.pow(1-h/F,2);Q.x+=o/(h||1)*q*60*T*A*5,Q.y+=s/(h||1)*q*60*T*A*5}}else if(E.type===O.Orbit){const F=((N=E.settings)==null?void 0:N.speed)||1,T=((M=E.settings)==null?void 0:M.radius)||30,q=this.currentTime*F*Math.PI*2;Q.x+=Math.cos(q)*T*A*5,Q.y+=Math.sin(q)*T*A*5,Q.rotation+=2*A*5}else if(E.type===O.Vortex){const F=((e=E.settings)==null?void 0:e.radius)||400,T=((Y=E.settings)==null?void 0:Y.speed)||2,q=((j=E.settings)==null?void 0:j.strength)||1;if(h<F){const iA=Math.pow(1-h/F,1.5),RA=this.currentTime*T*Math.PI*2,BA=Math.cos(RA)*30-o*.4,_=Math.sin(RA)*30-s*.4;Q.x+=BA*iA*q*A*5,Q.y+=_*iA*q*A*5,Q.rotation+=5*iA*q*A*5,Q.scale_x*=1-iA*.1*q*A,Q.scale_y*=1-iA*.1*q*A}}else if(E.type===O.Fluid){const F=((l=E.settings)==null?void 0:l.radius)||300,T=((r=E.settings)==null?void 0:r.strength)||1;if(h<F){const q=Math.pow(1-h/F,1.2),iA=o/(h||1)*q*1.2*T,RA=s/(h||1)*q*1.2*T;Q.x+=iA*10*A*5,Q.y+=RA*10*A*5,Q.scale_x*=1+q*.3*T*A,Q.scale_y*=1+q*.3*T*A}}else if(E.type===O.Elastic){const F=((v=E.settings)==null?void 0:v.radius)||300,T=((n=E.settings)==null?void 0:n.strength)||1;if(h<F){const q=1-h/F;Q.scale_x*=1+q*.4*T*A,Q.scale_y*=1+q*.4*T*A}}else if(E.type===O.Holographic){const F=Q.x-this.canvasWidth/2,T=Q.y-this.canvasHeight/2,q=((L=E.settings)==null?void 0:L.factor)||25;if(Q.x-=F/1e3*q*A*5,Q.y-=T/1e3*q*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===O.Sticky){const F=((P=E.settings)==null?void 0:P.radius)||80,T=((wA=E.settings)==null?void 0:wA.strength)||1;if(h<F){const q=Math.pow(1-h/F,2);Q.x-=o*q*T*A*10,Q.y-=s*q*T*A*10,Q.scale_x*=1-q*.1*T*A,Q.scale_y*=1-q*.1*T*A}}else if(E.type===O.Dilation){const F=((EA=E.settings)==null?void 0:EA.size)||120,T=((u=E.settings)==null?void 0:u.strength)||1;if(h<F){const q=1-h/F;Q.scale_x*=1+q*.5*T*A,Q.scale_y*=1+q*.5*T*A}}else if(E.type===O.Parallax){const F=((z=E.settings)==null?void 0:z.factor)||.05,T=this.canvasHeight/2,q=(this._lastPointerPos.y-T)*F;Q.y+=q*A*10}else if(E.type===O.Noise||E.type===O.Float){const F=(((IA=E.settings)==null?void 0:IA.frequency)||((Z=E.settings)==null?void 0:Z.speed)||1)*.002,T=(((p=E.settings)==null?void 0:p.amplitude)||((d=E.settings)==null?void 0:d.range)||50)*(((R=E.settings)==null?void 0:R.strength)||1),q=Date.now();Q.x+=Math.sin(q*F)*T*A,Q.y+=Math.cos(q*F*.8)*T*A,Q.rotation+=Math.sin(q*F*.5)*5*A}else if(E.type===O.Pulse){const F=(((m=E.settings)==null?void 0:m.speed)||1)*.005,T=(((b=E.settings)==null?void 0:b.scale)||1.2)-1,q=Math.sin(Date.now()*F),iA=((AA=E.settings)==null?void 0:AA.strength)||1;Q.scale_x*=1+q*T*iA*A,Q.scale_y*=1+q*T*iA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,q)*.1*iA*A)}else if(E.type===O.Draggable){const F=((sA=E.settings)==null?void 0:sA.radius)||150,T=this.draggingBehaviors.has(g.id);if(h<F||T){const q=((kA=E.settings)==null?void 0:kA.strength)||1,iA=T?1:Math.max(0,1-h/F);this.applyBehaviorSensor(Q,uA.PositionX,iA*q,A,E.settings),this.applyBehaviorSensor(Q,uA.PositionY,iA*q,A,E.settings)}}else if(E.type===O.Scroll){const F=((HA=E.settings)==null?void 0:HA.axis)||"vertical",T=((NA=E.settings)==null?void 0:NA.factor)||.5,q=((f=E.settings)==null?void 0:f.strength)||1;(F==="vertical"||F==="both")&&(Q.y+=this.scrollOffset.y*T*q*A),(F==="horizontal"||F==="both")&&(Q.x+=this.scrollOffset.x*T*q*A)}else if(E.type===O.LookAt){const F=((W=E.settings)==null?void 0:W.factor)||1,T=((H=E.settings)==null?void 0:H.strength)||1,q=Math.atan2(-s,-o)*(180/Math.PI),iA=Q.rotation,RA=(q-iA+180)%360-180;Q.rotation+=RA*F*T*A*10}else if(E.type===O.Glint||E.type===O.Scan){const F=(((U=E.settings)==null?void 0:U.speed)||1)*.004,T=((x=E.settings)==null?void 0:x.strength)||1,q=(Math.sin(Date.now()*F)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+q*T*A*5),Q.x+=(q-.5)*20*T*A}else if(E.type===O.Ratchet){const F=((V=E.settings)==null?void 0:V.steps)||12,T=(((aA=E.settings)==null?void 0:aA.speed)||1)*30,q=Math.floor(Q.rotation/(360/F))*(360/F);Q.rotation=this.lerp(Q.rotation,q+T*A,.1)}else if(E.type===O.Jitter&&h<300){const F=((gA=E.settings)==null?void 0:gA.strength)||1,T=(((KA=E.settings)==null?void 0:KA.intensity)||5)*F;Q.x+=(Math.random()-.5)*T*A*60,Q.y+=(Math.random()-.5)*T*A*60,Q.rotation+=(Math.random()-.5)*T*A*120}else if(E.type===O.Follower){const F=(yA=E.settings)==null?void 0:yA.targetId;if(F){const T=this.objectStates.get(F);if(T){const q=((CA=E.settings)==null?void 0:CA.stiffness)||.1,iA=T.x-Q.x,RA=T.y-Q.y;Q.x+=iA*q*A*60,Q.y+=RA*q*A*60}}}else E.type===O.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=cA.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=cA.useRef(null),N=cA.useRef(new xQ),M=cA.useRef(),e=cA.useRef(0),Y=cA.useRef(null);cA.useImperativeHandle(S,()=>y.current),cA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),N.current.setLayout(Q,E)},[Q,E]),cA.useEffect(()=>{w&&N.current.setTriggerCallback(w)},[w]),cA.useEffect(()=>{o&&N.current.setInputUpdateCallback(o)},[o]),cA.useEffect(()=>{s&&N.current.setComponentChangeCallback(s)},[s]),cA.useEffect(()=>{h&&N.current.setToggleCallback(h)},[h]),cA.useEffect(()=>{a&&N.current.setInputChangeCallback(a)},[a]),cA.useEffect(()=>{G&&N.current.setInputFocusCallback(G)},[G]),cA.useEffect(()=>{t&&N.current.setInputBlurCallback(t)},[t]),cA.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]),cA.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 wA=(P-e.current)/1e3;e.current=P,g&&l.advance(wA);const EA=window.devicePixelRatio||1,u=r.getBoundingClientRect(),z=Math.floor(u.width*EA),IA=Math.floor(u.height*EA);(r.width!==z||r.height!==IA)&&(r.width=z,r.height=IA),l.render(v,z,IA),M.current=requestAnimationFrame(n)};M.current=requestAnimationFrame(n);const L=()=>{l.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",L,{passive:!0}),()=>{M.current&&cancelAnimationFrame(M.current),window.removeEventListener("scroll",L)}},[g]);const j=(l,r)=>{const v=l.currentTarget.getBoundingClientRect(),n=l.clientX-v.left,L=l.clientY-v.top,P=v.width,wA=v.height;N.current.handlePointerInput(r,n,L,P,wA)};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]=cA.useState(null),I=cA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=cA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=cA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=cA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=cA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=cA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=cA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=cA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=cA.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.18";pA.BehaviorSensor=uA,pA.BehaviorType=O,pA.ConditionOp=tC,pA.ExodeUICanvas=$E,pA.ExodeUIEngine=xQ,pA.LogicOp=NI,pA.VERSION=Ii,pA.useExodeUI=Ai,Object.defineProperty(pA,Symbol.toStringTag,{value:"Module"})});
|
|
22
|
+
`);let f=-E/2+d;const W=IA*1.2;let H=0;NA.forEach((U,x)=>{const V=U.split(" ");let aA="";for(let gA=0;gA<V.length;gA++){const KA=aA+V[gA]+" ";A.measureText(KA).width>AA&&gA>0?(A.fillText(aA,b,f),aA=V[gA]+" ",f+=W):aA=KA}A.fillText(aA,b,f),H=A.measureText(aA).width,x<NA.length-1&&(f+=W,H=0)}),i&&!EA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(b+H,f,1.5,IA)}else{const f=A.measureText(sA).width;let W=0;if(f>AA&&(W=f-AA),A.fillText(sA,b-W,0),i&&!EA&&Math.floor(performance.now()/500)%2===0){const U=b+f-W;A.fillRect(U,-(IA/2),1.5,IA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",f=h.fontSize||12,W=h.color||"rgba(156, 163, 175, 1)",H=h.offset??8;A.font=`600 ${f}px "${Z}", sans-serif`,A.fillStyle=W,A.textAlign="left",A.textBaseline="bottom";const U=-(Q/2),x=-(E/2)-H;A.fillText(NA,U,x)}if(a.visible===!0){const NA=a.text||"Helper text",f=a.fontSize||11,W=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",H=a.offset??6;A.font=`400 ${f}px "${Z}", sans-serif`,A.fillStyle=W,A.textAlign="left",A.textBaseline="top";const U=-(Q/2),x=E/2+H;A.fillText(NA,U,x)}}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",L=Q.tooltipColor||"#ffffff",P=Q.tooltipOffsetX??0,wA=Q.tooltipOffsetY??-25,EA=(R,m,b,AA,sA,kA,HA)=>{if((R==="Custom"||R==="Icon")&&HA)try{const NA=new Path2D(HA);if(A.save(),A.translate(m,b),R==="Icon"){const f=Math.min(AA,sA)/24;A.scale(f,f),A.translate(-12,-12)}A.fill(NA),A.restore();return}catch(NA){console.error("Error drawing slider shape in engine:",NA)}if(A.beginPath(),R==="Ellipse")A.ellipse(m,b,AA/2,sA/2,0,0,Math.PI*2);else if(R==="Rectangle")this.drawRoundRect(A,m-AA/2,b-sA/2,AA,sA,kA);else if(R==="Triangle")A.moveTo(m,b-sA/2),A.lineTo(m+AA/2,b+sA/2),A.lineTo(m-AA/2,b+sA/2),A.closePath();else if(R==="Diamond")A.moveTo(m,b-sA/2),A.lineTo(m+AA/2,b),A.lineTo(m,b+sA/2),A.lineTo(m-AA/2,b),A.closePath();else if(R==="Polygon"){const NA=I.geometry.sides||3,f=I.geometry.radius||Math.min(AA,sA)/2;for(let W=0;W<NA;W++){const H=W*2*Math.PI/NA-Math.PI/2,U=m+f*Math.cos(H),x=b+f*Math.sin(H);W===0?A.moveTo(U,x):A.lineTo(U,x)}A.closePath()}else if(R==="Star"){const f=Math.min(AA,sA)/2,W=f/2;for(let H=0;H<5*2;H++){const U=H%2===0?f:W,x=H*Math.PI/5-Math.PI/2;A.lineTo(m+U*Math.cos(x),b+U*Math.sin(x))}A.closePath()}else R==="Line"&&(A.moveTo(m-AA/2,b),A.lineTo(m+AA/2,b));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 u=E-M,z=-E/2+M/2+h*u,IA=z- -E/2;if(IA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(z,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,IA,a,G),A.fill())),A.save(),A.translate(z,0),A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4,A.shadowOffsetY=1,A.fillStyle=j,EA(N,0,0,M,e,Y,N==="Icon"?r:l),A.restore(),v){A.save(),A.translate(z+P,wA);const R=Math.round(i).toString();A.font="10px Inter, sans-serif";const m=A.measureText(R),b=6,AA=4,sA=m.width+b*2,kA=14+AA;A.beginPath(),this.drawRoundRect(A,-sA/2,-kA/2,sA,kA,4),A.fillStyle=n,A.fill(),A.fillStyle=L,A.textAlign="center",A.textBaseline="middle",A.fillText(R,0,0),A.restore()}const Z=Q.label||{},p=Q.helperText||{},d=Q.fontFamily||"Inter";if(Z.visible!==!1){const R=Z.text||"Label",m=Z.fontSize||12,b=Z.color||"rgba(156, 163, 175, 1)",AA=Z.offset??8;A.font=`600 ${m}px "${d}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="bottom";const sA=-(E/2),kA=-(a/2)-AA;A.fillText(R,sA,kA)}if(p.visible===!0){const R=p.text||"Helper text",m=p.fontSize||11,b=p.color||"rgba(156, 163, 175, 1)",AA=p.offset??6;A.font=`400 ${m}px "${d}", sans-serif`,A.fillStyle=b,A.textAlign="left",A.textBaseline="top";const sA=-(E/2),kA=a/2+AA;A.fillText(R,sA,kA)}}renderDropdown(A,I){var wA;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 u=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(u*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 z=a&&g.openIconPath||g.closedIconPath;if(z){const IA=new Path2D(z);A.save();const Z=e/24;A.scale(Z,Z),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 L=M==="none"?0:e+8,P=Q-N*2-L;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,u=g.optionsList||[],z=g.itemHeight||32,IA=g.listPadding??4,Z=u.length*z+IA*2,p=g.listCornerRadius??o;A.save();const d=g.listShadow||{};A.shadowColor=typeof d.color=="string"?d.color:((wA=d.color)==null?void 0:wA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=d.blur??12,A.shadowOffsetY=d.offsetY??6,A.beginPath(),this.drawRoundRect(A,i,EA,Q,Z,p),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,Z)||"#ffffff",A.fill();const R=g.listBorderWidth??1;R>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,Z)||"#e5e7eb",A.lineWidth=R,A.stroke()),A.restore();const m=g.itemFontSize||l,b=g.itemFontFamily||v;A.font=`${r} ${m}px ${b}`,u.forEach((AA,sA)=>{const kA=EA+IA+sA*z;if(AA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,z)||"#f3f4f6",A.fillRect(i+R,kA,Q-R*2,z),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const NA=this._lastPointerPos.y-(EA+IA),f=Math.floor(NA/z);sA===f&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,z)||"#f9fafb",A.fillRect(i+R,kA,Q-R*2,z),A.fillStyle=g.itemHoverColor||K)}A.fillText(AA,i+N,kA+z/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),L=l/24;A.scale(L,L),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,u,z,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:((u=I.geometry)==null?void 0:u.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=(z=r.stops)==null?void 0:z[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&&(A.shadowColor=v,A.shadowBlur=l*2,A.shadowOffsetX=0,A.shadowOffsetY=0),y){const Z=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",p=this.createCanvasFill(A,Z,Q,E);A.fillStyle=p||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,w,Q,E,o),A.fill();const d=A.createLinearGradient(i,w,i+Q,w+E);d.addColorStop(0,"rgba(255, 255, 255, 0.15)"),d.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),d.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=d,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 Z=g.listBackgroundColor||"transparent",p=this.createCanvasFill(A,Z,Q,E);p&&(A.fillStyle=p,this.drawListViewRect(A,i,w,Q,E,o),A.fill());const d=g.borderWidth??0;d>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=d,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 L=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let P=(s==="vertical"?w:i)+K+L;if(A.textBaseline="middle",h.forEach((Z,p)=>{const d=s==="vertical"?Q:t,R=s==="vertical"?G:E,m=s==="vertical"?i:P,b=s==="vertical"?P:w,AA=Y===p,sA=j===p;if(sA){const W=this.createCanvasFill(A,N,d,R);A.fillStyle=W||N;const H=A.globalAlpha;A.globalAlpha=H*.8,A.fillRect(m,b,d,R),A.globalAlpha=H}else if(AA)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(m,b,d,R);else if(e!=="transparent"){const W=this.createCanvasFill(A,e,d,R);A.fillStyle=W||e,A.fillRect(m,b,d,R)}if(sA||AA){const W=this.createCanvasFill(A,N,s==="vertical"?3:d,s==="vertical"?R:3);A.fillStyle=W||N,s==="vertical"?A.fillRect(m,b,3,R):A.fillRect(m,b+R-3,d,3)}const kA=sA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":M;A.fillStyle=kA,A.font=sA||AA?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const HA=typeof Z=="string"?Z:(Z==null?void 0:Z.label)||`Item ${p+1}`,NA=m+(s==="vertical"?16:d/2),f=b+R/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(HA,NA,f),P+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const Z=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,p=s==="vertical"?E:Q;if(Z>p){const d=p/Z,R=p*d,m=-K/Z*p,b=g.scrollbarColor||"rgba(255,255,255,0.3)",AA=g.scrollbarWidth||4;A.fillStyle=b,s==="vertical"?A.fillRect(i+Q-AA-2,w+m,AA,R):A.fillRect(i+m,w+E-AA-2,R,AA)}}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 L,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:((L=A.geometry)==null?void 0:L.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 wA=0;wA<E.length;wA++){const EA=o==="vertical"?i:a,u=o==="vertical"?h:w,z=o==="vertical"?l:n,IA=o==="vertical"?n:r;if(Y>=z&&Y<=z+EA&&j>=IA&&j<=IA+u)return wA;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,L,P,wA,EA,u,z,IA,Z,p,d,R,m,b,AA,sA,kA,HA,NA,f,W,H,U,x,V,aA,gA,KA,yA,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===O.Proximity){const F=((a=E.settings)==null?void 0:a.radius)||300,T=((G=E.settings)==null?void 0:G.falloff)||"smooth";let q=0;h<F&&(T==="linear"?q=1-h/F:q=Math.pow(1-h/F,2)),q>0&&E.sensors.forEach(iA=>{this.applyBehaviorSensor(Q,iA,q,A,E.settings)})}else if(E.type===O.Magnetic){const F=((t=E.settings)==null?void 0:t.radius)||400,T=((K=E.settings)==null?void 0:K.strength)||.5;if(h<F&&h>5){const q=1-h/F,iA=o*q*T,RA=s*q*T;Q.x-=iA*A*10,Q.y-=RA*A*10}}else if(E.type===O.Repel){const F=((S=E.settings)==null?void 0:S.radius)||300,T=((y=E.settings)==null?void 0:y.strength)||1;if(h<F){const q=Math.pow(1-h/F,2);Q.x+=o/(h||1)*q*60*T*A*5,Q.y+=s/(h||1)*q*60*T*A*5}}else if(E.type===O.Orbit){const F=((N=E.settings)==null?void 0:N.speed)||1,T=((M=E.settings)==null?void 0:M.radius)||30,q=this.currentTime*F*Math.PI*2;Q.x+=Math.cos(q)*T*A*5,Q.y+=Math.sin(q)*T*A*5,Q.rotation+=2*A*5}else if(E.type===O.Vortex){const F=((e=E.settings)==null?void 0:e.radius)||400,T=((Y=E.settings)==null?void 0:Y.speed)||2,q=((j=E.settings)==null?void 0:j.strength)||1;if(h<F){const iA=Math.pow(1-h/F,1.5),RA=this.currentTime*T*Math.PI*2,BA=Math.cos(RA)*30-o*.4,_=Math.sin(RA)*30-s*.4;Q.x+=BA*iA*q*A*5,Q.y+=_*iA*q*A*5,Q.rotation+=5*iA*q*A*5,Q.scale_x*=1-iA*.1*q*A,Q.scale_y*=1-iA*.1*q*A}}else if(E.type===O.Fluid){const F=((l=E.settings)==null?void 0:l.radius)||300,T=((r=E.settings)==null?void 0:r.strength)||1;if(h<F){const q=Math.pow(1-h/F,1.2),iA=o/(h||1)*q*1.2*T,RA=s/(h||1)*q*1.2*T;Q.x+=iA*10*A*5,Q.y+=RA*10*A*5,Q.scale_x*=1+q*.3*T*A,Q.scale_y*=1+q*.3*T*A}}else if(E.type===O.Elastic){const F=((v=E.settings)==null?void 0:v.radius)||300,T=((n=E.settings)==null?void 0:n.strength)||1;if(h<F){const q=1-h/F;Q.scale_x*=1+q*.4*T*A,Q.scale_y*=1+q*.4*T*A}}else if(E.type===O.Holographic){const F=Q.x-this.canvasWidth/2,T=Q.y-this.canvasHeight/2,q=((L=E.settings)==null?void 0:L.factor)||25;if(Q.x-=F/1e3*q*A*5,Q.y-=T/1e3*q*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===O.Sticky){const F=((P=E.settings)==null?void 0:P.radius)||80,T=((wA=E.settings)==null?void 0:wA.strength)||1;if(h<F){const q=Math.pow(1-h/F,2);Q.x-=o*q*T*A*10,Q.y-=s*q*T*A*10,Q.scale_x*=1-q*.1*T*A,Q.scale_y*=1-q*.1*T*A}}else if(E.type===O.Dilation){const F=((EA=E.settings)==null?void 0:EA.size)||120,T=((u=E.settings)==null?void 0:u.strength)||1;if(h<F){const q=1-h/F;Q.scale_x*=1+q*.5*T*A,Q.scale_y*=1+q*.5*T*A}}else if(E.type===O.Parallax){const F=((z=E.settings)==null?void 0:z.factor)||.05,T=this.canvasHeight/2,q=(this._lastPointerPos.y-T)*F;Q.y+=q*A*10}else if(E.type===O.Noise||E.type===O.Float){const F=(((IA=E.settings)==null?void 0:IA.frequency)||((Z=E.settings)==null?void 0:Z.speed)||1)*.002,T=(((p=E.settings)==null?void 0:p.amplitude)||((d=E.settings)==null?void 0:d.range)||50)*(((R=E.settings)==null?void 0:R.strength)||1),q=Date.now();Q.x+=Math.sin(q*F)*T*A,Q.y+=Math.cos(q*F*.8)*T*A,Q.rotation+=Math.sin(q*F*.5)*5*A}else if(E.type===O.Pulse){const F=(((m=E.settings)==null?void 0:m.speed)||1)*.005,T=(((b=E.settings)==null?void 0:b.scale)||1.2)-1,q=Math.sin(Date.now()*F),iA=((AA=E.settings)==null?void 0:AA.strength)||1;Q.scale_x*=1+q*T*iA*A,Q.scale_y*=1+q*T*iA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,q)*.1*iA*A)}else if(E.type===O.Draggable){const F=((sA=E.settings)==null?void 0:sA.radius)||150,T=this.draggingBehaviors.has(g.id);if(h<F||T){const q=((kA=E.settings)==null?void 0:kA.strength)||1,iA=T?1:Math.max(0,1-h/F);this.applyBehaviorSensor(Q,uA.PositionX,iA*q,A,E.settings),this.applyBehaviorSensor(Q,uA.PositionY,iA*q,A,E.settings)}}else if(E.type===O.Scroll){const F=((HA=E.settings)==null?void 0:HA.axis)||"vertical",T=((NA=E.settings)==null?void 0:NA.factor)||.5,q=((f=E.settings)==null?void 0:f.strength)||1;(F==="vertical"||F==="both")&&(Q.y+=this.scrollOffset.y*T*q*A),(F==="horizontal"||F==="both")&&(Q.x+=this.scrollOffset.x*T*q*A)}else if(E.type===O.LookAt){const F=((W=E.settings)==null?void 0:W.factor)||1,T=((H=E.settings)==null?void 0:H.strength)||1,q=Math.atan2(-s,-o)*(180/Math.PI),iA=Q.rotation,RA=(q-iA+180)%360-180;Q.rotation+=RA*F*T*A*10}else if(E.type===O.Glint||E.type===O.Scan){const F=(((U=E.settings)==null?void 0:U.speed)||1)*.004,T=((x=E.settings)==null?void 0:x.strength)||1,q=(Math.sin(Date.now()*F)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+q*T*A*5),Q.x+=(q-.5)*20*T*A}else if(E.type===O.Ratchet){const F=((V=E.settings)==null?void 0:V.steps)||12,T=(((aA=E.settings)==null?void 0:aA.speed)||1)*30,q=Math.floor(Q.rotation/(360/F))*(360/F);Q.rotation=this.lerp(Q.rotation,q+T*A,.1)}else if(E.type===O.Jitter&&h<300){const F=((gA=E.settings)==null?void 0:gA.strength)||1,T=(((KA=E.settings)==null?void 0:KA.intensity)||5)*F;Q.x+=(Math.random()-.5)*T*A*60,Q.y+=(Math.random()-.5)*T*A*60,Q.rotation+=(Math.random()-.5)*T*A*120}else if(E.type===O.Follower){const F=(yA=E.settings)==null?void 0:yA.targetId;if(F){const T=this.objectStates.get(F);if(T){const q=((CA=E.settings)==null?void 0:CA.stiffness)||.1,iA=T.x-Q.x,RA=T.y-Q.y;Q.x+=iA*q*A*60,Q.y+=RA*q*A*60}}}else E.type===O.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=cA.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=cA.useRef(null),N=cA.useRef(new xQ),M=cA.useRef(),e=cA.useRef(0),Y=cA.useRef(null);cA.useImperativeHandle(S,()=>y.current),cA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),N.current.setLayout(Q,E)},[Q,E]),cA.useEffect(()=>{w&&N.current.setTriggerCallback(w)},[w]),cA.useEffect(()=>{o&&N.current.setInputUpdateCallback(o)},[o]),cA.useEffect(()=>{s&&N.current.setComponentChangeCallback(s)},[s]),cA.useEffect(()=>{h&&N.current.setToggleCallback(h)},[h]),cA.useEffect(()=>{a&&N.current.setInputChangeCallback(a)},[a]),cA.useEffect(()=>{G&&N.current.setInputFocusCallback(G)},[G]),cA.useEffect(()=>{t&&N.current.setInputBlurCallback(t)},[t]),cA.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]),cA.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 wA=(P-e.current)/1e3;e.current=P,g&&l.advance(wA);const EA=window.devicePixelRatio||1,u=r.getBoundingClientRect(),z=Math.floor(u.width*EA),IA=Math.floor(u.height*EA);(r.width!==z||r.height!==IA)&&(r.width=z,r.height=IA),l.render(v,z,IA),M.current=requestAnimationFrame(n)};M.current=requestAnimationFrame(n);const L=()=>{l.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",L,{passive:!0}),()=>{M.current&&cancelAnimationFrame(M.current),window.removeEventListener("scroll",L)}},[g]);const j=(l,r)=>{const v=l.currentTarget.getBoundingClientRect(),n=l.clientX-v.left,L=l.clientY-v.top,P=v.width,wA=v.height;N.current.handlePointerInput(r,n,L,P,wA)};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]=cA.useState(null),I=cA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=cA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=cA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=cA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=cA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=cA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),w=cA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=cA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=cA.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";pA.BehaviorSensor=uA,pA.BehaviorType=O,pA.ConditionOp=tC,pA.ExodeUICanvas=$E,pA.ExodeUIEngine=xQ,pA.LogicOp=NI,pA.VERSION=Ii,pA.useExodeUI=Ai,Object.defineProperty(pA,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -6547,7 +6547,7 @@ class Ei {
|
|
|
6547
6547
|
});
|
|
6548
6548
|
// Trigger Management
|
|
6549
6549
|
GA(this, "activeTriggers", /* @__PURE__ */ new Map());
|
|
6550
|
-
console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.
|
|
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)");
|
|
6551
6551
|
}
|
|
6552
6552
|
setTriggerCallback(A) {
|
|
6553
6553
|
this.onTrigger = A;
|
|
@@ -9358,7 +9358,7 @@ function si() {
|
|
|
9358
9358
|
updateObjectOptions: w
|
|
9359
9359
|
};
|
|
9360
9360
|
}
|
|
9361
|
-
const hi = "6.0.
|
|
9361
|
+
const hi = "6.0.22";
|
|
9362
9362
|
export {
|
|
9363
9363
|
TA as BehaviorSensor,
|
|
9364
9364
|
O as BehaviorType,
|