exodeui 6.3.26 → 6.3.27

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.
Files changed (3) hide show
  1. package/dist/index.js +20 -20
  2. package/dist/index.mjs +1323 -1330
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,34 +1,34 @@
1
- (function(Ht,se){typeof exports=="object"&&typeof module<"u"?se(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"],se):(Ht=typeof globalThis<"u"?globalThis:Ht||self,se(Ht.ExodeUIReact={},Ht.jsxRuntime,Ht.React,Ht.pretext,Ht.Rapier,Ht.LZString))})(this,(function(Ht,se,$t,xe,ne,bs){"use strict";var fi=Object.defineProperty;var hi=(Ht,se,$t)=>se in Ht?fi(Ht,se,{enumerable:!0,configurable:!0,writable:!0,value:$t}):Ht[se]=$t;var j=(Ht,se,$t)=>hi(Ht,typeof se!="symbol"?se+"":se,$t);function vs(p){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const i in p)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(p,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>p[i]})}}return t.default=p,Object.freeze(t)}const Cs=vs(bs);var z=(p=>(p.Proximity="Proximity",p.Magnetic="Magnetic",p.Repel="Repel",p.Orbit="Orbit",p.Vortex="Vortex",p.Fluid="Fluid",p.Elastic="Elastic",p.Holographic="Holographic",p.Sticky="Sticky",p.Dilation="Dilation",p.Parallax="Parallax",p.Noise="Noise",p.Float="Float",p.Pulse="Pulse",p.Draggable="Draggable",p.Scroll="Scroll",p.LookAt="LookAt",p.Glint="Glint",p.Scan="Scan",p.Ratchet="Ratchet",p.Jitter="Jitter",p.Follower="Follower",p.Wrap="Wrap",p.Typewriter="Typewriter",p.Scramble="Scramble",p.Wave="Wave",p.Bounce="Bounce",p.TextTrail="TextTrail",p.Reveal3D="Reveal3D",p.RevealSlide="RevealSlide",p.RevealBlur="RevealBlur",p.TextLiquid="TextLiquid",p.TextVortex="TextVortex",p.TextExplosion="TextExplosion",p.TextRain="TextRain",p.TextGravity="TextGravity",p.TextMatrix="TextMatrix",p.TextNeon="TextNeon",p.TextDissolve="TextDissolve",p.TextOrganic="TextOrganic",p.TextBreathe="TextBreathe",p.TextSpin="TextSpin",p.TextMagnet="TextMagnet",p.TextPerspective="TextPerspective",p.TextMirror="TextMirror",p.TextFloral="TextFloral",p.TextSmoke="TextSmoke",p.TextVariable="TextVariable",p.TextZing="TextZing",p.TextElastic="TextElastic",p.TextGlitch3D="TextGlitch3D",p.GlitchText="GlitchText",p.TextCounter="TextCounter",p.Squash="Squash",p.Spotlight="Spotlight",p.Lens="Lens",p.Gravity="Gravity",p.Velocity="Velocity",p.Shear="Shear",p.LayoutAnimation="LayoutAnimation",p.SpringChain="SpringChain",p.ParticleEmitter="ParticleEmitter",p.StateReactive="StateReactive",p.Fold="Fold",p.Crumple="Crumple",p.GraphPathDraw="GraphPathDraw",p.GraphWipeReveal="GraphWipeReveal",p.GraphPointPop="GraphPointPop",p.GraphGradientFlow="GraphGradientFlow",p))(z||{}),oe=(p=>(p.Scale="Scale",p.Opacity="Opacity",p.RotateZ="RotateZ",p.RotateX="RotateX",p.RotateY="RotateY",p.PositionX="PositionX",p.PositionY="PositionY",p.SkewX="SkewX",p.Blur="Blur",p.Exposure="Exposure",p.HueShift="HueShift",p.Negative="Negative",p.CornerRadius="CornerRadius",p.StrokeWidth="StrokeWidth",p.BoxShadow="BoxShadow",p.FontSize="FontSize",p.LetterSpacing="LetterSpacing",p))(oe||{}),Xe=(p=>(p.Equal="Equal",p.NotEqual="NotEqual",p.GreaterThan="GreaterThan",p.LessThan="LessThan",p.GreaterEqual="GreaterEqual",p.LessEqual="LessEqual",p.IsTrue="IsTrue",p.IsFalse="IsFalse",p))(Xe||{}),wt=(p=>(p.AND="AND",p.OR="OR",p.NOT="NOT",p.XOR="XOR",p.OBJECT="OBJECT",p.PROPERTY="PROPERTY",p.GET_PROPERTY="GET_PROPERTY",p.SET_PROPERTY="SET_PROPERTY",p.ADD="ADD",p.SUB="SUB",p.MUL="MUL",p.DIV="DIV",p.MOD="MOD",p.POW="POW",p.ABS="ABS",p.ROUND="ROUND",p.FLOOR="FLOOR",p.CEIL="CEIL",p.SIN="SIN",p.COS="COS",p.TAN="TAN",p.CLAMP="CLAMP",p.REMAP="REMAP",p.EQ="EQ",p.NEQ="NEQ",p.GT="GT",p.LT="LT",p.GTE="GTE",p.LTE="LTE",p.IF_ELSE="IF_ELSE",p.VALUE="VALUE",p.INPUT="INPUT",p.LOG="LOG",p.SCROLL_X="SCROLL_X",p.SCROLL_Y="SCROLL_Y",p.MOUSE_X="MOUSE_X",p.MOUSE_Y="MOUSE_Y",p.IS_MOUSE_DOWN="IS_MOUSE_DOWN",p.EFFECTOR="EFFECTOR",p.MONITOR="MONITOR",p.DELAY="DELAY",p.SPRING_PULL="SPRING_PULL",p.SPRING_SETTLE="SPRING_SETTLE",p.EMIT="EMIT",p))(wt||{});function Ss(p){if(p.length<5)return p;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(p))return p;let o="";for(let e=0;e<p.length;e++){if(o+=p[e],e>=p.length-2)continue;const s=t.has(p[e]),n=t.has(p[e+1]),a=t.has(p[e+2]);s&&!n&&a&&(o+="­"),s&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(p){return p.replace(/\b([a-zA-Z]{4,})\b/g,(t,i)=>Ss(i))}function Ms(p,t,i){return p}function Is(p,t,i){return p}const ke=new Map;function De(p){var I;const{text:t,fontFamily:i="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:s="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:h=0,paragraphIndent:f=0,textCase:c="none",segments:g=[],enableSegments:d=!1}=p;let l=String(t||"");c==="uppercase"?l=l.toUpperCase():c==="lowercase"?l=l.toLowerCase():c==="capitalize"&&(l=l.replace(/\b\w/g,_=>_.toUpperCase())),p.hyphenation===!0&&(l=ws(l));const u=`${s} ${e} ${o}px "${i}", sans-serif`,y=`${l}|${u}|${r}|${h}|${f}|${d}|${JSON.stringify(g)}|hyp:${!!p.hyphenation}|comp:${p.composer}|bal:${!!p.balanceRaggedLines}`;let m=ke.get(y);const b=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,v=function(_){if(!b)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const E=b.call(this,_);return r!==0&&_&&_.length>0?{...E,width:E.width+(_.length-1)*r}:E};if(!m){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=v),d&&g&&g.length>0){const _=g.map(E=>{let F=E.text||"";const T=E.textCase||c||"none";return T==="uppercase"?F.toUpperCase():T==="lowercase"?F.toLowerCase():T==="capitalize"?F.replace(/\b\w/g,P=>P.toUpperCase()):F}).join("");if(m=xe.prepareWithSegments(_,u),m){let E=0,F=o;for(const T of g){let P=T.text||"";if(!P)continue;const L=T.textCase||c||"none";L==="uppercase"?P=P.toUpperCase():L==="lowercase"?P=P.toLowerCase():L==="capitalize"&&(P=P.replace(/\b\w/g,A=>A.toUpperCase()));const O=T.fontSize||o;O>F&&(F=O);const W=`${T.fontStyle||s} ${T.fontWeight||e} ${O}px "${T.fontFamily||i}", sans-serif`,B=xe.prepareWithSegments(P,W);if(B&&B.widths)for(let A=0;A<B.widths.length;A++){const $=E+A;if($<m.widths.length){m.widths[$]=B.widths[A];const G=B.kinds[A];if(G===2){const N=P[A];N===`
2
- `||N==="\r"?m.kinds[$]=2:m.kinds[$]=0}else m.kinds[$]=G}}E+=P.length}m.fullText=_,m.maxFontSize=F}}else m=xe.prepareWithSegments(l,u);m&&ke.set(y,m)}catch(_){return console.error("[ExodeUI] Pretext prepare failed:",_),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}if(ke.size>500){const _=ke.keys().next().value;_&&ke.delete(_)}}if(f>0&&m&&m.widths&&!m.indentApplied){const _=[...m.widths],E=m.fullText||l;let F=!0;for(let T=0;T<E.length;T++)F&&_[T]!==void 0&&(_[T]+=f,F=!1),(E[T]===`
3
- `||E[T]==="\r")&&(F=!0,E[T]==="\r"&&E[T+1]===`
4
- `&&T++);m={...m,widths:_,indentApplied:!0}}if(!m)return{width:a,height:0,lineCount:0,lines:[]};let C=n;typeof C=="string"&&(C=parseFloat(C)),C>5&&o>0&&(C=C/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=v);let S;try{const _=m.maxFontSize||o;if(a>=1e5){const E=l.split(/\r\n|\r|\n/);S={lines:E.map(F=>({text:F,width:0})),height:E.length*(C*_),lineCount:E.length}}else S=xe.layoutWithLines(m,a,C*_)}finally{r!==0&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}let M=(S==null?void 0:S.height)!==void 0&&S.height>0?S.height:(((I=S==null?void 0:S.lines)==null?void 0:I.length)||0)*C*o;if(h>0&&S&&S.lines&&S.lines.length>1){let _=0;const E=m.fullText||t;for(let F=0;F<S.lines.length-1;F++)_+=S.lines[F].text.length,(E[_]===`
5
- `||E[_]==="\r")&&(M+=h,_++,E[_-1]==="\r"&&E[_]===`
6
- `&&_++)}let w=(S==null?void 0:S.lines)||[];return p.composer==="every-line"&&w.length>1&&(w=Ms(w)),p.balanceRaggedLines===!0&&w.length>1&&(w=Is(w)),{width:a,height:M,lineCount:w.length,lines:w}}function ze(p,t,i){let o=String(p||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((r,h)=>{if(r.endsWith("px")){const f=parseFloat(r);s[h]=f,n-=f}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(s[h]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((h,f)=>{h.endsWith("fr")&&(s[f]=r*parseFloat(h))})}return s}function Ve(p,t,i){try{const o=p.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(p,t,i):ks(p,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(p,t,i){var P,L;const o=p.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:r}=o,h=e==="vertical",f=t.map(O=>{const W=i(O.id),B=O.geometry;let A=(W==null?void 0:W.width)??B.width??100,$=(W==null?void 0:W.height)??B.height??100;if(B.type==="Ellipse"||B.type==="Polygon"||B.type==="Star"){const G=(W==null?void 0:W.radius)??B.radius??(W==null?void 0:W.outer_radius)??B.outer_radius??50;A=G*2,$=G*2}else if(B.type==="Text"){const G=De({text:(W==null?void 0:W.text)??B.text??"",fontFamily:B.fontFamily,fontSize:B.fontSize,fontWeight:B.fontWeight,fontStyle:B.fontStyle,lineHeight:B.lineHeight,width:B.width||200,letterSpacing:B.letterSpacing,paragraphSpacing:B.paragraphSpacing,paragraphIndent:B.paragraphIndent,textCase:B.textCase,segments:B.segments,enableSegments:B.enableSegments});$=G.height,B.width||(A=G.width)}return A*=O.transform.scale_x||1,$*=O.transform.scale_y||1,{id:O.id,w:A,h:$,original:O}});let c=p.width,g=p.height;const d=((P=p.layoutProps)==null?void 0:P.width)==="hug",l=((L=p.layoutProps)==null?void 0:L.height)==="hug",u=[];let y=[],m=0,b=0;const v=c-n.left-n.right,C=g-n.top-n.bottom;f.forEach(O=>{r&&y.length>0&&(h?b+s+O.h>C:m+s+O.w>v)?(u.push({children:y,width:m,height:b}),y=[O],m=O.w,b=O.h):(y.push(O),h?(m=Math.max(m,O.w),b+=(y.length>1?s:0)+O.h):(m+=(y.length>1?s:0)+O.w,b=Math.max(b,O.h)))}),y.length>0&&u.push({children:y,width:m,height:b}),d&&!h&&(c=Math.max(...u.map(O=>O.width),0)+n.left+n.right),l&&h&&(g=Math.max(...u.map(O=>O.height),0)+n.top+n.bottom);const S=[];let M=n.left,w=n.top;const I=a.toLowerCase(),_=I==="center"||I.endsWith("-center"),E=I.endsWith("-right"),F=I==="center"||I.startsWith("center-"),T=I.startsWith("bottom-");return u.forEach(O=>{let W=M,B=w;h?F?B=n.top+(g-n.top-n.bottom-O.height)/2:T&&(B=g-n.bottom-O.height):_?W=n.left+(c-n.left-n.right-O.width)/2:E&&(W=c-n.right-O.width),O.children.forEach(A=>{var k,Y;let $=W,G=B;h?_?$+=(O.width-A.w)/2:E&&($+=O.width-A.w):F?G+=(O.height-A.h)/2:T&&(G+=O.height-A.h);const N=((k=A.original.layoutProps)==null?void 0:k.width)==="fill",x=((Y=A.original.layoutProps)==null?void 0:Y.height)==="fill";S.push({id:A.id,x:$+A.w/2-c/2,y:G+A.h/2-g/2,width:N&&h?O.width:void 0,height:x?h?void 0:O.height:void 0}),h?B+=A.h+s:W+=A.w+s}),h?M+=O.width+s:w+=O.height+s}),{frameWidth:d?c:void 0,frameHeight:l?g:void 0,childUpdates:S}}function Ts(p,t,i){const o=p.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:r,align:h}=o;let f=p.width,c=p.height;const g=f-r.left-r.right,d=c-r.top-r.bottom,l=ze(e||"1fr",g,n),u=ze(s||"auto",d,a),y=l.length>0?l.reduce((E,F)=>E+F,0)+(l.length-1)*n:0,m=u.length>0?u.reduce((E,F)=>E+F,0)+(u.length-1)*a:0,b=h.toLowerCase(),v=b==="center"||b.endsWith("-center"),C=b.endsWith("-right"),S=b==="center"||b.startsWith("center-"),M=b.startsWith("bottom-");let w=0,I=0;v?w=(g-y)/2:C&&(w=g-y),S?I=(d-m)/2:M&&(I=d-m);const _=[];return t.forEach((E,F)=>{var Y,X;const T=F%l.length||0,P=Math.floor(F/l.length)||0;P>=u.length&&u.push(100);const L=l[T],O=u[P];let W=r.left+w+l.slice(0,T).reduce((J,tt)=>J+tt+n,0),B=r.top+I+u.slice(0,P).reduce((J,tt)=>J+tt+a,0);const A=i(E.id),$=E.geometry;let G=(A==null?void 0:A.width)??$.width??100,N=(A==null?void 0:A.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const J=(A==null?void 0:A.radius)??$.radius??(A==null?void 0:A.outer_radius)??$.outer_radius??50;G=J*2,N=J*2}G*=E.transform.scale_x||1,N*=E.transform.scale_y||1;let x=W,k=B;v?x+=(L-G)/2:C&&(x+=L-G),S?k+=(O-N)/2:M&&(k+=O-N),_.push({id:E.id,x:x+G/2-f/2,y:k+N/2-c/2,width:((Y=E.layoutProps)==null?void 0:Y.width)==="fill"?L:void 0,height:((X=E.layoutProps)==null?void 0:X.height)==="fill"?O:void 0})}),{childUpdates:_}}class Ne{constructor(){j(this,"world",null);j(this,"bodies",new Map);j(this,"colliders",new Map);j(this,"joints",new Map);j(this,"initialized",!1);j(this,"bodyIdByCollider",new Map);j(this,"onCollisionCB",null);j(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await ne.init(),this.world=new ne.World(new ne.Vector2(t.x*100,t.y*100)),this.eventQueue=new ne.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 ne.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?ne.RigidBodyDesc.fixed():ne.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=ne.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=ne.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=ne.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=ne.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 ne.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 ne.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 ne.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new ne.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 ne.Vector2(t.anchorA.x,t.anchorA.y),s=new ne.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,h=t.damping??10;n=ne.JointData.spring(a,r,h,e,s)}else n=ne.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 He=p=>p,_s=p=>p>0?1:0,Ps=p=>p<1?0:1,Ue=p=>p*p,qe=p=>p*(2-p),Je=p=>p<.5?2*p*p:-1+(4-2*p)*p,Es=p=>p*p*p,xs=p=>--p*p*p+1,As=p=>p<.5?4*p*p*p:(p-1)*(2*p-2)*(2*p-2)+1,Os=p=>p*p*p*p,Ls=p=>1- --p*p*p*p,Rs=p=>p<.5?8*p*p*p*p:1-8*--p*p*p*p,Fs=p=>p*p*p*p*p,$s=p=>1+--p*p*p*p*p,Ws=p=>p<.5?16*p*p*p*p*p:1+16*--p*p*p*p*p,Bs=p=>1-Math.cos(p*Math.PI/2),Ys=p=>Math.sin(p*Math.PI/2),Gs=p=>-(Math.cos(Math.PI*p)-1)/2,Xs=p=>p===0?0:Math.pow(2,10*(p-1)),Ds=p=>p===1?1:1-Math.pow(2,-10*p),zs=p=>p===0?0:p===1?1:p<.5?Math.pow(2,20*p-10)/2:(2-Math.pow(2,-20*p+10))/2,Vs=p=>1-Math.sqrt(1-p*p),Ns=p=>Math.sqrt(1- --p*p),Hs=p=>p<.5?(1-Math.sqrt(1-4*p*p))/2:(Math.sqrt(1-(-2*p+2)*(-2*p+2))+1)/2,Ae=1.70158,Oe=Ae*1.525,Qe=Ae+1,Us=p=>Qe*p*p*p-Ae*p*p,qs=p=>1+Qe*Math.pow(p-1,3)+Ae*Math.pow(p-1,2),Js=p=>p<.5?Math.pow(2*p,2)*((Oe+1)*2*p-Oe)/2:(Math.pow(2*p-2,2)*((Oe+1)*(p*2-2)+Oe)+2)/2,Ke=2*Math.PI/3,Ze=2*Math.PI/4.5,Qs=p=>p===0?0:p===1?1:-Math.pow(2,10*p-10)*Math.sin((p*10-10.75)*Ke),Ks=p=>p===0?0:p===1?1:Math.pow(2,-10*p)*Math.sin((p*10-.75)*Ke)+1,Zs=p=>p===0?0:p===1?1:p<.5?-(Math.pow(2,20*p-10)*Math.sin((20*p-11.125)*Ze))/2:Math.pow(2,-20*p+10)*Math.sin((20*p-11.125)*Ze)/2+1,Le=p=>p<1/2.75?7.5625*p*p:p<2/2.75?7.5625*(p-=1.5/2.75)*p+.75:p<2.5/2.75?7.5625*(p-=2.25/2.75)*p+.9375:7.5625*(p-=2.625/2.75)*p+.984375,js=p=>1-Le(1-p),ti=Le,ei=p=>p<.5?(1-Le(1-2*p))/2:(1+Le(2*p-1))/2,Ge=new Map,Te=(p,t,i,o)=>{const e=`${p},${t},${i},${o}`;if(Ge.has(e))return Ge.get(e);const s=f=>(1-3*i+3*p)*f*f*f+(3*i-6*p)*f*f+3*p*f,n=f=>(1-3*o+3*t)*f*f*f+(3*o-6*t)*f*f+3*t*f,a=f=>3*(1-3*i+3*p)*f*f+2*(3*i-6*p)*f+3*p,r=f=>{let c=f;for(let g=0;g<8;g++){const d=s(c)-f;if(Math.abs(d)<1e-6)return c;const l=a(c);if(Math.abs(l)<1e-6)break;c=c-d/l}return c},h=f=>f===0?0:f===1?1:n(r(f));return Ge.set(e,h),h},je=p=>{const t=p.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return Te(i,o,e,s)},ts={ease:Te(.25,.1,.25,1),"ease-in":Te(.42,0,1,1),"ease-out":Te(0,0,.58,1),"ease-in-out":Te(.42,0,.58,1)},Re={Linear:He,EaseInQuad:Ue,EaseOutQuad:qe,EaseInOutQuad:Je,EaseInCubic:Es,EaseOutCubic:xs,EaseInOutCubic:As,EaseInQuart:Os,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Ws,EaseInSine:Bs,EaseOutSine:Ys,EaseInOutSine:Gs,EaseInExpo:Xs,EaseOutExpo:Ds,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Js,EaseInElastic:Qs,EaseOutElastic:Ks,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:Ue,EaseOut:qe,EaseInOut:Je,StepStart:_s,StepEnd:Ps},si=p=>{const t=p.trim(),i=t.toLowerCase();if(Re[t])return Re[t];const o=Object.keys(Re).find(s=>s.toLowerCase()===i);if(o)return Re[o];const e=Object.keys(es).find(s=>s.toLowerCase()===i);if(e){const s=je(es[e].value);if(s)return s}if(ts[i])return ts[i];if(i.startsWith("cubic-bezier")){const s=je(t);if(s)return s}return He},es={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=(p,t,i,o,e)=>{if(!p||!t||!i)return p;const s=o.scale_x??1,n=o.scale_y??1,a=(r,h,f)=>{let c=0,g=0;const d=o.rotation*Math.PI/180,l=Math.cos(d),u=Math.sin(d),y=r*s*l-h*n*u+o.x,m=r*s*u+h*n*l+o.y;f.forEach(I=>{const _=e(I.boneId);if(!_)return;const E={x:_.x,y:_.y,rotation:_.rotation,scaleX:_.scale_x??1,scaleY:_.scale_y??1},F=i[I.boneId]||[1,0,0,1,0,0],T=y*F[0]+m*F[2]+F[4],P=y*F[1]+m*F[3]+F[5],L=E.rotation*Math.PI/180,O=Math.cos(L),W=Math.sin(L),B=T*E.scaleX*O-P*E.scaleY*W+E.x,A=T*E.scaleX*W+P*E.scaleY*O+E.y;c+=B*I.amount,g+=A*I.amount});const b=[...f].sort((I,_)=>_.amount-I.amount);if(b.length>=2&&b[0].amount>0&&b[1].amount>0){const I=e(b[0].boneId),_=e(b[1].boneId);if(I&&_&&I.length!==void 0&&_.length!==void 0){const E=I.length*(I.scale_y??1),F=I.rotation*Math.PI/180,T=I.x-E*Math.sin(F),P=I.y+E*Math.cos(F),L=_.length*(_.scale_y??1),O=_.rotation*Math.PI/180,W=_.x-L*Math.sin(O),B=_.y+L*Math.cos(O);let A=null,$=null,G=!1;const N=1;if(Math.hypot(I.x-_.x,I.y-_.y)<N||Math.hypot(I.x-W,I.y-B)<N?(A=I.x,$=I.y):(Math.hypot(T-_.x,P-_.y)<N||Math.hypot(T-W,P-B)<N)&&(A=T,$=P,G=!0),A!==null&&$!==null){const x=i[b[0].boneId]||[1,0,0,1,0,0],k=x[0]*x[3]-x[1]*x[2];let Y=0,X=0;if(k!==0){const J=(x[2]*x[5]-x[3]*x[4])/k,tt=(x[1]*x[4]-x[0]*x[5])/k,lt=Math.atan2(-x[1],x[3]);if(!G)Y=J,X=tt;else{const at=-x[2]/k,Et=x[0]/k,xt=Math.hypot(at,Et),bt=I.length*xt;Y=J-bt*Math.sin(lt),X=tt+bt*Math.cos(lt)}const Z=Math.hypot(y-Y,m-X),pt=Math.hypot(c-A,g-$);if(pt>0&&Z>0){const at=Math.max(pt,.01),Et=Math.min(Z/at,3),xt=A+(c-A)*Et,bt=$+(g-$)*Et,Yt=b[0].amount,Wt=b[1].amount,_t=Math.min(Yt,Wt)*2,Nt=1-Math.pow(1-_t,4);c=c*(1-Nt)+xt*Nt,g=g*(1-Nt)+bt*Nt}}}}}const v=o.rotation*Math.PI/180,C=Math.cos(v),S=Math.sin(v),M=c-o.x,w=g-o.y;return{x:(M*C+w*S)/s,y:(-M*S+w*C)/n}};return p.map((r,h)=>{const f=t[h];if(!f||f.length===0)return{...r};const c={...r,...a(r.x,r.y,f)};if(r.in_x!==void 0&&r.in_y!==void 0){const g=a(r.in_x,r.in_y,f);c.in_x=g.x,c.in_y=g.y}if(r.out_x!==void 0&&r.out_y!==void 0){const g=a(r.out_x,r.out_y,f);c.out_x=g.x,c.out_y=g.y}return c})};function ni(p,t,i,o,e){const s=p*i*.01,n=t*i*.01,a=Math.sin(e*12.9898)*43758.5453%(Math.PI*2),r=Math.cos(e*78.233)*43758.5453%(Math.PI*2);return(Math.sin(s+a)*Math.cos(n+r)+.5*Math.sin(s*2.1-r)*Math.cos(n*2.3+a)+.25*Math.sin(s*4.5+a)*Math.cos(n*4.2-r))/1.75*o}function oi(p,t,i,o,e,s,n=0,a=0){const r=[];if(!p)return[];const h=p.type;if(h==="Rectangle"||h==="Image"||h==="Frame"){const l=Math.max(20,Math.floor((t+i)/10)),u=Math.max(2,Math.floor(l*(t/(t+i)))),y=Math.max(2,Math.floor(l*(i/(t+i))));for(let m=0;m<u;m++)r.push({x:-t/2+t/u*m,y:-i/2,nx:0,ny:-1});for(let m=0;m<y;m++)r.push({x:t/2,y:-i/2+i/y*m,nx:1,ny:0});for(let m=0;m<u;m++)r.push({x:t/2-t/u*m,y:i/2,nx:0,ny:1});for(let m=0;m<y;m++)r.push({x:-t/2,y:i/2-i/y*m,nx:-1,ny:0})}else if(h==="Ellipse"){const l=Math.max(60,Math.floor(Math.PI*Math.max(t,i)/5));for(let u=0;u<l;u++){const y=u/l*Math.PI*2,m=Math.cos(y),b=Math.sin(y);r.push({x:m*t/2,y:b*i/2,nx:m,ny:b})}}else if(h==="Triangle"){const l={x:0,y:-i/2},u={x:t/2,y:i/2},y={x:-t/2,y:i/2},m=20;let b=u.x-l.x,v=u.y-l.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<m;w++)r.push({x:l.x+b*(w/m),y:l.y+v*(w/m),nx:S,ny:M});b=y.x-u.x,v=y.y-u.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<m;w++)r.push({x:u.x+b*(w/m),y:u.y+v*(w/m),nx:S,ny:M});b=l.x-y.x,v=l.y-y.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<m;w++)r.push({x:y.x+b*(w/m),y:y.y+v*(w/m),nx:S,ny:M})}else for(let u=0;u<80;u++){const y=u/80*Math.PI*2,m=Math.cos(y),b=Math.sin(y);r.push({x:m*t/2,y:b*i/2,nx:m,ny:b})}const f=n*Math.PI/180,c=Math.cos(f),g=Math.sin(f);return r.map(l=>{const u=ni(l.x,l.y,e,o,s),y=l.nx*(1-a)+c*a,m=l.ny*(1-a)+g*a;let b=Math.hypot(y,m);return b===0&&(b=1),{x:l.x+y/b*u,y:l.y+m/b*u}})}const ss={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}},is={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 ns{constructor(){j(this,"artboard",null);j(this,"objectStates",new Map);j(this,"physicsEngine",null);j(this,"activeStateMachine",null);j(this,"inputs",new Map);j(this,"inputNameMap",new Map);j(this,"layerStates",new Map);j(this,"pretextCache",new Map);j(this,"pointerHistory",[]);j(this,"MAX_HISTORY",200);j(this,"imageCache",new Map);j(this,"lastValidSvgImgMap",new Map);j(this,"maskBuffer",null);j(this,"maskCtx",null);j(this,"lumaBuffer",null);j(this,"lumaCtx",null);j(this,"_noiseTileCanvas",null);j(this,"layout",{fit:"Contain",alignment:"Center"});j(this,"onTrigger");j(this,"onInputUpdate");j(this,"onComponentChange");j(this,"onToggle");j(this,"onInputChange");j(this,"onInputFocus");j(this,"onInputBlur");j(this,"onLog");j(this,"onButtonClick");j(this,"onGraphPointClick");j(this,"justFiredTriggers",new Set);j(this,"rootTransform",null);j(this,"canvasWidth",0);j(this,"canvasHeight",0);j(this,"lastHoveredObjectId",null);j(this,"_lastPointerPos",null);j(this,"_prevPointerPos",null);j(this,"focusedId",null);j(this,"draggingSliderId",null);j(this,"activeDropdownId",null);j(this,"activeObjectId",null);j(this,"draggingListViewId",null);j(this,"scrollOffset",{x:0,y:0});j(this,"_totalScroll",{x:0,y:0});j(this,"draggingBehaviors",new Set);j(this,"isMouseDown",!1);j(this,"_layoutAnimCache",new Map);j(this,"_springChainState",new Map);j(this,"_emitterPools",new Map);j(this,"objectVelocities",new Map);j(this,"currentTime",0);j(this,"frameCount",0);j(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});j(this,"onLogicUpdate");j(this,"logicNodeValues",new Map);j(this,"logicNodeState",new Map);j(this,"pointerDownTimes",new Map);j(this,"activeHoverIds",new Set);j(this,"onNavigation");j(this,"periodicTriggerTimes",new Map);j(this,"wasInView",new Set);j(this,"scrollProgressLastValue",new Map);j(this,"debug_objectsRendered",0);j(this,"debug_objectsTotal",0);j(this,"lastRenderTime",0);j(this,"debugMode",!1);j(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points: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,h=0,f=0,c=0,g;for(;(g=i.exec(t))!==null;){const d=g[1],l=(g[2].match(o)||[]).map(parseFloat),u=d===d.toLowerCase(),y=d.toUpperCase();let m=0;const b=C=>{let S=l[m++];return u&&(S+=C?n:a),S},v=()=>({x:b(!0),y:b(!1)});switch(y){case"M":{const C=v();for(f=n=C.x,c=a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});m<l.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"L":for(;m<l.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"H":for(;m<l.length;)n=b(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;m<l.length;)a=b(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;m<l.length;){const C=v(),S=v(),M=v();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=M.x,a=M.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,h=S.y}break;case"S":for(;m<l.length;){const C={x:2*n-r,y:2*a-h},S=v(),M=v();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=M.x,a=M.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,h=S.y}break;case"Q":for(;m<l.length;){const C=v(),S=v();if(e.length>0){const M=e[e.length-1];M.out_x=M.x+2/3*(C.x-M.x),M.out_y=M.y+2/3*(C.y-M.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,h=C.y}break;case"T":for(;m<l.length;){const C={x:2*n-r,y:2*a-h},S=v();if(e.length>0){const M=e[e.length-1];M.out_x=M.x+2/3*(C.x-M.x),M.out_y=M.y+2/3*(C.y-M.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,h=C.y}break;case"Z":if(s=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const S=[...e].reverse().find(M=>M.moveTo)||e[0];S&&Math.hypot(S.x-C.x,S.y-C.y)<.1&&(S.in_x=C.in_x,S.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=f,a=c;break;default:if(l.length>=2){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}}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(h=>{if(e.has(h.id))return;const f={...h},c=f.childrenObjects||[];e.add(f.id),o.push(f),s(c)})};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(h=>{r.set(h.id,h),h.children||(h.children=[])}),this.artboard.objects.forEach(h=>{if(h.parentId){const f=r.get(h.parentId);f&&(f.children||(f.children=[]),f.children.includes(h.id)||f.children.push(h.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=Cs.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,h,f,c,g;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)??((h=i.geometry)==null?void 0:h.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((f=i.transform)==null?void 0:f.x)??i.x??0,y:((c=i.transform)==null?void 0:c.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:((g=i.transform)==null?void 0:g.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 Ne;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,h=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:h,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=>{let o=i.value;if(i.type==="RandomNumber"){const s=i.min!==void 0?i.min:0,n=i.max!==void 0?i.max:100;o=s+Math.random()*(n-s)}else if(i.type==="RandomColor"){const s=i.minAlpha!==void 0?i.minAlpha:.2,n=i.maxAlpha!==void 0?i.maxAlpha:1,a=Math.floor(Math.random()*256),r=Math.floor(Math.random()*256),h=Math.floor(Math.random()*256),f=s+Math.random()*(n-s);o=`rgba(${a}, ${r}, ${h}, ${f.toFixed(2)})`}this.inputs.set(i.id,o);const e=this.inputNameMap.get(i.name)||[];e.includes(i.id)||e.push(i.id),this.inputNameMap.set(i.name,e)}),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 h=Math.abs(r.x-a.x),f=Math.abs(r.y-a.y);!t&&(h>20||f>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((s=this.artboard.autoLayout)!=null&&s.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=Ve(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var r;const a=n.type==="Component"&&(!n.variant||n.variant==="artboard"||n.variant==="instance");if((n.type==="Frame"||a)&&((r=n.autoLayout)!=null&&r.enabled)&&n.children&&n.children.length>0){const h=n.children.map(g=>i.get(g)).filter(g=>!!g),f=this.objectStates.get(n.id);if(!f)return;const c=Ve(f,h,g=>this.objectStates.get(g));c.frameWidth!==void 0&&(f.width=c.frameWidth),c.frameHeight!==void 0&&(f.height=c.frameHeight),e(c.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 h=a.states.find(f=>f.id===r);if(h){let f=null;h.animationId&&(f=this.artboard.animations.find(c=>c.id===h.animationId)||null),f||(f=this.artboard.animations.find(c=>{var g,d;return c.name===h.name||c.id===h.name||(h.name==="Entry"||h.id==="entry")&&(((g=c.name)==null?void 0:g.toLowerCase())==="onload"||((d=c.name)==null?void 0:d.toLowerCase())==="intro")})||null),f&&((n=this.artboard.animationFlow)!=null&&n.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(f==null?void 0:f.id))||(e.push({animation:f,state:h}),s=Math.max(s,f.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}resolveRandomValue(t){if(t.type==="RandomNumber"){const i=t.min!==void 0?t.min:0,o=t.max!==void 0?t.max:100;return i+Math.random()*(o-i)}else if(t.type==="RandomColor"){const i=t.minAlpha!==void 0?t.minAlpha:.2,o=t.maxAlpha!==void 0?t.maxAlpha:1,e=Math.floor(Math.random()*256),s=Math.floor(Math.random()*256),n=Math.floor(Math.random()*256),a=i+Math.random()*(o-i);return`rgba(${e}, ${s}, ${n}, ${a.toFixed(2)})`}return t.value}updateInput(t,i){var a,r,h,f,c,g,d;let o;if(this.inputs.has(t)){const l=(a=this.activeStateMachine)==null?void 0:a.inputs.find(u=>u.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const u=(r=this.activeStateMachine)==null?void 0:r.inputs.find(y=>y.id===l[0]);u&&typeof u.value=="object"&&(o=u.value.type)}}let e=(f=(h=this.artboard)==null?void 0:h.stateVariables)==null?void 0:f.find(l=>l.id===t||l.name===t);if(!e){const l=this.inputNameMap.get(t);l&&l.length>0&&(e=(g=(c=this.artboard)==null?void 0:c.stateVariables)==null?void 0:g.find(u=>u.id===l[0]))}let s=e&&(e.type==="RandomNumber"||e.type==="RandomColor")?this.resolveRandomValue(e):i;o==="Trigger"&&(i===1?s=!0:i===0&&(s=!1)),this.inputs.has(t)&&this.inputs.get(t)!==s&&this.setInternalInput(t,s);const n=this.inputNameMap.get(t);n&&n.forEach(l=>{this.inputs.get(l)!==s&&this.setInternalInput(l,s)}),o==="Trigger"&&s===!0&&(this.justFiredTriggers.add(t),n&&n.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(s)&&((d=this.artboard)==null||d.objects.forEach(l=>{if(l.inputId===t||l.name===t){const u=this.objectStates.get(l.id);u&&u.options&&(l.type==="ListView"||l.variant==="listview"?u.options.items=s:(l.type==="Dropdown"||l.variant==="dropdown")&&(u.options.optionsList=s))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,s)}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 h=!1;switch(a){case"Equal":case"==":h=i==r;break;case"NotEqual":case"!=":h=i!=r;break;case"GreaterThan":case">":h=i>r;break;case"LessThan":case"<":h=i<r;break;case"GreaterEqual":case">=":h=i>=r;break;case"LessEqual":case"<=":h=i<=r;break;case"IsTrue":h=!!i;break;case"IsFalse":h=!i;break}if(h){const f=s.delay||0;f<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),f)}}})}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(h=>h.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,h,f,c,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(d=>d.id===t);if(e){const d=(u,y)=>{const m=e.inputs.find(b=>b.id===u);return m?m.sourceId?this.evaluateLogicTree(m.sourceId,m.sourceHandleId,o):m.value!==void 0?m.value:y:y};let l=0;switch(e.op){case wt.AND:l=d("a",!1)&&d("b",!1);break;case wt.OR:l=d("a",!1)||d("b",!1);break;case wt.NOT:l=!d("in",!1);break;case wt.XOR:l=!!d("a",!1)!=!!d("b",!1);break;case wt.OBJECT:l=e.name;break;case wt.PROPERTY:case wt.GET_PROPERTY:{const u=d("id","");if(!u){l=0;break}const y=e.name;if(!y||y==="GET_PROPERTY"||y==="PROPERTY"){l=0;break}const m=this.objectStates.get(u);if(!m){l=0;break}y in m?l=m[y]:l=this.resolvePath(m,y);break}case wt.SET_PROPERTY:{const u=d("id",""),y=d("value",void 0);if(!u||y===void 0){l=0;break}const m=e.name;if(!m||m==="SET_PROPERTY"){l=0;break}const b=this.objectStates.get(u);if(!b){l=0;break}if(["x","y","rotation","scale_x","scale_y","skew_x","skew_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(m))b[m]=y,l=y;else{const C=m.split(".");let S=b;for(let w=0;w<C.length-1;w++){const I=C[w];S[I]===void 0&&(S[I]={}),S=S[I]}const M=C[C.length-1];S[M]=y,l=y}break}case wt.ADD:l=d("a",0)+d("b",0);break;case wt.SUB:l=d("a",0)-d("b",0);break;case wt.MUL:l=d("a",0)*d("b",0);break;case wt.DIV:{const u=d("b",1);l=u===0?0:d("a",0)/u;break}case wt.MOD:l=d("a",0)%d("b",1);break;case wt.POW:l=Math.pow(d("a",0),d("b",1));break;case wt.ABS:l=Math.abs(d("in",0));break;case wt.ROUND:l=Math.round(d("in",0));break;case wt.FLOOR:l=Math.floor(d("in",0));break;case wt.CEIL:l=Math.ceil(d("in",0));break;case wt.SIN:l=Math.sin(d("in",0));break;case wt.COS:l=Math.cos(d("in",0));break;case wt.TAN:l=Math.tan(d("in",0));break;case wt.CLAMP:{const u=d("in",0),y=d("min",0),m=d("max",1);l=Math.max(y,Math.min(m,u));break}case wt.REMAP:{const u=d("in",0),y=d("inMin",0),m=d("inMax",100),b=d("outMin",0),v=d("outMax",1);l=m===y?b:b+(u-y)*(v-b)/(m-y);break}case wt.EQ:l=d("a",0)==d("b",0);break;case wt.NEQ:l=d("a",0)!=d("b",0);break;case wt.GT:l=d("a",0)>d("b",0);break;case wt.LT:l=d("a",0)<d("b",0);break;case wt.GTE:l=d("a",0)>=d("b",0);break;case wt.LTE:l=d("a",0)<=d("b",0);break;case wt.IF_ELSE:l=d("cond",!1)?d("then",0):d("else",0);break;case wt.VALUE:l=e.value!==void 0?e.value:0;break;case wt.INPUT:l=this.inputs.get(e.name)??0;break;case wt.LOG:{const u=d("in","");this.debugLog(`[User Logic] ${u}`),l=u;break}case wt.SCROLL_X:l=this.inputs.get("scrollX")??0;break;case wt.SCROLL_Y:l=this.inputs.get("scrollY")??0;break;case wt.MOUSE_X:l=this.inputs.get("mouseX")??0;break;case wt.MOUSE_Y:l=this.inputs.get("mouseY")??0;break;case wt.IS_MOUSE_DOWN:l=this.inputs.get("isMouseDown")??!1;break;case wt.EFFECTOR:{const u=d("id",""),y=d("intensity",1),m=d("trigger",!0);if(!u||!m){l=0;break}const b=e.name;if(!b){l=0;break}const v=this.objectStates.get(u);if(!v){l=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(b))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:b,intensity:y},l=1;else{v.behaviors||(v.behaviors=[]);let S=v.behaviors.find(M=>M.type===b);S?(S.enabled=!0,S.settings||(S.settings={}),S.settings.intensity=y):(S={id:`eff_${Date.now()}_${b}`,type:b,enabled:!0,sensors:[],settings:{intensity:y}},v.behaviors.push(S)),l=1}break}case wt.MONITOR:{l=d("in",0);break}case wt.SPRING_PULL:{const u=d("objectId",""),y=d("forceX",0),m=d("forceY",0);u&&((h=this.artboard)==null||h.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(v=>{var C;if(v.type===z.SpringChain&&((C=v.settings)!=null&&C.connections)&&(v.settings.connections.some(M=>M.targetId===u)||b.id===u)){this._springChainState.has(b.id)||this._springChainState.set(b.id,new Map);const M=this._springChainState.get(b.id);if(!M.has(u)){const I=this.objectStates.get(u);M.set(u,{x:(I==null?void 0:I.x)??0,y:(I==null?void 0:I.y)??0,vx:0,vy:0})}const w=M.get(u);w&&(w.vx+=y,w.vy+=m)}})})),l=1;break}case wt.SPRING_SETTLE:{const u=d("objectId","");let y=!0;if(u){const m=d("threshold",1);this._springChainState.forEach(b=>{const v=b.get(u);v&&(Math.abs(v.vx)>m||Math.abs(v.vy)>m)&&(y=!1)})}l=y;break}case wt.EMIT:{const u=d("objectId",""),y=d("count",20);u&&((f=this.artboard)==null||f.objects.forEach(m=>{m.behaviors&&m.behaviors.forEach(b=>{b.type===z.ParticleEmitter&&m.id===u&&(b._pendingBurst=(b._pendingBurst||0)+y)})})),l=1;break}default:l=0;break}if(this.logicNodeValues.set(t,l),e.op===wt.DELAY){const u=d("delay",0),y=d("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:y});m.queue.length>0&&m.queue[0].time<=this.currentTime;)m.lastValue=m.queue.shift().value;l=m.lastValue??0}return l}const s=(c=this.activeStateMachine)==null?void 0:c.inputs.find(d=>d.id===t||d.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const d=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,d),d}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 d=(g=this.activeStateMachine)==null?void 0:g.inputs.find(l=>l.id===t);if(d&&d.value.type==="Number"&&typeof n=="number"){const l=d.value.defaultValue??d.value.value;if(i==="source-greater")return n>l;if(i==="source-less")return n<l;if(i==="source-equal")return n===l}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(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));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=>{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,h,f,c;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.objects.find(g=>g.id===e))==null?void 0:n.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(f=(h=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:h.triggers)==null?void 0:f.find(u=>u.id===o.triggerId),d=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let l=o.elapsedHold>=d;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(l=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(l=!0),l)if(g!=null&&g.exitAnimationId){const u=(c=this.artboard)==null?void 0:c.animations.find(y=>y.id===g.exitAnimationId);u?(o.phase="exit",o.animation=u,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t),this.evaluateLogicProperties(t)}evaluateLogicProperties(t){this.artboard&&this.artboard.objects.forEach(i=>{const o=i.logicProperties;if(o&&o.length>0){const e=this.objectStates.get(i.id);if(!e)return;o.forEach(s=>{var a,r,h;let n=null;if(s.valueType==="constant"||s.valueType==="boolean"||s.valueType==="color")n=s.value;else if(s.valueType==="variable"&&s.variableId){if(n=this.inputs.get(s.variableId),n===void 0){const f=(r=(a=this.activeStateMachine)==null?void 0:a.inputs)==null?void 0:r.find(c=>c.id===s.variableId||c.name===s.variableId);f&&(n=this.inputs.get(f.id)??((h=f.value)==null?void 0:h.value)??f.value)}}else if(s.valueType==="expression"&&s.formula)try{let f=s.formula;this.inputs.forEach((c,g)=>{const d=new RegExp(`\\b${g}\\b`,"g");f=f.replace(d,JSON.stringify(c))}),n=Function(`"use strict"; return (${f})`)()}catch(f){this.debugLog(`Failed to evaluate expression: ${s.formula}, error: ${f}`)}else if(s.valueType==="object_ref"&&s.objectId){const f=this.objectStates.get(s.objectId);if(f){let c=s.refProperty;c==="cornerRadius"&&(c="corner_radius");let g=f[c];g===void 0&&f.geometry&&(g=f.geometry[c]),c==="width"&&typeof g=="number"&&f.scale_x?g=g*Math.abs(f.scale_x):c==="height"&&typeof g=="number"&&f.scale_y&&(g=g*Math.abs(f.scale_y)),g!=null&&(n=g,typeof n=="number"&&typeof s.offset=="number"&&(n+=s.offset))}}if(n!=null){let f=s.name;if(f==="cornerRadius"&&(f="corner_radius"),f==="width"||f==="height"||f==="corner_radius")f==="width"&&typeof n=="number"&&e.scale_x&&Math.abs(e.scale_x)>.001?n=n/Math.abs(e.scale_x):f==="height"&&typeof n=="number"&&e.scale_y&&Math.abs(e.scale_y)>.001&&(n=n/Math.abs(e.scale_y)),e[f]=n,e.geometry&&(e.geometry[f]=n);else if(f==="x"||f==="y"||f==="rotation"||f==="scale_x"||f==="scale_y"||f==="skew_x"||f==="skew_y")e[f]=n;else if(f.startsWith("style.")){const c=f.split(".");c.length===3&&e.style&&e.style[c[1]]&&(e.style[c[1]][c[2]]=n)}else e[f]=n}})}})}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),h=(((s=i.geometry)==null?void 0:s.width)||100)*(r.scale_x||1),f=(((n=i.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),c=50,g=r.x+h/2>=-this.canvasWidth/2-c&&r.x-h/2<=this.canvasWidth/2+c&&r.y+f/2>=-this.canvasHeight/2-c&&r.y-f/2<=this.canvasHeight/2+c,d=`analytics_${i.id}`,l=this.wasInView.has(d);g&&!l&&this.fireAnalyticsEvent(i.id,"visible"),g?this.wasInView.add(d):this.wasInView.delete(d)}}}),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,h,f;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const c=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const c=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(i.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const c=this.objectStates.get(i.id);if(c&&c.visible!==!1){const g=this.getGlobalTransform(i.id),d=(((r=i.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),l=(((h=i.geometry)==null?void 0:h.height)||100)*(g.scale_y||1),u=50,y=g.x+d/2>=-this.canvasWidth/2-u&&g.x-d/2<=this.canvasWidth/2+u&&g.y+l/2>=-this.canvasHeight/2-u&&g.y-l/2<=this.canvasHeight/2+u,m=this.wasInView.has(i.id);y&&!m&&(!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 c=Math.abs(this.scrollOffset.y)/(((f=this.artboard)==null?void 0:f.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(c-g)>.001&&(this.scrollProgressLastValue.set(e.id,c),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,c))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(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 f,c,g,d,l,u,y,m,b;const a=((f=o.constraints)==null?void 0:f[n])||{},r={...s,...a},h=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const C=r.offsetX||0,S=r.offsetY||0,M=v.x+C,w=v.y+S,I=r.useSpring;if(I){const E=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:F,y:T,vx:P,vy:L}=this.computeSpring(e.x,e.y,E.vx,E.vy,M,w,r,t);r.copyX&&(e.x=e.x+(F-e.x)*h),r.copyY&&(e.y=e.y+(T-e.y)*h),this.objectVelocities.set(i.id,{vx:P,vy:L})}else r.copyX&&(e.x=e.x+(M-e.x)*h),r.copyY&&(e.y=e.y+(w-e.y)*h);let _=!1;if((c=r.limitX)!=null&&c.enabled){const E=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==E&&(_=!0)}if((g=r.limitY)!=null&&g.enabled){const E=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==E&&(_=!0)}_&&I&&this.objectVelocities.set(i.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const v=this.getGlobalTransform(r.targetId);if(v){let S=(v.rotation+(r.offset||0)-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*h}}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)*h),r.copyY&&(e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*h))}else if(r.type==="Transform"){const v=this.getGlobalTransform(r.targetId);if(v){e.x=e.x+(v.x-e.x)*h,e.y=e.y+(v.y-e.y)*h;let C=(v.rotation-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*h,e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*h,e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*h}}else if(r.type==="FollowPointer"){const v=((d=this._lastPointerPos)==null?void 0:d.x)??e.x,C=((l=this._lastPointerPos)==null?void 0:l.y)??e.y,S=r.useSpring;if(S){const w=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:I,y:_,vx:E,vy:F}=this.computeSpring(e.x,e.y,w.vx,w.vy,v,C,r,t);e.x=I,e.y=_,this.objectVelocities.set(i.id,{vx:E,vy:F})}else e.x=e.x+(v-e.x)*h,e.y=e.y+(C-e.y)*h;let M=!1;if((u=r.limitX)!=null&&u.enabled){const w=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==w&&(M=!0)}if((y=r.limitY)!=null&&y.enabled){const w=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==w&&(M=!0)}M&&S&&this.objectVelocities.set(i.id,{vx:0,vy:0})}else if(r.type==="Distance"){const v=this.getGlobalTransform(r.targetId);if(v){const C=e.x-v.x,S=e.y-v.y,M=Math.sqrt(C*C+S*S),w=r.distance||0;let I=M;switch(r.mode){case"exact":I=w;break;case"minimum":I=Math.max(w,M);break;case"maximum":I=Math.min(w,M);break;case"clamped":I=Math.max(0,Math.min(w,M));break}if(M>0){const _=e.x===v.x&&e.y===v.y?1:I/M;e.x=e.x+(v.x+C*_-e.x)*h,e.y=e.y+(v.y+S*_-e.y)*h}}}else if(r.type==="FollowPath"){const v=(m=this.artboard)==null?void 0:m.objects.find(C=>C.id===r.targetId);if(v){const C=this.getGlobalTransform(v.id);if(C){let S=v.geometry;if(v.type==="Frame"||v.type==="Group"||!S||S.type!=="Path"&&S.type!=="Ellipse"&&S.type!=="Rectangle"){const k=(b=this.artboard)==null?void 0:b.objects.find(Y=>Y.parentId===v.id&&Y.type==="Shape"&&Y.geometry&&(Y.geometry.type==="Path"||Y.geometry.type==="Ellipse"||Y.geometry.type==="Rectangle"));k&&(S=k.geometry)}if(!S)return;const M=(r.distance||0)/100,w=C.width||S.width||0,I=C.height||S.height||0,_=this.getPointOnPath(S,w,I,M),E=C.rotation*Math.PI/180,F=Math.cos(E),T=Math.sin(E),P=_.x*C.scale_x*F-_.y*C.scale_y*T,L=_.x*C.scale_x*T+_.y*C.scale_y*F;let O=C.rotation+(r.offsetRotation||0);if(r.orient){const k=Math.cos(_.angle),Y=Math.sin(_.angle),X=k*C.scale_x*F-Y*C.scale_y*T,J=k*C.scale_x*T+Y*C.scale_y*F;O=Math.atan2(J,X)*180/Math.PI+(r.offsetRotation||0)}const W=O*Math.PI/180,B=Math.cos(W),A=Math.sin(W),$=(r.offsetX||0)*B-(r.offsetY||0)*A,G=(r.offsetX||0)*A+(r.offsetY||0)*B,N=C.x+P+$,x=C.y+L+G;if(e.x=e.x+(N-e.x)*h,e.y=e.y+(x-e.y)*h,r.orient){let k=(O-e.rotation)%360;k>180&&(k-=360),k<-180&&(k+=360),e.rotation=e.rotation+k*h}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(i,v,r.boneCount||2,h)}}),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 c,g;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(c=this.artboard)==null?void 0:c.objects.find(d=>d.id===t),e=(o==null?void 0:o.type)==="Bone"?(g=o.geometry)==null?void 0:g.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),h=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*r),f=s.y+(i.x*s.scale_x*r+i.y*s.scale_y*a);return{x:h,y:f,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),h=i.x-o.x,f=i.y-o.y,c=(h*a-f*r)*e,g=(h*r+f*a)*s;return{x:c,y:g,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 h;const s=[];let n=t.id;for(let f=0;f<o&&n;f++){const c=(h=this.artboard)==null?void 0:h.objects.find(g=>g.id===n);if(!c)break;s.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=c.parentId}if(s.length<2)return;const a=s.reverse(),r=5;for(let f=0;f<r;f++){const c=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const d=a[g],l=this.getGlobalTransform(d.id),u=c.x-l.x,y=c.y-l.y,m=i.x-l.x,b=i.y-l.y,v=Math.sqrt(u*u+y*y),C=Math.sqrt(m*m+b*b);if(v>.001&&C>.001){const S=Math.atan2(y,u);let w=(Math.atan2(b,m)-S)*180/Math.PI;w*=e;const I=this.objectStates.get(d.id);I&&(I.rotation+=w)}}}}computeSpring(t,i,o,e,s,n,a,r){const h=a.stiffness??100,f=a.damping??10,c=a.mass??1,g=-h*(t-s),d=-h*(i-n),l=-f*o,u=-f*e,y=(g+l)/c,m=(d+u)/c,b=o+y*r,v=e+m*r,C=t+b*r,S=i+v*r;return{x:C,y:S,vx:b,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.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,h,f,c,g;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const s=(d,l)=>{var C;let u=l;l==="click"?u="onClick":l==="down"?u="onPointerDown":l==="up"?u="onPointerUp":l==="blur"&&(u="onPointerLeave");const y=new Set([u]);l==="move"&&y.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&y.add("click"),u==="onPointerDown"&&y.add("pointerDown"),u==="onPointerUp"&&y.add("pointerUp");const m=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup"];return!!(d.type==="Component"&&m.includes(d.variant)||m.includes((C=d.type)==null?void 0:C.toLowerCase())||(d.interactions||[]).some(S=>S.event&&y.has(S.event)?!0:S.triggers&&Array.isArray(S.triggers)?S.triggers.some(M=>{if(!M)return!1;const w=M.toLowerCase();return Array.from(y).some(I=>I.toLowerCase()===w||I.toLowerCase()==="on"+w)}):!1)||(d.triggers||[]).some(S=>y.has(S.eventType)))};let n=null;for(let d=this.artboard.objects.length-1;d>=0;d--){const l=this.artboard.objects[d],u=this.objectStates.get(l.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(l,i,o)&&(n||(n=l),s(l,t))){e=l;break}}!e&&n&&(e=n),(t==="down"||t==="click")&&this.log(`[Engine] Pointer ${t} at (${Math.round(i)},${Math.round(o)}). Hit: ${(e==null?void 0:e.id)||"none"}, TopHit: ${(n==null?void 0:n.id)||"none"}`),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 d=this.artboard.objects.find(l=>l.id===this.draggingSliderId);d&&this.updateSliderValueFromPointer(d,i,o);return}if(this.draggingListViewId){const d=this.artboard.objects.find(l=>l.id===this.draggingListViewId);d&&this.updateListViewScrollFromPointer(d);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.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(d=>d.type===z.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(d=>{d!==a&&this.activeHoverIds.delete(d)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const d=this.artboard.objects.find(l=>l.id===this.activeDropdownId);if(d&&(d.type==="Dropdown"||d.variant==="dropdown")){const l=this.objectStates.get(d.id),u=(l==null?void 0:l.options)||d.options||{},y=d.geometry||{},m=y.width??d.width??200,b=y.height??d.height??40,v=u.optionsList||[],C=u.itemHeight||32,S=u.listPadding??4,M=v.length*C+S*2,w=this.getWorldTransform(d.id),I=m*Math.abs(w.scaleX),_=b*Math.abs(w.scaleY),E=w.y+_/2+4,F=Math.abs(i-w.x)<=I/2,T=o>=E&&o<=E+M*Math.abs(w.scaleY);if(F&&T){const P=Math.abs(w.scaleY),L=o-(E+S*P),O=Math.floor(L/(C*P));if(O>=0&&O<v.length){const W=v[O];u.selectedOption=W,u.isOpen=!1,this.activeDropdownId=null,d.inputId&&this.setInternalInput(d.inputId,W),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"dropdown",property:"selectedOption",value:W})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let d=e,l=e;for(;l&&l.parentId;){const y=this.artboard.objects.find(m=>m.id===l.parentId);if(y&&y.type==="Component"){d=y;break}l=y}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),d!==e&&this.fireEventForObject(d.id,u),d.type==="Component"&&d.variant==="toggle_button"&&t==="down"){const y=this.objectStates.get(d.id),m=(y==null?void 0:y.options)||d.options||{};m.checked=!m.checked,d.inputId&&this.setInternalInput(d.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"toggle_button",property:"checked",value:m.checked}),this.fireEventForObject(d.id,"Toggle"),this.fireEventForObject(d.id,m.checked?"Toggle True":"Toggle False")}if(d.type==="Component"&&d.variant==="toggle"&&t==="down"){const y=this.objectStates.get(d.id),m=(y==null?void 0:y.options)||d.options||{};m.checked=!m.checked,d.inputId&&this.setInternalInput(d.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"toggle",property:"checked",value:m.checked}),this.onToggle&&this.onToggle(d.name,m.checked),this.fireEventForObject(d.id,"Toggle"),this.fireEventForObject(d.id,m.checked?"Toggle True":"Toggle False")}if(d.type==="Component"&&d.variant==="dropdown"&&t==="down"){const y=this.objectStates.get(d.id),m=(y==null?void 0:y.options)||d.options||{},b=!m.isOpen;if(b&&this.activeDropdownId&&this.activeDropdownId!==d.id){const v=this.artboard.objects.find(C=>C.id===this.activeDropdownId);v&&v.options&&(v.options.isOpen=!1)}m.isOpen=b,this.activeDropdownId=b?d.id:null}if(d.type==="Component"&&d.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(d.name,d.id),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"button",property:"click",value:!0})),(d.type==="ListView"||d.type==="Component"&&d.variant==="listview")&&t==="down"){this.draggingListViewId=d.id;const y=this.getListViewItemIndexAtPointer(d,i,o);if(y!==null){const m=d.options||{};m.activeItemIndex=y;const b=this.objectStates.get(d.id);b&&b.options&&(b.options.activeItemIndex=y);const v=(m.items||[])[y],C=typeof v=="string"?v:v.label||v.value||y;b&&b.options&&(b.options.selectedValue=C),d.inputId&&this.setInternalInput(d.inputId,C),this.onComponentChange&&(this.onComponentChange({objectId:d.id,componentName:d.name,variant:"listview",property:"activeItemIndex",value:y}),this.onComponentChange({objectId:d.id,componentName:d.name,variant:"listview",property:"selected",value:C}))}}if(d.type==="Component"&&d.variant==="slider"&&t==="down"&&(this.draggingSliderId=d.id,this.updateSliderValueFromPointer(d,i,o)),d.type==="Component"&&d.variant==="checkbox"&&t==="down"){const y=this.objectStates.get(d.id),m=(y==null?void 0:y.options)||d.options||{};m.checked=!m.checked,d.inputId&&this.setInternalInput(d.inputId,m.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"checkbox",property:"checked",value:m.checked}),this.fireEventForObject(d.id,"Click"),this.fireEventForObject(d.id,m.checked?"Checked":"Unchecked")}if(d.type==="Component"&&d.variant==="radiogroup"&&t==="down"){const y=this.objectStates.get(d.id),m=(y==null?void 0:y.options)||d.options||{},b=m.optionsList||[],v=this.getRadioGroupItemIndexAtPointer(d,i,o);if(v!==null&&v>=0&&v<b.length){const C=b[v];m.selectedValue=C,d.inputId&&this.setInternalInput(d.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"radiogroup",property:"selectedValue",value:C}),this.fireEventForObject(d.id,"Click"),this.fireEventForObject(d.id,`Selected: ${C}`)}}if(d.type==="LineGraph"&&(t==="down"||t==="click")){const y=d.geometry,m=(y==null?void 0:y.datasets)||[],b=this.objectStates.get(d.id),v=(b==null?void 0:b.width)||(y==null?void 0:y.width)||200,C=(b==null?void 0:b.height)||(y==null?void 0:y.height)||150,S=this.getWorldTransform(d.id),M=30,w=20,I=v-M,_=C-w;let E=1;m.forEach(P=>{const L=Math.max(...P.data||[0]);L>E&&(E=L)});let F=1/0,T=null;m.forEach((P,L)=>{const O=P.data||[],W=I/Math.max(O.length-1,1);O.forEach((B,A)=>{const $=S.x-v/2+M+A*W,G=S.y+C/2-w-B/E*_,N=Math.sqrt((i-$)**2+(o-G)**2);N<F&&(F=N,T={dIdx:L,pIdx:A,val:B,label:P.label||`Dataset ${L+1}`})})}),T&&F<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:d.id,componentName:d.name,datasetIndex:T.dIdx,pointIndex:T.pIdx,value:T.val,label:T.label}),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"linegraph",property:"click",value:(T==null?void 0:T.val)??null})}if(t==="click"){const y=(h=this.artboard)==null?void 0:h.objects.find(v=>v.id===e.id),m=this.focusedId,b=(y==null?void 0:y.type)==="InputBox"||(y==null?void 0:y.type)==="Component"&&y.variant==="inputbox";if(y&&b){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),m!==this.focusedId){if(m){const v=(f=this.artboard)==null?void 0:f.objects.find(C=>C.id===m);v&&this.onInputBlur&&this.onInputBlur(v.name)}this.onInputFocus&&this.onInputFocus(y.name)}}else if(this.focusedId=null,m){const v=(c=this.artboard)==null?void 0:c.objects.find(C=>C.id===m);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}else if(t==="click"){const d=this.focusedId;if(this.focusedId=null,d){const l=(g=this.artboard)==null?void 0:g.objects.find(u=>u.id===d);l&&this.onInputBlur&&this.onInputBlur(l.name)}}}handleKeyDown(t){if(!this.artboard||!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)}fireEventForObject(t,i){var f,c,g,d,l;const o=(f=this.artboard)==null?void 0:f.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 y=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?y.every(v=>v&&e.has(v.toLowerCase())):y.some(v=>v&&e.has(v.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,y=a.targetProperty;y&&this.updateObjectProperty(u,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 u=a.targetAnimationId,y=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(g=(c=this.artboard)==null?void 0:c.animations)==null||g.forEach(m=>{this.triggerGlobalAnimation(m.id,y)}):u&&this.triggerGlobalAnimation(u,y)}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((y,m)=>{m.startsWith("global_")&&this.layerStates.delete(m)}):u&&this.layerStates.forEach((y,m)=>{m.startsWith(`global_${u}_`)&&this.layerStates.delete(m)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,y=this.activeStateMachine.layers.find(m=>m.states.some(b=>b.id===u||b.name===u));y&&(this.log(`[Engine] Switching Layer ${y.name} to State ${u}`),this.enterStates(y.name,[u]))}this.onTrigger&&this.onTrigger(i,a.action)}const h=(o.triggers||[]).find(u=>{const y=u.eventType.toLowerCase();let m=!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"))&&(m=!0),m&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):m});if(h&&h.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${h.eventType}) -> Animation ${h.entryAnimationId}`);const u=(l=(d=this.artboard)==null?void 0:d.animations)==null?void 0:l.find(y=>y.id===h.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:h.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:h.targetObjectId}),this.onTrigger&&this.onTrigger(h.name,u.name))}}fireAnalyticsEvent(t,i){var r,h;const o=(r=this.artboard)==null?void 0:r.objects.find(f=>f.id===t);if(!o)return;const e=(h=o.style)==null?void 0:h.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(f=>{if(f.type==="literal")n[f.key]=f.value;else if(f.type==="variable"){const c=this.inputs.get(f.value);n[f.key]=c!==void 0?c:""}}),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 f=window;typeof f.gtag=="function"?(f.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 f=window;typeof f.fbq=="function"?(f.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 f=window;f.mixpanel&&typeof f.mixpanel.track=="function"?(f.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 g;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(d=>d.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,h=i.y*e.scaleY,f=e.x+(r*n-h*a),c=e.y+(r*a+h*n);return{x:f,y:c,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,C;if(!this.objectStates.get(t.id))return!1;const s=((v=t.geometry)==null?void 0:v.width)??t.width??100,n=((C=t.geometry)==null?void 0:C.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,h=o-a.y,f=-a.rotation*(Math.PI/180),c=Math.cos(f),g=Math.sin(f),d=r*c-h*g,l=r*g+h*c,u=a.scaleX,y=a.scaleY,m=s*Math.abs(u),b=n*Math.abs(y);return Math.abs(d)<=m/2&&Math.abs(l)<=b/2}updateSliderValueFromPointer(t,i,o){var w;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((w=t.geometry)==null?void 0:w.width)??t.width??200,a=this.getWorldTransform(t.id),r=i-a.x,h=o-a.y,f=-a.rotation*(Math.PI/180),c=Math.cos(f),g=Math.sin(f),d=r*c-h*g,l=s.thumbWidth??16,u=n-l;let m=(d+u/2)/u;m=Math.max(0,Math.min(1,m));const b=s.min??0,v=s.max??100,C=s.step||1;let S=b+m*(v-b);C>0&&(S=Math.round(S/C)*C),S=Math.max(b,Math.min(v,S));const M=e.options||{};M.value!==S&&(e.options={...M,value:S},t.inputId&&this.setInternalInput(t.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:S}))}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var c,g,d;const s=e.object_id||e.objectId;if(o){const l=u=>{var m,b;if(s===u)return!0;let y=(m=this.artboard)==null?void 0:m.objects.find(v=>v.id===s);for(;y&&y.parentId;){if(y.parentId===u)return!0;y=(b=this.artboard)==null?void 0:b.objects.find(v=>v.id===(y==null?void 0:y.parentId))}return!1};if(Array.isArray(o)){if(!o.some(l))return}else if(typeof o=="string"&&!l(o))return}const n=(c=this.artboard)==null?void 0:c.objects.find(l=>l.id===s),a=((g=n==null?void 0:n.physics)==null?void 0:g.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const h=this.objectStates.get(s);if(!h){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const f=this.interpolate(e.keyframes,i);if(f!==void 0){if(this.frameCount%240===0){const l=(n==null?void 0:n.name)||s,u=typeof f=="object"?JSON.stringify(f).slice(0,50):f;this.debugLog(`[Anim] Applying ${r} = ${u} to ${l}`)}if(r.includes(".")){const l=(r||"").split(".");let u=h;for(let y=0;y<l.length-1;y++){if(typeof u[l[y]]!="object"||u[l[y]]===null){let m=n;for(let b=0;b<=y;b++)m=m?m[l[b]]:null;if(l[y]==="corner_radius"||l[y]==="cornerRadius"){const b=typeof u[l[y]]=="number"?u[l[y]]:typeof m=="number"?m:0;u[l[y]]={tl:b,tr:b,bl:b,br:b}}else u[l[y]]=m?JSON.parse(JSON.stringify(m)):{}}u=u[l[y]]}u[l[l.length-1]]=f,l[l.length-1]==="color"&&(l[l.length-2]==="fill"||l[l.length-2]==="stroke")&&(u.type="Solid")}else r==="fill"?(h.style||(h.style={}),h.style.fill=f):r==="stroke"?(h.style||(h.style={}),h.style.stroke=f):h[r]=f;if(this.physicsEngine&&((d=n==null?void 0:n.physics)!=null&&d.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const l=this.physicsEngine.getPosition(s);l&&this.physicsEngine.setPosition(s,f,l.y)}else if(r==="y"){const l=this.physicsEngine.getPosition(s);l&&this.physicsEngine.setPosition(s,l.x,f)}else r==="rotation"&&this.physicsEngine.setRotation(s,f*(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 h=e.value[r];return typeof a=="number"&&typeof h=="number"?a+(h-a)*n:n<.5?a:h}):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(h=>{const f=o.value[h],c=e.value[h];typeof f=="number"&&typeof c=="number"?a[h]=f+(c-f)*n:f===void 0?a[h]=c:c===void 0?a[h]=f:a[h]=n<.5?f:c}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,i,o){var l,u;const e=((u=(l=this.artboard)==null?void 0:l.tokens)==null?void 0:u.colors)||{},s=e[t]||t,n=e[i]||i,a=y=>{if(!y)return{r:0,g:0,b:0};const m=y.startsWith("#")?y.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)}},r=a(s),h=a(n),f=Math.round(r.r+(h.r-r.r)*o),c=Math.round(r.g+(h.g-r.g)*o),g=Math.round(r.b+(h.b-r.b)*o),d=y=>{const m=Math.max(0,Math.min(255,y)).toString(16);return m.length===1?"0"+m:m};return`#${d(f)}${d(c)}${d(g)}`}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 c=this.artboard.backgroundImage;let g=this.imageCache.get(c);if(g||(g=new Image,g.src=c,this.imageCache.set(c,g)),g.complete&&g.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=g.naturalWidth/g.naturalHeight,l=s/n;let u,y,m,b;l>d?(u=s,y=s/d):(y=n,u=n*d),m=0,b=0,t.drawImage(g,m,b,u,y),t.restore()}}t.beginPath(),t.rect(0,0,s,n),t.clip();const r=new Map;this.artboard.objects.forEach(c=>r.set(c.id,c)),this.artboard.objects.filter(c=>!c.parentId).map((c,g)=>{const d=this.objectStates.get(c.id),l=(d==null?void 0:d.zIndex)??g;return{obj:c,zIndex:l}}).sort((c,g)=>c.zIndex-g.zIndex).forEach(({obj:c})=>{this.renderObject(t,c,r)}),this._emitterPools.forEach((c,g)=>{if(!(c.length===0||!r.get(g)))for(const l of c)t.save(),t.globalAlpha=l.opacity,t.fillStyle=l.color,t.beginPath(),t.arc(l.x,l.y,Math.max(1,l.size*l.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,h=i*a.b+o*a.d+a.f,f=Math.sqrt(a.a*a.a+a.b*a.b),c=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+n)*f,d=(s/2+n)*c;return r+g>=0&&r-g<=this.canvasWidth&&h+d>=0&&h-d<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,r=1,h=1;const f=o/e,c=t/i;switch(s){case"Contain":c>f?h=i/e:h=t/o,a=r=h;break;case"Cover":c>f?h=t/o:h=i/e,a=r=h;break;case"Fill":a=t/o,r=i/e;break;case"FitWidth":h=t/o,a=r=h;break;case"FitHeight":h=i/e,a=r=h;break;case"None":a=r=1;break;case"ScaleDown":h=Math.min(t/o,i/e),h>1&&(h=1),a=r=h;break;default:a=r=1;break}const g=o*a,d=e*r;let l=0,u=0;return n.includes("Left")?l=0:n.includes("Right")?l=t-g:l=(t-g)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=i-d:u=(i-d)/2,{scaleX:a,scaleY:r,tx:l,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 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 m,b,v,C,S,M,w,I,_,E,F,T,P,L,O,W,B;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=(A,$,G,N,x)=>(this.drawRoundRect(t,A,$,G,N,x),t));const s=e.geometry?this.deepMerge(i.geometry,e.geometry):i.geometry,n=e.style?this.deepMerge(i.style,e.style):i.style;let a=(s==null?void 0:s.width)||((m=i.geometry)==null?void 0:m.width)||i.width||0,r=(s==null?void 0:s.height)||((b=i.geometry)==null?void 0:b.height)||i.height||0;if((a===0||r===0)&&(s!=null&&s.points)&&Array.isArray(s.points)&&s.points.length>0){let A=1/0,$=-1/0,G=1/0,N=-1/0;s.points.forEach(x=>{A=Math.min(A,x.x),$=Math.max($,x.x),G=Math.min(G,x.y),N=Math.max(N,x.y)}),a===0&&(a=$-A),r===0&&(r=N-G)}const h=A=>{if(A)return A.corner_radius??A.cornerRadius},f=h(e)??h(n)??h(s)??h(i.style)??h(i.geometry)??0;let c={...s,width:a,height:r};if(delete c.cornerRadius,c.corner_radius=f,c.type==="Path"&&i.weights&&i.bindMatrices&&c.points){const A=this.getGlobalTransform(i.id);if(A){const $=ii(c.points,i.weights,i.bindMatrices,A,G=>this.getGlobalTransform(G));c={...c,points:$}}}const g=n.effects||((v=n.effect)!=null&&v.isEnabled?[n.effect]:[]),d=g.find(A=>A.isEnabled&&A.type==="PathDistortion");if(d&&c.type!=="SVG"&&c.type!=="Image"&&c.type!=="Text"){const A=oi(c,a,r,d.amplitude||5,d.frequency||10,d.seed||0,d.direction||0,d.directionStrength||0);c={...c,type:"DistortedPath",points:A}}if(e.visible===!1)return;const l=i.repeaterConfig,u=l&&l.isEnabled&&l.count>1,y=u?l.count:1;for(let A=0;A<y;A++){let $=e.x,G=e.y,N=e.rotation,x=e.scale_x??1,k=e.scale_y??1;if(u&&A>0){if(l.type==="Linear"){const it=l.offsetX||0,dt=l.offsetY||0,U=l.rotation||0,D=l.scale!==void 0?l.scale:1;$+=A*it,G+=A*dt,N+=A*U,x*=Math.pow(D,A),k*=Math.pow(D,A)}else if(l.type==="Grid"){const it=l.cols||Math.ceil(Math.sqrt(l.count)),dt=l.gapX||0,U=l.gapY||0,D=Math.floor(A/it),nt=A%it,et=a+dt,Ot=r+U;$+=nt*et,G+=D*Ot}else if(l.type==="Radial"){const it=l.radius||100,dt=l.startAngle||0,D=(l.endAngle||360)-dt,nt=l.count>1?D/(D===360?l.count:l.count-1):0,et=dt+A*nt,Ot=et*Math.PI/180;$=e.x+it*Math.cos(Ot),G=e.y+it*Math.sin(Ot),N+=et}}const Y=i.type==="Group"||i.type==="Frame"||i.type==="Component",X=a>0&&r>0;if(!Y&&X){const it=(((C=n.shadow)==null?void 0:C.isEnabled)!==!1?(((S=n.shadow)==null?void 0:S.blur)||0)+10:0)+(((M=n.blur)==null?void 0:M.isEnabled)!==!1&&((w=n.blur)==null?void 0:w.radius)||0)+20;if(!this.isObjectInView(t,$,G,a,r,it))continue}this.debug_objectsRendered++,t.save();const J=[],tt=n.blur||((I=i.style)==null?void 0:I.blur);tt&&tt.amount>0&&J.push(`blur(${tt.amount}px)`);const lt=g.find(it=>it.isEnabled&&it.type==="BackgroundBlur"),Z=g.find(it=>it.isEnabled&&it.type==="LayerBlur");Z&&J.push(`blur(${Z.radius??10}px)`),lt&&(n.fill=null,n.stroke&&(n.stroke.isEnabled=!1));const pt=((_=s==null?void 0:s.type)==null?void 0:_.toLowerCase().includes("image"))||((E=i.type)==null?void 0:E.toLowerCase().includes("image")),at=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Et=s!=null&&s.adjustments&&Object.keys(s.adjustments).length>0?s.adjustments:null,xt=pt?Et||at:at||Et,bt=pt&&!xt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:xt;if(e&&bt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...bt}),bt){const it=(bt.exposure||0)/100,dt=bt.contrast||0,U=1+(bt.saturation||0)/100,D=(bt.temperature||0)/200,nt=(bt.tint||0)/200,et=(bt.highlights||0)/500,Ot=(bt.shadows||0)/500;let Gt="",At="SourceGraphic";if(it!==0&&(Gt+=`
1
+ (function(Ht,se){typeof exports=="object"&&typeof module<"u"?se(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"],se):(Ht=typeof globalThis<"u"?globalThis:Ht||self,se(Ht.ExodeUIReact={},Ht.jsxRuntime,Ht.React,Ht.pretext,Ht.Rapier,Ht.LZString))})(this,(function(Ht,se,$t,xe,ne,bs){"use strict";var fi=Object.defineProperty;var hi=(Ht,se,$t)=>se in Ht?fi(Ht,se,{enumerable:!0,configurable:!0,writable:!0,value:$t}):Ht[se]=$t;var j=(Ht,se,$t)=>hi(Ht,typeof se!="symbol"?se+"":se,$t);function vs(p){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const i in p)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(p,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>p[i]})}}return t.default=p,Object.freeze(t)}const Cs=vs(bs);var z=(p=>(p.Proximity="Proximity",p.Magnetic="Magnetic",p.Repel="Repel",p.Orbit="Orbit",p.Vortex="Vortex",p.Fluid="Fluid",p.Elastic="Elastic",p.Holographic="Holographic",p.Sticky="Sticky",p.Dilation="Dilation",p.Parallax="Parallax",p.Noise="Noise",p.Float="Float",p.Pulse="Pulse",p.Draggable="Draggable",p.Scroll="Scroll",p.LookAt="LookAt",p.Glint="Glint",p.Scan="Scan",p.Ratchet="Ratchet",p.Jitter="Jitter",p.Follower="Follower",p.Wrap="Wrap",p.Typewriter="Typewriter",p.Scramble="Scramble",p.Wave="Wave",p.Bounce="Bounce",p.TextTrail="TextTrail",p.Reveal3D="Reveal3D",p.RevealSlide="RevealSlide",p.RevealBlur="RevealBlur",p.TextLiquid="TextLiquid",p.TextVortex="TextVortex",p.TextExplosion="TextExplosion",p.TextRain="TextRain",p.TextGravity="TextGravity",p.TextMatrix="TextMatrix",p.TextNeon="TextNeon",p.TextDissolve="TextDissolve",p.TextOrganic="TextOrganic",p.TextBreathe="TextBreathe",p.TextSpin="TextSpin",p.TextMagnet="TextMagnet",p.TextPerspective="TextPerspective",p.TextMirror="TextMirror",p.TextFloral="TextFloral",p.TextSmoke="TextSmoke",p.TextVariable="TextVariable",p.TextZing="TextZing",p.TextElastic="TextElastic",p.TextGlitch3D="TextGlitch3D",p.GlitchText="GlitchText",p.TextCounter="TextCounter",p.Squash="Squash",p.Spotlight="Spotlight",p.Lens="Lens",p.Gravity="Gravity",p.Velocity="Velocity",p.Shear="Shear",p.LayoutAnimation="LayoutAnimation",p.SpringChain="SpringChain",p.ParticleEmitter="ParticleEmitter",p.StateReactive="StateReactive",p.Fold="Fold",p.Crumple="Crumple",p.GraphPathDraw="GraphPathDraw",p.GraphWipeReveal="GraphWipeReveal",p.GraphPointPop="GraphPointPop",p.GraphGradientFlow="GraphGradientFlow",p))(z||{}),oe=(p=>(p.Scale="Scale",p.Opacity="Opacity",p.RotateZ="RotateZ",p.RotateX="RotateX",p.RotateY="RotateY",p.PositionX="PositionX",p.PositionY="PositionY",p.SkewX="SkewX",p.Blur="Blur",p.Exposure="Exposure",p.HueShift="HueShift",p.Negative="Negative",p.CornerRadius="CornerRadius",p.StrokeWidth="StrokeWidth",p.BoxShadow="BoxShadow",p.FontSize="FontSize",p.LetterSpacing="LetterSpacing",p))(oe||{}),Xe=(p=>(p.Equal="Equal",p.NotEqual="NotEqual",p.GreaterThan="GreaterThan",p.LessThan="LessThan",p.GreaterEqual="GreaterEqual",p.LessEqual="LessEqual",p.IsTrue="IsTrue",p.IsFalse="IsFalse",p))(Xe||{}),wt=(p=>(p.AND="AND",p.OR="OR",p.NOT="NOT",p.XOR="XOR",p.OBJECT="OBJECT",p.PROPERTY="PROPERTY",p.GET_PROPERTY="GET_PROPERTY",p.SET_PROPERTY="SET_PROPERTY",p.ADD="ADD",p.SUB="SUB",p.MUL="MUL",p.DIV="DIV",p.MOD="MOD",p.POW="POW",p.ABS="ABS",p.ROUND="ROUND",p.FLOOR="FLOOR",p.CEIL="CEIL",p.SIN="SIN",p.COS="COS",p.TAN="TAN",p.CLAMP="CLAMP",p.REMAP="REMAP",p.EQ="EQ",p.NEQ="NEQ",p.GT="GT",p.LT="LT",p.GTE="GTE",p.LTE="LTE",p.IF_ELSE="IF_ELSE",p.VALUE="VALUE",p.INPUT="INPUT",p.LOG="LOG",p.SCROLL_X="SCROLL_X",p.SCROLL_Y="SCROLL_Y",p.MOUSE_X="MOUSE_X",p.MOUSE_Y="MOUSE_Y",p.IS_MOUSE_DOWN="IS_MOUSE_DOWN",p.EFFECTOR="EFFECTOR",p.MONITOR="MONITOR",p.DELAY="DELAY",p.SPRING_PULL="SPRING_PULL",p.SPRING_SETTLE="SPRING_SETTLE",p.EMIT="EMIT",p))(wt||{});function Ss(p){if(p.length<5)return p;const t=new Set("aeiouyAEIOUY".split(""));if(/[\u4E00-\u9FFF\u3400-\u4DBF]/.test(p))return p;let o="";for(let e=0;e<p.length;e++){if(o+=p[e],e>=p.length-2)continue;const s=t.has(p[e]),n=t.has(p[e+1]),a=t.has(p[e+2]);s&&!n&&a&&(o+="­"),s&&!n&&!a&&e>=1&&(o+="­")}return o}function ws(p){return p.replace(/\b([a-zA-Z]{4,})\b/g,(t,i)=>Ss(i))}function Ms(p,t,i){return p}function Is(p,t,i){return p}const ke=new Map;function De(p){var I;const{text:t,fontFamily:i="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:s="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:h=0,paragraphIndent:l=0,textCase:f="none",segments:y=[],enableSegments:d=!1}=p;let c=String(t||"");f==="uppercase"?c=c.toUpperCase():f==="lowercase"?c=c.toLowerCase():f==="capitalize"&&(c=c.replace(/\b\w/g,_=>_.toUpperCase())),p.hyphenation===!0&&(c=ws(c));const u=`${s} ${e} ${o}px "${i}", sans-serif`,m=`${c}|${u}|${r}|${h}|${l}|${d}|${JSON.stringify(y)}|hyp:${!!p.hyphenation}|comp:${p.composer}|bal:${!!p.balanceRaggedLines}`;let g=ke.get(m);const b=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,v=function(_){if(!b)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const x=b.call(this,_);return r!==0&&_&&_.length>0?{...x,width:x.width+(_.length-1)*r}:x};if(!g){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=v),d&&y&&y.length>0){const _=y.map(x=>{let F=x.text||"";const T=x.textCase||f||"none";return T==="uppercase"?F.toUpperCase():T==="lowercase"?F.toLowerCase():T==="capitalize"?F.replace(/\b\w/g,P=>P.toUpperCase()):F}).join("");if(g=xe.prepareWithSegments(_,u),g){let x=0,F=o;for(const T of y){let P=T.text||"";if(!P)continue;const L=T.textCase||f||"none";L==="uppercase"?P=P.toUpperCase():L==="lowercase"?P=P.toLowerCase():L==="capitalize"&&(P=P.replace(/\b\w/g,A=>A.toUpperCase()));const O=T.fontSize||o;O>F&&(F=O);const W=`${T.fontStyle||s} ${T.fontWeight||e} ${O}px "${T.fontFamily||i}", sans-serif`,B=xe.prepareWithSegments(P,W);if(B&&B.widths)for(let A=0;A<B.widths.length;A++){const $=x+A;if($<g.widths.length){g.widths[$]=B.widths[A];const Y=B.kinds[A];if(Y===2){const N=P[A];N===`
2
+ `||N==="\r"?g.kinds[$]=2:g.kinds[$]=0}else g.kinds[$]=Y}}x+=P.length}g.fullText=_,g.maxFontSize=F}}else g=xe.prepareWithSegments(c,u);g&&ke.set(m,g)}catch(_){return console.error("[ExodeUI] Pretext prepare failed:",_),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}if(ke.size>500){const _=ke.keys().next().value;_&&ke.delete(_)}}if(l>0&&g&&g.widths&&!g.indentApplied){const _=[...g.widths],x=g.fullText||c;let F=!0;for(let T=0;T<x.length;T++)F&&_[T]!==void 0&&(_[T]+=l,F=!1),(x[T]===`
3
+ `||x[T]==="\r")&&(F=!0,x[T]==="\r"&&x[T+1]===`
4
+ `&&T++);g={...g,widths:_,indentApplied:!0}}if(!g)return{width:a,height:0,lineCount:0,lines:[]};let C=n;typeof C=="string"&&(C=parseFloat(C)),C>5&&o>0&&(C=C/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=v);let S;try{const _=g.maxFontSize||o;if(a>=1e5){const x=c.split(/\r\n|\r|\n/);S={lines:x.map(F=>({text:F,width:0})),height:x.length*(C*_),lineCount:x.length}}else S=xe.layoutWithLines(g,a,C*_)}finally{r!==0&&b&&(CanvasRenderingContext2D.prototype.measureText=b)}let M=(S==null?void 0:S.height)!==void 0&&S.height>0?S.height:(((I=S==null?void 0:S.lines)==null?void 0:I.length)||0)*C*o;if(h>0&&S&&S.lines&&S.lines.length>1){let _=0;const x=g.fullText||t;for(let F=0;F<S.lines.length-1;F++)_+=S.lines[F].text.length,(x[_]===`
5
+ `||x[_]==="\r")&&(M+=h,_++,x[_-1]==="\r"&&x[_]===`
6
+ `&&_++)}let w=(S==null?void 0:S.lines)||[];return p.composer==="every-line"&&w.length>1&&(w=Ms(w)),p.balanceRaggedLines===!0&&w.length>1&&(w=Is(w)),{width:a,height:M,lineCount:w.length,lines:w}}function ze(p,t,i){let o=String(p||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),s=new Array(e.length).fill(0);let n=t-(e.length-1)*i,a=0;if(e.forEach((r,h)=>{if(r.endsWith("px")){const l=parseFloat(r);s[h]=l,n-=l}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(s[h]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((h,l)=>{h.endsWith("fr")&&(s[l]=r*parseFloat(h))})}return s}function Ve(p,t,i){try{const o=p.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Ts(p,t,i):ks(p,t,i)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ks(p,t,i){var P,L;const o=p.autoLayout,{direction:e,spacing:s,padding:n,align:a,wrap:r}=o,h=e==="vertical",l=t.map(O=>{const W=i(O.id),B=O.geometry;let A=(W==null?void 0:W.width)??B.width??100,$=(W==null?void 0:W.height)??B.height??100;if(B.type==="Ellipse"||B.type==="Polygon"||B.type==="Star"){const Y=(W==null?void 0:W.radius)??B.radius??(W==null?void 0:W.outer_radius)??B.outer_radius??50;A=Y*2,$=Y*2}else if(B.type==="Text"){const Y=De({text:(W==null?void 0:W.text)??B.text??"",fontFamily:B.fontFamily,fontSize:B.fontSize,fontWeight:B.fontWeight,fontStyle:B.fontStyle,lineHeight:B.lineHeight,width:B.width||200,letterSpacing:B.letterSpacing,paragraphSpacing:B.paragraphSpacing,paragraphIndent:B.paragraphIndent,textCase:B.textCase,segments:B.segments,enableSegments:B.enableSegments});$=Y.height,B.width||(A=Y.width)}return A*=O.transform.scale_x||1,$*=O.transform.scale_y||1,{id:O.id,w:A,h:$,original:O}});let f=p.width,y=p.height;const d=((P=p.layoutProps)==null?void 0:P.width)==="hug",c=((L=p.layoutProps)==null?void 0:L.height)==="hug",u=[];let m=[],g=0,b=0;const v=f-n.left-n.right,C=y-n.top-n.bottom;l.forEach(O=>{r&&m.length>0&&(h?b+s+O.h>C:g+s+O.w>v)?(u.push({children:m,width:g,height:b}),m=[O],g=O.w,b=O.h):(m.push(O),h?(g=Math.max(g,O.w),b+=(m.length>1?s:0)+O.h):(g+=(m.length>1?s:0)+O.w,b=Math.max(b,O.h)))}),m.length>0&&u.push({children:m,width:g,height:b}),d&&!h&&(f=Math.max(...u.map(O=>O.width),0)+n.left+n.right),c&&h&&(y=Math.max(...u.map(O=>O.height),0)+n.top+n.bottom);const S=[];let M=n.left,w=n.top;const I=a.toLowerCase(),_=I==="center"||I.endsWith("-center"),x=I.endsWith("-right"),F=I==="center"||I.startsWith("center-"),T=I.startsWith("bottom-");return u.forEach(O=>{let W=M,B=w;h?F?B=n.top+(y-n.top-n.bottom-O.height)/2:T&&(B=y-n.bottom-O.height):_?W=n.left+(f-n.left-n.right-O.width)/2:x&&(W=f-n.right-O.width),O.children.forEach(A=>{var k,G;let $=W,Y=B;h?_?$+=(O.width-A.w)/2:x&&($+=O.width-A.w):F?Y+=(O.height-A.h)/2:T&&(Y+=O.height-A.h);const N=((k=A.original.layoutProps)==null?void 0:k.width)==="fill",E=((G=A.original.layoutProps)==null?void 0:G.height)==="fill";S.push({id:A.id,x:$+A.w/2-f/2,y:Y+A.h/2-y/2,width:N&&h?O.width:void 0,height:E?h?void 0:O.height:void 0}),h?B+=A.h+s:W+=A.w+s}),h?M+=O.width+s:w+=O.height+s}),{frameWidth:d?f:void 0,frameHeight:c?y:void 0,childUpdates:S}}function Ts(p,t,i){const o=p.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:s,columnGap:n=0,rowGap:a=0,padding:r,align:h}=o;let l=p.width,f=p.height;const y=l-r.left-r.right,d=f-r.top-r.bottom,c=ze(e||"1fr",y,n),u=ze(s||"auto",d,a),m=c.length>0?c.reduce((x,F)=>x+F,0)+(c.length-1)*n:0,g=u.length>0?u.reduce((x,F)=>x+F,0)+(u.length-1)*a:0,b=h.toLowerCase(),v=b==="center"||b.endsWith("-center"),C=b.endsWith("-right"),S=b==="center"||b.startsWith("center-"),M=b.startsWith("bottom-");let w=0,I=0;v?w=(y-m)/2:C&&(w=y-m),S?I=(d-g)/2:M&&(I=d-g);const _=[];return t.forEach((x,F)=>{var G,X;const T=F%c.length||0,P=Math.floor(F/c.length)||0;P>=u.length&&u.push(100);const L=c[T],O=u[P];let W=r.left+w+c.slice(0,T).reduce((J,tt)=>J+tt+n,0),B=r.top+I+u.slice(0,P).reduce((J,tt)=>J+tt+a,0);const A=i(x.id),$=x.geometry;let Y=(A==null?void 0:A.width)??$.width??100,N=(A==null?void 0:A.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const J=(A==null?void 0:A.radius)??$.radius??(A==null?void 0:A.outer_radius)??$.outer_radius??50;Y=J*2,N=J*2}Y*=x.transform.scale_x||1,N*=x.transform.scale_y||1;let E=W,k=B;v?E+=(L-Y)/2:C&&(E+=L-Y),S?k+=(O-N)/2:M&&(k+=O-N),_.push({id:x.id,x:E+Y/2-l/2,y:k+N/2-f/2,width:((G=x.layoutProps)==null?void 0:G.width)==="fill"?L:void 0,height:((X=x.layoutProps)==null?void 0:X.height)==="fill"?O:void 0})}),{childUpdates:_}}class Ne{constructor(){j(this,"world",null);j(this,"bodies",new Map);j(this,"colliders",new Map);j(this,"joints",new Map);j(this,"initialized",!1);j(this,"bodyIdByCollider",new Map);j(this,"onCollisionCB",null);j(this,"eventQueue",null)}setCollisionCallback(t){this.onCollisionCB=t}async init(t){this.initialized||(await ne.init(),this.world=new ne.World(new ne.Vector2(t.x*100,t.y*100)),this.eventQueue=new ne.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 ne.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?ne.RigidBodyDesc.fixed():ne.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=ne.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=ne.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=ne.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=ne.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 ne.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 ne.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 ne.Vector2(i,o),!0)}applyImpulse(t,i,o){const e=this.bodies.get(t);e&&e.applyImpulse(new ne.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 ne.Vector2(t.anchorA.x,t.anchorA.y),s=new ne.Vector2(t.anchorB.x,t.anchorB.y);let n;if(t.type==="Distance"){const a=t.length??100,r=t.stiffness??100,h=t.damping??10;n=ne.JointData.spring(a,r,h,e,s)}else n=ne.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 He=p=>p,_s=p=>p>0?1:0,Ps=p=>p<1?0:1,Ue=p=>p*p,qe=p=>p*(2-p),Je=p=>p<.5?2*p*p:-1+(4-2*p)*p,Es=p=>p*p*p,xs=p=>--p*p*p+1,As=p=>p<.5?4*p*p*p:(p-1)*(2*p-2)*(2*p-2)+1,Os=p=>p*p*p*p,Ls=p=>1- --p*p*p*p,Rs=p=>p<.5?8*p*p*p*p:1-8*--p*p*p*p,Fs=p=>p*p*p*p*p,$s=p=>1+--p*p*p*p*p,Ws=p=>p<.5?16*p*p*p*p*p:1+16*--p*p*p*p*p,Bs=p=>1-Math.cos(p*Math.PI/2),Gs=p=>Math.sin(p*Math.PI/2),Ys=p=>-(Math.cos(Math.PI*p)-1)/2,Xs=p=>p===0?0:Math.pow(2,10*(p-1)),Ds=p=>p===1?1:1-Math.pow(2,-10*p),zs=p=>p===0?0:p===1?1:p<.5?Math.pow(2,20*p-10)/2:(2-Math.pow(2,-20*p+10))/2,Vs=p=>1-Math.sqrt(1-p*p),Ns=p=>Math.sqrt(1- --p*p),Hs=p=>p<.5?(1-Math.sqrt(1-4*p*p))/2:(Math.sqrt(1-(-2*p+2)*(-2*p+2))+1)/2,Ae=1.70158,Oe=Ae*1.525,Qe=Ae+1,Us=p=>Qe*p*p*p-Ae*p*p,qs=p=>1+Qe*Math.pow(p-1,3)+Ae*Math.pow(p-1,2),Js=p=>p<.5?Math.pow(2*p,2)*((Oe+1)*2*p-Oe)/2:(Math.pow(2*p-2,2)*((Oe+1)*(p*2-2)+Oe)+2)/2,Ke=2*Math.PI/3,Ze=2*Math.PI/4.5,Qs=p=>p===0?0:p===1?1:-Math.pow(2,10*p-10)*Math.sin((p*10-10.75)*Ke),Ks=p=>p===0?0:p===1?1:Math.pow(2,-10*p)*Math.sin((p*10-.75)*Ke)+1,Zs=p=>p===0?0:p===1?1:p<.5?-(Math.pow(2,20*p-10)*Math.sin((20*p-11.125)*Ze))/2:Math.pow(2,-20*p+10)*Math.sin((20*p-11.125)*Ze)/2+1,Le=p=>p<1/2.75?7.5625*p*p:p<2/2.75?7.5625*(p-=1.5/2.75)*p+.75:p<2.5/2.75?7.5625*(p-=2.25/2.75)*p+.9375:7.5625*(p-=2.625/2.75)*p+.984375,js=p=>1-Le(1-p),ti=Le,ei=p=>p<.5?(1-Le(1-2*p))/2:(1+Le(2*p-1))/2,Ye=new Map,Te=(p,t,i,o)=>{const e=`${p},${t},${i},${o}`;if(Ye.has(e))return Ye.get(e);const s=l=>(1-3*i+3*p)*l*l*l+(3*i-6*p)*l*l+3*p*l,n=l=>(1-3*o+3*t)*l*l*l+(3*o-6*t)*l*l+3*t*l,a=l=>3*(1-3*i+3*p)*l*l+2*(3*i-6*p)*l+3*p,r=l=>{let f=l;for(let y=0;y<8;y++){const d=s(f)-l;if(Math.abs(d)<1e-6)return f;const c=a(f);if(Math.abs(c)<1e-6)break;f=f-d/c}return f},h=l=>l===0?0:l===1?1:n(r(l));return Ye.set(e,h),h},je=p=>{const t=p.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,i,o,e,s]=t.map(Number);return Te(i,o,e,s)},ts={ease:Te(.25,.1,.25,1),"ease-in":Te(.42,0,1,1),"ease-out":Te(0,0,.58,1),"ease-in-out":Te(.42,0,.58,1)},Re={Linear:He,EaseInQuad:Ue,EaseOutQuad:qe,EaseInOutQuad:Je,EaseInCubic:Es,EaseOutCubic:xs,EaseInOutCubic:As,EaseInQuart:Os,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Ws,EaseInSine:Bs,EaseOutSine:Gs,EaseInOutSine:Ys,EaseInExpo:Xs,EaseOutExpo:Ds,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Js,EaseInElastic:Qs,EaseOutElastic:Ks,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:Ue,EaseOut:qe,EaseInOut:Je,StepStart:_s,StepEnd:Ps},si=p=>{const t=p.trim(),i=t.toLowerCase();if(Re[t])return Re[t];const o=Object.keys(Re).find(s=>s.toLowerCase()===i);if(o)return Re[o];const e=Object.keys(es).find(s=>s.toLowerCase()===i);if(e){const s=je(es[e].value);if(s)return s}if(ts[i])return ts[i];if(i.startsWith("cubic-bezier")){const s=je(t);if(s)return s}return He},es={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=(p,t,i,o,e)=>{if(!p||!t||!i)return p;const s=o.scale_x??1,n=o.scale_y??1,a=(r,h,l)=>{let f=0,y=0;const d=o.rotation*Math.PI/180,c=Math.cos(d),u=Math.sin(d),m=r*s*c-h*n*u+o.x,g=r*s*u+h*n*c+o.y;l.forEach(I=>{const _=e(I.boneId);if(!_)return;const x={x:_.x,y:_.y,rotation:_.rotation,scaleX:_.scale_x??1,scaleY:_.scale_y??1},F=i[I.boneId]||[1,0,0,1,0,0],T=m*F[0]+g*F[2]+F[4],P=m*F[1]+g*F[3]+F[5],L=x.rotation*Math.PI/180,O=Math.cos(L),W=Math.sin(L),B=T*x.scaleX*O-P*x.scaleY*W+x.x,A=T*x.scaleX*W+P*x.scaleY*O+x.y;f+=B*I.amount,y+=A*I.amount});const b=[...l].sort((I,_)=>_.amount-I.amount);if(b.length>=2&&b[0].amount>0&&b[1].amount>0){const I=e(b[0].boneId),_=e(b[1].boneId);if(I&&_&&I.length!==void 0&&_.length!==void 0){const x=I.length*(I.scale_y??1),F=I.rotation*Math.PI/180,T=I.x-x*Math.sin(F),P=I.y+x*Math.cos(F),L=_.length*(_.scale_y??1),O=_.rotation*Math.PI/180,W=_.x-L*Math.sin(O),B=_.y+L*Math.cos(O);let A=null,$=null,Y=!1;const N=1;if(Math.hypot(I.x-_.x,I.y-_.y)<N||Math.hypot(I.x-W,I.y-B)<N?(A=I.x,$=I.y):(Math.hypot(T-_.x,P-_.y)<N||Math.hypot(T-W,P-B)<N)&&(A=T,$=P,Y=!0),A!==null&&$!==null){const E=i[b[0].boneId]||[1,0,0,1,0,0],k=E[0]*E[3]-E[1]*E[2];let G=0,X=0;if(k!==0){const J=(E[2]*E[5]-E[3]*E[4])/k,tt=(E[1]*E[4]-E[0]*E[5])/k,lt=Math.atan2(-E[1],E[3]);if(!Y)G=J,X=tt;else{const at=-E[2]/k,Et=E[0]/k,xt=Math.hypot(at,Et),bt=I.length*xt;G=J-bt*Math.sin(lt),X=tt+bt*Math.cos(lt)}const Z=Math.hypot(m-G,g-X),pt=Math.hypot(f-A,y-$);if(pt>0&&Z>0){const at=Math.max(pt,.01),Et=Math.min(Z/at,3),xt=A+(f-A)*Et,bt=$+(y-$)*Et,Gt=b[0].amount,Wt=b[1].amount,_t=Math.min(Gt,Wt)*2,Nt=1-Math.pow(1-_t,4);f=f*(1-Nt)+xt*Nt,y=y*(1-Nt)+bt*Nt}}}}}const v=o.rotation*Math.PI/180,C=Math.cos(v),S=Math.sin(v),M=f-o.x,w=y-o.y;return{x:(M*C+w*S)/s,y:(-M*S+w*C)/n}};return p.map((r,h)=>{const l=t[h];if(!l||l.length===0)return{...r};const f={...r,...a(r.x,r.y,l)};if(r.in_x!==void 0&&r.in_y!==void 0){const y=a(r.in_x,r.in_y,l);f.in_x=y.x,f.in_y=y.y}if(r.out_x!==void 0&&r.out_y!==void 0){const y=a(r.out_x,r.out_y,l);f.out_x=y.x,f.out_y=y.y}return f})};function ni(p,t,i,o,e){const s=p*i*.01,n=t*i*.01,a=Math.sin(e*12.9898)*43758.5453%(Math.PI*2),r=Math.cos(e*78.233)*43758.5453%(Math.PI*2);return(Math.sin(s+a)*Math.cos(n+r)+.5*Math.sin(s*2.1-r)*Math.cos(n*2.3+a)+.25*Math.sin(s*4.5+a)*Math.cos(n*4.2-r))/1.75*o}function oi(p,t,i,o,e,s,n=0,a=0){const r=[];if(!p)return[];const h=p.type;if(h==="Rectangle"||h==="Image"||h==="Frame"){const c=Math.max(20,Math.floor((t+i)/10)),u=Math.max(2,Math.floor(c*(t/(t+i)))),m=Math.max(2,Math.floor(c*(i/(t+i))));for(let g=0;g<u;g++)r.push({x:-t/2+t/u*g,y:-i/2,nx:0,ny:-1});for(let g=0;g<m;g++)r.push({x:t/2,y:-i/2+i/m*g,nx:1,ny:0});for(let g=0;g<u;g++)r.push({x:t/2-t/u*g,y:i/2,nx:0,ny:1});for(let g=0;g<m;g++)r.push({x:-t/2,y:i/2-i/m*g,nx:-1,ny:0})}else if(h==="Ellipse"){const c=Math.max(60,Math.floor(Math.PI*Math.max(t,i)/5));for(let u=0;u<c;u++){const m=u/c*Math.PI*2,g=Math.cos(m),b=Math.sin(m);r.push({x:g*t/2,y:b*i/2,nx:g,ny:b})}}else if(h==="Triangle"){const c={x:0,y:-i/2},u={x:t/2,y:i/2},m={x:-t/2,y:i/2},g=20;let b=u.x-c.x,v=u.y-c.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<g;w++)r.push({x:c.x+b*(w/g),y:c.y+v*(w/g),nx:S,ny:M});b=m.x-u.x,v=m.y-u.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<g;w++)r.push({x:u.x+b*(w/g),y:u.y+v*(w/g),nx:S,ny:M});b=c.x-m.x,v=c.y-m.y,C=Math.hypot(b,v),S=-v/C,M=b/C;for(let w=0;w<g;w++)r.push({x:m.x+b*(w/g),y:m.y+v*(w/g),nx:S,ny:M})}else for(let u=0;u<80;u++){const m=u/80*Math.PI*2,g=Math.cos(m),b=Math.sin(m);r.push({x:g*t/2,y:b*i/2,nx:g,ny:b})}const l=n*Math.PI/180,f=Math.cos(l),y=Math.sin(l);return r.map(c=>{const u=ni(c.x,c.y,e,o,s),m=c.nx*(1-a)+f*a,g=c.ny*(1-a)+y*a;let b=Math.hypot(m,g);return b===0&&(b=1),{x:c.x+m/b*u,y:c.y+g/b*u}})}const ss={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}},is={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 ns{constructor(){j(this,"artboard",null);j(this,"objectStates",new Map);j(this,"physicsEngine",null);j(this,"activeStateMachine",null);j(this,"inputs",new Map);j(this,"inputNameMap",new Map);j(this,"layerStates",new Map);j(this,"pretextCache",new Map);j(this,"pointerHistory",[]);j(this,"MAX_HISTORY",200);j(this,"imageCache",new Map);j(this,"lastValidSvgImgMap",new Map);j(this,"maskBuffer",null);j(this,"maskCtx",null);j(this,"lumaBuffer",null);j(this,"lumaCtx",null);j(this,"_noiseTileCanvas",null);j(this,"layout",{fit:"Contain",alignment:"Center"});j(this,"onTrigger");j(this,"onInputUpdate");j(this,"onComponentChange");j(this,"onToggle");j(this,"onInputChange");j(this,"onInputFocus");j(this,"onInputBlur");j(this,"onLog");j(this,"onButtonClick");j(this,"onGraphPointClick");j(this,"justFiredTriggers",new Set);j(this,"rootTransform",null);j(this,"canvasWidth",0);j(this,"canvasHeight",0);j(this,"lastHoveredObjectId",null);j(this,"_lastPointerPos",null);j(this,"_prevPointerPos",null);j(this,"focusedId",null);j(this,"draggingSliderId",null);j(this,"activeDropdownId",null);j(this,"activeObjectId",null);j(this,"draggingListViewId",null);j(this,"scrollOffset",{x:0,y:0});j(this,"_totalScroll",{x:0,y:0});j(this,"draggingBehaviors",new Set);j(this,"isMouseDown",!1);j(this,"_layoutAnimCache",new Map);j(this,"_springChainState",new Map);j(this,"_emitterPools",new Map);j(this,"objectVelocities",new Map);j(this,"currentTime",0);j(this,"frameCount",0);j(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});j(this,"onLogicUpdate");j(this,"logicNodeValues",new Map);j(this,"logicNodeState",new Map);j(this,"pointerDownTimes",new Map);j(this,"activeHoverIds",new Set);j(this,"onNavigation");j(this,"periodicTriggerTimes",new Map);j(this,"wasInView",new Set);j(this,"scrollProgressLastValue",new Map);j(this,"debug_objectsRendered",0);j(this,"debug_objectsTotal",0);j(this,"lastRenderTime",0);j(this,"debugMode",!1);j(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points: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,h=0,l=0,f=0,y;for(;(y=i.exec(t))!==null;){const d=y[1],c=(y[2].match(o)||[]).map(parseFloat),u=d===d.toLowerCase(),m=d.toUpperCase();let g=0;const b=C=>{let S=c[g++];return u&&(S+=C?n:a),S},v=()=>({x:b(!0),y:b(!1)});switch(m){case"M":{const C=v();for(l=n=C.x,f=a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});g<c.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"L":for(;g<c.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"H":for(;g<c.length;)n=b(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;g<c.length;)a=b(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;g<c.length;){const C=v(),S=v(),M=v();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=M.x,a=M.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,h=S.y}break;case"S":for(;g<c.length;){const C={x:2*n-r,y:2*a-h},S=v(),M=v();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=M.x,a=M.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,h=S.y}break;case"Q":for(;g<c.length;){const C=v(),S=v();if(e.length>0){const M=e[e.length-1];M.out_x=M.x+2/3*(C.x-M.x),M.out_y=M.y+2/3*(C.y-M.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,h=C.y}break;case"T":for(;g<c.length;){const C={x:2*n-r,y:2*a-h},S=v();if(e.length>0){const M=e[e.length-1];M.out_x=M.x+2/3*(C.x-M.x),M.out_y=M.y+2/3*(C.y-M.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,h=C.y}break;case"Z":if(s=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const S=[...e].reverse().find(M=>M.moveTo)||e[0];S&&Math.hypot(S.x-C.x,S.y-C.y)<.1&&(S.in_x=C.in_x,S.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=l,a=f;break;default:if(c.length>=2){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}}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(h=>{if(e.has(h.id))return;const l={...h},f=l.childrenObjects||[];e.add(l.id),o.push(l),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(h=>{r.set(h.id,h),h.children||(h.children=[])}),this.artboard.objects.forEach(h=>{if(h.parentId){const l=r.get(h.parentId);l&&(l.children||(l.children=[]),l.children.includes(h.id)||l.children.push(h.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=Cs.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,h,l,f,y;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)??((h=i.geometry)==null?void 0:h.cornerRadius)??0;this.objectStates.set(i.id,{...i.transform||{},x:((l=i.transform)==null?void 0:l.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:((y=i.transform)==null?void 0:y.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 Ne;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,h=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:h,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=>{let o=i.value;if(i.type==="RandomNumber"){const s=i.min!==void 0?i.min:0,n=i.max!==void 0?i.max:100;o=s+Math.random()*(n-s)}else if(i.type==="RandomColor"){const s=i.minAlpha!==void 0?i.minAlpha:.2,n=i.maxAlpha!==void 0?i.maxAlpha:1,a=Math.floor(Math.random()*256),r=Math.floor(Math.random()*256),h=Math.floor(Math.random()*256),l=s+Math.random()*(n-s);o=`rgba(${a}, ${r}, ${h}, ${l.toFixed(2)})`}this.inputs.set(i.id,o);const e=this.inputNameMap.get(i.name)||[];e.includes(i.id)||e.push(i.id),this.inputNameMap.set(i.name,e)}),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 h=Math.abs(r.x-a.x),l=Math.abs(r.y-a.y);!t&&(h>20||l>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=Ve(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var r;const a=n.type==="Component"&&(!n.variant||n.variant==="artboard"||n.variant==="instance");if((n.type==="Frame"||a)&&((r=n.autoLayout)!=null&&r.enabled)&&n.children&&n.children.length>0){const h=n.children.map(y=>i.get(y)).filter(y=>!!y),l=this.objectStates.get(n.id);if(!l)return;const f=Ve(l,h,y=>this.objectStates.get(y));f.frameWidth!==void 0&&(l.width=f.frameWidth),f.frameHeight!==void 0&&(l.height=f.frameHeight),e(f.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let 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 h=a.states.find(l=>l.id===r);if(h){let l=null;h.animationId&&(l=this.artboard.animations.find(f=>f.id===h.animationId)||null),l||(l=this.artboard.animations.find(f=>{var y,d;return f.name===h.name||f.id===h.name||(h.name==="Entry"||h.id==="entry")&&(((y=f.name)==null?void 0:y.toLowerCase())==="onload"||((d=f.name)==null?void 0:d.toLowerCase())==="intro")})||null),l&&((n=this.artboard.animationFlow)!=null&&n.some(y=>(y.trigger==="on_load"||y.trigger==="after_delay")&&y.targetAnimationId===(l==null?void 0:l.id))||(e.push({animation:l,state:h}),s=Math.max(s,l.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}resolveRandomValue(t){if(t.type==="RandomNumber"){const i=t.min!==void 0?t.min:0,o=t.max!==void 0?t.max:100;return i+Math.random()*(o-i)}else if(t.type==="RandomColor"){const i=t.minAlpha!==void 0?t.minAlpha:.2,o=t.maxAlpha!==void 0?t.maxAlpha:1,e=Math.floor(Math.random()*256),s=Math.floor(Math.random()*256),n=Math.floor(Math.random()*256),a=i+Math.random()*(o-i);return`rgba(${e}, ${s}, ${n}, ${a.toFixed(2)})`}return t.value}updateInput(t,i){var a,r,h,l,f,y,d;let o;if(this.inputs.has(t)){const c=(a=this.activeStateMachine)==null?void 0:a.inputs.find(u=>u.id===t);c&&typeof c.value=="object"&&(o=c.value.type)}else{const c=this.inputNameMap.get(t);if(c&&c.length>0){const u=(r=this.activeStateMachine)==null?void 0:r.inputs.find(m=>m.id===c[0]);u&&typeof u.value=="object"&&(o=u.value.type)}}let e=(l=(h=this.artboard)==null?void 0:h.stateVariables)==null?void 0:l.find(c=>c.id===t||c.name===t);if(!e){const c=this.inputNameMap.get(t);c&&c.length>0&&(e=(y=(f=this.artboard)==null?void 0:f.stateVariables)==null?void 0:y.find(u=>u.id===c[0]))}let s=e&&(e.type==="RandomNumber"||e.type==="RandomColor")?this.resolveRandomValue(e):i;o==="Trigger"&&(i===1?s=!0:i===0&&(s=!1)),this.inputs.has(t)&&this.inputs.get(t)!==s&&this.setInternalInput(t,s);const n=this.inputNameMap.get(t);n&&n.forEach(c=>{this.inputs.get(c)!==s&&this.setInternalInput(c,s)}),o==="Trigger"&&s===!0&&(this.justFiredTriggers.add(t),n&&n.forEach(c=>this.justFiredTriggers.add(c))),Array.isArray(s)&&((d=this.artboard)==null||d.objects.forEach(c=>{if(c.inputId===t||c.name===t){const u=this.objectStates.get(c.id);u&&u.options&&(c.type==="ListView"||c.variant==="listview"?u.options.items=s:(c.type==="Dropdown"||c.variant==="dropdown")&&(u.options.optionsList=s))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,s)}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 h=!1;switch(a){case"Equal":case"==":h=i==r;break;case"NotEqual":case"!=":h=i!=r;break;case"GreaterThan":case">":h=i>r;break;case"LessThan":case"<":h=i<r;break;case"GreaterEqual":case">=":h=i>=r;break;case"LessEqual":case"<=":h=i<=r;break;case"IsTrue":h=!!i;break;case"IsFalse":h=!i;break}if(h){const l=s.delay||0;l<=0?this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id):setTimeout(()=>this.triggerGlobalAnimation(s.targetAnimationId,s.subAnimationIds,s.loop,s.id),l)}}})}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(h=>h.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,h,l,f,y;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(d=>d.id===t);if(e){const d=(u,m)=>{const g=e.inputs.find(b=>b.id===u);return g?g.sourceId?this.evaluateLogicTree(g.sourceId,g.sourceHandleId,o):g.value!==void 0?g.value:m:m};let c=0;switch(e.op){case wt.AND:c=d("a",!1)&&d("b",!1);break;case wt.OR:c=d("a",!1)||d("b",!1);break;case wt.NOT:c=!d("in",!1);break;case wt.XOR:c=!!d("a",!1)!=!!d("b",!1);break;case wt.OBJECT:c=e.name;break;case wt.PROPERTY:case wt.GET_PROPERTY:{const u=d("id","");if(!u){c=0;break}const m=e.name;if(!m||m==="GET_PROPERTY"||m==="PROPERTY"){c=0;break}const g=this.objectStates.get(u);if(!g){c=0;break}m in g?c=g[m]:c=this.resolvePath(g,m);break}case wt.SET_PROPERTY:{const u=d("id",""),m=d("value",void 0);if(!u||m===void 0){c=0;break}const g=e.name;if(!g||g==="SET_PROPERTY"){c=0;break}const b=this.objectStates.get(u);if(!b){c=0;break}if(["x","y","rotation","scale_x","scale_y","skew_x","skew_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(g))b[g]=m,c=m;else{const C=g.split(".");let S=b;for(let w=0;w<C.length-1;w++){const I=C[w];S[I]===void 0&&(S[I]={}),S=S[I]}const M=C[C.length-1];S[M]=m,c=m}break}case wt.ADD:c=d("a",0)+d("b",0);break;case wt.SUB:c=d("a",0)-d("b",0);break;case wt.MUL:c=d("a",0)*d("b",0);break;case wt.DIV:{const u=d("b",1);c=u===0?0:d("a",0)/u;break}case wt.MOD:c=d("a",0)%d("b",1);break;case wt.POW:c=Math.pow(d("a",0),d("b",1));break;case wt.ABS:c=Math.abs(d("in",0));break;case wt.ROUND:c=Math.round(d("in",0));break;case wt.FLOOR:c=Math.floor(d("in",0));break;case wt.CEIL:c=Math.ceil(d("in",0));break;case wt.SIN:c=Math.sin(d("in",0));break;case wt.COS:c=Math.cos(d("in",0));break;case wt.TAN:c=Math.tan(d("in",0));break;case wt.CLAMP:{const u=d("in",0),m=d("min",0),g=d("max",1);c=Math.max(m,Math.min(g,u));break}case wt.REMAP:{const u=d("in",0),m=d("inMin",0),g=d("inMax",100),b=d("outMin",0),v=d("outMax",1);c=g===m?b:b+(u-m)*(v-b)/(g-m);break}case wt.EQ:c=d("a",0)==d("b",0);break;case wt.NEQ:c=d("a",0)!=d("b",0);break;case wt.GT:c=d("a",0)>d("b",0);break;case wt.LT:c=d("a",0)<d("b",0);break;case wt.GTE:c=d("a",0)>=d("b",0);break;case wt.LTE:c=d("a",0)<=d("b",0);break;case wt.IF_ELSE:c=d("cond",!1)?d("then",0):d("else",0);break;case wt.VALUE:c=e.value!==void 0?e.value:0;break;case wt.INPUT:c=this.inputs.get(e.name)??0;break;case wt.LOG:{const u=d("in","");this.debugLog(`[User Logic] ${u}`),c=u;break}case wt.SCROLL_X:c=this.inputs.get("scrollX")??0;break;case wt.SCROLL_Y:c=this.inputs.get("scrollY")??0;break;case wt.MOUSE_X:c=this.inputs.get("mouseX")??0;break;case wt.MOUSE_Y:c=this.inputs.get("mouseY")??0;break;case wt.IS_MOUSE_DOWN:c=this.inputs.get("isMouseDown")??!1;break;case wt.EFFECTOR:{const u=d("id",""),m=d("intensity",1),g=d("trigger",!0);if(!u||!g){c=0;break}const b=e.name;if(!b){c=0;break}const v=this.objectStates.get(u);if(!v){c=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(b))v.style||(v.style={}),v.style.artEffect={enabled:!0,type:b,intensity:m},c=1;else{v.behaviors||(v.behaviors=[]);let S=v.behaviors.find(M=>M.type===b);S?(S.enabled=!0,S.settings||(S.settings={}),S.settings.intensity=m):(S={id:`eff_${Date.now()}_${b}`,type:b,enabled:!0,sensors:[],settings:{intensity:m}},v.behaviors.push(S)),c=1}break}case wt.MONITOR:{c=d("in",0);break}case wt.SPRING_PULL:{const u=d("objectId",""),m=d("forceX",0),g=d("forceY",0);u&&((h=this.artboard)==null||h.objects.forEach(b=>{b.behaviors&&b.behaviors.forEach(v=>{var C;if(v.type===z.SpringChain&&((C=v.settings)!=null&&C.connections)&&(v.settings.connections.some(M=>M.targetId===u)||b.id===u)){this._springChainState.has(b.id)||this._springChainState.set(b.id,new Map);const M=this._springChainState.get(b.id);if(!M.has(u)){const I=this.objectStates.get(u);M.set(u,{x:(I==null?void 0:I.x)??0,y:(I==null?void 0:I.y)??0,vx:0,vy:0})}const w=M.get(u);w&&(w.vx+=m,w.vy+=g)}})})),c=1;break}case wt.SPRING_SETTLE:{const u=d("objectId","");let m=!0;if(u){const g=d("threshold",1);this._springChainState.forEach(b=>{const v=b.get(u);v&&(Math.abs(v.vx)>g||Math.abs(v.vy)>g)&&(m=!1)})}c=m;break}case wt.EMIT:{const u=d("objectId",""),m=d("count",20);u&&((l=this.artboard)==null||l.objects.forEach(g=>{g.behaviors&&g.behaviors.forEach(b=>{b.type===z.ParticleEmitter&&g.id===u&&(b._pendingBurst=(b._pendingBurst||0)+m)})})),c=1;break}default:c=0;break}if(this.logicNodeValues.set(t,c),e.op===wt.DELAY){const u=d("delay",0),m=d("in",0);let g=this.logicNodeState.get(t);for(g||(g={queue:[]},this.logicNodeState.set(t,g)),g.queue.push({time:this.currentTime+u,value:m});g.queue.length>0&&g.queue[0].time<=this.currentTime;)g.lastValue=g.queue.shift().value;c=g.lastValue??0}return c}const s=(f=this.activeStateMachine)==null?void 0:f.inputs.find(d=>d.id===t||d.name===t);if(s&&s.sourceId&&!o.has(s.sourceId)){const d=this.evaluateLogicTree(s.sourceId,s.sourceHandleId,o);return this.inputs.set(s.id,d),d}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 d=(y=this.activeStateMachine)==null?void 0:y.inputs.find(c=>c.id===t);if(d&&d.value.type==="Number"&&typeof n=="number"){const c=d.value.defaultValue??d.value.value;if(i==="source-greater")return n>c;if(i==="source-less")return n<c;if(i==="source-equal")return n===c}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(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));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=>{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,h,l,f;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(s=this.artboard)==null?void 0:s.objects.find(y=>y.id===e))==null?void 0:n.triggers)==null||a.find(y=>y.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 y=(l=(h=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:h.triggers)==null?void 0:l.find(u=>u.id===o.triggerId),d=(y==null?void 0:y.duration)||0;o.elapsedHold+=t*1e3;let c=o.elapsedHold>=d;if((y==null?void 0:y.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(c=!0),((y==null?void 0:y.eventType)==="onHold"||(y==null?void 0:y.eventType)==="pointerDown")&&!this.isMouseDown&&(c=!0),c)if(y!=null&&y.exitAnimationId){const u=(f=this.artboard)==null?void 0:f.animations.find(m=>m.id===y.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.evaluateLogicProperties(t)}evaluateLogicProperties(t){this.artboard&&this.artboard.objects.forEach(i=>{const o=i.logicProperties;if(o&&o.length>0){const e=this.objectStates.get(i.id);if(!e)return;o.forEach(s=>{var a,r,h;let n=null;if(s.valueType==="constant"||s.valueType==="boolean"||s.valueType==="color")n=s.value;else if(s.valueType==="variable"&&s.variableId){if(n=this.inputs.get(s.variableId),n===void 0){const l=(r=(a=this.activeStateMachine)==null?void 0:a.inputs)==null?void 0:r.find(f=>f.id===s.variableId||f.name===s.variableId);l&&(n=this.inputs.get(l.id)??((h=l.value)==null?void 0:h.value)??l.value)}}else if(s.valueType==="expression"&&s.formula)try{let l=s.formula;this.inputs.forEach((f,y)=>{const d=new RegExp(`\\b${y}\\b`,"g");l=l.replace(d,JSON.stringify(f))}),n=Function(`"use strict"; return (${l})`)()}catch(l){this.debugLog(`Failed to evaluate expression: ${s.formula}, error: ${l}`)}else if(s.valueType==="object_ref"&&s.objectId){const l=this.objectStates.get(s.objectId);if(l){let f=s.refProperty;f==="cornerRadius"&&(f="corner_radius");let y=l[f];y===void 0&&l.geometry&&(y=l.geometry[f]),f==="width"&&typeof y=="number"&&l.scale_x?y=y*Math.abs(l.scale_x):f==="height"&&typeof y=="number"&&l.scale_y&&(y=y*Math.abs(l.scale_y)),y!=null&&(n=y,typeof n=="number"&&typeof s.offset=="number"&&(n+=s.offset))}}if(n!=null){let l=s.name;if(l==="cornerRadius"&&(l="corner_radius"),l==="width"||l==="height"||l==="corner_radius")l==="width"&&typeof n=="number"&&e.scale_x&&Math.abs(e.scale_x)>.001?n=n/Math.abs(e.scale_x):l==="height"&&typeof n=="number"&&e.scale_y&&Math.abs(e.scale_y)>.001&&(n=n/Math.abs(e.scale_y)),e[l]=n,e.geometry&&(e.geometry[l]=n);else if(l==="x"||l==="y"||l==="rotation"||l==="scale_x"||l==="scale_y"||l==="skew_x"||l==="skew_y")e[l]=n;else if(l.startsWith("style.")){const f=l.split(".");f.length===3&&e.style&&e.style[f[1]]&&(e.style[f[1]][f[2]]=n)}else e[l]=n}})}})}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),h=(((s=i.geometry)==null?void 0:s.width)||100)*(r.scale_x||1),l=(((n=i.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),f=50,y=r.x+h/2>=-this.canvasWidth/2-f&&r.x-h/2<=this.canvasWidth/2+f&&r.y+l/2>=-this.canvasHeight/2-f&&r.y-l/2<=this.canvasHeight/2+f,d=`analytics_${i.id}`,c=this.wasInView.has(d);y&&!c&&this.fireAnalyticsEvent(i.id,"visible"),y?this.wasInView.add(d):this.wasInView.delete(d)}}}),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,h,l;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const f=e.intervalValue||2e3,y=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-y>=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 y=this.getGlobalTransform(i.id),d=(((r=i.geometry)==null?void 0:r.width)||100)*(y.scale_x||1),c=(((h=i.geometry)==null?void 0:h.height)||100)*(y.scale_y||1),u=50,m=y.x+d/2>=-this.canvasWidth/2-u&&y.x-d/2<=this.canvasWidth/2+u&&y.y+c/2>=-this.canvasHeight/2-u&&y.y-c/2<=this.canvasHeight/2+u,g=this.wasInView.has(i.id);m&&!g&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(i.id,"Scroll Into View"),m?this.wasInView.add(i.id):this.wasInView.delete(i.id)}}if(a==="scroll progress"||a==="scrollprogress"){const f=Math.abs(this.scrollOffset.y)/(((l=this.artboard)==null?void 0:l.height)||1e3),y=this.scrollProgressLastValue.get(e.id)||0;Math.abs(f-y)>.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 l,f,y,d,c,u,m,g,b;const a=((l=o.constraints)==null?void 0:l[n])||{},r={...s,...a},h=r.strength??1;if(r.type==="Translation"){const v=this.getGlobalTransform(r.targetId);if(v){const C=r.offsetX||0,S=r.offsetY||0,M=v.x+C,w=v.y+S,I=r.useSpring;if(I){const x=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:F,y:T,vx:P,vy:L}=this.computeSpring(e.x,e.y,x.vx,x.vy,M,w,r,t);r.copyX&&(e.x=e.x+(F-e.x)*h),r.copyY&&(e.y=e.y+(T-e.y)*h),this.objectVelocities.set(i.id,{vx:P,vy:L})}else r.copyX&&(e.x=e.x+(M-e.x)*h),r.copyY&&(e.y=e.y+(w-e.y)*h);let _=!1;if((f=r.limitX)!=null&&f.enabled){const x=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==x&&(_=!0)}if((y=r.limitY)!=null&&y.enabled){const x=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==x&&(_=!0)}_&&I&&this.objectVelocities.set(i.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const v=this.getGlobalTransform(r.targetId);if(v){let S=(v.rotation+(r.offset||0)-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*h}}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)*h),r.copyY&&(e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*h))}else if(r.type==="Transform"){const v=this.getGlobalTransform(r.targetId);if(v){e.x=e.x+(v.x-e.x)*h,e.y=e.y+(v.y-e.y)*h;let C=(v.rotation-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*h,e.scale_x=e.scale_x+(v.scale_x-e.scale_x)*h,e.scale_y=e.scale_y+(v.scale_y-e.scale_y)*h}}else if(r.type==="FollowPointer"){const v=((d=this._lastPointerPos)==null?void 0:d.x)??e.x,C=((c=this._lastPointerPos)==null?void 0:c.y)??e.y,S=r.useSpring;if(S){const w=this.objectVelocities.get(i.id)||{vx:0,vy:0},{x:I,y:_,vx:x,vy:F}=this.computeSpring(e.x,e.y,w.vx,w.vy,v,C,r,t);e.x=I,e.y=_,this.objectVelocities.set(i.id,{vx:x,vy:F})}else e.x=e.x+(v-e.x)*h,e.y=e.y+(C-e.y)*h;let M=!1;if((u=r.limitX)!=null&&u.enabled){const w=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==w&&(M=!0)}if((m=r.limitY)!=null&&m.enabled){const w=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==w&&(M=!0)}M&&S&&this.objectVelocities.set(i.id,{vx:0,vy:0})}else if(r.type==="Distance"){const v=this.getGlobalTransform(r.targetId);if(v){const C=e.x-v.x,S=e.y-v.y,M=Math.sqrt(C*C+S*S),w=r.distance||0;let I=M;switch(r.mode){case"exact":I=w;break;case"minimum":I=Math.max(w,M);break;case"maximum":I=Math.min(w,M);break;case"clamped":I=Math.max(0,Math.min(w,M));break}if(M>0){const _=e.x===v.x&&e.y===v.y?1:I/M;e.x=e.x+(v.x+C*_-e.x)*h,e.y=e.y+(v.y+S*_-e.y)*h}}}else if(r.type==="FollowPath"){const v=(g=this.artboard)==null?void 0:g.objects.find(C=>C.id===r.targetId);if(v){const C=this.getGlobalTransform(v.id);if(C){let S=v.geometry;if(v.type==="Frame"||v.type==="Group"||!S||S.type!=="Path"&&S.type!=="Ellipse"&&S.type!=="Rectangle"){const k=(b=this.artboard)==null?void 0:b.objects.find(G=>G.parentId===v.id&&G.type==="Shape"&&G.geometry&&(G.geometry.type==="Path"||G.geometry.type==="Ellipse"||G.geometry.type==="Rectangle"));k&&(S=k.geometry)}if(!S)return;const M=(r.distance||0)/100,w=C.width||S.width||0,I=C.height||S.height||0,_=this.getPointOnPath(S,w,I,M),x=C.rotation*Math.PI/180,F=Math.cos(x),T=Math.sin(x),P=_.x*C.scale_x*F-_.y*C.scale_y*T,L=_.x*C.scale_x*T+_.y*C.scale_y*F;let O=C.rotation+(r.offsetRotation||0);if(r.orient){const k=Math.cos(_.angle),G=Math.sin(_.angle),X=k*C.scale_x*F-G*C.scale_y*T,J=k*C.scale_x*T+G*C.scale_y*F;O=Math.atan2(J,X)*180/Math.PI+(r.offsetRotation||0)}const W=O*Math.PI/180,B=Math.cos(W),A=Math.sin(W),$=(r.offsetX||0)*B-(r.offsetY||0)*A,Y=(r.offsetX||0)*A+(r.offsetY||0)*B,N=C.x+P+$,E=C.y+L+Y;if(e.x=e.x+(N-e.x)*h,e.y=e.y+(E-e.y)*h,r.orient){let k=(O-e.rotation)%360;k>180&&(k-=360),k<-180&&(k+=360),e.rotation=e.rotation+k*h}}}}else if(r.type==="IK"){const v=this.getGlobalTransform(r.targetId);v&&this.solveIK(i,v,r.boneCount||2,h)}}),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,y;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(d=>d.id===t),e=(o==null?void 0:o.type)==="Bone"?(y=o.geometry)==null?void 0:y.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),h=s.x+(i.x*s.scale_x*a-i.y*s.scale_y*r),l=s.y+(i.x*s.scale_x*r+i.y*s.scale_y*a);return{x:h,y:l,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),h=i.x-o.x,l=i.y-o.y,f=(h*a-l*r)*e,y=(h*r+l*a)*s;return{x:f,y,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 h;const s=[];let n=t.id;for(let l=0;l<o&&n;l++){const f=(h=this.artboard)==null?void 0:h.objects.find(y=>y.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 l=0;l<r;l++){const f=this.getGlobalTransform(t.id);for(let y=a.length-2;y>=0;y--){const d=a[y],c=this.getGlobalTransform(d.id),u=f.x-c.x,m=f.y-c.y,g=i.x-c.x,b=i.y-c.y,v=Math.sqrt(u*u+m*m),C=Math.sqrt(g*g+b*b);if(v>.001&&C>.001){const S=Math.atan2(m,u);let w=(Math.atan2(b,g)-S)*180/Math.PI;w*=e;const I=this.objectStates.get(d.id);I&&(I.rotation+=w)}}}}computeSpring(t,i,o,e,s,n,a,r){const h=a.stiffness??100,l=a.damping??10,f=a.mass??1,y=-h*(t-s),d=-h*(i-n),c=-l*o,u=-l*e,m=(y+c)/f,g=(d+u)/f,b=o+m*r,v=e+g*r,C=t+b*r,S=i+v*r;return{x:C,y:S,vx:b,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.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,h,l,f,y;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=(d,c)=>{var C;let u=c;c==="click"?u="onClick":c==="down"?u="onPointerDown":c==="up"?u="onPointerUp":c==="blur"&&(u="onPointerLeave");const m=new Set([u]);c==="move"&&m.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&m.add("click"),u==="onPointerDown"&&m.add("pointerDown"),u==="onPointerUp"&&m.add("pointerUp");const g=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup"];return!!(d.type==="Component"&&g.includes(d.variant)||g.includes((C=d.type)==null?void 0:C.toLowerCase())||(d.interactions||[]).some(S=>S.event&&m.has(S.event)?!0:S.triggers&&Array.isArray(S.triggers)?S.triggers.some(M=>{if(!M)return!1;const w=M.toLowerCase();return Array.from(m).some(I=>I.toLowerCase()===w||I.toLowerCase()==="on"+w)}):!1)||(d.triggers||[]).some(S=>m.has(S.eventType)))};let n=null;for(let d=this.artboard.objects.length-1;d>=0;d--){const c=this.artboard.objects[d],u=this.objectStates.get(c.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(c,i,o)&&(n||(n=c),s(c,t))){e=c;break}}!e&&n&&(e=n),(t==="down"||t==="click")&&this.log(`[Engine] Pointer ${t} at (${Math.round(i)},${Math.round(o)}). Hit: ${(e==null?void 0:e.id)||"none"}, TopHit: ${(n==null?void 0:n.id)||"none"}`),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 d=this.artboard.objects.find(c=>c.id===this.draggingSliderId);d&&this.updateSliderValueFromPointer(d,i,o);return}if(this.draggingListViewId){const d=this.artboard.objects.find(c=>c.id===this.draggingListViewId);d&&this.updateListViewScrollFromPointer(d);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.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(d=>d.type===z.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(d=>{d!==a&&this.activeHoverIds.delete(d)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const d=this.artboard.objects.find(c=>c.id===this.activeDropdownId);if(d&&(d.type==="Dropdown"||d.variant==="dropdown")){const c=this.objectStates.get(d.id),u=(c==null?void 0:c.options)||d.options||{},m=d.geometry||{},g=m.width??d.width??200,b=m.height??d.height??40,v=u.optionsList||[],C=u.itemHeight||32,S=u.listPadding??4,M=v.length*C+S*2,w=this.getWorldTransform(d.id),I=g*Math.abs(w.scaleX),_=b*Math.abs(w.scaleY),x=w.y+_/2+4,F=Math.abs(i-w.x)<=I/2,T=o>=x&&o<=x+M*Math.abs(w.scaleY);if(F&&T){const P=Math.abs(w.scaleY),L=o-(x+S*P),O=Math.floor(L/(C*P));if(O>=0&&O<v.length){const W=v[O];u.selectedOption=W,u.isOpen=!1,this.activeDropdownId=null,d.inputId&&this.setInternalInput(d.inputId,W),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"dropdown",property:"selectedOption",value:W})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let d=e,c=e;for(;c&&c.parentId;){const m=this.artboard.objects.find(g=>g.id===c.parentId);if(m&&m.type==="Component"){d=m;break}c=m}let u=t;if(t==="click"?u="onClick":t==="down"?u="onPointerDown":t==="up"?u="onPointerUp":t==="blur"&&(u="onPointerLeave"),this.fireEventForObject(e.id,u),d!==e&&this.fireEventForObject(d.id,u),d.type==="Component"&&d.variant==="toggle_button"&&t==="down"){const m=this.objectStates.get(d.id),g=(m==null?void 0:m.options)||d.options||{};g.checked=!g.checked,d.inputId&&this.setInternalInput(d.inputId,g.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"toggle_button",property:"checked",value:g.checked}),this.fireEventForObject(d.id,"Toggle"),this.fireEventForObject(d.id,g.checked?"Toggle True":"Toggle False")}if(d.type==="Component"&&d.variant==="toggle"&&t==="down"){const m=this.objectStates.get(d.id),g=(m==null?void 0:m.options)||d.options||{};g.checked=!g.checked,d.inputId&&this.setInternalInput(d.inputId,g.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"toggle",property:"checked",value:g.checked}),this.onToggle&&this.onToggle(d.name,g.checked),this.fireEventForObject(d.id,"Toggle"),this.fireEventForObject(d.id,g.checked?"Toggle True":"Toggle False")}if(d.type==="Component"&&d.variant==="dropdown"&&t==="down"){const m=this.objectStates.get(d.id),g=(m==null?void 0:m.options)||d.options||{},b=!g.isOpen;if(b&&this.activeDropdownId&&this.activeDropdownId!==d.id){const v=this.artboard.objects.find(C=>C.id===this.activeDropdownId);v&&v.options&&(v.options.isOpen=!1)}g.isOpen=b,this.activeDropdownId=b?d.id:null}if(d.type==="Component"&&d.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(d.name,d.id),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"button",property:"click",value:!0})),(d.type==="ListView"||d.type==="Component"&&d.variant==="listview")&&t==="down"){this.draggingListViewId=d.id;const m=this.getListViewItemIndexAtPointer(d,i,o);if(m!==null){const g=d.options||{};g.activeItemIndex=m;const b=this.objectStates.get(d.id);b&&b.options&&(b.options.activeItemIndex=m);const v=(g.items||[])[m],C=typeof v=="string"?v:v.label||v.value||m;b&&b.options&&(b.options.selectedValue=C),d.inputId&&this.setInternalInput(d.inputId,C),this.onComponentChange&&(this.onComponentChange({objectId:d.id,componentName:d.name,variant:"listview",property:"activeItemIndex",value:m}),this.onComponentChange({objectId:d.id,componentName:d.name,variant:"listview",property:"selected",value:C}))}}if(d.type==="Component"&&d.variant==="slider"&&t==="down"&&(this.draggingSliderId=d.id,this.updateSliderValueFromPointer(d,i,o)),d.type==="Component"&&d.variant==="checkbox"&&t==="down"){const m=this.objectStates.get(d.id),g=(m==null?void 0:m.options)||d.options||{};g.checked=!g.checked,d.inputId&&this.setInternalInput(d.inputId,g.checked),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"checkbox",property:"checked",value:g.checked}),this.fireEventForObject(d.id,"Click"),this.fireEventForObject(d.id,g.checked?"Checked":"Unchecked")}if(d.type==="Component"&&d.variant==="radiogroup"&&t==="down"){const m=this.objectStates.get(d.id),g=(m==null?void 0:m.options)||d.options||{},b=g.optionsList||[],v=this.getRadioGroupItemIndexAtPointer(d,i,o);if(v!==null&&v>=0&&v<b.length){const C=b[v];g.selectedValue=C,d.inputId&&this.setInternalInput(d.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"radiogroup",property:"selectedValue",value:C}),this.fireEventForObject(d.id,"Click"),this.fireEventForObject(d.id,`Selected: ${C}`)}}if(d.type==="LineGraph"&&(t==="down"||t==="click")){const m=d.geometry,g=(m==null?void 0:m.datasets)||[],b=this.objectStates.get(d.id),v=(b==null?void 0:b.width)||(m==null?void 0:m.width)||200,C=(b==null?void 0:b.height)||(m==null?void 0:m.height)||150,S=this.getWorldTransform(d.id),M=30,w=20,I=v-M,_=C-w;let x=1;g.forEach(P=>{const L=Math.max(...P.data||[0]);L>x&&(x=L)});let F=1/0,T=null;g.forEach((P,L)=>{const O=P.data||[],W=I/Math.max(O.length-1,1);O.forEach((B,A)=>{const $=S.x-v/2+M+A*W,Y=S.y+C/2-w-B/x*_,N=Math.sqrt((i-$)**2+(o-Y)**2);N<F&&(F=N,T={dIdx:L,pIdx:A,val:B,label:P.label||`Dataset ${L+1}`})})}),T&&F<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:d.id,componentName:d.name,datasetIndex:T.dIdx,pointIndex:T.pIdx,value:T.val,label:T.label}),this.onComponentChange&&this.onComponentChange({objectId:d.id,componentName:d.name,variant:"linegraph",property:"click",value:(T==null?void 0:T.val)??null})}if(t==="click"){const m=(h=this.artboard)==null?void 0:h.objects.find(v=>v.id===e.id),g=this.focusedId,b=(m==null?void 0:m.type)==="InputBox"||(m==null?void 0:m.type)==="Component"&&m.variant==="inputbox";if(m&&b){if(this.focusedId=e.id,this.log(`[Engine] Focus set to: ${e.id}`),g!==this.focusedId){if(g){const v=(l=this.artboard)==null?void 0:l.objects.find(C=>C.id===g);v&&this.onInputBlur&&this.onInputBlur(v.name)}this.onInputFocus&&this.onInputFocus(m.name)}}else if(this.focusedId=null,g){const v=(f=this.artboard)==null?void 0:f.objects.find(C=>C.id===g);v&&this.onInputBlur&&this.onInputBlur(v.name)}}}else if(t==="click"){const d=this.focusedId;if(this.focusedId=null,d){const c=(y=this.artboard)==null?void 0:y.objects.find(u=>u.id===d);c&&this.onInputBlur&&this.onInputBlur(c.name)}}}handleKeyDown(t){if(!this.artboard||!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)}fireEventForObject(t,i){var l,f,y,d,c;const o=(l=this.artboard)==null?void 0:l.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 m=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?m.every(v=>v&&e.has(v.toLowerCase())):m.some(v=>v&&e.has(v.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,m=a.targetProperty;m&&this.updateObjectProperty(u,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const u=a.targetAnimationId,m=!a.playMode||a.playMode==="all"?void 0:a.subAnimationIds;u==="__all__"?(y=(f=this.artboard)==null?void 0:f.animations)==null||y.forEach(g=>{this.triggerGlobalAnimation(g.id,m)}):u&&this.triggerGlobalAnimation(u,m)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,g={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,g),this.log(`[Engine] State updated for ${u}:`,g)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((m,g)=>{g.startsWith("global_")&&this.layerStates.delete(g)}):u&&this.layerStates.forEach((m,g)=>{g.startsWith(`global_${u}_`)&&this.layerStates.delete(g)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,m=this.activeStateMachine.layers.find(g=>g.states.some(b=>b.id===u||b.name===u));m&&(this.log(`[Engine] Switching Layer ${m.name} to State ${u}`),this.enterStates(m.name,[u]))}this.onTrigger&&this.onTrigger(i,a.action)}const h=(o.triggers||[]).find(u=>{const m=u.eventType.toLowerCase();let g=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(g=!0),g&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):g});if(h&&h.entryAnimationId){this.log(`[Engine] Trigger matched: ${i} (as ${h.eventType}) -> Animation ${h.entryAnimationId}`);const u=(c=(d=this.artboard)==null?void 0:d.animations)==null?void 0:c.find(m=>m.id===h.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:h.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:h.targetObjectId}),this.onTrigger&&this.onTrigger(h.name,u.name))}}fireAnalyticsEvent(t,i){var r,h;const o=(r=this.artboard)==null?void 0:r.objects.find(l=>l.id===t);if(!o)return;const e=(h=o.style)==null?void 0:h.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(l=>{if(l.type==="literal")n[l.key]=l.value;else if(l.type==="variable"){const f=this.inputs.get(l.value);n[l.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 l=window;typeof l.gtag=="function"?(l.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 l=window;typeof l.fbq=="function"?(l.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 l=window;l.mixpanel&&typeof l.mixpanel.track=="function"?(l.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 y;const i=this.objectStates.get(t);if(!i)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(y=this.artboard)==null?void 0:y.objects.find(d=>d.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,h=i.y*e.scaleY,l=e.x+(r*n-h*a),f=e.y+(r*a+h*n);return{x:l,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,C;if(!this.objectStates.get(t.id))return!1;const s=((v=t.geometry)==null?void 0:v.width)??t.width??100,n=((C=t.geometry)==null?void 0:C.height)??t.height??100,a=this.getWorldTransform(t.id),r=i-a.x,h=o-a.y,l=-a.rotation*(Math.PI/180),f=Math.cos(l),y=Math.sin(l),d=r*f-h*y,c=r*y+h*f,u=a.scaleX,m=a.scaleY,g=s*Math.abs(u),b=n*Math.abs(m);return Math.abs(d)<=g/2&&Math.abs(c)<=b/2}updateSliderValueFromPointer(t,i,o){var w;const e=this.objectStates.get(t.id);if(!e)return;const s=t.options||{},n=((w=t.geometry)==null?void 0:w.width)??t.width??200,a=this.getWorldTransform(t.id),r=i-a.x,h=o-a.y,l=-a.rotation*(Math.PI/180),f=Math.cos(l),y=Math.sin(l),d=r*f-h*y,c=s.thumbWidth??16,u=n-c;let g=(d+u/2)/u;g=Math.max(0,Math.min(1,g));const b=s.min??0,v=s.max??100,C=s.step||1;let S=b+g*(v-b);C>0&&(S=Math.round(S/C)*C),S=Math.max(b,Math.min(v,S));const M=e.options||{};M.value!==S&&(e.options={...M,value:S},t.inputId&&this.setInternalInput(t.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:S}))}applyAnimation(t,i,o){!t||!t.tracks||t.tracks.forEach(e=>{var f,y,d;const s=e.object_id||e.objectId;if(o){const c=u=>{var g,b;if(s===u)return!0;let m=(g=this.artboard)==null?void 0:g.objects.find(v=>v.id===s);for(;m&&m.parentId;){if(m.parentId===u)return!0;m=(b=this.artboard)==null?void 0:b.objects.find(v=>v.id===(m==null?void 0:m.parentId))}return!1};if(Array.isArray(o)){if(!o.some(c))return}else if(typeof o=="string"&&!c(o))return}const n=(f=this.artboard)==null?void 0:f.objects.find(c=>c.id===s),a=((y=n==null?void 0:n.physics)==null?void 0:y.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const h=this.objectStates.get(s);if(!h){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${s} not found in state`);return}const l=this.interpolate(e.keyframes,i);if(l!==void 0){if(this.frameCount%240===0){const c=(n==null?void 0:n.name)||s,u=typeof l=="object"?JSON.stringify(l).slice(0,50):l;this.debugLog(`[Anim] Applying ${r} = ${u} to ${c}`)}if(r.includes(".")){const c=(r||"").split(".");let u=h;for(let m=0;m<c.length-1;m++){if(typeof u[c[m]]!="object"||u[c[m]]===null){let g=n;for(let b=0;b<=m;b++)g=g?g[c[b]]:null;if(c[m]==="corner_radius"||c[m]==="cornerRadius"){const b=typeof u[c[m]]=="number"?u[c[m]]:typeof g=="number"?g:0;u[c[m]]={tl:b,tr:b,bl:b,br:b}}else u[c[m]]=g?JSON.parse(JSON.stringify(g)):{}}u=u[c[m]]}u[c[c.length-1]]=l,c[c.length-1]==="color"&&(c[c.length-2]==="fill"||c[c.length-2]==="stroke")&&(u.type="Solid")}else r==="fill"?(h.style||(h.style={}),h.style.fill=l):r==="stroke"?(h.style||(h.style={}),h.style.stroke=l):h[r]=l;if(this.physicsEngine&&((d=n==null?void 0:n.physics)!=null&&d.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const c=this.physicsEngine.getPosition(s);c&&this.physicsEngine.setPosition(s,l,c.y)}else if(r==="y"){const c=this.physicsEngine.getPosition(s);c&&this.physicsEngine.setPosition(s,c.x,l)}else r==="rotation"&&this.physicsEngine.setRotation(s,l*(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 h=e.value[r];return typeof a=="number"&&typeof h=="number"?a+(h-a)*n:n<.5?a:h}):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(h=>{const l=o.value[h],f=e.value[h];typeof l=="number"&&typeof f=="number"?a[h]=l+(f-l)*n:l===void 0?a[h]=f:f===void 0?a[h]=l:a[h]=n<.5?l: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 c,u;const e=((u=(c=this.artboard)==null?void 0:c.tokens)==null?void 0:u.colors)||{},s=e[t]||t,n=e[i]||i,a=m=>{if(!m)return{r:0,g:0,b:0};const g=m.startsWith("#")?m.replace("#",""):"000000";return g.length===3?{r:parseInt(g[0]+g[0],16),g:parseInt(g[1]+g[1],16),b:parseInt(g[2]+g[2],16)}:{r:parseInt(g.substring(0,2),16),g:parseInt(g.substring(2,4),16),b:parseInt(g.substring(4,6),16)}},r=a(s),h=a(n),l=Math.round(r.r+(h.r-r.r)*o),f=Math.round(r.g+(h.g-r.g)*o),y=Math.round(r.b+(h.b-r.b)*o),d=m=>{const g=Math.max(0,Math.min(255,m)).toString(16);return g.length===1?"0"+g:g};return`#${d(l)}${d(f)}${d(y)}`}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 l;this.debug_objectsTotal=((l=this.artboard)==null?void 0:l.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 f=this.artboard.backgroundImage;let y=this.imageCache.get(f);if(y||(y=new Image,y.src=f,this.imageCache.set(f,y)),y.complete&&y.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const d=y.naturalWidth/y.naturalHeight,c=s/n;let u,m,g,b;c>d?(u=s,m=s/d):(m=n,u=n*d),g=0,b=0,t.drawImage(y,g,b,u,m),t.restore()}}t.beginPath(),t.rect(0,0,s,n),t.clip();const r=new Map;this.artboard.objects.forEach(f=>r.set(f.id,f)),this.artboard.objects.filter(f=>!f.parentId).map((f,y)=>{const d=this.objectStates.get(f.id),c=(d==null?void 0:d.zIndex)??y;return{obj:f,zIndex:c}}).sort((f,y)=>f.zIndex-y.zIndex).forEach(({obj:f})=>{this.renderObject(t,f,r)}),this._emitterPools.forEach((f,y)=>{if(!(f.length===0||!r.get(y)))for(const c of f)t.save(),t.globalAlpha=c.opacity,t.fillStyle=c.color,t.beginPath(),t.arc(c.x,c.y,Math.max(1,c.size*c.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,h=i*a.b+o*a.d+a.f,l=Math.sqrt(a.a*a.a+a.b*a.b),f=Math.sqrt(a.c*a.c+a.d*a.d),y=(e/2+n)*l,d=(s/2+n)*f;return r+y>=0&&r-y<=this.canvasWidth&&h+d>=0&&h-d<=this.canvasHeight}calculateTransform(t,i,o,e,s,n){let a=1,r=1,h=1;const l=o/e,f=t/i;switch(s){case"Contain":f>l?h=i/e:h=t/o,a=r=h;break;case"Cover":f>l?h=t/o:h=i/e,a=r=h;break;case"Fill":a=t/o,r=i/e;break;case"FitWidth":h=t/o,a=r=h;break;case"FitHeight":h=i/e,a=r=h;break;case"None":a=r=1;break;case"ScaleDown":h=Math.min(t/o,i/e),h>1&&(h=1),a=r=h;break;default:a=r=1;break}const y=o*a,d=e*r;let c=0,u=0;return n.includes("Left")?c=0:n.includes("Right")?c=t-y:c=(t-y)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=i-d:u=(i-d)/2,{scaleX:a,scaleY:r,tx:c,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 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 g,b,v,C,S,M,w,I,_,x,F,T,P,L,O,W,B;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=(A,$,Y,N,E)=>(this.drawRoundRect(t,A,$,Y,N,E),t));const s=e.geometry?this.deepMerge(i.geometry,e.geometry):i.geometry,n=e.style?this.deepMerge(i.style,e.style):i.style;let a=(s==null?void 0:s.width)||((g=i.geometry)==null?void 0:g.width)||i.width||0,r=(s==null?void 0:s.height)||((b=i.geometry)==null?void 0:b.height)||i.height||0;if((a===0||r===0)&&(s!=null&&s.points)&&Array.isArray(s.points)&&s.points.length>0){let A=1/0,$=-1/0,Y=1/0,N=-1/0;s.points.forEach(E=>{A=Math.min(A,E.x),$=Math.max($,E.x),Y=Math.min(Y,E.y),N=Math.max(N,E.y)}),a===0&&(a=$-A),r===0&&(r=N-Y)}const h=A=>{if(A)return A.corner_radius??A.cornerRadius},l=h(e)??h(n)??h(s)??h(i.style)??h(i.geometry)??0;let f={...s,width:a,height:r};if(delete f.cornerRadius,f.corner_radius=l,f.type==="Path"&&i.weights&&i.bindMatrices&&f.points){const A=this.getGlobalTransform(i.id);if(A){const $=ii(f.points,i.weights,i.bindMatrices,A,Y=>this.getGlobalTransform(Y));f={...f,points:$}}}const y=n.effects||((v=n.effect)!=null&&v.isEnabled?[n.effect]:[]),d=y.find(A=>A.isEnabled&&A.type==="PathDistortion");if(d&&f.type!=="SVG"&&f.type!=="Image"&&f.type!=="Text"){const A=oi(f,a,r,d.amplitude||5,d.frequency||10,d.seed||0,d.direction||0,d.directionStrength||0);f={...f,type:"DistortedPath",points:A}}if(e.visible===!1)return;const c=i.repeaterConfig,u=c&&c.isEnabled&&c.count>1,m=u?c.count:1;for(let A=0;A<m;A++){let $=e.x,Y=e.y,N=e.rotation,E=e.scale_x??1,k=e.scale_y??1;if(u&&A>0){if(c.type==="Linear"){const it=c.offsetX||0,dt=c.offsetY||0,U=c.rotation||0,D=c.scale!==void 0?c.scale:1;$+=A*it,Y+=A*dt,N+=A*U,E*=Math.pow(D,A),k*=Math.pow(D,A)}else if(c.type==="Grid"){const it=c.cols||Math.ceil(Math.sqrt(c.count)),dt=c.gapX||0,U=c.gapY||0,D=Math.floor(A/it),nt=A%it,et=a+dt,Ot=r+U;$+=nt*et,Y+=D*Ot}else if(c.type==="Radial"){const it=c.radius||100,dt=c.startAngle||0,D=(c.endAngle||360)-dt,nt=c.count>1?D/(D===360?c.count:c.count-1):0,et=dt+A*nt,Ot=et*Math.PI/180;$=e.x+it*Math.cos(Ot),Y=e.y+it*Math.sin(Ot),N+=et}}const G=i.type==="Group"||i.type==="Frame"||i.type==="Component",X=a>0&&r>0;if(!G&&X){const it=(((C=n.shadow)==null?void 0:C.isEnabled)!==!1?(((S=n.shadow)==null?void 0:S.blur)||0)+10:0)+(((M=n.blur)==null?void 0:M.isEnabled)!==!1&&((w=n.blur)==null?void 0:w.radius)||0)+20;if(!this.isObjectInView(t,$,Y,a,r,it))continue}this.debug_objectsRendered++,t.save();const J=[],tt=n.blur||((I=i.style)==null?void 0:I.blur);tt&&tt.amount>0&&J.push(`blur(${tt.amount}px)`);const lt=y.find(it=>it.isEnabled&&it.type==="BackgroundBlur"),Z=y.find(it=>it.isEnabled&&it.type==="LayerBlur");Z&&J.push(`blur(${Z.radius??10}px)`),lt&&(n.fill=null,n.stroke&&(n.stroke.isEnabled=!1));const pt=((_=s==null?void 0:s.type)==null?void 0:_.toLowerCase().includes("image"))||((x=i.type)==null?void 0:x.toLowerCase().includes("image")),at=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Et=s!=null&&s.adjustments&&Object.keys(s.adjustments).length>0?s.adjustments:null,xt=pt?Et||at:at||Et,bt=pt&&!xt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:xt;if(e&&bt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...bt}),bt){const it=(bt.exposure||0)/100,dt=bt.contrast||0,U=1+(bt.saturation||0)/100,D=(bt.temperature||0)/200,nt=(bt.tint||0)/200,et=(bt.highlights||0)/500,Ot=(bt.shadows||0)/500;let Yt="",At="SourceGraphic";if(it!==0&&(Yt+=`
8
8
  <feComponentTransfer in="${At}" result="exposure">
9
9
  <feFuncR type="linear" slope="1" intercept="${it}"/>
10
10
  <feFuncG type="linear" slope="1" intercept="${it}"/>
11
11
  <feFuncB type="linear" slope="1" intercept="${it}"/>
12
- </feComponentTransfer>`,At="exposure"),dt!==0){const Tt=(dt+100)/100,R=.5*(1-Tt);Gt+=`
12
+ </feComponentTransfer>`,At="exposure"),dt!==0){const Tt=(dt+100)/100,R=.5*(1-Tt);Yt+=`
13
13
  <feComponentTransfer in="${At}" result="contrast">
14
14
  <feFuncR type="linear" slope="${Tt}" intercept="${R}"/>
15
15
  <feFuncG type="linear" slope="${Tt}" intercept="${R}"/>
16
16
  <feFuncB type="linear" slope="${Tt}" intercept="${R}"/>
17
- </feComponentTransfer>`,At="contrast"}if(U!==1&&(Gt+=`<feColorMatrix in="${At}" type="saturate" values="${U}" result="saturate"/>`,At="saturate"),bt.hue&&(Gt+=`<feColorMatrix in="${At}" type="hueRotate" values="${bt.hue}" result="hue"/>`,At="hue"),bt.negative){const Tt=1-bt.negative/50;Gt+=`
17
+ </feComponentTransfer>`,At="contrast"}if(U!==1&&(Yt+=`<feColorMatrix in="${At}" type="saturate" values="${U}" result="saturate"/>`,At="saturate"),bt.hue&&(Yt+=`<feColorMatrix in="${At}" type="hueRotate" values="${bt.hue}" result="hue"/>`,At="hue"),bt.negative){const Tt=1-bt.negative/50;Yt+=`
18
18
  <feColorMatrix in="${At}" type="matrix" result="invert"
19
19
  values="${Tt} 0 0 0 ${1-Tt}
20
20
  0 ${Tt} 0 0 ${1-Tt}
21
21
  0 0 ${Tt} 0 ${1-Tt}
22
- 0 0 0 1 0"/>`,At="invert"}if(D!==0||nt!==0||et!==0||Ot!==0){const Tt=1+et+Ot,R=Tt*(1+D-nt/2),Ft=Tt*(1+nt),le=Tt*(1-D-nt/2),Mt=bt.shadows*.1/255,Jt=[R,0,0,0,Mt,0,Ft,0,0,Mt,0,0,le,0,Mt,0,0,0,1,0].join(" ");Gt+=`<feColorMatrix in="${At}" type="matrix" values="${Jt}" result="advanced"/>`,At="advanced"}if(bt.blur&&(Gt+=`<feGaussianBlur in="${At}" stdDeviation="${bt.blur}" result="blur"/>`,At="blur"),Gt){const Tt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Gt}</filter></svg>`,R=btoa(Tt);J.push(`url('data:image/svg+xml;base64,${R}#f')`)}}J.length>0?t.filter=J.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const Yt=t.globalAlpha,Wt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=Yt*Wt;const _t=e.compositeOperation||e.blendMode;if(_t&&_t!=="Normal"){const it=_t.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 Nt=t,Q=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 ct=!1;const Rt=Q.filter(it=>it.isVisible!==!1&&o.has(it.maskId));if(Rt.length>0){const it=Rt[0],dt=o.get(it.maskId),U=this.objectStates.get(dt.id);U&&U.visible!==!1&&(ct=!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=Nt.filter)}t.translate(Math.round($),Math.round(G)),t.rotate(N*Math.PI/180);const Ct=e.skew_x||0,St=e.skew_y||0;(Ct!==0||St!==0)&&t.transform(1,Math.tan(St*Math.PI/180),Math.tan(Ct*Math.PI/180),1,0,0);const Xt=e.rotate_x||0,te=e.rotate_y||0,ee=(e.flip_x===!0?-1:1)*Math.cos(te*Math.PI/180),Zt=(e.flip_y===!0?-1:1)*Math.cos(Xt*Math.PI/180);t.scale(x*ee,k*Zt),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 Ut=n.shadow;if(Ut&&Ut.isEnabled!==!1){let it=Ut.color||"#000000";(T=(F=this.artboard)==null?void 0:F.tokens)!=null&&T.colors&&this.artboard.tokens.colors[it]&&(it=this.artboard.tokens.colors[it]);const dt=this.normalizeOpacity(Ut.opacity??100),U=Ut.spread||0,nt=(Ut.blur||0)+U*1.5;let et=it;if(it.startsWith("#")){const At=it.replace("#",""),qt=parseInt(At.substring(0,2),16),Tt=parseInt(At.substring(2,4),16),R=parseInt(At.substring(4,6),16);et=`rgba(${qt}, ${Tt}, ${R}, ${dt})`}else if(it.startsWith("rgba")){const At=it.match(/[\d.]+/g);if(At&&At.length>=4){const qt=At[0],Tt=At[1],R=At[2],Ft=At[3];et=`rgba(${qt}, ${Tt}, ${R}, ${parseFloat(Ft)*dt})`}}const Ot=t.getTransform(),Gt=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1;t.shadowColor=et,t.shadowBlur=nt*Gt,t.shadowOffsetX=(Ut.offsetX||0)*Gt,t.shadowOffsetY=(Ut.offsetY||0)*Gt}const ae=i.liquidFill||((P=i.style)==null?void 0:P.liquidFill);if(ae&&ae.enabled){t.save();const it=ae.fillLevel??.5;t.beginPath();const dt=r/2-r*it;t.rect(-a/2,dt,a,r*it),t.clip(),t.fillStyle=ae.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ae.opacity??1)}if((s==null?void 0:s.type)==="Text")this._renderText(t,i,c,n,e,a,r);else if((s==null?void 0:s.type)==="Image"){const it=s.originalSrc||s.src;if(it){let dt=this.imageCache.get(it);dt||(dt=new Image,dt.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${dt.naturalWidth}x${dt.naturalHeight}`)},dt.onerror=nt=>{console.error("[ExodeUI] Image load failed:",nt,`Src preview: ${it.substring(0,100)}...`)},dt.src=it,this.imageCache.set(it,dt));const U=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,D=(((L=n.stroke)==null?void 0:L.alignment)||"center").toLowerCase();if(U&&(D==="outside"||D==="center")&&this.applyStrokeAlignment(t,n,c,a,r,f),n.fill&&n.fill.type!=="None"){t.save();const nt=t.globalAlpha,et=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=et||n.fill.color||"transparent",t.globalAlpha=nt*this.normalizeOpacity(n.fill.opacity??100),f!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,f),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=nt,t.restore()}dt.complete&&dt.naturalWidth>0?(f!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,f),t.clip(),t.drawImage(dt,-a/2,-r/2,a,r),t.restore()):t.drawImage(dt,-a/2,-r/2,a,r),U&&D==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,f)):U&&D==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,f)}}else if(s.type==="SVG"){const it=s.svgContent;if(it){const dt=n.palette||[],U=n.fill,D=n.stroke,nt=U?this.normalizeOpacity(U.opacity??100):1,et=(U==null?void 0:U.type)==="Solid"&&(!D||D.isEnabled===!1||D.type==="Solid"&&D.color===U.color),Ot=U&&U.type!=="None"?et?"monochrome":U.type==="Solid"?(U.color||"")+"|opacity:"+nt:JSON.stringify(U.stops||[])+"|opacity:"+nt:"",Gt=D&&D.isEnabled!==!1&&(D.width||0)>0?et?["monochrome",D.width||0,D.trimStart??0,D.trimEnd??1,D.trimOffset??0,D.dashOffset??0].join("|"):[D.width||0,D.fill?D.fill.type==="Solid"?D.fill.color||"":JSON.stringify(D.fill.stops||[]):D.color||"",D.opacity??1,D.lineCap||"",D.lineJoin||"",(D.dashArray||[]).join(","),D.trimStart??0,D.trimEnd??1,D.trimOffset??0,D.dashOffset??0].join("|"):"nostroke",At=[i.id,dt.join("_"),Ot,Gt,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let qt=this.imageCache.get(At);if(!qt){qt=new Image,qt.crossOrigin="anonymous";let R=it;R.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(R=R.replace(/<svg([^>]*)>/i,(ft,ht)=>`<svg xmlns="http://www.w3.org/2000/svg"${ht}>`));let Ft=s.width||a||100,le=s.height||r||100;const Mt=R.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(Mt&&(Ft=parseFloat(Mt[1]),le=parseFloat(Mt[2])),R=R.replace(/<svg([^>]*)>/i,(ft,ht)=>{let mt=ht.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return mt.match(/\bviewBox=/i)||(mt+=` viewBox="0 0 ${Ft} ${le}"`),mt.match(/\bpreserveAspectRatio=/i)||(mt+=' preserveAspectRatio="none"'),mt+=' width="100%" height="100%"',`<svg${mt}>`}),s.colors&&s.colors.length>0&&dt.length>0&&s.colors.forEach((ft,ht)=>{if(dt[ht]){const mt=ft.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),kt=new RegExp(mt,"gi");R=R.replace(kt,dt[ht])}}),U&&U.type&&U.type!=="None"){if(U.type==="Solid"&&U.color){const ft=et?"#FFFFFF":U.color,ht=et?1:this.normalizeOpacity(U.opacity??100);R=R.replace(/\bfill\s*=\s*["'][^"']*["']/gi,mt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(mt)?mt:`fill="${ft}"`),R=R.replace(/fill\s*:\s*[^;"')]+/gi,mt=>/fill\s*:\s*(none|transparent)/i.test(mt)?mt:`fill:${ft}`),ht<1&&(R=R.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${ht}"`),R=R.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${ht}`),R.match(/\bfill-opacity\s*=/i)||(R=R.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${ht}">`),R=R.replace(/<\/svg>/i,"</g></svg>")))}else if(U.type==="LinearGradient"||U.type==="RadialGradient"||U.type==="Linear"||U.type==="Radial"){const ft="exode-fill",ht=this.normalizeOpacity(U.opacity??100),mt=(U.stops||[]).map(gt=>{const zt=gt.offset!==void 0?gt.offset:gt.pos??0,ie=this.normalizeOpacity(gt.opacity??100)*ht;return`<stop offset="${zt*100}%" stop-color="${gt.color||"#000"}" stop-opacity="${ie}"/>`}).join("");let kt="";if(U.type==="LinearGradient"||U.type==="Linear"){const gt=(st,ut)=>Array.isArray(st)?st[ut]??(ut===0?0:1):st&&typeof st=="object"?st[ut===0?"x":"y"]??(ut===0?0:1):ut===0?0:1,zt=gt(U.start,0)*100,ie=gt(U.start,1)*100,jt=gt(U.end,0)*100,rt=gt(U.end,1)*100;kt=`<linearGradient id="${ft}" x1="${zt}%" y1="${ie}%" x2="${jt}%" y2="${rt}%" gradientUnits="objectBoundingBox">${mt}</linearGradient>`}else{const gt=(rt,st)=>Array.isArray(rt)?rt[st]??.5:rt&&typeof rt=="object"?rt[st===0?"x":"y"]??.5:.5,zt=gt(U.center,0)*100,ie=gt(U.center,1)*100,jt=(U.radius??.5)*100;kt=`<radialGradient id="${ft}" cx="${zt}%" cy="${ie}%" r="${jt}%" gradientUnits="objectBoundingBox">${mt}</radialGradient>`}/<defs>/i.test(R)?R=R.replace(/<defs>/i,`<defs>${kt}`):R=R.replace(/<svg([^>]*)>/i,`<svg$1><defs>${kt}</defs>`),R=R.replace(/\bfill\s*=\s*["'][^"']*["']/gi,gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(gt)?gt:`fill="url(#${ft})"`),R=R.replace(/fill\s*:\s*[^;"')]+/gi,gt=>/fill\s*:\s*(none|transparent)/i.test(gt)?gt:`fill:url(#${ft})`)}}const Jt=(ft,ht,mt=1)=>{const kt=(ft.stops||[]).map(rt=>{const st=rt.offset!==void 0?rt.offset:rt.pos??0,ut=this.normalizeOpacity(rt.opacity??100)*mt;return`<stop offset="${st*100}%" stop-color="${rt.color||"#000"}" stop-opacity="${ut}"/>`}).join(""),gt=(rt,st,ut=.5)=>Array.isArray(rt)?rt[st]??ut:rt&&typeof rt=="object"?rt[st===0?"x":"y"]??ut:ut;if(ft.type==="LinearGradient"||ft.type==="Linear"){const rt=gt(ft.start,0,0)*100,st=gt(ft.start,1,0)*100,ut=gt(ft.end,0,1)*100,Bt=gt(ft.end,1,1)*100;return`<linearGradient id="${ht}" x1="${rt}%" y1="${st}%" x2="${ut}%" y2="${Bt}%" gradientUnits="objectBoundingBox">${kt}</linearGradient>`}const zt=gt(ft.center,0,.5)*100,ie=gt(ft.center,1,.5)*100,jt=(ft.radius??.5)*100;return`<radialGradient id="${ht}" cx="${zt}%" cy="${ie}%" r="${jt}%" gradientUnits="objectBoundingBox">${kt}</radialGradient>`},It=(ft,ht)=>/<defs>/i.test(ft)?ft.replace(/<defs>/i,`<defs>${ht}`):ft.replace(/(<svg[^>]*>)/i,`$1<defs>${ht}</defs>`);if(D&&D.isEnabled!==!1&&(D.width||0)>0){const ft=et?1:this.normalizeOpacity(D.opacity??100),ht=et?"#FFFFFF":D.color||(U==null?void 0:U.color)||"#000000";let mt="";const kt=D.fill;if(kt&&kt.type){if(kt.type==="Solid")mt=kt.color||D.color||"#000000";else if(kt.type==="LinearGradient"||kt.type==="RadialGradient"||kt.type==="Linear"||kt.type==="Radial"){const Kt="exode-stroke";R=It(R,Jt(kt,Kt,ft)),mt=`url(#${Kt})`}}mt||(mt=ht),R.match(/\bstroke\s*=\s*["']/i)?R=R.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Kt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Kt)?Kt:`stroke="${mt}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${mt}"`),R=R.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${mt}`);let gt=s.width||a||100,zt=s.height||r||100;const ie=it.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie){const Kt=parseFloat(ie[1]),ce=parseFloat(ie[2]);!isNaN(Kt)&&!isNaN(ce)&&(gt=Kt,zt=ce)}const jt=Math.max(.001,a/gt),rt=Math.max(.001,r/zt),st=(jt+rt)/2,ut=(D.width||1)/st;R.match(/\bstroke-width\s*=\s*["']/i)?R=R.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${ut}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${ut}"`),R=R.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${ut}`),R.match(/\bstroke-opacity\s*=\s*["']/i)?R=R.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${ft}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${ft}"`),R=R.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${ft}`);const Bt=D.lineCap||"round";R.match(/\bstroke-linecap\s*=\s*["']/i)?R=R.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Bt}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Bt}"`),R=R.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Bt}`);const K=D.lineJoin||"round";R.match(/\bstroke-linejoin\s*=\s*["']/i)?R=R.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${K}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${K}"`),R=R.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${K}`);const vt=D.trimStart??0,yt=D.trimEnd??1,pe=D.trimOffset??0,Ce=D.dashOffset??0,_e=vt!==0||yt!==1||pe!==0||Ce!==0;if(_e){const Kt=Math.max(0,Math.min(1,vt)),ce=Math.max(0,Math.min(1,yt));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Kt}, End: ${ce}`);const ve=(gt+zt)*2,Me=(pe%1+1)%1,Ie=(Ce%1+1)%1;let ge="",de=0;if(Kt>=ce)ge=`0 ${ve}`,de=0;else{const ue=ve*(ce-Kt),Se=ve-ue;de=-(ve*(Kt+Me+Ie)),ge=`${ue} ${Se}`}R.match(/\bstroke-dasharray\s*=/i)?R=R.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ge}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ge}"`),R=R.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ge}`),R.match(/\bstroke-dashoffset\s*=/i)?R=R.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${de}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${de}"`),R=R.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${de}`)}else if(D.dashArray&&D.dashArray.length>0){const Kt=D.dashArray.join(" ");R=R.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Kt}"`),R=R.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Kt}`),D.dashOffset&&(R=R.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${D.dashOffset}"`),R=R.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${D.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(it)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(it)){let Kt="",ce="";if(_e){const ge=s.width||a||100,de=s.height||r||100,ue=(ge+de)*2,Se=Math.max(0,Math.min(1,vt)),Pe=Math.max(0,Math.min(1,yt)),Fe=(pe%1+1)%1,$e=(Ce%1+1)%1;if(Se>=Pe)Kt=` stroke-dasharray="0 ${ue}"`,ce=' stroke-dashoffset="0"';else{const Ee=ue*(Pe-Se),We=ue-Ee,Be=-(ue*(Se+Fe+$e));Kt=` stroke-dasharray="${Ee} ${We}"`,ce=` stroke-dashoffset="${Be}"`}}else(O=D.dashArray)!=null&&O.length&&(Kt=` stroke-dasharray="${D.dashArray.join(" ")}"`,D.dashOffset&&(ce=` stroke-dashoffset="${D.dashOffset}"`));const ve=` stroke-linecap="${D.lineCap||"round"}"`,Me=` stroke-linejoin="${D.lineJoin||"round"}"`,Ie=`stroke="${mt}" stroke-width="${ut}" stroke-opacity="${ft}"${ve}${Me}${Kt}${ce}`;R=R.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ge,de,ue)=>`${de}${ue}<g ${Ie}>`),R=R.replace(/<\/svg>/i,"</g></svg>")}}else D&&D.isEnabled===!1&&(R=R.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),R=R.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Dt=new Blob([R],{type:"image/svg+xml"}),Qt=URL.createObjectURL(Dt);qt.onload=()=>{if(URL.revokeObjectURL(Qt),this.frameCount%900===0){const ft=this.imageCache.get(At);ft&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${ft.naturalWidth}x${ft.naturalHeight})`)}},qt.onerror=()=>{URL.revokeObjectURL(Qt),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},qt.src=Qt,this.imageCache.set(At,qt)}let Tt=null;if(qt.complete&&qt.naturalWidth>0?(Tt=qt,this.lastValidSvgImgMap.set(i.id,qt)):Tt=this.lastValidSvgImgMap.get(i.id)||null,Tt&&Tt.complete&&Tt.naturalWidth>0){const R=Math.max(1,a),Ft=Math.max(1,r);if(et&&(U==null?void 0:U.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=R,this.maskBuffer.height=Ft,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,R,Ft),this.maskCtx.drawImage(Tt,0,0,R,Ft),this.maskCtx.globalCompositeOperation="source-in";const le=U.color||"#000000",Mt=this.normalizeOpacity(U.opacity??100);this.maskCtx.fillStyle=le,this.maskCtx.globalAlpha=Mt,this.maskCtx.fillRect(0,0,R,Ft),t.drawImage(this.maskBuffer,-R/2,-Ft/2,R,Ft)}else f!==0?(t.save(),this.drawRoundRect(t,-R/2,-Ft/2,R,Ft,f),t.clip(),t.drawImage(Tt,-R/2,-Ft/2,R,Ft),t.restore()):t.drawImage(Tt,-R/2,-Ft/2,R,Ft)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,a,r);else if(i.type==="Shape"){if(this.applyPath(t,c,a,r,f),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const it=t.globalAlpha;if(((W=n.fill)==null?void 0:W.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const dt=n.fill.originalSrc||n.fill.src;let U=this.imageCache.get(dt);U||(U=new Image,U.src=dt,this.imageCache.set(dt,U)),U.complete&&U.naturalWidth>0&&(t.save(),this.applyPath(t,c,a,r,f),t.clip(),this.renderFittedImage(t,U,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const dt=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=dt||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=it*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,c,a,r,f),t.fill()}t.globalAlpha=it}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,c,a,r,f)}else if(i.type==="Frame"||i.type==="Component"&&(!i.variant||i.variant==="artboard"||i.variant==="instance")||i.type==="Group"&&!i.isStructuralGroup){const it=e.width??s.width??i.width??a,dt=e.height??s.height??i.height??r,U=f;if(t.save(),t.beginPath(),this.drawRoundRect(t,-it/2,-dt/2,it,dt,U),n.fill&&n.fill.type!=="None"){const D=t.globalAlpha,nt=this.createCanvasFill(t,n.fill,it,dt);t.fillStyle=nt||n.fill.color||"transparent",t.globalAlpha=D*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=D}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const D={type:"Rectangle"};this.applyStrokeAlignment(t,n,D,it,dt,U)}}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):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(B=i.geometry)==null?void 0:B.type));if(this.applyArtEffectOverlay(t,i,c,a,r,f),lt&&this.applyBackgroundBlurGlass(t,c,a,r,f,lt),ae&&ae.enabled&&t.restore(),i.children&&i.children.length>0){const dt=i.type==="Frame"||i.type==="Component"&&(!i.variant||i.variant==="artboard"||i.variant==="instance"),U=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:dt;if(t.save(),U){t.beginPath();const nt=e.width??(s==null?void 0:s.width)??i.width??0,et=e.height??(s==null?void 0:s.height)??i.height??0,Ot=e.cornerRadius??(s==null?void 0:s.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-nt/2,-et/2,nt,et,Ot),t.clip()}let D=0;for(i.children.forEach(nt=>{const et=o.get(nt);if(!et)return;const Ot=this.objectStates.get(nt),Gt=(Ot==null?void 0:Ot.geometry)||et.geometry;if(Gt&&Gt.isMask&&(Ot==null?void 0:Ot.visible)!==!1){const At=Gt.width||0,qt=Gt.height||0;this.applyObjectTransform(t,nt);const Tt=(Ot==null?void 0:Ot.corner_radius)??(Gt==null?void 0:Gt.corner_radius)??0;this.applyPath(t,Gt,At,qt,Tt),t.clip(),D++}else this.renderObject(t,et,o)});D>0;)t.restore(),D--;t.restore()}if(ct){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(D=>D.isVisible!==!1&&o.has(D.maskId)).forEach(D=>{var Tt,R,Ft,le,Mt,Jt;const nt=o.get(D.maskId),et=this.objectStates.get(nt.id),Ot=D.feather||0,Gt=D.inverted===!0,At=D.opacity!==void 0?typeof D.opacity=="number"?D.opacity:D.opacity/100:1;if((D.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),Ot>0&&(this.lumaCtx.filter=`blur(${Ot}px)`),this.lumaCtx.globalAlpha=At;const It=(et==null?void 0:et.width)||nt.geometry.width||0,Dt=(et==null?void 0:et.height)||nt.geometry.height||0,Qt=(et==null?void 0:et.corner_radius)??nt.corner_radius??0;if(((Tt=nt.geometry)==null?void 0:Tt.type)==="Text"){const kt=et!=null&&et.geometry?this.deepMerge(nt.geometry,et.geometry):nt.geometry,gt=et!=null&&et.style?this.deepMerge(nt.style,et.style):nt.style;this._renderText(this.lumaCtx,nt,{...kt,width:It,height:Dt,corner_radius:Qt},gt,et,It,Dt,!0)}else if(((R=nt.geometry)==null?void 0:R.type)==="Image"){const kt=nt.geometry.src;if(kt){let gt=this.imageCache.get(kt);gt||(gt=new Image,gt.src=kt,this.imageCache.set(kt,gt)),gt.complete&&gt.naturalWidth>0?this.lumaCtx.drawImage(gt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Ft=nt.geometry)==null?void 0:Ft.type)==="SVG"){const kt=nt.geometry.svgContent;if(kt){const gt=`__lumamask_${nt.id}`;let zt=this.imageCache.get(gt);if(!zt){zt=new Image;const ie=new Blob([kt],{type:"image/svg+xml"});zt.src=URL.createObjectURL(ie),zt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(gt,zt)}zt.complete&&zt.naturalWidth>0?this.lumaCtx.drawImage(zt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ft=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),ht=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,mt=ft.data;for(let kt=0;kt<mt.length;kt+=4){const gt=ht[kt],zt=ht[kt+1],ie=ht[kt+2];let jt=(.299*gt+.587*zt+.114*ie)/255;Gt&&(jt=1-jt),mt[kt+3]*=jt}this.maskCtx.putImageData(ft,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Gt?"destination-out":"destination-in",Ot>0&&(this.maskCtx.filter=`blur(${Ot}px)`),this.maskCtx.globalAlpha=At,this.applyAbsoluteTransform(this.maskCtx,nt.id,o);const It=(et==null?void 0:et.width)||nt.geometry.width||0,Dt=(et==null?void 0:et.height)||nt.geometry.height||0,Qt=(et==null?void 0:et.corner_radius)??nt.corner_radius??0;if(((le=nt.geometry)==null?void 0:le.type)==="Text"){const ft=et!=null&&et.geometry?this.deepMerge(nt.geometry,et.geometry):nt.geometry,ht=et!=null&&et.style?this.deepMerge(nt.style,et.style):nt.style;this._renderText(this.maskCtx,nt,{...ft,width:It,height:Dt,corner_radius:Qt},ht,et,It,Dt,!0)}else if(((Mt=nt.geometry)==null?void 0:Mt.type)==="Image"){const ft=nt.geometry.src;if(ft){let ht=this.imageCache.get(ft);ht||(ht=new Image,ht.src=ft,this.imageCache.set(ft,ht)),ht.complete&&ht.naturalWidth>0?this.maskCtx.drawImage(ht,-It/2,-Dt/2,It,Dt):(this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((Jt=nt.geometry)==null?void 0:Jt.type)==="SVG"){const ft=nt.geometry.svgContent;if(ft){const ht=`__alphamask_${nt.id}`;let mt=this.imageCache.get(ht);if(!mt){mt=new Image;const kt=new Blob([ft],{type:"image/svg+xml"});mt.src=URL.createObjectURL(kt),mt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(ht,mt)}mt.complete&&mt.naturalWidth>0?this.maskCtx.drawImage(mt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),Nt.save(),Nt.setTransform(1,0,0,1,0,0);const U=i.maskBlendMode||i.blendMode;U&&U!=="Normal"&&(Nt.globalCompositeOperation=U.toLowerCase()),Nt.drawImage(this.maskBuffer,0,0),Nt.restore(),Nt.restore()}else t.restore()}}_renderText(t,i,o,e,s,n,a,r=!1,h=!1){var pt,at,Et,xt,bt,Yt,Wt,_t,Nt;let f=o.text||"";if(o.textInputId&&!r){const Q=this.inputs.get(o.textInputId);Q!==void 0&&(f=String(Q),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=f))}if(o.svgPath){const Q=o.svgPath;t.save();const ct=((pt=e==null?void 0:e.fill)==null?void 0:pt.color)||"#000000",Rt=((at=e==null?void 0:e.fill)==null?void 0:at.opacity)!==void 0?(Et=e==null?void 0:e.fill)==null?void 0:Et.opacity:1;t.fillStyle=ct,t.globalAlpha*=Rt;const Ct=new Path2D(Q);t.fill(Ct),t.restore();return}let c=f||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(Q=>Q&&Q.text?Q.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?c=c.toUpperCase():g==="lowercase"?c=c.toLowerCase():g==="capitalize"&&(c=c.replace(/\b\w/g,Q=>Q.toUpperCase()));let d=((xt=o.fontWeight)==null?void 0:xt.toString())||"400",l=o.fontStyle||"normal";d.toLowerCase().includes("italic")&&(l="italic",d=d.replace(/italic/gi,"").trim()||"400");const u=this.mapFontWeight(d),y=Math.max(1,o.fontSize||32);let m=o.fontFamily||"Inter";const b=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];b.forEach(Q=>{const ct=new RegExp(`[\\s-]${Q}$`,"i");ct.test(m)&&(m=m.replace(ct,"").trim())});const S=`${o.smallCaps===!0?"small-caps ":""}${l} ${u} ${y}px "${m}", sans-serif`;t.font=S;const M=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let I=0;if(typeof o.letterSpacing=="number")I=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const Q=o.letterSpacing;I=Q.unit==="PERCENT"?Q.value/100*y:Q.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${I}px`);const _=o.kerning||"auto",E=o.kerningValue||0;_==="manual"&&E!==0&&(t.letterSpacing=`${I+E}px`);const F=o.paragraphSpacing||0;let T=o.lineHeight??1.2;typeof T=="string"&&(T=parseFloat(T)),T>5&&y>0&&(T=T/y);const P=(T||1.2)*y,L=o.isPointText===!0||!o.width||o.width<=0,O=((bt=o.padding)==null?void 0:bt.left)||((Yt=o.padding)==null?void 0:Yt.right)||0,W=L?1e5:o.width&&o.width>0?Math.ceil(o.width)-O*2:1e5;o.autoHeight;const B=De({text:c,fontFamily:m,fontSize:y,fontWeight:u,fontStyle:l,lineHeight:T,width:W,letterSpacing:I,paragraphSpacing:F,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),A=B.lines||[],$=B.maxFontSize||y,G=this.fontLeadingFactors[m]??.5,N=(P-y)*G;let x=B.height,k=n,Y=a;if(k===0||Y===0||k>=1e5){let Q=0,ct=0;const Rt=B.fullText||c;(A||[]).forEach(Ct=>{const St=Ct.text||"",Xt=t.measureText(St).width+(St.length>0?(St.length-1)*I:0);Xt>Q&&(Q=Xt),ct+=St.length,ct<Rt.length&&(Rt[ct]===`
22
+ 0 0 0 1 0"/>`,At="invert"}if(D!==0||nt!==0||et!==0||Ot!==0){const Tt=1+et+Ot,R=Tt*(1+D-nt/2),Ft=Tt*(1+nt),le=Tt*(1-D-nt/2),Mt=bt.shadows*.1/255,Jt=[R,0,0,0,Mt,0,Ft,0,0,Mt,0,0,le,0,Mt,0,0,0,1,0].join(" ");Yt+=`<feColorMatrix in="${At}" type="matrix" values="${Jt}" result="advanced"/>`,At="advanced"}if(bt.blur&&(Yt+=`<feGaussianBlur in="${At}" stdDeviation="${bt.blur}" result="blur"/>`,At="blur"),Yt){const Tt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Yt}</filter></svg>`,R=btoa(Tt);J.push(`url('data:image/svg+xml;base64,${R}#f')`)}}J.length>0?t.filter=J.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const Gt=t.globalAlpha,Wt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=Gt*Wt;const _t=e.compositeOperation||e.blendMode;if(_t&&_t!=="Normal"){const it=_t.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 Nt=t,Q=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 ct=!1;const Rt=Q.filter(it=>it.isVisible!==!1&&o.has(it.maskId));if(Rt.length>0){const it=Rt[0],dt=o.get(it.maskId),U=this.objectStates.get(dt.id);U&&U.visible!==!1&&(ct=!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=Nt.filter)}t.translate(Math.round($),Math.round(Y)),t.rotate(N*Math.PI/180);const Ct=e.skew_x||0,St=e.skew_y||0;(Ct!==0||St!==0)&&t.transform(1,Math.tan(St*Math.PI/180),Math.tan(Ct*Math.PI/180),1,0,0);const Xt=e.rotate_x||0,te=e.rotate_y||0,ee=(e.flip_x===!0?-1:1)*Math.cos(te*Math.PI/180),Zt=(e.flip_y===!0?-1:1)*Math.cos(Xt*Math.PI/180);t.scale(E*ee,k*Zt),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 Ut=n.shadow;if(Ut&&Ut.isEnabled!==!1){let it=Ut.color||"#000000";(T=(F=this.artboard)==null?void 0:F.tokens)!=null&&T.colors&&this.artboard.tokens.colors[it]&&(it=this.artboard.tokens.colors[it]);const dt=this.normalizeOpacity(Ut.opacity??100),U=Ut.spread||0,nt=(Ut.blur||0)+U*1.5;let et=it;if(it.startsWith("#")){const At=it.replace("#",""),qt=parseInt(At.substring(0,2),16),Tt=parseInt(At.substring(2,4),16),R=parseInt(At.substring(4,6),16);et=`rgba(${qt}, ${Tt}, ${R}, ${dt})`}else if(it.startsWith("rgba")){const At=it.match(/[\d.]+/g);if(At&&At.length>=4){const qt=At[0],Tt=At[1],R=At[2],Ft=At[3];et=`rgba(${qt}, ${Tt}, ${R}, ${parseFloat(Ft)*dt})`}}const Ot=t.getTransform(),Yt=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1;t.shadowColor=et,t.shadowBlur=nt*Yt,t.shadowOffsetX=(Ut.offsetX||0)*Yt,t.shadowOffsetY=(Ut.offsetY||0)*Yt}const ae=i.liquidFill||((P=i.style)==null?void 0:P.liquidFill);if(ae&&ae.enabled){t.save();const it=ae.fillLevel??.5;t.beginPath();const dt=r/2-r*it;t.rect(-a/2,dt,a,r*it),t.clip(),t.fillStyle=ae.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ae.opacity??1)}if((s==null?void 0:s.type)==="Text")this._renderText(t,i,f,n,e,a,r);else if((s==null?void 0:s.type)==="Image"){const it=s.originalSrc||s.src;if(it){let dt=this.imageCache.get(it);dt||(dt=new Image,dt.onload=()=>{this.log(`[ExodeUI] Image loaded successfully, size: ${dt.naturalWidth}x${dt.naturalHeight}`)},dt.onerror=nt=>{console.error("[ExodeUI] Image load failed:",nt,`Src preview: ${it.substring(0,100)}...`)},dt.src=it,this.imageCache.set(it,dt));const U=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,D=(((L=n.stroke)==null?void 0:L.alignment)||"center").toLowerCase();if(U&&(D==="outside"||D==="center")&&this.applyStrokeAlignment(t,n,f,a,r,l),n.fill&&n.fill.type!=="None"){t.save();const nt=t.globalAlpha,et=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=et||n.fill.color||"transparent",t.globalAlpha=nt*this.normalizeOpacity(n.fill.opacity??100),l!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,l),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=nt,t.restore()}dt.complete&&dt.naturalWidth>0?(l!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,l),t.clip(),t.drawImage(dt,-a/2,-r/2,a,r),t.restore()):t.drawImage(dt,-a/2,-r/2,a,r),U&&D==="inside"&&this.applyStrokeAlignment(t,n,f,a,r,l)):U&&D==="inside"&&this.applyStrokeAlignment(t,n,f,a,r,l)}}else if(s.type==="SVG"){const it=s.svgContent;if(it){const dt=n.palette||[],U=n.fill,D=n.stroke,nt=U?this.normalizeOpacity(U.opacity??100):1,et=(U==null?void 0:U.type)==="Solid"&&(!D||D.isEnabled===!1||D.type==="Solid"&&D.color===U.color),Ot=U&&U.type!=="None"?et?"monochrome":U.type==="Solid"?(U.color||"")+"|opacity:"+nt:JSON.stringify(U.stops||[])+"|opacity:"+nt:"",Yt=D&&D.isEnabled!==!1&&(D.width||0)>0?et?["monochrome",D.width||0,D.trimStart??0,D.trimEnd??1,D.trimOffset??0,D.dashOffset??0].join("|"):[D.width||0,D.fill?D.fill.type==="Solid"?D.fill.color||"":JSON.stringify(D.fill.stops||[]):D.color||"",D.opacity??1,D.lineCap||"",D.lineJoin||"",(D.dashArray||[]).join(","),D.trimStart??0,D.trimEnd??1,D.trimOffset??0,D.dashOffset??0].join("|"):"nostroke",At=[i.id,dt.join("_"),Ot,Yt,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let qt=this.imageCache.get(At);if(!qt){qt=new Image,qt.crossOrigin="anonymous";let R=it;R.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(R=R.replace(/<svg([^>]*)>/i,(ft,ht)=>`<svg xmlns="http://www.w3.org/2000/svg"${ht}>`));let Ft=s.width||a||100,le=s.height||r||100;const Mt=R.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(Mt&&(Ft=parseFloat(Mt[1]),le=parseFloat(Mt[2])),R=R.replace(/<svg([^>]*)>/i,(ft,ht)=>{let mt=ht.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return mt.match(/\bviewBox=/i)||(mt+=` viewBox="0 0 ${Ft} ${le}"`),mt.match(/\bpreserveAspectRatio=/i)||(mt+=' preserveAspectRatio="none"'),mt+=' width="100%" height="100%"',`<svg${mt}>`}),s.colors&&s.colors.length>0&&dt.length>0&&s.colors.forEach((ft,ht)=>{if(dt[ht]){const mt=ft.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),kt=new RegExp(mt,"gi");R=R.replace(kt,dt[ht])}}),U&&U.type&&U.type!=="None"){if(U.type==="Solid"&&U.color){const ft=et?"#FFFFFF":U.color,ht=et?1:this.normalizeOpacity(U.opacity??100);R=R.replace(/\bfill\s*=\s*["'][^"']*["']/gi,mt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(mt)?mt:`fill="${ft}"`),R=R.replace(/fill\s*:\s*[^;"')]+/gi,mt=>/fill\s*:\s*(none|transparent)/i.test(mt)?mt:`fill:${ft}`),ht<1&&(R=R.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${ht}"`),R=R.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${ht}`),R.match(/\bfill-opacity\s*=/i)||(R=R.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${ht}">`),R=R.replace(/<\/svg>/i,"</g></svg>")))}else if(U.type==="LinearGradient"||U.type==="RadialGradient"||U.type==="Linear"||U.type==="Radial"){const ft="exode-fill",ht=this.normalizeOpacity(U.opacity??100),mt=(U.stops||[]).map(gt=>{const zt=gt.offset!==void 0?gt.offset:gt.pos??0,ie=this.normalizeOpacity(gt.opacity??100)*ht;return`<stop offset="${zt*100}%" stop-color="${gt.color||"#000"}" stop-opacity="${ie}"/>`}).join("");let kt="";if(U.type==="LinearGradient"||U.type==="Linear"){const gt=(st,ut)=>Array.isArray(st)?st[ut]??(ut===0?0:1):st&&typeof st=="object"?st[ut===0?"x":"y"]??(ut===0?0:1):ut===0?0:1,zt=gt(U.start,0)*100,ie=gt(U.start,1)*100,jt=gt(U.end,0)*100,rt=gt(U.end,1)*100;kt=`<linearGradient id="${ft}" x1="${zt}%" y1="${ie}%" x2="${jt}%" y2="${rt}%" gradientUnits="objectBoundingBox">${mt}</linearGradient>`}else{const gt=(rt,st)=>Array.isArray(rt)?rt[st]??.5:rt&&typeof rt=="object"?rt[st===0?"x":"y"]??.5:.5,zt=gt(U.center,0)*100,ie=gt(U.center,1)*100,jt=(U.radius??.5)*100;kt=`<radialGradient id="${ft}" cx="${zt}%" cy="${ie}%" r="${jt}%" gradientUnits="objectBoundingBox">${mt}</radialGradient>`}/<defs>/i.test(R)?R=R.replace(/<defs>/i,`<defs>${kt}`):R=R.replace(/<svg([^>]*)>/i,`<svg$1><defs>${kt}</defs>`),R=R.replace(/\bfill\s*=\s*["'][^"']*["']/gi,gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(gt)?gt:`fill="url(#${ft})"`),R=R.replace(/fill\s*:\s*[^;"')]+/gi,gt=>/fill\s*:\s*(none|transparent)/i.test(gt)?gt:`fill:url(#${ft})`)}}const Jt=(ft,ht,mt=1)=>{const kt=(ft.stops||[]).map(rt=>{const st=rt.offset!==void 0?rt.offset:rt.pos??0,ut=this.normalizeOpacity(rt.opacity??100)*mt;return`<stop offset="${st*100}%" stop-color="${rt.color||"#000"}" stop-opacity="${ut}"/>`}).join(""),gt=(rt,st,ut=.5)=>Array.isArray(rt)?rt[st]??ut:rt&&typeof rt=="object"?rt[st===0?"x":"y"]??ut:ut;if(ft.type==="LinearGradient"||ft.type==="Linear"){const rt=gt(ft.start,0,0)*100,st=gt(ft.start,1,0)*100,ut=gt(ft.end,0,1)*100,Bt=gt(ft.end,1,1)*100;return`<linearGradient id="${ht}" x1="${rt}%" y1="${st}%" x2="${ut}%" y2="${Bt}%" gradientUnits="objectBoundingBox">${kt}</linearGradient>`}const zt=gt(ft.center,0,.5)*100,ie=gt(ft.center,1,.5)*100,jt=(ft.radius??.5)*100;return`<radialGradient id="${ht}" cx="${zt}%" cy="${ie}%" r="${jt}%" gradientUnits="objectBoundingBox">${kt}</radialGradient>`},It=(ft,ht)=>/<defs>/i.test(ft)?ft.replace(/<defs>/i,`<defs>${ht}`):ft.replace(/(<svg[^>]*>)/i,`$1<defs>${ht}</defs>`);if(D&&D.isEnabled!==!1&&(D.width||0)>0){const ft=et?1:this.normalizeOpacity(D.opacity??100),ht=et?"#FFFFFF":D.color||(U==null?void 0:U.color)||"#000000";let mt="";const kt=D.fill;if(kt&&kt.type){if(kt.type==="Solid")mt=kt.color||D.color||"#000000";else if(kt.type==="LinearGradient"||kt.type==="RadialGradient"||kt.type==="Linear"||kt.type==="Radial"){const Kt="exode-stroke";R=It(R,Jt(kt,Kt,ft)),mt=`url(#${Kt})`}}mt||(mt=ht),R.match(/\bstroke\s*=\s*["']/i)?R=R.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,Kt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(Kt)?Kt:`stroke="${mt}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${mt}"`),R=R.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${mt}`);let gt=s.width||a||100,zt=s.height||r||100;const ie=it.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(ie){const Kt=parseFloat(ie[1]),ce=parseFloat(ie[2]);!isNaN(Kt)&&!isNaN(ce)&&(gt=Kt,zt=ce)}const jt=Math.max(.001,a/gt),rt=Math.max(.001,r/zt),st=(jt+rt)/2,ut=(D.width||1)/st;R.match(/\bstroke-width\s*=\s*["']/i)?R=R.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${ut}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${ut}"`),R=R.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${ut}`),R.match(/\bstroke-opacity\s*=\s*["']/i)?R=R.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${ft}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${ft}"`),R=R.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${ft}`);const Bt=D.lineCap||"round";R.match(/\bstroke-linecap\s*=\s*["']/i)?R=R.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${Bt}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${Bt}"`),R=R.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${Bt}`);const K=D.lineJoin||"round";R.match(/\bstroke-linejoin\s*=\s*["']/i)?R=R.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${K}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${K}"`),R=R.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${K}`);const vt=D.trimStart??0,yt=D.trimEnd??1,pe=D.trimOffset??0,Ce=D.dashOffset??0,_e=vt!==0||yt!==1||pe!==0||Ce!==0;if(_e){const Kt=Math.max(0,Math.min(1,vt)),ce=Math.max(0,Math.min(1,yt));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${i.name||i.id}, Start: ${Kt}, End: ${ce}`);const ve=(gt+zt)*2,Me=(pe%1+1)%1,Ie=(Ce%1+1)%1;let ge="",de=0;if(Kt>=ce)ge=`0 ${ve}`,de=0;else{const ue=ve*(ce-Kt),Se=ve-ue;de=-(ve*(Kt+Me+Ie)),ge=`${ue} ${Se}`}R.match(/\bstroke-dasharray\s*=/i)?R=R.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${ge}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${ge}"`),R=R.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${ge}`),R.match(/\bstroke-dashoffset\s*=/i)?R=R.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${de}"`):R=R.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${de}"`),R=R.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${de}`)}else if(D.dashArray&&D.dashArray.length>0){const Kt=D.dashArray.join(" ");R=R.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${Kt}"`),R=R.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${Kt}`),D.dashOffset&&(R=R.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${D.dashOffset}"`),R=R.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${D.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(it)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(it)){let Kt="",ce="";if(_e){const ge=s.width||a||100,de=s.height||r||100,ue=(ge+de)*2,Se=Math.max(0,Math.min(1,vt)),Pe=Math.max(0,Math.min(1,yt)),Fe=(pe%1+1)%1,$e=(Ce%1+1)%1;if(Se>=Pe)Kt=` stroke-dasharray="0 ${ue}"`,ce=' stroke-dashoffset="0"';else{const Ee=ue*(Pe-Se),We=ue-Ee,Be=-(ue*(Se+Fe+$e));Kt=` stroke-dasharray="${Ee} ${We}"`,ce=` stroke-dashoffset="${Be}"`}}else(O=D.dashArray)!=null&&O.length&&(Kt=` stroke-dasharray="${D.dashArray.join(" ")}"`,D.dashOffset&&(ce=` stroke-dashoffset="${D.dashOffset}"`));const ve=` stroke-linecap="${D.lineCap||"round"}"`,Me=` stroke-linejoin="${D.lineJoin||"round"}"`,Ie=`stroke="${mt}" stroke-width="${ut}" stroke-opacity="${ft}"${ve}${Me}${Kt}${ce}`;R=R.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(ge,de,ue)=>`${de}${ue}<g ${Ie}>`),R=R.replace(/<\/svg>/i,"</g></svg>")}}else D&&D.isEnabled===!1&&(R=R.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),R=R.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Dt=new Blob([R],{type:"image/svg+xml"}),Qt=URL.createObjectURL(Dt);qt.onload=()=>{if(URL.revokeObjectURL(Qt),this.frameCount%900===0){const ft=this.imageCache.get(At);ft&&this.debugLog(`SVG Payload Ready: ${i.name||i.id} (${ft.naturalWidth}x${ft.naturalHeight})`)}},qt.onerror=()=>{URL.revokeObjectURL(Qt),this.debugLog(`SVG Error: Failed to load payload for ${i.name||i.id}`)},qt.src=Qt,this.imageCache.set(At,qt)}let Tt=null;if(qt.complete&&qt.naturalWidth>0?(Tt=qt,this.lastValidSvgImgMap.set(i.id,qt)):Tt=this.lastValidSvgImgMap.get(i.id)||null,Tt&&Tt.complete&&Tt.naturalWidth>0){const R=Math.max(1,a),Ft=Math.max(1,r);if(et&&(U==null?void 0:U.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=R,this.maskBuffer.height=Ft,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,R,Ft),this.maskCtx.drawImage(Tt,0,0,R,Ft),this.maskCtx.globalCompositeOperation="source-in";const le=U.color||"#000000",Mt=this.normalizeOpacity(U.opacity??100);this.maskCtx.fillStyle=le,this.maskCtx.globalAlpha=Mt,this.maskCtx.fillRect(0,0,R,Ft),t.drawImage(this.maskBuffer,-R/2,-Ft/2,R,Ft)}else l!==0?(t.save(),this.drawRoundRect(t,-R/2,-Ft/2,R,Ft,l),t.clip(),t.drawImage(Tt,-R/2,-Ft/2,R,Ft),t.restore()):t.drawImage(Tt,-R/2,-Ft/2,R,Ft)}}}else if(f.type==="LineGraph")this.renderLineGraph(t,f,a,r);else if(i.type==="Shape"){if(this.applyPath(t,f,a,r,l),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const it=t.globalAlpha;if(((W=n.fill)==null?void 0:W.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const dt=n.fill.originalSrc||n.fill.src;let U=this.imageCache.get(dt);U||(U=new Image,U.src=dt,this.imageCache.set(dt,U)),U.complete&&U.naturalWidth>0&&(t.save(),this.applyPath(t,f,a,r,l),t.clip(),this.renderFittedImage(t,U,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const dt=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=dt||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=it*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,f,a,r,l),t.fill()}t.globalAlpha=it}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,f,a,r,l)}else if(i.type==="Frame"||i.type==="Component"&&(!i.variant||i.variant==="artboard"||i.variant==="instance")||i.type==="Group"&&!i.isStructuralGroup){const it=e.width??s.width??i.width??a,dt=e.height??s.height??i.height??r,U=l;if(t.save(),t.beginPath(),this.drawRoundRect(t,-it/2,-dt/2,it,dt,U),n.fill&&n.fill.type!=="None"){const D=t.globalAlpha,nt=this.createCanvasFill(t,n.fill,it,dt);t.fillStyle=nt||n.fill.color||"transparent",t.globalAlpha=D*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=D}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const D={type:"Rectangle"};this.applyStrokeAlignment(t,n,D,it,dt,U)}}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):this.frameCount%300===0&&this.warn("[Engine] Unhandled object type in renderObject:",i.type,"Geo:",(B=i.geometry)==null?void 0:B.type));if(this.applyArtEffectOverlay(t,i,f,a,r,l),lt&&this.applyBackgroundBlurGlass(t,f,a,r,l,lt),ae&&ae.enabled&&t.restore(),i.children&&i.children.length>0){const dt=i.type==="Frame"||i.type==="Component"&&(!i.variant||i.variant==="artboard"||i.variant==="instance"),U=i.clipsContent!==void 0?i.clipsContent:i.clipContent!==void 0?i.clipContent:dt;if(t.save(),U){t.beginPath();const nt=e.width??(s==null?void 0:s.width)??i.width??0,et=e.height??(s==null?void 0:s.height)??i.height??0,Ot=e.cornerRadius??(s==null?void 0:s.corner_radius)??i.cornerRadius??0;this.drawRoundRect(t,-nt/2,-et/2,nt,et,Ot),t.clip()}let D=0;for(i.children.forEach(nt=>{const et=o.get(nt);if(!et)return;const Ot=this.objectStates.get(nt),Yt=(Ot==null?void 0:Ot.geometry)||et.geometry;if(Yt&&Yt.isMask&&(Ot==null?void 0:Ot.visible)!==!1){const At=Yt.width||0,qt=Yt.height||0;this.applyObjectTransform(t,nt);const Tt=(Ot==null?void 0:Ot.corner_radius)??(Yt==null?void 0:Yt.corner_radius)??0;this.applyPath(t,Yt,At,qt,Tt),t.clip(),D++}else this.renderObject(t,et,o)});D>0;)t.restore(),D--;t.restore()}if(ct){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(D=>D.isVisible!==!1&&o.has(D.maskId)).forEach(D=>{var Tt,R,Ft,le,Mt,Jt;const nt=o.get(D.maskId),et=this.objectStates.get(nt.id),Ot=D.feather||0,Yt=D.inverted===!0,At=D.opacity!==void 0?typeof D.opacity=="number"?D.opacity:D.opacity/100:1;if((D.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),Ot>0&&(this.lumaCtx.filter=`blur(${Ot}px)`),this.lumaCtx.globalAlpha=At;const It=(et==null?void 0:et.width)||nt.geometry.width||0,Dt=(et==null?void 0:et.height)||nt.geometry.height||0,Qt=(et==null?void 0:et.corner_radius)??nt.corner_radius??0;if(((Tt=nt.geometry)==null?void 0:Tt.type)==="Text"){const kt=et!=null&&et.geometry?this.deepMerge(nt.geometry,et.geometry):nt.geometry,gt=et!=null&&et.style?this.deepMerge(nt.style,et.style):nt.style;this._renderText(this.lumaCtx,nt,{...kt,width:It,height:Dt,corner_radius:Qt},gt,et,It,Dt,!0)}else if(((R=nt.geometry)==null?void 0:R.type)==="Image"){const kt=nt.geometry.src;if(kt){let gt=this.imageCache.get(kt);gt||(gt=new Image,gt.src=kt,this.imageCache.set(kt,gt)),gt.complete&&gt.naturalWidth>0?this.lumaCtx.drawImage(gt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Ft=nt.geometry)==null?void 0:Ft.type)==="SVG"){const kt=nt.geometry.svgContent;if(kt){const gt=`__lumamask_${nt.id}`;let zt=this.imageCache.get(gt);if(!zt){zt=new Image;const ie=new Blob([kt],{type:"image/svg+xml"});zt.src=URL.createObjectURL(ie),zt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(gt,zt)}zt.complete&&zt.naturalWidth>0?this.lumaCtx.drawImage(zt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,nt.geometry,It,Dt,Qt),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ft=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),ht=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,mt=ft.data;for(let kt=0;kt<mt.length;kt+=4){const gt=ht[kt],zt=ht[kt+1],ie=ht[kt+2];let jt=(.299*gt+.587*zt+.114*ie)/255;Yt&&(jt=1-jt),mt[kt+3]*=jt}this.maskCtx.putImageData(ft,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Yt?"destination-out":"destination-in",Ot>0&&(this.maskCtx.filter=`blur(${Ot}px)`),this.maskCtx.globalAlpha=At,this.applyAbsoluteTransform(this.maskCtx,nt.id,o);const It=(et==null?void 0:et.width)||nt.geometry.width||0,Dt=(et==null?void 0:et.height)||nt.geometry.height||0,Qt=(et==null?void 0:et.corner_radius)??nt.corner_radius??0;if(((le=nt.geometry)==null?void 0:le.type)==="Text"){const ft=et!=null&&et.geometry?this.deepMerge(nt.geometry,et.geometry):nt.geometry,ht=et!=null&&et.style?this.deepMerge(nt.style,et.style):nt.style;this._renderText(this.maskCtx,nt,{...ft,width:It,height:Dt,corner_radius:Qt},ht,et,It,Dt,!0)}else if(((Mt=nt.geometry)==null?void 0:Mt.type)==="Image"){const ft=nt.geometry.src;if(ft){let ht=this.imageCache.get(ft);ht||(ht=new Image,ht.src=ft,this.imageCache.set(ft,ht)),ht.complete&&ht.naturalWidth>0?this.maskCtx.drawImage(ht,-It/2,-Dt/2,It,Dt):(this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((Jt=nt.geometry)==null?void 0:Jt.type)==="SVG"){const ft=nt.geometry.svgContent;if(ft){const ht=`__alphamask_${nt.id}`;let mt=this.imageCache.get(ht);if(!mt){mt=new Image;const kt=new Blob([ft],{type:"image/svg+xml"});mt.src=URL.createObjectURL(kt),mt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(ht,mt)}mt.complete&&mt.naturalWidth>0?this.maskCtx.drawImage(mt,-It/2,-Dt/2,It,Dt):(this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,nt.geometry,It,Dt,Qt),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),Nt.save(),Nt.setTransform(1,0,0,1,0,0);const U=i.maskBlendMode||i.blendMode;U&&U!=="Normal"&&(Nt.globalCompositeOperation=U.toLowerCase()),Nt.drawImage(this.maskBuffer,0,0),Nt.restore(),Nt.restore()}else t.restore()}}_renderText(t,i,o,e,s,n,a,r=!1,h=!1){var pt,at,Et,xt,bt,Gt,Wt,_t,Nt;let l=o.text||"";if(o.textInputId&&!r){const Q=this.inputs.get(o.textInputId);Q!==void 0&&(l=String(Q),s.geometry&&s.geometry.type==="Text"&&(s.geometry.text=l))}if(o.svgPath){const Q=o.svgPath;t.save();const ct=((pt=e==null?void 0:e.fill)==null?void 0:pt.color)||"#000000",Rt=((at=e==null?void 0:e.fill)==null?void 0:at.opacity)!==void 0?(Et=e==null?void 0:e.fill)==null?void 0:Et.opacity:1;t.fillStyle=ct,t.globalAlpha*=Rt;const Ct=new Path2D(Q);t.fill(Ct),t.restore();return}let f=l||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(f=o.segments.map(Q=>Q&&Q.text?Q.text:"").join(""));const y=o.textCase||"none";y==="uppercase"?f=f.toUpperCase():y==="lowercase"?f=f.toLowerCase():y==="capitalize"&&(f=f.replace(/\b\w/g,Q=>Q.toUpperCase()));let d=((xt=o.fontWeight)==null?void 0:xt.toString())||"400",c=o.fontStyle||"normal";d.toLowerCase().includes("italic")&&(c="italic",d=d.replace(/italic/gi,"").trim()||"400");const u=this.mapFontWeight(d),m=Math.max(1,o.fontSize||32);let g=o.fontFamily||"Inter";const b=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];b.forEach(Q=>{const ct=new RegExp(`[\\s-]${Q}$`,"i");ct.test(g)&&(g=g.replace(ct,"").trim())});const S=`${o.smallCaps===!0?"small-caps ":""}${c} ${u} ${m}px "${g}", sans-serif`;t.font=S;const M=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let I=0;if(typeof o.letterSpacing=="number")I=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const Q=o.letterSpacing;I=Q.unit==="PERCENT"?Q.value/100*m:Q.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${I}px`);const _=o.kerning||"auto",x=o.kerningValue||0;_==="manual"&&x!==0&&(t.letterSpacing=`${I+x}px`);const F=o.paragraphSpacing||0;let T=o.lineHeight??1.2;typeof T=="string"&&(T=parseFloat(T)),T>5&&m>0&&(T=T/m);const P=(T||1.2)*m,L=o.isPointText===!0||!o.width||o.width<=0,O=((bt=o.padding)==null?void 0:bt.left)||((Gt=o.padding)==null?void 0:Gt.right)||0,W=L?1e5:o.width&&o.width>0?Math.ceil(o.width)-O*2:1e5;o.autoHeight;const B=De({text:f,fontFamily:g,fontSize:m,fontWeight:u,fontStyle:c,lineHeight:T,width:W,letterSpacing:I,paragraphSpacing:F,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:y,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),A=B.lines||[],$=B.maxFontSize||m,Y=this.fontLeadingFactors[g]??.5,N=(P-m)*Y;let E=B.height,k=n,G=a;if(k===0||G===0||k>=1e5){let Q=0,ct=0;const Rt=B.fullText||f;(A||[]).forEach(Ct=>{const St=Ct.text||"",Xt=t.measureText(St).width+(St.length>0?(St.length-1)*I:0);Xt>Q&&(Q=Xt),ct+=St.length,ct<Rt.length&&(Rt[ct]===`
23
23
  `||Rt[ct]==="\r")&&(ct++,Rt[ct-1]==="\r"&&Rt[ct]===`
24
- `&&ct++)}),(k===0||k>=1e5)&&(k=Q),Y===0&&(Y=x||0)}L&&s&&s.geometry&&(s.width=k,s.geometry.width=k,s.height=Y,s.geometry.height=Y);let X=-x/2;a>0&&a>x&&(M==="top"?X=-a/2:M==="middle"||M==="center"?X=-x/2:M==="bottom"&&(X=a/2-x)),X+=N;let J=null,tt=0;if(o.pathId&&this.artboard){const Q=this.artboard.objects.find(ct=>ct.id===o.pathId);if(Q&&Q.type==="Shape"&&((Wt=Q.geometry)==null?void 0:Wt.type)==="Path"){const ct=this.objectStates.get(Q.id),Rt=ct!=null&&ct.geometry?this.deepMerge(Q.geometry,ct.geometry):Q.geometry,Ct=(ct==null?void 0:ct.scale_x)!==void 0?(Q.width||0)*ct.scale_x:Q.width||0,St=(ct==null?void 0:ct.scale_y)!==void 0?(Q.height||0)*ct.scale_y:Q.height||0;J={geo:Rt,obj:Q,w:Ct,h:St},tt=this.getPerimeter(Rt,Ct,St)}}const lt=(Q,ct)=>{var Ct,St;if(I===0&&(!o.enableSegments||!((Ct=o.segments)!=null&&Ct.length)))return t.measureText(Q).width;let Rt=0;for(let Xt=0;Xt<Q.length;Xt++){const te=ct+Xt;let ee=0;if(o.enableSegments===!0&&((St=o.segments)==null?void 0:St.length)>0){let Zt=0,Ut=null;for(const ae of o.segments){if(te<Zt+(ae.text||"").length){Ut=ae;break}Zt+=(ae.text||"").length}if(Ut){t.save();let ae=Ut.fontFamily||o.fontFamily||"Inter";const it=this.mapFontWeight((Ut.fontWeight||o.fontWeight||"400").toString()),dt=Ut.fontStyle||l,U=Ut.fontSize||y;t.font=`${dt} ${it} ${U}px "${ae}", sans-serif`,ee=t.measureText(Q[Xt]).width,t.restore()}else ee=t.measureText(Q[Xt]).width}else ee=t.measureText(Q[Xt]).width;Rt+=ee+I}return Rt-(Q.length>0?I:0)},Z=(Q,ct,Rt,Ct,St)=>{var it,dt;const te=(St===0||c[St-1]===`
25
- `||c[St-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,ee=(!r||h)&&(i.behaviors||[]).some(U=>U.enabled&&(U.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(U.type))),Zt=!o.pathId&&!ee&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Ut=o.baselineShift||0,ae=Rt+Ut;if(Zt)t.font=S,Ct?t.strokeText(Q,ct+te,ae):t.fillText(Q,ct+te,ae);else{const U=lt(Q,St);let D=ct+te;w==="center"?D-=U/2:w==="right"&&(D-=U);const nt=St+Q.length>=c.length||c[St+Q.length]===`
26
- `||c[St+Q.length]==="\r";let et=0,Ot=0;const Gt=o.justifyMinWordSpacing,At=o.justifyMaxWordSpacing;if(w==="justify"&&!nt&&U>0&&!o.pathId){const Ft=L?U:W-O*2+0,le=Math.max(0,Ft-U);for(let Mt=0;Mt<Q.length;Mt++)Q[Mt]===" "&&Ot++;if(Ot>0){const Mt=t.measureText(" ").width;let Jt=Gt||Mt*.5,It=At||Mt*2.5;et=Math.max(0,Math.min(le/Ot,It-Jt))}}let qt=o.pathOffset||0;o.pathId&&tt>0&&J&&(w==="center"?qt+=tt/2-U/2:w==="right"&&(qt+=tt-U));let Tt=D;const R=r&&!h?[]:((it=i.behaviors)==null?void 0:it.filter(Ft=>[z.Typewriter,z.Scramble,z.Wave,z.Bounce,z.GlitchText,z.TextTrail,z.Reveal3D,z.RevealSlide,z.RevealBlur,z.TextLiquid,z.TextVortex,z.TextExplosion,z.TextRain,z.TextGravity,z.TextElastic,z.TextMatrix,z.TextNeon,z.TextGlitch3D,z.TextDissolve,z.TextOrganic,z.TextBreathe,z.TextFloral,z.TextSmoke,z.TextVariable,z.TextMagnet,z.TextSpin,z.TextZing,z.TextPerspective,z.TextMirror].includes(Ft.type)&&Ft.enabled))||[];for(let Ft=0;Ft<Q.length;Ft++){let le=Q[Ft];const Mt=St+Ft;let Jt=0,It=0,Dt=1,Qt=1,ft=0,ht=1,mt=le;R.forEach(rt=>{const st=rt.settings||{},ut=st.strength||1,Bt=Date.now();if(rt.type===z.Typewriter)this.currentTime*(st.speed||1)-Mt*(st.stagger||.05)<0&&(ht=0);else if(rt.type===z.Scramble)Math.max(0,Math.min(1,this.currentTime/(st.duration||1.5))-Mt*.02)<1&&Math.random()<.3&&(mt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(rt.type===z.Wave)It+=Math.sin(this.currentTime*5*(st.speed||1)+Mt*(st.frequency||1))*(st.amplitude||20)*ut;else if(rt.type===z.Bounce){const K=Math.max(0,this.currentTime%2-Mt*(st.stagger||.1));K<1&&(It-=Math.abs(Math.sin(K*Math.PI))*(st.height||50)*ut)}else if(rt.type===z.TextTrail){const K=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-Mt*(st.delay||5))];K&&(Jt+=(K.x-(s.x+Tt))*ut*.2,It+=(K.y-(s.y+Rt+It))*ut*.2)}else if(rt.type===z.Reveal3D){const K=Math.max(0,Math.min(1,this.currentTime*(st.speed||1)-Mt*(st.stagger||.1)));Dt*=K,Qt*=K,ht=K}else if(rt.type===z.RevealSlide){const K=Math.max(0,Math.min(1,this.currentTime*1.5-Mt*.05)),vt=(1-K)*(st.distance||40)*ut,yt=st.direction||"up";yt==="up"?It-=vt:yt==="down"?It+=vt:yt==="left"?Jt-=vt:yt==="right"&&(Jt+=vt),ht=K}else if(rt.type===z.RevealBlur){const K=Math.max(0,Math.min(1,this.currentTime*1.2-Mt*.1));ht=K,Jt+=(1-K)*5}else if(rt.type===z.TextLiquid){const K=Math.max(0,Math.sin(Bt*.001*(st.speed||1)+Mt*.5));It+=K*(st.amplitude||10)*ut,Qt*=1+K*.2}else if(rt.type===z.TextVortex){const K=Bt*.002*(st.speed||1)+Mt*.2,vt=(1-(Math.sin(Bt*.001)*.5+.5))*(st.radius||50);Jt+=Math.cos(K)*vt*ut,It+=Math.sin(K)*vt*ut}else if(rt.type===z.TextExplosion){const K=st.force||1,vt=this.currentTime%2;if(vt<1){const yt=(Mt/Q.length-.5)*Math.PI*2,pe=vt*100*K;Jt+=Math.cos(yt)*pe*ut,It+=Math.sin(yt)*pe*ut,ht=1-vt}}else if(rt.type===z.TextRain){const K=st.speed||1,vt=st.height||100,yt=(Bt*.001*K+Mt*.1)%1;It-=(1-yt)*vt*ut,ht=yt>.1?1:yt*10}else if(rt.type===z.TextGravity){const K=st.gravity||9.8,vt=this.currentTime%3/3,yt=.5*K*Math.pow(vt*10,2);yt<100?It+=yt*ut:It+=100*ut}else if(rt.type===z.TextMatrix){const K=st.speed||1;if(Math.random()<.1*K){const yt="0123456789ABCDEF!@#$%^&*";mt=yt[Math.floor(Math.random()*yt.length)]}ht=.3+(Math.sin(Bt*.01*K+Mt)+1)/2*.7}else if(rt.type===z.TextNeon){const K=Math.random()>.95?.5:1;ht=(.7+(Math.sin(Bt*.005)+1)/2*.3)*K}else if(rt.type===z.TextDissolve)Math.sin(Mt*1.5+Bt*.002*(st.speed||1))>.5&&(ht=0);else if(rt.type===z.TextOrganic){const K=st.speed||1,vt=st.amplitude||10;Jt+=Math.sin(Bt*.002*K+Mt)*vt*ut,It+=Math.cos(Bt*.0015*K+Mt*.7)*vt*ut}else if(rt.type===z.TextBreathe){const vt=1+(Math.sin(Bt*.003+Mt*.2)+1)/2*.2*ut;Dt*=vt,Qt*=vt}else if(rt.type===z.TextSpin){const K=st.speed||1;ft+=Bt*.01*K+Mt}else if(rt.type===z.TextMagnet){const K=this.pointerHistory[this.pointerHistory.length-1];if(K){const vt=K.x-(s.x+Tt),yt=K.y-(s.y+Rt);ft=Math.atan2(yt,vt)}}else if(rt.type===z.TextPerspective){const K=Q.length/2,vt=(Mt-K)/K,yt=1-Math.abs(vt)*.3*ut;Dt*=yt,Qt*=yt,Jt+=vt*20*ut}else if(rt.type===z.TextMirror)ht*=.8;else if(rt.type===z.TextFloral){const K=st.speed||1,vt=st.stagger||.1,yt=(Bt*.001*K+Mt*vt)%2;yt<1&&(Dt*=yt,Qt*=yt,ft+=yt*Math.PI)}else if(rt.type===z.TextSmoke){const K=st.speed||1,vt=st.height||50,yt=(Bt*5e-4*K+Mt*.2)%1;It-=yt*vt*ut,Jt+=Math.sin(Bt*.002+Mt)*5*ut,ht=1-yt}else if(rt.type===z.TextVariable){const K=st.speed||1,vt=st.intensity||1.5,yt=(Math.sin(Bt*.004*K+Mt*.3)+1)/2;Dt*=1+yt*(vt-1)*ut}else if(rt.type===z.TextZing){const K=st.speed||2,vt=st.distance||100,yt=(Bt*.002*K+Mt*.05)%1;Jt+=(1-yt)*vt*ut,ht=yt}else if(rt.type===z.TextElastic){const K=st.stiffness||.2,vt=st.damping||.1,yt=Math.sin(Bt*.01)*Math.exp(-Bt*.001*vt);Qt*=1+yt*K*ut}else if(rt.type===z.TextGlitch3D){const K=st.intensity||5;Math.random()<.2&&(Jt+=(Math.random()-.5)*K,It+=(Math.random()-.5)*K,ht=.8)}else if(rt.type===z.GlitchText){const K=st.intensity||5;Math.random()<.1&&(Jt+=(Math.random()-.5)*K,It+=(Math.random()-.5)*K,Math.random()<.05&&(ht=.5))}});let kt=null,gt=o.textDecoration||"none",zt=y;if(o.enableSegments===!0&&((dt=o.segments)==null?void 0:dt.length)>0){let rt=0,st=null;for(const ut of o.segments){if(Mt<rt+(ut.text||"").length){st=ut;break}rt+=(ut.text||"").length}if(st){let ut=st.fontFamily||o.fontFamily||"Inter";b.forEach(vt=>{const yt=new RegExp(`[\\s-]${vt}$`,"i");yt.test(ut)&&(ut=ut.replace(yt,"").trim())});const Bt=this.mapFontWeight((st.fontWeight||o.fontWeight||"400").toString()),K=st.fontStyle||l;zt=st.fontSize||y,t.font=`${K} ${Bt} ${zt}px "${ut}", sans-serif`,st.fill&&(kt=st.fill),st.textDecoration&&(gt=st.textDecoration),zt<$&&(It+=($-zt)*.85)}}else t.font=S;const ie=t.globalAlpha;t.globalAlpha*=ht,t.save();const jt=t.measureText(mt).width;if(J&&tt>0){const rt=Tt-D+jt/2,ut=(qt+rt)/tt,Bt=this.getPointOnPath(J.geo,J.w,J.h,Math.abs(ut%1)),K=Bt.angle,vt=Rt+It+(o.pathOffsetY||0),yt=o.pathSide==="right"?-1:1,pe=Math.cos(K+Math.PI/2)*vt*yt,Ce=Math.sin(K+Math.PI/2)*vt*yt;t.translate(Bt.x+pe+Jt,Bt.y+Ce),t.rotate(K+ft+(yt===-1?Math.PI:0))}else t.translate(Tt+Jt+jt/2,Rt+It),ft!==0&&t.rotate(ft);if(t.scale(Dt,Qt),kt&&!r&&!h){const rt=this.createCanvasFill(t,kt,k,Y);t.fillStyle=rt||kt.color||"#000000"}else if(!r&&!h){const rt=this.createCanvasFill(t,e.fill,k,Y);t.fillStyle=rt||e.fill.color||"#000000"}if(ht>0)if(r||h){const rt=h?"#000000":this.createCanvasFill(t,e.fill,k,Y);t.fillStyle=rt||e.fill.color||"#ffffff",t.fillText(mt,-jt/2,0)}else Ct?t.strokeText(mt,-jt/2,0):t.fillText(mt,-jt/2,0);gt!=="none"&&!r&&this.drawTextDecoration(t,gt,0,0,jt,zt),t.restore(),t.globalAlpha=ie,w==="justify"&&et>0&&mt===" "&&!nt?Tt+=jt+I+et:Tt+=jt+I}}};if(r){let Q=0,ct=X;(A||[]).forEach(Rt=>{const Ct=Rt.text||"",St=c.indexOf(Ct,Q);St!==-1&&(Q=St);let Xt=-k/2;w==="center"?Xt=0:w==="right"&&(Xt=k/2),Z(Ct,Xt,ct,!1,Q),Q+=Ct.length,ct+=P})}else if(h){let Q=0,ct=X;(A||[]).forEach(Rt=>{const Ct=Rt.text||"";let St=-k/2;w==="center"?St=0:w==="right"&&(St=k/2),Z(Ct,St,ct,!1,Q),Q+=Ct.length,Q<c.length&&(c[Q]===`
27
- `||c[Q]==="\r")&&(Q++,c[Q-1]==="\r"&&c[Q]===`
28
- `&&Q++),ct+=P})}else{if(e.fill){const ct=t.globalAlpha,Rt=this.createCanvasFill(t,e.fill,k,Y);t.fillStyle=Rt||e.fill.color||"#000000",t.globalAlpha=ct*this.normalizeOpacity(e.fill.opacity??100);const Ct=B.fullText||(o.enableSegments?(o.segments||[]).map(te=>{let ee=te.text||"";const Zt=te.textCase||o.textCase||"none";return Zt==="uppercase"?ee.toUpperCase():Zt==="lowercase"?ee.toLowerCase():Zt==="capitalize"?ee.replace(/\b\w/g,Ut=>Ut.toUpperCase()):ee}).join(""):c);let St=0,Xt=X;(A||[]).forEach(te=>{const ee=te.text||"";let Zt=-k/2;w==="center"?Zt=0:w==="right"&&(Zt=k/2),Z(ee,Zt,Xt,!1,St),St+=ee.length,Xt+=P,St<Ct.length&&(Ct[St]===`
24
+ `&&ct++)}),(k===0||k>=1e5)&&(k=Q),G===0&&(G=E||0)}L&&s&&s.geometry&&(s.width=k,s.geometry.width=k,s.height=G,s.geometry.height=G);let X=-E/2;a>0&&a>E&&(M==="top"?X=-a/2:M==="middle"||M==="center"?X=-E/2:M==="bottom"&&(X=a/2-E)),X+=N;let J=null,tt=0;if(o.pathId&&this.artboard){const Q=this.artboard.objects.find(ct=>ct.id===o.pathId);if(Q&&Q.type==="Shape"&&((Wt=Q.geometry)==null?void 0:Wt.type)==="Path"){const ct=this.objectStates.get(Q.id),Rt=ct!=null&&ct.geometry?this.deepMerge(Q.geometry,ct.geometry):Q.geometry,Ct=(ct==null?void 0:ct.scale_x)!==void 0?(Q.width||0)*ct.scale_x:Q.width||0,St=(ct==null?void 0:ct.scale_y)!==void 0?(Q.height||0)*ct.scale_y:Q.height||0;J={geo:Rt,obj:Q,w:Ct,h:St},tt=this.getPerimeter(Rt,Ct,St)}}const lt=(Q,ct)=>{var Ct,St;if(I===0&&(!o.enableSegments||!((Ct=o.segments)!=null&&Ct.length)))return t.measureText(Q).width;let Rt=0;for(let Xt=0;Xt<Q.length;Xt++){const te=ct+Xt;let ee=0;if(o.enableSegments===!0&&((St=o.segments)==null?void 0:St.length)>0){let Zt=0,Ut=null;for(const ae of o.segments){if(te<Zt+(ae.text||"").length){Ut=ae;break}Zt+=(ae.text||"").length}if(Ut){t.save();let ae=Ut.fontFamily||o.fontFamily||"Inter";const it=this.mapFontWeight((Ut.fontWeight||o.fontWeight||"400").toString()),dt=Ut.fontStyle||c,U=Ut.fontSize||m;t.font=`${dt} ${it} ${U}px "${ae}", sans-serif`,ee=t.measureText(Q[Xt]).width,t.restore()}else ee=t.measureText(Q[Xt]).width}else ee=t.measureText(Q[Xt]).width;Rt+=ee+I}return Rt-(Q.length>0?I:0)},Z=(Q,ct,Rt,Ct,St)=>{var it,dt;const te=(St===0||f[St-1]===`
25
+ `||f[St-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,ee=(!r||h)&&(i.behaviors||[]).some(U=>U.enabled&&(U.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(U.type))),Zt=!o.pathId&&!ee&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),Ut=o.baselineShift||0,ae=Rt+Ut;if(Zt)t.font=S,Ct?t.strokeText(Q,ct+te,ae):t.fillText(Q,ct+te,ae);else{const U=lt(Q,St);let D=ct+te;w==="center"?D-=U/2:w==="right"&&(D-=U);const nt=St+Q.length>=f.length||f[St+Q.length]===`
26
+ `||f[St+Q.length]==="\r";let et=0,Ot=0;const Yt=o.justifyMinWordSpacing,At=o.justifyMaxWordSpacing;if(w==="justify"&&!nt&&U>0&&!o.pathId){const Ft=L?U:W-O*2+0,le=Math.max(0,Ft-U);for(let Mt=0;Mt<Q.length;Mt++)Q[Mt]===" "&&Ot++;if(Ot>0){const Mt=t.measureText(" ").width;let Jt=Yt||Mt*.5,It=At||Mt*2.5;et=Math.max(0,Math.min(le/Ot,It-Jt))}}let qt=o.pathOffset||0;o.pathId&&tt>0&&J&&(w==="center"?qt+=tt/2-U/2:w==="right"&&(qt+=tt-U));let Tt=D;const R=r&&!h?[]:((it=i.behaviors)==null?void 0:it.filter(Ft=>[z.Typewriter,z.Scramble,z.Wave,z.Bounce,z.GlitchText,z.TextTrail,z.Reveal3D,z.RevealSlide,z.RevealBlur,z.TextLiquid,z.TextVortex,z.TextExplosion,z.TextRain,z.TextGravity,z.TextElastic,z.TextMatrix,z.TextNeon,z.TextGlitch3D,z.TextDissolve,z.TextOrganic,z.TextBreathe,z.TextFloral,z.TextSmoke,z.TextVariable,z.TextMagnet,z.TextSpin,z.TextZing,z.TextPerspective,z.TextMirror].includes(Ft.type)&&Ft.enabled))||[];for(let Ft=0;Ft<Q.length;Ft++){let le=Q[Ft];const Mt=St+Ft;let Jt=0,It=0,Dt=1,Qt=1,ft=0,ht=1,mt=le;R.forEach(rt=>{const st=rt.settings||{},ut=st.strength||1,Bt=Date.now();if(rt.type===z.Typewriter)this.currentTime*(st.speed||1)-Mt*(st.stagger||.05)<0&&(ht=0);else if(rt.type===z.Scramble)Math.max(0,Math.min(1,this.currentTime/(st.duration||1.5))-Mt*.02)<1&&Math.random()<.3&&(mt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(rt.type===z.Wave)It+=Math.sin(this.currentTime*5*(st.speed||1)+Mt*(st.frequency||1))*(st.amplitude||20)*ut;else if(rt.type===z.Bounce){const K=Math.max(0,this.currentTime%2-Mt*(st.stagger||.1));K<1&&(It-=Math.abs(Math.sin(K*Math.PI))*(st.height||50)*ut)}else if(rt.type===z.TextTrail){const K=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-Mt*(st.delay||5))];K&&(Jt+=(K.x-(s.x+Tt))*ut*.2,It+=(K.y-(s.y+Rt+It))*ut*.2)}else if(rt.type===z.Reveal3D){const K=Math.max(0,Math.min(1,this.currentTime*(st.speed||1)-Mt*(st.stagger||.1)));Dt*=K,Qt*=K,ht=K}else if(rt.type===z.RevealSlide){const K=Math.max(0,Math.min(1,this.currentTime*1.5-Mt*.05)),vt=(1-K)*(st.distance||40)*ut,yt=st.direction||"up";yt==="up"?It-=vt:yt==="down"?It+=vt:yt==="left"?Jt-=vt:yt==="right"&&(Jt+=vt),ht=K}else if(rt.type===z.RevealBlur){const K=Math.max(0,Math.min(1,this.currentTime*1.2-Mt*.1));ht=K,Jt+=(1-K)*5}else if(rt.type===z.TextLiquid){const K=Math.max(0,Math.sin(Bt*.001*(st.speed||1)+Mt*.5));It+=K*(st.amplitude||10)*ut,Qt*=1+K*.2}else if(rt.type===z.TextVortex){const K=Bt*.002*(st.speed||1)+Mt*.2,vt=(1-(Math.sin(Bt*.001)*.5+.5))*(st.radius||50);Jt+=Math.cos(K)*vt*ut,It+=Math.sin(K)*vt*ut}else if(rt.type===z.TextExplosion){const K=st.force||1,vt=this.currentTime%2;if(vt<1){const yt=(Mt/Q.length-.5)*Math.PI*2,pe=vt*100*K;Jt+=Math.cos(yt)*pe*ut,It+=Math.sin(yt)*pe*ut,ht=1-vt}}else if(rt.type===z.TextRain){const K=st.speed||1,vt=st.height||100,yt=(Bt*.001*K+Mt*.1)%1;It-=(1-yt)*vt*ut,ht=yt>.1?1:yt*10}else if(rt.type===z.TextGravity){const K=st.gravity||9.8,vt=this.currentTime%3/3,yt=.5*K*Math.pow(vt*10,2);yt<100?It+=yt*ut:It+=100*ut}else if(rt.type===z.TextMatrix){const K=st.speed||1;if(Math.random()<.1*K){const yt="0123456789ABCDEF!@#$%^&*";mt=yt[Math.floor(Math.random()*yt.length)]}ht=.3+(Math.sin(Bt*.01*K+Mt)+1)/2*.7}else if(rt.type===z.TextNeon){const K=Math.random()>.95?.5:1;ht=(.7+(Math.sin(Bt*.005)+1)/2*.3)*K}else if(rt.type===z.TextDissolve)Math.sin(Mt*1.5+Bt*.002*(st.speed||1))>.5&&(ht=0);else if(rt.type===z.TextOrganic){const K=st.speed||1,vt=st.amplitude||10;Jt+=Math.sin(Bt*.002*K+Mt)*vt*ut,It+=Math.cos(Bt*.0015*K+Mt*.7)*vt*ut}else if(rt.type===z.TextBreathe){const vt=1+(Math.sin(Bt*.003+Mt*.2)+1)/2*.2*ut;Dt*=vt,Qt*=vt}else if(rt.type===z.TextSpin){const K=st.speed||1;ft+=Bt*.01*K+Mt}else if(rt.type===z.TextMagnet){const K=this.pointerHistory[this.pointerHistory.length-1];if(K){const vt=K.x-(s.x+Tt),yt=K.y-(s.y+Rt);ft=Math.atan2(yt,vt)}}else if(rt.type===z.TextPerspective){const K=Q.length/2,vt=(Mt-K)/K,yt=1-Math.abs(vt)*.3*ut;Dt*=yt,Qt*=yt,Jt+=vt*20*ut}else if(rt.type===z.TextMirror)ht*=.8;else if(rt.type===z.TextFloral){const K=st.speed||1,vt=st.stagger||.1,yt=(Bt*.001*K+Mt*vt)%2;yt<1&&(Dt*=yt,Qt*=yt,ft+=yt*Math.PI)}else if(rt.type===z.TextSmoke){const K=st.speed||1,vt=st.height||50,yt=(Bt*5e-4*K+Mt*.2)%1;It-=yt*vt*ut,Jt+=Math.sin(Bt*.002+Mt)*5*ut,ht=1-yt}else if(rt.type===z.TextVariable){const K=st.speed||1,vt=st.intensity||1.5,yt=(Math.sin(Bt*.004*K+Mt*.3)+1)/2;Dt*=1+yt*(vt-1)*ut}else if(rt.type===z.TextZing){const K=st.speed||2,vt=st.distance||100,yt=(Bt*.002*K+Mt*.05)%1;Jt+=(1-yt)*vt*ut,ht=yt}else if(rt.type===z.TextElastic){const K=st.stiffness||.2,vt=st.damping||.1,yt=Math.sin(Bt*.01)*Math.exp(-Bt*.001*vt);Qt*=1+yt*K*ut}else if(rt.type===z.TextGlitch3D){const K=st.intensity||5;Math.random()<.2&&(Jt+=(Math.random()-.5)*K,It+=(Math.random()-.5)*K,ht=.8)}else if(rt.type===z.GlitchText){const K=st.intensity||5;Math.random()<.1&&(Jt+=(Math.random()-.5)*K,It+=(Math.random()-.5)*K,Math.random()<.05&&(ht=.5))}});let kt=null,gt=o.textDecoration||"none",zt=m;if(o.enableSegments===!0&&((dt=o.segments)==null?void 0:dt.length)>0){let rt=0,st=null;for(const ut of o.segments){if(Mt<rt+(ut.text||"").length){st=ut;break}rt+=(ut.text||"").length}if(st){let ut=st.fontFamily||o.fontFamily||"Inter";b.forEach(vt=>{const yt=new RegExp(`[\\s-]${vt}$`,"i");yt.test(ut)&&(ut=ut.replace(yt,"").trim())});const Bt=this.mapFontWeight((st.fontWeight||o.fontWeight||"400").toString()),K=st.fontStyle||c;zt=st.fontSize||m,t.font=`${K} ${Bt} ${zt}px "${ut}", sans-serif`,st.fill&&(kt=st.fill),st.textDecoration&&(gt=st.textDecoration),zt<$&&(It+=($-zt)*.85)}}else t.font=S;const ie=t.globalAlpha;t.globalAlpha*=ht,t.save();const jt=t.measureText(mt).width;if(J&&tt>0){const rt=Tt-D+jt/2,ut=(qt+rt)/tt,Bt=this.getPointOnPath(J.geo,J.w,J.h,Math.abs(ut%1)),K=Bt.angle,vt=Rt+It+(o.pathOffsetY||0),yt=o.pathSide==="right"?-1:1,pe=Math.cos(K+Math.PI/2)*vt*yt,Ce=Math.sin(K+Math.PI/2)*vt*yt;t.translate(Bt.x+pe+Jt,Bt.y+Ce),t.rotate(K+ft+(yt===-1?Math.PI:0))}else t.translate(Tt+Jt+jt/2,Rt+It),ft!==0&&t.rotate(ft);if(t.scale(Dt,Qt),kt&&!r&&!h){const rt=this.createCanvasFill(t,kt,k,G);t.fillStyle=rt||kt.color||"#000000"}else if(!r&&!h){const rt=this.createCanvasFill(t,e.fill,k,G);t.fillStyle=rt||e.fill.color||"#000000"}if(ht>0)if(r||h){const rt=h?"#000000":this.createCanvasFill(t,e.fill,k,G);t.fillStyle=rt||e.fill.color||"#ffffff",t.fillText(mt,-jt/2,0)}else Ct?t.strokeText(mt,-jt/2,0):t.fillText(mt,-jt/2,0);gt!=="none"&&!r&&this.drawTextDecoration(t,gt,0,0,jt,zt),t.restore(),t.globalAlpha=ie,w==="justify"&&et>0&&mt===" "&&!nt?Tt+=jt+I+et:Tt+=jt+I}}};if(r){let Q=0,ct=X;(A||[]).forEach(Rt=>{const Ct=Rt.text||"",St=f.indexOf(Ct,Q);St!==-1&&(Q=St);let Xt=-k/2;w==="center"?Xt=0:w==="right"&&(Xt=k/2),Z(Ct,Xt,ct,!1,Q),Q+=Ct.length,ct+=P})}else if(h){let Q=0,ct=X;(A||[]).forEach(Rt=>{const Ct=Rt.text||"";let St=-k/2;w==="center"?St=0:w==="right"&&(St=k/2),Z(Ct,St,ct,!1,Q),Q+=Ct.length,Q<f.length&&(f[Q]===`
27
+ `||f[Q]==="\r")&&(Q++,f[Q-1]==="\r"&&f[Q]===`
28
+ `&&Q++),ct+=P})}else{if(e.fill){const ct=t.globalAlpha,Rt=this.createCanvasFill(t,e.fill,k,G);t.fillStyle=Rt||e.fill.color||"#000000",t.globalAlpha=ct*this.normalizeOpacity(e.fill.opacity??100);const Ct=B.fullText||(o.enableSegments?(o.segments||[]).map(te=>{let ee=te.text||"";const Zt=te.textCase||o.textCase||"none";return Zt==="uppercase"?ee.toUpperCase():Zt==="lowercase"?ee.toLowerCase():Zt==="capitalize"?ee.replace(/\b\w/g,Ut=>Ut.toUpperCase()):ee}).join(""):f);let St=0,Xt=X;(A||[]).forEach(te=>{const ee=te.text||"";let Zt=-k/2;w==="center"?Zt=0:w==="right"&&(Zt=k/2),Z(ee,Zt,Xt,!1,St),St+=ee.length,Xt+=P,St<Ct.length&&(Ct[St]===`
29
29
  `||Ct[St]==="\r")&&(F>0&&(Xt+=F),St++,Ct[St-1]==="\r"&&Ct[St]===`
30
- `&&St++)}),t.globalAlpha=ct}const Q=o.paragraphRule;if(Q&&(((_t=Q.top)==null?void 0:_t.width)>0||((Nt=Q.bottom)==null?void 0:Nt.width)>0)){let ct=0;(A||[]).forEach((Rt,Ct)=>{var te,ee;const Xt=ct===0||ct<c.length&&(c[ct]===`
31
- `||c[ct]==="\r");if(Xt&&Ct>0&&ct++,Xt){if(((te=Q.top)==null?void 0:te.width)>0){const Zt=X+Ct*P-Q.top.offset;t.strokeStyle=Q.top.color||"#000000",t.lineWidth=Q.top.width,t.beginPath();const Ut=-n/2+P*.2;t.moveTo(Ut,Zt),t.lineTo(n/2-P*.2,Zt),t.stroke()}if(((ee=Q.bottom)==null?void 0:ee.width)>0){const Zt=X+(Ct+1)*P-Q.bottom.offset;t.strokeStyle=Q.bottom.color||"#000000",t.lineWidth=Q.bottom.width,t.beginPath();const Ut=-n/2+P*.2;t.moveTo(Ut,Zt),t.lineTo(n/2-P*.2,Zt),t.stroke()}}ct+=(Rt.text||"").length})}if(e.stroke&&e.stroke.width>0){const ct=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color,t.lineWidth=e.stroke.width,t.globalAlpha=ct*this.normalizeOpacity(e.stroke.opacity??100);let Ct=0,St=X;(A||[]).forEach(Xt=>{let te=-k/2;w==="center"?te=0:w==="right"&&(te=k/2),Z(Xt.text,te,St,!0,Ct),Ct+=(Xt.text||"").length,St+=P,Ct<c.length&&(c[Ct]===`
32
- `||c[Ct]==="\r")&&(F>0&&(St+=F),Ct++,c[Ct-1]==="\r"&&c[Ct]===`
33
- `&&Ct++)}),t.globalAlpha=ct}}}applyStrokeAlignment(t,i,o,e,s,n){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const a=i.stroke,r=a.width,h=(a.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),a.fill){const m=this.createCanvasFill(t,a.fill,e,s);m?t.strokeStyle=m:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const c=t.globalAlpha;t.globalAlpha=c*this.normalizeOpacity(a.opacity??100),t.lineWidth=r,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const g=a.trimStart??0,d=a.trimEnd??1,l=a.trimOffset??0,u=a.dashOffset??0,y=a.dashArray||[];if(g!==0||d!==1||l!==0){const m=this.getPerimeter(o,e,s);if(m>0){const b=Math.max(0,Math.min(1,g)),v=Math.max(0,Math.min(1,d));if(b<v){const C=m*(v-b),S=m-C,M=-(m*(b+l%1));t.setLineDash([C,S]),t.lineDashOffset=M+u*m}else if(b===v)t.setLineDash([0,m]);else{const C=m*(1-b+v),S=m-C,M=-(m*b);t.setLineDash([C,S]),t.lineDashOffset=M+u*m}}}else y.length>0&&(t.setLineDash(y),t.lineDashOffset=u);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):h==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):h==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=r,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 h=n/360*r;if(a>0){const f=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));h+=n/360*f,n<360&&(h+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(h+=2*Math.max(e,s));return isNaN(h)?0:h}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 h=e[r];if(h.moveTo){n=h.x,a=h.y;continue}const f=n,c=a,g=e[r-1].out_x,d=e[r-1].out_y;if(g!==void 0||h.in_x!==void 0?s+=this.getBezierLength(f,c,g??f,d??c,h.in_x??h.x,h.in_y??h.y,h.x,h.y):s+=Math.sqrt((h.x-f)**2+(h.y-c)**2),n=h.x,a=h.y,h.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const l=n,u=a,y=[...e.slice(0,r+1)].reverse().find(w=>w.moveTo)||e[0],m=y.x,b=y.y,v=e[r].out_x,C=e[r].out_y,S=y.in_x,M=y.in_y;v!==void 0||S!==void 0?s+=this.getBezierLength(l,u,v??l,C??u,S??m,M??b,m,b):s+=Math.sqrt((m-l)**2+(b-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,h=10){let f=0,c=t,g=i;for(let d=1;d<=h;d++){const l=d/h,u=1-l,y=l*l,m=u*u,b=m*u,v=y*l,C=b*t+3*m*l*o+3*u*y*s+v*a,S=b*i+3*m*l*e+3*u*y*n+v*r,M=C-c,w=S-g;f+=Math.sqrt(M*M+w*w),c=C,g=S}return f}getBezierTAtLength(t,i,o,e,s,n,a,r,h,f=20){if(t<=0)return 0;let c=0,g=i,d=o;for(let l=1;l<=f;l++){const u=l/f,y=1-u,m=u*u,b=y*y,v=b*y,C=m*u,S=v*i+3*b*u*e+3*y*m*n+C*r,M=v*o+3*b*u*s+3*y*m*a+C*h,w=S-g,I=M-d,_=Math.sqrt(w*w+I*I);if(c+_>=t){const E=t-c,F=_===0?0:E/_;return(l-1+F)/f}c+=_,g=S,d=M}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,h=-1/0;s.forEach(b=>{typeof b.x=="number"&&typeof b.y=="number"&&(n=Math.min(n,b.x),a=Math.max(a,b.x),r=Math.min(r,b.y),h=Math.max(h,b.y),b.out_x!==void 0&&(n=Math.min(n,b.out_x),a=Math.max(a,b.out_x)),b.out_y!==void 0&&(r=Math.min(r,b.out_y),h=Math.max(h,b.out_y)),b.in_x!==void 0&&(n=Math.min(n,b.in_x),a=Math.max(a,b.in_x)),b.in_y!==void 0&&(r=Math.min(r,b.in_y),h=Math.max(h,b.in_y)))});const f=(n+a)/2,c=(r+h)/2,d=this.getPerimeter(t,i,o)*e;let l=0;const u=[];let y=s[0],m=s[0];for(let b=1;b<s.length;b++){const v=s[b];if(v.moveTo){y=v,m=v;continue}u.push({p0:y,p1:v}),(v.closePath||b===s.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:v,p1:m}),y=v}for(const b of u){const v=b.p0,C=b.p1;let S=0;const M=v.out_x!==void 0||C.in_x!==void 0;if(M?S=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y):S=Math.sqrt((C.x-v.x)**2+(C.y-v.y)**2),l+S>=d||b===u[u.length-1]){let w=0;if(M)return w=this.getBezierTAtLength(d-l,v.x,v.y,v.out_x??v.x,v.out_y??v.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y,20),this.getBezierPointAndAngle(w,v,C,f,c);{w=S===0?0:(d-l)/S;const I=v.x+(C.x-v.x)*w-f,_=v.y+(C.y-v.y)*w-c,E=Math.atan2(C.y-v.y,C.x-v.x);return{x:I,y:_,angle:E}}}l+=S}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,h=((t.startAngle??0)+a*e)*Math.PI/180,f=s*Math.cos(h),c=n*Math.sin(h),g=-s*Math.sin(h),d=n*Math.cos(h),l=Math.atan2(d,g);return{x:f,y:c,angle:l}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let h=0,f=0,c=0;return r<s?(h=-s/2+r,f=-n/2,c=0):r<s+n?(h=s/2,f=-n/2+(r-s),c=Math.PI/2):r<2*s+n?(h=s/2-(r-(s+n)),f=n/2,c=Math.PI):(h=-s/2,f=n/2-(r-(2*s+n)),c=-Math.PI/2),{x:h,y:f,angle:c}}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,h=i.out_y??i.y,f=o.in_x??o.x,c=o.in_y??o.y,g=o.x,d=o.y,l=1-t,u=t*t,y=l*l,m=y*l,b=u*t,v=m*n+3*y*t*r+3*l*u*f+b*g-e,C=m*a+3*y*t*h+3*l*u*c+b*d-s,S=3*y*(r-n)+6*l*t*(f-r)+3*u*(g-f),M=3*y*(h-a)+6*l*t*(c-h)+3*u*(d-c),w=Math.atan2(M,S);return{x:v,y:C,angle:w}}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){const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),s=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,s)}applyArtEffectOverlay(t,i,o,e,s,n){var d,l,u,y,m;const a=this.objectStates.get(i.id),r=((d=a==null?void 0:a.style)==null?void 0:d.artEffect)||i.artEffect||((l=i.style)==null?void 0:l.artEffect);if(!r||!r.enabled)return;const h=r.type,f=r.intensity??.5,c=r.speed??1,g=r.scale??10;if(h==="acid_gradient"||h==="acid_rave"||h==="shimmer"||h==="glint_overlay"||h==="halftone"||h==="noise"||h==="scanlines"||h==="chromatic_aberration"||h==="pixelate"||h==="glitch"||h==="fold_overlay"||h==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),h==="shimmer"){const v=this.currentTime*c%2/2,C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),C.addColorStop(v,`rgba(255,255,255,${f*.8})`),C.addColorStop(Math.min(1,v+.2),"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(h==="glint_overlay"){let C=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;C=Math.max(-.2,Math.min(1.2,C));const S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,C-.15),"rgba(255,255,255,0)"),S.addColorStop(Math.max(0,Math.min(1,C)),`rgba(255,255,255,${f})`),S.addColorStop(Math.min(1,C+.15),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(h==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((y=i.transform)==null?void 0:y.x)??0),C=b.y-(((m=i.transform)==null?void 0:m.y)??0),S=t.createLinearGradient(v>0?-e/2:e/2,C>0?-s/2:s/2,v>0?e/2:-e/2,C>0?s/2:-s/2);S.addColorStop(0,`rgba(0,0,0,${f*.6})`),S.addColorStop(.4,"rgba(0,0,0,0)"),S.addColorStop(.5,`rgba(255,255,255,${f*.4})`),S.addColorStop(1,`rgba(0,0,0,${f*.2})`),t.fillStyle=S,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&C>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&&C>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&&C<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=C>0?-2:2,t.fill()}else if(h==="crumple_overlay"){const b=Math.floor(e/g),v=document.createElement("canvas");v.width=b,v.height=Math.floor(s/g);const C=v.getContext("2d"),S=C.createImageData(v.width,v.height);for(let M=0;M<S.data.length;M+=4){const w=Math.random()>.95?150:255;S.data[M]=w,S.data[M+1]=w,S.data[M+2]=w,S.data[M+3]=255*f}C.putImageData(S,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-s/2,e,s)}else if(h==="acid_gradient"||h==="acid_rave"){const b=this.currentTime*c,v=r.color1,C=r.color2,S=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(v&&C){const M=b*60%360;S.addColorStop(0,this._shiftHue(v,M,f*.7)),S.addColorStop(1,this._shiftHue(C,(M+180)%360,f*.7))}else{const M=b*100%360,w=(M+180)%360;S.addColorStop(0,`hsla(${M}, 80%, 50%, ${f*.5})`),S.addColorStop(1,`hsla(${w}, 80%, 50%, ${f*.5})`)}t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(h==="halftone"){const b=Math.max(2,g*(1-f*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const C=v.getContext("2d");if(C){C.fillStyle="black",C.beginPath(),C.arc(b/2,b/2,b/2*f,0,Math.PI*2),C.fill();const S=t.createPattern(v,"repeat");S&&(t.globalAlpha=.3*f,t.fillStyle=S,t.fillRect(-e/2,-s/2,e,s))}}else if(h==="noise"){const b=Math.floor(e*s*f*.02);t.globalAlpha=.4*f;for(let v=0;v<b;v++){const C=Math.random()>.5?255:0;t.fillStyle=`rgba(${C}, ${C}, ${C}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(h==="scanlines"){t.globalAlpha=.2*f,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-s/2;b<s/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(h==="chromatic_aberration"){const b=5*f;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+b,-s/2,e,s)}else if(h==="pixelate"){const b=Math.max(2,Math.round(g*(1-f*.5))),v=document.createElement("canvas"),C=Math.max(1,Math.ceil(e/b)),S=Math.max(1,Math.ceil(s/b));v.width=C,v.height=S;const M=v.getContext("2d");if(M){M.imageSmoothingEnabled=!1;const w=t.getTransform(),I=w.e-e/2,_=w.f-s/2;M.drawImage(t.canvas,I,_,e,s,0,0,C,S),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,C,S,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(h==="glitch"){const b=this.currentTime*c,v=r.chaosAmount??.2,C=Math.max(3,Math.floor(8*f)),S=f*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=f*.4;const M=S*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+M,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-M,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const w=s/C;for(let I=0;I<C;I++){const _=Math.sin(I*127.1+b*311.7*c)*43758.5,E=_-Math.floor(_);if(E>1-v){const F=(E-(1-v))/v*S*(Math.random()>.5?1:-1),T=-s/2+I*w,P=t.getTransform(),L=P.e-e/2+F,O=P.f+T;t.save(),t.beginPath(),t.rect(-e/2,T,e,w),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,L,O,e,w,-e/2+F,T,e,w),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const d=t.replace("#","");e=parseInt(d.substring(0,2),16)/255,s=parseInt(d.substring(2,4),16)/255,n=parseInt(d.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let h=0,f=0,c=(a+r)/2;if(a!==r){const d=a-r;switch(f=c>.5?d/(2-a-r):d/(a+r),a){case e:h=((s-n)/d+(s<n?6:0))/6;break;case s:h=((n-e)/d+2)/6;break;case n:h=((e-s)/d+4)/6;break}}return`hsla(${(((h*360+i)%360+360)%360).toFixed(0)}, ${(f*100).toFixed(0)}%, ${(c*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",h=n.opacity??.5,f=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const c=t.getTransform();try{const d=[{x:-o/2,y:-e/2},{x:o/2,y:-e/2},{x:-o/2,y:e/2},{x:o/2,y:e/2}];let l=1/0,u=1/0,y=-1/0,m=-1/0;for(const w of d){const I=c.a*w.x+c.c*w.y+c.e,_=c.b*w.x+c.d*w.y+c.f;I<l&&(l=I),_<u&&(u=_),I>y&&(y=I),_>m&&(m=_)}const b=Math.sqrt(c.a*c.a+c.b*c.b),v=a*b,C=v*2;l=Math.max(0,Math.floor(l-C)),u=Math.max(0,Math.floor(u-C)),y=Math.min(t.canvas.width,Math.ceil(y+C)),m=Math.min(t.canvas.height,Math.ceil(m+C));const S=y-l,M=m-u;if(S>0&&M>0){const w=document.createElement("canvas");w.width=S,w.height=M;const I=w.getContext("2d");if(I){I.drawImage(t.canvas,l,u,S,M,0,0,S,M);const _=document.createElement("canvas");_.width=S,_.height=M;const E=_.getContext("2d");E.filter=`blur(${v}px)`,E.drawImage(w,0,0),t.save(),t.resetTransform(),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(_,l,u),t.restore()}}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=h,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const g=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(g.addColorStop(0,"rgba(255,255,255,0.12)"),g.addColorStop(.3,"rgba(255,255,255,0.04)"),g.addColorStop(.5,"rgba(255,255,255,0.0)"),g.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=g,t.fillRect(-o/2,-e/2,o,e),f>0){if(t.globalAlpha=f/100,!this._noiseTileCanvas){const l=document.createElement("canvas");l.width=64,l.height=64;const u=l.getContext("2d"),y=u.createImageData(64,64),m=y.data;for(let b=0;b<m.length;b+=4){const v=Math.floor(Math.random()*255);m[b]=v,m[b+1]=v,m[b+2]=v,m[b+3]=18}u.putImageData(y,0,0),this._noiseTileCanvas=l}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,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,h=o/2,f=e/2,c=n*Math.PI/180,g=a*Math.PI/180,d=c+g;a>=360&&r<=0?t.ellipse(0,0,h,f,0,0,Math.PI*2):(t.ellipse(0,0,h,f,0,c,d,!1),r>0?t.ellipse(0,0,h*r,f*r,0,d,c,!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 h=r*2*Math.PI/n-Math.PI/2,f=a*Math.cos(h),c=a*Math.sin(h);r===0?t.moveTo(f,c):t.lineTo(f,c)}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 h=0;h<n*2;h++){const f=h*Math.PI/n-Math.PI/2,c=h%2===0?a:r,g=c*Math.cos(f),d=c*Math.sin(f);h===0?t.moveTo(g,d):t.lineTo(g,d)}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,h=-1/0;if(i.points.forEach(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),h=Math.max(h,g.y),g.out_x!==void 0&&(n=Math.min(n,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),h=Math.max(h,g.out_y)),g.in_x!==void 0&&(n=Math.min(n,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),h=Math.max(h,g.in_y)))}),n===1/0)return;const f=(n+a)/2,c=(r+h)/2;if(isNaN(f)||isNaN(c)){this.warn("[Engine] Invalid path center:",f,c);return}i.points.forEach((g,d)=>{if(d===0||g.moveTo)t.moveTo(g.x-f,g.y-c);else{const l=i.points[d-1];if(!l)return;const u=(l.out_x??l.x)-f,y=(l.out_y??l.y)-c,m=(g.in_x??g.x)-f,b=(g.in_y??g.y)-c;isNaN(u)||isNaN(m)||isNaN(g.x)?t.lineTo(g.x-f,g.y-c):t.bezierCurveTo(u,y,m,b,g.x-f,g.y-c)}if(g.closePath||d===i.points.length-1&&(i.is_closed||i.isClosed)){const l=[...i.points.slice(0,d+1)].reverse().find(u=>u.moveTo)||i.points[0];l&&(g.out_x!==void 0||l.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-f,(g.out_y??g.y)-c,(l.in_x??l.x)-f,(l.in_y??l.y)-c,l.x-f,l.y-c),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,h=-1/0;i.points.forEach(g=>{n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),h=Math.max(h,g.y)});const f=(n+a)/2,c=(r+h)/2;i.points.forEach((g,d)=>{if(d===0)t.moveTo(g.x-f,g.y-c);else{const l=i.points[d-1];l.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((l.out_x??l.x)-f,(l.out_y??l.y)-c,(g.in_x??g.x)-f,(g.in_y??g.y)-c,g.x-f,g.y-c):t.lineTo(g.x-f,g.y-c)}(g.closePath||d===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var tt,lt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((tt=i.geometry)==null?void 0:tt.width)||250,n=((lt=i.geometry)==null?void 0:lt.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,h=e.previewState||"default",f=h!=="default"?h:a?"focused":r?"hovered":"default",c=e.label||{visible:!0,text:"Label"},g=e.helperText||{visible:!1,text:"Helper text"},d=e.leftIcon||{visible:!1},l=e.rightIcon||{visible:!1},u=e.multiline===!0,y=e.corner_radius??8,m=e.corners||{tl:y,tr:y,bl:y,br:y},b=[m.tl,m.tr,m.br,m.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",C=e.borderColor||"rgba(55, 65, 81, 1)",S=e.borderWidth??1.5,M=e.color||"#ffffff",w=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const _=`${f}Style`,E=e[_];E?(E.backgroundColor!==void 0&&(v=E.backgroundColor),E.borderColor!==void 0&&(C=E.borderColor),E.borderWidth!==void 0&&(S=E.borderWidth),E.color!==void 0&&(M=E.color),E.placeholderColor!==void 0&&(w=E.placeholderColor),E.fontSize!==void 0&&(I=E.fontSize)):f==="focused"?(C=e.focusBorderColor||"rgba(59, 130, 246, 1)",S=Math.max(S,2)):f==="hovered"||f==="hover"?(C=e.hoverBorderColor||C,v=e.hoverBackgroundColor||v):f==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",C=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):f==="error"&&(C="rgba(239, 68, 68, 1)",S=Math.max(S,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,b);const F=this.createCanvasFill(t,v,s,n);if(F&&(t.fillStyle=F,t.fill()),S>0){const Z=this.createCanvasFill(t,C,s,n);if(Z&&(t.strokeStyle=Z,t.lineWidth=S,t.stroke()),f==="focused"||f==="focus"){t.save(),t.beginPath();const pt=b.map(at=>at+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,pt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const T=(Z,pt)=>{if(!Z.visible||!Z.svgPath)return;const at=Z.size||14,Et=Z.offset??16,xt=Z.color||"#ffffff",bt=pt?-(s/2)+Et:s/2-Et,Yt=Z.svgPath;if(t.save(),t.translate(bt,0),!Yt.startsWith("<svg")){const Wt=new Path2D(Yt),_t=at/24;t.scale(_t,_t),t.translate(-12,-12),t.fillStyle=xt,t.fill(Wt)}t.restore()};T(d,!0),T(l,!1);const P=e.text||"",L=e.placeholder||"Enter text...",O=!P,W=P||L,B=O?w:M,A=I,$=e.fontFamily||"Inter",G=e.fontWeight||400;t.font=`${G} ${A}px "${$}", sans-serif`,t.fillStyle=B,t.textAlign="left",t.textBaseline=u?"top":"middle";const N=e.inputPadding??16,x=d.visible?(d.offset??16)+(d.size||14)/2+8:N,k=l.visible?(l.offset??16)+(l.size||14)/2+8:N,Y=-(s/2)+x,X=s-x-k,J=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(Y-2,-n/2+4,X+4,n-8),t.clip(),u){const Z=J.split(`
34
- `);let pt=-n/2+N;const at=A*1.2;let Et=0;Z.forEach((xt,bt)=>{const Yt=xt.split(" ");let Wt="";for(let _t=0;_t<Yt.length;_t++){const Nt=Wt+Yt[_t]+" ";t.measureText(Nt).width>X&&_t>0?(t.fillText(Wt,Y,pt),Wt=Yt[_t]+" ",pt+=at):Wt=Nt}t.fillText(Wt,Y,pt),Et=t.measureText(Wt).width,bt<Z.length-1&&(pt+=at,Et=0)}),a&&!O&&Math.floor(performance.now()/500)%2===0&&t.fillRect(Y+Et,pt,1.5,A)}else{const pt=t.measureText(J).width;let at=0;if(pt>X&&(at=pt-X),t.fillText(J,Y-at,0),a&&!O&&Math.floor(performance.now()/500)%2===0){const xt=Y+pt-at;t.fillRect(xt,-(A/2),1.5,A)}}if(t.restore(),c.visible!==!1){const Z=c.text||"Label",pt=c.fontSize||12,at=c.color||"rgba(156, 163, 175, 1)",Et=c.offset??8;t.font=`600 ${pt}px "${$}", sans-serif`,t.fillStyle=at,t.textAlign="left",t.textBaseline="bottom";const xt=-(s/2),bt=-(n/2)-Et;t.fillText(Z,xt,bt)}if(g.visible===!0){const Z=g.text||"Helper text",pt=g.fontSize||11,at=f==="error"?"rgba(239, 68, 68, 1)":g.color||"rgba(156, 163, 175, 1)",Et=g.offset??6;t.font=`400 ${pt}px "${$}", sans-serif`,t.fillStyle=at,t.textAlign="left",t.textBaseline="top";const xt=-(s/2),bt=n/2+Et;t.fillText(Z,xt,bt)}}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,f=(s.max??100)-r,c=f===0?0:(a-r)/f,g=s.trackHeight||4,d=s.trackRoundedness??2,l=s.trackShape??"Rectangle",u=s.trackPath||"",y=s.accentColor||"#3b82f6",m=s.inactiveColor||"#374151",b=s.thumbShape||"Ellipse",v=s.thumbWidth??16,C=s.thumbHeight??16,S=s.thumbRoundedness??0,M=s.thumbColor||"#ffffff",w=s.thumbPath||"",I=s.thumbIcon||"",_=s.showValueTooltip??!1,E=s.tooltipBgColor||"#333333",F=s.tooltipColor||"#ffffff",T=s.tooltipOffsetX??0,P=s.tooltipOffsetY??-25,L=(X,J,tt,lt,Z,pt,at)=>{if((X==="Custom"||X==="Icon")&&at)try{const Et=new Path2D(at);if(t.save(),t.translate(J,tt),X==="Icon"){const xt=Math.min(lt,Z)/24;t.scale(xt,xt),t.translate(-12,-12)}t.fill(Et),t.restore();return}catch(Et){console.error("Error drawing slider shape in engine:",Et)}if(t.beginPath(),X==="Ellipse")t.ellipse(J,tt,lt/2,Z/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,J-lt/2,tt-Z/2,lt,Z,pt);else if(X==="Triangle")t.moveTo(J,tt-Z/2),t.lineTo(J+lt/2,tt+Z/2),t.lineTo(J-lt/2,tt+Z/2),t.closePath();else if(X==="Diamond")t.moveTo(J,tt-Z/2),t.lineTo(J+lt/2,tt),t.lineTo(J,tt+Z/2),t.lineTo(J-lt/2,tt),t.closePath();else if(X==="Polygon"){const Et=i.geometry.sides||3,xt=i.geometry.radius||Math.min(lt,Z)/2;for(let bt=0;bt<Et;bt++){const Yt=bt*2*Math.PI/Et-Math.PI/2,Wt=J+xt*Math.cos(Yt),_t=tt+xt*Math.sin(Yt);bt===0?t.moveTo(Wt,_t):t.lineTo(Wt,_t)}t.closePath()}else if(X==="Star"){const xt=Math.min(lt,Z)/2,bt=xt/2;for(let Yt=0;Yt<10;Yt++){const Wt=Yt%2===0?xt:bt,_t=Yt*Math.PI/5-Math.PI/2;t.lineTo(J+Wt*Math.cos(_t),tt+Wt*Math.sin(_t))}t.closePath()}else X==="Line"&&(t.moveTo(J-lt/2,tt),t.lineTo(J+lt/2,tt));t.fill()},O=this.createCanvasFill(t,m,n,g);O&&(t.fillStyle=O,t.strokeStyle=O),l==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):L(l,0,0,n,g,d,u);const W=n-v,B=-n/2+v/2+c*W,A=B- -n/2;if(A>0){const X=this.createCanvasFill(t,y,n,g);X&&(t.fillStyle=X,t.strokeStyle=X),l==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(B,0),t.stroke()):l==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-g/2,A,g,d),t.fill())}t.save(),t.translate(B,0);const $=t.getTransform(),G=Math.sqrt($.a*$.a+$.b*$.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*G,t.shadowOffsetY=1*G;const N=this.createCanvasFill(t,M,v,C);if(N&&(t.fillStyle=N),L(b,0,0,v,C,S,b==="Icon"?I:w),t.restore(),_){t.save(),t.translate(B+T,P);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const J=t.measureText(X),tt=6,lt=4,Z=J.width+tt*2,pt=14+lt;t.beginPath(),this.drawRoundRect(t,-Z/2,-pt/2,Z,pt,4),t.fillStyle=E,t.fill(),t.fillStyle=F,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const x=s.label||{},k=s.helperText||{},Y=s.fontFamily||"Inter";if(x.visible!==!1){const X=x.text||"Label",J=x.fontSize||12,tt=x.color||"rgba(156, 163, 175, 1)",lt=x.offset??8;t.font=`600 ${J}px "${Y}", sans-serif`,t.fillStyle=tt,t.textAlign="left",t.textBaseline="bottom";const Z=-(n/2),pt=-(g/2)-lt;t.fillText(X,Z,pt)}if(k.visible===!0){const X=k.text||"Helper text",J=k.fontSize||11,tt=k.color||"rgba(156, 163, 175, 1)",lt=k.offset??6;t.font=`400 ${J}px "${Y}", sans-serif`,t.fillStyle=tt,t.textAlign="left",t.textBaseline="top";const Z=-(n/2),pt=g/2+lt;t.fillText(X,Z,pt)}}renderDropdown(t,i){var P;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,h=e.corner_radius??6,f=e.disabled||e.previewState==="disabled",c=this.lastHoveredObjectId===i.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!f;let d=e.backgroundColor,l=e.borderColor,u=e.color||"#333333";f?(d=e.disabledBackgroundColor||"#f3f4f6",l=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):g?(d=e.activeBackgroundColor||d,l=e.activeBorderColor||l,u=e.activeColor||u):c&&(d=e.hoverBackgroundColor||d,l=e.hoverBorderColor||l,u=e.hoverColor||u),d||(d="#ffffff"),l||(l="#e5e7eb");const y=t.globalAlpha;t.globalAlpha=y*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,h),t.fillStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#ffffff",t.fill();const m=e.borderWidth??1;m>0&&(t.strokeStyle=this.createCanvasFill(t,typeof l=="string"?{type:"Solid",color:l}:l,s,n)||"#e5e7eb",t.lineWidth=m,t.stroke());const b=12,v=e.chevronType||"chevron",C=e.chevronSize||16,S=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const L=a+s-b-C/2;t.save(),t.translate(L,0);const O=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(O*Math.PI/180),t.strokeStyle=S,t.fillStyle=S,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-C/2,-C*.2),t.lineTo(0,C*.2),t.lineTo(C/2,-C*.2),t.stroke();else if(v==="custom"||v==="path"){const W=g&&e.openIconPath||e.closedIconPath;if(W){const B=new Path2D(W);t.save();const A=C/24;t.scale(A,A),t.translate(-12,-12),t.fill(B),t.restore()}}t.restore()}const M=e.selectedOption||e.placeholder||"Select...",w=e.fontSize||14,I=e.fontWeight||400,_=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${w}px ${_}`;const E=f?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof E=="string"?{type:"Solid",color:E}:E,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const F=v==="none"?0:C+8,T=s-b*2-F;if(t.save(),t.beginPath(),t.rect(a+b,r,T,n),t.clip(),t.fillText(M,a+b,0),t.restore(),g&&!f){const L=r+n+4,O=e.optionsList||[],W=e.itemHeight||32,B=e.listPadding??4,A=O.length*W+B*2,$=e.listCornerRadius??h;t.save();const G=e.listShadow||{},N=t.getTransform(),x=Math.sqrt(N.a*N.a+N.b*N.b)||1;t.shadowColor=typeof G.color=="string"?G.color:((P=G.color)==null?void 0:P.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(G.blur??12)*x,t.shadowOffsetY=(G.offsetY??6)*x,t.shadowOffsetX=(G.offsetX??0)*x,t.beginPath(),this.drawRoundRect(t,a,L,s,A,$),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,A)||"#ffffff",t.fill();const k=e.listBorderWidth??1;k>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:l},s,A)||"#e5e7eb",t.lineWidth=k,t.stroke()),t.restore();const Y=e.itemFontSize||w,X=e.itemFontFamily||_;t.font=`${I} ${Y}px ${X}`,O.forEach((J,tt)=>{const lt=L+B+tt*W;if(J===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+k,lt,s-k*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const pt=this._lastPointerPos.y-(L+B),at=Math.floor(pt/W);tt===at&&(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+k,lt,s-k*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(J,a+b,lt+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,h=this.activeObjectId===i.id,f=e.label||{},c=e.hoverStyle||{},g=e.activeStyle||{},d=e.icon||{enabled:!1};let l=e.backgroundColor||"#3b82f6",u=f.color||"#ffffff",y=f.text||"Button",m=s.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,C=1;h&&g?(l=g.backgroundColor||l,u=g.color||u,y=g.text||y,C=g.scale??.95,m=g.cornerRadius??m):r&&c&&(l=c.backgroundColor||l,u=c.color||u,y=c.text||y,C=c.scale??1,m=c.cornerRadius??m,b=c.borderColor||b);const S=-n/2,M=-a/2;t.save(),t.scale(C,C),t.beginPath(),this.drawRoundRect(t,S,M,n,a,m);const w=this.createCanvasFill(t,l,n,a);w&&(t.fillStyle=w,t.fill()),(v>0||r&&c.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(r?1:0),t.stroke());const I=f.fontSize||14,_=f.fontFamily||"Inter",E=f.fontWeight||600;t.font=`${E} ${I}px "${_}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let F=0;if(d.enabled&&d.svgPath){const T=I*1.1,P=d.gap||8,L=t.measureText(y),W=-(L.width+T+P)/2,B=d.position==="left"?W+T/2:W+L.width+P+T/2;F=d.position==="left"?W+T+P+L.width/2:W+L.width/2,t.save(),t.translate(B,0);const A=new Path2D(d.svgPath),$=T/24;t.scale($,$),t.translate(-12,-12),t.fillStyle=u,t.fill(A),t.restore()}t.fillText(y,F,0),t.restore()}renderToggleButton(t,i){var y,m;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=((m=i.geometry)==null?void 0:m.height)||40,r=-n/2,h=-a/2,f=e.corner_radius??8,c=e.label||{},g=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",d=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,h,n,a,f),t.fillStyle=g,t.fill();const l=c.fontSize||14,u=c.fontFamily||"Inter";t.font=`${c.fontWeight||600} ${l}px "${u}", sans-serif`,t.fillStyle=d,t.textAlign="center",t.textBaseline="middle",t.fillText(c.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var $,G,N,x,k,Y,X,J,tt,lt,Z,pt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=(($=i.geometry)==null?void 0:$.width)||52,n=((G=i.geometry)==null?void 0:G.height)||30,a=-s/2,r=-n/2,h=e.checked??!1,f=e.cornerRadius??e.corner_radius??n/2,c=e.toggleStyle||{},g=c.backgroundColor||e.activeColor||"#10b981",d=c.borderColor||e.borderColor||"transparent",l=c.borderWidth??e.borderWidth??0,u=c.knobColor||e.knobColor||"#ffffff",y=h?g:e.inactiveColor||"#374151",m=h?d:e.borderColor||"transparent",b=h?l:e.borderWidth??0,v=h?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,f);const C=this.createCanvasFill(t,y,s,n);if(C&&(t.fillStyle=C,t.fill()),b>0){t.lineWidth=b;const at=this.createCanvasFill(t,m,s,n);at&&(t.strokeStyle=at,t.stroke())}const S=2,M=n-S*2,w=M/2,I=a+S,_=a+s-S-M,E=h?_:I,F=r+S;t.beginPath(),t.arc(E+w,F+w,w,0,Math.PI*2);const T=this.createCanvasFill(t,v,M,M);T&&(t.fillStyle=T,t.fill()),e.disabled&&(t.globalAlpha*=2);let P=!1,L=!1;const O=(h?(N=c.leftLabel)==null?void 0:N.text:null)||((x=e.leftLabel)==null?void 0:x.text)||"",W=(h?(k=c.leftLabel)==null?void 0:k.color:null)||((Y=e.leftLabel)==null?void 0:Y.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&O){const at=e.leftLabel;t.font=`${at.fontWeight||400} ${at.fontSize||12}px "${at.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(O,a-(at.gap||8),0),P=!0}const B=(h?(J=c.rightLabel)==null?void 0:J.text:null)||((tt=e.rightLabel)==null?void 0:tt.text)||"",A=(h?(lt=c.rightLabel)==null?void 0:lt.color:null)||((Z=e.rightLabel)==null?void 0:Z.color)||"#f3f4f6";if((pt=e.rightLabel)!=null&&pt.enabled&&B){const at=e.rightLabel;t.font=`${at.fontWeight||400} ${at.fontSize||12}px "${at.fontFamily||"Inter"}", sans-serif`,t.fillStyle=A,t.textBaseline="middle",t.textAlign="left",t.fillText(B,a+s+(at.gap||8),0),L=!0}if(!P&&!L&&e.label&&e.label.text){const at=e.label,Et=at.fontSize||14,xt=at.fontWeight||400,bt=at.fontFamily||"Inter";t.font=`${xt} ${Et}px "${bt}", sans-serif`,t.fillStyle=at.color||"#f3f4f6",t.textBaseline="middle";const Yt=at.gap||10;let Wt=0,_t=0;at.position==="left"?(t.textAlign="right",Wt=a-Yt,_t=0):at.position==="right"?(t.textAlign="left",Wt=a+s+Yt,_t=0):at.position==="top"?(t.textAlign="center",Wt=0,_t=r-Yt,t.textBaseline="bottom"):at.position==="bottom"?(t.textAlign="center",Wt=0,_t=r+n+Yt,t.textBaseline="top"):(t.textAlign="left",Wt=a+s+Yt,_t=0),t.fillText(at.text,Wt,_t)}}renderCheckbox(t,i){var C,S;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)||20,n=((S=i.geometry)==null?void 0:S.height)||20,a=-s/2,r=-n/2,h=e.cornerRadius??4,f=e.checked??!1,c=e.activeColor||"#3b82f6",g=e.inactiveColor||"transparent",d=e.checkColor||"#ffffff",l=e.borderColor||"#4b5563",u=e.borderWidth??2,y=f?c:g,m=f?"transparent":l,b=f?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const v=this.createCanvasFill(t,y,s,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const M=this.createCanvasFill(t,m,s,n);M&&(t.strokeStyle=M,t.stroke())}else if(f){t.lineWidth=1;const M=this.createCanvasFill(t,c,s,n);M&&(t.strokeStyle=M,t.stroke())}if(f){t.save(),t.beginPath();const M=this.createCanvasFill(t,d,s,n);t.strokeStyle=M||d,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const w=a+s*.25,I=r+n*.5,_=a+s*.45,E=r+n*.7,F=a+s*.75,T=r+n*.25;t.moveTo(w,I),t.lineTo(_,E),t.lineTo(F,T),t.stroke(),t.restore()}if(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||"#f3f4f6",t.textBaseline="middle";const w=M.gap||8;let I=0,_=0;M.position==="left"?(t.textAlign="right",I=a-w,_=0):M.position==="right"?(t.textAlign="left",I=a+s+w,_=0):M.position==="top"?(t.textAlign="center",I=0,_=r-w,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",I=0,_=r+n+w,t.textBaseline="top"),t.fillText(M.text,I,_),t.restore()}}renderRadioGroup(t,i){var S,M;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)||180,n=((M=i.geometry)==null?void 0:M.height)||100,a=-s/2,r=-n/2,h=e.selectedValue,f=e.optionsList||["Option 1","Option 2","Option 3"],c=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,d=e.activeColor||"#3b82f6",l=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",y=e.fontSize||14,m=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,C=v*2;if(t.save(),t.font=`${b} ${y}px "${m}", sans-serif`,t.textBaseline="middle",t.textAlign="left",c==="vertical"){const w=Math.max(C,y)+g;f.forEach((I,_)=>{const E=r+_*w+v;t.beginPath(),t.arc(a+v,E,v,0,Math.PI*2);const F=h===I,T=this.createCanvasFill(t,d,C,C),P=this.createCanvasFill(t,l,C,C);F?(t.strokeStyle=T||d,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,E,v/2,0,Math.PI*2),t.fillStyle=T||d,t.fill()):(t.strokeStyle=P||l,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+C+8,E)})}else{let w=a;f.forEach(I=>{const _=h===I,E=t.measureText(I).width;t.beginPath(),t.arc(w+v,0,v,0,Math.PI*2);const F=this.createCanvasFill(t,d,C,C),T=this.createCanvasFill(t,l,C,C);_?(t.strokeStyle=F||d,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(w+v,0,v/2,0,Math.PI*2),t.fillStyle=F||d,t.fill()):(t.strokeStyle=T||l,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,w+C+6,0),w+=C+6+E+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#9ca3af",t.textBaseline="middle";const I=w.gap||8;let _=0,E=0;w.position==="left"?(t.textAlign="right",_=a-I,E=0):w.position==="right"?(t.textAlign="left",_=a+s+I,E=0):w.position==="top"?(t.textAlign="center",_=0,E=r-I,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",_=0,E=r+n+I,t.textBaseline="top"),t.fillText(w.text,_,E),t.restore()}}renderBarChart(t,i){var E,F;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((E=i.geometry)==null?void 0:E.width)||300,height:((F=i.geometry)==null?void 0:F.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 ss[this.stylePreset]||ss.default},_resolveColor:function(T,P){const L=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(T)?L.colors[P%L.colors.length]:typeof T=="string"?T:L.colors[P%L.colors.length]},_makeGradient:function(T,P,L,O,W,B){if(!this._getPreset().barGradient&&!this.barGradient)return P;const $=T.createLinearGradient(L,O,W,B);return $.addColorStop(0,P),$.addColorStop(1,P+"44"),$},_drawRoundedBar:function(T,P,L,O,W,B,A){if(B=Math.min(B,Math.min(Math.abs(O),Math.abs(W))/2),B<=0||O===0||W===0){T.rect(P,L,O,W);return}T.beginPath(),A?(T.moveTo(P,L+W),T.lineTo(P,L+B),T.quadraticCurveTo(P,L,P+B,L),T.lineTo(P+O-B,L),T.quadraticCurveTo(P+O,L,P+O,L+B),T.lineTo(P+O,L+W),T.lineTo(P,L+W)):(T.moveTo(P,L),T.lineTo(P+O-B,L),T.quadraticCurveTo(P+O,L,P+O,L+B),T.lineTo(P+O,L+W-B),T.quadraticCurveTo(P+O,L+W,P+O-B,L+W),T.lineTo(P,L+W),T.lineTo(P,L)),T.closePath()}},n=s.width,a=s.height,r=-n/2,h=-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 f=s._getPreset();let c=-1/0,g=1/0;const d=s.categories.length,l=s.datasets.length;if(s.chartType==="stacked")for(let T=0;T<d;T++){let P=0,L=0;s.datasets.forEach(O=>{const W=O.data[T]??0;W>=0?P+=W:L+=W}),P>c&&(c=P),L<g&&(g=L)}else s.datasets.forEach(T=>{T.data&&T.data.forEach(P=>{P>c&&(c=P),P<g&&(g=P)})});isFinite(c)||(c=10),isFinite(g)||(g=0),c=Math.max(c,0),g=Math.min(g,0);const u=c-g||10;t.save(),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(c.toFixed(0)).width+14:10,m=s.showXLabels?s.axisLabelFontSize+12:8,v=(s.showLegend&&l>0?s.legendFontSize+10:0)+8,C=10,S=r+y,M=h+v,w=n-y-C,I=a-v-m;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,h,n,a,10),t.fillStyle=f.cardBackground,t.fill(),t.strokeStyle=f.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(S,M,w,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&l>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const T=h+12;let P=S;s.datasets.forEach((L,O)=>{const W=s._resolveColor(L.color,O),B=L.label||"Series "+(O+1),A=7;t.beginPath(),t.roundRect(P,T-A/2,A,A,2),t.fillStyle=W,t.fill(),t.fillStyle=f.legendColor,t.textAlign="left",t.fillText(B,P+A+4,T),P+=t.measureText(B).width+A+16})}const _=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=f.gridColor;for(let T=0;T<=_;T++)if(s.orientation==="horizontal"){const P=S+T/_*w;t.beginPath(),t.moveTo(P,M),t.lineTo(P,M+I),t.stroke()}else{const P=M+T/_*I;t.beginPath(),t.moveTo(S,P),t.lineTo(S+w,P),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor;for(let T=0;T<=_;T++)if(s.orientation==="horizontal"){const P=g+T/_*u,L=S+T/_*w;t.textAlign="center",t.fillText(P.toFixed(0),L,M+I+s.axisLabelFontSize)}else{const P=c-T/_*u,L=M+T/_*I;t.textAlign="right",t.fillText(P.toFixed(0),S-6,L)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(S,M+I),t.lineTo(S+w,M+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(S,M),t.lineTo(S,M+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const T=I/d;for(let P=0;P<d;P++){const L=M+P*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[P]||"",S-5,L),s.enableShadows&&(t.shadowColor=s.shadowColor));let O=S;s.datasets.forEach((W,B)=>{const A=W.data[P]??0;if(A===0)return;const $=A/u*w,G=Math.min(s.barWidth*l+s.barGap,T-8),N=L-G/2,x=O;O+=$;const k=s._resolveColor(W.color,B);t.beginPath(),t.fillStyle=s._makeGradient(t,k,x,N,x+$,N),s._drawRoundedBar(t,x,N,$,G,B===l-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?k:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const T=w/d;for(let P=0;P<d;P++){const L=S+P*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[P]||"",L,M+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let O=M+I;s.datasets.forEach((W,B)=>{const A=W.data[P]??0;if(A===0)return;const $=A/u*I,G=Math.min(s.barWidth*l+s.barGap,T-8),N=L-G/2,x=O-$;O-=$;const k=s._resolveColor(W.color,B);t.beginPath(),t.fillStyle=s._makeGradient(t,k,N,x,N,x+$),s._drawRoundedBar(t,N,x,G,$,B===l-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?k: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 T=I/d,P=l*s.barWidth+Math.max(0,(l-1)*s.barGap),L=S+(0-g)/u*w;for(let O=0;O<d;O++){const W=M+O*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[O]||"",S-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const B=W-P/2;s.datasets.forEach((A,$)=>{const G=A.data[O]??0,N=Math.abs(G/u*w);if(N<1)return;const x=B+$*(s.barWidth+s.barGap),k=G>=0?L:L-N,Y=s._resolveColor(A.color,$);t.beginPath(),t.fillStyle=s._makeGradient(t,Y,k,x,k+N,x),s._drawRoundedBar(t,k,x,N,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?Y:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&G!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=G>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?Y:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(G.toString(),G>=0?k+N+4:k-4,x+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const T=w/d,P=l*s.barWidth+Math.max(0,(l-1)*s.barGap),L=M+I-(0-g)/u*I;for(let O=0;O<d;O++){const W=S+O*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=f.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[O]||"",W,M+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const B=W-P/2;s.datasets.forEach((A,$)=>{const G=A.data[O]??0,N=Math.abs(G/u*I);if(N<1)return;const x=B+$*(s.barWidth+s.barGap),k=G>=0?L-N:L,Y=s._resolveColor(A.color,$);t.beginPath(),t.fillStyle=s._makeGradient(t,Y,x,k,x,k+N),s._drawRoundedBar(t,x,k,s.barWidth,N,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?Y:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&G!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=G>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?Y:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(G.toString(),x+s.barWidth/2,G>=0?k-4:k+N+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var y,m;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:((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 is[this.stylePreset]||is.default},_resolveSliceColor:function(b,v){const C=b.color,S=v,M=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(C)?M.colors[S%M.colors.length]:typeof C=="string"?C:M.colors[S%M.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((b,v)=>b+(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 h=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke();const f=s.showLegend?Math.ceil(s.slices.length/2):0,c=f>0?f*(s.legendFontSize+8)+10:0,g=a-c-16,d=Math.min(n-24,g)/2,l=0,u=-c/2;if(s.chartType==="rose"){const b=Math.max(...s.slices.map(S=>S.value||0)),v=Math.PI*2/s.slices.length,C=d>0?s.sliceGap/d:0;s.slices.forEach((S,M)=>{const w=S.value||0;if(w===0)return;const I=w/b*d,_=-Math.PI/2+M*v+C/2,E=_+v-C,F=s._resolveSliceColor(S,M);if(t.beginPath(),t.moveTo(l,u),t.arc(l,u,I,_,E),t.closePath(),t.fillStyle=F+"cc",t.fill(),t.strokeStyle=F,t.lineWidth=1.5,t.stroke(),s.showLabels){const T=_+(E-_)/2,P=l+I*.65*Math.cos(T),L=u+I*.65*Math.sin(T),O=Math.round(w/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=h.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${O}%`,P,L),t.restore()}})}else{const b=s.chartType==="pie"?0:s.innerRadius,v=d*Math.max(0,b),C=d>0?s.sliceGap/d:0;let S=-Math.PI/2;if(s.slices.forEach((M,w)=>{const I=M.value||0;if(I===0){S+=I/r*Math.PI*2;return}const _=I/r*Math.PI*2,E=S+C/2,F=S+_-C/2;if(F<=E){S+=_;return}const T=s._resolveSliceColor(M,w);if(t.beginPath(),t.fillStyle=T,v<=0?(t.moveTo(l,u),t.arc(l,u,d,E,F),t.lineTo(l,u)):(t.moveTo(l+d*Math.cos(E),u+d*Math.sin(E)),t.arc(l,u,d,E,F),t.arc(l,u,v,F,E,!0),t.closePath()),t.fill(),s.showLabels){const P=E+(F-E)/2,L=v+(d-v)/2,O=l+L*Math.cos(P),W=u+L*Math.sin(P),B=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=h.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${B}%`,O,W),t.restore()}S+=_}),s.chartType==="donut"&&s.showCenterText&&v>14){const M=Math.round(r),w=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${w}px Inter, sans-serif`,t.fillStyle=h.centerTextColor,t.fillText(M.toString(),l,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=h.centerLabelColor,t.fillText(s.centerLabel,l,u+w*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,C=s.legendFontSize+8,S=a/2-c+10,M=-n/2+10;s.slices.forEach((w,I)=>{const _=I%b,E=Math.floor(I/b),F=M+_*v,T=S+E*C,P=s._resolveSliceColor(w,I),L=7;t.beginPath(),t.roundRect(F,T-L/2,L,L,2),t.fillStyle=P,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=h.legendColor;const O=Math.round((w.value||0)/r*100),W=`${w.label||"Item"} ${O}%`,B=v-L-20;let A=W;for(;t.measureText(A).width>B&&A.length>4;)A=A.slice(0,-4)+"…";t.fillText(A,F+L+4,T)})}t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var 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:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((_=t.geometry)==null?void 0:_.height)||100,h=e.orientation||"vertical",f=e.itemGap!==void 0?e.itemGap:16,c=e.fontSize||14,g=this.getWorldTransform(t.id),d=i-g.x,l=o-g.y,u=-g.rotation*(Math.PI/180),y=Math.cos(u),m=Math.sin(u),b=d*y-l*m,v=d*m+l*y,S=8*2,M=-a/2,w=-r/2;if(h==="vertical"){const E=Math.max(S,c)+f;for(let F=0;F<n.length;F++){const T=w+F*E;if(b>=M&&b<=M+a&&v>=T&&v<=T+E)return F}}else{let E=M;for(let F=0;F<n.length;F++){const P=n[F].length*8,L=S+6+P+f;if(b>=E&&b<=E+L&&v>=w&&v<=w+r)return F;E+=L}}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,r=0;if(s.forEach(u=>{let y=u.data;if(u.isVarEnabled&&u.inputId){let m=this.inputs.get(u.inputId);if(m===void 0){const b=this.inputNameMap.get(u.inputId);b&&b.length>0&&(m=this.inputs.get(b[0]))}m&&Array.isArray(m)&&(y=m)}if(y&&y.length>0){const m=y.filter(b=>typeof b=="number"&&!isNaN(b));m.length>0&&(n=Math.min(n,...m),a=Math.max(a,...m),r=Math.max(r,y.length))}u._resolvedData=y}),r<2)return;const h=a-n,f=o/(r-1),c=u=>{const y=h===0?.5:(u-n)/h;return e/2-y*e},g=u=>u*f-o/2,d=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||d,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||d,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<r;u++){const y=g(u);t.fillText(`${u+1}`,y,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,y=(a+n)/2;t.fillText(a.toFixed(1),u,c(a)),t.fillText(y.toFixed(1),u,c(y)),t.fillText(n.toFixed(1),u,c(n))}const l=10;if(s.forEach(u=>{const y=u._resolvedData;if(!(!y||y.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(g(0),e/2),t.lineTo(g(0),c(y[0])),u.smoothing&&y.length>2)for(let b=0;b<y.length-1;b++){const v=y[b===0?b:b-1],C=y[b],S=y[b+1],M=y[b+1===y.length-1?b+1:b+2];for(let w=1;w<=l;w++){const I=w/l,_=this._catmullRom(v,C,S,M,I);t.lineTo(g(b+I),c(_))}}else for(let b=1;b<y.length;b++)t.lineTo(g(b),c(y[b]));t.lineTo(g(y.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(g(0),c(y[0])),u.smoothing&&y.length>2)for(let m=0;m<y.length-1;m++){const b=y[m===0?m:m-1],v=y[m],C=y[m+1],S=y[m+1===y.length-1?m+1:m+2];for(let M=1;M<=l;M++){const w=M/l,I=this._catmullRom(b,v,C,S,w);t.lineTo(g(m+w),c(I))}}else for(let m=1;m<y.length;m++)t.lineTo(g(m),c(y[m]));t.stroke(),u.showPoints&&y.forEach((m,b)=>{const v=g(b),C=c(m);t.beginPath(),t.arc(v,C,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let y=-e/2+15;const m=i.legendFontSize||10,b=m+5;t.font=`${m}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(v=>{const S=v.label||"Series",M=t.measureText(S).width;t.beginPath(),t.rect(u-M-8-5,y-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(S,u,y),y+=b})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,h=s*r;return(2*i-2*o+n+a)*h+(-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,f=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=f,f}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(h,f=100)=>{var C,S;const g=(((S=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:S.colors)||{})[h]||h,d=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(f)*d;if(u>=1&&g.startsWith("#"))return g;const y=g.startsWith("#")?g.replace("#",""):"ffffff",m=parseInt(y.substring(0,2),16),b=parseInt(y.substring(2,4),16),v=parseInt(y.substring(4,6),16);return`rgba(${m}, ${b}, ${v}, ${u})`};if(i.type==="LinearGradient"){const h=(u,y,m)=>Array.isArray(u)?u[y]??(y===0?0:1):u&&typeof u=="object"?u[m]??(y===0?0:1):y===0?0:1,f=h(i.start,0,"x")*o-o/2,c=h(i.start,1,"y")*e-e/2,g=h(i.end,0,"x")*o-o/2,d=h(i.end,1,"y")*e-e/2,l=t.createLinearGradient(f,c,g,d);if(i.stops.forEach(u=>{const y=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,m=r(u.color||"#000000",u.opacity??100);l.addColorStop(Math.max(0,Math.min(1,y)),m)}),i.gradientTransform&&l.setTransform){const[u,y,m,b,v,C]=i.gradientTransform;l.setTransform({a:u,b:y,c:m,d:b,e:v,f:C})}return l}else if(i.type==="RadialGradient"){const h=(l,u,y)=>Array.isArray(l)?l[u]??.5:l&&typeof l=="object"?l[y]??.5:.5,f=h(i.center,0,"x")*o-o/2,c=h(i.center,1,"y")*e-e/2,g=(i.radius??.5)*Math.max(o,e),d=t.createRadialGradient(f,c,0,f,c,g);if(i.stops.forEach(l=>{const u=l.offset!==void 0?l.offset:l.pos!==void 0?l.pos:l.position!==void 0?l.position:0,y=r(l.color||"#000000",l.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),y)}),i.gradientTransform&&d.setTransform){const[l,u,y,m,b,v]=i.gradientTransform;d.setTransform({a:l,b:u,c:y,d:m,e:b,f:v})}return d}else if(i.type==="AngularGradient"){const h=(l,u,y)=>Array.isArray(l)?l[u]??.5:l&&typeof l=="object"?l[y]??.5:.5,f=h(i.center||[.5,.5],0,"x")*o-o/2,c=h(i.center||[.5,.5],1,"y")*e-e/2,g=(i.degree||i.angle||0)*(Math.PI/180),d=(a=t.createConicGradient)==null?void 0:a.call(t,g,f,c);if(d){if(i.stops.forEach(l=>{const u=l.offset!==void 0?l.offset:l.pos!==void 0?l.pos:l.position!==void 0?l.position:0,y=r(l.color||"#000000",l.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),y)}),i.gradientTransform&&d.setTransform){const[l,u,y,m,b,v]=i.gradientTransform;d.setTransform({a:l,b:u,c:y,d:m,e:b,f:v})}return d}}else if(i.type==="DiamondGradient"){const h=(l,u,y)=>Array.isArray(l)?l[u]??.5:l&&typeof l=="object"?l[y]??.5:.5,f=h(i.center||[.5,.5],0,"x")*o-o/2,c=h(i.center||[.5,.5],1,"y")*e-e/2,g=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(f,c),t.rotate(Math.PI/4);const d=t.createRadialGradient(0,0,0,0,0,g);if(i.stops.forEach(l=>{const u=l.offset!==void 0?l.offset:l.pos!==void 0?l.pos:l.position!==void 0?l.position:0,y=r(l.color||"#000000",l.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),y)}),i.gradientTransform&&d.setTransform){const[l,u,y,m,b,v]=i.gradientTransform;d.setTransform({a:l,b:u,c:y,d:m,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=d,t.restore(),d}}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 h=t.createPattern(r,"repeat");if(h&&(i.scaleX!==void 0||i.offsetX!==void 0)){const f=new DOMMatrix,c=i.scaleX??1,g=i.scaleY??1,d=i.offsetX??0,l=i.offsetY??0,u=i.rotation??0;f.translateSelf(d,l),f.rotateSelf(u),f.scaleSelf(c,g),h.setTransform(f)}return h}}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,h=0,f=0,c=0;typeof a=="number"?r=h=f=c=a:Array.isArray(a)?a.length===1?r=h=f=c=a[0]:a.length===2?(r=f=a[0],h=c=a[1]):a.length===3?(r=a[0],h=c=a[1],f=a[2]):a.length>=4&&(r=a[0],h=a[1],f=a[2],c=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,h=a.tr??a.corner_radius??a.cornerRadius??0,f=a.br??a.corner_radius??a.cornerRadius??0,c=a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),g),h=Math.min(Math.max(0,h),g),f=Math.min(Math.max(0,f),g),c=Math.min(Math.max(0,c),g),t.roundRect){t.roundRect(i,o,e,s,[r,h,f,c]);return}t.moveTo(i+r,o),t.lineTo(i+e-h,o),t.arcTo(i+e,o,i+e,o+h,h),t.lineTo(i+e,o+s-f),t.arcTo(i+e,o+s,i+e-f,o+s,f),t.lineTo(i+c,o+s),t.arcTo(i,o+s,i,o+s-c,c),t.lineTo(i,o+r),t.arcTo(i,o,i+r,o,r),t.closePath()}renderListView(t,i){var O,W,B,A;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((O=i.geometry)==null?void 0:O.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,h=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,f=e.orientation||"vertical",c=e.items||[],g=e.itemGap??10,d=e.itemHeight??50,l=e.itemWidth??200,u=e.scrollOffset??0,y=e.padding??0,m=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",C=e.itemBackgroundColor||"#ffffff",S=e.hoveredIndex??null,M=e.activeItemIndex??null,w=e.glowIntensity??0,I=e.glowColor||"#3b82f6",_=typeof I=="string"?I:I.color||((A=(B=I.stops)==null?void 0:B[0])==null?void 0:A.color)||"#3b82f6",E=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=E,w>0){const $=t.getTransform(),G=Math.sqrt($.a*$.a+$.b*$.b)||1;t.shadowColor=_,t.shadowBlur=w*2*G,t.shadowOffsetX=0,t.shadowOffsetY=0}if(m){const $=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",G=this.createCanvasFill(t,$,s,n);t.fillStyle=G||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h)||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,h)||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,h)||t.stroke()}else{const $=e.backgroundColor||e.listBackgroundColor||"transparent",G=this.createCanvasFill(t,$,s,n);if(G){t.fillStyle=G,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);t.fill()}const N=e.borderWidth??0;if(N>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=N,t.beginPath();const x=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const F=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);if(e.listLayout!=="circular")if(F&&e.containerShape==="custom")try{const $=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip($),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const T=typeof y=="number"?y:f==="vertical"?y[0]:y[3];let P=(f==="vertical"?r:a)+u+T;if(t.textBaseline="middle",c.forEach(($,G)=>{const N=e.listLayout||"linear",x=N==="circular"?l:f==="vertical"?s:l,k=N==="circular"||f==="vertical"?d:n;let Y=0,X=0,J=0;if(N==="circular"){const _t=c.length||1,Nt=Math.PI*2/_t,Q=e.circularStartAngle||0,ct=e.circularRadius||100,Rt=u*.01+Q*Math.PI/180,Ct=G*Nt+Rt,St=a+s/2,Xt=r+n/2;Y=St+Math.cos(Ct)*ct-x/2,X=Xt+Math.sin(Ct)*ct-k/2,J=Ct+(e.itemRotation||0)*Math.PI/180}else Y=f==="vertical"?a:P,X=f==="vertical"?P:r,J=(e.itemRotation||0)*Math.PI/180;const tt=S===G,lt=M===G,Z=lt&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",pt=lt&&e.activeItemShape?e.activeItemPath:e.itemPath||"",at=e.itemCornerRadius||0;if(t.save(),J!==0&&(t.translate(Y+x/2,X+k/2),t.rotate(J),t.translate(-(Y+x/2),-(X+k/2))),lt){const _t=this.createCanvasFill(t,b,x,k);t.fillStyle=_t||b;const Nt=t.globalAlpha;t.globalAlpha=Nt*.8,t.beginPath(),this.drawCustomShape(t,Z,pt,Y,X,x,k,at)||(t.rect(Y,X,x,k),t.fill()),t.globalAlpha=Nt}else if(tt)t.fillStyle=m?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,Z,pt,Y,X,x,k,at)||(t.rect(Y,X,x,k),t.fill());else if(C!=="transparent"){const _t=this.createCanvasFill(t,C,x,k);t.fillStyle=_t||C,t.beginPath(),this.drawCustomShape(t,Z,pt,Y,X,x,k,at)||(t.rect(Y,X,x,k),t.fill())}if(lt||tt){const _t=this.createCanvasFill(t,b,f==="vertical"?3:x,f==="vertical"?k:3);t.fillStyle=_t||b,f==="vertical"?t.fillRect(Y,X,3,k):t.fillRect(Y,X+k-3,x,3)}const Et=lt?"#ffffff":m?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=Et,t.font=lt||tt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const xt=typeof $=="string"?$:($==null?void 0:$.label)||`Item ${G+1}`,bt=Y+(f==="vertical"?16:x/2),Yt=X+k/2;f==="horizontal"||N==="circular"?t.textAlign="center":t.textAlign="left";const Wt=N==="circular"?Y+x/2:bt;t.fillText(xt,Wt,Yt),t.restore(),P+=(f==="vertical"?d:l)+g}),t.restore(),e.showScrollbar!==!1){const $=(c.length||0)*(f==="vertical"?d:l)+((c.length||0)-1)*g,G=f==="vertical"?n:s,N=e.listLayout||"linear",x=e.containerShape==="circle"||N==="circular";if($>G||N==="circular"&&c.length>0){const k=e.scrollbarColor||"rgba(255,255,255,0.3)",Y=e.scrollbarWidth||4;if(x){const X=Math.min(s,n)/2-Y/2-2,J=a+s/2,tt=r+n/2;if(t.strokeStyle=k,t.lineWidth=Y,t.lineCap="round",t.beginPath(),N==="circular"){const lt=Math.PI/4,Z=-(u*.01)-Math.PI/2;t.arc(J,tt,X,Z,Z+lt)}else{const lt=Math.PI/2,Z=G/$,pt=lt*Z,at=-u/$*lt,xt=-Math.PI/4+at;t.arc(J,tt,X,xt,xt+pt)}t.stroke()}else{const X=G/$,J=G*X,tt=-u/$*G;t.fillStyle=k,f==="vertical"?t.fillRect(a+s-Y-2,r+tt,Y,J):t.fillRect(a+tt,r+n-Y-2,J,Y)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const h=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,h,0,Math.PI*2),!1}else if(i==="pill"){const h=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,h),!1}else if(i==="custom"&&o)try{const h=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(h),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 m,b;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||[],h=i.itemGap??10,f=i.itemHeight??50,c=i.itemWidth??200,g=a.width!==void 0?a.width:((m=t.geometry)==null?void 0:m.width)||200,d=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const l=(r.length||0)*(o==="vertical"?f:c)+((r.length||0)-1)*h,y=Math.max(0,l-(o==="vertical"?d:g)+(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 B,A;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:((B=t.geometry)==null?void 0:B.width)||200,r=s.height!==void 0?s.height:((A=t.geometry)==null?void 0:A.height)||300,h=e.orientation||"vertical",f=e.itemGap??10,c=e.itemHeight??50,g=e.itemWidth??200,d=e.scrollOffset??0,l=e.padding??0,u=this.getWorldTransform(t.id),y=i-u.x,m=o-u.y,b=-u.rotation*(Math.PI/180),v=Math.cos(b),C=Math.sin(b),S=y*v-m*C,M=y*C+m*v,w=-a/2,I=-r/2,_=typeof l=="number"?l:h==="vertical"?l[0]:l[3];let E=(h==="vertical"?I:w)+d+_;const F=e.listLayout||"linear",T=n.length||1,P=Math.PI*2/T,L=e.circularStartAngle||0,O=e.circularRadius||100,W=d*.01+L*Math.PI/180;for(let $=0;$<n.length;$++){const G=F==="circular"?g:h==="vertical"?a:g,N=F==="circular"||h==="vertical"?c:r;let x=0,k=0,Y=0;if(F==="circular"){const X=$*P+W,J=w+a/2,tt=I+r/2;x=J+Math.cos(X)*O-G/2,k=tt+Math.sin(X)*O-N/2,Y=X+(e.itemRotation||0)*Math.PI/180}else x=h==="vertical"?w:E,k=h==="vertical"?E:I,Y=(e.itemRotation||0)*Math.PI/180;if(Y!==0){const X=x+G/2,J=k+N/2,tt=S-X,lt=M-J,Z=-Y,pt=tt*Math.cos(Z)-lt*Math.sin(Z)+X,at=tt*Math.sin(Z)+lt*Math.cos(Z)+J;if(pt>=x&&pt<=x+G&&at>=k&&at<=k+N)return $}else if(S>=x&&S<=x+G&&M>=k&&M<=k+N)return $;E+=(h==="vertical"?c:g)+f}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 g,d,l,u,y,m,b,v,C,S,M,w,I,_,E,F,T,P,L,O,W,B,A,$,G,N,x,k,Y,X,J,tt,lt,Z,pt,at,Et,xt,bt,Yt,Wt,_t,Nt,Q,ct,Rt,Ct,St,Xt,te,ee,Zt,Ut,ae,it,dt,U,D,nt,et,Ot,Gt,At,qt,Tt,R,Ft,le,Mt,Jt,It,Dt,Qt,ft,ht,mt,kt,gt,zt,ie,jt,rt,st,ut,Bt,K,vt,yt,pe,Ce,_e,Kt,ce,ve,Me,Ie,ge,de,ue,Se,Pe,Fe,$e,Ee,We,Be,os,as,rs,ls,cs,fs,hs,ds,us,ps,gs,ms;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const h=s.x-i,f=s.y-o,c=Math.sqrt(h*h+f*f);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===z.Proximity){const V=((g=n.settings)==null?void 0:g.radius)||300,q=((d=n.settings)==null?void 0:d.falloff)||"smooth";let H=0;c<V&&(q==="linear"?H=1-c/V:H=Math.pow(1-c/V,2)),n.sensors.forEach(ot=>{this.applyBehaviorSensor(s,ot,H,t,n.settings,e,h,f,c)})}else if(n.type===z.Magnetic){const V=((l=n.settings)==null?void 0:l.radius)||400,q=((u=n.settings)==null?void 0:u.strength)||.5;if(c<V&&c>5){const H=1-c/V,ot=h*H*q,Pt=f*H*q;s.x-=ot*t*10,s.y-=Pt*t*10}}else if(n.type===z.Repel){const V=((y=n.settings)==null?void 0:y.radius)||300,q=((m=n.settings)==null?void 0:m.strength)||1;if(c<V){const H=Math.pow(1-c/V,2);s.x+=h/(c||1)*H*60*q*t*5,s.y+=f/(c||1)*H*60*q*t*5}}else if(n.type===z.Orbit){const V=((b=n.settings)==null?void 0:b.speed)||1,q=((v=n.settings)==null?void 0:v.radius)||30,H=this.currentTime*V*Math.PI*2;s.x+=Math.cos(H)*q*t*5,s.y+=Math.sin(H)*q*t*5,s.rotation+=2*t*5}else if(n.type===z.Vortex){const V=((C=n.settings)==null?void 0:C.radius)||400,q=((S=n.settings)==null?void 0:S.speed)||2,H=((M=n.settings)==null?void 0:M.strength)||1;if(c<V){const ot=Math.pow(1-c/V,1.5),Pt=this.currentTime*q*Math.PI*2,Lt=Math.cos(Pt)*30-h*.4,Vt=Math.sin(Pt)*30-f*.4;s.x+=Lt*ot*H*t*5,s.y+=Vt*ot*H*t*5,s.rotation+=5*ot*H*t*5,s.scale_x*=1-ot*.1*H*t,s.scale_y*=1-ot*.1*H*t}}else if(n.type===z.Fluid){const V=((w=n.settings)==null?void 0:w.radius)||300,q=((I=n.settings)==null?void 0:I.strength)||1;if(c<V){const H=Math.pow(1-c/V,1.2),ot=h/(c||1)*H*1.2*q,Pt=f/(c||1)*H*1.2*q;s.x+=ot*10*t*5,s.y+=Pt*10*t*5,s.scale_x*=1+H*.3*q*t,s.scale_y*=1+H*.3*q*t}}else if(n.type===z.Elastic){const V=((_=n.settings)==null?void 0:_.radius)||300,q=((E=n.settings)==null?void 0:E.strength)||1;if(c<V){const H=1-c/V;s.scale_x*=1+H*.4*q*t,s.scale_y*=1+H*.4*q*t}}else if(n.type===z.Holographic){const V=s.x-this.canvasWidth/2,q=s.y-this.canvasHeight/2,H=((F=n.settings)==null?void 0:F.factor)||25;if(s.x-=V/1e3*H*t*5,s.y-=q/1e3*H*t*5,s.style){const ot=1-Math.min(1,c/400);s.style.exposure=(s.style.exposure||1)+ot*.5*t}}else if(n.type===z.Sticky){const V=((T=n.settings)==null?void 0:T.radius)||80,q=((P=n.settings)==null?void 0:P.strength)||1;if(c<V){const H=Math.pow(1-c/V,2);s.x-=h*H*q*t*10,s.y-=f*H*q*t*10,s.scale_x*=1-H*.1*q*t,s.scale_y*=1-H*.1*q*t}}else if(n.type===z.Dilation){const V=((L=n.settings)==null?void 0:L.size)||120,q=((O=n.settings)==null?void 0:O.strength)||1;if(c<V){const H=1-c/V;s.scale_x*=1+H*.5*q*t,s.scale_y*=1+H*.5*q*t}}else if(n.type===z.Parallax){const V=((W=n.settings)==null?void 0:W.factor)||15,q=((B=n.settings)==null?void 0:B.strength)||1,H=this.canvasWidth/2,ot=this.canvasHeight/2,Pt=this._lastPointerPos||{x:H,y:ot},Lt=(Pt.x-H)/H,Vt=(Pt.y-ot)/ot,re=(((A=e.transform)==null?void 0:A.x)??0)+Lt*V*q,me=((($=e.transform)==null?void 0:$.y)??0)+Vt*V*q,we=(((G=e.transform)==null?void 0:G.rotate_x)??0)-Vt*V*1.5*q,fe=(((N=e.transform)==null?void 0:N.rotate_y)??0)+Lt*V*1.5*q,be=Math.min(1,10*t);s.x=this.lerp(s.x??((x=e.transform)==null?void 0:x.x)??0,re,be),s.y=this.lerp(s.y??((k=e.transform)==null?void 0:k.y)??0,me,be),s.rotate_x=this.lerp(s.rotate_x??((Y=e.transform)==null?void 0:Y.rotate_x)??0,we,be),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,be)}else if(n.type===z.Fold){if(c<300){const V=1-c/300,q=(h>0?-1:1)*V*10,H=1-V*.1,ot=f/300*V*20,Pt=-(h/300)*V*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((J=e.transform)==null?void 0:J.skew_x)??0,q,Lt),s.scale_y=this.lerp(s.scale_y??((tt=e.transform)==null?void 0:tt.scale_y)??1,(((lt=e.transform)==null?void 0:lt.scale_y)??1)*H,Lt),s.rotate_x=this.lerp(s.rotate_x??((Z=e.transform)==null?void 0:Z.rotate_x)??0,ot,Lt),s.rotate_y=this.lerp(s.rotate_y??((pt=e.transform)==null?void 0:pt.rotate_y)??0,Pt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((at=n.settings)==null?void 0:at.opacity)??.5}}}else if(n.type===z.Crumple){if(c<300){const V=1-c/300,q=V*(Math.random()-.5)*5,H=V*(Math.random()-.5)*.05,ot=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((Et=e.transform)==null?void 0:Et.skew_x)??0,q,ot),s.scale_x=this.lerp(s.scale_x??((xt=e.transform)==null?void 0:xt.scale_x)??1,(((bt=e.transform)==null?void 0:bt.scale_x)??1)*(1+H),ot),s.scale_y=this.lerp(s.scale_y??((Yt=e.transform)==null?void 0:Yt.scale_y)??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*(1+H),ot),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((_t=n.settings)==null?void 0:_t.intensity)??1,scale:((Nt=n.settings)==null?void 0:Nt.scale)??2}}}else if(n.type===z.Squash){const V=((Q=n.settings)==null?void 0:Q.strength)||.8;c<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((ct=e.transform)==null?void 0:ct.scale_y)??1)*V,.3),s.scale_x=this.lerp(s.scale_x??1,(((Rt=e.transform)==null?void 0:Rt.scale_x)??1)*(1+(1-V)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((Ct=e.transform)==null?void 0:Ct.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((St=e.transform)==null?void 0:St.scale_x)??1,.2))}else if(n.type===z.TextCounter){const V=((Xt=n.settings)==null?void 0:Xt.duration)||2,q=((te=n.settings)==null?void 0:te.from)||0,H=((ee=n.settings)==null?void 0:ee.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ot=this.currentTime-n._runtimeStart,Pt=Math.min(1,ot/V),Lt=Math.floor(q+(H-q)*Pt);if(((Zt=e.geometry)==null?void 0:Zt.type)==="Text"){const Vt=((Ut=n.settings)==null?void 0:Ut.prefix)||"",re=((ae=n.settings)==null?void 0:ae.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Vt}${Lt}${re}`}}else if(n.type===z.Spotlight){const V=((it=n.settings)==null?void 0:it.radius)||250,q=((dt=n.settings)==null?void 0:dt.strength)||1.5;if(c<V){const H=Math.pow(1-c/V,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(U=e.style)==null?void 0:U.adjustments}),s.style.adjustments.exposure=(((nt=(D=e.style)==null?void 0:D.adjustments)==null?void 0:nt.exposure)||0)+H*q*50}else(et=s.style)!=null&&et.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Gt=(Ot=e.style)==null?void 0:Ot.adjustments)==null?void 0:Gt.exposure)||0,.1))}else if(n.type===z.Noise||n.type===z.Float){const V=(((At=n.settings)==null?void 0:At.frequency)||((qt=n.settings)==null?void 0:qt.speed)||1)*.002,q=(((Tt=n.settings)==null?void 0:Tt.amplitude)||((R=n.settings)==null?void 0:R.range)||50)*(((Ft=n.settings)==null?void 0:Ft.strength)||1),H=Date.now();s.x+=Math.sin(H*V)*q*t,s.y+=Math.cos(H*V*.8)*q*t,s.rotation+=Math.sin(H*V*.5)*5*t}else if(n.type===z.Pulse){const V=(((le=n.settings)==null?void 0:le.speed)||1)*.005,q=(((Mt=n.settings)==null?void 0:Mt.scale)||1.2)-1,H=Math.sin(Date.now()*V),ot=((Jt=n.settings)==null?void 0:Jt.strength)||1;s.scale_x*=1+H*q*ot*t,s.scale_y*=1+H*q*ot*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,H)*.1*ot*t)}else if(n.type===z.Draggable){const V=((It=n.settings)==null?void 0:It.radius)||150,q=this.draggingBehaviors.has(e.id);if(c<V||q){const H=((Dt=n.settings)==null?void 0:Dt.strength)||1,ot=q?1:Math.max(0,1-c/V);this.applyBehaviorSensor(s,oe.PositionX,ot*H,t,n.settings),this.applyBehaviorSensor(s,oe.PositionY,ot*H,t,n.settings)}}else if(n.type===z.Scroll){const V=((Qt=n.settings)==null?void 0:Qt.axis)||"vertical",q=((ft=n.settings)==null?void 0:ft.factor)||.5,H=((ht=n.settings)==null?void 0:ht.strength)||1,ot=((mt=n.settings)==null?void 0:mt.scaleFactor)||0;(V==="vertical"||V==="both")&&(s.y+=this.scrollOffset.y*q*H*t),(V==="horizontal"||V==="both")&&(s.x+=this.scrollOffset.x*q*H*t),ot!==0&&(s.scale_x*=1+this.scrollOffset.y*ot*t,s.scale_y*=1+this.scrollOffset.y*ot*t)}else if(n.type===z.LookAt){const V=((kt=n.settings)==null?void 0:kt.factor)||1,q=((gt=n.settings)==null?void 0:gt.strength)||1,H=Math.atan2(-f,-h)*(180/Math.PI),ot=s.rotation,Pt=(H-ot+180)%360-180;s.rotation+=Pt*V*q*t*10}else if(n.type===z.Scan){const V=(((zt=n.settings)==null?void 0:zt.speed)||1)*.004,q=((ie=n.settings)==null?void 0:ie.strength)||1,H=(Math.sin(Date.now()*V)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+H*q*t*5),s.x+=(H-.5)*20*q*t}else if(n.type===z.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===z.Ratchet){const V=((rt=n.settings)==null?void 0:rt.steps)||12,q=(((st=n.settings)==null?void 0:st.speed)||1)*30,H=Math.floor(s.rotation/(360/V))*(360/V);s.rotation=this.lerp(s.rotation,H+q*t,.1)}else if(n.type===z.Jitter&&c<300){const V=((ut=n.settings)==null?void 0:ut.strength)||1,q=(((Bt=n.settings)==null?void 0:Bt.intensity)||5)*V;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===z.Follower){const V=(K=n.settings)==null?void 0:K.targetId;if(V){const q=this.objectStates.get(V);if(q){const H=((vt=n.settings)==null?void 0:vt.stiffness)||.1,ot=q.x-s.x,Pt=q.y-s.y;s.x+=ot*H*t*60,s.y+=Pt*H*t*60}}}else if(n.type===z.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===z.Gravity){const V=((yt=n.settings)==null?void 0:yt.strength)||9.8;s.y+=V*t*10}else if(n.type===z.Velocity){const V=((pe=n.settings)==null?void 0:pe.vx)||0,q=((Ce=n.settings)==null?void 0:Ce.vy)||0;s.x+=V*t*10,s.y+=q*t*10}else if(n.type===z.Shear){const V=((_e=n.settings)==null?void 0:_e.strength)||1,q=((Kt=n.settings)==null?void 0:Kt.radius)||300;if(c<q){const H=1-c/q;s.skew_x=this.lerp(s.skew_x||0,(((ce=e.transform)==null?void 0:ce.skew_x)||0)+H*V*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((ve=e.transform)==null?void 0:ve.skew_x)||0,.05)}else if(n.type===z.Lens){const V=((Me=n.settings)==null?void 0:Me.radius)||200,q=((Ie=n.settings)==null?void 0:Ie.strength)||.5;if(c<V){const H=Math.pow(1-c/V,2);s.scale_x=this.lerp(s.scale_x??1,(((ge=e.transform)==null?void 0:ge.scale_x)??1)*(1+H*q),.2),s.scale_y=this.lerp(s.scale_y??1,(((de=e.transform)==null?void 0:de.scale_y)??1)*(1+H*q),.2)}else s.scale_x=this.lerp(s.scale_x??1,((ue=e.transform)==null?void 0:ue.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Se=e.transform)==null?void 0:Se.scale_y)??1,.1)}else if(n.type===z.LayoutAnimation){const V=((Pe=n.settings)==null?void 0:Pe.watchProperties)||["x","y","scale_x","scale_y","skew_x","skew_y","opacity","rotation"],q=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const H=this._layoutAnimCache.get(e.id);for(const ot of V){const Pt=this.getObjectProperty(s,e,ot);if(Pt===void 0)continue;const Lt=H.get(ot);if(!Lt)H.set(ot,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Lt.to!==Pt){const re=this.getObjectProperty(s,e,ot);H.set(ot,{from:re??Lt.from,to:Pt,startTime:this.currentTime,duration:(($e=n.settings)==null?void 0:$e.duration)??q})}const Vt=H.get(ot);if(Vt.duration>0&&Vt.from!==Vt.to){const re=this.currentTime-Vt.startTime,me=Math.min(1,re/Vt.duration),we=this.applyEasing(me,((Ee=n.settings)==null?void 0:Ee.easing)||"easeOutCubic"),fe=Vt.from+(Vt.to-Vt.from)*we;this.setObjectProperty(s,e,ot,fe)}}}else if(n.type===z.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const V=this._layoutAnimCache.get(e.id),q=((We=n.settings)==null?void 0:We.defaultDuration)||.3,H=["x","y","scale_x","scale_y","skew_x","skew_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 ot of H){const Pt=this.getObjectProperty(s,e,ot);if(Pt===void 0||typeof Pt!="number")continue;const Lt=V.get(ot);if(!Lt)V.set(ot,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Lt.to!==Pt){const re=this.getObjectProperty(s,e,ot);V.set(ot,{from:re??Lt.from,to:Pt,startTime:this.currentTime,duration:q})}const Vt=V.get(ot);if(Vt.duration>0&&Vt.from!==Vt.to){const re=this.currentTime-Vt.startTime,me=Math.min(1,re/Vt.duration),we=this.applyEasing(me,((Be=n.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),fe=Vt.from+(Vt.to-Vt.from)*we;this.setObjectProperty(s,e,ot,fe)}}}else if(n.type===z.SpringChain){const V=((os=n.settings)==null?void 0:os.connections)||[],q=((as=n.settings)==null?void 0:as.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const H=this._springChainState.get(e.id);for(const Pt of V){if(!H.has(Pt.targetId)){const Lt=this.objectStates.get(Pt.targetId);H.set(Pt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}H.has(e.id)||H.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ot=H.get(e.id);if(ot){ot.x=s.x,ot.y=s.y;for(const Pt of V){const Lt=H.get(Pt.targetId);if(!Lt)continue;const Vt=Lt.x-ot.x,re=Lt.y-ot.y,me=Math.sqrt(Vt*Vt+re*re)||.001,fe=(me-(Pt.restLength||50))*(Pt.stiffness||.8),be=Vt/me*fe,Ye=re/me*fe;ot.vx+=be*t*10,ot.vy+=Ye*t*10,Lt.vx-=be*t*10,Lt.vy-=Ye*t*10,ot.vx*=1-q*t*10,ot.vy*=1-q*t*10,Lt.vx*=1-q*t*10,Lt.vy*=1-q*t*10;const ye=this.objectStates.get(Pt.targetId);ye&&(ye.x+=Lt.vx*t,ye.y+=Lt.vy*t)}s.x+=ot.vx*t,s.y+=ot.vy*t}}else if(n.type===z.ParticleEmitter){const V=((rs=n.settings)==null?void 0:rs.rate)||10,q=((ls=n.settings)==null?void 0:ls.speed)||100,H=((cs=n.settings)==null?void 0:cs.size)||5,ot=((fs=n.settings)==null?void 0:fs.lifetime)||2,Pt=((hs=n.settings)==null?void 0:hs.gravity)||0,Lt=((ds=n.settings)==null?void 0:ds.color)||"#ffffff",Vt=((us=n.settings)==null?void 0:us.maxParticles)||200,re=(ps=n.settings)!=null&&ps.rateInputId?this.inputs.get(n.settings.rateInputId)??V:V,me=(gs=n.settings)!=null&&gs.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Pt:Pt,we=(ms=n.settings)!=null&&ms.speedInputId?this.inputs.get(n.settings.speedInputId)??q:q;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let be=0;n._pendingBurst&&n._pendingBurst>0&&(be=n._pendingBurst,n._pendingBurst=0);const Ye=Math.floor(re*t)+(be||0);for(let ye=0;ye<Math.min(Ye,Vt-fe.length);ye++){const he=Math.random()*Math.PI*2,ys=we*(.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:ot*(.5+Math.random()*.5),size:H*(.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,h=1){var l,u,y,m,b,v,C,S,M,w,I,_,E,F,T,P,L,O,W,B,A,$,G,N;const f=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,c=Math.min(1,15*e),g=h>0?a/h:0,d=h>0?r/h:0;switch(i){case oe.Scale:{const x=((l=n==null?void 0:n.transform)==null?void 0:l.scale_x)??1,k=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,Y=x*(1+o*f*.4),X=k*(1+o*f*.4);t.scale_x=(t.scale_x??x)*(1-c)+Y*c,t.scale_y=(t.scale_y??k)*(1-c)+X*c;break}case oe.Opacity:{const x=((y=n==null?void 0:n.transform)==null?void 0:y.opacity)??100,k=Math.max(0,Math.min(100,x-o*f*100));t.opacity=(t.opacity??x)*(1-c)+k*c;break}case oe.RotateZ:{const x=((m=n==null?void 0:n.transform)==null?void 0:m.rotation)??0,k=x+o*f*45;t.rotation=(t.rotation??x)*(1-c)+k*c;break}case oe.RotateX:{const x=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,k=x-d*o*f*60;t.rotate_x=(t.rotate_x??x)*(1-c)+k*c;break}case oe.RotateY:{const x=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,k=x+g*o*f*60;t.rotate_y=(t.rotate_y??x)*(1-c)+k*c;break}case oe.PositionX:{const x=((C=n==null?void 0:n.transform)==null?void 0:C.x)??0,k=x-g*o*f*40;t.x=(t.x??x)*(1-c)+k*c;break}case oe.PositionY:{const x=((S=n==null?void 0:n.transform)==null?void 0:S.y)??0,k=x-d*o*f*40;t.y=(t.y??x)*(1-c)+k*c;break}case oe.SkewX:{const x=((M=n==null?void 0:n.transform)==null?void 0:M.skew_x)??0,k=x+g*o*f*45;t.skew_x=(t.skew_x??x)*(1-c)+k*c,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case oe.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(w=n==null?void 0:n.style)==null?void 0:w.blur});const x=((_=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:_.amount)||0,k=x+o*((s==null?void 0:s.blur)||20)*f;t.style.blur.amount=(t.style.blur.amount??x)*(1-c)+k*c;break}case oe.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(E=n==null?void 0:n.style)==null?void 0:E.adjustments});const x=((T=(F=n==null?void 0:n.style)==null?void 0:F.adjustments)==null?void 0:T.exposure)||0,k=x+o*((s==null?void 0:s.exposure)||50)*f;t.style.adjustments.exposure=(t.style.adjustments.exposure??x)*(1-c)+k*c;break}case oe.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(P=n==null?void 0:n.style)==null?void 0:P.adjustments});const x=((O=(L=n==null?void 0:n.style)==null?void 0:L.adjustments)==null?void 0:O.hue)||0,k=x+o*((s==null?void 0:s.hue)||180)*f;t.style.adjustments.hue=(t.style.adjustments.hue??x)*(1-c)+k*c;break}case oe.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=((A=(B=n==null?void 0:n.style)==null?void 0:B.adjustments)==null?void 0:A.negative)||0,k=x+o*((s==null?void 0:s.negative)||100)*f;t.style.adjustments.negative=(t.style.adjustments.negative??x)*(1-c)+k*c;break}case oe.CornerRadius:{const x=(($=n==null?void 0:n.transform)==null?void 0:$.corner_radius)||0,k=x+o*f*50;t.corner_radius=(t.corner_radius??x)*(1-c)+k*c;break}case oe.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const x=((G=n==null?void 0:n.style)==null?void 0:G.borderWidth)||0,k=x+o*f*10;t.style.borderWidth=(t.style.borderWidth??x)*(1-c)+k*c;break}case oe.LetterSpacing:{t.geometry||(t.geometry={});const x=((N=n==null?void 0:n.geometry)==null?void 0:N.letterSpacing)||0,k=x+o*f*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??x)*(1-c)+k*c;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 h=s[r];if(n[h]===void 0||n[h]===null){const f=i,c=s.slice(0,r+1).reduce((g,d)=>g==null?void 0:g[d],f);n[h]=c!==void 0?{...c}:{}}n=n[h]}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,h=i.naturalHeight,f=r/h,c=s/n;let g=s,d=n,l=o,u=e;a==="cover"?f>c?(g=n*f,l=o-(g-s)/2):(d=s/f,u=e-(d-n)/2):a==="contain"&&(f>c?(d=s/f,u=e+(n-d)/2):(g=n*f,l=o+(s-g)/2)),t.drawImage(i,l,u,g,d)}}const ai=$t.forwardRef(({artboard:p,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:h,onToggle:f,onInputChange:c,onInputFocus:g,onInputBlur:d,onLog:l,onLogicUpdate:u,onButtonClick:y,onGraphPointClick:m,currentTime:b,revision:v=0,scrollY:C,scrollX:S,mouseX:M,mouseY:w,isMouseDown:I,inputs:_,interactive:E=!0,onNavigation:F},T)=>{const P=$t.useRef(null),L=$t.useRef(null);L.current||(L.current=new ns);const O=$t.useRef(void 0),W=$t.useRef(0),B=$t.useRef(null),A=$t.useRef(v),$=$t.useRef(null),[,G]=$t.useState(p||null),N=$t.useRef(!0);$t.useImperativeHandle(T,()=>P.current),$t.useEffect(()=>(N.current=!0,()=>{N.current=!1,O.current&&cancelAnimationFrame(O.current)}),[]),$t.useEffect(()=>{L.current.setLayout(e,s)},[e,s]),$t.useEffect(()=>{const k=L.current;a&&k.setTriggerCallback(a),r&&k.setInputUpdateCallback((Y,X)=>r({[Y]:X})),h&&k.setComponentChangeCallback(Y=>h(Y)),f&&k.setToggleCallback(f),c&&k.setInputChangeCallback(c),g&&k.setInputFocusCallback(g),d&&k.setInputBlurCallback(d),l&&k.setOnLogCallback(Y=>l(Y,"info")),u&&k.setLogicUpdateCallback(u),y&&k.setButtonClickCallback(y),m&&k.setGraphPointClickCallback(Y=>m(Y.objectId,Y)),F&&k.setNavigationCallback(F)},[a,r,h,f,c,g,d,l,u,y,m,F]),$t.useEffect(()=>{(async()=>{let Y=p;if(t&&!p)try{t.startsWith("{")?Y=JSON.parse(t):Y=await(await fetch(t)).json()}catch(X){console.error("[ExodeUI] Failed to load src:",X)}if(Y){const X=L.current,J=Y.id||Y.name||"default";(B.current!==J||A.current!==v||$.current!==Y)&&(X.load(Y),B.current=J,A.current=v,$.current=Y,G(Y),W.current=0,X.advance(0)),n&&n(X)}})()},[p,t,v]),$t.useEffect(()=>{const k=Y=>{if(!L.current||!N.current)return;const X=L.current,J=P.current;if(!J)return;const tt=J.getContext("2d");if(!tt)return;const lt=Y/1e3;W.current===0&&(W.current=lt);let Z=lt-W.current;Z>.1&&(Z=.1),W.current=lt;const pt=J.getBoundingClientRect(),at=window.devicePixelRatio||1,Et=Math.round(pt.width*at),xt=Math.round(pt.height*at);(J.width!==Et||J.height!==xt)&&(J.width=Et,J.height=xt);try{o?X.advance(Z):b!==void 0&&X.seek(b),X.render(tt,J.width,J.height)}catch(bt){console.error("[ExodeUICanvas] Error in animation loop:",bt),l&&l(`[Error] Animation loop crashed: ${bt}`,"error")}O.current=requestAnimationFrame(k)};return O.current=requestAnimationFrame(k),()=>{O.current&&cancelAnimationFrame(O.current)}},[o,b]),$t.useEffect(()=>{const k=L.current;C!==void 0&&k.updateInput("scrollY",C),S!==void 0&&k.updateInput("scrollX",S),M!==void 0&&k.updateInput("mouseX",M),w!==void 0&&k.updateInput("mouseY",w),I!==void 0&&k.updateInput("isMouseDown",I),_&&Object.entries(_).forEach(([Y,X])=>k.updateInput(Y,X))},[C,S,M,w,I,_]);const x=(k,Y)=>{if(!E||!P.current)return;k.stopPropagation(),"nativeEvent"in k&&k.nativeEvent&&typeof k.nativeEvent.stopImmediatePropagation=="function"?k.nativeEvent.stopImmediatePropagation():typeof k.stopImmediatePropagation=="function"&&k.stopImmediatePropagation();const X=P.current,J=X.getBoundingClientRect(),tt=k.clientX-J.left,lt=k.clientY-J.top,Z=window.devicePixelRatio||1;(Y==="click"||Y==="down"||Y==="up")&&l&&l(`[Canvas] Pointer ${Y} at rect(${Math.round(tt)},${Math.round(lt)}) mapped to buffer(${Math.round(tt*Z)},${Math.round(lt*Z)})`,"info"),L.current.handlePointerInput(Y,tt*Z,lt*Z,X.width,X.height)};return se.jsx("canvas",{ref:P,onPointerDown:k=>{var Y;x(k,"down"),(Y=P.current)==null||Y.focus()},onPointerMove:k=>x(k,"move"),onPointerUp:k=>x(k,"up"),onPointerCancel:k=>x(k,"up"),onClick:k=>x(k,"click"),onWheel:k=>{L.current.handleWheel(k.deltaX,k.deltaY)},onKeyDown:k=>L.current.handleKeyDown(k.nativeEvent),onContextMenu:k=>k.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:E?"auto":"none"}})});function ri(){const[p,t]=$t.useState(null),i=$t.useCallback((c,g)=>{p==null||p.setInputBool(c,g)},[p]),o=$t.useCallback((c,g)=>{p==null||p.setInputNumber(c,g)},[p]),e=$t.useCallback(c=>{p==null||p.fireTrigger(c)},[p]),s=$t.useCallback((c,g)=>{p==null||p.setInputText(c,g)},[p]),n=$t.useCallback((c,g)=>{p==null||p.setInputNumberArray(c,g)},[p]),a=$t.useCallback((c,g)=>{p==null||p.setInputStringArray(c,g)},[p]),r=$t.useCallback((c,g)=>{p==null||p.updateObjectOptions(c,g)},[p]),h=$t.useCallback((c,g,d)=>{p==null||p.updateConstraint(c,g,d)},[p]),f=$t.useCallback((c,g)=>{p==null||p.updateGraphData(c,g)},[p]);return{setEngine:t,engine:p,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:h,updateGraphData:f,updateObjectOptions:r}}const li=({artboard:p,config:t})=>{const i={...p.seo,...t},o=i.enableSmartExtraction!==!1;$t.useEffect(()=>{const a=i.title||p.name;a&&(document.title=a);let r=i.description;if(!r&&o){const c=p.objects.filter(g=>{var d;return((d=g.geometry)==null?void 0:d.type)==="Text"}).sort((g,d)=>{var l,u;return(((l=d.geometry.text)==null?void 0:l.length)||0)-(((u=g.geometry.text)==null?void 0:u.length)||0)});c.length>0&&(r=c[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const h=i.ogImage||p.backgroundImage;h&&e("property","og:image",h),a&&e("property","og:title",a),e("property","og:type","website")},[i,p,o]);const e=(a,r,h)=>{let f=document.querySelector(`meta[${a}="${r}"]`);f||(f=document.createElement("meta"),f.setAttribute(a,r),document.head.appendChild(f)),f.setAttribute("content",h)},s=()=>{const a=[];return a.push(se.jsx("h1",{children:i.title||p.name},"artboard-title")),p.objects.forEach((h,f)=>{var c,g;if(!(h.visible===!1||h.isVisible===!1))if(((c=h.geometry)==null?void 0:c.type)==="Text"){const d=h.geometry.text;d&&(h.geometry.fontSize>24?a.push(se.jsx("h2",{children:d},h.id||f)):a.push(se.jsx("p",{children:d},h.id||f)))}else if(((g=h.geometry)==null?void 0:g.type)==="Image"){const d=h.geometry.src,l=h.altText||h.name||"Illustration";a.push(se.jsx("img",{src:d,alt:l},h.id||f))}else h.type==="Button"&&a.push(se.jsx("button",{children:h.name||"Button"},h.id||f))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||p.name,description:i.description,image:i.ogImage||p.backgroundImage,abstract:"Animated interface created with ExodeUI"};return se.jsxs("div",{id:`exode-seo-${p.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),se.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ci={version:"6.3.25"}.version;Ht.BehaviorSensor=oe,Ht.BehaviorType=z,Ht.ConditionOp=Xe,Ht.ExodeSEO=li,Ht.ExodeUICanvas=ai,Ht.ExodeUIEngine=ns,Ht.LogicOp=wt,Ht.RapierPhysics=Ne,Ht.VERSION=ci,Ht.useExodeUI=ri,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})}));
30
+ `&&St++)}),t.globalAlpha=ct}const Q=o.paragraphRule;if(Q&&(((_t=Q.top)==null?void 0:_t.width)>0||((Nt=Q.bottom)==null?void 0:Nt.width)>0)){let ct=0;(A||[]).forEach((Rt,Ct)=>{var te,ee;const Xt=ct===0||ct<f.length&&(f[ct]===`
31
+ `||f[ct]==="\r");if(Xt&&Ct>0&&ct++,Xt){if(((te=Q.top)==null?void 0:te.width)>0){const Zt=X+Ct*P-Q.top.offset;t.strokeStyle=Q.top.color||"#000000",t.lineWidth=Q.top.width,t.beginPath();const Ut=-n/2+P*.2;t.moveTo(Ut,Zt),t.lineTo(n/2-P*.2,Zt),t.stroke()}if(((ee=Q.bottom)==null?void 0:ee.width)>0){const Zt=X+(Ct+1)*P-Q.bottom.offset;t.strokeStyle=Q.bottom.color||"#000000",t.lineWidth=Q.bottom.width,t.beginPath();const Ut=-n/2+P*.2;t.moveTo(Ut,Zt),t.lineTo(n/2-P*.2,Zt),t.stroke()}}ct+=(Rt.text||"").length})}if(e.stroke&&e.stroke.width>0){const ct=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color,t.lineWidth=e.stroke.width,t.globalAlpha=ct*this.normalizeOpacity(e.stroke.opacity??100);let Ct=0,St=X;(A||[]).forEach(Xt=>{let te=-k/2;w==="center"?te=0:w==="right"&&(te=k/2),Z(Xt.text,te,St,!0,Ct),Ct+=(Xt.text||"").length,St+=P,Ct<f.length&&(f[Ct]===`
32
+ `||f[Ct]==="\r")&&(F>0&&(St+=F),Ct++,f[Ct-1]==="\r"&&f[Ct]===`
33
+ `&&Ct++)}),t.globalAlpha=ct}}}applyStrokeAlignment(t,i,o,e,s,n){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const a=i.stroke,r=a.width,h=(a.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),a.fill){const g=this.createCanvasFill(t,a.fill,e,s);g?t.strokeStyle=g:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const f=t.globalAlpha;t.globalAlpha=f*this.normalizeOpacity(a.opacity??100),t.lineWidth=r,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const y=a.trimStart??0,d=a.trimEnd??1,c=a.trimOffset??0,u=a.dashOffset??0,m=a.dashArray||[];if(y!==0||d!==1||c!==0){const g=this.getPerimeter(o,e,s);if(g>0){const b=Math.max(0,Math.min(1,y)),v=Math.max(0,Math.min(1,d));if(b<v){const C=g*(v-b),S=g-C,M=-(g*(b+c%1));t.setLineDash([C,S]),t.lineDashOffset=M+u*g}else if(b===v)t.setLineDash([0,g]);else{const C=g*(1-b+v),S=g-C,M=-(g*b);t.setLineDash([C,S]),t.lineDashOffset=M+u*g}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=u);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):h==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):h==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=r,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 h=n/360*r;if(a>0){const l=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));h+=n/360*l,n<360&&(h+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(h+=2*Math.max(e,s));return isNaN(h)?0:h}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 h=e[r];if(h.moveTo){n=h.x,a=h.y;continue}const l=n,f=a,y=e[r-1].out_x,d=e[r-1].out_y;if(y!==void 0||h.in_x!==void 0?s+=this.getBezierLength(l,f,y??l,d??f,h.in_x??h.x,h.in_y??h.y,h.x,h.y):s+=Math.sqrt((h.x-l)**2+(h.y-f)**2),n=h.x,a=h.y,h.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const c=n,u=a,m=[...e.slice(0,r+1)].reverse().find(w=>w.moveTo)||e[0],g=m.x,b=m.y,v=e[r].out_x,C=e[r].out_y,S=m.in_x,M=m.in_y;v!==void 0||S!==void 0?s+=this.getBezierLength(c,u,v??c,C??u,S??g,M??b,g,b):s+=Math.sqrt((g-c)**2+(b-u)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,r,h=10){let l=0,f=t,y=i;for(let d=1;d<=h;d++){const c=d/h,u=1-c,m=c*c,g=u*u,b=g*u,v=m*c,C=b*t+3*g*c*o+3*u*m*s+v*a,S=b*i+3*g*c*e+3*u*m*n+v*r,M=C-f,w=S-y;l+=Math.sqrt(M*M+w*w),f=C,y=S}return l}getBezierTAtLength(t,i,o,e,s,n,a,r,h,l=20){if(t<=0)return 0;let f=0,y=i,d=o;for(let c=1;c<=l;c++){const u=c/l,m=1-u,g=u*u,b=m*m,v=b*m,C=g*u,S=v*i+3*b*u*e+3*m*g*n+C*r,M=v*o+3*b*u*s+3*m*g*a+C*h,w=S-y,I=M-d,_=Math.sqrt(w*w+I*I);if(f+_>=t){const x=t-f,F=_===0?0:x/_;return(c-1+F)/l}f+=_,y=S,d=M}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,h=-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),h=Math.max(h,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),h=Math.max(h,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),h=Math.max(h,m.in_y)))});const f=this.getPerimeter(t,i,o)*e;let y=0;const d=[];let c=s[0],u=s[0];for(let m=1;m<s.length;m++){const g=s[m];if(g.moveTo){c=g,u=g;continue}d.push({p0:c,p1:g}),(g.closePath||m===s.length-1&&(t.is_closed||t.isClosed))&&d.push({p0:g,p1:u}),c=g}for(const m of d){const g=m.p0,b=m.p1;let v=0;const C=g.out_x!==void 0||b.in_x!==void 0;if(C?v=this.getBezierLength(g.x,g.y,g.out_x??g.x,g.out_y??g.y,b.in_x??b.x,b.in_y??b.y,b.x,b.y):v=Math.sqrt((b.x-g.x)**2+(b.y-g.y)**2),y+v>=f||m===d[d.length-1]){let S=0;if(C)return S=this.getBezierTAtLength(f-y,g.x,g.y,g.out_x??g.x,g.out_y??g.y,b.in_x??b.x,b.in_y??b.y,b.x,b.y,20),this.getBezierPointAndAngle(S,g,b);{S=v===0?0:(f-y)/v;const M=g.x+(b.x-g.x)*S,w=g.y+(b.y-g.y)*S,I=Math.atan2(b.y-g.y,b.x-g.x);return{x:M,y:w,angle:I}}}y+=v}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,h=((t.startAngle??0)+a*e)*Math.PI/180,l=s*Math.cos(h),f=n*Math.sin(h),y=-s*Math.sin(h),d=n*Math.cos(h),c=Math.atan2(d,y);return{x:l,y:f,angle:c}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),r=(s+n)*2*e;let h=0,l=0,f=0;return r<s?(h=-s/2+r,l=-n/2,f=0):r<s+n?(h=s/2,l=-n/2+(r-s),f=Math.PI/2):r<2*s+n?(h=s/2-(r-(s+n)),l=n/2,f=Math.PI):(h=-s/2,l=n/2-(r-(2*s+n)),f=-Math.PI/2),{x:h,y:l,angle:f}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o){const e=i.x,s=i.y,n=i.out_x??i.x,a=i.out_y??i.y,r=o.in_x??o.x,h=o.in_y??o.y,l=o.x,f=o.y,y=1-t,d=t*t,c=y*y,u=c*y,m=d*t,g=u*e+3*c*t*n+3*y*d*r+m*l,b=u*s+3*c*t*a+3*y*d*h+m*f,v=3*c*(n-e)+6*y*t*(r-n)+3*d*(l-r),C=3*c*(a-s)+6*y*t*(h-a)+3*d*(f-h),S=Math.atan2(C,v);return{x:g,y:b,angle:S}}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){const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),s=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,s)}applyArtEffectOverlay(t,i,o,e,s,n){var d,c,u,m,g;const a=this.objectStates.get(i.id),r=((d=a==null?void 0:a.style)==null?void 0:d.artEffect)||i.artEffect||((c=i.style)==null?void 0:c.artEffect);if(!r||!r.enabled)return;const h=r.type,l=r.intensity??.5,f=r.speed??1,y=r.scale??10;if(h==="acid_gradient"||h==="acid_rave"||h==="shimmer"||h==="glint_overlay"||h==="halftone"||h==="noise"||h==="scanlines"||h==="chromatic_aberration"||h==="pixelate"||h==="glitch"||h==="fold_overlay"||h==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),h==="shimmer"){const v=this.currentTime*f%2/2,C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),C.addColorStop(v,`rgba(255,255,255,${l*.8})`),C.addColorStop(Math.min(1,v+.2),"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(h==="glint_overlay"){let C=((this._lastPointerPos||{x:0}).x-(((u=i.transform)==null?void 0:u.x)??0)+300)/600;C=Math.max(-.2,Math.min(1.2,C));const S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,C-.15),"rgba(255,255,255,0)"),S.addColorStop(Math.max(0,Math.min(1,C)),`rgba(255,255,255,${l})`),S.addColorStop(Math.min(1,C+.15),"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(h==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((m=i.transform)==null?void 0:m.x)??0),C=b.y-(((g=i.transform)==null?void 0:g.y)??0),S=t.createLinearGradient(v>0?-e/2:e/2,C>0?-s/2:s/2,v>0?e/2:-e/2,C>0?s/2:-s/2);S.addColorStop(0,`rgba(0,0,0,${l*.6})`),S.addColorStop(.4,"rgba(0,0,0,0)"),S.addColorStop(.5,`rgba(255,255,255,${l*.4})`),S.addColorStop(1,`rgba(0,0,0,${l*.2})`),t.fillStyle=S,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&C>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&&C>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&&C<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=C>0?-2:2,t.fill()}else if(h==="crumple_overlay"){const b=Math.floor(e/y),v=document.createElement("canvas");v.width=b,v.height=Math.floor(s/y);const C=v.getContext("2d"),S=C.createImageData(v.width,v.height);for(let M=0;M<S.data.length;M+=4){const w=Math.random()>.95?150:255;S.data[M]=w,S.data[M+1]=w,S.data[M+2]=w,S.data[M+3]=255*l}C.putImageData(S,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-s/2,e,s)}else if(h==="acid_gradient"||h==="acid_rave"){const b=this.currentTime*f,v=r.color1,C=r.color2,S=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(v&&C){const M=b*60%360;S.addColorStop(0,this._shiftHue(v,M,l*.7)),S.addColorStop(1,this._shiftHue(C,(M+180)%360,l*.7))}else{const M=b*100%360,w=(M+180)%360;S.addColorStop(0,`hsla(${M}, 80%, 50%, ${l*.5})`),S.addColorStop(1,`hsla(${w}, 80%, 50%, ${l*.5})`)}t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(h==="halftone"){const b=Math.max(2,y*(1-l*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const C=v.getContext("2d");if(C){C.fillStyle="black",C.beginPath(),C.arc(b/2,b/2,b/2*l,0,Math.PI*2),C.fill();const S=t.createPattern(v,"repeat");S&&(t.globalAlpha=.3*l,t.fillStyle=S,t.fillRect(-e/2,-s/2,e,s))}}else if(h==="noise"){const b=Math.floor(e*s*l*.02);t.globalAlpha=.4*l;for(let v=0;v<b;v++){const C=Math.random()>.5?255:0;t.fillStyle=`rgba(${C}, ${C}, ${C}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(h==="scanlines"){t.globalAlpha=.2*l,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-s/2;b<s/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(h==="chromatic_aberration"){const b=5*l;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+b,-s/2,e,s)}else if(h==="pixelate"){const b=Math.max(2,Math.round(y*(1-l*.5))),v=document.createElement("canvas"),C=Math.max(1,Math.ceil(e/b)),S=Math.max(1,Math.ceil(s/b));v.width=C,v.height=S;const M=v.getContext("2d");if(M){M.imageSmoothingEnabled=!1;const w=t.getTransform(),I=w.e-e/2,_=w.f-s/2;M.drawImage(t.canvas,I,_,e,s,0,0,C,S),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,C,S,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(h==="glitch"){const b=this.currentTime*f,v=r.chaosAmount??.2,C=Math.max(3,Math.floor(8*l)),S=l*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=l*.4;const M=S*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+M,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-M,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const w=s/C;for(let I=0;I<C;I++){const _=Math.sin(I*127.1+b*311.7*f)*43758.5,x=_-Math.floor(_);if(x>1-v){const F=(x-(1-v))/v*S*(Math.random()>.5?1:-1),T=-s/2+I*w,P=t.getTransform(),L=P.e-e/2+F,O=P.f+T;t.save(),t.beginPath(),t.rect(-e/2,T,e,w),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,L,O,e,w,-e/2+F,T,e,w),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const d=t.replace("#","");e=parseInt(d.substring(0,2),16)/255,s=parseInt(d.substring(2,4),16)/255,n=parseInt(d.substring(4,6),16)/255}const a=Math.max(e,s,n),r=Math.min(e,s,n);let h=0,l=0,f=(a+r)/2;if(a!==r){const d=a-r;switch(l=f>.5?d/(2-a-r):d/(a+r),a){case e:h=((s-n)/d+(s<n?6:0))/6;break;case s:h=((n-e)/d+2)/6;break;case n:h=((e-s)/d+4)/6;break}}return`hsla(${(((h*360+i)%360+360)%360).toFixed(0)}, ${(l*100).toFixed(0)}%, ${(f*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",h=n.opacity??.5,l=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const f=t.getTransform();try{const d=[{x:-o/2,y:-e/2},{x:o/2,y:-e/2},{x:-o/2,y:e/2},{x:o/2,y:e/2}];let c=1/0,u=1/0,m=-1/0,g=-1/0;for(const w of d){const I=f.a*w.x+f.c*w.y+f.e,_=f.b*w.x+f.d*w.y+f.f;I<c&&(c=I),_<u&&(u=_),I>m&&(m=I),_>g&&(g=_)}const b=Math.sqrt(f.a*f.a+f.b*f.b),v=a*b,C=v*2;c=Math.max(0,Math.floor(c-C)),u=Math.max(0,Math.floor(u-C)),m=Math.min(t.canvas.width,Math.ceil(m+C)),g=Math.min(t.canvas.height,Math.ceil(g+C));const S=m-c,M=g-u;if(S>0&&M>0){const w=document.createElement("canvas");w.width=S,w.height=M;const I=w.getContext("2d");if(I){I.drawImage(t.canvas,c,u,S,M,0,0,S,M);const _=document.createElement("canvas");_.width=S,_.height=M;const x=_.getContext("2d");x.filter=`blur(${v}px)`,x.drawImage(w,0,0),t.save(),t.resetTransform(),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(_,c,u),t.restore()}}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=h,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const y=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(y.addColorStop(0,"rgba(255,255,255,0.12)"),y.addColorStop(.3,"rgba(255,255,255,0.04)"),y.addColorStop(.5,"rgba(255,255,255,0.0)"),y.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=y,t.fillRect(-o/2,-e/2,o,e),l>0){if(t.globalAlpha=l/100,!this._noiseTileCanvas){const c=document.createElement("canvas");c.width=64,c.height=64;const u=c.getContext("2d"),m=u.createImageData(64,64),g=m.data;for(let b=0;b<g.length;b+=4){const v=Math.floor(Math.random()*255);g[b]=v,g[b+1]=v,g[b+2]=v,g[b+3]=18}u.putImageData(m,0,0),this._noiseTileCanvas=c}const d=t.createPattern(this._noiseTileCanvas,"repeat");d&&(t.fillStyle=d,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,h=o/2,l=e/2,f=n*Math.PI/180,y=a*Math.PI/180,d=f+y;a>=360&&r<=0?t.ellipse(0,0,h,l,0,0,Math.PI*2):(t.ellipse(0,0,h,l,0,f,d,!1),r>0?t.ellipse(0,0,h*r,l*r,0,d,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 h=r*2*Math.PI/n-Math.PI/2,l=a*Math.cos(h),f=a*Math.sin(h);r===0?t.moveTo(l,f):t.lineTo(l,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 h=0;h<n*2;h++){const l=h*Math.PI/n-Math.PI/2,f=h%2===0?a:r,y=f*Math.cos(l),d=f*Math.sin(l);h===0?t.moveTo(y,d):t.lineTo(y,d)}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,h=-1/0;if(i.points.forEach(l=>{typeof l.x=="number"&&typeof l.y=="number"&&(n=Math.min(n,l.x),a=Math.max(a,l.x),r=Math.min(r,l.y),h=Math.max(h,l.y),l.out_x!==void 0&&(n=Math.min(n,l.out_x),a=Math.max(a,l.out_x)),l.out_y!==void 0&&(r=Math.min(r,l.out_y),h=Math.max(h,l.out_y)),l.in_x!==void 0&&(n=Math.min(n,l.in_x),a=Math.max(a,l.in_x)),l.in_y!==void 0&&(r=Math.min(r,l.in_y),h=Math.max(h,l.in_y)))}),n===1/0)return;i.points.forEach((l,f)=>{if(f===0||l.moveTo)t.moveTo(l.x,l.y);else{const y=i.points[f-1];if(!y)return;const d=y.out_x??y.x,c=y.out_y??y.y,u=l.in_x??l.x,m=l.in_y??l.y;isNaN(d)||isNaN(u)||isNaN(l.x)?t.lineTo(l.x,l.y):t.bezierCurveTo(d,c,u,m,l.x,l.y)}if(l.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed)){const y=[...i.points.slice(0,f+1)].reverse().find(d=>d.moveTo)||i.points[0];y&&(l.out_x!==void 0||y.in_x!==void 0)&&t.bezierCurveTo(l.out_x??l.x,l.out_y??l.y,y.in_x??y.x,y.in_y??y.y,y.x,y.y),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,r=1/0,h=-1/0;i.points.forEach(l=>{n=Math.min(n,l.x),a=Math.max(a,l.x),r=Math.min(r,l.y),h=Math.max(h,l.y)}),i.points.forEach((l,f)=>{if(f===0)t.moveTo(l.x,l.y);else{const y=i.points[f-1];y.out_x!==void 0||l.in_x!==void 0?t.bezierCurveTo(y.out_x??y.x,y.out_y??y.y,l.in_x??l.x,l.in_y??l.y,l.x,l.y):t.lineTo(l.x,l.y)}(l.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var tt,lt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((tt=i.geometry)==null?void 0:tt.width)||250,n=((lt=i.geometry)==null?void 0:lt.height)||45,a=this.focusedId===i.id,r=this.lastHoveredObjectId===i.id,h=e.previewState||"default",l=h!=="default"?h:a?"focused":r?"hovered":"default",f=e.label||{visible:!0,text:"Label"},y=e.helperText||{visible:!1,text:"Helper text"},d=e.leftIcon||{visible:!1},c=e.rightIcon||{visible:!1},u=e.multiline===!0,m=e.corner_radius??8,g=e.corners||{tl:m,tr:m,bl:m,br:m},b=[g.tl,g.tr,g.br,g.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",C=e.borderColor||"rgba(55, 65, 81, 1)",S=e.borderWidth??1.5,M=e.color||"#ffffff",w=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const _=`${l}Style`,x=e[_];x?(x.backgroundColor!==void 0&&(v=x.backgroundColor),x.borderColor!==void 0&&(C=x.borderColor),x.borderWidth!==void 0&&(S=x.borderWidth),x.color!==void 0&&(M=x.color),x.placeholderColor!==void 0&&(w=x.placeholderColor),x.fontSize!==void 0&&(I=x.fontSize)):l==="focused"?(C=e.focusBorderColor||"rgba(59, 130, 246, 1)",S=Math.max(S,2)):l==="hovered"||l==="hover"?(C=e.hoverBorderColor||C,v=e.hoverBackgroundColor||v):l==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",C=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):l==="error"&&(C="rgba(239, 68, 68, 1)",S=Math.max(S,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,b);const F=this.createCanvasFill(t,v,s,n);if(F&&(t.fillStyle=F,t.fill()),S>0){const Z=this.createCanvasFill(t,C,s,n);if(Z&&(t.strokeStyle=Z,t.lineWidth=S,t.stroke()),l==="focused"||l==="focus"){t.save(),t.beginPath();const pt=b.map(at=>at+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,pt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const T=(Z,pt)=>{if(!Z.visible||!Z.svgPath)return;const at=Z.size||14,Et=Z.offset??16,xt=Z.color||"#ffffff",bt=pt?-(s/2)+Et:s/2-Et,Gt=Z.svgPath;if(t.save(),t.translate(bt,0),!Gt.startsWith("<svg")){const Wt=new Path2D(Gt),_t=at/24;t.scale(_t,_t),t.translate(-12,-12),t.fillStyle=xt,t.fill(Wt)}t.restore()};T(d,!0),T(c,!1);const P=e.text||"",L=e.placeholder||"Enter text...",O=!P,W=P||L,B=O?w:M,A=I,$=e.fontFamily||"Inter",Y=e.fontWeight||400;t.font=`${Y} ${A}px "${$}", sans-serif`,t.fillStyle=B,t.textAlign="left",t.textBaseline=u?"top":"middle";const N=e.inputPadding??16,E=d.visible?(d.offset??16)+(d.size||14)/2+8:N,k=c.visible?(c.offset??16)+(c.size||14)/2+8:N,G=-(s/2)+E,X=s-E-k,J=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(G-2,-n/2+4,X+4,n-8),t.clip(),u){const Z=J.split(`
34
+ `);let pt=-n/2+N;const at=A*1.2;let Et=0;Z.forEach((xt,bt)=>{const Gt=xt.split(" ");let Wt="";for(let _t=0;_t<Gt.length;_t++){const Nt=Wt+Gt[_t]+" ";t.measureText(Nt).width>X&&_t>0?(t.fillText(Wt,G,pt),Wt=Gt[_t]+" ",pt+=at):Wt=Nt}t.fillText(Wt,G,pt),Et=t.measureText(Wt).width,bt<Z.length-1&&(pt+=at,Et=0)}),a&&!O&&Math.floor(performance.now()/500)%2===0&&t.fillRect(G+Et,pt,1.5,A)}else{const pt=t.measureText(J).width;let at=0;if(pt>X&&(at=pt-X),t.fillText(J,G-at,0),a&&!O&&Math.floor(performance.now()/500)%2===0){const xt=G+pt-at;t.fillRect(xt,-(A/2),1.5,A)}}if(t.restore(),f.visible!==!1){const Z=f.text||"Label",pt=f.fontSize||12,at=f.color||"rgba(156, 163, 175, 1)",Et=f.offset??8;t.font=`600 ${pt}px "${$}", sans-serif`,t.fillStyle=at,t.textAlign="left",t.textBaseline="bottom";const xt=-(s/2),bt=-(n/2)-Et;t.fillText(Z,xt,bt)}if(y.visible===!0){const Z=y.text||"Helper text",pt=y.fontSize||11,at=l==="error"?"rgba(239, 68, 68, 1)":y.color||"rgba(156, 163, 175, 1)",Et=y.offset??6;t.font=`400 ${pt}px "${$}", sans-serif`,t.fillStyle=at,t.textAlign="left",t.textBaseline="top";const xt=-(s/2),bt=n/2+Et;t.fillText(Z,xt,bt)}}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,l=(s.max??100)-r,f=l===0?0:(a-r)/l,y=s.trackHeight||4,d=s.trackRoundedness??2,c=s.trackShape??"Rectangle",u=s.trackPath||"",m=s.accentColor||"#3b82f6",g=s.inactiveColor||"#374151",b=s.thumbShape||"Ellipse",v=s.thumbWidth??16,C=s.thumbHeight??16,S=s.thumbRoundedness??0,M=s.thumbColor||"#ffffff",w=s.thumbPath||"",I=s.thumbIcon||"",_=s.showValueTooltip??!1,x=s.tooltipBgColor||"#333333",F=s.tooltipColor||"#ffffff",T=s.tooltipOffsetX??0,P=s.tooltipOffsetY??-25,L=(X,J,tt,lt,Z,pt,at)=>{if((X==="Custom"||X==="Icon")&&at)try{const Et=new Path2D(at);if(t.save(),t.translate(J,tt),X==="Icon"){const xt=Math.min(lt,Z)/24;t.scale(xt,xt),t.translate(-12,-12)}t.fill(Et),t.restore();return}catch(Et){console.error("Error drawing slider shape in engine:",Et)}if(t.beginPath(),X==="Ellipse")t.ellipse(J,tt,lt/2,Z/2,0,0,Math.PI*2);else if(X==="Rectangle")this.drawRoundRect(t,J-lt/2,tt-Z/2,lt,Z,pt);else if(X==="Triangle")t.moveTo(J,tt-Z/2),t.lineTo(J+lt/2,tt+Z/2),t.lineTo(J-lt/2,tt+Z/2),t.closePath();else if(X==="Diamond")t.moveTo(J,tt-Z/2),t.lineTo(J+lt/2,tt),t.lineTo(J,tt+Z/2),t.lineTo(J-lt/2,tt),t.closePath();else if(X==="Polygon"){const Et=i.geometry.sides||3,xt=i.geometry.radius||Math.min(lt,Z)/2;for(let bt=0;bt<Et;bt++){const Gt=bt*2*Math.PI/Et-Math.PI/2,Wt=J+xt*Math.cos(Gt),_t=tt+xt*Math.sin(Gt);bt===0?t.moveTo(Wt,_t):t.lineTo(Wt,_t)}t.closePath()}else if(X==="Star"){const xt=Math.min(lt,Z)/2,bt=xt/2;for(let Gt=0;Gt<10;Gt++){const Wt=Gt%2===0?xt:bt,_t=Gt*Math.PI/5-Math.PI/2;t.lineTo(J+Wt*Math.cos(_t),tt+Wt*Math.sin(_t))}t.closePath()}else X==="Line"&&(t.moveTo(J-lt/2,tt),t.lineTo(J+lt/2,tt));t.fill()},O=this.createCanvasFill(t,g,n,y);O&&(t.fillStyle=O,t.strokeStyle=O),c==="Line"?(t.lineWidth=y,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):L(c,0,0,n,y,d,u);const W=n-v,B=-n/2+v/2+f*W,A=B- -n/2;if(A>0){const X=this.createCanvasFill(t,m,n,y);X&&(t.fillStyle=X,t.strokeStyle=X),c==="Line"?(t.lineWidth=y,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(B,0),t.stroke()):c==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-y/2,A,y,d),t.fill())}t.save(),t.translate(B,0);const $=t.getTransform(),Y=Math.sqrt($.a*$.a+$.b*$.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*Y,t.shadowOffsetY=1*Y;const N=this.createCanvasFill(t,M,v,C);if(N&&(t.fillStyle=N),L(b,0,0,v,C,S,b==="Icon"?I:w),t.restore(),_){t.save(),t.translate(B+T,P);const X=Math.round(a).toString();t.font="10px Inter, sans-serif";const J=t.measureText(X),tt=6,lt=4,Z=J.width+tt*2,pt=14+lt;t.beginPath(),this.drawRoundRect(t,-Z/2,-pt/2,Z,pt,4),t.fillStyle=x,t.fill(),t.fillStyle=F,t.textAlign="center",t.textBaseline="middle",t.fillText(X,0,0),t.restore()}const E=s.label||{},k=s.helperText||{},G=s.fontFamily||"Inter";if(E.visible!==!1){const X=E.text||"Label",J=E.fontSize||12,tt=E.color||"rgba(156, 163, 175, 1)",lt=E.offset??8;t.font=`600 ${J}px "${G}", sans-serif`,t.fillStyle=tt,t.textAlign="left",t.textBaseline="bottom";const Z=-(n/2),pt=-(y/2)-lt;t.fillText(X,Z,pt)}if(k.visible===!0){const X=k.text||"Helper text",J=k.fontSize||11,tt=k.color||"rgba(156, 163, 175, 1)",lt=k.offset??6;t.font=`400 ${J}px "${G}", sans-serif`,t.fillStyle=tt,t.textAlign="left",t.textBaseline="top";const Z=-(n/2),pt=y/2+lt;t.fillText(X,Z,pt)}}renderDropdown(t,i){var P;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,h=e.corner_radius??6,l=e.disabled||e.previewState==="disabled",f=this.lastHoveredObjectId===i.id||e.previewState==="hover",y=(e.isOpen||e.previewState==="active")&&!l;let d=e.backgroundColor,c=e.borderColor,u=e.color||"#333333";l?(d=e.disabledBackgroundColor||"#f3f4f6",c=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):y?(d=e.activeBackgroundColor||d,c=e.activeBorderColor||c,u=e.activeColor||u):f&&(d=e.hoverBackgroundColor||d,c=e.hoverBorderColor||c,u=e.hoverColor||u),d||(d="#ffffff"),c||(c="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,r,s,n,h),t.fillStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#ffffff",t.fill();const g=e.borderWidth??1;g>0&&(t.strokeStyle=this.createCanvasFill(t,typeof c=="string"?{type:"Solid",color:c}:c,s,n)||"#e5e7eb",t.lineWidth=g,t.stroke());const b=12,v=e.chevronType||"chevron",C=e.chevronSize||16,S=(y?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const L=a+s-b-C/2;t.save(),t.translate(L,0);const O=y?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(O*Math.PI/180),t.strokeStyle=S,t.fillStyle=S,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-C/2,-C*.2),t.lineTo(0,C*.2),t.lineTo(C/2,-C*.2),t.stroke();else if(v==="custom"||v==="path"){const W=y&&e.openIconPath||e.closedIconPath;if(W){const B=new Path2D(W);t.save();const A=C/24;t.scale(A,A),t.translate(-12,-12),t.fill(B),t.restore()}}t.restore()}const M=e.selectedOption||e.placeholder||"Select...",w=e.fontSize||14,I=e.fontWeight||400,_=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${w}px ${_}`;const x=l?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof x=="string"?{type:"Solid",color:x}:x,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const F=v==="none"?0:C+8,T=s-b*2-F;if(t.save(),t.beginPath(),t.rect(a+b,r,T,n),t.clip(),t.fillText(M,a+b,0),t.restore(),y&&!l){const L=r+n+4,O=e.optionsList||[],W=e.itemHeight||32,B=e.listPadding??4,A=O.length*W+B*2,$=e.listCornerRadius??h;t.save();const Y=e.listShadow||{},N=t.getTransform(),E=Math.sqrt(N.a*N.a+N.b*N.b)||1;t.shadowColor=typeof Y.color=="string"?Y.color:((P=Y.color)==null?void 0:P.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(Y.blur??12)*E,t.shadowOffsetY=(Y.offsetY??6)*E,t.shadowOffsetX=(Y.offsetX??0)*E,t.beginPath(),this.drawRoundRect(t,a,L,s,A,$),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,A)||"#ffffff",t.fill();const k=e.listBorderWidth??1;k>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:c},s,A)||"#e5e7eb",t.lineWidth=k,t.stroke()),t.restore();const G=e.itemFontSize||w,X=e.itemFontFamily||_;t.font=`${I} ${G}px ${X}`,O.forEach((J,tt)=>{const lt=L+B+tt*W;if(J===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+k,lt,s-k*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const pt=this._lastPointerPos.y-(L+B),at=Math.floor(pt/W);tt===at&&(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+k,lt,s-k*2,W),t.fillStyle=e.itemHoverColor||u)}t.fillText(J,a+b,lt+W/2)})}t.globalAlpha=m}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,h=this.activeObjectId===i.id,l=e.label||{},f=e.hoverStyle||{},y=e.activeStyle||{},d=e.icon||{enabled:!1};let c=e.backgroundColor||"#3b82f6",u=l.color||"#ffffff",m=l.text||"Button",g=s.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,C=1;h&&y?(c=y.backgroundColor||c,u=y.color||u,m=y.text||m,C=y.scale??.95,g=y.cornerRadius??g):r&&f&&(c=f.backgroundColor||c,u=f.color||u,m=f.text||m,C=f.scale??1,g=f.cornerRadius??g,b=f.borderColor||b);const S=-n/2,M=-a/2;t.save(),t.scale(C,C),t.beginPath(),this.drawRoundRect(t,S,M,n,a,g);const w=this.createCanvasFill(t,c,n,a);w&&(t.fillStyle=w,t.fill()),(v>0||r&&f.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(r?1:0),t.stroke());const I=l.fontSize||14,_=l.fontFamily||"Inter",x=l.fontWeight||600;t.font=`${x} ${I}px "${_}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let F=0;if(d.enabled&&d.svgPath){const T=I*1.1,P=d.gap||8,L=t.measureText(m),W=-(L.width+T+P)/2,B=d.position==="left"?W+T/2:W+L.width+P+T/2;F=d.position==="left"?W+T+P+L.width/2:W+L.width/2,t.save(),t.translate(B,0);const A=new Path2D(d.svgPath),$=T/24;t.scale($,$),t.translate(-12,-12),t.fillStyle=u,t.fill(A),t.restore()}t.fillText(m,F,0),t.restore()}renderToggleButton(t,i){var m,g;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((m=i.geometry)==null?void 0:m.width)||120,a=((g=i.geometry)==null?void 0:g.height)||40,r=-n/2,h=-a/2,l=e.corner_radius??8,f=e.label||{},y=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",d=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,h,n,a,l),t.fillStyle=y,t.fill();const c=f.fontSize||14,u=f.fontFamily||"Inter";t.font=`${f.fontWeight||600} ${c}px "${u}", sans-serif`,t.fillStyle=d,t.textAlign="center",t.textBaseline="middle",t.fillText(f.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var $,Y,N,E,k,G,X,J,tt,lt,Z,pt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=(($=i.geometry)==null?void 0:$.width)||52,n=((Y=i.geometry)==null?void 0:Y.height)||30,a=-s/2,r=-n/2,h=e.checked??!1,l=e.cornerRadius??e.corner_radius??n/2,f=e.toggleStyle||{},y=f.backgroundColor||e.activeColor||"#10b981",d=f.borderColor||e.borderColor||"transparent",c=f.borderWidth??e.borderWidth??0,u=f.knobColor||e.knobColor||"#ffffff",m=h?y:e.inactiveColor||"#374151",g=h?d:e.borderColor||"transparent",b=h?c:e.borderWidth??0,v=h?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,l);const C=this.createCanvasFill(t,m,s,n);if(C&&(t.fillStyle=C,t.fill()),b>0){t.lineWidth=b;const at=this.createCanvasFill(t,g,s,n);at&&(t.strokeStyle=at,t.stroke())}const S=2,M=n-S*2,w=M/2,I=a+S,_=a+s-S-M,x=h?_:I,F=r+S;t.beginPath(),t.arc(x+w,F+w,w,0,Math.PI*2);const T=this.createCanvasFill(t,v,M,M);T&&(t.fillStyle=T,t.fill()),e.disabled&&(t.globalAlpha*=2);let P=!1,L=!1;const O=(h?(N=f.leftLabel)==null?void 0:N.text:null)||((E=e.leftLabel)==null?void 0:E.text)||"",W=(h?(k=f.leftLabel)==null?void 0:k.color:null)||((G=e.leftLabel)==null?void 0:G.color)||"#f3f4f6";if((X=e.leftLabel)!=null&&X.enabled&&O){const at=e.leftLabel;t.font=`${at.fontWeight||400} ${at.fontSize||12}px "${at.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(O,a-(at.gap||8),0),P=!0}const B=(h?(J=f.rightLabel)==null?void 0:J.text:null)||((tt=e.rightLabel)==null?void 0:tt.text)||"",A=(h?(lt=f.rightLabel)==null?void 0:lt.color:null)||((Z=e.rightLabel)==null?void 0:Z.color)||"#f3f4f6";if((pt=e.rightLabel)!=null&&pt.enabled&&B){const at=e.rightLabel;t.font=`${at.fontWeight||400} ${at.fontSize||12}px "${at.fontFamily||"Inter"}", sans-serif`,t.fillStyle=A,t.textBaseline="middle",t.textAlign="left",t.fillText(B,a+s+(at.gap||8),0),L=!0}if(!P&&!L&&e.label&&e.label.text){const at=e.label,Et=at.fontSize||14,xt=at.fontWeight||400,bt=at.fontFamily||"Inter";t.font=`${xt} ${Et}px "${bt}", sans-serif`,t.fillStyle=at.color||"#f3f4f6",t.textBaseline="middle";const Gt=at.gap||10;let Wt=0,_t=0;at.position==="left"?(t.textAlign="right",Wt=a-Gt,_t=0):at.position==="right"?(t.textAlign="left",Wt=a+s+Gt,_t=0):at.position==="top"?(t.textAlign="center",Wt=0,_t=r-Gt,t.textBaseline="bottom"):at.position==="bottom"?(t.textAlign="center",Wt=0,_t=r+n+Gt,t.textBaseline="top"):(t.textAlign="left",Wt=a+s+Gt,_t=0),t.fillText(at.text,Wt,_t)}}renderCheckbox(t,i){var C,S;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)||20,n=((S=i.geometry)==null?void 0:S.height)||20,a=-s/2,r=-n/2,h=e.cornerRadius??4,l=e.checked??!1,f=e.activeColor||"#3b82f6",y=e.inactiveColor||"transparent",d=e.checkColor||"#ffffff",c=e.borderColor||"#4b5563",u=e.borderWidth??2,m=l?f:y,g=l?"transparent":c,b=l?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,s,n,h);const v=this.createCanvasFill(t,m,s,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const M=this.createCanvasFill(t,g,s,n);M&&(t.strokeStyle=M,t.stroke())}else if(l){t.lineWidth=1;const M=this.createCanvasFill(t,f,s,n);M&&(t.strokeStyle=M,t.stroke())}if(l){t.save(),t.beginPath();const M=this.createCanvasFill(t,d,s,n);t.strokeStyle=M||d,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const w=a+s*.25,I=r+n*.5,_=a+s*.45,x=r+n*.7,F=a+s*.75,T=r+n*.25;t.moveTo(w,I),t.lineTo(_,x),t.lineTo(F,T),t.stroke(),t.restore()}if(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||"#f3f4f6",t.textBaseline="middle";const w=M.gap||8;let I=0,_=0;M.position==="left"?(t.textAlign="right",I=a-w,_=0):M.position==="right"?(t.textAlign="left",I=a+s+w,_=0):M.position==="top"?(t.textAlign="center",I=0,_=r-w,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",I=0,_=r+n+w,t.textBaseline="top"),t.fillText(M.text,I,_),t.restore()}}renderRadioGroup(t,i){var S,M;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)||180,n=((M=i.geometry)==null?void 0:M.height)||100,a=-s/2,r=-n/2,h=e.selectedValue,l=e.optionsList||["Option 1","Option 2","Option 3"],f=e.orientation||"vertical",y=e.itemGap!==void 0?e.itemGap:16,d=e.activeColor||"#3b82f6",c=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",m=e.fontSize||14,g=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,C=v*2;if(t.save(),t.font=`${b} ${m}px "${g}", sans-serif`,t.textBaseline="middle",t.textAlign="left",f==="vertical"){const w=Math.max(C,m)+y;l.forEach((I,_)=>{const x=r+_*w+v;t.beginPath(),t.arc(a+v,x,v,0,Math.PI*2);const F=h===I,T=this.createCanvasFill(t,d,C,C),P=this.createCanvasFill(t,c,C,C);F?(t.strokeStyle=T||d,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,x,v/2,0,Math.PI*2),t.fillStyle=T||d,t.fill()):(t.strokeStyle=P||c,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,a+C+8,x)})}else{let w=a;l.forEach(I=>{const _=h===I,x=t.measureText(I).width;t.beginPath(),t.arc(w+v,0,v,0,Math.PI*2);const F=this.createCanvasFill(t,d,C,C),T=this.createCanvasFill(t,c,C,C);_?(t.strokeStyle=F||d,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(w+v,0,v/2,0,Math.PI*2),t.fillStyle=F||d,t.fill()):(t.strokeStyle=T||c,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(I,w+C+6,0),w+=C+6+x+y})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#9ca3af",t.textBaseline="middle";const I=w.gap||8;let _=0,x=0;w.position==="left"?(t.textAlign="right",_=a-I,x=0):w.position==="right"?(t.textAlign="left",_=a+s+I,x=0):w.position==="top"?(t.textAlign="center",_=0,x=r-I,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",_=0,x=r+n+I,t.textBaseline="top"),t.fillText(w.text,_,x),t.restore()}}renderBarChart(t,i){var x,F;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((x=i.geometry)==null?void 0:x.width)||300,height:((F=i.geometry)==null?void 0:F.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 ss[this.stylePreset]||ss.default},_resolveColor:function(T,P){const L=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(T)?L.colors[P%L.colors.length]:typeof T=="string"?T:L.colors[P%L.colors.length]},_makeGradient:function(T,P,L,O,W,B){if(!this._getPreset().barGradient&&!this.barGradient)return P;const $=T.createLinearGradient(L,O,W,B);return $.addColorStop(0,P),$.addColorStop(1,P+"44"),$},_drawRoundedBar:function(T,P,L,O,W,B,A){if(B=Math.min(B,Math.min(Math.abs(O),Math.abs(W))/2),B<=0||O===0||W===0){T.rect(P,L,O,W);return}T.beginPath(),A?(T.moveTo(P,L+W),T.lineTo(P,L+B),T.quadraticCurveTo(P,L,P+B,L),T.lineTo(P+O-B,L),T.quadraticCurveTo(P+O,L,P+O,L+B),T.lineTo(P+O,L+W),T.lineTo(P,L+W)):(T.moveTo(P,L),T.lineTo(P+O-B,L),T.quadraticCurveTo(P+O,L,P+O,L+B),T.lineTo(P+O,L+W-B),T.quadraticCurveTo(P+O,L+W,P+O-B,L+W),T.lineTo(P,L+W),T.lineTo(P,L)),T.closePath()}},n=s.width,a=s.height,r=-n/2,h=-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 l=s._getPreset();let f=-1/0,y=1/0;const d=s.categories.length,c=s.datasets.length;if(s.chartType==="stacked")for(let T=0;T<d;T++){let P=0,L=0;s.datasets.forEach(O=>{const W=O.data[T]??0;W>=0?P+=W:L+=W}),P>f&&(f=P),L<y&&(y=L)}else s.datasets.forEach(T=>{T.data&&T.data.forEach(P=>{P>f&&(f=P),P<y&&(y=P)})});isFinite(f)||(f=10),isFinite(y)||(y=0),f=Math.max(f,0),y=Math.min(y,0);const u=f-y||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 m=s.showYLabels?t.measureText(f.toFixed(0)).width+14:10,g=s.showXLabels?s.axisLabelFontSize+12:8,v=(s.showLegend&&c>0?s.legendFontSize+10:0)+8,C=10,S=r+m,M=h+v,w=n-m-C,I=a-v-g;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(r,h,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(S,M,w,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&c>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const T=h+12;let P=S;s.datasets.forEach((L,O)=>{const W=s._resolveColor(L.color,O),B=L.label||"Series "+(O+1),A=7;t.beginPath(),t.roundRect(P,T-A/2,A,A,2),t.fillStyle=W,t.fill(),t.fillStyle=l.legendColor,t.textAlign="left",t.fillText(B,P+A+4,T),P+=t.measureText(B).width+A+16})}const _=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=l.gridColor;for(let T=0;T<=_;T++)if(s.orientation==="horizontal"){const P=S+T/_*w;t.beginPath(),t.moveTo(P,M),t.lineTo(P,M+I),t.stroke()}else{const P=M+T/_*I;t.beginPath(),t.moveTo(S,P),t.lineTo(S+w,P),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=l.axisLabelColor;for(let T=0;T<=_;T++)if(s.orientation==="horizontal"){const P=y+T/_*u,L=S+T/_*w;t.textAlign="center",t.fillText(P.toFixed(0),L,M+I+s.axisLabelFontSize)}else{const P=f-T/_*u,L=M+T/_*I;t.textAlign="right",t.fillText(P.toFixed(0),S-6,L)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(S,M+I),t.lineTo(S+w,M+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(S,M),t.lineTo(S,M+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const T=I/d;for(let P=0;P<d;P++){const L=M+P*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=l.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[P]||"",S-5,L),s.enableShadows&&(t.shadowColor=s.shadowColor));let O=S;s.datasets.forEach((W,B)=>{const A=W.data[P]??0;if(A===0)return;const $=A/u*w,Y=Math.min(s.barWidth*c+s.barGap,T-8),N=L-Y/2,E=O;O+=$;const k=s._resolveColor(W.color,B);t.beginPath(),t.fillStyle=s._makeGradient(t,k,E,N,E+$,N),s._drawRoundedBar(t,E,N,$,Y,B===c-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?k:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const T=w/d;for(let P=0;P<d;P++){const L=S+P*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=l.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[P]||"",L,M+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let O=M+I;s.datasets.forEach((W,B)=>{const A=W.data[P]??0;if(A===0)return;const $=A/u*I,Y=Math.min(s.barWidth*c+s.barGap,T-8),N=L-Y/2,E=O-$;O-=$;const k=s._resolveColor(W.color,B);t.beginPath(),t.fillStyle=s._makeGradient(t,k,N,E,N,E+$),s._drawRoundedBar(t,N,E,Y,$,B===c-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?k: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 T=I/d,P=c*s.barWidth+Math.max(0,(c-1)*s.barGap),L=S+(0-y)/u*w;for(let O=0;O<d;O++){const W=M+O*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=l.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[O]||"",S-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const B=W-P/2;s.datasets.forEach((A,$)=>{const Y=A.data[O]??0,N=Math.abs(Y/u*w);if(N<1)return;const E=B+$*(s.barWidth+s.barGap),k=Y>=0?L:L-N,G=s._resolveColor(A.color,$);t.beginPath(),t.fillStyle=s._makeGradient(t,G,k,E,k+N,E),s._drawRoundedBar(t,k,E,N,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&Y!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=Y>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(Y.toString(),Y>=0?k+N+4:k-4,E+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const T=w/d,P=c*s.barWidth+Math.max(0,(c-1)*s.barGap),L=M+I-(0-y)/u*I;for(let O=0;O<d;O++){const W=S+O*T+T/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=l.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[O]||"",W,M+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const B=W-P/2;s.datasets.forEach((A,$)=>{const Y=A.data[O]??0,N=Math.abs(Y/u*I);if(N<1)return;const E=B+$*(s.barWidth+s.barGap),k=Y>=0?L-N:L,G=s._resolveColor(A.color,$);t.beginPath(),t.fillStyle=s._makeGradient(t,G,E,k,E,k+N),s._drawRoundedBar(t,E,k,s.barWidth,N,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&Y!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=Y>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(Y.toString(),E+s.barWidth/2,Y>=0?k-4:k+N+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var m,g;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((m=i.geometry)==null?void 0:m.width)||180,height:((g=i.geometry)==null?void 0:g.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 is[this.stylePreset]||is.default},_resolveSliceColor:function(b,v){const C=b.color,S=v,M=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(C)?M.colors[S%M.colors.length]:typeof C=="string"?C:M.colors[S%M.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((b,v)=>b+(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 h=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke();const l=s.showLegend?Math.ceil(s.slices.length/2):0,f=l>0?l*(s.legendFontSize+8)+10:0,y=a-f-16,d=Math.min(n-24,y)/2,c=0,u=-f/2;if(s.chartType==="rose"){const b=Math.max(...s.slices.map(S=>S.value||0)),v=Math.PI*2/s.slices.length,C=d>0?s.sliceGap/d:0;s.slices.forEach((S,M)=>{const w=S.value||0;if(w===0)return;const I=w/b*d,_=-Math.PI/2+M*v+C/2,x=_+v-C,F=s._resolveSliceColor(S,M);if(t.beginPath(),t.moveTo(c,u),t.arc(c,u,I,_,x),t.closePath(),t.fillStyle=F+"cc",t.fill(),t.strokeStyle=F,t.lineWidth=1.5,t.stroke(),s.showLabels){const T=_+(x-_)/2,P=c+I*.65*Math.cos(T),L=u+I*.65*Math.sin(T),O=Math.round(w/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=h.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${O}%`,P,L),t.restore()}})}else{const b=s.chartType==="pie"?0:s.innerRadius,v=d*Math.max(0,b),C=d>0?s.sliceGap/d:0;let S=-Math.PI/2;if(s.slices.forEach((M,w)=>{const I=M.value||0;if(I===0){S+=I/r*Math.PI*2;return}const _=I/r*Math.PI*2,x=S+C/2,F=S+_-C/2;if(F<=x){S+=_;return}const T=s._resolveSliceColor(M,w);if(t.beginPath(),t.fillStyle=T,v<=0?(t.moveTo(c,u),t.arc(c,u,d,x,F),t.lineTo(c,u)):(t.moveTo(c+d*Math.cos(x),u+d*Math.sin(x)),t.arc(c,u,d,x,F),t.arc(c,u,v,F,x,!0),t.closePath()),t.fill(),s.showLabels){const P=x+(F-x)/2,L=v+(d-v)/2,O=c+L*Math.cos(P),W=u+L*Math.sin(P),B=Math.round(I/r*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=h.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${B}%`,O,W),t.restore()}S+=_}),s.chartType==="donut"&&s.showCenterText&&v>14){const M=Math.round(r),w=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${w}px Inter, sans-serif`,t.fillStyle=h.centerTextColor,t.fillText(M.toString(),c,u-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=h.centerLabelColor,t.fillText(s.centerLabel,c,u+w*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,C=s.legendFontSize+8,S=a/2-f+10,M=-n/2+10;s.slices.forEach((w,I)=>{const _=I%b,x=Math.floor(I/b),F=M+_*v,T=S+x*C,P=s._resolveSliceColor(w,I),L=7;t.beginPath(),t.roundRect(F,T-L/2,L,L,2),t.fillStyle=P,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=h.legendColor;const O=Math.round((w.value||0)/r*100),W=`${w.label||"Item"} ${O}%`,B=v-L-20;let A=W;for(;t.measureText(A).width>B&&A.length>4;)A=A.slice(0,-4)+"…";t.fillText(A,F+L+4,T)})}t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var 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:((I=t.geometry)==null?void 0:I.width)||180,r=s.height!==void 0?s.height:((_=t.geometry)==null?void 0:_.height)||100,h=e.orientation||"vertical",l=e.itemGap!==void 0?e.itemGap:16,f=e.fontSize||14,y=this.getWorldTransform(t.id),d=i-y.x,c=o-y.y,u=-y.rotation*(Math.PI/180),m=Math.cos(u),g=Math.sin(u),b=d*m-c*g,v=d*g+c*m,S=8*2,M=-a/2,w=-r/2;if(h==="vertical"){const x=Math.max(S,f)+l;for(let F=0;F<n.length;F++){const T=w+F*x;if(b>=M&&b<=M+a&&v>=T&&v<=T+x)return F}}else{let x=M;for(let F=0;F<n.length;F++){const P=n[F].length*8,L=S+6+P+l;if(b>=x&&b<=x+L&&v>=w&&v<=w+r)return F;x+=L}}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,r=0;if(s.forEach(u=>{let m=u.data;if(u.isVarEnabled&&u.inputId){let g=this.inputs.get(u.inputId);if(g===void 0){const b=this.inputNameMap.get(u.inputId);b&&b.length>0&&(g=this.inputs.get(b[0]))}g&&Array.isArray(g)&&(m=g)}if(m&&m.length>0){const g=m.filter(b=>typeof b=="number"&&!isNaN(b));g.length>0&&(n=Math.min(n,...g),a=Math.max(a,...g),r=Math.max(r,m.length))}u._resolvedData=m}),r<2)return;const h=a-n,l=o/(r-1),f=u=>{const m=h===0?.5:(u-n)/h;return e/2-m*e},y=u=>u*l-o/2,d=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||d,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||d,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<r;u++){const m=y(u);t.fillText(`${u+1}`,m,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),u,f(a)),t.fillText(m.toFixed(1),u,f(m)),t.fillText(n.toFixed(1),u,f(n))}const c=10;if(s.forEach(u=>{const m=u._resolvedData;if(!(!m||m.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(y(0),e/2),t.lineTo(y(0),f(m[0])),u.smoothing&&m.length>2)for(let b=0;b<m.length-1;b++){const v=m[b===0?b:b-1],C=m[b],S=m[b+1],M=m[b+1===m.length-1?b+1:b+2];for(let w=1;w<=c;w++){const I=w/c,_=this._catmullRom(v,C,S,M,I);t.lineTo(y(b+I),f(_))}}else for(let b=1;b<m.length;b++)t.lineTo(y(b),f(m[b]));t.lineTo(y(m.length-1),e/2),t.closePath();const g=t.globalAlpha;t.globalAlpha=g*(i.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=g}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(y(0),f(m[0])),u.smoothing&&m.length>2)for(let g=0;g<m.length-1;g++){const b=m[g===0?g:g-1],v=m[g],C=m[g+1],S=m[g+1===m.length-1?g+1:g+2];for(let M=1;M<=c;M++){const w=M/c,I=this._catmullRom(b,v,C,S,w);t.lineTo(y(g+w),f(I))}}else for(let g=1;g<m.length;g++)t.lineTo(y(g),f(m[g]));t.stroke(),u.showPoints&&m.forEach((g,b)=>{const v=y(b),C=f(g);t.beginPath(),t.arc(v,C,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const u=o/2-10;let m=-e/2+15;const g=i.legendFontSize||10,b=g+5;t.font=`${g}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(v=>{const S=v.label||"Series",M=t.measureText(S).width;t.beginPath(),t.rect(u-M-8-5,m-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(S,u,m),m+=b})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,r=s*s,h=s*r;return(2*i-2*o+n+a)*h+(-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,l=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=l,l}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const r=(h,l=100)=>{var C,S;const y=(((S=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:S.colors)||{})[h]||h,d=this.normalizeOpacity(i.opacity??100),u=this.normalizeOpacity(l)*d;if(u>=1&&y.startsWith("#"))return y;const m=y.startsWith("#")?y.replace("#",""):"ffffff",g=parseInt(m.substring(0,2),16),b=parseInt(m.substring(2,4),16),v=parseInt(m.substring(4,6),16);return`rgba(${g}, ${b}, ${v}, ${u})`};if(i.type==="LinearGradient"){const h=(u,m,g)=>Array.isArray(u)?u[m]??(m===0?0:1):u&&typeof u=="object"?u[g]??(m===0?0:1):m===0?0:1,l=h(i.start,0,"x")*o-o/2,f=h(i.start,1,"y")*e-e/2,y=h(i.end,0,"x")*o-o/2,d=h(i.end,1,"y")*e-e/2,c=t.createLinearGradient(l,f,y,d);if(i.stops.forEach(u=>{const m=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,g=r(u.color||"#000000",u.opacity??100);c.addColorStop(Math.max(0,Math.min(1,m)),g)}),i.gradientTransform&&c.setTransform){const[u,m,g,b,v,C]=i.gradientTransform;c.setTransform({a:u,b:m,c:g,d:b,e:v,f:C})}return c}else if(i.type==="RadialGradient"){const h=(c,u,m)=>Array.isArray(c)?c[u]??.5:c&&typeof c=="object"?c[m]??.5:.5,l=h(i.center,0,"x")*o-o/2,f=h(i.center,1,"y")*e-e/2,y=(i.radius??.5)*Math.max(o,e),d=t.createRadialGradient(l,f,0,l,f,y);if(i.stops.forEach(c=>{const u=c.offset!==void 0?c.offset:c.pos!==void 0?c.pos:c.position!==void 0?c.position:0,m=r(c.color||"#000000",c.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),m)}),i.gradientTransform&&d.setTransform){const[c,u,m,g,b,v]=i.gradientTransform;d.setTransform({a:c,b:u,c:m,d:g,e:b,f:v})}return d}else if(i.type==="AngularGradient"){const h=(c,u,m)=>Array.isArray(c)?c[u]??.5:c&&typeof c=="object"?c[m]??.5:.5,l=h(i.center||[.5,.5],0,"x")*o-o/2,f=h(i.center||[.5,.5],1,"y")*e-e/2,y=(i.degree||i.angle||0)*(Math.PI/180),d=(a=t.createConicGradient)==null?void 0:a.call(t,y,l,f);if(d){if(i.stops.forEach(c=>{const u=c.offset!==void 0?c.offset:c.pos!==void 0?c.pos:c.position!==void 0?c.position:0,m=r(c.color||"#000000",c.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),m)}),i.gradientTransform&&d.setTransform){const[c,u,m,g,b,v]=i.gradientTransform;d.setTransform({a:c,b:u,c:m,d:g,e:b,f:v})}return d}}else if(i.type==="DiamondGradient"){const h=(c,u,m)=>Array.isArray(c)?c[u]??.5:c&&typeof c=="object"?c[m]??.5:.5,l=h(i.center||[.5,.5],0,"x")*o-o/2,f=h(i.center||[.5,.5],1,"y")*e-e/2,y=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(l,f),t.rotate(Math.PI/4);const d=t.createRadialGradient(0,0,0,0,0,y);if(i.stops.forEach(c=>{const u=c.offset!==void 0?c.offset:c.pos!==void 0?c.pos:c.position!==void 0?c.position:0,m=r(c.color||"#000000",c.opacity??100);d.addColorStop(Math.max(0,Math.min(1,u)),m)}),i.gradientTransform&&d.setTransform){const[c,u,m,g,b,v]=i.gradientTransform;d.setTransform({a:c,b:u,c:m,d:g,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=d,t.restore(),d}}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 h=t.createPattern(r,"repeat");if(h&&(i.scaleX!==void 0||i.offsetX!==void 0)){const l=new DOMMatrix,f=i.scaleX??1,y=i.scaleY??1,d=i.offsetX??0,c=i.offsetY??0,u=i.rotation??0;l.translateSelf(d,c),l.rotateSelf(u),l.scaleSelf(f,y),h.setTransform(l)}return h}}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,h=0,l=0,f=0;typeof a=="number"?r=h=l=f=a:Array.isArray(a)?a.length===1?r=h=l=f=a[0]:a.length===2?(r=l=a[0],h=f=a[1]):a.length===3?(r=a[0],h=f=a[1],l=a[2]):a.length>=4&&(r=a[0],h=a[1],l=a[2],f=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,h=a.tr??a.corner_radius??a.cornerRadius??0,l=a.br??a.corner_radius??a.cornerRadius??0,f=a.bl??a.corner_radius??a.cornerRadius??0);const y=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(r=Math.min(Math.max(0,r),y),h=Math.min(Math.max(0,h),y),l=Math.min(Math.max(0,l),y),f=Math.min(Math.max(0,f),y),t.roundRect){t.roundRect(i,o,e,s,[r,h,l,f]);return}t.moveTo(i+r,o),t.lineTo(i+e-h,o),t.arcTo(i+e,o,i+e,o+h,h),t.lineTo(i+e,o+s-l),t.arcTo(i+e,o+s,i+e-l,o+s,l),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 O,W,B,A;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((O=i.geometry)==null?void 0:O.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,r=-n/2,h=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,l=e.orientation||"vertical",f=e.items||[],y=e.itemGap??10,d=e.itemHeight??50,c=e.itemWidth??200,u=e.scrollOffset??0,m=e.padding??0,g=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",C=e.itemBackgroundColor||"#ffffff",S=e.hoveredIndex??null,M=e.activeItemIndex??null,w=e.glowIntensity??0,I=e.glowColor||"#3b82f6",_=typeof I=="string"?I:I.color||((A=(B=I.stops)==null?void 0:B[0])==null?void 0:A.color)||"#3b82f6",x=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=x,w>0){const $=t.getTransform(),Y=Math.sqrt($.a*$.a+$.b*$.b)||1;t.shadowColor=_,t.shadowBlur=w*2*Y,t.shadowOffsetX=0,t.shadowOffsetY=0}if(g){const $=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",Y=this.createCanvasFill(t,$,s,n);t.fillStyle=Y||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h)||t.fill();const E=t.createLinearGradient(a,r,a+s,r+n);E.addColorStop(0,"rgba(255, 255, 255, 0.15)"),E.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),E.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=E,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h)||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,h)||t.stroke()}else{const $=e.backgroundColor||e.listBackgroundColor||"transparent",Y=this.createCanvasFill(t,$,s,n);if(Y){t.fillStyle=Y,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);t.fill()}const N=e.borderWidth??0;if(N>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=N,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const F=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,s,n,h);if(e.listLayout!=="circular")if(F&&e.containerShape==="custom")try{const $=new Path2D(e.containerPath);t.translate(a,r),t.scale(s/100,n/100),t.clip($),t.scale(100/s,100/n),t.translate(-a,-r)}catch{}else t.clip();const T=typeof m=="number"?m:l==="vertical"?m[0]:m[3];let P=(l==="vertical"?r:a)+u+T;if(t.textBaseline="middle",f.forEach(($,Y)=>{const N=e.listLayout||"linear",E=N==="circular"?c:l==="vertical"?s:c,k=N==="circular"||l==="vertical"?d:n;let G=0,X=0,J=0;if(N==="circular"){const _t=f.length||1,Nt=Math.PI*2/_t,Q=e.circularStartAngle||0,ct=e.circularRadius||100,Rt=u*.01+Q*Math.PI/180,Ct=Y*Nt+Rt,St=a+s/2,Xt=r+n/2;G=St+Math.cos(Ct)*ct-E/2,X=Xt+Math.sin(Ct)*ct-k/2,J=Ct+(e.itemRotation||0)*Math.PI/180}else G=l==="vertical"?a:P,X=l==="vertical"?P:r,J=(e.itemRotation||0)*Math.PI/180;const tt=S===Y,lt=M===Y,Z=lt&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",pt=lt&&e.activeItemShape?e.activeItemPath:e.itemPath||"",at=e.itemCornerRadius||0;if(t.save(),J!==0&&(t.translate(G+E/2,X+k/2),t.rotate(J),t.translate(-(G+E/2),-(X+k/2))),lt){const _t=this.createCanvasFill(t,b,E,k);t.fillStyle=_t||b;const Nt=t.globalAlpha;t.globalAlpha=Nt*.8,t.beginPath(),this.drawCustomShape(t,Z,pt,G,X,E,k,at)||(t.rect(G,X,E,k),t.fill()),t.globalAlpha=Nt}else if(tt)t.fillStyle=g?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,Z,pt,G,X,E,k,at)||(t.rect(G,X,E,k),t.fill());else if(C!=="transparent"){const _t=this.createCanvasFill(t,C,E,k);t.fillStyle=_t||C,t.beginPath(),this.drawCustomShape(t,Z,pt,G,X,E,k,at)||(t.rect(G,X,E,k),t.fill())}if(lt||tt){const _t=this.createCanvasFill(t,b,l==="vertical"?3:E,l==="vertical"?k:3);t.fillStyle=_t||b,l==="vertical"?t.fillRect(G,X,3,k):t.fillRect(G,X+k-3,E,3)}const Et=lt?"#ffffff":g?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=Et,t.font=lt||tt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const xt=typeof $=="string"?$:($==null?void 0:$.label)||`Item ${Y+1}`,bt=G+(l==="vertical"?16:E/2),Gt=X+k/2;l==="horizontal"||N==="circular"?t.textAlign="center":t.textAlign="left";const Wt=N==="circular"?G+E/2:bt;t.fillText(xt,Wt,Gt),t.restore(),P+=(l==="vertical"?d:c)+y}),t.restore(),e.showScrollbar!==!1){const $=(f.length||0)*(l==="vertical"?d:c)+((f.length||0)-1)*y,Y=l==="vertical"?n:s,N=e.listLayout||"linear",E=e.containerShape==="circle"||N==="circular";if($>Y||N==="circular"&&f.length>0){const k=e.scrollbarColor||"rgba(255,255,255,0.3)",G=e.scrollbarWidth||4;if(E){const X=Math.min(s,n)/2-G/2-2,J=a+s/2,tt=r+n/2;if(t.strokeStyle=k,t.lineWidth=G,t.lineCap="round",t.beginPath(),N==="circular"){const lt=Math.PI/4,Z=-(u*.01)-Math.PI/2;t.arc(J,tt,X,Z,Z+lt)}else{const lt=Math.PI/2,Z=Y/$,pt=lt*Z,at=-u/$*lt,xt=-Math.PI/4+at;t.arc(J,tt,X,xt,xt+pt)}t.stroke()}else{const X=Y/$,J=Y*X,tt=-u/$*Y;t.fillStyle=k,l==="vertical"?t.fillRect(a+s-G-2,r+tt,G,J):t.fillRect(a+tt,r+n-G-2,J,G)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,r){if(i==="circle"){const h=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,h,0,Math.PI*2),!1}else if(i==="pill"){const h=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,h),!1}else if(i==="custom"&&o)try{const h=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(h),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 g,b;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||[],h=i.itemGap??10,l=i.itemHeight??50,f=i.itemWidth??200,y=a.width!==void 0?a.width:((g=t.geometry)==null?void 0:g.width)||200,d=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const c=(r.length||0)*(o==="vertical"?l:f)+((r.length||0)-1)*h,m=Math.max(0,c-(o==="vertical"?d:y)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-m&&(i.scrollOffset=-m)}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 B,A;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:((B=t.geometry)==null?void 0:B.width)||200,r=s.height!==void 0?s.height:((A=t.geometry)==null?void 0:A.height)||300,h=e.orientation||"vertical",l=e.itemGap??10,f=e.itemHeight??50,y=e.itemWidth??200,d=e.scrollOffset??0,c=e.padding??0,u=this.getWorldTransform(t.id),m=i-u.x,g=o-u.y,b=-u.rotation*(Math.PI/180),v=Math.cos(b),C=Math.sin(b),S=m*v-g*C,M=m*C+g*v,w=-a/2,I=-r/2,_=typeof c=="number"?c:h==="vertical"?c[0]:c[3];let x=(h==="vertical"?I:w)+d+_;const F=e.listLayout||"linear",T=n.length||1,P=Math.PI*2/T,L=e.circularStartAngle||0,O=e.circularRadius||100,W=d*.01+L*Math.PI/180;for(let $=0;$<n.length;$++){const Y=F==="circular"?y:h==="vertical"?a:y,N=F==="circular"||h==="vertical"?f:r;let E=0,k=0,G=0;if(F==="circular"){const X=$*P+W,J=w+a/2,tt=I+r/2;E=J+Math.cos(X)*O-Y/2,k=tt+Math.sin(X)*O-N/2,G=X+(e.itemRotation||0)*Math.PI/180}else E=h==="vertical"?w:x,k=h==="vertical"?x:I,G=(e.itemRotation||0)*Math.PI/180;if(G!==0){const X=E+Y/2,J=k+N/2,tt=S-X,lt=M-J,Z=-G,pt=tt*Math.cos(Z)-lt*Math.sin(Z)+X,at=tt*Math.sin(Z)+lt*Math.cos(Z)+J;if(pt>=E&&pt<=E+Y&&at>=k&&at<=k+N)return $}else if(S>=E&&S<=E+Y&&M>=k&&M<=k+N)return $;x+=(h==="vertical"?f:y)+l}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 y,d,c,u,m,g,b,v,C,S,M,w,I,_,x,F,T,P,L,O,W,B,A,$,Y,N,E,k,G,X,J,tt,lt,Z,pt,at,Et,xt,bt,Gt,Wt,_t,Nt,Q,ct,Rt,Ct,St,Xt,te,ee,Zt,Ut,ae,it,dt,U,D,nt,et,Ot,Yt,At,qt,Tt,R,Ft,le,Mt,Jt,It,Dt,Qt,ft,ht,mt,kt,gt,zt,ie,jt,rt,st,ut,Bt,K,vt,yt,pe,Ce,_e,Kt,ce,ve,Me,Ie,ge,de,ue,Se,Pe,Fe,$e,Ee,We,Be,os,as,rs,ls,cs,fs,hs,ds,us,ps,gs,ms;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const h=s.x-i,l=s.y-o,f=Math.sqrt(h*h+l*l);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===z.Proximity){const V=((y=n.settings)==null?void 0:y.radius)||300,q=((d=n.settings)==null?void 0:d.falloff)||"smooth";let H=0;f<V&&(q==="linear"?H=1-f/V:H=Math.pow(1-f/V,2)),n.sensors.forEach(ot=>{this.applyBehaviorSensor(s,ot,H,t,n.settings,e,h,l,f)})}else if(n.type===z.Magnetic){const V=((c=n.settings)==null?void 0:c.radius)||400,q=((u=n.settings)==null?void 0:u.strength)||.5;if(f<V&&f>5){const H=1-f/V,ot=h*H*q,Pt=l*H*q;s.x-=ot*t*10,s.y-=Pt*t*10}}else if(n.type===z.Repel){const V=((m=n.settings)==null?void 0:m.radius)||300,q=((g=n.settings)==null?void 0:g.strength)||1;if(f<V){const H=Math.pow(1-f/V,2);s.x+=h/(f||1)*H*60*q*t*5,s.y+=l/(f||1)*H*60*q*t*5}}else if(n.type===z.Orbit){const V=((b=n.settings)==null?void 0:b.speed)||1,q=((v=n.settings)==null?void 0:v.radius)||30,H=this.currentTime*V*Math.PI*2;s.x+=Math.cos(H)*q*t*5,s.y+=Math.sin(H)*q*t*5,s.rotation+=2*t*5}else if(n.type===z.Vortex){const V=((C=n.settings)==null?void 0:C.radius)||400,q=((S=n.settings)==null?void 0:S.speed)||2,H=((M=n.settings)==null?void 0:M.strength)||1;if(f<V){const ot=Math.pow(1-f/V,1.5),Pt=this.currentTime*q*Math.PI*2,Lt=Math.cos(Pt)*30-h*.4,Vt=Math.sin(Pt)*30-l*.4;s.x+=Lt*ot*H*t*5,s.y+=Vt*ot*H*t*5,s.rotation+=5*ot*H*t*5,s.scale_x*=1-ot*.1*H*t,s.scale_y*=1-ot*.1*H*t}}else if(n.type===z.Fluid){const V=((w=n.settings)==null?void 0:w.radius)||300,q=((I=n.settings)==null?void 0:I.strength)||1;if(f<V){const H=Math.pow(1-f/V,1.2),ot=h/(f||1)*H*1.2*q,Pt=l/(f||1)*H*1.2*q;s.x+=ot*10*t*5,s.y+=Pt*10*t*5,s.scale_x*=1+H*.3*q*t,s.scale_y*=1+H*.3*q*t}}else if(n.type===z.Elastic){const V=((_=n.settings)==null?void 0:_.radius)||300,q=((x=n.settings)==null?void 0:x.strength)||1;if(f<V){const H=1-f/V;s.scale_x*=1+H*.4*q*t,s.scale_y*=1+H*.4*q*t}}else if(n.type===z.Holographic){const V=s.x-this.canvasWidth/2,q=s.y-this.canvasHeight/2,H=((F=n.settings)==null?void 0:F.factor)||25;if(s.x-=V/1e3*H*t*5,s.y-=q/1e3*H*t*5,s.style){const ot=1-Math.min(1,f/400);s.style.exposure=(s.style.exposure||1)+ot*.5*t}}else if(n.type===z.Sticky){const V=((T=n.settings)==null?void 0:T.radius)||80,q=((P=n.settings)==null?void 0:P.strength)||1;if(f<V){const H=Math.pow(1-f/V,2);s.x-=h*H*q*t*10,s.y-=l*H*q*t*10,s.scale_x*=1-H*.1*q*t,s.scale_y*=1-H*.1*q*t}}else if(n.type===z.Dilation){const V=((L=n.settings)==null?void 0:L.size)||120,q=((O=n.settings)==null?void 0:O.strength)||1;if(f<V){const H=1-f/V;s.scale_x*=1+H*.5*q*t,s.scale_y*=1+H*.5*q*t}}else if(n.type===z.Parallax){const V=((W=n.settings)==null?void 0:W.factor)||15,q=((B=n.settings)==null?void 0:B.strength)||1,H=this.canvasWidth/2,ot=this.canvasHeight/2,Pt=this._lastPointerPos||{x:H,y:ot},Lt=(Pt.x-H)/H,Vt=(Pt.y-ot)/ot,re=(((A=e.transform)==null?void 0:A.x)??0)+Lt*V*q,me=((($=e.transform)==null?void 0:$.y)??0)+Vt*V*q,we=(((Y=e.transform)==null?void 0:Y.rotate_x)??0)-Vt*V*1.5*q,fe=(((N=e.transform)==null?void 0:N.rotate_y)??0)+Lt*V*1.5*q,be=Math.min(1,10*t);s.x=this.lerp(s.x??((E=e.transform)==null?void 0:E.x)??0,re,be),s.y=this.lerp(s.y??((k=e.transform)==null?void 0:k.y)??0,me,be),s.rotate_x=this.lerp(s.rotate_x??((G=e.transform)==null?void 0:G.rotate_x)??0,we,be),s.rotate_y=this.lerp(s.rotate_y??((X=e.transform)==null?void 0:X.rotate_y)??0,fe,be)}else if(n.type===z.Fold){if(f<300){const V=1-f/300,q=(h>0?-1:1)*V*10,H=1-V*.1,ot=l/300*V*20,Pt=-(h/300)*V*20,Lt=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((J=e.transform)==null?void 0:J.skew_x)??0,q,Lt),s.scale_y=this.lerp(s.scale_y??((tt=e.transform)==null?void 0:tt.scale_y)??1,(((lt=e.transform)==null?void 0:lt.scale_y)??1)*H,Lt),s.rotate_x=this.lerp(s.rotate_x??((Z=e.transform)==null?void 0:Z.rotate_x)??0,ot,Lt),s.rotate_y=this.lerp(s.rotate_y??((pt=e.transform)==null?void 0:pt.rotate_y)??0,Pt,Lt),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((at=n.settings)==null?void 0:at.opacity)??.5}}}else if(n.type===z.Crumple){if(f<300){const V=1-f/300,q=V*(Math.random()-.5)*5,H=V*(Math.random()-.5)*.05,ot=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((Et=e.transform)==null?void 0:Et.skew_x)??0,q,ot),s.scale_x=this.lerp(s.scale_x??((xt=e.transform)==null?void 0:xt.scale_x)??1,(((bt=e.transform)==null?void 0:bt.scale_x)??1)*(1+H),ot),s.scale_y=this.lerp(s.scale_y??((Gt=e.transform)==null?void 0:Gt.scale_y)??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*(1+H),ot),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((_t=n.settings)==null?void 0:_t.intensity)??1,scale:((Nt=n.settings)==null?void 0:Nt.scale)??2}}}else if(n.type===z.Squash){const V=((Q=n.settings)==null?void 0:Q.strength)||.8;f<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((ct=e.transform)==null?void 0:ct.scale_y)??1)*V,.3),s.scale_x=this.lerp(s.scale_x??1,(((Rt=e.transform)==null?void 0:Rt.scale_x)??1)*(1+(1-V)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((Ct=e.transform)==null?void 0:Ct.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((St=e.transform)==null?void 0:St.scale_x)??1,.2))}else if(n.type===z.TextCounter){const V=((Xt=n.settings)==null?void 0:Xt.duration)||2,q=((te=n.settings)==null?void 0:te.from)||0,H=((ee=n.settings)==null?void 0:ee.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ot=this.currentTime-n._runtimeStart,Pt=Math.min(1,ot/V),Lt=Math.floor(q+(H-q)*Pt);if(((Zt=e.geometry)==null?void 0:Zt.type)==="Text"){const Vt=((Ut=n.settings)==null?void 0:Ut.prefix)||"",re=((ae=n.settings)==null?void 0:ae.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Vt}${Lt}${re}`}}else if(n.type===z.Spotlight){const V=((it=n.settings)==null?void 0:it.radius)||250,q=((dt=n.settings)==null?void 0:dt.strength)||1.5;if(f<V){const H=Math.pow(1-f/V,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(U=e.style)==null?void 0:U.adjustments}),s.style.adjustments.exposure=(((nt=(D=e.style)==null?void 0:D.adjustments)==null?void 0:nt.exposure)||0)+H*q*50}else(et=s.style)!=null&&et.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((Yt=(Ot=e.style)==null?void 0:Ot.adjustments)==null?void 0:Yt.exposure)||0,.1))}else if(n.type===z.Noise||n.type===z.Float){const V=(((At=n.settings)==null?void 0:At.frequency)||((qt=n.settings)==null?void 0:qt.speed)||1)*.002,q=(((Tt=n.settings)==null?void 0:Tt.amplitude)||((R=n.settings)==null?void 0:R.range)||50)*(((Ft=n.settings)==null?void 0:Ft.strength)||1),H=Date.now();s.x+=Math.sin(H*V)*q*t,s.y+=Math.cos(H*V*.8)*q*t,s.rotation+=Math.sin(H*V*.5)*5*t}else if(n.type===z.Pulse){const V=(((le=n.settings)==null?void 0:le.speed)||1)*.005,q=(((Mt=n.settings)==null?void 0:Mt.scale)||1.2)-1,H=Math.sin(Date.now()*V),ot=((Jt=n.settings)==null?void 0:Jt.strength)||1;s.scale_x*=1+H*q*ot*t,s.scale_y*=1+H*q*ot*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,H)*.1*ot*t)}else if(n.type===z.Draggable){const V=((It=n.settings)==null?void 0:It.radius)||150,q=this.draggingBehaviors.has(e.id);if(f<V||q){const H=((Dt=n.settings)==null?void 0:Dt.strength)||1,ot=q?1:Math.max(0,1-f/V);this.applyBehaviorSensor(s,oe.PositionX,ot*H,t,n.settings),this.applyBehaviorSensor(s,oe.PositionY,ot*H,t,n.settings)}}else if(n.type===z.Scroll){const V=((Qt=n.settings)==null?void 0:Qt.axis)||"vertical",q=((ft=n.settings)==null?void 0:ft.factor)||.5,H=((ht=n.settings)==null?void 0:ht.strength)||1,ot=((mt=n.settings)==null?void 0:mt.scaleFactor)||0;(V==="vertical"||V==="both")&&(s.y+=this.scrollOffset.y*q*H*t),(V==="horizontal"||V==="both")&&(s.x+=this.scrollOffset.x*q*H*t),ot!==0&&(s.scale_x*=1+this.scrollOffset.y*ot*t,s.scale_y*=1+this.scrollOffset.y*ot*t)}else if(n.type===z.LookAt){const V=((kt=n.settings)==null?void 0:kt.factor)||1,q=((gt=n.settings)==null?void 0:gt.strength)||1,H=Math.atan2(-l,-h)*(180/Math.PI),ot=s.rotation,Pt=(H-ot+180)%360-180;s.rotation+=Pt*V*q*t*10}else if(n.type===z.Scan){const V=(((zt=n.settings)==null?void 0:zt.speed)||1)*.004,q=((ie=n.settings)==null?void 0:ie.strength)||1,H=(Math.sin(Date.now()*V)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+H*q*t*5),s.x+=(H-.5)*20*q*t}else if(n.type===z.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===z.Ratchet){const V=((rt=n.settings)==null?void 0:rt.steps)||12,q=(((st=n.settings)==null?void 0:st.speed)||1)*30,H=Math.floor(s.rotation/(360/V))*(360/V);s.rotation=this.lerp(s.rotation,H+q*t,.1)}else if(n.type===z.Jitter&&f<300){const V=((ut=n.settings)==null?void 0:ut.strength)||1,q=(((Bt=n.settings)==null?void 0:Bt.intensity)||5)*V;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===z.Follower){const V=(K=n.settings)==null?void 0:K.targetId;if(V){const q=this.objectStates.get(V);if(q){const H=((vt=n.settings)==null?void 0:vt.stiffness)||.1,ot=q.x-s.x,Pt=q.y-s.y;s.x+=ot*H*t*60,s.y+=Pt*H*t*60}}}else if(n.type===z.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===z.Gravity){const V=((yt=n.settings)==null?void 0:yt.strength)||9.8;s.y+=V*t*10}else if(n.type===z.Velocity){const V=((pe=n.settings)==null?void 0:pe.vx)||0,q=((Ce=n.settings)==null?void 0:Ce.vy)||0;s.x+=V*t*10,s.y+=q*t*10}else if(n.type===z.Shear){const V=((_e=n.settings)==null?void 0:_e.strength)||1,q=((Kt=n.settings)==null?void 0:Kt.radius)||300;if(f<q){const H=1-f/q;s.skew_x=this.lerp(s.skew_x||0,(((ce=e.transform)==null?void 0:ce.skew_x)||0)+H*V*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((ve=e.transform)==null?void 0:ve.skew_x)||0,.05)}else if(n.type===z.Lens){const V=((Me=n.settings)==null?void 0:Me.radius)||200,q=((Ie=n.settings)==null?void 0:Ie.strength)||.5;if(f<V){const H=Math.pow(1-f/V,2);s.scale_x=this.lerp(s.scale_x??1,(((ge=e.transform)==null?void 0:ge.scale_x)??1)*(1+H*q),.2),s.scale_y=this.lerp(s.scale_y??1,(((de=e.transform)==null?void 0:de.scale_y)??1)*(1+H*q),.2)}else s.scale_x=this.lerp(s.scale_x??1,((ue=e.transform)==null?void 0:ue.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Se=e.transform)==null?void 0:Se.scale_y)??1,.1)}else if(n.type===z.LayoutAnimation){const V=((Pe=n.settings)==null?void 0:Pe.watchProperties)||["x","y","scale_x","scale_y","skew_x","skew_y","opacity","rotation"],q=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const H=this._layoutAnimCache.get(e.id);for(const ot of V){const Pt=this.getObjectProperty(s,e,ot);if(Pt===void 0)continue;const Lt=H.get(ot);if(!Lt)H.set(ot,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Lt.to!==Pt){const re=this.getObjectProperty(s,e,ot);H.set(ot,{from:re??Lt.from,to:Pt,startTime:this.currentTime,duration:(($e=n.settings)==null?void 0:$e.duration)??q})}const Vt=H.get(ot);if(Vt.duration>0&&Vt.from!==Vt.to){const re=this.currentTime-Vt.startTime,me=Math.min(1,re/Vt.duration),we=this.applyEasing(me,((Ee=n.settings)==null?void 0:Ee.easing)||"easeOutCubic"),fe=Vt.from+(Vt.to-Vt.from)*we;this.setObjectProperty(s,e,ot,fe)}}}else if(n.type===z.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const V=this._layoutAnimCache.get(e.id),q=((We=n.settings)==null?void 0:We.defaultDuration)||.3,H=["x","y","scale_x","scale_y","skew_x","skew_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 ot of H){const Pt=this.getObjectProperty(s,e,ot);if(Pt===void 0||typeof Pt!="number")continue;const Lt=V.get(ot);if(!Lt)V.set(ot,{from:Pt,to:Pt,startTime:this.currentTime,duration:0});else if(Lt.to!==Pt){const re=this.getObjectProperty(s,e,ot);V.set(ot,{from:re??Lt.from,to:Pt,startTime:this.currentTime,duration:q})}const Vt=V.get(ot);if(Vt.duration>0&&Vt.from!==Vt.to){const re=this.currentTime-Vt.startTime,me=Math.min(1,re/Vt.duration),we=this.applyEasing(me,((Be=n.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),fe=Vt.from+(Vt.to-Vt.from)*we;this.setObjectProperty(s,e,ot,fe)}}}else if(n.type===z.SpringChain){const V=((os=n.settings)==null?void 0:os.connections)||[],q=((as=n.settings)==null?void 0:as.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const H=this._springChainState.get(e.id);for(const Pt of V){if(!H.has(Pt.targetId)){const Lt=this.objectStates.get(Pt.targetId);H.set(Pt.targetId,{x:(Lt==null?void 0:Lt.x)??0,y:(Lt==null?void 0:Lt.y)??0,vx:0,vy:0})}H.has(e.id)||H.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ot=H.get(e.id);if(ot){ot.x=s.x,ot.y=s.y;for(const Pt of V){const Lt=H.get(Pt.targetId);if(!Lt)continue;const Vt=Lt.x-ot.x,re=Lt.y-ot.y,me=Math.sqrt(Vt*Vt+re*re)||.001,fe=(me-(Pt.restLength||50))*(Pt.stiffness||.8),be=Vt/me*fe,Ge=re/me*fe;ot.vx+=be*t*10,ot.vy+=Ge*t*10,Lt.vx-=be*t*10,Lt.vy-=Ge*t*10,ot.vx*=1-q*t*10,ot.vy*=1-q*t*10,Lt.vx*=1-q*t*10,Lt.vy*=1-q*t*10;const ye=this.objectStates.get(Pt.targetId);ye&&(ye.x+=Lt.vx*t,ye.y+=Lt.vy*t)}s.x+=ot.vx*t,s.y+=ot.vy*t}}else if(n.type===z.ParticleEmitter){const V=((rs=n.settings)==null?void 0:rs.rate)||10,q=((ls=n.settings)==null?void 0:ls.speed)||100,H=((cs=n.settings)==null?void 0:cs.size)||5,ot=((fs=n.settings)==null?void 0:fs.lifetime)||2,Pt=((hs=n.settings)==null?void 0:hs.gravity)||0,Lt=((ds=n.settings)==null?void 0:ds.color)||"#ffffff",Vt=((us=n.settings)==null?void 0:us.maxParticles)||200,re=(ps=n.settings)!=null&&ps.rateInputId?this.inputs.get(n.settings.rateInputId)??V:V,me=(gs=n.settings)!=null&&gs.gravityInputId?this.inputs.get(n.settings.gravityInputId)??Pt:Pt,we=(ms=n.settings)!=null&&ms.speedInputId?this.inputs.get(n.settings.speedInputId)??q:q;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const fe=this._emitterPools.get(e.id);let be=0;n._pendingBurst&&n._pendingBurst>0&&(be=n._pendingBurst,n._pendingBurst=0);const Ge=Math.floor(re*t)+(be||0);for(let ye=0;ye<Math.min(Ge,Vt-fe.length);ye++){const he=Math.random()*Math.PI*2,ys=we*(.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:ot*(.5+Math.random()*.5),size:H*(.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,h=1){var c,u,m,g,b,v,C,S,M,w,I,_,x,F,T,P,L,O,W,B,A,$,Y,N;const l=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,f=Math.min(1,15*e),y=h>0?a/h:0,d=h>0?r/h:0;switch(i){case oe.Scale:{const E=((c=n==null?void 0:n.transform)==null?void 0:c.scale_x)??1,k=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,G=E*(1+o*l*.4),X=k*(1+o*l*.4);t.scale_x=(t.scale_x??E)*(1-f)+G*f,t.scale_y=(t.scale_y??k)*(1-f)+X*f;break}case oe.Opacity:{const E=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,k=Math.max(0,Math.min(100,E-o*l*100));t.opacity=(t.opacity??E)*(1-f)+k*f;break}case oe.RotateZ:{const E=((g=n==null?void 0:n.transform)==null?void 0:g.rotation)??0,k=E+o*l*45;t.rotation=(t.rotation??E)*(1-f)+k*f;break}case oe.RotateX:{const E=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,k=E-d*o*l*60;t.rotate_x=(t.rotate_x??E)*(1-f)+k*f;break}case oe.RotateY:{const E=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,k=E+y*o*l*60;t.rotate_y=(t.rotate_y??E)*(1-f)+k*f;break}case oe.PositionX:{const E=((C=n==null?void 0:n.transform)==null?void 0:C.x)??0,k=E-y*o*l*40;t.x=(t.x??E)*(1-f)+k*f;break}case oe.PositionY:{const E=((S=n==null?void 0:n.transform)==null?void 0:S.y)??0,k=E-d*o*l*40;t.y=(t.y??E)*(1-f)+k*f;break}case oe.SkewX:{const E=((M=n==null?void 0:n.transform)==null?void 0:M.skew_x)??0,k=E+y*o*l*45;t.skew_x=(t.skew_x??E)*(1-f)+k*f,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case oe.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(w=n==null?void 0:n.style)==null?void 0:w.blur});const E=((_=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:_.amount)||0,k=E+o*((s==null?void 0:s.blur)||20)*l;t.style.blur.amount=(t.style.blur.amount??E)*(1-f)+k*f;break}case oe.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(x=n==null?void 0:n.style)==null?void 0:x.adjustments});const E=((T=(F=n==null?void 0:n.style)==null?void 0:F.adjustments)==null?void 0:T.exposure)||0,k=E+o*((s==null?void 0:s.exposure)||50)*l;t.style.adjustments.exposure=(t.style.adjustments.exposure??E)*(1-f)+k*f;break}case oe.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(P=n==null?void 0:n.style)==null?void 0:P.adjustments});const E=((O=(L=n==null?void 0:n.style)==null?void 0:L.adjustments)==null?void 0:O.hue)||0,k=E+o*((s==null?void 0:s.hue)||180)*l;t.style.adjustments.hue=(t.style.adjustments.hue??E)*(1-f)+k*f;break}case oe.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 E=((A=(B=n==null?void 0:n.style)==null?void 0:B.adjustments)==null?void 0:A.negative)||0,k=E+o*((s==null?void 0:s.negative)||100)*l;t.style.adjustments.negative=(t.style.adjustments.negative??E)*(1-f)+k*f;break}case oe.CornerRadius:{const E=(($=n==null?void 0:n.transform)==null?void 0:$.corner_radius)||0,k=E+o*l*50;t.corner_radius=(t.corner_radius??E)*(1-f)+k*f;break}case oe.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const E=((Y=n==null?void 0:n.style)==null?void 0:Y.borderWidth)||0,k=E+o*l*10;t.style.borderWidth=(t.style.borderWidth??E)*(1-f)+k*f;break}case oe.LetterSpacing:{t.geometry||(t.geometry={});const E=((N=n==null?void 0:n.geometry)==null?void 0:N.letterSpacing)||0,k=E+o*l*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??E)*(1-f)+k*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 h=s[r];if(n[h]===void 0||n[h]===null){const l=i,f=s.slice(0,r+1).reduce((y,d)=>y==null?void 0:y[d],l);n[h]=f!==void 0?{...f}:{}}n=n[h]}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,h=i.naturalHeight,l=r/h,f=s/n;let y=s,d=n,c=o,u=e;a==="cover"?l>f?(y=n*l,c=o-(y-s)/2):(d=s/l,u=e-(d-n)/2):a==="contain"&&(l>f?(d=s/l,u=e+(n-d)/2):(y=n*l,c=o+(s-y)/2)),t.drawImage(i,c,u,y,d)}}const ai=$t.forwardRef(({artboard:p,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:h,onToggle:l,onInputChange:f,onInputFocus:y,onInputBlur:d,onLog:c,onLogicUpdate:u,onButtonClick:m,onGraphPointClick:g,currentTime:b,revision:v=0,scrollY:C,scrollX:S,mouseX:M,mouseY:w,isMouseDown:I,inputs:_,interactive:x=!0,onNavigation:F},T)=>{const P=$t.useRef(null),L=$t.useRef(null);L.current||(L.current=new ns);const O=$t.useRef(void 0),W=$t.useRef(0),B=$t.useRef(null),A=$t.useRef(v),$=$t.useRef(null),[,Y]=$t.useState(p||null),N=$t.useRef(!0);$t.useImperativeHandle(T,()=>P.current),$t.useEffect(()=>(N.current=!0,()=>{N.current=!1,O.current&&cancelAnimationFrame(O.current)}),[]),$t.useEffect(()=>{L.current.setLayout(e,s)},[e,s]),$t.useEffect(()=>{const k=L.current;a&&k.setTriggerCallback(a),r&&k.setInputUpdateCallback((G,X)=>r({[G]:X})),h&&k.setComponentChangeCallback(G=>h(G)),l&&k.setToggleCallback(l),f&&k.setInputChangeCallback(f),y&&k.setInputFocusCallback(y),d&&k.setInputBlurCallback(d),c&&k.setOnLogCallback(G=>c(G,"info")),u&&k.setLogicUpdateCallback(u),m&&k.setButtonClickCallback(m),g&&k.setGraphPointClickCallback(G=>g(G.objectId,G)),F&&k.setNavigationCallback(F)},[a,r,h,l,f,y,d,c,u,m,g,F]),$t.useEffect(()=>{(async()=>{let G=p;if(t&&!p)try{t.startsWith("{")?G=JSON.parse(t):G=await(await fetch(t)).json()}catch(X){console.error("[ExodeUI] Failed to load src:",X)}if(G){const X=L.current,J=G.id||G.name||"default";(B.current!==J||A.current!==v||$.current!==G)&&(X.load(G),B.current=J,A.current=v,$.current=G,Y(G),W.current=0,X.advance(0)),n&&n(X)}})()},[p,t,v]),$t.useEffect(()=>{const k=G=>{if(!L.current||!N.current)return;const X=L.current,J=P.current;if(!J)return;const tt=J.getContext("2d");if(!tt)return;const lt=G/1e3;W.current===0&&(W.current=lt);let Z=lt-W.current;Z>.1&&(Z=.1),W.current=lt;const pt=J.getBoundingClientRect(),at=window.devicePixelRatio||1,Et=Math.round(pt.width*at),xt=Math.round(pt.height*at);(J.width!==Et||J.height!==xt)&&(J.width=Et,J.height=xt);try{o?X.advance(Z):b!==void 0&&X.seek(b),X.render(tt,J.width,J.height)}catch(bt){console.error("[ExodeUICanvas] Error in animation loop:",bt),c&&c(`[Error] Animation loop crashed: ${bt}`,"error")}O.current=requestAnimationFrame(k)};return O.current=requestAnimationFrame(k),()=>{O.current&&cancelAnimationFrame(O.current)}},[o,b]),$t.useEffect(()=>{const k=L.current;C!==void 0&&k.updateInput("scrollY",C),S!==void 0&&k.updateInput("scrollX",S),M!==void 0&&k.updateInput("mouseX",M),w!==void 0&&k.updateInput("mouseY",w),I!==void 0&&k.updateInput("isMouseDown",I),_&&Object.entries(_).forEach(([G,X])=>k.updateInput(G,X))},[C,S,M,w,I,_]);const E=(k,G)=>{if(!x||!P.current)return;k.stopPropagation(),"nativeEvent"in k&&k.nativeEvent&&typeof k.nativeEvent.stopImmediatePropagation=="function"?k.nativeEvent.stopImmediatePropagation():typeof k.stopImmediatePropagation=="function"&&k.stopImmediatePropagation();const X=P.current,J=X.getBoundingClientRect(),tt=k.clientX-J.left,lt=k.clientY-J.top,Z=window.devicePixelRatio||1;(G==="click"||G==="down"||G==="up")&&c&&c(`[Canvas] Pointer ${G} at rect(${Math.round(tt)},${Math.round(lt)}) mapped to buffer(${Math.round(tt*Z)},${Math.round(lt*Z)})`,"info"),L.current.handlePointerInput(G,tt*Z,lt*Z,X.width,X.height)};return se.jsx("canvas",{ref:P,onPointerDown:k=>{var G;E(k,"down"),(G=P.current)==null||G.focus()},onPointerMove:k=>E(k,"move"),onPointerUp:k=>E(k,"up"),onPointerCancel:k=>E(k,"up"),onClick:k=>E(k,"click"),onWheel:k=>{L.current.handleWheel(k.deltaX,k.deltaY)},onKeyDown:k=>L.current.handleKeyDown(k.nativeEvent),onContextMenu:k=>k.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:x?"auto":"none"}})});function ri(){const[p,t]=$t.useState(null),i=$t.useCallback((f,y)=>{p==null||p.setInputBool(f,y)},[p]),o=$t.useCallback((f,y)=>{p==null||p.setInputNumber(f,y)},[p]),e=$t.useCallback(f=>{p==null||p.fireTrigger(f)},[p]),s=$t.useCallback((f,y)=>{p==null||p.setInputText(f,y)},[p]),n=$t.useCallback((f,y)=>{p==null||p.setInputNumberArray(f,y)},[p]),a=$t.useCallback((f,y)=>{p==null||p.setInputStringArray(f,y)},[p]),r=$t.useCallback((f,y)=>{p==null||p.updateObjectOptions(f,y)},[p]),h=$t.useCallback((f,y,d)=>{p==null||p.updateConstraint(f,y,d)},[p]),l=$t.useCallback((f,y)=>{p==null||p.updateGraphData(f,y)},[p]);return{setEngine:t,engine:p,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:h,updateGraphData:l,updateObjectOptions:r}}const li=({artboard:p,config:t})=>{const i={...p.seo,...t},o=i.enableSmartExtraction!==!1;$t.useEffect(()=>{const a=i.title||p.name;a&&(document.title=a);let r=i.description;if(!r&&o){const f=p.objects.filter(y=>{var d;return((d=y.geometry)==null?void 0:d.type)==="Text"}).sort((y,d)=>{var c,u;return(((c=d.geometry.text)==null?void 0:c.length)||0)-(((u=y.geometry.text)==null?void 0:u.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 h=i.ogImage||p.backgroundImage;h&&e("property","og:image",h),a&&e("property","og:title",a),e("property","og:type","website")},[i,p,o]);const e=(a,r,h)=>{let l=document.querySelector(`meta[${a}="${r}"]`);l||(l=document.createElement("meta"),l.setAttribute(a,r),document.head.appendChild(l)),l.setAttribute("content",h)},s=()=>{const a=[];return a.push(se.jsx("h1",{children:i.title||p.name},"artboard-title")),p.objects.forEach((h,l)=>{var f,y;if(!(h.visible===!1||h.isVisible===!1))if(((f=h.geometry)==null?void 0:f.type)==="Text"){const d=h.geometry.text;d&&(h.geometry.fontSize>24?a.push(se.jsx("h2",{children:d},h.id||l)):a.push(se.jsx("p",{children:d},h.id||l)))}else if(((y=h.geometry)==null?void 0:y.type)==="Image"){const d=h.geometry.src,c=h.altText||h.name||"Illustration";a.push(se.jsx("img",{src:d,alt:c},h.id||l))}else h.type==="Button"&&a.push(se.jsx("button",{children:h.name||"Button"},h.id||l))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||p.name,description:i.description,image:i.ogImage||p.backgroundImage,abstract:"Animated interface created with ExodeUI"};return se.jsxs("div",{id:`exode-seo-${p.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),se.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ci={version:"6.3.27"}.version;Ht.BehaviorSensor=oe,Ht.BehaviorType=z,Ht.ConditionOp=Xe,Ht.ExodeSEO=li,Ht.ExodeUICanvas=ai,Ht.ExodeUIEngine=ns,Ht.LogicOp=wt,Ht.RapierPhysics=Ne,Ht.VERSION=ci,Ht.useExodeUI=ri,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})}));