exodeui 6.3.18 → 6.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -15
- package/dist/index.mjs +900 -849
- package/dist/src/types.d.ts +48 -0
- package/dist/src/utils/skinningUtils.d.ts +27 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
(function(Ht,Zt){typeof exports=="object"&&typeof module<"u"?Zt(exports,require("react/jsx-runtime"),require("react"),require("@chenglou/pretext"),require("@dimforge/rapier2d-compat"),require("lz-string")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@chenglou/pretext","@dimforge/rapier2d-compat","lz-string"],Zt):(Ht=typeof globalThis<"u"?globalThis:Ht||self,Zt(Ht.ExodeUIReact={},Ht.jsxRuntime,Ht.React,Ht.pretext,Ht.Rapier,Ht.LZString))})(this,function(Ht,Zt,$t,xe,le,ys){"use strict";var
|
|
2
|
-
`||et==="\r"?y.kinds[V]=2:y.kinds[V]=0}else y.kinds[V]=H}}T+=_.length}y.fullText=
|
|
3
|
-
`||T[
|
|
4
|
-
`&&
|
|
5
|
-
`||T[
|
|
6
|
-
`&&E++)}let w=(S==null?void 0:S.lines)||[];return p.composer==="every-line"&&w.length>1&&(w=Is(w)),p.balanceRaggedLines===!0&&w.length>1&&(w=ws(w)),{width:a,height:I,lineCount:w.length,lines:w}}function ze(p,t,s){let o=String(p||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const h=parseFloat(r);i[l]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[l]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((l,h)=>{l.endsWith("fr")&&(i[h]=r*parseFloat(l))})}return i}function Ve(p,t,s){try{const o=p.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?ks(p,t,s):Ms(p,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Ms(p,t,s){var _,R;const o=p.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,l=e==="vertical",h=t.map(x=>{const L=s(x.id),$=x.geometry;let A=(L==null?void 0:L.width)??$.width??100,V=(L==null?void 0:L.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const H=(L==null?void 0:L.radius)??$.radius??(L==null?void 0:L.outer_radius)??$.outer_radius??50;A=H*2,V=H*2}else if($.type==="Text"){const H=De({text:(L==null?void 0:L.text)??$.text??"",fontFamily:$.fontFamily,fontSize:$.fontSize,fontWeight:$.fontWeight,fontStyle:$.fontStyle,lineHeight:$.lineHeight,width:$.width||200,letterSpacing:$.letterSpacing,paragraphSpacing:$.paragraphSpacing,paragraphIndent:$.paragraphIndent,textCase:$.textCase,segments:$.segments,enableSegments:$.enableSegments});V=H.height,$.width||(A=H.width)}return A*=x.transform.scale_x||1,V*=x.transform.scale_y||1,{id:x.id,w:A,h:V,original:x}});let c=p.width,g=p.height;const f=((_=p.layoutProps)==null?void 0:_.width)==="hug",d=((R=p.layoutProps)==null?void 0:R.height)==="hug",u=[];let m=[],y=0,v=0;const b=c-n.left-n.right,C=g-n.top-n.bottom;h.forEach(x=>{r&&m.length>0&&(l?v+i+x.h>C:y+i+x.w>b)?(u.push({children:m,width:y,height:v}),m=[x],y=x.w,v=x.h):(m.push(x),l?(y=Math.max(y,x.w),v+=(m.length>1?i:0)+x.h):(y+=(m.length>1?i:0)+x.w,v=Math.max(v,x.h)))}),m.length>0&&u.push({children:m,width:y,height:v}),f&&!l&&(c=Math.max(...u.map(x=>x.width),0)+n.left+n.right),d&&l&&(g=Math.max(...u.map(x=>x.height),0)+n.top+n.bottom);const S=[];let I=n.left,w=n.top;const k=a.toLowerCase(),E=k==="center"||k.endsWith("-center"),T=k.endsWith("-right"),W=k==="center"||k.startsWith("center-"),M=k.startsWith("bottom-");return u.forEach(x=>{let L=I,$=w;l?W?$=n.top+(g-n.top-n.bottom-x.height)/2:M&&($=g-n.bottom-x.height):E?L=n.left+(c-n.left-n.right-x.width)/2:T&&(L=c-n.right-x.width),x.children.forEach(A=>{var F,q;let V=L,H=$;l?E?V+=(x.width-A.w)/2:T&&(V+=x.width-A.w):W?H+=(x.height-A.h)/2:M&&(H+=x.height-A.h);const et=((F=A.original.layoutProps)==null?void 0:F.width)==="fill",P=((q=A.original.layoutProps)==null?void 0:q.height)==="fill";S.push({id:A.id,x:V+A.w/2-c/2,y:H+A.h/2-g/2,width:et&&l?x.width:void 0,height:P?l?void 0:x.height:void 0}),l?$+=A.h+i:L+=A.w+i}),l?I+=x.width+i:w+=x.height+i}),{frameWidth:f?c:void 0,frameHeight:d?g:void 0,childUpdates:S}}function ks(p,t,s){const o=p.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:l}=o;let h=p.width,c=p.height;const g=h-r.left-r.right,f=c-r.top-r.bottom,d=ze(e||"1fr",g,n),u=ze(i||"auto",f,a),m=d.length>0?d.reduce((T,W)=>T+W,0)+(d.length-1)*n:0,y=u.length>0?u.reduce((T,W)=>T+W,0)+(u.length-1)*a:0,v=l.toLowerCase(),b=v==="center"||v.endsWith("-center"),C=v.endsWith("-right"),S=v==="center"||v.startsWith("center-"),I=v.startsWith("bottom-");let w=0,k=0;b?w=(g-m)/2:C&&(w=g-m),S?k=(f-y)/2:I&&(k=f-y);const E=[];return t.forEach((T,W)=>{var q,Q;const M=W%d.length||0,_=Math.floor(W/d.length)||0;_>=u.length&&u.push(100);const R=d[M],x=u[_];let L=r.left+w+d.slice(0,M).reduce((it,dt)=>it+dt+n,0),$=r.top+k+u.slice(0,_).reduce((it,dt)=>it+dt+a,0);const A=s(T.id),V=T.geometry;let H=(A==null?void 0:A.width)??V.width??100,et=(A==null?void 0:A.height)??V.height??100;if(V.type==="Ellipse"||V.type==="Polygon"||V.type==="Star"){const it=(A==null?void 0:A.radius)??V.radius??(A==null?void 0:A.outer_radius)??V.outer_radius??50;H=it*2,et=it*2}H*=T.transform.scale_x||1,et*=T.transform.scale_y||1;let P=L,F=$;b?P+=(R-H)/2:C&&(P+=R-H),S?F+=(x-et)/2:I&&(F+=x-et),E.push({id:T.id,x:P+H/2-h/2,y:F+et/2-c/2,width:((q=T.layoutProps)==null?void 0:q.width)==="fill"?R:void 0,height:((Q=T.layoutProps)==null?void 0:Q.height)==="fill"?x:void 0})}),{childUpdates:E}}class Ts{constructor(){tt(this,"world",null);tt(this,"bodies",new Map);tt(this,"colliders",new Map);tt(this,"initialized",!1)}async init(t){this.initialized||(await le.init(),this.world=new le.World(new le.Vector2(t.x,t.y)),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?le.RigidBodyDesc.fixed():le.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=le.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=le.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}removeBody(t){const s=this.bodies.get(t);s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){this.world&&this.world.step()}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new le.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new le.Vector2(s,o),!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new le.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new le.Vector2(s,o),!0)}}const Ne=p=>p,_s=p=>p>0?1:0,Ps=p=>p<1?0:1,He=p=>p*p,Ue=p=>p*(2-p),qe=p=>p<.5?2*p*p:-1+(4-2*p)*p,Es=p=>p*p*p,xs=p=>--p*p*p+1,Os=p=>p<.5?4*p*p*p:(p-1)*(2*p-2)*(2*p-2)+1,As=p=>p*p*p*p,Ls=p=>1- --p*p*p*p,Rs=p=>p<.5?8*p*p*p*p:1-8*--p*p*p*p,Fs=p=>p*p*p*p*p,$s=p=>1+--p*p*p*p*p,Ws=p=>p<.5?16*p*p*p*p*p:1+16*--p*p*p*p*p,Bs=p=>1-Math.cos(p*Math.PI/2),Gs=p=>Math.sin(p*Math.PI/2),Ys=p=>-(Math.cos(Math.PI*p)-1)/2,Xs=p=>p===0?0:Math.pow(2,10*(p-1)),Ds=p=>p===1?1:1-Math.pow(2,-10*p),zs=p=>p===0?0:p===1?1:p<.5?Math.pow(2,20*p-10)/2:(2-Math.pow(2,-20*p+10))/2,Vs=p=>1-Math.sqrt(1-p*p),Ns=p=>Math.sqrt(1- --p*p),Hs=p=>p<.5?(1-Math.sqrt(1-4*p*p))/2:(Math.sqrt(1-(-2*p+2)*(-2*p+2))+1)/2,Oe=1.70158,Ae=Oe*1.525,Je=Oe+1,Us=p=>Je*p*p*p-Oe*p*p,qs=p=>1+Je*Math.pow(p-1,3)+Oe*Math.pow(p-1,2),Js=p=>p<.5?Math.pow(2*p,2)*((Ae+1)*2*p-Ae)/2:(Math.pow(2*p-2,2)*((Ae+1)*(p*2-2)+Ae)+2)/2,Qe=2*Math.PI/3,Ke=2*Math.PI/4.5,Qs=p=>p===0?0:p===1?1:-Math.pow(2,10*p-10)*Math.sin((p*10-10.75)*Qe),Ks=p=>p===0?0:p===1?1:Math.pow(2,-10*p)*Math.sin((p*10-.75)*Qe)+1,Zs=p=>p===0?0:p===1?1:p<.5?-(Math.pow(2,20*p-10)*Math.sin((20*p-11.125)*Ke))/2:Math.pow(2,-20*p+10)*Math.sin((20*p-11.125)*Ke)/2+1,Le=p=>p<1/2.75?7.5625*p*p:p<2/2.75?7.5625*(p-=1.5/2.75)*p+.75:p<2.5/2.75?7.5625*(p-=2.25/2.75)*p+.9375:7.5625*(p-=2.625/2.75)*p+.984375,js=p=>1-Le(1-p),ti=Le,ei=p=>p<.5?(1-Le(1-2*p))/2:(1+Le(2*p-1))/2,Ye=new Map,Te=(p,t,s,o)=>{const e=`${p},${t},${s},${o}`;if(Ye.has(e))return Ye.get(e);const i=h=>(1-3*s+3*p)*h*h*h+(3*s-6*p)*h*h+3*p*h,n=h=>(1-3*o+3*t)*h*h*h+(3*o-6*t)*h*h+3*t*h,a=h=>3*(1-3*s+3*p)*h*h+2*(3*s-6*p)*h+3*p,r=h=>{let c=h;for(let g=0;g<8;g++){const f=i(c)-h;if(Math.abs(f)<1e-6)return c;const d=a(c);if(Math.abs(d)<1e-6)break;c=c-f/d}return c},l=h=>h===0?0:h===1?1:n(r(h));return Ye.set(e,l),l},Ze=p=>{const t=p.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return Te(s,o,e,i)},je={ease:Te(.25,.1,.25,1),"ease-in":Te(.42,0,1,1),"ease-out":Te(0,0,.58,1),"ease-in-out":Te(.42,0,.58,1)},Re={Linear:Ne,EaseInQuad:He,EaseOutQuad:Ue,EaseInOutQuad:qe,EaseInCubic:Es,EaseOutCubic:xs,EaseInOutCubic:Os,EaseInQuart:As,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Ws,EaseInSine:Bs,EaseOutSine:Gs,EaseInOutSine:Ys,EaseInExpo:Xs,EaseOutExpo:Ds,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Js,EaseInElastic:Qs,EaseOutElastic:Ks,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:He,EaseOut:Ue,EaseInOut:qe,StepStart:_s,StepEnd:Ps},si=p=>{const t=p.trim(),s=t.toLowerCase();if(Re[t])return Re[t];const o=Object.keys(Re).find(i=>i.toLowerCase()===s);if(o)return Re[o];const e=Object.keys(ts).find(i=>i.toLowerCase()===s);if(e){const i=Ze(ts[e].value);if(i)return i}if(je[s])return je[s];if(s.startsWith("cubic-bezier")){const i=Ze(t);if(i)return i}return Ne},ts={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)"}},es={default:{label:"Default",colors:["#6366f1","#f59e0b"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",gridColor:"rgba(255,255,255,0.06)",axisLabelColor:"rgba(255,255,255,0.5)",legendColor:"rgba(255,255,255,0.7)",barGradient:!0},neon:{label:"Neon",colors:["#00f5ff","#ff00e5"],cardBackground:"rgba(0,0,0,0.5)",cardBorderColor:"rgba(0,245,255,0.2)",gridColor:"rgba(0,245,255,0.08)",axisLabelColor:"rgba(0,245,255,0.6)",legendColor:"rgba(0,245,255,0.8)",barGradient:!0},pastel:{label:"Pastel",colors:["#a5b4fc","#fcd34d"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",gridColor:"rgba(255,255,255,0.08)",axisLabelColor:"rgba(255,255,255,0.45)",legendColor:"rgba(255,255,255,0.65)",barGradient:!1},warm:{label:"Warm",colors:["#f97316","#ef4444"],cardBackground:"rgba(30,10,0,0.4)",cardBorderColor:"rgba(249,115,22,0.2)",gridColor:"rgba(249,115,22,0.08)",axisLabelColor:"rgba(253,186,116,0.7)",legendColor:"rgba(253,186,116,0.85)",barGradient:!0},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",gridColor:"rgba(6,182,212,0.06)",axisLabelColor:"rgba(125,211,252,0.6)",legendColor:"rgba(125,211,252,0.8)",barGradient:!0},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.4)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",gridColor:"rgba(255,255,255,0.05)",axisLabelColor:"rgba(255,255,255,0.4)",legendColor:"rgba(255,255,255,0.6)",barGradient:!1}},ss={default:{label:"Default",colors:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",legendColor:"rgba(255,255,255,0.65)",labelColor:"#ffffff",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"},neon:{label:"Neon",colors:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff"],cardBackground:"rgba(0,0,0,0.55)",cardBorderColor:"rgba(0,245,255,0.2)",legendColor:"rgba(0,245,255,0.75)",labelColor:"#ffffff",centerTextColor:"#00f5ff",centerLabelColor:"rgba(0,245,255,0.5)"},pastel:{label:"Pastel",colors:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",legendColor:"rgba(255,255,255,0.6)",labelColor:"#1a1a2e",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.45)"},warm:{label:"Warm",colors:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c"],cardBackground:"rgba(30,10,0,0.45)",cardBorderColor:"rgba(249,115,22,0.2)",legendColor:"rgba(253,186,116,0.8)",labelColor:"#ffffff",centerTextColor:"#fb923c",centerLabelColor:"rgba(253,186,116,0.5)"},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",legendColor:"rgba(125,211,252,0.75)",labelColor:"#ffffff",centerTextColor:"#38bdf8",centerLabelColor:"rgba(125,211,252,0.5)"},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.65)","rgba(255,255,255,0.45)","rgba(255,255,255,0.28)","rgba(255,255,255,0.15)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",legendColor:"rgba(255,255,255,0.55)",labelColor:"#000000",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"}};class is{constructor(){tt(this,"artboard",null);tt(this,"objectStates",new Map);tt(this,"physicsEngine",null);tt(this,"activeStateMachine",null);tt(this,"inputs",new Map);tt(this,"inputNameMap",new Map);tt(this,"layerStates",new Map);tt(this,"pretextCache",new Map);tt(this,"pointerHistory",[]);tt(this,"MAX_HISTORY",200);tt(this,"imageCache",new Map);tt(this,"lastValidSvgImgMap",new Map);tt(this,"maskBuffer",null);tt(this,"maskCtx",null);tt(this,"lumaBuffer",null);tt(this,"lumaCtx",null);tt(this,"_noiseTileCanvas",null);tt(this,"layout",{fit:"Contain",alignment:"Center"});tt(this,"onTrigger");tt(this,"onInputUpdate");tt(this,"onComponentChange");tt(this,"onToggle");tt(this,"onInputChange");tt(this,"onInputFocus");tt(this,"onInputBlur");tt(this,"onLog");tt(this,"onButtonClick");tt(this,"onGraphPointClick");tt(this,"justFiredTriggers",new Set);tt(this,"rootTransform",null);tt(this,"canvasWidth",0);tt(this,"canvasHeight",0);tt(this,"lastHoveredObjectId",null);tt(this,"_lastPointerPos",null);tt(this,"_prevPointerPos",null);tt(this,"focusedId",null);tt(this,"draggingSliderId",null);tt(this,"activeDropdownId",null);tt(this,"activeObjectId",null);tt(this,"draggingListViewId",null);tt(this,"scrollOffset",{x:0,y:0});tt(this,"_totalScroll",{x:0,y:0});tt(this,"draggingBehaviors",new Set);tt(this,"isMouseDown",!1);tt(this,"_layoutAnimCache",new Map);tt(this,"_springChainState",new Map);tt(this,"_emitterPools",new Map);tt(this,"objectVelocities",new Map);tt(this,"currentTime",0);tt(this,"frameCount",0);tt(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4,Lato:.35,"Bebas Neue":.45,Oswald:.4});tt(this,"onLogicUpdate");tt(this,"logicNodeValues",new Map);tt(this,"logicNodeState",new Map);tt(this,"pointerDownTimes",new Map);tt(this,"activeHoverIds",new Set);tt(this,"onNavigation");tt(this,"periodicTriggerTimes",new Map);tt(this,"wasInView",new Set);tt(this,"scrollProgressLastValue",new Map);tt(this,"debug_objectsRendered",0);tt(this,"debug_objectsTotal",0);tt(this,"lastRenderTime",0);tt(this,"debugMode",!1);tt(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,l=0,h=0,c=0,g;for(;(g=s.exec(t))!==null;){const f=g[1],d=(g[2].match(o)||[]).map(parseFloat),u=f===f.toLowerCase(),m=f.toUpperCase();let y=0;const v=C=>{let S=d[y++];return u&&(S+=C?n:a),S},b=()=>({x:v(!0),y:v(!1)});switch(m){case"M":{const C=b();for(h=n=C.x,c=a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<d.length;){const S=b();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<d.length;){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<d.length;)n=v(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<d.length;)a=v(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<d.length;){const C=b(),S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"S":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"Q":for(;y<d.length;){const C=b(),S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"T":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"Z":if(i=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const S=[...e].reverse().find(I=>I.moveTo)||e[0];S&&Math.hypot(S.x-C.x,S.y-C.y)<.1&&(S.in_x=C.in_x,S.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=h,a=c;break;default:if(d.length>=2){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const h={...l},c=h.childrenObjects||[];e.add(h.id),o.push(h),i(c)})};if(i(s.objects||[]),o.length>(s.objects||[]).length&&console.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),console.log(`[ExodeUIEngine] Loading artboard: "${(n=this.artboard)==null?void 0:n.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(l=>{r.set(l.id,l),l.children||(l.children=[])}),this.artboard.objects.forEach(l=>{if(l.parentId){const h=r.get(l.parentId);h&&(h.children||(h.children=[]),h.children.includes(l.id)||h.children.push(l.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{console.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=vs.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}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.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this._layoutAnimCache.clear(),this._springChainState.clear(),this._emitterPools.clear(),this.artboard.objects.forEach(s=>{var n,a,r,l,h,c,g;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((l=s.geometry)==null?void 0:l.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((h=s.transform)==null?void 0:h.x)??s.x??0,y:((c=s.transform)==null?void 0:c.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((g=s.transform)==null?void 0:g.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new Ts;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var i,n;if((i=e.physics)!=null&&i.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,l=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((n=e.geometry)==null?void 0:n.type)||"Rectangle",x:a.x,y:a.y,width:r,height:l,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var i;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(n=>s.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(l>20||h>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((i=this.artboard.autoLayout)!=null&&i.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=Ve(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var a;if(n.type==="Frame"&&((a=n.autoLayout)!=null&&a.enabled)&&n.children&&n.children.length>0){const r=n.children.map(c=>s.get(c)).filter(c=>!!c),l=this.objectStates.get(n.id);if(!l)return;const h=Ve(l,r,c=>this.objectStates.get(c));h.frameWidth!==void 0&&(l.width=h.frameWidth),h.frameHeight!==void 0&&(l.height=h.frameHeight),e(h.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let s="";t.forEach(n=>{const a=n.replace(/ /g,"+");s+=`&family=${a}: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 o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let i=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const l=a.states.find(h=>h.id===r);if(l){let h=null;l.animationId&&(h=this.artboard.animations.find(c=>c.id===l.animationId)||null),h||(h=this.artboard.animations.find(c=>{var g,f;return c.name===l.name||c.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((g=c.name)==null?void 0:g.toLowerCase())==="onload"||((f=c.name)==null?void 0:f.toLowerCase())==="intro")})||null),h&&((n=this.artboard.animationFlow)!=null&&n.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(h==null?void 0:h.id))||(e.push({animation:h,state:l}),i=Math.max(i,h.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")){const i=s.split(".");let n=e;for(let a=0;a<i.length-1;a++)n[i[a]]||(n[i[a]]={}),n=n[i[a]];n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const l=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(c=>c.id===l[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(l=>this.setInternalInput(l,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(l=>{if(l.inputId===t||l.name===t){const h=this.objectStates.get(l.id);h&&h.options&&(l.type==="ListView"||l.variant==="listview"?h.options.items=e:(l.type==="Dropdown"||l.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.conditionValue;let l=!1;switch(a){case"Equal":case"==":l=s==r;break;case"NotEqual":case"!=":l=s!=r;break;case"GreaterThan":case">":l=s>r;break;case"LessThan":case"<":l=s<r;break;case"GreaterEqual":case">=":l=s>=r;break;case"LessEqual":case"<=":l=s<=r;break;case"IsTrue":l=!!s;break;case"IsFalse":l=!s;break}if(l){const h=i.delay||0;h<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return console.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,h,c,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(f=>f.id===t);if(e){const f=(u,m)=>{const y=e.inputs.find(v=>v.id===u);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:m:m};let d=0;switch(e.op){case yt.AND:d=f("a",!1)&&f("b",!1);break;case yt.OR:d=f("a",!1)||f("b",!1);break;case yt.NOT:d=!f("in",!1);break;case yt.XOR:d=!!f("a",!1)!=!!f("b",!1);break;case yt.OBJECT:d=e.name;break;case yt.PROPERTY:case yt.GET_PROPERTY:{const u=f("id","");if(!u){d=0;break}const m=e.name;if(!m||m==="GET_PROPERTY"||m==="PROPERTY"){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}m in y?d=y[m]:d=this.resolvePath(y,m);break}case yt.SET_PROPERTY:{const u=f("id",""),m=f("value",void 0);if(!u||m===void 0){d=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){d=0;break}const v=this.objectStates.get(u);if(!v){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))v[y]=m,d=m;else{const C=y.split(".");let S=v;for(let w=0;w<C.length-1;w++){const k=C[w];S[k]===void 0&&(S[k]={}),S=S[k]}const I=C[C.length-1];S[I]=m,d=m}break}case yt.ADD:d=f("a",0)+f("b",0);break;case yt.SUB:d=f("a",0)-f("b",0);break;case yt.MUL:d=f("a",0)*f("b",0);break;case yt.DIV:{const u=f("b",1);d=u===0?0:f("a",0)/u;break}case yt.MOD:d=f("a",0)%f("b",1);break;case yt.POW:d=Math.pow(f("a",0),f("b",1));break;case yt.ABS:d=Math.abs(f("in",0));break;case yt.ROUND:d=Math.round(f("in",0));break;case yt.FLOOR:d=Math.floor(f("in",0));break;case yt.CEIL:d=Math.ceil(f("in",0));break;case yt.SIN:d=Math.sin(f("in",0));break;case yt.COS:d=Math.cos(f("in",0));break;case yt.TAN:d=Math.tan(f("in",0));break;case yt.CLAMP:{const u=f("in",0),m=f("min",0),y=f("max",1);d=Math.max(m,Math.min(y,u));break}case yt.REMAP:{const u=f("in",0),m=f("inMin",0),y=f("inMax",100),v=f("outMin",0),b=f("outMax",1);d=y===m?v:v+(u-m)*(b-v)/(y-m);break}case yt.EQ:d=f("a",0)==f("b",0);break;case yt.NEQ:d=f("a",0)!=f("b",0);break;case yt.GT:d=f("a",0)>f("b",0);break;case yt.LT:d=f("a",0)<f("b",0);break;case yt.GTE:d=f("a",0)>=f("b",0);break;case yt.LTE:d=f("a",0)<=f("b",0);break;case yt.IF_ELSE:d=f("cond",!1)?f("then",0):f("else",0);break;case yt.VALUE:d=e.value!==void 0?e.value:0;break;case yt.INPUT:d=this.inputs.get(e.name)??0;break;case yt.LOG:{const u=f("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case yt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case yt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case yt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case yt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case yt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case yt.EFFECTOR:{const u=f("id",""),m=f("intensity",1),y=f("trigger",!0);if(!u||!y){d=0;break}const v=e.name;if(!v){d=0;break}const b=this.objectStates.get(u);if(!b){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(v))b.style||(b.style={}),b.style.artEffect={enabled:!0,type:v,intensity:m},d=1;else{b.behaviors||(b.behaviors=[]);let S=b.behaviors.find(I=>I.type===v);S?(S.enabled=!0,S.settings||(S.settings={}),S.settings.intensity=m):(S={id:`eff_${Date.now()}_${v}`,type:v,enabled:!0,sensors:[],settings:{intensity:m}},b.behaviors.push(S)),d=1}break}case yt.MONITOR:{d=f("in",0);break}case yt.SPRING_PULL:{const u=f("objectId",""),m=f("forceX",0),y=f("forceY",0);u&&((l=this.artboard)==null||l.objects.forEach(v=>{v.behaviors&&v.behaviors.forEach(b=>{var C;if(b.type===Y.SpringChain&&((C=b.settings)!=null&&C.connections)&&(b.settings.connections.some(I=>I.targetId===u)||v.id===u)){this._springChainState.has(v.id)||this._springChainState.set(v.id,new Map);const I=this._springChainState.get(v.id);if(!I.has(u)){const k=this.objectStates.get(u);I.set(u,{x:(k==null?void 0:k.x)??0,y:(k==null?void 0:k.y)??0,vx:0,vy:0})}const w=I.get(u);w&&(w.vx+=m,w.vy+=y)}})})),d=1;break}case yt.SPRING_SETTLE:{const u=f("objectId","");let m=!0;if(u){const y=f("threshold",1);this._springChainState.forEach(v=>{const b=v.get(u);b&&(Math.abs(b.vx)>y||Math.abs(b.vy)>y)&&(m=!1)})}d=m;break}case yt.EMIT:{const u=f("objectId",""),m=f("count",20);u&&((h=this.artboard)==null||h.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(v=>{v.type===Y.ParticleEmitter&&y.id===u&&(v._pendingBurst=(v._pendingBurst||0)+m)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===yt.DELAY){const u=f("delay",0),m=f("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+u,value:m});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;d=y.lastValue??0}return d}const i=(c=this.activeStateMachine)==null?void 0:c.inputs.find(f=>f.id===t||f.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const f=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,f),f}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const f=(g=this.activeStateMachine)==null?void 0:g.inputs.find(d=>d.id===t);if(f&&f.value.type==="Number"&&typeof n=="number"){const d=f.value.defaultValue??f.value.value;if(s==="source-greater")return n>d;if(s==="source-less")return n<d;if(s==="source-equal")return n===d}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===yt.SET_PROPERTY||t.op===yt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(console.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{this.applyAnimation(i.animation,o.time,i.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var i,n,a,r,l,h,c;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(g=>g.id===e))==null?void 0:n.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(h=(l=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:l.triggers)==null?void 0:h.find(u=>u.id===o.triggerId),f=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=f;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(g!=null&&g.exitAnimationId){const u=(c=this.artboard)==null?void 0:c.animations.find(m=>m.id===g.exitAnimationId);u?(o.phase="exit",o.animation=u,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t)}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,i,n;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),l=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),h=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),c=50,g=r.x+l/2>=-this.canvasWidth/2-c&&r.x-l/2<=this.canvasWidth/2+c&&r.y+h/2>=-this.canvasHeight/2-c&&r.y-h/2<=this.canvasHeight/2+c,f=`analytics_${s.id}`,d=this.wasInView.has(f);g&&!d&&this.fireAnalyticsEvent(s.id,"visible"),g?this.wasInView.add(f):this.wasInView.delete(f)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,l,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const c=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const c=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const c=this.objectStates.get(s.id);if(c&&c.visible!==!1){const g=this.getGlobalTransform(s.id),f=(((r=s.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),d=(((l=s.geometry)==null?void 0:l.height)||100)*(g.scale_y||1),u=50,m=g.x+f/2>=-this.canvasWidth/2-u&&g.x-f/2<=this.canvasWidth/2+u&&g.y+d/2>=-this.canvasHeight/2-u&&g.y-d/2<=this.canvasHeight/2+u,y=this.wasInView.has(s.id);m&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),m?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const c=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(c-g)>.001&&(this.scrollProgressLastValue.set(e.id,c),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,c))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((i,n)=>{var h,c,g,f,d,u,m,y,v;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...i,...a},l=r.strength??1;if(r.type==="Translation"){const b=this.getGlobalTransform(r.targetId);if(b){const C=r.offsetX||0,S=r.offsetY||0,I=b.x+C,w=b.y+S,k=r.useSpring;if(k){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:W,y:M,vx:_,vy:R}=this.computeSpring(e.x,e.y,T.vx,T.vy,I,w,r,t);r.copyX&&(e.x=e.x+(W-e.x)*l),r.copyY&&(e.y=e.y+(M-e.y)*l),this.objectVelocities.set(s.id,{vx:_,vy:R})}else r.copyX&&(e.x=e.x+(I-e.x)*l),r.copyY&&(e.y=e.y+(w-e.y)*l);let E=!1;if((c=r.limitX)!=null&&c.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(E=!0)}if((g=r.limitY)!=null&&g.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(E=!0)}E&&k&&this.objectVelocities.set(s.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const b=this.getGlobalTransform(r.targetId);if(b){let S=(b.rotation+(r.offset||0)-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*l}}else if(r.type==="Scale"){const b=this.getGlobalTransform(r.targetId);b&&(r.copyX&&(e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l),r.copyY&&(e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l))}else if(r.type==="Transform"){const b=this.getGlobalTransform(r.targetId);if(b){e.x=e.x+(b.x-e.x)*l,e.y=e.y+(b.y-e.y)*l;let C=(b.rotation-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*l,e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l,e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l}}else if(r.type==="FollowPointer"){const b=((f=this._lastPointerPos)==null?void 0:f.x)??e.x,C=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,S=r.useSpring;if(S){const w=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:k,y:E,vx:T,vy:W}=this.computeSpring(e.x,e.y,w.vx,w.vy,b,C,r,t);e.x=k,e.y=E,this.objectVelocities.set(s.id,{vx:T,vy:W})}else e.x=e.x+(b-e.x)*l,e.y=e.y+(C-e.y)*l;let I=!1;if((u=r.limitX)!=null&&u.enabled){const w=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==w&&(I=!0)}if((m=r.limitY)!=null&&m.enabled){const w=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==w&&(I=!0)}I&&S&&this.objectVelocities.set(s.id,{vx:0,vy:0})}else if(r.type==="Distance"){const b=this.getGlobalTransform(r.targetId);if(b){const C=e.x-b.x,S=e.y-b.y,I=Math.sqrt(C*C+S*S),w=r.distance||0;let k=I;switch(r.mode){case"exact":k=w;break;case"minimum":k=Math.max(w,I);break;case"maximum":k=Math.min(w,I);break;case"clamped":k=Math.max(0,Math.min(w,I));break}if(I>0){const E=e.x===b.x&&e.y===b.y?1:k/I;e.x=e.x+(b.x+C*E-e.x)*l,e.y=e.y+(b.y+S*E-e.y)*l}}}else if(r.type==="FollowPath"){const b=(y=this.artboard)==null?void 0:y.objects.find(C=>C.id===r.targetId);if(b){const C=this.getGlobalTransform(b.id);if(C){let S=b.geometry;if(b.type==="Frame"||b.type==="Group"||!S||S.type!=="Path"&&S.type!=="Ellipse"&&S.type!=="Rectangle"){const F=(v=this.artboard)==null?void 0:v.objects.find(q=>q.parentId===b.id&&q.type==="Shape"&&q.geometry&&(q.geometry.type==="Path"||q.geometry.type==="Ellipse"||q.geometry.type==="Rectangle"));F&&(S=F.geometry)}if(!S)return;const I=(r.distance||0)/100,w=C.width||S.width||0,k=C.height||S.height||0,E=this.getPointOnPath(S,w,k,I),T=C.rotation*Math.PI/180,W=Math.cos(T),M=Math.sin(T),_=E.x*C.scale_x*W-E.y*C.scale_y*M,R=E.x*C.scale_x*M+E.y*C.scale_y*W;let x=C.rotation+(r.offsetRotation||0);if(r.orient){const F=Math.cos(E.angle),q=Math.sin(E.angle),Q=F*C.scale_x*W-q*C.scale_y*M,it=F*C.scale_x*M+q*C.scale_y*W;x=Math.atan2(it,Q)*180/Math.PI+(r.offsetRotation||0)}const L=x*Math.PI/180,$=Math.cos(L),A=Math.sin(L),V=(r.offsetX||0)*$-(r.offsetY||0)*A,H=(r.offsetX||0)*A+(r.offsetY||0)*$,et=C.x+_+V,P=C.y+R+H;if(e.x=e.x+(et-e.x)*l,e.y=e.y+(P-e.y)*l,r.orient){let F=(x-e.rotation)%360;F>180&&(F-=360),F<-180&&(F+=360),e.rotation=e.rotation+F*l}}}}else if(r.type==="IK"){const b=this.getGlobalTransform(r.targetId);b&&this.solveIK(s,b,r.boneCount||2,l)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var h;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(h=this.artboard)==null?void 0:h.objects.find(c=>c.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1)};const e=this.getGlobalTransform(o.parentId),i=e.rotation*Math.PI/180,n=Math.cos(i),a=Math.sin(i),r=e.x+(s.x*e.scale_x*n-s.y*e.scale_y*a),l=e.y+(s.x*e.scale_x*a+s.y*e.scale_y*n);return{x:r,y:l,rotation:e.rotation+s.rotation,scale_x:e.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:e.scale_y*(s.scale_y??1)*(s.flip_y?-1:1)}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=s.x-o.x,h=s.y-o.y,c=(l*a-h*r)*e,g=(l*r+h*a)*i;return{x:c,y:g,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var l;const i=[];let n=t.id;for(let h=0;h<o&&n;h++){const c=(l=this.artboard)==null?void 0:l.objects.find(g=>g.id===n);if(!c)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=c.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let h=0;h<r;h++){const c=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const f=a[g],d=this.getGlobalTransform(f.id),u=c.x-d.x,m=c.y-d.y,y=s.x-d.x,v=s.y-d.y,b=Math.sqrt(u*u+m*m),C=Math.sqrt(y*y+v*v);if(b>.001&&C>.001){const S=Math.atan2(m,u);let w=(Math.atan2(v,y)-S)*180/Math.PI;w*=e;const k=this.objectStates.get(f.id);k&&(k.rotation+=w)}}}}computeSpring(t,s,o,e,i,n,a,r){const l=a.stiffness??100,h=a.damping??10,c=a.mass??1,g=-l*(t-i),f=-l*(s-n),d=-h*o,u=-h*e,m=(g+d)/c,y=(f+u)/c,v=o+m*r,b=e+y*r,C=t+v*r,S=s+b*r;return{x:C,y:S,vx:v,vy:b}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX-this.artboard.width/2,r=(o-n.ty)/n.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,s){this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,l,h,c,g;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const i=(f,d)=>{var C;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const m=new Set([u]);d==="move"&&m.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&m.add("click"),u==="onPointerDown"&&m.add("pointerDown"),u==="onPointerUp"&&m.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup"];return!!(f.type==="Component"&&y.includes(f.variant)||y.includes((C=f.type)==null?void 0:C.toLowerCase())||(f.interactions||[]).some(S=>m.has(S.event))||(f.triggers||[]).some(S=>m.has(S.eventType)))};let n=null;for(let f=this.artboard.objects.length-1;f>=0;f--){const d=this.artboard.objects[f],u=this.objectStates.get(d.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(d,s,o)&&(n||(n=d),i(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const f=this.artboard.objects.find(d=>d.id===this.draggingSliderId);f&&this.updateSliderValueFromPointer(f,s,o);return}if(this.draggingListViewId){const f=this.artboard.objects.find(d=>d.id===this.draggingListViewId);f&&this.updateListViewScrollFromPointer(f);return}e&&e.type==="Component"&&e.variant==="listview"&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(f=>f.type===Y.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(f=>{f!==a&&this.activeHoverIds.delete(f)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const f=this.artboard.objects.find(d=>d.id===this.activeDropdownId);if(f&&(f.type==="Dropdown"||f.variant==="dropdown")){const d=this.objectStates.get(f.id),u=(d==null?void 0:d.options)||f.options||{},m=f.geometry||{},y=m.width??f.width??200,v=m.height??f.height??40,b=u.optionsList||[],C=u.itemHeight||32,S=u.listPadding??4,I=b.length*C+S*2,w=this.getWorldTransform(f.id),k=y*Math.abs(w.scaleX),E=v*Math.abs(w.scaleY),T=w.y+E/2+4,W=Math.abs(s-w.x)<=k/2,M=o>=T&&o<=T+I*Math.abs(w.scaleY);if(W&&M){const _=Math.abs(w.scaleY),R=o-(T+S*_),x=Math.floor(R/(C*_));if(x>=0&&x<b.length){const L=b[x];u.selectedOption=L,u.isOpen=!1,this.activeDropdownId=null,f.inputId&&this.setInternalInput(f.inputId,L),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"dropdown",property:"selectedOption",value:L})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let f=e,d=e;for(;d&&d.parentId;){const m=this.artboard.objects.find(y=>y.id===d.parentId);if(m&&m.type==="Component"){f=m;break}d=m}let u=t;if(t==="click"?u="onClick":t==="down"?u="onPointerDown":t==="up"?u="onPointerUp":t==="blur"&&(u="onPointerLeave"),this.fireEventForObject(e.id,u),f!==e&&this.fireEventForObject(f.id,u),f.type==="Component"&&f.variant==="toggle_button"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(f.id,"Toggle"),this.fireEventForObject(f.id,y.checked?"Toggle True":"Toggle False")}if(f.type==="Component"&&f.variant==="toggle"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(f.name,y.checked),this.fireEventForObject(f.id,"Toggle"),this.fireEventForObject(f.id,y.checked?"Toggle True":"Toggle False")}if(f.type==="Component"&&f.variant==="dropdown"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{},v=!y.isOpen;if(v&&this.activeDropdownId&&this.activeDropdownId!==f.id){const b=this.artboard.objects.find(C=>C.id===this.activeDropdownId);b&&b.options&&(b.options.isOpen=!1)}y.isOpen=v,this.activeDropdownId=v?f.id:null}if(f.type==="Component"&&f.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(f.name,f.id),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"button",property:"click",value:!0})),f.type==="Component"&&f.variant==="listview"&&t==="down"){this.draggingListViewId=f.id;const m=this.getListViewItemIndexAtPointer(f,s,o);if(m!==null){const y=f.options||{};y.activeItemIndex=m;const v=this.objectStates.get(f.id);v&&v.options&&(v.options.activeItemIndex=m);const b=(y.items||[])[m],C=typeof b=="string"?b:b.label||b.value||m;v&&v.options&&(v.options.selectedValue=C),f.inputId&&this.setInternalInput(f.inputId,C),this.onComponentChange&&(this.onComponentChange({objectId:f.id,componentName:f.name,variant:"listview",property:"activeItemIndex",value:m}),this.onComponentChange({objectId:f.id,componentName:f.name,variant:"listview",property:"selected",value:C}))}}if(f.type==="Component"&&f.variant==="slider"&&t==="down"&&(this.draggingSliderId=f.id,this.updateSliderValueFromPointer(f,s,o)),f.type==="Component"&&f.variant==="checkbox"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"checkbox",property:"checked",value:y.checked}),this.fireEventForObject(f.id,"Click"),this.fireEventForObject(f.id,y.checked?"Checked":"Unchecked")}if(f.type==="Component"&&f.variant==="radiogroup"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{},v=y.optionsList||[],b=this.getRadioGroupItemIndexAtPointer(f,s,o);if(b!==null&&b>=0&&b<v.length){const C=v[b];y.selectedValue=C,f.inputId&&this.setInternalInput(f.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"radiogroup",property:"selectedValue",value:C}),this.fireEventForObject(f.id,"Click"),this.fireEventForObject(f.id,`Selected: ${C}`)}}if(f.type==="LineGraph"&&(t==="down"||t==="click")){const m=f.geometry,y=(m==null?void 0:m.datasets)||[],v=this.objectStates.get(f.id),b=(v==null?void 0:v.width)||(m==null?void 0:m.width)||200,C=(v==null?void 0:v.height)||(m==null?void 0:m.height)||150,S=this.getWorldTransform(f.id),I=30,w=20,k=b-I,E=C-w;let T=1;y.forEach(_=>{const R=Math.max(..._.data||[0]);R>T&&(T=R)});let W=1/0,M=null;y.forEach((_,R)=>{const x=_.data||[],L=k/Math.max(x.length-1,1);x.forEach(($,A)=>{const V=S.x-b/2+I+A*L,H=S.y+C/2-w-$/T*E,et=Math.sqrt((s-V)**2+(o-H)**2);et<W&&(W=et,M={dIdx:R,pIdx:A,val:$,label:_.label||`Dataset ${R+1}`})})}),M&&W<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:f.id,componentName:f.name,datasetIndex:M.dIdx,pointIndex:M.pIdx,value:M.val,label:M.label}),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"linegraph",property:"click",value:(M==null?void 0:M.val)??null})}if(t==="click"){const m=(l=this.artboard)==null?void 0:l.objects.find(b=>b.id===e.id),y=this.focusedId,v=(m==null?void 0:m.type)==="InputBox"||(m==null?void 0:m.type)==="Component"&&m.variant==="inputbox";if(m&&v){if(this.focusedId=e.id,console.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const b=(h=this.artboard)==null?void 0:h.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}this.onInputFocus&&this.onInputFocus(m.name)}}else if(this.focusedId=null,y){const b=(c=this.artboard)==null?void 0:c.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}}}else if(t==="click"){const f=this.focusedId;if(this.focusedId=null,f){const d=(g=this.artboard)==null?void 0:g.objects.find(u=>u.id===f);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||!this.focusedId)return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
|
|
7
|
-
`;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}fireEventForObject(t,s){var h,c,g,f,d;const o=(h=this.artboard)==null?void 0:h.objects.find(u=>u.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const m=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?m.every(b=>e.has(b.toLowerCase())):m.some(b=>e.has(b.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(console.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let u=a.value||a.inputValue;u==="toggle"&&(u=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,u)}else if(a.action==="Toggle Boolean"){const u=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!u)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const u=a.targetObjectId||o.id,m=a.targetProperty;m&&this.updateObjectProperty(u,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const u=a.targetAnimationId;u==="__all__"?(g=(c=this.artboard)==null?void 0:c.animations)==null||g.forEach(m=>{this.triggerGlobalAnimation(m.id,a.subAnimationIds)}):u&&this.triggerGlobalAnimation(u,a.subAnimationIds)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,y={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,y),console.log(`[Engine] State updated for ${u}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((m,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):u&&this.layerStates.forEach((m,y)=>{y.startsWith(`global_${u}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,m=this.activeStateMachine.layers.find(y=>y.states.some(v=>v.id===u||v.name===u));m&&(console.log(`[Engine] Switching Layer ${m.name} to State ${u}`),this.enterStates(m.name,[u]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(u=>{const m=u.eventType.toLowerCase();let y=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):y});if(l&&l.entryAnimationId){console.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const u=(d=(f=this.artboard)==null?void 0:f.animations)==null?void 0:d.find(m=>m.id===l.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,u.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(h=>{if(h.type==="literal")n[h.key]=h.value;else if(h.type==="variable"){const c=this.inputs.get(h.value);n[h.key]=c!==void 0?c:""}}),console.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const h=window;typeof h.gtag=="function"?(h.gtag("event",i,n),console.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",i,n),console.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(i,n),console.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(f=>f.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,l=s.y*e.scaleY,h=e.x+(r*n-l*a),c=e.y+(r*a+l*n);return{x:h,y:c,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var b,C;if(!this.objectStates.get(t.id))return!1;const i=((b=t.geometry)==null?void 0:b.width)??t.width??100,n=((C=t.geometry)==null?void 0:C.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),c=Math.cos(h),g=Math.sin(h),f=r*c-l*g,d=r*g+l*c,u=a.scaleX,m=a.scaleY,y=i*Math.abs(u),v=n*Math.abs(m);return Math.abs(f)<=y/2&&Math.abs(d)<=v/2}updateSliderValueFromPointer(t,s,o){var w;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((w=t.geometry)==null?void 0:w.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),c=Math.cos(h),g=Math.sin(h),f=r*c-l*g,d=i.thumbWidth??16,u=n-d;let y=(f+u/2)/u;y=Math.max(0,Math.min(1,y));const v=i.min??0,b=i.max??100,C=i.step||1;let S=v+y*(b-v);C>0&&(S=Math.round(S/C)*C),S=Math.max(v,Math.min(b,S));const I=e.options||{};I.value!==S&&(e.options={...I,value:S},t.inputId&&this.setInternalInput(t.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:S}))}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var c,g,f;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(c=this.artboard)==null?void 0:c.objects.find(d=>d.id===i),a=((g=n==null?void 0:n.physics)==null?void 0:g.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(i);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const h=this.interpolate(e.keyframes,s);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||i,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${u} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let u=l;for(let m=0;m<d.length-1;m++){if(typeof u[d[m]]!="object"||u[d[m]]===null){let y=n;for(let v=0;v<=m;v++)y=y?y[d[v]]:null;if(d[m]==="corner_radius"||d[m]==="cornerRadius"){const v=typeof u[d[m]]=="number"?u[d[m]]:typeof y=="number"?y:0;u[d[m]]={tl:v,tr:v,bl:v,br:v}}else u[d[m]]=y?JSON.parse(JSON.stringify(y)):{}}u=u[d[m]]}u[d[d.length-1]]=h,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(u.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=h):r==="stroke"?(l.style||(l.style={}),l.style.stroke=h):l[r]=h;if(this.physicsEngine&&((f=n==null?void 0:n.physics)!=null&&f.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(i,h*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const i=e.time-o.time;let n=(s-o.time)/i;if(o.easing&&(n=si(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const l=e.value[r];return typeof a=="number"&&typeof l=="number"?a+(l-a)*n:n<.5?a:l}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(l=>{const h=o.value[l],c=e.value[l];typeof h=="number"&&typeof c=="number"?a[l]=h+(c-h)*n:h===void 0?a[l]=c:c===void 0?a[l]=h:a[l]=n<.5?h:c}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,s,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},i=e[t]||t,n=e[s]||s,a=m=>{if(!m)return{r:0,g:0,b:0};const y=m.startsWith("#")?m.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)}},r=a(i),l=a(n),h=Math.round(r.r+(l.r-r.r)*o),c=Math.round(r.g+(l.g-r.g)*o),g=Math.round(r.b+(l.b-r.b)*o),f=m=>{const y=Math.max(0,Math.min(255,m)).toString(16);return y.length===1?"0"+y:y};return`#${f(h)}${f(c)}${f(g)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var h;this.debug_objectsTotal=((h=this.artboard)==null?void 0:h.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),t.translate(i/2,n/2),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(-i/2,-n/2,i,n)),this.artboard.backgroundImage){const c=this.artboard.backgroundImage;let g=this.imageCache.get(c);if(g||(g=new Image,g.src=c,this.imageCache.set(c,g)),g.complete&&g.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const f=g.naturalWidth/g.naturalHeight,d=i/n;let u,m,y,v;d>f?(u=i,m=i/f):(m=n,u=n*f),y=-u/2,v=-m/2,t.drawImage(g,y,v,u,m),t.restore()}}t.beginPath(),t.rect(-i/2,-n/2,i,n),t.clip();const r=new Map;this.artboard.objects.forEach(c=>r.set(c.id,c)),this.artboard.objects.filter(c=>!c.parentId).map((c,g)=>{const f=this.objectStates.get(c.id),d=(f==null?void 0:f.zIndex)??g;return{obj:c,zIndex:d}}).sort((c,g)=>c.zIndex-g.zIndex).forEach(({obj:c})=>{this.renderObject(t,c,r)}),this._emitterPools.forEach((c,g)=>{if(!(c.length===0||!r.get(g)))for(const d of c)t.save(),t.globalAlpha=d.opacity,t.fillStyle=d.color,t.beginPath(),t.arc(d.x,d.y,Math.max(1,d.size*d.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&console.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),c=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+n)*h,f=(i/2+n)*c;return r+g>=0&&r-g<=this.canvasWidth&&l+f>=0&&l-f<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,l=1;const h=o/e,c=t/s;switch(i){case"Contain":c>h?l=s/e:l=t/o,a=r=l;break;case"Cover":c>h?l=t/o:l=s/e,a=r=l;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":l=t/o,a=r=l;break;case"FitHeight":l=s/e,a=r=l;break;case"None":a=r=1;break;case"ScaleDown":l=Math.min(t/o,s/e),l>1&&(l=1),a=r=l;break;default:a=r=1;break}const g=o*a,f=e*r;let d=0,u=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-g:d=(t-g)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=s-f:u=(s-f)/2,{scaleX:a,scaleY:r,tx:d,ty:u}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o){var u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x;const e=this.objectStates.get(s.id);if(!e){console.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(L,$,A,V,H)=>(this.drawRoundRect(t,L,$,A,V,H),t));const i=e.geometry?this.deepMerge(s.geometry,e.geometry):s.geometry,n=e.style?this.deepMerge(s.style,e.style):s.style;let a=(i==null?void 0:i.width)||((u=s.geometry)==null?void 0:u.width)||s.width||0,r=(i==null?void 0:i.height)||((m=s.geometry)==null?void 0:m.height)||s.height||0;if((a===0||r===0)&&(i!=null&&i.points)&&Array.isArray(i.points)&&i.points.length>0){let L=1/0,$=-1/0,A=1/0,V=-1/0;i.points.forEach(H=>{L=Math.min(L,H.x),$=Math.max($,H.x),A=Math.min(A,H.y),V=Math.max(V,H.y)}),a===0&&(a=$-L),r===0&&(r=V-A)}const l=L=>{if(L)return L.corner_radius??L.cornerRadius},h=l(e)??l(n)??l(i)??l(s.style)??l(s.geometry)??0,c={...i,width:a,height:r};if(delete c.cornerRadius,c.corner_radius=h,e.visible===!1)return;const g=s.repeaterConfig,f=g&&g.isEnabled&&g.count>1,d=f?g.count:1;for(let L=0;L<d;L++){let $=e.x,A=e.y,V=e.rotation,H=e.scale_x??1,et=e.scale_y??1;if(f&&L>0){if(g.type==="Linear"){const J=g.offsetX||0,ft=g.offsetY||0,U=g.rotation||0,G=g.scale!==void 0?g.scale:1;$+=L*J,A+=L*ft,V+=L*U,H*=Math.pow(G,L),et*=Math.pow(G,L)}else if(g.type==="Grid"){const J=g.cols||Math.ceil(Math.sqrt(g.count)),ft=g.gapX||0,U=g.gapY||0,G=Math.floor(L/J),K=L%J,Z=a+ft,Ot=r+U;$+=K*Z,A+=G*Ot}else if(g.type==="Radial"){const J=g.radius||100,ft=g.startAngle||0,G=(g.endAngle||360)-ft,K=g.count>1?G/(G===360?g.count:g.count-1):0,Z=ft+L*K,Ot=Z*Math.PI/180;$=e.x+J*Math.cos(Ot),A=e.y+J*Math.sin(Ot),V+=Z}}const P=s.type==="Group"||s.type==="Frame"||s.type==="Component",F=a>0&&r>0;if(!P&&F){const J=(((y=n.shadow)==null?void 0:y.isEnabled)!==!1?(((v=n.shadow)==null?void 0:v.blur)||0)+10:0)+(((b=n.blur)==null?void 0:b.isEnabled)!==!1&&((C=n.blur)==null?void 0:C.radius)||0)+20;if(!this.isObjectInView(t,$,A,a,r,J))continue}this.debug_objectsRendered++,t.save();const q=[],Q=n.blur||((S=s.style)==null?void 0:S.blur);Q&&Q.amount>0&&q.push(`blur(${Q.amount}px)`);const it=n.effect||((I=s.style)==null?void 0:I.effect),dt=(it==null?void 0:it.isEnabled)===!0,St=it==null?void 0:it.type,ht=(it==null?void 0:it.radius)??10;dt&&St==="LayerBlur"&&q.push(`blur(${ht}px)`);const mt=((w=i==null?void 0:i.type)==null?void 0:w.toLowerCase().includes("image"))||((k=s.type)==null?void 0:k.toLowerCase().includes("image")),rt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Rt=i!=null&&i.adjustments&&Object.keys(i.adjustments).length>0?i.adjustments:null,Yt=mt?Rt||rt:rt||Rt,Pt=mt&&!Yt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:Yt;if(e&&Pt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...Pt}),Pt){const J=(Pt.exposure||0)/100,ft=Pt.contrast||0,U=1+(Pt.saturation||0)/100,G=(Pt.temperature||0)/200,K=(Pt.tint||0)/200,Z=(Pt.highlights||0)/500,Ot=(Pt.shadows||0)/500;let At="",kt="SourceGraphic";if(J!==0&&(At+=`
|
|
1
|
+
(function(Ht,Zt){typeof exports=="object"&&typeof module<"u"?Zt(exports,require("react/jsx-runtime"),require("react"),require("@chenglou/pretext"),require("@dimforge/rapier2d-compat"),require("lz-string")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@chenglou/pretext","@dimforge/rapier2d-compat","lz-string"],Zt):(Ht=typeof globalThis<"u"?globalThis:Ht||self,Zt(Ht.ExodeUIReact={},Ht.jsxRuntime,Ht.React,Ht.pretext,Ht.Rapier,Ht.LZString))})(this,function(Ht,Zt,$t,xe,le,ys){"use strict";var li=Object.defineProperty;var ci=(Ht,Zt,$t)=>Zt in Ht?li(Ht,Zt,{enumerable:!0,configurable:!0,writable:!0,value:$t}):Ht[Zt]=$t;var tt=(Ht,Zt,$t)=>ci(Ht,typeof Zt!="symbol"?Zt+"":Zt,$t);function bs(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>u[s]})}}return t.default=u,Object.freeze(t)}const vs=bs(ys);var Y=(u=>(u.Proximity="Proximity",u.Magnetic="Magnetic",u.Repel="Repel",u.Orbit="Orbit",u.Vortex="Vortex",u.Fluid="Fluid",u.Elastic="Elastic",u.Holographic="Holographic",u.Sticky="Sticky",u.Dilation="Dilation",u.Parallax="Parallax",u.Noise="Noise",u.Float="Float",u.Pulse="Pulse",u.Draggable="Draggable",u.Scroll="Scroll",u.LookAt="LookAt",u.Glint="Glint",u.Scan="Scan",u.Ratchet="Ratchet",u.Jitter="Jitter",u.Follower="Follower",u.Wrap="Wrap",u.Typewriter="Typewriter",u.Scramble="Scramble",u.Wave="Wave",u.Bounce="Bounce",u.TextTrail="TextTrail",u.Reveal3D="Reveal3D",u.RevealSlide="RevealSlide",u.RevealBlur="RevealBlur",u.TextLiquid="TextLiquid",u.TextVortex="TextVortex",u.TextExplosion="TextExplosion",u.TextRain="TextRain",u.TextGravity="TextGravity",u.TextMatrix="TextMatrix",u.TextNeon="TextNeon",u.TextDissolve="TextDissolve",u.TextOrganic="TextOrganic",u.TextBreathe="TextBreathe",u.TextSpin="TextSpin",u.TextMagnet="TextMagnet",u.TextPerspective="TextPerspective",u.TextMirror="TextMirror",u.TextFloral="TextFloral",u.TextSmoke="TextSmoke",u.TextVariable="TextVariable",u.TextZing="TextZing",u.TextElastic="TextElastic",u.TextGlitch3D="TextGlitch3D",u.GlitchText="GlitchText",u.TextCounter="TextCounter",u.Squash="Squash",u.Spotlight="Spotlight",u.Lens="Lens",u.Gravity="Gravity",u.Velocity="Velocity",u.Shear="Shear",u.LayoutAnimation="LayoutAnimation",u.SpringChain="SpringChain",u.ParticleEmitter="ParticleEmitter",u.StateReactive="StateReactive",u.Fold="Fold",u.Crumple="Crumple",u))(Y||{}),jt=(u=>(u.Scale="Scale",u.Opacity="Opacity",u.RotateZ="RotateZ",u.RotateX="RotateX",u.RotateY="RotateY",u.PositionX="PositionX",u.PositionY="PositionY",u.SkewX="SkewX",u.Blur="Blur",u.Exposure="Exposure",u.HueShift="HueShift",u.Negative="Negative",u.CornerRadius="CornerRadius",u.StrokeWidth="StrokeWidth",u.BoxShadow="BoxShadow",u.FontSize="FontSize",u.LetterSpacing="LetterSpacing",u))(jt||{}),Xe=(u=>(u.Equal="Equal",u.NotEqual="NotEqual",u.GreaterThan="GreaterThan",u.LessThan="LessThan",u.GreaterEqual="GreaterEqual",u.LessEqual="LessEqual",u.IsTrue="IsTrue",u.IsFalse="IsFalse",u))(Xe||{}),yt=(u=>(u.AND="AND",u.OR="OR",u.NOT="NOT",u.XOR="XOR",u.OBJECT="OBJECT",u.PROPERTY="PROPERTY",u.GET_PROPERTY="GET_PROPERTY",u.SET_PROPERTY="SET_PROPERTY",u.ADD="ADD",u.SUB="SUB",u.MUL="MUL",u.DIV="DIV",u.MOD="MOD",u.POW="POW",u.ABS="ABS",u.ROUND="ROUND",u.FLOOR="FLOOR",u.CEIL="CEIL",u.SIN="SIN",u.COS="COS",u.TAN="TAN",u.CLAMP="CLAMP",u.REMAP="REMAP",u.EQ="EQ",u.NEQ="NEQ",u.GT="GT",u.LT="LT",u.GTE="GTE",u.LTE="LTE",u.IF_ELSE="IF_ELSE",u.VALUE="VALUE",u.INPUT="INPUT",u.LOG="LOG",u.SCROLL_X="SCROLL_X",u.SCROLL_Y="SCROLL_Y",u.MOUSE_X="MOUSE_X",u.MOUSE_Y="MOUSE_Y",u.IS_MOUSE_DOWN="IS_MOUSE_DOWN",u.EFFECTOR="EFFECTOR",u.MONITOR="MONITOR",u.DELAY="DELAY",u.SPRING_PULL="SPRING_PULL",u.SPRING_SETTLE="SPRING_SETTLE",u.EMIT="EMIT",u))(yt||{});function Cs(u){if(u.length<5)return u;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(u))return u;let o="";for(let e=0;e<u.length;e++){if(o+=u[e],e>=u.length-2)continue;const i=t.has(u[e]),n=t.has(u[e+1]),a=t.has(u[e+2]);i&&!n&&a&&(o+=""),i&&!n&&!a&&e>=1&&(o+="")}return o}function Ss(u){return u.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>Cs(s))}function Is(u,t,s){return u}function ws(u,t,s){return u}const ke=new Map;function De(u){var M;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:i="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:f=0,textCase:c="none",segments:g=[],enableSegments:h=!1}=u;let d=String(t||"");c==="uppercase"?d=d.toUpperCase():c==="lowercase"?d=d.toLowerCase():c==="capitalize"&&(d=d.replace(/\b\w/g,P=>P.toUpperCase())),u.hyphenation===!0&&(d=Ss(d));const p=`${i} ${e} ${o}px "${s}", sans-serif`,m=`${d}|${p}|${r}|${l}|${f}|${h}|${JSON.stringify(g)}|hyp:${!!u.hyphenation}|comp:${u.composer}|bal:${!!u.balanceRaggedLines}`;let y=ke.get(m);const v=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,b=function(P){if(!v)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=v.call(this,P);return r!==0&&P&&P.length>0?{...T,width:T.width+(P.length-1)*r}:T};if(!y){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=b),h&&g&&g.length>0){const P=g.map(T=>{let W=T.text||"";const k=T.textCase||c||"none";return k==="uppercase"?W.toUpperCase():k==="lowercase"?W.toLowerCase():k==="capitalize"?W.replace(/\b\w/g,_=>_.toUpperCase()):W}).join("");if(y=xe.prepareWithSegments(P,p),y){let T=0,W=o;for(const k of g){let _=k.text||"";if(!_)continue;const R=k.textCase||c||"none";R==="uppercase"?_=_.toUpperCase():R==="lowercase"?_=_.toLowerCase():R==="capitalize"&&(_=_.replace(/\b\w/g,A=>A.toUpperCase()));const x=k.fontSize||o;x>W&&(W=x);const O=`${k.fontStyle||i} ${k.fontWeight||e} ${x}px "${k.fontFamily||s}", sans-serif`,$=xe.prepareWithSegments(_,O);if($&&$.widths)for(let A=0;A<$.widths.length;A++){const V=T+A;if(V<y.widths.length){y.widths[V]=$.widths[A];const H=$.kinds[A];if(H===2){const et=_[A];et===`
|
|
2
|
+
`||et==="\r"?y.kinds[V]=2:y.kinds[V]=0}else y.kinds[V]=H}}T+=_.length}y.fullText=P,y.maxFontSize=W}}else y=xe.prepareWithSegments(d,p);y&&ke.set(m,y)}catch(P){return console.error("[ExodeUI] Pretext prepare failed:",P),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&v&&(CanvasRenderingContext2D.prototype.measureText=v)}if(ke.size>500){const P=ke.keys().next().value;P&&ke.delete(P)}}if(f>0&&y&&y.widths&&!y.indentApplied){const P=[...y.widths],T=y.fullText||d;let W=!0;for(let k=0;k<T.length;k++)W&&P[k]!==void 0&&(P[k]+=f,W=!1),(T[k]===`
|
|
3
|
+
`||T[k]==="\r")&&(W=!0,T[k]==="\r"&&T[k+1]===`
|
|
4
|
+
`&&k++);y={...y,widths:P,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let C=n;typeof C=="string"&&(C=parseFloat(C)),C>5&&o>0&&(C=C/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=b);let S;try{const P=y.maxFontSize||o;if(a>=1e5){const T=d.split(/\r\n|\r|\n/);S={lines:T.map(W=>({text:W,width:0})),height:T.length*(C*P),lineCount:T.length}}else S=xe.layoutWithLines(y,a,C*P)}finally{r!==0&&v&&(CanvasRenderingContext2D.prototype.measureText=v)}let I=(S==null?void 0:S.height)!==void 0&&S.height>0?S.height:(((M=S==null?void 0:S.lines)==null?void 0:M.length)||0)*C*o;if(l>0&&S&&S.lines&&S.lines.length>1){let P=0;const T=y.fullText||t;for(let W=0;W<S.lines.length-1;W++)P+=S.lines[W].text.length,(T[P]===`
|
|
5
|
+
`||T[P]==="\r")&&(I+=l,P++,T[P-1]==="\r"&&T[P]===`
|
|
6
|
+
`&&P++)}let w=(S==null?void 0:S.lines)||[];return u.composer==="every-line"&&w.length>1&&(w=Is(w)),u.balanceRaggedLines===!0&&w.length>1&&(w=ws(w)),{width:a,height:I,lineCount:w.length,lines:w}}function ze(u,t,s){let o=String(u||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const f=parseFloat(r);i[l]=f,n-=f}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[l]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((l,f)=>{l.endsWith("fr")&&(i[f]=r*parseFloat(l))})}return i}function Ve(u,t,s){try{const o=u.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?ks(u,t,s):Ms(u,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Ms(u,t,s){var _,R;const o=u.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,l=e==="vertical",f=t.map(x=>{const O=s(x.id),$=x.geometry;let A=(O==null?void 0:O.width)??$.width??100,V=(O==null?void 0:O.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const H=(O==null?void 0:O.radius)??$.radius??(O==null?void 0:O.outer_radius)??$.outer_radius??50;A=H*2,V=H*2}else if($.type==="Text"){const H=De({text:(O==null?void 0:O.text)??$.text??"",fontFamily:$.fontFamily,fontSize:$.fontSize,fontWeight:$.fontWeight,fontStyle:$.fontStyle,lineHeight:$.lineHeight,width:$.width||200,letterSpacing:$.letterSpacing,paragraphSpacing:$.paragraphSpacing,paragraphIndent:$.paragraphIndent,textCase:$.textCase,segments:$.segments,enableSegments:$.enableSegments});V=H.height,$.width||(A=H.width)}return A*=x.transform.scale_x||1,V*=x.transform.scale_y||1,{id:x.id,w:A,h:V,original:x}});let c=u.width,g=u.height;const h=((_=u.layoutProps)==null?void 0:_.width)==="hug",d=((R=u.layoutProps)==null?void 0:R.height)==="hug",p=[];let m=[],y=0,v=0;const b=c-n.left-n.right,C=g-n.top-n.bottom;f.forEach(x=>{r&&m.length>0&&(l?v+i+x.h>C:y+i+x.w>b)?(p.push({children:m,width:y,height:v}),m=[x],y=x.w,v=x.h):(m.push(x),l?(y=Math.max(y,x.w),v+=(m.length>1?i:0)+x.h):(y+=(m.length>1?i:0)+x.w,v=Math.max(v,x.h)))}),m.length>0&&p.push({children:m,width:y,height:v}),h&&!l&&(c=Math.max(...p.map(x=>x.width),0)+n.left+n.right),d&&l&&(g=Math.max(...p.map(x=>x.height),0)+n.top+n.bottom);const S=[];let I=n.left,w=n.top;const M=a.toLowerCase(),P=M==="center"||M.endsWith("-center"),T=M.endsWith("-right"),W=M==="center"||M.startsWith("center-"),k=M.startsWith("bottom-");return p.forEach(x=>{let O=I,$=w;l?W?$=n.top+(g-n.top-n.bottom-x.height)/2:k&&($=g-n.bottom-x.height):P?O=n.left+(c-n.left-n.right-x.width)/2:T&&(O=c-n.right-x.width),x.children.forEach(A=>{var F,q;let V=O,H=$;l?P?V+=(x.width-A.w)/2:T&&(V+=x.width-A.w):W?H+=(x.height-A.h)/2:k&&(H+=x.height-A.h);const et=((F=A.original.layoutProps)==null?void 0:F.width)==="fill",E=((q=A.original.layoutProps)==null?void 0:q.height)==="fill";S.push({id:A.id,x:V+A.w/2-c/2,y:H+A.h/2-g/2,width:et&&l?x.width:void 0,height:E?l?void 0:x.height:void 0}),l?$+=A.h+i:O+=A.w+i}),l?I+=x.width+i:w+=x.height+i}),{frameWidth:h?c:void 0,frameHeight:d?g:void 0,childUpdates:S}}function ks(u,t,s){const o=u.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:l}=o;let f=u.width,c=u.height;const g=f-r.left-r.right,h=c-r.top-r.bottom,d=ze(e||"1fr",g,n),p=ze(i||"auto",h,a),m=d.length>0?d.reduce((T,W)=>T+W,0)+(d.length-1)*n:0,y=p.length>0?p.reduce((T,W)=>T+W,0)+(p.length-1)*a:0,v=l.toLowerCase(),b=v==="center"||v.endsWith("-center"),C=v.endsWith("-right"),S=v==="center"||v.startsWith("center-"),I=v.startsWith("bottom-");let w=0,M=0;b?w=(g-m)/2:C&&(w=g-m),S?M=(h-y)/2:I&&(M=h-y);const P=[];return t.forEach((T,W)=>{var q,Q;const k=W%d.length||0,_=Math.floor(W/d.length)||0;_>=p.length&&p.push(100);const R=d[k],x=p[_];let O=r.left+w+d.slice(0,k).reduce((it,dt)=>it+dt+n,0),$=r.top+M+p.slice(0,_).reduce((it,dt)=>it+dt+a,0);const A=s(T.id),V=T.geometry;let H=(A==null?void 0:A.width)??V.width??100,et=(A==null?void 0:A.height)??V.height??100;if(V.type==="Ellipse"||V.type==="Polygon"||V.type==="Star"){const it=(A==null?void 0:A.radius)??V.radius??(A==null?void 0:A.outer_radius)??V.outer_radius??50;H=it*2,et=it*2}H*=T.transform.scale_x||1,et*=T.transform.scale_y||1;let E=O,F=$;b?E+=(R-H)/2:C&&(E+=R-H),S?F+=(x-et)/2:I&&(F+=x-et),P.push({id:T.id,x:E+H/2-f/2,y:F+et/2-c/2,width:((q=T.layoutProps)==null?void 0:q.width)==="fill"?R:void 0,height:((Q=T.layoutProps)==null?void 0:Q.height)==="fill"?x:void 0})}),{childUpdates:P}}class Ts{constructor(){tt(this,"world",null);tt(this,"bodies",new Map);tt(this,"colliders",new Map);tt(this,"initialized",!1)}async init(t){this.initialized||(await le.init(),this.world=new le.World(new le.Vector2(t.x,t.y)),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?le.RigidBodyDesc.fixed():le.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=le.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=le.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}removeBody(t){const s=this.bodies.get(t);s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){this.world&&this.world.step()}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new le.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new le.Vector2(s,o),!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new le.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new le.Vector2(s,o),!0)}}const Ne=u=>u,_s=u=>u>0?1:0,Ps=u=>u<1?0:1,He=u=>u*u,Ue=u=>u*(2-u),qe=u=>u<.5?2*u*u:-1+(4-2*u)*u,Es=u=>u*u*u,xs=u=>--u*u*u+1,Os=u=>u<.5?4*u*u*u:(u-1)*(2*u-2)*(2*u-2)+1,As=u=>u*u*u*u,Ls=u=>1- --u*u*u*u,Rs=u=>u<.5?8*u*u*u*u:1-8*--u*u*u*u,Fs=u=>u*u*u*u*u,$s=u=>1+--u*u*u*u*u,Ws=u=>u<.5?16*u*u*u*u*u:1+16*--u*u*u*u*u,Bs=u=>1-Math.cos(u*Math.PI/2),Gs=u=>Math.sin(u*Math.PI/2),Ys=u=>-(Math.cos(Math.PI*u)-1)/2,Xs=u=>u===0?0:Math.pow(2,10*(u-1)),Ds=u=>u===1?1:1-Math.pow(2,-10*u),zs=u=>u===0?0:u===1?1:u<.5?Math.pow(2,20*u-10)/2:(2-Math.pow(2,-20*u+10))/2,Vs=u=>1-Math.sqrt(1-u*u),Ns=u=>Math.sqrt(1- --u*u),Hs=u=>u<.5?(1-Math.sqrt(1-4*u*u))/2:(Math.sqrt(1-(-2*u+2)*(-2*u+2))+1)/2,Oe=1.70158,Ae=Oe*1.525,Je=Oe+1,Us=u=>Je*u*u*u-Oe*u*u,qs=u=>1+Je*Math.pow(u-1,3)+Oe*Math.pow(u-1,2),Js=u=>u<.5?Math.pow(2*u,2)*((Ae+1)*2*u-Ae)/2:(Math.pow(2*u-2,2)*((Ae+1)*(u*2-2)+Ae)+2)/2,Qe=2*Math.PI/3,Ke=2*Math.PI/4.5,Qs=u=>u===0?0:u===1?1:-Math.pow(2,10*u-10)*Math.sin((u*10-10.75)*Qe),Ks=u=>u===0?0:u===1?1:Math.pow(2,-10*u)*Math.sin((u*10-.75)*Qe)+1,Zs=u=>u===0?0:u===1?1:u<.5?-(Math.pow(2,20*u-10)*Math.sin((20*u-11.125)*Ke))/2:Math.pow(2,-20*u+10)*Math.sin((20*u-11.125)*Ke)/2+1,Le=u=>u<1/2.75?7.5625*u*u:u<2/2.75?7.5625*(u-=1.5/2.75)*u+.75:u<2.5/2.75?7.5625*(u-=2.25/2.75)*u+.9375:7.5625*(u-=2.625/2.75)*u+.984375,js=u=>1-Le(1-u),ti=Le,ei=u=>u<.5?(1-Le(1-2*u))/2:(1+Le(2*u-1))/2,Ye=new Map,Te=(u,t,s,o)=>{const e=`${u},${t},${s},${o}`;if(Ye.has(e))return Ye.get(e);const i=f=>(1-3*s+3*u)*f*f*f+(3*s-6*u)*f*f+3*u*f,n=f=>(1-3*o+3*t)*f*f*f+(3*o-6*t)*f*f+3*t*f,a=f=>3*(1-3*s+3*u)*f*f+2*(3*s-6*u)*f+3*u,r=f=>{let c=f;for(let g=0;g<8;g++){const h=i(c)-f;if(Math.abs(h)<1e-6)return c;const d=a(c);if(Math.abs(d)<1e-6)break;c=c-h/d}return c},l=f=>f===0?0:f===1?1:n(r(f));return Ye.set(e,l),l},Ze=u=>{const t=u.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return Te(s,o,e,i)},je={ease:Te(.25,.1,.25,1),"ease-in":Te(.42,0,1,1),"ease-out":Te(0,0,.58,1),"ease-in-out":Te(.42,0,.58,1)},Re={Linear:Ne,EaseInQuad:He,EaseOutQuad:Ue,EaseInOutQuad:qe,EaseInCubic:Es,EaseOutCubic:xs,EaseInOutCubic:Os,EaseInQuart:As,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Ws,EaseInSine:Bs,EaseOutSine:Gs,EaseInOutSine:Ys,EaseInExpo:Xs,EaseOutExpo:Ds,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Js,EaseInElastic:Qs,EaseOutElastic:Ks,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:He,EaseOut:Ue,EaseInOut:qe,StepStart:_s,StepEnd:Ps},si=u=>{const t=u.trim(),s=t.toLowerCase();if(Re[t])return Re[t];const o=Object.keys(Re).find(i=>i.toLowerCase()===s);if(o)return Re[o];const e=Object.keys(ts).find(i=>i.toLowerCase()===s);if(e){const i=Ze(ts[e].value);if(i)return i}if(je[s])return je[s];if(s.startsWith("cubic-bezier")){const i=Ze(t);if(i)return i}return Ne},ts={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)"}},ii=(u,t,s,o,e)=>{if(!u||!t||!s)return u;const i=o.scale_x??1,n=o.scale_y??1,a=(r,l,f)=>{let c=0,g=0;const h=o.rotation*Math.PI/180,d=Math.cos(h),p=Math.sin(h),m=r*i*d-l*n*p+o.x,y=r*i*p+l*n*d+o.y;f.forEach(w=>{const M=e(w.boneId);if(!M)return;const P={x:M.x,y:M.y,rotation:M.rotation,scaleX:M.scale_x??1,scaleY:M.scale_y??1},T=s[w.boneId]||[1,0,0,1,0,0],W=m*T[0]+y*T[2]+T[4],k=m*T[1]+y*T[3]+T[5],_=P.rotation*Math.PI/180,R=Math.cos(_),x=Math.sin(_),O=W*P.scaleX*R-k*P.scaleY*x+P.x,$=W*P.scaleX*x+k*P.scaleY*R+P.y;c+=O*w.amount,g+=$*w.amount});const v=o.rotation*Math.PI/180,b=Math.cos(v),C=Math.sin(v),S=c-o.x,I=g-o.y;return{x:(S*b+I*C)/i,y:(-S*C+I*b)/n}};return u.map((r,l)=>{const f=t[l];if(!f||f.length===0)return{...r};const c={...r,...a(r.x,r.y,f)};if(r.in_x!==void 0&&r.in_y!==void 0){const g=a(r.in_x,r.in_y,f);c.in_x=g.x,c.in_y=g.y}if(r.out_x!==void 0&&r.out_y!==void 0){const g=a(r.out_x,r.out_y,f);c.out_x=g.x,c.out_y=g.y}return c})},es={default:{label:"Default",colors:["#6366f1","#f59e0b"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",gridColor:"rgba(255,255,255,0.06)",axisLabelColor:"rgba(255,255,255,0.5)",legendColor:"rgba(255,255,255,0.7)",barGradient:!0},neon:{label:"Neon",colors:["#00f5ff","#ff00e5"],cardBackground:"rgba(0,0,0,0.5)",cardBorderColor:"rgba(0,245,255,0.2)",gridColor:"rgba(0,245,255,0.08)",axisLabelColor:"rgba(0,245,255,0.6)",legendColor:"rgba(0,245,255,0.8)",barGradient:!0},pastel:{label:"Pastel",colors:["#a5b4fc","#fcd34d"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",gridColor:"rgba(255,255,255,0.08)",axisLabelColor:"rgba(255,255,255,0.45)",legendColor:"rgba(255,255,255,0.65)",barGradient:!1},warm:{label:"Warm",colors:["#f97316","#ef4444"],cardBackground:"rgba(30,10,0,0.4)",cardBorderColor:"rgba(249,115,22,0.2)",gridColor:"rgba(249,115,22,0.08)",axisLabelColor:"rgba(253,186,116,0.7)",legendColor:"rgba(253,186,116,0.85)",barGradient:!0},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",gridColor:"rgba(6,182,212,0.06)",axisLabelColor:"rgba(125,211,252,0.6)",legendColor:"rgba(125,211,252,0.8)",barGradient:!0},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.4)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",gridColor:"rgba(255,255,255,0.05)",axisLabelColor:"rgba(255,255,255,0.4)",legendColor:"rgba(255,255,255,0.6)",barGradient:!1}},ss={default:{label:"Default",colors:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",legendColor:"rgba(255,255,255,0.65)",labelColor:"#ffffff",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"},neon:{label:"Neon",colors:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff"],cardBackground:"rgba(0,0,0,0.55)",cardBorderColor:"rgba(0,245,255,0.2)",legendColor:"rgba(0,245,255,0.75)",labelColor:"#ffffff",centerTextColor:"#00f5ff",centerLabelColor:"rgba(0,245,255,0.5)"},pastel:{label:"Pastel",colors:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",legendColor:"rgba(255,255,255,0.6)",labelColor:"#1a1a2e",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.45)"},warm:{label:"Warm",colors:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c"],cardBackground:"rgba(30,10,0,0.45)",cardBorderColor:"rgba(249,115,22,0.2)",legendColor:"rgba(253,186,116,0.8)",labelColor:"#ffffff",centerTextColor:"#fb923c",centerLabelColor:"rgba(253,186,116,0.5)"},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",legendColor:"rgba(125,211,252,0.75)",labelColor:"#ffffff",centerTextColor:"#38bdf8",centerLabelColor:"rgba(125,211,252,0.5)"},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.65)","rgba(255,255,255,0.45)","rgba(255,255,255,0.28)","rgba(255,255,255,0.15)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",legendColor:"rgba(255,255,255,0.55)",labelColor:"#000000",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"}};class is{constructor(){tt(this,"artboard",null);tt(this,"objectStates",new Map);tt(this,"physicsEngine",null);tt(this,"activeStateMachine",null);tt(this,"inputs",new Map);tt(this,"inputNameMap",new Map);tt(this,"layerStates",new Map);tt(this,"pretextCache",new Map);tt(this,"pointerHistory",[]);tt(this,"MAX_HISTORY",200);tt(this,"imageCache",new Map);tt(this,"lastValidSvgImgMap",new Map);tt(this,"maskBuffer",null);tt(this,"maskCtx",null);tt(this,"lumaBuffer",null);tt(this,"lumaCtx",null);tt(this,"_noiseTileCanvas",null);tt(this,"layout",{fit:"Contain",alignment:"Center"});tt(this,"onTrigger");tt(this,"onInputUpdate");tt(this,"onComponentChange");tt(this,"onToggle");tt(this,"onInputChange");tt(this,"onInputFocus");tt(this,"onInputBlur");tt(this,"onLog");tt(this,"onButtonClick");tt(this,"onGraphPointClick");tt(this,"justFiredTriggers",new Set);tt(this,"rootTransform",null);tt(this,"canvasWidth",0);tt(this,"canvasHeight",0);tt(this,"lastHoveredObjectId",null);tt(this,"_lastPointerPos",null);tt(this,"_prevPointerPos",null);tt(this,"focusedId",null);tt(this,"draggingSliderId",null);tt(this,"activeDropdownId",null);tt(this,"activeObjectId",null);tt(this,"draggingListViewId",null);tt(this,"scrollOffset",{x:0,y:0});tt(this,"_totalScroll",{x:0,y:0});tt(this,"draggingBehaviors",new Set);tt(this,"isMouseDown",!1);tt(this,"_layoutAnimCache",new Map);tt(this,"_springChainState",new Map);tt(this,"_emitterPools",new Map);tt(this,"objectVelocities",new Map);tt(this,"currentTime",0);tt(this,"frameCount",0);tt(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4,Lato:.35,"Bebas Neue":.45,Oswald:.4});tt(this,"onLogicUpdate");tt(this,"logicNodeValues",new Map);tt(this,"logicNodeState",new Map);tt(this,"pointerDownTimes",new Map);tt(this,"activeHoverIds",new Set);tt(this,"onNavigation");tt(this,"periodicTriggerTimes",new Map);tt(this,"wasInView",new Set);tt(this,"scrollProgressLastValue",new Map);tt(this,"debug_objectsRendered",0);tt(this,"debug_objectsTotal",0);tt(this,"lastRenderTime",0);tt(this,"debugMode",!1);tt(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,l=0,f=0,c=0,g;for(;(g=s.exec(t))!==null;){const h=g[1],d=(g[2].match(o)||[]).map(parseFloat),p=h===h.toLowerCase(),m=h.toUpperCase();let y=0;const v=C=>{let S=d[y++];return p&&(S+=C?n:a),S},b=()=>({x:v(!0),y:v(!1)});switch(m){case"M":{const C=b();for(f=n=C.x,c=a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<d.length;){const S=b();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<d.length;){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<d.length;)n=v(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<d.length;)a=v(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<d.length;){const C=b(),S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"S":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"Q":for(;y<d.length;){const C=b(),S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"T":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"Z":if(i=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const S=[...e].reverse().find(I=>I.moveTo)||e[0];S&&Math.hypot(S.x-C.x,S.y-C.y)<.1&&(S.in_x=C.in_x,S.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=f,a=c;break;default:if(d.length>=2){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const f={...l},c=f.childrenObjects||[];e.add(f.id),o.push(f),i(c)})};if(i(s.objects||[]),o.length>(s.objects||[]).length&&console.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),console.log(`[ExodeUIEngine] Loading artboard: "${(n=this.artboard)==null?void 0:n.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(l=>{r.set(l.id,l),l.children||(l.children=[])}),this.artboard.objects.forEach(l=>{if(l.parentId){const f=r.get(l.parentId);f&&(f.children||(f.children=[]),f.children.includes(l.id)||f.children.push(l.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{console.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=vs.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}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.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this._layoutAnimCache.clear(),this._springChainState.clear(),this._emitterPools.clear(),this.artboard.objects.forEach(s=>{var n,a,r,l,f,c,g;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((l=s.geometry)==null?void 0:l.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((f=s.transform)==null?void 0:f.x)??s.x??0,y:((c=s.transform)==null?void 0:c.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((g=s.transform)==null?void 0:g.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new Ts;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var i,n;if((i=e.physics)!=null&&i.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,l=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((n=e.geometry)==null?void 0:n.type)||"Rectangle",x:a.x,y:a.y,width:r,height:l,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var i;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(n=>s.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),f=Math.abs(r.y-a.y);!t&&(l>20||f>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((i=this.artboard.autoLayout)!=null&&i.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=Ve(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var a;if(n.type==="Frame"&&((a=n.autoLayout)!=null&&a.enabled)&&n.children&&n.children.length>0){const r=n.children.map(c=>s.get(c)).filter(c=>!!c),l=this.objectStates.get(n.id);if(!l)return;const f=Ve(l,r,c=>this.objectStates.get(c));f.frameWidth!==void 0&&(l.width=f.frameWidth),f.frameHeight!==void 0&&(l.height=f.frameHeight),e(f.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let s="";t.forEach(n=>{const a=n.replace(/ /g,"+");s+=`&family=${a}: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 o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let i=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const l=a.states.find(f=>f.id===r);if(l){let f=null;l.animationId&&(f=this.artboard.animations.find(c=>c.id===l.animationId)||null),f||(f=this.artboard.animations.find(c=>{var g,h;return c.name===l.name||c.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((g=c.name)==null?void 0:g.toLowerCase())==="onload"||((h=c.name)==null?void 0:h.toLowerCase())==="intro")})||null),f&&((n=this.artboard.animationFlow)!=null&&n.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(f==null?void 0:f.id))||(e.push({animation:f,state:l}),i=Math.max(i,f.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")){const i=s.split(".");let n=e;for(let a=0;a<i.length-1;a++)n[i[a]]||(n[i[a]]={}),n=n[i[a]];n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const l=(n=this.activeStateMachine)==null?void 0:n.inputs.find(f=>f.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const f=(a=this.activeStateMachine)==null?void 0:a.inputs.find(c=>c.id===l[0]);f&&typeof f.value=="object"&&(o=f.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(l=>this.setInternalInput(l,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(l=>{if(l.inputId===t||l.name===t){const f=this.objectStates.get(l.id);f&&f.options&&(l.type==="ListView"||l.variant==="listview"?f.options.items=e:(l.type==="Dropdown"||l.variant==="dropdown")&&(f.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.conditionValue;let l=!1;switch(a){case"Equal":case"==":l=s==r;break;case"NotEqual":case"!=":l=s!=r;break;case"GreaterThan":case">":l=s>r;break;case"LessThan":case"<":l=s<r;break;case"GreaterEqual":case">=":l=s>=r;break;case"LessEqual":case"<=":l=s<=r;break;case"IsTrue":l=!!s;break;case"IsFalse":l=!s;break}if(l){const f=i.delay||0;f<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),f)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return console.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,f,c,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(h=>h.id===t);if(e){const h=(p,m)=>{const y=e.inputs.find(v=>v.id===p);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:m:m};let d=0;switch(e.op){case yt.AND:d=h("a",!1)&&h("b",!1);break;case yt.OR:d=h("a",!1)||h("b",!1);break;case yt.NOT:d=!h("in",!1);break;case yt.XOR:d=!!h("a",!1)!=!!h("b",!1);break;case yt.OBJECT:d=e.name;break;case yt.PROPERTY:case yt.GET_PROPERTY:{const p=h("id","");if(!p){d=0;break}const m=e.name;if(!m||m==="GET_PROPERTY"||m==="PROPERTY"){d=0;break}const y=this.objectStates.get(p);if(!y){d=0;break}m in y?d=y[m]:d=this.resolvePath(y,m);break}case yt.SET_PROPERTY:{const p=h("id",""),m=h("value",void 0);if(!p||m===void 0){d=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){d=0;break}const v=this.objectStates.get(p);if(!v){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))v[y]=m,d=m;else{const C=y.split(".");let S=v;for(let w=0;w<C.length-1;w++){const M=C[w];S[M]===void 0&&(S[M]={}),S=S[M]}const I=C[C.length-1];S[I]=m,d=m}break}case yt.ADD:d=h("a",0)+h("b",0);break;case yt.SUB:d=h("a",0)-h("b",0);break;case yt.MUL:d=h("a",0)*h("b",0);break;case yt.DIV:{const p=h("b",1);d=p===0?0:h("a",0)/p;break}case yt.MOD:d=h("a",0)%h("b",1);break;case yt.POW:d=Math.pow(h("a",0),h("b",1));break;case yt.ABS:d=Math.abs(h("in",0));break;case yt.ROUND:d=Math.round(h("in",0));break;case yt.FLOOR:d=Math.floor(h("in",0));break;case yt.CEIL:d=Math.ceil(h("in",0));break;case yt.SIN:d=Math.sin(h("in",0));break;case yt.COS:d=Math.cos(h("in",0));break;case yt.TAN:d=Math.tan(h("in",0));break;case yt.CLAMP:{const p=h("in",0),m=h("min",0),y=h("max",1);d=Math.max(m,Math.min(y,p));break}case yt.REMAP:{const p=h("in",0),m=h("inMin",0),y=h("inMax",100),v=h("outMin",0),b=h("outMax",1);d=y===m?v:v+(p-m)*(b-v)/(y-m);break}case yt.EQ:d=h("a",0)==h("b",0);break;case yt.NEQ:d=h("a",0)!=h("b",0);break;case yt.GT:d=h("a",0)>h("b",0);break;case yt.LT:d=h("a",0)<h("b",0);break;case yt.GTE:d=h("a",0)>=h("b",0);break;case yt.LTE:d=h("a",0)<=h("b",0);break;case yt.IF_ELSE:d=h("cond",!1)?h("then",0):h("else",0);break;case yt.VALUE:d=e.value!==void 0?e.value:0;break;case yt.INPUT:d=this.inputs.get(e.name)??0;break;case yt.LOG:{const p=h("in","");this.debugLog(`[User Logic] ${p}`),d=p;break}case yt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case yt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case yt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case yt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case yt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case yt.EFFECTOR:{const p=h("id",""),m=h("intensity",1),y=h("trigger",!0);if(!p||!y){d=0;break}const v=e.name;if(!v){d=0;break}const b=this.objectStates.get(p);if(!b){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(v))b.style||(b.style={}),b.style.artEffect={enabled:!0,type:v,intensity:m},d=1;else{b.behaviors||(b.behaviors=[]);let S=b.behaviors.find(I=>I.type===v);S?(S.enabled=!0,S.settings||(S.settings={}),S.settings.intensity=m):(S={id:`eff_${Date.now()}_${v}`,type:v,enabled:!0,sensors:[],settings:{intensity:m}},b.behaviors.push(S)),d=1}break}case yt.MONITOR:{d=h("in",0);break}case yt.SPRING_PULL:{const p=h("objectId",""),m=h("forceX",0),y=h("forceY",0);p&&((l=this.artboard)==null||l.objects.forEach(v=>{v.behaviors&&v.behaviors.forEach(b=>{var C;if(b.type===Y.SpringChain&&((C=b.settings)!=null&&C.connections)&&(b.settings.connections.some(I=>I.targetId===p)||v.id===p)){this._springChainState.has(v.id)||this._springChainState.set(v.id,new Map);const I=this._springChainState.get(v.id);if(!I.has(p)){const M=this.objectStates.get(p);I.set(p,{x:(M==null?void 0:M.x)??0,y:(M==null?void 0:M.y)??0,vx:0,vy:0})}const w=I.get(p);w&&(w.vx+=m,w.vy+=y)}})})),d=1;break}case yt.SPRING_SETTLE:{const p=h("objectId","");let m=!0;if(p){const y=h("threshold",1);this._springChainState.forEach(v=>{const b=v.get(p);b&&(Math.abs(b.vx)>y||Math.abs(b.vy)>y)&&(m=!1)})}d=m;break}case yt.EMIT:{const p=h("objectId",""),m=h("count",20);p&&((f=this.artboard)==null||f.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(v=>{v.type===Y.ParticleEmitter&&y.id===p&&(v._pendingBurst=(v._pendingBurst||0)+m)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===yt.DELAY){const p=h("delay",0),m=h("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+p,value:m});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;d=y.lastValue??0}return d}const i=(c=this.activeStateMachine)==null?void 0:c.inputs.find(h=>h.id===t||h.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const h=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,h),h}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const h=(g=this.activeStateMachine)==null?void 0:g.inputs.find(d=>d.id===t);if(h&&h.value.type==="Number"&&typeof n=="number"){const d=h.value.defaultValue??h.value.value;if(s==="source-greater")return n>d;if(s==="source-less")return n<d;if(s==="source-equal")return n===d}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===yt.SET_PROPERTY||t.op===yt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(console.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{this.applyAnimation(i.animation,o.time,i.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var i,n,a,r,l,f,c;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(g=>g.id===e))==null?void 0:n.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(f=(l=(r=this.artboard)==null?void 0:r.objects.find(p=>p.id===e))==null?void 0:l.triggers)==null?void 0:f.find(p=>p.id===o.triggerId),h=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=h;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(g!=null&&g.exitAnimationId){const p=(c=this.artboard)==null?void 0:c.animations.find(m=>m.id===g.exitAnimationId);p?(o.phase="exit",o.animation=p,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t)}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,i,n;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),l=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),f=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),c=50,g=r.x+l/2>=-this.canvasWidth/2-c&&r.x-l/2<=this.canvasWidth/2+c&&r.y+f/2>=-this.canvasHeight/2-c&&r.y-f/2<=this.canvasHeight/2+c,h=`analytics_${s.id}`,d=this.wasInView.has(h);g&&!d&&this.fireAnalyticsEvent(s.id,"visible"),g?this.wasInView.add(h):this.wasInView.delete(h)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,l,f;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const c=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const c=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const c=this.objectStates.get(s.id);if(c&&c.visible!==!1){const g=this.getGlobalTransform(s.id),h=(((r=s.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),d=(((l=s.geometry)==null?void 0:l.height)||100)*(g.scale_y||1),p=50,m=g.x+h/2>=-this.canvasWidth/2-p&&g.x-h/2<=this.canvasWidth/2+p&&g.y+d/2>=-this.canvasHeight/2-p&&g.y-d/2<=this.canvasHeight/2+p,y=this.wasInView.has(s.id);m&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),m?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const c=Math.abs(this.scrollOffset.y)/(((f=this.artboard)==null?void 0:f.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(c-g)>.001&&(this.scrollProgressLastValue.set(e.id,c),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,c))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((i,n)=>{var f,c,g,h,d,p,m,y,v;const a=((f=o.constraints)==null?void 0:f[n])||{},r={...i,...a},l=r.strength??1;if(r.type==="Translation"){const b=this.getGlobalTransform(r.targetId);if(b){const C=r.offsetX||0,S=r.offsetY||0,I=b.x+C,w=b.y+S,M=r.useSpring;if(M){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:W,y:k,vx:_,vy:R}=this.computeSpring(e.x,e.y,T.vx,T.vy,I,w,r,t);r.copyX&&(e.x=e.x+(W-e.x)*l),r.copyY&&(e.y=e.y+(k-e.y)*l),this.objectVelocities.set(s.id,{vx:_,vy:R})}else r.copyX&&(e.x=e.x+(I-e.x)*l),r.copyY&&(e.y=e.y+(w-e.y)*l);let P=!1;if((c=r.limitX)!=null&&c.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(P=!0)}if((g=r.limitY)!=null&&g.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(P=!0)}P&&M&&this.objectVelocities.set(s.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const b=this.getGlobalTransform(r.targetId);if(b){let S=(b.rotation+(r.offset||0)-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*l}}else if(r.type==="Scale"){const b=this.getGlobalTransform(r.targetId);b&&(r.copyX&&(e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l),r.copyY&&(e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l))}else if(r.type==="Transform"){const b=this.getGlobalTransform(r.targetId);if(b){e.x=e.x+(b.x-e.x)*l,e.y=e.y+(b.y-e.y)*l;let C=(b.rotation-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*l,e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l,e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l}}else if(r.type==="FollowPointer"){const b=((h=this._lastPointerPos)==null?void 0:h.x)??e.x,C=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,S=r.useSpring;if(S){const w=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:M,y:P,vx:T,vy:W}=this.computeSpring(e.x,e.y,w.vx,w.vy,b,C,r,t);e.x=M,e.y=P,this.objectVelocities.set(s.id,{vx:T,vy:W})}else e.x=e.x+(b-e.x)*l,e.y=e.y+(C-e.y)*l;let I=!1;if((p=r.limitX)!=null&&p.enabled){const w=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==w&&(I=!0)}if((m=r.limitY)!=null&&m.enabled){const w=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==w&&(I=!0)}I&&S&&this.objectVelocities.set(s.id,{vx:0,vy:0})}else if(r.type==="Distance"){const b=this.getGlobalTransform(r.targetId);if(b){const C=e.x-b.x,S=e.y-b.y,I=Math.sqrt(C*C+S*S),w=r.distance||0;let M=I;switch(r.mode){case"exact":M=w;break;case"minimum":M=Math.max(w,I);break;case"maximum":M=Math.min(w,I);break;case"clamped":M=Math.max(0,Math.min(w,I));break}if(I>0){const P=e.x===b.x&&e.y===b.y?1:M/I;e.x=e.x+(b.x+C*P-e.x)*l,e.y=e.y+(b.y+S*P-e.y)*l}}}else if(r.type==="FollowPath"){const b=(y=this.artboard)==null?void 0:y.objects.find(C=>C.id===r.targetId);if(b){const C=this.getGlobalTransform(b.id);if(C){let S=b.geometry;if(b.type==="Frame"||b.type==="Group"||!S||S.type!=="Path"&&S.type!=="Ellipse"&&S.type!=="Rectangle"){const F=(v=this.artboard)==null?void 0:v.objects.find(q=>q.parentId===b.id&&q.type==="Shape"&&q.geometry&&(q.geometry.type==="Path"||q.geometry.type==="Ellipse"||q.geometry.type==="Rectangle"));F&&(S=F.geometry)}if(!S)return;const I=(r.distance||0)/100,w=C.width||S.width||0,M=C.height||S.height||0,P=this.getPointOnPath(S,w,M,I),T=C.rotation*Math.PI/180,W=Math.cos(T),k=Math.sin(T),_=P.x*C.scale_x*W-P.y*C.scale_y*k,R=P.x*C.scale_x*k+P.y*C.scale_y*W;let x=C.rotation+(r.offsetRotation||0);if(r.orient){const F=Math.cos(P.angle),q=Math.sin(P.angle),Q=F*C.scale_x*W-q*C.scale_y*k,it=F*C.scale_x*k+q*C.scale_y*W;x=Math.atan2(it,Q)*180/Math.PI+(r.offsetRotation||0)}const O=x*Math.PI/180,$=Math.cos(O),A=Math.sin(O),V=(r.offsetX||0)*$-(r.offsetY||0)*A,H=(r.offsetX||0)*A+(r.offsetY||0)*$,et=C.x+_+V,E=C.y+R+H;if(e.x=e.x+(et-e.x)*l,e.y=e.y+(E-e.y)*l,r.orient){let F=(x-e.rotation)%360;F>180&&(F-=360),F<-180&&(F+=360),e.rotation=e.rotation+F*l}}}}else if(r.type==="IK"){const b=this.getGlobalTransform(r.targetId);b&&this.solveIK(s,b,r.boneCount||2,l)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var f;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(f=this.artboard)==null?void 0:f.objects.find(c=>c.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1)};const e=this.getGlobalTransform(o.parentId),i=e.rotation*Math.PI/180,n=Math.cos(i),a=Math.sin(i),r=e.x+(s.x*e.scale_x*n-s.y*e.scale_y*a),l=e.y+(s.x*e.scale_x*a+s.y*e.scale_y*n);return{x:r,y:l,rotation:e.rotation+s.rotation,scale_x:e.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:e.scale_y*(s.scale_y??1)*(s.flip_y?-1:1)}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=s.x-o.x,f=s.y-o.y,c=(l*a-f*r)*e,g=(l*r+f*a)*i;return{x:c,y:g,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var l;const i=[];let n=t.id;for(let f=0;f<o&&n;f++){const c=(l=this.artboard)==null?void 0:l.objects.find(g=>g.id===n);if(!c)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=c.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let f=0;f<r;f++){const c=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const h=a[g],d=this.getGlobalTransform(h.id),p=c.x-d.x,m=c.y-d.y,y=s.x-d.x,v=s.y-d.y,b=Math.sqrt(p*p+m*m),C=Math.sqrt(y*y+v*v);if(b>.001&&C>.001){const S=Math.atan2(m,p);let w=(Math.atan2(v,y)-S)*180/Math.PI;w*=e;const M=this.objectStates.get(h.id);M&&(M.rotation+=w)}}}}computeSpring(t,s,o,e,i,n,a,r){const l=a.stiffness??100,f=a.damping??10,c=a.mass??1,g=-l*(t-i),h=-l*(s-n),d=-f*o,p=-f*e,m=(g+d)/c,y=(h+p)/c,v=o+m*r,b=e+y*r,C=t+v*r,S=s+b*r;return{x:C,y:S,vx:v,vy:b}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX-this.artboard.width/2,r=(o-n.ty)/n.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,s){this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,l,f,c,g;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const i=(h,d)=>{var C;let p=d;d==="click"?p="onClick":d==="down"?p="onPointerDown":d==="up"?p="onPointerUp":d==="blur"&&(p="onPointerLeave");const m=new Set([p]);d==="move"&&m.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),p==="onClick"&&m.add("click"),p==="onPointerDown"&&m.add("pointerDown"),p==="onPointerUp"&&m.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup"];return!!(h.type==="Component"&&y.includes(h.variant)||y.includes((C=h.type)==null?void 0:C.toLowerCase())||(h.interactions||[]).some(S=>m.has(S.event))||(h.triggers||[]).some(S=>m.has(S.eventType)))};let n=null;for(let h=this.artboard.objects.length-1;h>=0;h--){const d=this.artboard.objects[h],p=this.objectStates.get(d.id);if(p&&p.visible!==!1&&p.opacity>0&&this.hitTest(d,s,o)&&(n||(n=d),i(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const h=this.artboard.objects.find(d=>d.id===this.draggingSliderId);h&&this.updateSliderValueFromPointer(h,s,o);return}if(this.draggingListViewId){const h=this.artboard.objects.find(d=>d.id===this.draggingListViewId);h&&this.updateListViewScrollFromPointer(h);return}e&&e.type==="Component"&&e.variant==="listview"&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(h=>h.type===Y.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(h=>{h!==a&&this.activeHoverIds.delete(h)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const h=this.artboard.objects.find(d=>d.id===this.activeDropdownId);if(h&&(h.type==="Dropdown"||h.variant==="dropdown")){const d=this.objectStates.get(h.id),p=(d==null?void 0:d.options)||h.options||{},m=h.geometry||{},y=m.width??h.width??200,v=m.height??h.height??40,b=p.optionsList||[],C=p.itemHeight||32,S=p.listPadding??4,I=b.length*C+S*2,w=this.getWorldTransform(h.id),M=y*Math.abs(w.scaleX),P=v*Math.abs(w.scaleY),T=w.y+P/2+4,W=Math.abs(s-w.x)<=M/2,k=o>=T&&o<=T+I*Math.abs(w.scaleY);if(W&&k){const _=Math.abs(w.scaleY),R=o-(T+S*_),x=Math.floor(R/(C*_));if(x>=0&&x<b.length){const O=b[x];p.selectedOption=O,p.isOpen=!1,this.activeDropdownId=null,h.inputId&&this.setInternalInput(h.inputId,O),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"dropdown",property:"selectedOption",value:O})}return}else a!==this.activeDropdownId&&(p.isOpen=!1,this.activeDropdownId=null)}}if(e){let h=e,d=e;for(;d&&d.parentId;){const m=this.artboard.objects.find(y=>y.id===d.parentId);if(m&&m.type==="Component"){h=m;break}d=m}let p=t;if(t==="click"?p="onClick":t==="down"?p="onPointerDown":t==="up"?p="onPointerUp":t==="blur"&&(p="onPointerLeave"),this.fireEventForObject(e.id,p),h!==e&&this.fireEventForObject(h.id,p),h.type==="Component"&&h.variant==="toggle_button"&&t==="down"){const m=this.objectStates.get(h.id),y=(m==null?void 0:m.options)||h.options||{};y.checked=!y.checked,h.inputId&&this.setInternalInput(h.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(h.id,"Toggle"),this.fireEventForObject(h.id,y.checked?"Toggle True":"Toggle False")}if(h.type==="Component"&&h.variant==="toggle"&&t==="down"){const m=this.objectStates.get(h.id),y=(m==null?void 0:m.options)||h.options||{};y.checked=!y.checked,h.inputId&&this.setInternalInput(h.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(h.name,y.checked),this.fireEventForObject(h.id,"Toggle"),this.fireEventForObject(h.id,y.checked?"Toggle True":"Toggle False")}if(h.type==="Component"&&h.variant==="dropdown"&&t==="down"){const m=this.objectStates.get(h.id),y=(m==null?void 0:m.options)||h.options||{},v=!y.isOpen;if(v&&this.activeDropdownId&&this.activeDropdownId!==h.id){const b=this.artboard.objects.find(C=>C.id===this.activeDropdownId);b&&b.options&&(b.options.isOpen=!1)}y.isOpen=v,this.activeDropdownId=v?h.id:null}if(h.type==="Component"&&h.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(h.name,h.id),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"button",property:"click",value:!0})),h.type==="Component"&&h.variant==="listview"&&t==="down"){this.draggingListViewId=h.id;const m=this.getListViewItemIndexAtPointer(h,s,o);if(m!==null){const y=h.options||{};y.activeItemIndex=m;const v=this.objectStates.get(h.id);v&&v.options&&(v.options.activeItemIndex=m);const b=(y.items||[])[m],C=typeof b=="string"?b:b.label||b.value||m;v&&v.options&&(v.options.selectedValue=C),h.inputId&&this.setInternalInput(h.inputId,C),this.onComponentChange&&(this.onComponentChange({objectId:h.id,componentName:h.name,variant:"listview",property:"activeItemIndex",value:m}),this.onComponentChange({objectId:h.id,componentName:h.name,variant:"listview",property:"selected",value:C}))}}if(h.type==="Component"&&h.variant==="slider"&&t==="down"&&(this.draggingSliderId=h.id,this.updateSliderValueFromPointer(h,s,o)),h.type==="Component"&&h.variant==="checkbox"&&t==="down"){const m=this.objectStates.get(h.id),y=(m==null?void 0:m.options)||h.options||{};y.checked=!y.checked,h.inputId&&this.setInternalInput(h.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"checkbox",property:"checked",value:y.checked}),this.fireEventForObject(h.id,"Click"),this.fireEventForObject(h.id,y.checked?"Checked":"Unchecked")}if(h.type==="Component"&&h.variant==="radiogroup"&&t==="down"){const m=this.objectStates.get(h.id),y=(m==null?void 0:m.options)||h.options||{},v=y.optionsList||[],b=this.getRadioGroupItemIndexAtPointer(h,s,o);if(b!==null&&b>=0&&b<v.length){const C=v[b];y.selectedValue=C,h.inputId&&this.setInternalInput(h.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"radiogroup",property:"selectedValue",value:C}),this.fireEventForObject(h.id,"Click"),this.fireEventForObject(h.id,`Selected: ${C}`)}}if(h.type==="LineGraph"&&(t==="down"||t==="click")){const m=h.geometry,y=(m==null?void 0:m.datasets)||[],v=this.objectStates.get(h.id),b=(v==null?void 0:v.width)||(m==null?void 0:m.width)||200,C=(v==null?void 0:v.height)||(m==null?void 0:m.height)||150,S=this.getWorldTransform(h.id),I=30,w=20,M=b-I,P=C-w;let T=1;y.forEach(_=>{const R=Math.max(..._.data||[0]);R>T&&(T=R)});let W=1/0,k=null;y.forEach((_,R)=>{const x=_.data||[],O=M/Math.max(x.length-1,1);x.forEach(($,A)=>{const V=S.x-b/2+I+A*O,H=S.y+C/2-w-$/T*P,et=Math.sqrt((s-V)**2+(o-H)**2);et<W&&(W=et,k={dIdx:R,pIdx:A,val:$,label:_.label||`Dataset ${R+1}`})})}),k&&W<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:h.id,componentName:h.name,datasetIndex:k.dIdx,pointIndex:k.pIdx,value:k.val,label:k.label}),this.onComponentChange&&this.onComponentChange({objectId:h.id,componentName:h.name,variant:"linegraph",property:"click",value:(k==null?void 0:k.val)??null})}if(t==="click"){const m=(l=this.artboard)==null?void 0:l.objects.find(b=>b.id===e.id),y=this.focusedId,v=(m==null?void 0:m.type)==="InputBox"||(m==null?void 0:m.type)==="Component"&&m.variant==="inputbox";if(m&&v){if(this.focusedId=e.id,console.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const b=(f=this.artboard)==null?void 0:f.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}this.onInputFocus&&this.onInputFocus(m.name)}}else if(this.focusedId=null,y){const b=(c=this.artboard)==null?void 0:c.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}}}else if(t==="click"){const h=this.focusedId;if(this.focusedId=null,h){const d=(g=this.artboard)==null?void 0:g.objects.find(p=>p.id===h);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||!this.focusedId)return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
|
|
7
|
+
`;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}fireEventForObject(t,s){var f,c,g,h,d;const o=(f=this.artboard)==null?void 0:f.objects.find(p=>p.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(p=>{const m=p.triggers||[p.event||p.trigger||"click"];return((p.triggerLogic||"OR")==="AND"?m.every(b=>e.has(b.toLowerCase())):m.some(b=>e.has(b.toLowerCase())))?p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):!0:!1});if(a){if(console.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let p=a.value||a.inputValue;p==="toggle"&&(p=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,p)}else if(a.action==="Toggle Boolean"){const p=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!p)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const p=a.targetObjectId||o.id,m=a.targetProperty;m&&this.updateObjectProperty(p,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const p=a.targetAnimationId;p==="__all__"?(g=(c=this.artboard)==null?void 0:c.animations)==null||g.forEach(m=>{this.triggerGlobalAnimation(m.id,a.subAnimationIds)}):p&&this.triggerGlobalAnimation(p,a.subAnimationIds)}else if(a.action==="setState"||a.action==="Set State"){const p=a.targetObjectId||o.id,y={...this.objectStates.get(p)||{},...a.value||{}};this.objectStates.set(p,y),console.log(`[Engine] State updated for ${p}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const p=a.targetAnimationId;p==="__all__"?this.layerStates.forEach((m,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):p&&this.layerStates.forEach((m,y)=>{y.startsWith(`global_${p}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const p=a.targetState,m=this.activeStateMachine.layers.find(y=>y.states.some(v=>v.id===p||v.name===p));m&&(console.log(`[Engine] Switching Layer ${m.name} to State ${p}`),this.enterStates(m.name,[p]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(p=>{const m=p.eventType.toLowerCase();let y=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):y});if(l&&l.entryAnimationId){console.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const p=(d=(h=this.artboard)==null?void 0:h.animations)==null?void 0:d.find(m=>m.id===l.entryAnimationId);p&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:p,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,p.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(f=>f.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(f=>{if(f.type==="literal")n[f.key]=f.value;else if(f.type==="variable"){const c=this.inputs.get(f.value);n[f.key]=c!==void 0?c:""}}),console.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const f=window;typeof f.gtag=="function"?(f.gtag("event",i,n),console.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const f=window;typeof f.fbq=="function"?(f.fbq("track",i,n),console.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const f=window;f.mixpanel&&typeof f.mixpanel.track=="function"?(f.mixpanel.track(i,n),console.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(h=>h.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,l=s.y*e.scaleY,f=e.x+(r*n-l*a),c=e.y+(r*a+l*n);return{x:f,y:c,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var b,C;if(!this.objectStates.get(t.id))return!1;const i=((b=t.geometry)==null?void 0:b.width)??t.width??100,n=((C=t.geometry)==null?void 0:C.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,f=-a.rotation*(Math.PI/180),c=Math.cos(f),g=Math.sin(f),h=r*c-l*g,d=r*g+l*c,p=a.scaleX,m=a.scaleY,y=i*Math.abs(p),v=n*Math.abs(m);return Math.abs(h)<=y/2&&Math.abs(d)<=v/2}updateSliderValueFromPointer(t,s,o){var w;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((w=t.geometry)==null?void 0:w.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,f=-a.rotation*(Math.PI/180),c=Math.cos(f),g=Math.sin(f),h=r*c-l*g,d=i.thumbWidth??16,p=n-d;let y=(h+p/2)/p;y=Math.max(0,Math.min(1,y));const v=i.min??0,b=i.max??100,C=i.step||1;let S=v+y*(b-v);C>0&&(S=Math.round(S/C)*C),S=Math.max(v,Math.min(b,S));const I=e.options||{};I.value!==S&&(e.options={...I,value:S},t.inputId&&this.setInternalInput(t.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:S}))}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var c,g,h;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(c=this.artboard)==null?void 0:c.objects.find(d=>d.id===i),a=((g=n==null?void 0:n.physics)==null?void 0:g.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(i);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const f=this.interpolate(e.keyframes,s);if(f!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||i,p=typeof f=="object"?JSON.stringify(f).slice(0,50):f;this.debugLog(`[Anim] Applying ${r} = ${p} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let p=l;for(let m=0;m<d.length-1;m++){if(typeof p[d[m]]!="object"||p[d[m]]===null){let y=n;for(let v=0;v<=m;v++)y=y?y[d[v]]:null;if(d[m]==="corner_radius"||d[m]==="cornerRadius"){const v=typeof p[d[m]]=="number"?p[d[m]]:typeof y=="number"?y:0;p[d[m]]={tl:v,tr:v,bl:v,br:v}}else p[d[m]]=y?JSON.parse(JSON.stringify(y)):{}}p=p[d[m]]}p[d[d.length-1]]=f,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(p.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=f):r==="stroke"?(l.style||(l.style={}),l.style.stroke=f):l[r]=f;if(this.physicsEngine&&((h=n==null?void 0:n.physics)!=null&&h.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,f,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,d.x,f)}else r==="rotation"&&this.physicsEngine.setRotation(i,f*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const i=e.time-o.time;let n=(s-o.time)/i;if(o.easing&&(n=si(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const l=e.value[r];return typeof a=="number"&&typeof l=="number"?a+(l-a)*n:n<.5?a:l}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(l=>{const f=o.value[l],c=e.value[l];typeof f=="number"&&typeof c=="number"?a[l]=f+(c-f)*n:f===void 0?a[l]=c:c===void 0?a[l]=f:a[l]=n<.5?f:c}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,s,o){var d,p;const e=((p=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:p.colors)||{},i=e[t]||t,n=e[s]||s,a=m=>{if(!m)return{r:0,g:0,b:0};const y=m.startsWith("#")?m.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)}},r=a(i),l=a(n),f=Math.round(r.r+(l.r-r.r)*o),c=Math.round(r.g+(l.g-r.g)*o),g=Math.round(r.b+(l.b-r.b)*o),h=m=>{const y=Math.max(0,Math.min(255,m)).toString(16);return y.length===1?"0"+y:y};return`#${h(f)}${h(c)}${h(g)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var f;this.debug_objectsTotal=((f=this.artboard)==null?void 0:f.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),t.translate(i/2,n/2),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(-i/2,-n/2,i,n)),this.artboard.backgroundImage){const c=this.artboard.backgroundImage;let g=this.imageCache.get(c);if(g||(g=new Image,g.src=c,this.imageCache.set(c,g)),g.complete&&g.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const h=g.naturalWidth/g.naturalHeight,d=i/n;let p,m,y,v;d>h?(p=i,m=i/h):(m=n,p=n*h),y=-p/2,v=-m/2,t.drawImage(g,y,v,p,m),t.restore()}}t.beginPath(),t.rect(-i/2,-n/2,i,n),t.clip();const r=new Map;this.artboard.objects.forEach(c=>r.set(c.id,c)),this.artboard.objects.filter(c=>!c.parentId).map((c,g)=>{const h=this.objectStates.get(c.id),d=(h==null?void 0:h.zIndex)??g;return{obj:c,zIndex:d}}).sort((c,g)=>c.zIndex-g.zIndex).forEach(({obj:c})=>{this.renderObject(t,c,r)}),this._emitterPools.forEach((c,g)=>{if(!(c.length===0||!r.get(g)))for(const d of c)t.save(),t.globalAlpha=d.opacity,t.fillStyle=d.color,t.beginPath(),t.arc(d.x,d.y,Math.max(1,d.size*d.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&console.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,f=Math.sqrt(a.a*a.a+a.b*a.b),c=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+n)*f,h=(i/2+n)*c;return r+g>=0&&r-g<=this.canvasWidth&&l+h>=0&&l-h<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,l=1;const f=o/e,c=t/s;switch(i){case"Contain":c>f?l=s/e:l=t/o,a=r=l;break;case"Cover":c>f?l=t/o:l=s/e,a=r=l;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":l=t/o,a=r=l;break;case"FitHeight":l=s/e,a=r=l;break;case"None":a=r=1;break;case"ScaleDown":l=Math.min(t/o,s/e),l>1&&(l=1),a=r=l;break;default:a=r=1;break}const g=o*a,h=e*r;let d=0,p=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-g:d=(t-g)/2,n.includes("Top")?p=0:n.includes("Bottom")?p=s-h:p=(s-h)/2,{scaleX:a,scaleY:r,tx:d,ty:p}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o){var p,m,y,v,b,C,S,I,w,M,P,T,W,k,_,R,x;const e=this.objectStates.get(s.id);if(!e){console.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(O,$,A,V,H)=>(this.drawRoundRect(t,O,$,A,V,H),t));const i=e.geometry?this.deepMerge(s.geometry,e.geometry):s.geometry,n=e.style?this.deepMerge(s.style,e.style):s.style;let a=(i==null?void 0:i.width)||((p=s.geometry)==null?void 0:p.width)||s.width||0,r=(i==null?void 0:i.height)||((m=s.geometry)==null?void 0:m.height)||s.height||0;if((a===0||r===0)&&(i!=null&&i.points)&&Array.isArray(i.points)&&i.points.length>0){let O=1/0,$=-1/0,A=1/0,V=-1/0;i.points.forEach(H=>{O=Math.min(O,H.x),$=Math.max($,H.x),A=Math.min(A,H.y),V=Math.max(V,H.y)}),a===0&&(a=$-O),r===0&&(r=V-A)}const l=O=>{if(O)return O.corner_radius??O.cornerRadius},f=l(e)??l(n)??l(i)??l(s.style)??l(s.geometry)??0;let c={...i,width:a,height:r};if(delete c.cornerRadius,c.corner_radius=f,c.type==="Path"&&s.weights&&s.bindMatrices&&c.points){const O=this.getGlobalTransform(s.id);if(O){const $=ii(c.points,s.weights,s.bindMatrices,O,A=>this.getGlobalTransform(A));c={...c,points:$}}}if(e.visible===!1)return;const g=s.repeaterConfig,h=g&&g.isEnabled&&g.count>1,d=h?g.count:1;for(let O=0;O<d;O++){let $=e.x,A=e.y,V=e.rotation,H=e.scale_x??1,et=e.scale_y??1;if(h&&O>0){if(g.type==="Linear"){const J=g.offsetX||0,ft=g.offsetY||0,U=g.rotation||0,G=g.scale!==void 0?g.scale:1;$+=O*J,A+=O*ft,V+=O*U,H*=Math.pow(G,O),et*=Math.pow(G,O)}else if(g.type==="Grid"){const J=g.cols||Math.ceil(Math.sqrt(g.count)),ft=g.gapX||0,U=g.gapY||0,G=Math.floor(O/J),K=O%J,Z=a+ft,Ot=r+U;$+=K*Z,A+=G*Ot}else if(g.type==="Radial"){const J=g.radius||100,ft=g.startAngle||0,G=(g.endAngle||360)-ft,K=g.count>1?G/(G===360?g.count:g.count-1):0,Z=ft+O*K,Ot=Z*Math.PI/180;$=e.x+J*Math.cos(Ot),A=e.y+J*Math.sin(Ot),V+=Z}}const E=s.type==="Group"||s.type==="Frame"||s.type==="Component",F=a>0&&r>0;if(!E&&F){const J=(((y=n.shadow)==null?void 0:y.isEnabled)!==!1?(((v=n.shadow)==null?void 0:v.blur)||0)+10:0)+(((b=n.blur)==null?void 0:b.isEnabled)!==!1&&((C=n.blur)==null?void 0:C.radius)||0)+20;if(!this.isObjectInView(t,$,A,a,r,J))continue}this.debug_objectsRendered++,t.save();const q=[],Q=n.blur||((S=s.style)==null?void 0:S.blur);Q&&Q.amount>0&&q.push(`blur(${Q.amount}px)`);const it=n.effect||((I=s.style)==null?void 0:I.effect),dt=(it==null?void 0:it.isEnabled)===!0,St=it==null?void 0:it.type,ht=(it==null?void 0:it.radius)??10;dt&&St==="LayerBlur"&&q.push(`blur(${ht}px)`);const mt=((w=i==null?void 0:i.type)==null?void 0:w.toLowerCase().includes("image"))||((M=s.type)==null?void 0:M.toLowerCase().includes("image")),rt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Rt=i!=null&&i.adjustments&&Object.keys(i.adjustments).length>0?i.adjustments:null,Yt=mt?Rt||rt:rt||Rt,Pt=mt&&!Yt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:Yt;if(e&&Pt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...Pt}),Pt){const J=(Pt.exposure||0)/100,ft=Pt.contrast||0,U=1+(Pt.saturation||0)/100,G=(Pt.temperature||0)/200,K=(Pt.tint||0)/200,Z=(Pt.highlights||0)/500,Ot=(Pt.shadows||0)/500;let At="",kt="SourceGraphic";if(J!==0&&(At+=`
|
|
8
8
|
<feComponentTransfer in="${kt}" result="exposure">
|
|
9
9
|
<feFuncR type="linear" slope="1" intercept="${J}"/>
|
|
10
10
|
<feFuncG type="linear" slope="1" intercept="${J}"/>
|
|
11
11
|
<feFuncB type="linear" slope="1" intercept="${J}"/>
|
|
12
|
-
</feComponentTransfer>`,kt="exposure"),ft!==0){const bt=(ft+100)/100,
|
|
12
|
+
</feComponentTransfer>`,kt="exposure"),ft!==0){const bt=(ft+100)/100,L=.5*(1-bt);At+=`
|
|
13
13
|
<feComponentTransfer in="${kt}" result="contrast">
|
|
14
|
-
<feFuncR type="linear" slope="${bt}" intercept="${
|
|
15
|
-
<feFuncG type="linear" slope="${bt}" intercept="${
|
|
16
|
-
<feFuncB type="linear" slope="${bt}" intercept="${
|
|
14
|
+
<feFuncR type="linear" slope="${bt}" intercept="${L}"/>
|
|
15
|
+
<feFuncG type="linear" slope="${bt}" intercept="${L}"/>
|
|
16
|
+
<feFuncB type="linear" slope="${bt}" intercept="${L}"/>
|
|
17
17
|
</feComponentTransfer>`,kt="contrast"}if(U!==1&&(At+=`<feColorMatrix in="${kt}" type="saturate" values="${U}" result="saturate"/>`,kt="saturate"),Pt.hue&&(At+=`<feColorMatrix in="${kt}" type="hueRotate" values="${Pt.hue}" result="hue"/>`,kt="hue"),Pt.negative){const bt=1-Pt.negative/50;At+=`
|
|
18
18
|
<feColorMatrix in="${kt}" type="matrix" result="invert"
|
|
19
19
|
values="${bt} 0 0 0 ${1-bt}
|
|
20
20
|
0 ${bt} 0 0 ${1-bt}
|
|
21
21
|
0 0 ${bt} 0 ${1-bt}
|
|
22
|
-
0 0 0 1 0"/>`,kt="invert"}if(G!==0||K!==0||Z!==0||Ot!==0){const bt=1+Z+Ot,O=bt*(1+G-K/2),ct=bt*(1+K),Dt=bt*(1-G-K/2),xt=Pt.shadows*.1/255,ie=[O,0,0,0,xt,0,ct,0,0,xt,0,0,Dt,0,xt,0,0,0,1,0].join(" ");At+=`<feColorMatrix in="${kt}" type="matrix" values="${ie}" result="advanced"/>`,kt="advanced"}if(Pt.blur&&(At+=`<feGaussianBlur in="${kt}" stdDeviation="${Pt.blur}" result="blur"/>`,kt="blur"),At){const bt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${At}</filter></svg>`,O=btoa(bt);q.push(`url('data:image/svg+xml;base64,${O}#f')`)}}q.length>0?t.filter=q.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const zt=t.globalAlpha,Xt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=zt*Xt;const B=e.compositeOperation||e.blendMode;if(B&&B!=="Normal"){const J=B.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(J)&&(t.globalCompositeOperation=J)}const lt=t,Vt=e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let Mt=!1;const Tt=Vt.filter(J=>J.isVisible!==!1&&o.has(J.maskId));if(Tt.length>0){const J=Tt[0],ft=o.get(J.maskId),U=this.objectStates.get(ft.id);U&&U.visible!==!1&&(Mt=!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),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=lt.filter)}t.translate(Math.round($),Math.round(A)),t.rotate(V*Math.PI/180);const Nt=e.skew_x||0,Jt=e.skew_y||0;(Nt!==0||Jt!==0)&&t.transform(1,Math.tan(Jt*Math.PI/180),Math.tan(Nt*Math.PI/180),1,0,0);const Kt=e.rotate_x||0,Qt=e.rotate_y||0,te=(e.flip_x===!0?-1:1)*Math.cos(Qt*Math.PI/180),ce=(e.flip_y===!0?-1:1)*Math.cos(Kt*Math.PI/180);t.scale(H*te,et*ce),n.shadow&&n.shadow.isEnabled!==!0&&((n.shadow.blur||0)>0||Math.abs(n.shadow.offsetX||0)>0||Math.abs(n.shadow.offsetY||0)>0)&&(n.shadow.isEnabled=!0);const se=n.shadow;if(se&&se.isEnabled!==!1){let J=se.color||"#000000";(T=(E=this.artboard)==null?void 0:E.tokens)!=null&&T.colors&&this.artboard.tokens.colors[J]&&(J=this.artboard.tokens.colors[J]);const ft=this.normalizeOpacity(se.opacity??100),U=se.spread||0,K=(se.blur||0)+U*1.5;let Z=J;if(J.startsWith("#")){const kt=J.replace("#",""),Ut=parseInt(kt.substring(0,2),16),bt=parseInt(kt.substring(2,4),16),O=parseInt(kt.substring(4,6),16);Z=`rgba(${Ut}, ${bt}, ${O}, ${ft})`}else if(J.startsWith("rgba")){const kt=J.match(/[\d.]+/g);if(kt&&kt.length>=4){const Ut=kt[0],bt=kt[1],O=kt[2],ct=kt[3];Z=`rgba(${Ut}, ${bt}, ${O}, ${parseFloat(ct)*ft})`}}const Ot=t.getTransform(),At=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1;t.shadowColor=Z,t.shadowBlur=K*At,t.shadowOffsetX=(se.offsetX||0)*At,t.shadowOffsetY=(se.offsetY||0)*At}const ne=s.liquidFill||((W=s.style)==null?void 0:W.liquidFill);if(ne&&ne.enabled){t.save();const J=ne.fillLevel??.5;t.beginPath();const ft=r/2-r*J;t.rect(-a/2,ft,a,r*J),t.clip(),t.fillStyle=ne.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ne.opacity??1)}if((i==null?void 0:i.type)==="Text")this._renderText(t,s,c,n,e,a,r);else if((i==null?void 0:i.type)==="Image"){const J=i.originalSrc||i.src;if(J){let ft=this.imageCache.get(J);ft||(ft=new Image,ft.onload=()=>{console.log(`[ExodeUI] Image loaded successfully, size: ${ft.naturalWidth}x${ft.naturalHeight}`)},ft.onerror=K=>{console.error("[ExodeUI] Image load failed:",K,`Src preview: ${J.substring(0,100)}...`)},ft.src=J,this.imageCache.set(J,ft));const U=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,G=(((M=n.stroke)==null?void 0:M.alignment)||"center").toLowerCase();if(U&&(G==="outside"||G==="center")&&this.applyStrokeAlignment(t,n,c,a,r,h),n.fill&&n.fill.type!=="None"){t.save();const K=t.globalAlpha,Z=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Z||n.fill.color||"transparent",t.globalAlpha=K*this.normalizeOpacity(n.fill.opacity??100),h!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=K,t.restore()}ft.complete&&ft.naturalWidth>0?(h!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.clip(),t.drawImage(ft,-a/2,-r/2,a,r),t.restore()):t.drawImage(ft,-a/2,-r/2,a,r),U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,h)):U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,h)}}else if(i.type==="SVG"){const J=i.svgContent;if(J){const ft=n.palette||[],U=n.fill,G=n.stroke,K=U?this.normalizeOpacity(U.opacity??100):1,Z=(U==null?void 0:U.type)==="Solid"&&(!G||G.isEnabled===!1||G.type==="Solid"&&G.color===U.color),Ot=U&&U.type!=="None"?Z?"monochrome":U.type==="Solid"?(U.color||"")+"|opacity:"+K:JSON.stringify(U.stops||[])+"|opacity:"+K:"",At=G&&G.isEnabled!==!1&&(G.width||0)>0?Z?["monochrome",G.width||0,G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):[G.width||0,G.fill?G.fill.type==="Solid"?G.fill.color||"":JSON.stringify(G.fill.stops||[]):G.color||"",G.opacity??1,G.lineCap||"",G.lineJoin||"",(G.dashArray||[]).join(","),G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):"nostroke",kt=[s.id,ft.join("_"),Ot,At,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let Ut=this.imageCache.get(kt);if(!Ut){Ut=new Image,Ut.crossOrigin="anonymous";let O=J;O.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(O=O.replace(/<svg([^>]*)>/i,(ot,It)=>`<svg xmlns="http://www.w3.org/2000/svg"${It}>`));let ct=i.width||a||100,Dt=i.height||r||100;const xt=O.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(xt&&(ct=parseFloat(xt[1]),Dt=parseFloat(xt[2])),O=O.replace(/<svg([^>]*)>/i,(ot,It)=>{let vt=It.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return vt.match(/\bviewBox=/i)||(vt+=` viewBox="0 0 ${ct} ${Dt}"`),vt.match(/\bpreserveAspectRatio=/i)||(vt+=' preserveAspectRatio="none"'),vt+=' width="100%" height="100%"',`<svg${vt}>`}),i.colors&&i.colors.length>0&&ft.length>0&&i.colors.forEach((ot,It)=>{if(ft[It]){const vt=ot.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),Ct=new RegExp(vt,"gi");O=O.replace(Ct,ft[It])}}),U&&U.type&&U.type!=="None"){if(U.type==="Solid"&&U.color){const ot=Z?"#FFFFFF":U.color,It=Z?1:this.normalizeOpacity(U.opacity??100);O=O.replace(/\bfill\s*=\s*["'][^"']*["']/gi,vt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(vt)?vt:`fill="${ot}"`),O=O.replace(/fill\s*:\s*[^;"')]+/gi,vt=>/fill\s*:\s*(none|transparent)/i.test(vt)?vt:`fill:${ot}`),It<1&&(O=O.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${It}"`),O=O.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${It}`),O.match(/\bfill-opacity\s*=/i)||(O=O.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${It}">`),O=O.replace(/<\/svg>/i,"</g></svg>")))}else if(U.type==="LinearGradient"||U.type==="RadialGradient"||U.type==="Linear"||U.type==="Radial"){const ot="exode-fill",It=this.normalizeOpacity(U.opacity??100),vt=(U.stops||[]).map(gt=>{const Lt=gt.offset!==void 0?gt.offset:gt.pos??0,at=this.normalizeOpacity(gt.opacity??100)*It;return`<stop offset="${Lt*100}%" stop-color="${gt.color||"#000"}" stop-opacity="${at}"/>`}).join("");let Ct="";if(U.type==="LinearGradient"||U.type==="Linear"){const gt=(wt,z)=>Array.isArray(wt)?wt[z]??(z===0?0:1):wt&&typeof wt=="object"?wt[z===0?"x":"y"]??(z===0?0:1):z===0?0:1,Lt=gt(U.start,0)*100,at=gt(U.start,1)*100,st=gt(U.end,0)*100,nt=gt(U.end,1)*100;Ct=`<linearGradient id="${ot}" x1="${Lt}%" y1="${at}%" x2="${st}%" y2="${nt}%" gradientUnits="objectBoundingBox">${vt}</linearGradient>`}else{const gt=(nt,wt)=>Array.isArray(nt)?nt[wt]??.5:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??.5:.5,Lt=gt(U.center,0)*100,at=gt(U.center,1)*100,st=(U.radius??.5)*100;Ct=`<radialGradient id="${ot}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${vt}</radialGradient>`}/<defs>/i.test(O)?O=O.replace(/<defs>/i,`<defs>${Ct}`):O=O.replace(/<svg([^>]*)>/i,`<svg$1><defs>${Ct}</defs>`),O=O.replace(/\bfill\s*=\s*["'][^"']*["']/gi,gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(gt)?gt:`fill="url(#${ot})"`),O=O.replace(/fill\s*:\s*[^;"')]+/gi,gt=>/fill\s*:\s*(none|transparent)/i.test(gt)?gt:`fill:url(#${ot})`)}}const ie=(ot,It,vt=1)=>{const Ct=(ot.stops||[]).map(nt=>{const wt=nt.offset!==void 0?nt.offset:nt.pos??0,z=this.normalizeOpacity(nt.opacity??100)*vt;return`<stop offset="${wt*100}%" stop-color="${nt.color||"#000"}" stop-opacity="${z}"/>`}).join(""),gt=(nt,wt,z=.5)=>Array.isArray(nt)?nt[wt]??z:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??z:z;if(ot.type==="LinearGradient"||ot.type==="Linear"){const nt=gt(ot.start,0,0)*100,wt=gt(ot.start,1,0)*100,z=gt(ot.end,0,1)*100,pt=gt(ot.end,1,1)*100;return`<linearGradient id="${It}" x1="${nt}%" y1="${wt}%" x2="${z}%" y2="${pt}%" gradientUnits="objectBoundingBox">${Ct}</linearGradient>`}const Lt=gt(ot.center,0,.5)*100,at=gt(ot.center,1,.5)*100,st=(ot.radius??.5)*100;return`<radialGradient id="${It}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${Ct}</radialGradient>`},Wt=(ot,It)=>/<defs>/i.test(ot)?ot.replace(/<defs>/i,`<defs>${It}`):ot.replace(/(<svg[^>]*>)/i,`$1<defs>${It}</defs>`);if(G&&G.isEnabled!==!1&&(G.width||0)>0){const ot=Z?1:this.normalizeOpacity(G.opacity??100),It=Z?"#FFFFFF":G.color||(U==null?void 0:U.color)||"#000000";let vt="";const Ct=G.fill;if(Ct&&Ct.type){if(Ct.type==="Solid")vt=Ct.color||G.color||"#000000";else if(Ct.type==="LinearGradient"||Ct.type==="RadialGradient"||Ct.type==="Linear"||Ct.type==="Radial"){const qt="exode-stroke";O=Wt(O,ie(Ct,qt,ot)),vt=`url(#${qt})`}}vt||(vt=It),O.match(/\bstroke\s*=\s*["']/i)?O=O.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,qt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(qt)?qt:`stroke="${vt}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${vt}"`),O=O.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${vt}`);let gt=i.width||a||100,Lt=i.height||r||100;const at=J.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(at){const qt=parseFloat(at[1]),oe=parseFloat(at[2]);!isNaN(qt)&&!isNaN(oe)&&(gt=qt,Lt=oe)}const st=Math.max(.001,a/gt),nt=Math.max(.001,r/Lt),wt=(st+nt)/2,z=(G.width||1)/wt;O.match(/\bstroke-width\s*=\s*["']/i)?O=O.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${z}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${z}"`),O=O.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${z}`),O.match(/\bstroke-opacity\s*=\s*["']/i)?O=O.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${ot}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${ot}"`),O=O.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${ot}`);const pt=G.lineCap||"round";O.match(/\bstroke-linecap\s*=\s*["']/i)?O=O.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${pt}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${pt}"`),O=O.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${pt}`);const ut=G.lineJoin||"round";O.match(/\bstroke-linejoin\s*=\s*["']/i)?O=O.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${ut}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${ut}"`),O=O.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${ut}`);const de=G.trimStart??0,be=G.trimEnd??1,Se=G.trimOffset??0,Ie=G.dashOffset??0,_e=de!==0||be!==1||Se!==0||Ie!==0;if(_e){const qt=Math.max(0,Math.min(1,de)),oe=Math.max(0,Math.min(1,be));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${qt}, End: ${oe}`);const ye=(gt+Lt)*2,we=(Se%1+1)%1,Me=(Ie%1+1)%1;let pe="",fe=0;if(qt>=oe)pe=`0 ${ye}`,fe=0;else{const he=ye*(oe-qt),ve=ye-he;fe=-(ye*(qt+we+Me)),pe=`${he} ${ve}`}O.match(/\bstroke-dasharray\s*=/i)?O=O.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${pe}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${pe}"`),O=O.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${pe}`),O.match(/\bstroke-dashoffset\s*=/i)?O=O.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${fe}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${fe}"`),O=O.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${fe}`)}else if(G.dashArray&&G.dashArray.length>0){const qt=G.dashArray.join(" ");O=O.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${qt}"`),O=O.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${qt}`),G.dashOffset&&(O=O.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${G.dashOffset}"`),O=O.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${G.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(J)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(J)){let qt="",oe="";if(_e){const pe=i.width||a||100,fe=i.height||r||100,he=(pe+fe)*2,ve=Math.max(0,Math.min(1,de)),Pe=Math.max(0,Math.min(1,be)),Fe=(Se%1+1)%1,$e=(Ie%1+1)%1;if(ve>=Pe)qt=` stroke-dasharray="0 ${he}"`,oe=' stroke-dashoffset="0"';else{const Ee=he*(Pe-ve),We=he-Ee,Be=-(he*(ve+Fe+$e));qt=` stroke-dasharray="${Ee} ${We}"`,oe=` stroke-dashoffset="${Be}"`}}else(_=G.dashArray)!=null&&_.length&&(qt=` stroke-dasharray="${G.dashArray.join(" ")}"`,G.dashOffset&&(oe=` stroke-dashoffset="${G.dashOffset}"`));const ye=` stroke-linecap="${G.lineCap||"round"}"`,we=` stroke-linejoin="${G.lineJoin||"round"}"`,Me=`stroke="${vt}" stroke-width="${z}" stroke-opacity="${ot}"${ye}${we}${qt}${oe}`;O=O.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(pe,fe,he)=>`${fe}${he}<g ${Me}>`),O=O.replace(/<\/svg>/i,"</g></svg>")}}else G&&G.isEnabled===!1&&(O=O.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),O=O.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Bt=new Blob([O],{type:"image/svg+xml"}),Ft=URL.createObjectURL(Bt);Ut.onload=()=>{if(URL.revokeObjectURL(Ft),this.frameCount%900===0){const ot=this.imageCache.get(kt);ot&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${ot.naturalWidth}x${ot.naturalHeight})`)}},Ut.onerror=()=>{URL.revokeObjectURL(Ft),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Ut.src=Ft,this.imageCache.set(kt,Ut)}let bt=null;if(Ut.complete&&Ut.naturalWidth>0?(bt=Ut,this.lastValidSvgImgMap.set(s.id,Ut)):bt=this.lastValidSvgImgMap.get(s.id)||null,bt&&bt.complete&&bt.naturalWidth>0){const O=Math.max(1,a),ct=Math.max(1,r);if(Z&&(U==null?void 0:U.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=O,this.maskBuffer.height=ct,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,O,ct),this.maskCtx.drawImage(bt,0,0,O,ct),this.maskCtx.globalCompositeOperation="source-in";const Dt=U.color||"#000000",xt=this.normalizeOpacity(U.opacity??100);this.maskCtx.fillStyle=Dt,this.maskCtx.globalAlpha=xt,this.maskCtx.fillRect(0,0,O,ct),t.drawImage(this.maskBuffer,-O/2,-ct/2,O,ct)}else h!==0?(t.save(),this.drawRoundRect(t,-O/2,-ct/2,O,ct,h),t.clip(),t.drawImage(bt,-O/2,-ct/2,O,ct),t.restore()):t.drawImage(bt,-O/2,-ct/2,O,ct)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,a,r);else if(s.type==="Shape"){if(this.applyPath(t,c,a,r,h),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const J=t.globalAlpha;if(((R=n.fill)==null?void 0:R.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const ft=n.fill.originalSrc||n.fill.src;let U=this.imageCache.get(ft);U||(U=new Image,U.src=ft,this.imageCache.set(ft,U)),U.complete&&U.naturalWidth>0&&(t.save(),this.applyPath(t,c,a,r,h),t.clip(),this.renderFittedImage(t,U,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const ft=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=ft||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=J*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,c,a,r,h),t.fill()}t.globalAlpha=J}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,c,a,r,h)}else if(s.type==="Frame"||s.type==="Group"&&!s.isStructuralGroup){const J=e.width??i.width??s.width??a,ft=e.height??i.height??s.height??r,U=h;if(t.save(),t.beginPath(),this.drawRoundRect(t,-J/2,-ft/2,J,ft,U),n.fill&&n.fill.type!=="None"){const G=t.globalAlpha,K=this.createCanvasFill(t,n.fill,J,ft);t.fillStyle=K||n.fill.color||"transparent",t.globalAlpha=G*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=G}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const G={type:"Rectangle"};this.applyStrokeAlignment(t,n,G,J,ft,U)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):s.type==="Checkbox"||s.type==="Component"&&s.variant==="checkbox"?this.renderCheckbox(t,s):s.type==="RadioGroup"||s.type==="Component"&&s.variant==="radiogroup"?this.renderRadioGroup(t,s):s.type==="BarChart"||s.type==="Component"&&s.variant==="barchart"?this.renderBarChart(t,s):s.type==="PieChart"||s.type==="Component"&&s.variant==="piechart"?this.renderPieChart(t,s):this.frameCount%60===0&&console.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(x=s.geometry)==null?void 0:x.type));if(this.applyArtEffectOverlay(t,s,c,a,r,h),dt&&St==="BackgroundBlur"&&this.applyBackgroundBlurGlass(t,c,a,r,h,it),ne&&ne.enabled&&t.restore(),s.children&&s.children.length>0){const ft=s.type==="Frame",U=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ft;if(t.save(),U){t.beginPath();const K=e.width??(i==null?void 0:i.width)??s.width??0,Z=e.height??(i==null?void 0:i.height)??s.height??0,Ot=e.cornerRadius??(i==null?void 0:i.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-K/2,-Z/2,K,Z,Ot),t.clip()}let G=0;for(s.children.forEach(K=>{const Z=o.get(K);if(!Z)return;const Ot=this.objectStates.get(K),At=(Ot==null?void 0:Ot.geometry)||Z.geometry;if(At&&At.isMask&&(Ot==null?void 0:Ot.visible)!==!1){const kt=At.width||0,Ut=At.height||0;this.applyObjectTransform(t,K);const bt=(Ot==null?void 0:Ot.corner_radius)??(At==null?void 0:At.corner_radius)??0;this.applyPath(t,At,kt,Ut,bt),t.clip(),G++}else this.renderObject(t,Z,o)});G>0;)t.restore(),G--;t.restore()}if(Mt){this.maskCtx.restore(),(e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(G=>G.isVisible!==!1&&o.has(G.maskId)).forEach(G=>{var bt,O,ct,Dt,xt,ie;const K=o.get(G.maskId),Z=this.objectStates.get(K.id),Ot=G.feather||0,At=G.inverted===!0,kt=G.opacity!==void 0?typeof G.opacity=="number"?G.opacity:G.opacity/100:1;if((G.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,K.id,o),Ot>0&&(this.lumaCtx.filter=`blur(${Ot}px)`),this.lumaCtx.globalAlpha=kt;const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((bt=K.geometry)==null?void 0:bt.type)==="Text"){const Ct=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,gt=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.lumaCtx,K,{...Ct,width:Wt,height:Bt,corner_radius:Ft},gt,Z,Wt,Bt,!0)}else if(((O=K.geometry)==null?void 0:O.type)==="Image"){const Ct=K.geometry.src;if(Ct){let gt=this.imageCache.get(Ct);gt||(gt=new Image,gt.src=Ct,this.imageCache.set(Ct,gt)),gt.complete&>.naturalWidth>0?this.lumaCtx.drawImage(gt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((ct=K.geometry)==null?void 0:ct.type)==="SVG"){const Ct=K.geometry.svgContent;if(Ct){const gt=`__lumamask_${K.id}`;let Lt=this.imageCache.get(gt);if(!Lt){Lt=new Image;const at=new Blob([Ct],{type:"image/svg+xml"});Lt.src=URL.createObjectURL(at),Lt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(gt,Lt)}Lt.complete&&Lt.naturalWidth>0?this.lumaCtx.drawImage(Lt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ot=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),It=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,vt=ot.data;for(let Ct=0;Ct<vt.length;Ct+=4){const gt=It[Ct],Lt=It[Ct+1],at=It[Ct+2];let st=(.299*gt+.587*Lt+.114*at)/255;At&&(st=1-st),vt[Ct+3]*=st}this.maskCtx.putImageData(ot,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=At?"destination-out":"destination-in",Ot>0&&(this.maskCtx.filter=`blur(${Ot}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,K.id,o);const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((Dt=K.geometry)==null?void 0:Dt.type)==="Text"){const ot=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,It=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.maskCtx,K,{...ot,width:Wt,height:Bt,corner_radius:Ft},It,Z,Wt,Bt,!0)}else if(((xt=K.geometry)==null?void 0:xt.type)==="Image"){const ot=K.geometry.src;if(ot){let It=this.imageCache.get(ot);It||(It=new Image,It.src=ot,this.imageCache.set(ot,It)),It.complete&&It.naturalWidth>0?this.maskCtx.drawImage(It,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((ie=K.geometry)==null?void 0:ie.type)==="SVG"){const ot=K.geometry.svgContent;if(ot){const It=`__alphamask_${K.id}`;let vt=this.imageCache.get(It);if(!vt){vt=new Image;const Ct=new Blob([ot],{type:"image/svg+xml"});vt.src=URL.createObjectURL(Ct),vt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(It,vt)}vt.complete&&vt.naturalWidth>0?this.maskCtx.drawImage(vt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),lt.save(),lt.setTransform(1,0,0,1,0,0);const U=s.maskBlendMode||s.blendMode;U&&U!=="Normal"&&(lt.globalCompositeOperation=U.toLowerCase()),lt.drawImage(this.maskBuffer,0,0),lt.restore(),lt.restore()}else t.restore()}}_renderText(t,s,o,e,i,n,a,r=!1,l=!1){var St,ht,mt,rt,Rt,Yt,Pt,zt,Xt;let h=o.text||"";if(o.textInputId&&!r){const B=this.inputs.get(o.textInputId);B!==void 0&&(h=String(B),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=h))}if(o.svgPath){const B=o.svgPath;t.save();const lt=((St=e==null?void 0:e.fill)==null?void 0:St.color)||"#000000",Vt=((ht=e==null?void 0:e.fill)==null?void 0:ht.opacity)!==void 0?(mt=e==null?void 0:e.fill)==null?void 0:mt.opacity:1;t.fillStyle=lt,t.globalAlpha*=Vt;const Mt=new Path2D(B);t.fill(Mt),t.restore();return}let c=h||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(B=>B&&B.text?B.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?c=c.toUpperCase():g==="lowercase"?c=c.toLowerCase():g==="capitalize"&&(c=c.replace(/\b\w/g,B=>B.toUpperCase()));let f=((rt=o.fontWeight)==null?void 0:rt.toString())||"400",d=o.fontStyle||"normal";f.toLowerCase().includes("italic")&&(d="italic",f=f.replace(/italic/gi,"").trim()||"400");const u=this.mapFontWeight(f),m=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const v=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];v.forEach(B=>{const lt=new RegExp(`[\\s-]${B}$`,"i");lt.test(y)&&(y=y.replace(lt,"").trim())});const S=`${o.smallCaps===!0?"small-caps ":""}${d} ${u} ${m}px "${y}", sans-serif`;t.font=S;const I=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let k=0;if(typeof o.letterSpacing=="number")k=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const B=o.letterSpacing;k=B.unit==="PERCENT"?B.value/100*m:B.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${k}px`);const E=o.kerning||"auto",T=o.kerningValue||0;E==="manual"&&T!==0&&(t.letterSpacing=`${k+T}px`);const W=o.paragraphSpacing||0;let M=o.lineHeight??1.2;typeof M=="string"&&(M=parseFloat(M)),M>5&&m>0&&(M=M/m);const _=(M||1.2)*m,R=o.isPointText===!0||!o.width||o.width<=0,x=((Rt=o.padding)==null?void 0:Rt.left)||((Yt=o.padding)==null?void 0:Yt.right)||0,L=R?1e5:o.width&&o.width>0?Math.ceil(o.width)-x*2:1e5;o.autoHeight;const $=De({text:c,fontFamily:y,fontSize:m,fontWeight:u,fontStyle:d,lineHeight:M,width:L,letterSpacing:k,paragraphSpacing:W,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),A=$.lines||[],V=$.maxFontSize||m,H=this.fontLeadingFactors[y]??.5,et=(_-m)*H;let P=$.height,F=-P/2;a>0&&a>P&&(I==="top"?F=-a/2:I==="middle"||I==="center"?F=-P/2:I==="bottom"&&(F=a/2-P)),F+=et;let q=null,Q=0;if(o.pathId&&this.artboard){const B=this.artboard.objects.find(lt=>lt.id===o.pathId);if(B&&B.type==="Shape"&&((Pt=B.geometry)==null?void 0:Pt.type)==="Path"){const lt=this.objectStates.get(B.id),Vt=lt!=null&<.geometry?this.deepMerge(B.geometry,lt.geometry):B.geometry,Mt=(lt==null?void 0:lt.scale_x)!==void 0?(B.width||0)*lt.scale_x:B.width||0,Tt=(lt==null?void 0:lt.scale_y)!==void 0?(B.height||0)*lt.scale_y:B.height||0;q={geo:Vt,obj:B,w:Mt,h:Tt},Q=this.getPerimeter(Vt,Mt,Tt)}}const it=(B,lt)=>{var Mt,Tt;if(k===0&&(!o.enableSegments||!((Mt=o.segments)!=null&&Mt.length)))return t.measureText(B).width;let Vt=0;for(let Nt=0;Nt<B.length;Nt++){const Jt=lt+Nt;let Kt=0;if(o.enableSegments===!0&&((Tt=o.segments)==null?void 0:Tt.length)>0){let Qt=0,te=null;for(const ce of o.segments){if(Jt<Qt+(ce.text||"").length){te=ce;break}Qt+=(ce.text||"").length}if(te){t.save();let ce=te.fontFamily||o.fontFamily||"Inter";const se=this.mapFontWeight((te.fontWeight||o.fontWeight||"400").toString()),ne=te.fontStyle||d,J=te.fontSize||m;t.font=`${ne} ${se} ${J}px "${ce}", sans-serif`,Kt=t.measureText(B[Nt]).width,t.restore()}else Kt=t.measureText(B[Nt]).width}else Kt=t.measureText(B[Nt]).width;Vt+=Kt+k}return Vt-(B.length>0?k:0)},dt=(B,lt,Vt,Mt,Tt)=>{var se,ne;const Jt=(Tt===0||c[Tt-1]===`
|
|
22
|
+
0 0 0 1 0"/>`,kt="invert"}if(G!==0||K!==0||Z!==0||Ot!==0){const bt=1+Z+Ot,L=bt*(1+G-K/2),ct=bt*(1+K),Dt=bt*(1-G-K/2),xt=Pt.shadows*.1/255,ie=[L,0,0,0,xt,0,ct,0,0,xt,0,0,Dt,0,xt,0,0,0,1,0].join(" ");At+=`<feColorMatrix in="${kt}" type="matrix" values="${ie}" result="advanced"/>`,kt="advanced"}if(Pt.blur&&(At+=`<feGaussianBlur in="${kt}" stdDeviation="${Pt.blur}" result="blur"/>`,kt="blur"),At){const bt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${At}</filter></svg>`,L=btoa(bt);q.push(`url('data:image/svg+xml;base64,${L}#f')`)}}q.length>0?t.filter=q.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const zt=t.globalAlpha,Xt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=zt*Xt;const B=e.compositeOperation||e.blendMode;if(B&&B!=="Normal"){const J=B.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(J)&&(t.globalCompositeOperation=J)}const lt=t,Vt=e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let Mt=!1;const Tt=Vt.filter(J=>J.isVisible!==!1&&o.has(J.maskId));if(Tt.length>0){const J=Tt[0],ft=o.get(J.maskId),U=this.objectStates.get(ft.id);U&&U.visible!==!1&&(Mt=!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),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=lt.filter)}t.translate(Math.round($),Math.round(A)),t.rotate(V*Math.PI/180);const Nt=e.skew_x||0,Jt=e.skew_y||0;(Nt!==0||Jt!==0)&&t.transform(1,Math.tan(Jt*Math.PI/180),Math.tan(Nt*Math.PI/180),1,0,0);const Kt=e.rotate_x||0,Qt=e.rotate_y||0,te=(e.flip_x===!0?-1:1)*Math.cos(Qt*Math.PI/180),ce=(e.flip_y===!0?-1:1)*Math.cos(Kt*Math.PI/180);t.scale(H*te,et*ce),n.shadow&&n.shadow.isEnabled!==!0&&((n.shadow.blur||0)>0||Math.abs(n.shadow.offsetX||0)>0||Math.abs(n.shadow.offsetY||0)>0)&&(n.shadow.isEnabled=!0);const se=n.shadow;if(se&&se.isEnabled!==!1){let J=se.color||"#000000";(T=(P=this.artboard)==null?void 0:P.tokens)!=null&&T.colors&&this.artboard.tokens.colors[J]&&(J=this.artboard.tokens.colors[J]);const ft=this.normalizeOpacity(se.opacity??100),U=se.spread||0,K=(se.blur||0)+U*1.5;let Z=J;if(J.startsWith("#")){const kt=J.replace("#",""),Ut=parseInt(kt.substring(0,2),16),bt=parseInt(kt.substring(2,4),16),L=parseInt(kt.substring(4,6),16);Z=`rgba(${Ut}, ${bt}, ${L}, ${ft})`}else if(J.startsWith("rgba")){const kt=J.match(/[\d.]+/g);if(kt&&kt.length>=4){const Ut=kt[0],bt=kt[1],L=kt[2],ct=kt[3];Z=`rgba(${Ut}, ${bt}, ${L}, ${parseFloat(ct)*ft})`}}const Ot=t.getTransform(),At=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1;t.shadowColor=Z,t.shadowBlur=K*At,t.shadowOffsetX=(se.offsetX||0)*At,t.shadowOffsetY=(se.offsetY||0)*At}const ne=s.liquidFill||((W=s.style)==null?void 0:W.liquidFill);if(ne&&ne.enabled){t.save();const J=ne.fillLevel??.5;t.beginPath();const ft=r/2-r*J;t.rect(-a/2,ft,a,r*J),t.clip(),t.fillStyle=ne.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ne.opacity??1)}if((i==null?void 0:i.type)==="Text")this._renderText(t,s,c,n,e,a,r);else if((i==null?void 0:i.type)==="Image"){const J=i.originalSrc||i.src;if(J){let ft=this.imageCache.get(J);ft||(ft=new Image,ft.onload=()=>{console.log(`[ExodeUI] Image loaded successfully, size: ${ft.naturalWidth}x${ft.naturalHeight}`)},ft.onerror=K=>{console.error("[ExodeUI] Image load failed:",K,`Src preview: ${J.substring(0,100)}...`)},ft.src=J,this.imageCache.set(J,ft));const U=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,G=(((k=n.stroke)==null?void 0:k.alignment)||"center").toLowerCase();if(U&&(G==="outside"||G==="center")&&this.applyStrokeAlignment(t,n,c,a,r,f),n.fill&&n.fill.type!=="None"){t.save();const K=t.globalAlpha,Z=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Z||n.fill.color||"transparent",t.globalAlpha=K*this.normalizeOpacity(n.fill.opacity??100),f!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,f),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=K,t.restore()}ft.complete&&ft.naturalWidth>0?(f!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,f),t.clip(),t.drawImage(ft,-a/2,-r/2,a,r),t.restore()):t.drawImage(ft,-a/2,-r/2,a,r),U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,f)):U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,f)}}else if(i.type==="SVG"){const J=i.svgContent;if(J){const ft=n.palette||[],U=n.fill,G=n.stroke,K=U?this.normalizeOpacity(U.opacity??100):1,Z=(U==null?void 0:U.type)==="Solid"&&(!G||G.isEnabled===!1||G.type==="Solid"&&G.color===U.color),Ot=U&&U.type!=="None"?Z?"monochrome":U.type==="Solid"?(U.color||"")+"|opacity:"+K:JSON.stringify(U.stops||[])+"|opacity:"+K:"",At=G&&G.isEnabled!==!1&&(G.width||0)>0?Z?["monochrome",G.width||0,G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):[G.width||0,G.fill?G.fill.type==="Solid"?G.fill.color||"":JSON.stringify(G.fill.stops||[]):G.color||"",G.opacity??1,G.lineCap||"",G.lineJoin||"",(G.dashArray||[]).join(","),G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):"nostroke",kt=[s.id,ft.join("_"),Ot,At,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let Ut=this.imageCache.get(kt);if(!Ut){Ut=new Image,Ut.crossOrigin="anonymous";let L=J;L.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(L=L.replace(/<svg([^>]*)>/i,(ot,It)=>`<svg xmlns="http://www.w3.org/2000/svg"${It}>`));let ct=i.width||a||100,Dt=i.height||r||100;const xt=L.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(xt&&(ct=parseFloat(xt[1]),Dt=parseFloat(xt[2])),L=L.replace(/<svg([^>]*)>/i,(ot,It)=>{let vt=It.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return vt.match(/\bviewBox=/i)||(vt+=` viewBox="0 0 ${ct} ${Dt}"`),vt.match(/\bpreserveAspectRatio=/i)||(vt+=' preserveAspectRatio="none"'),vt+=' width="100%" height="100%"',`<svg${vt}>`}),i.colors&&i.colors.length>0&&ft.length>0&&i.colors.forEach((ot,It)=>{if(ft[It]){const vt=ot.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),Ct=new RegExp(vt,"gi");L=L.replace(Ct,ft[It])}}),U&&U.type&&U.type!=="None"){if(U.type==="Solid"&&U.color){const ot=Z?"#FFFFFF":U.color,It=Z?1:this.normalizeOpacity(U.opacity??100);L=L.replace(/\bfill\s*=\s*["'][^"']*["']/gi,vt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(vt)?vt:`fill="${ot}"`),L=L.replace(/fill\s*:\s*[^;"')]+/gi,vt=>/fill\s*:\s*(none|transparent)/i.test(vt)?vt:`fill:${ot}`),It<1&&(L=L.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${It}"`),L=L.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${It}`),L.match(/\bfill-opacity\s*=/i)||(L=L.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${It}">`),L=L.replace(/<\/svg>/i,"</g></svg>")))}else if(U.type==="LinearGradient"||U.type==="RadialGradient"||U.type==="Linear"||U.type==="Radial"){const ot="exode-fill",It=this.normalizeOpacity(U.opacity??100),vt=(U.stops||[]).map(gt=>{const Lt=gt.offset!==void 0?gt.offset:gt.pos??0,at=this.normalizeOpacity(gt.opacity??100)*It;return`<stop offset="${Lt*100}%" stop-color="${gt.color||"#000"}" stop-opacity="${at}"/>`}).join("");let Ct="";if(U.type==="LinearGradient"||U.type==="Linear"){const gt=(wt,z)=>Array.isArray(wt)?wt[z]??(z===0?0:1):wt&&typeof wt=="object"?wt[z===0?"x":"y"]??(z===0?0:1):z===0?0:1,Lt=gt(U.start,0)*100,at=gt(U.start,1)*100,st=gt(U.end,0)*100,nt=gt(U.end,1)*100;Ct=`<linearGradient id="${ot}" x1="${Lt}%" y1="${at}%" x2="${st}%" y2="${nt}%" gradientUnits="objectBoundingBox">${vt}</linearGradient>`}else{const gt=(nt,wt)=>Array.isArray(nt)?nt[wt]??.5:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??.5:.5,Lt=gt(U.center,0)*100,at=gt(U.center,1)*100,st=(U.radius??.5)*100;Ct=`<radialGradient id="${ot}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${vt}</radialGradient>`}/<defs>/i.test(L)?L=L.replace(/<defs>/i,`<defs>${Ct}`):L=L.replace(/<svg([^>]*)>/i,`<svg$1><defs>${Ct}</defs>`),L=L.replace(/\bfill\s*=\s*["'][^"']*["']/gi,gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(gt)?gt:`fill="url(#${ot})"`),L=L.replace(/fill\s*:\s*[^;"')]+/gi,gt=>/fill\s*:\s*(none|transparent)/i.test(gt)?gt:`fill:url(#${ot})`)}}const ie=(ot,It,vt=1)=>{const Ct=(ot.stops||[]).map(nt=>{const wt=nt.offset!==void 0?nt.offset:nt.pos??0,z=this.normalizeOpacity(nt.opacity??100)*vt;return`<stop offset="${wt*100}%" stop-color="${nt.color||"#000"}" stop-opacity="${z}"/>`}).join(""),gt=(nt,wt,z=.5)=>Array.isArray(nt)?nt[wt]??z:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??z:z;if(ot.type==="LinearGradient"||ot.type==="Linear"){const nt=gt(ot.start,0,0)*100,wt=gt(ot.start,1,0)*100,z=gt(ot.end,0,1)*100,ut=gt(ot.end,1,1)*100;return`<linearGradient id="${It}" x1="${nt}%" y1="${wt}%" x2="${z}%" y2="${ut}%" gradientUnits="objectBoundingBox">${Ct}</linearGradient>`}const Lt=gt(ot.center,0,.5)*100,at=gt(ot.center,1,.5)*100,st=(ot.radius??.5)*100;return`<radialGradient id="${It}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${Ct}</radialGradient>`},Wt=(ot,It)=>/<defs>/i.test(ot)?ot.replace(/<defs>/i,`<defs>${It}`):ot.replace(/(<svg[^>]*>)/i,`$1<defs>${It}</defs>`);if(G&&G.isEnabled!==!1&&(G.width||0)>0){const ot=Z?1:this.normalizeOpacity(G.opacity??100),It=Z?"#FFFFFF":G.color||(U==null?void 0:U.color)||"#000000";let vt="";const Ct=G.fill;if(Ct&&Ct.type){if(Ct.type==="Solid")vt=Ct.color||G.color||"#000000";else if(Ct.type==="LinearGradient"||Ct.type==="RadialGradient"||Ct.type==="Linear"||Ct.type==="Radial"){const qt="exode-stroke";L=Wt(L,ie(Ct,qt,ot)),vt=`url(#${qt})`}}vt||(vt=It),L.match(/\bstroke\s*=\s*["']/i)?L=L.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,qt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(qt)?qt:`stroke="${vt}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${vt}"`),L=L.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${vt}`);let gt=i.width||a||100,Lt=i.height||r||100;const at=J.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(at){const qt=parseFloat(at[1]),oe=parseFloat(at[2]);!isNaN(qt)&&!isNaN(oe)&&(gt=qt,Lt=oe)}const st=Math.max(.001,a/gt),nt=Math.max(.001,r/Lt),wt=(st+nt)/2,z=(G.width||1)/wt;L.match(/\bstroke-width\s*=\s*["']/i)?L=L.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${z}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${z}"`),L=L.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${z}`),L.match(/\bstroke-opacity\s*=\s*["']/i)?L=L.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${ot}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${ot}"`),L=L.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${ot}`);const ut=G.lineCap||"round";L.match(/\bstroke-linecap\s*=\s*["']/i)?L=L.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${ut}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${ut}"`),L=L.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${ut}`);const pt=G.lineJoin||"round";L.match(/\bstroke-linejoin\s*=\s*["']/i)?L=L.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${pt}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${pt}"`),L=L.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${pt}`);const de=G.trimStart??0,be=G.trimEnd??1,Se=G.trimOffset??0,Ie=G.dashOffset??0,_e=de!==0||be!==1||Se!==0||Ie!==0;if(_e){const qt=Math.max(0,Math.min(1,de)),oe=Math.max(0,Math.min(1,be));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${qt}, End: ${oe}`);const ye=(gt+Lt)*2,we=(Se%1+1)%1,Me=(Ie%1+1)%1;let ue="",fe=0;if(qt>=oe)ue=`0 ${ye}`,fe=0;else{const he=ye*(oe-qt),ve=ye-he;fe=-(ye*(qt+we+Me)),ue=`${he} ${ve}`}L.match(/\bstroke-dasharray\s*=/i)?L=L.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ue}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ue}"`),L=L.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ue}`),L.match(/\bstroke-dashoffset\s*=/i)?L=L.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${fe}"`):L=L.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${fe}"`),L=L.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${fe}`)}else if(G.dashArray&&G.dashArray.length>0){const qt=G.dashArray.join(" ");L=L.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${qt}"`),L=L.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${qt}`),G.dashOffset&&(L=L.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${G.dashOffset}"`),L=L.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${G.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(J)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(J)){let qt="",oe="";if(_e){const ue=i.width||a||100,fe=i.height||r||100,he=(ue+fe)*2,ve=Math.max(0,Math.min(1,de)),Pe=Math.max(0,Math.min(1,be)),Fe=(Se%1+1)%1,$e=(Ie%1+1)%1;if(ve>=Pe)qt=` stroke-dasharray="0 ${he}"`,oe=' stroke-dashoffset="0"';else{const Ee=he*(Pe-ve),We=he-Ee,Be=-(he*(ve+Fe+$e));qt=` stroke-dasharray="${Ee} ${We}"`,oe=` stroke-dashoffset="${Be}"`}}else(_=G.dashArray)!=null&&_.length&&(qt=` stroke-dasharray="${G.dashArray.join(" ")}"`,G.dashOffset&&(oe=` stroke-dashoffset="${G.dashOffset}"`));const ye=` stroke-linecap="${G.lineCap||"round"}"`,we=` stroke-linejoin="${G.lineJoin||"round"}"`,Me=`stroke="${vt}" stroke-width="${z}" stroke-opacity="${ot}"${ye}${we}${qt}${oe}`;L=L.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ue,fe,he)=>`${fe}${he}<g ${Me}>`),L=L.replace(/<\/svg>/i,"</g></svg>")}}else G&&G.isEnabled===!1&&(L=L.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),L=L.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Bt=new Blob([L],{type:"image/svg+xml"}),Ft=URL.createObjectURL(Bt);Ut.onload=()=>{if(URL.revokeObjectURL(Ft),this.frameCount%900===0){const ot=this.imageCache.get(kt);ot&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${ot.naturalWidth}x${ot.naturalHeight})`)}},Ut.onerror=()=>{URL.revokeObjectURL(Ft),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Ut.src=Ft,this.imageCache.set(kt,Ut)}let bt=null;if(Ut.complete&&Ut.naturalWidth>0?(bt=Ut,this.lastValidSvgImgMap.set(s.id,Ut)):bt=this.lastValidSvgImgMap.get(s.id)||null,bt&&bt.complete&&bt.naturalWidth>0){const L=Math.max(1,a),ct=Math.max(1,r);if(Z&&(U==null?void 0:U.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=L,this.maskBuffer.height=ct,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,L,ct),this.maskCtx.drawImage(bt,0,0,L,ct),this.maskCtx.globalCompositeOperation="source-in";const Dt=U.color||"#000000",xt=this.normalizeOpacity(U.opacity??100);this.maskCtx.fillStyle=Dt,this.maskCtx.globalAlpha=xt,this.maskCtx.fillRect(0,0,L,ct),t.drawImage(this.maskBuffer,-L/2,-ct/2,L,ct)}else f!==0?(t.save(),this.drawRoundRect(t,-L/2,-ct/2,L,ct,f),t.clip(),t.drawImage(bt,-L/2,-ct/2,L,ct),t.restore()):t.drawImage(bt,-L/2,-ct/2,L,ct)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,a,r);else if(s.type==="Shape"){if(this.applyPath(t,c,a,r,f),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const J=t.globalAlpha;if(((R=n.fill)==null?void 0:R.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const ft=n.fill.originalSrc||n.fill.src;let U=this.imageCache.get(ft);U||(U=new Image,U.src=ft,this.imageCache.set(ft,U)),U.complete&&U.naturalWidth>0&&(t.save(),this.applyPath(t,c,a,r,f),t.clip(),this.renderFittedImage(t,U,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const ft=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=ft||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=J*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,c,a,r,f),t.fill()}t.globalAlpha=J}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,c,a,r,f)}else if(s.type==="Frame"||s.type==="Group"&&!s.isStructuralGroup){const J=e.width??i.width??s.width??a,ft=e.height??i.height??s.height??r,U=f;if(t.save(),t.beginPath(),this.drawRoundRect(t,-J/2,-ft/2,J,ft,U),n.fill&&n.fill.type!=="None"){const G=t.globalAlpha,K=this.createCanvasFill(t,n.fill,J,ft);t.fillStyle=K||n.fill.color||"transparent",t.globalAlpha=G*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=G}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const G={type:"Rectangle"};this.applyStrokeAlignment(t,n,G,J,ft,U)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):s.type==="Checkbox"||s.type==="Component"&&s.variant==="checkbox"?this.renderCheckbox(t,s):s.type==="RadioGroup"||s.type==="Component"&&s.variant==="radiogroup"?this.renderRadioGroup(t,s):s.type==="BarChart"||s.type==="Component"&&s.variant==="barchart"?this.renderBarChart(t,s):s.type==="PieChart"||s.type==="Component"&&s.variant==="piechart"?this.renderPieChart(t,s):this.frameCount%60===0&&console.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(x=s.geometry)==null?void 0:x.type));if(this.applyArtEffectOverlay(t,s,c,a,r,f),dt&&St==="BackgroundBlur"&&this.applyBackgroundBlurGlass(t,c,a,r,f,it),ne&&ne.enabled&&t.restore(),s.children&&s.children.length>0){const ft=s.type==="Frame",U=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ft;if(t.save(),U){t.beginPath();const K=e.width??(i==null?void 0:i.width)??s.width??0,Z=e.height??(i==null?void 0:i.height)??s.height??0,Ot=e.cornerRadius??(i==null?void 0:i.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-K/2,-Z/2,K,Z,Ot),t.clip()}let G=0;for(s.children.forEach(K=>{const Z=o.get(K);if(!Z)return;const Ot=this.objectStates.get(K),At=(Ot==null?void 0:Ot.geometry)||Z.geometry;if(At&&At.isMask&&(Ot==null?void 0:Ot.visible)!==!1){const kt=At.width||0,Ut=At.height||0;this.applyObjectTransform(t,K);const bt=(Ot==null?void 0:Ot.corner_radius)??(At==null?void 0:At.corner_radius)??0;this.applyPath(t,At,kt,Ut,bt),t.clip(),G++}else this.renderObject(t,Z,o)});G>0;)t.restore(),G--;t.restore()}if(Mt){this.maskCtx.restore(),(e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(G=>G.isVisible!==!1&&o.has(G.maskId)).forEach(G=>{var bt,L,ct,Dt,xt,ie;const K=o.get(G.maskId),Z=this.objectStates.get(K.id),Ot=G.feather||0,At=G.inverted===!0,kt=G.opacity!==void 0?typeof G.opacity=="number"?G.opacity:G.opacity/100:1;if((G.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,K.id,o),Ot>0&&(this.lumaCtx.filter=`blur(${Ot}px)`),this.lumaCtx.globalAlpha=kt;const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((bt=K.geometry)==null?void 0:bt.type)==="Text"){const Ct=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,gt=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.lumaCtx,K,{...Ct,width:Wt,height:Bt,corner_radius:Ft},gt,Z,Wt,Bt,!0)}else if(((L=K.geometry)==null?void 0:L.type)==="Image"){const Ct=K.geometry.src;if(Ct){let gt=this.imageCache.get(Ct);gt||(gt=new Image,gt.src=Ct,this.imageCache.set(Ct,gt)),gt.complete&>.naturalWidth>0?this.lumaCtx.drawImage(gt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((ct=K.geometry)==null?void 0:ct.type)==="SVG"){const Ct=K.geometry.svgContent;if(Ct){const gt=`__lumamask_${K.id}`;let Lt=this.imageCache.get(gt);if(!Lt){Lt=new Image;const at=new Blob([Ct],{type:"image/svg+xml"});Lt.src=URL.createObjectURL(at),Lt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(gt,Lt)}Lt.complete&&Lt.naturalWidth>0?this.lumaCtx.drawImage(Lt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ot=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),It=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,vt=ot.data;for(let Ct=0;Ct<vt.length;Ct+=4){const gt=It[Ct],Lt=It[Ct+1],at=It[Ct+2];let st=(.299*gt+.587*Lt+.114*at)/255;At&&(st=1-st),vt[Ct+3]*=st}this.maskCtx.putImageData(ot,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=At?"destination-out":"destination-in",Ot>0&&(this.maskCtx.filter=`blur(${Ot}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,K.id,o);const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((Dt=K.geometry)==null?void 0:Dt.type)==="Text"){const ot=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,It=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.maskCtx,K,{...ot,width:Wt,height:Bt,corner_radius:Ft},It,Z,Wt,Bt,!0)}else if(((xt=K.geometry)==null?void 0:xt.type)==="Image"){const ot=K.geometry.src;if(ot){let It=this.imageCache.get(ot);It||(It=new Image,It.src=ot,this.imageCache.set(ot,It)),It.complete&&It.naturalWidth>0?this.maskCtx.drawImage(It,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((ie=K.geometry)==null?void 0:ie.type)==="SVG"){const ot=K.geometry.svgContent;if(ot){const It=`__alphamask_${K.id}`;let vt=this.imageCache.get(It);if(!vt){vt=new Image;const Ct=new Blob([ot],{type:"image/svg+xml"});vt.src=URL.createObjectURL(Ct),vt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(It,vt)}vt.complete&&vt.naturalWidth>0?this.maskCtx.drawImage(vt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),lt.save(),lt.setTransform(1,0,0,1,0,0);const U=s.maskBlendMode||s.blendMode;U&&U!=="Normal"&&(lt.globalCompositeOperation=U.toLowerCase()),lt.drawImage(this.maskBuffer,0,0),lt.restore(),lt.restore()}else t.restore()}}_renderText(t,s,o,e,i,n,a,r=!1,l=!1){var St,ht,mt,rt,Rt,Yt,Pt,zt,Xt;let f=o.text||"";if(o.textInputId&&!r){const B=this.inputs.get(o.textInputId);B!==void 0&&(f=String(B),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=f))}if(o.svgPath){const B=o.svgPath;t.save();const lt=((St=e==null?void 0:e.fill)==null?void 0:St.color)||"#000000",Vt=((ht=e==null?void 0:e.fill)==null?void 0:ht.opacity)!==void 0?(mt=e==null?void 0:e.fill)==null?void 0:mt.opacity:1;t.fillStyle=lt,t.globalAlpha*=Vt;const Mt=new Path2D(B);t.fill(Mt),t.restore();return}let c=f||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(B=>B&&B.text?B.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?c=c.toUpperCase():g==="lowercase"?c=c.toLowerCase():g==="capitalize"&&(c=c.replace(/\b\w/g,B=>B.toUpperCase()));let h=((rt=o.fontWeight)==null?void 0:rt.toString())||"400",d=o.fontStyle||"normal";h.toLowerCase().includes("italic")&&(d="italic",h=h.replace(/italic/gi,"").trim()||"400");const p=this.mapFontWeight(h),m=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const v=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];v.forEach(B=>{const lt=new RegExp(`[\\s-]${B}$`,"i");lt.test(y)&&(y=y.replace(lt,"").trim())});const S=`${o.smallCaps===!0?"small-caps ":""}${d} ${p} ${m}px "${y}", sans-serif`;t.font=S;const I=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let M=0;if(typeof o.letterSpacing=="number")M=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const B=o.letterSpacing;M=B.unit==="PERCENT"?B.value/100*m:B.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${M}px`);const P=o.kerning||"auto",T=o.kerningValue||0;P==="manual"&&T!==0&&(t.letterSpacing=`${M+T}px`);const W=o.paragraphSpacing||0;let k=o.lineHeight??1.2;typeof k=="string"&&(k=parseFloat(k)),k>5&&m>0&&(k=k/m);const _=(k||1.2)*m,R=o.isPointText===!0||!o.width||o.width<=0,x=((Rt=o.padding)==null?void 0:Rt.left)||((Yt=o.padding)==null?void 0:Yt.right)||0,O=R?1e5:o.width&&o.width>0?Math.ceil(o.width)-x*2:1e5;o.autoHeight;const $=De({text:c,fontFamily:y,fontSize:m,fontWeight:p,fontStyle:d,lineHeight:k,width:O,letterSpacing:M,paragraphSpacing:W,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),A=$.lines||[],V=$.maxFontSize||m,H=this.fontLeadingFactors[y]??.5,et=(_-m)*H;let E=$.height,F=-E/2;a>0&&a>E&&(I==="top"?F=-a/2:I==="middle"||I==="center"?F=-E/2:I==="bottom"&&(F=a/2-E)),F+=et;let q=null,Q=0;if(o.pathId&&this.artboard){const B=this.artboard.objects.find(lt=>lt.id===o.pathId);if(B&&B.type==="Shape"&&((Pt=B.geometry)==null?void 0:Pt.type)==="Path"){const lt=this.objectStates.get(B.id),Vt=lt!=null&<.geometry?this.deepMerge(B.geometry,lt.geometry):B.geometry,Mt=(lt==null?void 0:lt.scale_x)!==void 0?(B.width||0)*lt.scale_x:B.width||0,Tt=(lt==null?void 0:lt.scale_y)!==void 0?(B.height||0)*lt.scale_y:B.height||0;q={geo:Vt,obj:B,w:Mt,h:Tt},Q=this.getPerimeter(Vt,Mt,Tt)}}const it=(B,lt)=>{var Mt,Tt;if(M===0&&(!o.enableSegments||!((Mt=o.segments)!=null&&Mt.length)))return t.measureText(B).width;let Vt=0;for(let Nt=0;Nt<B.length;Nt++){const Jt=lt+Nt;let Kt=0;if(o.enableSegments===!0&&((Tt=o.segments)==null?void 0:Tt.length)>0){let Qt=0,te=null;for(const ce of o.segments){if(Jt<Qt+(ce.text||"").length){te=ce;break}Qt+=(ce.text||"").length}if(te){t.save();let ce=te.fontFamily||o.fontFamily||"Inter";const se=this.mapFontWeight((te.fontWeight||o.fontWeight||"400").toString()),ne=te.fontStyle||d,J=te.fontSize||m;t.font=`${ne} ${se} ${J}px "${ce}", sans-serif`,Kt=t.measureText(B[Nt]).width,t.restore()}else Kt=t.measureText(B[Nt]).width}else Kt=t.measureText(B[Nt]).width;Vt+=Kt+M}return Vt-(B.length>0?M:0)},dt=(B,lt,Vt,Mt,Tt)=>{var se,ne;const Jt=(Tt===0||c[Tt-1]===`
|
|
23
23
|
`||c[Tt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,Kt=(!r||l)&&(s.behaviors||[]).some(J=>J.enabled&&(J.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(J.type))),Qt=!o.pathId&&!Kt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),te=o.baselineShift||0,ce=Vt+te;if(Qt)t.font=S,Mt?t.strokeText(B,lt+Jt,ce):t.fillText(B,lt+Jt,ce);else{const J=it(B,Tt);let ft=lt+Jt;w==="center"?ft-=J/2:w==="right"&&(ft-=J);const U=Tt+B.length>=c.length||c[Tt+B.length]===`
|
|
24
|
-
`||c[Tt+B.length]==="\r";let G=0,K=0;const Z=o.justifyMinWordSpacing,Ot=o.justifyMaxWordSpacing;if(w==="justify"&&!U&&J>0&&!o.pathId){const bt=R?J:
|
|
24
|
+
`||c[Tt+B.length]==="\r";let G=0,K=0;const Z=o.justifyMinWordSpacing,Ot=o.justifyMaxWordSpacing;if(w==="justify"&&!U&&J>0&&!o.pathId){const bt=R?J:O-x*2+0,L=Math.max(0,bt-J);for(let ct=0;ct<B.length;ct++)B[ct]===" "&&K++;if(K>0){const ct=t.measureText(" ").width;let Dt=Z||ct*.5,xt=Ot||ct*2.5;G=Math.max(0,Math.min(L/K,xt-Dt))}}let At=o.pathOffset||0;o.pathId&&Q>0&&q&&(w==="center"?At+=Q/2-J/2:w==="right"&&(At+=Q-J));let kt=ft;const Ut=r&&!l?[]:((se=s.behaviors)==null?void 0:se.filter(bt=>[Y.Typewriter,Y.Scramble,Y.Wave,Y.Bounce,Y.GlitchText,Y.TextTrail,Y.Reveal3D,Y.RevealSlide,Y.RevealBlur,Y.TextLiquid,Y.TextVortex,Y.TextExplosion,Y.TextRain,Y.TextGravity,Y.TextElastic,Y.TextMatrix,Y.TextNeon,Y.TextGlitch3D,Y.TextDissolve,Y.TextOrganic,Y.TextBreathe,Y.TextFloral,Y.TextSmoke,Y.TextVariable,Y.TextMagnet,Y.TextSpin,Y.TextZing,Y.TextPerspective,Y.TextMirror].includes(bt.type)&&bt.enabled))||[];for(let bt=0;bt<B.length;bt++){let L=B[bt];const ct=Tt+bt;let Dt=0,xt=0,ie=1,Wt=1,Bt=0,Ft=1,ot=L;Ut.forEach(at=>{const st=at.settings||{},nt=st.strength||1,wt=Date.now();if(at.type===Y.Typewriter)this.currentTime*(st.speed||1)-ct*(st.stagger||.05)<0&&(Ft=0);else if(at.type===Y.Scramble)Math.max(0,Math.min(1,this.currentTime/(st.duration||1.5))-ct*.02)<1&&Math.random()<.3&&(ot="$%#@!*&"[Math.floor(Math.random()*7)]);else if(at.type===Y.Wave)xt+=Math.sin(this.currentTime*5*(st.speed||1)+ct*(st.frequency||1))*(st.amplitude||20)*nt;else if(at.type===Y.Bounce){const z=Math.max(0,this.currentTime%2-ct*(st.stagger||.1));z<1&&(xt-=Math.abs(Math.sin(z*Math.PI))*(st.height||50)*nt)}else if(at.type===Y.TextTrail){const z=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-ct*(st.delay||5))];z&&(Dt+=(z.x-(i.x+kt))*nt*.2,xt+=(z.y-(i.y+Vt+xt))*nt*.2)}else if(at.type===Y.Reveal3D){const z=Math.max(0,Math.min(1,this.currentTime*(st.speed||1)-ct*(st.stagger||.1)));ie*=z,Wt*=z,Ft=z}else if(at.type===Y.RevealSlide){const z=Math.max(0,Math.min(1,this.currentTime*1.5-ct*.05)),ut=(1-z)*(st.distance||40)*nt,pt=st.direction||"up";pt==="up"?xt-=ut:pt==="down"?xt+=ut:pt==="left"?Dt-=ut:pt==="right"&&(Dt+=ut),Ft=z}else if(at.type===Y.RevealBlur){const z=Math.max(0,Math.min(1,this.currentTime*1.2-ct*.1));Ft=z,Dt+=(1-z)*5}else if(at.type===Y.TextLiquid){const z=Math.max(0,Math.sin(wt*.001*(st.speed||1)+ct*.5));xt+=z*(st.amplitude||10)*nt,Wt*=1+z*.2}else if(at.type===Y.TextVortex){const z=wt*.002*(st.speed||1)+ct*.2,ut=(1-(Math.sin(wt*.001)*.5+.5))*(st.radius||50);Dt+=Math.cos(z)*ut*nt,xt+=Math.sin(z)*ut*nt}else if(at.type===Y.TextExplosion){const z=st.force||1,ut=this.currentTime%2;if(ut<1){const pt=(ct/B.length-.5)*Math.PI*2,de=ut*100*z;Dt+=Math.cos(pt)*de*nt,xt+=Math.sin(pt)*de*nt,Ft=1-ut}}else if(at.type===Y.TextRain){const z=st.speed||1,ut=st.height||100,pt=(wt*.001*z+ct*.1)%1;xt-=(1-pt)*ut*nt,Ft=pt>.1?1:pt*10}else if(at.type===Y.TextGravity){const z=st.gravity||9.8,ut=this.currentTime%3/3,pt=.5*z*Math.pow(ut*10,2);pt<100?xt+=pt*nt:xt+=100*nt}else if(at.type===Y.TextMatrix){const z=st.speed||1;if(Math.random()<.1*z){const pt="0123456789ABCDEF!@#$%^&*";ot=pt[Math.floor(Math.random()*pt.length)]}Ft=.3+(Math.sin(wt*.01*z+ct)+1)/2*.7}else if(at.type===Y.TextNeon){const z=Math.random()>.95?.5:1;Ft=(.7+(Math.sin(wt*.005)+1)/2*.3)*z}else if(at.type===Y.TextDissolve)Math.sin(ct*1.5+wt*.002*(st.speed||1))>.5&&(Ft=0);else if(at.type===Y.TextOrganic){const z=st.speed||1,ut=st.amplitude||10;Dt+=Math.sin(wt*.002*z+ct)*ut*nt,xt+=Math.cos(wt*.0015*z+ct*.7)*ut*nt}else if(at.type===Y.TextBreathe){const ut=1+(Math.sin(wt*.003+ct*.2)+1)/2*.2*nt;ie*=ut,Wt*=ut}else if(at.type===Y.TextSpin){const z=st.speed||1;Bt+=wt*.01*z+ct}else if(at.type===Y.TextMagnet){const z=this.pointerHistory[this.pointerHistory.length-1];if(z){const ut=z.x-(i.x+kt),pt=z.y-(i.y+Vt);Bt=Math.atan2(pt,ut)}}else if(at.type===Y.TextPerspective){const z=B.length/2,ut=(ct-z)/z,pt=1-Math.abs(ut)*.3*nt;ie*=pt,Wt*=pt,Dt+=ut*20*nt}else if(at.type===Y.TextMirror)Ft*=.8;else if(at.type===Y.TextFloral){const z=st.speed||1,ut=st.stagger||.1,pt=(wt*.001*z+ct*ut)%2;pt<1&&(ie*=pt,Wt*=pt,Bt+=pt*Math.PI)}else if(at.type===Y.TextSmoke){const z=st.speed||1,ut=st.height||50,pt=(wt*5e-4*z+ct*.2)%1;xt-=pt*ut*nt,Dt+=Math.sin(wt*.002+ct)*5*nt,Ft=1-pt}else if(at.type===Y.TextVariable){const z=st.speed||1,ut=st.intensity||1.5,pt=(Math.sin(wt*.004*z+ct*.3)+1)/2;ie*=1+pt*(ut-1)*nt}else if(at.type===Y.TextZing){const z=st.speed||2,ut=st.distance||100,pt=(wt*.002*z+ct*.05)%1;Dt+=(1-pt)*ut*nt,Ft=pt}else if(at.type===Y.TextElastic){const z=st.stiffness||.2,ut=st.damping||.1,pt=Math.sin(wt*.01)*Math.exp(-wt*.001*ut);Wt*=1+pt*z*nt}else if(at.type===Y.TextGlitch3D){const z=st.intensity||5;Math.random()<.2&&(Dt+=(Math.random()-.5)*z,xt+=(Math.random()-.5)*z,Ft=.8)}else if(at.type===Y.GlitchText){const z=st.intensity||5;Math.random()<.1&&(Dt+=(Math.random()-.5)*z,xt+=(Math.random()-.5)*z,Math.random()<.05&&(Ft=.5))}});let It=null,vt=o.textDecoration||"none",Ct=m;if(o.enableSegments===!0&&((ne=o.segments)==null?void 0:ne.length)>0){let at=0,st=null;for(const nt of o.segments){if(ct<at+(nt.text||"").length){st=nt;break}at+=(nt.text||"").length}if(st){let nt=st.fontFamily||o.fontFamily||"Inter";v.forEach(ut=>{const pt=new RegExp(`[\\s-]${ut}$`,"i");pt.test(nt)&&(nt=nt.replace(pt,"").trim())});const wt=this.mapFontWeight((st.fontWeight||o.fontWeight||"400").toString()),z=st.fontStyle||d;Ct=st.fontSize||m,t.font=`${z} ${wt} ${Ct}px "${nt}", sans-serif`,st.fill&&(It=st.fill),st.textDecoration&&(vt=st.textDecoration),Ct<V&&(xt+=(V-Ct)*.85)}}else t.font=S;const gt=t.globalAlpha;t.globalAlpha*=Ft,t.save();const Lt=t.measureText(ot).width;if(q&&Q>0){const at=kt-ft+Lt/2,nt=(At+at)/Q,wt=this.getPointOnPath(q.geo,q.w,q.h,Math.abs(nt%1)),z=wt.angle,ut=Vt+xt+(o.pathOffsetY||0),pt=o.pathSide==="right"?-1:1,de=Math.cos(z+Math.PI/2)*ut*pt,be=Math.sin(z+Math.PI/2)*ut*pt;t.translate(wt.x+de+Dt,wt.y+be),t.rotate(z+Bt+(pt===-1?Math.PI:0))}else t.translate(kt+Dt+Lt/2,Vt+xt),Bt!==0&&t.rotate(Bt);if(t.scale(ie,Wt),It&&!r&&!l){const at=this.createCanvasFill(t,It,n,a);t.fillStyle=at||It.color||"#000000"}else if(!r&&!l){const at=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=at||e.fill.color||"#000000"}if(Ft>0)if(r||l){const at=l?"#000000":this.createCanvasFill(t,e.fill,n,a);t.fillStyle=at||e.fill.color||"#ffffff",t.fillText(ot,-Lt/2,0)}else Mt?t.strokeText(ot,-Lt/2,0):t.fillText(ot,-Lt/2,0);vt!=="none"&&!r&&this.drawTextDecoration(t,vt,0,0,Lt,Ct),t.restore(),t.globalAlpha=gt,w==="justify"&&G>0&&ot===" "&&!U?kt+=Lt+M+G:kt+=Lt+M}}};if(r){let B=0,lt=F;(A||[]).forEach(Vt=>{const Mt=Vt.text||"",Tt=c.indexOf(Mt,B);Tt!==-1&&(B=Tt);let Nt=-n/2;w==="center"?Nt=0:w==="right"&&(Nt=n/2),dt(Mt,Nt,lt,!1,B),B+=Mt.length,lt+=_})}else if(l){let B=0,lt=F;(A||[]).forEach(Vt=>{const Mt=Vt.text||"";let Tt=-n/2;w==="center"?Tt=0:w==="right"&&(Tt=n/2),dt(Mt,Tt,lt,!1,B),B+=Mt.length,B<c.length&&(c[B]===`
|
|
25
25
|
`||c[B]==="\r")&&(B++,c[B-1]==="\r"&&c[B]===`
|
|
26
26
|
`&&B++),lt+=_})}else{if(e.fill){const lt=t.globalAlpha,Vt=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=Vt||e.fill.color||"#000000",t.globalAlpha=lt*this.normalizeOpacity(e.fill.opacity??100);const Mt=$.fullText||(o.enableSegments?(o.segments||[]).map(Jt=>{let Kt=Jt.text||"";const Qt=Jt.textCase||o.textCase||"none";return Qt==="uppercase"?Kt.toUpperCase():Qt==="lowercase"?Kt.toLowerCase():Qt==="capitalize"?Kt.replace(/\b\w/g,te=>te.toUpperCase()):Kt}).join(""):c);let Tt=0,Nt=F;(A||[]).forEach(Jt=>{const Kt=Jt.text||"";let Qt=-n/2;w==="center"?Qt=0:w==="right"&&(Qt=n/2),dt(Kt,Qt,Nt,!1,Tt),Tt+=Kt.length,Nt+=_,Tt<Mt.length&&(Mt[Tt]===`
|
|
27
27
|
`||Mt[Tt]==="\r")&&(W>0&&(Nt+=W),Tt++,Mt[Tt-1]==="\r"&&Mt[Tt]===`
|
|
28
28
|
`&&Tt++)}),t.globalAlpha=lt}const B=o.paragraphRule;if(B&&(((zt=B.top)==null?void 0:zt.width)>0||((Xt=B.bottom)==null?void 0:Xt.width)>0)){let lt=0;(A||[]).forEach((Vt,Mt)=>{var Jt,Kt;const Nt=lt===0||lt<c.length&&(c[lt]===`
|
|
29
29
|
`||c[lt]==="\r");if(Nt&&Mt>0&<++,Nt){if(((Jt=B.top)==null?void 0:Jt.width)>0){const Qt=F+Mt*_-B.top.offset;t.strokeStyle=B.top.color||"#000000",t.lineWidth=B.top.width,t.beginPath();const te=-n/2+_*.2;t.moveTo(te,Qt),t.lineTo(n/2-_*.2,Qt),t.stroke()}if(((Kt=B.bottom)==null?void 0:Kt.width)>0){const Qt=F+(Mt+1)*_-B.bottom.offset;t.strokeStyle=B.bottom.color||"#000000",t.lineWidth=B.bottom.width,t.beginPath();const te=-n/2+_*.2;t.moveTo(te,Qt),t.lineTo(n/2-_*.2,Qt),t.stroke()}}lt+=(Vt.text||"").length})}if(e.stroke&&e.stroke.width>0){const lt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color,t.lineWidth=e.stroke.width,t.globalAlpha=lt*this.normalizeOpacity(e.stroke.opacity??100);let Mt=0,Tt=F;(A||[]).forEach(Nt=>{let Jt=-n/2;w==="center"?Jt=0:w==="right"&&(Jt=n/2),dt(Nt.text,Jt,Tt,!0,Mt),Mt+=(Nt.text||"").length,Tt+=_,Mt<c.length&&(c[Mt]===`
|
|
30
30
|
`||c[Mt]==="\r")&&(W>0&&(Tt+=W),Mt++,c[Mt-1]==="\r"&&c[Mt]===`
|
|
31
|
-
`&&Mt++)}),t.globalAlpha=lt}}}applyStrokeAlignment(t,s,o,e,i,n){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=a.width,l=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,i);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const c=t.globalAlpha;t.globalAlpha=c*this.normalizeOpacity(a.opacity??100),t.lineWidth=r,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const g=a.trimStart??0,f=a.trimEnd??1,d=a.trimOffset??0,u=a.dashOffset??0,m=a.dashArray||[];if(g!==0||f!==1||d!==0){const y=this.getPerimeter(o,e,i);if(y>0){const v=Math.max(0,Math.min(1,g)),b=Math.max(0,Math.min(1,f));if(v<b){const C=y*(b-v),S=y-C,I=-(y*(v+d%1));t.setLineDash([C,S]),t.lineDashOffset=I+u*y}else if(v===b)t.setLineDash([0,y]);else{const C=y*(1-v+b),S=y-C,I=-(y*v);t.setLineDash([C,S]),t.lineDashOffset=I+u*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=u);(o==null?void 0:o.type)==="Line"||e===0||i===0?(this.applyPath(t,o,e,i,n),t.stroke()):l==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore()):l==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,i,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,i,n),t.fill(),t.restore()):(t.lineWidth=r,this.applyPath(t,o,e,i,n),t.stroke()),t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let l=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));l+=n/360*h,n<360&&(l+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(l+=2*Math.max(e,i));return isNaN(l)?0:l}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){n=l.x,a=l.y;continue}const h=n,c=a,g=e[r-1].out_x,f=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?i+=this.getBezierLength(h,c,g??h,f??c,l.in_x??l.x,l.in_y??l.y,l.x,l.y):i+=Math.sqrt((l.x-h)**2+(l.y-c)**2),n=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,m=[...e.slice(0,r+1)].reverse().find(w=>w.moveTo)||e[0],y=m.x,v=m.y,b=e[r].out_x,C=e[r].out_y,S=m.in_x,I=m.in_y;b!==void 0||S!==void 0?i+=this.getBezierLength(d,u,b??d,C??u,S??y,I??v,y,v):i+=Math.sqrt((y-d)**2+(v-u)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,l=10){let h=0,c=t,g=s;for(let f=1;f<=l;f++){const d=f/l,u=1-d,m=d*d,y=u*u,v=y*u,b=m*d,C=v*t+3*y*d*o+3*u*m*i+b*a,S=v*s+3*y*d*e+3*u*m*n+b*r,I=C-c,w=S-g;h+=Math.sqrt(I*I+w*w),c=C,g=S}return h}getBezierTAtLength(t,s,o,e,i,n,a,r,l,h=20){if(t<=0)return 0;let c=0,g=s,f=o;for(let d=1;d<=h;d++){const u=d/h,m=1-u,y=u*u,v=m*m,b=v*m,C=y*u,S=b*s+3*v*u*e+3*m*y*n+C*r,I=b*o+3*v*u*i+3*m*y*a+C*l,w=S-g,k=I-f,E=Math.sqrt(w*w+k*k);if(c+E>=t){const T=t-c,W=E===0?0:T/E;return(d-1+W)/h}c+=E,g=S,f=I}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,l=-1/0;i.forEach(v=>{typeof v.x=="number"&&typeof v.y=="number"&&(n=Math.min(n,v.x),a=Math.max(a,v.x),r=Math.min(r,v.y),l=Math.max(l,v.y),v.out_x!==void 0&&(n=Math.min(n,v.out_x),a=Math.max(a,v.out_x)),v.out_y!==void 0&&(r=Math.min(r,v.out_y),l=Math.max(l,v.out_y)),v.in_x!==void 0&&(n=Math.min(n,v.in_x),a=Math.max(a,v.in_x)),v.in_y!==void 0&&(r=Math.min(r,v.in_y),l=Math.max(l,v.in_y)))});const h=(n+a)/2,c=(r+l)/2,f=this.getPerimeter(t,s,o)*e;let d=0;const u=[];let m=i[0],y=i[0];for(let v=1;v<i.length;v++){const b=i[v];if(b.moveTo){m=b,y=b;continue}u.push({p0:m,p1:b}),(b.closePath||v===i.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:b,p1:y}),m=b}for(const v of u){const b=v.p0,C=v.p1;let S=0;const I=b.out_x!==void 0||C.in_x!==void 0;if(I?S=this.getBezierLength(b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y):S=Math.sqrt((C.x-b.x)**2+(C.y-b.y)**2),d+S>=f||v===u[u.length-1]){let w=0;if(I)return w=this.getBezierTAtLength(f-d,b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y,20),this.getBezierPointAndAngle(w,b,C,h,c);{w=S===0?0:(f-d)/S;const k=b.x+(C.x-b.x)*w-h,E=b.y+(C.y-b.y)*w-c,T=Math.atan2(C.y-b.y,C.x-b.x);return{x:k,y:E,angle:T}}}d+=S}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,h=i*Math.cos(l),c=n*Math.sin(l),g=-i*Math.sin(l),f=n*Math.cos(l),d=Math.atan2(f,g);return{x:h,y:c,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let l=0,h=0,c=0;return r<i?(l=-i/2+r,h=-n/2,c=0):r<i+n?(l=i/2,h=-n/2+(r-i),c=Math.PI/2):r<2*i+n?(l=i/2-(r-(i+n)),h=n/2,c=Math.PI):(l=-i/2,h=n/2-(r-(2*i+n)),c=-Math.PI/2),{x:l,y:h,angle:c}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,h=o.in_x??o.x,c=o.in_y??o.y,g=o.x,f=o.y,d=1-t,u=t*t,m=d*d,y=m*d,v=u*t,b=y*n+3*m*t*r+3*d*u*h+v*g-e,C=y*a+3*m*t*l+3*d*u*c+v*f-i,S=3*m*(r-n)+6*d*t*(h-r)+3*u*(g-h),I=3*m*(l-a)+6*d*t*(c-l)+3*u*(f-c),w=Math.atan2(I,S);return{x:b,y:C,angle:w}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),i=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,i)}applyArtEffectOverlay(t,s,o,e,i,n){var f,d,u,m,y;const a=this.objectStates.get(s.id),r=((f=a==null?void 0:a.style)==null?void 0:f.artEffect)||s.artEffect||((d=s.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const l=r.type,h=r.intensity??.5,c=r.speed??1,g=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,i,n),t.clip(),l==="shimmer"){const b=this.currentTime*c%2/2,C=t.createLinearGradient(-e,-i,e,i);C.addColorStop(Math.max(0,b-.2),"rgba(255,255,255,0)"),C.addColorStop(b,`rgba(255,255,255,${h*.8})`),C.addColorStop(Math.min(1,b+.2),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let C=((this._lastPointerPos||{x:0}).x-(((u=s.transform)==null?void 0:u.x)??0)+300)/600;C=Math.max(-.2,Math.min(1.2,C));const S=t.createLinearGradient(-e,-i,e,i);S.addColorStop(Math.max(0,C-.15),"rgba(255,255,255,0)"),S.addColorStop(Math.max(0,Math.min(1,C)),`rgba(255,255,255,${h})`),S.addColorStop(Math.min(1,C+.15),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const v=this._lastPointerPos||{x:0,y:0},b=v.x-(((m=s.transform)==null?void 0:m.x)??0),C=v.y-(((y=s.transform)==null?void 0:y.y)??0),S=t.createLinearGradient(b>0?-e/2:e/2,C>0?-i/2:i/2,b>0?e/2:-e/2,C>0?i/2:-i/2);S.addColorStop(0,`rgba(0,0,0,${h*.6})`),S.addColorStop(.4,"rgba(0,0,0,0)"),S.addColorStop(.5,`rgba(255,255,255,${h*.4})`),S.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=S,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over",t.beginPath(),b>0&&C>0?(t.moveTo(e/2-40,i/2),t.lineTo(e/2,i/2-40),t.lineTo(e/2-40,i/2-40)):b<0&&C>0?(t.moveTo(-e/2+40,i/2),t.lineTo(-e/2,i/2-40),t.lineTo(-e/2+40,i/2-40)):b>0&&C<0?(t.moveTo(e/2-40,-i/2),t.lineTo(e/2,-i/2+40),t.lineTo(e/2-40,-i/2+40)):(t.moveTo(-e/2+40,-i/2),t.lineTo(-e/2,-i/2+40),t.lineTo(-e/2+40,-i/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=b>0?-2:2,t.shadowOffsetY=C>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const v=Math.floor(e/g),b=document.createElement("canvas");b.width=v,b.height=Math.floor(i/g);const C=b.getContext("2d"),S=C.createImageData(b.width,b.height);for(let I=0;I<S.data.length;I+=4){const w=Math.random()>.95?150:255;S.data[I]=w,S.data[I+1]=w,S.data[I+2]=w,S.data[I+3]=255*h}C.putImageData(S,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(b,-e/2,-i/2,e,i)}else if(l==="acid_gradient"||l==="acid_rave"){const v=this.currentTime*c,b=r.color1,C=r.color2,S=t.createLinearGradient(-e/2,-i/2,e/2,i/2);if(b&&C){const I=v*60%360;S.addColorStop(0,this._shiftHue(b,I,h*.7)),S.addColorStop(1,this._shiftHue(C,(I+180)%360,h*.7))}else{const I=v*100%360,w=(I+180)%360;S.addColorStop(0,`hsla(${I}, 80%, 50%, ${h*.5})`),S.addColorStop(1,`hsla(${w}, 80%, 50%, ${h*.5})`)}t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(l==="halftone"){const v=Math.max(2,g*(1-h*.8)),b=document.createElement("canvas");b.width=v,b.height=v;const C=b.getContext("2d");if(C){C.fillStyle="black",C.beginPath(),C.arc(v/2,v/2,v/2*h,0,Math.PI*2),C.fill();const S=t.createPattern(b,"repeat");S&&(t.globalAlpha=.3*h,t.fillStyle=S,t.fillRect(-e/2,-i/2,e,i))}}else if(l==="noise"){const v=Math.floor(e*i*h*.02);t.globalAlpha=.4*h;for(let b=0;b<v;b++){const C=Math.random()>.5?255:0;t.fillStyle=`rgba(${C}, ${C}, ${C}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let v=-i/2;v<i/2;v+=4)t.beginPath(),t.moveTo(-e/2,v),t.lineTo(e/2,v),t.stroke()}else if(l==="chromatic_aberration"){const v=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-v,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+v,-i/2,e,i)}else if(l==="pixelate"){const v=Math.max(2,Math.round(g*(1-h*.5))),b=document.createElement("canvas"),C=Math.max(1,Math.ceil(e/v)),S=Math.max(1,Math.ceil(i/v));b.width=C,b.height=S;const I=b.getContext("2d");if(I){I.imageSmoothingEnabled=!1;const w=t.getTransform(),k=w.e-e/2,E=w.f-i/2;I.drawImage(t.canvas,k,E,e,i,0,0,C,S),t.imageSmoothingEnabled=!1,t.drawImage(b,0,0,C,S,-e/2,-i/2,e,i),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const v=this.currentTime*c,b=r.chaosAmount??.2,C=Math.max(3,Math.floor(8*h)),S=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const I=S*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+I,-i/2,e,i),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-I,-i/2,e,i),t.globalCompositeOperation="source-over",t.globalAlpha=1;const w=i/C;for(let k=0;k<C;k++){const E=Math.sin(k*127.1+v*311.7*c)*43758.5,T=E-Math.floor(E);if(T>1-b){const W=(T-(1-b))/b*S*(Math.random()>.5?1:-1),M=-i/2+k*w,_=t.getTransform(),R=_.e-e/2+W,x=_.f+M;t.save(),t.beginPath(),t.rect(-e/2,M,e,w),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,R,x,e,w,-e/2+W,M,e,w),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,i=0,n=0;if(t.startsWith("#")){const f=t.replace("#","");e=parseInt(f.substring(0,2),16)/255,i=parseInt(f.substring(2,4),16)/255,n=parseInt(f.substring(4,6),16)/255}const a=Math.max(e,i,n),r=Math.min(e,i,n);let l=0,h=0,c=(a+r)/2;if(a!==r){const f=a-r;switch(h=c>.5?f/(2-a-r):f/(a+r),a){case e:l=((i-n)/f+(i<n?6:0))/6;break;case i:l=((n-e)/f+2)/6;break;case n:l=((e-i)/f+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(c*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,i,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",l=n.opacity??.5,h=n.noise??0;t.save(),this.applyPath(t,s,o,e,i),t.clip();const c=t.getTransform(),g=c.e-o/2,f=c.f-e/2;try{const u=document.createElement("canvas");u.width=Math.max(1,Math.ceil(o)),u.height=Math.max(1,Math.ceil(e));const m=u.getContext("2d");if(m){m.drawImage(t.canvas,g,f,o,e,0,0,o,e),m.filter=`blur(${a}px)`;const y=document.createElement("canvas");y.width=u.width,y.height=u.height;const v=y.getContext("2d");v.filter=`blur(${a}px)`,v.drawImage(u,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(y,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const d=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(d.addColorStop(0,"rgba(255,255,255,0.12)"),d.addColorStop(.3,"rgba(255,255,255,0.04)"),d.addColorStop(.5,"rgba(255,255,255,0.0)"),d.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const m=document.createElement("canvas");m.width=64,m.height=64;const y=m.getContext("2d"),v=y.createImageData(64,64),b=v.data;for(let C=0;C<b.length;C+=4){const S=Math.floor(Math.random()*255);b[C]=S,b[C+1]=S,b[C+2]=S,b[C+3]=18}y.putImageData(v,0,0),this._noiseTileCanvas=m}const u=t.createPattern(this._noiseTileCanvas,"repeat");u&&(t.fillStyle=u,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,i),t.stroke(),t.restore()}applyPath(t,s,o,e,i){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,h=e/2,c=n*Math.PI/180,g=a*Math.PI/180,f=c+g;a>=360&&r<=0?t.ellipse(0,0,l,h,0,0,Math.PI*2):(t.ellipse(0,0,l,h,0,c,f,!1),r>0?t.ellipse(0,0,l*r,h*r,0,f,c,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const l=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(l),c=a*Math.sin(l);r===0?t.moveTo(h,c):t.lineTo(h,c)}t.closePath()}else if(s.type==="Star"){const n=s.points||5,a=s.outer_radius||Math.min(o,e)/2;let r=s.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let l=0;l<n*2;l++){const h=l*Math.PI/n-Math.PI/2,c=l%2===0?a:r,g=c*Math.cos(h),f=c*Math.sin(h);l===0?t.moveTo(g,f):t.lineTo(g,f)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%10===0&&console.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(n=Math.min(n,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(n=Math.min(n,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.in_y)))}),n===1/0)return;const h=(n+a)/2,c=(r+l)/2;if(isNaN(h)||isNaN(c)){console.warn("[Engine] Invalid path center:",h,c);return}s.points.forEach((g,f)=>{if(f===0||g.moveTo)t.moveTo(g.x-h,g.y-c);else{const d=s.points[f-1];if(!d)return;const u=(d.out_x??d.x)-h,m=(d.out_y??d.y)-c,y=(g.in_x??g.x)-h,v=(g.in_y??g.y)-c;isNaN(u)||isNaN(y)||isNaN(g.x)?t.lineTo(g.x-h,g.y-c):t.bezierCurveTo(u,m,y,v,g.x-h,g.y-c)}if(g.closePath||f===s.points.length-1&&(s.is_closed||s.isClosed)){const d=[...s.points.slice(0,f+1)].reverse().find(u=>u.moveTo)||s.points[0];d&&(g.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-h,(g.out_y??g.y)-c,(d.in_x??d.x)-h,(d.in_y??d.y)-c,d.x-h,d.y-c),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(g=>{n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const h=(n+a)/2,c=(r+l)/2;s.points.forEach((g,f)=>{if(f===0)t.moveTo(g.x-h,g.y-c);else{const d=s.points[f-1];d.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-c,(g.in_x??g.x)-h,(g.in_y??g.y)-c,g.x-h,g.y-c):t.lineTo(g.x-h,g.y-c)}(g.closePath||f===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var dt,St;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((dt=s.geometry)==null?void 0:dt.width)||250,n=((St=s.geometry)==null?void 0:St.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",h=l!=="default"?l:a?"focused":r?"hovered":"default",c=e.label||{visible:!0,text:"Label"},g=e.helperText||{visible:!1,text:"Helper text"},f=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},v=[y.tl,y.tr,y.br,y.bl];let b=e.backgroundColor||"rgba(31, 41, 55, 1)",C=e.borderColor||"rgba(55, 65, 81, 1)",S=e.borderWidth??1.5,I=e.color||"#ffffff",w=e.placeholderColor||"rgba(156, 163, 175, 1)",k=e.fontSize||14;const E=`${h}Style`,T=e[E];T?(T.backgroundColor!==void 0&&(b=T.backgroundColor),T.borderColor!==void 0&&(C=T.borderColor),T.borderWidth!==void 0&&(S=T.borderWidth),T.color!==void 0&&(I=T.color),T.placeholderColor!==void 0&&(w=T.placeholderColor),T.fontSize!==void 0&&(k=T.fontSize)):h==="focused"?(C=e.focusBorderColor||"rgba(59, 130, 246, 1)",S=Math.max(S,2)):h==="hovered"||h==="hover"?(C=e.hoverBorderColor||C,b=e.hoverBackgroundColor||b):h==="disabled"?(b=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",C=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(C="rgba(239, 68, 68, 1)",S=Math.max(S,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,v);const W=this.createCanvasFill(t,b,i,n);if(W&&(t.fillStyle=W,t.fill()),S>0){const ht=this.createCanvasFill(t,C,i,n);if(ht&&(t.strokeStyle=ht,t.lineWidth=S,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const mt=v.map(rt=>rt+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,mt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const M=(ht,mt)=>{if(!ht.visible||!ht.svgPath)return;const rt=ht.size||14,Rt=ht.offset??16,Yt=ht.color||"#ffffff",Pt=mt?-(i/2)+Rt:i/2-Rt,zt=ht.svgPath;if(t.save(),t.translate(Pt,0),!zt.startsWith("<svg")){const Xt=new Path2D(zt),B=rt/24;t.scale(B,B),t.translate(-12,-12),t.fillStyle=Yt,t.fill(Xt)}t.restore()};M(f,!0),M(d,!1);const _=e.text||"",R=e.placeholder||"Enter text...",x=!_,L=_||R,$=x?w:I,A=k,V=e.fontFamily||"Inter",H=e.fontWeight||400;t.font=`${H} ${A}px "${V}", sans-serif`,t.fillStyle=$,t.textAlign="left",t.textBaseline=u?"top":"middle";const et=e.inputPadding??16,P=f.visible?(f.offset??16)+(f.size||14)/2+8:et,F=d.visible?(d.offset??16)+(d.size||14)/2+8:et,q=-(i/2)+P,Q=i-P-F,it=e.inputType==="password"?"•".repeat(L.length):L;if(t.save(),t.beginPath(),t.rect(q-2,-n/2+4,Q+4,n-8),t.clip(),u){const ht=it.split(`
|
|
32
|
-
`);let mt=-n/2+et;const rt=A*1.2;let Rt=0;ht.forEach((Yt,Pt)=>{const zt=Yt.split(" ");let Xt="";for(let B=0;B<zt.length;B++){const lt=Xt+zt[B]+" ";t.measureText(lt).width>Q&&B>0?(t.fillText(Xt,q,mt),Xt=zt[B]+" ",mt+=rt):Xt=lt}t.fillText(Xt,q,mt),Rt=t.measureText(Xt).width,Pt<ht.length-1&&(mt+=rt,Rt=0)}),a&&!x&&Math.floor(performance.now()/500)%2===0&&t.fillRect(q+Rt,mt,1.5,A)}else{const mt=t.measureText(it).width;let rt=0;if(mt>Q&&(rt=mt-Q),t.fillText(it,q-rt,0),a&&!x&&Math.floor(performance.now()/500)%2===0){const Yt=q+mt-rt;t.fillRect(Yt,-(A/2),1.5,A)}}if(t.restore(),c.visible!==!1){const ht=c.text||"Label",mt=c.fontSize||12,rt=c.color||"rgba(156, 163, 175, 1)",Rt=c.offset??8;t.font=`600 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="bottom";const Yt=-(i/2),Pt=-(n/2)-Rt;t.fillText(ht,Yt,Pt)}if(g.visible===!0){const ht=g.text||"Helper text",mt=g.fontSize||11,rt=h==="error"?"rgba(239, 68, 68, 1)":g.color||"rgba(156, 163, 175, 1)",Rt=g.offset??6;t.font=`400 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top";const Yt=-(i/2),Pt=n/2+Rt;t.fillText(ht,Yt,Pt)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,h=(i.max??100)-r,c=h===0?0:(a-r)/h,g=i.trackHeight||4,f=i.trackRoundedness??2,d=i.trackShape??"Rectangle",u=i.trackPath||"",m=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",v=i.thumbShape||"Ellipse",b=i.thumbWidth??16,C=i.thumbHeight??16,S=i.thumbRoundedness??0,I=i.thumbColor||"#ffffff",w=i.thumbPath||"",k=i.thumbIcon||"",E=i.showValueTooltip??!1,T=i.tooltipBgColor||"#333333",W=i.tooltipColor||"#ffffff",M=i.tooltipOffsetX??0,_=i.tooltipOffsetY??-25,R=(Q,it,dt,St,ht,mt,rt)=>{if((Q==="Custom"||Q==="Icon")&&rt)try{const Rt=new Path2D(rt);if(t.save(),t.translate(it,dt),Q==="Icon"){const Yt=Math.min(St,ht)/24;t.scale(Yt,Yt),t.translate(-12,-12)}t.fill(Rt),t.restore();return}catch(Rt){console.error("Error drawing slider shape in engine:",Rt)}if(t.beginPath(),Q==="Ellipse")t.ellipse(it,dt,St/2,ht/2,0,0,Math.PI*2);else if(Q==="Rectangle")this.drawRoundRect(t,it-St/2,dt-ht/2,St,ht,mt);else if(Q==="Triangle")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt+ht/2),t.lineTo(it-St/2,dt+ht/2),t.closePath();else if(Q==="Diamond")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt),t.lineTo(it,dt+ht/2),t.lineTo(it-St/2,dt),t.closePath();else if(Q==="Polygon"){const Rt=s.geometry.sides||3,Yt=s.geometry.radius||Math.min(St,ht)/2;for(let Pt=0;Pt<Rt;Pt++){const zt=Pt*2*Math.PI/Rt-Math.PI/2,Xt=it+Yt*Math.cos(zt),B=dt+Yt*Math.sin(zt);Pt===0?t.moveTo(Xt,B):t.lineTo(Xt,B)}t.closePath()}else if(Q==="Star"){const Yt=Math.min(St,ht)/2,Pt=Yt/2;for(let zt=0;zt<5*2;zt++){const Xt=zt%2===0?Yt:Pt,B=zt*Math.PI/5-Math.PI/2;t.lineTo(it+Xt*Math.cos(B),dt+Xt*Math.sin(B))}t.closePath()}else Q==="Line"&&(t.moveTo(it-St/2,dt),t.lineTo(it+St/2,dt));t.fill()},x=this.createCanvasFill(t,y,n,g);x&&(t.fillStyle=x,t.strokeStyle=x),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):R(d,0,0,n,g,f,u);const L=n-b,$=-n/2+b/2+c*L,A=$- -n/2;if(A>0){const Q=this.createCanvasFill(t,m,n,g);Q&&(t.fillStyle=Q,t.strokeStyle=Q),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo($,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-g/2,A,g,f),t.fill())}t.save(),t.translate($,0);const V=t.getTransform(),H=Math.sqrt(V.a*V.a+V.b*V.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*H,t.shadowOffsetY=1*H;const et=this.createCanvasFill(t,I,b,C);if(et&&(t.fillStyle=et),R(v,0,0,b,C,S,v==="Icon"?k:w),t.restore(),E){t.save(),t.translate($+M,_);const Q=Math.round(a).toString();t.font="10px Inter, sans-serif";const it=t.measureText(Q),dt=6,St=4,ht=it.width+dt*2,mt=14+St;t.beginPath(),this.drawRoundRect(t,-ht/2,-mt/2,ht,mt,4),t.fillStyle=T,t.fill(),t.fillStyle=W,t.textAlign="center",t.textBaseline="middle",t.fillText(Q,0,0),t.restore()}const P=i.label||{},F=i.helperText||{},q=i.fontFamily||"Inter";if(P.visible!==!1){const Q=P.text||"Label",it=P.fontSize||12,dt=P.color||"rgba(156, 163, 175, 1)",St=P.offset??8;t.font=`600 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="bottom";const ht=-(n/2),mt=-(g/2)-St;t.fillText(Q,ht,mt)}if(F.visible===!0){const Q=F.text||"Helper text",it=F.fontSize||11,dt=F.color||"rgba(156, 163, 175, 1)",St=F.offset??6;t.font=`400 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="top";const ht=-(n/2),mt=g/2+St;t.fillText(Q,ht,mt)}}renderDropdown(t,s){var _;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,l=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",c=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!h;let f=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(f=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):g?(f=e.activeBackgroundColor||f,d=e.activeBorderColor||d,u=e.activeColor||u):c&&(f=e.hoverBackgroundColor||f,d=e.hoverBorderColor||d,u=e.hoverColor||u),f||(f="#ffffff"),d||(d="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,l),t.fillStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const v=12,b=e.chevronType||"chevron",C=e.chevronSize||16,S=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const R=a+i-v-C/2;t.save(),t.translate(R,0);const x=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(x*Math.PI/180),t.strokeStyle=S,t.fillStyle=S,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-C/2,-C*.2),t.lineTo(0,C*.2),t.lineTo(C/2,-C*.2),t.stroke();else if(b==="custom"||b==="path"){const L=g&&e.openIconPath||e.closedIconPath;if(L){const $=new Path2D(L);t.save();const A=C/24;t.scale(A,A),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const I=e.selectedOption||e.placeholder||"Select...",w=e.fontSize||14,k=e.fontWeight||400,E=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${w}px ${E}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const W=b==="none"?0:C+8,M=i-v*2-W;if(t.save(),t.beginPath(),t.rect(a+v,r,M,n),t.clip(),t.fillText(I,a+v,0),t.restore(),g&&!h){const R=r+n+4,x=e.optionsList||[],L=e.itemHeight||32,$=e.listPadding??4,A=x.length*L+$*2,V=e.listCornerRadius??l;t.save();const H=e.listShadow||{},et=t.getTransform(),P=Math.sqrt(et.a*et.a+et.b*et.b)||1;t.shadowColor=typeof H.color=="string"?H.color:((_=H.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(H.blur??12)*P,t.shadowOffsetY=(H.offsetY??6)*P,t.shadowOffsetX=(H.offsetX??0)*P,t.beginPath(),this.drawRoundRect(t,a,R,i,A,V),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,A)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},i,A)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const q=e.itemFontSize||w,Q=e.itemFontFamily||E;t.font=`${k} ${q}px ${Q}`,x.forEach((it,dt)=>{const St=R+$+dt*L;if(it===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,L)||"#f3f4f6",t.fillRect(a+F,St,i-F*2,L),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const mt=this._lastPointerPos.y-(R+$),rt=Math.floor(mt/L);dt===rt&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,L)||"#f9fafb",t.fillRect(a+F,St,i-F*2,L),t.fillStyle=e.itemHoverColor||u)}t.fillText(it,a+v,St+L/2)})}t.globalAlpha=m}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,h=e.label||{},c=e.hoverStyle||{},g=e.activeStyle||{},f=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",m=h.text||"Button",y=i.cornerRadius??8,v=e.borderColor||"transparent",b=e.borderWidth||0,C=1;l&&g?(d=g.backgroundColor||d,u=g.color||u,m=g.text||m,C=g.scale??.95,y=g.cornerRadius??y):r&&c&&(d=c.backgroundColor||d,u=c.color||u,m=c.text||m,C=c.scale??1,y=c.cornerRadius??y,v=c.borderColor||v);const S=-n/2,I=-a/2;t.save(),t.scale(C,C),t.beginPath(),this.drawRoundRect(t,S,I,n,a,y);const w=this.createCanvasFill(t,d,n,a);w&&(t.fillStyle=w,t.fill()),(b>0||r&&c.borderColor)&&(t.strokeStyle=v,t.lineWidth=b||(r?1:0),t.stroke());const k=h.fontSize||14,E=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${k}px "${E}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let W=0;if(f.enabled&&f.svgPath){const M=k*1.1,_=f.gap||8,R=t.measureText(m),L=-(R.width+M+_)/2,$=f.position==="left"?L+M/2:L+R.width+_+M/2;W=f.position==="left"?L+M+_+R.width/2:L+R.width/2,t.save(),t.translate($,0);const A=new Path2D(f.svgPath),V=M/24;t.scale(V,V),t.translate(-12,-12),t.fillStyle=u,t.fill(A),t.restore()}t.fillText(m,W,0),t.restore()}renderToggleButton(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((m=s.geometry)==null?void 0:m.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,l=-a/2,h=e.corner_radius??8,c=e.label||{},g=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",f=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,n,a,h),t.fillStyle=g,t.fill();const d=c.fontSize||14,u=c.fontFamily||"Inter";t.font=`${c.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle",t.fillText(c.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var V,H,et,P,F,q,Q,it,dt,St,ht,mt;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((V=s.geometry)==null?void 0:V.width)||52,n=((H=s.geometry)==null?void 0:H.height)||30,a=-i/2,r=-n/2,l=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,c=e.toggleStyle||{},g=c.backgroundColor||e.activeColor||"#10b981",f=c.borderColor||e.borderColor||"transparent",d=c.borderWidth??e.borderWidth??0,u=c.knobColor||e.knobColor||"#ffffff",m=l?g:e.inactiveColor||"#374151",y=l?f:e.borderColor||"transparent",v=l?d:e.borderWidth??0,b=l?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,h);const C=this.createCanvasFill(t,m,i,n);if(C&&(t.fillStyle=C,t.fill()),v>0){t.lineWidth=v;const rt=this.createCanvasFill(t,y,i,n);rt&&(t.strokeStyle=rt,t.stroke())}const S=2,I=n-S*2,w=I/2,k=a+S,E=a+i-S-I,T=l?E:k,W=r+S;t.beginPath(),t.arc(T+w,W+w,w,0,Math.PI*2);const M=this.createCanvasFill(t,b,I,I);M&&(t.fillStyle=M,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,R=!1;const x=(l?(et=c.leftLabel)==null?void 0:et.text:null)||((P=e.leftLabel)==null?void 0:P.text)||"",L=(l?(F=c.leftLabel)==null?void 0:F.color:null)||((q=e.leftLabel)==null?void 0:q.color)||"#f3f4f6";if((Q=e.leftLabel)!=null&&Q.enabled&&x){const rt=e.leftLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=L,t.textBaseline="middle",t.textAlign="right",t.fillText(x,a-(rt.gap||8),0),_=!0}const $=(l?(it=c.rightLabel)==null?void 0:it.text:null)||((dt=e.rightLabel)==null?void 0:dt.text)||"",A=(l?(St=c.rightLabel)==null?void 0:St.color:null)||((ht=e.rightLabel)==null?void 0:ht.color)||"#f3f4f6";if((mt=e.rightLabel)!=null&&mt.enabled&&$){const rt=e.rightLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=A,t.textBaseline="middle",t.textAlign="left",t.fillText($,a+i+(rt.gap||8),0),R=!0}if(!_&&!R&&e.label&&e.label.text){const rt=e.label,Rt=rt.fontSize||14,Yt=rt.fontWeight||400,Pt=rt.fontFamily||"Inter";t.font=`${Yt} ${Rt}px "${Pt}", sans-serif`,t.fillStyle=rt.color||"#f3f4f6",t.textBaseline="middle";const zt=rt.gap||10;let Xt=0,B=0;rt.position==="left"?(t.textAlign="right",Xt=a-zt,B=0):rt.position==="right"?(t.textAlign="left",Xt=a+i+zt,B=0):rt.position==="top"?(t.textAlign="center",Xt=0,B=r-zt,t.textBaseline="bottom"):rt.position==="bottom"?(t.textAlign="center",Xt=0,B=r+n+zt,t.textBaseline="top"):(t.textAlign="left",Xt=a+i+zt,B=0),t.fillText(rt.text,Xt,B)}}renderCheckbox(t,s){var C,S;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((C=s.geometry)==null?void 0:C.width)||20,n=((S=s.geometry)==null?void 0:S.height)||20,a=-i/2,r=-n/2,l=e.cornerRadius??4,h=e.checked??!1,c=e.activeColor||"#3b82f6",g=e.inactiveColor||"transparent",f=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,m=h?c:g,y=h?"transparent":d,v=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,l);const b=this.createCanvasFill(t,m,i,n);if(b&&(t.fillStyle=b,t.fill()),v>0){t.lineWidth=v;const I=this.createCanvasFill(t,y,i,n);I&&(t.strokeStyle=I,t.stroke())}else if(h){t.lineWidth=1;const I=this.createCanvasFill(t,c,i,n);I&&(t.strokeStyle=I,t.stroke())}if(h){t.save(),t.beginPath();const I=this.createCanvasFill(t,f,i,n);t.strokeStyle=I||f,t.lineWidth=Math.max(2,i*.12),t.lineCap="round",t.lineJoin="round";const w=a+i*.25,k=r+n*.5,E=a+i*.45,T=r+n*.7,W=a+i*.75,M=r+n*.25;t.moveTo(w,k),t.lineTo(E,T),t.lineTo(W,M),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const I=e.label;t.save(),t.font=`${I.fontWeight||400} ${I.fontSize||14}px "${I.fontFamily||"Inter"}", sans-serif`,t.fillStyle=I.color||"#f3f4f6",t.textBaseline="middle";const w=I.gap||8;let k=0,E=0;I.position==="left"?(t.textAlign="right",k=a-w,E=0):I.position==="right"?(t.textAlign="left",k=a+i+w,E=0):I.position==="top"?(t.textAlign="center",k=0,E=r-w,t.textBaseline="bottom"):I.position==="bottom"&&(t.textAlign="center",k=0,E=r+n+w,t.textBaseline="top"),t.fillText(I.text,k,E),t.restore()}}renderRadioGroup(t,s){var S,I;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((S=s.geometry)==null?void 0:S.width)||180,n=((I=s.geometry)==null?void 0:I.height)||100,a=-i/2,r=-n/2,l=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],c=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,f=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",m=e.fontSize||14,y=e.fontFamily||"Inter",v=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const b=8,C=b*2;if(t.save(),t.font=`${v} ${m}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",c==="vertical"){const w=Math.max(C,m)+g;h.forEach((k,E)=>{const T=r+E*w+b;t.beginPath(),t.arc(a+b,T,b,0,Math.PI*2);const W=l===k,M=this.createCanvasFill(t,f,C,C),_=this.createCanvasFill(t,d,C,C);W?(t.strokeStyle=M||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+b,T,b/2,0,Math.PI*2),t.fillStyle=M||f,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,a+C+8,T)})}else{let w=a;h.forEach(k=>{const E=l===k,T=t.measureText(k).width;t.beginPath(),t.arc(w+b,0,b,0,Math.PI*2);const W=this.createCanvasFill(t,f,C,C),M=this.createCanvasFill(t,d,C,C);E?(t.strokeStyle=W||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(w+b,0,b/2,0,Math.PI*2),t.fillStyle=W||f,t.fill()):(t.strokeStyle=M||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,w+C+6,0),w+=C+6+T+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#9ca3af",t.textBaseline="middle";const k=w.gap||8;let E=0,T=0;w.position==="left"?(t.textAlign="right",E=a-k,T=0):w.position==="right"?(t.textAlign="left",E=a+i+k,T=0):w.position==="top"?(t.textAlign="center",E=0,T=r-k,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",E=0,T=r+n+k,t.textBaseline="top"),t.fillText(w.text,E,T),t.restore()}}renderBarChart(t,s){var T,W;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((T=s.geometry)==null?void 0:T.width)||300,height:((W=s.geometry)==null?void 0:W.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,_getPreset:function(){return es[this.stylePreset]||es.default},_resolveColor:function(M,_){const R=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(M)?R.colors[_%R.colors.length]:typeof M=="string"?M:R.colors[_%R.colors.length]},_makeGradient:function(M,_,R,x,L,$){if(!this._getPreset().barGradient&&!this.barGradient)return _;const V=M.createLinearGradient(R,x,L,$);return V.addColorStop(0,_),V.addColorStop(1,_+"44"),V},_drawRoundedBar:function(M,_,R,x,L,$,A){if($=Math.min($,Math.min(Math.abs(x),Math.abs(L))/2),$<=0||x===0||L===0){M.rect(_,R,x,L);return}M.beginPath(),A?(M.moveTo(_,R+L),M.lineTo(_,R+$),M.quadraticCurveTo(_,R,_+$,R),M.lineTo(_+x-$,R),M.quadraticCurveTo(_+x,R,_+x,R+$),M.lineTo(_+x,R+L),M.lineTo(_,R+L)):(M.moveTo(_,R),M.lineTo(_+x-$,R),M.quadraticCurveTo(_+x,R,_+x,R+$),M.lineTo(_+x,R+L-$),M.quadraticCurveTo(_+x,R+L,_+x-$,R+L),M.lineTo(_,R+L),M.lineTo(_,R)),M.closePath()}},n=i.width,a=i.height,r=-n/2,l=-a/2;if(!i.datasets||i.datasets.length===0||i.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=i._getPreset();let c=-1/0,g=1/0;const f=i.categories.length,d=i.datasets.length;if(i.chartType==="stacked")for(let M=0;M<f;M++){let _=0,R=0;i.datasets.forEach(x=>{const L=x.data[M]??0;L>=0?_+=L:R+=L}),_>c&&(c=_),R<g&&(g=R)}else i.datasets.forEach(M=>{M.data&&M.data.forEach(_=>{_>c&&(c=_),_<g&&(g=_)})});isFinite(c)||(c=10),isFinite(g)||(g=0),c=Math.max(c,0),g=Math.min(g,0);const u=c-g||10;t.save(),t.font=`${i.axisLabelFontSize}px Inter, sans-serif`;const m=i.showYLabels?t.measureText(c.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,b=(i.showLegend&&d>0?i.legendFontSize+10:0)+8,C=10,S=r+m,I=l+b,w=n-m-C,k=a-b-y;if(t.beginPath(),t.roundRect(r,l,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&d>0){t.font=`${i.legendFontSize}px Inter, sans-serif`,t.textBaseline="middle";const M=l+12;let _=S;i.datasets.forEach((R,x)=>{const L=i._resolveColor(R.color,x),$=R.label||`Series ${x+1}`,A=7;t.beginPath(),t.roundRect(_,M-A/2,A,A,2),t.fillStyle=L,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText($,_+A+4,M),_+=t.measureText($).width+A+16})}const E=4;if(i.showGridLines){t.setLineDash([3,4]),t.lineWidth=1,t.strokeStyle=h.gridColor;for(let M=0;M<=E;M++){const _=I+M/E*k;t.beginPath(),t.moveTo(S,_),t.lineTo(S+w,_),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let M=0;M<=E;M++){const _=c-M/E*u,R=I+M/E*k;t.fillText(_.toFixed(0),S-6,R)}}if(t.lineWidth=1,t.setLineDash([]),i.showXAxis&&(t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(S,I+k),t.lineTo(S+w,I+k),t.stroke()),i.showYAxis&&(t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(S,I),t.lineTo(S,I+k),t.stroke()),i.chartType==="stacked"){const M=w/f;for(let _=0;_<f;_++){const R=S+_*M+M/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.fillText(i.categories[_]||"",R,I+k+5));let x=I+k;i.datasets.forEach((L,$)=>{const A=L.data[_]??0;if(A===0)return;const V=A/u*k,H=Math.min(i.barWidth*d+i.barGap,M-8),et=R-H/2,P=x-V;x-=V;const F=i._resolveColor(L.color,$);t.beginPath(),t.fillStyle=i._makeGradient(t,F,et,P,et,P+V),i._drawRoundedBar(t,et,P,H,V,$===d-1?i.barCornerRadius:0,!0),t.fill()})}}else{const M=w/f,_=d*i.barWidth+Math.max(0,(d-1)*i.barGap),R=I+k-(0-g)/u*k;for(let x=0;x<f;x++){const L=S+x*M+M/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.fillText(i.categories[x]||"",L,I+k+5));const $=L-_/2;i.datasets.forEach((A,V)=>{const H=A.data[x]??0,et=Math.abs(H/u*k);if(et<1)return;const P=$+V*(i.barWidth+i.barGap),F=H>=0?R-et:R,q=i._resolveColor(A.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,q,P,F,P,F+et),i._drawRoundedBar(t,P,F,i.barWidth,et,i.barCornerRadius,!0),t.fill(),i.showValueOnTop&&H!==0&&(t.font=`bold ${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=q,t.fillText(H.toString(),P+i.barWidth/2,F-2))})}}t.restore()}renderPieChart(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((m=s.geometry)==null?void 0:m.width)||180,height:((y=s.geometry)==null?void 0:y.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return ss[this.stylePreset]||ss.default},_resolveSliceColor:function(v,b){const C=v.color,S=b,I=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(C)?I.colors[S%I.colors.length]:typeof C=="string"?C:I.colors[S%I.colors.length]}},n=i.width,a=i.height;if(!i.slices||i.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=i.slices.reduce((v,b)=>v+(b.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const l=i._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke();const h=i.showLegend?Math.ceil(i.slices.length/2):0,c=h>0?h*(i.legendFontSize+8)+10:0,g=a-c-16,f=Math.min(n-24,g)/2,d=0,u=-c/2;if(i.chartType==="rose"){const v=Math.max(...i.slices.map(S=>S.value||0)),b=Math.PI*2/i.slices.length,C=f>0?i.sliceGap/f:0;i.slices.forEach((S,I)=>{const w=S.value||0;if(w===0)return;const k=w/v*f,E=-Math.PI/2+I*b+C/2,T=E+b-C,W=i._resolveSliceColor(S,I);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,k,E,T),t.closePath(),t.fillStyle=W+"cc",t.fill(),t.strokeStyle=W,t.lineWidth=1.5,t.stroke(),i.showLabels){const M=E+(T-E)/2,_=d+k*.65*Math.cos(M),R=u+k*.65*Math.sin(M),x=Math.round(w/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,_,R),t.restore()}})}else{const v=i.chartType==="pie"?0:i.innerRadius,b=f*Math.max(0,v),C=f>0?i.sliceGap/f:0;let S=-Math.PI/2;if(i.slices.forEach((I,w)=>{const k=I.value||0;if(k===0){S+=k/r*Math.PI*2;return}const E=k/r*Math.PI*2,T=S+C/2,W=S+E-C/2;if(W<=T){S+=E;return}const M=i._resolveSliceColor(I,w);if(t.beginPath(),t.fillStyle=M,b<=0?(t.moveTo(d,u),t.arc(d,u,f,T,W),t.lineTo(d,u)):(t.moveTo(d+f*Math.cos(T),u+f*Math.sin(T)),t.arc(d,u,f,T,W),t.arc(d,u,b,W,T,!0),t.closePath()),t.fill(),i.showLabels){const _=T+(W-T)/2,R=b+(f-b)/2,x=d+R*Math.cos(_),L=u+R*Math.sin(_),$=Math.round(k/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${$}%`,x,L),t.restore()}S+=E}),i.chartType==="donut"&&i.showCenterText&&b>14){const I=Math.round(r),w=Math.min(Math.floor(b*.52),20),k=Math.min(Math.floor(b*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${w}px Inter, sans-serif`,t.fillStyle=l.centerTextColor,t.fillText(I.toString(),d,u-k*.5),i.centerLabel&&(t.font=`${k}px Inter, sans-serif`,t.fillStyle=l.centerLabelColor,t.fillText(i.centerLabel,d,u+w*.6))}}if(i.showLegend&&i.slices.length>0){t.font=`${i.legendFontSize}px Inter, sans-serif`;const v=2,b=n/v,C=i.legendFontSize+8,S=a/2-c+10,I=-n/2+10;i.slices.forEach((w,k)=>{const E=k%v,T=Math.floor(k/v),W=I+E*b,M=S+T*C,_=i._resolveSliceColor(w,k),R=7;t.beginPath(),t.roundRect(W,M-R/2,R,R,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=l.legendColor;const x=Math.round((w.value||0)/r*100),L=`${w.label||"Item"} ${x}%`,$=b-R-20;let A=L;for(;t.measureText(A).width>$&&A.length>4;)A=A.slice(0,-4)+"…";t.fillText(A,W+R+4,M)})}t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var k,E;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((k=t.geometry)==null?void 0:k.width)||180,r=i.height!==void 0?i.height:((E=t.geometry)==null?void 0:E.height)||100,l=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,c=e.fontSize||14,g=this.getWorldTransform(t.id),f=s-g.x,d=o-g.y,u=-g.rotation*(Math.PI/180),m=Math.cos(u),y=Math.sin(u),v=f*m-d*y,b=f*y+d*m,S=8*2,I=-a/2,w=-r/2;if(l==="vertical"){const T=Math.max(S,c)+h;for(let W=0;W<n.length;W++){const M=w+W*T;if(v>=I&&v<=I+a&&b>=M&&b<=M+T)return W}}else{let T=I;for(let W=0;W<n.length;W++){const _=n[W].length*8,R=S+6+_+h;if(v>=T&&v<=T+R&&b>=w&&b<=w+r)return W;T+=R}}return null}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(u=>{let m=u.data;if(u.isVarEnabled&&u.inputId){let y=this.inputs.get(u.inputId);if(y===void 0){const v=this.inputNameMap.get(u.inputId);v&&v.length>0&&(y=this.inputs.get(v[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(v=>typeof v=="number"&&!isNaN(v));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,m.length))}u._resolvedData=m}),r<2)return;const l=a-n,h=o/(r-1),c=u=>{const m=l===0?.5:(u-n)/l;return e/2-m*e},g=u=>u*h-o/2,f=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const m=g(u);t.fillText(`${u+1}`,m,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),u,c(a)),t.fillText(m.toFixed(1),u,c(m)),t.fillText(n.toFixed(1),u,c(n))}const d=10;if(i.forEach(u=>{const m=u._resolvedData;if(!(!m||m.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(g(0),e/2),t.lineTo(g(0),c(m[0])),u.smoothing&&m.length>2)for(let v=0;v<m.length-1;v++){const b=m[v===0?v:v-1],C=m[v],S=m[v+1],I=m[v+1===m.length-1?v+1:v+2];for(let w=1;w<=d;w++){const k=w/d,E=this._catmullRom(b,C,S,I,k);t.lineTo(g(v+k),c(E))}}else for(let v=1;v<m.length;v++)t.lineTo(g(v),c(m[v]));t.lineTo(g(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(g(0),c(m[0])),u.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const v=m[y===0?y:y-1],b=m[y],C=m[y+1],S=m[y+1===m.length-1?y+1:y+2];for(let I=1;I<=d;I++){const w=I/d,k=this._catmullRom(v,b,C,S,w);t.lineTo(g(y+w),c(k))}}else for(let y=1;y<m.length;y++)t.lineTo(g(y),c(m[y]));t.stroke(),u.showPoints&&m.forEach((y,v)=>{const b=g(v),C=c(y);t.beginPath(),t.arc(b,C,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const u=o/2-10;let m=-e/2+15;const y=s.legendFontSize||10,v=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(b=>{const S=b.label||"Series",I=t.measureText(S).width;t.beginPath(),t.rect(u-I-8-5,m-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(S,u,m),m+=v})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,l=i*r;return(2*s-2*o+n+a)*l+(-3*s+3*o-2*n-a)*r+n*i+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,h=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,h=100)=>{var C,S;const g=(((S=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:S.colors)||{})[l]||l,f=this.normalizeOpacity(s.opacity??100),u=this.normalizeOpacity(h)*f;if(u>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),v=parseInt(m.substring(2,4),16),b=parseInt(m.substring(4,6),16);return`rgba(${y}, ${v}, ${b}, ${u})`};if(s.type==="LinearGradient"){const l=(u,m,y)=>Array.isArray(u)?u[m]??(m===0?0:1):u&&typeof u=="object"?u[y]??(m===0?0:1):m===0?0:1,h=l(s.start,0,"x")*o-o/2,c=l(s.start,1,"y")*e-e/2,g=l(s.end,0,"x")*o-o/2,f=l(s.end,1,"y")*e-e/2,d=t.createLinearGradient(h,c,g,f);if(s.stops.forEach(u=>{const m=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,y=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,m)),y)}),s.gradientTransform&&d.setTransform){const[u,m,y,v,b,C]=s.gradientTransform;d.setTransform({a:u,b:m,c:y,d:v,e:b,f:C})}return d}else if(s.type==="RadialGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center,0,"x")*o-o/2,c=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),f=t.createRadialGradient(h,c,0,h,c,g);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return f}else if(s.type==="AngularGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),f=(a=t.createConicGradient)==null?void 0:a.call(t,g,h,c);if(f){if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return f}}else if(s.type==="DiamondGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(h,c),t.rotate(Math.PI/4);const f=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=f,t.restore(),f}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const h=new DOMMatrix,c=s.scaleX??1,g=s.scaleY??1,f=s.offsetX??0,d=s.offsetY??0,u=s.rotation??0;h.translateSelf(f,d),h.rotateSelf(u),h.scaleSelf(c,g),l.setTransform(h)}return l}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,h=0,c=0;typeof a=="number"?r=l=h=c=a:Array.isArray(a)?a.length===1?r=l=h=c=a[0]:a.length===2?(r=h=a[0],l=c=a[1]):a.length===3?(r=a[0],l=c=a[1],h=a[2]):a.length>=4&&(r=a[0],l=a[1],h=a[2],c=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,l=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,c=a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),h=Math.min(Math.max(0,h),g),c=Math.min(Math.max(0,c),g),t.roundRect){t.roundRect(s,o,e,i,[r,l,h,c]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+i-h),t.arcTo(s+e,o+i,s+e-h,o+i,h),t.lineTo(s+c,o+i),t.arcTo(s,o+i,s,o+i-c,c),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,x,L,$;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,n=o.height!==void 0?o.height:((x=s.geometry)==null?void 0:x.height)||300,a=-i/2,r=-n/2,l=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",c=e.items||[],g=e.itemGap??10,f=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,v=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",C=e.itemBackgroundColor||"#ffffff",S=e.hoveredIndex??null,I=e.activeItemIndex??null,w=e.glowIntensity??0,k=e.glowColor||"#3b82f6",E=typeof k=="string"?k:k.color||(($=(L=k.stops)==null?void 0:L[0])==null?void 0:$.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,w>0){const A=t.getTransform(),V=Math.sqrt(A.a*A.a+A.b*A.b)||1;t.shadowColor=E,t.shadowBlur=w*2*V,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const A=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",V=this.createCanvasFill(t,A,i,n);t.fillStyle=V||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(t,a,r,i,n,l),t.fill();const H=t.createLinearGradient(a,r,a+i,r+n);H.addColorStop(0,"rgba(255, 255, 255, 0.15)"),H.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),H.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=H,this.drawListViewRect(t,a,r,i,n,l),t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,this.drawListViewRect(t,a,r,i,n,l),t.stroke()}else{const A=e.listBackgroundColor||"transparent",V=this.createCanvasFill(t,A,i,n);V&&(t.fillStyle=V,this.drawListViewRect(t,a,r,i,n,l),t.fill());const H=e.borderWidth??0;H>0&&(t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=H,this.drawListViewRect(t,a,r,i,n,l),t.stroke())}t.shadowBlur=0,t.save(),this.drawListViewRect(t,a,r,i,n,l),t.clip();const W=typeof m=="number"?m:h==="vertical"?m[0]:m[3];let M=(h==="vertical"?r:a)+u+W;if(t.textBaseline="middle",c.forEach((A,V)=>{const H=h==="vertical"?i:d,et=h==="vertical"?f:n,P=h==="vertical"?a:M,F=h==="vertical"?M:r,q=S===V,Q=I===V;if(Q){const mt=this.createCanvasFill(t,v,H,et);t.fillStyle=mt||v;const rt=t.globalAlpha;t.globalAlpha=rt*.8,t.fillRect(P,F,H,et),t.globalAlpha=rt}else if(q)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.fillRect(P,F,H,et);else if(C!=="transparent"){const mt=this.createCanvasFill(t,C,H,et);t.fillStyle=mt||C,t.fillRect(P,F,H,et)}if(Q||q){const mt=this.createCanvasFill(t,v,h==="vertical"?3:H,h==="vertical"?et:3);t.fillStyle=mt||v,h==="vertical"?t.fillRect(P,F,3,et):t.fillRect(P,F+et-3,H,3)}const it=Q?"#ffffff":y?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=it,t.font=Q||q?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const dt=typeof A=="string"?A:(A==null?void 0:A.label)||`Item ${V+1}`,St=P+(h==="vertical"?16:H/2),ht=F+et/2;h==="horizontal"?t.textAlign="center":t.textAlign="left",t.fillText(dt,St,ht),M+=(h==="vertical"?f:d)+g}),t.restore(),e.showScrollbar!==!1){const A=(c.length||0)*(h==="vertical"?f:d)+((c.length||0)-1)*g,V=h==="vertical"?n:i;if(A>V){const H=V/A,et=V*H,P=-u/A*V,F=e.scrollbarColor||"rgba(255,255,255,0.3)",q=e.scrollbarWidth||4;t.fillStyle=F,h==="vertical"?t.fillRect(a+i-q-2,r+P,q,et):t.fillRect(a+P,r+n-q-2,et,q)}}t.restore()}updateListViewScrollFromPointer(t){var m,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=this.objectStates.get(t.id)||{},a=s.items||[],r=s.itemGap??10,l=s.itemHeight??50,h=s.itemWidth??200,c=n.width!==void 0?n.width:((m=t.geometry)==null?void 0:m.width)||200,g=n.height!==void 0?n.height:((y=t.geometry)==null?void 0:y.height)||300,f=(a.length||0)*(o==="vertical"?l:h)+((a.length||0)-1)*r,u=Math.max(0,f-(o==="vertical"?g:c)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-u&&(s.scrollOffset=-u)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var W,M;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((W=t.geometry)==null?void 0:W.width)||200,r=i.height!==void 0?i.height:((M=t.geometry)==null?void 0:M.height)||300,l=e.orientation||"vertical",h=e.itemGap??10,c=e.itemHeight??50,g=e.itemWidth??200,f=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),m=s-u.x,y=o-u.y,v=-u.rotation*(Math.PI/180),b=Math.cos(v),C=Math.sin(v),S=m*b-y*C,I=m*C+y*b,w=-a/2,k=-r/2,E=typeof d=="number"?d:l==="vertical"?d[0]:d[3];let T=(l==="vertical"?k:w)+f+E;for(let _=0;_<n.length;_++){const R=l==="vertical"?a:g,x=l==="vertical"?c:r,L=l==="vertical"?w:T,$=l==="vertical"?T:k;if(S>=L&&S<=L+R&&I>=$&&I<=$+x)return _;T+=(l==="vertical"?c:g)+h}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var g,f,d,u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x,L,$,A,V,H,et,P,F,q,Q,it,dt,St,ht,mt,rt,Rt,Yt,Pt,zt,Xt,B,lt,Vt,Mt,Tt,Nt,Jt,Kt,Qt,te,ce,se,ne,J,ft,U,G,K,Z,Ot,At,kt,Ut,bt,O,ct,Dt,xt,ie,Wt,Bt,Ft,ot,It,vt,Ct,gt,Lt,at,st,nt,wt,z,pt,ut,de,be,Se,Ie,_e,qt,oe,ye,we,Me,pe,fe,he,ve,Pe,Fe,$e,Ee,We,Be,ns,os,as,rs,ls,cs,fs,hs,ds,ps,us,gs;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=i.x-s,h=i.y-o,c=Math.sqrt(l*l+h*h);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===Y.Proximity){const X=((g=n.settings)==null?void 0:g.radius)||300,N=((f=n.settings)==null?void 0:f.falloff)||"smooth";let D=0;c<X&&(N==="linear"?D=1-c/X:D=Math.pow(1-c/X,2)),n.sensors.forEach(j=>{this.applyBehaviorSensor(i,j,D,t,n.settings,e,l,h,c)})}else if(n.type===Y.Magnetic){const X=((d=n.settings)==null?void 0:d.radius)||400,N=((u=n.settings)==null?void 0:u.strength)||.5;if(c<X&&c>5){const D=1-c/X,j=l*D*N,_t=h*D*N;i.x-=j*t*10,i.y-=_t*t*10}}else if(n.type===Y.Repel){const X=((m=n.settings)==null?void 0:m.radius)||300,N=((y=n.settings)==null?void 0:y.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x+=l/(c||1)*D*60*N*t*5,i.y+=h/(c||1)*D*60*N*t*5}}else if(n.type===Y.Orbit){const X=((v=n.settings)==null?void 0:v.speed)||1,N=((b=n.settings)==null?void 0:b.radius)||30,D=this.currentTime*X*Math.PI*2;i.x+=Math.cos(D)*N*t*5,i.y+=Math.sin(D)*N*t*5,i.rotation+=2*t*5}else if(n.type===Y.Vortex){const X=((C=n.settings)==null?void 0:C.radius)||400,N=((S=n.settings)==null?void 0:S.speed)||2,D=((I=n.settings)==null?void 0:I.strength)||1;if(c<X){const j=Math.pow(1-c/X,1.5),_t=this.currentTime*N*Math.PI*2,Et=Math.cos(_t)*30-l*.4,Gt=Math.sin(_t)*30-h*.4;i.x+=Et*j*D*t*5,i.y+=Gt*j*D*t*5,i.rotation+=5*j*D*t*5,i.scale_x*=1-j*.1*D*t,i.scale_y*=1-j*.1*D*t}}else if(n.type===Y.Fluid){const X=((w=n.settings)==null?void 0:w.radius)||300,N=((k=n.settings)==null?void 0:k.strength)||1;if(c<X){const D=Math.pow(1-c/X,1.2),j=l/(c||1)*D*1.2*N,_t=h/(c||1)*D*1.2*N;i.x+=j*10*t*5,i.y+=_t*10*t*5,i.scale_x*=1+D*.3*N*t,i.scale_y*=1+D*.3*N*t}}else if(n.type===Y.Elastic){const X=((E=n.settings)==null?void 0:E.radius)||300,N=((T=n.settings)==null?void 0:T.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.4*N*t,i.scale_y*=1+D*.4*N*t}}else if(n.type===Y.Holographic){const X=i.x-this.canvasWidth/2,N=i.y-this.canvasHeight/2,D=((W=n.settings)==null?void 0:W.factor)||25;if(i.x-=X/1e3*D*t*5,i.y-=N/1e3*D*t*5,i.style){const j=1-Math.min(1,c/400);i.style.exposure=(i.style.exposure||1)+j*.5*t}}else if(n.type===Y.Sticky){const X=((M=n.settings)==null?void 0:M.radius)||80,N=((_=n.settings)==null?void 0:_.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x-=l*D*N*t*10,i.y-=h*D*N*t*10,i.scale_x*=1-D*.1*N*t,i.scale_y*=1-D*.1*N*t}}else if(n.type===Y.Dilation){const X=((R=n.settings)==null?void 0:R.size)||120,N=((x=n.settings)==null?void 0:x.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.5*N*t,i.scale_y*=1+D*.5*N*t}}else if(n.type===Y.Parallax){const X=((L=n.settings)==null?void 0:L.factor)||15,N=(($=n.settings)==null?void 0:$.strength)||1,D=this.canvasWidth/2,j=this.canvasHeight/2,_t=this._lastPointerPos||{x:D,y:j},Et=(_t.x-D)/D,Gt=(_t.y-j)/j,ee=(((A=e.transform)==null?void 0:A.x)??0)+Et*X*N,ue=(((V=e.transform)==null?void 0:V.y)??0)+Gt*X*N,Ce=(((H=e.transform)==null?void 0:H.rotate_x)??0)-Gt*X*1.5*N,ae=(((et=e.transform)==null?void 0:et.rotate_y)??0)+Et*X*1.5*N,me=Math.min(1,10*t);i.x=this.lerp(i.x??((P=e.transform)==null?void 0:P.x)??0,ee,me),i.y=this.lerp(i.y??((F=e.transform)==null?void 0:F.y)??0,ue,me),i.rotate_x=this.lerp(i.rotate_x??((q=e.transform)==null?void 0:q.rotate_x)??0,Ce,me),i.rotate_y=this.lerp(i.rotate_y??((Q=e.transform)==null?void 0:Q.rotate_y)??0,ae,me)}else if(n.type===Y.Fold){if(c<300){const X=1-c/300,N=(l>0?-1:1)*X*10,D=1-X*.1,j=h/300*X*20,_t=-(l/300)*X*20,Et=Math.min(1,10*t);i.skew_x=this.lerp(i.skew_x??((it=e.transform)==null?void 0:it.skew_x)??0,N,Et),i.scale_y=this.lerp(i.scale_y??((dt=e.transform)==null?void 0:dt.scale_y)??1,(((St=e.transform)==null?void 0:St.scale_y)??1)*D,Et),i.rotate_x=this.lerp(i.rotate_x??((ht=e.transform)==null?void 0:ht.rotate_x)??0,j,Et),i.rotate_y=this.lerp(i.rotate_y??((mt=e.transform)==null?void 0:mt.rotate_y)??0,_t,Et),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((rt=n.settings)==null?void 0:rt.opacity)??.5}}}else if(n.type===Y.Crumple){if(c<300){const X=1-c/300,N=X*(Math.random()-.5)*5,D=X*(Math.random()-.5)*.05,j=Math.min(1,15*t);i.skew_x=this.lerp(i.skew_x??((Rt=e.transform)==null?void 0:Rt.skew_x)??0,N,j),i.scale_x=this.lerp(i.scale_x??((Yt=e.transform)==null?void 0:Yt.scale_x)??1,(((Pt=e.transform)==null?void 0:Pt.scale_x)??1)*(1+D),j),i.scale_y=this.lerp(i.scale_y??((zt=e.transform)==null?void 0:zt.scale_y)??1,(((Xt=e.transform)==null?void 0:Xt.scale_y)??1)*(1+D),j),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((B=n.settings)==null?void 0:B.intensity)??1,scale:((lt=n.settings)==null?void 0:lt.scale)??2}}}else if(n.type===Y.Squash){const X=((Vt=n.settings)==null?void 0:Vt.strength)||.8;c<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((Mt=e.transform)==null?void 0:Mt.scale_y)??1)*X,.3),i.scale_x=this.lerp(i.scale_x??1,(((Tt=e.transform)==null?void 0:Tt.scale_x)??1)*(1+(1-X)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((Nt=e.transform)==null?void 0:Nt.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((Jt=e.transform)==null?void 0:Jt.scale_x)??1,.2))}else if(n.type===Y.TextCounter){const X=((Kt=n.settings)==null?void 0:Kt.duration)||2,N=((Qt=n.settings)==null?void 0:Qt.from)||0,D=((te=n.settings)==null?void 0:te.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const j=this.currentTime-n._runtimeStart,_t=Math.min(1,j/X),Et=Math.floor(N+(D-N)*_t);if(((ce=e.geometry)==null?void 0:ce.type)==="Text"){const Gt=((se=n.settings)==null?void 0:se.prefix)||"",ee=((ne=n.settings)==null?void 0:ne.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${Gt}${Et}${ee}`}}else if(n.type===Y.Spotlight){const X=((J=n.settings)==null?void 0:J.radius)||250,N=((ft=n.settings)==null?void 0:ft.strength)||1.5;if(c<X){const D=Math.pow(1-c/X,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(U=e.style)==null?void 0:U.adjustments}),i.style.adjustments.exposure=(((K=(G=e.style)==null?void 0:G.adjustments)==null?void 0:K.exposure)||0)+D*N*50}else(Z=i.style)!=null&&Z.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((At=(Ot=e.style)==null?void 0:Ot.adjustments)==null?void 0:At.exposure)||0,.1))}else if(n.type===Y.Noise||n.type===Y.Float){const X=(((kt=n.settings)==null?void 0:kt.frequency)||((Ut=n.settings)==null?void 0:Ut.speed)||1)*.002,N=(((bt=n.settings)==null?void 0:bt.amplitude)||((O=n.settings)==null?void 0:O.range)||50)*(((ct=n.settings)==null?void 0:ct.strength)||1),D=Date.now();i.x+=Math.sin(D*X)*N*t,i.y+=Math.cos(D*X*.8)*N*t,i.rotation+=Math.sin(D*X*.5)*5*t}else if(n.type===Y.Pulse){const X=(((Dt=n.settings)==null?void 0:Dt.speed)||1)*.005,N=(((xt=n.settings)==null?void 0:xt.scale)||1.2)-1,D=Math.sin(Date.now()*X),j=((ie=n.settings)==null?void 0:ie.strength)||1;i.scale_x*=1+D*N*j*t,i.scale_y*=1+D*N*j*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,D)*.1*j*t)}else if(n.type===Y.Draggable){const X=((Wt=n.settings)==null?void 0:Wt.radius)||150,N=this.draggingBehaviors.has(e.id);if(c<X||N){const D=((Bt=n.settings)==null?void 0:Bt.strength)||1,j=N?1:Math.max(0,1-c/X);this.applyBehaviorSensor(i,jt.PositionX,j*D,t,n.settings),this.applyBehaviorSensor(i,jt.PositionY,j*D,t,n.settings)}}else if(n.type===Y.Scroll){const X=((Ft=n.settings)==null?void 0:Ft.axis)||"vertical",N=((ot=n.settings)==null?void 0:ot.factor)||.5,D=((It=n.settings)==null?void 0:It.strength)||1,j=((vt=n.settings)==null?void 0:vt.scaleFactor)||0;(X==="vertical"||X==="both")&&(i.y+=this.scrollOffset.y*N*D*t),(X==="horizontal"||X==="both")&&(i.x+=this.scrollOffset.x*N*D*t),j!==0&&(i.scale_x*=1+this.scrollOffset.y*j*t,i.scale_y*=1+this.scrollOffset.y*j*t)}else if(n.type===Y.LookAt){const X=((Ct=n.settings)==null?void 0:Ct.factor)||1,N=((gt=n.settings)==null?void 0:gt.strength)||1,D=Math.atan2(-h,-l)*(180/Math.PI),j=i.rotation,_t=(D-j+180)%360-180;i.rotation+=_t*X*N*t*10}else if(n.type===Y.Scan){const X=(((Lt=n.settings)==null?void 0:Lt.speed)||1)*.004,N=((at=n.settings)==null?void 0:at.strength)||1,D=(Math.sin(Date.now()*X)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+D*N*t*5),i.x+=(D-.5)*20*N*t}else if(n.type===Y.Glint)i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((st=n.settings)==null?void 0:st.strength)??.8};else if(n.type===Y.Ratchet){const X=((nt=n.settings)==null?void 0:nt.steps)||12,N=(((wt=n.settings)==null?void 0:wt.speed)||1)*30,D=Math.floor(i.rotation/(360/X))*(360/X);i.rotation=this.lerp(i.rotation,D+N*t,.1)}else if(n.type===Y.Jitter&&c<300){const X=((z=n.settings)==null?void 0:z.strength)||1,N=(((pt=n.settings)==null?void 0:pt.intensity)||5)*X;i.x+=(Math.random()-.5)*N*t*60,i.y+=(Math.random()-.5)*N*t*60,i.rotation+=(Math.random()-.5)*N*t*120}else if(n.type===Y.Follower){const X=(ut=n.settings)==null?void 0:ut.targetId;if(X){const N=this.objectStates.get(X);if(N){const D=((de=n.settings)==null?void 0:de.stiffness)||.1,j=N.x-i.x,_t=N.y-i.y;i.x+=j*D*t*60,i.y+=_t*D*t*60}}}else if(n.type===Y.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===Y.Gravity){const X=((be=n.settings)==null?void 0:be.strength)||9.8;i.y+=X*t*10}else if(n.type===Y.Velocity){const X=((Se=n.settings)==null?void 0:Se.vx)||0,N=((Ie=n.settings)==null?void 0:Ie.vy)||0;i.x+=X*t*10,i.y+=N*t*10}else if(n.type===Y.Shear){const X=((_e=n.settings)==null?void 0:_e.strength)||1,N=((qt=n.settings)==null?void 0:qt.radius)||300;if(c<N){const D=1-c/N;i.skew_x=this.lerp(i.skew_x||0,(((oe=e.transform)==null?void 0:oe.skew_x)||0)+D*X*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((ye=e.transform)==null?void 0:ye.skew_x)||0,.05)}else if(n.type===Y.Lens){const X=((we=n.settings)==null?void 0:we.radius)||200,N=((Me=n.settings)==null?void 0:Me.strength)||.5;if(c<X){const D=Math.pow(1-c/X,2);i.scale_x=this.lerp(i.scale_x??1,(((pe=e.transform)==null?void 0:pe.scale_x)??1)*(1+D*N),.2),i.scale_y=this.lerp(i.scale_y??1,(((fe=e.transform)==null?void 0:fe.scale_y)??1)*(1+D*N),.2)}else i.scale_x=this.lerp(i.scale_x??1,((he=e.transform)==null?void 0:he.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((ve=e.transform)==null?void 0:ve.scale_y)??1,.1)}else if(n.type===Y.LayoutAnimation){const X=((Pe=n.settings)==null?void 0:Pe.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],N=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const D=this._layoutAnimCache.get(e.id);for(const j of X){const _t=this.getObjectProperty(i,e,j);if(_t===void 0)continue;const Et=D.get(j);if(!Et)D.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);D.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:(($e=n.settings)==null?void 0:$e.duration)??N})}const Gt=D.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,ue=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(ue,((Ee=n.settings)==null?void 0:Ee.easing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const X=this._layoutAnimCache.get(e.id),N=((We=n.settings)==null?void 0:We.defaultDuration)||.3,D=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const j of D){const _t=this.getObjectProperty(i,e,j);if(_t===void 0||typeof _t!="number")continue;const Et=X.get(j);if(!Et)X.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);X.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:N})}const Gt=X.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,ue=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(ue,((Be=n.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.SpringChain){const X=((ns=n.settings)==null?void 0:ns.connections)||[],N=((os=n.settings)==null?void 0:os.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const D=this._springChainState.get(e.id);for(const _t of X){if(!D.has(_t.targetId)){const Et=this.objectStates.get(_t.targetId);D.set(_t.targetId,{x:(Et==null?void 0:Et.x)??0,y:(Et==null?void 0:Et.y)??0,vx:0,vy:0})}D.has(e.id)||D.set(e.id,{x:i.x,y:i.y,vx:0,vy:0})}const j=D.get(e.id);if(j){j.x=i.x,j.y=i.y;for(const _t of X){const Et=D.get(_t.targetId);if(!Et)continue;const Gt=Et.x-j.x,ee=Et.y-j.y,ue=Math.sqrt(Gt*Gt+ee*ee)||.001,ae=(ue-(_t.restLength||50))*(_t.stiffness||.8),me=Gt/ue*ae,Ge=ee/ue*ae;j.vx+=me*t*10,j.vy+=Ge*t*10,Et.vx-=me*t*10,Et.vy-=Ge*t*10,j.vx*=1-N*t*10,j.vy*=1-N*t*10,Et.vx*=1-N*t*10,Et.vy*=1-N*t*10;const ge=this.objectStates.get(_t.targetId);ge&&(ge.x+=Et.vx*t,ge.y+=Et.vy*t)}i.x+=j.vx*t,i.y+=j.vy*t}}else if(n.type===Y.ParticleEmitter){const X=((as=n.settings)==null?void 0:as.rate)||10,N=((rs=n.settings)==null?void 0:rs.speed)||100,D=((ls=n.settings)==null?void 0:ls.size)||5,j=((cs=n.settings)==null?void 0:cs.lifetime)||2,_t=((fs=n.settings)==null?void 0:fs.gravity)||0,Et=((hs=n.settings)==null?void 0:hs.color)||"#ffffff",Gt=((ds=n.settings)==null?void 0:ds.maxParticles)||200,ee=(ps=n.settings)!=null&&ps.rateInputId?this.inputs.get(n.settings.rateInputId)??X:X,ue=(us=n.settings)!=null&&us.gravityInputId?this.inputs.get(n.settings.gravityInputId)??_t:_t,Ce=(gs=n.settings)!=null&&gs.speedInputId?this.inputs.get(n.settings.speedInputId)??N:N;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ae=this._emitterPools.get(e.id);let me=0;n._pendingBurst&&n._pendingBurst>0&&(me=n._pendingBurst,n._pendingBurst=0);const Ge=Math.floor(ee*t)+(me||0);for(let ge=0;ge<Math.min(Ge,Gt-ae.length);ge++){const re=Math.random()*Math.PI*2,ms=Ce*(.5+Math.random()*.5);ae.push({x:i.x,y:i.y,vx:Math.cos(re)*ms,vy:Math.sin(re)*ms,life:0,maxLife:j*(.5+Math.random()*.5),size:D*(.5+Math.random()),color:Et,opacity:1})}for(let ge=ae.length-1;ge>=0;ge--){const re=ae[ge];re.vy+=ue*t*10,re.x+=re.vx*t,re.y+=re.vy*t,re.life+=t,re.opacity=Math.max(0,1-re.life/re.maxLife),re.life>=re.maxLife&&ae.splice(ge,1)}}})})}applyBehaviorSensor(t,s,o,e,i,n,a=0,r=0,l=1){var d,u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x,L,$,A,V,H,et;const h=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,c=Math.min(1,15*e),g=l>0?a/l:0,f=l>0?r/l:0;switch(s){case jt.Scale:{const P=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,q=P*(1+o*h*.4),Q=F*(1+o*h*.4);t.scale_x=(t.scale_x??P)*(1-c)+q*c,t.scale_y=(t.scale_y??F)*(1-c)+Q*c;break}case jt.Opacity:{const P=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,F=Math.max(0,Math.min(100,P-o*h*100));t.opacity=(t.opacity??P)*(1-c)+F*c;break}case jt.RotateZ:{const P=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,F=P+o*h*45;t.rotation=(t.rotation??P)*(1-c)+F*c;break}case jt.RotateX:{const P=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_x)??0,F=P-f*o*h*60;t.rotate_x=(t.rotate_x??P)*(1-c)+F*c;break}case jt.RotateY:{const P=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_y)??0,F=P+g*o*h*60;t.rotate_y=(t.rotate_y??P)*(1-c)+F*c;break}case jt.PositionX:{const P=((C=n==null?void 0:n.transform)==null?void 0:C.x)??0,F=P-g*o*h*40;t.x=(t.x??P)*(1-c)+F*c;break}case jt.PositionY:{const P=((S=n==null?void 0:n.transform)==null?void 0:S.y)??0,F=P-f*o*h*40;t.y=(t.y??P)*(1-c)+F*c;break}case jt.SkewX:{const P=((I=n==null?void 0:n.transform)==null?void 0:I.skew_x)??0,F=P+g*o*h*45;t.skew_x=(t.skew_x??P)*(1-c)+F*c,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case jt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(w=n==null?void 0:n.style)==null?void 0:w.blur});const P=((E=(k=n==null?void 0:n.style)==null?void 0:k.blur)==null?void 0:E.amount)||0,F=P+o*((i==null?void 0:i.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??P)*(1-c)+F*c;break}case jt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const P=((M=(W=n==null?void 0:n.style)==null?void 0:W.adjustments)==null?void 0:M.exposure)||0,F=P+o*((i==null?void 0:i.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??P)*(1-c)+F*c;break}case jt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const P=((x=(R=n==null?void 0:n.style)==null?void 0:R.adjustments)==null?void 0:x.hue)||0,F=P+o*((i==null?void 0:i.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??P)*(1-c)+F*c;break}case jt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(L=n==null?void 0:n.style)==null?void 0:L.adjustments});const P=((A=($=n==null?void 0:n.style)==null?void 0:$.adjustments)==null?void 0:A.negative)||0,F=P+o*((i==null?void 0:i.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??P)*(1-c)+F*c;break}case jt.CornerRadius:{const P=((V=n==null?void 0:n.transform)==null?void 0:V.corner_radius)||0,F=P+o*h*50;t.corner_radius=(t.corner_radius??P)*(1-c)+F*c;break}case jt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const P=((H=n==null?void 0:n.style)==null?void 0:H.borderWidth)||0,F=P+o*h*10;t.style.borderWidth=(t.style.borderWidth??P)*(1-c)+F*c;break}case jt.LetterSpacing:{t.geometry||(t.geometry={});const P=((et=n==null?void 0:n.geometry)==null?void 0:et.letterSpacing)||0,F=P+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??P)*(1-c)+F*c;break}}}getObjectProperty(t,s,o){const e=o.split(".");let i=t;for(const n of e){if(i==null||typeof i!="object")return;if(n==="style"&&t.style===void 0){i=s.style;continue}i=i[n]}return typeof i=="number"?i:void 0}setObjectProperty(t,s,o,e){const i=o.split(".");let n=t;for(let r=0;r<i.length-1;r++){const l=i[r];if(n[l]===void 0||n[l]===null){const h=s,c=i.slice(0,r+1).reduce((g,f)=>g==null?void 0:g[f],h);n[l]=c!==void 0?{...c}:{}}n=n[l]}const a=i[i.length-1];n!=null&&(n[a]=e)}applyEasing(t,s){switch(s){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,l=s.naturalHeight,h=r/l,c=i/n;let g=i,f=n,d=o,u=e;a==="cover"?h>c?(g=n*h,d=o-(g-i)/2):(f=i/h,u=e-(f-n)/2):a==="contain"&&(h>c?(f=i/h,u=e+(n-f)/2):(g=n*h,d=o+(i-g)/2)),t.drawImage(s,d,u,g,f)}}const ii=$t.forwardRef(({artboard:p,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:h,onInputChange:c,onInputFocus:g,onInputBlur:f,onLog:d,onLogicUpdate:u,onButtonClick:m,onGraphPointClick:y,currentTime:v,revision:b=0,scrollY:C,scrollX:S,mouseX:I,mouseY:w,isMouseDown:k,inputs:E,interactive:T=!0,onNavigation:W},M)=>{const _=$t.useRef(null),R=$t.useRef(new is),x=$t.useRef(void 0),L=$t.useRef(0),$=$t.useRef(null),A=$t.useRef(b),[,V]=$t.useState(p||null),H=$t.useRef(!0);$t.useImperativeHandle(M,()=>_.current),$t.useEffect(()=>(H.current=!0,()=>{H.current=!1,x.current&&cancelAnimationFrame(x.current)}),[]),$t.useEffect(()=>{R.current.setLayout(e,i)},[e,i]),$t.useEffect(()=>{const P=R.current;a&&P.setTriggerCallback(a),r&&P.setInputUpdateCallback((F,q)=>r({[F]:q})),l&&P.setComponentChangeCallback(F=>l(F)),h&&P.setToggleCallback(h),c&&P.setInputChangeCallback(c),g&&P.setInputFocusCallback(g),f&&P.setInputBlurCallback(f),d&&P.setOnLogCallback(F=>d(F,"info")),u&&P.setLogicUpdateCallback(u),m&&P.setButtonClickCallback(m),y&&P.setGraphPointClickCallback(F=>y(F.objectId,F)),W&&P.setNavigationCallback(W)},[a,r,l,h,c,g,f,d,u,m,y,W]),$t.useEffect(()=>{(async()=>{let F=p;if(t&&!p)try{t.startsWith("{")?F=JSON.parse(t):F=await(await fetch(t)).json()}catch(q){console.error("[ExodeUI] Failed to load src:",q)}if(F){const q=R.current,Q=F.id||F.name||"default";($.current!==Q||A.current!==b)&&(q.load(F),$.current=Q,A.current=b,V(F),L.current=0,q.advance(0)),n&&n(q)}})()},[p==null?void 0:p.id,t,b]),$t.useEffect(()=>{const P=F=>{if(!R.current||!H.current)return;const q=R.current,Q=_.current;if(!Q)return;const it=Q.getContext("2d");if(!it)return;const dt=F/1e3;L.current===0&&(L.current=dt);let St=dt-L.current;St>.1&&(St=.1),L.current=dt;const ht=Q.getBoundingClientRect(),mt=window.devicePixelRatio||1,rt=Math.round(ht.width*mt),Rt=Math.round(ht.height*mt);(Q.width!==rt||Q.height!==Rt)&&(Q.width=rt,Q.height=Rt),o?q.advance(St):v!==void 0&&q.seek(v),q.render(it,Q.width,Q.height),x.current=requestAnimationFrame(P)};return x.current=requestAnimationFrame(P),()=>{x.current&&cancelAnimationFrame(x.current)}},[o,v]),$t.useEffect(()=>{const P=R.current;C!==void 0&&P.updateInput("scrollY",C),S!==void 0&&P.updateInput("scrollX",S),I!==void 0&&P.updateInput("mouseX",I),w!==void 0&&P.updateInput("mouseY",w),k!==void 0&&P.updateInput("isMouseDown",k),E&&Object.entries(E).forEach(([F,q])=>P.updateInput(F,q))},[C,S,I,w,k,E]);const et=(P,F)=>{if(!T||!_.current)return;const q=_.current,Q=q.getBoundingClientRect(),it=P.clientX-Q.left,dt=P.clientY-Q.top,St=window.devicePixelRatio||1;R.current.handlePointerInput(F,it*St,dt*St,q.width,q.height)};return Zt.jsx("canvas",{ref:_,onPointerDown:P=>{var F;et(P,"down"),(F=_.current)==null||F.focus()},onPointerMove:P=>et(P,"move"),onPointerUp:P=>et(P,"up"),onPointerCancel:P=>et(P,"up"),onClick:P=>et(P,"click"),onWheel:P=>{R.current.handleWheel(P.deltaX,P.deltaY)},onKeyDown:P=>R.current.handleKeyDown(P.nativeEvent),onContextMenu:P=>P.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}})});function ni(){const[p,t]=$t.useState(null),s=$t.useCallback((c,g)=>{p==null||p.setInputBool(c,g)},[p]),o=$t.useCallback((c,g)=>{p==null||p.setInputNumber(c,g)},[p]),e=$t.useCallback(c=>{p==null||p.fireTrigger(c)},[p]),i=$t.useCallback((c,g)=>{p==null||p.setInputText(c,g)},[p]),n=$t.useCallback((c,g)=>{p==null||p.setInputNumberArray(c,g)},[p]),a=$t.useCallback((c,g)=>{p==null||p.setInputStringArray(c,g)},[p]),r=$t.useCallback((c,g)=>{p==null||p.updateObjectOptions(c,g)},[p]),l=$t.useCallback((c,g,f)=>{p==null||p.updateConstraint(c,g,f)},[p]),h=$t.useCallback((c,g)=>{p==null||p.updateGraphData(c,g)},[p]);return{setEngine:t,engine:p,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:l,updateGraphData:h,updateObjectOptions:r}}const oi=({artboard:p,config:t})=>{const s={...p.seo,...t},o=s.enableSmartExtraction!==!1;$t.useEffect(()=>{const a=s.title||p.name;a&&(document.title=a);let r=s.description;if(!r&&o){const c=p.objects.filter(g=>{var f;return((f=g.geometry)==null?void 0:f.type)==="Text"}).sort((g,f)=>{var d,u;return(((d=f.geometry.text)==null?void 0:d.length)||0)-(((u=g.geometry.text)==null?void 0:u.length)||0)});c.length>0&&(r=c[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||p.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,p,o]);const e=(a,r,l)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",l)},i=()=>{const a=[];return a.push(Zt.jsx("h1",{children:s.title||p.name},"artboard-title")),p.objects.forEach((l,h)=>{var c,g;if(!(l.visible===!1||l.isVisible===!1))if(((c=l.geometry)==null?void 0:c.type)==="Text"){const f=l.geometry.text;f&&(l.geometry.fontSize>24?a.push(Zt.jsx("h2",{children:f},l.id||h)):a.push(Zt.jsx("p",{children:f},l.id||h)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const f=l.geometry.src,d=l.altText||l.name||"Illustration";a.push(Zt.jsx("img",{src:f,alt:d},l.id||h))}else l.type==="Button"&&a.push(Zt.jsx("button",{children:l.name||"Button"},l.id||h))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||p.name,description:s.description,image:s.ogImage||p.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Zt.jsxs("div",{id:`exode-seo-${p.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:[i(),Zt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ai={version:"6.3.18"}.version;Ht.BehaviorSensor=jt,Ht.BehaviorType=Y,Ht.ConditionOp=Xe,Ht.ExodeSEO=oi,Ht.ExodeUICanvas=ii,Ht.ExodeUIEngine=is,Ht.LogicOp=yt,Ht.VERSION=ai,Ht.useExodeUI=ni,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})});
|
|
31
|
+
`&&Mt++)}),t.globalAlpha=lt}}}applyStrokeAlignment(t,s,o,e,i,n){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=a.width,l=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,i);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const c=t.globalAlpha;t.globalAlpha=c*this.normalizeOpacity(a.opacity??100),t.lineWidth=r,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const g=a.trimStart??0,h=a.trimEnd??1,d=a.trimOffset??0,p=a.dashOffset??0,m=a.dashArray||[];if(g!==0||h!==1||d!==0){const y=this.getPerimeter(o,e,i);if(y>0){const v=Math.max(0,Math.min(1,g)),b=Math.max(0,Math.min(1,h));if(v<b){const C=y*(b-v),S=y-C,I=-(y*(v+d%1));t.setLineDash([C,S]),t.lineDashOffset=I+p*y}else if(v===b)t.setLineDash([0,y]);else{const C=y*(1-v+b),S=y-C,I=-(y*v);t.setLineDash([C,S]),t.lineDashOffset=I+p*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=p);(o==null?void 0:o.type)==="Line"||e===0||i===0?(this.applyPath(t,o,e,i,n),t.stroke()):l==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore()):l==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,i,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,i,n),t.fill(),t.restore()):(t.lineWidth=r,this.applyPath(t,o,e,i,n),t.stroke()),t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let l=n/360*r;if(a>0){const f=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));l+=n/360*f,n<360&&(l+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(l+=2*Math.max(e,i));return isNaN(l)?0:l}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){n=l.x,a=l.y;continue}const f=n,c=a,g=e[r-1].out_x,h=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?i+=this.getBezierLength(f,c,g??f,h??c,l.in_x??l.x,l.in_y??l.y,l.x,l.y):i+=Math.sqrt((l.x-f)**2+(l.y-c)**2),n=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,p=a,m=[...e.slice(0,r+1)].reverse().find(w=>w.moveTo)||e[0],y=m.x,v=m.y,b=e[r].out_x,C=e[r].out_y,S=m.in_x,I=m.in_y;b!==void 0||S!==void 0?i+=this.getBezierLength(d,p,b??d,C??p,S??y,I??v,y,v):i+=Math.sqrt((y-d)**2+(v-p)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,l=10){let f=0,c=t,g=s;for(let h=1;h<=l;h++){const d=h/l,p=1-d,m=d*d,y=p*p,v=y*p,b=m*d,C=v*t+3*y*d*o+3*p*m*i+b*a,S=v*s+3*y*d*e+3*p*m*n+b*r,I=C-c,w=S-g;f+=Math.sqrt(I*I+w*w),c=C,g=S}return f}getBezierTAtLength(t,s,o,e,i,n,a,r,l,f=20){if(t<=0)return 0;let c=0,g=s,h=o;for(let d=1;d<=f;d++){const p=d/f,m=1-p,y=p*p,v=m*m,b=v*m,C=y*p,S=b*s+3*v*p*e+3*m*y*n+C*r,I=b*o+3*v*p*i+3*m*y*a+C*l,w=S-g,M=I-h,P=Math.sqrt(w*w+M*M);if(c+P>=t){const T=t-c,W=P===0?0:T/P;return(d-1+W)/f}c+=P,g=S,h=I}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,l=-1/0;i.forEach(v=>{typeof v.x=="number"&&typeof v.y=="number"&&(n=Math.min(n,v.x),a=Math.max(a,v.x),r=Math.min(r,v.y),l=Math.max(l,v.y),v.out_x!==void 0&&(n=Math.min(n,v.out_x),a=Math.max(a,v.out_x)),v.out_y!==void 0&&(r=Math.min(r,v.out_y),l=Math.max(l,v.out_y)),v.in_x!==void 0&&(n=Math.min(n,v.in_x),a=Math.max(a,v.in_x)),v.in_y!==void 0&&(r=Math.min(r,v.in_y),l=Math.max(l,v.in_y)))});const f=(n+a)/2,c=(r+l)/2,h=this.getPerimeter(t,s,o)*e;let d=0;const p=[];let m=i[0],y=i[0];for(let v=1;v<i.length;v++){const b=i[v];if(b.moveTo){m=b,y=b;continue}p.push({p0:m,p1:b}),(b.closePath||v===i.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:b,p1:y}),m=b}for(const v of p){const b=v.p0,C=v.p1;let S=0;const I=b.out_x!==void 0||C.in_x!==void 0;if(I?S=this.getBezierLength(b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y):S=Math.sqrt((C.x-b.x)**2+(C.y-b.y)**2),d+S>=h||v===p[p.length-1]){let w=0;if(I)return w=this.getBezierTAtLength(h-d,b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y,20),this.getBezierPointAndAngle(w,b,C,f,c);{w=S===0?0:(h-d)/S;const M=b.x+(C.x-b.x)*w-f,P=b.y+(C.y-b.y)*w-c,T=Math.atan2(C.y-b.y,C.x-b.x);return{x:M,y:P,angle:T}}}d+=S}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,f=i*Math.cos(l),c=n*Math.sin(l),g=-i*Math.sin(l),h=n*Math.cos(l),d=Math.atan2(h,g);return{x:f,y:c,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let l=0,f=0,c=0;return r<i?(l=-i/2+r,f=-n/2,c=0):r<i+n?(l=i/2,f=-n/2+(r-i),c=Math.PI/2):r<2*i+n?(l=i/2-(r-(i+n)),f=n/2,c=Math.PI):(l=-i/2,f=n/2-(r-(2*i+n)),c=-Math.PI/2),{x:l,y:f,angle:c}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,f=o.in_x??o.x,c=o.in_y??o.y,g=o.x,h=o.y,d=1-t,p=t*t,m=d*d,y=m*d,v=p*t,b=y*n+3*m*t*r+3*d*p*f+v*g-e,C=y*a+3*m*t*l+3*d*p*c+v*h-i,S=3*m*(r-n)+6*d*t*(f-r)+3*p*(g-f),I=3*m*(l-a)+6*d*t*(c-l)+3*p*(h-c),w=Math.atan2(I,S);return{x:b,y:C,angle:w}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),i=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,i)}applyArtEffectOverlay(t,s,o,e,i,n){var h,d,p,m,y;const a=this.objectStates.get(s.id),r=((h=a==null?void 0:a.style)==null?void 0:h.artEffect)||s.artEffect||((d=s.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const l=r.type,f=r.intensity??.5,c=r.speed??1,g=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,i,n),t.clip(),l==="shimmer"){const b=this.currentTime*c%2/2,C=t.createLinearGradient(-e,-i,e,i);C.addColorStop(Math.max(0,b-.2),"rgba(255,255,255,0)"),C.addColorStop(b,`rgba(255,255,255,${f*.8})`),C.addColorStop(Math.min(1,b+.2),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let C=((this._lastPointerPos||{x:0}).x-(((p=s.transform)==null?void 0:p.x)??0)+300)/600;C=Math.max(-.2,Math.min(1.2,C));const S=t.createLinearGradient(-e,-i,e,i);S.addColorStop(Math.max(0,C-.15),"rgba(255,255,255,0)"),S.addColorStop(Math.max(0,Math.min(1,C)),`rgba(255,255,255,${f})`),S.addColorStop(Math.min(1,C+.15),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const v=this._lastPointerPos||{x:0,y:0},b=v.x-(((m=s.transform)==null?void 0:m.x)??0),C=v.y-(((y=s.transform)==null?void 0:y.y)??0),S=t.createLinearGradient(b>0?-e/2:e/2,C>0?-i/2:i/2,b>0?e/2:-e/2,C>0?i/2:-i/2);S.addColorStop(0,`rgba(0,0,0,${f*.6})`),S.addColorStop(.4,"rgba(0,0,0,0)"),S.addColorStop(.5,`rgba(255,255,255,${f*.4})`),S.addColorStop(1,`rgba(0,0,0,${f*.2})`),t.fillStyle=S,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over",t.beginPath(),b>0&&C>0?(t.moveTo(e/2-40,i/2),t.lineTo(e/2,i/2-40),t.lineTo(e/2-40,i/2-40)):b<0&&C>0?(t.moveTo(-e/2+40,i/2),t.lineTo(-e/2,i/2-40),t.lineTo(-e/2+40,i/2-40)):b>0&&C<0?(t.moveTo(e/2-40,-i/2),t.lineTo(e/2,-i/2+40),t.lineTo(e/2-40,-i/2+40)):(t.moveTo(-e/2+40,-i/2),t.lineTo(-e/2,-i/2+40),t.lineTo(-e/2+40,-i/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=b>0?-2:2,t.shadowOffsetY=C>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const v=Math.floor(e/g),b=document.createElement("canvas");b.width=v,b.height=Math.floor(i/g);const C=b.getContext("2d"),S=C.createImageData(b.width,b.height);for(let I=0;I<S.data.length;I+=4){const w=Math.random()>.95?150:255;S.data[I]=w,S.data[I+1]=w,S.data[I+2]=w,S.data[I+3]=255*f}C.putImageData(S,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(b,-e/2,-i/2,e,i)}else if(l==="acid_gradient"||l==="acid_rave"){const v=this.currentTime*c,b=r.color1,C=r.color2,S=t.createLinearGradient(-e/2,-i/2,e/2,i/2);if(b&&C){const I=v*60%360;S.addColorStop(0,this._shiftHue(b,I,f*.7)),S.addColorStop(1,this._shiftHue(C,(I+180)%360,f*.7))}else{const I=v*100%360,w=(I+180)%360;S.addColorStop(0,`hsla(${I}, 80%, 50%, ${f*.5})`),S.addColorStop(1,`hsla(${w}, 80%, 50%, ${f*.5})`)}t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(l==="halftone"){const v=Math.max(2,g*(1-f*.8)),b=document.createElement("canvas");b.width=v,b.height=v;const C=b.getContext("2d");if(C){C.fillStyle="black",C.beginPath(),C.arc(v/2,v/2,v/2*f,0,Math.PI*2),C.fill();const S=t.createPattern(b,"repeat");S&&(t.globalAlpha=.3*f,t.fillStyle=S,t.fillRect(-e/2,-i/2,e,i))}}else if(l==="noise"){const v=Math.floor(e*i*f*.02);t.globalAlpha=.4*f;for(let b=0;b<v;b++){const C=Math.random()>.5?255:0;t.fillStyle=`rgba(${C}, ${C}, ${C}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*f,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let v=-i/2;v<i/2;v+=4)t.beginPath(),t.moveTo(-e/2,v),t.lineTo(e/2,v),t.stroke()}else if(l==="chromatic_aberration"){const v=5*f;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-v,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+v,-i/2,e,i)}else if(l==="pixelate"){const v=Math.max(2,Math.round(g*(1-f*.5))),b=document.createElement("canvas"),C=Math.max(1,Math.ceil(e/v)),S=Math.max(1,Math.ceil(i/v));b.width=C,b.height=S;const I=b.getContext("2d");if(I){I.imageSmoothingEnabled=!1;const w=t.getTransform(),M=w.e-e/2,P=w.f-i/2;I.drawImage(t.canvas,M,P,e,i,0,0,C,S),t.imageSmoothingEnabled=!1,t.drawImage(b,0,0,C,S,-e/2,-i/2,e,i),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const v=this.currentTime*c,b=r.chaosAmount??.2,C=Math.max(3,Math.floor(8*f)),S=f*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=f*.4;const I=S*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+I,-i/2,e,i),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-I,-i/2,e,i),t.globalCompositeOperation="source-over",t.globalAlpha=1;const w=i/C;for(let M=0;M<C;M++){const P=Math.sin(M*127.1+v*311.7*c)*43758.5,T=P-Math.floor(P);if(T>1-b){const W=(T-(1-b))/b*S*(Math.random()>.5?1:-1),k=-i/2+M*w,_=t.getTransform(),R=_.e-e/2+W,x=_.f+k;t.save(),t.beginPath(),t.rect(-e/2,k,e,w),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,R,x,e,w,-e/2+W,k,e,w),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,i=0,n=0;if(t.startsWith("#")){const h=t.replace("#","");e=parseInt(h.substring(0,2),16)/255,i=parseInt(h.substring(2,4),16)/255,n=parseInt(h.substring(4,6),16)/255}const a=Math.max(e,i,n),r=Math.min(e,i,n);let l=0,f=0,c=(a+r)/2;if(a!==r){const h=a-r;switch(f=c>.5?h/(2-a-r):h/(a+r),a){case e:l=((i-n)/h+(i<n?6:0))/6;break;case i:l=((n-e)/h+2)/6;break;case n:l=((e-i)/h+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(f*100).toFixed(0)}%, ${(c*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,i,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",l=n.opacity??.5,f=n.noise??0;t.save(),this.applyPath(t,s,o,e,i),t.clip();const c=t.getTransform(),g=c.e-o/2,h=c.f-e/2;try{const p=document.createElement("canvas");p.width=Math.max(1,Math.ceil(o)),p.height=Math.max(1,Math.ceil(e));const m=p.getContext("2d");if(m){m.drawImage(t.canvas,g,h,o,e,0,0,o,e),m.filter=`blur(${a}px)`;const y=document.createElement("canvas");y.width=p.width,y.height=p.height;const v=y.getContext("2d");v.filter=`blur(${a}px)`,v.drawImage(p,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(y,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const d=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(d.addColorStop(0,"rgba(255,255,255,0.12)"),d.addColorStop(.3,"rgba(255,255,255,0.04)"),d.addColorStop(.5,"rgba(255,255,255,0.0)"),d.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e),f>0){if(t.globalAlpha=f/100,!this._noiseTileCanvas){const m=document.createElement("canvas");m.width=64,m.height=64;const y=m.getContext("2d"),v=y.createImageData(64,64),b=v.data;for(let C=0;C<b.length;C+=4){const S=Math.floor(Math.random()*255);b[C]=S,b[C+1]=S,b[C+2]=S,b[C+3]=18}y.putImageData(v,0,0),this._noiseTileCanvas=m}const p=t.createPattern(this._noiseTileCanvas,"repeat");p&&(t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,i),t.stroke(),t.restore()}applyPath(t,s,o,e,i){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,f=e/2,c=n*Math.PI/180,g=a*Math.PI/180,h=c+g;a>=360&&r<=0?t.ellipse(0,0,l,f,0,0,Math.PI*2):(t.ellipse(0,0,l,f,0,c,h,!1),r>0?t.ellipse(0,0,l*r,f*r,0,h,c,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const l=r*2*Math.PI/n-Math.PI/2,f=a*Math.cos(l),c=a*Math.sin(l);r===0?t.moveTo(f,c):t.lineTo(f,c)}t.closePath()}else if(s.type==="Star"){const n=s.points||5,a=s.outer_radius||Math.min(o,e)/2;let r=s.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let l=0;l<n*2;l++){const f=l*Math.PI/n-Math.PI/2,c=l%2===0?a:r,g=c*Math.cos(f),h=c*Math.sin(f);l===0?t.moveTo(g,h):t.lineTo(g,h)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%10===0&&console.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(n=Math.min(n,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(n=Math.min(n,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.in_y)))}),n===1/0)return;const f=(n+a)/2,c=(r+l)/2;if(isNaN(f)||isNaN(c)){console.warn("[Engine] Invalid path center:",f,c);return}s.points.forEach((g,h)=>{if(h===0||g.moveTo)t.moveTo(g.x-f,g.y-c);else{const d=s.points[h-1];if(!d)return;const p=(d.out_x??d.x)-f,m=(d.out_y??d.y)-c,y=(g.in_x??g.x)-f,v=(g.in_y??g.y)-c;isNaN(p)||isNaN(y)||isNaN(g.x)?t.lineTo(g.x-f,g.y-c):t.bezierCurveTo(p,m,y,v,g.x-f,g.y-c)}if(g.closePath||h===s.points.length-1&&(s.is_closed||s.isClosed)){const d=[...s.points.slice(0,h+1)].reverse().find(p=>p.moveTo)||s.points[0];d&&(g.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-f,(g.out_y??g.y)-c,(d.in_x??d.x)-f,(d.in_y??d.y)-c,d.x-f,d.y-c),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(g=>{n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const f=(n+a)/2,c=(r+l)/2;s.points.forEach((g,h)=>{if(h===0)t.moveTo(g.x-f,g.y-c);else{const d=s.points[h-1];d.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-f,(d.out_y??d.y)-c,(g.in_x??g.x)-f,(g.in_y??g.y)-c,g.x-f,g.y-c):t.lineTo(g.x-f,g.y-c)}(g.closePath||h===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var dt,St;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((dt=s.geometry)==null?void 0:dt.width)||250,n=((St=s.geometry)==null?void 0:St.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",f=l!=="default"?l:a?"focused":r?"hovered":"default",c=e.label||{visible:!0,text:"Label"},g=e.helperText||{visible:!1,text:"Helper text"},h=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},p=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},v=[y.tl,y.tr,y.br,y.bl];let b=e.backgroundColor||"rgba(31, 41, 55, 1)",C=e.borderColor||"rgba(55, 65, 81, 1)",S=e.borderWidth??1.5,I=e.color||"#ffffff",w=e.placeholderColor||"rgba(156, 163, 175, 1)",M=e.fontSize||14;const P=`${f}Style`,T=e[P];T?(T.backgroundColor!==void 0&&(b=T.backgroundColor),T.borderColor!==void 0&&(C=T.borderColor),T.borderWidth!==void 0&&(S=T.borderWidth),T.color!==void 0&&(I=T.color),T.placeholderColor!==void 0&&(w=T.placeholderColor),T.fontSize!==void 0&&(M=T.fontSize)):f==="focused"?(C=e.focusBorderColor||"rgba(59, 130, 246, 1)",S=Math.max(S,2)):f==="hovered"||f==="hover"?(C=e.hoverBorderColor||C,b=e.hoverBackgroundColor||b):f==="disabled"?(b=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",C=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):f==="error"&&(C="rgba(239, 68, 68, 1)",S=Math.max(S,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,v);const W=this.createCanvasFill(t,b,i,n);if(W&&(t.fillStyle=W,t.fill()),S>0){const ht=this.createCanvasFill(t,C,i,n);if(ht&&(t.strokeStyle=ht,t.lineWidth=S,t.stroke()),f==="focused"||f==="focus"){t.save(),t.beginPath();const mt=v.map(rt=>rt+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,mt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const k=(ht,mt)=>{if(!ht.visible||!ht.svgPath)return;const rt=ht.size||14,Rt=ht.offset??16,Yt=ht.color||"#ffffff",Pt=mt?-(i/2)+Rt:i/2-Rt,zt=ht.svgPath;if(t.save(),t.translate(Pt,0),!zt.startsWith("<svg")){const Xt=new Path2D(zt),B=rt/24;t.scale(B,B),t.translate(-12,-12),t.fillStyle=Yt,t.fill(Xt)}t.restore()};k(h,!0),k(d,!1);const _=e.text||"",R=e.placeholder||"Enter text...",x=!_,O=_||R,$=x?w:I,A=M,V=e.fontFamily||"Inter",H=e.fontWeight||400;t.font=`${H} ${A}px "${V}", sans-serif`,t.fillStyle=$,t.textAlign="left",t.textBaseline=p?"top":"middle";const et=e.inputPadding??16,E=h.visible?(h.offset??16)+(h.size||14)/2+8:et,F=d.visible?(d.offset??16)+(d.size||14)/2+8:et,q=-(i/2)+E,Q=i-E-F,it=e.inputType==="password"?"•".repeat(O.length):O;if(t.save(),t.beginPath(),t.rect(q-2,-n/2+4,Q+4,n-8),t.clip(),p){const ht=it.split(`
|
|
32
|
+
`);let mt=-n/2+et;const rt=A*1.2;let Rt=0;ht.forEach((Yt,Pt)=>{const zt=Yt.split(" ");let Xt="";for(let B=0;B<zt.length;B++){const lt=Xt+zt[B]+" ";t.measureText(lt).width>Q&&B>0?(t.fillText(Xt,q,mt),Xt=zt[B]+" ",mt+=rt):Xt=lt}t.fillText(Xt,q,mt),Rt=t.measureText(Xt).width,Pt<ht.length-1&&(mt+=rt,Rt=0)}),a&&!x&&Math.floor(performance.now()/500)%2===0&&t.fillRect(q+Rt,mt,1.5,A)}else{const mt=t.measureText(it).width;let rt=0;if(mt>Q&&(rt=mt-Q),t.fillText(it,q-rt,0),a&&!x&&Math.floor(performance.now()/500)%2===0){const Yt=q+mt-rt;t.fillRect(Yt,-(A/2),1.5,A)}}if(t.restore(),c.visible!==!1){const ht=c.text||"Label",mt=c.fontSize||12,rt=c.color||"rgba(156, 163, 175, 1)",Rt=c.offset??8;t.font=`600 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="bottom";const Yt=-(i/2),Pt=-(n/2)-Rt;t.fillText(ht,Yt,Pt)}if(g.visible===!0){const ht=g.text||"Helper text",mt=g.fontSize||11,rt=f==="error"?"rgba(239, 68, 68, 1)":g.color||"rgba(156, 163, 175, 1)",Rt=g.offset??6;t.font=`400 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top";const Yt=-(i/2),Pt=n/2+Rt;t.fillText(ht,Yt,Pt)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,f=(i.max??100)-r,c=f===0?0:(a-r)/f,g=i.trackHeight||4,h=i.trackRoundedness??2,d=i.trackShape??"Rectangle",p=i.trackPath||"",m=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",v=i.thumbShape||"Ellipse",b=i.thumbWidth??16,C=i.thumbHeight??16,S=i.thumbRoundedness??0,I=i.thumbColor||"#ffffff",w=i.thumbPath||"",M=i.thumbIcon||"",P=i.showValueTooltip??!1,T=i.tooltipBgColor||"#333333",W=i.tooltipColor||"#ffffff",k=i.tooltipOffsetX??0,_=i.tooltipOffsetY??-25,R=(Q,it,dt,St,ht,mt,rt)=>{if((Q==="Custom"||Q==="Icon")&&rt)try{const Rt=new Path2D(rt);if(t.save(),t.translate(it,dt),Q==="Icon"){const Yt=Math.min(St,ht)/24;t.scale(Yt,Yt),t.translate(-12,-12)}t.fill(Rt),t.restore();return}catch(Rt){console.error("Error drawing slider shape in engine:",Rt)}if(t.beginPath(),Q==="Ellipse")t.ellipse(it,dt,St/2,ht/2,0,0,Math.PI*2);else if(Q==="Rectangle")this.drawRoundRect(t,it-St/2,dt-ht/2,St,ht,mt);else if(Q==="Triangle")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt+ht/2),t.lineTo(it-St/2,dt+ht/2),t.closePath();else if(Q==="Diamond")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt),t.lineTo(it,dt+ht/2),t.lineTo(it-St/2,dt),t.closePath();else if(Q==="Polygon"){const Rt=s.geometry.sides||3,Yt=s.geometry.radius||Math.min(St,ht)/2;for(let Pt=0;Pt<Rt;Pt++){const zt=Pt*2*Math.PI/Rt-Math.PI/2,Xt=it+Yt*Math.cos(zt),B=dt+Yt*Math.sin(zt);Pt===0?t.moveTo(Xt,B):t.lineTo(Xt,B)}t.closePath()}else if(Q==="Star"){const Yt=Math.min(St,ht)/2,Pt=Yt/2;for(let zt=0;zt<5*2;zt++){const Xt=zt%2===0?Yt:Pt,B=zt*Math.PI/5-Math.PI/2;t.lineTo(it+Xt*Math.cos(B),dt+Xt*Math.sin(B))}t.closePath()}else Q==="Line"&&(t.moveTo(it-St/2,dt),t.lineTo(it+St/2,dt));t.fill()},x=this.createCanvasFill(t,y,n,g);x&&(t.fillStyle=x,t.strokeStyle=x),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):R(d,0,0,n,g,h,p);const O=n-b,$=-n/2+b/2+c*O,A=$- -n/2;if(A>0){const Q=this.createCanvasFill(t,m,n,g);Q&&(t.fillStyle=Q,t.strokeStyle=Q),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo($,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-g/2,A,g,h),t.fill())}t.save(),t.translate($,0);const V=t.getTransform(),H=Math.sqrt(V.a*V.a+V.b*V.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*H,t.shadowOffsetY=1*H;const et=this.createCanvasFill(t,I,b,C);if(et&&(t.fillStyle=et),R(v,0,0,b,C,S,v==="Icon"?M:w),t.restore(),P){t.save(),t.translate($+k,_);const Q=Math.round(a).toString();t.font="10px Inter, sans-serif";const it=t.measureText(Q),dt=6,St=4,ht=it.width+dt*2,mt=14+St;t.beginPath(),this.drawRoundRect(t,-ht/2,-mt/2,ht,mt,4),t.fillStyle=T,t.fill(),t.fillStyle=W,t.textAlign="center",t.textBaseline="middle",t.fillText(Q,0,0),t.restore()}const E=i.label||{},F=i.helperText||{},q=i.fontFamily||"Inter";if(E.visible!==!1){const Q=E.text||"Label",it=E.fontSize||12,dt=E.color||"rgba(156, 163, 175, 1)",St=E.offset??8;t.font=`600 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="bottom";const ht=-(n/2),mt=-(g/2)-St;t.fillText(Q,ht,mt)}if(F.visible===!0){const Q=F.text||"Helper text",it=F.fontSize||11,dt=F.color||"rgba(156, 163, 175, 1)",St=F.offset??6;t.font=`400 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="top";const ht=-(n/2),mt=g/2+St;t.fillText(Q,ht,mt)}}renderDropdown(t,s){var _;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,l=e.corner_radius??6,f=e.disabled||e.previewState==="disabled",c=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!f;let h=e.backgroundColor,d=e.borderColor,p=e.color||"#333333";f?(h=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):g?(h=e.activeBackgroundColor||h,d=e.activeBorderColor||d,p=e.activeColor||p):c&&(h=e.hoverBackgroundColor||h,d=e.hoverBorderColor||d,p=e.hoverColor||p),h||(h="#ffffff"),d||(d="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,l),t.fillStyle=this.createCanvasFill(t,typeof h=="string"?{type:"Solid",color:h}:h,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const v=12,b=e.chevronType||"chevron",C=e.chevronSize||16,S=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const R=a+i-v-C/2;t.save(),t.translate(R,0);const x=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(x*Math.PI/180),t.strokeStyle=S,t.fillStyle=S,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-C/2,-C*.2),t.lineTo(0,C*.2),t.lineTo(C/2,-C*.2),t.stroke();else if(b==="custom"||b==="path"){const O=g&&e.openIconPath||e.closedIconPath;if(O){const $=new Path2D(O);t.save();const A=C/24;t.scale(A,A),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const I=e.selectedOption||e.placeholder||"Select...",w=e.fontSize||14,M=e.fontWeight||400,P=e.fontFamily||"Inter, sans-serif";t.font=`${M} ${w}px ${P}`;const T=f?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const W=b==="none"?0:C+8,k=i-v*2-W;if(t.save(),t.beginPath(),t.rect(a+v,r,k,n),t.clip(),t.fillText(I,a+v,0),t.restore(),g&&!f){const R=r+n+4,x=e.optionsList||[],O=e.itemHeight||32,$=e.listPadding??4,A=x.length*O+$*2,V=e.listCornerRadius??l;t.save();const H=e.listShadow||{},et=t.getTransform(),E=Math.sqrt(et.a*et.a+et.b*et.b)||1;t.shadowColor=typeof H.color=="string"?H.color:((_=H.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(H.blur??12)*E,t.shadowOffsetY=(H.offsetY??6)*E,t.shadowOffsetX=(H.offsetX??0)*E,t.beginPath(),this.drawRoundRect(t,a,R,i,A,V),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,A)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},i,A)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const q=e.itemFontSize||w,Q=e.itemFontFamily||P;t.font=`${M} ${q}px ${Q}`,x.forEach((it,dt)=>{const St=R+$+dt*O;if(it===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,O)||"#f3f4f6",t.fillRect(a+F,St,i-F*2,O),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const mt=this._lastPointerPos.y-(R+$),rt=Math.floor(mt/O);dt===rt&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,O)||"#f9fafb",t.fillRect(a+F,St,i-F*2,O),t.fillStyle=e.itemHoverColor||p)}t.fillText(it,a+v,St+O/2)})}t.globalAlpha=m}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,f=e.label||{},c=e.hoverStyle||{},g=e.activeStyle||{},h=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",p=f.color||"#ffffff",m=f.text||"Button",y=i.cornerRadius??8,v=e.borderColor||"transparent",b=e.borderWidth||0,C=1;l&&g?(d=g.backgroundColor||d,p=g.color||p,m=g.text||m,C=g.scale??.95,y=g.cornerRadius??y):r&&c&&(d=c.backgroundColor||d,p=c.color||p,m=c.text||m,C=c.scale??1,y=c.cornerRadius??y,v=c.borderColor||v);const S=-n/2,I=-a/2;t.save(),t.scale(C,C),t.beginPath(),this.drawRoundRect(t,S,I,n,a,y);const w=this.createCanvasFill(t,d,n,a);w&&(t.fillStyle=w,t.fill()),(b>0||r&&c.borderColor)&&(t.strokeStyle=v,t.lineWidth=b||(r?1:0),t.stroke());const M=f.fontSize||14,P=f.fontFamily||"Inter",T=f.fontWeight||600;t.font=`${T} ${M}px "${P}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let W=0;if(h.enabled&&h.svgPath){const k=M*1.1,_=h.gap||8,R=t.measureText(m),O=-(R.width+k+_)/2,$=h.position==="left"?O+k/2:O+R.width+_+k/2;W=h.position==="left"?O+k+_+R.width/2:O+R.width/2,t.save(),t.translate($,0);const A=new Path2D(h.svgPath),V=k/24;t.scale(V,V),t.translate(-12,-12),t.fillStyle=p,t.fill(A),t.restore()}t.fillText(m,W,0),t.restore()}renderToggleButton(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((m=s.geometry)==null?void 0:m.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,l=-a/2,f=e.corner_radius??8,c=e.label||{},g=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",h=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,n,a,f),t.fillStyle=g,t.fill();const d=c.fontSize||14,p=c.fontFamily||"Inter";t.font=`${c.fontWeight||600} ${d}px "${p}", sans-serif`,t.fillStyle=h,t.textAlign="center",t.textBaseline="middle",t.fillText(c.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var V,H,et,E,F,q,Q,it,dt,St,ht,mt;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((V=s.geometry)==null?void 0:V.width)||52,n=((H=s.geometry)==null?void 0:H.height)||30,a=-i/2,r=-n/2,l=e.checked??!1,f=e.cornerRadius??e.corner_radius??n/2,c=e.toggleStyle||{},g=c.backgroundColor||e.activeColor||"#10b981",h=c.borderColor||e.borderColor||"transparent",d=c.borderWidth??e.borderWidth??0,p=c.knobColor||e.knobColor||"#ffffff",m=l?g:e.inactiveColor||"#374151",y=l?h:e.borderColor||"transparent",v=l?d:e.borderWidth??0,b=l?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,f);const C=this.createCanvasFill(t,m,i,n);if(C&&(t.fillStyle=C,t.fill()),v>0){t.lineWidth=v;const rt=this.createCanvasFill(t,y,i,n);rt&&(t.strokeStyle=rt,t.stroke())}const S=2,I=n-S*2,w=I/2,M=a+S,P=a+i-S-I,T=l?P:M,W=r+S;t.beginPath(),t.arc(T+w,W+w,w,0,Math.PI*2);const k=this.createCanvasFill(t,b,I,I);k&&(t.fillStyle=k,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,R=!1;const x=(l?(et=c.leftLabel)==null?void 0:et.text:null)||((E=e.leftLabel)==null?void 0:E.text)||"",O=(l?(F=c.leftLabel)==null?void 0:F.color:null)||((q=e.leftLabel)==null?void 0:q.color)||"#f3f4f6";if((Q=e.leftLabel)!=null&&Q.enabled&&x){const rt=e.leftLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=O,t.textBaseline="middle",t.textAlign="right",t.fillText(x,a-(rt.gap||8),0),_=!0}const $=(l?(it=c.rightLabel)==null?void 0:it.text:null)||((dt=e.rightLabel)==null?void 0:dt.text)||"",A=(l?(St=c.rightLabel)==null?void 0:St.color:null)||((ht=e.rightLabel)==null?void 0:ht.color)||"#f3f4f6";if((mt=e.rightLabel)!=null&&mt.enabled&&$){const rt=e.rightLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=A,t.textBaseline="middle",t.textAlign="left",t.fillText($,a+i+(rt.gap||8),0),R=!0}if(!_&&!R&&e.label&&e.label.text){const rt=e.label,Rt=rt.fontSize||14,Yt=rt.fontWeight||400,Pt=rt.fontFamily||"Inter";t.font=`${Yt} ${Rt}px "${Pt}", sans-serif`,t.fillStyle=rt.color||"#f3f4f6",t.textBaseline="middle";const zt=rt.gap||10;let Xt=0,B=0;rt.position==="left"?(t.textAlign="right",Xt=a-zt,B=0):rt.position==="right"?(t.textAlign="left",Xt=a+i+zt,B=0):rt.position==="top"?(t.textAlign="center",Xt=0,B=r-zt,t.textBaseline="bottom"):rt.position==="bottom"?(t.textAlign="center",Xt=0,B=r+n+zt,t.textBaseline="top"):(t.textAlign="left",Xt=a+i+zt,B=0),t.fillText(rt.text,Xt,B)}}renderCheckbox(t,s){var C,S;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((C=s.geometry)==null?void 0:C.width)||20,n=((S=s.geometry)==null?void 0:S.height)||20,a=-i/2,r=-n/2,l=e.cornerRadius??4,f=e.checked??!1,c=e.activeColor||"#3b82f6",g=e.inactiveColor||"transparent",h=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",p=e.borderWidth??2,m=f?c:g,y=f?"transparent":d,v=f?0:p;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,l);const b=this.createCanvasFill(t,m,i,n);if(b&&(t.fillStyle=b,t.fill()),v>0){t.lineWidth=v;const I=this.createCanvasFill(t,y,i,n);I&&(t.strokeStyle=I,t.stroke())}else if(f){t.lineWidth=1;const I=this.createCanvasFill(t,c,i,n);I&&(t.strokeStyle=I,t.stroke())}if(f){t.save(),t.beginPath();const I=this.createCanvasFill(t,h,i,n);t.strokeStyle=I||h,t.lineWidth=Math.max(2,i*.12),t.lineCap="round",t.lineJoin="round";const w=a+i*.25,M=r+n*.5,P=a+i*.45,T=r+n*.7,W=a+i*.75,k=r+n*.25;t.moveTo(w,M),t.lineTo(P,T),t.lineTo(W,k),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const I=e.label;t.save(),t.font=`${I.fontWeight||400} ${I.fontSize||14}px "${I.fontFamily||"Inter"}", sans-serif`,t.fillStyle=I.color||"#f3f4f6",t.textBaseline="middle";const w=I.gap||8;let M=0,P=0;I.position==="left"?(t.textAlign="right",M=a-w,P=0):I.position==="right"?(t.textAlign="left",M=a+i+w,P=0):I.position==="top"?(t.textAlign="center",M=0,P=r-w,t.textBaseline="bottom"):I.position==="bottom"&&(t.textAlign="center",M=0,P=r+n+w,t.textBaseline="top"),t.fillText(I.text,M,P),t.restore()}}renderRadioGroup(t,s){var S,I;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((S=s.geometry)==null?void 0:S.width)||180,n=((I=s.geometry)==null?void 0:I.height)||100,a=-i/2,r=-n/2,l=e.selectedValue,f=e.optionsList||["Option 1","Option 2","Option 3"],c=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,h=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",p=e.textColor||"#ffffff",m=e.fontSize||14,y=e.fontFamily||"Inter",v=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const b=8,C=b*2;if(t.save(),t.font=`${v} ${m}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",c==="vertical"){const w=Math.max(C,m)+g;f.forEach((M,P)=>{const T=r+P*w+b;t.beginPath(),t.arc(a+b,T,b,0,Math.PI*2);const W=l===M,k=this.createCanvasFill(t,h,C,C),_=this.createCanvasFill(t,d,C,C);W?(t.strokeStyle=k||h,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+b,T,b/2,0,Math.PI*2),t.fillStyle=k||h,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(M,a+C+8,T)})}else{let w=a;f.forEach(M=>{const P=l===M,T=t.measureText(M).width;t.beginPath(),t.arc(w+b,0,b,0,Math.PI*2);const W=this.createCanvasFill(t,h,C,C),k=this.createCanvasFill(t,d,C,C);P?(t.strokeStyle=W||h,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(w+b,0,b/2,0,Math.PI*2),t.fillStyle=W||h,t.fill()):(t.strokeStyle=k||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(M,w+C+6,0),w+=C+6+T+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#9ca3af",t.textBaseline="middle";const M=w.gap||8;let P=0,T=0;w.position==="left"?(t.textAlign="right",P=a-M,T=0):w.position==="right"?(t.textAlign="left",P=a+i+M,T=0):w.position==="top"?(t.textAlign="center",P=0,T=r-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",P=0,T=r+n+M,t.textBaseline="top"),t.fillText(w.text,P,T),t.restore()}}renderBarChart(t,s){var T,W;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((T=s.geometry)==null?void 0:T.width)||300,height:((W=s.geometry)==null?void 0:W.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,_getPreset:function(){return es[this.stylePreset]||es.default},_resolveColor:function(k,_){const R=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(k)?R.colors[_%R.colors.length]:typeof k=="string"?k:R.colors[_%R.colors.length]},_makeGradient:function(k,_,R,x,O,$){if(!this._getPreset().barGradient&&!this.barGradient)return _;const V=k.createLinearGradient(R,x,O,$);return V.addColorStop(0,_),V.addColorStop(1,_+"44"),V},_drawRoundedBar:function(k,_,R,x,O,$,A){if($=Math.min($,Math.min(Math.abs(x),Math.abs(O))/2),$<=0||x===0||O===0){k.rect(_,R,x,O);return}k.beginPath(),A?(k.moveTo(_,R+O),k.lineTo(_,R+$),k.quadraticCurveTo(_,R,_+$,R),k.lineTo(_+x-$,R),k.quadraticCurveTo(_+x,R,_+x,R+$),k.lineTo(_+x,R+O),k.lineTo(_,R+O)):(k.moveTo(_,R),k.lineTo(_+x-$,R),k.quadraticCurveTo(_+x,R,_+x,R+$),k.lineTo(_+x,R+O-$),k.quadraticCurveTo(_+x,R+O,_+x-$,R+O),k.lineTo(_,R+O),k.lineTo(_,R)),k.closePath()}},n=i.width,a=i.height,r=-n/2,l=-a/2;if(!i.datasets||i.datasets.length===0||i.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const f=i._getPreset();let c=-1/0,g=1/0;const h=i.categories.length,d=i.datasets.length;if(i.chartType==="stacked")for(let k=0;k<h;k++){let _=0,R=0;i.datasets.forEach(x=>{const O=x.data[k]??0;O>=0?_+=O:R+=O}),_>c&&(c=_),R<g&&(g=R)}else i.datasets.forEach(k=>{k.data&&k.data.forEach(_=>{_>c&&(c=_),_<g&&(g=_)})});isFinite(c)||(c=10),isFinite(g)||(g=0),c=Math.max(c,0),g=Math.min(g,0);const p=c-g||10;t.save(),t.font=`${i.axisLabelFontSize}px Inter, sans-serif`;const m=i.showYLabels?t.measureText(c.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,b=(i.showLegend&&d>0?i.legendFontSize+10:0)+8,C=10,S=r+m,I=l+b,w=n-m-C,M=a-b-y;if(t.beginPath(),t.roundRect(r,l,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&d>0){t.font=`${i.legendFontSize}px Inter, sans-serif`,t.textBaseline="middle";const k=l+12;let _=S;i.datasets.forEach((R,x)=>{const O=i._resolveColor(R.color,x),$=R.label||`Series ${x+1}`,A=7;t.beginPath(),t.roundRect(_,k-A/2,A,A,2),t.fillStyle=O,t.fill(),t.fillStyle=f.legendColor,t.textAlign="left",t.fillText($,_+A+4,k),_+=t.measureText($).width+A+16})}const P=4;if(i.showGridLines){t.setLineDash([3,4]),t.lineWidth=1,t.strokeStyle=f.gridColor;for(let k=0;k<=P;k++){const _=I+k/P*M;t.beginPath(),t.moveTo(S,_),t.lineTo(S+w,_),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor;for(let k=0;k<=P;k++){const _=c-k/P*p,R=I+k/P*M;t.fillText(_.toFixed(0),S-6,R)}}if(t.lineWidth=1,t.setLineDash([]),i.showXAxis&&(t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(S,I+M),t.lineTo(S+w,I+M),t.stroke()),i.showYAxis&&(t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(S,I),t.lineTo(S,I+M),t.stroke()),i.chartType==="stacked"){const k=w/h;for(let _=0;_<h;_++){const R=S+_*k+k/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.fillText(i.categories[_]||"",R,I+M+5));let x=I+M;i.datasets.forEach((O,$)=>{const A=O.data[_]??0;if(A===0)return;const V=A/p*M,H=Math.min(i.barWidth*d+i.barGap,k-8),et=R-H/2,E=x-V;x-=V;const F=i._resolveColor(O.color,$);t.beginPath(),t.fillStyle=i._makeGradient(t,F,et,E,et,E+V),i._drawRoundedBar(t,et,E,H,V,$===d-1?i.barCornerRadius:0,!0),t.fill()})}}else{const k=w/h,_=d*i.barWidth+Math.max(0,(d-1)*i.barGap),R=I+M-(0-g)/p*M;for(let x=0;x<h;x++){const O=S+x*k+k/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.fillText(i.categories[x]||"",O,I+M+5));const $=O-_/2;i.datasets.forEach((A,V)=>{const H=A.data[x]??0,et=Math.abs(H/p*M);if(et<1)return;const E=$+V*(i.barWidth+i.barGap),F=H>=0?R-et:R,q=i._resolveColor(A.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,q,E,F,E,F+et),i._drawRoundedBar(t,E,F,i.barWidth,et,i.barCornerRadius,!0),t.fill(),i.showValueOnTop&&H!==0&&(t.font=`bold ${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=q,t.fillText(H.toString(),E+i.barWidth/2,F-2))})}}t.restore()}renderPieChart(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((m=s.geometry)==null?void 0:m.width)||180,height:((y=s.geometry)==null?void 0:y.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return ss[this.stylePreset]||ss.default},_resolveSliceColor:function(v,b){const C=v.color,S=b,I=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(C)?I.colors[S%I.colors.length]:typeof C=="string"?C:I.colors[S%I.colors.length]}},n=i.width,a=i.height;if(!i.slices||i.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=i.slices.reduce((v,b)=>v+(b.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const l=i._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke();const f=i.showLegend?Math.ceil(i.slices.length/2):0,c=f>0?f*(i.legendFontSize+8)+10:0,g=a-c-16,h=Math.min(n-24,g)/2,d=0,p=-c/2;if(i.chartType==="rose"){const v=Math.max(...i.slices.map(S=>S.value||0)),b=Math.PI*2/i.slices.length,C=h>0?i.sliceGap/h:0;i.slices.forEach((S,I)=>{const w=S.value||0;if(w===0)return;const M=w/v*h,P=-Math.PI/2+I*b+C/2,T=P+b-C,W=i._resolveSliceColor(S,I);if(t.beginPath(),t.moveTo(d,p),t.arc(d,p,M,P,T),t.closePath(),t.fillStyle=W+"cc",t.fill(),t.strokeStyle=W,t.lineWidth=1.5,t.stroke(),i.showLabels){const k=P+(T-P)/2,_=d+M*.65*Math.cos(k),R=p+M*.65*Math.sin(k),x=Math.round(w/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,_,R),t.restore()}})}else{const v=i.chartType==="pie"?0:i.innerRadius,b=h*Math.max(0,v),C=h>0?i.sliceGap/h:0;let S=-Math.PI/2;if(i.slices.forEach((I,w)=>{const M=I.value||0;if(M===0){S+=M/r*Math.PI*2;return}const P=M/r*Math.PI*2,T=S+C/2,W=S+P-C/2;if(W<=T){S+=P;return}const k=i._resolveSliceColor(I,w);if(t.beginPath(),t.fillStyle=k,b<=0?(t.moveTo(d,p),t.arc(d,p,h,T,W),t.lineTo(d,p)):(t.moveTo(d+h*Math.cos(T),p+h*Math.sin(T)),t.arc(d,p,h,T,W),t.arc(d,p,b,W,T,!0),t.closePath()),t.fill(),i.showLabels){const _=T+(W-T)/2,R=b+(h-b)/2,x=d+R*Math.cos(_),O=p+R*Math.sin(_),$=Math.round(M/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${$}%`,x,O),t.restore()}S+=P}),i.chartType==="donut"&&i.showCenterText&&b>14){const I=Math.round(r),w=Math.min(Math.floor(b*.52),20),M=Math.min(Math.floor(b*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${w}px Inter, sans-serif`,t.fillStyle=l.centerTextColor,t.fillText(I.toString(),d,p-M*.5),i.centerLabel&&(t.font=`${M}px Inter, sans-serif`,t.fillStyle=l.centerLabelColor,t.fillText(i.centerLabel,d,p+w*.6))}}if(i.showLegend&&i.slices.length>0){t.font=`${i.legendFontSize}px Inter, sans-serif`;const v=2,b=n/v,C=i.legendFontSize+8,S=a/2-c+10,I=-n/2+10;i.slices.forEach((w,M)=>{const P=M%v,T=Math.floor(M/v),W=I+P*b,k=S+T*C,_=i._resolveSliceColor(w,M),R=7;t.beginPath(),t.roundRect(W,k-R/2,R,R,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=l.legendColor;const x=Math.round((w.value||0)/r*100),O=`${w.label||"Item"} ${x}%`,$=b-R-20;let A=O;for(;t.measureText(A).width>$&&A.length>4;)A=A.slice(0,-4)+"…";t.fillText(A,W+R+4,k)})}t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var M,P;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((M=t.geometry)==null?void 0:M.width)||180,r=i.height!==void 0?i.height:((P=t.geometry)==null?void 0:P.height)||100,l=e.orientation||"vertical",f=e.itemGap!==void 0?e.itemGap:16,c=e.fontSize||14,g=this.getWorldTransform(t.id),h=s-g.x,d=o-g.y,p=-g.rotation*(Math.PI/180),m=Math.cos(p),y=Math.sin(p),v=h*m-d*y,b=h*y+d*m,S=8*2,I=-a/2,w=-r/2;if(l==="vertical"){const T=Math.max(S,c)+f;for(let W=0;W<n.length;W++){const k=w+W*T;if(v>=I&&v<=I+a&&b>=k&&b<=k+T)return W}}else{let T=I;for(let W=0;W<n.length;W++){const _=n[W].length*8,R=S+6+_+f;if(v>=T&&v<=T+R&&b>=w&&b<=w+r)return W;T+=R}}return null}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(p=>p.data&&p.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(p=>{let m=p.data;if(p.isVarEnabled&&p.inputId){let y=this.inputs.get(p.inputId);if(y===void 0){const v=this.inputNameMap.get(p.inputId);v&&v.length>0&&(y=this.inputs.get(v[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(v=>typeof v=="number"&&!isNaN(v));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,m.length))}p._resolvedData=m}),r<2)return;const l=a-n,f=o/(r-1),c=p=>{const m=l===0?.5:(p-n)/l;return e/2-m*e},g=p=>p*f-o/2,h=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||h,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||h,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<r;p++){const m=g(p);t.fillText(`${p+1}`,m,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),p,c(a)),t.fillText(m.toFixed(1),p,c(m)),t.fillText(n.toFixed(1),p,c(n))}const d=10;if(i.forEach(p=>{const m=p._resolvedData;if(!(!m||m.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(g(0),e/2),t.lineTo(g(0),c(m[0])),p.smoothing&&m.length>2)for(let v=0;v<m.length-1;v++){const b=m[v===0?v:v-1],C=m[v],S=m[v+1],I=m[v+1===m.length-1?v+1:v+2];for(let w=1;w<=d;w++){const M=w/d,P=this._catmullRom(b,C,S,I,M);t.lineTo(g(v+M),c(P))}}else for(let v=1;v<m.length;v++)t.lineTo(g(v),c(m[v]));t.lineTo(g(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=p.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=p.lineColor||"#3b82f6",t.lineWidth=p.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(g(0),c(m[0])),p.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const v=m[y===0?y:y-1],b=m[y],C=m[y+1],S=m[y+1===m.length-1?y+1:y+2];for(let I=1;I<=d;I++){const w=I/d,M=this._catmullRom(v,b,C,S,w);t.lineTo(g(y+w),c(M))}}else for(let y=1;y<m.length;y++)t.lineTo(g(y),c(m[y]));t.stroke(),p.showPoints&&m.forEach((y,v)=>{const b=g(v),C=c(y);t.beginPath(),t.arc(b,C,(p.pointSize||6)/2,0,Math.PI*2),t.fillStyle=p.pointFill||"#ffffff",t.fill(),t.strokeStyle=p.pointStrokeColor||p.lineColor||"#3b82f6",t.lineWidth=p.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const p=o/2-10;let m=-e/2+15;const y=s.legendFontSize||10,v=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(b=>{const S=b.label||"Series",I=t.measureText(S).width;t.beginPath(),t.rect(p-I-8-5,m-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(S,p,m),m+=v})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,l=i*r;return(2*s-2*o+n+a)*l+(-3*s+3*o-2*n-a)*r+n*i+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,f=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=f,f}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,f=100)=>{var C,S;const g=(((S=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:S.colors)||{})[l]||l,h=this.normalizeOpacity(s.opacity??100),p=this.normalizeOpacity(f)*h;if(p>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),v=parseInt(m.substring(2,4),16),b=parseInt(m.substring(4,6),16);return`rgba(${y}, ${v}, ${b}, ${p})`};if(s.type==="LinearGradient"){const l=(p,m,y)=>Array.isArray(p)?p[m]??(m===0?0:1):p&&typeof p=="object"?p[y]??(m===0?0:1):m===0?0:1,f=l(s.start,0,"x")*o-o/2,c=l(s.start,1,"y")*e-e/2,g=l(s.end,0,"x")*o-o/2,h=l(s.end,1,"y")*e-e/2,d=t.createLinearGradient(f,c,g,h);if(s.stops.forEach(p=>{const m=p.offset!==void 0?p.offset:p.pos!==void 0?p.pos:p.position!==void 0?p.position:0,y=r(p.color||"#000000",p.opacity??100);d.addColorStop(Math.max(0,Math.min(1,m)),y)}),s.gradientTransform&&d.setTransform){const[p,m,y,v,b,C]=s.gradientTransform;d.setTransform({a:p,b:m,c:y,d:v,e:b,f:C})}return d}else if(s.type==="RadialGradient"){const l=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,f=l(s.center,0,"x")*o-o/2,c=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),h=t.createRadialGradient(f,c,0,f,c,g);if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);h.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&h.setTransform){const[d,p,m,y,v,b]=s.gradientTransform;h.setTransform({a:d,b:p,c:m,d:y,e:v,f:b})}return h}else if(s.type==="AngularGradient"){const l=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,f=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),h=(a=t.createConicGradient)==null?void 0:a.call(t,g,f,c);if(h){if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);h.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&h.setTransform){const[d,p,m,y,v,b]=s.gradientTransform;h.setTransform({a:d,b:p,c:m,d:y,e:v,f:b})}return h}}else if(s.type==="DiamondGradient"){const l=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,f=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(f,c),t.rotate(Math.PI/4);const h=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);h.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&h.setTransform){const[d,p,m,y,v,b]=s.gradientTransform;h.setTransform({a:d,b:p,c:m,d:y,e:v,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=h,t.restore(),h}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const f=new DOMMatrix,c=s.scaleX??1,g=s.scaleY??1,h=s.offsetX??0,d=s.offsetY??0,p=s.rotation??0;f.translateSelf(h,d),f.rotateSelf(p),f.scaleSelf(c,g),l.setTransform(f)}return l}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,f=0,c=0;typeof a=="number"?r=l=f=c=a:Array.isArray(a)?a.length===1?r=l=f=c=a[0]:a.length===2?(r=f=a[0],l=c=a[1]):a.length===3?(r=a[0],l=c=a[1],f=a[2]):a.length>=4&&(r=a[0],l=a[1],f=a[2],c=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,l=a.tr??a.corner_radius??a.cornerRadius??0,f=a.br??a.corner_radius??a.cornerRadius??0,c=a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),f=Math.min(Math.max(0,f),g),c=Math.min(Math.max(0,c),g),t.roundRect){t.roundRect(s,o,e,i,[r,l,f,c]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+i-f),t.arcTo(s+e,o+i,s+e-f,o+i,f),t.lineTo(s+c,o+i),t.arcTo(s,o+i,s,o+i-c,c),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,x,O,$;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,n=o.height!==void 0?o.height:((x=s.geometry)==null?void 0:x.height)||300,a=-i/2,r=-n/2,l=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,f=e.orientation||"vertical",c=e.items||[],g=e.itemGap??10,h=e.itemHeight??50,d=e.itemWidth??200,p=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,v=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",C=e.itemBackgroundColor||"#ffffff",S=e.hoveredIndex??null,I=e.activeItemIndex??null,w=e.glowIntensity??0,M=e.glowColor||"#3b82f6",P=typeof M=="string"?M:M.color||(($=(O=M.stops)==null?void 0:O[0])==null?void 0:$.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,w>0){const A=t.getTransform(),V=Math.sqrt(A.a*A.a+A.b*A.b)||1;t.shadowColor=P,t.shadowBlur=w*2*V,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const A=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",V=this.createCanvasFill(t,A,i,n);t.fillStyle=V||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(t,a,r,i,n,l),t.fill();const H=t.createLinearGradient(a,r,a+i,r+n);H.addColorStop(0,"rgba(255, 255, 255, 0.15)"),H.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),H.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=H,this.drawListViewRect(t,a,r,i,n,l),t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,this.drawListViewRect(t,a,r,i,n,l),t.stroke()}else{const A=e.listBackgroundColor||"transparent",V=this.createCanvasFill(t,A,i,n);V&&(t.fillStyle=V,this.drawListViewRect(t,a,r,i,n,l),t.fill());const H=e.borderWidth??0;H>0&&(t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=H,this.drawListViewRect(t,a,r,i,n,l),t.stroke())}t.shadowBlur=0,t.save(),this.drawListViewRect(t,a,r,i,n,l),t.clip();const W=typeof m=="number"?m:f==="vertical"?m[0]:m[3];let k=(f==="vertical"?r:a)+p+W;if(t.textBaseline="middle",c.forEach((A,V)=>{const H=f==="vertical"?i:d,et=f==="vertical"?h:n,E=f==="vertical"?a:k,F=f==="vertical"?k:r,q=S===V,Q=I===V;if(Q){const mt=this.createCanvasFill(t,v,H,et);t.fillStyle=mt||v;const rt=t.globalAlpha;t.globalAlpha=rt*.8,t.fillRect(E,F,H,et),t.globalAlpha=rt}else if(q)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.fillRect(E,F,H,et);else if(C!=="transparent"){const mt=this.createCanvasFill(t,C,H,et);t.fillStyle=mt||C,t.fillRect(E,F,H,et)}if(Q||q){const mt=this.createCanvasFill(t,v,f==="vertical"?3:H,f==="vertical"?et:3);t.fillStyle=mt||v,f==="vertical"?t.fillRect(E,F,3,et):t.fillRect(E,F+et-3,H,3)}const it=Q?"#ffffff":y?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=it,t.font=Q||q?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const dt=typeof A=="string"?A:(A==null?void 0:A.label)||`Item ${V+1}`,St=E+(f==="vertical"?16:H/2),ht=F+et/2;f==="horizontal"?t.textAlign="center":t.textAlign="left",t.fillText(dt,St,ht),k+=(f==="vertical"?h:d)+g}),t.restore(),e.showScrollbar!==!1){const A=(c.length||0)*(f==="vertical"?h:d)+((c.length||0)-1)*g,V=f==="vertical"?n:i;if(A>V){const H=V/A,et=V*H,E=-p/A*V,F=e.scrollbarColor||"rgba(255,255,255,0.3)",q=e.scrollbarWidth||4;t.fillStyle=F,f==="vertical"?t.fillRect(a+i-q-2,r+E,q,et):t.fillRect(a+E,r+n-q-2,et,q)}}t.restore()}updateListViewScrollFromPointer(t){var m,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=this.objectStates.get(t.id)||{},a=s.items||[],r=s.itemGap??10,l=s.itemHeight??50,f=s.itemWidth??200,c=n.width!==void 0?n.width:((m=t.geometry)==null?void 0:m.width)||200,g=n.height!==void 0?n.height:((y=t.geometry)==null?void 0:y.height)||300,h=(a.length||0)*(o==="vertical"?l:f)+((a.length||0)-1)*r,p=Math.max(0,h-(o==="vertical"?g:c)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-p&&(s.scrollOffset=-p)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var W,k;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((W=t.geometry)==null?void 0:W.width)||200,r=i.height!==void 0?i.height:((k=t.geometry)==null?void 0:k.height)||300,l=e.orientation||"vertical",f=e.itemGap??10,c=e.itemHeight??50,g=e.itemWidth??200,h=e.scrollOffset??0,d=e.padding??0,p=this.getWorldTransform(t.id),m=s-p.x,y=o-p.y,v=-p.rotation*(Math.PI/180),b=Math.cos(v),C=Math.sin(v),S=m*b-y*C,I=m*C+y*b,w=-a/2,M=-r/2,P=typeof d=="number"?d:l==="vertical"?d[0]:d[3];let T=(l==="vertical"?M:w)+h+P;for(let _=0;_<n.length;_++){const R=l==="vertical"?a:g,x=l==="vertical"?c:r,O=l==="vertical"?w:T,$=l==="vertical"?T:M;if(S>=O&&S<=O+R&&I>=$&&I<=$+x)return _;T+=(l==="vertical"?c:g)+f}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var g,h,d,p,m,y,v,b,C,S,I,w,M,P,T,W,k,_,R,x,O,$,A,V,H,et,E,F,q,Q,it,dt,St,ht,mt,rt,Rt,Yt,Pt,zt,Xt,B,lt,Vt,Mt,Tt,Nt,Jt,Kt,Qt,te,ce,se,ne,J,ft,U,G,K,Z,Ot,At,kt,Ut,bt,L,ct,Dt,xt,ie,Wt,Bt,Ft,ot,It,vt,Ct,gt,Lt,at,st,nt,wt,z,ut,pt,de,be,Se,Ie,_e,qt,oe,ye,we,Me,ue,fe,he,ve,Pe,Fe,$e,Ee,We,Be,ns,os,as,rs,ls,cs,fs,hs,ds,us,ps,gs;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=i.x-s,f=i.y-o,c=Math.sqrt(l*l+f*f);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===Y.Proximity){const X=((g=n.settings)==null?void 0:g.radius)||300,N=((h=n.settings)==null?void 0:h.falloff)||"smooth";let D=0;c<X&&(N==="linear"?D=1-c/X:D=Math.pow(1-c/X,2)),n.sensors.forEach(j=>{this.applyBehaviorSensor(i,j,D,t,n.settings,e,l,f,c)})}else if(n.type===Y.Magnetic){const X=((d=n.settings)==null?void 0:d.radius)||400,N=((p=n.settings)==null?void 0:p.strength)||.5;if(c<X&&c>5){const D=1-c/X,j=l*D*N,_t=f*D*N;i.x-=j*t*10,i.y-=_t*t*10}}else if(n.type===Y.Repel){const X=((m=n.settings)==null?void 0:m.radius)||300,N=((y=n.settings)==null?void 0:y.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x+=l/(c||1)*D*60*N*t*5,i.y+=f/(c||1)*D*60*N*t*5}}else if(n.type===Y.Orbit){const X=((v=n.settings)==null?void 0:v.speed)||1,N=((b=n.settings)==null?void 0:b.radius)||30,D=this.currentTime*X*Math.PI*2;i.x+=Math.cos(D)*N*t*5,i.y+=Math.sin(D)*N*t*5,i.rotation+=2*t*5}else if(n.type===Y.Vortex){const X=((C=n.settings)==null?void 0:C.radius)||400,N=((S=n.settings)==null?void 0:S.speed)||2,D=((I=n.settings)==null?void 0:I.strength)||1;if(c<X){const j=Math.pow(1-c/X,1.5),_t=this.currentTime*N*Math.PI*2,Et=Math.cos(_t)*30-l*.4,Gt=Math.sin(_t)*30-f*.4;i.x+=Et*j*D*t*5,i.y+=Gt*j*D*t*5,i.rotation+=5*j*D*t*5,i.scale_x*=1-j*.1*D*t,i.scale_y*=1-j*.1*D*t}}else if(n.type===Y.Fluid){const X=((w=n.settings)==null?void 0:w.radius)||300,N=((M=n.settings)==null?void 0:M.strength)||1;if(c<X){const D=Math.pow(1-c/X,1.2),j=l/(c||1)*D*1.2*N,_t=f/(c||1)*D*1.2*N;i.x+=j*10*t*5,i.y+=_t*10*t*5,i.scale_x*=1+D*.3*N*t,i.scale_y*=1+D*.3*N*t}}else if(n.type===Y.Elastic){const X=((P=n.settings)==null?void 0:P.radius)||300,N=((T=n.settings)==null?void 0:T.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.4*N*t,i.scale_y*=1+D*.4*N*t}}else if(n.type===Y.Holographic){const X=i.x-this.canvasWidth/2,N=i.y-this.canvasHeight/2,D=((W=n.settings)==null?void 0:W.factor)||25;if(i.x-=X/1e3*D*t*5,i.y-=N/1e3*D*t*5,i.style){const j=1-Math.min(1,c/400);i.style.exposure=(i.style.exposure||1)+j*.5*t}}else if(n.type===Y.Sticky){const X=((k=n.settings)==null?void 0:k.radius)||80,N=((_=n.settings)==null?void 0:_.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x-=l*D*N*t*10,i.y-=f*D*N*t*10,i.scale_x*=1-D*.1*N*t,i.scale_y*=1-D*.1*N*t}}else if(n.type===Y.Dilation){const X=((R=n.settings)==null?void 0:R.size)||120,N=((x=n.settings)==null?void 0:x.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.5*N*t,i.scale_y*=1+D*.5*N*t}}else if(n.type===Y.Parallax){const X=((O=n.settings)==null?void 0:O.factor)||15,N=(($=n.settings)==null?void 0:$.strength)||1,D=this.canvasWidth/2,j=this.canvasHeight/2,_t=this._lastPointerPos||{x:D,y:j},Et=(_t.x-D)/D,Gt=(_t.y-j)/j,ee=(((A=e.transform)==null?void 0:A.x)??0)+Et*X*N,pe=(((V=e.transform)==null?void 0:V.y)??0)+Gt*X*N,Ce=(((H=e.transform)==null?void 0:H.rotate_x)??0)-Gt*X*1.5*N,ae=(((et=e.transform)==null?void 0:et.rotate_y)??0)+Et*X*1.5*N,me=Math.min(1,10*t);i.x=this.lerp(i.x??((E=e.transform)==null?void 0:E.x)??0,ee,me),i.y=this.lerp(i.y??((F=e.transform)==null?void 0:F.y)??0,pe,me),i.rotate_x=this.lerp(i.rotate_x??((q=e.transform)==null?void 0:q.rotate_x)??0,Ce,me),i.rotate_y=this.lerp(i.rotate_y??((Q=e.transform)==null?void 0:Q.rotate_y)??0,ae,me)}else if(n.type===Y.Fold){if(c<300){const X=1-c/300,N=(l>0?-1:1)*X*10,D=1-X*.1,j=f/300*X*20,_t=-(l/300)*X*20,Et=Math.min(1,10*t);i.skew_x=this.lerp(i.skew_x??((it=e.transform)==null?void 0:it.skew_x)??0,N,Et),i.scale_y=this.lerp(i.scale_y??((dt=e.transform)==null?void 0:dt.scale_y)??1,(((St=e.transform)==null?void 0:St.scale_y)??1)*D,Et),i.rotate_x=this.lerp(i.rotate_x??((ht=e.transform)==null?void 0:ht.rotate_x)??0,j,Et),i.rotate_y=this.lerp(i.rotate_y??((mt=e.transform)==null?void 0:mt.rotate_y)??0,_t,Et),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((rt=n.settings)==null?void 0:rt.opacity)??.5}}}else if(n.type===Y.Crumple){if(c<300){const X=1-c/300,N=X*(Math.random()-.5)*5,D=X*(Math.random()-.5)*.05,j=Math.min(1,15*t);i.skew_x=this.lerp(i.skew_x??((Rt=e.transform)==null?void 0:Rt.skew_x)??0,N,j),i.scale_x=this.lerp(i.scale_x??((Yt=e.transform)==null?void 0:Yt.scale_x)??1,(((Pt=e.transform)==null?void 0:Pt.scale_x)??1)*(1+D),j),i.scale_y=this.lerp(i.scale_y??((zt=e.transform)==null?void 0:zt.scale_y)??1,(((Xt=e.transform)==null?void 0:Xt.scale_y)??1)*(1+D),j),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((B=n.settings)==null?void 0:B.intensity)??1,scale:((lt=n.settings)==null?void 0:lt.scale)??2}}}else if(n.type===Y.Squash){const X=((Vt=n.settings)==null?void 0:Vt.strength)||.8;c<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((Mt=e.transform)==null?void 0:Mt.scale_y)??1)*X,.3),i.scale_x=this.lerp(i.scale_x??1,(((Tt=e.transform)==null?void 0:Tt.scale_x)??1)*(1+(1-X)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((Nt=e.transform)==null?void 0:Nt.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((Jt=e.transform)==null?void 0:Jt.scale_x)??1,.2))}else if(n.type===Y.TextCounter){const X=((Kt=n.settings)==null?void 0:Kt.duration)||2,N=((Qt=n.settings)==null?void 0:Qt.from)||0,D=((te=n.settings)==null?void 0:te.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const j=this.currentTime-n._runtimeStart,_t=Math.min(1,j/X),Et=Math.floor(N+(D-N)*_t);if(((ce=e.geometry)==null?void 0:ce.type)==="Text"){const Gt=((se=n.settings)==null?void 0:se.prefix)||"",ee=((ne=n.settings)==null?void 0:ne.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${Gt}${Et}${ee}`}}else if(n.type===Y.Spotlight){const X=((J=n.settings)==null?void 0:J.radius)||250,N=((ft=n.settings)==null?void 0:ft.strength)||1.5;if(c<X){const D=Math.pow(1-c/X,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(U=e.style)==null?void 0:U.adjustments}),i.style.adjustments.exposure=(((K=(G=e.style)==null?void 0:G.adjustments)==null?void 0:K.exposure)||0)+D*N*50}else(Z=i.style)!=null&&Z.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((At=(Ot=e.style)==null?void 0:Ot.adjustments)==null?void 0:At.exposure)||0,.1))}else if(n.type===Y.Noise||n.type===Y.Float){const X=(((kt=n.settings)==null?void 0:kt.frequency)||((Ut=n.settings)==null?void 0:Ut.speed)||1)*.002,N=(((bt=n.settings)==null?void 0:bt.amplitude)||((L=n.settings)==null?void 0:L.range)||50)*(((ct=n.settings)==null?void 0:ct.strength)||1),D=Date.now();i.x+=Math.sin(D*X)*N*t,i.y+=Math.cos(D*X*.8)*N*t,i.rotation+=Math.sin(D*X*.5)*5*t}else if(n.type===Y.Pulse){const X=(((Dt=n.settings)==null?void 0:Dt.speed)||1)*.005,N=(((xt=n.settings)==null?void 0:xt.scale)||1.2)-1,D=Math.sin(Date.now()*X),j=((ie=n.settings)==null?void 0:ie.strength)||1;i.scale_x*=1+D*N*j*t,i.scale_y*=1+D*N*j*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,D)*.1*j*t)}else if(n.type===Y.Draggable){const X=((Wt=n.settings)==null?void 0:Wt.radius)||150,N=this.draggingBehaviors.has(e.id);if(c<X||N){const D=((Bt=n.settings)==null?void 0:Bt.strength)||1,j=N?1:Math.max(0,1-c/X);this.applyBehaviorSensor(i,jt.PositionX,j*D,t,n.settings),this.applyBehaviorSensor(i,jt.PositionY,j*D,t,n.settings)}}else if(n.type===Y.Scroll){const X=((Ft=n.settings)==null?void 0:Ft.axis)||"vertical",N=((ot=n.settings)==null?void 0:ot.factor)||.5,D=((It=n.settings)==null?void 0:It.strength)||1,j=((vt=n.settings)==null?void 0:vt.scaleFactor)||0;(X==="vertical"||X==="both")&&(i.y+=this.scrollOffset.y*N*D*t),(X==="horizontal"||X==="both")&&(i.x+=this.scrollOffset.x*N*D*t),j!==0&&(i.scale_x*=1+this.scrollOffset.y*j*t,i.scale_y*=1+this.scrollOffset.y*j*t)}else if(n.type===Y.LookAt){const X=((Ct=n.settings)==null?void 0:Ct.factor)||1,N=((gt=n.settings)==null?void 0:gt.strength)||1,D=Math.atan2(-f,-l)*(180/Math.PI),j=i.rotation,_t=(D-j+180)%360-180;i.rotation+=_t*X*N*t*10}else if(n.type===Y.Scan){const X=(((Lt=n.settings)==null?void 0:Lt.speed)||1)*.004,N=((at=n.settings)==null?void 0:at.strength)||1,D=(Math.sin(Date.now()*X)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+D*N*t*5),i.x+=(D-.5)*20*N*t}else if(n.type===Y.Glint)i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((st=n.settings)==null?void 0:st.strength)??.8};else if(n.type===Y.Ratchet){const X=((nt=n.settings)==null?void 0:nt.steps)||12,N=(((wt=n.settings)==null?void 0:wt.speed)||1)*30,D=Math.floor(i.rotation/(360/X))*(360/X);i.rotation=this.lerp(i.rotation,D+N*t,.1)}else if(n.type===Y.Jitter&&c<300){const X=((z=n.settings)==null?void 0:z.strength)||1,N=(((ut=n.settings)==null?void 0:ut.intensity)||5)*X;i.x+=(Math.random()-.5)*N*t*60,i.y+=(Math.random()-.5)*N*t*60,i.rotation+=(Math.random()-.5)*N*t*120}else if(n.type===Y.Follower){const X=(pt=n.settings)==null?void 0:pt.targetId;if(X){const N=this.objectStates.get(X);if(N){const D=((de=n.settings)==null?void 0:de.stiffness)||.1,j=N.x-i.x,_t=N.y-i.y;i.x+=j*D*t*60,i.y+=_t*D*t*60}}}else if(n.type===Y.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===Y.Gravity){const X=((be=n.settings)==null?void 0:be.strength)||9.8;i.y+=X*t*10}else if(n.type===Y.Velocity){const X=((Se=n.settings)==null?void 0:Se.vx)||0,N=((Ie=n.settings)==null?void 0:Ie.vy)||0;i.x+=X*t*10,i.y+=N*t*10}else if(n.type===Y.Shear){const X=((_e=n.settings)==null?void 0:_e.strength)||1,N=((qt=n.settings)==null?void 0:qt.radius)||300;if(c<N){const D=1-c/N;i.skew_x=this.lerp(i.skew_x||0,(((oe=e.transform)==null?void 0:oe.skew_x)||0)+D*X*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((ye=e.transform)==null?void 0:ye.skew_x)||0,.05)}else if(n.type===Y.Lens){const X=((we=n.settings)==null?void 0:we.radius)||200,N=((Me=n.settings)==null?void 0:Me.strength)||.5;if(c<X){const D=Math.pow(1-c/X,2);i.scale_x=this.lerp(i.scale_x??1,(((ue=e.transform)==null?void 0:ue.scale_x)??1)*(1+D*N),.2),i.scale_y=this.lerp(i.scale_y??1,(((fe=e.transform)==null?void 0:fe.scale_y)??1)*(1+D*N),.2)}else i.scale_x=this.lerp(i.scale_x??1,((he=e.transform)==null?void 0:he.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((ve=e.transform)==null?void 0:ve.scale_y)??1,.1)}else if(n.type===Y.LayoutAnimation){const X=((Pe=n.settings)==null?void 0:Pe.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],N=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const D=this._layoutAnimCache.get(e.id);for(const j of X){const _t=this.getObjectProperty(i,e,j);if(_t===void 0)continue;const Et=D.get(j);if(!Et)D.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);D.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:(($e=n.settings)==null?void 0:$e.duration)??N})}const Gt=D.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,pe=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(pe,((Ee=n.settings)==null?void 0:Ee.easing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const X=this._layoutAnimCache.get(e.id),N=((We=n.settings)==null?void 0:We.defaultDuration)||.3,D=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const j of D){const _t=this.getObjectProperty(i,e,j);if(_t===void 0||typeof _t!="number")continue;const Et=X.get(j);if(!Et)X.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);X.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:N})}const Gt=X.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,pe=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(pe,((Be=n.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.SpringChain){const X=((ns=n.settings)==null?void 0:ns.connections)||[],N=((os=n.settings)==null?void 0:os.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const D=this._springChainState.get(e.id);for(const _t of X){if(!D.has(_t.targetId)){const Et=this.objectStates.get(_t.targetId);D.set(_t.targetId,{x:(Et==null?void 0:Et.x)??0,y:(Et==null?void 0:Et.y)??0,vx:0,vy:0})}D.has(e.id)||D.set(e.id,{x:i.x,y:i.y,vx:0,vy:0})}const j=D.get(e.id);if(j){j.x=i.x,j.y=i.y;for(const _t of X){const Et=D.get(_t.targetId);if(!Et)continue;const Gt=Et.x-j.x,ee=Et.y-j.y,pe=Math.sqrt(Gt*Gt+ee*ee)||.001,ae=(pe-(_t.restLength||50))*(_t.stiffness||.8),me=Gt/pe*ae,Ge=ee/pe*ae;j.vx+=me*t*10,j.vy+=Ge*t*10,Et.vx-=me*t*10,Et.vy-=Ge*t*10,j.vx*=1-N*t*10,j.vy*=1-N*t*10,Et.vx*=1-N*t*10,Et.vy*=1-N*t*10;const ge=this.objectStates.get(_t.targetId);ge&&(ge.x+=Et.vx*t,ge.y+=Et.vy*t)}i.x+=j.vx*t,i.y+=j.vy*t}}else if(n.type===Y.ParticleEmitter){const X=((as=n.settings)==null?void 0:as.rate)||10,N=((rs=n.settings)==null?void 0:rs.speed)||100,D=((ls=n.settings)==null?void 0:ls.size)||5,j=((cs=n.settings)==null?void 0:cs.lifetime)||2,_t=((fs=n.settings)==null?void 0:fs.gravity)||0,Et=((hs=n.settings)==null?void 0:hs.color)||"#ffffff",Gt=((ds=n.settings)==null?void 0:ds.maxParticles)||200,ee=(us=n.settings)!=null&&us.rateInputId?this.inputs.get(n.settings.rateInputId)??X:X,pe=(ps=n.settings)!=null&&ps.gravityInputId?this.inputs.get(n.settings.gravityInputId)??_t:_t,Ce=(gs=n.settings)!=null&&gs.speedInputId?this.inputs.get(n.settings.speedInputId)??N:N;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ae=this._emitterPools.get(e.id);let me=0;n._pendingBurst&&n._pendingBurst>0&&(me=n._pendingBurst,n._pendingBurst=0);const Ge=Math.floor(ee*t)+(me||0);for(let ge=0;ge<Math.min(Ge,Gt-ae.length);ge++){const re=Math.random()*Math.PI*2,ms=Ce*(.5+Math.random()*.5);ae.push({x:i.x,y:i.y,vx:Math.cos(re)*ms,vy:Math.sin(re)*ms,life:0,maxLife:j*(.5+Math.random()*.5),size:D*(.5+Math.random()),color:Et,opacity:1})}for(let ge=ae.length-1;ge>=0;ge--){const re=ae[ge];re.vy+=pe*t*10,re.x+=re.vx*t,re.y+=re.vy*t,re.life+=t,re.opacity=Math.max(0,1-re.life/re.maxLife),re.life>=re.maxLife&&ae.splice(ge,1)}}})})}applyBehaviorSensor(t,s,o,e,i,n,a=0,r=0,l=1){var d,p,m,y,v,b,C,S,I,w,M,P,T,W,k,_,R,x,O,$,A,V,H,et;const f=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,c=Math.min(1,15*e),g=l>0?a/l:0,h=l>0?r/l:0;switch(s){case jt.Scale:{const E=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((p=n==null?void 0:n.transform)==null?void 0:p.scale_y)??1,q=E*(1+o*f*.4),Q=F*(1+o*f*.4);t.scale_x=(t.scale_x??E)*(1-c)+q*c,t.scale_y=(t.scale_y??F)*(1-c)+Q*c;break}case jt.Opacity:{const E=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,F=Math.max(0,Math.min(100,E-o*f*100));t.opacity=(t.opacity??E)*(1-c)+F*c;break}case jt.RotateZ:{const E=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,F=E+o*f*45;t.rotation=(t.rotation??E)*(1-c)+F*c;break}case jt.RotateX:{const E=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_x)??0,F=E-h*o*f*60;t.rotate_x=(t.rotate_x??E)*(1-c)+F*c;break}case jt.RotateY:{const E=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_y)??0,F=E+g*o*f*60;t.rotate_y=(t.rotate_y??E)*(1-c)+F*c;break}case jt.PositionX:{const E=((C=n==null?void 0:n.transform)==null?void 0:C.x)??0,F=E-g*o*f*40;t.x=(t.x??E)*(1-c)+F*c;break}case jt.PositionY:{const E=((S=n==null?void 0:n.transform)==null?void 0:S.y)??0,F=E-h*o*f*40;t.y=(t.y??E)*(1-c)+F*c;break}case jt.SkewX:{const E=((I=n==null?void 0:n.transform)==null?void 0:I.skew_x)??0,F=E+g*o*f*45;t.skew_x=(t.skew_x??E)*(1-c)+F*c,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case jt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(w=n==null?void 0:n.style)==null?void 0:w.blur});const E=((P=(M=n==null?void 0:n.style)==null?void 0:M.blur)==null?void 0:P.amount)||0,F=E+o*((i==null?void 0:i.blur)||20)*f;t.style.blur.amount=(t.style.blur.amount??E)*(1-c)+F*c;break}case jt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const E=((k=(W=n==null?void 0:n.style)==null?void 0:W.adjustments)==null?void 0:k.exposure)||0,F=E+o*((i==null?void 0:i.exposure)||50)*f;t.style.adjustments.exposure=(t.style.adjustments.exposure??E)*(1-c)+F*c;break}case jt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const E=((x=(R=n==null?void 0:n.style)==null?void 0:R.adjustments)==null?void 0:x.hue)||0,F=E+o*((i==null?void 0:i.hue)||180)*f;t.style.adjustments.hue=(t.style.adjustments.hue??E)*(1-c)+F*c;break}case jt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(O=n==null?void 0:n.style)==null?void 0:O.adjustments});const E=((A=($=n==null?void 0:n.style)==null?void 0:$.adjustments)==null?void 0:A.negative)||0,F=E+o*((i==null?void 0:i.negative)||100)*f;t.style.adjustments.negative=(t.style.adjustments.negative??E)*(1-c)+F*c;break}case jt.CornerRadius:{const E=((V=n==null?void 0:n.transform)==null?void 0:V.corner_radius)||0,F=E+o*f*50;t.corner_radius=(t.corner_radius??E)*(1-c)+F*c;break}case jt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const E=((H=n==null?void 0:n.style)==null?void 0:H.borderWidth)||0,F=E+o*f*10;t.style.borderWidth=(t.style.borderWidth??E)*(1-c)+F*c;break}case jt.LetterSpacing:{t.geometry||(t.geometry={});const E=((et=n==null?void 0:n.geometry)==null?void 0:et.letterSpacing)||0,F=E+o*f*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??E)*(1-c)+F*c;break}}}getObjectProperty(t,s,o){const e=o.split(".");let i=t;for(const n of e){if(i==null||typeof i!="object")return;if(n==="style"&&t.style===void 0){i=s.style;continue}i=i[n]}return typeof i=="number"?i:void 0}setObjectProperty(t,s,o,e){const i=o.split(".");let n=t;for(let r=0;r<i.length-1;r++){const l=i[r];if(n[l]===void 0||n[l]===null){const f=s,c=i.slice(0,r+1).reduce((g,h)=>g==null?void 0:g[h],f);n[l]=c!==void 0?{...c}:{}}n=n[l]}const a=i[i.length-1];n!=null&&(n[a]=e)}applyEasing(t,s){switch(s){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,l=s.naturalHeight,f=r/l,c=i/n;let g=i,h=n,d=o,p=e;a==="cover"?f>c?(g=n*f,d=o-(g-i)/2):(h=i/f,p=e-(h-n)/2):a==="contain"&&(f>c?(h=i/f,p=e+(n-h)/2):(g=n*f,d=o+(i-g)/2)),t.drawImage(s,d,p,g,h)}}const ni=$t.forwardRef(({artboard:u,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:f,onInputChange:c,onInputFocus:g,onInputBlur:h,onLog:d,onLogicUpdate:p,onButtonClick:m,onGraphPointClick:y,currentTime:v,revision:b=0,scrollY:C,scrollX:S,mouseX:I,mouseY:w,isMouseDown:M,inputs:P,interactive:T=!0,onNavigation:W},k)=>{const _=$t.useRef(null),R=$t.useRef(new is),x=$t.useRef(void 0),O=$t.useRef(0),$=$t.useRef(null),A=$t.useRef(b),[,V]=$t.useState(u||null),H=$t.useRef(!0);$t.useImperativeHandle(k,()=>_.current),$t.useEffect(()=>(H.current=!0,()=>{H.current=!1,x.current&&cancelAnimationFrame(x.current)}),[]),$t.useEffect(()=>{R.current.setLayout(e,i)},[e,i]),$t.useEffect(()=>{const E=R.current;a&&E.setTriggerCallback(a),r&&E.setInputUpdateCallback((F,q)=>r({[F]:q})),l&&E.setComponentChangeCallback(F=>l(F)),f&&E.setToggleCallback(f),c&&E.setInputChangeCallback(c),g&&E.setInputFocusCallback(g),h&&E.setInputBlurCallback(h),d&&E.setOnLogCallback(F=>d(F,"info")),p&&E.setLogicUpdateCallback(p),m&&E.setButtonClickCallback(m),y&&E.setGraphPointClickCallback(F=>y(F.objectId,F)),W&&E.setNavigationCallback(W)},[a,r,l,f,c,g,h,d,p,m,y,W]),$t.useEffect(()=>{(async()=>{let F=u;if(t&&!u)try{t.startsWith("{")?F=JSON.parse(t):F=await(await fetch(t)).json()}catch(q){console.error("[ExodeUI] Failed to load src:",q)}if(F){const q=R.current,Q=F.id||F.name||"default";($.current!==Q||A.current!==b)&&(q.load(F),$.current=Q,A.current=b,V(F),O.current=0,q.advance(0)),n&&n(q)}})()},[u==null?void 0:u.id,t,b]),$t.useEffect(()=>{const E=F=>{if(!R.current||!H.current)return;const q=R.current,Q=_.current;if(!Q)return;const it=Q.getContext("2d");if(!it)return;const dt=F/1e3;O.current===0&&(O.current=dt);let St=dt-O.current;St>.1&&(St=.1),O.current=dt;const ht=Q.getBoundingClientRect(),mt=window.devicePixelRatio||1,rt=Math.round(ht.width*mt),Rt=Math.round(ht.height*mt);(Q.width!==rt||Q.height!==Rt)&&(Q.width=rt,Q.height=Rt),o?q.advance(St):v!==void 0&&q.seek(v),q.render(it,Q.width,Q.height),x.current=requestAnimationFrame(E)};return x.current=requestAnimationFrame(E),()=>{x.current&&cancelAnimationFrame(x.current)}},[o,v]),$t.useEffect(()=>{const E=R.current;C!==void 0&&E.updateInput("scrollY",C),S!==void 0&&E.updateInput("scrollX",S),I!==void 0&&E.updateInput("mouseX",I),w!==void 0&&E.updateInput("mouseY",w),M!==void 0&&E.updateInput("isMouseDown",M),P&&Object.entries(P).forEach(([F,q])=>E.updateInput(F,q))},[C,S,I,w,M,P]);const et=(E,F)=>{if(!T||!_.current)return;const q=_.current,Q=q.getBoundingClientRect(),it=E.clientX-Q.left,dt=E.clientY-Q.top,St=window.devicePixelRatio||1;R.current.handlePointerInput(F,it*St,dt*St,q.width,q.height)};return Zt.jsx("canvas",{ref:_,onPointerDown:E=>{var F;et(E,"down"),(F=_.current)==null||F.focus()},onPointerMove:E=>et(E,"move"),onPointerUp:E=>et(E,"up"),onPointerCancel:E=>et(E,"up"),onClick:E=>et(E,"click"),onWheel:E=>{R.current.handleWheel(E.deltaX,E.deltaY)},onKeyDown:E=>R.current.handleKeyDown(E.nativeEvent),onContextMenu:E=>E.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}})});function oi(){const[u,t]=$t.useState(null),s=$t.useCallback((c,g)=>{u==null||u.setInputBool(c,g)},[u]),o=$t.useCallback((c,g)=>{u==null||u.setInputNumber(c,g)},[u]),e=$t.useCallback(c=>{u==null||u.fireTrigger(c)},[u]),i=$t.useCallback((c,g)=>{u==null||u.setInputText(c,g)},[u]),n=$t.useCallback((c,g)=>{u==null||u.setInputNumberArray(c,g)},[u]),a=$t.useCallback((c,g)=>{u==null||u.setInputStringArray(c,g)},[u]),r=$t.useCallback((c,g)=>{u==null||u.updateObjectOptions(c,g)},[u]),l=$t.useCallback((c,g,h)=>{u==null||u.updateConstraint(c,g,h)},[u]),f=$t.useCallback((c,g)=>{u==null||u.updateGraphData(c,g)},[u]);return{setEngine:t,engine:u,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:l,updateGraphData:f,updateObjectOptions:r}}const ai=({artboard:u,config:t})=>{const s={...u.seo,...t},o=s.enableSmartExtraction!==!1;$t.useEffect(()=>{const a=s.title||u.name;a&&(document.title=a);let r=s.description;if(!r&&o){const c=u.objects.filter(g=>{var h;return((h=g.geometry)==null?void 0:h.type)==="Text"}).sort((g,h)=>{var d,p;return(((d=h.geometry.text)==null?void 0:d.length)||0)-(((p=g.geometry.text)==null?void 0:p.length)||0)});c.length>0&&(r=c[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||u.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,u,o]);const e=(a,r,l)=>{let f=document.querySelector(`meta[${a}="${r}"]`);f||(f=document.createElement("meta"),f.setAttribute(a,r),document.head.appendChild(f)),f.setAttribute("content",l)},i=()=>{const a=[];return a.push(Zt.jsx("h1",{children:s.title||u.name},"artboard-title")),u.objects.forEach((l,f)=>{var c,g;if(!(l.visible===!1||l.isVisible===!1))if(((c=l.geometry)==null?void 0:c.type)==="Text"){const h=l.geometry.text;h&&(l.geometry.fontSize>24?a.push(Zt.jsx("h2",{children:h},l.id||f)):a.push(Zt.jsx("p",{children:h},l.id||f)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const h=l.geometry.src,d=l.altText||l.name||"Illustration";a.push(Zt.jsx("img",{src:h,alt:d},l.id||f))}else l.type==="Button"&&a.push(Zt.jsx("button",{children:l.name||"Button"},l.id||f))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||u.name,description:s.description,image:s.ogImage||u.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Zt.jsxs("div",{id:`exode-seo-${u.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:[i(),Zt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.18"}.version;Ht.BehaviorSensor=jt,Ht.BehaviorType=Y,Ht.ConditionOp=Xe,Ht.ExodeSEO=ai,Ht.ExodeUICanvas=ni,Ht.ExodeUIEngine=is,Ht.LogicOp=yt,Ht.VERSION=ri,Ht.useExodeUI=oi,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})});
|