exodeui 6.0.27 → 6.0.29

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/README.md CHANGED
@@ -65,10 +65,24 @@ Render beautiful, animated line graphs with zero extra code.
65
65
  - **Line Graphs**: Supports multiple datasets, smoothing (Catmull-Rom splines), fill areas, and points.
66
66
  - **Data Binding**: Bind graph data to runtime inputs or variables.
67
67
 
68
+ ### 4. SEO & Metadata
69
+ Automatically manage page metadata and generate semantic HTML for search engines and screen readers.
70
+ - **Automatic Metadata**: Updates `document.title`, meta description, keywords, and OpenGraph tags based on your artboard configuration.
71
+ - **Semantic Overlay**: Generates a visually hidden but accessible HTML structure (H1, H2, P, buttons) based on the objects in your animation.
72
+ - **JSON-LD**: Injects structured data (schema.org) for advanced search engine rich results.
73
+
68
74
  ```tsx
69
- // Example of injecting data via Inputs (if supported by your graph configuration)
70
- // engine.setInputNumberArray('StockData', [10, 25, 15, 40, 35, 60]);
71
- // (Note: array input support depends on your specific version/setup)
75
+ import { ExodeUICanvas, ExodeSEO } from 'exodeui';
76
+
77
+ function MyPage({ artboard }) {
78
+ return (
79
+ <>
80
+ {/* ExodeSEO handles title, meta tags, and accessibility overlay */}
81
+ <ExodeSEO artboard={artboard} />
82
+ <ExodeUICanvas artboard={artboard} />
83
+ </>
84
+ );
85
+ }
72
86
  ```
73
87
 
74
88
  ## API Reference
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export * from './types';
3
3
  export * from './engine';
4
4
  export * from './useExodeUI';
5
5
  export * from './ExodeSEO';
6
- export declare const VERSION = "6.0.24";
6
+ export declare const VERSION = "6.0.28";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  `):B.replace(/\r\n/g,`
4
4
  `)}let QC=null,NB;function FB(){return QC===null&&(QC=new Intl.Segmenter(NB,{granularity:"word"})),QC}const MB=new RegExp("\\p{Script=Arabic}","u"),ig=new RegExp("\\p{M}","u"),FQ=new RegExp("\\p{Nd}","u");function BC(B){return MB.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([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),eB=new Set([":",".","،","؛"]),cB=new Set(["၏"]),JB=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function RB(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 UB(B){for(const A of B)if(!MQ.has(A)&&!uI.has(A))return!1;return B.length>0}function rB(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 nB(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 YB(B,A){if(B.length===0)return!1;for(const I of B)if(I!==A)return!1;return!0}function lB(B){return!BC(B)||B.length===0?!1:eB.has(B[B.length-1])}function LB(B){return B.length===0?!1:cB.has(B[B.length-1])}function qB(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(JB.has(I))return!0;if(!uI.has(I))return!1}return!1}function pB(B,A){if(A.preserveOrdinarySpaces||A.preserveHardBreaks){if(B===" ")return"preserved-space";if(B===" ")return"tab";if(A.preserveHardBreaks&&B===`
5
5
  `)return"hard-break"}return B===" "?"space":B===" "||B===" "||B==="⁠"||B==="\uFEFF"?"glue":B==="​"?"zero-width-break":B==="­"?"soft-hyphen":"text"}function HB(B,A,I,C){const g=[];let Q=null,E="",i=I,D=!1,o=0;for(const s of B){const h=pB(s,C),a=h==="text"&&A;if(Q!==null&&h===Q&&a===D){E+=s,o+=s.length;continue}Q!==null&&g.push({text:E,isWordLike:D,kind:Q,start:i}),Q=h,E=s,i=I+o,D=a,o+=s.length}return Q!==null&&g.push({text:E,isWordLike:D,kind:Q,start:i}),g}function oC(B){return B==="space"||B==="preserved-space"||B==="zero-width-break"||B==="hard-break"}const dB=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function fB(B,A){const I=B.texts[A];return I.startsWith("www.")?!0:dB.test(I)&&A+1<B.len&&B.kinds[A+1]==="text"&&B.texts[A+1]==="//"}function bB(B){return B.includes("?")&&(B.includes("://")||B.startsWith("www."))}function TB(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"||!fB(B,E))continue;let i=E+1;for(;i<B.len&&!oC(C[i]);){A[E]+=A[i],I[E]=!0;const D=A[i].includes("?");if(C[i]="text",A[i]="",i++,D)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 uB(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]),!bB(E))continue;const i=Q+1;if(i>=B.len||oC(B.kinds[i]))continue;let D="";const o=B.starts[i];let s=i;for(;s<B.len&&!oC(B.kinds[s]);)D+=B.texts[s],s++;D.length>0&&(A.push(D),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 mB=new Set([":","-","/","×",",",".","+","–","—"]),cQ=/^[A-Za-z0-9_]+[,:;]*$/,xB=/[,:;]+$/;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)||mB.has(A)))return!1;return!0}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];if(i==="text"&&DC(E)&&JQ(E)){let D=E,o=Q+1;for(;o<B.len&&B.kinds[o]==="text"&&DC(B.texts[o]);)D+=B.texts[o],o++;A.push(D),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 WB(B){const A=[],I=[],C=[],g=[];for(let Q=0;Q<B.len;Q++){const E=B.texts[Q],i=B.kinds[Q],D=B.isWordLike[Q];if(i==="text"&&D&&cQ.test(E)){let o=E,s=Q+1;for(;xB.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(D),C.push(i),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=[];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 D=i.length>1;for(let o=0;o<i.length;o++){const s=i[o];if(!D)break;(s.length===0||!JQ(s)||!DC(s))&&(D=!1)}if(D){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 jB(B){const A=[],I=[],C=[],g=[];let Q=0;for(;Q<B.len;){let E=B.texts[Q],i=B.isWordLike[Q],D=B.kinds[Q],o=B.starts[Q];if(D==="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],D="text",o=h,Q++;else{A.push(s),I.push(!1),C.push("glue"),g.push(h);continue}}else Q++;if(D==="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(D),g.push(o)}return{len:A.length,texts:A,isWordLike:I,kinds:C,starts:g}}function XB(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=nB(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 vB(B,A,I){const C=FB();let g=0;const Q=[],E=[],i=[],D=[];for(const a of C.segment(B))for(const G of HB(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"&&UB(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)&&lB(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!=="—"&&YB(Q[g-1],G.text)||t&&!G.isWordLike&&g>0&&i[g-1]==="text"&&(RB(G.text)||G.text==="-"&&E[g-1])?Q[g-1]+=G.text:(Q[g]=G.text,E[g]=G.isWordLike,i[g]=G.kind,D[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]&&rB(Q[a])){let G=a+1;for(;G<g&&Q[G]==="";)G++;G<g&&i[G]==="text"&&(Q[G]=Q[a]+Q[G],D[G]=D[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],D[o]=D[a]),o++)}Q.length=o,E.length=o,i.length=o,D.length=o;const s=jB({len:o,texts:Q,isWordLike:E,kinds:i,starts:D}),h=XB(WB(ZB(OB(uB(TB(s))))));for(let a=0;a<h.len-1;a++){const G=qB(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 PB(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 VB(B,A,I="normal"){const C=SB(I),g=C.mode==="pre-wrap"?kB(B):yB(B);if(g.length===0)return{normalized:g,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const Q=vB(g,A,C);return{normalized:g,chunks:PB(Q,C),...Q}}let JI=null;const RQ=new Map;let RI=null;const zB=new RegExp("\\p{Emoji_Presentation}","u"),_B=/[\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 AE(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 IE(B){return zB.test(B)||B.includes("️")}function gE(B){return _B.test(B)}function CE(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 QE(B){let A=0;const I=hC();for(const C of I.segment(B))IE(C.segment)&&A++;return A}function BE(B,A){return A.emojiCount===void 0&&(A.emojiCount=QE(B)),A.emojiCount}function SI(B,A,I){return I===0?A.width:A.width-BE(B,A)*I}function EE(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 iE(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 D=KI(E,I);g.push(SI(E,D,C))}return A.graphemePrefixWidths=g.length>1?g:null,A.graphemePrefixWidths}function oE(B,A){const I=sC();I.font=B;const C=$B(B),g=AE(B),Q=A?CE(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 DE(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 wE(B,A,I,C,g,Q){let E=0,i=A;for(;E<B.length;){const D=Q?A+B[E]:i+B[E];if((E+1<B.length?D+g:D)>I+C)break;i=D,E++}return{fitCount:E,fittedWidth:i}}function sE(B,A,I){const{widths:C,kinds:g,breakableWidths:Q,breakablePrefixWidths:E}=B;if(C.length===0)return 0;const i=Dg(),D=i.lineFitEpsilon;let o=0,s=0,h=!1,a=0,G=0,t=0,K=0,S=-1,y=0;function F(){S=-1,y=0}function e(U=t,T=K,AA=s){o++,I==null||I({startSegmentIndex:a,startGraphemeIndex:G,endSegmentIndex:U,endGraphemeIndex:T,width:AA}),s=0,h=!1,F()}function M(U,T){h=!0,a=U,G=0,t=U+1,K=0,s=T}function n(U,T,AA){h=!0,a=U,G=T,t=U,K=T+1,s=AA}function X(U,T){if(!h){M(U,T);return}s+=T,t=U+1,K=0}function Z(U,T){wg(g[U])&&(S=U+1,y=s-T)}function H(U){QA(U,0)}function QA(U,T){const AA=Q[U],IA=E[U]??null;for(let b=T;b<AA.length;b++){const P=rQ(AA,IA,b,i.preferPrefixWidthsForBreakableRuns);if(!h){n(U,b,P);continue}s+P>A+D?(e(),n(U,b,P)):(s+=P,t=U,K=b+1)}h&&t===U&&K===AA.length&&(t=U+1,K=0)}let L=0;for(;L<C.length;){const U=C[L],T=g[L];if(!h){U>A&&Q[L]!==null?H(L):M(L,U),Z(L,U),L++;continue}if(s+U>A+D){if(wg(T)){X(L,U),e(L+1,0,s-U),L++;continue}if(S>=0){e(S,0,y);continue}if(U>A&&Q[L]!==null){e(),H(L),L++;continue}e();continue}X(L,U),Z(L,U),L++}return h&&e(),o}function hE(B,A,I){if(B.simpleLineWalkFastPath)return sE(B,A,I);const{widths:C,lineEndFitAdvances:g,lineEndPaintAdvances:Q,kinds:E,breakableWidths:i,breakablePrefixWidths:D,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,F=0,e=0,M=0,n=-1,X=0,Z=0,H=null;function QA(){n=-1,X=0,Z=0,H=null}function L(q=e,l=M,r=K){t++,I==null||I({startSegmentIndex:y,startGraphemeIndex:F,endSegmentIndex:q,endGraphemeIndex:l,width:r}),K=0,S=!1,QA()}function U(q,l){S=!0,y=q,F=0,e=q+1,M=0,K=l}function T(q,l,r){S=!0,y=q,F=l,e=q,M=l+1,K=r}function AA(q,l){if(!S){U(q,l);return}K+=l,e=q+1,M=0}function IA(q,l){if(!wg(E[q]))return;const r=E[q]==="tab"?0:g[q],z=E[q]==="tab"?l:Q[q];n=q+1,X=K-l+r,Z=K-l+z,H=E[q]}function b(q){P(q,0)}function P(q,l){const r=i[q],z=D[q]??null;for(let d=l;d<r.length;d++){const _=rQ(r,z,d,a.preferPrefixWidthsForBreakableRuns);if(!S){T(q,d,_);continue}K+_>A+G?(L(),T(q,d,_)):(K+=_,e=q,M=d+1)}S&&e===q&&M===r.length&&(e=q+1,M=0)}function gA(q){if(H!=="soft-hyphen")return!1;const l=i[q];if(l===null)return!1;const r=a.preferPrefixWidthsForBreakableRuns?D[q]??l:l,z=r!==l,{fitCount:d,fittedWidth:_}=wE(r,K,A,G,o,z);return d===0?!1:(K=_,e=q,M=d,QA(),d===l.length?(e=q+1,M=0,!0):(L(q,d,_+o),P(q,d),!0))}function u(q){t++,I==null||I({startSegmentIndex:q.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:q.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),QA()}for(let q=0;q<h.length;q++){const l=h[q];if(l.startSegmentIndex===l.endSegmentIndex){u(l);continue}S=!1,K=0,y=l.startSegmentIndex,F=0,e=l.startSegmentIndex,M=0,QA();let r=l.startSegmentIndex;for(;r<l.endSegmentIndex;){const z=E[r],d=z==="tab"?DE(K,s):C[r];if(z==="soft-hyphen"){S&&(e=r+1,M=0,n=r+1,X=K+o,Z=K+o,H=z),r++;continue}if(!S){d>A&&i[r]!==null?b(r):U(r,d),IA(r,d),r++;continue}if(K+d>A+G){const hA=K+(z==="tab"?0:g[r]),SA=K+(z==="tab"?d:Q[r]);if(H==="soft-hyphen"&&a.preferEarlySoftHyphenBreak&&X<=A+G){L(n,0,Z);continue}if(H==="soft-hyphen"&&gA(r)){r++;continue}if(wg(z)&&hA<=A+G){AA(r,d),L(r+1,0,SA),r++;continue}if(n>=0&&X<=A+G){L(n,0,Z);continue}if(d>A&&i[r]!==null){L(),b(r),r++;continue}L();continue}AA(r,d),IA(r,d),r++}if(S){const z=n===l.consumedEndSegmentIndex?Z:K;L(l.consumedEndSegmentIndex,0,z)}}return t}let aC=null,nQ=new WeakMap;function YQ(){return aC===null&&(aC=new Intl.Segmenter(void 0,{granularity:"grapheme"})),aC}function aE(B){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableWidths:[],breakablePrefixWidths:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function GE(B,A,I){const C=YQ(),g=Dg(),{cache:Q,emojiCorrection:E}=oE(A,gE(B.normalized)),i=SI("-",KI("-",Q),E),o=SI(" ",KI(" ",Q),E)*8;if(B.len===0)return aE();const s=[],h=[],a=[],G=[];let t=B.chunks.length<=1;const K=[],S=[],y=[],F=I?[]:null,e=Array.from({length:B.len}),M=Array.from({length:B.len});function n(H,QA,L,U,T,AA,IA,b){T!=="text"&&T!=="space"&&T!=="zero-width-break"&&(t=!1),s.push(QA),h.push(L),a.push(U),G.push(T),K==null||K.push(AA),S.push(IA),y.push(b),F!==null&&F.push(H)}for(let H=0;H<B.len;H++){e[H]=s.length;const QA=B.texts[H],L=B.isWordLike[H],U=B.kinds[H],T=B.starts[H];if(U==="soft-hyphen"){n(QA,0,i,i,U,T,null,null),M[H]=s.length;continue}if(U==="hard-break"){n(QA,0,0,0,U,T,null,null),M[H]=s.length;continue}if(U==="tab"){n(QA,0,0,0,U,T,null,null),M[H]=s.length;continue}const AA=KI(QA,Q);if(U==="text"&&AA.containsCJK){let gA="",u=0;for(const q of C.segment(QA)){const l=q.segment;if(gA.length===0){gA=l,u=q.index;continue}if(og.has(gA)||MQ.has(l)||uI.has(l)||g.carryCJKAfterClosingQuote&&tI(l)&&eQ(gA)){gA+=l;continue}const r=KI(gA,Q),z=SI(gA,r,E);n(gA,z,z,z,"text",T+u,null,null),gA=l,u=q.index}if(gA.length>0){const q=KI(gA,Q),l=SI(gA,q,E);n(gA,l,l,l,"text",T+u,null,null)}M[H]=s.length;continue}const IA=SI(QA,AA,E),b=U==="space"||U==="preserved-space"||U==="zero-width-break"?0:IA,P=U==="space"||U==="zero-width-break"?0:IA;if(L&&QA.length>1){const gA=EE(QA,AA,Q,E),u=g.preferPrefixWidthsForBreakableRuns?iE(QA,AA,Q,E):null;n(QA,IA,b,P,U,T,gA,u)}else n(QA,IA,b,P,U,T,null,null);M[H]=s.length}const X=tE(B.chunks,e,M),Z=K===null?null:GB(B.normalized,K);return F!==null?{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:Z,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:X,segments:F}:{widths:s,lineEndFitAdvances:h,lineEndPaintAdvances:a,kinds:G,simpleLineWalkFastPath:t,segLevels:Z,breakableWidths:S,breakablePrefixWidths:y,discretionaryHyphenWidth:i,tabStopAdvance:o,chunks:X}}function tE(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,D=Q.consumedEndSegmentIndex<A.length?A[Q.consumedEndSegmentIndex]:I[I.length-1]??0;C.push({startSegmentIndex:E,endSegmentIndex:i,consumedEndSegmentIndex:D})}return C}function KE(B,A,I,C){const g=VB(B,Dg(),C==null?void 0:C.whiteSpace);return GE(g,A,I)}function SE(B,A,I){return KE(B,A,!0,I)}function ii(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 yE(B){let A=nQ.get(B);return A!==void 0||(A=new Map,nQ.set(B,A)),A}function kE(B,A,I,C){return C>0&&B[C-1]==="soft-hyphen"&&!(A===C&&I>0)}function NE(B,A,I,C,g,Q,E){let i="";const D=kE(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?(D&&(i+="-"),i+=lQ(Q,B,I).slice(C===Q?g:0,E).join("")):D&&(i+="-"),i}function FE(B,A,I,C,g,Q,E){return{text:NE(B.segments,B.kinds,A,C,g,Q,E),width:I,start:{segmentIndex:C,graphemeIndex:g},end:{segmentIndex:Q,graphemeIndex:E}}}function ME(B,A,I){return FE(B,A,I.width,I.startSegmentIndex,I.startGraphemeIndex,I.endSegmentIndex,I.endGraphemeIndex)}function eE(B,A,I){const C=[];if(B.widths.length===0)return{lineCount:0,height:0,lines:C};const g=yE(B),Q=hE(B,A,E=>{C.push(ME(B,g,E))});return{lineCount:Q,height:Q*I,lines:C}}const LQ=B=>B,cE=B=>B>0?1:0,JE=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,RE=B=>B*B*B,UE=B=>--B*B*B+1,rE=B=>B<.5?4*B*B*B:(B-1)*(2*B-2)*(2*B-2)+1,nE=B=>B*B*B*B,YE=B=>1- --B*B*B*B,lE=B=>B<.5?8*B*B*B*B:1-8*--B*B*B*B,LE=B=>B*B*B*B*B,qE=B=>1+--B*B*B*B*B,pE=B=>B<.5?16*B*B*B*B*B:1+16*--B*B*B*B*B,HE=B=>1-Math.cos(B*Math.PI/2),dE=B=>Math.sin(B*Math.PI/2),fE=B=>-(Math.cos(Math.PI*B)-1)/2,bE=B=>B===0?0:Math.pow(2,10*(B-1)),TE=B=>B===1?1:1-Math.pow(2,-10*B),uE=B=>B===0?0:B===1?1:B<.5?Math.pow(2,20*B-10)/2:(2-Math.pow(2,-20*B+10))/2,mE=B=>1-Math.sqrt(1-B*B),xE=B=>Math.sqrt(1- --B*B),OE=B=>B<.5?(1-Math.sqrt(1-4*B*B))/2:(Math.sqrt(1-(-2*B+2)*(-2*B+2))+1)/2,sg=1.70158,hg=sg*1.525,dQ=sg+1,WE=B=>dQ*B*B*B-sg*B*B,ZE=B=>1+dQ*Math.pow(B-1,3)+sg*Math.pow(B-1,2),jE=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,XE=B=>B===0?0:B===1?1:-Math.pow(2,10*B-10)*Math.sin((B*10-10.75)*fQ),vE=B=>B===0?0:B===1?1:Math.pow(2,-10*B)*Math.sin((B*10-.75)*fQ)+1,PE=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,VE=B=>1-ag(1-B),zE=ag,_E=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,D=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(D(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:RE,EaseOutCubic:UE,EaseInOutCubic:rE,EaseInQuart:nE,EaseOutQuart:YE,EaseInOutQuart:lE,EaseInQuint:LE,EaseOutQuint:qE,EaseInOutQuint:pE,EaseInSine:HE,EaseOutSine:dE,EaseInOutSine:fE,EaseInExpo:bE,EaseOutExpo:TE,EaseInOutExpo:uE,EaseInCirc:mE,EaseOutCirc:xE,EaseInOutCirc:OE,EaseInBack:WE,EaseOutBack:ZE,EaseInOutBack:jE,EaseInElastic:XE,EaseOutElastic:vE,EaseInOutElastic:PE,EaseInBounce:VE,EaseOutBounce:zE,EaseInOutBounce:_E,EaseIn:qQ,EaseOut:pQ,EaseInOut:HQ,StepStart:cE,StepEnd:JE},$E=B=>{const A=B.trim(),I=A.toLowerCase();if(Gg[A])return Gg[A];const C=Object.keys(Gg).find(Q=>Q.toLowerCase()===I);if(C)return Gg[C];const g=Object.keys(mQ).find(Q=>Q.toLowerCase()===I);if(g){const Q=TQ(mQ[g].value);if(Q)return Q}if(uQ[I])return uQ[I];if(I.startsWith("cubic-bezier")){const Q=TQ(A);if(Q)return Q}return LQ},mQ={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}};class xQ{constructor(){tA(this,"artboard",null);tA(this,"objectStates",new Map);tA(this,"physicsEngine",null);tA(this,"activeStateMachine",null);tA(this,"inputs",new Map);tA(this,"inputNameMap",new Map);tA(this,"layerStates",new Map);tA(this,"pretextCache",new Map);tA(this,"pointerHistory",[]);tA(this,"MAX_HISTORY",200);tA(this,"imageCache",new Map);tA(this,"lastValidSvgImgMap",new Map);tA(this,"maskBuffer",null);tA(this,"maskCtx",null);tA(this,"lumaBuffer",null);tA(this,"lumaCtx",null);tA(this,"layout",{fit:"Contain",alignment:"Center"});tA(this,"onTrigger");tA(this,"onInputUpdate");tA(this,"onComponentChange");tA(this,"onToggle");tA(this,"onInputChange");tA(this,"onInputFocus");tA(this,"onInputBlur");tA(this,"onLog");tA(this,"justFiredTriggers",new Set);tA(this,"rootTransform",null);tA(this,"canvasWidth",0);tA(this,"canvasHeight",0);tA(this,"lastHoveredObjectId",null);tA(this,"_lastPointerPos",null);tA(this,"_prevPointerPos",null);tA(this,"focusedId",null);tA(this,"draggingSliderId",null);tA(this,"activeDropdownId",null);tA(this,"draggingListViewId",null);tA(this,"scrollOffset",{x:0,y:0});tA(this,"draggingBehaviors",new Set);tA(this,"objectVelocities",new Map);tA(this,"currentTime",0);tA(this,"frameCount",0);tA(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4});tA(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.0.24) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(A){this.onTrigger=A}setInputUpdateCallback(A){this.onInputUpdate=A}setComponentChangeCallback(A){this.onComponentChange=A}setToggleCallback(A){this.onToggle=A}setInputChangeCallback(A){this.onInputChange=A}setOnLogCallback(A){this.onLog=A}debugLog(A){this.onLog&&this.onLog(A)}setInputFocusCallback(A){this.onInputFocus=A}setInputBlurCallback(A){this.onInputBlur=A}updateConstraint(A,I,C){var Q;const g=(Q=this.artboard)==null?void 0:Q.objects.find(E=>E.id===A);g&&g.constraints&&g.constraints[I]&&(g.constraints[I]={...g.constraints[I],...C},C.useSpring===!1&&this.objectVelocities.delete(A))}setInternalInput(A,I){this.inputs.set(A,I),this.onInputUpdate&&this.onInputUpdate(A,I)}setLayout(A,I){this.layout={fit:A,alignment:I}}getActiveStateIds(A="Base Layer"){const I=this.layerStates.get(A);return I?I.currentStateIds:[]}getObjectState(A){return this.objectStates.get(A)}updateObjectOptions(A,I){const C=this.objectStates.get(A);C&&(C.options={...C.options,...I})}updateGraphData(A,I){if(!this.artboard)return;const C=this.artboard.objects.find(g=>g.id===A||g.name===A);if(C&&C.geometry.type==="LineGraph"){const g=C.geometry;!g.datasets||g.datasets.length===0?g.datasets=[{id:"default",label:"Runtime Data",data:I,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:g.datasets[0].data=I;const Q=this.objectStates.get(C.id);Q&&Q.geometry&&Q.geometry.type==="LineGraph"&&(!Q.geometry.datasets||Q.geometry.datasets.length===0?Q.geometry.datasets=JSON.parse(JSON.stringify(g.datasets)):Q.geometry.datasets[0].data=[...I]),g.datasets[0].inputId&&this.updateInput(g.datasets[0].inputId,I)}else this.updateInput(A,I)}load(A){this.artboard=A,this.currentTime=0,this.loadFonts(),this.reset(),this.advance(0)}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this.artboard.objects.forEach(I=>{var E,i,D,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??((D=I.geometry)==null?void 0:D.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 DB;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,D=g.geometry.height||100;this.physicsEngine.createBody({id:g.id,type:g.geometry.type,x:E.x,y:E.y,width:i,height:D,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 D=Math.abs(i.x-E.x),o=Math.abs(i.y-E.y);D>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),D=this.objectStates.get(Q.id);if(!D)return;const o=SC(D,i,s=>this.objectStates.get(s));o.frameWidth!==void 0&&(D.width=o.frameWidth),o.frameHeight!==void 0&&(D.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(D=>{D.value&&typeof D.value=="string"&&A.add(D.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 D=E.states.find(o=>o.id===i);if(D){let o=null;D.animationId&&(o=this.artboard.animations.find(s=>s.id===D.animationId)||null),o||(o=this.artboard.animations.find(s=>s.name===D.name||s.id===D.name||D.name==="Entry"&&s.name==="Rotate")||null),o&&(g.push({animation:o,state:D}),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,D;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)&&((D=this.artboard)==null||D.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(D=>D.id===Q);if(!E)continue;let i=!1;for(const D of E.transitions)this.checkConditions(D.conditions)&&(C.push(D.targetStateId),i=!0,g=!0,D.conditions&&D.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 D;const i=(D=this.activeStateMachine)==null?void 0:D.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,D;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=(D=this.activeStateMachine)==null?void 0:D.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,D,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=(D=(i=this.artboard)==null?void 0:i.objects.find(G=>G.id===C))==null?void 0:D.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,D,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:F,vx:e,vy:M}=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=F),this.objectVelocities.set(I.id,{vx:e,vy:M})}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))),(D=Q.limitY)!=null&&D.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:F,y:e,vx:M,vy:n}=this.computeSpring(g.x,g.y,y.vx,y.vy,t,K,Q,A);g.x=F,g.y=e,this.objectVelocities.set(I.id,{vx:M,vy:n})}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),F=Q.distance||0;let e=y;switch(Q.mode){case"exact":e=F;break;case"minimum":e=Math.max(F,y);break;case"maximum":e=Math.min(F,y);break;case"clamped":e=Math.max(0,Math.min(F,y));break}if(y>0){const M=g.x===t.x&&g.y===t.y?1:e/y;g.x=g.x+(t.x+K*M-g.x)*E,g.y=g.y+(t.y+S*M-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,F=K.height||t.geometry.height||0,e=this.getPointOnPath(t.geometry,y,F,S),M=K.rotation*Math.PI/180,n=Math.cos(M),X=Math.sin(M),Z=e.x*K.scale_x*n-e.y*K.scale_y*X,H=e.x*K.scale_x*X+e.y*K.scale_y*n,QA=K.x+Z+(Q.offsetX||0),L=K.y+H+(Q.offsetY||0);if(g.x=g.x+(QA-g.x)*E,g.y=g.y+(L-g.y)*E,Q.orient){let T=(e.angle*180/Math.PI+K.rotation+(Q.offsetRotation||0)-g.rotation)%360;T>180&&(T-=360),T<-180&&(T+=360),g.rotation=g.rotation+T*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),D=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:D,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),D=Math.sin(E),o=I.x-C.x,s=I.y-C.y,h=(o*i-s*D)*g,a=(o*D+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(),D=5;for(let s=0;s<D;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,F=I.y-t.y,e=Math.sqrt(K*K+S*S),M=Math.sqrt(y*y+F*F);if(e>.001&&M>.001){const n=Math.atan2(S,K);let Z=(Math.atan2(F,y)-n)*180/Math.PI;Z*=g;const H=this.objectStates.get(G.id);H&&(H.rotation+=Z)}}}}computeSpring(A,I,C,g,Q,E,i,D){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,F=C+S*D,e=g+y*D,M=A+F*D,n=I+e*D;return{x:M,y:n,vx:F,vy:e}}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,D=(C-E.ty)/E.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:i,y:D},this.updateInput("mouseX",i),this.updateInput("mouseY",D),this.handlePointerEvent(A,i,D)}handleScroll(A,I){this.scrollOffset={x:A,y:I}}handlePointerEvent(A,I,C){var D,o,s,h,a;if(!this.artboard)return;let g=null;const Q=(G,t)=>{var M;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((M=G.type)==null?void 0:M.toLowerCase())||(G.interactions||[]).some(n=>S.has(n.event))||(G.triggers||[]).some(n=>S.has(n.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&&((D=g.behaviors)!=null&&D.some(G=>G.type===W.Draggable))&&this.draggingBehaviors.add(i),this.activeDropdownId&&A==="down"){const G=this.artboard.objects.find(t=>t.id===this.activeDropdownId);if(G&&(G.type==="Dropdown"||G.variant==="dropdown")){const t=this.objectStates.get(G.id),K=(t==null?void 0:t.options)||G.options||{},S=G.geometry||{},y=S.width??G.width??200,F=S.height??G.height??40,e=K.optionsList||[],M=K.itemHeight||32,n=K.listPadding??4,X=e.length*M+n*2,Z=this.getWorldTransform(G.id),H=y*Math.abs(Z.scaleX),QA=F*Math.abs(Z.scaleY),L=Z.y+QA/2+4,U=Math.abs(I-Z.x)<=H/2,T=C>=L&&C<=L+X*Math.abs(Z.scaleY);if(U&&T){const AA=Math.abs(Z.scaleY),IA=C-(L+n*AA),b=Math.floor(IA/(M*AA));if(b>=0&&b<e.length){const P=e[b];K.selectedOption=P,K.isOpen=!1,this.activeDropdownId=null,G.inputId&&this.setInternalInput(G.inputId,P),this.onComponentChange&&this.onComponentChange({objectId:G.id,componentName:G.name,variant:"dropdown",property:"selectedOption",value:P})}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||{},F=!y.isOpen;if(F&&this.activeDropdownId&&this.activeDropdownId!==G.id){const e=this.artboard.objects.find(M=>M.id===this.activeDropdownId);e&&e.options&&(e.options.isOpen=!1)}y.isOpen=F,this.activeDropdownId=F?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 F=this.objectStates.get(g.id);F&&F.options&&(F.options.activeItemIndex=S);const e=(y.items||[])[S],M=typeof e=="string"?e:e.label||e.value||S;F&&F.options&&(F.options.selectedValue=M),g.inputId&&this.setInternalInput(g.inputId,M),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:M}))}}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(F=>F.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 F=(s=this.artboard)==null?void 0:s.objects.find(e=>e.id===y);F&&this.onInputBlur&&this.onInputBlur(F.name)}this.onInputFocus&&this.onInputFocus(S.name)}}else if(this.focusedId=null,y){const F=(h=this.artboard)==null?void 0:h.objects.find(e=>e.id===y);F&&this.onInputBlur&&this.onInputBlur(F.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
- `;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 D=(C.triggers||[]).find(o=>g.has(o.eventType));if(D&&D.entryAnimationId){console.log(`[Engine] Trigger matched: ${I} (as ${D.eventType}) -> Animation ${D.entryAnimationId}`);const o=this.artboard.animations.find(s=>s.id===D.entryAnimationId);o&&(this.activeTriggers.set(C.id,{triggerId:D.id,animation:o,time:0,phase:"entry",elapsedHold:0}),this.onTrigger&&this.onTrigger(D.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),D=I.x*g.scaleX,o=I.y*g.scaleY,s=g.x+(D*E-o*i),h=g.y+(D*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 e,M;if(!this.objectStates.get(A.id))return!1;const Q=((e=A.geometry)==null?void 0:e.width)??A.width??100,E=((M=A.geometry)==null?void 0:M.height)??A.height??100,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=D*a+o*h,K=i.scaleX,S=i.scaleY,y=Q*Math.abs(K),F=E*Math.abs(S);return Math.abs(G)<=y/2&&Math.abs(t)<=F/2}updateSliderValueFromPointer(A,I,C){var Z;const g=this.objectStates.get(A.id);if(!g)return;const Q=A.options||{},E=((Z=A.geometry)==null?void 0:Z.width)??A.width??200,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*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 F=Q.min??0,e=Q.max??100,M=Q.step||1;let n=F+y*(e-F);M>0&&(n=Math.round(n/M)*M),n=Math.max(F,Math.min(e,n));const X=g.options||{};X.value!==n&&(g.options={...X,value:n},A.inputId&&this.setInternalInput(A.inputId,n),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:n}))}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 D=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 D=="object"?"OBJ":D} 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]]=D}else i[E]=D;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,D,a.y)}else if(E==="y"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,a.x,D)}else E==="rotation"&&this.physicsEngine.setRotation(C.object_id,D*(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),D=parseFloat(g.value);return!isNaN(i)&&!isNaN(D)?Math.round(i+(D-i)*E).toString():C.value}return Array.isArray(C.value)&&Array.isArray(g.value)?C.value.length===g.value.length?C.value.map((i,D)=>{const o=g.value[D];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)}},D=i(Q),o=i(E),s=Math.round(D.r+(o.r-D.r)*C),h=Math.round(D.g+(o.g-D.g)*C),a=Math.round(D.b+(o.b-D.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 D=this.artboard.backgroundImage;let o=this.imageCache.get(D);if(o||(o=new Image,o.src=D,this.imageCache.set(D,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(D=>i.set(D.id,D)),this.artboard.objects.forEach(D=>{D.parentId||this.renderObject(A,D,i)}),A.restore()}calculateTransform(A,I,C,g,Q,E){let i=1,D=1,o=1;const s=C/g,h=A/I;switch(Q){case"Contain":h>s?o=I/g:o=A/C,i=D=o;break;case"Cover":h>s?o=A/C:o=I/g,i=D=o;break;case"Fill":i=A/C,D=I/g;break;case"FitWidth":o=A/C,i=D=o;break;case"FitHeight":o=I/g,i=D=o;break;case"None":i=D=1;break;case"ScaleDown":o=Math.min(A/C,I/g),o>1&&(o=1),i=D=o;break;default:i=D=1;break}const a=C*i,G=g*D;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:D,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 u,q,l,r,z,d,_,hA,SA,FA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(m,O,Y,R,x)=>(this.drawRoundRect(A,m,O,Y,R,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)||((u=I.geometry)==null?void 0:u.width)||I.width||0,D=(Q==null?void 0:Q.height)||((q=I.geometry)==null?void 0:q.height)||I.height||0;if((i===0||D===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let m=1/0,O=-1/0,Y=1/0,R=-1/0;Q.points.forEach(x=>{m=Math.min(m,x.x),O=Math.max(O,x.x),Y=Math.min(Y,x.y),R=Math.max(R,x.y)}),i===0&&(i=O-m),D===0&&(D=R-Y)}const o=m=>{if(m)return m.corner_radius??m.cornerRadius},s=o(g)??o(E)??o(Q)??o(I.style)??o(I.geometry)??0,h={...Q,width:i,height:D};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||((l=I.style)==null?void 0:l.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"))||((z=I.type)==null?void 0:z.toLowerCase().includes("image")),y=E.adjustments&&Object.keys(E.adjustments).length>0?E.adjustments:null,F=Q!=null&&Q.adjustments&&Object.keys(Q.adjustments).length>0?Q.adjustments:null,e=S?F||y:y||F,M=S&&!e?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:e;if(g&&M&&(g.geometry=g.geometry||{},g.geometry.adjustments={...M}),M){const m=(M.exposure||0)/100,O=M.contrast||0,Y=1+(M.saturation||0)/100,R=(M.temperature||0)/200,x=(M.tint||0)/200,j=(M.highlights||0)/500,GA=(M.shadows||0)/500;let CA="",wA="SourceGraphic";if(m!==0&&(CA+=`
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 D=(C.triggers||[]).find(o=>g.has(o.eventType));if(D&&D.entryAnimationId){console.log(`[Engine] Trigger matched: ${I} (as ${D.eventType}) -> Animation ${D.entryAnimationId}`);const o=this.artboard.animations.find(s=>s.id===D.entryAnimationId);o&&(this.activeTriggers.set(C.id,{triggerId:D.id,animation:o,time:0,phase:"entry",elapsedHold:0}),this.onTrigger&&this.onTrigger(D.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),D=I.x*g.scaleX,o=I.y*g.scaleY,s=g.x+(D*E-o*i),h=g.y+(D*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 e,M;if(!this.objectStates.get(A.id))return!1;const Q=((e=A.geometry)==null?void 0:e.width)??A.width??100,E=((M=A.geometry)==null?void 0:M.height)??A.height??100,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*h-o*a,t=D*a+o*h,K=i.scaleX,S=i.scaleY,y=Q*Math.abs(K),F=E*Math.abs(S);return Math.abs(G)<=y/2&&Math.abs(t)<=F/2}updateSliderValueFromPointer(A,I,C){var Z;const g=this.objectStates.get(A.id);if(!g)return;const Q=A.options||{},E=((Z=A.geometry)==null?void 0:Z.width)??A.width??200,i=this.getWorldTransform(A.id),D=I-i.x,o=C-i.y,s=-i.rotation*(Math.PI/180),h=Math.cos(s),a=Math.sin(s),G=D*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 F=Q.min??0,e=Q.max??100,M=Q.step||1;let n=F+y*(e-F);M>0&&(n=Math.round(n/M)*M),n=Math.max(F,Math.min(e,n));const X=g.options||{};X.value!==n&&(g.options={...X,value:n},A.inputId&&this.setInternalInput(A.inputId,n),this.onComponentChange&&this.onComponentChange({objectId:A.id,componentName:A.name,variant:"slider",property:"value",value:n}))}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 D=this.interpolate(C.keyframes,I);if(D!==void 0){if(this.frameCount%480===0){const a=(g==null?void 0:g.name)||C.object_id;this.debugLog(`Applying ${E} = ${typeof D=="object"?"OBJ":D} 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]]=D}else i[E]=D;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,D,a.y)}else if(E==="y"){const a=this.physicsEngine.getPosition(C.object_id);a&&this.physicsEngine.setPosition(C.object_id,a.x,D)}else E==="rotation"&&this.physicsEngine.setRotation(C.object_id,D*(Math.PI/180))}})}interpolate(A,I){if(A.length===0)return;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),D=parseFloat(g.value);return!isNaN(i)&&!isNaN(D)?Math.round(i+(D-i)*E).toString():C.value}return Array.isArray(C.value)&&Array.isArray(g.value)?C.value.length===g.value.length?C.value.map((i,D)=>{const o=g.value[D];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)}},D=i(Q),o=i(E),s=Math.round(D.r+(o.r-D.r)*C),h=Math.round(D.g+(o.g-D.g)*C),a=Math.round(D.b+(o.b-D.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 D=this.artboard.backgroundImage;let o=this.imageCache.get(D);if(o||(o=new Image,o.src=D,this.imageCache.set(D,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(D=>i.set(D.id,D)),this.artboard.objects.forEach(D=>{D.parentId||this.renderObject(A,D,i)}),A.restore()}calculateTransform(A,I,C,g,Q,E){let i=1,D=1,o=1;const s=C/g,h=A/I;switch(Q){case"Contain":h>s?o=I/g:o=A/C,i=D=o;break;case"Cover":h>s?o=A/C:o=I/g,i=D=o;break;case"Fill":i=A/C,D=I/g;break;case"FitWidth":o=A/C,i=D=o;break;case"FitHeight":o=I/g,i=D=o;break;case"None":i=D=1;break;case"ScaleDown":o=Math.min(A/C,I/g),o>1&&(o=1),i=D=o;break;default:i=D=1;break}const a=C*i,G=g*D;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:D,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 u,q,l,r,z,d,_,hA,SA,FA,NA;const g=this.objectStates.get(I.id);if(!g){console.warn("No state for object:",I.id);return}A.roundRect||(A.roundRect=(m,O,Y,R,x)=>(this.drawRoundRect(A,m,O,Y,R,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)||((u=I.geometry)==null?void 0:u.width)||I.width||0,D=(Q==null?void 0:Q.height)||((q=I.geometry)==null?void 0:q.height)||I.height||0;if((i===0||D===0)&&(Q!=null&&Q.points)&&Array.isArray(Q.points)&&Q.points.length>0){let m=1/0,O=-1/0,Y=1/0,R=-1/0;Q.points.forEach(x=>{m=Math.min(m,x.x),O=Math.max(O,x.x),Y=Math.min(Y,x.y),R=Math.max(R,x.y)}),i===0&&(i=O-m),D===0&&(D=R-Y)}const o=m=>{if(m)return m.corner_radius??m.cornerRadius},s=o(g)??o(E)??o(Q)??o(I.style)??o(I.geometry)??0,h={...Q,width:i,height:D};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||((l=I.style)==null?void 0:l.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"))||((z=I.type)==null?void 0:z.toLowerCase().includes("image")),y=E.adjustments&&Object.keys(E.adjustments).length>0?E.adjustments:null,F=Q!=null&&Q.adjustments&&Object.keys(Q.adjustments).length>0?Q.adjustments:null,e=S?F||y:y||F,M=S&&!e?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:e;if(g&&M&&(g.geometry=g.geometry||{},g.geometry.adjustments={...M}),M){const m=(M.exposure||0)/100,O=M.contrast||0,Y=1+(M.saturation||0)/100,R=(M.temperature||0)/200,x=(M.tint||0)/200,j=(M.highlights||0)/500,GA=(M.shadows||0)/500;let CA="",wA="SourceGraphic";if(m!==0&&(CA+=`
7
7
  <feComponentTransfer in="${wA}" result="exposure">
8
8
  <feFuncR type="linear" slope="1" intercept="${m}"/>
9
9
  <feFuncG type="linear" slope="1" intercept="${m}"/>
@@ -19,4 +19,4 @@
19
19
  0 ${BA} 0 0 ${1-BA}
20
20
  0 0 ${BA} 0 ${1-BA}
21
21
  0 0 0 1 0"/>`,wA="invert"}if(R!==0||x!==0||j!==0||GA!==0){const BA=1+j+GA,N=BA*(1+R-x/2),f=BA*(1+x),p=BA*(1-R-x/2),oA=M.shadows*.1/255,UA=[N,0,0,0,oA,0,f,0,0,oA,0,0,p,0,oA,0,0,0,1,0].join(" ");CA+=`<feColorMatrix in="${wA}" type="matrix" values="${UA}" result="advanced"/>`,wA="advanced"}if(M.blur&&(CA+=`<feGaussianBlur in="${wA}" stdDeviation="${M.blur}" result="blur"/>`,wA="blur"),CA){const BA=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${CA}</filter></svg>`,N=btoa(BA);t.push(`url('data:image/svg+xml;base64,${N}#f')`)}}t.length>0?A.filter=t.join(" "):A.filter="none",A.imageSmoothingEnabled=!0,A.imageSmoothingQuality="high";const n=A.globalAlpha,X=this.normalizeOpacity(g.opacity!==void 0?g.opacity:100);A.globalAlpha=n*X;const Z=g.compositeOperation||g.blendMode;if(Z&&Z!=="Normal"){const m=Z.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(m)&&(A.globalCompositeOperation=m)}const H=A,QA=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 L=!1;const U=QA.filter(m=>m.isVisible!==!1&&C.has(m.maskId));if(U.length>0){const m=U[0],O=C.get(m.maskId),Y=this.objectStates.get(O.id);Y&&Y.visible!==!1&&(L=!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.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",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=H.filter)}A.translate(Math.round(a),Math.round(G)),A.rotate(g.rotation*Math.PI/180);const T=g.skew_x||0,AA=g.skew_y||0;(T!==0||AA!==0)&&A.transform(1,Math.tan(AA*Math.PI/180),Math.tan(T*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 IA=E.shadow;if(IA&&IA.isEnabled!==!1){let m=IA.color||"#000000";(_=(d=this.artboard)==null?void 0:d.tokens)!=null&&_.colors&&this.artboard.tokens.colors[m]&&(m=this.artboard.tokens.colors[m]);const O=this.normalizeOpacity(IA.opacity??100),Y=IA.spread||0,x=(IA.blur||0)+Y*1.5;let j=m;if(m.startsWith("#")){const wA=m.replace("#",""),kA=parseInt(wA.substring(0,2),16),BA=parseInt(wA.substring(2,4),16),N=parseInt(wA.substring(4,6),16);j=`rgba(${kA}, ${BA}, ${N}, ${O})`}else if(m.startsWith("rgba")){const wA=m.match(/[\d.]+/g);if(wA&&wA.length>=4){const kA=wA[0],BA=wA[1],N=wA[2],f=wA[3];j=`rgba(${kA}, ${BA}, ${N}, ${parseFloat(f)*O})`}}const GA=A.getTransform(),CA=Math.sqrt(GA.a*GA.a+GA.b*GA.b)||1;A.shadowColor=j,A.shadowBlur=x*CA,A.shadowOffsetX=(IA.offsetX||0)*CA,A.shadowOffsetY=(IA.offsetY||0)*CA}const b=I.liquidFill||((hA=I.style)==null?void 0:hA.liquidFill),P=I.artEffect||((SA=I.style)==null?void 0:SA.artEffect);if(b&&b.enabled){A.save();const m=b.fillLevel??.5;A.beginPath();const O=D/2-D*m;A.rect(-i/2,O,i,D*m),A.clip(),A.fillStyle=b.color||"#3b82f6",A.globalAlpha=A.globalAlpha*(b.opacity??1)}const gA=P&&P.enabled&&P.type==="glitch";if(gA){A.save();const O=(P.intensity??.5)*10,Y=A.getTransform(),R=Math.sqrt(Y.a*Y.a+Y.b*Y.b)||1;A.shadowColor="rgba(255, 0, 0, 0.5)",A.shadowBlur=O*R,A.translate(O/2,0)}if(Q.type==="Text")this._renderText(A,I,h,E,g,i,D);else if(Q.type==="Image"){const m=Q.src;if(m){let O=this.imageCache.get(m);O||(O=new Image,O.onload=()=>{},O.onerror=()=>{console.error(`[ExodeUI] Image load failed: ${m.substring(0,100)}${m.length>100?"...":""}`)},O.src=m,this.imageCache.set(m,O));const Y=E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1,R=(((FA=E.stroke)==null?void 0:FA.alignment)||"center").toLowerCase();if(Y&&(R==="outside"||R==="center")&&this.applyStrokeAlignment(A,E,h,i,D,s),E.fill&&E.fill.type!=="None"){A.save();const x=A.globalAlpha,j=this.createCanvasFill(A,E.fill,i,D);A.fillStyle=j||E.fill.color||"transparent",A.globalAlpha=x*this.normalizeOpacity(E.fill.opacity??100),s!==0?(this.drawRoundRect(A,-i/2,-D/2,i,D,s),A.fill()):A.fillRect(-i/2,-D/2,i,D),A.globalAlpha=x,A.restore()}O.complete&&O.naturalWidth>0?(s!==0?(A.save(),this.drawRoundRect(A,-i/2,-D/2,i,D,s),A.clip(),A.drawImage(O,-i/2,-D/2,i,D),A.restore()):A.drawImage(O,-i/2,-D/2,i,D),Y&&R==="inside"&&this.applyStrokeAlignment(A,E,h,i,D,s)):Y&&R==="inside"&&this.applyStrokeAlignment(A,E,h,i,D,s)}}else if(Q.type==="SVG"){const m=Q.svgContent;if(m){const O=E.palette||[],Y=E.fill,R=E.stroke,x=Y?this.normalizeOpacity(Y.opacity??100):1,j=(Y==null?void 0:Y.type)==="Solid"&&(!R||R.isEnabled===!1||R.type==="Solid"&&R.color===Y.color),GA=Y&&Y.type!=="None"?j?"monochrome":Y.type==="Solid"?(Y.color||"")+"|opacity:"+x:JSON.stringify(Y.stops||[])+"|opacity:"+x:"",CA=R&&R.isEnabled!==!1&&(R.width||0)>0?j?["monochrome",R.width||0,R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):[R.width||0,R.fill?R.fill.type==="Solid"?R.fill.color||"":JSON.stringify(R.fill.stops||[]):R.color||"",R.opacity??1,R.lineCap||"",R.lineJoin||"",(R.dashArray||[]).join(","),R.trimStart??0,R.trimEnd??1,R.trimOffset??0,R.dashOffset??0].join("|"):"nostroke",wA=[I.id,O.join("_"),GA,CA,g.opacity??100,g.visible!==!1?"v":"h"].join("_");let kA=this.imageCache.get(wA);if(!kA){kA=new Image,kA.crossOrigin="anonymous";let N=m;if(Q.colors&&Q.colors.length>0&&O.length>0&&Q.colors.forEach((iA,V)=>{if(O[V]){const $=iA.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),DA=new RegExp($,"gi");N=N.replace(DA,O[V])}}),Y&&Y.type&&Y.type!=="None"){if(Y.type==="Solid"&&Y.color){const iA=j?"#FFFFFF":Y.color,V=j?1:this.normalizeOpacity(Y.opacity??100);N=N.replace(/\bfill\s*=\s*["'][^"']*["']/gi,$=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test($)?$:`fill="${iA}"`),N=N.replace(/fill\s*:\s*[^;"')]+/gi,$=>/fill\s*:\s*(none|transparent)/i.test($)?$:`fill:${iA}`),V<1&&(N=N.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${V}"`),N=N.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${V}`),N.match(/\bfill-opacity\s*=/i)||(N=N.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${V}">`),N=N.replace(/<\/svg>/i,"</g></svg>")))}else if(Y.type==="LinearGradient"||Y.type==="RadialGradient"||Y.type==="Linear"||Y.type==="Radial"){const iA="exode-fill",V=this.normalizeOpacity(Y.opacity??100),$=(Y.stops||[]).map(EA=>{const v=EA.offset!==void 0?EA.offset:EA.pos??0,aA=this.normalizeOpacity(EA.opacity??100)*V;return`<stop offset="${v*100}%" stop-color="${EA.color||"#000"}" stop-opacity="${aA}"/>`}).join("");let DA="";if(Y.type==="LinearGradient"||Y.type==="Linear"){const EA=(uA,RA)=>Array.isArray(uA)?uA[RA]??(RA===0?0:1):uA&&typeof uA=="object"?uA[RA===0?"x":"y"]??(RA===0?0:1):RA===0?0:1,v=EA(Y.start,0)*100,aA=EA(Y.start,1)*100,yA=EA(Y.end,0)*100,YA=EA(Y.end,1)*100;DA=`<linearGradient id="${iA}" x1="${v}%" y1="${aA}%" x2="${yA}%" y2="${YA}%" gradientUnits="objectBoundingBox">${$}</linearGradient>`}else{const EA=(YA,uA)=>Array.isArray(YA)?YA[uA]??.5:YA&&typeof YA=="object"?YA[uA===0?"x":"y"]??.5:.5,v=EA(Y.center,0)*100,aA=EA(Y.center,1)*100,yA=(Y.radius??.5)*100;DA=`<radialGradient id="${iA}" cx="${v}%" cy="${aA}%" r="${yA}%" gradientUnits="objectBoundingBox">${$}</radialGradient>`}/<defs>/i.test(N)?N=N.replace(/<defs>/i,`<defs>${DA}`):N=N.replace(/<svg([^>]*)>/i,`<svg$1><defs>${DA}</defs>`),N=N.replace(/\bfill\s*=\s*["'][^"']*["']/gi,EA=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(EA)?EA:`fill="url(#${iA})"`),N=N.replace(/fill\s*:\s*[^;"')]+/gi,EA=>/fill\s*:\s*(none|transparent)/i.test(EA)?EA:`fill:url(#${iA})`)}}const f=(iA,V,$=1)=>{const DA=(iA.stops||[]).map(YA=>{const uA=YA.offset!==void 0?YA.offset:YA.pos??0,RA=this.normalizeOpacity(YA.opacity??100)*$;return`<stop offset="${uA*100}%" stop-color="${YA.color||"#000"}" stop-opacity="${RA}"/>`}).join(""),EA=(YA,uA,RA=.5)=>Array.isArray(YA)?YA[uA]??RA:YA&&typeof YA=="object"?YA[uA===0?"x":"y"]??RA:RA;if(iA.type==="LinearGradient"||iA.type==="Linear"){const YA=EA(iA.start,0,0)*100,uA=EA(iA.start,1,0)*100,RA=EA(iA.end,0,1)*100,$A=EA(iA.end,1,1)*100;return`<linearGradient id="${V}" x1="${YA}%" y1="${uA}%" x2="${RA}%" y2="${$A}%" gradientUnits="objectBoundingBox">${DA}</linearGradient>`}const v=EA(iA.center,0,.5)*100,aA=EA(iA.center,1,.5)*100,yA=(iA.radius??.5)*100;return`<radialGradient id="${V}" cx="${v}%" cy="${aA}%" r="${yA}%" gradientUnits="objectBoundingBox">${DA}</radialGradient>`},p=(iA,V)=>/<defs>/i.test(iA)?iA.replace(/<defs>/i,`<defs>${V}`):iA.replace(/(<svg[^>]*>)/i,`$1<defs>${V}</defs>`);if(R&&R.isEnabled!==!1&&(R.width||0)>0){const iA=R.width||1,V=j?1:this.normalizeOpacity(R.opacity??100),$=j?"#FFFFFF":R.color||(Y==null?void 0:Y.color)||"#000000";let DA="";const EA=R.fill;if(EA&&EA.type){if(EA.type==="Solid")DA=EA.color||R.color||"#000000";else if(EA.type==="LinearGradient"||EA.type==="RadialGradient"||EA.type==="Linear"||EA.type==="Radial"){const RA="exode-stroke";N=p(N,f(EA,RA,V)),DA=`url(#${RA})`}}DA||(DA=$),N.match(/\bstroke\s*=/i)?N=N.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,RA=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(RA)?RA:`stroke="${DA}"`):N=N.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${DA}"`),N=N.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${DA}`),N.match(/\bstroke-width\s*=/i)?N=N.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${iA}"`):N=N.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${iA}"`),N=N.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${iA}`),N.match(/\bstroke-opacity\s*=/i)?N=N.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${V}"`):N=N.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${V}"`),N=N.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${V}`),R.lineCap&&(N=N.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${R.lineCap}"`),N=N.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${R.lineCap}`)),R.lineJoin&&(N=N.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${R.lineJoin}"`),N=N.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${R.lineJoin}`));const v=R.trimStart??0,aA=R.trimEnd??1,yA=R.trimOffset??0,YA=R.dashOffset??0,uA=v!==0||aA!==1||yA!==0||YA!==0;if(uA){const RA=Math.max(0,Math.min(1,v)),$A=Math.max(0,Math.min(1,aA));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${I.name||I.id}, Start: ${RA}, End: ${$A}`);let tg=Q.width||i||100,Kg=Q.height||D||100;const xI=m.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(xI){const kI=parseFloat(xI[1]),UI=parseFloat(xI[2]);!isNaN(kI)&&!isNaN(UI)&&(tg=kI,Kg=UI)}const yI=(tg+Kg)*2,OI=(yA%1+1)%1,oI=(YA%1+1)%1;let QI="",DI=0;if(RA>=$A)QI=`0 ${yI}`,DI=0;else{const kI=yI*($A-RA),UI=yI-kI;DI=-(yI*(RA+OI+oI)),QI=`${kI} ${UI}`}N.match(/\bstroke-dasharray\s*=/i)?N=N.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${QI}"`):N=N.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${QI}"`),N=N.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${QI}`),N.match(/\bstroke-dashoffset\s*=/i)?N=N.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${DI}"`):N=N.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${DI}"`),N=N.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${DI}`)}else if(R.dashArray&&R.dashArray.length>0){const RA=R.dashArray.join(" ");N=N.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${RA}"`),N=N.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${RA}`),R.dashOffset&&(N=N.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${R.dashOffset}"`),N=N.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${R.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(m)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(m)){let RA="",$A="";if(uA){const yI=Q.width||i||100,OI=Q.height||D||100,oI=(yI+OI)*2,QI=Math.max(0,Math.min(1,v)),DI=Math.max(0,Math.min(1,aA)),kI=(yA%1+1)%1,UI=(YA%1+1)%1;if(QI>=DI)RA=` stroke-dasharray="0 ${oI}"`,$A=' stroke-dashoffset="0"';else{const WQ=oI*(DI-QI),Ci=oI-WQ,Qi=-(oI*(QI+kI+UI));RA=` stroke-dasharray="${WQ} ${Ci}"`,$A=` stroke-dashoffset="${Qi}"`}}else(NA=R.dashArray)!=null&&NA.length&&(RA=` stroke-dasharray="${R.dashArray.join(" ")}"`,R.dashOffset&&($A=` stroke-dashoffset="${R.dashOffset}"`));const tg=R.lineCap?` stroke-linecap="${R.lineCap}"`:"",Kg=R.lineJoin?` stroke-linejoin="${R.lineJoin}"`:"",xI=`stroke="${DA}" stroke-width="${iA}" stroke-opacity="${V}"${tg}${Kg}${RA}${$A}`;N=N.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(yI,OI,oI)=>`${OI}${oI}<g ${xI}>`),N=N.replace(/<\/svg>/i,"</g></svg>")}}else R&&R.isEnabled===!1&&(N=N.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),N=N.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const oA=new Blob([N],{type:"image/svg+xml"}),UA=URL.createObjectURL(oA);kA.onload=()=>{if(URL.revokeObjectURL(UA),this.frameCount%900===0){const iA=this.imageCache.get(wA);iA&&this.debugLog(`SVG Payload Ready: ${I.name||I.id} (${iA.naturalWidth}x${iA.naturalHeight})`)}},kA.onerror=()=>{URL.revokeObjectURL(UA),this.debugLog(`SVG Error: Failed to load payload for ${I.name||I.id}`)},kA.src=UA,this.imageCache.set(wA,kA)}let BA=null;if(kA.complete&&kA.naturalWidth>0?(BA=kA,this.lastValidSvgImgMap.set(I.id,kA)):BA=this.lastValidSvgImgMap.get(I.id)||null,BA&&BA.complete&&BA.naturalWidth>0){const N=Math.max(1,i),f=Math.max(1,D);if(j&&(Y==null?void 0:Y.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=N,this.maskBuffer.height=f,this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,N,f),this.maskCtx.drawImage(BA,0,0,N,f),this.maskCtx.globalCompositeOperation="source-in";const p=Y.color||"#000000",oA=this.normalizeOpacity(Y.opacity??100);this.maskCtx.fillStyle=p,this.maskCtx.globalAlpha=oA,this.maskCtx.fillRect(0,0,N,f),A.drawImage(this.maskBuffer,-N/2,-f/2,N,f)}else s!==0?(A.save(),this.drawRoundRect(A,-N/2,-f/2,N,f,s),A.clip(),A.drawImage(BA,-N/2,-f/2,N,f),A.restore()):A.drawImage(BA,-N/2,-f/2,N,f)}}}else if(h.type==="LineGraph")this.renderLineGraph(A,h,i,D);else if(I.type==="Shape"){if(this.applyPath(A,h,i,D,s),A.save(),E.blur&&E.blur.amount>0&&(A.filter=`blur(${E.blur.amount}px)`),E.fill){const m=A.globalAlpha,O=this.createCanvasFill(A,E.fill,i,D);O?A.fillStyle=O:A.fillStyle=typeof E.fill=="string"?E.fill:E.fill.color||"transparent",A.globalAlpha=m*this.normalizeOpacity(E.fill.opacity??100),this.applyPath(A,h,i,D,s),A.fill(),A.globalAlpha=m}A.restore(),E.stroke&&E.stroke.width>0&&this.applyStrokeAlignment(A,E,h,i,D,s)}else if(I.type==="Frame"||I.type==="Group"&&!I.isStructuralGroup){const m=g.width??Q.width??I.width??i,O=g.height??Q.height??I.height??D,Y=s;if(A.save(),A.beginPath(),this.drawRoundRect(A,-m/2,-O/2,m,O,Y),E.fill&&E.fill.type!=="None"){const R=A.globalAlpha,x=this.createCanvasFill(A,E.fill,m,O);A.fillStyle=x||E.fill.color||"transparent",A.globalAlpha=R*this.normalizeOpacity(E.fill.opacity??100),A.fill(),A.globalAlpha=R}if(A.restore(),E.stroke&&E.stroke.width>0&&E.stroke.isEnabled!==!1){const R={type:"Rectangle"};this.applyStrokeAlignment(A,E,R,m,O,Y)}}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(gA&&A.restore(),b&&b.enabled&&A.restore(),I.children&&I.children.length>0){const O=I.type==="Frame",Y=I.clipsContent!==void 0?I.clipsContent:I.clipContent!==void 0?I.clipContent:O;if(A.save(),Y){A.beginPath();const x=g.width??(Q==null?void 0:Q.width)??I.width??0,j=g.height??(Q==null?void 0:Q.height)??I.height??0,GA=g.cornerRadius??(Q==null?void 0:Q.corner_radius)??I.cornerRadius??0;this.drawRoundRect(A,-x/2,-j/2,x,j,GA),A.clip()}let R=0;for(I.children.forEach(x=>{const j=C.get(x);if(!j)return;const GA=this.objectStates.get(x),CA=(GA==null?void 0:GA.geometry)||j.geometry;if(CA&&CA.isMask&&(GA==null?void 0:GA.visible)!==!1){const wA=CA.width||0,kA=CA.height||0;this.applyObjectTransform(A,x);const BA=(GA==null?void 0:GA.corner_radius)??(CA==null?void 0:CA.corner_radius)??0;this.applyPath(A,CA,wA,kA,BA),A.clip(),R++}else this.renderObject(A,j,C)});R>0;)A.restore(),R--;A.restore()}if(L){this.maskCtx.restore(),(g.masks||(I.maskedBy?[{maskId:I.maskedBy,inverted:I.maskInverted===!0,type:I.maskType||"alpha",opacity:I.maskOpacity!==void 0?I.maskOpacity/100:1,feather:I.maskFeather||0,isVisible:!0}]:[])).filter(R=>R.isVisible!==!1&&C.has(R.maskId)).forEach(R=>{const x=C.get(R.maskId),j=this.objectStates.get(x.id),GA=R.feather||0,CA=R.inverted===!0,wA=R.opacity!==void 0?typeof R.opacity=="number"?R.opacity:R.opacity/100:1;if((R.type||"alpha")==="luma"){(!this.lumaBuffer||this.lumaBuffer.width!==this.maskBuffer.width||this.lumaBuffer.height!==this.maskBuffer.height)&&(this.lumaBuffer=document.createElement("canvas"),this.lumaBuffer.width=this.maskBuffer.width,this.lumaBuffer.height=this.maskBuffer.height,this.lumaCtx=this.lumaBuffer.getContext("2d",{willReadFrequently:!0}),this.lumaCtx&&(this.lumaCtx.imageSmoothingEnabled=!0,this.lumaCtx.imageSmoothingQuality="high")),this.lumaCtx.setTransform(1,0,0,1,0,0),this.lumaCtx.globalCompositeOperation="source-over",this.lumaCtx.globalAlpha=1,this.lumaCtx.filter="none",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),GA>0&&(this.lumaCtx.filter=`blur(${GA}px)`),this.lumaCtx.globalAlpha=wA;const BA=(j==null?void 0:j.width)||x.geometry.width||0,N=(j==null?void 0:j.height)||x.geometry.height||0,f=(j==null?void 0:j.corner_radius)??x.corner_radius??0;if(x.geometry.type==="Text"){const iA=j!=null&&j.geometry?this.deepMerge(x.geometry,j.geometry):x.geometry,V=j!=null&&j.style?this.deepMerge(x.style,j.style):x.style;this._renderText(this.lumaCtx,x,{...iA,width:BA,height:N,corner_radius:f},V,j,BA,N,!0)}else if(x.geometry.type==="Image"){const iA=x.geometry.src;if(iA){let V=this.imageCache.get(iA);V||(V=new Image,V.src=iA,this.imageCache.set(iA,V)),V.complete&&V.naturalWidth>0?this.lumaCtx.drawImage(V,-BA/2,-N/2,BA,N):(this.applyPath(this.lumaCtx,x.geometry,BA,N,f),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(x.geometry.type==="SVG"){const iA=x.geometry.svgContent;if(iA){const V=`__lumamask_${x.id}`;let $=this.imageCache.get(V);if(!$){$=new Image;const DA=new Blob([iA],{type:"image/svg+xml"});$.src=URL.createObjectURL(DA),$.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(V,$)}$.complete&&$.naturalWidth>0?this.lumaCtx.drawImage($,-BA/2,-N/2,BA,N):(this.applyPath(this.lumaCtx,x.geometry,BA,N,f),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,x.geometry,BA,N,f),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const p=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),oA=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,UA=p.data;for(let iA=0;iA<UA.length;iA+=4){const V=oA[iA],$=oA[iA+1],DA=oA[iA+2];let EA=(.299*V+.587*$+.114*DA)/255;CA&&(EA=1-EA),UA[iA+3]*=EA}this.maskCtx.putImageData(p,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=CA?"destination-out":"destination-in",GA>0&&(this.maskCtx.filter=`blur(${GA}px)`),this.maskCtx.globalAlpha=wA,this.applyAbsoluteTransform(this.maskCtx,x.id,C);const BA=(j==null?void 0:j.width)||x.geometry.width||0,N=(j==null?void 0:j.height)||x.geometry.height||0,f=(j==null?void 0:j.corner_radius)??x.corner_radius??0;if(x.geometry.type==="Text"){const p=j!=null&&j.geometry?this.deepMerge(x.geometry,j.geometry):x.geometry,oA=j!=null&&j.style?this.deepMerge(x.style,j.style):x.style;this._renderText(this.maskCtx,x,{...p,width:BA,height:N,corner_radius:f},oA,j,BA,N,!0)}else if(x.geometry.type==="Image"){const p=x.geometry.src;if(p){let oA=this.imageCache.get(p);oA||(oA=new Image,oA.src=p,this.imageCache.set(p,oA)),oA.complete&&oA.naturalWidth>0?this.maskCtx.drawImage(oA,-BA/2,-N/2,BA,N):(this.applyPath(this.maskCtx,x.geometry,BA,N,f),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(x.geometry.type==="SVG"){const p=x.geometry.svgContent;if(p){const oA=`__alphamask_${x.id}`;let UA=this.imageCache.get(oA);if(!UA){UA=new Image;const iA=new Blob([p],{type:"image/svg+xml"});UA.src=URL.createObjectURL(iA),UA.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(oA,UA)}UA.complete&&UA.naturalWidth>0?this.maskCtx.drawImage(UA,-BA/2,-N/2,BA,N):(this.applyPath(this.maskCtx,x.geometry,BA,N,f),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,x.geometry,BA,N,f),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),H.save(),H.setTransform(1,0,0,1,0,0);const Y=I.maskBlendMode||I.blendMode;Y&&Y!=="Normal"&&(H.globalCompositeOperation=Y.toLowerCase()),H.drawImage(this.maskBuffer,0,0),H.restore(),H.restore()}else A.restore()}_renderText(A,I,C,g,Q,E,i,D=!1,o=!1){var l;let s=C.text||"";if(C.textInputId&&!D){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(z=>z&&z.text?z.text:"").join("");r!==h&&r.toUpperCase()===(s||"").toUpperCase()?h=s||"":h=r}let a=((l=C.fontWeight)==null?void 0:l.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 z=new RegExp(`[\\s-]${r}$`,"i");z.test(S)&&(S=S.replace(z,"").trim())}),A.font=`${G} ${t} ${K}px "${S}", sans-serif`;const F=C.textVerticalAlign||"top";A.textBaseline="top";const e=C.textAlign||"left";A.textAlign=e;const M=C.letterSpacing||0,n=C.paragraphSpacing||0,X=(C.lineHeight||1.2)*K,Z=Math.ceil(C.width||E||200)+.5,H=`${G} ${t} ${K}px "${S}", sans-serif`,QA=r=>{if(M===0)return A.measureText(r).width;let z=0;for(let d=0;d<r.length;d++)z+=A.measureText(r[d]).width+M;return z-M},L=`${h}|${H}|${M}|${n}`;let U=this.pretextCache.get(L);if(!U&&(U=SE(h,H),this.pretextCache.set(L,U),this.pretextCache.size>1e3)){const r=this.pretextCache.keys().next().value;r&&this.pretextCache.delete(r)}const T=U?eE(U,Z,X):{height:0,lines:[]},AA=(T==null?void 0:T.height)??0,IA=(T==null?void 0:T.lines)??[];let b=AA;const P=this.getFontLeadingFactor(C.fontFamily||"Inter"),gA=(X-K)*P;let u=Math.round(-b/2);i>0&&(F==="top"?u=Math.round(-i/2):F==="middle"||F==="center"?u=Math.round(-b/2):F==="bottom"&&(u=Math.round(i/2-b))),u+=gA;const q=(r,z,d,_,hA)=>{var FA,NA,m;const SA=(!D||o)&&(I.behaviors||[]).some(O=>O.enabled&&(O.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(O.type)));if(M===0&&!SA&&(C.enableSegments!==!0||!C.segments||C.segments.length===0))_?A.strokeText(r,z,d):A.fillText(r,z,d);else{const O=QA(r);let Y=z;e==="center"?Y-=O/2:e==="right"&&(Y-=O);let R=Y;const x=D&&!o?[]:((FA=I.behaviors)==null?void 0:FA.filter(j=>[W.Typewriter,W.Scramble,W.Wave,W.Bounce,W.GlitchText,W.TextTrail,W.Reveal3D,W.RevealSlide,W.RevealBlur,W.TextLiquid,W.TextVortex,W.TextExplosion,W.TextRain,W.TextGravity,W.TextElastic,W.TextMatrix,W.TextNeon,W.TextGlitch3D,W.TextDissolve,W.TextOrganic,W.TextBreathe,W.TextFloral,W.TextSmoke,W.TextVariable,W.TextMagnet,W.TextSpin,W.TextZing,W.TextPerspective,W.TextMirror].includes(j.type)&&j.enabled))||[];for(let j=0;j<r.length;j++){let GA=r[j];const CA=hA+j;let wA=0,kA=0,BA=1,N=1,f=0,p=1,oA=GA;if(x.forEach(V=>{const $=V.settings||{},DA=$.strength||1,EA=Date.now();if(V.type===W.Typewriter)this.currentTime*($.speed||1)-CA*($.stagger||.05)<0&&(p=0);else if(V.type===W.Scramble)Math.max(0,Math.min(1,this.currentTime/($.duration||1.5))-CA*.02)<1&&Math.random()<.3&&(oA="$%#@!*&"[Math.floor(Math.random()*7)]);else if(V.type===W.Wave)kA+=Math.sin(this.currentTime*5*($.speed||1)+CA*($.frequency||1))*($.amplitude||20)*DA;else if(V.type===W.Bounce){const v=Math.max(0,this.currentTime%2-CA*($.stagger||.1));v<1&&(kA-=Math.abs(Math.sin(v*Math.PI))*($.height||50)*DA)}else if(V.type===W.TextTrail){const v=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-CA*($.delay||5))];v&&(wA+=(v.x-(Q.x+R))*DA*.2,kA+=(v.y-(Q.y+d+kA))*DA*.2)}else if(V.type===W.Reveal3D){const v=Math.max(0,Math.min(1,this.currentTime*($.speed||1)-CA*($.stagger||.1)));BA*=v,N*=v,p=v}else if(V.type===W.RevealSlide){const v=Math.max(0,Math.min(1,this.currentTime*1.5-CA*.05)),aA=(1-v)*($.distance||40)*DA,yA=$.direction||"up";yA==="up"?kA-=aA:yA==="down"?kA+=aA:yA==="left"?wA-=aA:yA==="right"&&(wA+=aA),p=v}else if(V.type===W.RevealBlur){const v=Math.max(0,Math.min(1,this.currentTime*1.2-CA*.1));p=v,wA+=(1-v)*5}else if(V.type===W.TextLiquid){const v=Math.max(0,Math.sin(EA*.001*($.speed||1)+CA*.5));kA+=v*($.amplitude||10)*DA,N*=1+v*.2}else if(V.type===W.TextVortex){const v=EA*.002*($.speed||1)+CA*.2,aA=(1-(Math.sin(EA*.001)*.5+.5))*($.radius||50);wA+=Math.cos(v)*aA*DA,kA+=Math.sin(v)*aA*DA}else if(V.type===W.TextExplosion){const v=$.force||1,aA=this.currentTime%2;if(aA<1){const yA=(CA/r.length-.5)*Math.PI*2,YA=aA*100*v;wA+=Math.cos(yA)*YA*DA,kA+=Math.sin(yA)*YA*DA,p=1-aA}}else if(V.type===W.TextRain){const v=$.speed||1,aA=$.height||100,yA=(EA*.001*v+CA*.1)%1;kA-=(1-yA)*aA*DA,p=yA>.1?1:yA*10}else if(V.type===W.TextGravity){const v=$.gravity||9.8,aA=this.currentTime%3/3,yA=.5*v*Math.pow(aA*10,2);yA<100?kA+=yA*DA:kA+=100*DA}else if(V.type===W.TextMatrix){const v=$.speed||1;if(Math.random()<.1*v){const yA="0123456789ABCDEF!@#$%^&*";oA=yA[Math.floor(Math.random()*yA.length)]}p=.3+(Math.sin(EA*.01*v+CA)+1)/2*.7}else if(V.type===W.TextNeon){const v=Math.random()>.95?.5:1;p=(.7+(Math.sin(EA*.005)+1)/2*.3)*v}else if(V.type===W.TextDissolve)Math.sin(CA*1.5+EA*.002*($.speed||1))>.5&&(p=0);else if(V.type===W.TextOrganic){const v=$.speed||1,aA=$.amplitude||10;wA+=Math.sin(EA*.002*v+CA)*aA*DA,kA+=Math.cos(EA*.0015*v+CA*.7)*aA*DA}else if(V.type===W.TextBreathe){const aA=1+(Math.sin(EA*.003+CA*.2)+1)/2*.2*DA;BA*=aA,N*=aA}else if(V.type===W.TextSpin){const v=$.speed||1;f+=EA*.01*v+CA}else if(V.type===W.TextMagnet){const v=this.pointerHistory[this.pointerHistory.length-1];if(v){const aA=v.x-(Q.x+R),yA=v.y-(Q.y+d);f=Math.atan2(yA,aA)}}else if(V.type===W.TextPerspective){const v=r.length/2,aA=(CA-v)/v,yA=1-Math.abs(aA)*.3*DA;BA*=yA,N*=yA,wA+=aA*20*DA}else if(V.type===W.TextMirror)p*=.8;else if(V.type===W.TextFloral){const v=$.speed||1,aA=$.stagger||.1,yA=(EA*.001*v+CA*aA)%2;yA<1&&(BA*=yA,N*=yA,f+=yA*Math.PI)}else if(V.type===W.TextSmoke){const v=$.speed||1,aA=$.height||50,yA=(EA*5e-4*v+CA*.2)%1;kA-=yA*aA*DA,wA+=Math.sin(EA*.002+CA)*5*DA,p=1-yA}else if(V.type===W.TextVariable){const v=$.speed||1,aA=$.intensity||1.5,yA=(Math.sin(EA*.004*v+CA*.3)+1)/2;BA*=1+yA*(aA-1)*DA}else if(V.type===W.TextZing){const v=$.speed||2,aA=$.distance||100,yA=(EA*.002*v+CA*.05)%1;wA+=(1-yA)*aA*DA,p=yA}else if(V.type===W.TextElastic){const v=$.stiffness||.2,aA=$.damping||.1,yA=Math.sin(EA*.01)*Math.exp(-EA*.001*aA);N*=1+yA*v*DA}else if(V.type===W.TextGlitch3D){const v=$.intensity||5;Math.random()<.2&&(wA+=(Math.random()-.5)*v,kA+=(Math.random()-.5)*v,p=.8)}else if(V.type===W.GlitchText){const v=$.intensity||5;Math.random()<.1&&(wA+=(Math.random()-.5)*v,kA+=(Math.random()-.5)*v,Math.random()<.05&&(p=.5))}}),p<=0){R+=A.measureText(GA).width+M;continue}if(C.enableSegments===!0&&((NA=C.segments)==null?void 0:NA.length)>0){let V=0,$=null;for(const DA of C.segments){if(CA<V+(DA.text||"").length){$=DA;break}V+=(DA.text||"").length}if($){let DA=$.fontFamily||C.fontFamily||"Inter";y.forEach(EA=>{const v=new RegExp(`[\\s-]${EA}$`,"i");v.test(DA)&&(DA=DA.replace(v,"").trim())}),A.font=`${G} ${this.mapFontWeight(($.fontWeight||C.fontWeight||"400").toString())} ${$.fontSize||K}px "${DA}", sans-serif`}}const UA=A.globalAlpha;A.globalAlpha*=p,A.save();const iA=A.measureText(oA).width;if(A.translate(R+wA+iA/2,d+kA),f!==0&&A.rotate(f),A.scale(BA,N),D||o){const V=o?"#000000":this.createCanvasFill(A,g.fill,E,i);A.fillStyle=V||g.fill.color||"#ffffff",A.fillText(oA,-iA/2,0)}else _?A.strokeText(oA,-iA/2,0):A.fillText(oA,-iA/2,0);A.restore(),A.globalAlpha=UA,C.enableSegments===!0&&((m=C.segments)==null?void 0:m.length)>0&&(A.font=`${G} ${this.mapFontWeight((C.fontWeight||"400").toString())} ${K}px "${C.fontFamily||"Inter"}", sans-serif`),R+=A.measureText(GA).width+M}}};if(D){let r=0,z=u;(IA||[]).forEach(d=>{let _=-E/2;e==="center"?_=0:e==="right"&&(_=E/2),q(d.text,_,z,!1,r),r+=(d.text||"").length+1,z+=X})}else if(o){let r=0,z=u;(IA||[]).forEach(d=>{let _=-E/2;e==="center"?_=0:e==="right"&&(_=E/2),q(d.text,_,z,!1,r),r+=(d.text||"").length+1,z+=X})}else{if(g.fill){const r=A.globalAlpha,z=this.createCanvasFill(A,g.fill,E,i);A.fillStyle=z||g.fill.color||"#000000",A.globalAlpha=r*this.normalizeOpacity(g.fill.opacity??100);let d=0,_=u;(IA||[]).forEach(hA=>{let SA=Math.round(-E/2);e==="center"?SA=0:e==="right"&&(SA=Math.round(E/2)),q(hA.text,SA,_,!1,d),d+=(hA.text||"").length+1,_+=X}),A.globalAlpha=r}if(g.stroke&&g.stroke.width>0){const r=A.globalAlpha;g.fill&&g.fill.type!=="None"&&(A.shadowColor="transparent",A.shadowBlur=0,A.shadowOffsetX=0,A.shadowOffsetY=0),A.strokeStyle=g.stroke.color,A.lineWidth=g.stroke.width,A.globalAlpha=r*this.normalizeOpacity(g.stroke.opacity??100);let z=0,d=u;(IA||[]).forEach(_=>{let hA=Math.round(-E/2);e==="center"?hA=0:e==="right"&&(hA=Math.round(E/2)),q(_.text,hA,d,!0,z),z+=(_.text||"").length+1,d+=X}),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,D=i.width,o=(i.alignment||"center").toLowerCase();if(A.save(),I.fill&&I.fill.type!=="None"&&(A.shadowColor="transparent",A.shadowBlur=0,A.shadowOffsetX=0,A.shadowOffsetY=0),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=D,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)),F=Math.max(0,Math.min(1,a));if(y<F){const e=S*(F-y),M=S-e,n=-(S*(y+G%1+t%1));A.setLineDash([e,M]),A.lineDashOffset=n}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=D*2,A.save(),this.applyPath(A,C,g,Q,E),A.clip(),A.stroke(),A.restore()):o==="outside"?(A.lineWidth=D*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=D,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,D=Math.PI*(3*(g+Q)-Math.sqrt((3*g+Q)*(g+3*Q)));if(E>=360&&i<=0)return D;let o=E/360*D;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],D=g[E];if(i.out_x!==void 0||D.in_x!==void 0)Q+=this.getBezierLength(i.x,i.y,i.out_x??i.x,i.out_y??i.y,D.in_x??D.x,D.in_y??D.y,D.x,D.y);else{const o=D.x-i.x,s=D.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 D=i.x-E.x,o=i.y-E.y;Q+=Math.sqrt(D*D+o*o)}}return Q}default:return(I+C)*2}}getBezierLength(A,I,C,g,Q,E,i,D,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,F=y*K,e=S*t,M=F*A+3*y*t*C+3*K*S*Q+e*i,n=F*I+3*y*t*g+3*K*S*E+e*D,X=M-h,Z=n-a;s+=Math.sqrt(X*X+Z*Z),h=M,a=n}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,D=1/0,o=-1/0;Q.forEach(S=>{E=Math.min(E,S.x),i=Math.max(i,S.x),D=Math.min(D,S.y),o=Math.max(o,S.y)});const s=(E+i)/2,h=(D+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,F=S.p1;let e=0;const M=y.out_x!==void 0||F.in_x!==void 0;if(M?e=this.getBezierLength(y.x,y.y,y.out_x??y.x,y.out_y??y.y,F.in_x??F.x,F.in_y??F.y,F.x,F.y):e=Math.sqrt((F.x-y.x)**2+(F.y-y.y)**2),t+e>=G||S===K[K.length-1]){const n=e===0?0:(G-t)/e;if(M)return this.getBezierPointAndAngle(n,y,F,s,h);{const X=y.x+(F.x-y.x)*n-s,Z=y.y+(F.y-y.y)*n-h,H=Math.atan2(F.y-y.y,F.x-y.x);return{x:X,y:Z,angle:H}}}t+=e}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(A,I,C,g,Q){const E=I.x,i=I.y,D=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,F=K*A,e=y*E+3*S*A*D+3*t*K*s+F*a-g,M=y*i+3*S*A*o+3*t*K*h+F*G-Q,n=3*S*(D-E)+6*t*A*(s-D)+3*K*(a-s),X=3*S*(o-i)+6*t*A*(h-o)+3*K*(G-h),Z=Math.atan2(X,n);return{x:e,y:M,angle:Z}}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:D=0}=I,o=C/2,s=g/2,h=E*Math.PI/180,a=i*Math.PI/180,G=h+a;i>=360&&D<=0?A.ellipse(0,0,o,s,0,0,Math.PI*2):(A.ellipse(0,0,o,s,0,h,G,!1),D>0?A.ellipse(0,0,o*D,s*D,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 D=0;D<E;D++){const o=D*2*Math.PI/E-Math.PI/2,s=i*Math.cos(o),h=i*Math.sin(o);D===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,D=I.points||5;for(let o=0;o<D*2;o++){const s=o*Math.PI/D-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,D=1/0,o=-1/0;I.points.forEach(a=>{E=Math.min(E,a.x),i=Math.max(i,a.x),D=Math.min(D,a.y),o=Math.max(o,a.y)});const s=(E+i)/2,h=(D+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,F=(a.in_y??a.y)-h;A.bezierCurveTo(K,S,y,F,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,D=1/0,o=-1/0;I.points.forEach(a=>{E=Math.min(E,a.x),i=Math.max(i,a.x),D=Math.min(D,a.y),o=Math.max(o,a.y)});const s=(E+i)/2,h=(D+o)/2;I.points.forEach((a,G)=>{if(G===0)A.moveTo(a.x-s,a.y-h);else{const t=I.points[G-1];t.out_x!==void 0||a.in_x!==void 0?A.bezierCurveTo((t.out_x??t.x)-s,(t.out_y??t.y)-h,(a.in_x??a.x)-s,(a.in_y??a.y)-h,a.x-s,a.y-h):A.lineTo(a.x-s,a.y-h)}}),I.is_closed&&A.closePath()}}renderInputBox(A,I){var SA,FA;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((SA=I.geometry)==null?void 0:SA.width)||250,E=((FA=I.geometry)==null?void 0:FA.height)||45,i=this.focusedId===I.id,D=this.lastHoveredObjectId===I.id,o=g.previewState||"default",s=o!=="default"?o:i?"focused":D?"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},F=[y.tl,y.tr,y.br,y.bl];let e=g.backgroundColor||"rgba(31, 41, 55, 1)",M=g.borderColor||"rgba(55, 65, 81, 1)",n=g.borderWidth??1.5,X=g.color||"#ffffff",Z=g.placeholderColor||"rgba(156, 163, 175, 1)",H=g.fontSize||14;const QA=`${s}Style`,L=g[QA];if(L?(L.backgroundColor!==void 0&&(e=L.backgroundColor),L.borderColor!==void 0&&(M=L.borderColor),L.borderWidth!==void 0&&(n=L.borderWidth),L.color!==void 0&&(X=L.color),L.placeholderColor!==void 0&&(Z=L.placeholderColor),L.fontSize!==void 0&&(H=L.fontSize)):s==="focused"?(M=g.focusBorderColor||"rgba(59, 130, 246, 1)",n=Math.max(n,2)):s==="hovered"||s==="hover"?(M=g.hoverBorderColor||M,e=g.hoverBackgroundColor||e):s==="disabled"?(e=g.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",M=g.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):s==="error"&&(M="rgba(239, 68, 68, 1)",n=Math.max(n,2)),A.beginPath(),this.drawRoundRect(A,-Q/2,-E/2,Q,E,F),A.fillStyle=e,A.fill(),n>0&&(A.strokeStyle=M,A.lineWidth=n,A.stroke(),s==="focused"||s==="focus")){A.save(),A.beginPath();const NA=F.map(m=>m+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 U=(NA,m)=>{if(!NA.visible||!NA.svgPath)return;const O=NA.size||14,Y=NA.offset??16,R=NA.color||"#ffffff",x=m?-(Q/2)+Y:Q/2-Y,j=NA.svgPath;if(A.save(),A.translate(x,0),!j.startsWith("<svg")){const GA=new Path2D(j),CA=O/24;A.scale(CA,CA),A.translate(-12,-12),A.fillStyle=R,A.fill(GA)}A.restore()};U(G,!0),U(t,!1);const T=g.text||"",AA=g.placeholder||"Enter text...",IA=!T,b=T||AA,P=IA?Z:X,gA=H,u=g.fontFamily||"Inter",q=g.fontWeight||400;A.font=`${q} ${gA}px "${u}", sans-serif`,A.fillStyle=P,A.textAlign="left",A.textBaseline=K?"top":"middle";const l=g.inputPadding??16,r=G.visible?(G.offset??16)+(G.size||14)/2+8:l,z=t.visible?(t.offset??16)+(t.size||14)/2+8:l,d=-(Q/2)+r,_=Q-r-z,hA=g.inputType==="password"?"•".repeat(b.length):b;if(A.save(),A.beginPath(),A.rect(d-2,-E/2+4,_+4,E-8),A.clip(),K){const NA=hA.split(`
22
- `);let m=-E/2+l;const O=gA*1.2;let Y=0;NA.forEach((R,x)=>{const j=R.split(" ");let GA="";for(let CA=0;CA<j.length;CA++){const wA=GA+j[CA]+" ";A.measureText(wA).width>_&&CA>0?(A.fillText(GA,d,m),GA=j[CA]+" ",m+=O):GA=wA}A.fillText(GA,d,m),Y=A.measureText(GA).width,x<NA.length-1&&(m+=O,Y=0)}),i&&!IA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(d+Y,m,1.5,gA)}else{const m=A.measureText(hA).width;let O=0;if(m>_&&(O=m-_),A.fillText(hA,d-O,0),i&&!IA&&Math.floor(performance.now()/500)%2===0){const R=d+m-O;A.fillRect(R,-(gA/2),1.5,gA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",m=h.fontSize||12,O=h.color||"rgba(156, 163, 175, 1)",Y=h.offset??8;A.font=`600 ${m}px "${u}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="bottom";const R=-(Q/2),x=-(E/2)-Y;A.fillText(NA,R,x)}if(a.visible===!0){const NA=a.text||"Helper text",m=a.fontSize||11,O=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",Y=a.offset??6;A.font=`400 ${m}px "${u}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="top";const R=-(Q/2),x=E/2+Y;A.fillText(NA,R,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,D=Q.min??0,s=(Q.max??100)-D,h=s===0?0:(i-D)/s,a=Q.trackHeight||4,G=Q.trackRoundedness??2,t=Q.trackShape??"Rectangle",K=Q.trackPath||"",S=Q.activeColor||"#3b82f6",y=Q.inactiveColor||"#374151",F=Q.thumbShape||"Ellipse",e=Q.thumbWidth??16,M=Q.thumbHeight??16,n=Q.thumbRoundedness??0,X=Q.thumbColor||"#ffffff",Z=Q.thumbPath||"",H=Q.thumbIcon||"",QA=Q.showValueTooltip??!1,L=Q.tooltipBgColor||"#333333",U=Q.tooltipColor||"#ffffff",T=Q.tooltipOffsetX??0,AA=Q.tooltipOffsetY??-25,IA=(d,_,hA,SA,FA,NA,m)=>{if((d==="Custom"||d==="Icon")&&m)try{const O=new Path2D(m);if(A.save(),A.translate(_,hA),d==="Icon"){const Y=Math.min(SA,FA)/24;A.scale(Y,Y),A.translate(-12,-12)}A.fill(O),A.restore();return}catch(O){console.error("Error drawing slider shape in engine:",O)}if(A.beginPath(),d==="Ellipse")A.ellipse(_,hA,SA/2,FA/2,0,0,Math.PI*2);else if(d==="Rectangle")this.drawRoundRect(A,_-SA/2,hA-FA/2,SA,FA,NA);else if(d==="Triangle")A.moveTo(_,hA-FA/2),A.lineTo(_+SA/2,hA+FA/2),A.lineTo(_-SA/2,hA+FA/2),A.closePath();else if(d==="Diamond")A.moveTo(_,hA-FA/2),A.lineTo(_+SA/2,hA),A.lineTo(_,hA+FA/2),A.lineTo(_-SA/2,hA),A.closePath();else if(d==="Polygon"){const O=I.geometry.sides||3,Y=I.geometry.radius||Math.min(SA,FA)/2;for(let R=0;R<O;R++){const x=R*2*Math.PI/O-Math.PI/2,j=_+Y*Math.cos(x),GA=hA+Y*Math.sin(x);R===0?A.moveTo(j,GA):A.lineTo(j,GA)}A.closePath()}else if(d==="Star"){const Y=Math.min(SA,FA)/2,R=Y/2;for(let x=0;x<5*2;x++){const j=x%2===0?Y:R,GA=x*Math.PI/5-Math.PI/2;A.lineTo(_+j*Math.cos(GA),hA+j*Math.sin(GA))}A.closePath()}else d==="Line"&&(A.moveTo(_-SA/2,hA),A.lineTo(_+SA/2,hA));A.fill()};A.fillStyle=y,t==="Line"?(A.strokeStyle=y,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):IA(t,0,0,E,a,G,K);const b=E-e,P=-E/2+e/2+h*b,gA=P- -E/2;gA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(P,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,gA,a,G),A.fill())),A.save(),A.translate(P,0);const u=A.getTransform(),q=Math.sqrt(u.a*u.a+u.b*u.b)||1;if(A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4*q,A.shadowOffsetY=1*q,A.fillStyle=X,IA(F,0,0,e,M,n,F==="Icon"?H:Z),A.restore(),QA){A.save(),A.translate(P+T,AA);const d=Math.round(i).toString();A.font="10px Inter, sans-serif";const _=A.measureText(d),hA=6,SA=4,FA=_.width+hA*2,NA=14+SA;A.beginPath(),this.drawRoundRect(A,-FA/2,-NA/2,FA,NA,4),A.fillStyle=L,A.fill(),A.fillStyle=U,A.textAlign="center",A.textBaseline="middle",A.fillText(d,0,0),A.restore()}const l=Q.label||{},r=Q.helperText||{},z=Q.fontFamily||"Inter";if(l.visible!==!1){const d=l.text||"Label",_=l.fontSize||12,hA=l.color||"rgba(156, 163, 175, 1)",SA=l.offset??8;A.font=`600 ${_}px "${z}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="bottom";const FA=-(E/2),NA=-(a/2)-SA;A.fillText(d,FA,NA)}if(r.visible===!0){const d=r.text||"Helper text",_=r.fontSize||11,hA=r.color||"rgba(156, 163, 175, 1)",SA=r.offset??6;A.font=`400 ${_}px "${z}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="top";const FA=-(E/2),NA=a/2+SA;A.fillText(d,FA,NA)}}renderDropdown(A,I){var AA;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,D=-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,D,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 F=12,e=g.chevronType||"chevron",M=g.chevronSize||16,n=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(e!=="none"){const IA=i+Q-F-M/2;A.save(),A.translate(IA,0);const b=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(b*Math.PI/180),A.strokeStyle=n,A.fillStyle=n,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",e==="chevron")A.beginPath(),A.moveTo(-M/2,-M*.2),A.lineTo(0,M*.2),A.lineTo(M/2,-M*.2),A.stroke();else if(e==="custom"||e==="path"){const P=a&&g.openIconPath||g.closedIconPath;if(P){const gA=new Path2D(P);A.save();const u=M/24;A.scale(u,u),A.translate(-12,-12),A.fill(gA),A.restore()}}A.restore()}const X=g.selectedOption||g.placeholder||"Select...",Z=g.fontSize||14,H=g.fontWeight||400,QA=g.fontFamily||"Inter, sans-serif";A.font=`${H} ${Z}px ${QA}`;const L=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":K;A.fillStyle=this.createCanvasFill(A,typeof L=="string"?{type:"Solid",color:L}:L,Q,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const U=e==="none"?0:M+8,T=Q-F*2-U;if(A.save(),A.beginPath(),A.rect(i+F,D,T,E),A.clip(),A.fillText(X,i+F,0),A.restore(),a&&!s){const IA=D+E+4,b=g.optionsList||[],P=g.itemHeight||32,gA=g.listPadding??4,u=b.length*P+gA*2,q=g.listCornerRadius??o;A.save();const l=g.listShadow||{},r=A.getTransform(),z=Math.sqrt(r.a*r.a+r.b*r.b)||1;A.shadowColor=typeof l.color=="string"?l.color:((AA=l.color)==null?void 0:AA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=(l.blur??12)*z,A.shadowOffsetY=(l.offsetY??6)*z,A.shadowOffsetX=(l.offsetX??0)*z,A.beginPath(),this.drawRoundRect(A,i,IA,Q,u,q),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,u)||"#ffffff",A.fill();const d=g.listBorderWidth??1;d>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,u)||"#e5e7eb",A.lineWidth=d,A.stroke()),A.restore();const _=g.itemFontSize||Z,hA=g.itemFontFamily||QA;A.font=`${H} ${_}px ${hA}`,b.forEach((SA,FA)=>{const NA=IA+gA+FA*P;if(SA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,P)||"#f3f4f6",A.fillRect(i+d,NA,Q-d*2,P),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const O=this._lastPointerPos.y-(IA+gA),Y=Math.floor(O/P);FA===Y&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,P)||"#f9fafb",A.fillRect(i+d,NA,Q-d*2,P),A.fillStyle=g.itemHoverColor||K)}A.fillText(SA,i+F,NA+P/2)})}A.globalAlpha=S}renderButton(A,I){var e,M,n,X;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((e=I.geometry)==null?void 0:e.width)||120,E=((M=I.geometry)==null?void 0:M.height)||40,i=-Q/2,D=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((n=g.hoverStyle)==null?void 0:n.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},t=o?((X=g.hoverStyle)==null?void 0:X.textColor)||G.color||"#ffffff":G.color||"#ffffff",K=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,D,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,D,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 F=0;if(K.enabled&&K.svgPath){const Z=K.size||16,H=K.gap||8,QA=K.position==="left"?-(A.measureText(G.text||"").width/2+Z/2+H/2):A.measureText(G.text||"").width/2+Z/2+H/2;A.save(),A.translate(QA,0);const L=new Path2D(K.svgPath),U=Z/24;A.scale(U,U),A.translate(-12,-12),A.fillStyle=K.color||t,A.fill(L),A.restore(),F=K.position==="left"?Z/2+H/2:-(Z/2+H/2)}A.fillText(G.text||"Button",F,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,D=-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,D,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 F,e;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((F=I.geometry)==null?void 0:F.width)||52,E=((e=I.geometry)==null?void 0:e.height)||30,i=-Q/2,D=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,D,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=D+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 M=g.label,n=M.fontSize||14,X=M.fontWeight||400,Z=M.fontFamily||"Inter";A.font=`${X} ${n}px "${Z}", sans-serif`,A.fillStyle=M.color||"#f3f4f6",A.textBaseline="middle";const H=M.gap||10;let QA=0,L=0;M.position==="left"?(A.textAlign="right",QA=i-H,L=0):M.position==="right"?(A.textAlign="left",QA=i+Q+H,L=0):M.position==="top"?(A.textAlign="center",QA=0,L=D-H,A.textBaseline="bottom"):M.position==="bottom"?(A.textAlign="center",QA=0,L=D+E+H,A.textBaseline="top"):(A.textAlign="left",QA=i+Q+H,L=0),A.fillText(M.text,QA,L)}}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,D=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 F=this.inputNameMap.get(K.inputId);F&&F.length>0&&(y=this.inputs.get(F[0]))}y&&Array.isArray(y)&&(S=y)}if(S&&S.length>0){const y=S.filter(F=>typeof F=="number"&&!isNaN(F));y.length>0&&(E=Math.min(E,...y),i=Math.max(i,...y),D=Math.max(D,S.length))}K._resolvedData=S}),D<2)return;const o=i-E,s=C/(D-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<D;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 F=0;F<S.length-1;F++){const e=S[F===0?F:F-1],M=S[F],n=S[F+1],X=S[F+1===S.length-1?F+1:F+2];for(let Z=1;Z<=t;Z++){const H=Z/t,QA=this._catmullRom(e,M,n,X,H);A.lineTo(a(F+H),h(QA))}}else for(let F=1;F<S.length;F++)A.lineTo(a(F),h(S[F]));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 F=S[y===0?y:y-1],e=S[y],M=S[y+1],n=S[y+1===S.length-1?y+1:y+2];for(let X=1;X<=t;X++){const Z=X/t,H=this._catmullRom(F,e,M,n,Z);A.lineTo(a(y+Z),h(H))}}else for(let y=1;y<S.length;y++)A.lineTo(a(y),h(S[y]));A.stroke(),K.showPoints&&S.forEach((y,F)=>{const e=a(F),M=h(y);A.beginPath(),A.arc(e,M,(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,F=y+5;A.font=`${y}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",Q.forEach(e=>{const n=e.label||"Series",X=A.measureText(n).width;A.beginPath(),A.rect(K-X-8-5,S-(8/2+2),8,8),A.fillStyle=e.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(n,K,S),S+=F})}}_catmullRom(A,I,C,g,Q){const E=(C-A)*.5,i=(g-I)*.5,D=Q*Q,o=Q*D;return(2*I-2*C+E+i)*o+(-3*I+3*C-2*E-i)*D+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 D=I.color,s=(((E=(Q=this.artboard)==null?void 0:Q.tokens)==null?void 0:E.colors)||{})[D]||D;return A.fillStyle=s,s}if((I.type==="LinearGradient"||I.type==="RadialGradient"||I.type==="AngularGradient"||I.type==="DiamondGradient")&&I.stops){const D=(o,s=100)=>{var M,n;const a=(((n=(M=this.artboard)==null?void 0:M.tokens)==null?void 0:n.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),F=parseInt(S.substring(2,4),16),e=parseInt(S.substring(4,6),16);return`rgba(${y}, ${F}, ${e}, ${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=D(K.color||"#000000",K.opacity??100);t.addColorStop(Math.max(0,Math.min(1,S)),y)}),I.gradientTransform&&t.setTransform){const[K,S,y,F,e,M]=I.gradientTransform;t.setTransform({a:K,b:S,c:y,d:F,e,f:M})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}return A.scale(1/Math.SQRT2,1/Math.SQRT2),A.fillStyle=G,A.restore(),G}}if(I.type==="Pattern"&&I.url){let D=this.imageCache.get(I.url);if(D||(D=new Image,D.src=I.url,this.imageCache.set(I.url,D)),D.complete&&D.naturalWidth>0){const o=A.createPattern(D,"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 D=0,o=0,s=0,h=0;typeof i=="number"?D=o=s=h=i:Array.isArray(i)?i.length===1?D=o=s=h=i[0]:i.length===2?(D=s=i[0],o=h=i[1]):i.length===3?(D=i[0],o=h=i[1],s=i[2]):i.length>=4&&(D=i[0],o=i[1],s=i[2],h=i[3]):i&&typeof i=="object"&&(D=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(D=Math.min(Math.max(0,D),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,[D,o,s,h]);return}A.moveTo(I+D,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+D),A.arcTo(I,C,I+D,C,D),A.closePath()}renderListView(A,I){var IA,b,P,gA;const C=this.objectStates.get(I.id)||{},g=C.options||I.options||{},Q=C.width!==void 0?C.width:((IA=I.geometry)==null?void 0:IA.width)||200,E=C.height!==void 0?C.height:((b=I.geometry)==null?void 0:b.height)||300,i=-Q/2,D=-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,F=g.accentColor||"#3b82f6",e=g.itemTextColor||"#333333",M=g.itemBackgroundColor||"#ffffff",n=g.hoveredIndex??null,X=g.activeItemIndex??null,Z=g.glowIntensity??0,H=g.glowColor||"#3b82f6",QA=typeof H=="string"?H:H.color||((gA=(P=H.stops)==null?void 0:P[0])==null?void 0:gA.color)||"#3b82f6",L=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=L,Z>0){const u=A.getTransform(),q=Math.sqrt(u.a*u.a+u.b*u.b)||1;A.shadowColor=QA,A.shadowBlur=Z*2*q,A.shadowOffsetX=0,A.shadowOffsetY=0}if(y){const u=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",q=this.createCanvasFill(A,u,Q,E);A.fillStyle=q||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,D,Q,E,o),A.fill();const l=A.createLinearGradient(i,D,i+Q,D+E);l.addColorStop(0,"rgba(255, 255, 255, 0.15)"),l.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),l.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=l,this.drawListViewRect(A,i,D,Q,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,D,Q,E,o),A.stroke()}else{const u=g.listBackgroundColor||"transparent",q=this.createCanvasFill(A,u,Q,E);q&&(A.fillStyle=q,this.drawListViewRect(A,i,D,Q,E,o),A.fill());const l=g.borderWidth??0;l>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=l,this.drawListViewRect(A,i,D,Q,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,D,Q,E,o),A.clip();const U=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let T=(s==="vertical"?D:i)+K+U;if(A.textBaseline="middle",h.forEach((u,q)=>{const l=s==="vertical"?Q:t,r=s==="vertical"?G:E,z=s==="vertical"?i:T,d=s==="vertical"?T:D,_=n===q,hA=X===q;if(hA){const O=this.createCanvasFill(A,F,l,r);A.fillStyle=O||F;const Y=A.globalAlpha;A.globalAlpha=Y*.8,A.fillRect(z,d,l,r),A.globalAlpha=Y}else if(_)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(z,d,l,r);else if(M!=="transparent"){const O=this.createCanvasFill(A,M,l,r);A.fillStyle=O||M,A.fillRect(z,d,l,r)}if(hA||_){const O=this.createCanvasFill(A,F,s==="vertical"?3:l,s==="vertical"?r:3);A.fillStyle=O||F,s==="vertical"?A.fillRect(z,d,3,r):A.fillRect(z,d+r-3,l,3)}const SA=hA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":e;A.fillStyle=SA,A.font=hA||_?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const FA=typeof u=="string"?u:(u==null?void 0:u.label)||`Item ${q+1}`,NA=z+(s==="vertical"?16:l/2),m=d+r/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(FA,NA,m),T+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const u=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,q=s==="vertical"?E:Q;if(u>q){const l=q/u,r=q*l,z=-K/u*q,d=g.scrollbarColor||"rgba(255,255,255,0.3)",_=g.scrollbarWidth||4;A.fillStyle=d,s==="vertical"?A.fillRect(i+Q-_-2,D+z,_,r):A.fillRect(i+z,D+E-_-2,r,_)}}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||[],D=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)*D,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 U,T;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:((U=A.geometry)==null?void 0:U.width)||200,D=Q.height!==void 0?Q.height:((T=A.geometry)==null?void 0:T.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,F=-K.rotation*(Math.PI/180),e=Math.cos(F),M=Math.sin(F),n=S*e-y*M,X=S*M+y*e,Z=-i/2,H=-D/2,QA=typeof t=="number"?t:o==="vertical"?t[0]:t[3];let L=(o==="vertical"?H:Z)+G+QA;for(let AA=0;AA<E.length;AA++){const IA=o==="vertical"?i:a,b=o==="vertical"?h:D,P=o==="vertical"?Z:L,gA=o==="vertical"?L:H;if(n>=P&&n<=P+IA&&X>=gA&&X<=gA+b)return AA;L+=(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,F,e,M,n,X,Z,H,QA,L,U,T,AA,IA,b,P,gA,u,q,l,r,z,d,_,hA,SA,FA,NA,m,O,Y,R,x,j,GA,CA,wA,kA,BA;if(!E.enabled)return;const i=E.startTime||0,D=E.endTime||1/0;if(this.currentTime<i||this.currentTime>D)return;const o=Q.x-I,s=Q.y-C,h=Math.sqrt(o*o+s*s);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${E.type} on ${g.name}`),E.type===W.Proximity){const N=((a=E.settings)==null?void 0:a.radius)||300,f=((G=E.settings)==null?void 0:G.falloff)||"smooth";let p=0;h<N&&(f==="linear"?p=1-h/N:p=Math.pow(1-h/N,2)),p>0&&E.sensors.forEach(oA=>{this.applyBehaviorSensor(Q,oA,p,A,E.settings)})}else if(E.type===W.Magnetic){const N=((t=E.settings)==null?void 0:t.radius)||400,f=((K=E.settings)==null?void 0:K.strength)||.5;if(h<N&&h>5){const p=1-h/N,oA=o*p*f,UA=s*p*f;Q.x-=oA*A*10,Q.y-=UA*A*10}}else if(E.type===W.Repel){const N=((S=E.settings)==null?void 0:S.radius)||300,f=((y=E.settings)==null?void 0:y.strength)||1;if(h<N){const p=Math.pow(1-h/N,2);Q.x+=o/(h||1)*p*60*f*A*5,Q.y+=s/(h||1)*p*60*f*A*5}}else if(E.type===W.Orbit){const N=((F=E.settings)==null?void 0:F.speed)||1,f=((e=E.settings)==null?void 0:e.radius)||30,p=this.currentTime*N*Math.PI*2;Q.x+=Math.cos(p)*f*A*5,Q.y+=Math.sin(p)*f*A*5,Q.rotation+=2*A*5}else if(E.type===W.Vortex){const N=((M=E.settings)==null?void 0:M.radius)||400,f=((n=E.settings)==null?void 0:n.speed)||2,p=((X=E.settings)==null?void 0:X.strength)||1;if(h<N){const oA=Math.pow(1-h/N,1.5),UA=this.currentTime*f*Math.PI*2,iA=Math.cos(UA)*30-o*.4,V=Math.sin(UA)*30-s*.4;Q.x+=iA*oA*p*A*5,Q.y+=V*oA*p*A*5,Q.rotation+=5*oA*p*A*5,Q.scale_x*=1-oA*.1*p*A,Q.scale_y*=1-oA*.1*p*A}}else if(E.type===W.Fluid){const N=((Z=E.settings)==null?void 0:Z.radius)||300,f=((H=E.settings)==null?void 0:H.strength)||1;if(h<N){const p=Math.pow(1-h/N,1.2),oA=o/(h||1)*p*1.2*f,UA=s/(h||1)*p*1.2*f;Q.x+=oA*10*A*5,Q.y+=UA*10*A*5,Q.scale_x*=1+p*.3*f*A,Q.scale_y*=1+p*.3*f*A}}else if(E.type===W.Elastic){const N=((QA=E.settings)==null?void 0:QA.radius)||300,f=((L=E.settings)==null?void 0:L.strength)||1;if(h<N){const p=1-h/N;Q.scale_x*=1+p*.4*f*A,Q.scale_y*=1+p*.4*f*A}}else if(E.type===W.Holographic){const N=Q.x-this.canvasWidth/2,f=Q.y-this.canvasHeight/2,p=((U=E.settings)==null?void 0:U.factor)||25;if(Q.x-=N/1e3*p*A*5,Q.y-=f/1e3*p*A*5,Q.style){const oA=1-Math.min(1,h/400);Q.style.exposure=(Q.style.exposure||1)+oA*.5*A}}else if(E.type===W.Sticky){const N=((T=E.settings)==null?void 0:T.radius)||80,f=((AA=E.settings)==null?void 0:AA.strength)||1;if(h<N){const p=Math.pow(1-h/N,2);Q.x-=o*p*f*A*10,Q.y-=s*p*f*A*10,Q.scale_x*=1-p*.1*f*A,Q.scale_y*=1-p*.1*f*A}}else if(E.type===W.Dilation){const N=((IA=E.settings)==null?void 0:IA.size)||120,f=((b=E.settings)==null?void 0:b.strength)||1;if(h<N){const p=1-h/N;Q.scale_x*=1+p*.5*f*A,Q.scale_y*=1+p*.5*f*A}}else if(E.type===W.Parallax){const N=((P=E.settings)==null?void 0:P.factor)||.05,f=this.canvasHeight/2,p=(this._lastPointerPos.y-f)*N;Q.y+=p*A*10}else if(E.type===W.Noise||E.type===W.Float){const N=(((gA=E.settings)==null?void 0:gA.frequency)||((u=E.settings)==null?void 0:u.speed)||1)*.002,f=(((q=E.settings)==null?void 0:q.amplitude)||((l=E.settings)==null?void 0:l.range)||50)*(((r=E.settings)==null?void 0:r.strength)||1),p=Date.now();Q.x+=Math.sin(p*N)*f*A,Q.y+=Math.cos(p*N*.8)*f*A,Q.rotation+=Math.sin(p*N*.5)*5*A}else if(E.type===W.Pulse){const N=(((z=E.settings)==null?void 0:z.speed)||1)*.005,f=(((d=E.settings)==null?void 0:d.scale)||1.2)-1,p=Math.sin(Date.now()*N),oA=((_=E.settings)==null?void 0:_.strength)||1;Q.scale_x*=1+p*f*oA*A,Q.scale_y*=1+p*f*oA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,p)*.1*oA*A)}else if(E.type===W.Draggable){const N=((hA=E.settings)==null?void 0:hA.radius)||150,f=this.draggingBehaviors.has(g.id);if(h<N||f){const p=((SA=E.settings)==null?void 0:SA.strength)||1,oA=f?1:Math.max(0,1-h/N);this.applyBehaviorSensor(Q,mA.PositionX,oA*p,A,E.settings),this.applyBehaviorSensor(Q,mA.PositionY,oA*p,A,E.settings)}}else if(E.type===W.Scroll){const N=((FA=E.settings)==null?void 0:FA.axis)||"vertical",f=((NA=E.settings)==null?void 0:NA.factor)||.5,p=((m=E.settings)==null?void 0:m.strength)||1;(N==="vertical"||N==="both")&&(Q.y+=this.scrollOffset.y*f*p*A),(N==="horizontal"||N==="both")&&(Q.x+=this.scrollOffset.x*f*p*A)}else if(E.type===W.LookAt){const N=((O=E.settings)==null?void 0:O.factor)||1,f=((Y=E.settings)==null?void 0:Y.strength)||1,p=Math.atan2(-s,-o)*(180/Math.PI),oA=Q.rotation,UA=(p-oA+180)%360-180;Q.rotation+=UA*N*f*A*10}else if(E.type===W.Glint||E.type===W.Scan){const N=(((R=E.settings)==null?void 0:R.speed)||1)*.004,f=((x=E.settings)==null?void 0:x.strength)||1,p=(Math.sin(Date.now()*N)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+p*f*A*5),Q.x+=(p-.5)*20*f*A}else if(E.type===W.Ratchet){const N=((j=E.settings)==null?void 0:j.steps)||12,f=(((GA=E.settings)==null?void 0:GA.speed)||1)*30,p=Math.floor(Q.rotation/(360/N))*(360/N);Q.rotation=this.lerp(Q.rotation,p+f*A,.1)}else if(E.type===W.Jitter&&h<300){const N=((CA=E.settings)==null?void 0:CA.strength)||1,f=(((wA=E.settings)==null?void 0:wA.intensity)||5)*N;Q.x+=(Math.random()-.5)*f*A*60,Q.y+=(Math.random()-.5)*f*A*60,Q.rotation+=(Math.random()-.5)*f*A*120}else if(E.type===W.Follower){const N=(kA=E.settings)==null?void 0:kA.targetId;if(N){const f=this.objectStates.get(N);if(f){const p=((BA=E.settings)==null?void 0:BA.stiffness)||.1,oA=f.x-Q.x,UA=f.y-Q.y;Q.x+=oA*p*A*60,Q.y+=UA*p*A*60}}}else E.type===W.Wrap&&(Q.x<0?Q.x=this.canvasWidth:Q.x>this.canvasWidth&&(Q.x=0),Q.y<0?Q.y=this.canvasHeight:Q.y>this.canvasHeight&&(Q.y=0))})})}applyBehaviorSensor(A,I,C,g,Q){const E=(Q==null?void 0:Q.intensity)||(Q==null?void 0:Q.strength)||1,i=C*E*g;switch(I){case mA.Scale:A.scale_x*=1+i*.5,A.scale_y*=1+i*.5;break;case mA.Opacity:A.opacity=Math.max(0,Math.min(100,A.opacity-i*100));break;case mA.RotateZ:A.rotation+=i*180;break;case mA.RotateX:A.rotate_x=(A.rotate_x||0)+i*180;break;case mA.RotateY:A.rotate_y=(A.rotate_y||0)+i*180;break;case mA.PositionX:A.x+=i*300;break;case mA.PositionY:A.y+=i*300;break;case mA.SkewX:A.skew_x=(A.skew_x||0)+i*45;break;case mA.Blur:A.style||(A.style={}),A.style.blur=Math.min(100,(A.style.blur||0)+i*50);break;case mA.Exposure:A.style||(A.style={}),A.style.exposure=(A.style.exposure||1)+i*2;break;case mA.HueShift:A.style||(A.style={}),A.style.hue=(A.style.hue||0)+i*360;break;case mA.CornerRadius:A.corner_radius=Math.min(200,(A.corner_radius||0)+i*100);break;case mA.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 OQ=({artboard:B,config:A})=>{const I={...B.seo,...A},C=I.enableSmartExtraction!==!1;eA.useEffect(()=>{const i=I.title||B.name;i&&(document.title=i);let D=I.description;if(!D&&C){const h=B.objects.filter(a=>a.geometry.type==="Text").sort((a,G)=>{var t,K;return(((t=G.geometry.text)==null?void 0:t.length)||0)-(((K=a.geometry.text)==null?void 0:K.length)||0)});h.length>0&&(D=h[0].geometry.text)}D&&(g("name","description",D),g("property","og:description",D)),I.keywords&&I.keywords.length>0&&g("name","keywords",I.keywords.join(", "));const o=I.ogImage||B.backgroundImage;o&&g("property","og:image",o),i&&g("property","og:title",i),g("property","og:type","website")},[I,B,C]);const g=(i,D,o)=>{let s=document.querySelector(`meta[${i}="${D}"]`);s||(s=document.createElement("meta"),s.setAttribute(i,D),document.head.appendChild(s)),s.setAttribute("content",o)},Q=()=>{const i=[];return i.push(HA.jsx("h1",{children:I.title||B.name},"artboard-title")),B.objects.forEach((o,s)=>{if(!(!o.visible&&o.isVisible!==!0))if(o.geometry.type==="Text"){const h=o.geometry.text;h&&(o.geometry.fontSize>24?i.push(HA.jsx("h2",{children:h},o.id||s)):i.push(HA.jsx("p",{children:h},o.id||s)))}else if(o.geometry.type==="Image"){const h=o.geometry.src,a=o.altText||o.name||"Illustration";i.push(HA.jsx("img",{src:h,alt:a},o.id||s))}else o.type==="Button"&&i.push(HA.jsx("button",{children:o.name||"Button"},o.id||s))}),i},E=I.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:I.title||B.name,description:I.description,image:I.ogImage||B.backgroundImage,abstract:"Animated interface created with ExodeUI"};return HA.jsxs("div",{id:`exode-seo-${B.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[Q(),HA.jsx("script",{type:"application/ld+json",children:JSON.stringify(E)})]})},Ai=eA.forwardRef(({artboard:B,src:A,className:I,style:C,autoPlay:g=!0,fit:Q="Contain",alignment:E="Center",enableSEO:i=!0,seo:D,onReady:o,onTrigger:s,onInputUpdate:h,onComponentChange:a,onToggle:G,onInputChange:t,onInputFocus:K,onInputBlur:S,onLog:y},F)=>{const e=eA.useRef(null),M=eA.useRef(new xQ),n=eA.useRef(),X=eA.useRef(0),Z=eA.useRef(null),[H,QA]=eA.useState(B||null);eA.useImperativeHandle(F,()=>e.current),eA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),M.current.setLayout(Q,E)},[Q,E]),eA.useEffect(()=>{s&&M.current.setTriggerCallback(s)},[s]),eA.useEffect(()=>{h&&M.current.setInputUpdateCallback(h)},[h]),eA.useEffect(()=>{a&&M.current.setComponentChangeCallback(a)},[a]),eA.useEffect(()=>{G&&M.current.setToggleCallback(G)},[G]),eA.useEffect(()=>{t&&M.current.setInputChangeCallback(t)},[t]),eA.useEffect(()=>{K&&M.current.setInputFocusCallback(K)},[K]),eA.useEffect(()=>{S&&M.current.setInputBlurCallback(S)},[S]),eA.useEffect(()=>{(async()=>{const T=M.current;let AA=B;if(!AA&&A)try{AA=await(await fetch(A)).json()}catch(IA){console.error("Failed to load ExodeUI animation:",IA);return}if(AA){const IA=AA.id||AA.name||"default";Z.current!==IA&&(T.load(AA),Z.current=IA,QA(AA),X.current=0),o&&o(T)}})()},[B,A]),eA.useEffect(()=>{const U=M.current,T=e.current;if(!T)return;const AA=T.getContext("2d");if(!AA)return;AA.imageSmoothingEnabled=!0,AA.imageSmoothingQuality="high",y&&U.setOnLogCallback(y);const IA=P=>{X.current||(X.current=P);const gA=(P-X.current)/1e3;X.current=P,g&&U.advance(gA);const u=window.devicePixelRatio||1,q=T.getBoundingClientRect(),l=Math.floor(q.width*u),r=Math.floor(q.height*u);(T.width!==l||T.height!==r)&&(T.width=l,T.height=r),U.render(AA,l,r),n.current=requestAnimationFrame(IA)};n.current=requestAnimationFrame(IA);const b=()=>{U.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",b,{passive:!0}),()=>{n.current&&cancelAnimationFrame(n.current),window.removeEventListener("scroll",b)}},[g]);const L=(U,T)=>{const AA=U.currentTarget.getBoundingClientRect(),IA=U.clientX-AA.left,b=U.clientY-AA.top,P=AA.width,gA=AA.height;M.current.handlePointerInput(T,IA,b,P,gA)};return HA.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...C},className:I,children:[HA.jsx("canvas",{ref:e,style:{width:"100%",height:"100%",outline:"none"},tabIndex:0,onPointerDown:U=>{var T;L(U,"down"),(T=e.current)==null||T.focus()},onPointerUp:U=>L(U,"up"),onPointerMove:U=>L(U,"move"),onPointerLeave:U=>L(U,"blur"),onClick:U=>L(U,"click"),onKeyDown:U=>{U.key==="Backspace"||U.key==="Enter"||U.key,M.current.handleKeyDown(U.nativeEvent)}}),i&&H&&HA.jsx(OQ,{artboard:H,config:D})]})});function Ii(){const[B,A]=eA.useState(null),I=eA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=eA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=eA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=eA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=eA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=eA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),D=eA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=eA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=eA.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:D}}const gi="6.0.24";pA.BehaviorSensor=mA,pA.BehaviorType=W,pA.ConditionOp=tC,pA.ExodeSEO=OQ,pA.ExodeUICanvas=Ai,pA.ExodeUIEngine=xQ,pA.LogicOp=NI,pA.VERSION=gi,pA.useExodeUI=Ii,Object.defineProperty(pA,Symbol.toStringTag,{value:"Module"})});
22
+ `);let m=-E/2+l;const O=gA*1.2;let Y=0;NA.forEach((R,x)=>{const j=R.split(" ");let GA="";for(let CA=0;CA<j.length;CA++){const wA=GA+j[CA]+" ";A.measureText(wA).width>_&&CA>0?(A.fillText(GA,d,m),GA=j[CA]+" ",m+=O):GA=wA}A.fillText(GA,d,m),Y=A.measureText(GA).width,x<NA.length-1&&(m+=O,Y=0)}),i&&!IA&&Math.floor(performance.now()/500)%2===0&&A.fillRect(d+Y,m,1.5,gA)}else{const m=A.measureText(hA).width;let O=0;if(m>_&&(O=m-_),A.fillText(hA,d-O,0),i&&!IA&&Math.floor(performance.now()/500)%2===0){const R=d+m-O;A.fillRect(R,-(gA/2),1.5,gA)}}if(A.restore(),h.visible!==!1){const NA=h.text||"Label",m=h.fontSize||12,O=h.color||"rgba(156, 163, 175, 1)",Y=h.offset??8;A.font=`600 ${m}px "${u}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="bottom";const R=-(Q/2),x=-(E/2)-Y;A.fillText(NA,R,x)}if(a.visible===!0){const NA=a.text||"Helper text",m=a.fontSize||11,O=s==="error"?"rgba(239, 68, 68, 1)":a.color||"rgba(156, 163, 175, 1)",Y=a.offset??6;A.font=`400 ${m}px "${u}", sans-serif`,A.fillStyle=O,A.textAlign="left",A.textBaseline="top";const R=-(Q/2),x=E/2+Y;A.fillText(NA,R,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,D=Q.min??0,s=(Q.max??100)-D,h=s===0?0:(i-D)/s,a=Q.trackHeight||4,G=Q.trackRoundedness??2,t=Q.trackShape??"Rectangle",K=Q.trackPath||"",S=Q.activeColor||"#3b82f6",y=Q.inactiveColor||"#374151",F=Q.thumbShape||"Ellipse",e=Q.thumbWidth??16,M=Q.thumbHeight??16,n=Q.thumbRoundedness??0,X=Q.thumbColor||"#ffffff",Z=Q.thumbPath||"",H=Q.thumbIcon||"",QA=Q.showValueTooltip??!1,L=Q.tooltipBgColor||"#333333",U=Q.tooltipColor||"#ffffff",T=Q.tooltipOffsetX??0,AA=Q.tooltipOffsetY??-25,IA=(d,_,hA,SA,FA,NA,m)=>{if((d==="Custom"||d==="Icon")&&m)try{const O=new Path2D(m);if(A.save(),A.translate(_,hA),d==="Icon"){const Y=Math.min(SA,FA)/24;A.scale(Y,Y),A.translate(-12,-12)}A.fill(O),A.restore();return}catch(O){console.error("Error drawing slider shape in engine:",O)}if(A.beginPath(),d==="Ellipse")A.ellipse(_,hA,SA/2,FA/2,0,0,Math.PI*2);else if(d==="Rectangle")this.drawRoundRect(A,_-SA/2,hA-FA/2,SA,FA,NA);else if(d==="Triangle")A.moveTo(_,hA-FA/2),A.lineTo(_+SA/2,hA+FA/2),A.lineTo(_-SA/2,hA+FA/2),A.closePath();else if(d==="Diamond")A.moveTo(_,hA-FA/2),A.lineTo(_+SA/2,hA),A.lineTo(_,hA+FA/2),A.lineTo(_-SA/2,hA),A.closePath();else if(d==="Polygon"){const O=I.geometry.sides||3,Y=I.geometry.radius||Math.min(SA,FA)/2;for(let R=0;R<O;R++){const x=R*2*Math.PI/O-Math.PI/2,j=_+Y*Math.cos(x),GA=hA+Y*Math.sin(x);R===0?A.moveTo(j,GA):A.lineTo(j,GA)}A.closePath()}else if(d==="Star"){const Y=Math.min(SA,FA)/2,R=Y/2;for(let x=0;x<5*2;x++){const j=x%2===0?Y:R,GA=x*Math.PI/5-Math.PI/2;A.lineTo(_+j*Math.cos(GA),hA+j*Math.sin(GA))}A.closePath()}else d==="Line"&&(A.moveTo(_-SA/2,hA),A.lineTo(_+SA/2,hA));A.fill()};A.fillStyle=y,t==="Line"?(A.strokeStyle=y,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(E/2,0),A.stroke()):IA(t,0,0,E,a,G,K);const b=E-e,P=-E/2+e/2+h*b,gA=P- -E/2;gA>0&&(A.fillStyle=S,t==="Line"?(A.strokeStyle=S,A.lineWidth=a,A.beginPath(),A.moveTo(-E/2,0),A.lineTo(P,0),A.stroke()):t==="Rectangle"&&(A.beginPath(),this.drawRoundRect(A,-E/2,-a/2,gA,a,G),A.fill())),A.save(),A.translate(P,0);const u=A.getTransform(),q=Math.sqrt(u.a*u.a+u.b*u.b)||1;if(A.shadowColor="rgba(0,0,0,0.2)",A.shadowBlur=4*q,A.shadowOffsetY=1*q,A.fillStyle=X,IA(F,0,0,e,M,n,F==="Icon"?H:Z),A.restore(),QA){A.save(),A.translate(P+T,AA);const d=Math.round(i).toString();A.font="10px Inter, sans-serif";const _=A.measureText(d),hA=6,SA=4,FA=_.width+hA*2,NA=14+SA;A.beginPath(),this.drawRoundRect(A,-FA/2,-NA/2,FA,NA,4),A.fillStyle=L,A.fill(),A.fillStyle=U,A.textAlign="center",A.textBaseline="middle",A.fillText(d,0,0),A.restore()}const l=Q.label||{},r=Q.helperText||{},z=Q.fontFamily||"Inter";if(l.visible!==!1){const d=l.text||"Label",_=l.fontSize||12,hA=l.color||"rgba(156, 163, 175, 1)",SA=l.offset??8;A.font=`600 ${_}px "${z}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="bottom";const FA=-(E/2),NA=-(a/2)-SA;A.fillText(d,FA,NA)}if(r.visible===!0){const d=r.text||"Helper text",_=r.fontSize||11,hA=r.color||"rgba(156, 163, 175, 1)",SA=r.offset??6;A.font=`400 ${_}px "${z}", sans-serif`,A.fillStyle=hA,A.textAlign="left",A.textBaseline="top";const FA=-(E/2),NA=a/2+SA;A.fillText(d,FA,NA)}}renderDropdown(A,I){var AA;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,D=-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,D,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 F=12,e=g.chevronType||"chevron",M=g.chevronSize||16,n=(a?g.openIconColor:g.closedIconColor)||g.chevronColor||"#6b7280";if(e!=="none"){const IA=i+Q-F-M/2;A.save(),A.translate(IA,0);const b=a?g.openIconAngle??180:g.closedIconAngle??0;if(A.rotate(b*Math.PI/180),A.strokeStyle=n,A.fillStyle=n,A.lineWidth=1.5,A.lineCap="round",A.lineJoin="round",e==="chevron")A.beginPath(),A.moveTo(-M/2,-M*.2),A.lineTo(0,M*.2),A.lineTo(M/2,-M*.2),A.stroke();else if(e==="custom"||e==="path"){const P=a&&g.openIconPath||g.closedIconPath;if(P){const gA=new Path2D(P);A.save();const u=M/24;A.scale(u,u),A.translate(-12,-12),A.fill(gA),A.restore()}}A.restore()}const X=g.selectedOption||g.placeholder||"Select...",Z=g.fontSize||14,H=g.fontWeight||400,QA=g.fontFamily||"Inter, sans-serif";A.font=`${H} ${Z}px ${QA}`;const L=s?g.disabledColor||"#9ca3af":!g.selectedOption&&g.placeholder?"#9ca3af":K;A.fillStyle=this.createCanvasFill(A,typeof L=="string"?{type:"Solid",color:L}:L,Q,E)||"#333333",A.textAlign="left",A.textBaseline="middle";const U=e==="none"?0:M+8,T=Q-F*2-U;if(A.save(),A.beginPath(),A.rect(i+F,D,T,E),A.clip(),A.fillText(X,i+F,0),A.restore(),a&&!s){const IA=D+E+4,b=g.optionsList||[],P=g.itemHeight||32,gA=g.listPadding??4,u=b.length*P+gA*2,q=g.listCornerRadius??o;A.save();const l=g.listShadow||{},r=A.getTransform(),z=Math.sqrt(r.a*r.a+r.b*r.b)||1;A.shadowColor=typeof l.color=="string"?l.color:((AA=l.color)==null?void 0:AA.color)||"rgba(0,0,0,0.15)",A.shadowBlur=(l.blur??12)*z,A.shadowOffsetY=(l.offsetY??6)*z,A.shadowOffsetX=(l.offsetX??0)*z,A.beginPath(),this.drawRoundRect(A,i,IA,Q,u,q),A.fillStyle=this.createCanvasFill(A,typeof g.listBackgroundColor=="string"?{type:"Solid",color:g.listBackgroundColor}:g.listBackgroundColor||{type:"Solid",color:"#ffffff"},Q,u)||"#ffffff",A.fill();const d=g.listBorderWidth??1;d>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,u)||"#e5e7eb",A.lineWidth=d,A.stroke()),A.restore();const _=g.itemFontSize||Z,hA=g.itemFontFamily||QA;A.font=`${H} ${_}px ${hA}`,b.forEach((SA,FA)=>{const NA=IA+gA+FA*P;if(SA===g.selectedOption)A.fillStyle=this.createCanvasFill(A,typeof g.itemSelectedBackgroundColor=="string"?{type:"Solid",color:g.itemSelectedBackgroundColor}:g.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},Q,P)||"#f3f4f6",A.fillRect(i+d,NA,Q-d*2,P),A.fillStyle=g.itemSelectedColor||g.activeColor||K||"#374151";else if(A.fillStyle=g.listTextColor||K||"#333333",this.activeDropdownId===I.id&&this._lastPointerPos){const O=this._lastPointerPos.y-(IA+gA),Y=Math.floor(O/P);FA===Y&&(A.fillStyle=this.createCanvasFill(A,typeof g.itemHoverBackgroundColor=="string"?{type:"Solid",color:g.itemHoverBackgroundColor}:g.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},Q,P)||"#f9fafb",A.fillRect(i+d,NA,Q-d*2,P),A.fillStyle=g.itemHoverColor||K)}A.fillText(SA,i+F,NA+P/2)})}A.globalAlpha=S}renderButton(A,I){var e,M,n,X;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((e=I.geometry)==null?void 0:e.width)||120,E=((M=I.geometry)==null?void 0:M.height)||40,i=-Q/2,D=-E/2,o=this.lastHoveredObjectId===I.id,s=g.corner_radius??8,h=g.bgShape||"Rectangle",a=o?((n=g.hoverStyle)==null?void 0:n.backgroundColor)||g.buttonBgColor||"#3b82f6":g.buttonBgColor||"#3b82f6",G=g.label||{},t=o?((X=g.hoverStyle)==null?void 0:X.textColor)||G.color||"#ffffff":G.color||"#ffffff",K=g.icon||{enabled:!1};A.save(),A.beginPath(),h==="Rectangle"?this.drawRoundRect(A,i,D,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,D,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 F=0;if(K.enabled&&K.svgPath){const Z=K.size||16,H=K.gap||8,QA=K.position==="left"?-(A.measureText(G.text||"").width/2+Z/2+H/2):A.measureText(G.text||"").width/2+Z/2+H/2;A.save(),A.translate(QA,0);const L=new Path2D(K.svgPath),U=Z/24;A.scale(U,U),A.translate(-12,-12),A.fillStyle=K.color||t,A.fill(L),A.restore(),F=K.position==="left"?Z/2+H/2:-(Z/2+H/2)}A.fillText(G.text||"Button",F,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,D=-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,D,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 F,e;const C=this.objectStates.get(I.id),g=(C==null?void 0:C.options)||I.options||{},Q=((F=I.geometry)==null?void 0:F.width)||52,E=((e=I.geometry)==null?void 0:e.height)||30,i=-Q/2,D=-E/2,o=g.checked??!1,s=g.corner_radius??E/2;A.beginPath(),this.drawRoundRect(A,i,D,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=D+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 M=g.label,n=M.fontSize||14,X=M.fontWeight||400,Z=M.fontFamily||"Inter";A.font=`${X} ${n}px "${Z}", sans-serif`,A.fillStyle=M.color||"#f3f4f6",A.textBaseline="middle";const H=M.gap||10;let QA=0,L=0;M.position==="left"?(A.textAlign="right",QA=i-H,L=0):M.position==="right"?(A.textAlign="left",QA=i+Q+H,L=0):M.position==="top"?(A.textAlign="center",QA=0,L=D-H,A.textBaseline="bottom"):M.position==="bottom"?(A.textAlign="center",QA=0,L=D+E+H,A.textBaseline="top"):(A.textAlign="left",QA=i+Q+H,L=0),A.fillText(M.text,QA,L)}}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,D=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 F=this.inputNameMap.get(K.inputId);F&&F.length>0&&(y=this.inputs.get(F[0]))}y&&Array.isArray(y)&&(S=y)}if(S&&S.length>0){const y=S.filter(F=>typeof F=="number"&&!isNaN(F));y.length>0&&(E=Math.min(E,...y),i=Math.max(i,...y),D=Math.max(D,S.length))}K._resolvedData=S}),D<2)return;const o=i-E,s=C/(D-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<D;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 F=0;F<S.length-1;F++){const e=S[F===0?F:F-1],M=S[F],n=S[F+1],X=S[F+1===S.length-1?F+1:F+2];for(let Z=1;Z<=t;Z++){const H=Z/t,QA=this._catmullRom(e,M,n,X,H);A.lineTo(a(F+H),h(QA))}}else for(let F=1;F<S.length;F++)A.lineTo(a(F),h(S[F]));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 F=S[y===0?y:y-1],e=S[y],M=S[y+1],n=S[y+1===S.length-1?y+1:y+2];for(let X=1;X<=t;X++){const Z=X/t,H=this._catmullRom(F,e,M,n,Z);A.lineTo(a(y+Z),h(H))}}else for(let y=1;y<S.length;y++)A.lineTo(a(y),h(S[y]));A.stroke(),K.showPoints&&S.forEach((y,F)=>{const e=a(F),M=h(y);A.beginPath(),A.arc(e,M,(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,F=y+5;A.font=`${y}px Inter, sans-serif`,A.textAlign="right",A.textBaseline="alphabetic",Q.forEach(e=>{const n=e.label||"Series",X=A.measureText(n).width;A.beginPath(),A.rect(K-X-8-5,S-(8/2+2),8,8),A.fillStyle=e.lineColor||"#3b82f6",A.fill(),A.fillStyle=I.legendColor||"#333333",A.fillText(n,K,S),S+=F})}}_catmullRom(A,I,C,g,Q){const E=(C-A)*.5,i=(g-I)*.5,D=Q*Q,o=Q*D;return(2*I-2*C+E+i)*o+(-3*I+3*C-2*E-i)*D+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 D=I.color,s=(((E=(Q=this.artboard)==null?void 0:Q.tokens)==null?void 0:E.colors)||{})[D]||D;return A.fillStyle=s,s}if((I.type==="LinearGradient"||I.type==="RadialGradient"||I.type==="AngularGradient"||I.type==="DiamondGradient")&&I.stops){const D=(o,s=100)=>{var M,n;const a=(((n=(M=this.artboard)==null?void 0:M.tokens)==null?void 0:n.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),F=parseInt(S.substring(2,4),16),e=parseInt(S.substring(4,6),16);return`rgba(${y}, ${F}, ${e}, ${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=D(K.color||"#000000",K.opacity??100);t.addColorStop(Math.max(0,Math.min(1,S)),y)}),I.gradientTransform&&t.setTransform){const[K,S,y,F,e,M]=I.gradientTransform;t.setTransform({a:K,b:S,c:y,d:F,e,f:M})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}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=D(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,F,e]=I.gradientTransform;G.setTransform({a:t,b:K,c:S,d:y,e:F,f:e})}return A.scale(1/Math.SQRT2,1/Math.SQRT2),A.fillStyle=G,A.restore(),G}}if(I.type==="Pattern"&&I.url){let D=this.imageCache.get(I.url);if(D||(D=new Image,D.src=I.url,this.imageCache.set(I.url,D)),D.complete&&D.naturalWidth>0){const o=A.createPattern(D,"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 D=0,o=0,s=0,h=0;typeof i=="number"?D=o=s=h=i:Array.isArray(i)?i.length===1?D=o=s=h=i[0]:i.length===2?(D=s=i[0],o=h=i[1]):i.length===3?(D=i[0],o=h=i[1],s=i[2]):i.length>=4&&(D=i[0],o=i[1],s=i[2],h=i[3]):i&&typeof i=="object"&&(D=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(D=Math.min(Math.max(0,D),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,[D,o,s,h]);return}A.moveTo(I+D,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+D),A.arcTo(I,C,I+D,C,D),A.closePath()}renderListView(A,I){var IA,b,P,gA;const C=this.objectStates.get(I.id)||{},g=C.options||I.options||{},Q=C.width!==void 0?C.width:((IA=I.geometry)==null?void 0:IA.width)||200,E=C.height!==void 0?C.height:((b=I.geometry)==null?void 0:b.height)||300,i=-Q/2,D=-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,F=g.accentColor||"#3b82f6",e=g.itemTextColor||"#333333",M=g.itemBackgroundColor||"#ffffff",n=g.hoveredIndex??null,X=g.activeItemIndex??null,Z=g.glowIntensity??0,H=g.glowColor||"#3b82f6",QA=typeof H=="string"?H:H.color||((gA=(P=H.stops)==null?void 0:P[0])==null?void 0:gA.color)||"#3b82f6",L=g.opacity!==void 0?g.opacity:I.opacity!==void 0?I.opacity:1;if(A.save(),A.globalAlpha*=L,Z>0){const u=A.getTransform(),q=Math.sqrt(u.a*u.a+u.b*u.b)||1;A.shadowColor=QA,A.shadowBlur=Z*2*q,A.shadowOffsetX=0,A.shadowOffsetY=0}if(y){const u=g.listBackgroundColor||"rgba(31, 41, 55, 0.4)",q=this.createCanvasFill(A,u,Q,E);A.fillStyle=q||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(A,i,D,Q,E,o),A.fill();const l=A.createLinearGradient(i,D,i+Q,D+E);l.addColorStop(0,"rgba(255, 255, 255, 0.15)"),l.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),l.addColorStop(1,"rgba(255, 255, 255, 0.03)"),A.fillStyle=l,this.drawListViewRect(A,i,D,Q,E,o),A.fill(),A.strokeStyle="rgba(255, 255, 255, 0.25)",A.lineWidth=1,this.drawListViewRect(A,i,D,Q,E,o),A.stroke()}else{const u=g.listBackgroundColor||"transparent",q=this.createCanvasFill(A,u,Q,E);q&&(A.fillStyle=q,this.drawListViewRect(A,i,D,Q,E,o),A.fill());const l=g.borderWidth??0;l>0&&(A.strokeStyle=g.borderColor||"#cccccc",A.lineWidth=l,this.drawListViewRect(A,i,D,Q,E,o),A.stroke())}A.shadowBlur=0,A.save(),this.drawListViewRect(A,i,D,Q,E,o),A.clip();const U=typeof S=="number"?S:s==="vertical"?S[0]:S[3];let T=(s==="vertical"?D:i)+K+U;if(A.textBaseline="middle",h.forEach((u,q)=>{const l=s==="vertical"?Q:t,r=s==="vertical"?G:E,z=s==="vertical"?i:T,d=s==="vertical"?T:D,_=n===q,hA=X===q;if(hA){const O=this.createCanvasFill(A,F,l,r);A.fillStyle=O||F;const Y=A.globalAlpha;A.globalAlpha=Y*.8,A.fillRect(z,d,l,r),A.globalAlpha=Y}else if(_)A.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",A.fillRect(z,d,l,r);else if(M!=="transparent"){const O=this.createCanvasFill(A,M,l,r);A.fillStyle=O||M,A.fillRect(z,d,l,r)}if(hA||_){const O=this.createCanvasFill(A,F,s==="vertical"?3:l,s==="vertical"?r:3);A.fillStyle=O||F,s==="vertical"?A.fillRect(z,d,3,r):A.fillRect(z,d+r-3,l,3)}const SA=hA?"#ffffff":y?"rgba(255, 255, 255, 0.9)":e;A.fillStyle=SA,A.font=hA||_?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const FA=typeof u=="string"?u:(u==null?void 0:u.label)||`Item ${q+1}`,NA=z+(s==="vertical"?16:l/2),m=d+r/2;s==="horizontal"?A.textAlign="center":A.textAlign="left",A.fillText(FA,NA,m),T+=(s==="vertical"?G:t)+a}),A.restore(),g.showScrollbar!==!1){const u=(h.length||0)*(s==="vertical"?G:t)+((h.length||0)-1)*a,q=s==="vertical"?E:Q;if(u>q){const l=q/u,r=q*l,z=-K/u*q,d=g.scrollbarColor||"rgba(255,255,255,0.3)",_=g.scrollbarWidth||4;A.fillStyle=d,s==="vertical"?A.fillRect(i+Q-_-2,D+z,_,r):A.fillRect(i+z,D+E-_-2,r,_)}}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||[],D=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)*D,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 U,T;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:((U=A.geometry)==null?void 0:U.width)||200,D=Q.height!==void 0?Q.height:((T=A.geometry)==null?void 0:T.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,F=-K.rotation*(Math.PI/180),e=Math.cos(F),M=Math.sin(F),n=S*e-y*M,X=S*M+y*e,Z=-i/2,H=-D/2,QA=typeof t=="number"?t:o==="vertical"?t[0]:t[3];let L=(o==="vertical"?H:Z)+G+QA;for(let AA=0;AA<E.length;AA++){const IA=o==="vertical"?i:a,b=o==="vertical"?h:D,P=o==="vertical"?Z:L,gA=o==="vertical"?L:H;if(n>=P&&n<=P+IA&&X>=gA&&X<=gA+b)return AA;L+=(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,F,e,M,n,X,Z,H,QA,L,U,T,AA,IA,b,P,gA,u,q,l,r,z,d,_,hA,SA,FA,NA,m,O,Y,R,x,j,GA,CA,wA,kA,BA;if(!E.enabled)return;const i=E.startTime||0,D=E.endTime||1/0;if(this.currentTime<i||this.currentTime>D)return;const o=Q.x-I,s=Q.y-C,h=Math.sqrt(o*o+s*s);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${E.type} on ${g.name}`),E.type===W.Proximity){const N=((a=E.settings)==null?void 0:a.radius)||300,f=((G=E.settings)==null?void 0:G.falloff)||"smooth";let p=0;h<N&&(f==="linear"?p=1-h/N:p=Math.pow(1-h/N,2)),p>0&&E.sensors.forEach(oA=>{this.applyBehaviorSensor(Q,oA,p,A,E.settings)})}else if(E.type===W.Magnetic){const N=((t=E.settings)==null?void 0:t.radius)||400,f=((K=E.settings)==null?void 0:K.strength)||.5;if(h<N&&h>5){const p=1-h/N,oA=o*p*f,UA=s*p*f;Q.x-=oA*A*10,Q.y-=UA*A*10}}else if(E.type===W.Repel){const N=((S=E.settings)==null?void 0:S.radius)||300,f=((y=E.settings)==null?void 0:y.strength)||1;if(h<N){const p=Math.pow(1-h/N,2);Q.x+=o/(h||1)*p*60*f*A*5,Q.y+=s/(h||1)*p*60*f*A*5}}else if(E.type===W.Orbit){const N=((F=E.settings)==null?void 0:F.speed)||1,f=((e=E.settings)==null?void 0:e.radius)||30,p=this.currentTime*N*Math.PI*2;Q.x+=Math.cos(p)*f*A*5,Q.y+=Math.sin(p)*f*A*5,Q.rotation+=2*A*5}else if(E.type===W.Vortex){const N=((M=E.settings)==null?void 0:M.radius)||400,f=((n=E.settings)==null?void 0:n.speed)||2,p=((X=E.settings)==null?void 0:X.strength)||1;if(h<N){const oA=Math.pow(1-h/N,1.5),UA=this.currentTime*f*Math.PI*2,iA=Math.cos(UA)*30-o*.4,V=Math.sin(UA)*30-s*.4;Q.x+=iA*oA*p*A*5,Q.y+=V*oA*p*A*5,Q.rotation+=5*oA*p*A*5,Q.scale_x*=1-oA*.1*p*A,Q.scale_y*=1-oA*.1*p*A}}else if(E.type===W.Fluid){const N=((Z=E.settings)==null?void 0:Z.radius)||300,f=((H=E.settings)==null?void 0:H.strength)||1;if(h<N){const p=Math.pow(1-h/N,1.2),oA=o/(h||1)*p*1.2*f,UA=s/(h||1)*p*1.2*f;Q.x+=oA*10*A*5,Q.y+=UA*10*A*5,Q.scale_x*=1+p*.3*f*A,Q.scale_y*=1+p*.3*f*A}}else if(E.type===W.Elastic){const N=((QA=E.settings)==null?void 0:QA.radius)||300,f=((L=E.settings)==null?void 0:L.strength)||1;if(h<N){const p=1-h/N;Q.scale_x*=1+p*.4*f*A,Q.scale_y*=1+p*.4*f*A}}else if(E.type===W.Holographic){const N=Q.x-this.canvasWidth/2,f=Q.y-this.canvasHeight/2,p=((U=E.settings)==null?void 0:U.factor)||25;if(Q.x-=N/1e3*p*A*5,Q.y-=f/1e3*p*A*5,Q.style){const oA=1-Math.min(1,h/400);Q.style.exposure=(Q.style.exposure||1)+oA*.5*A}}else if(E.type===W.Sticky){const N=((T=E.settings)==null?void 0:T.radius)||80,f=((AA=E.settings)==null?void 0:AA.strength)||1;if(h<N){const p=Math.pow(1-h/N,2);Q.x-=o*p*f*A*10,Q.y-=s*p*f*A*10,Q.scale_x*=1-p*.1*f*A,Q.scale_y*=1-p*.1*f*A}}else if(E.type===W.Dilation){const N=((IA=E.settings)==null?void 0:IA.size)||120,f=((b=E.settings)==null?void 0:b.strength)||1;if(h<N){const p=1-h/N;Q.scale_x*=1+p*.5*f*A,Q.scale_y*=1+p*.5*f*A}}else if(E.type===W.Parallax){const N=((P=E.settings)==null?void 0:P.factor)||.05,f=this.canvasHeight/2,p=(this._lastPointerPos.y-f)*N;Q.y+=p*A*10}else if(E.type===W.Noise||E.type===W.Float){const N=(((gA=E.settings)==null?void 0:gA.frequency)||((u=E.settings)==null?void 0:u.speed)||1)*.002,f=(((q=E.settings)==null?void 0:q.amplitude)||((l=E.settings)==null?void 0:l.range)||50)*(((r=E.settings)==null?void 0:r.strength)||1),p=Date.now();Q.x+=Math.sin(p*N)*f*A,Q.y+=Math.cos(p*N*.8)*f*A,Q.rotation+=Math.sin(p*N*.5)*5*A}else if(E.type===W.Pulse){const N=(((z=E.settings)==null?void 0:z.speed)||1)*.005,f=(((d=E.settings)==null?void 0:d.scale)||1.2)-1,p=Math.sin(Date.now()*N),oA=((_=E.settings)==null?void 0:_.strength)||1;Q.scale_x*=1+p*f*oA*A,Q.scale_y*=1+p*f*oA*A,Q.style&&(Q.style.exposure=(Q.style.exposure||1)+Math.max(0,p)*.1*oA*A)}else if(E.type===W.Draggable){const N=((hA=E.settings)==null?void 0:hA.radius)||150,f=this.draggingBehaviors.has(g.id);if(h<N||f){const p=((SA=E.settings)==null?void 0:SA.strength)||1,oA=f?1:Math.max(0,1-h/N);this.applyBehaviorSensor(Q,mA.PositionX,oA*p,A,E.settings),this.applyBehaviorSensor(Q,mA.PositionY,oA*p,A,E.settings)}}else if(E.type===W.Scroll){const N=((FA=E.settings)==null?void 0:FA.axis)||"vertical",f=((NA=E.settings)==null?void 0:NA.factor)||.5,p=((m=E.settings)==null?void 0:m.strength)||1;(N==="vertical"||N==="both")&&(Q.y+=this.scrollOffset.y*f*p*A),(N==="horizontal"||N==="both")&&(Q.x+=this.scrollOffset.x*f*p*A)}else if(E.type===W.LookAt){const N=((O=E.settings)==null?void 0:O.factor)||1,f=((Y=E.settings)==null?void 0:Y.strength)||1,p=Math.atan2(-s,-o)*(180/Math.PI),oA=Q.rotation,UA=(p-oA+180)%360-180;Q.rotation+=UA*N*f*A*10}else if(E.type===W.Glint||E.type===W.Scan){const N=(((R=E.settings)==null?void 0:R.speed)||1)*.004,f=((x=E.settings)==null?void 0:x.strength)||1,p=(Math.sin(Date.now()*N)+1)/2;Q.style&&(Q.style.exposure=(Q.style.exposure||1)+p*f*A*5),Q.x+=(p-.5)*20*f*A}else if(E.type===W.Ratchet){const N=((j=E.settings)==null?void 0:j.steps)||12,f=(((GA=E.settings)==null?void 0:GA.speed)||1)*30,p=Math.floor(Q.rotation/(360/N))*(360/N);Q.rotation=this.lerp(Q.rotation,p+f*A,.1)}else if(E.type===W.Jitter&&h<300){const N=((CA=E.settings)==null?void 0:CA.strength)||1,f=(((wA=E.settings)==null?void 0:wA.intensity)||5)*N;Q.x+=(Math.random()-.5)*f*A*60,Q.y+=(Math.random()-.5)*f*A*60,Q.rotation+=(Math.random()-.5)*f*A*120}else if(E.type===W.Follower){const N=(kA=E.settings)==null?void 0:kA.targetId;if(N){const f=this.objectStates.get(N);if(f){const p=((BA=E.settings)==null?void 0:BA.stiffness)||.1,oA=f.x-Q.x,UA=f.y-Q.y;Q.x+=oA*p*A*60,Q.y+=UA*p*A*60}}}else E.type===W.Wrap&&(Q.x<0?Q.x=this.canvasWidth:Q.x>this.canvasWidth&&(Q.x=0),Q.y<0?Q.y=this.canvasHeight:Q.y>this.canvasHeight&&(Q.y=0))})})}applyBehaviorSensor(A,I,C,g,Q){const E=(Q==null?void 0:Q.intensity)||(Q==null?void 0:Q.strength)||1,i=C*E*g;switch(I){case mA.Scale:A.scale_x*=1+i*.5,A.scale_y*=1+i*.5;break;case mA.Opacity:A.opacity=Math.max(0,Math.min(100,A.opacity-i*100));break;case mA.RotateZ:A.rotation+=i*180;break;case mA.RotateX:A.rotate_x=(A.rotate_x||0)+i*180;break;case mA.RotateY:A.rotate_y=(A.rotate_y||0)+i*180;break;case mA.PositionX:A.x+=i*300;break;case mA.PositionY:A.y+=i*300;break;case mA.SkewX:A.skew_x=(A.skew_x||0)+i*45;break;case mA.Blur:A.style||(A.style={}),A.style.blur=Math.min(100,(A.style.blur||0)+i*50);break;case mA.Exposure:A.style||(A.style={}),A.style.exposure=(A.style.exposure||1)+i*2;break;case mA.HueShift:A.style||(A.style={}),A.style.hue=(A.style.hue||0)+i*360;break;case mA.CornerRadius:A.corner_radius=Math.min(200,(A.corner_radius||0)+i*100);break;case mA.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 OQ=({artboard:B,config:A})=>{const I={...B.seo,...A},C=I.enableSmartExtraction!==!1;eA.useEffect(()=>{const i=I.title||B.name;i&&(document.title=i);let D=I.description;if(!D&&C){const h=B.objects.filter(a=>a.geometry.type==="Text").sort((a,G)=>{var t,K;return(((t=G.geometry.text)==null?void 0:t.length)||0)-(((K=a.geometry.text)==null?void 0:K.length)||0)});h.length>0&&(D=h[0].geometry.text)}D&&(g("name","description",D),g("property","og:description",D)),I.keywords&&I.keywords.length>0&&g("name","keywords",I.keywords.join(", "));const o=I.ogImage||B.backgroundImage;o&&g("property","og:image",o),i&&g("property","og:title",i),g("property","og:type","website")},[I,B,C]);const g=(i,D,o)=>{let s=document.querySelector(`meta[${i}="${D}"]`);s||(s=document.createElement("meta"),s.setAttribute(i,D),document.head.appendChild(s)),s.setAttribute("content",o)},Q=()=>{const i=[];return i.push(HA.jsx("h1",{children:I.title||B.name},"artboard-title")),B.objects.forEach((o,s)=>{if(!(!o.visible&&o.isVisible!==!0))if(o.geometry.type==="Text"){const h=o.geometry.text;h&&(o.geometry.fontSize>24?i.push(HA.jsx("h2",{children:h},o.id||s)):i.push(HA.jsx("p",{children:h},o.id||s)))}else if(o.geometry.type==="Image"){const h=o.geometry.src,a=o.altText||o.name||"Illustration";i.push(HA.jsx("img",{src:h,alt:a},o.id||s))}else o.type==="Button"&&i.push(HA.jsx("button",{children:o.name||"Button"},o.id||s))}),i},E=I.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:I.title||B.name,description:I.description,image:I.ogImage||B.backgroundImage,abstract:"Animated interface created with ExodeUI"};return HA.jsxs("div",{id:`exode-seo-${B.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[Q(),HA.jsx("script",{type:"application/ld+json",children:JSON.stringify(E)})]})},Ai=eA.forwardRef(({artboard:B,src:A,className:I,style:C,autoPlay:g=!0,fit:Q="Contain",alignment:E="Center",enableSEO:i=!0,seo:D,onReady:o,onTrigger:s,onInputUpdate:h,onComponentChange:a,onToggle:G,onInputChange:t,onInputFocus:K,onInputBlur:S,onLog:y},F)=>{const e=eA.useRef(null),M=eA.useRef(new xQ),n=eA.useRef(),X=eA.useRef(0),Z=eA.useRef(null),[H,QA]=eA.useState(B||null);eA.useImperativeHandle(F,()=>e.current),eA.useEffect(()=>{console.log("[ExodeUI] Layout Effect - Component Updated/Mounted"),M.current.setLayout(Q,E)},[Q,E]),eA.useEffect(()=>{s&&M.current.setTriggerCallback(s)},[s]),eA.useEffect(()=>{h&&M.current.setInputUpdateCallback(h)},[h]),eA.useEffect(()=>{a&&M.current.setComponentChangeCallback(a)},[a]),eA.useEffect(()=>{G&&M.current.setToggleCallback(G)},[G]),eA.useEffect(()=>{t&&M.current.setInputChangeCallback(t)},[t]),eA.useEffect(()=>{K&&M.current.setInputFocusCallback(K)},[K]),eA.useEffect(()=>{S&&M.current.setInputBlurCallback(S)},[S]),eA.useEffect(()=>{(async()=>{const T=M.current;let AA=B;if(!AA&&A)try{AA=await(await fetch(A)).json()}catch(IA){console.error("Failed to load ExodeUI animation:",IA);return}if(AA){const IA=AA.id||AA.name||"default";Z.current!==IA&&(T.load(AA),Z.current=IA,QA(AA),X.current=0),o&&o(T)}})()},[B,A]),eA.useEffect(()=>{const U=M.current,T=e.current;if(!T)return;const AA=T.getContext("2d");if(!AA)return;AA.imageSmoothingEnabled=!0,AA.imageSmoothingQuality="high",y&&U.setOnLogCallback(y);const IA=P=>{X.current||(X.current=P);const gA=(P-X.current)/1e3;X.current=P,g&&U.advance(gA);const u=window.devicePixelRatio||1,q=T.getBoundingClientRect(),l=Math.floor(q.width*u),r=Math.floor(q.height*u);(T.width!==l||T.height!==r)&&(T.width=l,T.height=r),U.render(AA,l,r),n.current=requestAnimationFrame(IA)};n.current=requestAnimationFrame(IA);const b=()=>{U.handleScroll(window.scrollX,window.scrollY)};return window.addEventListener("scroll",b,{passive:!0}),()=>{n.current&&cancelAnimationFrame(n.current),window.removeEventListener("scroll",b)}},[g]);const L=(U,T)=>{const AA=U.currentTarget.getBoundingClientRect(),IA=U.clientX-AA.left,b=U.clientY-AA.top,P=AA.width,gA=AA.height;M.current.handlePointerInput(T,IA,b,P,gA)};return HA.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...C},className:I,children:[HA.jsx("canvas",{ref:e,style:{width:"100%",height:"100%",outline:"none"},tabIndex:0,onPointerDown:U=>{var T;L(U,"down"),(T=e.current)==null||T.focus()},onPointerUp:U=>L(U,"up"),onPointerMove:U=>L(U,"move"),onPointerLeave:U=>L(U,"blur"),onClick:U=>L(U,"click"),onKeyDown:U=>{U.key==="Backspace"||U.key==="Enter"||U.key,M.current.handleKeyDown(U.nativeEvent)}}),i&&H&&HA.jsx(OQ,{artboard:H,config:D})]})});function Ii(){const[B,A]=eA.useState(null),I=eA.useCallback((h,a)=>{B==null||B.setInputBool(h,a)},[B]),C=eA.useCallback((h,a)=>{B==null||B.setInputNumber(h,a)},[B]),g=eA.useCallback(h=>{B==null||B.fireTrigger(h)},[B]),Q=eA.useCallback((h,a)=>{B==null||B.setInputText(h,a)},[B]),E=eA.useCallback((h,a)=>{B==null||B.setInputNumberArray(h,a)},[B]),i=eA.useCallback((h,a)=>{B==null||B.setInputStringArray(h,a)},[B]),D=eA.useCallback((h,a)=>{B==null||B.updateObjectOptions(h,a)},[B]),o=eA.useCallback((h,a,G)=>{B==null||B.updateConstraint(h,a,G)},[B]),s=eA.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:D}}const gi="6.0.28";pA.BehaviorSensor=mA,pA.BehaviorType=W,pA.ConditionOp=tC,pA.ExodeSEO=OQ,pA.ExodeUICanvas=Ai,pA.ExodeUIEngine=xQ,pA.LogicOp=NI,pA.VERSION=gi,pA.useExodeUI=Ii,Object.defineProperty(pA,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -7437,37 +7437,39 @@ class ii {
7437
7437
  return;
7438
7438
  }
7439
7439
  const D = this.interpolate(C.keyframes, I);
7440
- if (this.frameCount % 480 === 0) {
7441
- const a = (g == null ? void 0 : g.name) || C.object_id;
7442
- this.debugLog(`Applying ${E} = ${typeof D == "object" ? "OBJ" : D} to ${a}`);
7443
- }
7444
- if (E.includes(".")) {
7445
- const a = (E || "").split(".");
7446
- let G = i;
7447
- for (let t = 0; t < a.length - 1; t++) {
7448
- if (typeof G[a[t]] != "object" || G[a[t]] === null) {
7449
- let K = g;
7450
- for (let S = 0; S <= t; S++)
7451
- K = K ? K[a[S]] : null;
7452
- G[a[t]] = K ? JSON.parse(JSON.stringify(K)) : {};
7453
- }
7454
- G = G[a[t]];
7440
+ if (D !== void 0) {
7441
+ if (this.frameCount % 480 === 0) {
7442
+ const a = (g == null ? void 0 : g.name) || C.object_id;
7443
+ this.debugLog(`Applying ${E} = ${typeof D == "object" ? "OBJ" : D} to ${a}`);
7455
7444
  }
7456
- G[a[a.length - 1]] = D;
7457
- } else
7458
- i[E] = D;
7459
- if (this.physicsEngine && ((h = g == null ? void 0 : g.physics) != null && h.enabled) && g.physics.bodyType === "Static")
7460
- if (E === "x") {
7461
- const a = this.physicsEngine.getPosition(C.object_id);
7462
- a && this.physicsEngine.setPosition(C.object_id, D, a.y);
7463
- } else if (E === "y") {
7464
- const a = this.physicsEngine.getPosition(C.object_id);
7465
- a && this.physicsEngine.setPosition(C.object_id, a.x, D);
7466
- } else E === "rotation" && this.physicsEngine.setRotation(C.object_id, D * (Math.PI / 180));
7445
+ if (E.includes(".")) {
7446
+ const a = (E || "").split(".");
7447
+ let G = i;
7448
+ for (let t = 0; t < a.length - 1; t++) {
7449
+ if (typeof G[a[t]] != "object" || G[a[t]] === null) {
7450
+ let K = g;
7451
+ for (let S = 0; S <= t; S++)
7452
+ K = K ? K[a[S]] : null;
7453
+ G[a[t]] = K ? JSON.parse(JSON.stringify(K)) : {};
7454
+ }
7455
+ G = G[a[t]];
7456
+ }
7457
+ G[a[a.length - 1]] = D;
7458
+ } else
7459
+ i[E] = D;
7460
+ if (this.physicsEngine && ((h = g == null ? void 0 : g.physics) != null && h.enabled) && g.physics.bodyType === "Static")
7461
+ if (E === "x") {
7462
+ const a = this.physicsEngine.getPosition(C.object_id);
7463
+ a && this.physicsEngine.setPosition(C.object_id, D, a.y);
7464
+ } else if (E === "y") {
7465
+ const a = this.physicsEngine.getPosition(C.object_id);
7466
+ a && this.physicsEngine.setPosition(C.object_id, a.x, D);
7467
+ } else E === "rotation" && this.physicsEngine.setRotation(C.object_id, D * (Math.PI / 180));
7468
+ }
7467
7469
  });
7468
7470
  }
7469
7471
  interpolate(A, I) {
7470
- if (A.length === 0) return 0;
7472
+ if (A.length === 0) return;
7471
7473
  let C = A[0], g = A[A.length - 1];
7472
7474
  if (I <= C.time) return C.value;
7473
7475
  if (I >= g.time) return g.value;
@@ -9434,7 +9436,7 @@ function ai() {
9434
9436
  updateObjectOptions: D
9435
9437
  };
9436
9438
  }
9437
- const Gi = "6.0.24";
9439
+ const Gi = "6.0.28";
9438
9440
  export {
9439
9441
  TA as BehaviorSensor,
9440
9442
  j as BehaviorType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodeui",
3
- "version": "6.0.27",
3
+ "version": "6.0.29",
4
4
  "description": "React Runtime for ExodeUI Animation Engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",