exodeui 6.3.44 → 6.3.45
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 +33 -33
- package/dist/index.mjs +3122 -3052
- package/dist/src/engine.d.ts +3 -5
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`||J==="\r"?
|
|
1
|
+
(function(Ut,Vt){typeof exports=="object"&&typeof module<"u"?Vt(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"],Vt):(Ut=typeof globalThis<"u"?globalThis:Ut||self,Vt(Ut.ExodeUIReact={},Ut.jsxRuntime,Ut.React,Ut.pretext,Ut.Rapier,Ut.LZString))})(this,(function(Ut,Vt,Lt,Ye,ie,bs){"use strict";var li=Object.defineProperty;var ci=(Ut,Vt,Lt)=>Vt in Ut?li(Ut,Vt,{enumerable:!0,configurable:!0,writable:!0,value:Lt}):Ut[Vt]=Lt;var rt=(Ut,Vt,Lt)=>ci(Ut,typeof Vt!="symbol"?Vt+"":Vt,Lt);function Ss(g){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const i in g)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(g,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>g[i]})}}return t.default=g,Object.freeze(t)}const vs=Ss(bs);var U=(g=>(g.Proximity="Proximity",g.Magnetic="Magnetic",g.Repel="Repel",g.Orbit="Orbit",g.Vortex="Vortex",g.Fluid="Fluid",g.Elastic="Elastic",g.Holographic="Holographic",g.Sticky="Sticky",g.Dilation="Dilation",g.Parallax="Parallax",g.Noise="Noise",g.Float="Float",g.Pulse="Pulse",g.Draggable="Draggable",g.Scroll="Scroll",g.LookAt="LookAt",g.Glint="Glint",g.Scan="Scan",g.Ratchet="Ratchet",g.Jitter="Jitter",g.Follower="Follower",g.Wrap="Wrap",g.Typewriter="Typewriter",g.Scramble="Scramble",g.Wave="Wave",g.Bounce="Bounce",g.TextTrail="TextTrail",g.Reveal3D="Reveal3D",g.RevealSlide="RevealSlide",g.RevealBlur="RevealBlur",g.TextLiquid="TextLiquid",g.TextVortex="TextVortex",g.TextExplosion="TextExplosion",g.TextRain="TextRain",g.TextGravity="TextGravity",g.TextMatrix="TextMatrix",g.TextNeon="TextNeon",g.TextDissolve="TextDissolve",g.TextOrganic="TextOrganic",g.TextBreathe="TextBreathe",g.TextSpin="TextSpin",g.TextMagnet="TextMagnet",g.TextPerspective="TextPerspective",g.TextMirror="TextMirror",g.TextFloral="TextFloral",g.TextSmoke="TextSmoke",g.TextVariable="TextVariable",g.TextZing="TextZing",g.TextElastic="TextElastic",g.TextGlitch3D="TextGlitch3D",g.GlitchText="GlitchText",g.TextCounter="TextCounter",g.Squash="Squash",g.Spotlight="Spotlight",g.Lens="Lens",g.Gravity="Gravity",g.Velocity="Velocity",g.Shear="Shear",g.LayoutAnimation="LayoutAnimation",g.SpringChain="SpringChain",g.ParticleEmitter="ParticleEmitter",g.StateReactive="StateReactive",g.Fold="Fold",g.Crumple="Crumple",g))(U||{}),ne=(g=>(g.Scale="Scale",g.Opacity="Opacity",g.RotateZ="RotateZ",g.RotateX="RotateX",g.RotateY="RotateY",g.PositionX="PositionX",g.PositionY="PositionY",g.SkewX="SkewX",g.Blur="Blur",g.Exposure="Exposure",g.HueShift="HueShift",g.Negative="Negative",g.CornerRadius="CornerRadius",g.StrokeWidth="StrokeWidth",g.BoxShadow="BoxShadow",g.FontSize="FontSize",g.LetterSpacing="LetterSpacing",g))(ne||{}),Je=(g=>(g.Equal="Equal",g.NotEqual="NotEqual",g.GreaterThan="GreaterThan",g.LessThan="LessThan",g.GreaterEqual="GreaterEqual",g.LessEqual="LessEqual",g.IsTrue="IsTrue",g.IsFalse="IsFalse",g))(Je||{}),kt=(g=>(g.AND="AND",g.OR="OR",g.NOT="NOT",g.XOR="XOR",g.OBJECT="OBJECT",g.PROPERTY="PROPERTY",g.GET_PROPERTY="GET_PROPERTY",g.SET_PROPERTY="SET_PROPERTY",g.ADD="ADD",g.SUB="SUB",g.MUL="MUL",g.DIV="DIV",g.MOD="MOD",g.POW="POW",g.ABS="ABS",g.ROUND="ROUND",g.FLOOR="FLOOR",g.CEIL="CEIL",g.SIN="SIN",g.COS="COS",g.TAN="TAN",g.CLAMP="CLAMP",g.REMAP="REMAP",g.EQ="EQ",g.NEQ="NEQ",g.GT="GT",g.LT="LT",g.GTE="GTE",g.LTE="LTE",g.IF_ELSE="IF_ELSE",g.VALUE="VALUE",g.INPUT="INPUT",g.LOG="LOG",g.SCROLL_X="SCROLL_X",g.SCROLL_Y="SCROLL_Y",g.MOUSE_X="MOUSE_X",g.MOUSE_Y="MOUSE_Y",g.IS_MOUSE_DOWN="IS_MOUSE_DOWN",g.EFFECTOR="EFFECTOR",g.MONITOR="MONITOR",g.DELAY="DELAY",g.SPRING_PULL="SPRING_PULL",g.SPRING_SETTLE="SPRING_SETTLE",g.EMIT="EMIT",g))(kt||{});function Cs(g){if(g.length<5)return g;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(g))return g;let o="";for(let e=0;e<g.length;e++){if(o+=g[e],e>=g.length-2)continue;const s=t.has(g[e]),n=t.has(g[e+1]),a=t.has(g[e+2]);s&&!n&&a&&(o+=""),s&&!n&&!a&&e>=1&&(o+="")}return o}function ws(g){return g.replace(/\b([a-zA-Z]{4,})\b/g,(t,i)=>Cs(i))}function Ms(g,t,i){return g}function ks(g,t,i){return g}const Fe=new Map;function Qe(g){var k;const{text:t,fontFamily:i="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:s="normal",lineHeight:n=1.2,width:a=200,letterSpacing:l=0,paragraphSpacing:r=0,paragraphIndent:h=0,textCase:f="none",segments:p=[],enableSegments:c=!1}=g;let d=String(t||"");f==="uppercase"?d=d.toUpperCase():f==="lowercase"?d=d.toLowerCase():f==="capitalize"&&(d=d.replace(/\b\w/g,I=>I.toUpperCase())),g.hyphenation===!0&&(d=ws(d));const u=`${s} ${e} ${o}px "${i}", sans-serif`,b=`${d}|${u}|${l}|${r}|${h}|${c}|${JSON.stringify(p)}|hyp:${!!g.hyphenation}|comp:${g.composer}|bal:${!!g.balanceRaggedLines}`;let m=Fe.get(b);const y=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,S=function(I){if(!y)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=y.call(this,I);return l!==0&&I&&I.length>0?{...T,width:T.width+(I.length-1)*l}:T};if(!m){try{if(l!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=S),c&&p&&p.length>0){const I=p.map(T=>{let O=T.text||"";const P=T.textCase||f||"none";return P==="uppercase"?O.toUpperCase():P==="lowercase"?O.toLowerCase():P==="capitalize"?O.replace(/\b\w/g,_=>_.toUpperCase()):O}).join("");if(m=Ye.prepareWithSegments(I,u),m){let T=0,O=o;for(const P of p){let _=P.text||"";if(!_)continue;const E=P.textCase||f||"none";E==="uppercase"?_=_.toUpperCase():E==="lowercase"?_=_.toLowerCase():E==="capitalize"&&(_=_.replace(/\b\w/g,W=>W.toUpperCase()));const A=P.fontSize||o;A>O&&(O=A);const B=`${P.fontStyle||s} ${P.fontWeight||e} ${A}px "${P.fontFamily||i}", sans-serif`,X=Ye.prepareWithSegments(_,B);if(X&&X.widths)for(let W=0;W<X.widths.length;W++){const Y=T+W;if(Y<m.widths.length){m.widths[Y]=X.widths[W];const z=X.kinds[W];if(z===2){const J=_[W];J===`
|
|
2
|
+
`||J==="\r"?m.kinds[Y]=2:m.kinds[Y]=0}else m.kinds[Y]=z}}T+=_.length}m.fullText=I,m.maxFontSize=O}}else m=Ye.prepareWithSegments(d,u);m&&Fe.set(b,m)}catch(I){return console.error("[ExodeUI] Pretext prepare failed:",I),{width:a,height:0,lineCount:0,lines:[]}}finally{l!==0&&typeof CanvasRenderingContext2D<"u"&&y&&(CanvasRenderingContext2D.prototype.measureText=y)}if(Fe.size>500){const I=Fe.keys().next().value;I&&Fe.delete(I)}}if(h>0&&m&&m.widths&&!m.indentApplied){const I=[...m.widths],T=m.fullText||d;let O=!0;for(let P=0;P<T.length;P++)O&&I[P]!==void 0&&(I[P]+=h,O=!1),(T[P]===`
|
|
3
3
|
`||T[P]==="\r")&&(O=!0,T[P]==="\r"&&T[P+1]===`
|
|
4
|
-
`&&P++);
|
|
5
|
-
`||T[
|
|
6
|
-
`&&k++)}let I=(C==null?void 0:C.lines)||[];return g.composer==="every-line"&&I.length>1&&(I=Ms(I)),g.balanceRaggedLines===!0&&I.length>1&&(I=Is(I)),{width:a,height:w,lineCount:I.length,lines:I}}function es(g,t,i){let o=String(g||"").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),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((r,c)=>{if(r.endsWith("px")){const h=parseFloat(r);s[c]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(s[c]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((c,h)=>{c.endsWith("fr")&&(s[h]=r*parseFloat(c))})}return s}function ss(g,t,i){try{const o=g.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(g,t,i):ks(g,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(g,t,i){var _,E;const o=g.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:r}=o,c=e==="vertical",h=t.map(A=>{const W=i(A.id),z=A.geometry;let Y=(W==null?void 0:W.width)??z.width??100,G=(W==null?void 0:W.height)??z.height??100;if(z.type==="Ellipse"||z.type==="Polygon"||z.type==="Star"){const N=(W==null?void 0:W.radius)??z.radius??(W==null?void 0:W.outer_radius)??z.outer_radius??50;Y=N*2,G=N*2}else if(z.type==="Text"){const N=ts({text:(W==null?void 0:W.text)??z.text??"",fontFamily:z.fontFamily,fontSize:z.fontSize,fontWeight:z.fontWeight,fontStyle:z.fontStyle,lineHeight:z.lineHeight,width:z.width||200,letterSpacing:z.letterSpacing,paragraphSpacing:z.paragraphSpacing,paragraphIndent:z.paragraphIndent,textCase:z.textCase,segments:z.segments,enableSegments:z.enableSegments});G=N.height,z.width||(Y=N.width)}return Y*=A.transform.scale_x||1,G*=A.transform.scale_y||1,{id:A.id,w:Y,h:G,original:A}});let f=g.width,u=g.height;const l=((_=g.layoutProps)==null?void 0:_.width)==="hug",d=((E=g.layoutProps)==null?void 0:E.height)==="hug",p=[];let y=[],b=0,m=0;const v=f-n.left-n.right,S=u-n.top-n.bottom;h.forEach(A=>{r&&y.length>0&&(c?m+s+A.h>S:b+s+A.w>v)?(p.push({children:y,width:b,height:m}),y=[A],b=A.w,m=A.h):(y.push(A),c?(b=Math.max(b,A.w),m+=(y.length>1?s:0)+A.h):(b+=(y.length>1?s:0)+A.w,m=Math.max(m,A.h)))}),y.length>0&&p.push({children:y,width:b,height:m}),l&&!c&&(f=Math.max(...p.map(A=>A.width),0)+n.left+n.right),d&&c&&(u=Math.max(...p.map(A=>A.height),0)+n.top+n.bottom);const C=[];let w=n.left,I=n.top;const M=a.toLowerCase(),k=M==="center"||M.endsWith("-center"),T=M.endsWith("-right"),O=M==="center"||M.startsWith("center-"),P=M.startsWith("bottom-");return p.forEach(A=>{let W=w,z=I;c?O?z=n.top+(u-n.top-n.bottom-A.height)/2:P&&(z=u-n.bottom-A.height):k?W=n.left+(f-n.left-n.right-A.width)/2:T&&(W=f-n.right-A.width),A.children.forEach(Y=>{var F,j;let G=W,N=z;c?k?G+=(A.width-Y.w)/2:T&&(G+=A.width-Y.w):O?N+=(A.height-Y.h)/2:P&&(N+=A.height-Y.h);const J=((F=Y.original.layoutProps)==null?void 0:F.width)==="fill",x=((j=Y.original.layoutProps)==null?void 0:j.height)==="fill";C.push({id:Y.id,x:G+Y.w/2-f/2,y:N+Y.h/2-u/2,width:J&&c?A.width:void 0,height:x?c?void 0:A.height:void 0}),c?z+=Y.h+s:W+=Y.w+s}),c?w+=A.width+s:I+=A.height+s}),{frameWidth:l?f:void 0,frameHeight:d?u:void 0,childUpdates:C}}function Ts(g,t,i){const o=g.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:r,align:c}=o;let h=g.width,f=g.height;const u=h-r.left-r.right,l=f-r.top-r.bottom,d=es(e||"1fr",u,n),p=es(s||"auto",l,a),y=d.length>0?d.reduce((T,O)=>T+O,0)+(d.length-1)*n:0,b=p.length>0?p.reduce((T,O)=>T+O,0)+(p.length-1)*a:0,m=c.toLowerCase(),v=m==="center"||m.endsWith("-center"),S=m.endsWith("-right"),C=m==="center"||m.startsWith("center-"),w=m.startsWith("bottom-");let I=0,M=0;v?I=(u-y)/2:S&&(I=u-y),C?M=(l-b)/2:w&&(M=l-b);const k=[];return t.forEach((T,O)=>{var j,X;const P=O%d.length||0,_=Math.floor(O/d.length)||0;_>=p.length&&p.push(100);const E=d[P],A=p[_];let W=r.left+I+d.slice(0,P).reduce((tt,L)=>tt+L+n,0),z=r.top+M+p.slice(0,_).reduce((tt,L)=>tt+L+a,0);const Y=i(T.id),G=T.geometry;let N=(Y==null?void 0:Y.width)??G.width??100,J=(Y==null?void 0:Y.height)??G.height??100;if(G.type==="Ellipse"||G.type==="Polygon"||G.type==="Star"){const tt=(Y==null?void 0:Y.radius)??G.radius??(Y==null?void 0:Y.outer_radius)??G.outer_radius??50;N=tt*2,J=tt*2}N*=T.transform.scale_x||1,J*=T.transform.scale_y||1;let x=W,F=z;v?x+=(E-N)/2:S&&(x+=E-N),C?F+=(A-J)/2:w&&(F+=A-J),k.push({id:T.id,x:x+N/2-h/2,y:F+J/2-f/2,width:((j=T.layoutProps)==null?void 0:j.width)==="fill"?E:void 0,height:((X=T.layoutProps)==null?void 0:X.height)==="fill"?A:void 0})}),{childUpdates:k}}class is{constructor(){lt(this,"world",null);lt(this,"bodies",new Map);lt(this,"colliders",new Map);lt(this,"joints",new Map);lt(this,"initialized",!1);lt(this,"bodyIdByCollider",new Map);lt(this,"onCollisionCB",null);lt(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await Jt.init(),this.world=new Jt.World(new Jt.Vector2(t.x*100,t.y*100)),this.eventQueue=new Jt.EventQueue(!0),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.joints.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}setGravity(t){this.world&&(this.world.gravity=new Jt.Vector2(t.x*100,t.y*100))}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const i=t.isStatic?Jt.RigidBodyDesc.fixed():Jt.RigidBodyDesc.dynamic();i.setTranslation(t.x,t.y),t.rotation!==void 0&&i.setRotation(t.rotation);const o=this.world.createRigidBody(i);let e;switch(t.type){case"Rectangle":e=Jt.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=Jt.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=Jt.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=Jt.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 s=this.world.createCollider(e,o);this.bodyIdByCollider.set(s.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,s)}removeBody(t){const i=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),i&&this.world&&(this.world.removeRigidBody(i),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const i=this.onCollisionCB,o=this.eventQueue;i&&o&&o.drainContactEvents((e,s,n)=>{const a=this.bodyIdByCollider.get(e),r=this.bodyIdByCollider.get(s);a&&r&&i(a,r,n)})}getPosition(t){const i=this.bodies.get(t);if(!i)return null;const o=i.translation();return{x:o.x,y:o.y}}getRotation(t){const i=this.bodies.get(t);return i?i.rotation():null}getVelocity(t){const i=this.bodies.get(t);if(!i)return null;const o=i.linvel();return{x:o.x,y:o.y}}setPosition(t,i,o){const e=this.bodies.get(t);e&&e.setTranslation(new Jt.Vector2(i,o),!0)}setRotation(t,i){const o=this.bodies.get(t);o&&o.setRotation(i,!0)}setVelocity(t,i,o){const e=this.bodies.get(t);e&&e.setLinvel(new Jt.Vector2(i,o),!0)}setAngularVelocity(t,i){const o=this.bodies.get(t);o&&o.setAngvel(i,!0)}applyForce(t,i,o){const e=this.bodies.get(t);e&&e.addForce(new Jt.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new Jt.Vector2(i,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const i=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!i||!o){console.warn(`[RapierPhysics] Cannot create joint ${t.id}: bodyA (${t.bodyA}) or bodyB (${t.bodyB}) not found`);return}const e=new Jt.Vector2(t.anchorA.x,t.anchorA.y),s=new Jt.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,c=t.damping??10;n=Jt.JointData.spring(a,r,c,e,s)}else n=Jt.JointData.revolute(e,s);try{const a=this.world.createImpulseJoint(n,i,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const i=this.joints.get(t);if(i&&this.world){try{this.world.removeImpulseJoint(i,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const ns=g=>g,_s=g=>g>0?1:0,Ps=g=>g<1?0:1,os=g=>g*g,as=g=>g*(2-g),rs=g=>g<.5?2*g*g:-1+(4-2*g)*g,Es=g=>g*g*g,As=g=>--g*g*g+1,xs=g=>g<.5?4*g*g*g:(g-1)*(2*g-2)*(2*g-2)+1,Os=g=>g*g*g*g,Ls=g=>1- --g*g*g*g,Rs=g=>g<.5?8*g*g*g*g:1-8*--g*g*g*g,Fs=g=>g*g*g*g*g,$s=g=>1+--g*g*g*g*g,Bs=g=>g<.5?16*g*g*g*g*g:1+16*--g*g*g*g*g,Ws=g=>1-Math.cos(g*Math.PI/2),Ys=g=>Math.sin(g*Math.PI/2),Xs=g=>-(Math.cos(Math.PI*g)-1)/2,Ds=g=>g===0?0:Math.pow(2,10*(g-1)),Gs=g=>g===1?1:1-Math.pow(2,-10*g),zs=g=>g===0?0:g===1?1:g<.5?Math.pow(2,20*g-10)/2:(2-Math.pow(2,-20*g+10))/2,Vs=g=>1-Math.sqrt(1-g*g),Ns=g=>Math.sqrt(1- --g*g),Hs=g=>g<.5?(1-Math.sqrt(1-4*g*g))/2:(Math.sqrt(1-(-2*g+2)*(-2*g+2))+1)/2,Ve=1.70158,Ne=Ve*1.525,ls=Ve+1,Us=g=>ls*g*g*g-Ve*g*g,qs=g=>1+ls*Math.pow(g-1,3)+Ve*Math.pow(g-1,2),Ks=g=>g<.5?Math.pow(2*g,2)*((Ne+1)*2*g-Ne)/2:(Math.pow(2*g-2,2)*((Ne+1)*(g*2-2)+Ne)+2)/2,cs=2*Math.PI/3,fs=2*Math.PI/4.5,Js=g=>g===0?0:g===1?1:-Math.pow(2,10*g-10)*Math.sin((g*10-10.75)*cs),Qs=g=>g===0?0:g===1?1:Math.pow(2,-10*g)*Math.sin((g*10-.75)*cs)+1,Zs=g=>g===0?0:g===1?1:g<.5?-(Math.pow(2,20*g-10)*Math.sin((20*g-11.125)*fs))/2:Math.pow(2,-20*g+10)*Math.sin((20*g-11.125)*fs)/2+1,He=g=>g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375,js=g=>1-He(1-g),ti=He,ei=g=>g<.5?(1-He(1-2*g))/2:(1+He(2*g-1))/2,Ze=new Map,Ye=(g,t,i,o)=>{const e=`${g},${t},${i},${o}`;if(Ze.has(e))return Ze.get(e);const s=h=>(1-3*i+3*g)*h*h*h+(3*i-6*g)*h*h+3*g*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*i+3*g)*h*h+2*(3*i-6*g)*h+3*g,r=h=>{let f=h;for(let u=0;u<8;u++){const l=s(f)-h;if(Math.abs(l)<1e-6)return f;const d=a(f);if(Math.abs(d)<1e-6)break;f=f-l/d}return f},c=h=>h===0?0:h===1?1:n(r(h));return Ze.set(e,c),c},hs=g=>{const t=g.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return Ye(i,o,e,s)},ds={ease:Ye(.25,.1,.25,1),"ease-in":Ye(.42,0,1,1),"ease-out":Ye(0,0,.58,1),"ease-in-out":Ye(.42,0,.58,1)},Ue={Linear:ns,EaseInQuad:os,EaseOutQuad:as,EaseInOutQuad:rs,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:xs,EaseInQuart:Os,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Ks,EaseInElastic:Js,EaseOutElastic:Qs,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:os,EaseOut:as,EaseInOut:rs,StepStart:_s,StepEnd:Ps},si=g=>{const t=g.trim(),i=t.toLowerCase();if(Ue[t])return Ue[t];const o=Object.keys(Ue).find(s=>s.toLowerCase()===i);if(o)return Ue[o];const e=Object.keys(us).find(s=>s.toLowerCase()===i);if(e){const s=hs(us[e].value);if(s)return s}if(ds[i])return ds[i];if(i.startsWith("cubic-bezier")){const s=hs(t);if(s)return s}return ns},us={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=(g,t,i,o,e)=>{if(!g||!t||!i)return g;const s=o.scale_x??1,n=o.scale_y??1,a=(r,c,h)=>{let f=0,u=0;const l=o.rotation*Math.PI/180,d=Math.cos(l),p=Math.sin(l),y=r*s*d-c*n*p+o.x,b=r*s*p+c*n*d+o.y;h.forEach(M=>{const k=e(M.boneId);if(!k)return;const T={x:k.x,y:k.y,rotation:k.rotation,scaleX:k.scale_x??1,scaleY:k.scale_y??1},O=i[M.boneId]||[1,0,0,1,0,0],P=y*O[0]+b*O[2]+O[4],_=y*O[1]+b*O[3]+O[5],E=T.rotation*Math.PI/180,A=Math.cos(E),W=Math.sin(E),z=P*T.scaleX*A-_*T.scaleY*W+T.x,Y=P*T.scaleX*W+_*T.scaleY*A+T.y;f+=z*M.amount,u+=Y*M.amount});const m=[...h].sort((M,k)=>k.amount-M.amount);if(m.length>=2&&m[0].amount>0&&m[1].amount>0){const M=e(m[0].boneId),k=e(m[1].boneId);if(M&&k&&M.length!==void 0&&k.length!==void 0){const T=M.length*(M.scale_y??1),O=M.rotation*Math.PI/180,P=M.x-T*Math.sin(O),_=M.y+T*Math.cos(O),E=k.length*(k.scale_y??1),A=k.rotation*Math.PI/180,W=k.x-E*Math.sin(A),z=k.y+E*Math.cos(A);let Y=null,G=null,N=!1;const J=1;if(Math.hypot(M.x-k.x,M.y-k.y)<J||Math.hypot(M.x-W,M.y-z)<J?(Y=M.x,G=M.y):(Math.hypot(P-k.x,_-k.y)<J||Math.hypot(P-W,_-z)<J)&&(Y=P,G=_,N=!0),Y!==null&&G!==null){const x=i[m[0].boneId]||[1,0,0,1,0,0],F=x[0]*x[3]-x[1]*x[2];let j=0,X=0;if(F!==0){const tt=(x[2]*x[5]-x[3]*x[4])/F,L=(x[1]*x[4]-x[0]*x[5])/F,R=Math.atan2(-x[1],x[3]);if(!N)j=tt,X=L;else{const ot=-x[2]/F,yt=x[0]/F,bt=Math.hypot(ot,yt),gt=M.length*bt;j=tt-gt*Math.sin(R),X=L+gt*Math.cos(R)}const D=Math.hypot(y-j,b-X),q=Math.hypot(f-Y,u-G);if(q>0&&D>0){const ot=Math.max(q,.01),yt=Math.min(D/ot,3),bt=Y+(f-Y)*yt,gt=G+(u-G)*yt,Et=m[0].amount,It=m[1].amount,vt=Math.min(Et,It)*2,Dt=1-Math.pow(1-vt,4);f=f*(1-Dt)+bt*Dt,u=u*(1-Dt)+gt*Dt}}}}}const v=o.rotation*Math.PI/180,S=Math.cos(v),C=Math.sin(v),w=f-o.x,I=u-o.y;return{x:(w*S+I*C)/s,y:(-w*C+I*S)/n}};return g.map((r,c)=>{const h=t[c];if(!h||h.length===0)return{...r};const f={...r,...a(r.x,r.y,h)};if(r.in_x!==void 0&&r.in_y!==void 0){const u=a(r.in_x,r.in_y,h);f.in_x=u.x,f.in_y=u.y}if(r.out_x!==void 0&&r.out_y!==void 0){const u=a(r.out_x,r.out_y,h);f.out_x=u.x,f.out_y=u.y}return f})},ps={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}},gs={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 ms{constructor(){lt(this,"artboard",null);lt(this,"objectStates",new Map);lt(this,"physicsEngine",null);lt(this,"activeStateMachine",null);lt(this,"inputs",new Map);lt(this,"inputNameMap",new Map);lt(this,"layerStates",new Map);lt(this,"pretextCache",new Map);lt(this,"pointerHistory",[]);lt(this,"MAX_HISTORY",200);lt(this,"imageCache",new Map);lt(this,"lastValidSvgImgMap",new Map);lt(this,"maskBuffer",null);lt(this,"maskCtx",null);lt(this,"lumaBuffer",null);lt(this,"lumaCtx",null);lt(this,"_noiseTileCanvas",null);lt(this,"layout",{fit:"Contain",alignment:"Center"});lt(this,"onTrigger");lt(this,"onInputUpdate");lt(this,"onComponentChange");lt(this,"onToggle");lt(this,"onInputChange");lt(this,"onInputFocus");lt(this,"onInputBlur");lt(this,"onLog");lt(this,"onButtonClick");lt(this,"onGraphPointClick");lt(this,"justFiredTriggers",new Set);lt(this,"rootTransform",null);lt(this,"canvasWidth",0);lt(this,"canvasHeight",0);lt(this,"lastHoveredObjectId",null);lt(this,"_lastPointerPos",null);lt(this,"_prevPointerPos",null);lt(this,"_mouseDelta",{dx:0,dy:0});lt(this,"focusedId",null);lt(this,"draggingSliderId",null);lt(this,"draggingJoystickId",null);lt(this,"activeDropdownId",null);lt(this,"activeObjectId",null);lt(this,"draggingListViewId",null);lt(this,"scrollOffset",{x:0,y:0});lt(this,"_totalScroll",{x:0,y:0});lt(this,"draggingBehaviors",new Set);lt(this,"isMouseDown",!1);lt(this,"activeKeys",new Set);lt(this,"_layoutAnimCache",new Map);lt(this,"_springChainState",new Map);lt(this,"_emitterPools",new Map);lt(this,"objectVelocities",new Map);lt(this,"currentTime",0);lt(this,"frameCount",0);lt(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});lt(this,"onLogicUpdate");lt(this,"logicNodeValues",new Map);lt(this,"logicNodeState",new Map);lt(this,"pointerDownTimes",new Map);lt(this,"activeHoverIds",new Set);lt(this,"onNavigation");lt(this,"periodicTriggerTimes",new Map);lt(this,"wasInView",new Set);lt(this,"scrollProgressLastValue",new Map);lt(this,"debug_objectsRendered",0);lt(this,"debug_objectsTotal",0);lt(this,"lastRenderTime",0);lt(this,"debugMode",!1);lt(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)")}getInputValue(t){return this.inputs.get(t)}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:i,isClosed:o}=this.svgPathToPoints(t.data);t.points=i,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const i=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let s=!1,n=0,a=0,r=0,c=0,h=0,f=0,u;for(;(u=i.exec(t))!==null;){const l=u[1],d=(u[2].match(o)||[]).map(parseFloat),p=l===l.toLowerCase(),y=l.toUpperCase();let b=0;const m=S=>{let C=d[b++];return p&&(C+=S?n:a),C},v=()=>({x:m(!0),y:m(!1)});switch(y){case"M":{const S=v();for(h=n=S.x,f=a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});b<d.length;){const C=v();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"L":for(;b<d.length;){const S=v();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"H":for(;b<d.length;)n=m(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;b<d.length;)a=m(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;b<d.length;){const S=v(),C=v(),w=v();if(e.length>0){const I=e[e.length-1];I.out_x=S.x,I.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,c=C.y}break;case"S":for(;b<d.length;){const S={x:2*n-r,y:2*a-c},C=v(),w=v();if(e.length>0){const I=e[e.length-1];I.out_x=S.x,I.out_y=S.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),r=C.x,c=C.y}break;case"Q":for(;b<d.length;){const S=v(),C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,c=S.y}break;case"T":for(;b<d.length;){const S={x:2*n-r,y:2*a-c},C=v();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(S.x-w.x),w.out_y=w.y+2/3*(S.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(S.x-n),in_y:a+2/3*(S.y-a),out_x:n,out_y:a}),r=S.x,c=S.y}break;case"Z":if(s=!0,e.length>0){const S=e[e.length-1];S.closePath=!0;const C=[...e].reverse().find(w=>w.moveTo)||e[0];C&&Math.hypot(C.x-S.x,C.y-S.y)<.1&&(C.in_x=S.in_x,C.in_y=S.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=h,a=f;break;default:if(d.length>=2){const S=v();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}}return{points:e,isClosed:s}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,i,o){var s;const e=(s=this.artboard)==null?void 0:s.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[i]&&(e.constraints[i]={...e.constraints[i],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,i){this.inputs.set(t,i),this.onInputUpdate&&this.onInputUpdate(t,i)}setLayout(t,i){this.layout={fit:t,alignment:i}}getActiveStateIds(t="Base Layer"){const i=this.layerStates.get(t);return i?i.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,i){const o=this.objectStates.get(t);o&&(o.options={...o.options,...i})}updateGraphData(t,i){var e,s;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:i,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=i;const a=this.objectStates.get(o.id);a&&((s=a.geometry)==null?void 0:s.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...i]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,i)}else this.updateInput(t,i)}load(t){var n,a;if(!t)return;let i=this.decompressStrings(t);const o=[],e=new Set,s=r=>{r&&r.forEach(c=>{if(e.has(c.id))return;const h={...c},f=h.childrenObjects||[];e.add(h.id),o.push(h),s(f)})};if(s(i.objects||[]),o.length>(i.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(i.objects||[]).length} to ${o.length} objects.`),i.objects=o,this.artboard=i,this.currentTime=0,this.objectStates.clear(),this.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(c=>{r.set(c.id,c),c.children||(c.children=[])}),this.artboard.objects.forEach(c=>{if(c.parentId){const h=r.get(c.parentId);h&&(h.children||(h.children=[]),h.children.includes(c.id)||h.children.push(c.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const i=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{this.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=s=>{console.error("[ExodeUI Preload] failed:",s,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,s,n;(e=o.geometry)!=null&&e.src&&i(o.geometry.src),(n=(s=o.style)==null?void 0:s.fill)!=null&&n.src&&i(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=Ss.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const i={};for(const[o,e]of Object.entries(t))i[o]=this.decompressStrings(e);return i}return Array.isArray(t)?t.map(i=>this.decompressStrings(i)):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(i=>{var n,a,r,c,h,f,u;const o=i.width??((n=i.geometry)==null?void 0:n.width)??0,e=i.height??((a=i.geometry)==null?void 0:a.height)??0,s=i.cornerRadius??i.corner_radius??((r=i.geometry)==null?void 0:r.corner_radius)??((c=i.geometry)==null?void 0:c.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((h=i.transform)==null?void 0:h.x)??i.x??0,y:((f=i.transform)==null?void 0:f.y)??i.y??0,width:o,height:e,cornerRadius:s,corner_radius:s,clipContent:i.clipContent??!1,autoLayout:i.autoLayout?JSON.parse(JSON.stringify(i.autoLayout)):void 0,layoutProps:i.layoutProps?JSON.parse(JSON.stringify(i.layoutProps)):void 0,opacity:((u=i.transform)==null?void 0:u.opacity)!==void 0?i.transform.opacity:i.opacity!==void 0?i.opacity:100,visible:i.visible!==void 0?i.visible:i.isVisible!==void 0?i.isVisible:!0,blendMode:i.blendMode||"Normal",style:JSON.parse(JSON.stringify(i.style||{})),geometry:JSON.parse(JSON.stringify(i.geometry||{})),options:i.options?JSON.parse(JSON.stringify(i.options)):{},masks:i.masks?JSON.parse(JSON.stringify(i.masks)):[],zIndex:i.zIndex!==void 0?i.zIndex:void 0})}),this.artboard.objects.some(i=>{var o;return(o=i.physics)==null?void 0:o.enabled})){this.physicsEngine=new is;const i=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(i).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var s,n;if((s=e.physics)!=null&&s.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,c=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:c,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(i=>{this.inputs.set(i.id,i.value);const o=this.inputNameMap.get(i.name)||[];o.includes(i.id)||o.push(i.id),this.inputNameMap.set(i.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(i=>{this.inputs.set(i.id,i.value.value);const o=this.inputNameMap.get(i.name)||[];o.push(i.id),this.inputNameMap.set(i.name,o)}),this.activeStateMachine.layers.forEach(i=>{let o=i.states.find(e=>e.id===i.entryStateId);!o&&i.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${i.entryStateId}" in layer "${i.name}". Falling back to first state.`),o=i.states[0]),o&&this.enterStates(i.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var s;if(!this.artboard)return;const i=new Map;this.artboard.objects.forEach(n=>i.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const c=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(c>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((s=this.artboard.autoLayout)!=null&&s.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=ss(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(f=>i.get(f)).filter(f=>!!f),c=this.objectStates.get(n.id);if(!c)return;const h=ss(c,r,f=>this.objectStates.get(f));h.frameWidth!==void 0&&(c.width=h.frameWidth),h.frameHeight!==void 0&&(c.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 i="";t.forEach(n=>{const a=n.replace(/ /g,"+");i+=`&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(i.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${i}`;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 s=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&s.push("clash-display@200,300,400,500,600,700")}),s.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${s.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,i){var n;if(i.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===i.length&&i.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let s=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of i){const c=a.states.find(h=>h.id===r);if(c)if(c.isBlendState&&c.blendAnimations&&c.blendAnimations.length>0)e.push({animation:null,state:c}),c.blendAnimations.forEach(h=>{const f=this.artboard.animations.find(u=>u.id===h.animationId);f&&(s=Math.max(s,f.duration))});else{let h=null;c.animationId&&(h=this.artboard.animations.find(f=>f.id===c.animationId)||null),h||(h=this.artboard.animations.find(f=>{var u,l;return f.name===c.name||f.id===c.name||(c.name==="Entry"||c.id==="entry")&&(((u=f.name)==null?void 0:u.toLowerCase())==="onload"||((l=f.name)==null?void 0:l.toLowerCase())==="intro")})||null),h&&((n=this.artboard.animationFlow)!=null&&n.some(u=>(u.trigger==="on_load"||u.trigger==="after_delay")&&u.targetAnimationId===(h==null?void 0:h.id))||(e.push({animation:h,state:c}),s=Math.max(s,h.duration)))}}}this.layerStates.set(t,{currentStateIds:i,animations:e,time:0,duration:s})}setInputBool(t,i){this.updateInput(t,i)}setInputNumber(t,i){this.updateInput(t,i)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,i){this.updateInput(t,i)}setInputNumberArray(t,i){this.updateInput(t,i)}setInputStringArray(t,i){this.updateInput(t,i)}updateObjectProperty(t,i,o){const e=this.objectStates.get(t);if(e)if(i.includes(".")){const s=i.split(".");let n=e;for(let a=0;a<s.length-1;a++)n[s[a]]||(n[s[a]]={}),n=n[s[a]];n[s[s.length-1]]=o}else e[i]=o}updateInput(t,i){var n,a,r;let o;if(this.inputs.has(t)){const c=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);c&&typeof c.value=="object"&&(o=c.value.type)}else{const c=this.inputNameMap.get(t);if(c&&c.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(f=>f.id===c[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=i;o==="Trigger"&&(i===1?e=!0:i===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const s=this.inputNameMap.get(t);s&&s.forEach(c=>this.setInternalInput(c,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),s&&s.forEach(c=>this.justFiredTriggers.add(c))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(c=>{if(c.inputId===t||c.name===t){const h=this.objectStates.get(c.id);h&&h.options&&(c.type==="ListView"||c.variant==="listview"?h.options.items=e:(c.type==="Dropdown"||c.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,i){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(s=>{if(s.trigger==="variable"&&s.conditionVariableId&&s.targetAnimationId&&(s.conditionVariableId===t||e&&e.includes(s.conditionVariableId))){const a=s.conditionOperator||"IsTrue",r=s.conditionValue;let c=!1;switch(a){case"Equal":case"==":c=i==r;break;case"NotEqual":case"!=":c=i!=r;break;case"GreaterThan":case">":c=i>r;break;case"LessThan":case"<":c=i<r;break;case"GreaterEqual":case">=":c=i>=r;break;case"LessEqual":case"<=":c=i<=r;break;case"IsTrue":c=!!i;break;case"IsFalse":c=!i;break}if(c){const h=s.delay||0;h<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const i=this.layerStates.get(t.name);if(!i||i.currentStateIds.length===0)return;const o=[];let e=!1;for(const s of i.currentStateIds){const n=t.states.find(r=>r.id===s);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(s)}if(!e){const s=this.findGlobalTransition(t,i.currentStateIds);s&&(o.length=0,o.push(s.targetStateId),e=!0,s.conditions&&(s.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(c=>c.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const s=Array.from(new Set(o));this.enterStates(t.name,s)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const i=(o=this.activeStateMachine)==null?void 0:o.inputs.find(s=>s.id===t);i&&this.inputNameMap.has(i.name)&&((e=this.inputNameMap.get(i.name))==null||e.forEach(s=>this.setInternalInput(s,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,i){for(const o of t.states)if(!(i.includes(o.id)&&this.justFiredTriggers.size===0)){for(const s of o.transitions||[])if(!(i.includes(s.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(s.conditions))return s}return null}checkConditions(t){return!t||t.length===0?!0:t.every(i=>{const o=i.inputId,e=i.op,s=i.value,n=this.evaluateLogicTree(o);if(n===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==s;break;case"NotEqual":case"!=":a=n!=s;break;case"GreaterThan":case">":a=n>s;break;case"LessThan":case"<":a=n<s;break;case"GreaterEqual":case">=":a=n>=s;break;case"LessEqual":case"<=":a=n<=s;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,i=null,o=new Set){var a,r,c,h,f,u;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(l=>l.id===t);if(e){const l=(p,y)=>{const b=e.inputs.find(m=>m.id===p);return b?b.sourceId?this.evaluateLogicTree(b.sourceId,b.sourceHandleId,o):b.value!==void 0?b.value:y:y};let d=0;switch(e.op){case wt.AND:d=l("a",!1)&&l("b",!1);break;case wt.OR:d=l("a",!1)||l("b",!1);break;case wt.NOT:d=!l("in",!1);break;case wt.XOR:d=!!l("a",!1)!=!!l("b",!1);break;case wt.OBJECT:d=e.name;break;case wt.PROPERTY:case wt.GET_PROPERTY:{const p=l("id","");if(!p){d=0;break}const y=e.name;if(!y||y==="GET_PROPERTY"||y==="PROPERTY"){d=0;break}const b=this.objectStates.get(p);if(!b){d=0;break}y in b?d=b[y]:d=this.resolvePath(b,y);break}case wt.SET_PROPERTY:{const p=l("id",""),y=l("value",void 0);if(!p||y===void 0){d=0;break}const b=e.name;if(!b||b==="SET_PROPERTY"){d=0;break}const m=this.objectStates.get(p);if(!m){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(b))m[b]=y,d=y;else{const S=b.split(".");let C=m;for(let I=0;I<S.length-1;I++){const M=S[I];C[M]===void 0&&(C[M]={}),C=C[M]}const w=S[S.length-1];C[w]=y,d=y}break}case wt.ADD:d=l("a",0)+l("b",0);break;case wt.SUB:d=l("a",0)-l("b",0);break;case wt.MUL:d=l("a",0)*l("b",0);break;case wt.DIV:{const p=l("b",1);d=p===0?0:l("a",0)/p;break}case wt.MOD:d=l("a",0)%l("b",1);break;case wt.POW:d=Math.pow(l("a",0),l("b",1));break;case wt.ABS:d=Math.abs(l("in",0));break;case wt.ROUND:d=Math.round(l("in",0));break;case wt.FLOOR:d=Math.floor(l("in",0));break;case wt.CEIL:d=Math.ceil(l("in",0));break;case wt.SIN:d=Math.sin(l("in",0));break;case wt.COS:d=Math.cos(l("in",0));break;case wt.TAN:d=Math.tan(l("in",0));break;case wt.CLAMP:{const p=l("in",0),y=l("min",0),b=l("max",1);d=Math.max(y,Math.min(b,p));break}case wt.REMAP:{const p=l("in",0),y=l("inMin",0),b=l("inMax",100),m=l("outMin",0),v=l("outMax",1);d=b===y?m:m+(p-y)*(v-m)/(b-y);break}case wt.EQ:d=l("a",0)==l("b",0);break;case wt.NEQ:d=l("a",0)!=l("b",0);break;case wt.GT:d=l("a",0)>l("b",0);break;case wt.LT:d=l("a",0)<l("b",0);break;case wt.GTE:d=l("a",0)>=l("b",0);break;case wt.LTE:d=l("a",0)<=l("b",0);break;case wt.IF_ELSE:d=l("cond",!1)?l("then",0):l("else",0);break;case wt.VALUE:d=e.value!==void 0?e.value:0;break;case wt.INPUT:d=this.inputs.get(e.name)??0;break;case wt.LOG:{const p=l("in","");this.debugLog(`[User Logic] ${p}`),d=p;break}case wt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case wt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case wt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case wt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case wt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case wt.EFFECTOR:{const p=l("id",""),y=l("intensity",1),b=l("trigger",!0);if(!p||!b){d=0;break}const m=e.name;if(!m){d=0;break}const v=this.objectStates.get(p);if(!v){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(m))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:m,intensity:y},d=1;else{v.behaviors||(v.behaviors=[]);let C=v.behaviors.find(w=>w.type===m);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=y):(C={id:`eff_${Date.now()}_${m}`,type:m,enabled:!0,sensors:[],settings:{intensity:y}},v.behaviors.push(C)),d=1}break}case wt.MONITOR:{d=l("in",0);break}case wt.SPRING_PULL:{const p=l("objectId",""),y=l("forceX",0),b=l("forceY",0);p&&((c=this.artboard)==null||c.objects.forEach(m=>{m.behaviors&&m.behaviors.forEach(v=>{var S;if(v.type===H.SpringChain&&((S=v.settings)!=null&&S.connections)&&(v.settings.connections.some(w=>w.targetId===p)||m.id===p)){this._springChainState.has(m.id)||this._springChainState.set(m.id,new Map);const w=this._springChainState.get(m.id);if(!w.has(p)){const M=this.objectStates.get(p);w.set(p,{x:(M==null?void 0:M.x)??0,y:(M==null?void 0:M.y)??0,vx:0,vy:0})}const I=w.get(p);I&&(I.vx+=y,I.vy+=b)}})})),d=1;break}case wt.SPRING_SETTLE:{const p=l("objectId","");let y=!0;if(p){const b=l("threshold",1);this._springChainState.forEach(m=>{const v=m.get(p);v&&(Math.abs(v.vx)>b||Math.abs(v.vy)>b)&&(y=!1)})}d=y;break}case wt.EMIT:{const p=l("objectId",""),y=l("count",20);p&&((h=this.artboard)==null||h.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(m=>{m.type===H.ParticleEmitter&&b.id===p&&(m._pendingBurst=(m._pendingBurst||0)+y)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===wt.DELAY){const p=l("delay",0),y=l("in",0);let b=this.logicNodeState.get(t);for(b||(b={queue:[]},this.logicNodeState.set(t,b)),b.queue.push({time:this.currentTime+p,value:y});b.queue.length>0&&b.queue[0].time<=this.currentTime;)b.lastValue=b.queue.shift().value;d=b.lastValue??0}return d}const s=(f=this.activeStateMachine)==null?void 0:f.inputs.find(l=>l.id===t||l.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const l=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,l),l}let n=this.inputs.get(t)??(s?this.inputs.get(s.id):void 0);if((this.justFiredTriggers.has(t)||s&&this.justFiredTriggers.has(s.id))&&(n=!0),i&&n!==void 0){const l=(u=this.activeStateMachine)==null?void 0:u.inputs.find(d=>d.id===t);if(l&&l.value.type==="Number"&&typeof n=="number"){const d=l.value.defaultValue??l.value.value;if(i==="source-greater")return n>d;if(i==="source-less")return n<d;if(i==="source-equal")return n===d}if(i==="source-true")return n===!0;if(i==="source-false")return n===!1;if(i==="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===wt.SET_PROPERTY||t.op===wt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,i){const o=i.split(".");let e=t;for(const s of o)if(e&&typeof e=="object"&&s in e)e=e[s];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(i=>{i.time=t,i.time>(i.duration||0)&&(i.animations.some(e=>{var s;return((s=e.state)==null?void 0:s.loop)===!0})?i.time%=i.duration||1:i.time=i.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&&(this.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 s=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&s!==null&&n!==null&&(a.x=s.x,a.y=s.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions());const i=[];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_")&&i.push(e))}o.animations.forEach(s=>{var n;(n=s.state)!=null&&n.isBlendState&&s.state.blendAnimations?this.applyBlendState(s.state,o.time):s.animation&&this.applyAnimation(s.animation,o.time,s.filterObjectIds)})}}),i.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 s,n,a,r,c,h,f;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.objects.find(u=>u.id===e))==null?void 0:n.triggers)==null||a.find(u=>u.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 u=(h=(c=(r=this.artboard)==null?void 0:r.objects.find(p=>p.id===e))==null?void 0:c.triggers)==null?void 0:h.find(p=>p.id===o.triggerId),l=(u==null?void 0:u.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=l;if((u==null?void 0:u.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((u==null?void 0:u.eventType)==="onHold"||(u==null?void 0:u.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(u!=null&&u.exitAnimationId){const p=(f=this.artboard)==null?void 0:f.animations.find(y=>y.id===u.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),this.processJoysticks(t),this.activeStateMachine&&this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues))}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(i=>{var e,s,n;const o=(e=i.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(i.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(i.id),c=(((s=i.geometry)==null?void 0:s.width)||100)*(r.scale_x||1),h=(((n=i.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),f=50,u=r.x+c/2>=-this.canvasWidth/2-f&&r.x-c/2<=this.canvasWidth/2+f&&r.y+h/2>=-this.canvasHeight/2-f&&r.y-h/2<=this.canvasHeight/2+f,l=`analytics_${i.id}`,d=this.wasInView.has(l);u&&!d&&this.fireAnalyticsEvent(i.id,"visible"),u?this.wasInView.add(l):this.wasInView.delete(l)}}}),this.artboard.objects.forEach(i=>{const o=i.interactions||[];o.length!==0&&o.forEach(e=>{const s=e.triggers||[e.event||e.trigger];s&&s.forEach(n=>{var r,c,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const f=e.intervalValue||2e3,u=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-u>=f&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const f=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=f&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const f=this.objectStates.get(i.id);if(f&&f.visible!==!1){const u=this.getGlobalTransform(i.id),l=(((r=i.geometry)==null?void 0:r.width)||100)*(u.scale_x||1),d=(((c=i.geometry)==null?void 0:c.height)||100)*(u.scale_y||1),p=50,y=u.x+l/2>=-this.canvasWidth/2-p&&u.x-l/2<=this.canvasWidth/2+p&&u.y+d/2>=-this.canvasHeight/2-p&&u.y-d/2<=this.canvasHeight/2+p,b=this.wasInView.has(i.id);y&&!b&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(i.id,"Scroll Into View"),y?this.wasInView.add(i.id):this.wasInView.delete(i.id)}}if(a==="scroll progress"||a==="scrollprogress"){const f=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),u=this.scrollProgressLastValue.get(e.id)||0;Math.abs(f-u)>.001&&(this.scrollProgressLastValue.set(e.id,f),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,f))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(i=>{if(!i.constraints||i.constraints.length===0)return;const o=this.objectStates.get(i.id);if(!o)return;const e=this.getGlobalTransform(i.id);if(i.constraints.forEach((s,n)=>{var h,f,u,l,d,p,y,b,m;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...s,...a},c=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const S=r.offsetX||0,C=r.offsetY||0,w=v.x+S,I=v.y+C,M=r.useSpring;if(M){const T=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:O,y:P,vx:_,vy:E}=this.computeSpring(e.x,e.y,T.vx,T.vy,w,I,r,t);r.copyX&&(e.x=e.x+(O-e.x)*c),r.copyY&&(e.y=e.y+(P-e.y)*c),this.objectVelocities.set(i.id,{vx:_,vy:E})}else r.copyX&&(e.x=e.x+(w-e.x)*c),r.copyY&&(e.y=e.y+(I-e.y)*c);let k=!1;if((f=r.limitX)!=null&&f.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(k=!0)}if((u=r.limitY)!=null&&u.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(k=!0)}k&&M&&this.objectVelocities.set(i.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const v=this.getGlobalTransform(r.targetId);if(v){let C=(v.rotation+(r.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*c}}else if(r.type==="Scale"){const v=this.getGlobalTransform(r.targetId);v&&(r.copyX&&(e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*c),r.copyY&&(e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*c))}else if(r.type==="Transform"){const v=this.getGlobalTransform(r.targetId);if(v){e.x=e.x+(v.x-e.x)*c,e.y=e.y+(v.y-e.y)*c;let S=(v.rotation-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*c,e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*c,e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*c}}else if(r.type==="FollowPointer"){const v=((l=this._lastPointerPos)==null?void 0:l.x)??e.x,S=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,C=r.useSpring;if(C){const I=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:M,y:k,vx:T,vy:O}=this.computeSpring(e.x,e.y,I.vx,I.vy,v,S,r,t);e.x=M,e.y=k,this.objectVelocities.set(i.id,{vx:T,vy:O})}else e.x=e.x+(v-e.x)*c,e.y=e.y+(S-e.y)*c;let w=!1;if((p=r.limitX)!=null&&p.enabled){const I=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==I&&(w=!0)}if((y=r.limitY)!=null&&y.enabled){const I=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==I&&(w=!0)}w&&C&&this.objectVelocities.set(i.id,{vx:0,vy:0})}else if(r.type==="Distance"){const v=this.getGlobalTransform(r.targetId);if(v){const S=e.x-v.x,C=e.y-v.y,w=Math.sqrt(S*S+C*C),I=r.distance||0;let M=w;switch(r.mode){case"exact":M=I;break;case"minimum":M=Math.max(I,w);break;case"maximum":M=Math.min(I,w);break;case"clamped":M=Math.max(0,Math.min(I,w));break}if(w>0){const k=e.x===v.x&&e.y===v.y?1:M/w;e.x=e.x+(v.x+S*k-e.x)*c,e.y=e.y+(v.y+C*k-e.y)*c}}}else if(r.type==="FollowPath"){const v=(b=this.artboard)==null?void 0:b.objects.find(S=>S.id===r.targetId);if(v){const S=this.getGlobalTransform(v.id);if(S){let C=v.geometry;if(v.type==="Frame"||v.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const F=(m=this.artboard)==null?void 0:m.objects.find(j=>j.parentId===v.id&&j.type==="Shape"&&j.geometry&&(j.geometry.type==="Path"||j.geometry.type==="Ellipse"||j.geometry.type==="Rectangle"));F&&(C=F.geometry)}if(!C)return;const w=(r.distance||0)/100,I=S.width||C.width||0,M=S.height||C.height||0,k=this.getPointOnPath(C,I,M,w),T=S.rotation*Math.PI/180,O=Math.cos(T),P=Math.sin(T),_=k.x*S.scale_x*O-k.y*S.scale_y*P,E=k.x*S.scale_x*P+k.y*S.scale_y*O;let A=S.rotation+(r.offsetRotation||0);if(r.orient){const F=Math.cos(k.angle),j=Math.sin(k.angle),X=F*S.scale_x*O-j*S.scale_y*P,tt=F*S.scale_x*P+j*S.scale_y*O;A=Math.atan2(tt,X)*180/Math.PI+(r.offsetRotation||0)}const W=A*Math.PI/180,z=Math.cos(W),Y=Math.sin(W),G=(r.offsetX||0)*z-(r.offsetY||0)*Y,N=(r.offsetX||0)*Y+(r.offsetY||0)*z,J=S.x+_+G,x=S.y+E+N;if(e.x=e.x+(J-e.x)*c,e.y=e.y+(x-e.y)*c,r.orient){let F=(A-e.rotation)%360;F>180&&(F-=360),F<-180&&(F+=360),e.rotation=e.rotation+F*c}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(i,v,r.boneCount||2,c)}}),i.constraints.some(s=>s.type!=="IK")){const s=this.globalToLocal(i.parentId,e);o.x=s.x,o.y=s.y,o.rotation=s.rotation,o.flip_x=s.scale_x<0,o.scale_x=Math.abs(s.scale_x),o.flip_y=s.scale_y<0,o.scale_y=Math.abs(s.scale_y)}})}getGlobalTransform(t){var f,u;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(f=this.artboard)==null?void 0:f.objects.find(l=>l.id===t),e=(o==null?void 0:o.type)==="Bone"?(u=o.geometry)==null?void 0:u.length:void 0;if(!o||!o.parentId)return{x:i.x,y:i.y,rotation:i.rotation,scale_x:(i.scale_x??1)*(i.flip_x?-1:1),scale_y:(i.scale_y??1)*(i.flip_y?-1:1),length:e};const s=this.getGlobalTransform(o.parentId),n=s.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),c=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*r),h=s.y+(i.x*s.scale_x*r+i.y*s.scale_y*a);return{x:c,y:h,rotation:s.rotation+i.rotation,scale_x:s.scale_x*(i.scale_x??1)*(i.flip_x?-1:1),scale_y:s.scale_y*(i.scale_y??1)*(i.flip_y?-1:1),length:e}}globalToLocal(t,i){if(!t)return i;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,s=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),c=i.x-o.x,h=i.y-o.y,f=(c*a-h*r)*e,u=(c*r+h*a)*s;return{x:f,y:u,rotation:i.rotation-o.rotation,scale_x:i.scale_x/(o.scale_x||1),scale_y:i.scale_y/(o.scale_y||1)}}solveIK(t,i,o,e){var c;const s=[];let n=t.id;for(let h=0;h<o&&n;h++){const f=(c=this.artboard)==null?void 0:c.objects.find(u=>u.id===n);if(!f)break;s.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=f.parentId}if(s.length<2)return;const a=s.reverse(),r=5;for(let h=0;h<r;h++){const f=this.getGlobalTransform(t.id);for(let u=a.length-2;u>=0;u--){const l=a[u],d=this.getGlobalTransform(l.id),p=f.x-d.x,y=f.y-d.y,b=i.x-d.x,m=i.y-d.y,v=Math.sqrt(p*p+y*y),S=Math.sqrt(b*b+m*m);if(v>.001&&S>.001){const C=Math.atan2(y,p);let I=(Math.atan2(m,b)-C)*180/Math.PI;I*=e;const M=this.objectStates.get(l.id);M&&(M.rotation+=I)}}}}computeSpring(t,i,o,e,s,n,a,r){const c=a.stiffness??100,h=a.damping??10,f=a.mass??1,u=-c*(t-s),l=-c*(i-n),d=-h*o,p=-h*e,y=(u+d)/f,b=(l+p)/f,m=o+y*r,v=e+b*r,S=t+m*r,C=i+v*r;return{x:S,y:C,vx:m,vy:v}}handlePointerInput(t,i,o,e,s){if(!this.artboard)return;const n=this.calculateTransform(e,s,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(i-n.tx)/n.scaleX,r=(o-n.ty)/n.scaleY;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this._prevPointerPos&&(this._mouseDelta.dx+=a-this._prevPointerPos.x,this._mouseDelta.dy+=r-this._prevPointerPos.y),this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,i){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:i},this._totalScroll.x+=t-o,this._totalScroll.y+=i-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,i){this._totalScroll.x+=t,this._totalScroll.y+=i,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,i,o){var r,c,h,f,u;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 s=(l,d)=>{var S;let p=d;d==="click"?p="onClick":d==="down"?p="onPointerDown":d==="up"?p="onPointerUp":d==="blur"&&(p="onPointerLeave");const y=new Set([p]);d==="move"&&y.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),p==="onClick"&&y.add("click"),p==="onPointerDown"&&y.add("pointerDown"),p==="onPointerUp"&&y.add("pointerUp");const b=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(l.type==="Component"&&b.includes(l.variant)||l.type==="Joystick"||b.includes((S=l.type)==null?void 0:S.toLowerCase())||(l.interactions||[]).some(C=>y.has(C.event))||(l.triggers||[]).some(C=>y.has(C.eventType)))};let n=null;for(let l=this.artboard.objects.length-1;l>=0;l--){const d=this.artboard.objects[l],p=this.objectStates.get(d.id);if(p&&p.visible!==!1&&p.opacity>0&&this.hitTest(d,i,o)&&(n||(n=d),s(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:i,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 l=this.artboard.objects.find(d=>d.id===this.draggingSliderId);l&&this.updateSliderValueFromPointer(l,i,o);return}if(this.draggingJoystickId){const l=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);l&&this.updateJoystickValueFromPointer(l,i,o);return}if(this.draggingListViewId){const l=this.artboard.objects.find(d=>d.id===this.draggingListViewId);l&&this.updateListViewScrollFromPointer(l);return}e&&(e.type==="ListView"||e.type==="Component"&&e.variant==="listview")&&this.updateListViewHoverFromPointer(e,i,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(this.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.draggingJoystickId=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(l=>l.type===H.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(l=>{l!==a&&this.activeHoverIds.delete(l)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const l=this.artboard.objects.find(d=>d.id===this.activeDropdownId);if(l&&(l.type==="Dropdown"||l.variant==="dropdown")){const d=this.objectStates.get(l.id),p=(d==null?void 0:d.options)||l.options||{},y=l.geometry||{},b=y.width??l.width??200,m=y.height??l.height??40,v=p.optionsList||[],S=p.itemHeight||32,C=p.listPadding??4,w=v.length*S+C*2,I=this.getWorldTransform(l.id),M=b*Math.abs(I.scaleX),k=m*Math.abs(I.scaleY),T=I.y+k/2+4,O=Math.abs(i-I.x)<=M/2,P=o>=T&&o<=T+w*Math.abs(I.scaleY);if(O&&P){const _=Math.abs(I.scaleY),E=o-(T+C*_),A=Math.floor(E/(S*_));if(A>=0&&A<v.length){const W=v[A];p.selectedOption=W,p.isOpen=!1,this.activeDropdownId=null,l.inputId&&this.setInternalInput(l.inputId,W),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"dropdown",property:"selectedOption",value:W})}return}else a!==this.activeDropdownId&&(p.isOpen=!1,this.activeDropdownId=null)}}if(e){let l=e,d=e;for(;d&&d.parentId;){const y=this.artboard.objects.find(b=>b.id===d.parentId);if(y&&y.type==="Component"){l=y;break}d=y}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),l!==e&&this.fireEventForObject(l.id,p),l.type==="Component"&&l.variant==="toggle_button"&&t==="down"){const y=this.objectStates.get(l.id),b=(y==null?void 0:y.options)||l.options||{};b.checked=!b.checked,l.inputId&&this.setInternalInput(l.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"toggle_button",property:"checked",value:b.checked}),this.fireEventForObject(l.id,"Toggle"),this.fireEventForObject(l.id,b.checked?"Toggle True":"Toggle False")}if(l.type==="Component"&&l.variant==="toggle"&&t==="down"){const y=this.objectStates.get(l.id),b=(y==null?void 0:y.options)||l.options||{};b.checked=!b.checked,l.inputId&&this.setInternalInput(l.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"toggle",property:"checked",value:b.checked}),this.onToggle&&this.onToggle(l.name,b.checked),this.fireEventForObject(l.id,"Toggle"),this.fireEventForObject(l.id,b.checked?"Toggle True":"Toggle False")}if(l.type==="Component"&&l.variant==="dropdown"&&t==="down"){const y=this.objectStates.get(l.id),b=(y==null?void 0:y.options)||l.options||{},m=!b.isOpen;if(m&&this.activeDropdownId&&this.activeDropdownId!==l.id){const v=this.artboard.objects.find(S=>S.id===this.activeDropdownId);v&&v.options&&(v.options.isOpen=!1)}b.isOpen=m,this.activeDropdownId=m?l.id:null}if(l.type==="Component"&&l.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(l.name,l.id),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"button",property:"click",value:!0})),(l.type==="ListView"||l.type==="Component"&&l.variant==="listview")&&t==="down"){this.draggingListViewId=l.id;const y=this.getListViewItemIndexAtPointer(l,i,o);if(y!==null){const b=l.options||{};b.activeItemIndex=y;const m=this.objectStates.get(l.id);m&&m.options&&(m.options.activeItemIndex=y);const v=(b.items||[])[y],S=typeof v=="string"?v:v.label||v.value||y;m&&m.options&&(m.options.selectedValue=S),l.inputId&&this.setInternalInput(l.inputId,S),this.onComponentChange&&(this.onComponentChange({objectId:l.id,componentName:l.name,variant:"listview",property:"activeItemIndex",value:y}),this.onComponentChange({objectId:l.id,componentName:l.name,variant:"listview",property:"selected",value:S}))}}if(l.type==="Component"&&l.variant==="slider"&&t==="down"&&(this.draggingSliderId=l.id,this.updateSliderValueFromPointer(l,i,o)),l.type==="Joystick"||l.type==="Component"&&l.variant==="joystick"){if(t==="down")this.draggingJoystickId=l.id,this.updateJoystickValueFromPointer(l,i,o);else if(t==="up"||t==="blur"){const y=this.objectStates.get(l.id);y&&l.isSpringReturn!==!1&&(y.handleX=0,y.handleY=0),l.isSpringReturn!==!1&&(l.handleX=0,l.handleY=0)}}if(l.type==="Component"&&l.variant==="checkbox"&&t==="down"){const y=this.objectStates.get(l.id),b=(y==null?void 0:y.options)||l.options||{};b.checked=!b.checked,l.inputId&&this.setInternalInput(l.inputId,b.checked),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"checkbox",property:"checked",value:b.checked}),this.fireEventForObject(l.id,"Click"),this.fireEventForObject(l.id,b.checked?"Checked":"Unchecked")}if(l.type==="Component"&&l.variant==="radiogroup"&&t==="down"){const y=this.objectStates.get(l.id),b=(y==null?void 0:y.options)||l.options||{},m=b.optionsList||[],v=this.getRadioGroupItemIndexAtPointer(l,i,o);if(v!==null&&v>=0&&v<m.length){const S=m[v];b.selectedValue=S,l.inputId&&this.setInternalInput(l.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"radiogroup",property:"selectedValue",value:S}),this.fireEventForObject(l.id,"Click"),this.fireEventForObject(l.id,`Selected: ${S}`)}}if(l.type==="LineGraph"&&(t==="down"||t==="click")){const y=l.geometry,b=(y==null?void 0:y.datasets)||[],m=this.objectStates.get(l.id),v=(m==null?void 0:m.width)||(y==null?void 0:y.width)||200,S=(m==null?void 0:m.height)||(y==null?void 0:y.height)||150,C=this.getWorldTransform(l.id),w=30,I=20,M=v-w,k=S-I;let T=1;b.forEach(_=>{const E=Math.max(..._.data||[0]);E>T&&(T=E)});let O=1/0,P=null;b.forEach((_,E)=>{const A=_.data||[],W=M/Math.max(A.length-1,1);A.forEach((z,Y)=>{const G=C.x-v/2+w+Y*W,N=C.y+S/2-I-z/T*k,J=Math.sqrt((i-G)**2+(o-N)**2);J<O&&(O=J,P={dIdx:E,pIdx:Y,val:z,label:_.label||`Dataset ${E+1}`})})}),P&&O<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:l.id,componentName:l.name,datasetIndex:P.dIdx,pointIndex:P.pIdx,value:P.val,label:P.label}),this.onComponentChange&&this.onComponentChange({objectId:l.id,componentName:l.name,variant:"linegraph",property:"click",value:(P==null?void 0:P.val)??null})}if(t==="click"){const y=(c=this.artboard)==null?void 0:c.objects.find(v=>v.id===e.id),b=this.focusedId,m=(y==null?void 0:y.type)==="InputBox"||(y==null?void 0:y.type)==="Component"&&y.variant==="inputbox";if(y&&m){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),b!==this.focusedId){if(b){const v=(h=this.artboard)==null?void 0:h.objects.find(S=>S.id===b);v&&this.onInputBlur&&this.onInputBlur(v.name)}this.onInputFocus&&this.onInputFocus(y.name)}}else if(this.focusedId=null,b){const v=(f=this.artboard)==null?void 0:f.objects.find(S=>S.id===b);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}else if(t==="click"){const l=this.focusedId;if(this.focusedId=null,l){const d=(u=this.artboard)==null?void 0:u.objects.find(p=>p.id===l);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const i=this.artboard.objects.find(a=>a.id===this.focusedId),o=(i==null?void 0:i.type)==="InputBox"||(i==null?void 0:i.type)==="Component"&&i.variant==="inputbox";if(!i||!o)return;const e=i.options||{};let s=e.text||"";if(t.key==="Backspace")s=s.slice(0,-1);else if(t.key==="Enter")if(e.multiline)s+=`
|
|
7
|
-
`;else{this.focusedId=null;return}else if(t.key.length===1)s+=t.key;else return;e.text=s;const n=i.geometry;n.textInputId&&this.updateInput(n.textInputId,s),this.onComponentChange&&this.onComponentChange({objectId:i.id,componentName:i.name,variant:"inputbox",property:"text",value:s}),this.onInputChange&&this.onInputChange(i.name,s),this.onInputUpdate&&this.onInputUpdate(this.focusedId,s)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}fireEventForObject(t,i){var h,f,u,l,d;const o=(h=this.artboard)==null?void 0:h.objects.find(p=>p.id===t);if(!o)return;const e=new Set([i,i.toLowerCase()]),s=i.toLowerCase();s==="onclick"||s==="click"||s==="onpointerdown"||s==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(s==="onpointerenter"||s==="hover"||s==="move")&&this.fireAnalyticsEvent(t,"hover"),s==="onclick"||s==="click"?(e.add("click"),e.add("onclick")):s==="onpointerdown"||s==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):s==="onpointerup"||s==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):s==="onpointerenter"||s==="hover"||s==="move"?(e.add("hover"),e.add("onpointerenter")):s==="onpointerleave"||s==="blur"?(e.add("onpointerleave"),e.add("blur")):s==="drag"||s==="ondrag"?(e.add("drag"),e.add("ondrag")):s==="toggle"||s==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):s==="toggle true"||s==="toggle_true"||s==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(s==="toggle false"||s==="toggle_false"||s==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(p=>{const y=p.triggers||[p.event||p.trigger||"click"];return((p.triggerLogic||"OR")==="AND"?y.every(v=>e.has(v.toLowerCase())):y.some(v=>e.has(v.toLowerCase())))?p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${i} -> 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,y=a.targetProperty;y&&this.updateObjectProperty(p,y,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,y=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;p==="__all__"?(u=(f=this.artboard)==null?void 0:f.animations)==null||u.forEach(b=>{this.triggerGlobalAnimation(b.id,y)}):p&&this.triggerGlobalAnimation(p,y)}else if(a.action==="setState"||a.action==="Set State"){const p=a.targetObjectId||o.id,b={...this.objectStates.get(p)||{},...a.value||{}};this.objectStates.set(p,b),this.log(`[Engine] State updated for ${p}:`,b)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const p=a.targetAnimationId;p==="__all__"?this.layerStates.forEach((y,b)=>{b.startsWith("global_")&&this.layerStates.delete(b)}):p&&this.layerStates.forEach((y,b)=>{b.startsWith(`global_${p}_`)&&this.layerStates.delete(b)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const p=a.targetState,y=this.activeStateMachine.layers.find(b=>b.states.some(m=>m.id===p||m.name===p));y&&(this.log(`[Engine] Switching Layer ${y.name} to State ${p}`),this.enterStates(y.name,[p]))}this.onTrigger&&this.onTrigger(i,a.action)}const c=(o.triggers||[]).find(p=>{const y=p.eventType.toLowerCase();let b=!1;return(e.has(y)||y==="click"&&e.has("onclick")||y==="hover"&&(e.has("onpointerenter")||e.has("hover"))||y==="pointerdown"&&e.has("onpointerdown")||y==="pointerup"&&e.has("onpointerup"))&&(b=!0),b&&p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):b});if(c&&c.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${c.eventType}) -> Animation ${c.entryAnimationId}`);const p=(d=(l=this.artboard)==null?void 0:l.animations)==null?void 0:d.find(y=>y.id===c.entryAnimationId);p&&(this.activeTriggers.set(o.id,{triggerId:c.id,animation:p,time:0,phase:"entry",elapsedHold:0,filterObjectId:c.targetObjectId}),this.onTrigger&&this.onTrigger(c.name,p.name))}}fireAnalyticsEvent(t,i){var r,c;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(c=o.style)==null?void 0:c.analytics;if(!e||!e.isEnabled||e.triggerType!==i)return;const s=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 f=this.inputs.get(h.value);n[h.key]=f!==void 0?f:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${s}" via ${i} 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",s,n),this.log(`[ExodeUI Analytics] GA4: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${s}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",s,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${s}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(s,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${s}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let i=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){i=!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)}}),!i&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,i,o=!1,e){if(!this.artboard)return;const s=this.artboard.animations.find(a=>a.id===t);if(!s)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:s,state:{loop:o},filterObjectIds:i}],time:0,duration:s.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${s.name} (Loop: ${o}, Sub-Anims: ${(i==null?void 0:i.length)||"All"})`)}handleAnimationFinished(t,i){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||i&&e.afterAnim===i)){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 u;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(u=this.artboard)==null?void 0:u.objects.find(l=>l.id===t);if(!o||!o.parentId)return{x:i.x,y:i.y,scaleX:i.scale_x??1,scaleY:i.scale_y??1,rotation:i.rotation??0};const e=this.getWorldTransform(o.parentId),s=e.rotation*(Math.PI/180),n=Math.cos(s),a=Math.sin(s),r=i.x*e.scaleX,c=i.y*e.scaleY,h=e.x+(r*n-c*a),f=e.y+(r*a+c*n);return{x:h,y:f,scaleX:(i.scale_x??1)*e.scaleX,scaleY:(i.scale_y??1)*e.scaleY,rotation:e.rotation+(i.rotation??0)}}hitTest(t,i,o){var v,S;if(!this.objectStates.get(t.id))return!1;const s=((v=t.geometry)==null?void 0:v.width)??t.width??100,n=((S=t.geometry)==null?void 0:S.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,c=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),u=Math.sin(h),l=r*f-c*u,d=r*u+c*f,p=a.scaleX,y=a.scaleY,b=s*Math.abs(p),m=n*Math.abs(y);return Math.abs(l)<=b/2&&Math.abs(d)<=m/2}updateSliderValueFromPointer(t,i,o){var I;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((I=t.geometry)==null?void 0:I.width)??t.width??200,a=this.getWorldTransform(t.id),r=i-a.x,c=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),u=Math.sin(h),l=r*f-c*u,d=s.thumbWidth??16,p=n-d;let b=(l+p/2)/p;b=Math.max(0,Math.min(1,b));const m=s.min??0,v=s.max??100,S=s.step||1;let C=m+b*(v-m);S>0&&(C=Math.round(C/S)*S),C=Math.max(m,Math.min(v,C));const w=e.options||{};w.value!==C&&(e.options={...w,value:C},t.inputId&&this.setInternalInput(t.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:C}))}updateJoystickValueFromPointer(t,i,o){var I,M;const e=this.objectStates.get(t.id);if(!e)return;const s=(e==null?void 0:e.width)!==void 0?e.width:((I=t.geometry)==null?void 0:I.width)??t.width??100,n=(e==null?void 0:e.height)!==void 0?e.height:((M=t.geometry)==null?void 0:M.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,c=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),u=Math.sin(h);let l=(r*f-c*u)/Math.max(.001,Math.abs(a.scaleX||1)),d=(r*u+c*f)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(l-=s/2,d-=n/2):t.handleOrigin==="bottom-right"&&(l+=s/2,d+=n/2);const p=Math.min(s,n)*.45,y=Math.min(s,n)*.15,b=p-y;let m=l/b,v=d/b;const S=Math.sqrt(m*m+v*v);t.boundsShape==="square"?(m=Math.max(-1,Math.min(1,m)),v=Math.max(-1,Math.min(1,v))):S>1&&(m/=S,v/=S),t.deadzone!==void 0&&S<t.deadzone?(m=0,v=0):(t.stepX!==void 0&&t.stepX>0&&(m=Math.round(m/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(v=Math.round(v/t.stepY)*t.stepY)),t.joystickType==="1D_X"?v=0:t.joystickType==="1D_Y"&&(m=0);const C=e.handleX,w=e.handleY;(C!==m||w!==v)&&(e.handleX=m,e.handleY=v,t.handleX=m,t.handleY=v)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(i=>{var a,r;if(i.type!=="Joystick"&&!(i.type==="Component"&&i.variant==="joystick"))return;const o=i,e=this.objectStates.get(o.id);if(!e)return;let s=e.handleX??o.handleX??0,n=e.handleY??o.handleY??0;if(((a=o.inputBinding)==null?void 0:a.type)==="keyboard"&&o.inputBinding.keyboardConfig){const c=o.inputBinding.keyboardConfig;let h=s,f=n;const l=(c.speed||5)*t;let d=!1;this.activeKeys.has(c.upKey.toLowerCase())&&(f-=l,d=!0),this.activeKeys.has(c.downKey.toLowerCase())&&(f+=l,d=!0),this.activeKeys.has(c.leftKey.toLowerCase())&&(h-=l,d=!0),this.activeKeys.has(c.rightKey.toLowerCase())&&(h+=l,d=!0),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const p=Math.sqrt(h*h+f*f);p>1&&(h/=p,f/=p),!d&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),s=h,n=f}else if(((r=o.inputBinding)==null?void 0:r.type)==="mouse"&&o.inputBinding.mouseConfig){const c=o.inputBinding.mouseConfig;let h=s,f=n;const u=c.sensitivity||.01,l=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;c.axisX&&(h+=this._mouseDelta.dx*u),c.axisY&&(f+=this._mouseDelta.dy*u),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const d=Math.sqrt(h*h+f*f);d>1&&(h/=d,f/=d),!l&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),s=h,n=f}if(e.handleX=s,e.handleY=n,o.handleX=s,o.handleY=n,o.bindings&&o.bindings.length>0){const c=Math.sqrt(s*s+n*n);let h=Math.atan2(n,s)*(180/Math.PI);h<0&&(h+=360),o.bindings.forEach(f=>{var d,p,y,b,m,v,S,C;let u=0;f.sourceAxis==="x"?u=o.invertX?-s:s:f.sourceAxis==="y"?u=o.invertY?-n:n:f.sourceAxis==="distance"?u=c:f.sourceAxis==="angle"&&(u=h);const l=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===f.targetObjectId);if(l){if(f.actionType==="bind"&&f.targetProperty&&f.isContinuous!==!1){const w=f.sourceMin??-1,I=f.sourceMax??1,M=f.targetMin??0,k=f.targetMax??100;let T=!!f.isContinuous,O=0,P=0;if(T){if((f.sourceAxis==="x"||f.sourceAxis==="y")&&M>=0){const E=Math.max(Math.abs(w),Math.abs(I))||1;P=u/E*k}else{let E=(u-w)/(I-w);E=Math.max(0,Math.min(1,E)),P=M+E*(k-M)}Math.abs(u)<.05&&(P=0)}else{const E=(u-w)/(I-w),A=Math.max(0,Math.min(1,E));O=M+A*(k-M),f.step&&f.step>0&&(O=Math.round(O/f.step)*f.step)}const _=this.objectStates.get(l.id);if(_){const E=f.isRelative!==!1,A=E?((p=l.transform)==null?void 0:p.x)??0:0,W=E?((y=l.transform)==null?void 0:y.y)??0:0,z=E?((b=l.transform)==null?void 0:b.rotation)??0:0,Y=E?((m=l.transform)==null?void 0:m.scale_x)??1:0,G=E?((v=l.transform)==null?void 0:v.scale_y)??1:0,N=E?((S=l.style)==null?void 0:S.opacity)??100:0,J=t*60,x=(F,j)=>{let X=O;if(T){const tt=`_internal_${F}_${f.id}`;let L=_[tt];L===void 0&&(L=_[F]??j),X=L+P*J,_[tt]=X,f.step&&f.step>0&&(X=Math.round(X/f.step)*f.step)}else X=j+O;_[F]=X};f.targetProperty==="x"||f.targetProperty==="transform.x"?x("x",A):f.targetProperty==="y"||f.targetProperty==="transform.y"?x("y",W):f.targetProperty==="rotation"||f.targetProperty==="r"||f.targetProperty==="transform.rotation"?x("rotation",z):f.targetProperty==="scaleX"||f.targetProperty==="transform.scale_x"?x("scale_x",Y):f.targetProperty==="scaleY"||f.targetProperty==="transform.scale_y"?x("scale_y",G):(f.targetProperty==="opacity"||f.targetProperty==="transform.opacity")&&x("opacity",N)}(C=l.physics)!=null&&C.enabled&&this.physicsEngine&&(f.targetProperty==="x"||f.targetProperty==="transform.x"||f.targetProperty==="y"||f.targetProperty==="transform.y")&&(f.targetProperty==="x"||f.targetProperty==="transform.x"?this.physicsEngine.applyForce(l.id,(O-((_==null?void 0:_.x)||0))*10,0):(f.targetProperty==="y"||f.targetProperty==="transform.y")&&this.physicsEngine.applyForce(l.id,0,(O-((_==null?void 0:_.y)||0))*10))}else if(f.actionType==="playAnimation"||f.actionType==="stopAnimation"||f.actionType==="pauseAnimation"){let w=!1;const I=f.threshold??0;f.condition==="always"?w=!0:f.condition===">"?w=u>I:f.condition==="<"?w=u<I:f.condition==="=="&&(w=Math.abs(u-I)<.01);const M=e[`_prev_src_${f.id}`]??u;let k=!1;f.condition==="always"?k=!0:f.condition===">"?k=M>I:f.condition==="<"?k=M<I:f.condition==="=="&&(k=Math.abs(M-I)<.01),e[`_prev_src_${f.id}`]=u,w&&!k&&f.targetAnimationId&&(f.actionType==="playAnimation"||f.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,i){var c,h,f,u,l,d,p,y;if(!t.blendAnimations||t.blendAnimations.length===0)return;let o=0,e=0;t.blendInputX&&(o=this.inputs.get(t.blendInputX)??0),t.blendInputY&&(e=this.inputs.get(t.blendInputY)??0);const s=[];let n=0;if(t.blendType==="1D"){const b=[...t.blendAnimations].sort((m,v)=>m.position[0]-v.position[0]);if(b.length===1){const m=(h=(c=this.artboard)==null?void 0:c.animations)==null?void 0:h.find(v=>v.id===b[0].animationId);m&&(s.push({anim:m,weight:1}),n=1)}else{let m=0;for(;m<b.length-1&&b[m+1].position[0]<o;)m++;if(m===b.length-1&&o>b[m].position[0]){const v=(u=(f=this.artboard)==null?void 0:f.animations)==null?void 0:u.find(S=>S.id===b[m].animationId);v&&(s.push({anim:v,weight:1}),n=1)}else{const v=b[m].position[0],S=b[m+1].position[0],C=(d=(l=this.artboard)==null?void 0:l.animations)==null?void 0:d.find(T=>T.id===b[m].animationId),w=(y=(p=this.artboard)==null?void 0:p.animations)==null?void 0:y.find(T=>T.id===b[m+1].animationId),I=Math.max(.001,S-v);let M=(o-v)/I;M=Math.max(0,Math.min(1,M));const k=1-M;C&&(s.push({anim:C,weight:k}),n+=k),w&&(s.push({anim:w,weight:M}),n+=M)}}}else t.blendAnimations.forEach(b=>{var w,I;const m=(I=(w=this.artboard)==null?void 0:w.animations)==null?void 0:I.find(M=>M.id===b.animationId);if(!m)return;const v=b.position[0]-o,S=b.position[1]-e,C=v*v+S*S;if(C<1e-4)s.push({anim:m,weight:1e4}),n+=1e4;else{const M=1/C;s.push({anim:m,weight:M}),n+=M}});if(n===0)return;s.forEach(b=>b.weight/=n);const a=new Map,r=b=>{let m=b.startsWith("#")?b.substring(1):b;return m.length===3&&(m=[m[0],m[0],m[1],m[1],m[2],m[2]].join("")),m="0x"+m,{r:m>>16&255,g:m>>8&255,b:m&255,a:1}};s.forEach(({anim:b,weight:m})=>{b.tracks&&b.tracks.forEach(v=>{var O,P;const S=v.object_id||v.objectId,C=v.property,w=(O=this.artboard)==null?void 0:O.objects.find(_=>_.id===S);if(((P=w==null?void 0:w.physics)==null?void 0:P.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const M=this.interpolate(v.keyframes,i);if(M===void 0)return;let k=a.get(S);k||(k=new Map,a.set(S,k));let T=k.get(C);if(!T){if(typeof M=="number")T={type:"number",value:0};else if(typeof M=="string"&&M.startsWith("#"))T={type:"color",value:M,colorAcc:{r:0,g:0,b:0,a:0}};else if(T={type:"number",value:M},m<.5)return;k.set(C,T)}if(T.type==="number"&&typeof M=="number")T.value+=M*m;else if(T.type==="color"&&typeof M=="string"&&T.colorAcc){const _=r(M);_&&(T.colorAcc.r+=_.r*m,T.colorAcc.g+=_.g*m,T.colorAcc.b+=_.b*m,T.colorAcc.a+=_.a*m)}else m>.5&&(T.value=M)})}),a.forEach((b,m)=>{var C;const v=this.objectStates.get(m),S=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===m);!v||!S||b.forEach((w,I)=>{let M=w.value;if(w.type==="color"&&w.colorAcc){const k=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),T=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),O=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");M=`#${k}${T}${O}`}if(I.includes(".")){const k=(I||"").split(".");let T=v;for(let O=0;O<k.length-1;O++){if(typeof T[k[O]]!="object"||T[k[O]]===null){let P=S;for(let _=0;_<=O;_++)P=P?P[k[_]]:null;if(k[O]==="corner_radius"||k[O]==="cornerRadius"){const _=typeof T[k[O]]=="number"?T[k[O]]:typeof P=="number"?P:0;T[k[O]]={tl:_,tr:_,bl:_,br:_}}else T[k[O]]=P?JSON.parse(JSON.stringify(P)):{}}T=T[k[O]]}T[k[k.length-1]]=M,k[k.length-1]==="color"&&(k[k.length-2]==="fill"||k[k.length-2]==="stroke")&&(T.type="Solid")}else I==="fill"?(v.style||(v.style={}),v.style.fill=M):I==="stroke"?(v.style||(v.style={}),v.style.stroke=M):v[I]=M})})}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var f,u,l;const s=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(s))return}else if(s!==o)return}const n=(f=this.artboard)==null?void 0:f.objects.find(d=>d.id===s),a=((u=n==null?void 0:n.physics)==null?void 0:u.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const c=this.objectStates.get(s);if(!c){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const h=this.interpolate(e.keyframes,i);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||s,p=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${p} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let p=c;for(let y=0;y<d.length-1;y++){if(typeof p[d[y]]!="object"||p[d[y]]===null){let b=n;for(let m=0;m<=y;m++)b=b?b[d[m]]:null;if(d[y]==="corner_radius"||d[y]==="cornerRadius"){const m=typeof p[d[y]]=="number"?p[d[y]]:typeof b=="number"?b:0;p[d[y]]={tl:m,tr:m,bl:m,br:m}}else p[d[y]]=b?JSON.parse(JSON.stringify(b)):{}}p=p[d[y]]}p[d[d.length-1]]=h,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(p.type="Solid")}else r==="fill"?(c.style||(c.style={}),c.style.fill=h):r==="stroke"?(c.style||(c.style={}),c.style.stroke=h):c[r]=h;if(this.physicsEngine&&((l=n==null?void 0:n.physics)!=null&&l.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(s,h*(Math.PI/180))}})}interpolate(t,i){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(i<=o.time)return o.value;if(i>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(i>=t[a].time&&i<t[a+1].time){o=t[a],e=t[a+1];break}const s=e.time-o.time;let n=(i-o.time)/s;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 c=e.value[r];return typeof a=="number"&&typeof c=="number"?a+(c-a)*n:n<.5?a:c}):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(c=>{const h=o.value[c],f=e.value[c];typeof h=="number"&&typeof f=="number"?a[c]=h+(f-h)*n:h===void 0?a[c]=f:f===void 0?a[c]=h:a[c]=n<.5?h:f}),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,i,o){var d,p;const e=((p=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:p.colors)||{},s=e[t]||t,n=e[i]||i,a=y=>{if(!y)return{r:0,g:0,b:0};const b=y.startsWith("#")?y.replace("#",""):"000000";return b.length===3?{r:parseInt(b[0]+b[0],16),g:parseInt(b[1]+b[1],16),b:parseInt(b[2]+b[2],16)}:{r:parseInt(b.substring(0,2),16),g:parseInt(b.substring(2,4),16),b:parseInt(b.substring(4,6),16)}},r=a(s),c=a(n),h=Math.round(r.r+(c.r-r.r)*o),f=Math.round(r.g+(c.g-r.g)*o),u=Math.round(r.b+(c.b-r.b)*o),l=y=>{const b=Math.max(0,Math.min(255,y)).toString(16);return b.length===1?"0"+b:b};return`#${l(h)}${l(f)}${l(u)}`}interpolateStops(t,i,o){return!t||!i||t.length!==i.length?o<.5?t:i:t.map((e,s)=>{const n=i[s];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,i,o){if(!t||!i||t.type!==i.type)return o<.5?t:i;const e={...t,opacity:(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,i.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&i.start&&(e.start=[t.start[0]+(i.start[0]-t.start[0])*o,t.start[1]+(i.start[1]-t.start[1])*o]),t.end&&i.end&&(e.end=[t.end[0]+(i.end[0]-t.end[0])*o,t.end[1]+(i.end[1]-t.end[1])*o]),t.center&&i.center&&(e.center=[t.center[0]+(i.center[0]-t.center[0])*o,t.center[1]+(i.center[1]-t.center[1])*o]),t.radius!==void 0&&i.radius!==void 0&&(e.radius=t.radius+(i.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,i.stops,o)),e}interpolateStroke(t,i,o){if(!t||!i)return o<.5?t:i;const e={...t};return e.width=(t.width??0)+((i.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o,t.fill&&i.fill?e.fill=this.interpolateFill(t.fill,i.fill,o):t.color&&i.color&&t.color.startsWith("#")&&i.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,i.color,o)),e.trimStart=(t.trimStart??0)+((i.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((i.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((i.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((i.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,i,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=i,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,i,o);const s=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(i,o,s,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),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(0,0,s,n)),this.artboard.backgroundImage){const u=this.artboard.backgroundImage;let l=this.imageCache.get(u);if(l||(l=new Image,l.src=u,this.imageCache.set(u,l)),l.complete&&l.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=l.naturalWidth/l.naturalHeight,p=s/n;let y,b,m,v;p>d?(y=s,b=s/d):(b=n,y=n*d),m=(s-y)/2,v=(n-b)/2,t.drawImage(l,m,v,y,b),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,s,n),t.clip());const c=new Map;this.artboard.objects.forEach(u=>c.set(u.id,u)),this.artboard.objects.filter(u=>!u.parentId).map((u,l)=>{const d=this.objectStates.get(u.id),p=(d==null?void 0:d.zIndex)??l;return{obj:u,zIndex:p}}).sort((u,l)=>u.zIndex-l.zIndex).forEach(({obj:u})=>{this.renderObject(t,u,c)}),this._emitterPools.forEach((u,l)=>{if(!(u.length===0||!c.get(l)))for(const p of u)t.save(),t.globalAlpha=p.opacity,t.fillStyle=p.color,t.beginPath(),t.arc(p.x,p.y,Math.max(1,p.size*p.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&this.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,i,o,e,s,n=0){const a=t.getTransform(),r=i*a.a+o*a.c+a.e,c=i*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),f=Math.sqrt(a.c*a.c+a.d*a.d),u=(e/2+n)*h,l=(s/2+n)*f;return r+u>=0&&r-u<=this.canvasWidth&&c+l>=0&&c-l<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,r=1,c=1;const h=o/e,f=t/i;switch(s){case"Contain":f>h?c=i/e:c=t/o,a=r=c;break;case"Cover":f>h?c=t/o:c=i/e,a=r=c;break;case"Fill":a=t/o,r=i/e;break;case"FitWidth":c=t/o,a=r=c;break;case"FitHeight":c=i/e,a=r=c;break;case"None":a=r=1;break;case"ScaleDown":c=Math.min(t/o,i/e),c>1&&(c=1),a=r=c;break;default:a=r=1;break}const u=o*a,l=e*r;let d=0,p=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-u:d=(t-u)/2,n.includes("Top")?p=0:n.includes("Bottom")?p=i-l:p=(i-l)/2,{scaleX:a,scaleY:r,tx:d,ty:p}}mapFontWeight(t){const i=t.toLowerCase();return i==="thin"||i==="100"?"100":i==="extralight"||i==="200"?"200":i==="light"||i==="300"?"300":i==="regular"||i==="normal"||i==="400"?"400":i==="medium"||i==="500"?"500":i==="semibold"||i==="600"?"600":i==="bold"||i==="700"?"700":i==="extrabold"||i==="800"?"800":i==="black"||i==="900"?"900":t}drawTextDecoration(t,i,o,e,s,n){t.beginPath();const a=Math.max(1,n/14);let r=e;i==="underline"?r=e+n*.12:i==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-s/2,r),t.lineTo(o+s/2,r),t.stroke()}renderObject(t,i,o){var p,y,b,m,v,S,C,w,I,M,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j;const e=this.objectStates.get(i.id);if(!e){this.warn("No state for object:",i.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(X,tt,L,R,D)=>(this.drawRoundRect(t,X,tt,L,R,D),t));const s=e.geometry?this.deepMerge(i.geometry,e.geometry):i.geometry;let n=e.style?this.deepMerge(i.style,e.style):i.style,a=(s==null?void 0:s.width)||((p=i.geometry)==null?void 0:p.width)||i.width||0,r=(s==null?void 0:s.height)||((y=i.geometry)==null?void 0:y.height)||i.height||0;if((a===0||r===0)&&(s!=null&&s.points)&&Array.isArray(s.points)&&s.points.length>0){let X=1/0,tt=-1/0,L=1/0,R=-1/0;s.points.forEach(D=>{X=Math.min(X,D.x),tt=Math.max(tt,D.x),L=Math.min(L,D.y),R=Math.max(R,D.y)}),a===0&&(a=tt-X),r===0&&(r=R-L)}const c=X=>{if(X)return X.corner_radius??X.cornerRadius},h=c(e)??c(n)??c(s)??c(i.style)??c(i.geometry)??0;let f={...s,width:a,height:r};if(delete f.cornerRadius,f.corner_radius=h,f.type==="Path"&&i.weights&&i.bindMatrices&&f.points){const X=this.getGlobalTransform(i.id);if(X){const tt=ii(f.points,i.weights,i.bindMatrices,X,L=>this.getGlobalTransform(L));f={...f,points:tt}}}if(e.visible===!1)return;const u=i.repeaterConfig,l=u&&u.isEnabled&&u.count>1,d=l?u.count:1;for(let X=0;X<d;X++){let tt=e.x!==void 0?e.x:((b=e.transform)==null?void 0:b.x)??0,L=e.y!==void 0?e.y:((m=e.transform)==null?void 0:m.y)??0,R=e.rotation!==void 0?e.rotation:((v=e.transform)==null?void 0:v.rotation)??0,D=e.scale_x!==void 0?e.scale_x:((S=e.transform)==null?void 0:S.scale_x)??1,q=e.scale_y!==void 0?e.scale_y:((C=e.transform)==null?void 0:C.scale_y)??1;if(l&&X>0){if(u.type==="Linear"){const ft=u.offsetX||0,ut=u.offsetY||0,at=u.rotation||0,B=u.scale!==void 0?u.scale:1;tt+=X*ft,L+=X*ut,R+=X*at,D*=Math.pow(B,X),q*=Math.pow(B,X)}else if(u.type==="Grid"){const ft=u.cols||Math.ceil(Math.sqrt(u.count)),ut=u.gapX||0,at=u.gapY||0,B=Math.floor(X/ft),et=X%ft,Q=a+ut,Pt=r+at;tt+=et*Q,L+=B*Pt}else if(u.type==="Radial"){const ft=u.radius||100,ut=u.startAngle||0,B=(u.endAngle||360)-ut,et=u.count>1?B/(B===360?u.count:u.count-1):0,Q=ut+X*et,Pt=Q*Math.PI/180;tt=e.x+ft*Math.cos(Pt),L=e.y+ft*Math.sin(Pt),R+=Q}}const ot=i.type==="Group"||i.type==="Frame"||i.type==="Component",yt=a>0&&r>0;if(!ot&&yt){const ft=(((w=n.shadow)==null?void 0:w.isEnabled)!==!1?(((I=n.shadow)==null?void 0:I.blur)||0)+10:0)+(((M=n.blur)==null?void 0:M.isEnabled)!==!1&&((k=n.blur)==null?void 0:k.radius)||0)+20;if(!this.isObjectInView(t,tt,L,a,r,ft))continue}this.debug_objectsRendered++,t.save();const bt=[],gt=n.blur||((T=i.style)==null?void 0:T.blur);gt&>.amount>0&&bt.push(`blur(${gt.amount}px)`);const Et=n.effects||((O=i.style)==null?void 0:O.effects)||[];let It=Et.find(ft=>ft.isEnabled!==!1&&(ft.type==="BackgroundBlur"||ft.type==="LayerBlur"));It||(It=n.effect||((P=i.style)==null?void 0:P.effect)||Et.find(ft=>ft.isEnabled!==!1));const vt=It,Dt=(vt==null?void 0:vt.isEnabled)!==!1,ae=vt==null?void 0:vt.type,pe=(vt==null?void 0:vt.radius)??10;Dt&&ae==="LayerBlur"?bt.push(`blur(${pe}px)`):Dt&&ae==="BackgroundBlur"&&(n===i.style&&(n={...n}),n.fill={type:"None"});const st=((_=s==null?void 0:s.type)==null?void 0:_.toLowerCase().includes("image"))||((E=i.type)==null?void 0:E.toLowerCase().includes("image")),mt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Rt=s!=null&&s.adjustments&&Object.keys(s.adjustments).length>0?s.adjustments:null,_t=st?Rt||mt:mt||Rt,dt=st&&!_t?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:_t;if(e&&dt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...dt}),dt){const ft=(dt.exposure||0)/100,ut=dt.contrast||0,at=1+(dt.saturation||0)/100,B=(dt.temperature||0)/200,et=(dt.tint||0)/200,Q=(dt.highlights||0)/500,Pt=(dt.shadows||0)/500;let Ot="",kt="SourceGraphic";if(ft!==0&&(Ot+=`
|
|
8
|
-
<feComponentTransfer in="${
|
|
9
|
-
<feFuncR type="linear" slope="1" intercept="${
|
|
10
|
-
<feFuncG type="linear" slope="1" intercept="${
|
|
11
|
-
<feFuncB type="linear" slope="1" intercept="${
|
|
12
|
-
</feComponentTransfer>`,
|
|
13
|
-
<feComponentTransfer in="${
|
|
14
|
-
<feFuncR type="linear" slope="${
|
|
15
|
-
<feFuncG type="linear" slope="${
|
|
16
|
-
<feFuncB type="linear" slope="${
|
|
17
|
-
</feComponentTransfer>`,
|
|
18
|
-
<feColorMatrix in="${
|
|
19
|
-
values="${
|
|
20
|
-
0 ${
|
|
21
|
-
0 0 ${
|
|
22
|
-
0 0 0 1 0"/>`,kt="invert"}if(B!==0||et!==0||Q!==0||Pt!==0){const Mt=1+Q+Pt,$=Mt*(1+B-et/2),Yt=Mt*(1+et),jt=Mt*(1-B-et/2),ie=dt.shadows*.1/255,te=[$,0,0,0,ie,0,Yt,0,0,ie,0,0,jt,0,ie,0,0,0,1,0].join(" ");Ot+=`<feColorMatrix in="${kt}" type="matrix" values="${te}" result="advanced"/>`,kt="advanced"}if(dt.blur&&(Ot+=`<feGaussianBlur in="${kt}" stdDeviation="${dt.blur}" result="blur"/>`,kt="blur"),Ot){const Mt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Ot}</filter></svg>`,$=btoa(Mt);bt.push(`url('data:image/svg+xml;base64,${$}#f')`)}}bt.length>0?t.filter=bt.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const $t=t.globalAlpha,Vt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=$t*Vt;const Bt=e.compositeOperation||e.blendMode;if(Bt&&Bt!=="Normal"){const ft=Bt.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(ft)&&(t.globalCompositeOperation=ft)}const Ft=t,Ut=e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[]);let re=!1;const be=Ut.filter(ft=>ft.isVisible!==!1&&o.has(ft.maskId));if(be.length>0){const ft=be[0],ut=o.get(ft.maskId),at=this.objectStates.get(ut.id);at&&at.visible!==!1&&(re=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),i.parentId&&this.applyAbsoluteTransform(this.maskCtx,i.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=Ft.filter)}t.translate(Math.round(tt),Math.round(L)),t.rotate(R*Math.PI/180);const ve=e.skew_x||0,Zt=e.skew_y||0;if(ve!==0||Zt!==0){const ft=Math.tan(ve*Math.PI/180),ut=Math.tan(Zt*Math.PI/180);t.transform(1+ft*ut,ut,ft,1,0,0)}const Ce=e.rotate_x!==void 0?e.rotate_x:((A=e.transform)==null?void 0:A.rotate_x)??0,_e=e.rotate_y!==void 0?e.rotate_y:((W=e.transform)==null?void 0:W.rotate_y)??0,we=1+(e.translate_z!==void 0?e.translate_z:((z=e.transform)==null?void 0:z.translate_z)??0)/1e3,Ee=(e.flip_x===!0?-1:1)*Math.cos(_e*Math.PI/180)*we,Ae=(e.flip_y===!0?-1:1)*Math.cos(Ce*Math.PI/180)*we;t.scale(D*Ee,q*Ae),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 oe=n.shadow;if(oe&&oe.isEnabled!==!1){let ft=oe.color||"#000000";(G=(Y=this.artboard)==null?void 0:Y.tokens)!=null&&G.colors&&this.artboard.tokens.colors[ft]&&(ft=this.artboard.tokens.colors[ft]);const ut=this.normalizeOpacity(oe.opacity??100),at=oe.spread||0,et=(oe.blur||0)+at*1.5;let Q=ft;if(ft.startsWith("#")){const kt=ft.replace("#",""),At=parseInt(kt.substring(0,2),16),Mt=parseInt(kt.substring(2,4),16),$=parseInt(kt.substring(4,6),16);Q=`rgba(${At}, ${Mt}, ${$}, ${ut})`}else if(ft.startsWith("rgba")){const kt=ft.match(/[\d.]+/g);if(kt&&kt.length>=4){const At=kt[0],Mt=kt[1],$=kt[2],Yt=kt[3];Q=`rgba(${At}, ${Mt}, ${$}, ${parseFloat(Yt)*ut})`}}const Pt=t.getTransform(),Ot=Math.sqrt(Pt.a*Pt.a+Pt.b*Pt.b)||1;t.shadowColor=Q,t.shadowBlur=et*Ot,t.shadowOffsetX=(oe.offsetX||0)*Ot,t.shadowOffsetY=(oe.offsetY||0)*Ot}const se=i.liquidFill||((N=i.style)==null?void 0:N.liquidFill);if(se&&se.enabled){t.save();const ft=se.fillLevel??.5;t.beginPath();const ut=r/2-r*ft;t.rect(-a/2,ut,a,r*ft),t.clip(),t.fillStyle=se.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(se.opacity??1)}if((s==null?void 0:s.type)==="Text")this._renderText(t,i,f,n,e,a,r,!1,!1,D,q);else if((s==null?void 0:s.type)==="Image"){const ft=s.originalSrc||s.src;if(ft){let ut=this.imageCache.get(ft);ut||(ut=new Image,ut.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${ut.naturalWidth}x${ut.naturalHeight}`)},ut.onerror=et=>{console.error("[ExodeUI] Image load failed:",et,`Src preview: ${ft.substring(0,100)}...`)},ut.src=ft,this.imageCache.set(ft,ut));const at=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,B=(((J=n.stroke)==null?void 0:J.alignment)||"center").toLowerCase();if(at&&(B==="outside"||B==="center")&&this.applyStrokeAlignment(t,n,f,a,r,h,D,q),n.fill&&n.fill.type!=="None"){t.save();const et=t.globalAlpha,Q=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Q||n.fill.color||"transparent",t.globalAlpha=et*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=et,t.restore()}ut.complete&&ut.naturalWidth>0?(h!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.clip(),t.drawImage(ut,-a/2,-r/2,a,r),t.restore()):t.drawImage(ut,-a/2,-r/2,a,r),at&&B==="inside"&&this.applyStrokeAlignment(t,n,f,a,r,h,D,q)):at&&B==="inside"&&this.applyStrokeAlignment(t,n,f,a,r,h,D,q)}}else if(s.type==="SVG"){const ft=s.svgContent;if(ft){const ut=n.palette||[],at=n.fill,B=n.stroke,et=at?this.normalizeOpacity(at.opacity??100):1,Q=(at==null?void 0:at.type)==="Solid"&&(!B||B.isEnabled===!1||B.type==="Solid"&&B.color===at.color),Pt=at&&at.type!=="None"?Q?"monochrome":at.type==="Solid"?(at.color||"")+"|opacity:"+et:JSON.stringify(at.stops||[])+"|opacity:"+et:"",Ot=B&&B.isEnabled!==!1&&(B.width||0)>0?Q?["monochrome",B.width||0,B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):[B.width||0,B.fill?B.fill.type==="Solid"?B.fill.color||"":JSON.stringify(B.fill.stops||[]):B.color||"",B.opacity??1,B.lineCap||"",B.lineJoin||"",(B.dashArray||[]).join(","),B.trimStart??0,B.trimEnd??1,B.trimOffset??0,B.dashOffset??0].join("|"):"nostroke",kt=[i.id,ut.join("_"),Pt,Ot,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let At=this.imageCache.get(kt);if(!At){At=new Image,At.crossOrigin="anonymous";let $=ft;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(rt,V)=>`<svg xmlns="http://www.w3.org/2000/svg"${V}>`));let Yt=s.width||a||100,jt=s.height||r||100;const ie=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie&&(Yt=parseFloat(ie[1]),jt=parseFloat(ie[2])),$=$.replace(/<svg([^>]*)>/i,(rt,V)=>{let it=V.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return it.match(/\bviewBox=/i)||(it+=` viewBox="0 0 ${Yt} ${jt}"`),it.match(/\bpreserveAspectRatio=/i)||(it+=' preserveAspectRatio="none"'),it+=' width="100%" height="100%"',`<svg${it}>`}),s.colors&&s.colors.length>0&&ut.length>0&&s.colors.forEach((rt,V)=>{if(ut[V]){const it=rt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),nt=new RegExp(it,"gi");$=$.replace(nt,ut[V])}}),at&&at.type&&at.type!=="None"){if(at.type==="Solid"&&at.color){const rt=Q?"#FFFFFF":at.color,V=Q?1:this.normalizeOpacity(at.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,it=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(it)?it:`fill="${rt}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,it=>/fill\s*:\s*(none|transparent)/i.test(it)?it:`fill:${rt}`),V<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${V}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${V}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${V}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(at.type==="LinearGradient"||at.type==="RadialGradient"||at.type==="Linear"||at.type==="Radial"){const rt="exode-fill",V=this.normalizeOpacity(at.opacity??100),it=(at.stops||[]).map(St=>{const Gt=St.offset!==void 0?St.offset:St.pos??0,ee=this.normalizeOpacity(St.opacity??100)*V;return`<stop offset="${Gt*100}%" stop-color="${St.color||"#000"}" stop-opacity="${ee}"/>`}).join("");let nt="";if(at.type==="LinearGradient"||at.type==="Linear"){const St=(Kt,qt)=>Array.isArray(Kt)?Kt[qt]??(qt===0?0:1):Kt&&typeof Kt=="object"?Kt[qt===0?"x":"y"]??(qt===0?0:1):qt===0?0:1,Gt=St(at.start,0)*100,ee=St(at.start,1)*100,le=St(at.end,0)*100,Nt=St(at.end,1)*100;nt=`<linearGradient id="${rt}" x1="${Gt}%" y1="${ee}%" x2="${le}%" y2="${Nt}%" gradientUnits="objectBoundingBox">${it}</linearGradient>`}else{const St=(Nt,Kt)=>Array.isArray(Nt)?Nt[Kt]??.5:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??.5:.5,Gt=St(at.center,0)*100,ee=St(at.center,1)*100,le=(at.radius??.5)*100;nt=`<radialGradient id="${rt}" cx="${Gt}%" cy="${ee}%" r="${le}%" gradientUnits="objectBoundingBox">${it}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${nt}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${nt}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,St=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(St)?St:`fill="url(#${rt})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,St=>/fill\s*:\s*(none|transparent)/i.test(St)?St:`fill:url(#${rt})`)}}const te=(rt,V,it=1)=>{const nt=(rt.stops||[]).map(Nt=>{const Kt=Nt.offset!==void 0?Nt.offset:Nt.pos??0,qt=this.normalizeOpacity(Nt.opacity??100)*it;return`<stop offset="${Kt*100}%" stop-color="${Nt.color||"#000"}" stop-opacity="${qt}"/>`}).join(""),St=(Nt,Kt,qt=.5)=>Array.isArray(Nt)?Nt[Kt]??qt:Nt&&typeof Nt=="object"?Nt[Kt===0?"x":"y"]??qt:qt;if(rt.type==="LinearGradient"||rt.type==="Linear"){const Nt=St(rt.start,0,0)*100,Kt=St(rt.start,1,0)*100,qt=St(rt.end,0,1)*100,Ie=St(rt.end,1,1)*100;return`<linearGradient id="${V}" x1="${Nt}%" y1="${Kt}%" x2="${qt}%" y2="${Ie}%" gradientUnits="objectBoundingBox">${nt}</linearGradient>`}const Gt=St(rt.center,0,.5)*100,ee=St(rt.center,1,.5)*100,le=(rt.radius??.5)*100;return`<radialGradient id="${V}" cx="${Gt}%" cy="${ee}%" r="${le}%" gradientUnits="objectBoundingBox">${nt}</radialGradient>`},pt=(rt,V)=>/<defs>/i.test(rt)?rt.replace(/<defs>/i,`<defs>${V}`):rt.replace(/(<svg[^>]*>)/i,`$1<defs>${V}</defs>`);if(B&&B.isEnabled!==!1&&(B.width||0)>0){const rt=Q?1:this.normalizeOpacity(B.opacity??100),V=Q?"#FFFFFF":B.color||(at==null?void 0:at.color)||"#000000";let it="";const nt=B.fill;if(nt&&nt.type){if(nt.type==="Solid")it=nt.color||B.color||"#000000";else if(nt.type==="LinearGradient"||nt.type==="RadialGradient"||nt.type==="Linear"||nt.type==="Radial"){const Ht="exode-stroke";$=pt($,te(nt,Ht,rt)),it=`url(#${Ht})`}}it||(it=V),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Ht=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Ht)?Ht:`stroke="${it}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${it}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${it}`);let St=s.width||a||100,Gt=s.height||r||100;const ee=ft.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ee){const Ht=parseFloat(ee[1]),ce=parseFloat(ee[2]);!isNaN(Ht)&&!isNaN(ce)&&(St=Ht,Gt=ce)}const le=Math.max(.001,a/St),Nt=Math.max(.001,r/Gt),Kt=(le+Nt)/2,qt=(B.width||1)/Kt;$.match(/\bstroke-width\s*=\s*["']/i)?$=$.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${qt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${qt}"`),$=$.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${qt}`),$.match(/\bstroke-opacity\s*=\s*["']/i)?$=$.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${rt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${rt}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${rt}`);const Ie=B.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Ie}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Ie}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Ie}`);const xe=B.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${xe}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${xe}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${xe}`);const Oe=B.trimStart??0,Le=B.trimEnd??1,Re=B.trimOffset??0,Fe=B.dashOffset??0,Xe=Oe!==0||Le!==1||Re!==0||Fe!==0;if(Xe){const Ht=Math.max(0,Math.min(1,Oe)),ce=Math.max(0,Math.min(1,Le));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Ht}, End: ${ce}`);const Me=(St+Gt)*2,$e=(Re%1+1)%1,Be=(Fe%1+1)%1;let ge="",de=0;if(Ht>=ce)ge=`0 ${Me}`,de=0;else{const ue=Me*(ce-Ht),ke=Me-ue;de=-(Me*(Ht+$e+Be)),ge=`${ue} ${ke}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ge}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ge}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ge}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${de}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${de}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${de}`)}else if(B.dashArray&&B.dashArray.length>0){const Ht=B.dashArray.join(" ");$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Ht}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Ht}`),B.dashOffset&&($=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${B.dashOffset}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${B.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(ft)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(ft)){let Ht="",ce="";if(Xe){const ge=s.width||a||100,de=s.height||r||100,ue=(ge+de)*2,ke=Math.max(0,Math.min(1,Oe)),De=Math.max(0,Math.min(1,Le)),qe=(Re%1+1)%1,Ke=(Fe%1+1)%1;if(ke>=De)Ht=` stroke-dasharray="0 ${ue}"`,ce=' stroke-dashoffset="0"';else{const Ge=ue*(De-ke),Je=ue-Ge,U=-(ue*(ke+qe+Ke));Ht=` stroke-dasharray="${Ge} ${Je}"`,ce=` stroke-dashoffset="${U}"`}}else(x=B.dashArray)!=null&&x.length&&(Ht=` stroke-dasharray="${B.dashArray.join(" ")}"`,B.dashOffset&&(ce=` stroke-dashoffset="${B.dashOffset}"`));const Me=` stroke-linecap="${B.lineCap||"round"}"`,$e=` stroke-linejoin="${B.lineJoin||"round"}"`,Be=`stroke="${it}" stroke-width="${qt}" stroke-opacity="${rt}"${Me}${$e}${Ht}${ce}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ge,de,ue)=>`${de}${ue}<g ${Be}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else B&&B.isEnabled===!1&&($=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const ct=new Blob([$],{type:"image/svg+xml"}),Ct=URL.createObjectURL(ct);At.onload=()=>{if(URL.revokeObjectURL(Ct),this.frameCount%900===0){const rt=this.imageCache.get(kt);rt&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${rt.naturalWidth}x${rt.naturalHeight})`)}},At.onerror=()=>{URL.revokeObjectURL(Ct),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},At.src=Ct,this.imageCache.set(kt,At)}let Mt=null;if(At.complete&&At.naturalWidth>0?(Mt=At,this.lastValidSvgImgMap.set(i.id,At)):Mt=this.lastValidSvgImgMap.get(i.id)||null,Mt&&Mt.complete&&Mt.naturalWidth>0){const $=Math.max(1,a),Yt=Math.max(1,r);if(Q&&(at==null?void 0:at.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=Yt,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,$,Yt),this.maskCtx.drawImage(Mt,0,0,$,Yt),this.maskCtx.globalCompositeOperation="source-in";const jt=at.color||"#000000",ie=this.normalizeOpacity(at.opacity??100);this.maskCtx.fillStyle=jt,this.maskCtx.globalAlpha=ie,this.maskCtx.fillRect(0,0,$,Yt),t.drawImage(this.maskBuffer,-$/2,-Yt/2,$,Yt)}else h!==0?(t.save(),this.drawRoundRect(t,-$/2,-Yt/2,$,Yt,h),t.clip(),t.drawImage(Mt,-$/2,-Yt/2,$,Yt),t.restore()):t.drawImage(Mt,-$/2,-Yt/2,$,Yt)}}}else if(f.type==="LineGraph")this.renderLineGraph(t,f,a,r);else if(i.type==="Shape"){if(this.applyPath(t,f,a,r,h),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),Dt&&ae==="BackgroundBlur")this.applyBackgroundBlurGlass(t,f,a,r,h,vt);else if(n.fill){const ut=t.globalAlpha;if(((F=n.fill)==null?void 0:F.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const at=n.fill.originalSrc||n.fill.src;let B=this.imageCache.get(at);B||(B=new Image,B.src=at,this.imageCache.set(at,B)),B.complete&&B.naturalWidth>0&&(t.save(),this.applyPath(t,f,a,r,h),t.clip(),this.renderFittedImage(t,B,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const at=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=at||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=ut*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,f,a,r,h),t.fill()}t.globalAlpha=ut}t.restore(),n.stroke&&n.stroke.width>0&&(this.applyPath(t,f,a,r,h),this.applyStrokeAlignment(t,n,f,a,r,h,D,q))}else if(i.type==="Frame"||i.type==="Group"&&!i.isStructuralGroup){const ft=e.width??s.width??i.width??a,ut=e.height??s.height??i.height??r,at=h;if(t.save(),t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),Dt&&ae==="BackgroundBlur")this.applyBackgroundBlurGlass(t,f,ft,ut,at,vt);else if(n.fill&&n.fill.type!=="None"){const et=t.globalAlpha,Q=this.createCanvasFill(t,n.fill,ft,ut);t.fillStyle=Q||n.fill.color||"transparent",t.globalAlpha=et*this.normalizeOpacity(n.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),t.fill(),t.globalAlpha=et}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const et={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-ft/2,-ut/2,ft,ut,at),this.applyStrokeAlignment(t,n,et,ft,ut,at,D,q)}}else i.type==="Group"&&i.isStructuralGroup||(i.type==="Component"&&i.variant==="inputbox"?this.renderInputBox(t,i):i.type==="Component"&&i.variant==="button"?this.renderButton(t,i):i.type==="Component"&&i.variant==="toggle_button"?this.renderToggleButton(t,i):i.type==="Toggle"||i.type==="Component"&&i.variant==="toggle"?this.renderToggle(t,i):i.type==="Slider"||i.type==="Component"&&i.variant==="slider"?this.renderSlider(t,i):i.type==="Dropdown"||i.type==="Component"&&i.variant==="dropdown"?this.renderDropdown(t,i):i.type==="ListView"||i.type==="Component"&&i.variant==="listview"?this.renderListView(t,i):i.type==="Checkbox"||i.type==="Component"&&i.variant==="checkbox"?this.renderCheckbox(t,i):i.type==="RadioGroup"||i.type==="Component"&&i.variant==="radiogroup"?this.renderRadioGroup(t,i):i.type==="BarChart"||i.type==="Component"&&i.variant==="barchart"?this.renderBarChart(t,i):i.type==="PieChart"||i.type==="Component"&&i.variant==="piechart"?this.renderPieChart(t,i):i.type==="Joystick"||i.type==="Component"&&i.variant==="joystick"?this.renderJoystick(t,i):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(j=i.geometry)==null?void 0:j.type));if(this.applyArtEffectOverlay(t,i,f,a,r,h),se&&se.enabled&&t.restore(),i.children&&i.children.length>0){const ut=i.type==="Frame",at=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:ut;if(t.save(),at){t.beginPath();const et=e.width??(s==null?void 0:s.width)??i.width??0,Q=e.height??(s==null?void 0:s.height)??i.height??0,Pt=e.cornerRadius??(s==null?void 0:s.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-et/2,-Q/2,et,Q,Pt),t.clip()}let B=0;for(i.children.forEach(et=>{const Q=o.get(et);if(!Q)return;const Pt=this.objectStates.get(et),Ot=(Pt==null?void 0:Pt.geometry)||Q.geometry;if(Ot&&Ot.isMask&&(Pt==null?void 0:Pt.visible)!==!1){const kt=Ot.width||0,At=Ot.height||0;this.applyObjectTransform(t,et);const Mt=(Pt==null?void 0:Pt.corner_radius)??(Ot==null?void 0:Ot.corner_radius)??0;this.applyPath(t,Ot,kt,At,Mt),t.clip(),B++}else this.renderObject(t,Q,o)});B>0;)t.restore(),B--;t.restore()}if(re){this.maskCtx.restore(),(e.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[])).filter(B=>B.isVisible!==!1&&o.has(B.maskId)).forEach(B=>{var Mt,$,Yt,jt,ie,te;const et=o.get(B.maskId),Q=this.objectStates.get(et.id),Pt=B.feather||0,Ot=B.inverted===!0,kt=B.opacity!==void 0?typeof B.opacity=="number"?B.opacity:B.opacity/100:1;if((B.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,et.id,o),Pt>0&&(this.lumaCtx.filter=`blur(${Pt}px)`),this.lumaCtx.globalAlpha=kt;const pt=(Q==null?void 0:Q.width)||et.geometry.width||0,ct=(Q==null?void 0:Q.height)||et.geometry.height||0,Ct=(Q==null?void 0:Q.corner_radius)??et.corner_radius??0;if(((Mt=et.geometry)==null?void 0:Mt.type)==="Text"){const nt=Q!=null&&Q.geometry?this.deepMerge(et.geometry,Q.geometry):et.geometry,St=Q!=null&&Q.style?this.deepMerge(et.style,Q.style):et.style;this._renderText(this.lumaCtx,et,{...nt,width:pt,height:ct,corner_radius:Ct},St,Q,pt,ct,!0,!1,D,q)}else if((($=et.geometry)==null?void 0:$.type)==="Image"){const nt=et.geometry.src;if(nt){let St=this.imageCache.get(nt);St||(St=new Image,St.src=nt,this.imageCache.set(nt,St)),St.complete&&St.naturalWidth>0?this.lumaCtx.drawImage(St,-pt/2,-ct/2,pt,ct):(this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Yt=et.geometry)==null?void 0:Yt.type)==="SVG"){const nt=et.geometry.svgContent;if(nt){const St=`__lumamask_${et.id}`;let Gt=this.imageCache.get(St);if(!Gt){Gt=new Image;const ee=new Blob([nt],{type:"image/svg+xml"});Gt.src=URL.createObjectURL(ee),Gt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(St,Gt)}Gt.complete&&Gt.naturalWidth>0?this.lumaCtx.drawImage(Gt,-pt/2,-ct/2,pt,ct):(this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,et.geometry,pt,ct,Ct),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const rt=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),V=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,it=rt.data;for(let nt=0;nt<it.length;nt+=4){const St=V[nt],Gt=V[nt+1],ee=V[nt+2];let le=(.299*St+.587*Gt+.114*ee)/255;Ot&&(le=1-le),it[nt+3]*=le}this.maskCtx.putImageData(rt,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Ot?"destination-out":"destination-in",Pt>0&&(this.maskCtx.filter=`blur(${Pt}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,et.id,o);const pt=(Q==null?void 0:Q.width)||et.geometry.width||0,ct=(Q==null?void 0:Q.height)||et.geometry.height||0,Ct=(Q==null?void 0:Q.corner_radius)??et.corner_radius??0;if(((jt=et.geometry)==null?void 0:jt.type)==="Text"){const rt=Q!=null&&Q.geometry?this.deepMerge(et.geometry,Q.geometry):et.geometry,V=Q!=null&&Q.style?this.deepMerge(et.style,Q.style):et.style;this._renderText(this.maskCtx,et,{...rt,width:pt,height:ct,corner_radius:Ct},V,Q,pt,ct,!0,!1,D,q)}else if(((ie=et.geometry)==null?void 0:ie.type)==="Image"){const rt=et.geometry.src;if(rt){let V=this.imageCache.get(rt);V||(V=new Image,V.src=rt,this.imageCache.set(rt,V)),V.complete&&V.naturalWidth>0?this.maskCtx.drawImage(V,-pt/2,-ct/2,pt,ct):(this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((te=et.geometry)==null?void 0:te.type)==="SVG"){const rt=et.geometry.svgContent;if(rt){const V=`__alphamask_${et.id}`;let it=this.imageCache.get(V);if(!it){it=new Image;const nt=new Blob([rt],{type:"image/svg+xml"});it.src=URL.createObjectURL(nt),it.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(V,it)}it.complete&&it.naturalWidth>0?this.maskCtx.drawImage(it,-pt/2,-ct/2,pt,ct):(this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,et.geometry,pt,ct,Ct),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),Ft.save(),Ft.setTransform(1,0,0,1,0,0);const at=i.maskBlendMode||i.blendMode;at&&at!=="Normal"&&(Ft.globalCompositeOperation=at.toLowerCase()),Ft.drawImage(this.maskBuffer,0,0),Ft.restore(),Ft.restore()}else t.restore()}}_renderText(t,i,o,e,s,n,a,r=!1,c=!1,h=1,f=1){var yt,bt,gt,Et,It,vt,Dt,ae,pe;let u=o.text||"";if(o.textInputId&&!r){const st=this.inputs.get(o.textInputId);st!==void 0&&(u=String(st),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=u))}if(o.svgPath){const st=o.svgPath;t.save();const mt=((yt=e==null?void 0:e.fill)==null?void 0:yt.color)||"#000000",Rt=((bt=e==null?void 0:e.fill)==null?void 0:bt.opacity)!==void 0?(gt=e==null?void 0:e.fill)==null?void 0:gt.opacity:1;t.fillStyle=mt,t.globalAlpha*=Rt;const _t=new Path2D(st);t.fill(_t),t.restore();return}let l=u||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(l=o.segments.map(st=>st&&st.text?st.text:"").join(""));const d=o.textCase||"none";d==="uppercase"?l=l.toUpperCase():d==="lowercase"?l=l.toLowerCase():d==="capitalize"&&(l=l.replace(/\b\w/g,st=>st.toUpperCase()));let p=((Et=o.fontWeight)==null?void 0:Et.toString())||"400",y=o.fontStyle||"normal";p.toLowerCase().includes("italic")&&(y="italic",p=p.replace(/italic/gi,"").trim()||"400");const b=this.mapFontWeight(p),m=Math.max(1,o.fontSize||32);let v=o.fontFamily||"Inter";const S=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];S.forEach(st=>{const mt=new RegExp(`[\\s-]${st}$`,"i");mt.test(v)&&(v=v.replace(mt,"").trim())});const I=`${o.smallCaps===!0?"small-caps ":""}${y} ${b} ${m}px "${v}", sans-serif`;t.font=I;const M=o.textVerticalAlign||"top";t.textBaseline="top";const k=o.textAlign||"left";t.textAlign=k;let T=0;if(typeof o.letterSpacing=="number")T=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const st=o.letterSpacing;T=st.unit==="PERCENT"?st.value/100*m:st.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${T}px`);const O=o.kerning||"auto",P=o.kerningValue||0;O==="manual"&&P!==0&&(t.letterSpacing=`${T+P}px`);const _=o.paragraphSpacing||0;let E=o.lineHeight??1.2;typeof E=="string"&&(E=parseFloat(E)),E>5&&m>0&&(E=E/m);const A=(E||1.2)*m,W=o.isPointText===!0||!o.width||o.width<=0,z=((It=o.padding)==null?void 0:It.left)||((vt=o.padding)==null?void 0:vt.right)||0,Y=W?1e5:o.width&&o.width>0?Math.ceil(o.width)-z*2:1e5;o.autoHeight;const G=ts({text:l,fontFamily:v,fontSize:m,fontWeight:b,fontStyle:y,lineHeight:E,width:Y,letterSpacing:T,paragraphSpacing:_,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:d,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),N=G.lines||[],J=G.maxFontSize||m,x=this.fontLeadingFactors[v]??.5,F=(A-m)*x;let j=G.height,X=n,tt=a;if(X===0||tt===0||X>=1e5){let st=0,mt=0;const Rt=G.fullText||l;(N||[]).forEach(_t=>{const dt=_t.text||"",$t=t.measureText(dt).width+(dt.length>0?(dt.length-1)*T:0);$t>st&&(st=$t),mt+=dt.length,mt<Rt.length&&(Rt[mt]===`
|
|
23
|
-
`||
|
|
24
|
-
`&&
|
|
25
|
-
`||
|
|
26
|
-
`||
|
|
27
|
-
`||
|
|
28
|
-
`&&
|
|
29
|
-
`||
|
|
30
|
-
`&&
|
|
31
|
-
`||
|
|
32
|
-
`||
|
|
33
|
-
`&&dt++)}),t.globalAlpha=mt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,r=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const c=i.stroke;let h=1;if(this.rootTransform){const S=t.getTransform(),C=Math.sqrt(S.a*S.a+S.b*S.b)||1,w=this.rootTransform,I=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/I}else h=(Math.abs(a)+Math.abs(r))/2||1;const f=(c.width||1)/(h||1),u=(c.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),c.fill){const S=this.createCanvasFill(t,c.fill,e,s);S?t.strokeStyle=S:t.strokeStyle=c.color||"#000000"}else t.strokeStyle=c.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(c.opacity??100),t.lineWidth=f,t.lineCap=c.lineCap||"round",t.lineJoin=c.lineJoin||"round",c.miterLimit!==void 0&&(t.miterLimit=c.miterLimit);const p=c.trimStart??0,y=c.trimEnd??1,b=c.trimOffset??0,m=c.dashOffset??0,v=c.dashArray||[];if(p!==0||y!==1||b!==0){const S=this.getPerimeter(o,e,s);if(S>0){const C=Math.max(0,Math.min(1,p)),w=Math.max(0,Math.min(1,y));if(C<w){const I=S*(w-C),M=S-I,k=-(S*(C+b%1));t.setLineDash([I,M]),t.lineDashOffset=k+m*S}else if(C===w)t.setLineDash([0,S]);else{const I=S*(1-C+w),M=S-I,k=-(S*C);t.setLineDash([I,M]),t.lineDashOffset=k+m*S}}}else v.length>0&&(t.setLineDash(v),t.lineDashOffset=m);if((o==null?void 0:o.type)==="Line"||e===0||s===0)this.applyPath(t,o,e,s,n),t.stroke();else if(u==="inside")t.lineWidth=f*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore();else if(u==="outside"){t.save(),t.beginPath();const S=Math.max(e,s,2e4);t.rect(-S,-S,S*2,S*2),this.applyPath(t,o,e,s,n),t.clip("evenodd"),t.lineWidth=f*2,t.beginPath(),this.applyPath(t,o,e,s,n),t.stroke(),t.restore()}else t.lineWidth=f,this.applyPath(t,o,e,s,n),t.stroke();t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return r;let c=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));c+=n/360*h,n<360&&(c+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(c+=2*Math.max(e,s));return isNaN(c)?0:c}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const c=e[r];if(c.moveTo){n=c.x,a=c.y;continue}const h=n,f=a,u=e[r-1].out_x,l=e[r-1].out_y;if(u!==void 0||c.in_x!==void 0?s+=this.getBezierLength(h,f,u??h,l??f,c.in_x??c.x,c.in_y??c.y,c.x,c.y):s+=Math.sqrt((c.x-h)**2+(c.y-f)**2),n=c.x,a=c.y,c.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,p=a,y=[...e.slice(0,r+1)].reverse().find(I=>I.moveTo)||e[0],b=y.x,m=y.y,v=e[r].out_x,S=e[r].out_y,C=y.in_x,w=y.in_y;v!==void 0||C!==void 0?s+=this.getBezierLength(d,p,v??d,S??p,C??b,w??m,b,m):s+=Math.sqrt((b-d)**2+(m-p)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,c=10){let h=0,f=t,u=i;for(let l=1;l<=c;l++){const d=l/c,p=1-d,y=d*d,b=p*p,m=b*p,v=y*d,S=m*t+3*b*d*o+3*p*y*s+v*a,C=m*i+3*b*d*e+3*p*y*n+v*r,w=S-f,I=C-u;h+=Math.sqrt(w*w+I*I),f=S,u=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,r,c,h=20){if(t<=0)return 0;let f=0,u=i,l=o;for(let d=1;d<=h;d++){const p=d/h,y=1-p,b=p*p,m=y*y,v=m*y,S=b*p,C=v*i+3*m*p*e+3*y*b*n+S*r,w=v*o+3*m*p*s+3*y*b*a+S*c,I=C-u,M=w-l,k=Math.sqrt(I*I+M*M);if(f+k>=t){const T=t-f,O=k===0?0:T/k;return(d-1+O)/h}f+=k,u=C,l=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,c=-1/0;s.forEach(m=>{typeof m.x=="number"&&typeof m.y=="number"&&(n=Math.min(n,m.x),a=Math.max(a,m.x),r=Math.min(r,m.y),c=Math.max(c,m.y),m.out_x!==void 0&&(n=Math.min(n,m.out_x),a=Math.max(a,m.out_x)),m.out_y!==void 0&&(r=Math.min(r,m.out_y),c=Math.max(c,m.out_y)),m.in_x!==void 0&&(n=Math.min(n,m.in_x),a=Math.max(a,m.in_x)),m.in_y!==void 0&&(r=Math.min(r,m.in_y),c=Math.max(c,m.in_y)))});const h=(n+a)/2,f=(r+c)/2,l=this.getPerimeter(t,i,o)*e;let d=0;const p=[];let y=s[0],b=s[0];for(let m=1;m<s.length;m++){const v=s[m];if(v.moveTo){y=v,b=v;continue}p.push({p0:y,p1:v}),(v.closePath||m===s.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:v,p1:b}),y=v}for(const m of p){const v=m.p0,S=m.p1;let C=0;const w=v.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-v.x)**2+(S.y-v.y)**2),d+C>=l||m===p[p.length-1]){let I=0;if(w)return I=this.getBezierTAtLength(l-d,v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(I,v,S,h,f);{I=C===0?0:(l-d)/C;const M=v.x+(S.x-v.x)*I-h,k=v.y+(S.y-v.y)*I-f,T=Math.atan2(S.y-v.y,S.x-v.x);return{x:M,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,c=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(c),f=n*Math.sin(c),u=-s*Math.sin(c),l=n*Math.cos(c),d=Math.atan2(l,u);return{x:h,y:f,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let c=0,h=0,f=0;return r<s?(c=-s/2+r,h=-n/2,f=0):r<s+n?(c=s/2,h=-n/2+(r-s),f=Math.PI/2):r<2*s+n?(c=s/2-(r-(s+n)),h=n/2,f=Math.PI):(c=-s/2,h=n/2-(r-(2*s+n)),f=-Math.PI/2),{x:c,y:h,angle:f}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,r=i.out_x??i.x,c=i.out_y??i.y,h=o.in_x??o.x,f=o.in_y??o.y,u=o.x,l=o.y,d=1-t,p=t*t,y=d*d,b=y*d,m=p*t,v=b*n+3*y*t*r+3*d*p*h+m*u-e,S=b*a+3*y*t*c+3*d*p*f+m*l-s,C=3*y*(r-n)+6*d*t*(h-r)+3*p*(u-h),w=3*y*(c-a)+6*d*t*(f-c)+3*p*(l-f),I=Math.atan2(w,C);return{x:v,y:S,angle:I}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,p,y;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const b=Math.tan(e*Math.PI/180),m=Math.tan(s*Math.PI/180);t.transform(1+b*m,m,b,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((p=o.transform)==null?void 0:p.rotate_y)??0,c=1+(o.translate_z!==void 0?o.translate_z:((y=o.transform)==null?void 0:y.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*c,f=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*c,u=(o.scale_x??1)*h,l=(o.scale_y??1)*f;t.scale(u,l)}applyArtEffectOverlay(t,i,o,e,s,n){var l,d,p,y,b;const a=this.objectStates.get(i.id),r=((l=a==null?void 0:a.style)==null?void 0:l.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const c=r.type,h=r.intensity??.5,f=r.speed??1,u=r.scale??10;if(c==="acid_gradient"||c==="acid_rave"||c==="shimmer"||c==="glint_overlay"||c==="halftone"||c==="noise"||c==="scanlines"||c==="chromatic_aberration"||c==="pixelate"||c==="glitch"||c==="fold_overlay"||c==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),c==="shimmer"){const v=this.currentTime*f%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),S.addColorStop(v,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((p=i.transform)==null?void 0:p.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="fold_overlay"){const m=this._lastPointerPos||{x:0,y:0},v=m.x-(((y=i.transform)==null?void 0:y.x)??0),S=m.y-(((b=i.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,S>0?-s/2:s/2,v>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):v<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):v>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=v>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(c==="crumple_overlay"){const m=Math.floor(e/u),v=document.createElement("canvas");v.width=m,v.height=Math.floor(s/u);const S=v.getContext("2d"),C=S.createImageData(v.width,v.height);for(let w=0;w<C.data.length;w+=4){const I=Math.random()>.95?150:255;C.data[w]=I,C.data[w+1]=I,C.data[w+2]=I,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-s/2,e,s)}else if(c==="acid_gradient"||c==="acid_rave"){const m=this.currentTime*f,v=r.color1,S=r.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(v&&S){const w=m*60%360;C.addColorStop(0,this._shiftHue(v,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=m*100%360,I=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${I}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(c==="halftone"){const m=Math.max(2,u*(1-h*.8)),v=document.createElement("canvas");v.width=m,v.height=m;const S=v.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(m/2,m/2,m/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(c==="noise"){const m=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let v=0;v<m;v++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(c==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let m=-s/2;m<s/2;m+=4)t.beginPath(),t.moveTo(-e/2,m),t.lineTo(e/2,m),t.stroke()}else if(c==="chromatic_aberration"){const m=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-m,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+m,-s/2,e,s)}else if(c==="pixelate"){const m=Math.max(2,Math.round(u*(1-h*.5))),v=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/m)),C=Math.max(1,Math.ceil(s/m));v.width=S,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const I=t.getTransform(),M=I.e-e/2,k=I.f-s/2;w.drawImage(t.canvas,M,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(c==="glitch"){const m=this.currentTime*f,v=r.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const I=s/S;for(let M=0;M<S;M++){const k=Math.sin(M*127.1+m*311.7*f)*43758.5,T=k-Math.floor(k);if(T>1-v){const O=(T-(1-v))/v*C*(Math.random()>.5?1:-1),P=-s/2+M*I,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,I),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,I,-e/2+O,P,e,I),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const l=t.replace("#","");e=parseInt(l.substring(0,2),16)/255,s=parseInt(l.substring(2,4),16)/255,n=parseInt(l.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let c=0,h=0,f=(a+r)/2;if(a!==r){const l=a-r;switch(h=f>.5?l/(2-a-r):l/(a+r),a){case e:c=((s-n)/l+(s<n?6:0))/6;break;case s:c=((n-e)/l+2)/6;break;case n:c=((e-s)/l+4)/6;break}}return`hsla(${(((c*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(f*100).toFixed(0)}%, ${o})`}_applyAlphaToColor(t,i){if(!t)return`rgba(255,255,255,${i})`;const o=t.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.%]+))?\s*\)/);if(o){const s=o[1],n=o[2],a=o[3];return`rgba(${s},${n},${a},${i})`}if(t.startsWith("#")){const s=t.replace("#",""),n=s.length;if(n===3||n===6){const a=n===3?s.split("").map(f=>f+f).join(""):s,r=parseInt(a.slice(0,2),16),c=parseInt(a.slice(2,4),16),h=parseInt(a.slice(4,6),16);return`rgba(${r},${c},${h},${i})`}if(n===8){const a=parseInt(s.slice(0,2),16),r=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${a},${r},${c},${i})`}}const e=t.match(/hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.%]+))?\s*\)/);return e?`hsla(${e[1]},${e[2]}%,${e[3]}%,${i})`:`rgba(255,255,255,${i})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,c=n.noise??0,h=n.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,i,o,e,s),t.clip();const f=t.getTransform(),u=t.canvas,l=(typeof window<"u"?window.devicePixelRatio:1)||1;try{const p=document.createElement("canvas");p.width=Math.max(1,Math.ceil(o)),p.height=Math.max(1,Math.ceil(e));const y=p.getContext("2d");if(y){y.save(),y.translate(o/2,e/2);const b=n.magnification||1;b!==1&&y.scale(b,b);const m=f.a*l,v=f.b*l,S=f.c*l,C=f.d*l,w=f.e*l,I=f.f*l;if(typeof f.inverse=="function"){const T=f.inverse();y.transform(T.a/l,T.b/l,T.c/l,T.d/l,T.e/l,T.f/l)}else{const T=m*C-v*S;T!==0&&y.transform(C/T,-v/T,-S/T,m/T,(S*I-C*w)/T,(v*w-m*I)/T)}y.drawImage(u,0,0),y.restore();const M=document.createElement("canvas");M.width=p.width,M.height=p.height;const k=M.getContext("2d");k.filter=`blur(${a}px)`,k.drawImage(p,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(M,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=r,t.fillStyle=h,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),c>0){if(t.globalAlpha=c/100,!this._noiseTileCanvas){const y=document.createElement("canvas");y.width=64,y.height=64;const b=y.getContext("2d"),m=b.createImageData(64,64),v=m.data;for(let S=0;S<v.length;S+=4){const C=Math.floor(Math.random()*255);v[S]=C,v[S+1]=C,v[S+2]=C,v[S+3]=18}b.putImageData(m,0,0),this._noiseTileCanvas=y}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,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=i,c=o/2,h=e/2,f=n*Math.PI/180,u=a*Math.PI/180,l=f+u;a>=360&&r<=0?t.ellipse(0,0,c,h,0,0,Math.PI*2):(t.ellipse(0,0,c,h,0,f,l,!1),r>0?t.ellipse(0,0,c*r,h*r,0,l,f,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const c=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(c),f=a*Math.sin(c);r===0?t.moveTo(h,f):t.lineTo(h,f)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let r=i.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let c=0;c<n*2;c++){const h=c*Math.PI/n-Math.PI/2,f=c%2===0?a:r,u=f*Math.cos(h),l=f*Math.sin(h);c===0?t.moveTo(u,l):t.lineTo(u,l)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,r=1/0,c=-1/0;if(i.points.forEach(u=>{typeof u.x=="number"&&typeof u.y=="number"&&(n=Math.min(n,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),c=Math.max(c,u.y),u.out_x!==void 0&&(n=Math.min(n,u.out_x),a=Math.max(a,u.out_x)),u.out_y!==void 0&&(r=Math.min(r,u.out_y),c=Math.max(c,u.out_y)),u.in_x!==void 0&&(n=Math.min(n,u.in_x),a=Math.max(a,u.in_x)),u.in_y!==void 0&&(r=Math.min(r,u.in_y),c=Math.max(c,u.in_y)))}),n===1/0)return;const h=(n+a)/2,f=(r+c)/2;if(isNaN(h)||isNaN(f)){this.warn("[Engine] Invalid path center:",h,f);return}i.points.forEach((u,l)=>{if(l===0||u.moveTo)t.moveTo(u.x-h,u.y-f);else{const d=i.points[l-1];if(!d)return;const p=(d.out_x??d.x)-h,y=(d.out_y??d.y)-f,b=(u.in_x??u.x)-h,m=(u.in_y??u.y)-f;isNaN(p)||isNaN(b)||isNaN(u.x)?t.lineTo(u.x-h,u.y-f):t.bezierCurveTo(p,y,b,m,u.x-h,u.y-f)}if(u.closePath||l===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,l+1)].reverse().find(p=>p.moveTo)||i.points[0];d&&(u.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((u.out_x??u.x)-h,(u.out_y??u.y)-f,(d.in_x??d.x)-h,(d.in_y??d.y)-f,d.x-h,d.y-f),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,c=-1/0;i.points.forEach(u=>{n=Math.min(n,u.x),a=Math.max(a,u.x),r=Math.min(r,u.y),c=Math.max(c,u.y)});const h=(n+a)/2,f=(r+c)/2;i.points.forEach((u,l)=>{if(l===0)t.moveTo(u.x-h,u.y-f);else{const d=i.points[l-1];d.out_x!==void 0||u.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-f,(u.in_x??u.x)-h,(u.in_y??u.y)-f,u.x-h,u.y-f):t.lineTo(u.x-h,u.y-f)}(u.closePath||l===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var L,R;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((L=i.geometry)==null?void 0:L.width)||250,n=((R=i.geometry)==null?void 0:R.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,c=e.previewState||"default",h=c!=="default"?c:a?"focused":r?"hovered":"default",f=e.label||{visible:!0,text:"Label"},u=e.helperText||{visible:!1,text:"Helper text"},l=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},p=e.multiline===!0,y=e.corner_radius??8,b=e.corners||{tl:y,tr:y,bl:y,br:y},m=[b.tl,b.tr,b.br,b.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",I=e.placeholderColor||"rgba(156, 163, 175, 1)",M=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(v=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(I=T.placeholderColor),T.fontSize!==void 0&&(M=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,v=e.hoverBackgroundColor||v):h==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,m);const O=this.createCanvasFill(t,v,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,S,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const q=m.map(ot=>ot+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,q),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,q)=>{if(!D.visible||!D.svgPath)return;const ot=D.size||14,yt=D.offset??16,bt=D.color||"#ffffff",gt=q?-(s/2)+yt:s/2-yt,Et=D.svgPath;if(t.save(),t.translate(gt,0),!Et.startsWith("<svg")){const It=new Path2D(Et),vt=ot/24;t.scale(vt,vt),t.translate(-12,-12),t.fillStyle=bt,t.fill(It)}t.restore()};P(l,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,W=_||E,z=A?I:w,Y=M,G=e.fontFamily||"Inter",N=e.fontWeight||400;t.font=`${N} ${Y}px "${G}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline=p?"top":"middle";const J=e.inputPadding??16,x=l.visible?(l.offset??16)+(l.size||14)/2+8:J,F=d.visible?(d.offset??16)+(d.size||14)/2+8:J,j=-(s/2)+x,X=s-x-F,tt=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(j-2,-n/2+4,X+4,n-8),t.clip(),p){const D=tt.split(`
|
|
34
|
-
`);let q=-n/2+J;const ot=Y*1.2;let yt=0;D.forEach((bt,gt)=>{const Et=bt.split(" ");let It="";for(let vt=0;vt<Et.length;vt++){const Dt=It+Et[vt]+" ";t.measureText(Dt).width>X&&vt>0?(t.fillText(It,j,q),It=Et[vt]+" ",q+=ot):It=Dt}t.fillText(It,j,q),yt=t.measureText(It).width,gt<D.length-1&&(q+=ot,yt=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(j+yt,q,1.5,Y)}else{const q=t.measureText(tt).width;let ot=0;if(q>X&&(ot=q-X),t.fillText(tt,j-ot,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const bt=j+q-ot;t.fillRect(bt,-(Y/2),1.5,Y)}}if(t.restore(),f.visible!==!1){const D=f.text||"Label",q=f.fontSize||12,ot=f.color||"rgba(156, 163, 175, 1)",yt=f.offset??8;t.font=`600 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="bottom";const bt=-(s/2),gt=-(n/2)-yt;t.fillText(D,bt,gt)}if(u.visible===!0){const D=u.text||"Helper text",q=u.fontSize||11,ot=h==="error"?"rgba(239, 68, 68, 1)":u.color||"rgba(156, 163, 175, 1)",yt=u.offset??6;t.font=`400 ${q}px "${G}", sans-serif`,t.fillStyle=ot,t.textAlign="left",t.textBaseline="top";const bt=-(s/2),gt=n/2+yt;t.fillText(D,bt,gt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,r=s.min??0,h=(s.max??100)-r,f=h===0?0:(a-r)/h,u=s.trackHeight||4,l=s.trackRoundedness??2,d=s.trackShape??"Rectangle",p=s.trackPath||"",y=s.accentColor||"#3b82f6",b=s.inactiveColor||"#374151",m=s.thumbShape||"Ellipse",v=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",I=s.thumbPath||"",M=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(X,tt,L,R,D,q,ot)=>{if((X==="Custom"||X==="Icon")&&ot)try{const yt=new Path2D(ot);if(t.save(),t.translate(tt,L),X==="Icon"){const bt=Math.min(R,D)/24;t.scale(bt,bt),t.translate(-12,-12)}t.fill(yt),t.restore();return}catch(yt){console.error("Error drawing slider shape in engine:",yt)}if(t.beginPath(),X==="Ellipse")t.ellipse(tt,L,R/2,D/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,tt-R/2,L-D/2,R,D,q);else if(X==="Triangle")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L+D/2),t.lineTo(tt-R/2,L+D/2),t.closePath();else if(X==="Diamond")t.moveTo(tt,L-D/2),t.lineTo(tt+R/2,L),t.lineTo(tt,L+D/2),t.lineTo(tt-R/2,L),t.closePath();else if(X==="Polygon"){const yt=i.geometry.sides||3,bt=i.geometry.radius||Math.min(R,D)/2;for(let gt=0;gt<yt;gt++){const Et=gt*2*Math.PI/yt-Math.PI/2,It=tt+bt*Math.cos(Et),vt=L+bt*Math.sin(Et);gt===0?t.moveTo(It,vt):t.lineTo(It,vt)}t.closePath()}else if(X==="Star"){const bt=Math.min(R,D)/2,gt=bt/2;for(let Et=0;Et<10;Et++){const It=Et%2===0?bt:gt,vt=Et*Math.PI/5-Math.PI/2;t.lineTo(tt+It*Math.cos(vt),L+It*Math.sin(vt))}t.closePath()}else X==="Line"&&(t.moveTo(tt-R/2,L),t.lineTo(tt+R/2,L));t.fill()},A=this.createCanvasFill(t,b,n,u);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,u,l,p);const W=n-v,z=-n/2+v/2+f*W,Y=z- -n/2;if(Y>0){const X=this.createCanvasFill(t,y,n,u);X&&(t.fillStyle=X,t.strokeStyle=X),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(z,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-u/2,Y,u,l),t.fill())}t.save(),t.translate(z,0);const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*N,t.shadowOffsetY=1*N;const J=this.createCanvasFill(t,w,v,S);if(J&&(t.fillStyle=J),E(m,0,0,v,S,C,m==="Icon"?M:I),t.restore(),k){t.save(),t.translate(z+P,_);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const tt=t.measureText(X),L=6,R=4,D=tt.width+L*2,q=14+R;t.beginPath(),this.drawRoundRect(t,-D/2,-q/2,D,q,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},F=s.helperText||{},j=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",tt=x.fontSize||12,L=x.color||"rgba(156, 163, 175, 1)",R=x.offset??8;t.font=`600 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),q=-(u/2)-R;t.fillText(X,D,q)}if(F.visible===!0){const X=F.text||"Helper text",tt=F.fontSize||11,L=F.color||"rgba(156, 163, 175, 1)",R=F.offset??6;t.font=`400 ${tt}px "${j}", sans-serif`,t.fillStyle=L,t.textAlign="left",t.textBaseline="top";const D=-(n/2),q=u/2+R;t.fillText(X,D,q)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,r=-n/2,c=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",f=this.lastHoveredObjectId===i.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!h;let l=e.backgroundColor,d=e.borderColor,p=e.color||"#333333";h?(l=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):u?(l=e.activeBackgroundColor||l,d=e.activeBorderColor||d,p=e.activeColor||p):f&&(l=e.hoverBackgroundColor||l,d=e.hoverBorderColor||d,p=e.hoverColor||p),l||(l="#ffffff"),d||(d="#e5e7eb");const y=t.globalAlpha;t.globalAlpha=y*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,c),t.fillStyle=this.createCanvasFill(t,typeof l=="string"?{type:"Solid",color:l}:l,s,n)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=b,t.stroke());const m=12,v=e.chevronType||"chevron",S=e.chevronSize||16,C=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const E=a+s-m-S/2;t.save(),t.translate(E,0);const A=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(v==="custom"||v==="path"){const W=u&&e.openIconPath||e.closedIconPath;if(W){const z=new Path2D(W);t.save();const Y=S/24;t.scale(Y,Y),t.translate(-12,-12),t.fill(z),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",I=e.fontSize||14,M=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${M} ${I}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=v==="none"?0:S+8,P=s-m*2-O;if(t.save(),t.beginPath(),t.rect(a+m,r,P,n),t.clip(),t.fillText(w,a+m,0),t.restore(),u&&!h){const E=r+n+4,A=e.optionsList||[],W=e.itemHeight||32,z=e.listPadding??4,Y=A.length*W+z*2,G=e.listCornerRadius??c;t.save();const N=e.listShadow||{},J=t.getTransform(),x=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof N.color=="string"?N.color:((_=N.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(N.blur??12)*x,t.shadowOffsetY=(N.offsetY??6)*x,t.shadowOffsetX=(N.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,E,s,Y,G),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,Y)||"#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},s,Y)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const j=e.itemFontSize||I,X=e.itemFontFamily||k;t.font=`${M} ${j}px ${X}`,A.forEach((tt,L)=>{const R=E+z+L*W;if(tt===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const q=this._lastPointerPos.y-(E+z),ot=Math.floor(q/W);L===ot&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+F,R,s-F*2,W),t.fillStyle=e.itemHoverColor||p)}t.fillText(tt,a+m,R+W/2)})}t.globalAlpha=y}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,r=this.lastHoveredObjectId===i.id,c=this.activeObjectId===i.id,h=e.label||{},f=e.hoverStyle||{},u=e.activeStyle||{},l=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",p=h.color||"#ffffff",y=h.text||"Button",b=s.cornerRadius??8,m=e.borderColor||"transparent",v=e.borderWidth||0,S=1;c&&u?(d=u.backgroundColor||d,p=u.color||p,y=u.text||y,S=u.scale??.95,b=u.cornerRadius??b):r&&f&&(d=f.backgroundColor||d,p=f.color||p,y=f.text||y,S=f.scale??1,b=f.cornerRadius??b,m=f.borderColor||m);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,b);const I=this.createCanvasFill(t,d,n,a);I&&(t.fillStyle=I,t.fill()),(v>0||r&&f.borderColor)&&(t.strokeStyle=m,t.lineWidth=v||(r?1:0),t.stroke());const M=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${M}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let O=0;if(l.enabled&&l.svgPath){const P=M*1.1,_=l.gap||8,E=t.measureText(y),W=-(E.width+P+_)/2,z=l.position==="left"?W+P/2:W+E.width+_+P/2;O=l.position==="left"?W+P+_+E.width/2:W+E.width/2,t.save(),t.translate(z,0);const Y=new Path2D(l.svgPath),G=P/24;t.scale(G,G),t.translate(-12,-12),t.fillStyle=p,t.fill(Y),t.restore()}t.fillText(y,O,0),t.restore()}renderToggleButton(t,i){var y,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((y=i.geometry)==null?void 0:y.width)||120,a=((b=i.geometry)==null?void 0:b.height)||40,r=-n/2,c=-a/2,h=e.corner_radius??8,f=e.label||{},u=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",l=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,c,n,a,h),t.fillStyle=u,t.fill();const d=f.fontSize||14,p=f.fontFamily||"Inter";t.font=`${f.fontWeight||600} ${d}px "${p}", sans-serif`,t.fillStyle=l,t.textAlign="center",t.textBaseline="middle",t.fillText(f.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var G,N,J,x,F,j,X,tt,L,R,D,q;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((G=i.geometry)==null?void 0:G.width)||52,n=((N=i.geometry)==null?void 0:N.height)||30,a=-s/2,r=-n/2,c=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,f=e.toggleStyle||{},u=f.backgroundColor||e.activeColor||"#10b981",l=f.borderColor||e.borderColor||"transparent",d=f.borderWidth??e.borderWidth??0,p=f.knobColor||e.knobColor||"#ffffff",y=c?u:e.inactiveColor||"#374151",b=c?l:e.borderColor||"transparent",m=c?d:e.borderWidth??0,v=c?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const S=this.createCanvasFill(t,y,s,n);if(S&&(t.fillStyle=S,t.fill()),m>0){t.lineWidth=m;const ot=this.createCanvasFill(t,b,s,n);ot&&(t.strokeStyle=ot,t.stroke())}const C=2,w=n-C*2,I=w/2,M=a+C,k=a+s-C-w,T=c?k:M,O=r+C;t.beginPath(),t.arc(T+I,O+I,I,0,Math.PI*2);const P=this.createCanvasFill(t,v,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(c?(J=f.leftLabel)==null?void 0:J.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(c?(F=f.leftLabel)==null?void 0:F.color:null)||((j=e.leftLabel)==null?void 0:j.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&A){const ot=e.leftLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(ot.gap||8),0),_=!0}const z=(c?(tt=f.rightLabel)==null?void 0:tt.text:null)||((L=e.rightLabel)==null?void 0:L.text)||"",Y=(c?(R=f.rightLabel)==null?void 0:R.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((q=e.rightLabel)!=null&&q.enabled&&z){const ot=e.rightLabel;t.font=`${ot.fontWeight||400} ${ot.fontSize||12}px "${ot.fontFamily||"Inter"}", sans-serif`,t.fillStyle=Y,t.textBaseline="middle",t.textAlign="left",t.fillText(z,a+s+(ot.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const ot=e.label,yt=ot.fontSize||14,bt=ot.fontWeight||400,gt=ot.fontFamily||"Inter";t.font=`${bt} ${yt}px "${gt}", sans-serif`,t.fillStyle=ot.color||"#f3f4f6",t.textBaseline="middle";const Et=ot.gap||10;let It=0,vt=0;ot.position==="left"?(t.textAlign="right",It=a-Et,vt=0):ot.position==="right"?(t.textAlign="left",It=a+s+Et,vt=0):ot.position==="top"?(t.textAlign="center",It=0,vt=r-Et,t.textBaseline="bottom"):ot.position==="bottom"?(t.textAlign="center",It=0,vt=r+n+Et,t.textBaseline="top"):(t.textAlign="left",It=a+s+Et,vt=0),t.fillText(ot.text,It,vt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,r=-n/2,c=e.cornerRadius??4,h=e.checked??!1,f=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",l=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",p=e.borderWidth??2,y=h?f:u,b=h?"transparent":d,m=h?0:p;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,c);const v=this.createCanvasFill(t,y,s,n);if(v&&(t.fillStyle=v,t.fill()),m>0){t.lineWidth=m;const w=this.createCanvasFill(t,b,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,f,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,l,s,n);t.strokeStyle=w||l,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const I=a+s*.25,M=r+n*.5,k=a+s*.45,T=r+n*.7,O=a+s*.75,P=r+n*.25;t.moveTo(I,M),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(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||"#f3f4f6",t.textBaseline="middle";const I=w.gap||8;let M=0,k=0;w.position==="left"?(t.textAlign="right",M=a-I,k=0):w.position==="right"?(t.textAlign="left",M=a+s+I,k=0):w.position==="top"?(t.textAlign="center",M=0,k=r-I,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",M=0,k=r+n+I,t.textBaseline="top"),t.fillText(w.text,M,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,r=-n/2,c=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],f=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,l=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",p=e.textColor||"#ffffff",y=e.fontSize||14,b=e.fontFamily||"Inter",m=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,S=v*2;if(t.save(),t.font=`${m} ${y}px "${b}", sans-serif`,t.textBaseline="middle",t.textAlign="left",f==="vertical"){const I=Math.max(S,y)+u;h.forEach((M,k)=>{const T=r+k*I+v;t.beginPath(),t.arc(a+v,T,v,0,Math.PI*2);const O=c===M,P=this.createCanvasFill(t,l,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||l,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,T,v/2,0,Math.PI*2),t.fillStyle=P||l,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(M,a+S+8,T)})}else{let I=a;h.forEach(M=>{const k=c===M,T=t.measureText(M).width;t.beginPath(),t.arc(I+v,0,v,0,Math.PI*2);const O=this.createCanvasFill(t,l,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||l,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(I+v,0,v/2,0,Math.PI*2),t.fillStyle=O||l,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(M,I+S+6,0),I+=S+6+T+u})}if(t.restore(),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||"#9ca3af",t.textBaseline="middle";const M=I.gap||8;let k=0,T=0;I.position==="left"?(t.textAlign="right",k=a-M,T=0):I.position==="right"?(t.textAlign="left",k=a+s+M,T=0):I.position==="top"?(t.textAlign="center",k=0,T=r-M,t.textBaseline="bottom"):I.position==="bottom"&&(t.textAlign="center",k=0,T=r+n+M,t.textBaseline="top"),t.fillText(I.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.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,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ps[this.stylePreset]||ps.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,W,z){if(!this._getPreset().barGradient&&!this.barGradient)return _;const G=P.createLinearGradient(E,A,W,z);return G.addColorStop(0,_),G.addColorStop(1,_+"44"),G},_drawRoundedBar:function(P,_,E,A,W,z,Y){if(z=Math.min(z,Math.min(Math.abs(A),Math.abs(W))/2),z<=0||A===0||W===0){P.rect(_,E,A,W);return}P.beginPath(),Y?(P.moveTo(_,E+W),P.lineTo(_,E+z),P.quadraticCurveTo(_,E,_+z,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W),P.lineTo(_,E+W)):(P.moveTo(_,E),P.lineTo(_+A-z,E),P.quadraticCurveTo(_+A,E,_+A,E+z),P.lineTo(_+A,E+W-z),P.quadraticCurveTo(_+A,E+W,_+A-z,E+W),P.lineTo(_,E+W),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,r=-n/2,c=-a/2;if(!s.datasets||s.datasets.length===0||s.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=s._getPreset();let f=-1/0,u=1/0;const l=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<l;P++){let _=0,E=0;s.datasets.forEach(A=>{const W=A.data[P]??0;W>=0?_+=W:E+=W}),_>f&&(f=_),E<u&&(u=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>f&&(f=_),_<u&&(u=_)})});isFinite(f)||(f=10),isFinite(u)||(u=0),f=Math.max(f,0),u=Math.min(u,0);const p=f-u||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const y=s.showYLabels?t.measureText(f.toFixed(0)).width+14:10,b=s.showXLabels?s.axisLabelFontSize+12:8,v=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=r+y,w=c+v,I=n-y-S,M=a-v-b;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,c,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,I,M),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=c+12;let _=C;s.datasets.forEach((E,A)=>{const W=s._resolveColor(E.color,A),z=E.label||"Series "+(A+1),Y=7;t.beginPath(),t.roundRect(_,P-Y/2,Y,Y,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(z,_+Y+4,P),_+=t.measureText(z).width+Y+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*I;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+M),t.stroke()}else{const _=w+P/k*M;t.beginPath(),t.moveTo(C,_),t.lineTo(C+I,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=u+P/k*p,E=C+P/k*I;t.textAlign="center",t.fillText(_.toFixed(0),E,w+M+s.axisLabelFontSize)}else{const _=f-P/k*p,E=w+P/k*M;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+M),t.lineTo(C+I,w+M),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+M),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=M/l;for(let _=0;_<l;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/p*I,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A;A+=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,x,J,x+G,J),s._drawRoundedBar(t,x,J,G,N,z===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=I/l;for(let _=0;_<l;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+M+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+M;s.datasets.forEach((W,z)=>{const Y=W.data[_]??0;if(Y===0)return;const G=Y/p*M,N=Math.min(s.barWidth*d+s.barGap,P-8),J=E-N/2,x=A-G;A-=G;const F=s._resolveColor(W.color,z);t.beginPath(),t.fillStyle=s._makeGradient(t,F,J,x,J,x+G),s._drawRoundedBar(t,J,x,N,G,z===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?F:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=M/l,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-u)/p*I;for(let A=0;A<l;A++){const W=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/p*I);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E:E-J,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,F,x,F+J,x),s._drawRoundedBar(t,F,x,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=N>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),N>=0?F+J+4:F-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=I/l,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+M-(0-u)/p*M;for(let A=0;A<l;A++){const W=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",W,w+M+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const z=W-_/2;s.datasets.forEach((Y,G)=>{const N=Y.data[A]??0,J=Math.abs(N/p*M);if(J<1)return;const x=z+G*(s.barWidth+s.barGap),F=N>=0?E-J:E,j=s._resolveColor(Y.color,G);t.beginPath(),t.fillStyle=s._makeGradient(t,j,x,F,x,F+J),s._drawRoundedBar(t,x,F,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?j:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&N!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=N>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?j:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(N.toString(),x+s.barWidth/2,N>=0?F-4:F+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var y,b;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((y=i.geometry)==null?void 0:y.width)||180,height:((b=i.geometry)==null?void 0:b.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 gs[this.stylePreset]||gs.default},_resolveSliceColor:function(m,v){const S=m.color,C=v,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.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=s.slices.reduce((m,v)=>m+(v.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 c=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=c.cardBackground,t.fill(),t.strokeStyle=c.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,f=h>0?h*(s.legendFontSize+8)+10:0,u=a-f-16,l=Math.min(n-24,u)/2,d=0,p=-f/2;if(s.chartType==="rose"){const m=Math.max(...s.slices.map(C=>C.value||0)),v=Math.PI*2/s.slices.length,S=l>0?s.sliceGap/l:0;s.slices.forEach((C,w)=>{const I=C.value||0;if(I===0)return;const M=I/m*l,k=-Math.PI/2+w*v+S/2,T=k+v-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,p),t.arc(d,p,M,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+M*.65*Math.cos(P),E=p+M*.65*Math.sin(P),A=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const m=s.chartType==="pie"?0:s.innerRadius,v=l*Math.max(0,m),S=l>0?s.sliceGap/l:0;let C=-Math.PI/2;if(s.slices.forEach((w,I)=>{const M=w.value||0;if(M===0){C+=M/r*Math.PI*2;return}const k=M/r*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,I);if(t.beginPath(),t.fillStyle=P,v<=0?(t.moveTo(d,p),t.arc(d,p,l,T,O),t.lineTo(d,p)):(t.moveTo(d+l*Math.cos(T),p+l*Math.sin(T)),t.arc(d,p,l,T,O),t.arc(d,p,v,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=v+(l-v)/2,A=d+E*Math.cos(_),W=p+E*Math.sin(_),z=Math.round(M/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${z}%`,A,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&v>14){const w=Math.round(r),I=Math.min(Math.floor(v*.52),20),M=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${I}px Inter, sans-serif`,t.fillStyle=c.centerTextColor,t.fillText(w.toString(),d,p-M*.5),s.centerLabel&&(t.font=`${M}px Inter, sans-serif`,t.fillStyle=c.centerLabelColor,t.fillText(s.centerLabel,d,p+I*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const m=2,v=n/m,S=s.legendFontSize+8,C=a/2-f+10,w=-n/2+10;s.slices.forEach((I,M)=>{const k=M%m,T=Math.floor(M/m),O=w+k*v,P=C+T*S,_=s._resolveSliceColor(I,M),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=c.legendColor;const A=Math.round((I.value||0)/r*100),W=`${I.label||"Item"} ${A}%`,z=v-E-20;let Y=W;for(;t.measureText(Y).width>z&&Y.length>4;)Y=Y.slice(0,-4)+"…";t.fillText(Y,O+E+4,P)})}t.restore()}renderJoystick(t,i){var p,y,b,m,v;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((p=i.geometry)==null?void 0:p.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((y=i.geometry)==null?void 0:y.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let r=i.handleX||0,c=i.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(c=o.handleY),t.save();let h=0,f=0;i.handleOrigin==="top-left"?(h=e/2,f=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,f=-s/2),t.translate(h,f),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(b=i.style)!=null&&b.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(m=i.style)!=null&&m.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(v=i.style)!=null&&v.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const u=n-a;let l=0,d=0;i.joystickType==="2D"?(l=r*u,d=c*u):i.joystickType==="1D_X"?(l=r*u,d=0):i.joystickType==="1D_Y"&&(l=0,d=c*u),t.beginPath(),t.arc(l,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var M,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((M=t.geometry)==null?void 0:M.width)||180,r=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,c=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,f=e.fontSize||14,u=this.getWorldTransform(t.id),l=i-u.x,d=o-u.y,p=-u.rotation*(Math.PI/180),y=Math.cos(p),b=Math.sin(p),m=l*y-d*b,v=l*b+d*y,C=8*2,w=-a/2,I=-r/2;if(c==="vertical"){const T=Math.max(C,f)+h;for(let O=0;O<n.length;O++){const P=I+O*T;if(m>=w&&m<=w+a&&v>=P&&v<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(m>=T&&m<=T+E&&v>=I&&v<=I+r)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.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(s.forEach(p=>{let y=p.data;if(p.isVarEnabled&&p.inputId){let b=this.inputs.get(p.inputId);if(b===void 0){const m=this.inputNameMap.get(p.inputId);m&&m.length>0&&(b=this.inputs.get(m[0]))}b&&Array.isArray(b)&&(y=b)}if(y&&y.length>0){const b=y.filter(m=>typeof m=="number"&&!isNaN(m));b.length>0&&(n=Math.min(n,...b),a=Math.max(a,...b),r=Math.max(r,y.length))}p._resolvedData=y}),r<2)return;const c=a-n,h=o/(r-1),f=p=>{const y=c===0?.5:(p-n)/c;return e/2-y*e},u=p=>p*h-o/2,l=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||l,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||l,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<r;p++){const y=u(p);t.fillText(`${p+1}`,y,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,y=(a+n)/2;t.fillText(a.toFixed(1),p,f(a)),t.fillText(y.toFixed(1),p,f(y)),t.fillText(n.toFixed(1),p,f(n))}const d=10;if(s.forEach(p=>{const y=p._resolvedData;if(!(!y||y.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),f(y[0])),p.smoothing&&y.length>2)for(let m=0;m<y.length-1;m++){const v=y[m===0?m:m-1],S=y[m],C=y[m+1],w=y[m+1===y.length-1?m+1:m+2];for(let I=1;I<=d;I++){const M=I/d,k=this._catmullRom(v,S,C,w,M);t.lineTo(u(m+M),f(k))}}else for(let m=1;m<y.length;m++)t.lineTo(u(m),f(y[m]));t.lineTo(u(y.length-1),e/2),t.closePath();const b=t.globalAlpha;t.globalAlpha=b*(i.areaOpacity??.3),t.fillStyle=p.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=b}if(t.beginPath(),t.strokeStyle=p.lineColor||"#3b82f6",t.lineWidth=p.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(u(0),f(y[0])),p.smoothing&&y.length>2)for(let b=0;b<y.length-1;b++){const m=y[b===0?b:b-1],v=y[b],S=y[b+1],C=y[b+1===y.length-1?b+1:b+2];for(let w=1;w<=d;w++){const I=w/d,M=this._catmullRom(m,v,S,C,I);t.lineTo(u(b+I),f(M))}}else for(let b=1;b<y.length;b++)t.lineTo(u(b),f(y[b]));t.stroke(),p.showPoints&&y.forEach((b,m)=>{const v=u(m),S=f(b);t.beginPath(),t.arc(v,S,(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()})}}),i.showLegend&&s.length>0){const p=o/2-10;let y=-e/2+15;const b=i.legendFontSize||10,m=b+5;t.font=`${b}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(v=>{const C=v.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(p-w-8-5,y-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,p,y),y+=m})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,c=s*r;return(2*i-2*o+n+a)*c+(-3*i+3*o-2*n-a)*r+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const r=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(c,h=100)=>{var S,C;const u=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[c]||c,l=this.normalizeOpacity(i.opacity??100),p=this.normalizeOpacity(h)*l;if(p>=1&&u.startsWith("#"))return u;const y=u.startsWith("#")?u.replace("#",""):"ffffff",b=parseInt(y.substring(0,2),16),m=parseInt(y.substring(2,4),16),v=parseInt(y.substring(4,6),16);return`rgba(${b}, ${m}, ${v}, ${p})`};if(i.type==="LinearGradient"){const c=(p,y,b)=>Array.isArray(p)?p[y]??(y===0?0:1):p&&typeof p=="object"?p[b]??(y===0?0:1):y===0?0:1,h=c(i.start,0,"x")*o-o/2,f=c(i.start,1,"y")*e-e/2,u=c(i.end,0,"x")*o-o/2,l=c(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,f,u,l);if(i.stops.forEach(p=>{const y=p.offset!==void 0?p.offset:p.pos!==void 0?p.pos:p.position!==void 0?p.position:0,b=r(p.color||"#000000",p.opacity??100);d.addColorStop(Math.max(0,Math.min(1,y)),b)}),i.gradientTransform&&d.setTransform){const[p,y,b,m,v,S]=i.gradientTransform;d.setTransform({a:p,b:y,c:b,d:m,e:v,f:S})}return d}else if(i.type==="RadialGradient"){const c=(d,p,y)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[y]??.5:.5,h=c(i.center,0,"x")*o-o/2,f=c(i.center,1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e),l=t.createRadialGradient(h,f,0,h,f,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,y=r(d.color||"#000000",d.opacity??100);l.addColorStop(Math.max(0,Math.min(1,p)),y)}),i.gradientTransform&&l.setTransform){const[d,p,y,b,m,v]=i.gradientTransform;l.setTransform({a:d,b:p,c:y,d:b,e:m,f:v})}return l}else if(i.type==="AngularGradient"){const c=(d,p,y)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[y]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,f=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.degree||i.angle||0)*(Math.PI/180),l=(a=t.createConicGradient)==null?void 0:a.call(t,u,h,f);if(l){if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,y=r(d.color||"#000000",d.opacity??100);l.addColorStop(Math.max(0,Math.min(1,p)),y)}),i.gradientTransform&&l.setTransform){const[d,p,y,b,m,v]=i.gradientTransform;l.setTransform({a:d,b:p,c:y,d:b,e:m,f:v})}return l}}else if(i.type==="DiamondGradient"){const c=(d,p,y)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[y]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,f=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,f),t.rotate(Math.PI/4);const l=t.createRadialGradient(0,0,0,0,0,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,y=r(d.color||"#000000",d.opacity??100);l.addColorStop(Math.max(0,Math.min(1,p)),y)}),i.gradientTransform&&l.setTransform){const[d,p,y,b,m,v]=i.gradientTransform;l.setTransform({a:d,b:p,c:y,d:b,e:m,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=l,t.restore(),l}}if(i.type==="Pattern"&&i.url){let r=this.imageCache.get(i.url);if(r||(r=new Image,r.src=i.url,this.imageCache.set(i.url,r)),r.complete&&r.naturalWidth>0){const c=t.createPattern(r,"repeat");if(c&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,f=i.scaleX??1,u=i.scaleY??1,l=i.offsetX??0,d=i.offsetY??0,p=i.rotation??0;h.translateSelf(l,d),h.rotateSelf(p),h.scaleSelf(f,u),c.setTransform(h)}return c}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,c=0,h=0,f=0;typeof a=="number"?r=c=h=f=a:Array.isArray(a)?a.length===1?r=c=h=f=a[0]:a.length===2?(r=h=a[0],c=f=a[1]):a.length===3?(r=a[0],c=f=a[1],h=a[2]):a.length>=4&&(r=a[0],c=a[1],h=a[2],f=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,c=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,f=a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),u),c=Math.min(Math.max(0,c),u),h=Math.min(Math.max(0,h),u),f=Math.min(Math.max(0,f),u),t.roundRect){t.roundRect(i,o,e,s,[r,c,h,f]);return}t.moveTo(i+r,o),t.lineTo(i+e-c,o),t.arcTo(i+e,o,i+e,o+c,c),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+f,o+s),t.arcTo(i,o+s,i,o+s-f,f),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var A,W,z,Y;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,c=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",f=e.items||[],u=e.itemGap??10,l=e.itemHeight??50,d=e.itemWidth??200,p=e.scrollOffset??0,y=e.padding??0,b=e.glassEffect!==!1,m=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,I=e.glowIntensity??0,M=e.glowColor||"#3b82f6",k=typeof M=="string"?M:M.color||((Y=(z=M.stops)==null?void 0:z[0])==null?void 0:Y.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,I>0){const G=t.getTransform(),N=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=k,t.shadowBlur=I*2*N,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",N=this.createCanvasFill(t,G,s,n);t.fillStyle=N||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c)||t.fill();const x=t.createLinearGradient(a,r,a+s,r+n);x.addColorStop(0,"rgba(255, 255, 255, 0.15)"),x.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),x.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=x,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c)||t.stroke()}else{const G=e.backgroundColor||e.listBackgroundColor||"transparent",N=this.createCanvasFill(t,G,s,n);if(N){t.fillStyle=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,c);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const G=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip(G),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const P=typeof y=="number"?y:h==="vertical"?y[0]:y[3];let _=(h==="vertical"?r:a)+p+P;if(t.textBaseline="middle",f.forEach((G,N)=>{const J=e.listLayout||"linear",x=J==="circular"?d:h==="vertical"?s:d,F=J==="circular"||h==="vertical"?l:n;let j=0,X=0,tt=0;if(J==="circular"){const vt=f.length||1,Dt=Math.PI*2/vt,ae=e.circularStartAngle||0,pe=e.circularRadius||100,st=p*.01+ae*Math.PI/180,mt=N*Dt+st,Rt=a+s/2,_t=r+n/2;j=Rt+Math.cos(mt)*pe-x/2,X=_t+Math.sin(mt)*pe-F/2,tt=mt+(e.itemRotation||0)*Math.PI/180}else j=h==="vertical"?a:_,X=h==="vertical"?_:r,tt=(e.itemRotation||0)*Math.PI/180;const L=C===N,R=w===N,D=R&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",q=R&&e.activeItemShape?e.activeItemPath:e.itemPath||"",ot=e.itemCornerRadius||0;if(t.save(),tt!==0&&(t.translate(j+x/2,X+F/2),t.rotate(tt),t.translate(-(j+x/2),-(X+F/2))),R){const vt=this.createCanvasFill(t,m,x,F);t.fillStyle=vt||m;const Dt=t.globalAlpha;t.globalAlpha=Dt*.8,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill()),t.globalAlpha=Dt}else if(L)t.fillStyle=b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill());else if(S!=="transparent"){const vt=this.createCanvasFill(t,S,x,F);t.fillStyle=vt||S,t.beginPath(),this.drawCustomShape(t,D,q,j,X,x,F,ot)||(t.rect(j,X,x,F),t.fill())}if(R||L){const vt=this.createCanvasFill(t,m,h==="vertical"?3:x,h==="vertical"?F:3);t.fillStyle=vt||m,h==="vertical"?t.fillRect(j,X,3,F):t.fillRect(j,X+F-3,x,3)}const yt=R?"#ffffff":b?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=yt,t.font=R||L?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const bt=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${N+1}`,gt=j+(h==="vertical"?16:x/2),Et=X+F/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?j+x/2:gt;t.fillText(bt,It,Et),t.restore(),_+=(h==="vertical"?l:d)+u}),t.restore(),e.showScrollbar!==!1){const G=(f.length||0)*(h==="vertical"?l:d)+((f.length||0)-1)*u,N=h==="vertical"?n:s,J=e.listLayout||"linear",x=e.containerShape==="circle"||J==="circular";if(G>N||J==="circular"&&f.length>0){const F=e.scrollbarColor||"rgba(255,255,255,0.3)",j=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-j/2-2,tt=a+s/2,L=r+n/2;if(t.strokeStyle=F,t.lineWidth=j,t.lineCap="round",t.beginPath(),J==="circular"){const R=Math.PI/4,D=-(p*.01)-Math.PI/2;t.arc(tt,L,X,D,D+R)}else{const R=Math.PI/2,D=N/G,q=R*D,ot=-p/G*R,bt=-Math.PI/4+ot;t.arc(tt,L,X,bt,bt+q)}t.stroke()}else{const X=N/G,tt=N*X,L=-p/G*N;t.fillStyle=F,h==="vertical"?t.fillRect(a+s-j-2,r+L,j,tt):t.fillRect(a+L,r+n-j-2,tt,j)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const c=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,c,0,Math.PI*2),!1}else if(i==="pill"){const c=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,c),!1}else if(i==="custom"&&o)try{const c=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(c),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,r),!1}return this.drawListViewRect(t,e,s,n,a,r),!1}updateListViewScrollFromPointer(t){var b,m;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},r=i.items||[],c=i.itemGap??10,h=i.itemHeight??50,f=i.itemWidth??200,u=a.width!==void 0?a.width:((b=t.geometry)==null?void 0:b.width)||200,l=a.height!==void 0?a.height:((m=t.geometry)==null?void 0:m.height)||300;if(n==="circular")return;const d=(r.length||0)*(o==="vertical"?h:f)+((r.length||0)-1)*c,y=Math.max(0,d-(o==="vertical"?l:u)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-y&&(i.scrollOffset=-y)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var z,Y;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((z=t.geometry)==null?void 0:z.width)||200,r=s.height!==void 0?s.height:((Y=t.geometry)==null?void 0:Y.height)||300,c=e.orientation||"vertical",h=e.itemGap??10,f=e.itemHeight??50,u=e.itemWidth??200,l=e.scrollOffset??0,d=e.padding??0,p=this.getWorldTransform(t.id),y=i-p.x,b=o-p.y,m=-p.rotation*(Math.PI/180),v=Math.cos(m),S=Math.sin(m),C=y*v-b*S,w=y*S+b*v,I=-a/2,M=-r/2,k=typeof d=="number"?d:c==="vertical"?d[0]:d[3];let T=(c==="vertical"?M:I)+l+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,W=l*.01+E*Math.PI/180;for(let G=0;G<n.length;G++){const N=O==="circular"?u:c==="vertical"?a:u,J=O==="circular"||c==="vertical"?f:r;let x=0,F=0,j=0;if(O==="circular"){const X=G*_+W,tt=I+a/2,L=M+r/2;x=tt+Math.cos(X)*A-N/2,F=L+Math.sin(X)*A-J/2,j=X+(e.itemRotation||0)*Math.PI/180}else x=c==="vertical"?I:T,F=c==="vertical"?T:M,j=(e.itemRotation||0)*Math.PI/180;if(j!==0){const X=x+N/2,tt=F+J/2,L=C-X,R=w-tt,D=-j,q=L*Math.cos(D)-R*Math.sin(D)+X,ot=L*Math.sin(D)+R*Math.cos(D)+tt;if(q>=x&&q<=x+N&&ot>=F&&ot<=F+J)return G}else if(C>=x&&C<=x+N&&w>=F&&w<=F+J)return G;T+=(c==="vertical"?f:u)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var u,l,d,p,y,b,m,v,S,C,w,I,M,k,T,O,P,_,E,A,W,z,Y,G,N,J,x,F,j,X,tt,L,R,D,q,ot,yt,bt,gt,Et,It,vt,Dt,ae,pe,st,mt,Rt,_t,dt,$t,Vt,Bt,Ft,Ut,re,be,ve,Zt,Ce,_e,Pe,we,Ee,Ae,oe,se,ft,ut,at,B,et,Q,Pt,Ot,kt,At,Mt,$,Yt,jt,ie,te,pt,ct,Ct,rt,V,it,nt,St,Gt,ee,le,Nt,Kt,qt,Ie,xe,Oe,Le,Re,Fe,Xe,Ht,ce,Me,$e,Be,ge,de,ue,ke,De,qe,Ke,Ge,Je;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const c=s.x-i,h=s.y-o,f=Math.sqrt(c*c+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===H.Proximity){const U=((u=n.settings)==null?void 0:u.radius)||300,Z=((l=n.settings)==null?void 0:l.falloff)||"smooth";let K=0;f<U&&(Z==="linear"?K=1-f/U:K=Math.pow(1-f/U,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,K,t,n.settings,e,c,h,f)})}else if(n.type===H.Magnetic){const U=((d=n.settings)==null?void 0:d.radius)||400,Z=((p=n.settings)==null?void 0:p.strength)||.5;if(f<U&&f>5){const K=1-f/U,ht=c*K*Z,Tt=h*K*Z;s.x-=ht*t*10,s.y-=Tt*t*10}}else if(n.type===H.Repel){const U=((y=n.settings)==null?void 0:y.radius)||300,Z=((b=n.settings)==null?void 0:b.strength)||1;if(f<U){const K=Math.pow(1-f/U,2);s.x+=c/(f||1)*K*60*Z*t*5,s.y+=h/(f||1)*K*60*Z*t*5}}else if(n.type===H.Orbit){const U=((m=n.settings)==null?void 0:m.speed)||1,Z=((v=n.settings)==null?void 0:v.radius)||30,K=this.currentTime*U*Math.PI*2;s.x+=Math.cos(K)*Z*t*5,s.y+=Math.sin(K)*Z*t*5,s.rotation+=2*t*5}else if(n.type===H.Vortex){const U=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(f<U){const ht=Math.pow(1-f/U,1.5),Tt=this.currentTime*Z*Math.PI*2,Lt=Math.cos(Tt)*30-c*.4,Wt=Math.sin(Tt)*30-h*.4;s.x+=Lt*ht*K*t*5,s.y+=Wt*ht*K*t*5,s.rotation+=5*ht*K*t*5,s.scale_x*=1-ht*.1*K*t,s.scale_y*=1-ht*.1*K*t}}else if(n.type===H.Fluid){const U=((I=n.settings)==null?void 0:I.radius)||300,Z=((M=n.settings)==null?void 0:M.strength)||1;if(f<U){const K=Math.pow(1-f/U,1.2),ht=c/(f||1)*K*1.2*Z,Tt=h/(f||1)*K*1.2*Z;s.x+=ht*10*t*5,s.y+=Tt*10*t*5,s.scale_x*=1+K*.3*Z*t,s.scale_y*=1+K*.3*Z*t}}else if(n.type===H.Elastic){const U=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(f<U){const K=1-f/U;s.scale_x*=1+K*.4*Z*t,s.scale_y*=1+K*.4*Z*t}}else if(n.type===H.Holographic){const U=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=U/1e3*K*t*5,s.y-=Z/1e3*K*t*5,s.style){const ht=1-Math.min(1,f/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===H.Sticky){const U=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(f<U){const K=Math.pow(1-f/U,2);s.x-=c*K*Z*t*10,s.y-=h*K*Z*t*10,s.scale_x*=1-K*.1*Z*t,s.scale_y*=1-K*.1*Z*t}}else if(n.type===H.Dilation){const U=((E=n.settings)==null?void 0:E.size)||120,Z=((A=n.settings)==null?void 0:A.strength)||1;if(f<U){const K=1-f/U;s.scale_x*=1+K*.5*Z*t,s.scale_y*=1+K*.5*Z*t}}else if(n.type===H.Parallax){const U=((W=n.settings)==null?void 0:W.factor)||15,Z=((z=n.settings)==null?void 0:z.strength)||1,K=this.canvasWidth/2,ht=this.canvasHeight/2,Tt=this._lastPointerPos||{x:K,y:ht},Lt=(Tt.x-K)/K,Wt=(Tt.y-ht)/ht,ne=(((Y=e.transform)==null?void 0:Y.x)??0)+Lt*U*Z,me=(((G=e.transform)==null?void 0:G.y)??0)+Wt*U*Z,Te=(((N=e.transform)==null?void 0:N.rotate_x)??0)-Wt*U*1.5*Z,fe=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Lt*U*1.5*Z,Se=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,ne,Se),s.y=this.lerp(s.y??((F=e.transform)==null?void 0:F.y)??0,me,Se),s.rotate_x=this.lerp(s.rotate_x??((j=e.transform)==null?void 0:j.rotate_x)??0,Te,Se),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,Se)}else if(n.type===H.Fold){if(f<300){const U=1-f/300,Z=(c>0?-1:1)*U*10,K=1-U*.1,ht=h/300*U*20,Tt=-(c/300)*U*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((tt=e.transform)==null?void 0:tt.skew_x)??0,Z,Lt),s.scale_y=this.lerp(s.scale_y??((L=e.transform)==null?void 0:L.scale_y)??1,(((R=e.transform)==null?void 0:R.scale_y)??1)*K,Lt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,ht,Lt),s.rotate_y=this.lerp(s.rotate_y??((q=e.transform)==null?void 0:q.rotate_y)??0,Tt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((ot=n.settings)==null?void 0:ot.opacity)??.5}}}else if(n.type===H.Crumple){if(f<300){const U=1-f/300,Z=U*(Math.random()-.5)*5,K=U*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((yt=e.transform)==null?void 0:yt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((bt=e.transform)==null?void 0:bt.scale_x)??1,(((gt=e.transform)==null?void 0:gt.scale_x)??1)*(1+K),ht),s.scale_y=this.lerp(s.scale_y??((Et=e.transform)==null?void 0:Et.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((vt=n.settings)==null?void 0:vt.intensity)??1,scale:((Dt=n.settings)==null?void 0:Dt.scale)??2}}}else if(n.type===H.Squash){const U=((ae=n.settings)==null?void 0:ae.strength)||.8;f<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((pe=e.transform)==null?void 0:pe.scale_y)??1)*U,.3),s.scale_x=this.lerp(s.scale_x??1,(((st=e.transform)==null?void 0:st.scale_x)??1)*(1+(1-U)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((mt=e.transform)==null?void 0:mt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Rt=e.transform)==null?void 0:Rt.scale_x)??1,.2))}else if(n.type===H.TextCounter){const U=((_t=n.settings)==null?void 0:_t.duration)||2,Z=((dt=n.settings)==null?void 0:dt.from)||0,K=(($t=n.settings)==null?void 0:$t.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,Tt=Math.min(1,ht/U),Lt=Math.floor(Z+(K-Z)*Tt);if(((Vt=e.geometry)==null?void 0:Vt.type)==="Text"){const Wt=((Bt=n.settings)==null?void 0:Bt.prefix)||"",ne=((Ft=n.settings)==null?void 0:Ft.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Wt}${Lt}${ne}`}}else if(n.type===H.Spotlight){const U=((Ut=n.settings)==null?void 0:Ut.radius)||250,Z=((re=n.settings)==null?void 0:re.strength)||1.5;if(f<U){const K=Math.pow(1-f/U,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(be=e.style)==null?void 0:be.adjustments}),s.style.adjustments.exposure=(((Zt=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Zt.exposure)||0)+K*Z*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Pe=(_e=e.style)==null?void 0:_e.adjustments)==null?void 0:Pe.exposure)||0,.1))}else if(n.type===H.Noise||n.type===H.Float){const U=(((we=n.settings)==null?void 0:we.frequency)||((Ee=n.settings)==null?void 0:Ee.speed)||1)*.002,Z=(((Ae=n.settings)==null?void 0:Ae.amplitude)||((oe=n.settings)==null?void 0:oe.range)||50)*(((se=n.settings)==null?void 0:se.strength)||1),K=Date.now();s.x+=Math.sin(K*U)*Z*t,s.y+=Math.cos(K*U*.8)*Z*t,s.rotation+=Math.sin(K*U*.5)*5*t}else if(n.type===H.Pulse){const U=(((ft=n.settings)==null?void 0:ft.speed)||1)*.005,Z=(((ut=n.settings)==null?void 0:ut.scale)||1.2)-1,K=Math.sin(Date.now()*U),ht=((at=n.settings)==null?void 0:at.strength)||1;s.scale_x*=1+K*Z*ht*t,s.scale_y*=1+K*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*ht*t)}else if(n.type===H.Draggable){const U=((B=n.settings)==null?void 0:B.radius)||150,Z=this.draggingBehaviors.has(e.id);if(f<U||Z){const K=((et=n.settings)==null?void 0:et.strength)||1,ht=Z?1:Math.max(0,1-f/U);this.applyBehaviorSensor(s,Qt.PositionX,ht*K,t,n.settings),this.applyBehaviorSensor(s,Qt.PositionY,ht*K,t,n.settings)}}else if(n.type===H.Scroll){const U=((Q=n.settings)==null?void 0:Q.axis)||"vertical",Z=((Pt=n.settings)==null?void 0:Pt.factor)||.5,K=((Ot=n.settings)==null?void 0:Ot.strength)||1,ht=((kt=n.settings)==null?void 0:kt.scaleFactor)||0;(U==="vertical"||U==="both")&&(s.y+=this.scrollOffset.y*Z*K*t),(U==="horizontal"||U==="both")&&(s.x+=this.scrollOffset.x*Z*K*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===H.LookAt){const U=((At=n.settings)==null?void 0:At.factor)||1,Z=((Mt=n.settings)==null?void 0:Mt.strength)||1,K=Math.atan2(-h,-c)*(180/Math.PI),ht=s.rotation,Tt=(K-ht+180)%360-180;s.rotation+=Tt*U*Z*t*10}else if(n.type===H.Scan){const U=((($=n.settings)==null?void 0:$.speed)||1)*.004,Z=((Yt=n.settings)==null?void 0:Yt.strength)||1,K=(Math.sin(Date.now()*U)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Z*t*5),s.x+=(K-.5)*20*Z*t}else if(n.type===H.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((jt=n.settings)==null?void 0:jt.strength)??.8};else if(n.type===H.Ratchet){const U=((ie=n.settings)==null?void 0:ie.steps)||12,Z=(((te=n.settings)==null?void 0:te.speed)||1)*30,K=Math.floor(s.rotation/(360/U))*(360/U);s.rotation=this.lerp(s.rotation,K+Z*t,.1)}else if(n.type===H.Jitter&&f<300){const U=((pt=n.settings)==null?void 0:pt.strength)||1,Z=(((ct=n.settings)==null?void 0:ct.intensity)||5)*U;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===H.Follower){const U=(Ct=n.settings)==null?void 0:Ct.targetId;if(U){const Z=this.objectStates.get(U);if(Z){const K=((rt=n.settings)==null?void 0:rt.stiffness)||.1,ht=Z.x-s.x,Tt=Z.y-s.y;s.x+=ht*K*t*60,s.y+=Tt*K*t*60}}}else if(n.type===H.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===H.Gravity){const U=((V=n.settings)==null?void 0:V.strength)||9.8;s.y+=U*t*10}else if(n.type===H.Velocity){const U=((it=n.settings)==null?void 0:it.vx)||0,Z=((nt=n.settings)==null?void 0:nt.vy)||0;s.x+=U*t*10,s.y+=Z*t*10}else if(n.type===H.Shear){const U=((St=n.settings)==null?void 0:St.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(f<Z){const K=1-f/Z;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*U*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((le=e.transform)==null?void 0:le.skew_x)||0,.05)}else if(n.type===H.Lens){const U=((Nt=n.settings)==null?void 0:Nt.radius)||200,Z=((Kt=n.settings)==null?void 0:Kt.strength)||.5;if(f<U){const K=Math.pow(1-f/U,2);s.scale_x=this.lerp(s.scale_x??1,(((qt=e.transform)==null?void 0:qt.scale_x)??1)*(1+K*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ie=e.transform)==null?void 0:Ie.scale_y)??1)*(1+K*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===H.LayoutAnimation){const U=((Le=n.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Re=n.settings)==null?void 0:Re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const ht of U){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0)continue;const Lt=K.get(ht);if(!Lt)K.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);K.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:((Fe=n.settings)==null?void 0:Fe.duration)??Z})}const Wt=K.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,me=Math.min(1,ne/Wt.duration),Te=this.applyEasing(me,((Xe=n.settings)==null?void 0:Xe.easing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const U=this._layoutAnimCache.get(e.id),Z=((Ht=n.settings)==null?void 0:Ht.defaultDuration)||.3,K=["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 ht of K){const Tt=this.getObjectProperty(s,e,ht);if(Tt===void 0||typeof Tt!="number")continue;const Lt=U.get(ht);if(!Lt)U.set(ht,{from:Tt,to:Tt,startTime:this.currentTime,duration:0});else if(Lt.to!==Tt){const ne=this.getObjectProperty(s,e,ht);U.set(ht,{from:ne??Lt.from,to:Tt,startTime:this.currentTime,duration:Z})}const Wt=U.get(ht);if(Wt.duration>0&&Wt.from!==Wt.to){const ne=this.currentTime-Wt.startTime,me=Math.min(1,ne/Wt.duration),Te=this.applyEasing(me,((ce=n.settings)==null?void 0:ce.defaultEasing)||"easeOutCubic"),fe=Wt.from+(Wt.to-Wt.from)*Te;this.setObjectProperty(s,e,ht,fe)}}}else if(n.type===H.SpringChain){const U=((Me=n.settings)==null?void 0:Me.connections)||[],Z=(($e=n.settings)==null?void 0:$e.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Tt of U){if(!K.has(Tt.targetId)){const Lt=this.objectStates.get(Tt.targetId);K.set(Tt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=K.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const Tt of U){const Lt=K.get(Tt.targetId);if(!Lt)continue;const Wt=Lt.x-ht.x,ne=Lt.y-ht.y,me=Math.sqrt(Wt*Wt+ne*ne)||.001,fe=(me-(Tt.restLength||50))*(Tt.stiffness||.8),Se=Wt/me*fe,Qe=ne/me*fe;ht.vx+=Se*t*10,ht.vy+=Qe*t*10,Lt.vx-=Se*t*10,Lt.vy-=Qe*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,Lt.vx*=1-Z*t*10,Lt.vy*=1-Z*t*10;const ye=this.objectStates.get(Tt.targetId);ye&&(ye.x+=Lt.vx*t,ye.y+=Lt.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===H.ParticleEmitter){const U=((Be=n.settings)==null?void 0:Be.rate)||10,Z=((ge=n.settings)==null?void 0:ge.speed)||100,K=((de=n.settings)==null?void 0:de.size)||5,ht=((ue=n.settings)==null?void 0:ue.lifetime)||2,Tt=((ke=n.settings)==null?void 0:ke.gravity)||0,Lt=((De=n.settings)==null?void 0:De.color)||"#ffffff",Wt=((qe=n.settings)==null?void 0:qe.maxParticles)||200,ne=(Ke=n.settings)!=null&&Ke.rateInputId?this.inputs.get(n.settings.rateInputId)??U:U,me=(Ge=n.settings)!=null&&Ge.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Tt:Tt,Te=(Je=n.settings)!=null&&Je.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let Se=0;n._pendingBurst&&n._pendingBurst>0&&(Se=n._pendingBurst,n._pendingBurst=0);const Qe=Math.floor(ne*t)+(Se||0);for(let ye=0;ye<Math.min(Qe,Wt-fe.length);ye++){const he=Math.random()*Math.PI*2,ys=Te*(.5+Math.random()*.5);fe.push({x:s.x,y:s.y,vx:Math.cos(he)*ys,vy:Math.sin(he)*ys,life:0,maxLife:ht*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Lt,opacity:1})}for(let ye=fe.length-1;ye>=0;ye--){const he=fe[ye];he.vy+=me*t*10,he.x+=he.vx*t,he.y+=he.vy*t,he.life+=t,he.opacity=Math.max(0,1-he.life/he.maxLife),he.life>=he.maxLife&&fe.splice(ye,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,r=0,c=1){var d,p,y,b,m,v,S,C,w,I,M,k,T,O,P,_,E,A,W,z,Y,G,N,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,f=Math.min(1,15*e),u=c>0?a/c:0,l=c>0?r/c:0;switch(i){case Qt.Scale:{const x=((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,j=x*(1+o*h*.4),X=F*(1+o*h*.4);t.scale_x=(t.scale_x??x)*(1-f)+j*f,t.scale_y=(t.scale_y??F)*(1-f)+X*f;break}case Qt.Opacity:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.opacity)??100,F=Math.max(0,Math.min(100,x-o*h*100));t.opacity=(t.opacity??x)*(1-f)+F*f;break}case Qt.RotateZ:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotation)??0,F=x+o*h*45;t.rotation=(t.rotation??x)*(1-f)+F*f;break}case Qt.RotateX:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotate_x)??0,F=x-l*o*h*60;t.rotate_x=(t.rotate_x??x)*(1-f)+F*f;break}case Qt.RotateY:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,F=x+u*o*h*60;t.rotate_y=(t.rotate_y??x)*(1-f)+F*f;break}case Qt.PositionX:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,F=x-u*o*h*40;t.x=(t.x??x)*(1-f)+F*f;break}case Qt.PositionY:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,F=x-l*o*h*40;t.y=(t.y??x)*(1-f)+F*f;break}case Qt.SkewX:{const x=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,F=x+u*o*h*45;t.skew_x=(t.skew_x??x)*(1-f)+F*f,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case Qt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(I=n==null?void 0:n.style)==null?void 0:I.blur});const x=((k=(M=n==null?void 0:n.style)==null?void 0:M.blur)==null?void 0:k.amount)||0,F=x+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??x)*(1-f)+F*f;break}case Qt.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 x=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,F=x+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-f)+F*f;break}case Qt.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 x=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,F=x+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-f)+F*f;break}case Qt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const x=((Y=(z=n==null?void 0:n.style)==null?void 0:z.adjustments)==null?void 0:Y.negative)||0,F=x+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-f)+F*f;break}case Qt.CornerRadius:{const x=((G=n==null?void 0:n.transform)==null?void 0:G.corner_radius)||0,F=x+o*h*50;t.corner_radius=(t.corner_radius??x)*(1-f)+F*f;break}case Qt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((N=n==null?void 0:n.style)==null?void 0:N.borderWidth)||0,F=x+o*h*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-f)+F*f;break}case Qt.LetterSpacing:{t.geometry||(t.geometry={});const x=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,F=x+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-f)+F*f;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let r=0;r<s.length-1;r++){const c=s[r];if(n[c]===void 0||n[c]===null){const h=i,f=s.slice(0,r+1).reduce((u,l)=>u==null?void 0:u[l],h);n[c]=f!==void 0?{...f}:{}}n=n[c]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){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,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const r=i.naturalWidth,c=i.naturalHeight,h=r/c,f=s/n;let u=s,l=n,d=o,p=e;a==="cover"?h>f?(u=n*h,d=o-(u-s)/2):(l=s/h,p=e-(l-n)/2):a==="contain"&&(h>f?(l=s/h,p=e+(n-l)/2):(u=n*h,d=o+(s-u)/2)),t.drawImage(i,d,p,u,l)}}const ni=xt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:c,onToggle:h,onInputChange:f,onInputFocus:u,onInputBlur:l,onLog:d,onLogicUpdate:p,onButtonClick:y,onGraphPointClick:b,currentTime:m,revision:v=0,scrollY:S,scrollX:C,mouseX:w,mouseY:I,isMouseDown:M,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=xt.useRef(null),E=xt.useRef(null);E.current||(E.current=new ms);const A=xt.useRef(void 0),W=xt.useRef(0),z=xt.useRef(null),Y=xt.useRef(v),G=xt.useRef(null),[,N]=xt.useState(g||null),J=xt.useRef(!0);xt.useImperativeHandle(P,()=>_.current),xt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),xt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),xt.useEffect(()=>{const L=E.current;a&&L.setTriggerCallback(a),r&&L.setInputUpdateCallback((R,D)=>r({[R]:D})),c&&L.setComponentChangeCallback(R=>c(R)),h&&L.setToggleCallback(h),f&&L.setInputChangeCallback(f),u&&L.setInputFocusCallback(u),l&&L.setInputBlurCallback(l),d&&L.setOnLogCallback(R=>d(R,"info")),p&&L.setLogicUpdateCallback(p),y&&L.setButtonClickCallback(y),b&&L.setGraphPointClickCallback(R=>b(R.objectId,R)),O&&L.setNavigationCallback(O)},[a,r,c,h,f,u,l,d,p,y,b,O]),xt.useEffect(()=>{(async()=>{let R=g;if(t&&!g)try{t.startsWith("{")?R=JSON.parse(t):R=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(R){const D=E.current,q=R.id||R.name||"default";(z.current!==q||Y.current!==v||G.current!==R)&&(D.load(R),z.current=q,Y.current=v,G.current=R,N(R),W.current=0,D.advance(0)),n&&n(D)}})()},[g,t,v]),xt.useEffect(()=>{const L=R=>{if(!E.current||!J.current)return;const D=E.current,q=_.current;if(!q)return;const ot=q.getContext("2d");if(!ot)return;const yt=R/1e3;W.current===0&&(W.current=yt);let bt=yt-W.current;bt>.1&&(bt=.1),W.current=yt;const gt=q.getBoundingClientRect(),Et=window.devicePixelRatio||1,It=Math.round(gt.width*Et),vt=Math.round(gt.height*Et);(q.width!==It||q.height!==vt)&&(q.width=It,q.height=vt);try{o?D.advance(bt):m!==void 0&&D.seek(m),D.render(ot,q.width,q.height)}catch(Dt){console.error("[ExodeUICanvas] Error in animation loop:",Dt),d&&d(`[Error] Animation loop crashed: ${Dt}`,"error")}A.current=requestAnimationFrame(L)};return A.current=requestAnimationFrame(L),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,m]),xt.useEffect(()=>{const L=E.current;S!==void 0&&L.updateInput("scrollY",S),C!==void 0&&L.updateInput("scrollX",C),w!==void 0&&L.updateInput("mouseX",w),I!==void 0&&L.updateInput("mouseY",I),M!==void 0&&L.updateInput("isMouseDown",M),k&&Object.entries(k).forEach(([R,D])=>L.updateInput(R,D))},[S,C,w,I,M,k]);const x=(L,R)=>{if(!T||!_.current)return;L.stopPropagation(),"nativeEvent"in L&&L.nativeEvent&&typeof L.nativeEvent.stopImmediatePropagation=="function"?L.nativeEvent.stopImmediatePropagation():typeof L.stopImmediatePropagation=="function"&&L.stopImmediatePropagation();const D=_.current,q=D.getBoundingClientRect(),ot=L.clientX-q.left,yt=L.clientY-q.top,bt=window.devicePixelRatio||1;(R==="click"||R==="down"||R==="up")&&d&&d(`[Canvas] Pointer ${R} at rect(${Math.round(ot)},${Math.round(yt)}) mapped to buffer(${Math.round(ot*bt)},${Math.round(yt*bt)})`,"info"),E.current.handlePointerInput(R,ot*bt,yt*bt,D.width,D.height)};xt.useEffect(()=>{if(!T)return;const L=D=>{var q,ot,yt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(yt=E.current)==null||yt.handleKeyDown(D)},R=D=>{var q,ot,yt;((q=document.activeElement)==null?void 0:q.tagName)==="INPUT"||((ot=document.activeElement)==null?void 0:ot.tagName)==="TEXTAREA"||(yt=E.current)==null||yt.handleKeyUp(D)};return window.addEventListener("keydown",L),window.addEventListener("keyup",R),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",R)}},[T]);const[F,j]=xt.useState([]);xt.useEffect(()=>{if(g&&g.objects){const L=g.objects.filter(R=>{var D,q;return R.type==="Joystick"&&((D=R.inputBinding)==null?void 0:D.type)==="keyboard"&&((q=R.inputBinding.keyboardConfig)==null?void 0:q.showVirtualKeyboard)});j(L)}},[g]);const[,X]=xt.useState(0);xt.useEffect(()=>{if(F.length===0)return;let L;const R=()=>{X(D=>D+1),L=requestAnimationFrame(R)};return L=requestAnimationFrame(R),()=>cancelAnimationFrame(L)},[F.length]);const tt=()=>F.map(L=>{const R=L.inputBinding.keyboardConfig,D=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(Et)},q=gt=>{var It;const Et={key:gt,code:gt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(Et)},ot=E.current,yt=gt=>ot&&ot.activeKeys?ot.activeKeys.has(gt.toLowerCase()):!1,bt=gt=>({width:"50px",height:"50px",background:gt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:gt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:bt(yt(R.upKey)),onMouseDown:()=>D(R.upKey),onMouseUp:()=>q(R.upKey),onMouseLeave:()=>q(R.upKey),onTouchStart:gt=>{gt.preventDefault(),D(R.upKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.upKey)},children:R.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:bt(yt(R.leftKey)),onMouseDown:()=>D(R.leftKey),onMouseUp:()=>q(R.leftKey),onMouseLeave:()=>q(R.leftKey),onTouchStart:gt=>{gt.preventDefault(),D(R.leftKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.leftKey)},children:R.leftKey.toUpperCase()}),Xt.jsx("div",{style:bt(yt(R.downKey)),onMouseDown:()=>D(R.downKey),onMouseUp:()=>q(R.downKey),onMouseLeave:()=>q(R.downKey),onTouchStart:gt=>{gt.preventDefault(),D(R.downKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.downKey)},children:R.downKey.toUpperCase()}),Xt.jsx("div",{style:bt(yt(R.rightKey)),onMouseDown:()=>D(R.rightKey),onMouseUp:()=>q(R.rightKey),onMouseLeave:()=>q(R.rightKey),onTouchStart:gt=>{gt.preventDefault(),D(R.rightKey)},onTouchEnd:gt=>{gt.preventDefault(),q(R.rightKey)},children:R.rightKey.toUpperCase()})]})]},L.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:L=>{var R;x(L,"down"),(R=_.current)==null||R.focus()},onPointerMove:L=>x(L,"move"),onPointerUp:L=>x(L,"up"),onPointerCancel:L=>x(L,"up"),onClick:L=>x(L,"click"),onWheel:L=>{E.current.handleWheel(L.deltaX,L.deltaY)},onKeyDown:L=>E.current.handleKeyDown(L.nativeEvent),onKeyUp:L=>E.current.handleKeyUp(L.nativeEvent),onContextMenu:L=>L.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),tt()]})});function oi(){const[g,t]=xt.useState(null),i=xt.useCallback((f,u)=>{g==null||g.setInputBool(f,u)},[g]),o=xt.useCallback((f,u)=>{g==null||g.setInputNumber(f,u)},[g]),e=xt.useCallback(f=>{g==null||g.fireTrigger(f)},[g]),s=xt.useCallback((f,u)=>{g==null||g.setInputText(f,u)},[g]),n=xt.useCallback((f,u)=>{g==null||g.setInputNumberArray(f,u)},[g]),a=xt.useCallback((f,u)=>{g==null||g.setInputStringArray(f,u)},[g]),r=xt.useCallback((f,u)=>{g==null||g.updateObjectOptions(f,u)},[g]),c=xt.useCallback((f,u,l)=>{g==null||g.updateConstraint(f,u,l)},[g]),h=xt.useCallback((f,u)=>{g==null||g.updateGraphData(f,u)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:c,updateGraphData:h,updateObjectOptions:r}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let r=i.description;if(!r&&o){const f=g.objects.filter(u=>{var l;return((l=u.geometry)==null?void 0:l.type)==="Text"}).sort((u,l)=>{var d,p;return(((d=l.geometry.text)==null?void 0:d.length)||0)-(((p=u.geometry.text)==null?void 0:p.length)||0)});f.length>0&&(r=f[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const c=i.ogImage||g.backgroundImage;c&&e("property","og:image",c),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,r,c)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",c)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((c,h)=>{var f,u;if(!(c.visible===!1||c.isVisible===!1))if(((f=c.geometry)==null?void 0:f.type)==="Text"){const l=c.geometry.text;l&&(c.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:l},c.id||h)):a.push(Xt.jsx("p",{children:l},c.id||h)))}else if(((u=c.geometry)==null?void 0:u.type)==="Image"){const l=c.geometry.src,d=c.altText||c.name||"Illustration";a.push(Xt.jsx("img",{src:l,alt:d},c.id||h))}else c.type==="Button"&&a.push(Xt.jsx("button",{children:c.name||"Button"},c.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.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:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.43"}.version;zt.BehaviorSensor=Qt,zt.BehaviorType=H,zt.ConditionOp=je,zt.ExodeSEO=ai,zt.ExodeUICanvas=ni,zt.ExodeUIEngine=ms,zt.LogicOp=wt,zt.RapierPhysics=is,zt.VERSION=ri,zt.useExodeUI=oi,Object.defineProperty(zt,Symbol.toStringTag,{value:"Module"})}));
|
|
4
|
+
`&&P++);m={...m,widths:I,indentApplied:!0}}if(!m)return{width:a,height:0,lineCount:0,lines:[]};let v=n;typeof v=="string"&&(v=parseFloat(v)),v>5&&o>0&&(v=v/o),l!==0&&(CanvasRenderingContext2D.prototype.measureText=S);let C;try{const I=m.maxFontSize||o;if(a>=1e5){const T=d.split(/\r\n|\r|\n/);C={lines:T.map(O=>({text:O,width:0})),height:T.length*(v*I),lineCount:T.length}}else C=Ye.layoutWithLines(m,a,v*I)}finally{l!==0&&y&&(CanvasRenderingContext2D.prototype.measureText=y)}let w=(C==null?void 0:C.height)!==void 0&&C.height>0?C.height:(((k=C==null?void 0:C.lines)==null?void 0:k.length)||0)*v*o;if(r>0&&C&&C.lines&&C.lines.length>1){let I=0;const T=m.fullText||t;for(let O=0;O<C.lines.length-1;O++)I+=C.lines[O].text.length,(T[I]===`
|
|
5
|
+
`||T[I]==="\r")&&(w+=r,I++,T[I-1]==="\r"&&T[I]===`
|
|
6
|
+
`&&I++)}let M=(C==null?void 0:C.lines)||[];return g.composer==="every-line"&&M.length>1&&(M=Ms(M)),g.balanceRaggedLines===!0&&M.length>1&&(M=ks(M)),{width:a,height:w,lineCount:M.length,lines:M}}function Ze(g,t,i){let o=String(g||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const l=Math.max(1,parseInt(o));o=new Array(l).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((l,r)=>{if(l.endsWith("px")){const h=parseFloat(l);s[r]=h,n-=h}else l.endsWith("fr")?a+=parseFloat(l):l==="auto"&&(s[r]=100,n-=100)}),a>0&&n>0){const l=n/a;e.forEach((r,h)=>{r.endsWith("fr")&&(s[h]=l*parseFloat(r))})}return s}function je(g,t,i){try{const o=g.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(g,t,i):Is(g,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Is(g,t,i){var _,E;const o=g.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:l}=o,r=e==="vertical",h=t.map(A=>{const B=i(A.id),X=A.geometry;let W=(B==null?void 0:B.width)??X.width??100,Y=(B==null?void 0:B.height)??X.height??100;if(X.type==="Ellipse"||X.type==="Polygon"||X.type==="Star"){const z=(B==null?void 0:B.radius)??X.radius??(B==null?void 0:B.outer_radius)??X.outer_radius??50;W=z*2,Y=z*2}else if(X.type==="Text"){const z=Qe({text:(B==null?void 0:B.text)??X.text??"",fontFamily:X.fontFamily,fontSize:X.fontSize,fontWeight:X.fontWeight,fontStyle:X.fontStyle,lineHeight:X.lineHeight,width:X.width||200,letterSpacing:X.letterSpacing,paragraphSpacing:X.paragraphSpacing,paragraphIndent:X.paragraphIndent,textCase:X.textCase,segments:X.segments,enableSegments:X.enableSegments});Y=z.height,X.width||(W=z.width)}return W*=A.transform.scale_x||1,Y*=A.transform.scale_y||1,{id:A.id,w:W,h:Y,original:A}});let f=g.width,p=g.height;const c=((_=g.layoutProps)==null?void 0:_.width)==="hug",d=((E=g.layoutProps)==null?void 0:E.height)==="hug",u=[];let b=[],m=0,y=0;const S=f-n.left-n.right,v=p-n.top-n.bottom;h.forEach(A=>{l&&b.length>0&&(r?y+s+A.h>v:m+s+A.w>S)?(u.push({children:b,width:m,height:y}),b=[A],m=A.w,y=A.h):(b.push(A),r?(m=Math.max(m,A.w),y+=(b.length>1?s:0)+A.h):(m+=(b.length>1?s:0)+A.w,y=Math.max(y,A.h)))}),b.length>0&&u.push({children:b,width:m,height:y}),c&&!r&&(f=Math.max(...u.map(A=>A.width),0)+n.left+n.right),d&&r&&(p=Math.max(...u.map(A=>A.height),0)+n.top+n.bottom);const C=[];let w=n.left,M=n.top;const k=a.toLowerCase(),I=k==="center"||k.endsWith("-center"),T=k.endsWith("-right"),O=k==="center"||k.startsWith("center-"),P=k.startsWith("bottom-");return u.forEach(A=>{let B=w,X=M;r?O?X=n.top+(p-n.top-n.bottom-A.height)/2:P&&(X=p-n.bottom-A.height):I?B=n.left+(f-n.left-n.right-A.width)/2:T&&(B=f-n.right-A.width),A.children.forEach(W=>{var x,et;let Y=B,z=X;r?I?Y+=(A.width-W.w)/2:T&&(Y+=A.width-W.w):O?z+=(A.height-W.h)/2:P&&(z+=A.height-W.h);const J=((x=W.original.layoutProps)==null?void 0:x.width)==="fill",L=((et=W.original.layoutProps)==null?void 0:et.height)==="fill";C.push({id:W.id,x:Y+W.w/2-f/2,y:z+W.h/2-p/2,width:J&&r?A.width:void 0,height:L?r?void 0:A.height:void 0}),r?X+=W.h+s:B+=W.w+s}),r?w+=A.width+s:M+=A.height+s}),{frameWidth:c?f:void 0,frameHeight:d?p:void 0,childUpdates:C}}function Ts(g,t,i){const o=g.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:l,align:r}=o;let h=g.width,f=g.height;const p=h-l.left-l.right,c=f-l.top-l.bottom,d=Ze(e||"1fr",p,n),u=Ze(s||"auto",c,a),b=d.length>0?d.reduce((T,O)=>T+O,0)+(d.length-1)*n:0,m=u.length>0?u.reduce((T,O)=>T+O,0)+(u.length-1)*a:0,y=r.toLowerCase(),S=y==="center"||y.endsWith("-center"),v=y.endsWith("-right"),C=y==="center"||y.startsWith("center-"),w=y.startsWith("bottom-");let M=0,k=0;S?M=(p-b)/2:v&&(M=p-b),C?k=(c-m)/2:w&&(k=c-m);const I=[];return t.forEach((T,O)=>{var et,V;const P=O%d.length||0,_=Math.floor(O/d.length)||0;_>=u.length&&u.push(100);const E=d[P],A=u[_];let B=l.left+M+d.slice(0,P).reduce((at,F)=>at+F+n,0),X=l.top+k+u.slice(0,_).reduce((at,F)=>at+F+a,0);const W=i(T.id),Y=T.geometry;let z=(W==null?void 0:W.width)??Y.width??100,J=(W==null?void 0:W.height)??Y.height??100;if(Y.type==="Ellipse"||Y.type==="Polygon"||Y.type==="Star"){const at=(W==null?void 0:W.radius)??Y.radius??(W==null?void 0:W.outer_radius)??Y.outer_radius??50;z=at*2,J=at*2}z*=T.transform.scale_x||1,J*=T.transform.scale_y||1;let L=B,x=X;S?L+=(E-z)/2:v&&(L+=E-z),C?x+=(A-J)/2:w&&(x+=A-J),I.push({id:T.id,x:L+z/2-h/2,y:x+J/2-f/2,width:((et=T.layoutProps)==null?void 0:et.width)==="fill"?E:void 0,height:((V=T.layoutProps)==null?void 0:V.height)==="fill"?A:void 0})}),{childUpdates:I}}class ts{constructor(){rt(this,"world",null);rt(this,"bodies",new Map);rt(this,"colliders",new Map);rt(this,"joints",new Map);rt(this,"initialized",!1);rt(this,"bodyIdByCollider",new Map);rt(this,"onCollisionCB",null);rt(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await ie.init(),this.world=new ie.World(new ie.Vector2(t.x*100,t.y*100)),this.eventQueue=new ie.EventQueue(!0),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.joints.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}setGravity(t){this.world&&(this.world.gravity=new ie.Vector2(t.x*100,t.y*100))}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const i=t.isStatic?ie.RigidBodyDesc.fixed():ie.RigidBodyDesc.dynamic();i.setTranslation(t.x,t.y),t.rotation!==void 0&&i.setRotation(t.rotation);const o=this.world.createRigidBody(i);let e;switch(t.type){case"Rectangle":e=ie.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=ie.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=ie.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=ie.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 s=this.world.createCollider(e,o);this.bodyIdByCollider.set(s.handle,t.id),t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,s)}removeBody(t){const i=this.bodies.get(t),o=this.colliders.get(t);o&&this.bodyIdByCollider.delete(o.handle),i&&this.world&&(this.world.removeRigidBody(i),this.bodies.delete(t),this.colliders.delete(t))}step(t){if(!this.world)return;this.world.step(this.eventQueue);const i=this.onCollisionCB,o=this.eventQueue;i&&o&&o.drainContactEvents((e,s,n)=>{const a=this.bodyIdByCollider.get(e),l=this.bodyIdByCollider.get(s);a&&l&&i(a,l,n)})}getPosition(t){const i=this.bodies.get(t);if(!i)return null;const o=i.translation();return{x:o.x,y:o.y}}getRotation(t){const i=this.bodies.get(t);return i?i.rotation():null}getVelocity(t){const i=this.bodies.get(t);if(!i)return null;const o=i.linvel();return{x:o.x,y:o.y}}setPosition(t,i,o){const e=this.bodies.get(t);e&&e.setTranslation(new ie.Vector2(i,o),!0)}setRotation(t,i){const o=this.bodies.get(t);o&&o.setRotation(i,!0)}setVelocity(t,i,o){const e=this.bodies.get(t);e&&e.setLinvel(new ie.Vector2(i,o),!0)}setAngularVelocity(t,i){const o=this.bodies.get(t);o&&o.setAngvel(i,!0)}applyForce(t,i,o){const e=this.bodies.get(t);e&&e.addForce(new ie.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new ie.Vector2(i,o),!0)}createJoint(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.joints.has(t.id)&&this.removeJoint(t.id);const i=this.bodies.get(t.bodyA),o=this.bodies.get(t.bodyB);if(!i||!o){console.warn(`[RapierPhysics] Cannot create joint ${t.id}: bodyA (${t.bodyA}) or bodyB (${t.bodyB}) not found`);return}const e=new ie.Vector2(t.anchorA.x,t.anchorA.y),s=new ie.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,l=t.stiffness??100,r=t.damping??10;n=ie.JointData.spring(a,l,r,e,s)}else n=ie.JointData.revolute(e,s);try{const a=this.world.createImpulseJoint(n,i,o,!0);this.joints.set(t.id,a)}catch(a){console.error(`[RapierPhysics] Failed to create joint ${t.id}:`,a)}}removeJoint(t){const i=this.joints.get(t);if(i&&this.world){try{this.world.removeImpulseJoint(i,!0)}catch(o){console.error(`[RapierPhysics] Failed to remove joint ${t}:`,o)}this.joints.delete(t)}}}const es=g=>g,_s=g=>g>0?1:0,Ps=g=>g<1?0:1,ss=g=>g*g,is=g=>g*(2-g),ns=g=>g<.5?2*g*g:-1+(4-2*g)*g,Es=g=>g*g*g,As=g=>--g*g*g+1,Os=g=>g<.5?4*g*g*g:(g-1)*(2*g-2)*(2*g-2)+1,Ls=g=>g*g*g*g,Rs=g=>1- --g*g*g*g,Fs=g=>g<.5?8*g*g*g*g:1-8*--g*g*g*g,xs=g=>g*g*g*g*g,$s=g=>1+--g*g*g*g*g,Bs=g=>g<.5?16*g*g*g*g*g:1+16*--g*g*g*g*g,Ws=g=>1-Math.cos(g*Math.PI/2),Ys=g=>Math.sin(g*Math.PI/2),Xs=g=>-(Math.cos(Math.PI*g)-1)/2,Ds=g=>g===0?0:Math.pow(2,10*(g-1)),Gs=g=>g===1?1:1-Math.pow(2,-10*g),zs=g=>g===0?0:g===1?1:g<.5?Math.pow(2,20*g-10)/2:(2-Math.pow(2,-20*g+10))/2,Ns=g=>1-Math.sqrt(1-g*g),Vs=g=>Math.sqrt(1- --g*g),Hs=g=>g<.5?(1-Math.sqrt(1-4*g*g))/2:(Math.sqrt(1-(-2*g+2)*(-2*g+2))+1)/2,Xe=1.70158,De=Xe*1.525,os=Xe+1,Us=g=>os*g*g*g-Xe*g*g,qs=g=>1+os*Math.pow(g-1,3)+Xe*Math.pow(g-1,2),Ks=g=>g<.5?Math.pow(2*g,2)*((De+1)*2*g-De)/2:(Math.pow(2*g-2,2)*((De+1)*(g*2-2)+De)+2)/2,as=2*Math.PI/3,rs=2*Math.PI/4.5,Js=g=>g===0?0:g===1?1:-Math.pow(2,10*g-10)*Math.sin((g*10-10.75)*as),Qs=g=>g===0?0:g===1?1:Math.pow(2,-10*g)*Math.sin((g*10-.75)*as)+1,Zs=g=>g===0?0:g===1?1:g<.5?-(Math.pow(2,20*g-10)*Math.sin((20*g-11.125)*rs))/2:Math.pow(2,-20*g+10)*Math.sin((20*g-11.125)*rs)/2+1,Ge=g=>g<1/2.75?7.5625*g*g:g<2/2.75?7.5625*(g-=1.5/2.75)*g+.75:g<2.5/2.75?7.5625*(g-=2.25/2.75)*g+.9375:7.5625*(g-=2.625/2.75)*g+.984375,js=g=>1-Ge(1-g),ti=Ge,ei=g=>g<.5?(1-Ge(1-2*g))/2:(1+Ge(2*g-1))/2,Ke=new Map,xe=(g,t,i,o)=>{const e=`${g},${t},${i},${o}`;if(Ke.has(e))return Ke.get(e);const s=h=>(1-3*i+3*g)*h*h*h+(3*i-6*g)*h*h+3*g*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*i+3*g)*h*h+2*(3*i-6*g)*h+3*g,l=h=>{let f=h;for(let p=0;p<8;p++){const c=s(f)-h;if(Math.abs(c)<1e-6)return f;const d=a(f);if(Math.abs(d)<1e-6)break;f=f-c/d}return f},r=h=>h===0?0:h===1?1:n(l(h));return Ke.set(e,r),r},ls=g=>{const t=g.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return xe(i,o,e,s)},cs={ease:xe(.25,.1,.25,1),"ease-in":xe(.42,0,1,1),"ease-out":xe(0,0,.58,1),"ease-in-out":xe(.42,0,.58,1)},ze={Linear:es,EaseInQuad:ss,EaseOutQuad:is,EaseInOutQuad:ns,EaseInCubic:Es,EaseOutCubic:As,EaseInOutCubic:Os,EaseInQuart:Ls,EaseOutQuart:Rs,EaseInOutQuart:Fs,EaseInQuint:xs,EaseOutQuint:$s,EaseInOutQuint:Bs,EaseInSine:Ws,EaseOutSine:Ys,EaseInOutSine:Xs,EaseInExpo:Ds,EaseOutExpo:Gs,EaseInOutExpo:zs,EaseInCirc:Ns,EaseOutCirc:Vs,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Ks,EaseInElastic:Js,EaseOutElastic:Qs,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:ss,EaseOut:is,EaseInOut:ns,StepStart:_s,StepEnd:Ps},si=g=>{const t=g.trim(),i=t.toLowerCase();if(ze[t])return ze[t];const o=Object.keys(ze).find(s=>s.toLowerCase()===i);if(o)return ze[o];const e=Object.keys(fs).find(s=>s.toLowerCase()===i);if(e){const s=ls(fs[e].value);if(s)return s}if(cs[i])return cs[i];if(i.startsWith("cubic-bezier")){const s=ls(t);if(s)return s}return es},fs={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=(g,t,i,o,e)=>{if(!g||!t||!i)return g;const s=o.scale_x??1,n=o.scale_y??1,a=(l,r,h)=>{let f=0,p=0;const c=o.rotation*Math.PI/180,d=Math.cos(c),u=Math.sin(c),b=l*s*d-r*n*u+o.x,m=l*s*u+r*n*d+o.y;h.forEach(k=>{const I=e(k.boneId);if(!I)return;const T={x:I.x,y:I.y,rotation:I.rotation,scaleX:I.scale_x??1,scaleY:I.scale_y??1},O=i[k.boneId]||[1,0,0,1,0,0],P=b*O[0]+m*O[2]+O[4],_=b*O[1]+m*O[3]+O[5],E=T.rotation*Math.PI/180,A=Math.cos(E),B=Math.sin(E),X=P*T.scaleX*A-_*T.scaleY*B+T.x,W=P*T.scaleX*B+_*T.scaleY*A+T.y;f+=X*k.amount,p+=W*k.amount});const y=[...h].sort((k,I)=>I.amount-k.amount);if(y.length>=2&&y[0].amount>0&&y[1].amount>0){const k=e(y[0].boneId),I=e(y[1].boneId);if(k&&I&&k.length!==void 0&&I.length!==void 0){const T=k.length*(k.scale_y??1),O=k.rotation*Math.PI/180,P=k.x-T*Math.sin(O),_=k.y+T*Math.cos(O),E=I.length*(I.scale_y??1),A=I.rotation*Math.PI/180,B=I.x-E*Math.sin(A),X=I.y+E*Math.cos(A);let W=null,Y=null,z=!1;const J=1;if(Math.hypot(k.x-I.x,k.y-I.y)<J||Math.hypot(k.x-B,k.y-X)<J?(W=k.x,Y=k.y):(Math.hypot(P-I.x,_-I.y)<J||Math.hypot(P-B,_-X)<J)&&(W=P,Y=_,z=!0),W!==null&&Y!==null){const L=i[y[0].boneId]||[1,0,0,1,0,0],x=L[0]*L[3]-L[1]*L[2];let et=0,V=0;if(x!==0){const at=(L[2]*L[5]-L[3]*L[4])/x,F=(L[1]*L[4]-L[0]*L[5])/x,R=Math.atan2(-L[1],L[3]);if(!z)et=at,V=F;else{const Z=-L[2]/x,ct=L[0]/x,Ct=Math.hypot(Z,ct),vt=k.length*Ct;et=at-vt*Math.sin(R),V=F+vt*Math.cos(R)}const D=Math.hypot(b-et,m-V),H=Math.hypot(f-W,p-Y);if(H>0&&D>0){const Z=Math.max(H,.01),ct=Math.min(D/Z,3),Ct=W+(f-W)*ct,vt=Y+(p-Y)*ct,At=y[0].amount,It=y[1].amount,Tt=Math.min(At,It)*2,qt=1-Math.pow(1-Tt,4);f=f*(1-qt)+Ct*qt,p=p*(1-qt)+vt*qt}}}}}const S=o.rotation*Math.PI/180,v=Math.cos(S),C=Math.sin(S),w=f-o.x,M=p-o.y;return{x:(w*v+M*C)/s,y:(-w*C+M*v)/n}};return g.map((l,r)=>{const h=t[r];if(!h||h.length===0)return{...l};const f={...l,...a(l.x,l.y,h)};if(l.in_x!==void 0&&l.in_y!==void 0){const p=a(l.in_x,l.in_y,h);f.in_x=p.x,f.in_y=p.y}if(l.out_x!==void 0&&l.out_y!==void 0){const p=a(l.out_x,l.out_y,h);f.out_x=p.x,f.out_y=p.y}return f})},hs={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}},ds={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 ps{constructor(){rt(this,"artboard",null);rt(this,"objectStates",new Map);rt(this,"physicsEngine",null);rt(this,"activeStateMachine",null);rt(this,"inputs",new Map);rt(this,"inputNameMap",new Map);rt(this,"layerStates",new Map);rt(this,"pretextCache",new Map);rt(this,"pointerHistory",[]);rt(this,"MAX_HISTORY",200);rt(this,"imageCache",new Map);rt(this,"lastValidSvgImgMap",new Map);rt(this,"maskBuffer",null);rt(this,"maskCtx",null);rt(this,"lumaBuffer",null);rt(this,"lumaCtx",null);rt(this,"_noiseTileCanvas",null);rt(this,"layout",{fit:"Contain",alignment:"Center"});rt(this,"onTrigger");rt(this,"onInputUpdate");rt(this,"onComponentChange");rt(this,"onToggle");rt(this,"onInputChange");rt(this,"onInputFocus");rt(this,"onInputBlur");rt(this,"onLog");rt(this,"onButtonClick");rt(this,"onGraphPointClick");rt(this,"justFiredTriggers",new Set);rt(this,"rootTransform",null);rt(this,"canvasWidth",0);rt(this,"canvasHeight",0);rt(this,"lastHoveredObjectId",null);rt(this,"_lastPointerPos",null);rt(this,"_prevPointerPos",null);rt(this,"_mouseDelta",{dx:0,dy:0});rt(this,"focusedId",null);rt(this,"draggingSliderId",null);rt(this,"draggingJoystickId",null);rt(this,"activeDropdownId",null);rt(this,"activeObjectId",null);rt(this,"draggingListViewId",null);rt(this,"scrollOffset",{x:0,y:0});rt(this,"_totalScroll",{x:0,y:0});rt(this,"draggingBehaviors",new Set);rt(this,"isMouseDown",!1);rt(this,"activeKeys",new Set);rt(this,"_layoutAnimCache",new Map);rt(this,"_springChainState",new Map);rt(this,"_emitterPools",new Map);rt(this,"objectVelocities",new Map);rt(this,"currentTime",0);rt(this,"frameCount",0);rt(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});rt(this,"onLogicUpdate");rt(this,"logicNodeValues",new Map);rt(this,"logicNodeState",new Map);rt(this,"pointerDownTimes",new Map);rt(this,"activeHoverIds",new Set);rt(this,"onNavigation");rt(this,"periodicTriggerTimes",new Map);rt(this,"wasInView",new Set);rt(this,"scrollProgressLastValue",new Map);rt(this,"debug_objectsRendered",0);rt(this,"debug_objectsTotal",0);rt(this,"lastRenderTime",0);rt(this,"debugMode",!1);rt(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)")}getInputValue(t){return this.inputs.get(t)}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:i,isClosed:o}=this.svgPathToPoints(t.data);t.points=i,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const i=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let s=!1,n=0,a=0,l=0,r=0,h=0,f=0,p;for(;(p=i.exec(t))!==null;){const c=p[1],d=(p[2].match(o)||[]).map(parseFloat),u=c===c.toLowerCase(),b=c.toUpperCase();let m=0;const y=v=>{let C=d[m++];return u&&(C+=v?n:a),C},S=()=>({x:y(!0),y:y(!1)});switch(b){case"M":{const v=S();for(h=n=v.x,f=a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});m<d.length;){const C=S();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"L":for(;m<d.length;){const v=S();n=v.x,a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;m<d.length;)n=y(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;m<d.length;)a=y(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;m<d.length;){const v=S(),C=S(),w=S();if(e.length>0){const M=e[e.length-1];M.out_x=v.x,M.out_y=v.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),l=C.x,r=C.y}break;case"S":for(;m<d.length;){const v={x:2*n-l,y:2*a-r},C=S(),w=S();if(e.length>0){const M=e[e.length-1];M.out_x=v.x,M.out_y=v.y}n=w.x,a=w.y,e.push({x:n,y:a,in_x:C.x,in_y:C.y,out_x:n,out_y:a}),l=C.x,r=C.y}break;case"Q":for(;m<d.length;){const v=S(),C=S();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(v.x-w.x),w.out_y=w.y+2/3*(v.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(v.x-n),in_y:a+2/3*(v.y-a),out_x:n,out_y:a}),l=v.x,r=v.y}break;case"T":for(;m<d.length;){const v={x:2*n-l,y:2*a-r},C=S();if(e.length>0){const w=e[e.length-1];w.out_x=w.x+2/3*(v.x-w.x),w.out_y=w.y+2/3*(v.y-w.y)}n=C.x,a=C.y,e.push({x:n,y:a,in_x:n+2/3*(v.x-n),in_y:a+2/3*(v.y-a),out_x:n,out_y:a}),l=v.x,r=v.y}break;case"Z":if(s=!0,e.length>0){const v=e[e.length-1];v.closePath=!0;const C=[...e].reverse().find(w=>w.moveTo)||e[0];C&&Math.hypot(C.x-v.x,C.y-v.y)<.1&&(C.in_x=v.in_x,C.in_y=v.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=h,a=f;break;default:if(d.length>=2){const v=S();n=v.x,a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:s}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,i,o){var s;const e=(s=this.artboard)==null?void 0:s.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[i]&&(e.constraints[i]={...e.constraints[i],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}log(...t){this.debugMode&&console.log(...t)}warn(...t){this.debugMode&&console.warn(...t)}setInternalInput(t,i){this.inputs.set(t,i),this.onInputUpdate&&this.onInputUpdate(t,i)}setLayout(t,i){this.layout={fit:t,alignment:i}}getActiveStateIds(t="Base Layer"){const i=this.layerStates.get(t);return i?i.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,i){const o=this.objectStates.get(t);o&&(o.options={...o.options,...i})}updateGraphData(t,i){var e,s;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:i,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=i;const a=this.objectStates.get(o.id);a&&((s=a.geometry)==null?void 0:s.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...i]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,i)}else this.updateInput(t,i)}load(t){var n,a;if(!t)return;let i=this.decompressStrings(t);const o=[],e=new Set,s=l=>{l&&l.forEach(r=>{if(e.has(r.id))return;const h={...r},f=h.childrenObjects||[];e.add(h.id),o.push(h),s(f)})};if(s(i.objects||[]),o.length>(i.objects||[]).length&&this.log(`[Engine] Flattened artboard from ${(i.objects||[]).length} to ${o.length} objects.`),i.objects=o,this.artboard=i,this.currentTime=0,this.objectStates.clear(),this.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 l=new Map;this.artboard.objects.forEach(r=>{l.set(r.id,r),r.children||(r.children=[])}),this.artboard.objects.forEach(r=>{if(r.parentId){const h=l.get(r.parentId);h&&(h.children||(h.children=[]),h.children.includes(r.id)||h.children.push(r.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const i=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{this.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=s=>{console.error("[ExodeUI Preload] failed:",s,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,s,n;(e=o.geometry)!=null&&e.src&&i(o.geometry.src),(n=(s=o.style)==null?void 0:s.fill)!=null&&n.src&&i(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 i={};for(const[o,e]of Object.entries(t))i[o]=this.decompressStrings(e);return i}return Array.isArray(t)?t.map(i=>this.decompressStrings(i)):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(i=>{var n,a,l,r,h,f,p;const o=i.width??((n=i.geometry)==null?void 0:n.width)??0,e=i.height??((a=i.geometry)==null?void 0:a.height)??0,s=i.cornerRadius??i.corner_radius??((l=i.geometry)==null?void 0:l.corner_radius)??((r=i.geometry)==null?void 0:r.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((h=i.transform)==null?void 0:h.x)??i.x??0,y:((f=i.transform)==null?void 0:f.y)??i.y??0,width:o,height:e,cornerRadius:s,corner_radius:s,clipContent:i.clipContent??!1,autoLayout:i.autoLayout?JSON.parse(JSON.stringify(i.autoLayout)):void 0,layoutProps:i.layoutProps?JSON.parse(JSON.stringify(i.layoutProps)):void 0,opacity:((p=i.transform)==null?void 0:p.opacity)!==void 0?i.transform.opacity:i.opacity!==void 0?i.opacity:100,visible:i.visible!==void 0?i.visible:i.isVisible!==void 0?i.isVisible:!0,blendMode:i.blendMode||"Normal",style:JSON.parse(JSON.stringify(i.style||{})),geometry:JSON.parse(JSON.stringify(i.geometry||{})),options:i.options?JSON.parse(JSON.stringify(i.options)):{},masks:i.masks?JSON.parse(JSON.stringify(i.masks)):[],zIndex:i.zIndex!==void 0?i.zIndex:void 0})}),this.artboard.objects.some(i=>{var o;return(o=i.physics)==null?void 0:o.enabled})){this.physicsEngine=new ts;const i=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(i).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var s,n;if((s=e.physics)!=null&&s.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const l=e.geometry.width||100,r=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:l,height:r,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(i=>{this.inputs.set(i.id,i.value);const o=this.inputNameMap.get(i.name)||[];o.includes(i.id)||o.push(i.id),this.inputNameMap.set(i.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(i=>{this.inputs.set(i.id,i.value.value);const o=this.inputNameMap.get(i.name)||[];o.push(i.id),this.inputNameMap.set(i.name,o)}),this.activeStateMachine.layers.forEach(i=>{let o=i.states.find(e=>e.id===i.entryStateId);!o&&i.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${i.entryStateId}" in layer "${i.name}". Falling back to first state.`),o=i.states[0]),o&&this.enterStates(i.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var s;if(!this.artboard)return;const i=new Map;this.artboard.objects.forEach(n=>i.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const l=this.objectStates.get(a.id);if(l){const r=Math.abs(l.x-a.x),h=Math.abs(l.y-a.y);!t&&(r>20||h>20)?(l.x+=(a.x-l.x)*o,l.y+=(a.y-l.y)*o):(l.x=a.x,l.y=a.y),a.width!==void 0&&(l.width=a.width),a.height!==void 0&&(l.height=a.height)}})};if((s=this.artboard.autoLayout)!=null&&s.enabled){const n=this.artboard.objects.filter(l=>!l.parentId),a=je(this.artboard,n,l=>this.objectStates.get(l));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 l=n.children.map(f=>i.get(f)).filter(f=>!!f),r=this.objectStates.get(n.id);if(!r)return;const h=je(r,l,f=>this.objectStates.get(f));h.frameWidth!==void 0&&(r.width=h.frameWidth),h.frameHeight!==void 0&&(r.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(l=>{l.value&&typeof l.value=="string"&&t.add(l.value)})})}),t.size===0)return;let i="";t.forEach(n=>{const a=n.replace(/ /g,"+");i+=`&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(i.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${i}`;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 s=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&s.push("clash-display@200,300,400,500,600,700")}),s.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${s.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,i){var n;if(i.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===i.length&&i.every(l=>o.currentStateIds.includes(l))&&this.justFiredTriggers.size===0)return;const e=[];let s=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(l=>l.name===t);if(a)for(const l of i){const r=a.states.find(h=>h.id===l);if(r)if(r.isBlendState&&r.blendAnimations&&r.blendAnimations.length>0)e.push({animation:null,state:r}),r.blendAnimations.forEach(h=>{const f=this.artboard.animations.find(p=>p.id===h.animationId);f&&(s=Math.max(s,f.duration))});else{let h=null;r.animationId&&(h=this.artboard.animations.find(f=>f.id===r.animationId)||null),h||(h=this.artboard.animations.find(f=>{var p,c;return f.name===r.name||f.id===r.name||(r.name==="Entry"||r.id==="entry")&&(((p=f.name)==null?void 0:p.toLowerCase())==="onload"||((c=f.name)==null?void 0:c.toLowerCase())==="intro")})||null),h&&((n=this.artboard.animationFlow)!=null&&n.some(p=>(p.trigger==="on_load"||p.trigger==="after_delay")&&p.targetAnimationId===(h==null?void 0:h.id))||(e.push({animation:h,state:r}),s=Math.max(s,h.duration)))}}}this.layerStates.set(t,{currentStateIds:i,animations:e,time:0,duration:s})}setInputBool(t,i){this.updateInput(t,i)}setInputNumber(t,i){this.updateInput(t,i)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,i){this.updateInput(t,i)}setInputNumberArray(t,i){this.updateInput(t,i)}setInputStringArray(t,i){this.updateInput(t,i)}updateObjectProperty(t,i,o){const e=this.objectStates.get(t);if(e)if(i.includes(".")||i.includes("[")){const s=i.replace(/\[(\d+)\]/g,".$1").split(".");let n=e;for(let a=0;a<s.length-1;a++){if(typeof n[s[a]]!="object"||n[s[a]]===null){const l=s[a+1],r=!isNaN(Number(l));n[s[a]]=r?[]:{}}n=n[s[a]]}n[s[s.length-1]]=o}else e[i]=o}updateInput(t,i){var n,a,l;let o;if(this.inputs.has(t)){const r=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);r&&typeof r.value=="object"&&(o=r.value.type)}else{const r=this.inputNameMap.get(t);if(r&&r.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(f=>f.id===r[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=i;o==="Trigger"&&(i===1?e=!0:i===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const s=this.inputNameMap.get(t);s&&s.forEach(r=>this.setInternalInput(r,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),s&&s.forEach(r=>this.justFiredTriggers.add(r))),Array.isArray(e)&&((l=this.artboard)==null||l.objects.forEach(r=>{if(r.inputId===t||r.name===t){const h=this.objectStates.get(r.id);h&&h.options&&(r.type==="ListView"||r.variant==="listview"?h.options.items=e:(r.type==="Dropdown"||r.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,i){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(s=>{if(s.trigger==="variable"&&s.conditionVariableId&&s.targetAnimationId&&(s.conditionVariableId===t||e&&e.includes(s.conditionVariableId))){const a=s.conditionOperator||"IsTrue",l=s.conditionValue;let r=!1;switch(a){case"Equal":case"==":r=i==l;break;case"NotEqual":case"!=":r=i!=l;break;case"GreaterThan":case">":r=i>l;break;case"LessThan":case"<":r=i<l;break;case"GreaterEqual":case">=":r=i>=l;break;case"LessEqual":case"<=":r=i<=l;break;case"IsTrue":r=!!i;break;case"IsFalse":r=!i;break}if(r){const h=s.delay||0;h<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const i=this.layerStates.get(t.name);if(!i||i.currentStateIds.length===0)return;const o=[];let e=!1;for(const s of i.currentStateIds){const n=t.states.find(l=>l.id===s);if(!n)continue;let a=!1;for(const l of n.transitions||[])this.checkConditions(l.conditions)&&(o.push(l.targetStateId),a=!0,e=!0);a||o.push(s)}if(!e){const s=this.findGlobalTransition(t,i.currentStateIds);s&&(o.length=0,o.push(s.targetStateId),e=!0,s.conditions&&(s.conditions||[]).forEach(n=>{var l;const a=(l=this.activeStateMachine)==null?void 0:l.inputs.find(r=>r.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const s=Array.from(new Set(o));this.enterStates(t.name,s)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const i=(o=this.activeStateMachine)==null?void 0:o.inputs.find(s=>s.id===t);i&&this.inputNameMap.has(i.name)&&((e=this.inputNameMap.get(i.name))==null||e.forEach(s=>this.setInternalInput(s,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,i){for(const o of t.states)if(!(i.includes(o.id)&&this.justFiredTriggers.size===0)){for(const s of o.transitions||[])if(!(i.includes(s.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(s.conditions))return s}return null}checkConditions(t){return!t||t.length===0?!0:t.every(i=>{const o=i.inputId,e=i.op,s=i.value,n=this.evaluateLogicTree(o);if(n===void 0)return this.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==s;break;case"NotEqual":case"!=":a=n!=s;break;case"GreaterThan":case">":a=n>s;break;case"LessThan":case"<":a=n<s;break;case"GreaterEqual":case">=":a=n>=s;break;case"LessEqual":case"<=":a=n<=s;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,i=null,o=new Set){var a,l,r,h,f,p;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(l=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:l.find(c=>c.id===t);if(e){const c=(u,b)=>{const m=e.inputs.find(y=>y.id===u);return m?m.sourceId?this.evaluateLogicTree(m.sourceId,m.sourceHandleId,o):m.value!==void 0?m.value:b:b};let d=0;switch(e.op){case kt.AND:d=c("a",!1)&&c("b",!1);break;case kt.OR:d=c("a",!1)||c("b",!1);break;case kt.NOT:d=!c("in",!1);break;case kt.XOR:d=!!c("a",!1)!=!!c("b",!1);break;case kt.OBJECT:d=e.name;break;case kt.PROPERTY:case kt.GET_PROPERTY:{const u=c("id","");if(!u){d=0;break}const b=e.name;if(!b||b==="GET_PROPERTY"||b==="PROPERTY"){d=0;break}const m=this.objectStates.get(u);if(!m){d=0;break}b in m?d=m[b]:d=this.resolvePath(m,b);break}case kt.SET_PROPERTY:{const u=c("id",""),b=c("value",void 0);if(!u||b===void 0){d=0;break}const m=e.name;if(!m||m==="SET_PROPERTY"){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(m))y[m]=b,d=b;else{const v=m.replace(/\[(\d+)\]/g,".$1").split(".");let C=y;for(let M=0;M<v.length-1;M++){const k=v[M],I=v[M+1];C[k]===void 0&&(C[k]=isNaN(Number(I))?{}:[]),C=C[k]}const w=v[v.length-1];C[w]=b,d=b}break}case kt.ADD:d=c("a",0)+c("b",0);break;case kt.SUB:d=c("a",0)-c("b",0);break;case kt.MUL:d=c("a",0)*c("b",0);break;case kt.DIV:{const u=c("b",1);d=u===0?0:c("a",0)/u;break}case kt.MOD:d=c("a",0)%c("b",1);break;case kt.POW:d=Math.pow(c("a",0),c("b",1));break;case kt.ABS:d=Math.abs(c("in",0));break;case kt.ROUND:d=Math.round(c("in",0));break;case kt.FLOOR:d=Math.floor(c("in",0));break;case kt.CEIL:d=Math.ceil(c("in",0));break;case kt.SIN:d=Math.sin(c("in",0));break;case kt.COS:d=Math.cos(c("in",0));break;case kt.TAN:d=Math.tan(c("in",0));break;case kt.CLAMP:{const u=c("in",0),b=c("min",0),m=c("max",1);d=Math.max(b,Math.min(m,u));break}case kt.REMAP:{const u=c("in",0),b=c("inMin",0),m=c("inMax",100),y=c("outMin",0),S=c("outMax",1);d=m===b?y:y+(u-b)*(S-y)/(m-b);break}case kt.EQ:d=c("a",0)==c("b",0);break;case kt.NEQ:d=c("a",0)!=c("b",0);break;case kt.GT:d=c("a",0)>c("b",0);break;case kt.LT:d=c("a",0)<c("b",0);break;case kt.GTE:d=c("a",0)>=c("b",0);break;case kt.LTE:d=c("a",0)<=c("b",0);break;case kt.IF_ELSE:d=c("cond",!1)?c("then",0):c("else",0);break;case kt.VALUE:d=e.value!==void 0?e.value:0;break;case kt.INPUT:d=this.inputs.get(e.name)??0;break;case kt.LOG:{const u=c("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case kt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case kt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case kt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case kt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case kt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case kt.EFFECTOR:{const u=c("id",""),b=c("intensity",1),m=c("trigger",!0);if(!u||!m){d=0;break}const y=e.name;if(!y){d=0;break}const S=this.objectStates.get(u);if(!S){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(y))S.style||(S.style={}),S.style.artEffect={enabled:!0,type:y,intensity:b},d=1;else{S.behaviors||(S.behaviors=[]);let C=S.behaviors.find(w=>w.type===y);C?(C.enabled=!0,C.settings||(C.settings={}),C.settings.intensity=b):(C={id:`eff_${Date.now()}_${y}`,type:y,enabled:!0,sensors:[],settings:{intensity:b}},S.behaviors.push(C)),d=1}break}case kt.MONITOR:{d=c("in",0);break}case kt.SPRING_PULL:{const u=c("objectId",""),b=c("forceX",0),m=c("forceY",0);u&&((r=this.artboard)==null||r.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(S=>{var v;if(S.type===U.SpringChain&&((v=S.settings)!=null&&v.connections)&&(S.settings.connections.some(w=>w.targetId===u)||y.id===u)){this._springChainState.has(y.id)||this._springChainState.set(y.id,new Map);const w=this._springChainState.get(y.id);if(!w.has(u)){const k=this.objectStates.get(u);w.set(u,{x:(k==null?void 0:k.x)??0,y:(k==null?void 0:k.y)??0,vx:0,vy:0})}const M=w.get(u);M&&(M.vx+=b,M.vy+=m)}})})),d=1;break}case kt.SPRING_SETTLE:{const u=c("objectId","");let b=!0;if(u){const m=c("threshold",1);this._springChainState.forEach(y=>{const S=y.get(u);S&&(Math.abs(S.vx)>m||Math.abs(S.vy)>m)&&(b=!1)})}d=b;break}case kt.EMIT:{const u=c("objectId",""),b=c("count",20);u&&((h=this.artboard)==null||h.objects.forEach(m=>{m.behaviors&&m.behaviors.forEach(y=>{y.type===U.ParticleEmitter&&m.id===u&&(y._pendingBurst=(y._pendingBurst||0)+b)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===kt.DELAY){const u=c("delay",0),b=c("in",0);let m=this.logicNodeState.get(t);for(m||(m={queue:[]},this.logicNodeState.set(t,m)),m.queue.push({time:this.currentTime+u,value:b});m.queue.length>0&&m.queue[0].time<=this.currentTime;)m.lastValue=m.queue.shift().value;d=m.lastValue??0}return d}const s=(f=this.activeStateMachine)==null?void 0:f.inputs.find(c=>c.id===t||c.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const c=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,c),c}let n=this.inputs.get(t)??(s?this.inputs.get(s.id):void 0);if((this.justFiredTriggers.has(t)||s&&this.justFiredTriggers.has(s.id))&&(n=!0),i&&n!==void 0){const c=(p=this.activeStateMachine)==null?void 0:p.inputs.find(d=>d.id===t);if(c&&c.value.type==="Number"&&typeof n=="number"){const d=c.value.defaultValue??c.value.value;if(i==="source-greater")return n>d;if(i==="source-less")return n<d;if(i==="source-equal")return n===d}if(i==="source-true")return n===!0;if(i==="source-false")return n===!1;if(i==="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===kt.SET_PROPERTY||t.op===kt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,i){const o=i.replace(/\[(\d+)\]/g,".$1").split(".");let e=t;for(const s of o)if(e&&typeof e=="object"&&s in e)e=e[s];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(i=>{i.time=t,i.time>(i.duration||0)&&(i.animations.some(e=>{var s;return((s=e.state)==null?void 0:s.loop)===!0})?i.time%=i.duration||1:i.time=i.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&&(this.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 s=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&s!==null&&n!==null&&(a.x=s.x,a.y=s.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions());const i=[];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_")&&i.push(e))}o.animations.forEach(s=>{var n;(n=s.state)!=null&&n.isBlendState&&s.state.blendAnimations?this.applyBlendState(s.state,o.time):s.animation&&this.applyAnimation(s.animation,o.time,s.filterObjectIds)})}}),i.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 s,n,a,l,r,h,f;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.objects.find(p=>p.id===e))==null?void 0:n.triggers)==null||a.find(p=>p.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 p=(h=(r=(l=this.artboard)==null?void 0:l.objects.find(u=>u.id===e))==null?void 0:r.triggers)==null?void 0:h.find(u=>u.id===o.triggerId),c=(p==null?void 0:p.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=c;if((p==null?void 0:p.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((p==null?void 0:p.eventType)==="onHold"||(p==null?void 0:p.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(p!=null&&p.exitAnimationId){const u=(f=this.artboard)==null?void 0:f.animations.find(b=>b.id===p.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),this.processJoysticks(t),this.activeStateMachine&&this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues))}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(i=>{var e,s,n;const o=(e=i.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(i.id);if(a&&a.visible!==!1){const l=this.getGlobalTransform(i.id),r=(((s=i.geometry)==null?void 0:s.width)||100)*(l.scale_x||1),h=(((n=i.geometry)==null?void 0:n.height)||100)*(l.scale_y||1),f=50,p=l.x+r/2>=-this.canvasWidth/2-f&&l.x-r/2<=this.canvasWidth/2+f&&l.y+h/2>=-this.canvasHeight/2-f&&l.y-h/2<=this.canvasHeight/2+f,c=`analytics_${i.id}`,d=this.wasInView.has(c);p&&!d&&this.fireAnalyticsEvent(i.id,"visible"),p?this.wasInView.add(c):this.wasInView.delete(c)}}}),this.artboard.objects.forEach(i=>{const o=i.interactions||[];o.length!==0&&o.forEach(e=>{const s=e.triggers||[e.event||e.trigger];s&&s.forEach(n=>{var l,r,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const f=e.intervalValue||2e3,p=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-p>=f&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const f=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=f&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const f=this.objectStates.get(i.id);if(f&&f.visible!==!1){const p=this.getGlobalTransform(i.id),c=(((l=i.geometry)==null?void 0:l.width)||100)*(p.scale_x||1),d=(((r=i.geometry)==null?void 0:r.height)||100)*(p.scale_y||1),u=50,b=p.x+c/2>=-this.canvasWidth/2-u&&p.x-c/2<=this.canvasWidth/2+u&&p.y+d/2>=-this.canvasHeight/2-u&&p.y-d/2<=this.canvasHeight/2+u,m=this.wasInView.has(i.id);b&&!m&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(i.id,"Scroll Into View"),b?this.wasInView.add(i.id):this.wasInView.delete(i.id)}}if(a==="scroll progress"||a==="scrollprogress"){const f=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),p=this.scrollProgressLastValue.get(e.id)||0;Math.abs(f-p)>.001&&(this.scrollProgressLastValue.set(e.id,f),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,f))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(i=>{if(!i.constraints||i.constraints.length===0)return;const o=this.objectStates.get(i.id);if(!o)return;const e=this.getGlobalTransform(i.id);if(i.constraints.forEach((s,n)=>{var h,f,p,c,d,u,b,m,y;const a=((h=o.constraints)==null?void 0:h[n])||{},l={...s,...a},r=l.strength??1;if(l.type==="Translation"){const S=this.getGlobalTransform(l.targetId);if(S){const v=l.offsetX||0,C=l.offsetY||0,w=S.x+v,M=S.y+C,k=l.useSpring;if(k){const T=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:O,y:P,vx:_,vy:E}=this.computeSpring(e.x,e.y,T.vx,T.vy,w,M,l,t);l.copyX&&(e.x=e.x+(O-e.x)*r),l.copyY&&(e.y=e.y+(P-e.y)*r),this.objectVelocities.set(i.id,{vx:_,vy:E})}else l.copyX&&(e.x=e.x+(w-e.x)*r),l.copyY&&(e.y=e.y+(M-e.y)*r);let I=!1;if((f=l.limitX)!=null&&f.enabled){const T=e.x;e.x=Math.max(l.limitX.min,Math.min(l.limitX.max,e.x)),e.x!==T&&(I=!0)}if((p=l.limitY)!=null&&p.enabled){const T=e.y;e.y=Math.max(l.limitY.min,Math.min(l.limitY.max,e.y)),e.y!==T&&(I=!0)}I&&k&&this.objectVelocities.set(i.id,{vx:0,vy:0})}}else if(l.type==="Rotation"){const S=this.getGlobalTransform(l.targetId);if(S){let C=(S.rotation+(l.offset||0)-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*r}}else if(l.type==="Scale"){const S=this.getGlobalTransform(l.targetId);S&&(l.copyX&&(e.scale_x=e.scale_x+(S.scale_x-e.scale_x)*r),l.copyY&&(e.scale_y=e.scale_y+(S.scale_y-e.scale_y)*r))}else if(l.type==="Transform"){const S=this.getGlobalTransform(l.targetId);if(S){e.x=e.x+(S.x-e.x)*r,e.y=e.y+(S.y-e.y)*r;let v=(S.rotation-e.rotation)%360;v>180&&(v-=360),v<-180&&(v+=360),e.rotation=e.rotation+v*r,e.scale_x=e.scale_x+(S.scale_x-e.scale_x)*r,e.scale_y=e.scale_y+(S.scale_y-e.scale_y)*r}}else if(l.type==="FollowPointer"){const S=((c=this._lastPointerPos)==null?void 0:c.x)??e.x,v=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,C=l.useSpring;if(C){const M=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:k,y:I,vx:T,vy:O}=this.computeSpring(e.x,e.y,M.vx,M.vy,S,v,l,t);e.x=k,e.y=I,this.objectVelocities.set(i.id,{vx:T,vy:O})}else e.x=e.x+(S-e.x)*r,e.y=e.y+(v-e.y)*r;let w=!1;if((u=l.limitX)!=null&&u.enabled){const M=e.x;e.x=Math.max(l.limitX.min,Math.min(l.limitX.max,e.x)),e.x!==M&&(w=!0)}if((b=l.limitY)!=null&&b.enabled){const M=e.y;e.y=Math.max(l.limitY.min,Math.min(l.limitY.max,e.y)),e.y!==M&&(w=!0)}w&&C&&this.objectVelocities.set(i.id,{vx:0,vy:0})}else if(l.type==="Distance"){const S=this.getGlobalTransform(l.targetId);if(S){const v=e.x-S.x,C=e.y-S.y,w=Math.sqrt(v*v+C*C),M=l.distance||0;let k=w;switch(l.mode){case"exact":k=M;break;case"minimum":k=Math.max(M,w);break;case"maximum":k=Math.min(M,w);break;case"clamped":k=Math.max(0,Math.min(M,w));break}if(w>0){const I=e.x===S.x&&e.y===S.y?1:k/w;e.x=e.x+(S.x+v*I-e.x)*r,e.y=e.y+(S.y+C*I-e.y)*r}}}else if(l.type==="FollowPath"){const S=(m=this.artboard)==null?void 0:m.objects.find(v=>v.id===l.targetId);if(S){const v=this.getGlobalTransform(S.id);if(v){let C=S.geometry;if(S.type==="Frame"||S.type==="Group"||!C||C.type!=="Path"&&C.type!=="Ellipse"&&C.type!=="Rectangle"){const x=(y=this.artboard)==null?void 0:y.objects.find(et=>et.parentId===S.id&&et.type==="Shape"&&et.geometry&&(et.geometry.type==="Path"||et.geometry.type==="Ellipse"||et.geometry.type==="Rectangle"));x&&(C=x.geometry)}if(!C)return;const w=(l.distance||0)/100,M=v.width||C.width||0,k=v.height||C.height||0,I=this.getPointOnPath(C,M,k,w),T=v.rotation*Math.PI/180,O=Math.cos(T),P=Math.sin(T),_=I.x*v.scale_x*O-I.y*v.scale_y*P,E=I.x*v.scale_x*P+I.y*v.scale_y*O;let A=v.rotation+(l.offsetRotation||0);if(l.orient){const x=Math.cos(I.angle),et=Math.sin(I.angle),V=x*v.scale_x*O-et*v.scale_y*P,at=x*v.scale_x*P+et*v.scale_y*O;A=Math.atan2(at,V)*180/Math.PI+(l.offsetRotation||0)}const B=A*Math.PI/180,X=Math.cos(B),W=Math.sin(B),Y=(l.offsetX||0)*X-(l.offsetY||0)*W,z=(l.offsetX||0)*W+(l.offsetY||0)*X,J=v.x+_+Y,L=v.y+E+z;if(e.x=e.x+(J-e.x)*r,e.y=e.y+(L-e.y)*r,l.orient){let x=(A-e.rotation)%360;x>180&&(x-=360),x<-180&&(x+=360),e.rotation=e.rotation+x*r}}}}else if(l.type==="IK"){const S=this.getGlobalTransform(l.targetId);S&&this.solveIK(i,S,l.boneCount||2,r)}}),i.constraints.some(s=>s.type!=="IK")){const s=this.globalToLocal(i.parentId,e);o.x=s.x,o.y=s.y,o.rotation=s.rotation,o.flip_x=s.scale_x<0,o.scale_x=Math.abs(s.scale_x),o.flip_y=s.scale_y<0,o.scale_y=Math.abs(s.scale_y)}})}getGlobalTransform(t){var f,p;const i=this.objectStates.get(t);if(!i)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),e=(o==null?void 0:o.type)==="Bone"?(p=o.geometry)==null?void 0:p.length:void 0;if(!o||!o.parentId)return{x:i.x,y:i.y,rotation:i.rotation,scale_x:(i.scale_x??1)*(i.flip_x?-1:1),scale_y:(i.scale_y??1)*(i.flip_y?-1:1),length:e};const s=this.getGlobalTransform(o.parentId),n=s.rotation*Math.PI/180,a=Math.cos(n),l=Math.sin(n),r=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*l),h=s.y+(i.x*s.scale_x*l+i.y*s.scale_y*a);return{x:r,y:h,rotation:s.rotation+i.rotation,scale_x:s.scale_x*(i.scale_x??1)*(i.flip_x?-1:1),scale_y:s.scale_y*(i.scale_y??1)*(i.flip_y?-1:1),length:e}}globalToLocal(t,i){if(!t)return i;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,s=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),l=Math.sin(n),r=i.x-o.x,h=i.y-o.y,f=(r*a-h*l)*e,p=(r*l+h*a)*s;return{x:f,y:p,rotation:i.rotation-o.rotation,scale_x:i.scale_x/(o.scale_x||1),scale_y:i.scale_y/(o.scale_y||1)}}solveIK(t,i,o,e){var r;const s=[];let n=t.id;for(let h=0;h<o&&n;h++){const f=(r=this.artboard)==null?void 0:r.objects.find(p=>p.id===n);if(!f)break;s.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=f.parentId}if(s.length<2)return;const a=s.reverse(),l=5;for(let h=0;h<l;h++){const f=this.getGlobalTransform(t.id);for(let p=a.length-2;p>=0;p--){const c=a[p],d=this.getGlobalTransform(c.id),u=f.x-d.x,b=f.y-d.y,m=i.x-d.x,y=i.y-d.y,S=Math.sqrt(u*u+b*b),v=Math.sqrt(m*m+y*y);if(S>.001&&v>.001){const C=Math.atan2(b,u);let M=(Math.atan2(y,m)-C)*180/Math.PI;M*=e;const k=this.objectStates.get(c.id);k&&(k.rotation+=M)}}}}computeSpring(t,i,o,e,s,n,a,l){const r=a.stiffness??100,h=a.damping??10,f=a.mass??1,p=-r*(t-s),c=-r*(i-n),d=-h*o,u=-h*e,b=(p+d)/f,m=(c+u)/f,y=o+b*l,S=e+m*l,v=t+y*l,C=i+S*l;return{x:v,y:C,vx:y,vy:S}}handlePointerInput(t,i,o,e,s){if(!this.artboard)return;const n=this.calculateTransform(e,s,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(i-n.tx)/n.scaleX,l=(o-n.ty)/n.scaleY;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:l},this._prevPointerPos&&(this._mouseDelta.dx+=a-this._prevPointerPos.x,this._mouseDelta.dy+=l-this._prevPointerPos.y),this.updateInput("mouseX",a),this.updateInput("mouseY",l),this.handlePointerEvent(t,a,l)}handleScroll(t,i){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:i},this._totalScroll.x+=t-o,this._totalScroll.y+=i-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,i){this._totalScroll.x+=t,this._totalScroll.y+=i,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,i,o){var l,r,h,f,p;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 s=(c,d)=>{var v;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const b=new Set([u]);d==="move"&&b.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&b.add("click"),u==="onPointerDown"&&b.add("pointerDown"),u==="onPointerUp"&&b.add("pointerUp");const m=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup","joystick"];return!!(c.type==="Component"&&m.includes(c.variant)||c.type==="Joystick"||m.includes((v=c.type)==null?void 0:v.toLowerCase())||(c.interactions||[]).some(C=>b.has(C.event))||(c.triggers||[]).some(C=>b.has(C.eventType)))};let n=null;for(let c=this.artboard.objects.length-1;c>=0;c--){const d=this.artboard.objects[c],u=this.objectStates.get(d.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(d,i,o)&&(n||(n=d),s(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:i,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 c=this.artboard.objects.find(d=>d.id===this.draggingSliderId);c&&this.updateSliderValueFromPointer(c,i,o);return}if(this.draggingJoystickId){const c=this.artboard.objects.find(d=>d.id===this.draggingJoystickId);c&&this.updateJoystickValueFromPointer(c,i,o);return}if(this.draggingListViewId){const c=this.artboard.objects.find(d=>d.id===this.draggingListViewId);c&&this.updateListViewScrollFromPointer(c);return}e&&(e.type==="ListView"||e.type==="Component"&&e.variant==="listview")&&this.updateListViewHoverFromPointer(e,i,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(this.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.draggingJoystickId=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&&((l=e.behaviors)!=null&&l.some(c=>c.type===U.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(c=>{c!==a&&this.activeHoverIds.delete(c)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const c=this.artboard.objects.find(d=>d.id===this.activeDropdownId);if(c&&(c.type==="Dropdown"||c.variant==="dropdown")){const d=this.objectStates.get(c.id),u=(d==null?void 0:d.options)||c.options||{},b=c.geometry||{},m=b.width??c.width??200,y=b.height??c.height??40,S=u.optionsList||[],v=u.itemHeight||32,C=u.listPadding??4,w=S.length*v+C*2,M=this.getWorldTransform(c.id),k=m*Math.abs(M.scaleX),I=y*Math.abs(M.scaleY),T=M.y+I/2+4,O=Math.abs(i-M.x)<=k/2,P=o>=T&&o<=T+w*Math.abs(M.scaleY);if(O&&P){const _=Math.abs(M.scaleY),E=o-(T+C*_),A=Math.floor(E/(v*_));if(A>=0&&A<S.length){const B=S[A];u.selectedOption=B,u.isOpen=!1,this.activeDropdownId=null,c.inputId&&this.setInternalInput(c.inputId,B),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"dropdown",property:"selectedOption",value:B})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let c=e,d=e;for(;d&&d.parentId;){const b=this.artboard.objects.find(m=>m.id===d.parentId);if(b&&b.type==="Component"){c=b;break}d=b}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),c!==e&&this.fireEventForObject(c.id,u),c.type==="Component"&&c.variant==="toggle_button"&&t==="down"){const b=this.objectStates.get(c.id),m=(b==null?void 0:b.options)||c.options||{};m.checked=!m.checked,c.inputId&&this.setInternalInput(c.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle_button",property:"checked",value:m.checked}),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,m.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="toggle"&&t==="down"){const b=this.objectStates.get(c.id),m=(b==null?void 0:b.options)||c.options||{};m.checked=!m.checked,c.inputId&&this.setInternalInput(c.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"toggle",property:"checked",value:m.checked}),this.onToggle&&this.onToggle(c.name,m.checked),this.fireEventForObject(c.id,"Toggle"),this.fireEventForObject(c.id,m.checked?"Toggle True":"Toggle False")}if(c.type==="Component"&&c.variant==="dropdown"&&t==="down"){const b=this.objectStates.get(c.id),m=(b==null?void 0:b.options)||c.options||{},y=!m.isOpen;if(y&&this.activeDropdownId&&this.activeDropdownId!==c.id){const S=this.artboard.objects.find(v=>v.id===this.activeDropdownId);S&&S.options&&(S.options.isOpen=!1)}m.isOpen=y,this.activeDropdownId=y?c.id:null}if(c.type==="Component"&&c.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(c.name,c.id),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"button",property:"click",value:!0})),(c.type==="ListView"||c.type==="Component"&&c.variant==="listview")&&t==="down"){this.draggingListViewId=c.id;const b=this.getListViewItemIndexAtPointer(c,i,o);if(b!==null){const m=c.options||{};m.activeItemIndex=b;const y=this.objectStates.get(c.id);y&&y.options&&(y.options.activeItemIndex=b);const S=(m.items||[])[b],v=typeof S=="string"?S:S.label||S.value||b;y&&y.options&&(y.options.selectedValue=v),c.inputId&&this.setInternalInput(c.inputId,v),this.onComponentChange&&(this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"activeItemIndex",value:b}),this.onComponentChange({objectId:c.id,componentName:c.name,variant:"listview",property:"selected",value:v}))}}if(c.type==="Component"&&c.variant==="slider"&&t==="down"&&(this.draggingSliderId=c.id,this.updateSliderValueFromPointer(c,i,o)),c.type==="Joystick"||c.type==="Component"&&c.variant==="joystick"){if(t==="down")this.draggingJoystickId=c.id,this.updateJoystickValueFromPointer(c,i,o);else if(t==="up"||t==="blur"){const b=this.objectStates.get(c.id);b&&c.isSpringReturn!==!1&&(b.handleX=0,b.handleY=0),c.isSpringReturn!==!1&&(c.handleX=0,c.handleY=0)}}if(c.type==="Component"&&c.variant==="checkbox"&&t==="down"){const b=this.objectStates.get(c.id),m=(b==null?void 0:b.options)||c.options||{};m.checked=!m.checked,c.inputId&&this.setInternalInput(c.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"checkbox",property:"checked",value:m.checked}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,m.checked?"Checked":"Unchecked")}if(c.type==="Component"&&c.variant==="radiogroup"&&t==="down"){const b=this.objectStates.get(c.id),m=(b==null?void 0:b.options)||c.options||{},y=m.optionsList||[],S=this.getRadioGroupItemIndexAtPointer(c,i,o);if(S!==null&&S>=0&&S<y.length){const v=y[S];m.selectedValue=v,c.inputId&&this.setInternalInput(c.inputId,v),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"radiogroup",property:"selectedValue",value:v}),this.fireEventForObject(c.id,"Click"),this.fireEventForObject(c.id,`Selected: ${v}`)}}if(c.type==="LineGraph"&&(t==="down"||t==="click")){const b=c.geometry,m=(b==null?void 0:b.datasets)||[],y=this.objectStates.get(c.id),S=(y==null?void 0:y.width)||(b==null?void 0:b.width)||200,v=(y==null?void 0:y.height)||(b==null?void 0:b.height)||150,C=this.getWorldTransform(c.id),w=30,M=20,k=S-w,I=v-M;let T=1;m.forEach(_=>{const E=Math.max(..._.data||[0]);E>T&&(T=E)});let O=1/0,P=null;m.forEach((_,E)=>{const A=_.data||[],B=k/Math.max(A.length-1,1);A.forEach((X,W)=>{const Y=C.x-S/2+w+W*B,z=C.y+v/2-M-X/T*I,J=Math.sqrt((i-Y)**2+(o-z)**2);J<O&&(O=J,P={dIdx:E,pIdx:W,val:X,label:_.label||`Dataset ${E+1}`})})}),P&&O<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:c.id,componentName:c.name,datasetIndex:P.dIdx,pointIndex:P.pIdx,value:P.val,label:P.label}),this.onComponentChange&&this.onComponentChange({objectId:c.id,componentName:c.name,variant:"linegraph",property:"click",value:(P==null?void 0:P.val)??null})}if(t==="click"){const b=(r=this.artboard)==null?void 0:r.objects.find(S=>S.id===e.id),m=this.focusedId,y=(b==null?void 0:b.type)==="InputBox"||(b==null?void 0:b.type)==="Component"&&b.variant==="inputbox";if(b&&y){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),m!==this.focusedId){if(m){const S=(h=this.artboard)==null?void 0:h.objects.find(v=>v.id===m);S&&this.onInputBlur&&this.onInputBlur(S.name)}this.onInputFocus&&this.onInputFocus(b.name)}}else if(this.focusedId=null,m){const S=(f=this.artboard)==null?void 0:f.objects.find(v=>v.id===m);S&&this.onInputBlur&&this.onInputBlur(S.name)}}}else if(t==="click"){const c=this.focusedId;if(this.focusedId=null,c){const d=(p=this.artboard)==null?void 0:p.objects.find(u=>u.id===c);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||(this.activeKeys.add(t.key.toLowerCase()),this.activeKeys.add(t.code),!this.focusedId))return;const i=this.artboard.objects.find(a=>a.id===this.focusedId),o=(i==null?void 0:i.type)==="InputBox"||(i==null?void 0:i.type)==="Component"&&i.variant==="inputbox";if(!i||!o)return;const e=i.options||{};let s=e.text||"";if(t.key==="Backspace")s=s.slice(0,-1);else if(t.key==="Enter")if(e.multiline)s+=`
|
|
7
|
+
`;else{this.focusedId=null;return}else if(t.key.length===1)s+=t.key;else return;e.text=s;const n=i.geometry;n.textInputId&&this.updateInput(n.textInputId,s),this.onComponentChange&&this.onComponentChange({objectId:i.id,componentName:i.name,variant:"inputbox",property:"text",value:s}),this.onInputChange&&this.onInputChange(i.name,s),this.onInputUpdate&&this.onInputUpdate(this.focusedId,s)}handleKeyUp(t){this.artboard&&(this.activeKeys.delete(t.key.toLowerCase()),this.activeKeys.delete(t.code))}fireEventForObject(t,i){var h,f,p,c,d;const o=(h=this.artboard)==null?void 0:h.objects.find(u=>u.id===t);if(!o)return;const e=new Set([i,i.toLowerCase()]),s=i.toLowerCase();s==="onclick"||s==="click"||s==="onpointerdown"||s==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(s==="onpointerenter"||s==="hover"||s==="move")&&this.fireAnalyticsEvent(t,"hover"),s==="onclick"||s==="click"?(e.add("click"),e.add("onclick")):s==="onpointerdown"||s==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):s==="onpointerup"||s==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):s==="onpointerenter"||s==="hover"||s==="move"?(e.add("hover"),e.add("onpointerenter")):s==="onpointerleave"||s==="blur"?(e.add("onpointerleave"),e.add("blur")):s==="drag"||s==="ondrag"?(e.add("drag"),e.add("ondrag")):s==="toggle"||s==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):s==="toggle true"||s==="toggle_true"||s==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(s==="toggle false"||s==="toggle_false"||s==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const b=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?b.every(S=>e.has(S.toLowerCase())):b.some(S=>e.has(S.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(this.log(`[Engine] Interaction matched: ${i} -> 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,b=a.targetProperty;b&&this.updateObjectProperty(u,b,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,b=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(p=(f=this.artboard)==null?void 0:f.animations)==null||p.forEach(m=>{this.triggerGlobalAnimation(m.id,b)}):u&&this.triggerGlobalAnimation(u,b)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,m={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,m),this.log(`[Engine] State updated for ${u}:`,m)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((b,m)=>{m.startsWith("global_")&&this.layerStates.delete(m)}):u&&this.layerStates.forEach((b,m)=>{m.startsWith(`global_${u}_`)&&this.layerStates.delete(m)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,b=this.activeStateMachine.layers.find(m=>m.states.some(y=>y.id===u||y.name===u));b&&(this.log(`[Engine] Switching Layer ${b.name} to State ${u}`),this.enterStates(b.name,[u]))}this.onTrigger&&this.onTrigger(i,a.action)}const r=(o.triggers||[]).find(u=>{const b=u.eventType.toLowerCase();let m=!1;return(e.has(b)||b==="click"&&e.has("onclick")||b==="hover"&&(e.has("onpointerenter")||e.has("hover"))||b==="pointerdown"&&e.has("onpointerdown")||b==="pointerup"&&e.has("onpointerup"))&&(m=!0),m&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):m});if(r&&r.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${r.eventType}) -> Animation ${r.entryAnimationId}`);const u=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(b=>b.id===r.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:r.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:r.targetObjectId}),this.onTrigger&&this.onTrigger(r.name,u.name))}}fireAnalyticsEvent(t,i){var l,r;const o=(l=this.artboard)==null?void 0:l.objects.find(h=>h.id===t);if(!o)return;const e=(r=o.style)==null?void 0:r.analytics;if(!e||!e.isEnabled||e.triggerType!==i)return;const s=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 f=this.inputs.get(h.value);n[h.key]=f!==void 0?f:""}}),this.log(`[ExodeUI Analytics] Dispatching event "${s}" via ${i} 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",s,n),this.log(`[ExodeUI Analytics] GA4: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${s}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",s,n),this.log(`[ExodeUI Analytics] Meta Pixel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${s}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(s,n),this.log(`[ExodeUI Analytics] Mixpanel: Event "${s}" sent successfully.`)):this.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${s}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let i=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){i=!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)}}),!i&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,i,o=!1,e){if(!this.artboard)return;const s=this.artboard.animations.find(a=>a.id===t);if(!s)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:s,state:{loop:o},filterObjectIds:i}],time:0,duration:s.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${s.name} (Loop: ${o}, Sub-Anims: ${(i==null?void 0:i.length)||"All"})`)}handleAnimationFinished(t,i){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||i&&e.afterAnim===i)){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 p;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(p=this.artboard)==null?void 0:p.objects.find(c=>c.id===t);if(!o||!o.parentId)return{x:i.x,y:i.y,scaleX:i.scale_x??1,scaleY:i.scale_y??1,rotation:i.rotation??0};const e=this.getWorldTransform(o.parentId),s=e.rotation*(Math.PI/180),n=Math.cos(s),a=Math.sin(s),l=i.x*e.scaleX,r=i.y*e.scaleY,h=e.x+(l*n-r*a),f=e.y+(l*a+r*n);return{x:h,y:f,scaleX:(i.scale_x??1)*e.scaleX,scaleY:(i.scale_y??1)*e.scaleY,rotation:e.rotation+(i.rotation??0)}}hitTest(t,i,o){var S,v;if(!this.objectStates.get(t.id))return!1;const s=((S=t.geometry)==null?void 0:S.width)??t.width??100,n=((v=t.geometry)==null?void 0:v.height)??t.height??100,a=this.getWorldTransform(t.id),l=i-a.x,r=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h),c=l*f-r*p,d=l*p+r*f,u=a.scaleX,b=a.scaleY,m=s*Math.abs(u),y=n*Math.abs(b);return Math.abs(c)<=m/2&&Math.abs(d)<=y/2}updateSliderValueFromPointer(t,i,o){var M;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((M=t.geometry)==null?void 0:M.width)??t.width??200,a=this.getWorldTransform(t.id),l=i-a.x,r=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h),c=l*f-r*p,d=s.thumbWidth??16,u=n-d;let m=(c+u/2)/u;m=Math.max(0,Math.min(1,m));const y=s.min??0,S=s.max??100,v=s.step||1;let C=y+m*(S-y);v>0&&(C=Math.round(C/v)*v),C=Math.max(y,Math.min(S,C));const w=e.options||{};w.value!==C&&(e.options={...w,value:C},t.inputId&&this.setInternalInput(t.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:C}))}updateJoystickValueFromPointer(t,i,o){var M,k;const e=this.objectStates.get(t.id);if(!e)return;const s=(e==null?void 0:e.width)!==void 0?e.width:((M=t.geometry)==null?void 0:M.width)??t.width??100,n=(e==null?void 0:e.height)!==void 0?e.height:((k=t.geometry)==null?void 0:k.height)??t.height??100,a=this.getWorldTransform(t.id),l=i-a.x,r=o-a.y,h=-a.rotation*(Math.PI/180),f=Math.cos(h),p=Math.sin(h);let c=(l*f-r*p)/Math.max(.001,Math.abs(a.scaleX||1)),d=(l*p+r*f)/Math.max(.001,Math.abs(a.scaleY||1));t.handleOrigin==="top-left"?(c-=s/2,d-=n/2):t.handleOrigin==="bottom-right"&&(c+=s/2,d+=n/2);const u=Math.min(s,n)*.45,b=Math.min(s,n)*.15,m=u-b;let y=c/m,S=d/m;const v=Math.sqrt(y*y+S*S);t.boundsShape==="square"?(y=Math.max(-1,Math.min(1,y)),S=Math.max(-1,Math.min(1,S))):v>1&&(y/=v,S/=v),t.deadzone!==void 0&&v<t.deadzone?(y=0,S=0):(t.stepX!==void 0&&t.stepX>0&&(y=Math.round(y/t.stepX)*t.stepX),t.stepY!==void 0&&t.stepY>0&&(S=Math.round(S/t.stepY)*t.stepY)),t.joystickType==="1D_X"?S=0:t.joystickType==="1D_Y"&&(y=0);const C=e.handleX,w=e.handleY;(C!==y||w!==S)&&(e.handleX=y,e.handleY=S,t.handleX=y,t.handleY=S)}processJoysticks(t){this.artboard&&(this.artboard.objects.forEach(i=>{var a,l;if(i.type!=="Joystick"&&!(i.type==="Component"&&i.variant==="joystick"))return;const o=i,e=this.objectStates.get(o.id);if(!e)return;let s=e.handleX??o.handleX??0,n=e.handleY??o.handleY??0;if(((a=o.inputBinding)==null?void 0:a.type)==="keyboard"&&o.inputBinding.keyboardConfig){const r=o.inputBinding.keyboardConfig;let h=s,f=n;const c=(r.speed||5)*t;let d=!1;this.activeKeys.has(r.upKey.toLowerCase())&&(f-=c,d=!0),this.activeKeys.has(r.downKey.toLowerCase())&&(f+=c,d=!0),this.activeKeys.has(r.leftKey.toLowerCase())&&(h-=c,d=!0),this.activeKeys.has(r.rightKey.toLowerCase())&&(h+=c,d=!0),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const u=Math.sqrt(h*h+f*f);u>1&&(h/=u,f/=u),!d&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),s=h,n=f}else if(((l=o.inputBinding)==null?void 0:l.type)==="mouse"&&o.inputBinding.mouseConfig){const r=o.inputBinding.mouseConfig;let h=s,f=n;const p=r.sensitivity||.01,c=Math.abs(this._mouseDelta.dx)>0||Math.abs(this._mouseDelta.dy)>0;r.axisX&&(h+=this._mouseDelta.dx*p),r.axisY&&(f+=this._mouseDelta.dy*p),o.joystickType==="1D_X"&&(f=0),o.joystickType==="1D_Y"&&(h=0);const d=Math.sqrt(h*h+f*f);d>1&&(h/=d,f/=d),!c&&o.isSpringReturn!==!1&&(h+=(0-h)*(10*t),f+=(0-f)*(10*t),Math.abs(h)<.01&&(h=0),Math.abs(f)<.01&&(f=0)),s=h,n=f}if(e.handleX=s,e.handleY=n,o.handleX=s,o.handleY=n,o.bindings&&o.bindings.length>0){const r=Math.sqrt(s*s+n*n);let h=Math.atan2(n,s)*(180/Math.PI);h<0&&(h+=360),o.bindings.forEach(f=>{var d,u,b,m,y,S,v,C;let p=0;f.sourceAxis==="x"?p=o.invertX?-s:s:f.sourceAxis==="y"?p=o.invertY?-n:n:f.sourceAxis==="distance"?p=r:f.sourceAxis==="angle"&&(p=h);const c=(d=this.artboard)==null?void 0:d.objects.find(w=>w.id===f.targetObjectId);if(c){if(f.actionType==="bind"&&f.targetProperty&&f.isContinuous!==!1){const w=f.sourceMin??-1,M=f.sourceMax??1,k=f.targetMin??0,I=f.targetMax??100;let T=!!f.isContinuous,O=0,P=0;if(T){if((f.sourceAxis==="x"||f.sourceAxis==="y")&&k>=0){const E=Math.max(Math.abs(w),Math.abs(M))||1;P=p/E*I}else{let E=(p-w)/(M-w);E=Math.max(0,Math.min(1,E)),P=k+E*(I-k)}Math.abs(p)<.05&&(P=0)}else{const E=(p-w)/(M-w),A=Math.max(0,Math.min(1,E));O=k+A*(I-k),f.step&&f.step>0&&(O=Math.round(O/f.step)*f.step)}const _=this.objectStates.get(c.id);if(_){const E=f.isRelative!==!1,A=E?((u=c.transform)==null?void 0:u.x)??0:0,B=E?((b=c.transform)==null?void 0:b.y)??0:0,X=E?((m=c.transform)==null?void 0:m.rotation)??0:0,W=E?((y=c.transform)==null?void 0:y.scale_x)??1:0,Y=E?((S=c.transform)==null?void 0:S.scale_y)??1:0,z=E?((v=c.style)==null?void 0:v.opacity)??100:0,J=t*60,L=(x,et)=>{let V=O;if(T){const at=`_internal_${x}_${f.id}`;let F=_[at];F===void 0&&(F=_[x]??et),V=F+P*J,_[at]=V,f.step&&f.step>0&&(V=Math.round(V/f.step)*f.step)}else V=et+O;_[x]=V};f.targetProperty==="x"||f.targetProperty==="transform.x"?L("x",A):f.targetProperty==="y"||f.targetProperty==="transform.y"?L("y",B):f.targetProperty==="rotation"||f.targetProperty==="r"||f.targetProperty==="transform.rotation"?L("rotation",X):f.targetProperty==="scaleX"||f.targetProperty==="transform.scale_x"?L("scale_x",W):f.targetProperty==="scaleY"||f.targetProperty==="transform.scale_y"?L("scale_y",Y):(f.targetProperty==="opacity"||f.targetProperty==="transform.opacity")&&L("opacity",z)}(C=c.physics)!=null&&C.enabled&&this.physicsEngine&&(f.targetProperty==="x"||f.targetProperty==="transform.x"||f.targetProperty==="y"||f.targetProperty==="transform.y")&&(f.targetProperty==="x"||f.targetProperty==="transform.x"?this.physicsEngine.applyForce(c.id,(O-((_==null?void 0:_.x)||0))*10,0):(f.targetProperty==="y"||f.targetProperty==="transform.y")&&this.physicsEngine.applyForce(c.id,0,(O-((_==null?void 0:_.y)||0))*10))}else if(f.actionType==="playAnimation"||f.actionType==="stopAnimation"||f.actionType==="pauseAnimation"){let w=!1;const M=f.threshold??0;f.condition==="always"?w=!0:f.condition===">"?w=p>M:f.condition==="<"?w=p<M:f.condition==="=="&&(w=Math.abs(p-M)<.01);const k=e[`_prev_src_${f.id}`]??p;let I=!1;f.condition==="always"?I=!0:f.condition===">"?I=k>M:f.condition==="<"?I=k<M:f.condition==="=="&&(I=Math.abs(k-M)<.01),e[`_prev_src_${f.id}`]=p,w&&!I&&f.targetAnimationId&&(f.actionType==="playAnimation"||f.actionType)}}})}}),this._mouseDelta.dx=0,this._mouseDelta.dy=0)}applyBlendState(t,i){var r,h,f,p,c,d,u,b;if(!t.blendAnimations||t.blendAnimations.length===0)return;let o=0,e=0;t.blendInputX&&(o=this.inputs.get(t.blendInputX)??0),t.blendInputY&&(e=this.inputs.get(t.blendInputY)??0);const s=[];let n=0;if(t.blendType==="1D"){const m=[...t.blendAnimations].sort((y,S)=>y.position[0]-S.position[0]);if(m.length===1){const y=(h=(r=this.artboard)==null?void 0:r.animations)==null?void 0:h.find(S=>S.id===m[0].animationId);y&&(s.push({anim:y,weight:1}),n=1)}else{let y=0;for(;y<m.length-1&&m[y+1].position[0]<o;)y++;if(y===m.length-1&&o>m[y].position[0]){const S=(p=(f=this.artboard)==null?void 0:f.animations)==null?void 0:p.find(v=>v.id===m[y].animationId);S&&(s.push({anim:S,weight:1}),n=1)}else{const S=m[y].position[0],v=m[y+1].position[0],C=(d=(c=this.artboard)==null?void 0:c.animations)==null?void 0:d.find(T=>T.id===m[y].animationId),w=(b=(u=this.artboard)==null?void 0:u.animations)==null?void 0:b.find(T=>T.id===m[y+1].animationId),M=Math.max(.001,v-S);let k=(o-S)/M;k=Math.max(0,Math.min(1,k));const I=1-k;C&&(s.push({anim:C,weight:I}),n+=I),w&&(s.push({anim:w,weight:k}),n+=k)}}}else t.blendAnimations.forEach(m=>{var w,M;const y=(M=(w=this.artboard)==null?void 0:w.animations)==null?void 0:M.find(k=>k.id===m.animationId);if(!y)return;const S=m.position[0]-o,v=m.position[1]-e,C=S*S+v*v;if(C<1e-4)s.push({anim:y,weight:1e4}),n+=1e4;else{const k=1/C;s.push({anim:y,weight:k}),n+=k}});if(n===0)return;s.forEach(m=>m.weight/=n);const a=new Map,l=m=>{let y=m.startsWith("#")?m.substring(1):m;return y.length===3&&(y=[y[0],y[0],y[1],y[1],y[2],y[2]].join("")),y="0x"+y,{r:y>>16&255,g:y>>8&255,b:y&255,a:1}};s.forEach(({anim:m,weight:y})=>{m.tracks&&m.tracks.forEach(S=>{var O,P;const v=S.object_id||S.objectId,C=S.property,w=(O=this.artboard)==null?void 0:O.objects.find(_=>_.id===v);if(((P=w==null?void 0:w.physics)==null?void 0:P.enabled)&&w.physics.bodyType!=="Static"&&(C==="x"||C==="y"||C==="rotation"))return;const k=this.interpolate(S.keyframes,i);if(k===void 0)return;let I=a.get(v);I||(I=new Map,a.set(v,I));let T=I.get(C);if(!T){if(typeof k=="number")T={type:"number",value:0};else if(typeof k=="string"&&k.startsWith("#"))T={type:"color",value:k,colorAcc:{r:0,g:0,b:0,a:0}};else if(T={type:"number",value:k},y<.5)return;I.set(C,T)}if(T.type==="number"&&typeof k=="number")T.value+=k*y;else if(T.type==="color"&&typeof k=="string"&&T.colorAcc){const _=l(k);_&&(T.colorAcc.r+=_.r*y,T.colorAcc.g+=_.g*y,T.colorAcc.b+=_.b*y,T.colorAcc.a+=_.a*y)}else y>.5&&(T.value=k)})}),a.forEach((m,y)=>{var C;const S=this.objectStates.get(y),v=(C=this.artboard)==null?void 0:C.objects.find(w=>w.id===y);!S||!v||m.forEach((w,M)=>{let k=w.value;if(w.type==="color"&&w.colorAcc){const I=Math.round(w.colorAcc.r).toString(16).padStart(2,"0"),T=Math.round(w.colorAcc.g).toString(16).padStart(2,"0"),O=Math.round(w.colorAcc.b).toString(16).padStart(2,"0");k=`#${I}${T}${O}`}if(M.includes(".")||M.includes("[")){const I=(M||"").replace(/\[(\d+)\]/g,".$1").split(".");let T=S;for(let O=0;O<I.length-1;O++){if(typeof T[I[O]]!="object"||T[I[O]]===null){let P=v;for(let _=0;_<=O;_++)P=P?P[I[_]]:null;if(I[O]==="corner_radius"||I[O]==="cornerRadius"){const _=typeof T[I[O]]=="number"?T[I[O]]:typeof P=="number"?P:0;T[I[O]]={tl:_,tr:_,bl:_,br:_}}else{const _=I[O+1],E=!isNaN(Number(_));T[I[O]]=P?JSON.parse(JSON.stringify(P)):E?[]:{}}}T=T[I[O]]}T[I[I.length-1]]=k,I[I.length-1]==="color"&&(I[I.length-2]==="fill"||I[I.length-2]==="stroke")&&(T.type="Solid")}else M==="fill"?(S.style||(S.style={}),S.style.fill=k):M==="stroke"?(S.style||(S.style={}),S.style.stroke=k):S[M]=k})})}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var f,p,c;const s=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(s))return}else if(s!==o)return}const n=(f=this.artboard)==null?void 0:f.objects.find(d=>d.id===s),a=((p=n==null?void 0:n.physics)==null?void 0:p.enabled)&&n.physics.bodyType!=="Static";let l=e.property;if(a&&(l==="x"||l==="y"||l==="rotation"))return;const r=this.objectStates.get(s);if(!r){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const h=this.interpolate(e.keyframes,i);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||s,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${l} = ${u} to ${d}`)}if(l.includes(".")||l.includes("[")){const d=(l||"").replace(/\[(\d+)\]/g,".$1").split(".");let u=r;for(let b=0;b<d.length-1;b++){if(typeof u[d[b]]!="object"||u[d[b]]===null){let m=n;for(let y=0;y<=b;y++)m=m?m[d[y]]:null;if(d[b]==="corner_radius"||d[b]==="cornerRadius"){const y=typeof u[d[b]]=="number"?u[d[b]]:typeof m=="number"?m:0;u[d[b]]={tl:y,tr:y,bl:y,br:y}}else{const y=d[b+1],S=!isNaN(Number(y));u[d[b]]=m?JSON.parse(JSON.stringify(m)):S?[]:{}}}u=u[d[b]]}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 l==="fill"?(r.style||(r.style={}),r.style.fill=h):l==="stroke"?(r.style||(r.style={}),r.style.stroke=h):r[l]=h;if(this.physicsEngine&&((c=n==null?void 0:n.physics)!=null&&c.enabled)&&n.physics.bodyType==="Static")if(l==="x"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,h,d.y)}else if(l==="y"){const d=this.physicsEngine.getPosition(s);d&&this.physicsEngine.setPosition(s,d.x,h)}else l==="rotation"&&this.physicsEngine.setRotation(s,h*(Math.PI/180))}})}interpolate(t,i){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(i<=o.time)return o.value;if(i>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(i>=t[a].time&&i<t[a+1].time){o=t[a],e=t[a+1];break}const s=e.time-o.time;let n=(i-o.time)/s;return o.easing&&(n=si(o.easing)(n)),this.interpolateValue(o.value,e.value,n)}interpolateValue(t,i,o){if(t===void 0)return i;if(i===void 0)return t;if(typeof t=="string"&&typeof i=="string"){if(t.startsWith("#"))return this.interpolateColor(t,i,o);const e=parseFloat(t),s=parseFloat(i);return!isNaN(e)&&!isNaN(s)?Math.round(e+(s-e)*o).toString():o<.5?t:i}if(Array.isArray(t)&&Array.isArray(i))return t.length===i.length?t.map((e,s)=>this.interpolateValue(e,i[s],o)):o<.5?t:i;if(typeof t=="object"&&typeof i=="object"&&t!==null&&i!==null){if(t.width!==void 0&&t.color!==void 0&&typeof t.width=="number")return this.interpolateStroke(t,i,o);if(t.type&&i.type&&(t.type==="Solid"||t.type==="LinearGradient"||t.type==="RadialGradient"||t.type==="Image"))return this.interpolateFill(t,i,o);const e={};return new Set([...Object.keys(t),...Object.keys(i)]).forEach(n=>{e[n]=this.interpolateValue(t[n],i[n],o)}),e}return typeof t=="number"&&typeof i=="number"?t+(i-t)*o:o<.5?t:i}interpolateColor(t,i,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},s=e[t]||t,n=e[i]||i,a=b=>{if(!b)return{r:0,g:0,b:0};const m=b.startsWith("#")?b.replace("#",""):"000000";return m.length===3?{r:parseInt(m[0]+m[0],16),g:parseInt(m[1]+m[1],16),b:parseInt(m[2]+m[2],16)}:{r:parseInt(m.substring(0,2),16),g:parseInt(m.substring(2,4),16),b:parseInt(m.substring(4,6),16)}},l=a(s),r=a(n),h=Math.round(l.r+(r.r-l.r)*o),f=Math.round(l.g+(r.g-l.g)*o),p=Math.round(l.b+(r.b-l.b)*o),c=b=>{const m=Math.max(0,Math.min(255,b)).toString(16);return m.length===1?"0"+m:m};return`#${c(h)}${c(f)}${c(p)}`}interpolateStops(t,i,o){return!t||!i||t.length!==i.length?o<.5?t:i:t.map((e,s)=>{const n=i[s];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,i,o){if(!t||!i||t.type!==i.type)return o<.5?t:i;const e={...t,opacity:(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,i.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&i.start&&(e.start=[t.start[0]+(i.start[0]-t.start[0])*o,t.start[1]+(i.start[1]-t.start[1])*o]),t.end&&i.end&&(e.end=[t.end[0]+(i.end[0]-t.end[0])*o,t.end[1]+(i.end[1]-t.end[1])*o]),t.center&&i.center&&(e.center=[t.center[0]+(i.center[0]-t.center[0])*o,t.center[1]+(i.center[1]-t.center[1])*o]),t.radius!==void 0&&i.radius!==void 0&&(e.radius=t.radius+(i.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,i.stops,o)),e}interpolateStroke(t,i,o){if(!t||!i)return o<.5?t:i;const e={...t};return e.width=(t.width??0)+((i.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((i.opacity??1)-(t.opacity??1))*o,t.fill&&i.fill?e.fill=this.interpolateFill(t.fill,i.fill,o):t.color&&i.color&&t.color.startsWith("#")&&i.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,i.color,o)),e.trimStart=(t.trimStart??0)+((i.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((i.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((i.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((i.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,i,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=i,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,i,o);const s=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(i,o,s,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),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(0,0,s,n)),this.artboard.backgroundImage){const p=this.artboard.backgroundImage;let c=this.imageCache.get(p);if(c||(c=new Image,c.src=p,this.imageCache.set(p,c)),c.complete&&c.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=c.naturalWidth/c.naturalHeight,u=s/n;let b,m,y,S;u>d?(b=s,m=s/d):(m=n,b=n*d),y=(s-b)/2,S=(n-m)/2,t.drawImage(c,y,S,b,m),t.restore()}}(this.artboard.clipContent===!0||this.artboard.clip_content===!0)&&(t.beginPath(),t.rect(0,0,s,n),t.clip());const r=new Map;this.artboard.objects.forEach(p=>r.set(p.id,p)),this.artboard.objects.filter(p=>!p.parentId).map((p,c)=>{const d=this.objectStates.get(p.id),u=(d==null?void 0:d.zIndex)??c;return{obj:p,zIndex:u}}).sort((p,c)=>p.zIndex-c.zIndex).forEach(({obj:p})=>{this.renderObject(t,p,r)}),this._emitterPools.forEach((p,c)=>{if(!(p.length===0||!r.get(c)))for(const u of p)t.save(),t.globalAlpha=u.opacity,t.fillStyle=u.color,t.beginPath(),t.arc(u.x,u.y,Math.max(1,u.size*u.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&this.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,i,o,e,s,n=0){const a=t.getTransform(),l=i*a.a+o*a.c+a.e,r=i*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),f=Math.sqrt(a.c*a.c+a.d*a.d),p=(e/2+n)*h,c=(s/2+n)*f;return l+p>=0&&l-p<=this.canvasWidth&&r+c>=0&&r-c<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,l=1,r=1;const h=o/e,f=t/i;switch(s){case"Contain":f>h?r=i/e:r=t/o,a=l=r;break;case"Cover":f>h?r=t/o:r=i/e,a=l=r;break;case"Fill":a=t/o,l=i/e;break;case"FitWidth":r=t/o,a=l=r;break;case"FitHeight":r=i/e,a=l=r;break;case"None":a=l=1;break;case"ScaleDown":r=Math.min(t/o,i/e),r>1&&(r=1),a=l=r;break;default:a=l=1;break}const p=o*a,c=e*l;let d=0,u=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-p:d=(t-p)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=i-c:u=(i-c)/2,{scaleX:a,scaleY:l,tx:d,ty:u}}mapFontWeight(t){const i=t.toLowerCase();return i==="thin"||i==="100"?"100":i==="extralight"||i==="200"?"200":i==="light"||i==="300"?"300":i==="regular"||i==="normal"||i==="400"?"400":i==="medium"||i==="500"?"500":i==="semibold"||i==="600"?"600":i==="bold"||i==="700"?"700":i==="extrabold"||i==="800"?"800":i==="black"||i==="900"?"900":t}drawTextDecoration(t,i,o,e,s,n){t.beginPath();const a=Math.max(1,n/14);let l=e;i==="underline"?l=e+n*.12:i==="line-through"&&(l=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-s/2,l),t.lineTo(o+s/2,l),t.stroke()}renderObject(t,i,o,e=!1,s=!1){var m,y,S,v,C,w,M,k,I,T,O,P,_,E,A,B,X,W,Y,z,J,L,x,et,V,at,F;const n=this.objectStates.get(i.id);if(!n){this.warn("No state for object:",i.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(R,D,H,Z,ct)=>(this.drawRoundRect(t,R,D,H,Z,ct),t));const a=n.geometry?this.deepMerge(i.geometry,n.geometry):i.geometry;let l=n.style?this.deepMerge(i.style,n.style):i.style,r=(a==null?void 0:a.width)||((m=i.geometry)==null?void 0:m.width)||i.width||0,h=(a==null?void 0:a.height)||((y=i.geometry)==null?void 0:y.height)||i.height||0;if((r===0||h===0)&&(a!=null&&a.points)&&Array.isArray(a.points)&&a.points.length>0){let R=1/0,D=-1/0,H=1/0,Z=-1/0;a.points.forEach(ct=>{R=Math.min(R,ct.x),D=Math.max(D,ct.x),H=Math.min(H,ct.y),Z=Math.max(Z,ct.y)}),r===0&&(r=D-R),h===0&&(h=Z-H)}const f=R=>{if(R)return R.corner_radius??R.cornerRadius},p=f(n)??f(l)??f(a)??f(i.style)??f(i.geometry)??0;let c={...a,width:r,height:h};if(delete c.cornerRadius,c.corner_radius=p,!c.type&&(i.type==="Frame"||i.type==="Component"||i.type==="Group")&&(c.type="Rectangle"),c.type==="Path"&&i.weights&&i.bindMatrices&&c.points){const R=this.getGlobalTransform(i.id);if(R){const D=ii(c.points,i.weights,i.bindMatrices,R,H=>this.getGlobalTransform(H));c={...c,points:D}}}if(n.visible===!1)return;const d=i.repeaterConfig,u=d&&d.isEnabled&&d.count>1,b=u?d.count:1;for(let R=0;R<b;R++){let D=n.x!==void 0?n.x:((S=n.transform)==null?void 0:S.x)??0,H=n.y!==void 0?n.y:((v=n.transform)==null?void 0:v.y)??0,Z=n.rotation!==void 0?n.rotation:((C=n.transform)==null?void 0:C.rotation)??0,ct=n.scale_x!==void 0?n.scale_x:((w=n.transform)==null?void 0:w.scale_x)??1,Ct=n.scale_y!==void 0?n.scale_y:((M=n.transform)==null?void 0:M.scale_y)??1;if(u&&R>0){if(d.type==="Linear"){const it=d.offsetX||0,ut=d.offsetY||0,st=d.rotation||0,G=d.scale!==void 0?d.scale:1;D+=R*it,H+=R*ut,Z+=R*st,ct*=Math.pow(G,R),Ct*=Math.pow(G,R)}else if(d.type==="Grid"){const it=d.cols||Math.ceil(Math.sqrt(d.count)),ut=d.gapX||0,st=d.gapY||0,G=Math.floor(R/it),nt=R%it,lt=r+ut,mt=h+st;D+=nt*lt,H+=G*mt}else if(d.type==="Radial"){const it=d.radius||100,ut=d.startAngle||0,G=(d.endAngle||360)-ut,nt=d.count>1?G/(G===360?d.count:d.count-1):0,lt=ut+R*nt,mt=lt*Math.PI/180;D=n.x+it*Math.cos(mt),H=n.y+it*Math.sin(mt),Z+=lt}}const vt=i.type==="Group"||i.type==="Frame"||i.type==="Component",At=r>0&&h>0;if(!vt&&At&&!e){const it=(((k=l.shadow)==null?void 0:k.isEnabled)!==!1?(((I=l.shadow)==null?void 0:I.blur)||0)+10:0)+(((T=l.blur)==null?void 0:T.isEnabled)!==!1&&((O=l.blur)==null?void 0:O.radius)||0)+20;if(!this.isObjectInView(t,D,H,r,h,it))continue}this.debug_objectsRendered++,t.save();const It=[],Tt=l.blur||((P=i.style)==null?void 0:P.blur);Tt&&Tt.amount>0&&It.push(`blur(${Tt.amount}px)`);const qt=l.effects||((_=i.style)==null?void 0:_.effects)||[];let ue=qt.find(it=>it.isEnabled!==!1&&(it.type==="BackgroundBlur"||it.type==="LayerBlur"));ue||(ue=l.effect||((E=i.style)==null?void 0:E.effect)||qt.find(it=>it.isEnabled!==!1));const Qt=ue,tt=(Qt==null?void 0:Qt.isEnabled)!==!1,gt=Qt==null?void 0:Qt.type,Ft=(Qt==null?void 0:Qt.radius)??10;tt&>==="LayerBlur"?It.push(`blur(${Ft}px)`):tt&>==="BackgroundBlur"&&(l===i.style&&(l={...l}),l.fill={type:"None"});const Et=((A=a==null?void 0:a.type)==null?void 0:A.toLowerCase().includes("image"))||((B=i.type)==null?void 0:B.toLowerCase().includes("image")),Mt=l.adjustments&&Object.keys(l.adjustments).length>0?l.adjustments:null,Bt=a!=null&&a.adjustments&&Object.keys(a.adjustments).length>0?a.adjustments:null,Ht=Et?Bt||Mt:Mt||Bt,_t=Et&&!Ht?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:Ht;if(n&&_t&&(n.geometry=n.geometry||{},n.geometry.adjustments={..._t}),_t){const it=(_t.exposure||0)/100,ut=_t.contrast||0,st=1+(_t.saturation||0)/100,G=(_t.temperature||0)/200,nt=(_t.tint||0)/200,lt=(_t.highlights||0)/500,mt=(_t.shadows||0)/500;let Ot="",ht="SourceGraphic";if(it!==0&&(Ot+=`
|
|
8
|
+
<feComponentTransfer in="${ht}" result="exposure">
|
|
9
|
+
<feFuncR type="linear" slope="1" intercept="${it}"/>
|
|
10
|
+
<feFuncG type="linear" slope="1" intercept="${it}"/>
|
|
11
|
+
<feFuncB type="linear" slope="1" intercept="${it}"/>
|
|
12
|
+
</feComponentTransfer>`,ht="exposure"),ut!==0){const bt=(ut+100)/100,$t=.5*(1-bt);Ot+=`
|
|
13
|
+
<feComponentTransfer in="${ht}" result="contrast">
|
|
14
|
+
<feFuncR type="linear" slope="${bt}" intercept="${$t}"/>
|
|
15
|
+
<feFuncG type="linear" slope="${bt}" intercept="${$t}"/>
|
|
16
|
+
<feFuncB type="linear" slope="${bt}" intercept="${$t}"/>
|
|
17
|
+
</feComponentTransfer>`,ht="contrast"}if(st!==1&&(Ot+=`<feColorMatrix in="${ht}" type="saturate" values="${st}" result="saturate"/>`,ht="saturate"),_t.hue&&(Ot+=`<feColorMatrix in="${ht}" type="hueRotate" values="${_t.hue}" result="hue"/>`,ht="hue"),_t.negative){const bt=1-_t.negative/50;Ot+=`
|
|
18
|
+
<feColorMatrix in="${ht}" type="matrix" result="invert"
|
|
19
|
+
values="${bt} 0 0 0 ${1-bt}
|
|
20
|
+
0 ${bt} 0 0 ${1-bt}
|
|
21
|
+
0 0 ${bt} 0 ${1-bt}
|
|
22
|
+
0 0 0 1 0"/>`,ht="invert"}if(G!==0||nt!==0||lt!==0||mt!==0){const bt=1+lt+mt,$t=bt*(1+G-nt/2),$=bt*(1+nt),Xt=bt*(1-G-nt/2),Wt=_t.shadows*.1/255,jt=[$t,0,0,0,Wt,0,$,0,0,Wt,0,0,Xt,0,Wt,0,0,0,1,0].join(" ");Ot+=`<feColorMatrix in="${ht}" type="matrix" values="${jt}" result="advanced"/>`,ht="advanced"}if(_t.blur&&(Ot+=`<feGaussianBlur in="${ht}" stdDeviation="${_t.blur}" result="blur"/>`,ht="blur"),Ot){const bt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Ot}</filter></svg>`,$t=btoa(bt);It.push(`url('data:image/svg+xml;base64,${$t}#f')`)}}It.length>0?t.filter=It.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const zt=t.globalAlpha,Zt=this.normalizeOpacity(n.opacity!==void 0?n.opacity:100);t.globalAlpha=zt*Zt;const le=n.compositeOperation||n.blendMode;if(le&&le!=="Normal"){const it=le.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(it)&&(t.globalCompositeOperation=it)}const ce=t,Me=n.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[]);let oe=!1;const Ce=Me.filter(it=>it.isVisible!==!1&&o.has(it.maskId));if(Ce.length>0){const it=Ce[0],ut=o.get(it.maskId),st=this.objectStates.get(ut.id);st&&st.visible!==!1&&(oe=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),i.parentId&&this.applyAbsoluteTransform(this.maskCtx,i.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=ce.filter)}if(!s){t.translate(Math.round(D),Math.round(H)),t.rotate(Z*Math.PI/180);const it=n.skew_x||0,ut=n.skew_y||0;if(it!==0||ut!==0){const ht=Math.tan(it*Math.PI/180),xt=Math.tan(ut*Math.PI/180);t.transform(1+ht*xt,xt,ht,1,0,0)}const st=n.rotate_x!==void 0?n.rotate_x:((X=n.transform)==null?void 0:X.rotate_x)??0,G=n.rotate_y!==void 0?n.rotate_y:((W=n.transform)==null?void 0:W.rotate_y)??0,lt=1+(n.translate_z!==void 0?n.translate_z:((Y=n.transform)==null?void 0:Y.translate_z)??0)/1e3,mt=(n.flip_x===!0?-1:1)*Math.cos(G*Math.PI/180)*lt,Ot=(n.flip_y===!0?-1:1)*Math.cos(st*Math.PI/180)*lt;t.scale(ct*mt,Ct*Ot)}l.shadow&&l.shadow.isEnabled!==!0&&((l.shadow.blur||0)>0||Math.abs(l.shadow.offsetX||0)>0||Math.abs(l.shadow.offsetY||0)>0)&&(l.shadow.isEnabled=!0);const fe=l.shadow;if(fe&&fe.isEnabled!==!1&&!e){let it=fe.color||"#000000";(J=(z=this.artboard)==null?void 0:z.tokens)!=null&&J.colors&&this.artboard.tokens.colors[it]&&(it=this.artboard.tokens.colors[it]);const ut=this.normalizeOpacity(fe.opacity??100)*.75,st=fe.spread||0,nt=(fe.blur||0)+st*1.5;let lt=it;if(it.startsWith("#")){const ht=it.replace("#",""),xt=parseInt(ht.substring(0,2),16),bt=parseInt(ht.substring(2,4),16),$t=parseInt(ht.substring(4,6),16);lt=`rgba(${xt}, ${bt}, ${$t}, ${ut})`}else if(it.startsWith("rgba")){const ht=it.match(/[\d.]+/g);if(ht&&ht.length>=4){const xt=ht[0],bt=ht[1],$t=ht[2],$=ht[3];lt=`rgba(${xt}, ${bt}, ${$t}, ${parseFloat($)*ut})`}}const mt=t.getTransform(),Ot=Math.sqrt(mt.a*mt.a+mt.b*mt.b)||1;t.shadowColor=lt,t.shadowBlur=nt*Ot,t.shadowOffsetX=(fe.offsetX||0)*Ot,t.shadowOffsetY=(fe.offsetY||0)*Ot}const he=i.liquidFill||((L=i.style)==null?void 0:L.liquidFill);if(he&&he.enabled){t.save();const it=he.fillLevel??.5;t.beginPath();const ut=h/2-h*it;t.rect(-r/2,ut,r,h*it),t.clip(),t.fillStyle=he.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(he.opacity??1)}if(e||this.applyOuterGlowUnderlay(t,i,c,r,h,p,l,o),(a==null?void 0:a.type)==="Text")this._renderText(t,i,c,l,n,r,h,!1,!1,ct,Ct);else if((a==null?void 0:a.type)==="Image"){const it=a.originalSrc||a.src;if(it){let ut=this.imageCache.get(it);ut||(ut=new Image,ut.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${ut.naturalWidth}x${ut.naturalHeight}`)},ut.onerror=nt=>{console.error("[ExodeUI] Image load failed:",nt,`Src preview: ${it.substring(0,100)}...`)},ut.src=it,this.imageCache.set(it,ut));const st=l.stroke&&l.stroke.width>0&&l.stroke.isEnabled!==!1,G=(((x=l.stroke)==null?void 0:x.alignment)||"center").toLowerCase();if(st&&(G==="outside"||G==="center")&&this.applyStrokeAlignment(t,l,c,r,h,p,ct,Ct),l.fill&&l.fill.type!=="None"){t.save();const nt=t.globalAlpha,lt=this.createCanvasFill(t,l.fill,r,h);t.fillStyle=lt||l.fill.color||"transparent",t.globalAlpha=nt*this.normalizeOpacity(l.fill.opacity??100),p!==0?(this.drawRoundRect(t,-r/2,-h/2,r,h,p),t.fill()):t.fillRect(-r/2,-h/2,r,h),t.globalAlpha=nt,t.restore()}ut.complete&&ut.naturalWidth>0?(p!==0?(t.save(),this.drawRoundRect(t,-r/2,-h/2,r,h,p),t.clip(),t.drawImage(ut,-r/2,-h/2,r,h),t.restore()):t.drawImage(ut,-r/2,-h/2,r,h),st&&G==="inside"&&this.applyStrokeAlignment(t,l,c,r,h,p,ct,Ct)):st&&G==="inside"&&this.applyStrokeAlignment(t,l,c,r,h,p,ct,Ct)}}else if(a.type==="SVG"){const it=a.svgContent;if(it){const ut=l.palette||[],st=l.fill,G=l.stroke,nt=st?this.normalizeOpacity(st.opacity??100):1,lt=G&&G.isEnabled!==!1?this.normalizeOpacity(G.opacity??100):1,mt=(st==null?void 0:st.type)==="Solid"&&(!G||G.isEnabled===!1||G.type==="Solid"&&G.color===st.color&<===nt),Ot=st&&st.type!=="None"?mt?"monochrome":st.type==="Solid"?(st.color||"")+"|opacity:"+nt:JSON.stringify(st.stops||[])+"|opacity:"+nt:"",ht=G&&G.isEnabled!==!1&&(G.width||0)>0?mt?["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",xt=[i.id,ut.join("_"),Ot,ht,n.opacity??100,n.visible!==!1?"v":"h"].join("_");let bt=this.imageCache.get(xt);if(!bt){bt=new Image,bt.crossOrigin="anonymous";let $=it;$.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||($=$.replace(/<svg([^>]*)>/i,(yt,ot)=>`<svg xmlns="http://www.w3.org/2000/svg"${ot}>`));let Xt=a.width||r||100,Wt=a.height||h||100;const jt=$.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(jt&&(Xt=parseFloat(jt[1]),Wt=parseFloat(jt[2])),$=$.replace(/<svg([^>]*)>/i,(yt,ot)=>{let N=ot.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return N.match(/\bviewBox=/i)||(N+=` viewBox="0 0 ${Xt} ${Wt}"`),N.match(/\bpreserveAspectRatio=/i)||(N+=' preserveAspectRatio="none"'),N+=' width="100%" height="100%"',`<svg${N}>`}),a.colors&&a.colors.length>0&&ut.length>0&&a.colors.forEach((yt,ot)=>{if(ut[ot]){const N=yt.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),ft=new RegExp(N,"gi");$=$.replace(ft,ut[ot])}}),st&&st.type&&st.type!=="None"){if(st.type==="Solid"&&st.color){const yt=mt?"#FFFFFF":st.color,ot=mt?1:this.normalizeOpacity(st.opacity??100);$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,N=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(N)?N:`fill="${yt}"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,N=>/fill\s*:\s*(none|transparent)/i.test(N)?N:`fill:${yt}`),ot<1&&($=$.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${ot}"`),$=$.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${ot}`),$.match(/\bfill-opacity\s*=/i)||($=$.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${ot}">`),$=$.replace(/<\/svg>/i,"</g></svg>")))}else if(st.type==="LinearGradient"||st.type==="RadialGradient"||st.type==="Linear"||st.type==="Radial"){const yt="exode-fill",ot=this.normalizeOpacity(st.opacity??100),N=(st.stops||[]).map(dt=>{const j=dt.offset!==void 0?dt.offset:dt.pos??0,St=this.normalizeOpacity(dt.opacity??100)*ot;return`<stop offset="${j*100}%" stop-color="${dt.color||"#000"}" stop-opacity="${St}"/>`}).join("");let ft="";if(st.type==="LinearGradient"||st.type==="Linear"){const dt=(Jt,ee)=>Array.isArray(Jt)?Jt[ee]??(ee===0?0:1):Jt&&typeof Jt=="object"?Jt[ee===0?"x":"y"]??(ee===0?0:1):ee===0?0:1,j=dt(st.start,0)*100,St=dt(st.start,1)*100,wt=dt(st.end,0)*100,Yt=dt(st.end,1)*100;ft=`<linearGradient id="${yt}" x1="${j}%" y1="${St}%" x2="${wt}%" y2="${Yt}%" gradientUnits="objectBoundingBox">${N}</linearGradient>`}else{const dt=(Yt,Jt)=>Array.isArray(Yt)?Yt[Jt]??.5:Yt&&typeof Yt=="object"?Yt[Jt===0?"x":"y"]??.5:.5,j=dt(st.center,0)*100,St=dt(st.center,1)*100,wt=(st.radius??.5)*100;ft=`<radialGradient id="${yt}" cx="${j}%" cy="${St}%" r="${wt}%" gradientUnits="objectBoundingBox">${N}</radialGradient>`}/<defs>/i.test($)?$=$.replace(/<defs>/i,`<defs>${ft}`):$=$.replace(/<svg([^>]*)>/i,`<svg$1><defs>${ft}</defs>`),$=$.replace(/\bfill\s*=\s*["'][^"']*["']/gi,dt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(dt)?dt:`fill="url(#${yt})"`),$=$.replace(/fill\s*:\s*[^;"')]+/gi,dt=>/fill\s*:\s*(none|transparent)/i.test(dt)?dt:`fill:url(#${yt})`)}}const Gt=(yt,ot,N=1)=>{const ft=(yt.stops||[]).map(Yt=>{const Jt=Yt.offset!==void 0?Yt.offset:Yt.pos??0,ee=this.normalizeOpacity(Yt.opacity??100)*N;return`<stop offset="${Jt*100}%" stop-color="${Yt.color||"#000"}" stop-opacity="${ee}"/>`}).join(""),dt=(Yt,Jt,ee=.5)=>Array.isArray(Yt)?Yt[Jt]??ee:Yt&&typeof Yt=="object"?Yt[Jt===0?"x":"y"]??ee:ee;if(yt.type==="LinearGradient"||yt.type==="Linear"){const Yt=dt(yt.start,0,0)*100,Jt=dt(yt.start,1,0)*100,ee=dt(yt.end,0,1)*100,ke=dt(yt.end,1,1)*100;return`<linearGradient id="${ot}" x1="${Yt}%" y1="${Jt}%" x2="${ee}%" y2="${ke}%" gradientUnits="objectBoundingBox">${ft}</linearGradient>`}const j=dt(yt.center,0,.5)*100,St=dt(yt.center,1,.5)*100,wt=(yt.radius??.5)*100;return`<radialGradient id="${ot}" cx="${j}%" cy="${St}%" r="${wt}%" gradientUnits="objectBoundingBox">${ft}</radialGradient>`},Nt=(yt,ot)=>/<defs>/i.test(yt)?yt.replace(/<defs>/i,`<defs>${ot}`):yt.replace(/(<svg[^>]*>)/i,`$1<defs>${ot}</defs>`);if(G&&G.isEnabled!==!1&&(G.width||0)>0){const yt=mt?1:this.normalizeOpacity(G.opacity??100),ot=mt?"#FFFFFF":G.color||(st==null?void 0:st.color)||"#000000";let N="";const ft=G.fill;if(ft&&ft.type){if(ft.type==="Solid")N=ft.color||G.color||"#000000";else if(ft.type==="LinearGradient"||ft.type==="RadialGradient"||ft.type==="Linear"||ft.type==="Radial"){const Kt="exode-stroke";$=Nt($,Gt(ft,Kt,yt)),N=`url(#${Kt})`}}N||(N=ot),$.match(/\bstroke\s*=\s*["']/i)?$=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Kt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Kt)?Kt:`stroke="${N}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${N}"`),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${N}`);let dt=a.width||r||100,j=a.height||h||100;const St=it.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(St){const Kt=parseFloat(St[1]),re=parseFloat(St[2]);!isNaN(Kt)&&!isNaN(re)&&(dt=Kt,j=re)}const wt=Math.max(.001,r/dt),Yt=Math.max(.001,h/j),Jt=(wt+Yt)/2,ee=(G.width||1)/Jt;$.match(/\bstroke-width\s*=\s*["']/i)?$=$.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${ee}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${ee}"`),$=$.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${ee}`),$.match(/\bstroke-opacity\s*=\s*["']/i)?$=$.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${yt}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${yt}"`),$=$.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${yt}`);const ke=G.lineCap||"round";$.match(/\bstroke-linecap\s*=\s*["']/i)?$=$.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${ke}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${ke}"`),$=$.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${ke}`);const _e=G.lineJoin||"round";$.match(/\bstroke-linejoin\s*=\s*["']/i)?$=$.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${_e}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${_e}"`),$=$.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${_e}`);const Pe=G.trimStart??0,Ee=G.trimEnd??1,Ae=G.trimOffset??0,Oe=G.dashOffset??0,$e=Pe!==0||Ee!==1||Ae!==0||Oe!==0;if($e){const Kt=Math.max(0,Math.min(1,Pe)),re=Math.max(0,Math.min(1,Ee));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Kt}, End: ${re}`);const ge=(dt+j)*2,Le=(Ae%1+1)%1,Re=(Oe%1+1)%1;let be="",ye=0;if(Kt>=re)be=`0 ${ge}`,ye=0;else{const me=ge*(re-Kt),Ie=ge-me;ye=-(ge*(Kt+Le+Re)),be=`${me} ${Ie}`}$.match(/\bstroke-dasharray\s*=/i)?$=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${be}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${be}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${be}`),$.match(/\bstroke-dashoffset\s*=/i)?$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${ye}"`):$=$.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${ye}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${ye}`)}else if(G.dashArray&&G.dashArray.length>0){const Kt=G.dashArray.join(" ");if($=$.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Kt}"`),$=$.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Kt}`),G.dashOffset){const re=(dt+j)*2,ge=-(G.dashOffset*re);$=$.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${ge}"`),$=$.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${ge}`)}}if(!/\bstroke\s*=\s*["']/i.test(it)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(it)){let Kt="",re="";if($e){const be=a.width||r||100,ye=a.height||h||100,me=(be+ye)*2,Ie=Math.max(0,Math.min(1,Pe)),Be=Math.max(0,Math.min(1,Ee)),Ne=(Ae%1+1)%1,Ve=(Oe%1+1)%1;if(Ie>=Be)Kt=` stroke-dasharray="0 ${me}"`,re=' stroke-dashoffset="0"';else{const We=me*(Be-Ie),He=me-We,Ue=-(me*(Ie+Ne+Ve));Kt=` stroke-dasharray="${We} ${He}"`,re=` stroke-dashoffset="${Ue}"`}}else(et=G.dashArray)!=null&&et.length&&(Kt=` stroke-dasharray="${G.dashArray.join(" ")}"`,G.dashOffset&&(re=` stroke-dashoffset="${G.dashOffset}"`));const ge=` stroke-linecap="${G.lineCap||"round"}"`,Le=` stroke-linejoin="${G.lineJoin||"round"}"`,Re=`stroke="${N}" stroke-width="${ee}" stroke-opacity="${yt}"${ge}${Le}${Kt}${re}`;$=$.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(be,ye,me)=>`${ye}${me}<g ${Re}>`),$=$.replace(/<\/svg>/i,"</g></svg>")}}else G&&G.isEnabled===!1&&($=$.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),$=$.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const se=new Blob([$],{type:"image/svg+xml"}),te=URL.createObjectURL(se);bt.onload=()=>{if(URL.revokeObjectURL(te),this.frameCount%900===0){const yt=this.imageCache.get(xt);yt&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${yt.naturalWidth}x${yt.naturalHeight})`)}},bt.onerror=()=>{URL.revokeObjectURL(te),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},bt.src=te,this.imageCache.set(xt,bt)}let $t=null;if(bt.complete&&bt.naturalWidth>0?($t=bt,this.lastValidSvgImgMap.set(i.id,bt)):$t=this.lastValidSvgImgMap.get(i.id)||null,$t&&$t.complete&&$t.naturalWidth>0){const $=Math.max(1,r),Xt=Math.max(1,h);if(mt&&(st==null?void 0:st.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=$,this.maskBuffer.height=Xt,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,$,Xt),this.maskCtx.drawImage($t,0,0,$,Xt),this.maskCtx.globalCompositeOperation="source-in";const Wt=st.color||"#000000",jt=this.normalizeOpacity(st.opacity??100);this.maskCtx.fillStyle=Wt,this.maskCtx.globalAlpha=jt,this.maskCtx.fillRect(0,0,$,Xt),t.drawImage(this.maskBuffer,-$/2,-Xt/2,$,Xt)}else p!==0?(t.save(),this.drawRoundRect(t,-$/2,-Xt/2,$,Xt,p),t.clip(),t.drawImage($t,-$/2,-Xt/2,$,Xt),t.restore()):t.drawImage($t,-$/2,-Xt/2,$,Xt)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,r,h);else if(i.type==="Shape"){if(this.applyPath(t,c,r,h,p),t.save(),l.blur&&l.blur.amount>0&&(t.filter=`blur(${l.blur.amount}px)`),tt&>==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,this.applyPath(t,c,r,h,p),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const st=t.getTransform(),G=t.shadowOffsetX,nt=t.shadowOffsetY;t.shadowOffsetX=G+1e4*st.a,t.shadowOffsetY=nt+1e4*st.b,t.save(),t.translate(-1e4,0),this.applyPath(t,c,r,h,p),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=G,t.shadowOffsetY=nt,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,r,h,p,Qt,l)}else if(l.fill){const ut=t.globalAlpha;if(((V=l.fill)==null?void 0:V.type)==="Image"&&(l.fill.originalSrc||l.fill.src)){const st=l.fill.originalSrc||l.fill.src;let G=this.imageCache.get(st);G||(G=new Image,G.src=st,this.imageCache.set(st,G)),G.complete&&G.naturalWidth>0&&(t.save(),this.applyPath(t,c,r,h,p),t.clip(),this.renderFittedImage(t,G,-r/2,-h/2,r,h,l.fill.fillMode),t.restore())}else{const st=this.createCanvasFill(t,l.fill,r,h);t.fillStyle=st||(typeof l.fill=="string"?l.fill:l.fill.color||"transparent"),t.globalAlpha=ut*this.normalizeOpacity(l.fill.opacity??100),this.applyPath(t,c,r,h,p),t.fill()}t.globalAlpha=ut}t.restore(),l.stroke&&l.stroke.width>0&&(this.applyPath(t,c,r,h,p),this.applyStrokeAlignment(t,l,c,r,h,p,ct,Ct))}else if(i.type==="Frame"||i.type==="Component"&&!i.variant||i.type==="Group"&&!i.isStructuralGroup){const it=n.width??a.width??i.width??r,ut=n.height??a.height??i.height??h,st=p;if(t.save(),t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),tt&>==="BackgroundBlur")if(e)t.fillStyle="#000000",t.globalAlpha=1,t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),t.fill();else{if(t.shadowColor&&t.shadowColor!=="rgba(0, 0, 0, 0)"&&t.shadowColor!=="transparent"){const lt=t.getTransform(),mt=t.shadowOffsetX,Ot=t.shadowOffsetY;t.shadowOffsetX=mt+1e4*lt.a,t.shadowOffsetY=Ot+1e4*lt.b,t.save(),t.translate(-1e4,0),t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),t.fillStyle="white",t.fill(),t.restore(),t.shadowOffsetX=mt,t.shadowOffsetY=Ot,t.shadowColor="transparent"}this.applyBackgroundBlurGlass(t,c,it,ut,st,Qt,l)}else if(l.fill&&l.fill.type!=="None"){const nt=t.globalAlpha;if(((at=l.fill)==null?void 0:at.type)==="Image"&&(l.fill.originalSrc||l.fill.src)){const lt=l.fill.originalSrc||l.fill.src;let mt=this.imageCache.get(lt);mt||(mt=new Image,mt.src=lt,this.imageCache.set(lt,mt)),mt.complete&&mt.naturalWidth>0&&(t.save(),t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),t.clip(),this.renderFittedImage(t,mt,-it/2,-ut/2,it,ut,l.fill.fillMode),t.restore())}else{const lt=this.createCanvasFill(t,l.fill,it,ut);t.fillStyle=lt||l.fill.color||"transparent",t.globalAlpha=nt*this.normalizeOpacity(l.fill.opacity??100),t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),t.fill(),t.globalAlpha=nt}}if(t.restore(),!e&&(tt&>==="BackgroundBlur"||l.fill&&l.fill.type!=="None")&&(t.shadowColor="transparent"),l.stroke&&l.stroke.width>0&&l.stroke.isEnabled!==!1){const nt={type:"Rectangle"};t.beginPath(),this.drawRoundRect(t,-it/2,-ut/2,it,ut,st),this.applyStrokeAlignment(t,l,nt,it,ut,st,ct,Ct)}}else i.type==="Group"&&i.isStructuralGroup||(i.type==="Component"&&i.variant==="inputbox"?this.renderInputBox(t,i):i.type==="Component"&&i.variant==="button"?this.renderButton(t,i):i.type==="Component"&&i.variant==="toggle_button"?this.renderToggleButton(t,i):i.type==="Toggle"||i.type==="Component"&&i.variant==="toggle"?this.renderToggle(t,i):i.type==="Slider"||i.type==="Component"&&i.variant==="slider"?this.renderSlider(t,i):i.type==="Dropdown"||i.type==="Component"&&i.variant==="dropdown"?this.renderDropdown(t,i):i.type==="ListView"||i.type==="Component"&&i.variant==="listview"?this.renderListView(t,i):i.type==="Checkbox"||i.type==="Component"&&i.variant==="checkbox"?this.renderCheckbox(t,i):i.type==="RadioGroup"||i.type==="Component"&&i.variant==="radiogroup"?this.renderRadioGroup(t,i):i.type==="BarChart"||i.type==="Component"&&i.variant==="barchart"?this.renderBarChart(t,i):i.type==="PieChart"||i.type==="Component"&&i.variant==="piechart"?this.renderPieChart(t,i):i.type==="Joystick"||i.type==="Component"&&i.variant==="joystick"?this.renderJoystick(t,i):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(F=i.geometry)==null?void 0:F.type));if(e||(this.applyInnerGlowOverlay(t,i,c,r,h,p,l),this.applyArtEffectOverlay(t,i,c,r,h,p)),he&&he.enabled&&t.restore(),i.children&&i.children.length>0){const ut=i.type==="Frame",st=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:ut;if(t.save(),st){t.beginPath();const nt=n.width??(a==null?void 0:a.width)??i.width??0,lt=n.height??(a==null?void 0:a.height)??i.height??0,mt=n.cornerRadius??(a==null?void 0:a.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-nt/2,-lt/2,nt,lt,mt),t.clip()}let G=0;for(i.children.forEach(nt=>{const lt=o.get(nt);if(!lt)return;const mt=this.objectStates.get(nt),Ot=(mt==null?void 0:mt.geometry)||lt.geometry;if(Ot&&Ot.isMask&&(mt==null?void 0:mt.visible)!==!1){const ht=Ot.width||0,xt=Ot.height||0;this.applyObjectTransform(t,nt);const bt=(mt==null?void 0:mt.corner_radius)??(Ot==null?void 0:Ot.corner_radius)??0;this.applyPath(t,Ot,ht,xt,bt),t.clip(),G++}else this.renderObject(t,lt,o,e)});G>0;)t.restore(),G--;t.restore()}if(oe){this.maskCtx.restore(),(n.masks||(i.maskedBy?[{maskId:i.maskedBy,inverted:i.maskInverted===!0,type:i.maskType||"alpha",opacity:i.maskOpacity!==void 0?i.maskOpacity/100:1,feather:i.maskFeather||0,isVisible:!0}]:[])).filter(G=>G.isVisible!==!1&&o.has(G.maskId)).forEach(G=>{var bt,$t,$,Xt,Wt,jt;const nt=o.get(G.maskId),lt=this.objectStates.get(nt.id),mt=G.feather||0,Ot=G.inverted===!0,ht=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,nt.id,o),mt>0&&(this.lumaCtx.filter=`blur(${mt}px)`),this.lumaCtx.globalAlpha=ht;const Gt=(lt==null?void 0:lt.width)||nt.geometry.width||0,Nt=(lt==null?void 0:lt.height)||nt.geometry.height||0,se=(lt==null?void 0:lt.corner_radius)??nt.corner_radius??0;if(((bt=nt.geometry)==null?void 0:bt.type)==="Text"){const N=lt!=null&<.geometry?this.deepMerge(nt.geometry,lt.geometry):nt.geometry,ft=lt!=null&<.style?this.deepMerge(nt.style,lt.style):nt.style;this._renderText(this.lumaCtx,nt,{...N,width:Gt,height:Nt,corner_radius:se},ft,lt,Gt,Nt,!0,!1,ct,Ct)}else if((($t=nt.geometry)==null?void 0:$t.type)==="Image"){const N=nt.geometry.src;if(N){let ft=this.imageCache.get(N);ft||(ft=new Image,ft.src=N,this.imageCache.set(N,ft)),ft.complete&&ft.naturalWidth>0?this.lumaCtx.drawImage(ft,-Gt/2,-Nt/2,Gt,Nt):(this.applyPath(this.lumaCtx,nt.geometry,Gt,Nt,se),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if((($=nt.geometry)==null?void 0:$.type)==="SVG"){const N=nt.geometry.svgContent;if(N){const ft=`__lumamask_${nt.id}`;let dt=this.imageCache.get(ft);if(!dt){dt=new Image;const j=new Blob([N],{type:"image/svg+xml"});dt.src=URL.createObjectURL(j),dt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(ft,dt)}dt.complete&&dt.naturalWidth>0?this.lumaCtx.drawImage(dt,-Gt/2,-Nt/2,Gt,Nt):(this.applyPath(this.lumaCtx,nt.geometry,Gt,Nt,se),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,nt.geometry,Gt,Nt,se),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const te=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),yt=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,ot=te.data;for(let N=0;N<ot.length;N+=4){const ft=yt[N],dt=yt[N+1],j=yt[N+2];let St=(.299*ft+.587*dt+.114*j)/255;Ot&&(St=1-St),ot[N+3]*=St}this.maskCtx.putImageData(te,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Ot?"destination-out":"destination-in",mt>0&&(this.maskCtx.filter=`blur(${mt}px)`),this.maskCtx.globalAlpha=ht,this.applyAbsoluteTransform(this.maskCtx,nt.id,o);const Gt=(lt==null?void 0:lt.width)||nt.geometry.width||0,Nt=(lt==null?void 0:lt.height)||nt.geometry.height||0,se=(lt==null?void 0:lt.corner_radius)??nt.corner_radius??0;if(((Xt=nt.geometry)==null?void 0:Xt.type)==="Text"){const te=lt!=null&<.geometry?this.deepMerge(nt.geometry,lt.geometry):nt.geometry,yt=lt!=null&<.style?this.deepMerge(nt.style,lt.style):nt.style;this._renderText(this.maskCtx,nt,{...te,width:Gt,height:Nt,corner_radius:se},yt,lt,Gt,Nt,!0,!1,ct,Ct)}else if(((Wt=nt.geometry)==null?void 0:Wt.type)==="Image"){const te=nt.geometry.src;if(te){let yt=this.imageCache.get(te);yt||(yt=new Image,yt.src=te,this.imageCache.set(te,yt)),yt.complete&&yt.naturalWidth>0?this.maskCtx.drawImage(yt,-Gt/2,-Nt/2,Gt,Nt):(this.applyPath(this.maskCtx,nt.geometry,Gt,Nt,se),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((jt=nt.geometry)==null?void 0:jt.type)==="SVG"){const te=nt.geometry.svgContent;if(te){const yt=`__alphamask_${nt.id}`;let ot=this.imageCache.get(yt);if(!ot){ot=new Image;const N=new Blob([te],{type:"image/svg+xml"});ot.src=URL.createObjectURL(N),ot.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(yt,ot)}ot.complete&&ot.naturalWidth>0?this.maskCtx.drawImage(ot,-Gt/2,-Nt/2,Gt,Nt):(this.applyPath(this.maskCtx,nt.geometry,Gt,Nt,se),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,nt.geometry,Gt,Nt,se),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),ce.save(),ce.setTransform(1,0,0,1,0,0);const st=i.maskBlendMode||i.blendMode;st&&st!=="Normal"&&(ce.globalCompositeOperation=st.toLowerCase()),ce.drawImage(this.maskBuffer,0,0),ce.restore(),ce.restore()}else t.restore()}}applyOuterGlowUnderlay(t,i,o,e,s,n,a,l){var k,I,T;const r=a||i.style||{},h=r.effect,f=r.effects||(h?[h]:[]),p=f.find(O=>O.isEnabled!==!1&&O.type==="Glow"&&(O.mode==="outer"||O.mode==="Outer Glow"||!O.mode));if(!p)return;const c=p.blur||10,d=1e4;let u=p.color||"white";(I=(k=this.artboard)==null?void 0:k.tokens)!=null&&I.colors&&this.artboard.tokens.colors[u]&&(u=this.artboard.tokens.colors[u]),t.save();const b=r.fill&&r.fill.type!=="None",m=f.some(O=>O.isEnabled!==!1&&O.type==="BackgroundBlur"),y=i.type==="Text",S=i.type==="Group";!y&&!S&&(b||m)&&(t.beginPath(),t.rect(-1e6,-1e6,2e6,2e6),i.type==="Frame"||i.type==="Component"?this.drawRoundRect(t,-e/2,-s/2,e,s,n):this._tracePath(t,o,e,s,n),t.clip("evenodd"));const v=t.getTransform();t.shadowColor=u,t.shadowBlur=c,t.shadowOffsetX=d*v.a,t.shadowOffsetY=d*v.b,t.translate(-d,0);let C="black";r.fill&&r.fill.type!=="None"&&(C=this.createCanvasFill(t,r.fill,e,s)||r.fill.color||"black");let w="black";r.stroke&&r.stroke.width>0&&(w=this.createCanvasFill(t,r.stroke.fill||{type:"Solid",color:r.stroke.color},e,s)||r.stroke.color||"black"),t.fillStyle=C,t.strokeStyle=w,t.lineWidth=((T=r.stroke)==null?void 0:T.width)||0;const M=Math.min(p.intensity||1,10);for(let O=0;O<M;O++)if(l)this.renderObject(t,i,l,!0,!0);else if(o.type==="Text")r.fill&&r.fill.type!=="None"&&t.fillText(i.text||"",0,0),r.stroke&&r.stroke.width>0&&t.strokeText(i.text||"",0,0);else if(o.points&&o.type==="Path")this.applyPath(t,o,e,s,n),r.fill&&r.fill.type!=="None"&&t.fill(),r.stroke&&r.stroke.width>0&&t.stroke();else{if(t.beginPath(),o.type==="circle"||o.type==="Ellipse"){const E=e/2,A=s/2;t.ellipse(0,0,E,A,0,0,Math.PI*2)}else n!==0?this.drawRoundRect(t,-e/2,-s/2,e,s,n):t.rect(-e/2,-s/2,e,s);const P=r.fill&&r.fill.type!=="None",_=r.stroke&&r.stroke.width>0;(P||!P&&!_)&&t.fill(),_&&t.stroke()}t.restore()}_renderText(t,i,o,e,s,n,a,l=!1,r=!1,h=1,f=1){var ct,Ct,vt,At,It,Tt,qt,ue,Qt;let p=o.text||"";if(o.textInputId&&!l){const tt=this.inputs.get(o.textInputId);tt!==void 0&&(p=String(tt),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=p))}if(o.svgPath){const tt=o.svgPath;t.save();const gt=((ct=e==null?void 0:e.fill)==null?void 0:ct.color)||"#000000",Ft=((Ct=e==null?void 0:e.fill)==null?void 0:Ct.opacity)!==void 0?(vt=e==null?void 0:e.fill)==null?void 0:vt.opacity:1;t.fillStyle=gt,t.globalAlpha*=Ft;const Et=new Path2D(tt);t.fill(Et),t.restore();return}let c=p||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(tt=>tt&&tt.text?tt.text:"").join(""));const d=o.textCase||"none";d==="uppercase"?c=c.toUpperCase():d==="lowercase"?c=c.toLowerCase():d==="capitalize"&&(c=c.replace(/\b\w/g,tt=>tt.toUpperCase()));let u=((At=o.fontWeight)==null?void 0:At.toString())||"400",b=o.fontStyle||"normal";u.toLowerCase().includes("italic")&&(b="italic",u=u.replace(/italic/gi,"").trim()||"400");const m=this.mapFontWeight(u),y=Math.max(1,o.fontSize||32);let S=o.fontFamily||"Inter";const v=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];v.forEach(tt=>{const gt=new RegExp(`[\\s-]${tt}$`,"i");gt.test(S)&&(S=S.replace(gt,"").trim())});const M=`${o.smallCaps===!0?"small-caps ":""}${b} ${m} ${y}px "${S}", sans-serif`;t.font=M;const k=o.textVerticalAlign||"top";t.textBaseline="top";const I=o.textAlign||"left";t.textAlign=I;let T=0;if(typeof o.letterSpacing=="number")T=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const tt=o.letterSpacing;T=tt.unit==="PERCENT"?tt.value/100*y:tt.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${T}px`);const O=o.kerning||"auto",P=o.kerningValue||0;O==="manual"&&P!==0&&(t.letterSpacing=`${T+P}px`);const _=o.paragraphSpacing||0;let E=o.lineHeight??1.2;typeof E=="string"&&(E=parseFloat(E)),E>5&&y>0&&(E=E/y);const A=(E||1.2)*y,B=o.isPointText===!0||!o.width||o.width<=0,X=((It=o.padding)==null?void 0:It.left)||((Tt=o.padding)==null?void 0:Tt.right)||0,W=B?1e5:o.width&&o.width>0?Math.ceil(o.width)-X*2:1e5;o.autoHeight;const Y=Qe({text:c,fontFamily:S,fontSize:y,fontWeight:m,fontStyle:b,lineHeight:E,width:W,letterSpacing:T,paragraphSpacing:_,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:d,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),z=Y.lines||[],J=Y.maxFontSize||y,L=this.fontLeadingFactors[S]??.5,x=(A-y)*L;let et=Y.height,V=n,at=a;if(V===0||at===0||V>=1e5){let tt=0,gt=0;const Ft=Y.fullText||c;(z||[]).forEach(Et=>{const Mt=Et.text||"",Bt=t.measureText(Mt).width+(Mt.length>0?(Mt.length-1)*T:0);Bt>tt&&(tt=Bt),gt+=Mt.length,gt<Ft.length&&(Ft[gt]===`
|
|
23
|
+
`||Ft[gt]==="\r")&&(gt++,Ft[gt-1]==="\r"&&Ft[gt]===`
|
|
24
|
+
`&>++)}),(V===0||V>=1e5)&&(V=tt),at===0&&(at=et||0)}let F=-et/2;a>0&&a>et&&(k==="top"?F=-a/2:k==="middle"||k==="center"?F=-et/2:k==="bottom"&&(F=a/2-et)),F+=x;let R=null,D=0;if(o.pathId&&this.artboard){const tt=this.artboard.objects.find(gt=>gt.id===o.pathId);if(tt&&tt.type==="Shape"&&((qt=tt.geometry)==null?void 0:qt.type)==="Path"){const gt=this.objectStates.get(tt.id),Ft=gt!=null&>.geometry?this.deepMerge(tt.geometry,gt.geometry):tt.geometry,Et=(gt==null?void 0:gt.scale_x)!==void 0?(tt.width||0)*gt.scale_x:tt.width||0,Mt=(gt==null?void 0:gt.scale_y)!==void 0?(tt.height||0)*gt.scale_y:tt.height||0;R={geo:Ft,obj:tt,w:Et,h:Mt},D=this.getPerimeter(Ft,Et,Mt)}}const H=(tt,gt)=>{var Et,Mt;if(T===0&&(!o.enableSegments||!((Et=o.segments)!=null&&Et.length)))return t.measureText(tt).width;let Ft=0;for(let Bt=0;Bt<tt.length;Bt++){const Ht=gt+Bt;let _t=0;if(o.enableSegments===!0&&((Mt=o.segments)==null?void 0:Mt.length)>0){let zt=0,Zt=null;for(const le of o.segments){if(Ht<zt+(le.text||"").length){Zt=le;break}zt+=(le.text||"").length}if(Zt){t.save();let le=Zt.fontFamily||o.fontFamily||"Inter";const ce=this.mapFontWeight((Zt.fontWeight||o.fontWeight||"400").toString()),Me=Zt.fontStyle||b,oe=Zt.fontSize||y;t.font=`${Me} ${ce} ${oe}px "${le}", sans-serif`,_t=t.measureText(tt[Bt]).width,t.restore()}else _t=t.measureText(tt[Bt]).width}else _t=t.measureText(tt[Bt]).width;Ft+=_t+T}return Ft-(tt.length>0?T:0)},Z=(tt,gt,Ft,Et,Mt)=>{var ce,Me;const Ht=(Mt===0||c[Mt-1]===`
|
|
25
|
+
`||c[Mt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,_t=(!l||r)&&(i.behaviors||[]).some(oe=>oe.enabled&&(oe.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(oe.type))),zt=!o.pathId&&!_t&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Zt=o.baselineShift||0,le=Ft+Zt;if(zt)t.font=M,Et?t.strokeText(tt,gt+Ht,le):t.fillText(tt,gt+Ht,le);else{const oe=H(tt,Mt);let Ce=gt+Ht;I==="center"?Ce-=oe/2:I==="right"&&(Ce-=oe);const fe=Mt+tt.length>=c.length||c[Mt+tt.length]===`
|
|
26
|
+
`||c[Mt+tt.length]==="\r";let he=0,it=0;const ut=o.justifyMinWordSpacing,st=o.justifyMaxWordSpacing;if(I==="justify"&&!fe&&oe>0&&!o.pathId){const mt=B?oe:W-X*2+0,Ot=Math.max(0,mt-oe);for(let ht=0;ht<tt.length;ht++)tt[ht]===" "&&it++;if(it>0){const ht=t.measureText(" ").width;let xt=ut||ht*.5,bt=st||ht*2.5;he=Math.max(0,Math.min(Ot/it,bt-xt))}}let G=o.pathOffset||0;o.pathId&&D>0&&R&&(I==="center"?G+=D/2-oe/2:I==="right"&&(G+=D-oe));let nt=Ce;const lt=l&&!r?[]:((ce=i.behaviors)==null?void 0:ce.filter(mt=>[U.Typewriter,U.Scramble,U.Wave,U.Bounce,U.GlitchText,U.TextTrail,U.Reveal3D,U.RevealSlide,U.RevealBlur,U.TextLiquid,U.TextVortex,U.TextExplosion,U.TextRain,U.TextGravity,U.TextElastic,U.TextMatrix,U.TextNeon,U.TextGlitch3D,U.TextDissolve,U.TextOrganic,U.TextBreathe,U.TextFloral,U.TextSmoke,U.TextVariable,U.TextMagnet,U.TextSpin,U.TextZing,U.TextPerspective,U.TextMirror].includes(mt.type)&&mt.enabled))||[];for(let mt=0;mt<tt.length;mt++){let Ot=tt[mt];const ht=Mt+mt;let xt=0,bt=0,$t=1,$=1,Xt=0,Wt=1,jt=Ot;lt.forEach(ot=>{const N=ot.settings||{},ft=N.strength||1,dt=Date.now();if(ot.type===U.Typewriter)this.currentTime*(N.speed||1)-ht*(N.stagger||.05)<0&&(Wt=0);else if(ot.type===U.Scramble)Math.max(0,Math.min(1,this.currentTime/(N.duration||1.5))-ht*.02)<1&&Math.random()<.3&&(jt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(ot.type===U.Wave)bt+=Math.sin(this.currentTime*5*(N.speed||1)+ht*(N.frequency||1))*(N.amplitude||20)*ft;else if(ot.type===U.Bounce){const j=Math.max(0,this.currentTime%2-ht*(N.stagger||.1));j<1&&(bt-=Math.abs(Math.sin(j*Math.PI))*(N.height||50)*ft)}else if(ot.type===U.TextTrail){const j=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-ht*(N.delay||5))];j&&(xt+=(j.x-(s.x+nt))*ft*.2,bt+=(j.y-(s.y+Ft+bt))*ft*.2)}else if(ot.type===U.Reveal3D){const j=Math.max(0,Math.min(1,this.currentTime*(N.speed||1)-ht*(N.stagger||.1)));$t*=j,$*=j,Wt=j}else if(ot.type===U.RevealSlide){const j=Math.max(0,Math.min(1,this.currentTime*1.5-ht*.05)),St=(1-j)*(N.distance||40)*ft,wt=N.direction||"up";wt==="up"?bt-=St:wt==="down"?bt+=St:wt==="left"?xt-=St:wt==="right"&&(xt+=St),Wt=j}else if(ot.type===U.RevealBlur){const j=Math.max(0,Math.min(1,this.currentTime*1.2-ht*.1));Wt=j,xt+=(1-j)*5}else if(ot.type===U.TextLiquid){const j=Math.max(0,Math.sin(dt*.001*(N.speed||1)+ht*.5));bt+=j*(N.amplitude||10)*ft,$*=1+j*.2}else if(ot.type===U.TextVortex){const j=dt*.002*(N.speed||1)+ht*.2,St=(1-(Math.sin(dt*.001)*.5+.5))*(N.radius||50);xt+=Math.cos(j)*St*ft,bt+=Math.sin(j)*St*ft}else if(ot.type===U.TextExplosion){const j=N.force||1,St=this.currentTime%2;if(St<1){const wt=(ht/tt.length-.5)*Math.PI*2,Yt=St*100*j;xt+=Math.cos(wt)*Yt*ft,bt+=Math.sin(wt)*Yt*ft,Wt=1-St}}else if(ot.type===U.TextRain){const j=N.speed||1,St=N.height||100,wt=(dt*.001*j+ht*.1)%1;bt-=(1-wt)*St*ft,Wt=wt>.1?1:wt*10}else if(ot.type===U.TextGravity){const j=N.gravity||9.8,St=this.currentTime%3/3,wt=.5*j*Math.pow(St*10,2);wt<100?bt+=wt*ft:bt+=100*ft}else if(ot.type===U.TextMatrix){const j=N.speed||1;if(Math.random()<.1*j){const wt="0123456789ABCDEF!@#$%^&*";jt=wt[Math.floor(Math.random()*wt.length)]}Wt=.3+(Math.sin(dt*.01*j+ht)+1)/2*.7}else if(ot.type===U.TextNeon){const j=Math.random()>.95?.5:1;Wt=(.7+(Math.sin(dt*.005)+1)/2*.3)*j}else if(ot.type===U.TextDissolve)Math.sin(ht*1.5+dt*.002*(N.speed||1))>.5&&(Wt=0);else if(ot.type===U.TextOrganic){const j=N.speed||1,St=N.amplitude||10;xt+=Math.sin(dt*.002*j+ht)*St*ft,bt+=Math.cos(dt*.0015*j+ht*.7)*St*ft}else if(ot.type===U.TextBreathe){const St=1+(Math.sin(dt*.003+ht*.2)+1)/2*.2*ft;$t*=St,$*=St}else if(ot.type===U.TextSpin){const j=N.speed||1;Xt+=dt*.01*j+ht}else if(ot.type===U.TextMagnet){const j=this.pointerHistory[this.pointerHistory.length-1];if(j){const St=j.x-(s.x+nt),wt=j.y-(s.y+Ft);Xt=Math.atan2(wt,St)}}else if(ot.type===U.TextPerspective){const j=tt.length/2,St=(ht-j)/j,wt=1-Math.abs(St)*.3*ft;$t*=wt,$*=wt,xt+=St*20*ft}else if(ot.type===U.TextMirror)Wt*=.8;else if(ot.type===U.TextFloral){const j=N.speed||1,St=N.stagger||.1,wt=(dt*.001*j+ht*St)%2;wt<1&&($t*=wt,$*=wt,Xt+=wt*Math.PI)}else if(ot.type===U.TextSmoke){const j=N.speed||1,St=N.height||50,wt=(dt*5e-4*j+ht*.2)%1;bt-=wt*St*ft,xt+=Math.sin(dt*.002+ht)*5*ft,Wt=1-wt}else if(ot.type===U.TextVariable){const j=N.speed||1,St=N.intensity||1.5,wt=(Math.sin(dt*.004*j+ht*.3)+1)/2;$t*=1+wt*(St-1)*ft}else if(ot.type===U.TextZing){const j=N.speed||2,St=N.distance||100,wt=(dt*.002*j+ht*.05)%1;xt+=(1-wt)*St*ft,Wt=wt}else if(ot.type===U.TextElastic){const j=N.stiffness||.2,St=N.damping||.1,wt=Math.sin(dt*.01)*Math.exp(-dt*.001*St);$*=1+wt*j*ft}else if(ot.type===U.TextGlitch3D){const j=N.intensity||5;Math.random()<.2&&(xt+=(Math.random()-.5)*j,bt+=(Math.random()-.5)*j,Wt=.8)}else if(ot.type===U.GlitchText){const j=N.intensity||5;Math.random()<.1&&(xt+=(Math.random()-.5)*j,bt+=(Math.random()-.5)*j,Math.random()<.05&&(Wt=.5))}});let Gt=null,Nt=o.textDecoration||"none",se=y;if(o.enableSegments===!0&&((Me=o.segments)==null?void 0:Me.length)>0){let ot=0,N=null;for(const ft of o.segments){if(ht<ot+(ft.text||"").length){N=ft;break}ot+=(ft.text||"").length}if(N){let ft=N.fontFamily||o.fontFamily||"Inter";v.forEach(St=>{const wt=new RegExp(`[\\s-]${St}$`,"i");wt.test(ft)&&(ft=ft.replace(wt,"").trim())});const dt=this.mapFontWeight((N.fontWeight||o.fontWeight||"400").toString()),j=N.fontStyle||b;se=N.fontSize||y,t.font=`${j} ${dt} ${se}px "${ft}", sans-serif`,N.fill&&(Gt=N.fill),N.textDecoration&&(Nt=N.textDecoration),se<J&&(bt+=(J-se)*.85)}}else t.font=M;const te=t.globalAlpha;t.globalAlpha*=Wt,t.save();const yt=t.measureText(jt).width;if(R&&D>0){const ot=nt-Ce+yt/2,ft=(G+ot)/D,dt=this.getPointOnPath(R.geo,R.w,R.h,Math.abs(ft%1)),j=dt.angle,St=Ft+bt+(o.pathOffsetY||0),wt=o.pathSide==="right"?-1:1,Yt=Math.cos(j+Math.PI/2)*St*wt,Jt=Math.sin(j+Math.PI/2)*St*wt;t.translate(dt.x+Yt+xt,dt.y+Jt),t.rotate(j+Xt+(wt===-1?Math.PI:0))}else t.translate(nt+xt+yt/2,Ft+bt),Xt!==0&&t.rotate(Xt);if(t.scale($t,$),Gt&&!l&&!r){const ot=this.createCanvasFill(t,Gt,V,at);t.fillStyle=ot||Gt.color||"#000000"}else if(!l&&!r){const ot=this.createCanvasFill(t,e.fill,V,at);t.fillStyle=ot||e.fill.color||"#000000"}if(Wt>0)if(l||r){const ot=r?"#000000":this.createCanvasFill(t,e.fill,V,at);t.fillStyle=ot||e.fill.color||"#ffffff",t.fillText(jt,-yt/2,0)}else Et?t.strokeText(jt,-yt/2,0):t.fillText(jt,-yt/2,0);Nt!=="none"&&!l&&this.drawTextDecoration(t,Nt,0,0,yt,se),t.restore(),t.globalAlpha=te,I==="justify"&&he>0&&jt===" "&&!fe?nt+=yt+T+he:nt+=yt+T}}};if(l){let tt=0,gt=F;(z||[]).forEach(Ft=>{const Et=Ft.text||"",Mt=c.indexOf(Et,tt);Mt!==-1&&(tt=Mt);let Bt=-V/2;I==="center"?Bt=0:I==="right"&&(Bt=V/2),Z(Et,Bt,gt,!1,tt),tt+=Et.length,gt+=A})}else if(r){let tt=0,gt=F;(z||[]).forEach(Ft=>{const Et=Ft.text||"";let Mt=-V/2;I==="center"?Mt=0:I==="right"&&(Mt=V/2),Z(Et,Mt,gt,!1,tt),tt+=Et.length,tt<c.length&&(c[tt]===`
|
|
27
|
+
`||c[tt]==="\r")&&(tt++,c[tt-1]==="\r"&&c[tt]===`
|
|
28
|
+
`&&tt++),gt+=A})}else{if(e.fill){const gt=t.globalAlpha,Ft=this.createCanvasFill(t,e.fill,V,at);t.fillStyle=Ft||e.fill.color||"#000000",t.globalAlpha=gt*this.normalizeOpacity(e.fill.opacity??100);const Et=Y.fullText||(o.enableSegments?(o.segments||[]).map(Ht=>{let _t=Ht.text||"";const zt=Ht.textCase||o.textCase||"none";return zt==="uppercase"?_t.toUpperCase():zt==="lowercase"?_t.toLowerCase():zt==="capitalize"?_t.replace(/\b\w/g,Zt=>Zt.toUpperCase()):_t}).join(""):c);let Mt=0,Bt=F;(z||[]).forEach(Ht=>{const _t=Ht.text||"";let zt=-V/2;I==="center"?zt=0:I==="right"&&(zt=V/2),Z(_t,zt,Bt,!1,Mt),Mt+=_t.length,Bt+=A,Mt<Et.length&&(Et[Mt]===`
|
|
29
|
+
`||Et[Mt]==="\r")&&(_>0&&(Bt+=_),Mt++,Et[Mt-1]==="\r"&&Et[Mt]===`
|
|
30
|
+
`&&Mt++)}),t.globalAlpha=gt}const tt=o.paragraphRule;if(tt&&(((ue=tt.top)==null?void 0:ue.width)>0||((Qt=tt.bottom)==null?void 0:Qt.width)>0)){let gt=0;(z||[]).forEach((Ft,Et)=>{var Ht,_t;const Bt=gt===0||gt<c.length&&(c[gt]===`
|
|
31
|
+
`||c[gt]==="\r");if(Bt&&Et>0&>++,Bt){if(((Ht=tt.top)==null?void 0:Ht.width)>0){const zt=F+Et*A-tt.top.offset;t.strokeStyle=tt.top.color||"#000000",t.lineWidth=tt.top.width,t.beginPath();const Zt=-n/2+A*.2;t.moveTo(Zt,zt),t.lineTo(n/2-A*.2,zt),t.stroke()}if(((_t=tt.bottom)==null?void 0:_t.width)>0){const zt=F+(Et+1)*A-tt.bottom.offset;t.strokeStyle=tt.bottom.color||"#000000",t.lineWidth=tt.bottom.width,t.beginPath();const Zt=-n/2+A*.2;t.moveTo(Zt,zt),t.lineTo(n/2-A*.2,zt),t.stroke()}}gt+=(Ft.text||"").length})}if(e.stroke&&e.stroke.width>0){const gt=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;let Et=1;if(this.rootTransform){const Ht=t.getTransform(),_t=Math.sqrt(Ht.a*Ht.a+Ht.b*Ht.b)||1,zt=this.rootTransform,Zt=Math.sqrt(zt.a*zt.a+zt.b*zt.b)||1;Et=_t/Zt}else Et=(Math.abs(h)+Math.abs(f))/2||1;t.lineWidth=(e.stroke.width||1)/(Et||1),t.globalAlpha=gt*this.normalizeOpacity(e.stroke.opacity??100);let Mt=0,Bt=F;(z||[]).forEach(Ht=>{let _t=-V/2;I==="center"?_t=0:I==="right"&&(_t=V/2),Z(Ht.text,_t,Bt,!0,Mt),Mt+=(Ht.text||"").length,Bt+=A,Mt<c.length&&(c[Mt]===`
|
|
32
|
+
`||c[Mt]==="\r")&&(_>0&&(Bt+=_),Mt++,c[Mt-1]==="\r"&&c[Mt]===`
|
|
33
|
+
`&&Mt++)}),t.globalAlpha=gt}}}applyStrokeAlignment(t,i,o,e,s,n,a=1,l=1){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const r=i.stroke;let h=1;if(this.rootTransform){const v=t.getTransform(),C=Math.sqrt(v.a*v.a+v.b*v.b)||1,w=this.rootTransform,M=Math.sqrt(w.a*w.a+w.b*w.b)||1;h=C/M}else h=(Math.abs(a)+Math.abs(l))/2||1;const f=(r.width||1)/(h||1),p=(r.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),r.fill){const v=this.createCanvasFill(t,r.fill,e,s);v?t.strokeStyle=v:t.strokeStyle=r.color||"#000000"}else t.strokeStyle=r.color||"#000000";const d=t.globalAlpha;t.globalAlpha=d*this.normalizeOpacity(r.opacity??100),t.lineWidth=f,t.lineCap=r.lineCap||"round",t.lineJoin=r.lineJoin||"round",r.miterLimit!==void 0&&(t.miterLimit=r.miterLimit);const u=r.trimStart??0,b=r.trimEnd??1,m=r.trimOffset??0,y=r.dashOffset??0,S=r.dashArray||[];if(u!==0||b!==1||m!==0){const v=this.getPerimeter(o,e,s);if(v>0){const C=Math.max(0,Math.min(1,u)),w=Math.max(0,Math.min(1,b));if(C<w){const M=v*(w-C),k=v-M,I=-(v*(C+m%1));t.setLineDash([M,k]),t.lineDashOffset=I-y*v}else if(C===w)t.setLineDash([0,v]);else{const M=v*(1-C+w),k=v-M,I=-(v*C);t.setLineDash([M,k]),t.lineDashOffset=I-y*v}}}else if(S.length>0||y!==0){S.length>0&&t.setLineDash(S);const v=this.getPerimeter(o,e,s);t.lineDashOffset=-(y*v)}if((o==null?void 0:o.type)==="Line"||e===0||s===0)this.applyPath(t,o,e,s,n),t.stroke();else if(p==="inside")t.lineWidth=f*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore();else if(p==="outside"){t.save(),t.beginPath();const v=Math.max(e,s,2e4);t.rect(-v,-v,v*2,v*2),this.applyPath(t,o,e,s,n),t.clip("evenodd"),t.lineWidth=f*2,t.beginPath(),this.applyPath(t,o,e,s,n),t.stroke(),t.restore()}else t.lineWidth=f,this.applyPath(t,o,e,s,n),t.stroke();t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,l=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return l;let r=n/360*l;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));r+=n/360*h,n<360&&(r+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(r+=2*Math.max(e,s));return isNaN(r)?0:r}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let l=1;l<e.length;l++){const r=e[l];if(r.moveTo){n=r.x,a=r.y;continue}const h=n,f=a,p=e[l-1].out_x,c=e[l-1].out_y;if(p!==void 0||r.in_x!==void 0?s+=this.getBezierLength(h,f,p??h,c??f,r.in_x??r.x,r.in_y??r.y,r.x,r.y):s+=Math.sqrt((r.x-h)**2+(r.y-f)**2),n=r.x,a=r.y,r.closePath||l===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,b=[...e.slice(0,l+1)].reverse().find(M=>M.moveTo)||e[0],m=b.x,y=b.y,S=e[l].out_x,v=e[l].out_y,C=b.in_x,w=b.in_y;S!==void 0||C!==void 0?s+=this.getBezierLength(d,u,S??d,v??u,C??m,w??y,m,y):s+=Math.sqrt((m-d)**2+(y-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,l,r=10){let h=0,f=t,p=i;for(let c=1;c<=r;c++){const d=c/r,u=1-d,b=d*d,m=u*u,y=m*u,S=b*d,v=y*t+3*m*d*o+3*u*b*s+S*a,C=y*i+3*m*d*e+3*u*b*n+S*l,w=v-f,M=C-p;h+=Math.sqrt(w*w+M*M),f=v,p=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,l,r,h=20){if(t<=0)return 0;let f=0,p=i,c=o;for(let d=1;d<=h;d++){const u=d/h,b=1-u,m=u*u,y=b*b,S=y*b,v=m*u,C=S*i+3*y*u*e+3*b*m*n+v*l,w=S*o+3*y*u*s+3*b*m*a+v*r,M=C-p,k=w-c,I=Math.sqrt(M*M+k*k);if(f+I>=t){const T=t-f,O=I===0?0:T/I;return(d-1+O)/h}f+=I,p=C,c=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,l=1/0,r=-1/0;s.forEach(y=>{typeof y.x=="number"&&typeof y.y=="number"&&(n=Math.min(n,y.x),a=Math.max(a,y.x),l=Math.min(l,y.y),r=Math.max(r,y.y),y.out_x!==void 0&&(n=Math.min(n,y.out_x),a=Math.max(a,y.out_x)),y.out_y!==void 0&&(l=Math.min(l,y.out_y),r=Math.max(r,y.out_y)),y.in_x!==void 0&&(n=Math.min(n,y.in_x),a=Math.max(a,y.in_x)),y.in_y!==void 0&&(l=Math.min(l,y.in_y),r=Math.max(r,y.in_y)))});const h=(n+a)/2,f=(l+r)/2,c=this.getPerimeter(t,i,o)*e;let d=0;const u=[];let b=s[0],m=s[0];for(let y=1;y<s.length;y++){const S=s[y];if(S.moveTo){b=S,m=S;continue}u.push({p0:b,p1:S}),(S.closePath||y===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:S,p1:m}),b=S}for(const y of u){const S=y.p0,v=y.p1;let C=0;const w=S.out_x!==void 0||v.in_x!==void 0;if(w?C=this.getBezierLength(S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y):C=Math.sqrt((v.x-S.x)**2+(v.y-S.y)**2),d+C>=c||y===u[u.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(c-d,S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y,20),this.getBezierPointAndAngle(M,S,v,h,f);{M=C===0?0:(c-d)/C;const k=S.x+(v.x-S.x)*M-h,I=S.y+(v.y-S.y)*M-f,T=Math.atan2(v.y-S.y,v.x-S.x);return{x:k,y:I,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,r=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(r),f=n*Math.sin(r),p=-s*Math.sin(r),c=n*Math.cos(r),d=Math.atan2(c,p);return{x:h,y:f,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),l=(s+n)*2*e;let r=0,h=0,f=0;return l<s?(r=-s/2+l,h=-n/2,f=0):l<s+n?(r=s/2,h=-n/2+(l-s),f=Math.PI/2):l<2*s+n?(r=s/2-(l-(s+n)),h=n/2,f=Math.PI):(r=-s/2,h=n/2-(l-(2*s+n)),f=-Math.PI/2),{x:r,y:h,angle:f}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,l=i.out_x??i.x,r=i.out_y??i.y,h=o.in_x??o.x,f=o.in_y??o.y,p=o.x,c=o.y,d=1-t,u=t*t,b=d*d,m=b*d,y=u*t,S=m*n+3*b*t*l+3*d*u*h+y*p-e,v=m*a+3*b*t*r+3*d*u*f+y*c-s,C=3*b*(l-n)+6*d*t*(h-l)+3*u*(p-h),w=3*b*(r-a)+6*d*t*(f-r)+3*u*(c-f),M=Math.atan2(w,C);return{x:S,y:v,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,u,b;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const m=Math.tan(e*Math.PI/180),y=Math.tan(s*Math.PI/180);t.transform(1+m*y,y,m,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((u=o.transform)==null?void 0:u.rotate_y)??0,r=1+(o.translate_z!==void 0?o.translate_z:((b=o.transform)==null?void 0:b.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*r,f=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*r,p=(o.scale_x??1)*h,c=(o.scale_y??1)*f;t.scale(p,c)}applyInnerGlowOverlay(t,i,o,e,s,n,a){var m,y;const l=a||i.style||{},r=l==null?void 0:l.effect,f=((l==null?void 0:l.effects)||(r?[r]:[])).find(S=>S.isEnabled!==!1&&S.type==="Glow"&&(S.mode==="inner"||S.mode==="Inner Glow"));if(!f)return;t.save(),t.beginPath(),this.applyPath(t,o,e,s,n),t.clip();const p=f.blur||10,c=1e4,d=t.getTransform();let u=f.color||"white";(y=(m=this.artboard)==null?void 0:m.tokens)!=null&&y.colors&&this.artboard.tokens.colors[u]&&(u=this.artboard.tokens.colors[u]),t.shadowColor=u,t.shadowBlur=p,t.shadowOffsetX=c*d.a,t.shadowOffsetY=c*d.b,t.translate(-c,0),t.lineWidth=p+5,t.strokeStyle=u;const b=Math.min(f.intensity||1,5);for(let S=0;S<b;S++)t.beginPath(),this.applyPath(t,o,e,s,n),t.stroke();t.restore()}applyArtEffectOverlay(t,i,o,e,s,n){var c,d,u,b,m;const a=this.objectStates.get(i.id),l=((c=a==null?void 0:a.style)==null?void 0:c.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!l||!l.enabled)return;const r=l.type,h=l.intensity??.5,f=l.speed??1,p=l.scale??10;if(r==="acid_gradient"||r==="acid_rave"||r==="shimmer"||r==="glint_overlay"||r==="halftone"||r==="noise"||r==="scanlines"||r==="chromatic_aberration"||r==="pixelate"||r==="glitch"||r==="fold_overlay"||r==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),r==="shimmer"){const S=this.currentTime*f%2/2,v=t.createLinearGradient(-e,-s,e,s);v.addColorStop(Math.max(0,S-.2),"rgba(255,255,255,0)"),v.addColorStop(S,`rgba(255,255,255,${h*.8})`),v.addColorStop(Math.min(1,S+.2),"rgba(255,255,255,0)"),t.fillStyle=v,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(r==="glint_overlay"){let v=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;v=Math.max(-.2,Math.min(1.2,v));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,v-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,v)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,v+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(r==="fold_overlay"){const y=this._lastPointerPos||{x:0,y:0},S=y.x-(((b=i.transform)==null?void 0:b.x)??0),v=y.y-(((m=i.transform)==null?void 0:m.y)??0),C=t.createLinearGradient(S>0?-e/2:e/2,v>0?-s/2:s/2,S>0?e/2:-e/2,v>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),S>0&&v>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):S<0&&v>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):S>0&&v<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=S>0?-2:2,t.shadowOffsetY=v>0?-2:2,t.fill()}else if(r==="crumple_overlay"){const y=Math.floor(e/p),S=document.createElement("canvas");S.width=y,S.height=Math.floor(s/p);const v=S.getContext("2d"),C=v.createImageData(S.width,S.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}v.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(S,-e/2,-s/2,e,s)}else if(r==="acid_gradient"||r==="acid_rave"){const y=this.currentTime*f,S=l.color1,v=l.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(S&&v){const w=y*60%360;C.addColorStop(0,this._shiftHue(S,w,h*.7)),C.addColorStop(1,this._shiftHue(v,(w+180)%360,h*.7))}else{const w=y*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(r==="halftone"){const y=Math.max(2,p*(1-h*.8)),S=document.createElement("canvas");S.width=y,S.height=y;const v=S.getContext("2d");if(v){v.fillStyle="black",v.beginPath(),v.arc(y/2,y/2,y/2*h,0,Math.PI*2),v.fill();const C=t.createPattern(S,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(r==="noise"){const y=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let S=0;S<y;S++){const v=Math.random()>.5?255:0;t.fillStyle=`rgba(${v}, ${v}, ${v}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(r==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let y=-s/2;y<s/2;y+=4)t.beginPath(),t.moveTo(-e/2,y),t.lineTo(e/2,y),t.stroke()}else if(r==="chromatic_aberration"){const y=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-y,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+y,-s/2,e,s)}else if(r==="pixelate"){const y=Math.max(2,Math.round(p*(1-h*.5))),S=document.createElement("canvas"),v=Math.max(1,Math.ceil(e/y)),C=Math.max(1,Math.ceil(s/y));S.width=v,S.height=C;const w=S.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),k=M.e-e/2,I=M.f-s/2;w.drawImage(t.canvas,k,I,e,s,0,0,v,C),t.imageSmoothingEnabled=!1,t.drawImage(S,0,0,v,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(r==="glitch"){const y=this.currentTime*f,S=l.chaosAmount??.2,v=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/v;for(let k=0;k<v;k++){const I=Math.sin(k*127.1+y*311.7*f)*43758.5,T=I-Math.floor(I);if(T>1-S){const O=(T-(1-S))/S*C*(Math.random()>.5?1:-1),P=-s/2+k*M,_=t.getTransform(),E=_.e-e/2+O,A=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,E,A,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const c=t.replace("#","");e=parseInt(c.substring(0,2),16)/255,s=parseInt(c.substring(2,4),16)/255,n=parseInt(c.substring(4,6),16)/255}const a=Math.max(e,s,n),l=Math.min(e,s,n);let r=0,h=0,f=(a+l)/2;if(a!==l){const c=a-l;switch(h=f>.5?c/(2-a-l):c/(a+l),a){case e:r=((s-n)/c+(s<n?6:0))/6;break;case s:r=((n-e)/c+2)/6;break;case n:r=((e-s)/c+4)/6;break}}return`hsla(${(((r*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(f*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n,a){const l=n.radius??10,r=n.opacity!==void 0?this.normalizeOpacity(n.opacity):.5,h=n.noise??0,f=n.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,i,o,e,s),t.clip();const p=t.getTransform(),c=t.canvas;try{const b=document.createElement("canvas");b.width=Math.max(1,Math.ceil(o)),b.height=Math.max(1,Math.ceil(e));const m=b.getContext("2d");if(m){m.save(),m.translate(o/2,e/2);const y=n.magnification||1;if(y!==1&&m.scale(y,y),typeof p.inverse=="function"){const C=p.inverse();m.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=p.a*p.d-p.b*p.c;C!==0&&m.transform(p.d/C,-p.b/C,-p.c/C,p.a/C,(p.c*p.f-p.d*p.e)/C,(p.b*p.e-p.a*p.f)/C)}m.drawImage(c,0,0),m.restore();const S=document.createElement("canvas");S.width=b.width,S.height=b.height;const v=S.getContext("2d");v.filter=`blur(${l}px)`,v.drawImage(b,0,0),t.globalCompositeOperation="destination-out",t.fillRect(-o/2,-e/2,o,e),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(S,-o/2,-e/2,o,e)}}catch(b){console.error("Background blur failed:",b)}t.globalCompositeOperation="source-over",t.globalAlpha=r,t.fillStyle=f,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;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"),S=y.createImageData(64,64),v=S.data;for(let C=0;C<v.length;C+=4){const w=Math.floor(Math.random()*255);v[C]=w,v[C+1]=w,v[C+2]=w,v[C+3]=18}y.putImageData(S,0,0),this._noiseTileCanvas=m}const b=t.createPattern(this._noiseTileCanvas,"repeat");b&&(t.fillStyle=b,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,(a==null?void 0:a.stroke)&&a.stroke.width>0&&a.stroke.isEnabled!==!1?(this.applyPath(t,i,o,e,s),this.applyStrokeAlignment(t,a,i,o,e,s,1,1)):(t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke()),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"||i.type==="circle"){const{startAngle:n=0,sweepAngle:a=360,ratio:l=0}=i,r=o/2,h=e/2,f=n*Math.PI/180,p=a*Math.PI/180,c=f+p;a>=360&&l<=0?t.ellipse(0,0,r,h,0,0,Math.PI*2):(t.ellipse(0,0,r,h,0,f,c,!1),l>0?t.ellipse(0,0,r*l,h*l,0,c,f,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let l=0;l<n;l++){const r=l*2*Math.PI/n-Math.PI/2,h=a*Math.cos(r),f=a*Math.sin(r);l===0?t.moveTo(h,f):t.lineTo(h,f)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let l=i.inner_radius;l==null?l=a*.382:l<=1&&(l=a*l);for(let r=0;r<n*2;r++){const h=r*Math.PI/n-Math.PI/2,f=r%2===0?a:l,p=f*Math.cos(h),c=f*Math.sin(h);r===0?t.moveTo(p,c):t.lineTo(p,c)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,l=1/0,r=-1/0;if(i.points.forEach(p=>{typeof p.x=="number"&&typeof p.y=="number"&&(n=Math.min(n,p.x),a=Math.max(a,p.x),l=Math.min(l,p.y),r=Math.max(r,p.y),p.out_x!==void 0&&(n=Math.min(n,p.out_x),a=Math.max(a,p.out_x)),p.out_y!==void 0&&(l=Math.min(l,p.out_y),r=Math.max(r,p.out_y)),p.in_x!==void 0&&(n=Math.min(n,p.in_x),a=Math.max(a,p.in_x)),p.in_y!==void 0&&(l=Math.min(l,p.in_y),r=Math.max(r,p.in_y)))}),n===1/0)return;const h=(n+a)/2,f=(l+r)/2;if(isNaN(h)||isNaN(f)){this.warn("[Engine] Invalid path center:",h,f);return}i.points.forEach((p,c)=>{if(c===0||p.moveTo)t.moveTo(p.x-h,p.y-f);else{const d=i.points[c-1];if(!d)return;const u=(d.out_x??d.x)-h,b=(d.out_y??d.y)-f,m=(p.in_x??p.x)-h,y=(p.in_y??p.y)-f;isNaN(u)||isNaN(m)||isNaN(p.x)?t.lineTo(p.x-h,p.y-f):t.bezierCurveTo(u,b,m,y,p.x-h,p.y-f)}if(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,c+1)].reverse().find(u=>u.moveTo)||i.points[0];d&&(p.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((p.out_x??p.x)-h,(p.out_y??p.y)-f,(d.in_x??d.x)-h,(d.in_y??d.y)-f,d.x-h,d.y-f),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,l=1/0,r=-1/0;i.points.forEach(p=>{n=Math.min(n,p.x),a=Math.max(a,p.x),l=Math.min(l,p.y),r=Math.max(r,p.y)});const h=(n+a)/2,f=(l+r)/2;i.points.forEach((p,c)=>{if(c===0)t.moveTo(p.x-h,p.y-f);else{const d=i.points[c-1];d.out_x!==void 0||p.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-f,(p.in_x??p.x)-h,(p.in_y??p.y)-f,p.x-h,p.y-f):t.lineTo(p.x-h,p.y-f)}(p.closePath||c===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var F,R;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((F=i.geometry)==null?void 0:F.width)||250,n=((R=i.geometry)==null?void 0:R.height)||45,a=this.focusedId===i.id,l=this.lastHoveredObjectId===i.id,r=e.previewState||"default",h=r!=="default"?r:a?"focused":l?"hovered":"default",f=e.label||{visible:!0,text:"Label"},p=e.helperText||{visible:!1,text:"Helper text"},c=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,b=e.corner_radius??8,m=e.corners||{tl:b,tr:b,bl:b,br:b},y=[m.tl,m.tr,m.br,m.bl];let S=e.backgroundColor||"rgba(31, 41, 55, 1)",v=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",k=e.fontSize||14;const I=`${h}Style`,T=e[I];T?(T.backgroundColor!==void 0&&(S=T.backgroundColor),T.borderColor!==void 0&&(v=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(k=T.fontSize)):h==="focused"?(v=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(v=e.hoverBorderColor||v,S=e.hoverBackgroundColor||S):h==="disabled"?(S=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",v=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(v="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,y);const O=this.createCanvasFill(t,S,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const D=this.createCanvasFill(t,v,s,n);if(D&&(t.strokeStyle=D,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const H=y.map(Z=>Z+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,H),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(D,H)=>{if(!D.visible||!D.svgPath)return;const Z=D.size||14,ct=D.offset??16,Ct=D.color||"#ffffff",vt=H?-(s/2)+ct:s/2-ct,At=D.svgPath;if(t.save(),t.translate(vt,0),!At.startsWith("<svg")){const It=new Path2D(At),Tt=Z/24;t.scale(Tt,Tt),t.translate(-12,-12),t.fillStyle=Ct,t.fill(It)}t.restore()};P(c,!0),P(d,!1);const _=e.text||"",E=e.placeholder||"Enter text...",A=!_,B=_||E,X=A?M:w,W=k,Y=e.fontFamily||"Inter",z=e.fontWeight||400;t.font=`${z} ${W}px "${Y}", sans-serif`,t.fillStyle=X,t.textAlign="left",t.textBaseline=u?"top":"middle";const J=e.inputPadding??16,L=c.visible?(c.offset??16)+(c.size||14)/2+8:J,x=d.visible?(d.offset??16)+(d.size||14)/2+8:J,et=-(s/2)+L,V=s-L-x,at=e.inputType==="password"?"•".repeat(B.length):B;if(t.save(),t.beginPath(),t.rect(et-2,-n/2+4,V+4,n-8),t.clip(),u){const D=at.split(`
|
|
34
|
+
`);let H=-n/2+J;const Z=W*1.2;let ct=0;D.forEach((Ct,vt)=>{const At=Ct.split(" ");let It="";for(let Tt=0;Tt<At.length;Tt++){const qt=It+At[Tt]+" ";t.measureText(qt).width>V&&Tt>0?(t.fillText(It,et,H),It=At[Tt]+" ",H+=Z):It=qt}t.fillText(It,et,H),ct=t.measureText(It).width,vt<D.length-1&&(H+=Z,ct=0)}),a&&!A&&Math.floor(performance.now()/500)%2===0&&t.fillRect(et+ct,H,1.5,W)}else{const H=t.measureText(at).width;let Z=0;if(H>V&&(Z=H-V),t.fillText(at,et-Z,0),a&&!A&&Math.floor(performance.now()/500)%2===0){const Ct=et+H-Z;t.fillRect(Ct,-(W/2),1.5,W)}}if(t.restore(),f.visible!==!1){const D=f.text||"Label",H=f.fontSize||12,Z=f.color||"rgba(156, 163, 175, 1)",ct=f.offset??8;t.font=`600 ${H}px "${Y}", sans-serif`,t.fillStyle=Z,t.textAlign="left",t.textBaseline="bottom";const Ct=-(s/2),vt=-(n/2)-ct;t.fillText(D,Ct,vt)}if(p.visible===!0){const D=p.text||"Helper text",H=p.fontSize||11,Z=h==="error"?"rgba(239, 68, 68, 1)":p.color||"rgba(156, 163, 175, 1)",ct=p.offset??6;t.font=`400 ${H}px "${Y}", sans-serif`,t.fillStyle=Z,t.textAlign="left",t.textBaseline="top";const Ct=-(s/2),vt=n/2+ct;t.fillText(D,Ct,vt)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,l=s.min??0,h=(s.max??100)-l,f=h===0?0:(a-l)/h,p=s.trackHeight||4,c=s.trackRoundedness??2,d=s.trackShape??"Rectangle",u=s.trackPath||"",b=s.accentColor||"#3b82f6",m=s.inactiveColor||"#374151",y=s.thumbShape||"Ellipse",S=s.thumbWidth??16,v=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",k=s.thumbIcon||"",I=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,E=(V,at,F,R,D,H,Z)=>{if((V==="Custom"||V==="Icon")&&Z)try{const ct=new Path2D(Z);if(t.save(),t.translate(at,F),V==="Icon"){const Ct=Math.min(R,D)/24;t.scale(Ct,Ct),t.translate(-12,-12)}t.fill(ct),t.restore();return}catch(ct){console.error("Error drawing slider shape in engine:",ct)}if(t.beginPath(),V==="Ellipse")t.ellipse(at,F,R/2,D/2,0,0,Math.PI*2);else if(V==="Rectangle")this.drawRoundRect(t,at-R/2,F-D/2,R,D,H);else if(V==="Triangle")t.moveTo(at,F-D/2),t.lineTo(at+R/2,F+D/2),t.lineTo(at-R/2,F+D/2),t.closePath();else if(V==="Diamond")t.moveTo(at,F-D/2),t.lineTo(at+R/2,F),t.lineTo(at,F+D/2),t.lineTo(at-R/2,F),t.closePath();else if(V==="Polygon"){const ct=i.geometry.sides||3,Ct=i.geometry.radius||Math.min(R,D)/2;for(let vt=0;vt<ct;vt++){const At=vt*2*Math.PI/ct-Math.PI/2,It=at+Ct*Math.cos(At),Tt=F+Ct*Math.sin(At);vt===0?t.moveTo(It,Tt):t.lineTo(It,Tt)}t.closePath()}else if(V==="Star"){const Ct=Math.min(R,D)/2,vt=Ct/2;for(let At=0;At<10;At++){const It=At%2===0?Ct:vt,Tt=At*Math.PI/5-Math.PI/2;t.lineTo(at+It*Math.cos(Tt),F+It*Math.sin(Tt))}t.closePath()}else V==="Line"&&(t.moveTo(at-R/2,F),t.lineTo(at+R/2,F));t.fill()},A=this.createCanvasFill(t,m,n,p);A&&(t.fillStyle=A,t.strokeStyle=A),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):E(d,0,0,n,p,c,u);const B=n-S,X=-n/2+S/2+f*B,W=X- -n/2;if(W>0){const V=this.createCanvasFill(t,b,n,p);V&&(t.fillStyle=V,t.strokeStyle=V),d==="Line"?(t.lineWidth=p,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(X,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-p/2,W,p,c),t.fill())}t.save(),t.translate(X,0);const Y=t.getTransform(),z=Math.sqrt(Y.a*Y.a+Y.b*Y.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*z,t.shadowOffsetY=1*z;const J=this.createCanvasFill(t,w,S,v);if(J&&(t.fillStyle=J),E(y,0,0,S,v,C,y==="Icon"?k:M),t.restore(),I){t.save(),t.translate(X+P,_);const V=Math.round(a).toString();t.font="10px Inter, sans-serif";const at=t.measureText(V),F=6,R=4,D=at.width+F*2,H=14+R;t.beginPath(),this.drawRoundRect(t,-D/2,-H/2,D,H,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(V,0,0),t.restore()}const L=s.label||{},x=s.helperText||{},et=s.fontFamily||"Inter";if(L.visible!==!1){const V=L.text||"Label",at=L.fontSize||12,F=L.color||"rgba(156, 163, 175, 1)",R=L.offset??8;t.font=`600 ${at}px "${et}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="bottom";const D=-(n/2),H=-(p/2)-R;t.fillText(V,D,H)}if(x.visible===!0){const V=x.text||"Helper text",at=x.fontSize||11,F=x.color||"rgba(156, 163, 175, 1)",R=x.offset??6;t.font=`400 ${at}px "${et}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="top";const D=-(n/2),H=p/2+R;t.fillText(V,D,H)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,l=-n/2,r=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",f=this.lastHoveredObjectId===i.id||e.previewState==="hover",p=(e.isOpen||e.previewState==="active")&&!h;let c=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(c=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):p?(c=e.activeBackgroundColor||c,d=e.activeBorderColor||d,u=e.activeColor||u):f&&(c=e.hoverBackgroundColor||c,d=e.hoverBorderColor||d,u=e.hoverColor||u),c||(c="#ffffff"),d||(d="#e5e7eb");const b=t.globalAlpha;t.globalAlpha=b*(e.opacity??1),this.drawRoundRect(t,a,l,s,n,r),t.fillStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#ffffff",t.fill();const m=e.borderWidth??1;m>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=m,t.stroke());const y=12,S=e.chevronType||"chevron",v=e.chevronSize||16,C=(p?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(S!=="none"){const E=a+s-y-v/2;t.save(),t.translate(E,0);const A=p?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(A*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",S==="chevron")t.beginPath(),t.moveTo(-v/2,-v*.2),t.lineTo(0,v*.2),t.lineTo(v/2,-v*.2),t.stroke();else if(S==="custom"||S==="path"){const B=p&&e.openIconPath||e.closedIconPath;if(B){const X=new Path2D(B);t.save();const W=v/24;t.scale(W,W),t.translate(-12,-12),t.fill(X),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,k=e.fontWeight||400,I=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${M}px ${I}`;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,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=S==="none"?0:v+8,P=s-y*2-O;if(t.save(),t.beginPath(),t.rect(a+y,l,P,n),t.clip(),t.fillText(w,a+y,0),t.restore(),p&&!h){const E=l+n+4,A=e.optionsList||[],B=e.itemHeight||32,X=e.listPadding??4,W=A.length*B+X*2,Y=e.listCornerRadius??r;t.save();const z=e.listShadow||{},J=t.getTransform(),L=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor=typeof z.color=="string"?z.color:((_=z.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(z.blur??12)*L,t.shadowOffsetY=(z.offsetY??6)*L,t.shadowOffsetX=(z.offsetX??0)*L,t.beginPath(),this.drawRoundRect(t,a,E,s,W,Y),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,W)||"#ffffff",t.fill();const x=e.listBorderWidth??1;x>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,W)||"#e5e7eb",t.lineWidth=x,t.stroke()),t.restore();const et=e.itemFontSize||M,V=e.itemFontFamily||I;t.font=`${k} ${et}px ${V}`,A.forEach((at,F)=>{const R=E+X+F*B;if(at===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,B)||"#f3f4f6",t.fillRect(a+x,R,s-x*2,B),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const H=this._lastPointerPos.y-(E+X),Z=Math.floor(H/B);F===Z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,B)||"#f9fafb",t.fillRect(a+x,R,s-x*2,B),t.fillStyle=e.itemHoverColor||u)}t.fillText(at,a+y,R+B/2)})}t.globalAlpha=b}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,l=this.lastHoveredObjectId===i.id,r=this.activeObjectId===i.id,h=e.label||{},f=e.hoverStyle||{},p=e.activeStyle||{},c=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",b=h.text||"Button",m=s.cornerRadius??8,y=e.borderColor||"transparent",S=e.borderWidth||0,v=1;r&&p?(d=p.backgroundColor||d,u=p.color||u,b=p.text||b,v=p.scale??.95,m=p.cornerRadius??m):l&&f&&(d=f.backgroundColor||d,u=f.color||u,b=f.text||b,v=f.scale??1,m=f.cornerRadius??m,y=f.borderColor||y);const C=-n/2,w=-a/2;t.save(),t.scale(v,v),t.beginPath(),this.drawRoundRect(t,C,w,n,a,m);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(S>0||l&&f.borderColor)&&(t.strokeStyle=y,t.lineWidth=S||(l?1:0),t.stroke());const k=h.fontSize||14,I=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${k}px "${I}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let O=0;if(c.enabled&&c.svgPath){const P=k*1.1,_=c.gap||8,E=t.measureText(b),B=-(E.width+P+_)/2,X=c.position==="left"?B+P/2:B+E.width+_+P/2;O=c.position==="left"?B+P+_+E.width/2:B+E.width/2,t.save(),t.translate(X,0);const W=new Path2D(c.svgPath),Y=P/24;t.scale(Y,Y),t.translate(-12,-12),t.fillStyle=u,t.fill(W),t.restore()}t.fillText(b,O,0),t.restore()}renderToggleButton(t,i){var b,m;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((b=i.geometry)==null?void 0:b.width)||120,a=((m=i.geometry)==null?void 0:m.height)||40,l=-n/2,r=-a/2,h=e.corner_radius??8,f=e.label||{},p=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",c=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,l,r,n,a,h),t.fillStyle=p,t.fill();const d=f.fontSize||14,u=f.fontFamily||"Inter";t.font=`${f.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=c,t.textAlign="center",t.textBaseline="middle",t.fillText(f.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var Y,z,J,L,x,et,V,at,F,R,D,H;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((Y=i.geometry)==null?void 0:Y.width)||52,n=((z=i.geometry)==null?void 0:z.height)||30,a=-s/2,l=-n/2,r=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,f=e.toggleStyle||{},p=f.backgroundColor||e.activeColor||"#10b981",c=f.borderColor||e.borderColor||"transparent",d=f.borderWidth??e.borderWidth??0,u=f.knobColor||e.knobColor||"#ffffff",b=r?p:e.inactiveColor||"#374151",m=r?c:e.borderColor||"transparent",y=r?d:e.borderWidth??0,S=r?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,h);const v=this.createCanvasFill(t,b,s,n);if(v&&(t.fillStyle=v,t.fill()),y>0){t.lineWidth=y;const Z=this.createCanvasFill(t,m,s,n);Z&&(t.strokeStyle=Z,t.stroke())}const C=2,w=n-C*2,M=w/2,k=a+C,I=a+s-C-w,T=r?I:k,O=l+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,S,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,E=!1;const A=(r?(J=f.leftLabel)==null?void 0:J.text:null)||((L=e.leftLabel)==null?void 0:L.text)||"",B=(r?(x=f.leftLabel)==null?void 0:x.color:null)||((et=e.leftLabel)==null?void 0:et.color)||"#f3f4f6";if((V=e.leftLabel)!=null&&V.enabled&&A){const Z=e.leftLabel;t.font=`${Z.fontWeight||400} ${Z.fontSize||12}px "${Z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=B,t.textBaseline="middle",t.textAlign="right",t.fillText(A,a-(Z.gap||8),0),_=!0}const X=(r?(at=f.rightLabel)==null?void 0:at.text:null)||((F=e.rightLabel)==null?void 0:F.text)||"",W=(r?(R=f.rightLabel)==null?void 0:R.color:null)||((D=e.rightLabel)==null?void 0:D.color)||"#f3f4f6";if((H=e.rightLabel)!=null&&H.enabled&&X){const Z=e.rightLabel;t.font=`${Z.fontWeight||400} ${Z.fontSize||12}px "${Z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="left",t.fillText(X,a+s+(Z.gap||8),0),E=!0}if(!_&&!E&&e.label&&e.label.text){const Z=e.label,ct=Z.fontSize||14,Ct=Z.fontWeight||400,vt=Z.fontFamily||"Inter";t.font=`${Ct} ${ct}px "${vt}", sans-serif`,t.fillStyle=Z.color||"#f3f4f6",t.textBaseline="middle";const At=Z.gap||10;let It=0,Tt=0;Z.position==="left"?(t.textAlign="right",It=a-At,Tt=0):Z.position==="right"?(t.textAlign="left",It=a+s+At,Tt=0):Z.position==="top"?(t.textAlign="center",It=0,Tt=l-At,t.textBaseline="bottom"):Z.position==="bottom"?(t.textAlign="center",It=0,Tt=l+n+At,t.textBaseline="top"):(t.textAlign="left",It=a+s+At,Tt=0),t.fillText(Z.text,It,Tt)}}renderCheckbox(t,i){var v,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((v=i.geometry)==null?void 0:v.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,l=-n/2,r=e.cornerRadius??4,h=e.checked??!1,f=e.activeColor||"#3b82f6",p=e.inactiveColor||"transparent",c=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,b=h?f:p,m=h?"transparent":d,y=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,r);const S=this.createCanvasFill(t,b,s,n);if(S&&(t.fillStyle=S,t.fill()),y>0){t.lineWidth=y;const w=this.createCanvasFill(t,m,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,f,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,c,s,n);t.strokeStyle=w||c,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,k=l+n*.5,I=a+s*.45,T=l+n*.7,O=a+s*.75,P=l+n*.25;t.moveTo(M,k),t.lineTo(I,T),t.lineTo(O,P),t.stroke(),t.restore()}if(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||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let k=0,I=0;w.position==="left"?(t.textAlign="right",k=a-M,I=0):w.position==="right"?(t.textAlign="left",k=a+s+M,I=0):w.position==="top"?(t.textAlign="center",k=0,I=l-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",k=0,I=l+n+M,t.textBaseline="top"),t.fillText(w.text,k,I),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,l=-n/2,r=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],f=e.orientation||"vertical",p=e.itemGap!==void 0?e.itemGap:16,c=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",b=e.fontSize||14,m=e.fontFamily||"Inter",y=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const S=8,v=S*2;if(t.save(),t.font=`${y} ${b}px "${m}", sans-serif`,t.textBaseline="middle",t.textAlign="left",f==="vertical"){const M=Math.max(v,b)+p;h.forEach((k,I)=>{const T=l+I*M+S;t.beginPath(),t.arc(a+S,T,S,0,Math.PI*2);const O=r===k,P=this.createCanvasFill(t,c,v,v),_=this.createCanvasFill(t,d,v,v);O?(t.strokeStyle=P||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+S,T,S/2,0,Math.PI*2),t.fillStyle=P||c,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,a+v+8,T)})}else{let M=a;h.forEach(k=>{const I=r===k,T=t.measureText(k).width;t.beginPath(),t.arc(M+S,0,S,0,Math.PI*2);const O=this.createCanvasFill(t,c,v,v),P=this.createCanvasFill(t,d,v,v);I?(t.strokeStyle=O||c,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+S,0,S/2,0,Math.PI*2),t.fillStyle=O||c,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,M+v+6,0),M+=v+6+T+p})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const k=M.gap||8;let I=0,T=0;M.position==="left"?(t.textAlign="right",I=a-k,T=0):M.position==="right"?(t.textAlign="left",I=a+s+k,T=0):M.position==="top"?(t.textAlign="center",I=0,T=l-k,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",I=0,T=l+n+k,t.textBaseline="top"),t.fillText(M.text,I,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.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,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return hs[this.stylePreset]||hs.default},_resolveColor:function(P,_){const E=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?E.colors[_%E.colors.length]:typeof P=="string"?P:E.colors[_%E.colors.length]},_makeGradient:function(P,_,E,A,B,X){if(!this._getPreset().barGradient&&!this.barGradient)return _;const Y=P.createLinearGradient(E,A,B,X);return Y.addColorStop(0,_),Y.addColorStop(1,_+"44"),Y},_drawRoundedBar:function(P,_,E,A,B,X,W){if(X=Math.min(X,Math.min(Math.abs(A),Math.abs(B))/2),X<=0||A===0||B===0){P.rect(_,E,A,B);return}P.beginPath(),W?(P.moveTo(_,E+B),P.lineTo(_,E+X),P.quadraticCurveTo(_,E,_+X,E),P.lineTo(_+A-X,E),P.quadraticCurveTo(_+A,E,_+A,E+X),P.lineTo(_+A,E+B),P.lineTo(_,E+B)):(P.moveTo(_,E),P.lineTo(_+A-X,E),P.quadraticCurveTo(_+A,E,_+A,E+X),P.lineTo(_+A,E+B-X),P.quadraticCurveTo(_+A,E+B,_+A-X,E+B),P.lineTo(_,E+B),P.lineTo(_,E)),P.closePath()}},n=s.width,a=s.height,l=-n/2,r=-a/2;if(!s.datasets||s.datasets.length===0||s.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=s._getPreset();let f=-1/0,p=1/0;const c=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<c;P++){let _=0,E=0;s.datasets.forEach(A=>{const B=A.data[P]??0;B>=0?_+=B:E+=B}),_>f&&(f=_),E<p&&(p=E)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>f&&(f=_),_<p&&(p=_)})});isFinite(f)||(f=10),isFinite(p)||(p=0),f=Math.max(f,0),p=Math.min(p,0);const u=f-p||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const b=s.showYLabels?t.measureText(f.toFixed(0)).width+14:10,m=s.showXLabels?s.axisLabelFontSize+12:8,S=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,v=10,C=l+b,w=r+S,M=n-b-v,k=a-S-m;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,r,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,k),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=r+12;let _=C;s.datasets.forEach((E,A)=>{const B=s._resolveColor(E.color,A),X=E.label||"Series "+(A+1),W=7;t.beginPath(),t.roundRect(_,P-W/2,W,W,2),t.fillStyle=B,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(X,_+W+4,P),_+=t.measureText(X).width+W+16})}const I=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=I;P++)if(s.orientation==="horizontal"){const _=C+P/I*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+k),t.stroke()}else{const _=w+P/I*k;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=I;P++)if(s.orientation==="horizontal"){const _=p+P/I*u,E=C+P/I*M;t.textAlign="center",t.fillText(_.toFixed(0),E,w+k+s.axisLabelFontSize)}else{const _=f-P/I*u,E=w+P/I*k;t.textAlign="right",t.fillText(_.toFixed(0),C-6,E)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+k),t.lineTo(C+M,w+k),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+k),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=k/c;for(let _=0;_<c;_++){const E=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,E),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=C;s.datasets.forEach((B,X)=>{const W=B.data[_]??0;if(W===0)return;const Y=W/u*M,z=Math.min(s.barWidth*d+s.barGap,P-8),J=E-z/2,L=A;A+=Y;const x=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,x,L,J,L+Y,J),s._drawRoundedBar(t,L,J,Y,z,X===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?x:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/c;for(let _=0;_<c;_++){const E=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",E,w+k+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let A=w+k;s.datasets.forEach((B,X)=>{const W=B.data[_]??0;if(W===0)return;const Y=W/u*k,z=Math.min(s.barWidth*d+s.barGap,P-8),J=E-z/2,L=A-Y;A-=Y;const x=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,x,J,L,J,L+Y),s._drawRoundedBar(t,J,L,z,Y,X===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?x:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=k/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=C+(0-p)/u*M;for(let A=0;A<c;A++){const B=w+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",C-5,B),s.enableShadows&&(t.shadowColor=s.shadowColor));const X=B-_/2;s.datasets.forEach((W,Y)=>{const z=W.data[A]??0,J=Math.abs(z/u*M);if(J<1)return;const L=X+Y*(s.barWidth+s.barGap),x=z>=0?E:E-J,et=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,et,x,L,x+J,L),s._drawRoundedBar(t,x,L,J,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?et:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&z!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=z>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?et:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(z.toString(),z>=0?x+J+4:x-4,L+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/c,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),E=w+k-(0-p)/u*k;for(let A=0;A<c;A++){const B=C+A*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[A]||"",B,w+k+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const X=B-_/2;s.datasets.forEach((W,Y)=>{const z=W.data[A]??0,J=Math.abs(z/u*k);if(J<1)return;const L=X+Y*(s.barWidth+s.barGap),x=z>=0?E-J:E,et=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,et,L,x,L,x+J),s._drawRoundedBar(t,L,x,s.barWidth,J,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?et:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&z!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=z>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?et:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(z.toString(),L+s.barWidth/2,z>=0?x-4:x+J+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var b,m;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((b=i.geometry)==null?void 0:b.width)||180,height:((m=i.geometry)==null?void 0:m.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 ds[this.stylePreset]||ds.default},_resolveSliceColor:function(y,S){const v=y.color,C=S,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(v)?w.colors[C%w.colors.length]:typeof v=="string"?v:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.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 l=s.slices.reduce((y,S)=>y+(S.value||0),0);if(l<=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 r=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=r.cardBackground,t.fill(),t.strokeStyle=r.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,f=h>0?h*(s.legendFontSize+8)+10:0,p=a-f-16,c=Math.min(n-24,p)/2,d=0,u=-f/2;if(s.chartType==="rose"){const y=Math.max(...s.slices.map(C=>C.value||0)),S=Math.PI*2/s.slices.length,v=c>0?s.sliceGap/c:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const k=M/y*c,I=-Math.PI/2+w*S+v/2,T=I+S-v,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,k,I,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=I+(T-I)/2,_=d+k*.65*Math.cos(P),E=u+k*.65*Math.sin(P),A=Math.round(M/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=r.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${A}%`,_,E),t.restore()}})}else{const y=s.chartType==="pie"?0:s.innerRadius,S=c*Math.max(0,y),v=c>0?s.sliceGap/c:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const k=w.value||0;if(k===0){C+=k/l*Math.PI*2;return}const I=k/l*Math.PI*2,T=C+v/2,O=C+I-v/2;if(O<=T){C+=I;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,S<=0?(t.moveTo(d,u),t.arc(d,u,c,T,O),t.lineTo(d,u)):(t.moveTo(d+c*Math.cos(T),u+c*Math.sin(T)),t.arc(d,u,c,T,O),t.arc(d,u,S,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,E=S+(c-S)/2,A=d+E*Math.cos(_),B=u+E*Math.sin(_),X=Math.round(k/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=r.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${X}%`,A,B),t.restore()}C+=I}),s.chartType==="donut"&&s.showCenterText&&S>14){const w=Math.round(l),M=Math.min(Math.floor(S*.52),20),k=Math.min(Math.floor(S*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=r.centerTextColor,t.fillText(w.toString(),d,u-k*.5),s.centerLabel&&(t.font=`${k}px Inter, sans-serif`,t.fillStyle=r.centerLabelColor,t.fillText(s.centerLabel,d,u+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const y=2,S=n/y,v=s.legendFontSize+8,C=a/2-f+10,w=-n/2+10;s.slices.forEach((M,k)=>{const I=k%y,T=Math.floor(k/y),O=w+I*S,P=C+T*v,_=s._resolveSliceColor(M,k),E=7;t.beginPath(),t.roundRect(O,P-E/2,E,E,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=r.legendColor;const A=Math.round((M.value||0)/l*100),B=`${M.label||"Item"} ${A}%`,X=S-E-20;let W=B;for(;t.measureText(W).width>X&&W.length>4;)W=W.slice(0,-4)+"…";t.fillText(W,O+E+4,P)})}t.restore()}renderJoystick(t,i){var u,b,m,y,S;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((u=i.geometry)==null?void 0:u.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((b=i.geometry)==null?void 0:b.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let l=i.handleX||0,r=i.handleY||0;o&&o.handleX!==void 0&&(l=o.handleX),o&&o.handleY!==void 0&&(r=o.handleY),t.save();let h=0,f=0;i.handleOrigin==="top-left"?(h=e/2,f=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,f=-s/2),t.translate(h,f),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(m=i.style)!=null&&m.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(y=i.style)!=null&&y.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(S=i.style)!=null&&S.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const p=n-a;let c=0,d=0;i.joystickType==="2D"?(c=l*p,d=r*p):i.joystickType==="1D_X"?(c=l*p,d=0):i.joystickType==="1D_Y"&&(c=0,d=r*p),t.beginPath(),t.arc(c,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var k,I;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((k=t.geometry)==null?void 0:k.width)||180,l=s.height!==void 0?s.height:((I=t.geometry)==null?void 0:I.height)||100,r=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,f=e.fontSize||14,p=this.getWorldTransform(t.id),c=i-p.x,d=o-p.y,u=-p.rotation*(Math.PI/180),b=Math.cos(u),m=Math.sin(u),y=c*b-d*m,S=c*m+d*b,C=8*2,w=-a/2,M=-l/2;if(r==="vertical"){const T=Math.max(C,f)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(y>=w&&y<=w+a&&S>=P&&S<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,E=C+6+_+h;if(y>=T&&y<=T+E&&S>=M&&S<=M+l)return O;T+=E}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.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,l=0;if(s.forEach(u=>{let b=u.data;if(u.isVarEnabled&&u.inputId){let m=this.inputs.get(u.inputId);if(m===void 0){const y=this.inputNameMap.get(u.inputId);y&&y.length>0&&(m=this.inputs.get(y[0]))}m&&Array.isArray(m)&&(b=m)}if(b&&b.length>0){const m=b.filter(y=>typeof y=="number"&&!isNaN(y));m.length>0&&(n=Math.min(n,...m),a=Math.max(a,...m),l=Math.max(l,b.length))}u._resolvedData=b}),l<2)return;const r=a-n,h=o/(l-1),f=u=>{const b=r===0?.5:(u-n)/r;return e/2-b*e},p=u=>u*h-o/2,c=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||c,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<l;u++){const b=p(u);t.fillText(`${u+1}`,b,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,b=(a+n)/2;t.fillText(a.toFixed(1),u,f(a)),t.fillText(b.toFixed(1),u,f(b)),t.fillText(n.toFixed(1),u,f(n))}const d=10;if(s.forEach(u=>{const b=u._resolvedData;if(!(!b||b.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(p(0),e/2),t.lineTo(p(0),f(b[0])),u.smoothing&&b.length>2)for(let y=0;y<b.length-1;y++){const S=b[y===0?y:y-1],v=b[y],C=b[y+1],w=b[y+1===b.length-1?y+1:y+2];for(let M=1;M<=d;M++){const k=M/d,I=this._catmullRom(S,v,C,w,k);t.lineTo(p(y+k),f(I))}}else for(let y=1;y<b.length;y++)t.lineTo(p(y),f(b[y]));t.lineTo(p(b.length-1),e/2),t.closePath();const m=t.globalAlpha;t.globalAlpha=m*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=m}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(p(0),f(b[0])),u.smoothing&&b.length>2)for(let m=0;m<b.length-1;m++){const y=b[m===0?m:m-1],S=b[m],v=b[m+1],C=b[m+1===b.length-1?m+1:m+2];for(let w=1;w<=d;w++){const M=w/d,k=this._catmullRom(y,S,v,C,M);t.lineTo(p(m+M),f(k))}}else for(let m=1;m<b.length;m++)t.lineTo(p(m),f(b[m]));t.stroke(),u.showPoints&&b.forEach((m,y)=>{const S=p(y),v=f(m);t.beginPath(),t.arc(S,v,(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()})}}),i.showLegend&&s.length>0){const u=o/2-10;let b=-e/2+15;const m=i.legendFontSize||10,y=m+5;t.font=`${m}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(S=>{const C=S.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(u-w-8-5,b-(8/2+2),8,8),t.fillStyle=S.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,u,b),b+=y})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,l=s*s,r=s*l;return(2*i-2*o+n+a)*r+(-3*i+3*o-2*n-a)*l+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const l=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[l]||l;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const l=(r,h=100)=>{var v,C;const p=(((C=(v=this.artboard)==null?void 0:v.tokens)==null?void 0:C.colors)||{})[r]||r,c=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(h)*c;if(u>=1&&p.startsWith("#"))return p;const b=p.startsWith("#")?p.replace("#",""):"ffffff",m=parseInt(b.substring(0,2),16),y=parseInt(b.substring(2,4),16),S=parseInt(b.substring(4,6),16);return`rgba(${m}, ${y}, ${S}, ${u})`};if(i.type==="LinearGradient"){const r=(u,b,m)=>Array.isArray(u)?u[b]??(b===0?0:1):u&&typeof u=="object"?u[m]??(b===0?0:1):b===0?0:1,h=r(i.start,0,"x")*o-o/2,f=r(i.start,1,"y")*e-e/2,p=r(i.end,0,"x")*o-o/2,c=r(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,f,p,c);if(i.stops.forEach(u=>{const b=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,m=l(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,b)),m)}),i.gradientTransform&&d.setTransform){const[u,b,m,y,S,v]=i.gradientTransform;d.setTransform({a:u,b,c:m,d:y,e:S,f:v})}return d}else if(i.type==="RadialGradient"){const r=(d,u,b)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[b]??.5:.5,h=r(i.center,0,"x")*o-o/2,f=r(i.center,1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e),c=t.createRadialGradient(h,f,0,h,f,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,b=l(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),b)}),i.gradientTransform&&c.setTransform){const[d,u,b,m,y,S]=i.gradientTransform;c.setTransform({a:d,b:u,c:b,d:m,e:y,f:S})}return c}else if(i.type==="AngularGradient"){const r=(d,u,b)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[b]??.5:.5,h=r(i.center||[.5,.5],0,"x")*o-o/2,f=r(i.center||[.5,.5],1,"y")*e-e/2,p=(i.degree||i.angle||0)*(Math.PI/180),c=(a=t.createConicGradient)==null?void 0:a.call(t,p,h,f);if(c){if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,b=l(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),b)}),i.gradientTransform&&c.setTransform){const[d,u,b,m,y,S]=i.gradientTransform;c.setTransform({a:d,b:u,c:b,d:m,e:y,f:S})}return c}}else if(i.type==="DiamondGradient"){const r=(d,u,b)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[b]??.5:.5,h=r(i.center||[.5,.5],0,"x")*o-o/2,f=r(i.center||[.5,.5],1,"y")*e-e/2,p=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,f),t.rotate(Math.PI/4);const c=t.createRadialGradient(0,0,0,0,0,p);if(i.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,b=l(d.color||"#000000",d.opacity??100);c.addColorStop(Math.max(0,Math.min(1,u)),b)}),i.gradientTransform&&c.setTransform){const[d,u,b,m,y,S]=i.gradientTransform;c.setTransform({a:d,b:u,c:b,d:m,e:y,f:S})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=c,t.restore(),c}}if(i.type==="Pattern"&&i.url){let l=this.imageCache.get(i.url);if(l||(l=new Image,l.src=i.url,this.imageCache.set(i.url,l)),l.complete&&l.naturalWidth>0){const r=t.createPattern(l,"repeat");if(r&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,f=i.scaleX??1,p=i.scaleY??1,c=i.offsetX??0,d=i.offsetY??0,u=i.rotation??0;h.translateSelf(c,d),h.rotateSelf(u),h.scaleSelf(f,p),r.setTransform(h)}return r}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let l=0,r=0,h=0,f=0;typeof a=="number"?l=r=h=f=a:Array.isArray(a)?a.length===1?l=r=h=f=a[0]:a.length===2?(l=h=a[0],r=f=a[1]):a.length===3?(l=a[0],r=f=a[1],h=a[2]):a.length>=4&&(l=a[0],r=a[1],h=a[2],f=a[3]):a&&typeof a=="object"&&(l=a.tl??a.corner_radius??a.cornerRadius??0,r=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,f=a.bl??a.corner_radius??a.cornerRadius??0);const p=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(l=Math.min(Math.max(0,l),p),r=Math.min(Math.max(0,r),p),h=Math.min(Math.max(0,h),p),f=Math.min(Math.max(0,f),p),t.roundRect){t.roundRect(i,o,e,s,[l,r,h,f]);return}t.moveTo(i+l,o),t.lineTo(i+e-r,o),t.arcTo(i+e,o,i+e,o+r,r),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+f,o+s),t.arcTo(i,o+s,i,o+s-f,f),t.lineTo(i,o+l),t.arcTo(i,o,i+l,o,l),t.closePath()}renderListView(t,i){var A,B,X,W;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((A=i.geometry)==null?void 0:A.width)||200,n=o.height!==void 0?o.height:((B=i.geometry)==null?void 0:B.height)||300,a=-s/2,l=-n/2,r=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",f=e.items||[],p=e.itemGap??10,c=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,b=e.padding??0,m=e.glassEffect!==!1,y=e.accentColor||"#3b82f6",S=e.itemTextColor||"#333333",v=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,k=e.glowColor||"#3b82f6",I=typeof k=="string"?k:k.color||((W=(X=k.stops)==null?void 0:X[0])==null?void 0:W.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const Y=t.getTransform(),z=Math.sqrt(Y.a*Y.a+Y.b*Y.b)||1;t.shadowColor=I,t.shadowBlur=M*2*z,t.shadowOffsetX=0,t.shadowOffsetY=0}if(m){const Y=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",z=this.createCanvasFill(t,Y,s,n);t.fillStyle=z||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r)||t.fill();const L=t.createLinearGradient(a,l,a+s,l+n);L.addColorStop(0,"rgba(255, 255, 255, 0.15)"),L.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),L.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=L,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r)||t.stroke()}else{const Y=e.backgroundColor||e.listBackgroundColor||"transparent",z=this.createCanvasFill(t,Y,s,n);if(z){t.fillStyle=z,t.beginPath();const L=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r);t.fill()}const J=e.borderWidth??0;if(J>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=J,t.beginPath();const L=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,r);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const Y=new Path2D(e.containerPath);t.translate(a,l),t.scale(s/100,n/100),t.clip(Y),t.scale(100/s,100/n),t.translate(-a,-l)}catch{}else t.clip();const P=typeof b=="number"?b:h==="vertical"?b[0]:b[3];let _=(h==="vertical"?l:a)+u+P;if(t.textBaseline="middle",f.forEach((Y,z)=>{const J=e.listLayout||"linear",L=J==="circular"?d:h==="vertical"?s:d,x=J==="circular"||h==="vertical"?c:n;let et=0,V=0,at=0;if(J==="circular"){const Tt=f.length||1,qt=Math.PI*2/Tt,ue=e.circularStartAngle||0,Qt=e.circularRadius||100,tt=u*.01+ue*Math.PI/180,gt=z*qt+tt,Ft=a+s/2,Et=l+n/2;et=Ft+Math.cos(gt)*Qt-L/2,V=Et+Math.sin(gt)*Qt-x/2,at=gt+(e.itemRotation||0)*Math.PI/180}else et=h==="vertical"?a:_,V=h==="vertical"?_:l,at=(e.itemRotation||0)*Math.PI/180;const F=C===z,R=w===z,D=R&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",H=R&&e.activeItemShape?e.activeItemPath:e.itemPath||"",Z=e.itemCornerRadius||0;if(t.save(),at!==0&&(t.translate(et+L/2,V+x/2),t.rotate(at),t.translate(-(et+L/2),-(V+x/2))),R){const Tt=this.createCanvasFill(t,y,L,x);t.fillStyle=Tt||y;const qt=t.globalAlpha;t.globalAlpha=qt*.8,t.beginPath(),this.drawCustomShape(t,D,H,et,V,L,x,Z)||(t.rect(et,V,L,x),t.fill()),t.globalAlpha=qt}else if(F)t.fillStyle=m?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,D,H,et,V,L,x,Z)||(t.rect(et,V,L,x),t.fill());else if(v!=="transparent"){const Tt=this.createCanvasFill(t,v,L,x);t.fillStyle=Tt||v,t.beginPath(),this.drawCustomShape(t,D,H,et,V,L,x,Z)||(t.rect(et,V,L,x),t.fill())}if(R||F){const Tt=this.createCanvasFill(t,y,h==="vertical"?3:L,h==="vertical"?x:3);t.fillStyle=Tt||y,h==="vertical"?t.fillRect(et,V,3,x):t.fillRect(et,V+x-3,L,3)}const ct=R?"#ffffff":m?"rgba(255, 255, 255, 0.9)":S;t.fillStyle=ct,t.font=R||F?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ct=typeof Y=="string"?Y:(Y==null?void 0:Y.label)||`Item ${z+1}`,vt=et+(h==="vertical"?16:L/2),At=V+x/2;h==="horizontal"||J==="circular"?t.textAlign="center":t.textAlign="left";const It=J==="circular"?et+L/2:vt;t.fillText(Ct,It,At),t.restore(),_+=(h==="vertical"?c:d)+p}),t.restore(),e.showScrollbar!==!1){const Y=(f.length||0)*(h==="vertical"?c:d)+((f.length||0)-1)*p,z=h==="vertical"?n:s,J=e.listLayout||"linear",L=e.containerShape==="circle"||J==="circular";if(Y>z||J==="circular"&&f.length>0){const x=e.scrollbarColor||"rgba(255,255,255,0.3)",et=e.scrollbarWidth||4;if(L){const V=Math.min(s,n)/2-et/2-2,at=a+s/2,F=l+n/2;if(t.strokeStyle=x,t.lineWidth=et,t.lineCap="round",t.beginPath(),J==="circular"){const R=Math.PI/4,D=-(u*.01)-Math.PI/2;t.arc(at,F,V,D,D+R)}else{const R=Math.PI/2,D=z/Y,H=R*D,Z=-u/Y*R,Ct=-Math.PI/4+Z;t.arc(at,F,V,Ct,Ct+H)}t.stroke()}else{const V=z/Y,at=z*V,F=-u/Y*z;t.fillStyle=x,h==="vertical"?t.fillRect(a+s-et-2,l+F,et,at):t.fillRect(a+F,l+n-et-2,at,et)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,l){if(i==="circle"){const r=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,r,0,Math.PI*2),!1}else if(i==="pill"){const r=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,r),!1}else if(i==="custom"&&o)try{const r=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(r),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,l),!1}return this.drawListViewRect(t,e,s,n,a,l),!1}updateListViewScrollFromPointer(t){var m,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},l=i.items||[],r=i.itemGap??10,h=i.itemHeight??50,f=i.itemWidth??200,p=a.width!==void 0?a.width:((m=t.geometry)==null?void 0:m.width)||200,c=a.height!==void 0?a.height:((y=t.geometry)==null?void 0:y.height)||300;if(n==="circular")return;const d=(l.length||0)*(o==="vertical"?h:f)+((l.length||0)-1)*r,b=Math.max(0,d-(o==="vertical"?c:p)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-b&&(i.scrollOffset=-b)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var X,W;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((X=t.geometry)==null?void 0:X.width)||200,l=s.height!==void 0?s.height:((W=t.geometry)==null?void 0:W.height)||300,r=e.orientation||"vertical",h=e.itemGap??10,f=e.itemHeight??50,p=e.itemWidth??200,c=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),b=i-u.x,m=o-u.y,y=-u.rotation*(Math.PI/180),S=Math.cos(y),v=Math.sin(y),C=b*S-m*v,w=b*v+m*S,M=-a/2,k=-l/2,I=typeof d=="number"?d:r==="vertical"?d[0]:d[3];let T=(r==="vertical"?k:M)+c+I;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,E=e.circularStartAngle||0,A=e.circularRadius||100,B=c*.01+E*Math.PI/180;for(let Y=0;Y<n.length;Y++){const z=O==="circular"?p:r==="vertical"?a:p,J=O==="circular"||r==="vertical"?f:l;let L=0,x=0,et=0;if(O==="circular"){const V=Y*_+B,at=M+a/2,F=k+l/2;L=at+Math.cos(V)*A-z/2,x=F+Math.sin(V)*A-J/2,et=V+(e.itemRotation||0)*Math.PI/180}else L=r==="vertical"?M:T,x=r==="vertical"?T:k,et=(e.itemRotation||0)*Math.PI/180;if(et!==0){const V=L+z/2,at=x+J/2,F=C-V,R=w-at,D=-et,H=F*Math.cos(D)-R*Math.sin(D)+V,Z=F*Math.sin(D)+R*Math.cos(D)+at;if(H>=L&&H<=L+z&&Z>=x&&Z<=x+J)return Y}else if(C>=L&&C<=L+z&&w>=x&&w<=x+J)return Y;T+=(r==="vertical"?f:p)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var p,c,d,u,b,m,y,S,v,C,w,M,k,I,T,O,P,_,E,A,B,X,W,Y,z,J,L,x,et,V,at,F,R,D,H,Z,ct,Ct,vt,At,It,Tt,qt,ue,Qt,tt,gt,Ft,Et,Mt,Bt,Ht,_t,zt,Zt,le,ce,Me,oe,Ce,fe,he,it,ut,st,G,nt,lt,mt,Ot,ht,xt,bt,$t,$,Xt,Wt,jt,Gt,Nt,se,te,yt,ot,N,ft,dt,j,St,wt,Yt,Jt,ee,ke,_e,Pe,Ee,Ae,Oe,$e,Kt,re,ge,Le,Re,be,ye,me,Ie,Be,Ne,Ve,We,He,Ue,us,gs,ys;if(!n.enabled)return;const a=n.startTime||0,l=n.endTime||1/0;if(this.currentTime<a||this.currentTime>l)return;const r=s.x-i,h=s.y-o,f=Math.sqrt(r*r+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===U.Proximity){const q=((p=n.settings)==null?void 0:p.radius)||300,Q=((c=n.settings)==null?void 0:c.falloff)||"smooth";let K=0;f<q&&(Q==="linear"?K=1-f/q:K=Math.pow(1-f/q,2)),n.sensors.forEach(pt=>{this.applyBehaviorSensor(s,pt,K,t,n.settings,e,r,h,f)})}else if(n.type===U.Magnetic){const q=((d=n.settings)==null?void 0:d.radius)||400,Q=((u=n.settings)==null?void 0:u.strength)||.5;if(f<q&&f>5){const K=1-f/q,pt=r*K*Q,Pt=h*K*Q;s.x-=pt*t*10,s.y-=Pt*t*10}}else if(n.type===U.Repel){const q=((b=n.settings)==null?void 0:b.radius)||300,Q=((m=n.settings)==null?void 0:m.strength)||1;if(f<q){const K=Math.pow(1-f/q,2);s.x+=r/(f||1)*K*60*Q*t*5,s.y+=h/(f||1)*K*60*Q*t*5}}else if(n.type===U.Orbit){const q=((y=n.settings)==null?void 0:y.speed)||1,Q=((S=n.settings)==null?void 0:S.radius)||30,K=this.currentTime*q*Math.PI*2;s.x+=Math.cos(K)*Q*t*5,s.y+=Math.sin(K)*Q*t*5,s.rotation+=2*t*5}else if(n.type===U.Vortex){const q=((v=n.settings)==null?void 0:v.radius)||400,Q=((C=n.settings)==null?void 0:C.speed)||2,K=((w=n.settings)==null?void 0:w.strength)||1;if(f<q){const pt=Math.pow(1-f/q,1.5),Pt=this.currentTime*Q*Math.PI*2,Rt=Math.cos(Pt)*30-r*.4,Dt=Math.sin(Pt)*30-h*.4;s.x+=Rt*pt*K*t*5,s.y+=Dt*pt*K*t*5,s.rotation+=5*pt*K*t*5,s.scale_x*=1-pt*.1*K*t,s.scale_y*=1-pt*.1*K*t}}else if(n.type===U.Fluid){const q=((M=n.settings)==null?void 0:M.radius)||300,Q=((k=n.settings)==null?void 0:k.strength)||1;if(f<q){const K=Math.pow(1-f/q,1.2),pt=r/(f||1)*K*1.2*Q,Pt=h/(f||1)*K*1.2*Q;s.x+=pt*10*t*5,s.y+=Pt*10*t*5,s.scale_x*=1+K*.3*Q*t,s.scale_y*=1+K*.3*Q*t}}else if(n.type===U.Elastic){const q=((I=n.settings)==null?void 0:I.radius)||300,Q=((T=n.settings)==null?void 0:T.strength)||1;if(f<q){const K=1-f/q;s.scale_x*=1+K*.4*Q*t,s.scale_y*=1+K*.4*Q*t}}else if(n.type===U.Holographic){const q=s.x-this.canvasWidth/2,Q=s.y-this.canvasHeight/2,K=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=q/1e3*K*t*5,s.y-=Q/1e3*K*t*5,s.style){const pt=1-Math.min(1,f/400);s.style.exposure=(s.style.exposure||1)+pt*.5*t}}else if(n.type===U.Sticky){const q=((P=n.settings)==null?void 0:P.radius)||80,Q=((_=n.settings)==null?void 0:_.strength)||1;if(f<q){const K=Math.pow(1-f/q,2);s.x-=r*K*Q*t*10,s.y-=h*K*Q*t*10,s.scale_x*=1-K*.1*Q*t,s.scale_y*=1-K*.1*Q*t}}else if(n.type===U.Dilation){const q=((E=n.settings)==null?void 0:E.size)||120,Q=((A=n.settings)==null?void 0:A.strength)||1;if(f<q){const K=1-f/q;s.scale_x*=1+K*.5*Q*t,s.scale_y*=1+K*.5*Q*t}}else if(n.type===U.Parallax){const q=((B=n.settings)==null?void 0:B.factor)||15,Q=((X=n.settings)==null?void 0:X.strength)||1,K=this.canvasWidth/2,pt=this.canvasHeight/2,Pt=this._lastPointerPos||{x:K,y:pt},Rt=(Pt.x-K)/K,Dt=(Pt.y-pt)/pt,ae=(((W=e.transform)==null?void 0:W.x)??0)+Rt*q*Q,Se=(((Y=e.transform)==null?void 0:Y.y)??0)+Dt*q*Q,Te=(((z=e.transform)==null?void 0:z.rotate_x)??0)-Dt*q*1.5*Q,de=(((J=e.transform)==null?void 0:J.rotate_y)??0)+Rt*q*1.5*Q,we=Math.min(1,10*t);s.x=this.lerp(s.x??((L=e.transform)==null?void 0:L.x)??0,ae,we),s.y=this.lerp(s.y??((x=e.transform)==null?void 0:x.y)??0,Se,we),s.rotate_x=this.lerp(s.rotate_x??((et=e.transform)==null?void 0:et.rotate_x)??0,Te,we),s.rotate_y=this.lerp(s.rotate_y??((V=e.transform)==null?void 0:V.rotate_y)??0,de,we)}else if(n.type===U.Fold){if(f<300){const q=1-f/300,Q=(r>0?-1:1)*q*10,K=1-q*.1,pt=h/300*q*20,Pt=-(r/300)*q*20,Rt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((at=e.transform)==null?void 0:at.skew_x)??0,Q,Rt),s.scale_y=this.lerp(s.scale_y??((F=e.transform)==null?void 0:F.scale_y)??1,(((R=e.transform)==null?void 0:R.scale_y)??1)*K,Rt),s.rotate_x=this.lerp(s.rotate_x??((D=e.transform)==null?void 0:D.rotate_x)??0,pt,Rt),s.rotate_y=this.lerp(s.rotate_y??((H=e.transform)==null?void 0:H.rotate_y)??0,Pt,Rt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((Z=n.settings)==null?void 0:Z.opacity)??.5}}}else if(n.type===U.Crumple){if(f<300){const q=1-f/300,Q=q*(Math.random()-.5)*5,K=q*(Math.random()-.5)*.05,pt=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((ct=e.transform)==null?void 0:ct.skew_x)??0,Q,pt),s.scale_x=this.lerp(s.scale_x??((Ct=e.transform)==null?void 0:Ct.scale_x)??1,(((vt=e.transform)==null?void 0:vt.scale_x)??1)*(1+K),pt),s.scale_y=this.lerp(s.scale_y??((At=e.transform)==null?void 0:At.scale_y)??1,(((It=e.transform)==null?void 0:It.scale_y)??1)*(1+K),pt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((Tt=n.settings)==null?void 0:Tt.intensity)??1,scale:((qt=n.settings)==null?void 0:qt.scale)??2}}}else if(n.type===U.Squash){const q=((ue=n.settings)==null?void 0:ue.strength)||.8;f<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((Qt=e.transform)==null?void 0:Qt.scale_y)??1)*q,.3),s.scale_x=this.lerp(s.scale_x??1,(((tt=e.transform)==null?void 0:tt.scale_x)??1)*(1+(1-q)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((gt=e.transform)==null?void 0:gt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Ft=e.transform)==null?void 0:Ft.scale_x)??1,.2))}else if(n.type===U.TextCounter){const q=((Et=n.settings)==null?void 0:Et.duration)||2,Q=((Mt=n.settings)==null?void 0:Mt.from)||0,K=((Bt=n.settings)==null?void 0:Bt.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const pt=this.currentTime-n._runtimeStart,Pt=Math.min(1,pt/q),Rt=Math.floor(Q+(K-Q)*Pt);if(((Ht=e.geometry)==null?void 0:Ht.type)==="Text"){const Dt=((_t=n.settings)==null?void 0:_t.prefix)||"",ae=((zt=n.settings)==null?void 0:zt.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Dt}${Rt}${ae}`}}else if(n.type===U.Spotlight){const q=((Zt=n.settings)==null?void 0:Zt.radius)||250,Q=((le=n.settings)==null?void 0:le.strength)||1.5;if(f<q){const K=Math.pow(1-f/q,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(ce=e.style)==null?void 0:ce.adjustments}),s.style.adjustments.exposure=(((oe=(Me=e.style)==null?void 0:Me.adjustments)==null?void 0:oe.exposure)||0)+K*Q*50}else(Ce=s.style)!=null&&Ce.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((he=(fe=e.style)==null?void 0:fe.adjustments)==null?void 0:he.exposure)||0,.1))}else if(n.type===U.Noise||n.type===U.Float){const q=(((it=n.settings)==null?void 0:it.frequency)||((ut=n.settings)==null?void 0:ut.speed)||1)*.002,Q=(((st=n.settings)==null?void 0:st.amplitude)||((G=n.settings)==null?void 0:G.range)||50)*(((nt=n.settings)==null?void 0:nt.strength)||1),K=Date.now();s.x+=Math.sin(K*q)*Q*t,s.y+=Math.cos(K*q*.8)*Q*t,s.rotation+=Math.sin(K*q*.5)*5*t}else if(n.type===U.Pulse){const q=(((lt=n.settings)==null?void 0:lt.speed)||1)*.005,Q=(((mt=n.settings)==null?void 0:mt.scale)||1.2)-1,K=Math.sin(Date.now()*q),pt=((Ot=n.settings)==null?void 0:Ot.strength)||1;s.scale_x*=1+K*Q*pt*t,s.scale_y*=1+K*Q*pt*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,K)*.1*pt*t)}else if(n.type===U.Draggable){const q=((ht=n.settings)==null?void 0:ht.radius)||150,Q=this.draggingBehaviors.has(e.id);if(f<q||Q){const K=((xt=n.settings)==null?void 0:xt.strength)||1,pt=Q?1:Math.max(0,1-f/q);this.applyBehaviorSensor(s,ne.PositionX,pt*K,t,n.settings),this.applyBehaviorSensor(s,ne.PositionY,pt*K,t,n.settings)}}else if(n.type===U.Scroll){const q=((bt=n.settings)==null?void 0:bt.axis)||"vertical",Q=(($t=n.settings)==null?void 0:$t.factor)||.5,K=(($=n.settings)==null?void 0:$.strength)||1,pt=((Xt=n.settings)==null?void 0:Xt.scaleFactor)||0;(q==="vertical"||q==="both")&&(s.y+=this.scrollOffset.y*Q*K*t),(q==="horizontal"||q==="both")&&(s.x+=this.scrollOffset.x*Q*K*t),pt!==0&&(s.scale_x*=1+this.scrollOffset.y*pt*t,s.scale_y*=1+this.scrollOffset.y*pt*t)}else if(n.type===U.LookAt){const q=((Wt=n.settings)==null?void 0:Wt.factor)||1,Q=((jt=n.settings)==null?void 0:jt.strength)||1,K=Math.atan2(-h,-r)*(180/Math.PI),pt=s.rotation,Pt=(K-pt+180)%360-180;s.rotation+=Pt*q*Q*t*10}else if(n.type===U.Scan){const q=(((Gt=n.settings)==null?void 0:Gt.speed)||1)*.004,Q=((Nt=n.settings)==null?void 0:Nt.strength)||1,K=(Math.sin(Date.now()*q)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+K*Q*t*5),s.x+=(K-.5)*20*Q*t}else if(n.type===U.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((se=n.settings)==null?void 0:se.strength)??.8};else if(n.type===U.Ratchet){const q=((te=n.settings)==null?void 0:te.steps)||12,Q=(((yt=n.settings)==null?void 0:yt.speed)||1)*30,K=Math.floor(s.rotation/(360/q))*(360/q);s.rotation=this.lerp(s.rotation,K+Q*t,.1)}else if(n.type===U.Jitter&&f<300){const q=((ot=n.settings)==null?void 0:ot.strength)||1,Q=(((N=n.settings)==null?void 0:N.intensity)||5)*q;s.x+=(Math.random()-.5)*Q*t*60,s.y+=(Math.random()-.5)*Q*t*60,s.rotation+=(Math.random()-.5)*Q*t*120}else if(n.type===U.Follower){const q=(ft=n.settings)==null?void 0:ft.targetId;if(q){const Q=this.objectStates.get(q);if(Q){const K=((dt=n.settings)==null?void 0:dt.stiffness)||.1,pt=Q.x-s.x,Pt=Q.y-s.y;s.x+=pt*K*t*60,s.y+=Pt*K*t*60}}}else if(n.type===U.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===U.Gravity){const q=((j=n.settings)==null?void 0:j.strength)||9.8;s.y+=q*t*10}else if(n.type===U.Velocity){const q=((St=n.settings)==null?void 0:St.vx)||0,Q=((wt=n.settings)==null?void 0:wt.vy)||0;s.x+=q*t*10,s.y+=Q*t*10}else if(n.type===U.Shear){const q=((Yt=n.settings)==null?void 0:Yt.strength)||1,Q=((Jt=n.settings)==null?void 0:Jt.radius)||300;if(f<Q){const K=1-f/Q;s.skew_x=this.lerp(s.skew_x||0,(((ee=e.transform)==null?void 0:ee.skew_x)||0)+K*q*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((ke=e.transform)==null?void 0:ke.skew_x)||0,.05)}else if(n.type===U.Lens){const q=((_e=n.settings)==null?void 0:_e.radius)||200,Q=((Pe=n.settings)==null?void 0:Pe.strength)||.5;if(f<q){const K=Math.pow(1-f/q,2);s.scale_x=this.lerp(s.scale_x??1,(((Ee=e.transform)==null?void 0:Ee.scale_x)??1)*(1+K*Q),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ae=e.transform)==null?void 0:Ae.scale_y)??1)*(1+K*Q),.2)}else s.scale_x=this.lerp(s.scale_x??1,((Oe=e.transform)==null?void 0:Oe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,(($e=e.transform)==null?void 0:$e.scale_y)??1,.1)}else if(n.type===U.LayoutAnimation){const q=((Kt=n.settings)==null?void 0:Kt.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Q=((re=n.settings)==null?void 0:re.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id);for(const pt of q){const Pt=this.getObjectProperty(s,e,pt);if(Pt===void 0)continue;const Rt=K.get(pt);if(!Rt)K.set(pt,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Rt.to!==Pt){const ae=this.getObjectProperty(s,e,pt);K.set(pt,{from:ae??Rt.from,to:Pt,startTime:this.currentTime,duration:((ge=n.settings)==null?void 0:ge.duration)??Q})}const Dt=K.get(pt);if(Dt.duration>0&&Dt.from!==Dt.to){const ae=this.currentTime-Dt.startTime,Se=Math.min(1,ae/Dt.duration),Te=this.applyEasing(Se,((Le=n.settings)==null?void 0:Le.easing)||"easeOutCubic"),de=Dt.from+(Dt.to-Dt.from)*Te;this.setObjectProperty(s,e,pt,de)}}}else if(n.type===U.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const q=this._layoutAnimCache.get(e.id),Q=((Re=n.settings)==null?void 0:Re.defaultDuration)||.3,K=["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 pt of K){const Pt=this.getObjectProperty(s,e,pt);if(Pt===void 0||typeof Pt!="number")continue;const Rt=q.get(pt);if(!Rt)q.set(pt,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Rt.to!==Pt){const ae=this.getObjectProperty(s,e,pt);q.set(pt,{from:ae??Rt.from,to:Pt,startTime:this.currentTime,duration:Q})}const Dt=q.get(pt);if(Dt.duration>0&&Dt.from!==Dt.to){const ae=this.currentTime-Dt.startTime,Se=Math.min(1,ae/Dt.duration),Te=this.applyEasing(Se,((be=n.settings)==null?void 0:be.defaultEasing)||"easeOutCubic"),de=Dt.from+(Dt.to-Dt.from)*Te;this.setObjectProperty(s,e,pt,de)}}}else if(n.type===U.SpringChain){const q=((ye=n.settings)==null?void 0:ye.connections)||[],Q=((me=n.settings)==null?void 0:me.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const K=this._springChainState.get(e.id);for(const Pt of q){if(!K.has(Pt.targetId)){const Rt=this.objectStates.get(Pt.targetId);K.set(Pt.targetId,{x:(Rt==null?void 0:Rt.x)??0,y:(Rt==null?void 0:Rt.y)??0,vx:0,vy:0})}K.has(e.id)||K.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const pt=K.get(e.id);if(pt){pt.x=s.x,pt.y=s.y;for(const Pt of q){const Rt=K.get(Pt.targetId);if(!Rt)continue;const Dt=Rt.x-pt.x,ae=Rt.y-pt.y,Se=Math.sqrt(Dt*Dt+ae*ae)||.001,de=(Se-(Pt.restLength||50))*(Pt.stiffness||.8),we=Dt/Se*de,qe=ae/Se*de;pt.vx+=we*t*10,pt.vy+=qe*t*10,Rt.vx-=we*t*10,Rt.vy-=qe*t*10,pt.vx*=1-Q*t*10,pt.vy*=1-Q*t*10,Rt.vx*=1-Q*t*10,Rt.vy*=1-Q*t*10;const ve=this.objectStates.get(Pt.targetId);ve&&(ve.x+=Rt.vx*t,ve.y+=Rt.vy*t)}s.x+=pt.vx*t,s.y+=pt.vy*t}}else if(n.type===U.ParticleEmitter){const q=((Ie=n.settings)==null?void 0:Ie.rate)||10,Q=((Be=n.settings)==null?void 0:Be.speed)||100,K=((Ne=n.settings)==null?void 0:Ne.size)||5,pt=((Ve=n.settings)==null?void 0:Ve.lifetime)||2,Pt=((We=n.settings)==null?void 0:We.gravity)||0,Rt=((He=n.settings)==null?void 0:He.color)||"#ffffff",Dt=((Ue=n.settings)==null?void 0:Ue.maxParticles)||200,ae=(us=n.settings)!=null&&us.rateInputId?this.inputs.get(n.settings.rateInputId)??q:q,Se=(gs=n.settings)!=null&&gs.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Pt:Pt,Te=(ys=n.settings)!=null&&ys.speedInputId?this.inputs.get(n.settings.speedInputId)??Q:Q;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const de=this._emitterPools.get(e.id);let we=0;n._pendingBurst&&n._pendingBurst>0&&(we=n._pendingBurst,n._pendingBurst=0);const qe=Math.floor(ae*t)+(we||0);for(let ve=0;ve<Math.min(qe,Dt-de.length);ve++){const pe=Math.random()*Math.PI*2,ms=Te*(.5+Math.random()*.5);de.push({x:s.x,y:s.y,vx:Math.cos(pe)*ms,vy:Math.sin(pe)*ms,life:0,maxLife:pt*(.5+Math.random()*.5),size:K*(.5+Math.random()),color:Rt,opacity:1})}for(let ve=de.length-1;ve>=0;ve--){const pe=de[ve];pe.vy+=Se*t*10,pe.x+=pe.vx*t,pe.y+=pe.vy*t,pe.life+=t,pe.opacity=Math.max(0,1-pe.life/pe.maxLife),pe.life>=pe.maxLife&&de.splice(ve,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,l=0,r=1){var d,u,b,m,y,S,v,C,w,M,k,I,T,O,P,_,E,A,B,X,W,Y,z,J;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,f=Math.min(1,15*e),p=r>0?a/r:0,c=r>0?l/r:0;switch(i){case ne.Scale:{const L=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,x=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,et=L*(1+o*h*.4),V=x*(1+o*h*.4);t.scale_x=(t.scale_x??L)*(1-f)+et*f,t.scale_y=(t.scale_y??x)*(1-f)+V*f;break}case ne.Opacity:{const L=((b=n==null?void 0:n.transform)==null?void 0:b.opacity)??100,x=Math.max(0,Math.min(100,L-o*h*100));t.opacity=(t.opacity??L)*(1-f)+x*f;break}case ne.RotateZ:{const L=((m=n==null?void 0:n.transform)==null?void 0:m.rotation)??0,x=L+o*h*45;t.rotation=(t.rotation??L)*(1-f)+x*f;break}case ne.RotateX:{const L=((y=n==null?void 0:n.transform)==null?void 0:y.rotate_x)??0,x=L-c*o*h*60;t.rotate_x=(t.rotate_x??L)*(1-f)+x*f;break}case ne.RotateY:{const L=((S=n==null?void 0:n.transform)==null?void 0:S.rotate_y)??0,x=L+p*o*h*60;t.rotate_y=(t.rotate_y??L)*(1-f)+x*f;break}case ne.PositionX:{const L=((v=n==null?void 0:n.transform)==null?void 0:v.x)??0,x=L-p*o*h*40;t.x=(t.x??L)*(1-f)+x*f;break}case ne.PositionY:{const L=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,x=L-c*o*h*40;t.y=(t.y??L)*(1-f)+x*f;break}case ne.SkewX:{const L=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,x=L+p*o*h*45;t.skew_x=(t.skew_x??L)*(1-f)+x*f,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case ne.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const L=((I=(k=n==null?void 0:n.style)==null?void 0:k.blur)==null?void 0:I.amount)||0,x=L+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??L)*(1-f)+x*f;break}case ne.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 L=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,x=L+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??L)*(1-f)+x*f;break}case ne.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 L=((A=(E=n==null?void 0:n.style)==null?void 0:E.adjustments)==null?void 0:A.hue)||0,x=L+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??L)*(1-f)+x*f;break}case ne.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(B=n==null?void 0:n.style)==null?void 0:B.adjustments});const L=((W=(X=n==null?void 0:n.style)==null?void 0:X.adjustments)==null?void 0:W.negative)||0,x=L+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??L)*(1-f)+x*f;break}case ne.CornerRadius:{const L=((Y=n==null?void 0:n.transform)==null?void 0:Y.corner_radius)||0,x=L+o*h*50;t.corner_radius=(t.corner_radius??L)*(1-f)+x*f;break}case ne.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const L=((z=n==null?void 0:n.style)==null?void 0:z.borderWidth)||0,x=L+o*h*10;t.style.borderWidth=(t.style.borderWidth??L)*(1-f)+x*f;break}case ne.LetterSpacing:{t.geometry||(t.geometry={});const L=((J=n==null?void 0:n.geometry)==null?void 0:J.letterSpacing)||0,x=L+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??L)*(1-f)+x*f;break}}}getObjectProperty(t,i,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(let l=0;l<s.length-1;l++){const r=s[l];if(n[r]===void 0||n[r]===null){const h=i,f=s.slice(0,l+1).reduce((d,u)=>d==null?void 0:d[u],h),p=s[l+1],c=!isNaN(Number(p));n[r]=f!==void 0?Array.isArray(f)?[...f]:{...f}:c?[]:{}}n=n[r]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){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,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;if(Array.isArray(i)){if(!Array.isArray(t))return i;const e=[...t];for(let s=0;s<i.length;s++)i[s]&&typeof i[s]=="object"&&!Array.isArray(i[s])&&t[s]&&typeof t[s]=="object"?e[s]=this.deepMerge(t[s],i[s]):e[s]=i[s];return e}const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const l=i.naturalWidth,r=i.naturalHeight,h=l/r,f=s/n;let p=s,c=n,d=o,u=e;a==="cover"?h>f?(p=n*h,d=o-(p-s)/2):(c=s/h,u=e-(c-n)/2):a==="contain"&&(h>f?(c=s/h,u=e+(n-c)/2):(p=n*h,d=o+(s-p)/2)),t.drawImage(i,d,u,p,c)}}const ni=Lt.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:l,onComponentChange:r,onToggle:h,onInputChange:f,onInputFocus:p,onInputBlur:c,onLog:d,onLogicUpdate:u,onButtonClick:b,onGraphPointClick:m,currentTime:y,revision:S=0,scrollY:v,scrollX:C,mouseX:w,mouseY:M,isMouseDown:k,inputs:I,interactive:T=!0,onNavigation:O},P)=>{const _=Lt.useRef(null),E=Lt.useRef(null);E.current||(E.current=new ps);const A=Lt.useRef(void 0),B=Lt.useRef(0),X=Lt.useRef(null),W=Lt.useRef(S),Y=Lt.useRef(null),[,z]=Lt.useState(g||null),J=Lt.useRef(!0);Lt.useImperativeHandle(P,()=>_.current),Lt.useEffect(()=>(J.current=!0,()=>{J.current=!1,A.current&&cancelAnimationFrame(A.current)}),[]),Lt.useEffect(()=>{E.current.setLayout(e,s)},[e,s]),Lt.useEffect(()=>{const F=E.current;a&&F.setTriggerCallback(a),l&&F.setInputUpdateCallback((R,D)=>l({[R]:D})),r&&F.setComponentChangeCallback(R=>r(R)),h&&F.setToggleCallback(h),f&&F.setInputChangeCallback(f),p&&F.setInputFocusCallback(p),c&&F.setInputBlurCallback(c),d&&F.setOnLogCallback(R=>d(R,"info")),u&&F.setLogicUpdateCallback(u),b&&F.setButtonClickCallback(b),m&&F.setGraphPointClickCallback(R=>m(R.objectId,R)),O&&F.setNavigationCallback(O)},[a,l,r,h,f,p,c,d,u,b,m,O]),Lt.useEffect(()=>{(async()=>{let R=g;if(t&&!g)try{t.startsWith("{")?R=JSON.parse(t):R=await(await fetch(t)).json()}catch(D){console.error("[ExodeUI] Failed to load src:",D)}if(R){const D=E.current,H=R.id||R.name||"default";(X.current!==H||W.current!==S||Y.current!==R)&&(D.load(R),X.current=H,W.current=S,Y.current=R,z(R),B.current=0,D.advance(0)),n&&n(D)}})()},[g,t,S]),Lt.useEffect(()=>{const F=R=>{if(!E.current||!J.current)return;const D=E.current,H=_.current;if(!H)return;const Z=H.getContext("2d");if(!Z)return;const ct=R/1e3;B.current===0&&(B.current=ct);let Ct=ct-B.current;Ct>.1&&(Ct=.1),B.current=ct;const vt=H.getBoundingClientRect(),At=window.devicePixelRatio||1,It=Math.round(vt.width*At),Tt=Math.round(vt.height*At);(H.width!==It||H.height!==Tt)&&(H.width=It,H.height=Tt);try{o?D.advance(Ct):y!==void 0&&D.seek(y),D.render(Z,H.width,H.height)}catch(qt){console.error("[ExodeUICanvas] Error in animation loop:",qt),d&&d(`[Error] Animation loop crashed: ${qt}`,"error")}A.current=requestAnimationFrame(F)};return A.current=requestAnimationFrame(F),()=>{A.current&&cancelAnimationFrame(A.current)}},[o,y]),Lt.useEffect(()=>{const F=E.current;v!==void 0&&F.updateInput("scrollY",v),C!==void 0&&F.updateInput("scrollX",C),w!==void 0&&F.updateInput("mouseX",w),M!==void 0&&F.updateInput("mouseY",M),k!==void 0&&F.updateInput("isMouseDown",k),I&&Object.entries(I).forEach(([R,D])=>F.updateInput(R,D))},[v,C,w,M,k,I]);const L=(F,R)=>{if(!T||!_.current)return;F.stopPropagation(),"nativeEvent"in F&&F.nativeEvent&&typeof F.nativeEvent.stopImmediatePropagation=="function"?F.nativeEvent.stopImmediatePropagation():typeof F.stopImmediatePropagation=="function"&&F.stopImmediatePropagation();const D=_.current,H=D.getBoundingClientRect(),Z=F.clientX-H.left,ct=F.clientY-H.top,Ct=window.devicePixelRatio||1;(R==="click"||R==="down"||R==="up")&&d&&d(`[Canvas] Pointer ${R} at rect(${Math.round(Z)},${Math.round(ct)}) mapped to buffer(${Math.round(Z*Ct)},${Math.round(ct*Ct)})`,"info"),E.current.handlePointerInput(R,Z*Ct,ct*Ct,D.width,D.height)};Lt.useEffect(()=>{if(!T)return;const F=D=>{var H,Z,ct;((H=document.activeElement)==null?void 0:H.tagName)==="INPUT"||((Z=document.activeElement)==null?void 0:Z.tagName)==="TEXTAREA"||(ct=E.current)==null||ct.handleKeyDown(D)},R=D=>{var H,Z,ct;((H=document.activeElement)==null?void 0:H.tagName)==="INPUT"||((Z=document.activeElement)==null?void 0:Z.tagName)==="TEXTAREA"||(ct=E.current)==null||ct.handleKeyUp(D)};return window.addEventListener("keydown",F),window.addEventListener("keyup",R),()=>{window.removeEventListener("keydown",F),window.removeEventListener("keyup",R)}},[T]);const[x,et]=Lt.useState([]);Lt.useEffect(()=>{if(g&&g.objects){const F=g.objects.filter(R=>{var D,H;return R.type==="Joystick"&&((D=R.inputBinding)==null?void 0:D.type)==="keyboard"&&((H=R.inputBinding.keyboardConfig)==null?void 0:H.showVirtualKeyboard)});et(F)}},[g]);const[,V]=Lt.useState(0);Lt.useEffect(()=>{if(x.length===0)return;let F;const R=()=>{V(D=>D+1),F=requestAnimationFrame(R)};return F=requestAnimationFrame(R),()=>cancelAnimationFrame(F)},[x.length]);const at=()=>x.map(F=>{const R=F.inputBinding.keyboardConfig,D=vt=>{var It;const At={key:vt,code:vt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyDown(At)},H=vt=>{var It;const At={key:vt,code:vt,preventDefault:()=>{}};(It=E.current)==null||It.handleKeyUp(At)},Z=E.current,ct=vt=>Z&&Z.activeKeys?Z.activeKeys.has(vt.toLowerCase()):!1,Ct=vt=>({width:"50px",height:"50px",background:vt?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:vt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Vt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Vt.jsx("div",{style:Ct(ct(R.upKey)),onMouseDown:()=>D(R.upKey),onMouseUp:()=>H(R.upKey),onMouseLeave:()=>H(R.upKey),onTouchStart:vt=>{vt.preventDefault(),D(R.upKey)},onTouchEnd:vt=>{vt.preventDefault(),H(R.upKey)},children:R.upKey.toUpperCase()}),Vt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Vt.jsx("div",{style:Ct(ct(R.leftKey)),onMouseDown:()=>D(R.leftKey),onMouseUp:()=>H(R.leftKey),onMouseLeave:()=>H(R.leftKey),onTouchStart:vt=>{vt.preventDefault(),D(R.leftKey)},onTouchEnd:vt=>{vt.preventDefault(),H(R.leftKey)},children:R.leftKey.toUpperCase()}),Vt.jsx("div",{style:Ct(ct(R.downKey)),onMouseDown:()=>D(R.downKey),onMouseUp:()=>H(R.downKey),onMouseLeave:()=>H(R.downKey),onTouchStart:vt=>{vt.preventDefault(),D(R.downKey)},onTouchEnd:vt=>{vt.preventDefault(),H(R.downKey)},children:R.downKey.toUpperCase()}),Vt.jsx("div",{style:Ct(ct(R.rightKey)),onMouseDown:()=>D(R.rightKey),onMouseUp:()=>H(R.rightKey),onMouseLeave:()=>H(R.rightKey),onTouchStart:vt=>{vt.preventDefault(),D(R.rightKey)},onTouchEnd:vt=>{vt.preventDefault(),H(R.rightKey)},children:R.rightKey.toUpperCase()})]})]},F.id)});return Vt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Vt.jsx("canvas",{ref:_,onPointerDown:F=>{var R;L(F,"down"),(R=_.current)==null||R.focus()},onPointerMove:F=>L(F,"move"),onPointerUp:F=>L(F,"up"),onPointerCancel:F=>L(F,"up"),onClick:F=>L(F,"click"),onWheel:F=>{E.current.handleWheel(F.deltaX,F.deltaY)},onKeyDown:F=>E.current.handleKeyDown(F.nativeEvent),onKeyUp:F=>E.current.handleKeyUp(F.nativeEvent),onContextMenu:F=>F.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),at()]})});function oi(){const[g,t]=Lt.useState(null),i=Lt.useCallback((f,p)=>{g==null||g.setInputBool(f,p)},[g]),o=Lt.useCallback((f,p)=>{g==null||g.setInputNumber(f,p)},[g]),e=Lt.useCallback(f=>{g==null||g.fireTrigger(f)},[g]),s=Lt.useCallback((f,p)=>{g==null||g.setInputText(f,p)},[g]),n=Lt.useCallback((f,p)=>{g==null||g.setInputNumberArray(f,p)},[g]),a=Lt.useCallback((f,p)=>{g==null||g.setInputStringArray(f,p)},[g]),l=Lt.useCallback((f,p)=>{g==null||g.updateObjectOptions(f,p)},[g]),r=Lt.useCallback((f,p,c)=>{g==null||g.updateConstraint(f,p,c)},[g]),h=Lt.useCallback((f,p)=>{g==null||g.updateGraphData(f,p)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:r,updateGraphData:h,updateObjectOptions:l}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;Lt.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let l=i.description;if(!l&&o){const f=g.objects.filter(p=>{var c;return((c=p.geometry)==null?void 0:c.type)==="Text"}).sort((p,c)=>{var d,u;return(((d=c.geometry.text)==null?void 0:d.length)||0)-(((u=p.geometry.text)==null?void 0:u.length)||0)});f.length>0&&(l=f[0].geometry.text)}l&&(e("name","description",l),e("property","og:description",l)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const r=i.ogImage||g.backgroundImage;r&&e("property","og:image",r),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,l,r)=>{let h=document.querySelector(`meta[${a}="${l}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,l),document.head.appendChild(h)),h.setAttribute("content",r)},s=()=>{const a=[];return a.push(Vt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((r,h)=>{var f,p;if(!(r.visible===!1||r.isVisible===!1))if(((f=r.geometry)==null?void 0:f.type)==="Text"){const c=r.geometry.text;c&&(r.geometry.fontSize>24?a.push(Vt.jsx("h2",{children:c},r.id||h)):a.push(Vt.jsx("p",{children:c},r.id||h)))}else if(((p=r.geometry)==null?void 0:p.type)==="Image"){const c=r.geometry.src,d=r.altText||r.name||"Illustration";a.push(Vt.jsx("img",{src:c,alt:d},r.id||h))}else r.type==="Button"&&a.push(Vt.jsx("button",{children:r.name||"Button"},r.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Vt.jsxs("div",{id:`exode-seo-${g.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:[s(),Vt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.45"}.version;Ut.BehaviorSensor=ne,Ut.BehaviorType=U,Ut.ConditionOp=Je,Ut.ExodeSEO=ai,Ut.ExodeUICanvas=ni,Ut.ExodeUIEngine=ps,Ut.LogicOp=kt,Ut.RapierPhysics=ts,Ut.VERSION=ri,Ut.useExodeUI=oi,Object.defineProperty(Ut,Symbol.toStringTag,{value:"Module"})}));
|