exodeui 6.3.14 → 6.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,30 +1,32 @@
1
- (function(At,Lt){typeof exports=="object"&&typeof module<"u"?Lt(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"],Lt):(At=typeof globalThis<"u"?globalThis:At||self,Lt(At.ExodeUIReact={},At.jsxRuntime,At.React,At.pretext,At.Rapier,At.LZString))})(this,function(At,Lt,xt,Zt,Nt,we){"use strict";var cs=Object.defineProperty;var fs=(At,Lt,xt)=>Lt in At?cs(At,Lt,{enumerable:!0,configurable:!0,writable:!0,value:xt}):At[Lt]=xt;var ot=(At,Lt,xt)=>fs(At,typeof Lt!="symbol"?Lt+"":Lt,xt);function Ce(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const s in h)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(h,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>h[s]})}}return t.default=h,Object.freeze(t)}const Ie=Ce(we);var W=(h=>(h.Proximity="Proximity",h.Magnetic="Magnetic",h.Repel="Repel",h.Orbit="Orbit",h.Vortex="Vortex",h.Fluid="Fluid",h.Elastic="Elastic",h.Holographic="Holographic",h.Sticky="Sticky",h.Dilation="Dilation",h.Parallax="Parallax",h.Noise="Noise",h.Float="Float",h.Pulse="Pulse",h.Draggable="Draggable",h.Scroll="Scroll",h.LookAt="LookAt",h.Glint="Glint",h.Scan="Scan",h.Ratchet="Ratchet",h.Jitter="Jitter",h.Follower="Follower",h.Wrap="Wrap",h.Typewriter="Typewriter",h.Scramble="Scramble",h.Wave="Wave",h.Bounce="Bounce",h.TextTrail="TextTrail",h.Reveal3D="Reveal3D",h.RevealSlide="RevealSlide",h.RevealBlur="RevealBlur",h.TextLiquid="TextLiquid",h.TextVortex="TextVortex",h.TextExplosion="TextExplosion",h.TextRain="TextRain",h.TextGravity="TextGravity",h.TextMatrix="TextMatrix",h.TextNeon="TextNeon",h.TextDissolve="TextDissolve",h.TextOrganic="TextOrganic",h.TextBreathe="TextBreathe",h.TextSpin="TextSpin",h.TextMagnet="TextMagnet",h.TextPerspective="TextPerspective",h.TextMirror="TextMirror",h.TextFloral="TextFloral",h.TextSmoke="TextSmoke",h.TextVariable="TextVariable",h.TextZing="TextZing",h.TextElastic="TextElastic",h.TextGlitch3D="TextGlitch3D",h.GlitchText="GlitchText",h.TextCounter="TextCounter",h.Squash="Squash",h.Spotlight="Spotlight",h.Lens="Lens",h.Gravity="Gravity",h.Velocity="Velocity",h.Shear="Shear",h))(W||{}),Bt=(h=>(h.Scale="Scale",h.Opacity="Opacity",h.RotateZ="RotateZ",h.RotateX="RotateX",h.RotateY="RotateY",h.PositionX="PositionX",h.PositionY="PositionY",h.SkewX="SkewX",h.Blur="Blur",h.Exposure="Exposure",h.HueShift="HueShift",h.Negative="Negative",h.CornerRadius="CornerRadius",h.StrokeWidth="StrokeWidth",h.BoxShadow="BoxShadow",h.FontSize="FontSize",h.LetterSpacing="LetterSpacing",h))(Bt||{}),oe=(h=>(h.Equal="Equal",h.NotEqual="NotEqual",h.GreaterThan="GreaterThan",h.LessThan="LessThan",h.GreaterEqual="GreaterEqual",h.LessEqual="LessEqual",h.IsTrue="IsTrue",h.IsFalse="IsFalse",h))(oe||{}),gt=(h=>(h.AND="AND",h.OR="OR",h.NOT="NOT",h.XOR="XOR",h.OBJECT="OBJECT",h.PROPERTY="PROPERTY",h.GET_PROPERTY="GET_PROPERTY",h.SET_PROPERTY="SET_PROPERTY",h.ADD="ADD",h.SUB="SUB",h.MUL="MUL",h.DIV="DIV",h.MOD="MOD",h.POW="POW",h.ABS="ABS",h.ROUND="ROUND",h.FLOOR="FLOOR",h.CEIL="CEIL",h.SIN="SIN",h.COS="COS",h.TAN="TAN",h.CLAMP="CLAMP",h.REMAP="REMAP",h.EQ="EQ",h.NEQ="NEQ",h.GT="GT",h.LT="LT",h.GTE="GTE",h.LTE="LTE",h.IF_ELSE="IF_ELSE",h.VALUE="VALUE",h.INPUT="INPUT",h.LOG="LOG",h.SCROLL_X="SCROLL_X",h.SCROLL_Y="SCROLL_Y",h.MOUSE_X="MOUSE_X",h.MOUSE_Y="MOUSE_Y",h.IS_MOUSE_DOWN="IS_MOUSE_DOWN",h.EFFECTOR="EFFECTOR",h.MONITOR="MONITOR",h.DELAY="DELAY",h))(gt||{});const Kt=new Map;function ae(h){var A;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:i="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:c=0,paragraphIndent:d=0,textCase:l="none",segments:f=[],enableSegments:g=!1}=h;let u=String(t||"");l==="uppercase"?u=u.toUpperCase():l==="lowercase"?u=u.toLowerCase():l==="capitalize"&&(u=u.replace(/\b\w/g,x=>x.toUpperCase()));const p=`${i} ${e} ${o}px "${s}", sans-serif`,m=`${u}|${p}|${r}|${c}|${d}|${g}|${JSON.stringify(f)}`;let y=Kt.get(m);const S=CanvasRenderingContext2D.prototype.measureText,b=function(x){const B=S.call(this,x);return r!==0&&x&&x.length>0?{...B,width:B.width+(x.length-1)*r}:B};if(!y){try{if(r!==0&&(CanvasRenderingContext2D.prototype.measureText=b),g&&f&&f.length>0){const x=f.map(B=>{let $=B.text||"";const K=B.textCase||l||"none";return K==="uppercase"?$.toUpperCase():K==="lowercase"?$.toLowerCase():K==="capitalize"?$.replace(/\b\w/g,tt=>tt.toUpperCase()):$}).join("");if(y=Zt.prepareWithSegments(x,p),y){let B=0,$=o;for(const K of f){let tt=K.text||"";if(!tt)continue;const rt=K.textCase||l||"none";rt==="uppercase"?tt=tt.toUpperCase():rt==="lowercase"?tt=tt.toLowerCase():rt==="capitalize"&&(tt=tt.replace(/\b\w/g,R=>R.toUpperCase()));const at=K.fontSize||o;at>$&&($=at);const V=`${K.fontStyle||i} ${K.fontWeight||e} ${at}px "${K.fontFamily||s}", sans-serif`,O=Zt.prepareWithSegments(tt,V);if(O&&O.widths)for(let R=0;R<O.widths.length;R++){const P=B+R;if(P<y.widths.length){y.widths[P]=O.widths[R];const J=O.kinds[R];if(J===2){const j=tt[R];j===`
2
- `||j==="\r"?y.kinds[P]=2:y.kinds[P]=0}else y.kinds[P]=J}}B+=tt.length}y.fullText=x,y.maxFontSize=$}}else y=Zt.prepareWithSegments(u,p);y&&Kt.set(m,y)}catch(x){return console.error("[ExodeUI] Pretext prepare failed:",x),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&(CanvasRenderingContext2D.prototype.measureText=S)}if(Kt.size>500){const x=Kt.keys().next().value;x&&Kt.delete(x)}}if(d>0&&y&&y.widths&&!y.indentApplied){const x=[...y.widths],B=y.fullText||u;let $=!0;for(let K=0;K<B.length;K++)$&&x[K]!==void 0&&(x[K]+=d,$=!1),(B[K]===`
3
- `||B[K]==="\r")&&($=!0,B[K]==="\r"&&B[K+1]===`
4
- `&&K++);y={...y,widths:x,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let v=n;typeof v=="string"&&(v=parseFloat(v)),v>5&&o>0&&(v=v/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=b);let w;try{const x=y.maxFontSize||o;if(a>=1e5){const B=u.split(/\r\n|\r|\n/);w={lines:B.map($=>({text:$,width:0})),height:B.length*(v*x),lineCount:B.length}}else w=Zt.layoutWithLines(y,a,v*x)}finally{r!==0&&(CanvasRenderingContext2D.prototype.measureText=S)}let k=(w==null?void 0:w.height)!==void 0&&w.height>0?w.height:(((A=w==null?void 0:w.lines)==null?void 0:A.length)||0)*v*o;if(c>0&&w&&w.lines&&w.lines.length>1){let x=0;const B=y.fullText||t;for(let $=0;$<w.lines.length-1;$++)x+=w.lines[$].text.length,(B[x]===`
5
- `||B[x]==="\r")&&(k+=c,x++,B[x-1]==="\r"&&B[x]===`
6
- `&&x++)}return{width:a,height:k,lineCount:(w==null?void 0:w.lineCount)||0,lines:(w==null?void 0:w.lines)||[]}}function re(h,t,s){let o=String(h||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,c)=>{if(r.endsWith("px")){const d=parseFloat(r);i[c]=d,n-=d}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[c]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((c,d)=>{c.endsWith("fr")&&(i[d]=r*parseFloat(c))})}return i}function le(h,t,s){try{const o=h.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?Me(h,t,s):ke(h,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function ke(h,t,s){var rt,at;const o=h.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,c=e==="vertical",d=t.map(V=>{const O=s(V.id),R=V.geometry;let P=(O==null?void 0:O.width)??R.width??100,J=(O==null?void 0:O.height)??R.height??100;if(R.type==="Ellipse"||R.type==="Polygon"||R.type==="Star"){const j=(O==null?void 0:O.radius)??R.radius??(O==null?void 0:O.outer_radius)??R.outer_radius??50;P=j*2,J=j*2}else if(R.type==="Text"){const j=ae({text:(O==null?void 0:O.text)??R.text??"",fontFamily:R.fontFamily,fontSize:R.fontSize,fontWeight:R.fontWeight,fontStyle:R.fontStyle,lineHeight:R.lineHeight,width:R.width||200,letterSpacing:R.letterSpacing,paragraphSpacing:R.paragraphSpacing,segments:R.segments,enableSegments:R.enableSegments});J=j.height,R.width||(P=j.width)}return P*=V.transform.scale_x||1,J*=V.transform.scale_y||1,{id:V.id,w:P,h:J,original:V}});let l=h.width,f=h.height;const g=((rt=h.layoutProps)==null?void 0:rt.width)==="hug",u=((at=h.layoutProps)==null?void 0:at.height)==="hug",p=[];let m=[],y=0,S=0;const b=l-n.left-n.right,v=f-n.top-n.bottom;d.forEach(V=>{r&&m.length>0&&(c?S+i+V.h>v:y+i+V.w>b)?(p.push({children:m,width:y,height:S}),m=[V],y=V.w,S=V.h):(m.push(V),c?(y=Math.max(y,V.w),S+=(m.length>1?i:0)+V.h):(y+=(m.length>1?i:0)+V.w,S=Math.max(S,V.h)))}),m.length>0&&p.push({children:m,width:y,height:S}),g&&!c&&(l=Math.max(...p.map(V=>V.width),0)+n.left+n.right),u&&c&&(f=Math.max(...p.map(V=>V.height),0)+n.top+n.bottom);const w=[];let k=n.left,A=n.top;const x=a.toLowerCase(),B=x==="center"||x.endsWith("-center"),$=x.endsWith("-right"),K=x==="center"||x.startsWith("center-"),tt=x.startsWith("bottom-");return p.forEach(V=>{let O=k,R=A;c?K?R=n.top+(f-n.top-n.bottom-V.height)/2:tt&&(R=f-n.bottom-V.height):B?O=n.left+(l-n.left-n.right-V.width)/2:$&&(O=l-n.right-V.width),V.children.forEach(P=>{var H,it;let J=O,j=R;c?B?J+=(V.width-P.w)/2:$&&(J+=V.width-P.w):K?j+=(V.height-P.h)/2:tt&&(j+=V.height-P.h);const lt=((H=P.original.layoutProps)==null?void 0:H.width)==="fill",Y=((it=P.original.layoutProps)==null?void 0:it.height)==="fill";w.push({id:P.id,x:J+P.w/2-l/2,y:j+P.h/2-f/2,width:lt&&c?V.width:void 0,height:Y?c?void 0:V.height:void 0}),c?R+=P.h+i:O+=P.w+i}),c?k+=V.width+i:A+=V.height+i}),{frameWidth:g?l:void 0,frameHeight:u?f:void 0,childUpdates:w}}function Me(h,t,s){const o=h.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:c}=o;let d=h.width,l=h.height;const f=d-r.left-r.right,g=l-r.top-r.bottom,u=re(e||"1fr",f,n),p=re(i||"auto",g,a),m=u.length>0?u.reduce(($,K)=>$+K,0)+(u.length-1)*n:0,y=p.length>0?p.reduce(($,K)=>$+K,0)+(p.length-1)*a:0,S=c.toLowerCase(),b=S==="center"||S.endsWith("-center"),v=S.endsWith("-right"),w=S==="center"||S.startsWith("center-"),k=S.startsWith("bottom-");let A=0,x=0;b?A=(f-m)/2:v&&(A=f-m),w?x=(g-y)/2:k&&(x=g-y);const B=[];return t.forEach(($,K)=>{var it,nt;const tt=K%u.length||0,rt=Math.floor(K/u.length)||0;rt>=p.length&&p.push(100);const at=u[tt],V=p[rt];let O=r.left+A+u.slice(0,tt).reduce((ft,M)=>ft+M+n,0),R=r.top+x+p.slice(0,rt).reduce((ft,M)=>ft+M+a,0);const P=s($.id),J=$.geometry;let j=(P==null?void 0:P.width)??J.width??100,lt=(P==null?void 0:P.height)??J.height??100;if(J.type==="Ellipse"||J.type==="Polygon"||J.type==="Star"){const ft=(P==null?void 0:P.radius)??J.radius??(P==null?void 0:P.outer_radius)??J.outer_radius??50;j=ft*2,lt=ft*2}j*=$.transform.scale_x||1,lt*=$.transform.scale_y||1;let Y=O,H=R;b?Y+=(at-j)/2:v&&(Y+=at-j),w?H+=(V-lt)/2:k&&(H+=V-lt),B.push({id:$.id,x:Y+j/2-d/2,y:H+lt/2-l/2,width:((it=$.layoutProps)==null?void 0:it.width)==="fill"?at:void 0,height:((nt=$.layoutProps)==null?void 0:nt.height)==="fill"?V:void 0})}),{childUpdates:B}}class Te{constructor(){ot(this,"world",null);ot(this,"bodies",new Map);ot(this,"colliders",new Map);ot(this,"initialized",!1)}async init(t){this.initialized||(await Nt.init(),this.world=new Nt.World(new Nt.Vector2(t.x,t.y)),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?Nt.RigidBodyDesc.fixed():Nt.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=Nt.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=Nt.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=Nt.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=Nt.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}removeBody(t){const s=this.bodies.get(t);s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){this.world&&this.world.step()}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new Nt.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new Nt.Vector2(s,o),!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new Nt.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new Nt.Vector2(s,o),!0)}}const ce=h=>h,xe=h=>h>0?1:0,_e=h=>h<1?0:1,fe=h=>h*h,he=h=>h*(2-h),de=h=>h<.5?2*h*h:-1+(4-2*h)*h,Ee=h=>h*h*h,Pe=h=>--h*h*h+1,Oe=h=>h<.5?4*h*h*h:(h-1)*(2*h-2)*(2*h-2)+1,Ae=h=>h*h*h*h,Fe=h=>1- --h*h*h*h,$e=h=>h<.5?8*h*h*h*h:1-8*--h*h*h*h,Re=h=>h*h*h*h*h,Le=h=>1+--h*h*h*h*h,We=h=>h<.5?16*h*h*h*h*h:1+16*--h*h*h*h*h,De=h=>1-Math.cos(h*Math.PI/2),Be=h=>Math.sin(h*Math.PI/2),Ve=h=>-(Math.cos(Math.PI*h)-1)/2,Ne=h=>h===0?0:Math.pow(2,10*(h-1)),Ye=h=>h===1?1:1-Math.pow(2,-10*h),Ge=h=>h===0?0:h===1?1:h<.5?Math.pow(2,20*h-10)/2:(2-Math.pow(2,-20*h+10))/2,Xe=h=>1-Math.sqrt(1-h*h),ze=h=>Math.sqrt(1- --h*h),He=h=>h<.5?(1-Math.sqrt(1-4*h*h))/2:(Math.sqrt(1-(-2*h+2)*(-2*h+2))+1)/2,te=1.70158,ee=te*1.525,ue=te+1,Ue=h=>ue*h*h*h-te*h*h,qe=h=>1+ue*Math.pow(h-1,3)+te*Math.pow(h-1,2),Je=h=>h<.5?Math.pow(2*h,2)*((ee+1)*2*h-ee)/2:(Math.pow(2*h-2,2)*((ee+1)*(h*2-2)+ee)+2)/2,pe=2*Math.PI/3,ge=2*Math.PI/4.5,Qe=h=>h===0?0:h===1?1:-Math.pow(2,10*h-10)*Math.sin((h*10-10.75)*pe),Ke=h=>h===0?0:h===1?1:Math.pow(2,-10*h)*Math.sin((h*10-.75)*pe)+1,je=h=>h===0?0:h===1?1:h<.5?-(Math.pow(2,20*h-10)*Math.sin((20*h-11.125)*ge))/2:Math.pow(2,-20*h+10)*Math.sin((20*h-11.125)*ge)/2+1,se=h=>h<1/2.75?7.5625*h*h:h<2/2.75?7.5625*(h-=1.5/2.75)*h+.75:h<2.5/2.75?7.5625*(h-=2.25/2.75)*h+.9375:7.5625*(h-=2.625/2.75)*h+.984375,Ze=h=>1-se(1-h),ts=se,es=h=>h<.5?(1-se(1-2*h))/2:(1+se(2*h-1))/2,ne=new Map,jt=(h,t,s,o)=>{const e=`${h},${t},${s},${o}`;if(ne.has(e))return ne.get(e);const i=d=>(1-3*s+3*h)*d*d*d+(3*s-6*h)*d*d+3*h*d,n=d=>(1-3*o+3*t)*d*d*d+(3*o-6*t)*d*d+3*t*d,a=d=>3*(1-3*s+3*h)*d*d+2*(3*s-6*h)*d+3*h,r=d=>{let l=d;for(let f=0;f<8;f++){const g=i(l)-d;if(Math.abs(g)<1e-6)return l;const u=a(l);if(Math.abs(u)<1e-6)break;l=l-g/u}return l},c=d=>d===0?0:d===1?1:n(r(d));return ne.set(e,c),c},me=h=>{const t=h.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return jt(s,o,e,i)},ye={ease:jt(.25,.1,.25,1),"ease-in":jt(.42,0,1,1),"ease-out":jt(0,0,.58,1),"ease-in-out":jt(.42,0,.58,1)},ie={Linear:ce,EaseInQuad:fe,EaseOutQuad:he,EaseInOutQuad:de,EaseInCubic:Ee,EaseOutCubic:Pe,EaseInOutCubic:Oe,EaseInQuart:Ae,EaseOutQuart:Fe,EaseInOutQuart:$e,EaseInQuint:Re,EaseOutQuint:Le,EaseInOutQuint:We,EaseInSine:De,EaseOutSine:Be,EaseInOutSine:Ve,EaseInExpo:Ne,EaseOutExpo:Ye,EaseInOutExpo:Ge,EaseInCirc:Xe,EaseOutCirc:ze,EaseInOutCirc:He,EaseInBack:Ue,EaseOutBack:qe,EaseInOutBack:Je,EaseInElastic:Qe,EaseOutElastic:Ke,EaseInOutElastic:je,EaseInBounce:Ze,EaseOutBounce:ts,EaseInOutBounce:es,EaseIn:fe,EaseOut:he,EaseInOut:de,StepStart:xe,StepEnd:_e},ss=h=>{const t=h.trim(),s=t.toLowerCase();if(ie[t])return ie[t];const o=Object.keys(ie).find(i=>i.toLowerCase()===s);if(o)return ie[o];const e=Object.keys(be).find(i=>i.toLowerCase()===s);if(e){const i=me(be[e].value);if(i)return i}if(ye[s])return ye[s];if(s.startsWith("cubic-bezier")){const i=me(t);if(i)return i}return ce},be={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}};class ve{constructor(){ot(this,"artboard",null);ot(this,"objectStates",new Map);ot(this,"physicsEngine",null);ot(this,"activeStateMachine",null);ot(this,"inputs",new Map);ot(this,"inputNameMap",new Map);ot(this,"layerStates",new Map);ot(this,"pretextCache",new Map);ot(this,"pointerHistory",[]);ot(this,"MAX_HISTORY",200);ot(this,"imageCache",new Map);ot(this,"lastValidSvgImgMap",new Map);ot(this,"maskBuffer",null);ot(this,"maskCtx",null);ot(this,"lumaBuffer",null);ot(this,"lumaCtx",null);ot(this,"layout",{fit:"Contain",alignment:"Center"});ot(this,"onTrigger");ot(this,"onInputUpdate");ot(this,"onComponentChange");ot(this,"onToggle");ot(this,"onInputChange");ot(this,"onInputFocus");ot(this,"onInputBlur");ot(this,"onLog");ot(this,"onButtonClick");ot(this,"onGraphPointClick");ot(this,"justFiredTriggers",new Set);ot(this,"rootTransform",null);ot(this,"canvasWidth",0);ot(this,"canvasHeight",0);ot(this,"lastHoveredObjectId",null);ot(this,"_lastPointerPos",null);ot(this,"_prevPointerPos",null);ot(this,"focusedId",null);ot(this,"draggingSliderId",null);ot(this,"activeDropdownId",null);ot(this,"activeObjectId",null);ot(this,"draggingListViewId",null);ot(this,"scrollOffset",{x:0,y:0});ot(this,"_totalScroll",{x:0,y:0});ot(this,"draggingBehaviors",new Set);ot(this,"isMouseDown",!1);ot(this,"objectVelocities",new Map);ot(this,"currentTime",0);ot(this,"frameCount",0);ot(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});ot(this,"onLogicUpdate");ot(this,"logicNodeValues",new Map);ot(this,"logicNodeState",new Map);ot(this,"pointerDownTimes",new Map);ot(this,"activeHoverIds",new Set);ot(this,"onNavigation");ot(this,"periodicTriggerTimes",new Map);ot(this,"wasInView",new Set);ot(this,"scrollProgressLastValue",new Map);ot(this,"debug_objectsRendered",0);ot(this,"debug_objectsTotal",0);ot(this,"lastRenderTime",0);ot(this,"debugMode",!1);ot(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,c=0,d=0,l=0,f;for(;(f=s.exec(t))!==null;){const g=f[1],u=(f[2].match(o)||[]).map(parseFloat),p=g===g.toLowerCase(),m=g.toUpperCase();let y=0;const S=v=>{let w=u[y++];return p&&(w+=v?n:a),w},b=()=>({x:S(!0),y:S(!1)});switch(m){case"M":{const v=b();for(d=n=v.x,l=a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<u.length;){const w=b();n=w.x,a=w.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<u.length;){const v=b();n=v.x,a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<u.length;)n=S(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<u.length;)a=S(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<u.length;){const v=b(),w=b(),k=b();if(e.length>0){const A=e[e.length-1];A.out_x=v.x,A.out_y=v.y}n=k.x,a=k.y,e.push({x:n,y:a,in_x:w.x,in_y:w.y,out_x:n,out_y:a}),r=w.x,c=w.y}break;case"S":for(;y<u.length;){const v={x:2*n-r,y:2*a-c},w=b(),k=b();if(e.length>0){const A=e[e.length-1];A.out_x=v.x,A.out_y=v.y}n=k.x,a=k.y,e.push({x:n,y:a,in_x:w.x,in_y:w.y,out_x:n,out_y:a}),r=w.x,c=w.y}break;case"Q":for(;y<u.length;){const v=b(),w=b();if(e.length>0){const k=e[e.length-1];k.out_x=k.x+2/3*(v.x-k.x),k.out_y=k.y+2/3*(v.y-k.y)}n=w.x,a=w.y,e.push({x:n,y:a,in_x:n+2/3*(v.x-n),in_y:a+2/3*(v.y-a),out_x:n,out_y:a}),r=v.x,c=v.y}break;case"T":for(;y<u.length;){const v={x:2*n-r,y:2*a-c},w=b();if(e.length>0){const k=e[e.length-1];k.out_x=k.x+2/3*(v.x-k.x),k.out_y=k.y+2/3*(v.y-k.y)}n=w.x,a=w.y,e.push({x:n,y:a,in_x:n+2/3*(v.x-n),in_y:a+2/3*(v.y-a),out_x:n,out_y:a}),r=v.x,c=v.y}break;case"Z":if(i=!0,e.length>0){const v=e[e.length-1];v.closePath=!0;const w=[...e].reverse().find(k=>k.moveTo)||e[0];w&&Math.hypot(w.x-v.x,w.y-v.y)<.1&&(w.in_x=v.in_x,w.in_y=v.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=d,a=l;break;default:if(u.length>=2){const v=b();n=v.x,a=v.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(c=>{if(e.has(c.id))return;const d={...c},l=d.childrenObjects||[];e.add(d.id),o.push(d),i(l)})};if(i(s.objects||[]),o.length>(s.objects||[]).length&&console.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),console.log(`[ExodeUIEngine] Loading artboard: "${(n=this.artboard)==null?void 0:n.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(c=>{r.set(c.id,c),c.children||(c.children=[])}),this.artboard.objects.forEach(c=>{if(c.parentId){const d=r.get(c.parentId);d&&(d.children||(d.children=[]),d.children.includes(c.id)||d.children.push(c.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{console.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=Ie.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this.artboard.objects.forEach(s=>{var n,a,r,c,d,l,f;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((c=s.geometry)==null?void 0:c.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((d=s.transform)==null?void 0:d.x)??s.x??0,y:((l=s.transform)==null?void 0:l.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((f=s.transform)==null?void 0:f.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new Te;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var i,n;if((i=e.physics)!=null&&i.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,c=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((n=e.geometry)==null?void 0:n.type)||"Rectangle",x:a.x,y:a.y,width:r,height:c,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(),this.loadFonts()}updateAutoLayout(){var e;if(!this.artboard)return;const t=new Map;this.artboard.objects.forEach(i=>t.set(i.id,i));const s=.15,o=i=>{i.forEach(n=>{const a=this.objectStates.get(n.id);if(a){const r=Math.abs(a.x-n.x),c=Math.abs(a.y-n.y);r>20||c>20?(a.x+=(n.x-a.x)*s,a.y+=(n.y-a.y)*s):(a.x=n.x,a.y=n.y),n.width!==void 0&&(a.width=n.width),n.height!==void 0&&(a.height=n.height)}})};if((e=this.artboard.autoLayout)!=null&&e.enabled){const i=this.artboard.objects.filter(a=>!a.parentId),n=le(this.artboard,i,a=>this.objectStates.get(a));o(n.childUpdates)}this.artboard.objects.forEach(i=>{var n;if(i.type==="Frame"&&((n=i.autoLayout)!=null&&n.enabled)&&i.children&&i.children.length>0){const a=i.children.map(d=>t.get(d)).filter(d=>!!d),r=this.objectStates.get(i.id);if(!r)return;const c=le(r,a,d=>this.objectStates.get(d));c.frameWidth!==void 0&&(r.width=c.frameWidth),c.frameHeight!==void 0&&(r.height=c.frameHeight),o(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 s="";t.forEach(n=>{const a=n.replace(/ /g,"+");s+=`&family=${a}:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900`});const o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let i=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const c=a.states.find(d=>d.id===r);if(c){let d=null;c.animationId&&(d=this.artboard.animations.find(l=>l.id===c.animationId)||null),d||(d=this.artboard.animations.find(l=>{var f,g;return l.name===c.name||l.id===c.name||(c.name==="Entry"||c.id==="entry")&&(((f=l.name)==null?void 0:f.toLowerCase())==="onload"||((g=l.name)==null?void 0:g.toLowerCase())==="intro")})||null),d&&((n=this.artboard.animationFlow)!=null&&n.some(f=>(f.trigger==="on_load"||f.trigger==="after_delay")&&f.targetAnimationId===(d==null?void 0:d.id))||(e.push({animation:d,state:c}),i=Math.max(i,d.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")){const i=s.split(".");let n=e;for(let a=0;a<i.length-1;a++)n[i[a]]||(n[i[a]]={}),n=n[i[a]];n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const c=(n=this.activeStateMachine)==null?void 0:n.inputs.find(d=>d.id===t);c&&typeof c.value=="object"&&(o=c.value.type)}else{const c=this.inputNameMap.get(t);if(c&&c.length>0){const d=(a=this.activeStateMachine)==null?void 0:a.inputs.find(l=>l.id===c[0]);d&&typeof d.value=="object"&&(o=d.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(c=>this.setInternalInput(c,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(c=>this.justFiredTriggers.add(c))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(c=>{if(c.inputId===t||c.name===t){const d=this.objectStates.get(c.id);d&&d.options&&(c.type==="ListView"||c.variant==="listview"?d.options.items=e:(c.type==="Dropdown"||c.variant==="dropdown")&&(d.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.conditionValue;let c=!1;switch(a){case"Equal":case"==":c=s==r;break;case"NotEqual":case"!=":c=s!=r;break;case"GreaterThan":case">":c=s>r;break;case"LessThan":case"<":c=s<r;break;case"GreaterEqual":case">=":c=s>=r;break;case"LessEqual":case"<=":c=s<=r;break;case"IsTrue":c=!!s;break;case"IsFalse":c=!s;break}if(c){const d=i.delay||0;d<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),d)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(c=>c.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return console.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,c,d;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(l=>l.id===t);if(e){const l=(g,u)=>{const p=e.inputs.find(m=>m.id===g);return p?p.sourceId?this.evaluateLogicTree(p.sourceId,p.sourceHandleId,o):p.value!==void 0?p.value:u:u};let f=0;switch(e.op){case gt.AND:f=l("a",!1)&&l("b",!1);break;case gt.OR:f=l("a",!1)||l("b",!1);break;case gt.NOT:f=!l("in",!1);break;case gt.XOR:f=!!l("a",!1)!=!!l("b",!1);break;case gt.OBJECT:f=e.name;break;case gt.PROPERTY:case gt.GET_PROPERTY:{const g=l("id","");if(!g){f=0;break}const u=e.name;if(!u||u==="GET_PROPERTY"||u==="PROPERTY"){f=0;break}const p=this.objectStates.get(g);if(!p){f=0;break}u in p?f=p[u]:f=this.resolvePath(p,u);break}case gt.SET_PROPERTY:{const g=l("id",""),u=l("value",void 0);if(!g||u===void 0){f=0;break}const p=e.name;if(!p||p==="SET_PROPERTY"){f=0;break}const m=this.objectStates.get(g);if(!m){f=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(p))m[p]=u,f=u;else{const S=p.split(".");let b=m;for(let w=0;w<S.length-1;w++){const k=S[w];b[k]===void 0&&(b[k]={}),b=b[k]}const v=S[S.length-1];b[v]=u,f=u}break}case gt.ADD:f=l("a",0)+l("b",0);break;case gt.SUB:f=l("a",0)-l("b",0);break;case gt.MUL:f=l("a",0)*l("b",0);break;case gt.DIV:{const g=l("b",1);f=g===0?0:l("a",0)/g;break}case gt.MOD:f=l("a",0)%l("b",1);break;case gt.POW:f=Math.pow(l("a",0),l("b",1));break;case gt.ABS:f=Math.abs(l("in",0));break;case gt.ROUND:f=Math.round(l("in",0));break;case gt.FLOOR:f=Math.floor(l("in",0));break;case gt.CEIL:f=Math.ceil(l("in",0));break;case gt.SIN:f=Math.sin(l("in",0));break;case gt.COS:f=Math.cos(l("in",0));break;case gt.TAN:f=Math.tan(l("in",0));break;case gt.CLAMP:{const g=l("in",0),u=l("min",0),p=l("max",1);f=Math.max(u,Math.min(p,g));break}case gt.REMAP:{const g=l("in",0),u=l("inMin",0),p=l("inMax",100),m=l("outMin",0),y=l("outMax",1);f=p===u?m:m+(g-u)*(y-m)/(p-u);break}case gt.EQ:f=l("a",0)==l("b",0);break;case gt.NEQ:f=l("a",0)!=l("b",0);break;case gt.GT:f=l("a",0)>l("b",0);break;case gt.LT:f=l("a",0)<l("b",0);break;case gt.GTE:f=l("a",0)>=l("b",0);break;case gt.LTE:f=l("a",0)<=l("b",0);break;case gt.IF_ELSE:f=l("cond",!1)?l("then",0):l("else",0);break;case gt.VALUE:f=e.value!==void 0?e.value:0;break;case gt.INPUT:f=this.inputs.get(e.name)??0;break;case gt.LOG:{const g=l("in","");this.debugLog(`[User Logic] ${g}`),f=g;break}case gt.SCROLL_X:f=this.inputs.get("scrollX")??0;break;case gt.SCROLL_Y:f=this.inputs.get("scrollY")??0;break;case gt.MOUSE_X:f=this.inputs.get("mouseX")??0;break;case gt.MOUSE_Y:f=this.inputs.get("mouseY")??0;break;case gt.IS_MOUSE_DOWN:f=this.inputs.get("isMouseDown")??!1;break;case gt.EFFECTOR:{const g=l("id",""),u=l("intensity",1),p=l("trigger",!0);if(!g||!p){f=0;break}const m=e.name;if(!m){f=0;break}const y=this.objectStates.get(g);if(!y){f=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(m))y.style||(y.style={}),y.style.artEffect={enabled:!0,type:m,intensity:u},f=1;else{y.behaviors||(y.behaviors=[]);let b=y.behaviors.find(v=>v.type===m);b?(b.enabled=!0,b.settings||(b.settings={}),b.settings.intensity=u):(b={id:`eff_${Date.now()}_${m}`,type:m,enabled:!0,sensors:[],settings:{intensity:u}},y.behaviors.push(b)),f=1}break}case gt.MONITOR:{f=l("in",0);break}default:f=0;break}if(this.logicNodeValues.set(t,f),e.op===gt.DELAY){const g=l("delay",0),u=l("in",0);let p=this.logicNodeState.get(t);for(p||(p={queue:[]},this.logicNodeState.set(t,p)),p.queue.push({time:this.currentTime+g,value:u});p.queue.length>0&&p.queue[0].time<=this.currentTime;)p.lastValue=p.queue.shift().value;f=p.lastValue??0}return f}const i=(c=this.activeStateMachine)==null?void 0:c.inputs.find(l=>l.id===t||l.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const l=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,l),l}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const l=(d=this.activeStateMachine)==null?void 0:d.inputs.find(f=>f.id===t);if(l&&l.value.type==="Number"&&typeof n=="number"){const f=l.value.defaultValue??l.value.value;if(s==="source-greater")return n>f;if(s==="source-less")return n<f;if(s==="source-equal")return n===f}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===gt.SET_PROPERTY||t.op===gt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(console.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{this.applyAnimation(i.animation,o.time,i.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var i,n,a,r,c,d,l;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(f=>f.id===e))==null?void 0:n.triggers)==null||a.find(f=>f.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 f=(d=(c=(r=this.artboard)==null?void 0:r.objects.find(p=>p.id===e))==null?void 0:c.triggers)==null?void 0:d.find(p=>p.id===o.triggerId),g=(f==null?void 0:f.duration)||0;o.elapsedHold+=t*1e3;let u=o.elapsedHold>=g;if((f==null?void 0:f.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(u=!0),((f==null?void 0:f.eventType)==="onHold"||(f==null?void 0:f.eventType)==="pointerDown")&&!this.isMouseDown&&(u=!0),u)if(f!=null&&f.exitAnimationId){const p=(l=this.artboard)==null?void 0:l.animations.find(m=>m.id===f.exitAnimationId);p?(o.phase="exit",o.animation=p,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t)}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,i,n;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),c=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),d=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),l=50,f=r.x+c/2>=-this.canvasWidth/2-l&&r.x-c/2<=this.canvasWidth/2+l&&r.y+d/2>=-this.canvasHeight/2-l&&r.y-d/2<=this.canvasHeight/2+l,g=`analytics_${s.id}`,u=this.wasInView.has(g);f&&!u&&this.fireAnalyticsEvent(s.id,"visible"),f?this.wasInView.add(g):this.wasInView.delete(g)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,c,d;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const l=e.intervalValue||2e3,f=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-f>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const l=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=l&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const l=this.objectStates.get(s.id);if(l&&l.visible!==!1){const f=this.getGlobalTransform(s.id),g=(((r=s.geometry)==null?void 0:r.width)||100)*(f.scale_x||1),u=(((c=s.geometry)==null?void 0:c.height)||100)*(f.scale_y||1),p=50,m=f.x+g/2>=-this.canvasWidth/2-p&&f.x-g/2<=this.canvasWidth/2+p&&f.y+u/2>=-this.canvasHeight/2-p&&f.y-u/2<=this.canvasHeight/2+p,y=this.wasInView.has(s.id);m&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),m?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const l=Math.abs(this.scrollOffset.y)/(((d=this.artboard)==null?void 0:d.height)||1e3),f=this.scrollProgressLastValue.get(e.id)||0;Math.abs(l-f)>.001&&(this.scrollProgressLastValue.set(e.id,l),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,l))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((i,n)=>{var d,l,f,g,u,p,m,y,S;const a=((d=o.constraints)==null?void 0:d[n])||{},r={...i,...a},c=r.strength??1;if(r.type==="Translation"){const b=this.getGlobalTransform(r.targetId);if(b){const v=r.offsetX||0,w=r.offsetY||0,k=b.x+v,A=b.y+w;if(r.useSpring){const B=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:$,y:K,vx:tt,vy:rt}=this.computeSpring(e.x,e.y,B.vx,B.vy,k,A,r,t);r.copyX&&(e.x=e.x+($-e.x)*c),r.copyY&&(e.y=e.y+(K-e.y)*c),this.objectVelocities.set(s.id,{vx:tt,vy:rt})}else r.copyX&&(e.x=e.x+(k-e.x)*c),r.copyY&&(e.y=e.y+(A-e.y)*c);(l=r.limitX)!=null&&l.enabled&&(e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x))),(f=r.limitY)!=null&&f.enabled&&(e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)))}}else if(r.type==="Rotation"){const b=this.getGlobalTransform(r.targetId);if(b){let w=(b.rotation+(r.offset||0)-e.rotation)%360;w>180&&(w-=360),w<-180&&(w+=360),e.rotation=e.rotation+w*c}}else if(r.type==="Scale"){const b=this.getGlobalTransform(r.targetId);b&&(r.copyX&&(e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*c),r.copyY&&(e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*c))}else if(r.type==="Transform"){const b=this.getGlobalTransform(r.targetId);if(b){e.x=e.x+(b.x-e.x)*c,e.y=e.y+(b.y-e.y)*c;let v=(b.rotation-e.rotation)%360;v>180&&(v-=360),v<-180&&(v+=360),e.rotation=e.rotation+v*c,e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*c,e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*c}}else if(r.type==="FollowPointer"){const b=((g=this._lastPointerPos)==null?void 0:g.x)??e.x,v=((u=this._lastPointerPos)==null?void 0:u.y)??e.y;if(r.useSpring){const k=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:A,y:x,vx:B,vy:$}=this.computeSpring(e.x,e.y,k.vx,k.vy,b,v,r,t);e.x=A,e.y=x,this.objectVelocities.set(s.id,{vx:B,vy:$})}else e.x=e.x+(b-e.x)*c,e.y=e.y+(v-e.y)*c;(p=r.limitX)!=null&&p.enabled&&(e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x))),(m=r.limitY)!=null&&m.enabled&&(e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)))}else if(r.type==="Distance"){const b=this.getGlobalTransform(r.targetId);if(b){const v=e.x-b.x,w=e.y-b.y,k=Math.sqrt(v*v+w*w),A=r.distance||0;let x=k;switch(r.mode){case"exact":x=A;break;case"minimum":x=Math.max(A,k);break;case"maximum":x=Math.min(A,k);break;case"clamped":x=Math.max(0,Math.min(A,k));break}if(k>0){const B=e.x===b.x&&e.y===b.y?1:x/k;e.x=e.x+(b.x+v*B-e.x)*c,e.y=e.y+(b.y+w*B-e.y)*c}}}else if(r.type==="FollowPath"){const b=(y=this.artboard)==null?void 0:y.objects.find(v=>v.id===r.targetId);if(b){const v=this.getGlobalTransform(b.id);if(v){let w=b.geometry;if(b.type==="Frame"||b.type==="Group"||!w||w.type!=="Path"&&w.type!=="Ellipse"&&w.type!=="Rectangle"){const H=(S=this.artboard)==null?void 0:S.objects.find(it=>it.parentId===b.id&&it.type==="Shape"&&it.geometry&&(it.geometry.type==="Path"||it.geometry.type==="Ellipse"||it.geometry.type==="Rectangle"));H&&(w=H.geometry)}if(!w)return;const k=(r.distance||0)/100,A=v.width||w.width||0,x=v.height||w.height||0,B=this.getPointOnPath(w,A,x,k),$=v.rotation*Math.PI/180,K=Math.cos($),tt=Math.sin($),rt=B.x*v.scale_x*K-B.y*v.scale_y*tt,at=B.x*v.scale_x*tt+B.y*v.scale_y*K;let V=v.rotation+(r.offsetRotation||0);if(r.orient){const H=Math.cos(B.angle),it=Math.sin(B.angle),nt=H*v.scale_x*K-it*v.scale_y*tt,ft=H*v.scale_x*tt+it*v.scale_y*K;V=Math.atan2(ft,nt)*180/Math.PI+(r.offsetRotation||0)}const O=V*Math.PI/180,R=Math.cos(O),P=Math.sin(O),J=(r.offsetX||0)*R-(r.offsetY||0)*P,j=(r.offsetX||0)*P+(r.offsetY||0)*R,lt=v.x+rt+J,Y=v.y+at+j;if(e.x=e.x+(lt-e.x)*c,e.y=e.y+(Y-e.y)*c,r.orient){let H=(V-e.rotation)%360;H>180&&(H-=360),H<-180&&(H+=360),e.rotation=e.rotation+H*c}}}}else if(r.type==="IK"){const b=this.getGlobalTransform(r.targetId);b&&this.solveIK(s,b,r.boneCount||2,c)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var d;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(d=this.artboard)==null?void 0:d.objects.find(l=>l.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1)};const e=this.getGlobalTransform(o.parentId),i=e.rotation*Math.PI/180,n=Math.cos(i),a=Math.sin(i),r=e.x+(s.x*e.scale_x*n-s.y*e.scale_y*a),c=e.y+(s.x*e.scale_x*a+s.y*e.scale_y*n);return{x:r,y:c,rotation:e.rotation+s.rotation,scale_x:e.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:e.scale_y*(s.scale_y??1)*(s.flip_y?-1:1)}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),c=s.x-o.x,d=s.y-o.y,l=(c*a-d*r)*e,f=(c*r+d*a)*i;return{x:l,y:f,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var c;const i=[];let n=t.id;for(let d=0;d<o&&n;d++){const l=(c=this.artboard)==null?void 0:c.objects.find(f=>f.id===n);if(!l)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=l.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let d=0;d<r;d++){const l=this.getGlobalTransform(t.id);for(let f=a.length-2;f>=0;f--){const g=a[f],u=this.getGlobalTransform(g.id),p=l.x-u.x,m=l.y-u.y,y=s.x-u.x,S=s.y-u.y,b=Math.sqrt(p*p+m*m),v=Math.sqrt(y*y+S*S);if(b>.001&&v>.001){const w=Math.atan2(m,p);let A=(Math.atan2(S,y)-w)*180/Math.PI;A*=e;const x=this.objectStates.get(g.id);x&&(x.rotation+=A)}}}}computeSpring(t,s,o,e,i,n,a,r){const c=a.stiffness??100,d=a.damping??10,l=a.mass??1,f=-c*(t-i),g=-c*(s-n),u=-d*o,p=-d*e,m=(f+u)/l,y=(g+p)/l,S=o+m*r,b=e+y*r,v=t+S*r,w=s+b*r;return{x:v,y:w,vx:S,vy:b}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX-this.artboard.width/2,r=(o-n.ty)/n.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,s){this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,c,d,l,f;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const i=(g,u)=>{var v;let p=u;u==="click"?p="onClick":u==="down"?p="onPointerDown":u==="up"?p="onPointerUp":u==="blur"&&(p="onPointerLeave");const m=new Set([p]);u==="move"&&m.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),p==="onClick"&&m.add("click"),p==="onPointerDown"&&m.add("pointerDown"),p==="onPointerUp"&&m.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider"];return!!(g.type==="Component"&&y.includes(g.variant)||y.includes((v=g.type)==null?void 0:v.toLowerCase())||(g.interactions||[]).some(w=>m.has(w.event))||(g.triggers||[]).some(w=>m.has(w.eventType)))};let n=null;for(let g=this.artboard.objects.length-1;g>=0;g--){const u=this.artboard.objects[g],p=this.objectStates.get(u.id);if(p&&p.visible!==!1&&p.opacity>0&&this.hitTest(u,s,o)&&(n||(n=u),i(u,t))){e=u;break}}!e&&n&&(e=n),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const g=this.artboard.objects.find(u=>u.id===this.draggingSliderId);g&&this.updateSliderValueFromPointer(g,s,o);return}if(this.draggingListViewId){const g=this.artboard.objects.find(u=>u.id===this.draggingListViewId);g&&this.updateListViewScrollFromPointer(g);return}e&&e.type==="Component"&&e.variant==="listview"&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(g=>g.type===W.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(g=>{g!==a&&this.activeHoverIds.delete(g)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const g=this.artboard.objects.find(u=>u.id===this.activeDropdownId);if(g&&(g.type==="Dropdown"||g.variant==="dropdown")){const u=this.objectStates.get(g.id),p=(u==null?void 0:u.options)||g.options||{},m=g.geometry||{},y=m.width??g.width??200,S=m.height??g.height??40,b=p.optionsList||[],v=p.itemHeight||32,w=p.listPadding??4,k=b.length*v+w*2,A=this.getWorldTransform(g.id),x=y*Math.abs(A.scaleX),B=S*Math.abs(A.scaleY),$=A.y+B/2+4,K=Math.abs(s-A.x)<=x/2,tt=o>=$&&o<=$+k*Math.abs(A.scaleY);if(K&&tt){const rt=Math.abs(A.scaleY),at=o-($+w*rt),V=Math.floor(at/(v*rt));if(V>=0&&V<b.length){const O=b[V];p.selectedOption=O,p.isOpen=!1,this.activeDropdownId=null,g.inputId&&this.setInternalInput(g.inputId,O),this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"dropdown",property:"selectedOption",value:O})}return}else a!==this.activeDropdownId&&(p.isOpen=!1,this.activeDropdownId=null)}}if(e){let g=e,u=e;for(;u&&u.parentId;){const m=this.artboard.objects.find(y=>y.id===u.parentId);if(m&&m.type==="Component"){g=m;break}u=m}let p=t;if(t==="click"?p="onClick":t==="down"?p="onPointerDown":t==="up"?p="onPointerUp":t==="blur"&&(p="onPointerLeave"),this.fireEventForObject(e.id,p),g!==e&&this.fireEventForObject(g.id,p),g.type==="Component"&&g.variant==="toggle_button"&&t==="down"){const m=this.objectStates.get(g.id),y=(m==null?void 0:m.options)||g.options||{};y.checked=!y.checked,g.inputId&&this.setInternalInput(g.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(g.id,"Toggle"),this.fireEventForObject(g.id,y.checked?"Toggle True":"Toggle False")}if(g.type==="Component"&&g.variant==="toggle"&&t==="down"){const m=this.objectStates.get(g.id),y=(m==null?void 0:m.options)||g.options||{};y.checked=!y.checked,g.inputId&&this.setInternalInput(g.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(g.name,y.checked),this.fireEventForObject(g.id,"Toggle"),this.fireEventForObject(g.id,y.checked?"Toggle True":"Toggle False")}if(g.type==="Component"&&g.variant==="dropdown"&&t==="down"){const m=this.objectStates.get(g.id),y=(m==null?void 0:m.options)||g.options||{},S=!y.isOpen;if(S&&this.activeDropdownId&&this.activeDropdownId!==g.id){const b=this.artboard.objects.find(v=>v.id===this.activeDropdownId);b&&b.options&&(b.options.isOpen=!1)}y.isOpen=S,this.activeDropdownId=S?g.id:null}if(g.type==="Component"&&g.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(g.name,g.id),this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"button",property:"click",value:!0})),g.type==="Component"&&g.variant==="listview"&&t==="down"){this.draggingListViewId=g.id;const m=this.getListViewItemIndexAtPointer(g,s,o);if(m!==null){const y=g.options||{};y.activeItemIndex=m;const S=this.objectStates.get(g.id);S&&S.options&&(S.options.activeItemIndex=m);const b=(y.items||[])[m],v=typeof b=="string"?b:b.label||b.value||m;S&&S.options&&(S.options.selectedValue=v),g.inputId&&this.setInternalInput(g.inputId,v),this.onComponentChange&&(this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"activeItemIndex",value:m}),this.onComponentChange({objectId:g.id,componentName:g.name,variant:"listview",property:"selected",value:v}))}}if(g.type==="Component"&&g.variant==="slider"&&t==="down"&&(this.draggingSliderId=g.id,this.updateSliderValueFromPointer(g,s,o)),g.type==="LineGraph"&&(t==="down"||t==="click")){const m=g.geometry,y=(m==null?void 0:m.datasets)||[],S=this.objectStates.get(g.id),b=(S==null?void 0:S.width)||(m==null?void 0:m.width)||200,v=(S==null?void 0:S.height)||(m==null?void 0:m.height)||150,w=this.getWorldTransform(g.id),k=30,A=20,x=b-k,B=v-A;let $=1;y.forEach(rt=>{const at=Math.max(...rt.data||[0]);at>$&&($=at)});let K=1/0,tt=null;y.forEach((rt,at)=>{const V=rt.data||[],O=x/Math.max(V.length-1,1);V.forEach((R,P)=>{const J=w.x-b/2+k+P*O,j=w.y+v/2-A-R/$*B,lt=Math.sqrt((s-J)**2+(o-j)**2);lt<K&&(K=lt,tt={dIdx:at,pIdx:P,val:R,label:rt.label||`Dataset ${at+1}`})})}),tt&&K<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:g.id,componentName:g.name,datasetIndex:tt.dIdx,pointIndex:tt.pIdx,value:tt.val,label:tt.label}),this.onComponentChange&&this.onComponentChange({objectId:g.id,componentName:g.name,variant:"linegraph",property:"click",value:(tt==null?void 0:tt.val)??null})}if(t==="click"){const m=(c=this.artboard)==null?void 0:c.objects.find(b=>b.id===e.id),y=this.focusedId,S=(m==null?void 0:m.type)==="InputBox"||(m==null?void 0:m.type)==="Component"&&m.variant==="inputbox";if(m&&S){if(this.focusedId=e.id,console.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const b=(d=this.artboard)==null?void 0:d.objects.find(v=>v.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}this.onInputFocus&&this.onInputFocus(m.name)}}else if(this.focusedId=null,y){const b=(l=this.artboard)==null?void 0:l.objects.find(v=>v.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}}}else if(t==="click"){const g=this.focusedId;if(this.focusedId=null,g){const u=(f=this.artboard)==null?void 0:f.objects.find(p=>p.id===g);u&&this.onInputBlur&&this.onInputBlur(u.name)}}}handleKeyDown(t){if(!this.artboard||!this.focusedId)return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
7
- `;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}fireEventForObject(t,s){var d,l,f,g,u;const o=(d=this.artboard)==null?void 0:d.objects.find(p=>p.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(p=>{const m=p.triggers||[p.event||p.trigger||"click"];return((p.triggerLogic||"OR")==="AND"?m.every(b=>e.has(b.toLowerCase())):m.some(b=>e.has(b.toLowerCase())))?p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):!0:!1});if(a){if(console.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let p=a.value||a.inputValue;p==="toggle"&&(p=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,p)}else if(a.action==="Toggle Boolean"){const p=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!p)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const p=a.targetObjectId||o.id,m=a.targetProperty;m&&this.updateObjectProperty(p,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const p=a.targetAnimationId;p==="__all__"?(f=(l=this.artboard)==null?void 0:l.animations)==null||f.forEach(m=>{this.triggerGlobalAnimation(m.id,a.subAnimationIds)}):p&&this.triggerGlobalAnimation(p,a.subAnimationIds)}else if(a.action==="setState"||a.action==="Set State"){const p=a.targetObjectId||o.id,y={...this.objectStates.get(p)||{},...a.value||{}};this.objectStates.set(p,y),console.log(`[Engine] State updated for ${p}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const p=a.targetAnimationId;p==="__all__"?this.layerStates.forEach((m,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):p&&this.layerStates.forEach((m,y)=>{y.startsWith(`global_${p}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const p=a.targetState,m=this.activeStateMachine.layers.find(y=>y.states.some(S=>S.id===p||S.name===p));m&&(console.log(`[Engine] Switching Layer ${m.name} to State ${p}`),this.enterStates(m.name,[p]))}this.onTrigger&&this.onTrigger(s,a.action)}const c=(o.triggers||[]).find(p=>{const m=p.eventType.toLowerCase();let y=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&p.conditions&&p.conditions.length>0?this.checkConditions(p.conditions):y});if(c&&c.entryAnimationId){console.log(`[Engine] Trigger matched: ${s} (as ${c.eventType}) -> Animation ${c.entryAnimationId}`);const p=(u=(g=this.artboard)==null?void 0:g.animations)==null?void 0:u.find(m=>m.id===c.entryAnimationId);p&&(this.activeTriggers.set(o.id,{triggerId:c.id,animation:p,time:0,phase:"entry",elapsedHold:0,filterObjectId:c.targetObjectId}),this.onTrigger&&this.onTrigger(c.name,p.name))}}fireAnalyticsEvent(t,s){var r,c;const o=(r=this.artboard)==null?void 0:r.objects.find(d=>d.id===t);if(!o)return;const e=(c=o.style)==null?void 0:c.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(d=>{if(d.type==="literal")n[d.key]=d.value;else if(d.type==="variable"){const l=this.inputs.get(d.value);n[d.key]=l!==void 0?l:""}}),console.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const d=window;typeof d.gtag=="function"?(d.gtag("event",i,n),console.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const d=window;typeof d.fbq=="function"?(d.fbq("track",i,n),console.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const d=window;d.mixpanel&&typeof d.mixpanel.track=="function"?(d.mixpanel.track(i,n),console.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var f;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(f=this.artboard)==null?void 0:f.objects.find(g=>g.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,c=s.y*e.scaleY,d=e.x+(r*n-c*a),l=e.y+(r*a+c*n);return{x:d,y:l,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var b,v;if(!this.objectStates.get(t.id))return!1;const i=((b=t.geometry)==null?void 0:b.width)??t.width??100,n=((v=t.geometry)==null?void 0:v.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,c=o-a.y,d=-a.rotation*(Math.PI/180),l=Math.cos(d),f=Math.sin(d),g=r*l-c*f,u=r*f+c*l,p=a.scaleX,m=a.scaleY,y=i*Math.abs(p),S=n*Math.abs(m);return Math.abs(g)<=y/2&&Math.abs(u)<=S/2}updateSliderValueFromPointer(t,s,o){var A;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((A=t.geometry)==null?void 0:A.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,c=o-a.y,d=-a.rotation*(Math.PI/180),l=Math.cos(d),f=Math.sin(d),g=r*l-c*f,u=i.thumbWidth??16,p=n-u;let y=(g+p/2)/p;y=Math.max(0,Math.min(1,y));const S=i.min??0,b=i.max??100,v=i.step||1;let w=S+y*(b-S);v>0&&(w=Math.round(w/v)*v),w=Math.max(S,Math.min(b,w));const k=e.options||{};k.value!==w&&(e.options={...k,value:w},t.inputId&&this.setInternalInput(t.inputId,w),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:w}))}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var l,f,g;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(l=this.artboard)==null?void 0:l.objects.find(u=>u.id===i),a=((f=n==null?void 0:n.physics)==null?void 0:f.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const c=this.objectStates.get(i);if(!c){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const d=this.interpolate(e.keyframes,s);if(d!==void 0){if(this.frameCount%240===0){const u=(n==null?void 0:n.name)||i,p=typeof d=="object"?JSON.stringify(d).slice(0,50):d;this.debugLog(`[Anim] Applying ${r} = ${p} to ${u}`)}if(r.includes(".")){const u=(r||"").split(".");let p=c;for(let m=0;m<u.length-1;m++){if(typeof p[u[m]]!="object"||p[u[m]]===null){let y=n;for(let S=0;S<=m;S++)y=y?y[u[S]]:null;if(u[m]==="corner_radius"||u[m]==="cornerRadius"){const S=typeof p[u[m]]=="number"?p[u[m]]:typeof y=="number"?y:0;p[u[m]]={tl:S,tr:S,bl:S,br:S}}else p[u[m]]=y?JSON.parse(JSON.stringify(y)):{}}p=p[u[m]]}p[u[u.length-1]]=d,u[u.length-1]==="color"&&(u[u.length-2]==="fill"||u[u.length-2]==="stroke")&&(p.type="Solid")}else r==="fill"?(c.style||(c.style={}),c.style.fill=d):r==="stroke"?(c.style||(c.style={}),c.style.stroke=d):c[r]=d;if(this.physicsEngine&&((g=n==null?void 0:n.physics)!=null&&g.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const u=this.physicsEngine.getPosition(i);u&&this.physicsEngine.setPosition(i,d,u.y)}else if(r==="y"){const u=this.physicsEngine.getPosition(i);u&&this.physicsEngine.setPosition(i,u.x,d)}else r==="rotation"&&this.physicsEngine.setRotation(i,d*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const i=e.time-o.time;let n=(s-o.time)/i;if(o.easing&&(n=ss(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const c=e.value[r];return typeof a=="number"&&typeof c=="number"?a+(c-a)*n:n<.5?a:c}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(c=>{const d=o.value[c],l=e.value[c];typeof d=="number"&&typeof l=="number"?a[c]=d+(l-d)*n:d===void 0?a[c]=l:l===void 0?a[c]=d:a[c]=n<.5?d:l}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,s,o){var u,p;const e=((p=(u=this.artboard)==null?void 0:u.tokens)==null?void 0:p.colors)||{},i=e[t]||t,n=e[s]||s,a=m=>{if(!m)return{r:0,g:0,b:0};const y=m.startsWith("#")?m.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},r=a(i),c=a(n),d=Math.round(r.r+(c.r-r.r)*o),l=Math.round(r.g+(c.g-r.g)*o),f=Math.round(r.b+(c.b-r.b)*o),g=m=>{const y=Math.max(0,Math.min(255,m)).toString(16);return y.length===1?"0"+y:y};return`#${g(d)}${g(l)}${g(f)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var d;this.debug_objectsTotal=((d=this.artboard)==null?void 0:d.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),t.translate(i/2,n/2),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(-i/2,-n/2,i,n)),this.artboard.backgroundImage){const l=this.artboard.backgroundImage;let f=this.imageCache.get(l);if(f||(f=new Image,f.src=l,this.imageCache.set(l,f)),f.complete&&f.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const g=f.naturalWidth/f.naturalHeight,u=i/n;let p,m,y,S;u>g?(p=i,m=i/g):(m=n,p=n*g),y=-p/2,S=-m/2,t.drawImage(f,y,S,p,m),t.restore()}}t.beginPath(),t.rect(-i/2,-n/2,i,n),t.clip();const r=new Map;this.artboard.objects.forEach(l=>r.set(l.id,l)),this.artboard.objects.filter(l=>!l.parentId).map((l,f)=>{const g=this.objectStates.get(l.id),u=(g==null?void 0:g.zIndex)??f;return{obj:l,zIndex:u}}).sort((l,f)=>l.zIndex-f.zIndex).forEach(({obj:l})=>{this.renderObject(t,l,r)}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&console.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,c=s*a.b+o*a.d+a.f,d=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d),f=(e/2+n)*d,g=(i/2+n)*l;return r+f>=0&&r-f<=this.canvasWidth&&c+g>=0&&c-g<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,c=1;const d=o/e,l=t/s;switch(i){case"Contain":l>d?c=s/e:c=t/o,a=r=c;break;case"Cover":l>d?c=t/o:c=s/e,a=r=c;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":c=t/o,a=r=c;break;case"FitHeight":c=s/e,a=r=c;break;case"None":a=r=1;break;case"ScaleDown":c=Math.min(t/o,s/e),c>1&&(c=1),a=r=c;break;default:a=r=1;break}const f=o*a,g=e*r;let u=0,p=0;return n.includes("Left")?u=0:n.includes("Right")?u=t-f:u=(t-f)/2,n.includes("Top")?p=0:n.includes("Bottom")?p=s-g:p=(s-g)/2,{scaleX:a,scaleY:r,tx:u,ty:p}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o){var p,m,y,S,b,v,w,k,A,x,B,$,K,tt,rt,at,V;const e=this.objectStates.get(s.id);if(!e){console.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(O,R,P,J,j)=>(this.drawRoundRect(t,O,R,P,J,j),t));const i=e.geometry?this.deepMerge(s.geometry,e.geometry):s.geometry,n=e.style?this.deepMerge(s.style,e.style):s.style;let a=(i==null?void 0:i.width)||((p=s.geometry)==null?void 0:p.width)||s.width||0,r=(i==null?void 0:i.height)||((m=s.geometry)==null?void 0:m.height)||s.height||0;if((a===0||r===0)&&(i!=null&&i.points)&&Array.isArray(i.points)&&i.points.length>0){let O=1/0,R=-1/0,P=1/0,J=-1/0;i.points.forEach(j=>{O=Math.min(O,j.x),R=Math.max(R,j.x),P=Math.min(P,j.y),J=Math.max(J,j.y)}),a===0&&(a=R-O),r===0&&(r=J-P)}const c=O=>{if(O)return O.corner_radius??O.cornerRadius},d=c(e)??c(n)??c(i)??c(s.style)??c(s.geometry)??0,l={...i,width:a,height:r};if(delete l.cornerRadius,l.corner_radius=d,e.visible===!1)return;const f=s.repeaterConfig,g=f&&f.isEnabled&&f.count>1,u=g?f.count:1;for(let O=0;O<u;O++){let R=e.x,P=e.y,J=e.rotation,j=e.scale_x??1,lt=e.scale_y??1;if(g&&O>0){if(f.type==="Linear"){const st=f.offsetX||0,ct=f.offsetY||0,_=f.rotation||0,I=f.scale!==void 0?f.scale:1;R+=O*st,P+=O*ct,J+=O*_,j*=Math.pow(I,O),lt*=Math.pow(I,O)}else if(f.type==="Grid"){const st=f.cols||Math.ceil(Math.sqrt(f.count)),ct=f.gapX||0,_=f.gapY||0,I=Math.floor(O/st),D=O%st,Z=a+ct,bt=r+_;R+=D*Z,P+=I*bt}else if(f.type==="Radial"){const st=f.radius||100,ct=f.startAngle||0,I=(f.endAngle||360)-ct,D=f.count>1?I/(I===360?f.count:f.count-1):0,Z=ct+O*D,bt=Z*Math.PI/180;R=e.x+st*Math.cos(bt),P=e.y+st*Math.sin(bt),J+=Z}}const Y=s.type==="Group"||s.type==="Frame"||s.type==="Component",H=a>0&&r>0;if(!Y&&H){const st=(((y=n.shadow)==null?void 0:y.isEnabled)!==!1?(((S=n.shadow)==null?void 0:S.blur)||0)+10:0)+(((b=n.blur)==null?void 0:b.isEnabled)!==!1&&((v=n.blur)==null?void 0:v.radius)||0)+20;if(!this.isObjectInView(t,R,P,a,r,st))continue}this.debug_objectsRendered++,t.save();const it=[],nt=n.blur||((w=s.style)==null?void 0:w.blur);nt&&nt.amount>0&&it.push(`blur(${nt.amount}px)`);const ft=((k=i==null?void 0:i.type)==null?void 0:k.toLowerCase().includes("image"))||((A=s.type)==null?void 0:A.toLowerCase().includes("image")),M=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Q=i!=null&&i.adjustments&&Object.keys(i.adjustments).length>0?i.adjustments:null,N=ft?Q||M:M||Q,L=ft&&!N?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:N;if(e&&L&&(e.geometry=e.geometry||{},e.geometry.adjustments={...L}),L){const st=(L.exposure||0)/100,ct=L.contrast||0,_=1+(L.saturation||0)/100,I=(L.temperature||0)/200,D=(L.tint||0)/200,Z=(L.highlights||0)/500,bt=(L.shadows||0)/500;let Mt="",ht="SourceGraphic";if(st!==0&&(Mt+=`
8
- <feComponentTransfer in="${ht}" result="exposure">
9
- <feFuncR type="linear" slope="1" intercept="${st}"/>
10
- <feFuncG type="linear" slope="1" intercept="${st}"/>
11
- <feFuncB type="linear" slope="1" intercept="${st}"/>
12
- </feComponentTransfer>`,ht="exposure"),ct!==0){const mt=(ct+100)/100,C=.5*(1-mt);Mt+=`
13
- <feComponentTransfer in="${ht}" result="contrast">
14
- <feFuncR type="linear" slope="${mt}" intercept="${C}"/>
15
- <feFuncG type="linear" slope="${mt}" intercept="${C}"/>
16
- <feFuncB type="linear" slope="${mt}" intercept="${C}"/>
17
- </feComponentTransfer>`,ht="contrast"}if(_!==1&&(Mt+=`<feColorMatrix in="${ht}" type="saturate" values="${_}" result="saturate"/>`,ht="saturate"),L.hue&&(Mt+=`<feColorMatrix in="${ht}" type="hueRotate" values="${L.hue}" result="hue"/>`,ht="hue"),L.negative){const mt=1-L.negative/50;Mt+=`
18
- <feColorMatrix in="${ht}" type="matrix" result="invert"
19
- values="${mt} 0 0 0 ${1-mt}
20
- 0 ${mt} 0 0 ${1-mt}
21
- 0 0 ${mt} 0 ${1-mt}
22
- 0 0 0 1 0"/>`,ht="invert"}if(I!==0||D!==0||Z!==0||bt!==0){const mt=1+Z+bt,C=mt*(1+I-D/2),Et=mt*(1+D),Gt=mt*(1-I-D/2),Rt=L.shadows*.1/255,dt=[C,0,0,0,Rt,0,Et,0,0,Rt,0,0,Gt,0,Rt,0,0,0,1,0].join(" ");Mt+=`<feColorMatrix in="${ht}" type="matrix" values="${dt}" result="advanced"/>`,ht="advanced"}if(L.blur&&(Mt+=`<feGaussianBlur in="${ht}" stdDeviation="${L.blur}" result="blur"/>`,ht="blur"),Mt){const mt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${Mt}</filter></svg>`,C=btoa(mt);it.push(`url('data:image/svg+xml;base64,${C}#f')`)}}it.length>0?t.filter=it.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const z=t.globalAlpha,pt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=z*pt;const vt=e.compositeOperation||e.blendMode;if(vt&&vt!=="Normal"){const st=vt.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(st)&&(t.globalCompositeOperation=st)}const yt=t,_t=e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let kt=!1;const Tt=_t.filter(st=>st.isVisible!==!1&&o.has(st.maskId));if(Tt.length>0){const st=Tt[0],ct=o.get(st.maskId),_=this.objectStates.get(ct.id);_&&_.visible!==!1&&(kt=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=yt.filter)}t.translate(Math.round(R),Math.round(P)),t.rotate(J*Math.PI/180);const Wt=e.skew_x||0,Yt=e.skew_y||0;(Wt!==0||Yt!==0)&&t.transform(1,Math.tan(Yt*Math.PI/180),Math.tan(Wt*Math.PI/180),1,0,0),t.scale(j*(e.flip_x===!0?-1:1),lt*(e.flip_y===!0?-1:1)),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 Dt=n.shadow;if(Dt&&Dt.isEnabled!==!1){let st=Dt.color||"#000000";(B=(x=this.artboard)==null?void 0:x.tokens)!=null&&B.colors&&this.artboard.tokens.colors[st]&&(st=this.artboard.tokens.colors[st]);const ct=this.normalizeOpacity(Dt.opacity??100),_=Dt.spread||0,D=(Dt.blur||0)+_*1.5;let Z=st;if(st.startsWith("#")){const ht=st.replace("#",""),Pt=parseInt(ht.substring(0,2),16),mt=parseInt(ht.substring(2,4),16),C=parseInt(ht.substring(4,6),16);Z=`rgba(${Pt}, ${mt}, ${C}, ${ct})`}else if(st.startsWith("rgba")){const ht=st.match(/[\d.]+/g);if(ht&&ht.length>=4){const Pt=ht[0],mt=ht[1],C=ht[2],Et=ht[3];Z=`rgba(${Pt}, ${mt}, ${C}, ${parseFloat(Et)*ct})`}}const bt=t.getTransform(),Mt=Math.sqrt(bt.a*bt.a+bt.b*bt.b)||1;t.shadowColor=Z,t.shadowBlur=D*Mt,t.shadowOffsetX=(Dt.offsetX||0)*Mt,t.shadowOffsetY=(Dt.offsetY||0)*Mt}const Vt=s.liquidFill||(($=s.style)==null?void 0:$.liquidFill),zt=s.artEffect||((K=s.style)==null?void 0:K.artEffect);if(Vt&&Vt.enabled){t.save();const st=Vt.fillLevel??.5;t.beginPath();const ct=r/2-r*st;t.rect(-a/2,ct,a,r*st),t.clip(),t.fillStyle=Vt.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(Vt.opacity??1)}if(zt&&zt.enabled){const st=zt.type,ct=zt.intensity??.5;if(st==="glitch"){t.save();const _=ct*10,I=t.getTransform(),D=Math.sqrt(I.a*I.a+I.b*I.b)||1;t.shadowColor="rgba(255, 0, 0, 0.5)",t.shadowBlur=_*D,t.translate(_/2,0)}}if((i==null?void 0:i.type)==="Text")this._renderText(t,s,l,n,e,a,r);else if((i==null?void 0:i.type)==="Image"){const st=i.originalSrc||i.src;if(st){let ct=this.imageCache.get(st);ct||(ct=new Image,ct.onload=()=>{console.log(`[ExodeUI] Image loaded successfully, size: ${ct.naturalWidth}x${ct.naturalHeight}`)},ct.onerror=D=>{console.error("[ExodeUI] Image load failed:",D,`Src preview: ${st.substring(0,100)}...`)},ct.src=st,this.imageCache.set(st,ct));const _=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,I=(((tt=n.stroke)==null?void 0:tt.alignment)||"center").toLowerCase();if(_&&(I==="outside"||I==="center")&&this.applyStrokeAlignment(t,n,l,a,r,d),n.fill&&n.fill.type!=="None"){t.save();const D=t.globalAlpha,Z=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Z||n.fill.color||"transparent",t.globalAlpha=D*this.normalizeOpacity(n.fill.opacity??100),d!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,d),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=D,t.restore()}ct.complete&&ct.naturalWidth>0?(d!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,d),t.clip(),t.drawImage(ct,-a/2,-r/2,a,r),t.restore()):t.drawImage(ct,-a/2,-r/2,a,r),_&&I==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,d)):_&&I==="inside"&&this.applyStrokeAlignment(t,n,l,a,r,d)}}else if(i.type==="SVG"){const st=i.svgContent;if(st){const ct=n.palette||[],_=n.fill,I=n.stroke,D=_?this.normalizeOpacity(_.opacity??100):1,Z=(_==null?void 0:_.type)==="Solid"&&(!I||I.isEnabled===!1||I.type==="Solid"&&I.color===_.color),bt=_&&_.type!=="None"?Z?"monochrome":_.type==="Solid"?(_.color||"")+"|opacity:"+D:JSON.stringify(_.stops||[])+"|opacity:"+D:"",Mt=I&&I.isEnabled!==!1&&(I.width||0)>0?Z?["monochrome",I.width||0,I.trimStart??0,I.trimEnd??1,I.trimOffset??0,I.dashOffset??0].join("|"):[I.width||0,I.fill?I.fill.type==="Solid"?I.fill.color||"":JSON.stringify(I.fill.stops||[]):I.color||"",I.opacity??1,I.lineCap||"",I.lineJoin||"",(I.dashArray||[]).join(","),I.trimStart??0,I.trimEnd??1,I.trimOffset??0,I.dashOffset??0].join("|"):"nostroke",ht=[s.id,ct.join("_"),bt,Mt,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let Pt=this.imageCache.get(ht);if(!Pt){Pt=new Image,Pt.crossOrigin="anonymous";let C=st;if(C.match(/xmlns\s*=\s*["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(C=C.replace(/<svg([^>]*)>/i,(T,G)=>G.includes("xmlns=")?T:`<svg xmlns="http://www.w3.org/2000/svg"${G}>`)),i.colors&&i.colors.length>0&&ct.length>0&&i.colors.forEach((T,G)=>{if(ct[G]){const ut=T.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),E=new RegExp(ut,"gi");C=C.replace(E,ct[G])}}),_&&_.type&&_.type!=="None"){if(_.type==="Solid"&&_.color){const T=Z?"#FFFFFF":_.color,G=Z?1:this.normalizeOpacity(_.opacity??100);C=C.replace(/\bfill\s*=\s*["'][^"']*["']/gi,ut=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(ut)?ut:`fill="${T}"`),C=C.replace(/fill\s*:\s*[^;"')]+/gi,ut=>/fill\s*:\s*(none|transparent)/i.test(ut)?ut:`fill:${T}`),G<1&&(C=C.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${G}"`),C=C.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${G}`),C.match(/\bfill-opacity\s*=/i)||(C=C.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${G}">`),C=C.replace(/<\/svg>/i,"</g></svg>")))}else if(_.type==="LinearGradient"||_.type==="RadialGradient"||_.type==="Linear"||_.type==="Radial"){const T="exode-fill",G=this.normalizeOpacity(_.opacity??100),ut=(_.stops||[]).map(F=>{const et=F.offset!==void 0?F.offset:F.pos??0,It=this.normalizeOpacity(F.opacity??100)*G;return`<stop offset="${et*100}%" stop-color="${F.color||"#000"}" stop-opacity="${It}"/>`}).join("");let E="";if(_.type==="LinearGradient"||_.type==="Linear"){const F=(Ft,wt)=>Array.isArray(Ft)?Ft[wt]??(wt===0?0:1):Ft&&typeof Ft=="object"?Ft[wt===0?"x":"y"]??(wt===0?0:1):wt===0?0:1,et=F(_.start,0)*100,It=F(_.start,1)*100,Ot=F(_.end,0)*100,St=F(_.end,1)*100;E=`<linearGradient id="${T}" x1="${et}%" y1="${It}%" x2="${Ot}%" y2="${St}%" gradientUnits="objectBoundingBox">${ut}</linearGradient>`}else{const F=(St,Ft)=>Array.isArray(St)?St[Ft]??.5:St&&typeof St=="object"?St[Ft===0?"x":"y"]??.5:.5,et=F(_.center,0)*100,It=F(_.center,1)*100,Ot=(_.radius??.5)*100;E=`<radialGradient id="${T}" cx="${et}%" cy="${It}%" r="${Ot}%" gradientUnits="objectBoundingBox">${ut}</radialGradient>`}/<defs>/i.test(C)?C=C.replace(/<defs>/i,`<defs>${E}`):C=C.replace(/<svg([^>]*)>/i,`<svg$1><defs>${E}</defs>`),C=C.replace(/\bfill\s*=\s*["'][^"']*["']/gi,F=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(F)?F:`fill="url(#${T})"`),C=C.replace(/fill\s*:\s*[^;"')]+/gi,F=>/fill\s*:\s*(none|transparent)/i.test(F)?F:`fill:url(#${T})`)}}const Et=(T,G,ut=1)=>{const E=(T.stops||[]).map(St=>{const Ft=St.offset!==void 0?St.offset:St.pos??0,wt=this.normalizeOpacity(St.opacity??100)*ut;return`<stop offset="${Ft*100}%" stop-color="${St.color||"#000"}" stop-opacity="${wt}"/>`}).join(""),F=(St,Ft,wt=.5)=>Array.isArray(St)?St[Ft]??wt:St&&typeof St=="object"?St[Ft===0?"x":"y"]??wt:wt;if(T.type==="LinearGradient"||T.type==="Linear"){const St=F(T.start,0,0)*100,Ft=F(T.start,1,0)*100,wt=F(T.end,0,1)*100,Xt=F(T.end,1,1)*100;return`<linearGradient id="${G}" x1="${St}%" y1="${Ft}%" x2="${wt}%" y2="${Xt}%" gradientUnits="objectBoundingBox">${E}</linearGradient>`}const et=F(T.center,0,.5)*100,It=F(T.center,1,.5)*100,Ot=(T.radius??.5)*100;return`<radialGradient id="${G}" cx="${et}%" cy="${It}%" r="${Ot}%" gradientUnits="objectBoundingBox">${E}</radialGradient>`},Gt=(T,G)=>/<defs>/i.test(T)?T.replace(/<defs>/i,`<defs>${G}`):T.replace(/(<svg[^>]*>)/i,`$1<defs>${G}</defs>`);if(I&&I.isEnabled!==!1&&(I.width||0)>0){const T=I.width||1,G=Z?1:this.normalizeOpacity(I.opacity??100),ut=Z?"#FFFFFF":I.color||(_==null?void 0:_.color)||"#000000";let E="";const F=I.fill;if(F&&F.type){if(F.type==="Solid")E=F.color||I.color||"#000000";else if(F.type==="LinearGradient"||F.type==="RadialGradient"||F.type==="Linear"||F.type==="Radial"){const wt="exode-stroke";C=Gt(C,Et(F,wt,G)),E=`url(#${wt})`}}E||(E=ut),C.match(/\bstroke\s*=\s*["']/i)?C=C.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,wt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(wt)?wt:`stroke="${E}"`):C=C.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${E}"`),C=C.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${E}`),C.match(/\bstroke-width\s*=\s*["']/i)?C=C.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${T}"`):C=C.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${T}"`),C=C.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${T}`),C.match(/\bstroke-opacity\s*=\s*["']/i)?C=C.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${G}"`):C=C.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${G}"`),C=C.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${G}`),I.lineCap&&(C=C.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${I.lineCap}"`),C=C.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${I.lineCap}`)),I.lineJoin&&(C=C.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${I.lineJoin}"`),C=C.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${I.lineJoin}`));const et=I.trimStart??0,It=I.trimEnd??1,Ot=I.trimOffset??0,St=I.dashOffset??0,Ft=et!==0||It!==1||Ot!==0||St!==0;if(Ft){const wt=Math.max(0,Math.min(1,et)),Xt=Math.max(0,Math.min(1,It));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${wt}, End: ${Xt}`);let Jt=i.width||a||100,Qt=i.height||r||100;const U=st.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(U){const Ut=parseFloat(U[1]),qt=parseFloat(U[2]);!isNaN(Ut)&&!isNaN(qt)&&(Jt=Ut,Qt=qt)}const X=(Jt+Qt)*2,q=(Ot%1+1)%1,Ct=(St%1+1)%1;let $t="",Ht=0;if(wt>=Xt)$t=`0 ${X}`,Ht=0;else{const Ut=X*(Xt-wt),qt=X-Ut;Ht=-(X*(wt+q+Ct)),$t=`${Ut} ${qt}`}C.match(/\bstroke-dasharray\s*=/i)?C=C.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${$t}"`):C=C.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${$t}"`),C=C.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${$t}`),C.match(/\bstroke-dashoffset\s*=/i)?C=C.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${Ht}"`):C=C.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${Ht}"`),C=C.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${Ht}`)}else if(I.dashArray&&I.dashArray.length>0){const wt=I.dashArray.join(" ");C=C.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${wt}"`),C=C.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${wt}`),I.dashOffset&&(C=C.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${I.dashOffset}"`),C=C.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${I.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(st)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(st)){let wt="",Xt="";if(Ft){const X=i.width||a||100,q=i.height||r||100,Ct=(X+q)*2,$t=Math.max(0,Math.min(1,et)),Ht=Math.max(0,Math.min(1,It)),Ut=(Ot%1+1)%1,qt=(St%1+1)%1;if($t>=Ht)wt=` stroke-dasharray="0 ${Ct}"`,Xt=' stroke-dashoffset="0"';else{const Se=Ct*(Ht-$t),rs=Ct-Se,ls=-(Ct*($t+Ut+qt));wt=` stroke-dasharray="${Se} ${rs}"`,Xt=` stroke-dashoffset="${ls}"`}}else(rt=I.dashArray)!=null&&rt.length&&(wt=` stroke-dasharray="${I.dashArray.join(" ")}"`,I.dashOffset&&(Xt=` stroke-dashoffset="${I.dashOffset}"`));const Jt=I.lineCap?` stroke-linecap="${I.lineCap}"`:"",Qt=I.lineJoin?` stroke-linejoin="${I.lineJoin}"`:"",U=`stroke="${E}" stroke-width="${T}" stroke-opacity="${G}"${Jt}${Qt}${wt}${Xt}`;C=C.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(X,q,Ct)=>`${q}${Ct}<g ${U}>`),C=C.replace(/<\/svg>/i,"</g></svg>")}}else I&&I.isEnabled===!1&&(C=C.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),C=C.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Rt=new Blob([C],{type:"image/svg+xml"}),dt=URL.createObjectURL(Rt);Pt.onload=()=>{if(URL.revokeObjectURL(dt),this.frameCount%900===0){const T=this.imageCache.get(ht);T&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${T.naturalWidth}x${T.naturalHeight})`)}},Pt.onerror=()=>{URL.revokeObjectURL(dt),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Pt.src=dt,this.imageCache.set(ht,Pt)}let mt=null;if(Pt.complete&&Pt.naturalWidth>0?(mt=Pt,this.lastValidSvgImgMap.set(s.id,Pt)):mt=this.lastValidSvgImgMap.get(s.id)||null,mt&&mt.complete&&mt.naturalWidth>0){const C=Math.max(1,a),Et=Math.max(1,r);if(Z&&(_==null?void 0:_.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=C,this.maskBuffer.height=Et,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,C,Et),this.maskCtx.drawImage(mt,0,0,C,Et),this.maskCtx.globalCompositeOperation="source-in";const Gt=_.color||"#000000",Rt=this.normalizeOpacity(_.opacity??100);this.maskCtx.fillStyle=Gt,this.maskCtx.globalAlpha=Rt,this.maskCtx.fillRect(0,0,C,Et),t.drawImage(this.maskBuffer,-C/2,-Et/2,C,Et)}else d!==0?(t.save(),this.drawRoundRect(t,-C/2,-Et/2,C,Et,d),t.clip(),t.drawImage(mt,-C/2,-Et/2,C,Et),t.restore()):t.drawImage(mt,-C/2,-Et/2,C,Et)}}}else if(l.type==="LineGraph")this.renderLineGraph(t,l,a,r);else if(s.type==="Shape"){if(this.applyPath(t,l,a,r,d),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const st=t.globalAlpha;if(((at=n.fill)==null?void 0:at.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const ct=n.fill.originalSrc||n.fill.src;let _=this.imageCache.get(ct);_||(_=new Image,_.src=ct,this.imageCache.set(ct,_)),_.complete&&_.naturalWidth>0&&(t.save(),this.applyPath(t,l,a,r,d),t.clip(),this.renderFittedImage(t,_,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const ct=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=ct||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=st*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,l,a,r,d),t.fill()}t.globalAlpha=st}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,l,a,r,d)}else if(s.type==="Frame"||s.type==="Group"&&!s.isStructuralGroup){const st=e.width??i.width??s.width??a,ct=e.height??i.height??s.height??r,_=d;if(t.save(),t.beginPath(),this.drawRoundRect(t,-st/2,-ct/2,st,ct,_),n.fill&&n.fill.type!=="None"){const I=t.globalAlpha,D=this.createCanvasFill(t,n.fill,st,ct);t.fillStyle=D||n.fill.color||"transparent",t.globalAlpha=I*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=I}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const I={type:"Rectangle"};this.applyStrokeAlignment(t,n,I,st,ct,_)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):this.frameCount%60===0&&console.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(V=s.geometry)==null?void 0:V.type));if(this.applyArtEffectOverlay(t,s,l,a,r,d),zt&&zt.enabled&&zt.type==="glitch"&&t.restore(),Vt&&Vt.enabled&&t.restore(),s.children&&s.children.length>0){const ct=s.type==="Frame",_=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ct;if(t.save(),_){t.beginPath();const D=e.width??(i==null?void 0:i.width)??s.width??0,Z=e.height??(i==null?void 0:i.height)??s.height??0,bt=e.cornerRadius??(i==null?void 0:i.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-D/2,-Z/2,D,Z,bt),t.clip()}let I=0;for(s.children.forEach(D=>{const Z=o.get(D);if(!Z)return;const bt=this.objectStates.get(D),Mt=(bt==null?void 0:bt.geometry)||Z.geometry;if(Mt&&Mt.isMask&&(bt==null?void 0:bt.visible)!==!1){const ht=Mt.width||0,Pt=Mt.height||0;this.applyObjectTransform(t,D);const mt=(bt==null?void 0:bt.corner_radius)??(Mt==null?void 0:Mt.corner_radius)??0;this.applyPath(t,Mt,ht,Pt,mt),t.clip(),I++}else this.renderObject(t,Z,o)});I>0;)t.restore(),I--;t.restore()}if(kt){this.maskCtx.restore(),(e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(I=>I.isVisible!==!1&&o.has(I.maskId)).forEach(I=>{var mt,C,Et,Gt,Rt,dt;const D=o.get(I.maskId),Z=this.objectStates.get(D.id),bt=I.feather||0,Mt=I.inverted===!0,ht=I.opacity!==void 0?typeof I.opacity=="number"?I.opacity:I.opacity/100:1;if((I.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,D.id,o),bt>0&&(this.lumaCtx.filter=`blur(${bt}px)`),this.lumaCtx.globalAlpha=ht;const T=(Z==null?void 0:Z.width)||D.geometry.width||0,G=(Z==null?void 0:Z.height)||D.geometry.height||0,ut=(Z==null?void 0:Z.corner_radius)??D.corner_radius??0;if(((mt=D.geometry)==null?void 0:mt.type)==="Text"){const It=Z!=null&&Z.geometry?this.deepMerge(D.geometry,Z.geometry):D.geometry,Ot=Z!=null&&Z.style?this.deepMerge(D.style,Z.style):D.style;this._renderText(this.lumaCtx,D,{...It,width:T,height:G,corner_radius:ut},Ot,Z,T,G,!0)}else if(((C=D.geometry)==null?void 0:C.type)==="Image"){const It=D.geometry.src;if(It){let Ot=this.imageCache.get(It);Ot||(Ot=new Image,Ot.src=It,this.imageCache.set(It,Ot)),Ot.complete&&Ot.naturalWidth>0?this.lumaCtx.drawImage(Ot,-T/2,-G/2,T,G):(this.applyPath(this.lumaCtx,D.geometry,T,G,ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((Et=D.geometry)==null?void 0:Et.type)==="SVG"){const It=D.geometry.svgContent;if(It){const Ot=`__lumamask_${D.id}`;let St=this.imageCache.get(Ot);if(!St){St=new Image;const Ft=new Blob([It],{type:"image/svg+xml"});St.src=URL.createObjectURL(Ft),St.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(Ot,St)}St.complete&&St.naturalWidth>0?this.lumaCtx.drawImage(St,-T/2,-G/2,T,G):(this.applyPath(this.lumaCtx,D.geometry,T,G,ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,D.geometry,T,G,ut),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const E=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),F=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,et=E.data;for(let It=0;It<et.length;It+=4){const Ot=F[It],St=F[It+1],Ft=F[It+2];let wt=(.299*Ot+.587*St+.114*Ft)/255;Mt&&(wt=1-wt),et[It+3]*=wt}this.maskCtx.putImageData(E,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=Mt?"destination-out":"destination-in",bt>0&&(this.maskCtx.filter=`blur(${bt}px)`),this.maskCtx.globalAlpha=ht,this.applyAbsoluteTransform(this.maskCtx,D.id,o);const T=(Z==null?void 0:Z.width)||D.geometry.width||0,G=(Z==null?void 0:Z.height)||D.geometry.height||0,ut=(Z==null?void 0:Z.corner_radius)??D.corner_radius??0;if(((Gt=D.geometry)==null?void 0:Gt.type)==="Text"){const E=Z!=null&&Z.geometry?this.deepMerge(D.geometry,Z.geometry):D.geometry,F=Z!=null&&Z.style?this.deepMerge(D.style,Z.style):D.style;this._renderText(this.maskCtx,D,{...E,width:T,height:G,corner_radius:ut},F,Z,T,G,!0)}else if(((Rt=D.geometry)==null?void 0:Rt.type)==="Image"){const E=D.geometry.src;if(E){let F=this.imageCache.get(E);F||(F=new Image,F.src=E,this.imageCache.set(E,F)),F.complete&&F.naturalWidth>0?this.maskCtx.drawImage(F,-T/2,-G/2,T,G):(this.applyPath(this.maskCtx,D.geometry,T,G,ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((dt=D.geometry)==null?void 0:dt.type)==="SVG"){const E=D.geometry.svgContent;if(E){const F=`__alphamask_${D.id}`;let et=this.imageCache.get(F);if(!et){et=new Image;const It=new Blob([E],{type:"image/svg+xml"});et.src=URL.createObjectURL(It),et.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(F,et)}et.complete&&et.naturalWidth>0?this.maskCtx.drawImage(et,-T/2,-G/2,T,G):(this.applyPath(this.maskCtx,D.geometry,T,G,ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,D.geometry,T,G,ut),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),yt.save(),yt.setTransform(1,0,0,1,0,0);const _=s.maskBlendMode||s.blendMode;_&&_!=="Normal"&&(yt.globalCompositeOperation=_.toLowerCase()),yt.drawImage(this.maskBuffer,0,0),yt.restore(),yt.restore()}else t.restore()}}_renderText(t,s,o,e,i,n,a,r=!1,c=!1){var Y,H,it,nt,ft;let d=o.text||"";if(o.textInputId&&!r){const M=this.inputs.get(o.textInputId);M!==void 0&&(d=String(M),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=d))}if(o.svgPath){const M=o.svgPath;t.save();const Q=((Y=e==null?void 0:e.fill)==null?void 0:Y.color)||"#000000",N=((H=e==null?void 0:e.fill)==null?void 0:H.opacity)!==void 0?(it=e==null?void 0:e.fill)==null?void 0:it.opacity:1;t.fillStyle=Q,t.globalAlpha*=N;const L=new Path2D(M);t.fill(L),t.restore();return}let l=d||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(l=o.segments.map(M=>M&&M.text?M.text:"").join(""));const f=o.textCase||"none";f==="uppercase"?l=l.toUpperCase():f==="lowercase"?l=l.toLowerCase():f==="capitalize"&&(l=l.replace(/\b\w/g,M=>M.toUpperCase()));let g=((nt=o.fontWeight)==null?void 0:nt.toString())||"400",u=o.fontStyle||"normal";g.toLowerCase().includes("italic")&&(u="italic",g=g.replace(/italic/gi,"").trim()||"400");const p=this.mapFontWeight(g),m=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const S=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];S.forEach(M=>{const Q=new RegExp(`[\\s-]${M}$`,"i");Q.test(y)&&(y=y.replace(Q,"").trim())});const b=`${u} ${p} ${m}px "${y}", sans-serif`;t.font=b;const v=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let k=0;if(typeof o.letterSpacing=="number")k=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const M=o.letterSpacing;k=M.unit==="PERCENT"?M.value/100*m:M.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${k}px`);const A=o.paragraphSpacing||0;let x=o.lineHeight??1.2;typeof x=="string"&&(x=parseFloat(x)),x>5&&m>0&&(x=x/m);const B=(x||1.2)*m,$=o.width&&o.width>0?Math.ceil(o.width):1e5,K=ae({text:l,fontFamily:y,fontSize:m,fontWeight:p,fontStyle:u,lineHeight:x,width:$,letterSpacing:k,paragraphSpacing:A,segments:o.segments,enableSegments:o.enableSegments,textCase:f}),tt=K.lines||[],rt=K.maxFontSize||m,at=this.fontLeadingFactors[y]??.5,V=(B-m)*at;let O=K.height,R=-O/2;a>0&&a>O&&(v==="top"?R=-a/2:v==="middle"||v==="center"?R=-O/2:v==="bottom"&&(R=a/2-O)),R+=V;let P=null,J=0;if(o.pathId&&this.artboard){const M=this.artboard.objects.find(Q=>Q.id===o.pathId);if(M&&M.type==="Shape"&&((ft=M.geometry)==null?void 0:ft.type)==="Path"){const Q=this.objectStates.get(M.id),N=Q!=null&&Q.geometry?this.deepMerge(M.geometry,Q.geometry):M.geometry,L=(Q==null?void 0:Q.scale_x)!==void 0?(M.width||0)*Q.scale_x:M.width||0,z=(Q==null?void 0:Q.scale_y)!==void 0?(M.height||0)*Q.scale_y:M.height||0;P={geo:N,obj:M,w:L,h:z},J=this.getPerimeter(N,L,z)}}const j=(M,Q)=>{var L,z;if(k===0&&(!o.enableSegments||!((L=o.segments)!=null&&L.length)))return t.measureText(M).width;let N=0;for(let pt=0;pt<M.length;pt++){const vt=Q+pt;let yt=0;if(o.enableSegments===!0&&((z=o.segments)==null?void 0:z.length)>0){let _t=0,kt=null;for(const Tt of o.segments){if(vt<_t+(Tt.text||"").length){kt=Tt;break}_t+=(Tt.text||"").length}if(kt){t.save();let Tt=kt.fontFamily||o.fontFamily||"Inter";const Wt=this.mapFontWeight((kt.fontWeight||o.fontWeight||"400").toString()),Yt=kt.fontStyle||u,Dt=kt.fontSize||m;t.font=`${Yt} ${Wt} ${Dt}px "${Tt}", sans-serif`,yt=t.measureText(M[pt]).width,t.restore()}else yt=t.measureText(M[pt]).width}else yt=t.measureText(M[pt]).width;N+=yt+k}return N-(M.length>0?k:0)},lt=(M,Q,N,L,z)=>{var kt,Tt;const vt=(z===0||l[z-1]===`
23
- `||l[z-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,yt=(!r||c)&&(s.behaviors||[]).some(Wt=>Wt.enabled&&(Wt.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(Wt.type)));if(!o.pathId&&!yt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0))t.font=b,L?t.strokeText(M,Q+vt,N):t.fillText(M,Q+vt,N);else{const Wt=j(M,z);let Yt=Q+vt;w==="center"?Yt-=Wt/2:w==="right"&&(Yt-=Wt);let Dt=o.pathOffset||0;o.pathId&&J>0&&P&&(w==="center"?Dt+=J/2-Wt/2:w==="right"&&(Dt+=J-Wt));let Vt=Yt;const zt=r&&!c?[]:((kt=s.behaviors)==null?void 0:kt.filter(st=>[W.Typewriter,W.Scramble,W.Wave,W.Bounce,W.GlitchText,W.TextTrail,W.Reveal3D,W.RevealSlide,W.RevealBlur,W.TextLiquid,W.TextVortex,W.TextExplosion,W.TextRain,W.TextGravity,W.TextElastic,W.TextMatrix,W.TextNeon,W.TextGlitch3D,W.TextDissolve,W.TextOrganic,W.TextBreathe,W.TextFloral,W.TextSmoke,W.TextVariable,W.TextMagnet,W.TextSpin,W.TextZing,W.TextPerspective,W.TextMirror].includes(st.type)&&st.enabled))||[];for(let st=0;st<M.length;st++){let ct=M[st];const _=z+st;let I=0,D=0,Z=1,bt=1,Mt=0,ht=1,Pt=ct;zt.forEach(dt=>{const T=dt.settings||{},G=T.strength||1,ut=Date.now();if(dt.type===W.Typewriter)this.currentTime*(T.speed||1)-_*(T.stagger||.05)<0&&(ht=0);else if(dt.type===W.Scramble)Math.max(0,Math.min(1,this.currentTime/(T.duration||1.5))-_*.02)<1&&Math.random()<.3&&(Pt="$%#@!*&"[Math.floor(Math.random()*7)]);else if(dt.type===W.Wave)D+=Math.sin(this.currentTime*5*(T.speed||1)+_*(T.frequency||1))*(T.amplitude||20)*G;else if(dt.type===W.Bounce){const E=Math.max(0,this.currentTime%2-_*(T.stagger||.1));E<1&&(D-=Math.abs(Math.sin(E*Math.PI))*(T.height||50)*G)}else if(dt.type===W.TextTrail){const E=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-_*(T.delay||5))];E&&(I+=(E.x-(i.x+Vt))*G*.2,D+=(E.y-(i.y+N+D))*G*.2)}else if(dt.type===W.Reveal3D){const E=Math.max(0,Math.min(1,this.currentTime*(T.speed||1)-_*(T.stagger||.1)));Z*=E,bt*=E,ht=E}else if(dt.type===W.RevealSlide){const E=Math.max(0,Math.min(1,this.currentTime*1.5-_*.05)),F=(1-E)*(T.distance||40)*G,et=T.direction||"up";et==="up"?D-=F:et==="down"?D+=F:et==="left"?I-=F:et==="right"&&(I+=F),ht=E}else if(dt.type===W.RevealBlur){const E=Math.max(0,Math.min(1,this.currentTime*1.2-_*.1));ht=E,I+=(1-E)*5}else if(dt.type===W.TextLiquid){const E=Math.max(0,Math.sin(ut*.001*(T.speed||1)+_*.5));D+=E*(T.amplitude||10)*G,bt*=1+E*.2}else if(dt.type===W.TextVortex){const E=ut*.002*(T.speed||1)+_*.2,F=(1-(Math.sin(ut*.001)*.5+.5))*(T.radius||50);I+=Math.cos(E)*F*G,D+=Math.sin(E)*F*G}else if(dt.type===W.TextExplosion){const E=T.force||1,F=this.currentTime%2;if(F<1){const et=(_/M.length-.5)*Math.PI*2,It=F*100*E;I+=Math.cos(et)*It*G,D+=Math.sin(et)*It*G,ht=1-F}}else if(dt.type===W.TextRain){const E=T.speed||1,F=T.height||100,et=(ut*.001*E+_*.1)%1;D-=(1-et)*F*G,ht=et>.1?1:et*10}else if(dt.type===W.TextGravity){const E=T.gravity||9.8,F=this.currentTime%3/3,et=.5*E*Math.pow(F*10,2);et<100?D+=et*G:D+=100*G}else if(dt.type===W.TextMatrix){const E=T.speed||1;if(Math.random()<.1*E){const et="0123456789ABCDEF!@#$%^&*";Pt=et[Math.floor(Math.random()*et.length)]}ht=.3+(Math.sin(ut*.01*E+_)+1)/2*.7}else if(dt.type===W.TextNeon){const E=Math.random()>.95?.5:1;ht=(.7+(Math.sin(ut*.005)+1)/2*.3)*E}else if(dt.type===W.TextDissolve)Math.sin(_*1.5+ut*.002*(T.speed||1))>.5&&(ht=0);else if(dt.type===W.TextOrganic){const E=T.speed||1,F=T.amplitude||10;I+=Math.sin(ut*.002*E+_)*F*G,D+=Math.cos(ut*.0015*E+_*.7)*F*G}else if(dt.type===W.TextBreathe){const F=1+(Math.sin(ut*.003+_*.2)+1)/2*.2*G;Z*=F,bt*=F}else if(dt.type===W.TextSpin){const E=T.speed||1;Mt+=ut*.01*E+_}else if(dt.type===W.TextMagnet){const E=this.pointerHistory[this.pointerHistory.length-1];if(E){const F=E.x-(i.x+Vt),et=E.y-(i.y+N);Mt=Math.atan2(et,F)}}else if(dt.type===W.TextPerspective){const E=M.length/2,F=(_-E)/E,et=1-Math.abs(F)*.3*G;Z*=et,bt*=et,I+=F*20*G}else if(dt.type===W.TextMirror)ht*=.8;else if(dt.type===W.TextFloral){const E=T.speed||1,F=T.stagger||.1,et=(ut*.001*E+_*F)%2;et<1&&(Z*=et,bt*=et,Mt+=et*Math.PI)}else if(dt.type===W.TextSmoke){const E=T.speed||1,F=T.height||50,et=(ut*5e-4*E+_*.2)%1;D-=et*F*G,I+=Math.sin(ut*.002+_)*5*G,ht=1-et}else if(dt.type===W.TextVariable){const E=T.speed||1,F=T.intensity||1.5,et=(Math.sin(ut*.004*E+_*.3)+1)/2;Z*=1+et*(F-1)*G}else if(dt.type===W.TextZing){const E=T.speed||2,F=T.distance||100,et=(ut*.002*E+_*.05)%1;I+=(1-et)*F*G,ht=et}else if(dt.type===W.TextElastic){const E=T.stiffness||.2,F=T.damping||.1,et=Math.sin(ut*.01)*Math.exp(-ut*.001*F);bt*=1+et*E*G}else if(dt.type===W.TextGlitch3D){const E=T.intensity||5;Math.random()<.2&&(I+=(Math.random()-.5)*E,D+=(Math.random()-.5)*E,ht=.8)}else if(dt.type===W.GlitchText){const E=T.intensity||5;Math.random()<.1&&(I+=(Math.random()-.5)*E,D+=(Math.random()-.5)*E,Math.random()<.05&&(ht=.5))}});let mt=null,C=o.textDecoration||"none",Et=m;if(o.enableSegments===!0&&((Tt=o.segments)==null?void 0:Tt.length)>0){let dt=0,T=null;for(const G of o.segments){if(_<dt+(G.text||"").length){T=G;break}dt+=(G.text||"").length}if(T){let G=T.fontFamily||o.fontFamily||"Inter";S.forEach(F=>{const et=new RegExp(`[\\s-]${F}$`,"i");et.test(G)&&(G=G.replace(et,"").trim())});const ut=this.mapFontWeight((T.fontWeight||o.fontWeight||"400").toString()),E=T.fontStyle||u;Et=T.fontSize||m,t.font=`${E} ${ut} ${Et}px "${G}", sans-serif`,T.fill&&(mt=T.fill),T.textDecoration&&(C=T.textDecoration),Et<rt&&(D+=(rt-Et)*.85)}}else t.font=b;const Gt=t.globalAlpha;t.globalAlpha*=ht,t.save();const Rt=t.measureText(Pt).width;if(P&&J>0){const dt=Vt-Yt+Rt/2,G=(Dt+dt)/J,ut=this.getPointOnPath(P.geo,P.w,P.h,Math.abs(G%1)),E=ut.angle,F=N+D+(o.pathOffsetY||0),et=o.pathSide==="right"?-1:1,It=Math.cos(E+Math.PI/2)*F*et,Ot=Math.sin(E+Math.PI/2)*F*et;t.translate(ut.x+It+I,ut.y+Ot),t.rotate(E+Mt+(et===-1?Math.PI:0))}else t.translate(Vt+I+Rt/2,N+D),Mt!==0&&t.rotate(Mt);if(t.scale(Z,bt),mt&&!r&&!c){const dt=this.createCanvasFill(t,mt,n,a);t.fillStyle=dt||mt.color||"#000000"}else if(!r&&!c){const dt=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=dt||e.fill.color||"#000000"}if(ht>0)if(r||c){const dt=c?"#000000":this.createCanvasFill(t,e.fill,n,a);t.fillStyle=dt||e.fill.color||"#ffffff",t.fillText(Pt,-Rt/2,0)}else L?t.strokeText(Pt,-Rt/2,0):t.fillText(Pt,-Rt/2,0);C!=="none"&&!r&&this.drawTextDecoration(t,C,0,0,Rt,Et),t.restore(),t.globalAlpha=Gt,Vt+=Rt+k}}};if(r){let M=0,Q=R;(tt||[]).forEach(N=>{const L=N.text||"",z=l.indexOf(L,M);z!==-1&&(M=z);let pt=-n/2;w==="center"?pt=0:w==="right"&&(pt=n/2),lt(L,pt,Q,!1,M),M+=L.length,Q+=B})}else if(c){let M=0,Q=R;(tt||[]).forEach(N=>{const L=N.text||"";let z=-n/2;w==="center"?z=0:w==="right"&&(z=n/2),lt(L,z,Q,!1,M),M+=L.length,M<l.length&&(l[M]===`
24
- `||l[M]==="\r")&&(M++,l[M-1]==="\r"&&l[M]===`
25
- `&&M++),Q+=B})}else{if(e.fill){const M=t.globalAlpha,Q=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=Q||e.fill.color||"#000000",t.globalAlpha=M*this.normalizeOpacity(e.fill.opacity??100);const N=K.fullText||(o.enableSegments?(o.segments||[]).map(pt=>{let vt=pt.text||"";const yt=pt.textCase||o.textCase||"none";return yt==="uppercase"?vt.toUpperCase():yt==="lowercase"?vt.toLowerCase():yt==="capitalize"?vt.replace(/\b\w/g,_t=>_t.toUpperCase()):vt}).join(""):l);let L=0,z=R;(tt||[]).forEach(pt=>{const vt=pt.text||"";let yt=-n/2;w==="center"?yt=0:w==="right"&&(yt=n/2),lt(vt,yt,z,!1,L),L+=vt.length,z+=B,L<N.length&&(N[L]===`
26
- `||N[L]==="\r")&&(A>0&&(z+=A),L++,N[L-1]==="\r"&&N[L]===`
27
- `&&L++)}),t.globalAlpha=M}if(e.stroke&&e.stroke.width>0){const M=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=M*this.normalizeOpacity(e.stroke.opacity??100);let N=0,L=R;(tt||[]).forEach(z=>{let pt=-n/2;w==="center"?pt=0:w==="right"&&(pt=n/2),lt(z.text,pt,L,!0,N),N+=(z.text||"").length,L+=B,N<l.length&&(l[N]===`
28
- `||l[N]==="\r")&&(A>0&&(L+=A),N++,l[N-1]==="\r"&&l[N]===`
29
- `&&N++)}),t.globalAlpha=M}}}applyStrokeAlignment(t,s,o,e,i,n){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=a.width,c=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,i);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const l=t.globalAlpha;t.globalAlpha=l*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 f=a.trimStart??0,g=a.trimEnd??1,u=a.trimOffset??0,p=a.dashOffset??0,m=a.dashArray||[];if(f!==0||g!==1||u!==0){const y=this.getPerimeter(o,e,i);if(y>0){const S=Math.max(0,Math.min(1,f)),b=Math.max(0,Math.min(1,g));if(S<b){const v=y*(b-S),w=y-v,k=-(y*(S+u%1));t.setLineDash([v,w]),t.lineDashOffset=k+p*y}else if(S===b)t.setLineDash([0,y]);else{const v=y*(1-S+b),w=y-v,k=-(y*S);t.setLineDash([v,w]),t.lineDashOffset=k+p*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=p);(o==null?void 0:o.type)==="Line"||e===0||i===0?(this.applyPath(t,o,e,i,n),t.stroke()):c==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore()):c==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,i,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,i,n),t.fill(),t.restore()):(t.lineWidth=r,this.applyPath(t,o,e,i,n),t.stroke()),t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let c=n/360*r;if(a>0){const d=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));c+=n/360*d,n<360&&(c+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(c+=2*Math.max(e,i));return isNaN(c)?0:c}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const c=e[r];if(c.moveTo){n=c.x,a=c.y;continue}const d=n,l=a,f=e[r-1].out_x,g=e[r-1].out_y;if(f!==void 0||c.in_x!==void 0?i+=this.getBezierLength(d,l,f??d,g??l,c.in_x??c.x,c.in_y??c.y,c.x,c.y):i+=Math.sqrt((c.x-d)**2+(c.y-l)**2),n=c.x,a=c.y,c.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const u=n,p=a,m=[...e.slice(0,r+1)].reverse().find(A=>A.moveTo)||e[0],y=m.x,S=m.y,b=e[r].out_x,v=e[r].out_y,w=m.in_x,k=m.in_y;b!==void 0||w!==void 0?i+=this.getBezierLength(u,p,b??u,v??p,w??y,k??S,y,S):i+=Math.sqrt((y-u)**2+(S-p)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,c=10){let d=0,l=t,f=s;for(let g=1;g<=c;g++){const u=g/c,p=1-u,m=u*u,y=p*p,S=y*p,b=m*u,v=S*t+3*y*u*o+3*p*m*i+b*a,w=S*s+3*y*u*e+3*p*m*n+b*r,k=v-l,A=w-f;d+=Math.sqrt(k*k+A*A),l=v,f=w}return d}getBezierTAtLength(t,s,o,e,i,n,a,r,c,d=20){if(t<=0)return 0;let l=0,f=s,g=o;for(let u=1;u<=d;u++){const p=u/d,m=1-p,y=p*p,S=m*m,b=S*m,v=y*p,w=b*s+3*S*p*e+3*m*y*n+v*r,k=b*o+3*S*p*i+3*m*y*a+v*c,A=w-f,x=k-g,B=Math.sqrt(A*A+x*x);if(l+B>=t){const $=t-l,K=B===0?0:$/B;return(u-1+K)/d}l+=B,f=w,g=k}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,c=-1/0;i.forEach(S=>{typeof S.x=="number"&&typeof S.y=="number"&&(n=Math.min(n,S.x),a=Math.max(a,S.x),r=Math.min(r,S.y),c=Math.max(c,S.y),S.out_x!==void 0&&(n=Math.min(n,S.out_x),a=Math.max(a,S.out_x)),S.out_y!==void 0&&(r=Math.min(r,S.out_y),c=Math.max(c,S.out_y)),S.in_x!==void 0&&(n=Math.min(n,S.in_x),a=Math.max(a,S.in_x)),S.in_y!==void 0&&(r=Math.min(r,S.in_y),c=Math.max(c,S.in_y)))});const d=(n+a)/2,l=(r+c)/2,g=this.getPerimeter(t,s,o)*e;let u=0;const p=[];let m=i[0],y=i[0];for(let S=1;S<i.length;S++){const b=i[S];if(b.moveTo){m=b,y=b;continue}p.push({p0:m,p1:b}),(b.closePath||S===i.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:b,p1:y}),m=b}for(const S of p){const b=S.p0,v=S.p1;let w=0;const k=b.out_x!==void 0||v.in_x!==void 0;if(k?w=this.getBezierLength(b.x,b.y,b.out_x??b.x,b.out_y??b.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y):w=Math.sqrt((v.x-b.x)**2+(v.y-b.y)**2),u+w>=g||S===p[p.length-1]){let A=0;if(k)return A=this.getBezierTAtLength(g-u,b.x,b.y,b.out_x??b.x,b.out_y??b.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y,20),this.getBezierPointAndAngle(A,b,v,d,l);{A=w===0?0:(g-u)/w;const x=b.x+(v.x-b.x)*A-d,B=b.y+(v.y-b.y)*A-l,$=Math.atan2(v.y-b.y,v.x-b.x);return{x,y:B,angle:$}}}u+=w}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,c=((t.startAngle??0)+a*e)*Math.PI/180,d=i*Math.cos(c),l=n*Math.sin(c),f=-i*Math.sin(c),g=n*Math.cos(c),u=Math.atan2(g,f);return{x:d,y:l,angle:u}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let c=0,d=0,l=0;return r<i?(c=-i/2+r,d=-n/2,l=0):r<i+n?(c=i/2,d=-n/2+(r-i),l=Math.PI/2):r<2*i+n?(c=i/2-(r-(i+n)),d=n/2,l=Math.PI):(c=-i/2,d=n/2-(r-(2*i+n)),l=-Math.PI/2),{x:c,y:d,angle:l}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,c=s.out_y??s.y,d=o.in_x??o.x,l=o.in_y??o.y,f=o.x,g=o.y,u=1-t,p=t*t,m=u*u,y=m*u,S=p*t,b=y*n+3*m*t*r+3*u*p*d+S*f-e,v=y*a+3*m*t*c+3*u*p*l+S*g-i,w=3*m*(r-n)+6*u*t*(d-r)+3*p*(f-d),k=3*m*(c-a)+6*u*t*(l-c)+3*p*(g-l),A=Math.atan2(k,w);return{x:b,y:v,angle:A}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),i=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,i)}applyArtEffectOverlay(t,s,o,e,i,n){var l;const a=s.artEffect||((l=s.style)==null?void 0:l.artEffect);if(!a||!a.enabled)return;const r=a.type,c=a.intensity??.5,d=a.speed??1;if(r==="acid_gradient"||r==="acid_rave"||r==="shimmer"||r==="halftone"||r==="noise"||r==="scanlines"||r==="chromatic_aberration"){if(t.save(),this.applyPath(t,o,e,i,n),t.clip(),r==="shimmer"){const g=this.currentTime*d%2/2,u=t.createLinearGradient(-e,-i,e,i);u.addColorStop(Math.max(0,g-.2),"rgba(255,255,255,0)"),u.addColorStop(g,`rgba(255,255,255,${c*.8})`),u.addColorStop(Math.min(1,g+.2),"rgba(255,255,255,0)"),t.fillStyle=u,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(r==="acid_gradient"||r==="acid_rave"){const f=this.currentTime*d,g=t.createLinearGradient(-e/2,-i/2,e/2,i/2),u=f*100%360,p=(u+180)%360;g.addColorStop(0,`hsla(${u}, 80%, 50%, ${c*.5})`),g.addColorStop(1,`hsla(${p}, 80%, 50%, ${c*.5})`),t.fillStyle=g,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(r==="halftone"){const f=Math.max(2,20*(1-c)),g=document.createElement("canvas");g.width=f,g.height=f;const u=g.getContext("2d");if(u){u.fillStyle="black",u.beginPath(),u.arc(f/2,f/2,f/2*c,0,Math.PI*2),u.fill();const p=t.createPattern(g,"repeat");p&&(t.globalAlpha=.3*c,t.fillStyle=p,t.fillRect(-e/2,-i/2,e,i))}}else if(r==="noise"){t.globalAlpha=.1*c;for(let f=0;f<5;f++)t.fillStyle=`rgba(${Math.random()*255}, ${Math.random()*255}, ${Math.random()*255}, ${c})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}else if(r==="scanlines"){t.globalAlpha=.2*c,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let f=-i/2;f<i/2;f+=4)t.beginPath(),t.moveTo(-e/2,f),t.lineTo(e/2,f),t.stroke()}else if(r==="chromatic_aberration"){const f=5*c;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-f,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+f,-i/2,e,i)}t.restore()}}applyPath(t,s,o,e,i){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=s,c=o/2,d=e/2,l=n*Math.PI/180,f=a*Math.PI/180,g=l+f;a>=360&&r<=0?t.ellipse(0,0,c,d,0,0,Math.PI*2):(t.ellipse(0,0,c,d,0,l,g,!1),r>0?t.ellipse(0,0,c*r,d*r,0,g,l,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const c=r*2*Math.PI/n-Math.PI/2,d=a*Math.cos(c),l=a*Math.sin(c);r===0?t.moveTo(d,l):t.lineTo(d,l)}t.closePath()}else if(s.type==="Star"){const n=s.inner_radius||20,a=s.outer_radius||50,r=s.points||5;for(let c=0;c<r*2;c++){const d=c*Math.PI/r-Math.PI/2,l=c%2===0?a:n,f=l*Math.cos(d),g=l*Math.sin(d);c===0?t.moveTo(f,g):t.lineTo(f,g)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%10===0&&console.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,c=-1/0;if(s.points.forEach(f=>{typeof f.x=="number"&&typeof f.y=="number"&&(n=Math.min(n,f.x),a=Math.max(a,f.x),r=Math.min(r,f.y),c=Math.max(c,f.y),f.out_x!==void 0&&(n=Math.min(n,f.out_x),a=Math.max(a,f.out_x)),f.out_y!==void 0&&(r=Math.min(r,f.out_y),c=Math.max(c,f.out_y)),f.in_x!==void 0&&(n=Math.min(n,f.in_x),a=Math.max(a,f.in_x)),f.in_y!==void 0&&(r=Math.min(r,f.in_y),c=Math.max(c,f.in_y)))}),n===1/0)return;const d=(n+a)/2,l=(r+c)/2;if(isNaN(d)||isNaN(l)){console.warn("[Engine] Invalid path center:",d,l);return}s.points.forEach((f,g)=>{if(g===0||f.moveTo)t.moveTo(f.x-d,f.y-l);else{const u=s.points[g-1];if(!u)return;const p=(u.out_x??u.x)-d,m=(u.out_y??u.y)-l,y=(f.in_x??f.x)-d,S=(f.in_y??f.y)-l;isNaN(p)||isNaN(y)||isNaN(f.x)?t.lineTo(f.x-d,f.y-l):t.bezierCurveTo(p,m,y,S,f.x-d,f.y-l)}if(f.closePath||g===s.points.length-1&&(s.is_closed||s.isClosed)){const u=[...s.points.slice(0,g+1)].reverse().find(p=>p.moveTo)||s.points[0];u&&(f.out_x!==void 0||u.in_x!==void 0)&&t.bezierCurveTo((f.out_x??f.x)-d,(f.out_y??f.y)-l,(u.in_x??u.x)-d,(u.in_y??u.y)-l,u.x-d,u.y-l),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,c=-1/0;s.points.forEach(f=>{n=Math.min(n,f.x),a=Math.max(a,f.x),r=Math.min(r,f.y),c=Math.max(c,f.y)});const d=(n+a)/2,l=(r+c)/2;s.points.forEach((f,g)=>{if(g===0)t.moveTo(f.x-d,f.y-l);else{const u=s.points[g-1];u.out_x!==void 0||f.in_x!==void 0?t.bezierCurveTo((u.out_x??u.x)-d,(u.out_y??u.y)-l,(f.in_x??f.x)-d,(f.in_y??f.y)-l,f.x-d,f.y-l):t.lineTo(f.x-d,f.y-l)}(f.closePath||g===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var M,Q;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((M=s.geometry)==null?void 0:M.width)||250,n=((Q=s.geometry)==null?void 0:Q.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,c=e.previewState||"default",d=c!=="default"?c:a?"focused":r?"hovered":"default",l=e.label||{visible:!0,text:"Label"},f=e.helperText||{visible:!1,text:"Helper text"},g=e.leftIcon||{visible:!1},u=e.rightIcon||{visible:!1},p=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},S=[y.tl,y.tr,y.br,y.bl];let b=e.backgroundColor||"rgba(31, 41, 55, 1)",v=e.borderColor||"rgba(55, 65, 81, 1)",w=e.borderWidth??1.5,k=e.color||"#ffffff",A=e.placeholderColor||"rgba(156, 163, 175, 1)",x=e.fontSize||14;const B=`${d}Style`,$=e[B];$?($.backgroundColor!==void 0&&(b=$.backgroundColor),$.borderColor!==void 0&&(v=$.borderColor),$.borderWidth!==void 0&&(w=$.borderWidth),$.color!==void 0&&(k=$.color),$.placeholderColor!==void 0&&(A=$.placeholderColor),$.fontSize!==void 0&&(x=$.fontSize)):d==="focused"?(v=e.focusBorderColor||"rgba(59, 130, 246, 1)",w=Math.max(w,2)):d==="hovered"||d==="hover"?(v=e.hoverBorderColor||v,b=e.hoverBackgroundColor||b):d==="disabled"?(b=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",v=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):d==="error"&&(v="rgba(239, 68, 68, 1)",w=Math.max(w,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,S);const K=this.createCanvasFill(t,b,i,n);if(K&&(t.fillStyle=K,t.fill()),w>0){const N=this.createCanvasFill(t,v,i,n);if(N&&(t.strokeStyle=N,t.lineWidth=w,t.stroke()),d==="focused"||d==="focus"){t.save(),t.beginPath();const L=S.map(z=>z+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,L),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const tt=(N,L)=>{if(!N.visible||!N.svgPath)return;const z=N.size||14,pt=N.offset??16,vt=N.color||"#ffffff",yt=L?-(i/2)+pt:i/2-pt,_t=N.svgPath;if(t.save(),t.translate(yt,0),!_t.startsWith("<svg")){const kt=new Path2D(_t),Tt=z/24;t.scale(Tt,Tt),t.translate(-12,-12),t.fillStyle=vt,t.fill(kt)}t.restore()};tt(g,!0),tt(u,!1);const rt=e.text||"",at=e.placeholder||"Enter text...",V=!rt,O=rt||at,R=V?A:k,P=x,J=e.fontFamily||"Inter",j=e.fontWeight||400;t.font=`${j} ${P}px "${J}", sans-serif`,t.fillStyle=R,t.textAlign="left",t.textBaseline=p?"top":"middle";const lt=e.inputPadding??16,Y=g.visible?(g.offset??16)+(g.size||14)/2+8:lt,H=u.visible?(u.offset??16)+(u.size||14)/2+8:lt,it=-(i/2)+Y,nt=i-Y-H,ft=e.inputType==="password"?"•".repeat(O.length):O;if(t.save(),t.beginPath(),t.rect(it-2,-n/2+4,nt+4,n-8),t.clip(),p){const N=ft.split(`
30
- `);let L=-n/2+lt;const z=P*1.2;let pt=0;N.forEach((vt,yt)=>{const _t=vt.split(" ");let kt="";for(let Tt=0;Tt<_t.length;Tt++){const Wt=kt+_t[Tt]+" ";t.measureText(Wt).width>nt&&Tt>0?(t.fillText(kt,it,L),kt=_t[Tt]+" ",L+=z):kt=Wt}t.fillText(kt,it,L),pt=t.measureText(kt).width,yt<N.length-1&&(L+=z,pt=0)}),a&&!V&&Math.floor(performance.now()/500)%2===0&&t.fillRect(it+pt,L,1.5,P)}else{const L=t.measureText(ft).width;let z=0;if(L>nt&&(z=L-nt),t.fillText(ft,it-z,0),a&&!V&&Math.floor(performance.now()/500)%2===0){const vt=it+L-z;t.fillRect(vt,-(P/2),1.5,P)}}if(t.restore(),l.visible!==!1){const N=l.text||"Label",L=l.fontSize||12,z=l.color||"rgba(156, 163, 175, 1)",pt=l.offset??8;t.font=`600 ${L}px "${J}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline="bottom";const vt=-(i/2),yt=-(n/2)-pt;t.fillText(N,vt,yt)}if(f.visible===!0){const N=f.text||"Helper text",L=f.fontSize||11,z=d==="error"?"rgba(239, 68, 68, 1)":f.color||"rgba(156, 163, 175, 1)",pt=f.offset??6;t.font=`400 ${L}px "${J}", sans-serif`,t.fillStyle=z,t.textAlign="left",t.textBaseline="top";const vt=-(i/2),yt=n/2+pt;t.fillText(N,vt,yt)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,d=(i.max??100)-r,l=d===0?0:(a-r)/d,f=i.trackHeight||4,g=i.trackRoundedness??2,u=i.trackShape??"Rectangle",p=i.trackPath||"",m=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",S=i.thumbShape||"Ellipse",b=i.thumbWidth??16,v=i.thumbHeight??16,w=i.thumbRoundedness??0,k=i.thumbColor||"#ffffff",A=i.thumbPath||"",x=i.thumbIcon||"",B=i.showValueTooltip??!1,$=i.tooltipBgColor||"#333333",K=i.tooltipColor||"#ffffff",tt=i.tooltipOffsetX??0,rt=i.tooltipOffsetY??-25,at=(nt,ft,M,Q,N,L,z)=>{if((nt==="Custom"||nt==="Icon")&&z)try{const pt=new Path2D(z);if(t.save(),t.translate(ft,M),nt==="Icon"){const vt=Math.min(Q,N)/24;t.scale(vt,vt),t.translate(-12,-12)}t.fill(pt),t.restore();return}catch(pt){console.error("Error drawing slider shape in engine:",pt)}if(t.beginPath(),nt==="Ellipse")t.ellipse(ft,M,Q/2,N/2,0,0,Math.PI*2);else if(nt==="Rectangle")this.drawRoundRect(t,ft-Q/2,M-N/2,Q,N,L);else if(nt==="Triangle")t.moveTo(ft,M-N/2),t.lineTo(ft+Q/2,M+N/2),t.lineTo(ft-Q/2,M+N/2),t.closePath();else if(nt==="Diamond")t.moveTo(ft,M-N/2),t.lineTo(ft+Q/2,M),t.lineTo(ft,M+N/2),t.lineTo(ft-Q/2,M),t.closePath();else if(nt==="Polygon"){const pt=s.geometry.sides||3,vt=s.geometry.radius||Math.min(Q,N)/2;for(let yt=0;yt<pt;yt++){const _t=yt*2*Math.PI/pt-Math.PI/2,kt=ft+vt*Math.cos(_t),Tt=M+vt*Math.sin(_t);yt===0?t.moveTo(kt,Tt):t.lineTo(kt,Tt)}t.closePath()}else if(nt==="Star"){const vt=Math.min(Q,N)/2,yt=vt/2;for(let _t=0;_t<5*2;_t++){const kt=_t%2===0?vt:yt,Tt=_t*Math.PI/5-Math.PI/2;t.lineTo(ft+kt*Math.cos(Tt),M+kt*Math.sin(Tt))}t.closePath()}else nt==="Line"&&(t.moveTo(ft-Q/2,M),t.lineTo(ft+Q/2,M));t.fill()},V=this.createCanvasFill(t,y,n,f);V&&(t.fillStyle=V,t.strokeStyle=V),u==="Line"?(t.lineWidth=f,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):at(u,0,0,n,f,g,p);const O=n-b,R=-n/2+b/2+l*O,P=R- -n/2;if(P>0){const nt=this.createCanvasFill(t,m,n,f);nt&&(t.fillStyle=nt,t.strokeStyle=nt),u==="Line"?(t.lineWidth=f,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(R,0),t.stroke()):u==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-f/2,P,f,g),t.fill())}t.save(),t.translate(R,0);const J=t.getTransform(),j=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*j,t.shadowOffsetY=1*j;const lt=this.createCanvasFill(t,k,b,v);if(lt&&(t.fillStyle=lt),at(S,0,0,b,v,w,S==="Icon"?x:A),t.restore(),B){t.save(),t.translate(R+tt,rt);const nt=Math.round(a).toString();t.font="10px Inter, sans-serif";const ft=t.measureText(nt),M=6,Q=4,N=ft.width+M*2,L=14+Q;t.beginPath(),this.drawRoundRect(t,-N/2,-L/2,N,L,4),t.fillStyle=$,t.fill(),t.fillStyle=K,t.textAlign="center",t.textBaseline="middle",t.fillText(nt,0,0),t.restore()}const Y=i.label||{},H=i.helperText||{},it=i.fontFamily||"Inter";if(Y.visible!==!1){const nt=Y.text||"Label",ft=Y.fontSize||12,M=Y.color||"rgba(156, 163, 175, 1)",Q=Y.offset??8;t.font=`600 ${ft}px "${it}", sans-serif`,t.fillStyle=M,t.textAlign="left",t.textBaseline="bottom";const N=-(n/2),L=-(f/2)-Q;t.fillText(nt,N,L)}if(H.visible===!0){const nt=H.text||"Helper text",ft=H.fontSize||11,M=H.color||"rgba(156, 163, 175, 1)",Q=H.offset??6;t.font=`400 ${ft}px "${it}", sans-serif`,t.fillStyle=M,t.textAlign="left",t.textBaseline="top";const N=-(n/2),L=f/2+Q;t.fillText(nt,N,L)}}renderDropdown(t,s){var rt;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,c=e.corner_radius??6,d=e.disabled||e.previewState==="disabled",l=this.lastHoveredObjectId===s.id||e.previewState==="hover",f=(e.isOpen||e.previewState==="active")&&!d;let g=e.backgroundColor,u=e.borderColor,p=e.color||"#333333";d?(g=e.disabledBackgroundColor||"#f3f4f6",u=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):f?(g=e.activeBackgroundColor||g,u=e.activeBorderColor||u,p=e.activeColor||p):l&&(g=e.hoverBackgroundColor||g,u=e.hoverBorderColor||u,p=e.hoverColor||p),g||(g="#ffffff"),u||(u="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,c),t.fillStyle=this.createCanvasFill(t,typeof g=="string"?{type:"Solid",color:g}:g,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof u=="string"?{type:"Solid",color:u}:u,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const S=12,b=e.chevronType||"chevron",v=e.chevronSize||16,w=(f?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const at=a+i-S-v/2;t.save(),t.translate(at,0);const V=f?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(V*Math.PI/180),t.strokeStyle=w,t.fillStyle=w,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-v/2,-v*.2),t.lineTo(0,v*.2),t.lineTo(v/2,-v*.2),t.stroke();else if(b==="custom"||b==="path"){const O=f&&e.openIconPath||e.closedIconPath;if(O){const R=new Path2D(O);t.save();const P=v/24;t.scale(P,P),t.translate(-12,-12),t.fill(R),t.restore()}}t.restore()}const k=e.selectedOption||e.placeholder||"Select...",A=e.fontSize||14,x=e.fontWeight||400,B=e.fontFamily||"Inter, sans-serif";t.font=`${x} ${A}px ${B}`;const $=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof $=="string"?{type:"Solid",color:$}:$,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const K=b==="none"?0:v+8,tt=i-S*2-K;if(t.save(),t.beginPath(),t.rect(a+S,r,tt,n),t.clip(),t.fillText(k,a+S,0),t.restore(),f&&!d){const at=r+n+4,V=e.optionsList||[],O=e.itemHeight||32,R=e.listPadding??4,P=V.length*O+R*2,J=e.listCornerRadius??c;t.save();const j=e.listShadow||{},lt=t.getTransform(),Y=Math.sqrt(lt.a*lt.a+lt.b*lt.b)||1;t.shadowColor=typeof j.color=="string"?j.color:((rt=j.color)==null?void 0:rt.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(j.blur??12)*Y,t.shadowOffsetY=(j.offsetY??6)*Y,t.shadowOffsetX=(j.offsetX??0)*Y,t.beginPath(),this.drawRoundRect(t,a,at,i,P,J),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,P)||"#ffffff",t.fill();const H=e.listBorderWidth??1;H>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:u},i,P)||"#e5e7eb",t.lineWidth=H,t.stroke()),t.restore();const it=e.itemFontSize||A,nt=e.itemFontFamily||B;t.font=`${x} ${it}px ${nt}`,V.forEach((ft,M)=>{const Q=at+R+M*O;if(ft===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,O)||"#f3f4f6",t.fillRect(a+H,Q,i-H*2,O),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const L=this._lastPointerPos.y-(at+R),z=Math.floor(L/O);M===z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,O)||"#f9fafb",t.fillRect(a+H,Q,i-H*2,O),t.fillStyle=e.itemHoverColor||p)}t.fillText(ft,a+S,Q+O/2)})}t.globalAlpha=m}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,c=this.activeObjectId===s.id,d=e.label||{},l=e.hoverStyle||{},f=e.activeStyle||{},g=e.icon||{enabled:!1};let u=e.backgroundColor||"#3b82f6",p=d.color||"#ffffff",m=d.text||"Button",y=i.cornerRadius??8,S=e.borderColor||"transparent",b=e.borderWidth||0,v=1;c&&f?(u=f.backgroundColor||u,p=f.color||p,m=f.text||m,v=f.scale??.95,y=f.cornerRadius??y):r&&l&&(u=l.backgroundColor||u,p=l.color||p,m=l.text||m,v=l.scale??1,y=l.cornerRadius??y,S=l.borderColor||S);const w=-n/2,k=-a/2;t.save(),t.scale(v,v),t.beginPath(),this.drawRoundRect(t,w,k,n,a,y);const A=this.createCanvasFill(t,u,n,a);A&&(t.fillStyle=A,t.fill()),(b>0||r&&l.borderColor)&&(t.strokeStyle=S,t.lineWidth=b||(r?1:0),t.stroke());const x=d.fontSize||14,B=d.fontFamily||"Inter",$=d.fontWeight||600;t.font=`${$} ${x}px "${B}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let K=0;if(g.enabled&&g.svgPath){const tt=x*1.1,rt=g.gap||8,at=t.measureText(m),O=-(at.width+tt+rt)/2,R=g.position==="left"?O+tt/2:O+at.width+rt+tt/2;K=g.position==="left"?O+tt+rt+at.width/2:O+at.width/2,t.save(),t.translate(R,0);const P=new Path2D(g.svgPath),J=tt/24;t.scale(J,J),t.translate(-12,-12),t.fillStyle=p,t.fill(P),t.restore()}t.fillText(m,K,0),t.restore()}renderToggleButton(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((m=s.geometry)==null?void 0:m.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,c=-a/2,d=e.corner_radius??8,l=e.label||{},f=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",g=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,c,n,a,d),t.fillStyle=f,t.fill();const u=l.fontSize||14,p=l.fontFamily||"Inter";t.font=`${l.fontWeight||600} ${u}px "${p}", sans-serif`,t.fillStyle=g,t.textAlign="center",t.textBaseline="middle",t.fillText(l.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var J,j,lt,Y,H,it,nt,ft,M,Q,N,L;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((J=s.geometry)==null?void 0:J.width)||52,n=((j=s.geometry)==null?void 0:j.height)||30,a=-i/2,r=-n/2,c=e.checked??!1,d=e.cornerRadius??e.corner_radius??n/2,l=e.toggleStyle||{},f=l.backgroundColor||e.activeColor||"#10b981",g=l.borderColor||e.borderColor||"transparent",u=l.borderWidth??e.borderWidth??0,p=l.knobColor||e.knobColor||"#ffffff",m=c?f:e.inactiveColor||"#374151",y=c?g:e.borderColor||"transparent",S=c?u:e.borderWidth??0,b=c?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,d);const v=this.createCanvasFill(t,m,i,n);if(v&&(t.fillStyle=v,t.fill()),S>0){t.lineWidth=S;const z=this.createCanvasFill(t,y,i,n);z&&(t.strokeStyle=z,t.stroke())}const w=2,k=n-w*2,A=k/2,x=a+w,B=a+i-w-k,$=c?B:x,K=r+w;t.beginPath(),t.arc($+A,K+A,A,0,Math.PI*2);const tt=this.createCanvasFill(t,b,k,k);tt&&(t.fillStyle=tt,t.fill()),e.disabled&&(t.globalAlpha*=2);let rt=!1,at=!1;const V=(c?(lt=l.leftLabel)==null?void 0:lt.text:null)||((Y=e.leftLabel)==null?void 0:Y.text)||"",O=(c?(H=l.leftLabel)==null?void 0:H.color:null)||((it=e.leftLabel)==null?void 0:it.color)||"#f3f4f6";if((nt=e.leftLabel)!=null&&nt.enabled&&V){const z=e.leftLabel;t.font=`${z.fontWeight||400} ${z.fontSize||12}px "${z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=O,t.textBaseline="middle",t.textAlign="right",t.fillText(V,a-(z.gap||8),0),rt=!0}const R=(c?(ft=l.rightLabel)==null?void 0:ft.text:null)||((M=e.rightLabel)==null?void 0:M.text)||"",P=(c?(Q=l.rightLabel)==null?void 0:Q.color:null)||((N=e.rightLabel)==null?void 0:N.color)||"#f3f4f6";if((L=e.rightLabel)!=null&&L.enabled&&R){const z=e.rightLabel;t.font=`${z.fontWeight||400} ${z.fontSize||12}px "${z.fontFamily||"Inter"}", sans-serif`,t.fillStyle=P,t.textBaseline="middle",t.textAlign="left",t.fillText(R,a+i+(z.gap||8),0),at=!0}if(!rt&&!at&&e.label&&e.label.text){const z=e.label,pt=z.fontSize||14,vt=z.fontWeight||400,yt=z.fontFamily||"Inter";t.font=`${vt} ${pt}px "${yt}", sans-serif`,t.fillStyle=z.color||"#f3f4f6",t.textBaseline="middle";const _t=z.gap||10;let kt=0,Tt=0;z.position==="left"?(t.textAlign="right",kt=a-_t,Tt=0):z.position==="right"?(t.textAlign="left",kt=a+i+_t,Tt=0):z.position==="top"?(t.textAlign="center",kt=0,Tt=r-_t,t.textBaseline="bottom"):z.position==="bottom"?(t.textAlign="center",kt=0,Tt=r+n+_t,t.textBaseline="top"):(t.textAlign="left",kt=a+i+_t,Tt=0),t.fillText(z.text,kt,Tt)}}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(p=>p.data&&p.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(p=>{let m=p.data;if(p.isVarEnabled&&p.inputId){let y=this.inputs.get(p.inputId);if(y===void 0){const S=this.inputNameMap.get(p.inputId);S&&S.length>0&&(y=this.inputs.get(S[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(S=>typeof S=="number"&&!isNaN(S));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,m.length))}p._resolvedData=m}),r<2)return;const c=a-n,d=o/(r-1),l=p=>{const m=c===0?.5:(p-n)/c;return e/2-m*e},f=p=>p*d-o/2,g=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||g,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||g,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<r;p++){const m=f(p);t.fillText(`${p+1}`,m,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),p,l(a)),t.fillText(m.toFixed(1),p,l(m)),t.fillText(n.toFixed(1),p,l(n))}const u=10;if(i.forEach(p=>{const m=p._resolvedData;if(!(!m||m.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(f(0),e/2),t.lineTo(f(0),l(m[0])),p.smoothing&&m.length>2)for(let S=0;S<m.length-1;S++){const b=m[S===0?S:S-1],v=m[S],w=m[S+1],k=m[S+1===m.length-1?S+1:S+2];for(let A=1;A<=u;A++){const x=A/u,B=this._catmullRom(b,v,w,k,x);t.lineTo(f(S+x),l(B))}}else for(let S=1;S<m.length;S++)t.lineTo(f(S),l(m[S]));t.lineTo(f(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=p.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=p.lineColor||"#3b82f6",t.lineWidth=p.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(f(0),l(m[0])),p.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const S=m[y===0?y:y-1],b=m[y],v=m[y+1],w=m[y+1===m.length-1?y+1:y+2];for(let k=1;k<=u;k++){const A=k/u,x=this._catmullRom(S,b,v,w,A);t.lineTo(f(y+A),l(x))}}else for(let y=1;y<m.length;y++)t.lineTo(f(y),l(m[y]));t.stroke(),p.showPoints&&m.forEach((y,S)=>{const b=f(S),v=l(y);t.beginPath(),t.arc(b,v,(p.pointSize||6)/2,0,Math.PI*2),t.fillStyle=p.pointFill||"#ffffff",t.fill(),t.strokeStyle=p.pointStrokeColor||p.lineColor||"#3b82f6",t.lineWidth=p.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const p=o/2-10;let m=-e/2+15;const y=s.legendFontSize||10,S=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(b=>{const w=b.label||"Series",k=t.measureText(w).width;t.beginPath(),t.rect(p-k-8-5,m-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(w,p,m),m+=S})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,c=i*r;return(2*s-2*o+n+a)*c+(-3*s+3*o-2*n-a)*r+n*i+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,d=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=d,d}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(c,d=100)=>{var v,w;const f=(((w=(v=this.artboard)==null?void 0:v.tokens)==null?void 0:w.colors)||{})[c]||c,g=this.normalizeOpacity(s.opacity??100),p=this.normalizeOpacity(d)*g;if(p>=1&&f.startsWith("#"))return f;const m=f.startsWith("#")?f.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),S=parseInt(m.substring(2,4),16),b=parseInt(m.substring(4,6),16);return`rgba(${y}, ${S}, ${b}, ${p})`};if(s.type==="LinearGradient"){const c=(p,m,y)=>Array.isArray(p)?p[m]??(m===0?0:1):p&&typeof p=="object"?p[y]??(m===0?0:1):m===0?0:1,d=c(s.start,0,"x")*o-o/2,l=c(s.start,1,"y")*e-e/2,f=c(s.end,0,"x")*o-o/2,g=c(s.end,1,"y")*e-e/2,u=t.createLinearGradient(d,l,f,g);if(s.stops.forEach(p=>{const m=p.offset!==void 0?p.offset:p.pos!==void 0?p.pos:p.position!==void 0?p.position:0,y=r(p.color||"#000000",p.opacity??100);u.addColorStop(Math.max(0,Math.min(1,m)),y)}),s.gradientTransform&&u.setTransform){const[p,m,y,S,b,v]=s.gradientTransform;u.setTransform({a:p,b:m,c:y,d:S,e:b,f:v})}return u}else if(s.type==="RadialGradient"){const c=(u,p,m)=>Array.isArray(u)?u[p]??.5:u&&typeof u=="object"?u[m]??.5:.5,d=c(s.center,0,"x")*o-o/2,l=c(s.center,1,"y")*e-e/2,f=(s.radius??.5)*Math.max(o,e),g=t.createRadialGradient(d,l,0,d,l,f);if(s.stops.forEach(u=>{const p=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);g.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&g.setTransform){const[u,p,m,y,S,b]=s.gradientTransform;g.setTransform({a:u,b:p,c:m,d:y,e:S,f:b})}return g}else if(s.type==="AngularGradient"){const c=(u,p,m)=>Array.isArray(u)?u[p]??.5:u&&typeof u=="object"?u[m]??.5:.5,d=c(s.center||[.5,.5],0,"x")*o-o/2,l=c(s.center||[.5,.5],1,"y")*e-e/2,f=(s.degree||s.angle||0)*(Math.PI/180),g=(a=t.createConicGradient)==null?void 0:a.call(t,f,d,l);if(g){if(s.stops.forEach(u=>{const p=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);g.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&g.setTransform){const[u,p,m,y,S,b]=s.gradientTransform;g.setTransform({a:u,b:p,c:m,d:y,e:S,f:b})}return g}}else if(s.type==="DiamondGradient"){const c=(u,p,m)=>Array.isArray(u)?u[p]??.5:u&&typeof u=="object"?u[m]??.5:.5,d=c(s.center||[.5,.5],0,"x")*o-o/2,l=c(s.center||[.5,.5],1,"y")*e-e/2,f=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,l),t.rotate(Math.PI/4);const g=t.createRadialGradient(0,0,0,0,0,f);if(s.stops.forEach(u=>{const p=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);g.addColorStop(Math.max(0,Math.min(1,p)),m)}),s.gradientTransform&&g.setTransform){const[u,p,m,y,S,b]=s.gradientTransform;g.setTransform({a:u,b:p,c:m,d:y,e:S,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=g,t.restore(),g}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const c=t.createPattern(r,"repeat");if(c&&(s.scaleX!==void 0||s.offsetX!==void 0)){const d=new DOMMatrix,l=s.scaleX??1,f=s.scaleY??1,g=s.offsetX??0,u=s.offsetY??0,p=s.rotation??0;d.translateSelf(g,u),d.rotateSelf(p),d.scaleSelf(l,f),c.setTransform(d)}return c}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,c=0,d=0,l=0;typeof a=="number"?r=c=d=l=a:Array.isArray(a)?a.length===1?r=c=d=l=a[0]:a.length===2?(r=d=a[0],c=l=a[1]):a.length===3?(r=a[0],c=l=a[1],d=a[2]):a.length>=4&&(r=a[0],c=a[1],d=a[2],l=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,c=a.tr??a.corner_radius??a.cornerRadius??0,d=a.br??a.corner_radius??a.cornerRadius??0,l=a.bl??a.corner_radius??a.cornerRadius??0);const f=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),f),c=Math.min(Math.max(0,c),f),d=Math.min(Math.max(0,d),f),l=Math.min(Math.max(0,l),f),t.roundRect){t.roundRect(s,o,e,i,[r,c,d,l]);return}t.moveTo(s+r,o),t.lineTo(s+e-c,o),t.arcTo(s+e,o,s+e,o+c,c),t.lineTo(s+e,o+i-d),t.arcTo(s+e,o+i,s+e-d,o+i,d),t.lineTo(s+l,o+i),t.arcTo(s,o+i,s,o+i-l,l),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var at,V,O,R;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((at=s.geometry)==null?void 0:at.width)||200,n=o.height!==void 0?o.height:((V=s.geometry)==null?void 0:V.height)||300,a=-i/2,r=-n/2,c=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,d=e.orientation||"vertical",l=e.items||[],f=e.itemGap??10,g=e.itemHeight??50,u=e.itemWidth??200,p=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,S=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",v=e.itemBackgroundColor||"#ffffff",w=e.hoveredIndex??null,k=e.activeItemIndex??null,A=e.glowIntensity??0,x=e.glowColor||"#3b82f6",B=typeof x=="string"?x:x.color||((R=(O=x.stops)==null?void 0:O[0])==null?void 0:R.color)||"#3b82f6",$=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=$,A>0){const P=t.getTransform(),J=Math.sqrt(P.a*P.a+P.b*P.b)||1;t.shadowColor=B,t.shadowBlur=A*2*J,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const P=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",J=this.createCanvasFill(t,P,i,n);t.fillStyle=J||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(t,a,r,i,n,c),t.fill();const j=t.createLinearGradient(a,r,a+i,r+n);j.addColorStop(0,"rgba(255, 255, 255, 0.15)"),j.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),j.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=j,this.drawListViewRect(t,a,r,i,n,c),t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,this.drawListViewRect(t,a,r,i,n,c),t.stroke()}else{const P=e.listBackgroundColor||"transparent",J=this.createCanvasFill(t,P,i,n);J&&(t.fillStyle=J,this.drawListViewRect(t,a,r,i,n,c),t.fill());const j=e.borderWidth??0;j>0&&(t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=j,this.drawListViewRect(t,a,r,i,n,c),t.stroke())}t.shadowBlur=0,t.save(),this.drawListViewRect(t,a,r,i,n,c),t.clip();const K=typeof m=="number"?m:d==="vertical"?m[0]:m[3];let tt=(d==="vertical"?r:a)+p+K;if(t.textBaseline="middle",l.forEach((P,J)=>{const j=d==="vertical"?i:u,lt=d==="vertical"?g:n,Y=d==="vertical"?a:tt,H=d==="vertical"?tt:r,it=w===J,nt=k===J;if(nt){const L=this.createCanvasFill(t,S,j,lt);t.fillStyle=L||S;const z=t.globalAlpha;t.globalAlpha=z*.8,t.fillRect(Y,H,j,lt),t.globalAlpha=z}else if(it)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.fillRect(Y,H,j,lt);else if(v!=="transparent"){const L=this.createCanvasFill(t,v,j,lt);t.fillStyle=L||v,t.fillRect(Y,H,j,lt)}if(nt||it){const L=this.createCanvasFill(t,S,d==="vertical"?3:j,d==="vertical"?lt:3);t.fillStyle=L||S,d==="vertical"?t.fillRect(Y,H,3,lt):t.fillRect(Y,H+lt-3,j,3)}const ft=nt?"#ffffff":y?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=ft,t.font=nt||it?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const M=typeof P=="string"?P:(P==null?void 0:P.label)||`Item ${J+1}`,Q=Y+(d==="vertical"?16:j/2),N=H+lt/2;d==="horizontal"?t.textAlign="center":t.textAlign="left",t.fillText(M,Q,N),tt+=(d==="vertical"?g:u)+f}),t.restore(),e.showScrollbar!==!1){const P=(l.length||0)*(d==="vertical"?g:u)+((l.length||0)-1)*f,J=d==="vertical"?n:i;if(P>J){const j=J/P,lt=J*j,Y=-p/P*J,H=e.scrollbarColor||"rgba(255,255,255,0.3)",it=e.scrollbarWidth||4;t.fillStyle=H,d==="vertical"?t.fillRect(a+i-it-2,r+Y,it,lt):t.fillRect(a+Y,r+n-it-2,lt,it)}}t.restore()}updateListViewScrollFromPointer(t){var m,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=this.objectStates.get(t.id)||{},a=s.items||[],r=s.itemGap??10,c=s.itemHeight??50,d=s.itemWidth??200,l=n.width!==void 0?n.width:((m=t.geometry)==null?void 0:m.width)||200,f=n.height!==void 0?n.height:((y=t.geometry)==null?void 0:y.height)||300,g=(a.length||0)*(o==="vertical"?c:d)+((a.length||0)-1)*r,p=Math.max(0,g-(o==="vertical"?f:l)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-p&&(s.scrollOffset=-p)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var K,tt;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((K=t.geometry)==null?void 0:K.width)||200,r=i.height!==void 0?i.height:((tt=t.geometry)==null?void 0:tt.height)||300,c=e.orientation||"vertical",d=e.itemGap??10,l=e.itemHeight??50,f=e.itemWidth??200,g=e.scrollOffset??0,u=e.padding??0,p=this.getWorldTransform(t.id),m=s-p.x,y=o-p.y,S=-p.rotation*(Math.PI/180),b=Math.cos(S),v=Math.sin(S),w=m*b-y*v,k=m*v+y*b,A=-a/2,x=-r/2,B=typeof u=="number"?u:c==="vertical"?u[0]:u[3];let $=(c==="vertical"?x:A)+g+B;for(let rt=0;rt<n.length;rt++){const at=c==="vertical"?a:f,V=c==="vertical"?l:r,O=c==="vertical"?A:$,R=c==="vertical"?$:x;if(w>=O&&w<=O+at&&k>=R&&k<=R+V)return rt;$+=(c==="vertical"?l:f)+d}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var f,g,u,p,m,y,S,b,v,w,k,A,x,B,$,K,tt,rt,at,V,O,R,P,J,j,lt,Y,H,it,nt,ft,M,Q,N,L,z,pt,vt,yt,_t,kt,Tt,Wt,Yt,Dt,Vt,zt,st,ct,_,I,D,Z,bt,Mt,ht,Pt,mt,C,Et,Gt,Rt,dt,T,G,ut,E,F,et,It,Ot,St,Ft,wt,Xt,Jt,Qt;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const c=i.x-s,d=i.y-o,l=Math.sqrt(c*c+d*d);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===W.Proximity){const U=((f=n.settings)==null?void 0:f.radius)||300,X=((g=n.settings)==null?void 0:g.falloff)||"smooth";let q=0;l<U&&(X==="linear"?q=1-l/U:q=Math.pow(1-l/U,2)),q>0&&n.sensors.forEach(Ct=>{this.applyBehaviorSensor(i,Ct,q,t,n.settings,e)})}else if(n.type===W.Magnetic){const U=((u=n.settings)==null?void 0:u.radius)||400,X=((p=n.settings)==null?void 0:p.strength)||.5;if(l<U&&l>5){const q=1-l/U,Ct=c*q*X,$t=d*q*X;i.x-=Ct*t*10,i.y-=$t*t*10}}else if(n.type===W.Repel){const U=((m=n.settings)==null?void 0:m.radius)||300,X=((y=n.settings)==null?void 0:y.strength)||1;if(l<U){const q=Math.pow(1-l/U,2);i.x+=c/(l||1)*q*60*X*t*5,i.y+=d/(l||1)*q*60*X*t*5}}else if(n.type===W.Orbit){const U=((S=n.settings)==null?void 0:S.speed)||1,X=((b=n.settings)==null?void 0:b.radius)||30,q=this.currentTime*U*Math.PI*2;i.x+=Math.cos(q)*X*t*5,i.y+=Math.sin(q)*X*t*5,i.rotation+=2*t*5}else if(n.type===W.Vortex){const U=((v=n.settings)==null?void 0:v.radius)||400,X=((w=n.settings)==null?void 0:w.speed)||2,q=((k=n.settings)==null?void 0:k.strength)||1;if(l<U){const Ct=Math.pow(1-l/U,1.5),$t=this.currentTime*X*Math.PI*2,Ht=Math.cos($t)*30-c*.4,Ut=Math.sin($t)*30-d*.4;i.x+=Ht*Ct*q*t*5,i.y+=Ut*Ct*q*t*5,i.rotation+=5*Ct*q*t*5,i.scale_x*=1-Ct*.1*q*t,i.scale_y*=1-Ct*.1*q*t}}else if(n.type===W.Fluid){const U=((A=n.settings)==null?void 0:A.radius)||300,X=((x=n.settings)==null?void 0:x.strength)||1;if(l<U){const q=Math.pow(1-l/U,1.2),Ct=c/(l||1)*q*1.2*X,$t=d/(l||1)*q*1.2*X;i.x+=Ct*10*t*5,i.y+=$t*10*t*5,i.scale_x*=1+q*.3*X*t,i.scale_y*=1+q*.3*X*t}}else if(n.type===W.Elastic){const U=((B=n.settings)==null?void 0:B.radius)||300,X=(($=n.settings)==null?void 0:$.strength)||1;if(l<U){const q=1-l/U;i.scale_x*=1+q*.4*X*t,i.scale_y*=1+q*.4*X*t}}else if(n.type===W.Holographic){const U=i.x-this.canvasWidth/2,X=i.y-this.canvasHeight/2,q=((K=n.settings)==null?void 0:K.factor)||25;if(i.x-=U/1e3*q*t*5,i.y-=X/1e3*q*t*5,i.style){const Ct=1-Math.min(1,l/400);i.style.exposure=(i.style.exposure||1)+Ct*.5*t}}else if(n.type===W.Sticky){const U=((tt=n.settings)==null?void 0:tt.radius)||80,X=((rt=n.settings)==null?void 0:rt.strength)||1;if(l<U){const q=Math.pow(1-l/U,2);i.x-=c*q*X*t*10,i.y-=d*q*X*t*10,i.scale_x*=1-q*.1*X*t,i.scale_y*=1-q*.1*X*t}}else if(n.type===W.Dilation){const U=((at=n.settings)==null?void 0:at.size)||120,X=((V=n.settings)==null?void 0:V.strength)||1;if(l<U){const q=1-l/U;i.scale_x*=1+q*.5*X*t,i.scale_y*=1+q*.5*X*t}}else if(n.type===W.Parallax){const U=((O=n.settings)==null?void 0:O.factor)||.05,X=this.canvasHeight/2,q=(this._lastPointerPos.y-X)*U;i.y+=q*t*10}else if(n.type===W.Squash){const U=((R=n.settings)==null?void 0:R.strength)||.8;l<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((P=e.transform)==null?void 0:P.scale_y)??1)*U,.3),i.scale_x=this.lerp(i.scale_x??1,(((J=e.transform)==null?void 0:J.scale_x)??1)*(1+(1-U)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((j=e.transform)==null?void 0:j.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((lt=e.transform)==null?void 0:lt.scale_x)??1,.2))}else if(n.type===W.TextCounter){const U=((Y=n.settings)==null?void 0:Y.duration)||2,X=((H=n.settings)==null?void 0:H.from)||0,q=((it=n.settings)==null?void 0:it.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const Ct=this.currentTime-n._runtimeStart,$t=Math.min(1,Ct/U),Ht=Math.floor(X+(q-X)*$t);if(((nt=e.geometry)==null?void 0:nt.type)==="Text"){const Ut=((ft=n.settings)==null?void 0:ft.prefix)||"",qt=((M=n.settings)==null?void 0:M.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${Ut}${Ht}${qt}`}}else if(n.type===W.Spotlight){const U=((Q=n.settings)==null?void 0:Q.radius)||250,X=((N=n.settings)==null?void 0:N.strength)||1.5;if(l<U){const q=Math.pow(1-l/U,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(L=e.style)==null?void 0:L.adjustments}),i.style.adjustments.exposure=(((pt=(z=e.style)==null?void 0:z.adjustments)==null?void 0:pt.exposure)||0)+q*X*50}else(vt=i.style)!=null&&vt.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((_t=(yt=e.style)==null?void 0:yt.adjustments)==null?void 0:_t.exposure)||0,.1))}else if(n.type===W.Noise||n.type===W.Float){const U=(((kt=n.settings)==null?void 0:kt.frequency)||((Tt=n.settings)==null?void 0:Tt.speed)||1)*.002,X=(((Wt=n.settings)==null?void 0:Wt.amplitude)||((Yt=n.settings)==null?void 0:Yt.range)||50)*(((Dt=n.settings)==null?void 0:Dt.strength)||1),q=Date.now();i.x+=Math.sin(q*U)*X*t,i.y+=Math.cos(q*U*.8)*X*t,i.rotation+=Math.sin(q*U*.5)*5*t}else if(n.type===W.Pulse){const U=(((Vt=n.settings)==null?void 0:Vt.speed)||1)*.005,X=(((zt=n.settings)==null?void 0:zt.scale)||1.2)-1,q=Math.sin(Date.now()*U),Ct=((st=n.settings)==null?void 0:st.strength)||1;i.scale_x*=1+q*X*Ct*t,i.scale_y*=1+q*X*Ct*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,q)*.1*Ct*t)}else if(n.type===W.Draggable){const U=((ct=n.settings)==null?void 0:ct.radius)||150,X=this.draggingBehaviors.has(e.id);if(l<U||X){const q=((_=n.settings)==null?void 0:_.strength)||1,Ct=X?1:Math.max(0,1-l/U);this.applyBehaviorSensor(i,Bt.PositionX,Ct*q,t,n.settings),this.applyBehaviorSensor(i,Bt.PositionY,Ct*q,t,n.settings)}}else if(n.type===W.Scroll){const U=((I=n.settings)==null?void 0:I.axis)||"vertical",X=((D=n.settings)==null?void 0:D.factor)||.5,q=((Z=n.settings)==null?void 0:Z.strength)||1,Ct=((bt=n.settings)==null?void 0:bt.scaleFactor)||0;(U==="vertical"||U==="both")&&(i.y+=this.scrollOffset.y*X*q*t),(U==="horizontal"||U==="both")&&(i.x+=this.scrollOffset.x*X*q*t),Ct!==0&&(i.scale_x*=1+this.scrollOffset.y*Ct*t,i.scale_y*=1+this.scrollOffset.y*Ct*t)}else if(n.type===W.LookAt){const U=((Mt=n.settings)==null?void 0:Mt.factor)||1,X=((ht=n.settings)==null?void 0:ht.strength)||1,q=Math.atan2(-d,-c)*(180/Math.PI),Ct=i.rotation,$t=(q-Ct+180)%360-180;i.rotation+=$t*U*X*t*10}else if(n.type===W.Glint||n.type===W.Scan){const U=(((Pt=n.settings)==null?void 0:Pt.speed)||1)*.004,X=((mt=n.settings)==null?void 0:mt.strength)||1,q=(Math.sin(Date.now()*U)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+q*X*t*5),i.x+=(q-.5)*20*X*t}else if(n.type===W.Ratchet){const U=((C=n.settings)==null?void 0:C.steps)||12,X=(((Et=n.settings)==null?void 0:Et.speed)||1)*30,q=Math.floor(i.rotation/(360/U))*(360/U);i.rotation=this.lerp(i.rotation,q+X*t,.1)}else if(n.type===W.Jitter&&l<300){const U=((Gt=n.settings)==null?void 0:Gt.strength)||1,X=(((Rt=n.settings)==null?void 0:Rt.intensity)||5)*U;i.x+=(Math.random()-.5)*X*t*60,i.y+=(Math.random()-.5)*X*t*60,i.rotation+=(Math.random()-.5)*X*t*120}else if(n.type===W.Follower){const U=(dt=n.settings)==null?void 0:dt.targetId;if(U){const X=this.objectStates.get(U);if(X){const q=((T=n.settings)==null?void 0:T.stiffness)||.1,Ct=X.x-i.x,$t=X.y-i.y;i.x+=Ct*q*t*60,i.y+=$t*q*t*60}}}else if(n.type===W.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===W.Gravity){const U=((G=n.settings)==null?void 0:G.strength)||9.8;i.y+=U*t*10}else if(n.type===W.Velocity){const U=((ut=n.settings)==null?void 0:ut.vx)||0,X=((E=n.settings)==null?void 0:E.vy)||0;i.x+=U*t*10,i.y+=X*t*10}else if(n.type===W.Shear){const U=((F=n.settings)==null?void 0:F.strength)||1,X=((et=n.settings)==null?void 0:et.radius)||300;if(l<X){const q=1-l/X;i.skew_x=this.lerp(i.skew_x||0,(((It=e.transform)==null?void 0:It.skew_x)||0)+q*U*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((Ot=e.transform)==null?void 0:Ot.skew_x)||0,.05)}else if(n.type===W.Lens){const U=((St=n.settings)==null?void 0:St.radius)||200,X=((Ft=n.settings)==null?void 0:Ft.strength)||.5;if(l<U){const q=Math.pow(1-l/U,2);i.scale_x=this.lerp(i.scale_x??1,(((wt=e.transform)==null?void 0:wt.scale_x)??1)*(1+q*X),.2),i.scale_y=this.lerp(i.scale_y??1,(((Xt=e.transform)==null?void 0:Xt.scale_y)??1)*(1+q*X),.2)}else i.scale_x=this.lerp(i.scale_x??1,((Jt=e.transform)==null?void 0:Jt.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((Qt=e.transform)==null?void 0:Qt.scale_y)??1,.1)}})})}applyBehaviorSensor(t,s,o,e,i,n){var c,d,l,f,g,u,p,m,y;const a=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,r=o*a*e;switch(s){case Bt.Scale:t.scale_x*=1+r*.5,t.scale_y*=1+r*.5;break;case Bt.Opacity:t.opacity=Math.max(0,Math.min(100,t.opacity-r*100));break;case Bt.RotateZ:t.rotation+=r*180;break;case Bt.RotateX:t.rotate_x=(t.rotate_x||0)+r*180;break;case Bt.RotateY:t.rotate_y=(t.rotate_y||0)+r*180;break;case Bt.PositionX:t.x+=r*300;break;case Bt.PositionY:t.y+=r*300;break;case Bt.SkewX:t.skew_x=(t.skew_x||0)+r*45;break;case Bt.Blur:t.style||(t.style={...n.style}),t.style.blur||(t.style.blur={...(c=n.style)==null?void 0:c.blur}),t.style.blur.amount=(((l=(d=n.style)==null?void 0:d.blur)==null?void 0:l.amount)||0)+o*((i==null?void 0:i.blur)||50)*a;break;case Bt.Exposure:t.style||(t.style={...n.style}),t.style.adjustments||(t.style.adjustments={...(f=n.style)==null?void 0:f.adjustments}),t.style.adjustments.exposure=(((u=(g=n.style)==null?void 0:g.adjustments)==null?void 0:u.exposure)||0)+o*((i==null?void 0:i.exposure)||50)*a;break;case Bt.HueShift:t.style||(t.style={...n.style}),t.style.adjustments||(t.style.adjustments={...(p=n.style)==null?void 0:p.adjustments}),t.style.adjustments.hue=(((y=(m=n.style)==null?void 0:m.adjustments)==null?void 0:y.hue)||0)+o*((i==null?void 0:i.hue)||180)*a;break;case Bt.CornerRadius:t.corner_radius=Math.min(200,(t.corner_radius||0)+r*100);break;case Bt.LetterSpacing:t.geometry||(t.geometry={}),t.geometry.letterSpacing=(t.geometry.letterSpacing||0)+r*10;break}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,c=s.naturalHeight,d=r/c,l=i/n;let f=i,g=n,u=o,p=e;a==="cover"?d>l?(f=n*d,u=o-(f-i)/2):(g=i/d,p=e-(g-n)/2):a==="contain"&&(d>l?(g=i/d,p=e+(n-g)/2):(f=n*d,u=o+(i-f)/2)),t.drawImage(s,u,p,f,g)}}const is=xt.forwardRef(({artboard:h,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:c,onToggle:d,onInputChange:l,onInputFocus:f,onInputBlur:g,onLog:u,onLogicUpdate:p,onButtonClick:m,onGraphPointClick:y,currentTime:S,revision:b=0,scrollY:v,scrollX:w,mouseX:k,mouseY:A,isMouseDown:x,inputs:B,interactive:$=!0,onNavigation:K},tt)=>{const rt=xt.useRef(null),at=xt.useRef(new ve),V=xt.useRef(void 0),O=xt.useRef(0),R=xt.useRef(null),P=xt.useRef(b),[,J]=xt.useState(h||null),j=xt.useRef(!0);xt.useImperativeHandle(tt,()=>rt.current),xt.useEffect(()=>(j.current=!0,()=>{j.current=!1,V.current&&cancelAnimationFrame(V.current)}),[]),xt.useEffect(()=>{at.current.setLayout(e,i)},[e,i]),xt.useEffect(()=>{const Y=at.current;a&&Y.setTriggerCallback(a),r&&Y.setInputUpdateCallback((H,it)=>r({[H]:it})),c&&Y.setComponentChangeCallback(H=>c(H)),d&&Y.setToggleCallback(d),l&&Y.setInputChangeCallback(l),f&&Y.setInputFocusCallback(f),g&&Y.setInputBlurCallback(g),u&&Y.setOnLogCallback(H=>u(H,"info")),p&&Y.setLogicUpdateCallback(p),m&&Y.setButtonClickCallback(m),y&&Y.setGraphPointClickCallback(H=>y(H.objectId,H)),K&&Y.setNavigationCallback(K)},[a,r,c,d,l,f,g,u,p,m,y,K]),xt.useEffect(()=>{(async()=>{let H=h;if(t&&!h)try{t.startsWith("{")?H=JSON.parse(t):H=await(await fetch(t)).json()}catch(it){console.error("[ExodeUI] Failed to load src:",it)}if(H){const it=at.current,nt=H.id||H.name||"default";(R.current!==nt||P.current!==b)&&(it.load(H),R.current=nt,P.current=b,J(H),O.current=0,it.advance(0)),n&&n(it)}})()},[h==null?void 0:h.id,t,b]),xt.useEffect(()=>{const Y=H=>{if(!at.current||!j.current)return;const it=at.current,nt=rt.current;if(!nt)return;const ft=nt.getContext("2d");if(!ft)return;const M=H/1e3;O.current===0&&(O.current=M);let Q=M-O.current;Q>.1&&(Q=.1),O.current=M;const N=nt.getBoundingClientRect(),L=window.devicePixelRatio||1,z=Math.round(N.width*L),pt=Math.round(N.height*L);(nt.width!==z||nt.height!==pt)&&(nt.width=z,nt.height=pt),o?it.advance(Q):S!==void 0&&it.seek(S),it.render(ft,nt.width,nt.height),V.current=requestAnimationFrame(Y)};return V.current=requestAnimationFrame(Y),()=>{V.current&&cancelAnimationFrame(V.current)}},[o,S]),xt.useEffect(()=>{const Y=at.current;v!==void 0&&Y.updateInput("scrollY",v),w!==void 0&&Y.updateInput("scrollX",w),k!==void 0&&Y.updateInput("mouseX",k),A!==void 0&&Y.updateInput("mouseY",A),x!==void 0&&Y.updateInput("isMouseDown",x),B&&Object.entries(B).forEach(([H,it])=>Y.updateInput(H,it))},[v,w,k,A,x,B]);const lt=(Y,H)=>{if(!$||!rt.current)return;const it=rt.current,nt=it.getBoundingClientRect(),ft=Y.clientX-nt.left,M=Y.clientY-nt.top,Q=window.devicePixelRatio||1;at.current.handlePointerInput(H,ft*Q,M*Q,it.width,it.height)};return Lt.jsx("canvas",{ref:rt,onPointerDown:Y=>{var H;lt(Y,"down"),(H=rt.current)==null||H.focus()},onPointerMove:Y=>lt(Y,"move"),onPointerUp:Y=>lt(Y,"up"),onPointerCancel:Y=>lt(Y,"up"),onClick:Y=>lt(Y,"click"),onWheel:Y=>{at.current.handleWheel(Y.deltaX,Y.deltaY)},onKeyDown:Y=>at.current.handleKeyDown(Y.nativeEvent),onContextMenu:Y=>Y.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:$?"auto":"none"}})});function ns(){const[h,t]=xt.useState(null),s=xt.useCallback((l,f)=>{h==null||h.setInputBool(l,f)},[h]),o=xt.useCallback((l,f)=>{h==null||h.setInputNumber(l,f)},[h]),e=xt.useCallback(l=>{h==null||h.fireTrigger(l)},[h]),i=xt.useCallback((l,f)=>{h==null||h.setInputText(l,f)},[h]),n=xt.useCallback((l,f)=>{h==null||h.setInputNumberArray(l,f)},[h]),a=xt.useCallback((l,f)=>{h==null||h.setInputStringArray(l,f)},[h]),r=xt.useCallback((l,f)=>{h==null||h.updateObjectOptions(l,f)},[h]),c=xt.useCallback((l,f,g)=>{h==null||h.updateConstraint(l,f,g)},[h]),d=xt.useCallback((l,f)=>{h==null||h.updateGraphData(l,f)},[h]);return{setEngine:t,engine:h,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:c,updateGraphData:d,updateObjectOptions:r}}const os=({artboard:h,config:t})=>{const s={...h.seo,...t},o=s.enableSmartExtraction!==!1;xt.useEffect(()=>{const a=s.title||h.name;a&&(document.title=a);let r=s.description;if(!r&&o){const l=h.objects.filter(f=>{var g;return((g=f.geometry)==null?void 0:g.type)==="Text"}).sort((f,g)=>{var u,p;return(((u=g.geometry.text)==null?void 0:u.length)||0)-(((p=f.geometry.text)==null?void 0:p.length)||0)});l.length>0&&(r=l[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const c=s.ogImage||h.backgroundImage;c&&e("property","og:image",c),a&&e("property","og:title",a),e("property","og:type","website")},[s,h,o]);const e=(a,r,c)=>{let d=document.querySelector(`meta[${a}="${r}"]`);d||(d=document.createElement("meta"),d.setAttribute(a,r),document.head.appendChild(d)),d.setAttribute("content",c)},i=()=>{const a=[];return a.push(Lt.jsx("h1",{children:s.title||h.name},"artboard-title")),h.objects.forEach((c,d)=>{var l,f;if(!(!c.visible&&c.isVisible!==!0))if(((l=c.geometry)==null?void 0:l.type)==="Text"){const g=c.geometry.text;g&&(c.geometry.fontSize>24?a.push(Lt.jsx("h2",{children:g},c.id||d)):a.push(Lt.jsx("p",{children:g},c.id||d)))}else if(((f=c.geometry)==null?void 0:f.type)==="Image"){const g=c.geometry.src,u=c.altText||c.name||"Illustration";a.push(Lt.jsx("img",{src:g,alt:u},c.id||d))}else c.type==="Button"&&a.push(Lt.jsx("button",{children:c.name||"Button"},c.id||d))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||h.name,description:s.description,image:s.ogImage||h.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Lt.jsxs("div",{id:`exode-seo-${h.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[i(),Lt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},as={version:"6.3.14"}.version;At.BehaviorSensor=Bt,At.BehaviorType=W,At.ConditionOp=oe,At.ExodeSEO=os,At.ExodeUICanvas=is,At.ExodeUIEngine=ve,At.LogicOp=gt,At.VERSION=as,At.useExodeUI=ns,Object.defineProperty(At,Symbol.toStringTag,{value:"Module"})});
1
+ (function(Ht,Zt){typeof exports=="object"&&typeof module<"u"?Zt(exports,require("react/jsx-runtime"),require("react"),require("@chenglou/pretext"),require("@dimforge/rapier2d-compat"),require("lz-string")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@chenglou/pretext","@dimforge/rapier2d-compat","lz-string"],Zt):(Ht=typeof globalThis<"u"?globalThis:Ht||self,Zt(Ht.ExodeUIReact={},Ht.jsxRuntime,Ht.React,Ht.pretext,Ht.Rapier,Ht.LZString))})(this,function(Ht,Zt,$t,xe,le,ys){"use strict";var ri=Object.defineProperty;var li=(Ht,Zt,$t)=>Zt in Ht?ri(Ht,Zt,{enumerable:!0,configurable:!0,writable:!0,value:$t}):Ht[Zt]=$t;var tt=(Ht,Zt,$t)=>li(Ht,typeof Zt!="symbol"?Zt+"":Zt,$t);function bs(p){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>p[s]})}}return t.default=p,Object.freeze(t)}const vs=bs(ys);var Y=(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))(Y||{}),jt=(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))(jt||{}),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||{}),yt=(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))(yt||{});function Cs(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 i=t.has(p[e]),n=t.has(p[e+1]),a=t.has(p[e+2]);i&&!n&&a&&(o+="­"),i&&!n&&!a&&e>=1&&(o+="­")}return o}function Ss(p){return p.replace(/\b([a-zA-Z]{4,})\b/g,(t,s)=>Cs(s))}function Is(p,t,s){return p}function ws(p,t,s){return p}const ke=new Map;function De(p){var k;const{text:t,fontFamily:s="Inter",fontSize:o=16,fontWeight:e=400,fontStyle:i="normal",lineHeight:n=1.2,width:a=200,letterSpacing:r=0,paragraphSpacing:l=0,paragraphIndent:h=0,textCase:c="none",segments:g=[],enableSegments:f=!1}=p;let d=String(t||"");c==="uppercase"?d=d.toUpperCase():c==="lowercase"?d=d.toLowerCase():c==="capitalize"&&(d=d.replace(/\b\w/g,E=>E.toUpperCase())),p.hyphenation===!0&&(d=Ss(d));const u=`${i} ${e} ${o}px "${s}", sans-serif`,m=`${d}|${u}|${r}|${l}|${h}|${f}|${JSON.stringify(g)}|hyp:${!!p.hyphenation}|comp:${p.composer}|bal:${!!p.balanceRaggedLines}`;let y=ke.get(m);const v=typeof CanvasRenderingContext2D<"u"?CanvasRenderingContext2D.prototype.measureText:null,b=function(E){if(!v)return{width:0,fontBoundingBoxAscent:0,fontBoundingBoxDescent:0};const T=v.call(this,E);return r!==0&&E&&E.length>0?{...T,width:T.width+(E.length-1)*r}:T};if(!y){try{if(r!==0&&typeof CanvasRenderingContext2D<"u"&&(CanvasRenderingContext2D.prototype.measureText=b),f&&g&&g.length>0){const E=g.map(T=>{let W=T.text||"";const M=T.textCase||c||"none";return M==="uppercase"?W.toUpperCase():M==="lowercase"?W.toLowerCase():M==="capitalize"?W.replace(/\b\w/g,_=>_.toUpperCase()):W}).join("");if(y=xe.prepareWithSegments(E,u),y){let T=0,W=o;for(const M of g){let _=M.text||"";if(!_)continue;const R=M.textCase||c||"none";R==="uppercase"?_=_.toUpperCase():R==="lowercase"?_=_.toLowerCase():R==="capitalize"&&(_=_.replace(/\b\w/g,A=>A.toUpperCase()));const x=M.fontSize||o;x>W&&(W=x);const L=`${M.fontStyle||i} ${M.fontWeight||e} ${x}px "${M.fontFamily||s}", sans-serif`,$=xe.prepareWithSegments(_,L);if($&&$.widths)for(let A=0;A<$.widths.length;A++){const V=T+A;if(V<y.widths.length){y.widths[V]=$.widths[A];const H=$.kinds[A];if(H===2){const et=_[A];et===`
2
+ `||et==="\r"?y.kinds[V]=2:y.kinds[V]=0}else y.kinds[V]=H}}T+=_.length}y.fullText=E,y.maxFontSize=W}}else y=xe.prepareWithSegments(d,u);y&&ke.set(m,y)}catch(E){return console.error("[ExodeUI] Pretext prepare failed:",E),{width:a,height:0,lineCount:0,lines:[]}}finally{r!==0&&typeof CanvasRenderingContext2D<"u"&&v&&(CanvasRenderingContext2D.prototype.measureText=v)}if(ke.size>500){const E=ke.keys().next().value;E&&ke.delete(E)}}if(h>0&&y&&y.widths&&!y.indentApplied){const E=[...y.widths],T=y.fullText||d;let W=!0;for(let M=0;M<T.length;M++)W&&E[M]!==void 0&&(E[M]+=h,W=!1),(T[M]===`
3
+ `||T[M]==="\r")&&(W=!0,T[M]==="\r"&&T[M+1]===`
4
+ `&&M++);y={...y,widths:E,indentApplied:!0}}if(!y)return{width:a,height:0,lineCount:0,lines:[]};let C=n;typeof C=="string"&&(C=parseFloat(C)),C>5&&o>0&&(C=C/o),r!==0&&(CanvasRenderingContext2D.prototype.measureText=b);let S;try{const E=y.maxFontSize||o;if(a>=1e5){const T=d.split(/\r\n|\r|\n/);S={lines:T.map(W=>({text:W,width:0})),height:T.length*(C*E),lineCount:T.length}}else S=xe.layoutWithLines(y,a,C*E)}finally{r!==0&&v&&(CanvasRenderingContext2D.prototype.measureText=v)}let I=(S==null?void 0:S.height)!==void 0&&S.height>0?S.height:(((k=S==null?void 0:S.lines)==null?void 0:k.length)||0)*C*o;if(l>0&&S&&S.lines&&S.lines.length>1){let E=0;const T=y.fullText||t;for(let W=0;W<S.lines.length-1;W++)E+=S.lines[W].text.length,(T[E]===`
5
+ `||T[E]==="\r")&&(I+=l,E++,T[E-1]==="\r"&&T[E]===`
6
+ `&&E++)}let w=(S==null?void 0:S.lines)||[];return p.composer==="every-line"&&w.length>1&&(w=Is(w)),p.balanceRaggedLines===!0&&w.length>1&&(w=ws(w)),{width:a,height:I,lineCount:w.length,lines:w}}function ze(p,t,s){let o=String(p||"").trim();if(o&&!isNaN(Number(o))&&!o.includes(" ")&&!o.endsWith("fr")&&!o.endsWith("px")&&!o.endsWith("%")){const r=Math.max(1,parseInt(o));o=new Array(r).fill("1fr").join(" ")}const e=o.split(/\s+/).filter(Boolean),i=new Array(e.length).fill(0);let n=t-(e.length-1)*s,a=0;if(e.forEach((r,l)=>{if(r.endsWith("px")){const h=parseFloat(r);i[l]=h,n-=h}else r.endsWith("fr")?a+=parseFloat(r):r==="auto"&&(i[l]=100,n-=100)}),a>0&&n>0){const r=n/a;e.forEach((l,h)=>{l.endsWith("fr")&&(i[h]=r*parseFloat(l))})}return i}function Ve(p,t,s){try{const o=p.autoLayout;return!o||!o.enabled?{childUpdates:[]}:(o.mode||"linear")==="grid"?ks(p,t,s):Ms(p,t,s)}catch(o){return console.error("Layout Engine Error:",o),{childUpdates:[]}}}function Ms(p,t,s){var _,R;const o=p.autoLayout,{direction:e,spacing:i,padding:n,align:a,wrap:r}=o,l=e==="vertical",h=t.map(x=>{const L=s(x.id),$=x.geometry;let A=(L==null?void 0:L.width)??$.width??100,V=(L==null?void 0:L.height)??$.height??100;if($.type==="Ellipse"||$.type==="Polygon"||$.type==="Star"){const H=(L==null?void 0:L.radius)??$.radius??(L==null?void 0:L.outer_radius)??$.outer_radius??50;A=H*2,V=H*2}else if($.type==="Text"){const H=De({text:(L==null?void 0:L.text)??$.text??"",fontFamily:$.fontFamily,fontSize:$.fontSize,fontWeight:$.fontWeight,fontStyle:$.fontStyle,lineHeight:$.lineHeight,width:$.width||200,letterSpacing:$.letterSpacing,paragraphSpacing:$.paragraphSpacing,paragraphIndent:$.paragraphIndent,textCase:$.textCase,segments:$.segments,enableSegments:$.enableSegments});V=H.height,$.width||(A=H.width)}return A*=x.transform.scale_x||1,V*=x.transform.scale_y||1,{id:x.id,w:A,h:V,original:x}});let c=p.width,g=p.height;const f=((_=p.layoutProps)==null?void 0:_.width)==="hug",d=((R=p.layoutProps)==null?void 0:R.height)==="hug",u=[];let m=[],y=0,v=0;const b=c-n.left-n.right,C=g-n.top-n.bottom;h.forEach(x=>{r&&m.length>0&&(l?v+i+x.h>C:y+i+x.w>b)?(u.push({children:m,width:y,height:v}),m=[x],y=x.w,v=x.h):(m.push(x),l?(y=Math.max(y,x.w),v+=(m.length>1?i:0)+x.h):(y+=(m.length>1?i:0)+x.w,v=Math.max(v,x.h)))}),m.length>0&&u.push({children:m,width:y,height:v}),f&&!l&&(c=Math.max(...u.map(x=>x.width),0)+n.left+n.right),d&&l&&(g=Math.max(...u.map(x=>x.height),0)+n.top+n.bottom);const S=[];let I=n.left,w=n.top;const k=a.toLowerCase(),E=k==="center"||k.endsWith("-center"),T=k.endsWith("-right"),W=k==="center"||k.startsWith("center-"),M=k.startsWith("bottom-");return u.forEach(x=>{let L=I,$=w;l?W?$=n.top+(g-n.top-n.bottom-x.height)/2:M&&($=g-n.bottom-x.height):E?L=n.left+(c-n.left-n.right-x.width)/2:T&&(L=c-n.right-x.width),x.children.forEach(A=>{var F,q;let V=L,H=$;l?E?V+=(x.width-A.w)/2:T&&(V+=x.width-A.w):W?H+=(x.height-A.h)/2:M&&(H+=x.height-A.h);const et=((F=A.original.layoutProps)==null?void 0:F.width)==="fill",P=((q=A.original.layoutProps)==null?void 0:q.height)==="fill";S.push({id:A.id,x:V+A.w/2-c/2,y:H+A.h/2-g/2,width:et&&l?x.width:void 0,height:P?l?void 0:x.height:void 0}),l?$+=A.h+i:L+=A.w+i}),l?I+=x.width+i:w+=x.height+i}),{frameWidth:f?c:void 0,frameHeight:d?g:void 0,childUpdates:S}}function ks(p,t,s){const o=p.autoLayout;if(!o)return{childUpdates:[]};const{gridColumns:e,gridRows:i,columnGap:n=0,rowGap:a=0,padding:r,align:l}=o;let h=p.width,c=p.height;const g=h-r.left-r.right,f=c-r.top-r.bottom,d=ze(e||"1fr",g,n),u=ze(i||"auto",f,a),m=d.length>0?d.reduce((T,W)=>T+W,0)+(d.length-1)*n:0,y=u.length>0?u.reduce((T,W)=>T+W,0)+(u.length-1)*a:0,v=l.toLowerCase(),b=v==="center"||v.endsWith("-center"),C=v.endsWith("-right"),S=v==="center"||v.startsWith("center-"),I=v.startsWith("bottom-");let w=0,k=0;b?w=(g-m)/2:C&&(w=g-m),S?k=(f-y)/2:I&&(k=f-y);const E=[];return t.forEach((T,W)=>{var q,Q;const M=W%d.length||0,_=Math.floor(W/d.length)||0;_>=u.length&&u.push(100);const R=d[M],x=u[_];let L=r.left+w+d.slice(0,M).reduce((it,dt)=>it+dt+n,0),$=r.top+k+u.slice(0,_).reduce((it,dt)=>it+dt+a,0);const A=s(T.id),V=T.geometry;let H=(A==null?void 0:A.width)??V.width??100,et=(A==null?void 0:A.height)??V.height??100;if(V.type==="Ellipse"||V.type==="Polygon"||V.type==="Star"){const it=(A==null?void 0:A.radius)??V.radius??(A==null?void 0:A.outer_radius)??V.outer_radius??50;H=it*2,et=it*2}H*=T.transform.scale_x||1,et*=T.transform.scale_y||1;let P=L,F=$;b?P+=(R-H)/2:C&&(P+=R-H),S?F+=(x-et)/2:I&&(F+=x-et),E.push({id:T.id,x:P+H/2-h/2,y:F+et/2-c/2,width:((q=T.layoutProps)==null?void 0:q.width)==="fill"?R:void 0,height:((Q=T.layoutProps)==null?void 0:Q.height)==="fill"?x:void 0})}),{childUpdates:E}}class Ts{constructor(){tt(this,"world",null);tt(this,"bodies",new Map);tt(this,"colliders",new Map);tt(this,"initialized",!1)}async init(t){this.initialized||(await le.init(),this.world=new le.World(new le.Vector2(t.x,t.y)),this.initialized=!0)}destroy(){this.bodies.clear(),this.colliders.clear(),this.world&&(this.world.free(),this.world=null),this.initialized=!1}createBody(t){if(!this.world){console.warn("[RapierPhysics] World not initialized");return}this.bodies.has(t.id)&&this.removeBody(t.id);const s=t.isStatic?le.RigidBodyDesc.fixed():le.RigidBodyDesc.dynamic();s.setTranslation(t.x,t.y),t.rotation!==void 0&&s.setRotation(t.rotation);const o=this.world.createRigidBody(s);let e;switch(t.type){case"Rectangle":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;case"Ellipse":e=le.ColliderDesc.ball(Math.max(t.width,t.height)/2);break;case"Triangle":case"Star":case"Polygon":e=le.ColliderDesc.cuboid(t.width/2,t.height/2);break;default:e=le.ColliderDesc.cuboid(t.width/2,t.height/2)}if(t.friction!==void 0&&e.setFriction(t.friction),t.restitution!==void 0&&e.setRestitution(t.restitution),t.density!==void 0)e.setDensity(t.density);else if(t.mass!==void 0&&!t.isStatic){const n=t.width*t.height;e.setDensity(t.mass/n)}t.isSensor&&e.setSensor(!0);const i=this.world.createCollider(e,o);t.frictionAir!==void 0&&o.setLinearDamping(t.frictionAir*10),this.bodies.set(t.id,o),this.colliders.set(t.id,i)}removeBody(t){const s=this.bodies.get(t);s&&this.world&&(this.world.removeRigidBody(s),this.bodies.delete(t),this.colliders.delete(t))}step(t){this.world&&this.world.step()}getPosition(t){const s=this.bodies.get(t);if(!s)return null;const o=s.translation();return{x:o.x,y:o.y}}getRotation(t){const s=this.bodies.get(t);return s?s.rotation():null}getVelocity(t){const s=this.bodies.get(t);if(!s)return null;const o=s.linvel();return{x:o.x,y:o.y}}setPosition(t,s,o){const e=this.bodies.get(t);e&&e.setTranslation(new le.Vector2(s,o),!0)}setRotation(t,s){const o=this.bodies.get(t);o&&o.setRotation(s,!0)}setVelocity(t,s,o){const e=this.bodies.get(t);e&&e.setLinvel(new le.Vector2(s,o),!0)}applyForce(t,s,o){const e=this.bodies.get(t);e&&e.addForce(new le.Vector2(s,o),!0)}applyImpulse(t,s,o){const e=this.bodies.get(t);e&&e.applyImpulse(new le.Vector2(s,o),!0)}}const Ne=p=>p,_s=p=>p>0?1:0,Ps=p=>p<1?0:1,He=p=>p*p,Ue=p=>p*(2-p),qe=p=>p<.5?2*p*p:-1+(4-2*p)*p,Es=p=>p*p*p,xs=p=>--p*p*p+1,Os=p=>p<.5?4*p*p*p:(p-1)*(2*p-2)*(2*p-2)+1,As=p=>p*p*p*p,Ls=p=>1- --p*p*p*p,Rs=p=>p<.5?8*p*p*p*p:1-8*--p*p*p*p,Fs=p=>p*p*p*p*p,$s=p=>1+--p*p*p*p*p,Ws=p=>p<.5?16*p*p*p*p*p:1+16*--p*p*p*p*p,Bs=p=>1-Math.cos(p*Math.PI/2),Gs=p=>Math.sin(p*Math.PI/2),Ys=p=>-(Math.cos(Math.PI*p)-1)/2,Xs=p=>p===0?0:Math.pow(2,10*(p-1)),Ds=p=>p===1?1:1-Math.pow(2,-10*p),zs=p=>p===0?0:p===1?1:p<.5?Math.pow(2,20*p-10)/2:(2-Math.pow(2,-20*p+10))/2,Vs=p=>1-Math.sqrt(1-p*p),Ns=p=>Math.sqrt(1- --p*p),Hs=p=>p<.5?(1-Math.sqrt(1-4*p*p))/2:(Math.sqrt(1-(-2*p+2)*(-2*p+2))+1)/2,Oe=1.70158,Ae=Oe*1.525,Je=Oe+1,Us=p=>Je*p*p*p-Oe*p*p,qs=p=>1+Je*Math.pow(p-1,3)+Oe*Math.pow(p-1,2),Js=p=>p<.5?Math.pow(2*p,2)*((Ae+1)*2*p-Ae)/2:(Math.pow(2*p-2,2)*((Ae+1)*(p*2-2)+Ae)+2)/2,Qe=2*Math.PI/3,Ke=2*Math.PI/4.5,Qs=p=>p===0?0:p===1?1:-Math.pow(2,10*p-10)*Math.sin((p*10-10.75)*Qe),Ks=p=>p===0?0:p===1?1:Math.pow(2,-10*p)*Math.sin((p*10-.75)*Qe)+1,Zs=p=>p===0?0:p===1?1:p<.5?-(Math.pow(2,20*p-10)*Math.sin((20*p-11.125)*Ke))/2:Math.pow(2,-20*p+10)*Math.sin((20*p-11.125)*Ke)/2+1,Le=p=>p<1/2.75?7.5625*p*p:p<2/2.75?7.5625*(p-=1.5/2.75)*p+.75:p<2.5/2.75?7.5625*(p-=2.25/2.75)*p+.9375:7.5625*(p-=2.625/2.75)*p+.984375,js=p=>1-Le(1-p),ti=Le,ei=p=>p<.5?(1-Le(1-2*p))/2:(1+Le(2*p-1))/2,Ye=new Map,Te=(p,t,s,o)=>{const e=`${p},${t},${s},${o}`;if(Ye.has(e))return Ye.get(e);const i=h=>(1-3*s+3*p)*h*h*h+(3*s-6*p)*h*h+3*p*h,n=h=>(1-3*o+3*t)*h*h*h+(3*o-6*t)*h*h+3*t*h,a=h=>3*(1-3*s+3*p)*h*h+2*(3*s-6*p)*h+3*p,r=h=>{let c=h;for(let g=0;g<8;g++){const f=i(c)-h;if(Math.abs(f)<1e-6)return c;const d=a(c);if(Math.abs(d)<1e-6)break;c=c-f/d}return c},l=h=>h===0?0:h===1?1:n(r(h));return Ye.set(e,l),l},Ze=p=>{const t=p.match(/cubic-bezier\s*\(\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*,\s*([-?\d.]+)\s*\)/);if(!t)return null;const[,s,o,e,i]=t.map(Number);return Te(s,o,e,i)},je={ease:Te(.25,.1,.25,1),"ease-in":Te(.42,0,1,1),"ease-out":Te(0,0,.58,1),"ease-in-out":Te(.42,0,.58,1)},Re={Linear:Ne,EaseInQuad:He,EaseOutQuad:Ue,EaseInOutQuad:qe,EaseInCubic:Es,EaseOutCubic:xs,EaseInOutCubic:Os,EaseInQuart:As,EaseOutQuart:Ls,EaseInOutQuart:Rs,EaseInQuint:Fs,EaseOutQuint:$s,EaseInOutQuint:Ws,EaseInSine:Bs,EaseOutSine:Gs,EaseInOutSine:Ys,EaseInExpo:Xs,EaseOutExpo:Ds,EaseInOutExpo:zs,EaseInCirc:Vs,EaseOutCirc:Ns,EaseInOutCirc:Hs,EaseInBack:Us,EaseOutBack:qs,EaseInOutBack:Js,EaseInElastic:Qs,EaseOutElastic:Ks,EaseInOutElastic:Zs,EaseInBounce:js,EaseOutBounce:ti,EaseInOutBounce:ei,EaseIn:He,EaseOut:Ue,EaseInOut:qe,StepStart:_s,StepEnd:Ps},si=p=>{const t=p.trim(),s=t.toLowerCase();if(Re[t])return Re[t];const o=Object.keys(Re).find(i=>i.toLowerCase()===s);if(o)return Re[o];const e=Object.keys(ts).find(i=>i.toLowerCase()===s);if(e){const i=Ze(ts[e].value);if(i)return i}if(je[s])return je[s];if(s.startsWith("cubic-bezier")){const i=Ze(t);if(i)return i}return Ne},ts={Snappy:{label:"Snappy",description:"High energy, quick arrival.",value:"cubic-bezier(0.2, 1, 0.2, 1)"},Bouncy:{label:"Bouncy",description:"Springy with an overshoot.",value:"cubic-bezier(0.2, 0.9, 0.4, 1.3)"},Gentle:{label:"Gentle",description:"Smooth and organic flow.",value:"cubic-bezier(0.4, 0, 0.6, 1)"},Stiff:{label:"Stiff",description:"Solid and reliable movement.",value:"cubic-bezier(0.3, 1, 0.7, 1)"},Floating:{label:"Floating",description:"Weightless and airy transition.",value:"cubic-bezier(0.5, 0, 0.5, 1)"},Sudden:{label:"Sudden",description:"Instant, direct movement.",value:"cubic-bezier(1, 0, 1, 1)"},Elastic:{label:"Elastic",description:"Extreme overshoot and spring.",value:"cubic-bezier(0.5, 1.5, 0.5, 1.5)"},Sharp:{label:"Sharp",description:"Fast start, very hard stop.",value:"cubic-bezier(0.1, 0.9, 0.1, 1)"},Fluid:{label:"Fluid",description:"Natural high-end flow.",value:"cubic-bezier(0.4, 0, 0.2, 1)"},Heavy:{label:"Heavy",description:"Slow start, massive impact.",value:"cubic-bezier(0.6, 0, 1, 1)"}},es={default:{label:"Default",colors:["#6366f1","#f59e0b"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",gridColor:"rgba(255,255,255,0.06)",axisLabelColor:"rgba(255,255,255,0.5)",legendColor:"rgba(255,255,255,0.7)",barGradient:!0},neon:{label:"Neon",colors:["#00f5ff","#ff00e5"],cardBackground:"rgba(0,0,0,0.5)",cardBorderColor:"rgba(0,245,255,0.2)",gridColor:"rgba(0,245,255,0.08)",axisLabelColor:"rgba(0,245,255,0.6)",legendColor:"rgba(0,245,255,0.8)",barGradient:!0},pastel:{label:"Pastel",colors:["#a5b4fc","#fcd34d"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",gridColor:"rgba(255,255,255,0.08)",axisLabelColor:"rgba(255,255,255,0.45)",legendColor:"rgba(255,255,255,0.65)",barGradient:!1},warm:{label:"Warm",colors:["#f97316","#ef4444"],cardBackground:"rgba(30,10,0,0.4)",cardBorderColor:"rgba(249,115,22,0.2)",gridColor:"rgba(249,115,22,0.08)",axisLabelColor:"rgba(253,186,116,0.7)",legendColor:"rgba(253,186,116,0.85)",barGradient:!0},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",gridColor:"rgba(6,182,212,0.06)",axisLabelColor:"rgba(125,211,252,0.6)",legendColor:"rgba(125,211,252,0.8)",barGradient:!0},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.4)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",gridColor:"rgba(255,255,255,0.05)",axisLabelColor:"rgba(255,255,255,0.4)",legendColor:"rgba(255,255,255,0.6)",barGradient:!1}},ss={default:{label:"Default",colors:["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399"],cardBackground:"rgba(255,255,255,0.04)",cardBorderColor:"rgba(255,255,255,0.08)",legendColor:"rgba(255,255,255,0.65)",labelColor:"#ffffff",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"},neon:{label:"Neon",colors:["#00f5ff","#ff00e5","#00ff9f","#ff6b00","#b400ff"],cardBackground:"rgba(0,0,0,0.55)",cardBorderColor:"rgba(0,245,255,0.2)",legendColor:"rgba(0,245,255,0.75)",labelColor:"#ffffff",centerTextColor:"#00f5ff",centerLabelColor:"rgba(0,245,255,0.5)"},pastel:{label:"Pastel",colors:["#a5b4fc","#67e8f9","#fcd34d","#f9a8d4","#6ee7b7"],cardBackground:"rgba(255,255,255,0.06)",cardBorderColor:"rgba(255,255,255,0.12)",legendColor:"rgba(255,255,255,0.6)",labelColor:"#1a1a2e",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.45)"},warm:{label:"Warm",colors:["#f97316","#ef4444","#f59e0b","#dc2626","#fb923c"],cardBackground:"rgba(30,10,0,0.45)",cardBorderColor:"rgba(249,115,22,0.2)",legendColor:"rgba(253,186,116,0.8)",labelColor:"#ffffff",centerTextColor:"#fb923c",centerLabelColor:"rgba(253,186,116,0.5)"},ocean:{label:"Ocean",colors:["#06b6d4","#0ea5e9","#38bdf8","#7dd3fc","#0284c7"],cardBackground:"rgba(0,20,40,0.5)",cardBorderColor:"rgba(6,182,212,0.2)",legendColor:"rgba(125,211,252,0.75)",labelColor:"#ffffff",centerTextColor:"#38bdf8",centerLabelColor:"rgba(125,211,252,0.5)"},mono:{label:"Mono",colors:["rgba(255,255,255,0.9)","rgba(255,255,255,0.65)","rgba(255,255,255,0.45)","rgba(255,255,255,0.28)","rgba(255,255,255,0.15)"],cardBackground:"rgba(255,255,255,0.03)",cardBorderColor:"rgba(255,255,255,0.1)",legendColor:"rgba(255,255,255,0.55)",labelColor:"#000000",centerTextColor:"#ffffff",centerLabelColor:"rgba(255,255,255,0.4)"}};class is{constructor(){tt(this,"artboard",null);tt(this,"objectStates",new Map);tt(this,"physicsEngine",null);tt(this,"activeStateMachine",null);tt(this,"inputs",new Map);tt(this,"inputNameMap",new Map);tt(this,"layerStates",new Map);tt(this,"pretextCache",new Map);tt(this,"pointerHistory",[]);tt(this,"MAX_HISTORY",200);tt(this,"imageCache",new Map);tt(this,"lastValidSvgImgMap",new Map);tt(this,"maskBuffer",null);tt(this,"maskCtx",null);tt(this,"lumaBuffer",null);tt(this,"lumaCtx",null);tt(this,"_noiseTileCanvas",null);tt(this,"layout",{fit:"Contain",alignment:"Center"});tt(this,"onTrigger");tt(this,"onInputUpdate");tt(this,"onComponentChange");tt(this,"onToggle");tt(this,"onInputChange");tt(this,"onInputFocus");tt(this,"onInputBlur");tt(this,"onLog");tt(this,"onButtonClick");tt(this,"onGraphPointClick");tt(this,"justFiredTriggers",new Set);tt(this,"rootTransform",null);tt(this,"canvasWidth",0);tt(this,"canvasHeight",0);tt(this,"lastHoveredObjectId",null);tt(this,"_lastPointerPos",null);tt(this,"_prevPointerPos",null);tt(this,"focusedId",null);tt(this,"draggingSliderId",null);tt(this,"activeDropdownId",null);tt(this,"activeObjectId",null);tt(this,"draggingListViewId",null);tt(this,"scrollOffset",{x:0,y:0});tt(this,"_totalScroll",{x:0,y:0});tt(this,"draggingBehaviors",new Set);tt(this,"isMouseDown",!1);tt(this,"_layoutAnimCache",new Map);tt(this,"_springChainState",new Map);tt(this,"_emitterPools",new Map);tt(this,"objectVelocities",new Map);tt(this,"currentTime",0);tt(this,"frameCount",0);tt(this,"fontLeadingFactors",{Inter:.35,Roboto:.45,Montserrat:.4,Outfit:.35,"Open Sans":.4,Poppins:.45,"Playfair Display":.35,Lora:.4,Lato:.35,"Bebas Neue":.45,Oswald:.4});tt(this,"onLogicUpdate");tt(this,"logicNodeValues",new Map);tt(this,"logicNodeState",new Map);tt(this,"pointerDownTimes",new Map);tt(this,"activeHoverIds",new Set);tt(this,"onNavigation");tt(this,"periodicTriggerTimes",new Map);tt(this,"wasInView",new Set);tt(this,"scrollProgressLastValue",new Map);tt(this,"debug_objectsRendered",0);tt(this,"debug_objectsTotal",0);tt(this,"lastRenderTime",0);tt(this,"debugMode",!1);tt(this,"activeTriggers",new Map);console.info("%c[ExodeUI Engine] Pixel-Perfect Parity Active (v6.3.10) - SVG Fill & Gradient Parity Active","color: #3b82f6; font-weight: bold; padding: 2px 4px; border-radius: 4px; background: rgba(59, 130, 246, 0.1)")}setTriggerCallback(t){this.onTrigger=t}setInputUpdateCallback(t){this.onInputUpdate=t}setComponentChangeCallback(t){this.onComponentChange=t}setToggleCallback(t){this.onToggle=t}setLogicUpdateCallback(t){this.onLogicUpdate=t}setInputChangeCallback(t){this.onInputChange=t}setButtonClickCallback(t){this.onButtonClick=t}setGraphPointClickCallback(t){this.onGraphPointClick=t}setNavigationCallback(t){this.onNavigation=t}ensurePathPoints(t){if(!t||t.type!=="Path"&&t.type!=="Subtract"&&t.type!=="Union"&&t.type!=="Intersect"&&t.type!=="Exclude"&&t.type!=="BooleanOperation")return;if(t.points&&t.points.length>0){if(t.is_closed===void 0&&t.isClosed===void 0&&t.data){const{isClosed:e}=this.svgPathToPoints(t.data);t.is_closed=e}return}if(!t.data)return;const{points:s,isClosed:o}=this.svgPathToPoints(t.data);t.points=s,t.is_closed===void 0&&(t.is_closed=o)}svgPathToPoints(t){const s=/([MLHVCSQTAZmlhvcsqtaz])([^MLHVCSQTAZmlhvcsqtaz]*)/g,o=/[-+]?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?/g,e=[];let i=!1,n=0,a=0,r=0,l=0,h=0,c=0,g;for(;(g=s.exec(t))!==null;){const f=g[1],d=(g[2].match(o)||[]).map(parseFloat),u=f===f.toLowerCase(),m=f.toUpperCase();let y=0;const v=C=>{let S=d[y++];return u&&(S+=C?n:a),S},b=()=>({x:v(!0),y:v(!1)});switch(m){case"M":{const C=b();for(h=n=C.x,c=a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a,moveTo:!0});y<d.length;){const S=b();n=S.x,a=S.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}case"L":for(;y<d.length;){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break;case"H":for(;y<d.length;)n=v(!0),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"V":for(;y<d.length;)a=v(!1),e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a});break;case"C":for(;y<d.length;){const C=b(),S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"S":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b(),I=b();if(e.length>0){const w=e[e.length-1];w.out_x=C.x,w.out_y=C.y}n=I.x,a=I.y,e.push({x:n,y:a,in_x:S.x,in_y:S.y,out_x:n,out_y:a}),r=S.x,l=S.y}break;case"Q":for(;y<d.length;){const C=b(),S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"T":for(;y<d.length;){const C={x:2*n-r,y:2*a-l},S=b();if(e.length>0){const I=e[e.length-1];I.out_x=I.x+2/3*(C.x-I.x),I.out_y=I.y+2/3*(C.y-I.y)}n=S.x,a=S.y,e.push({x:n,y:a,in_x:n+2/3*(C.x-n),in_y:a+2/3*(C.y-a),out_x:n,out_y:a}),r=C.x,l=C.y}break;case"Z":if(i=!0,e.length>0){const C=e[e.length-1];C.closePath=!0;const S=[...e].reverse().find(I=>I.moveTo)||e[0];S&&Math.hypot(S.x-C.x,S.y-C.y)<.1&&(S.in_x=C.in_x,S.in_y=C.in_y,e.pop(),e.length>0&&(e[e.length-1].closePath=!0))}n=h,a=c;break;default:if(d.length>=2){const C=b();n=C.x,a=C.y,e.push({x:n,y:a,in_x:n,in_y:a,out_x:n,out_y:a})}break}}return{points:e,isClosed:i}}setOnLogCallback(t){this.onLog=t}debugLog(t){this.onLog&&this.onLog(t)}setInputFocusCallback(t){this.onInputFocus=t}setInputBlurCallback(t){this.onInputBlur=t}updateConstraint(t,s,o){var i;const e=(i=this.artboard)==null?void 0:i.objects.find(n=>n.id===t);e&&e.constraints&&e.constraints[s]&&(e.constraints[s]={...e.constraints[s],...o},o.useSpring===!1&&this.objectVelocities.delete(t))}setInternalInput(t,s){this.inputs.set(t,s),this.onInputUpdate&&this.onInputUpdate(t,s)}setLayout(t,s){this.layout={fit:t,alignment:s}}getActiveStateIds(t="Base Layer"){const s=this.layerStates.get(t);return s?s.currentStateIds:[]}getObjectState(t){return this.objectStates.get(t)}updateObjectOptions(t,s){const o=this.objectStates.get(t);o&&(o.options={...o.options,...s})}updateGraphData(t,s){var e,i;if(!this.artboard)return;const o=this.artboard.objects.find(n=>n.id===t||n.name===t);if(o&&((e=o.geometry)==null?void 0:e.type)==="LineGraph"){const n=o.geometry;!n.datasets||n.datasets.length===0?n.datasets=[{id:"default",label:"Runtime Data",data:s,lineColor:"#3b82f6",lineWidth:2,showArea:!1}]:n.datasets[0].data=s;const a=this.objectStates.get(o.id);a&&((i=a.geometry)==null?void 0:i.type)==="LineGraph"&&(!a.geometry.datasets||a.geometry.datasets.length===0?a.geometry.datasets=JSON.parse(JSON.stringify(n.datasets)):a.geometry.datasets[0].data=[...s]),n.datasets[0].inputId&&this.updateInput(n.datasets[0].inputId,s)}else this.updateInput(t,s)}load(t){var n,a;if(!t)return;let s=this.decompressStrings(t);const o=[],e=new Set,i=r=>{r&&r.forEach(l=>{if(e.has(l.id))return;const h={...l},c=h.childrenObjects||[];e.add(h.id),o.push(h),i(c)})};if(i(s.objects||[]),o.length>(s.objects||[]).length&&console.log(`[Engine] Flattened artboard from ${(s.objects||[]).length} to ${o.length} objects.`),s.objects=o,this.artboard=s,this.currentTime=0,this.objectStates.clear(),console.log(`[ExodeUIEngine] Loading artboard: "${(n=this.artboard)==null?void 0:n.name}" with ${(a=this.artboard)==null?void 0:a.objects.length} objects`),this.artboard&&this.artboard.objects){const r=new Map;this.artboard.objects.forEach(l=>{r.set(l.id,l),l.children||(l.children=[])}),this.artboard.objects.forEach(l=>{if(l.parentId){const h=r.get(l.parentId);h&&(h.children||(h.children=[]),h.children.includes(l.id)||h.children.push(l.id))}})}this.loadFonts(),this.preloadImages(this.artboard),this.reset(),this.advance(0)}preloadImages(t){if(!t||!t.objects)return;const s=o=>{if(!o||this.imageCache.has(o))return;const e=new Image;e.onload=()=>{console.log(`[ExodeUI Preload] loaded ${e.naturalWidth}x${e.naturalHeight}`)},e.onerror=i=>{console.error("[ExodeUI Preload] failed:",i,`Src: ${o.substring(0,80)}...`)},e.src=o,this.imageCache.set(o,e)};t.objects.forEach(o=>{var e,i,n;(e=o.geometry)!=null&&e.src&&s(o.geometry.src),(n=(i=o.style)==null?void 0:i.fill)!=null&&n.src&&s(o.style.fill.src)})}decompressStrings(t){if(t&&typeof t=="object"&&!Array.isArray(t)){if(t._compressed&&t._data)try{const o=vs.decompressFromBase64(t._data);if(o)return o}catch(o){return console.error("[ExodeUI] Failed to decompress string:",o),t._data}const s={};for(const[o,e]of Object.entries(t))s[o]=this.decompressStrings(e);return s}return Array.isArray(t)?t.map(s=>this.decompressStrings(s)):t}reset(){if(!this.artboard)return;if(this.objectStates.clear(),this.objectVelocities.clear(),this.currentTime=0,this.inputs.clear(),this.inputNameMap.clear(),this.layerStates.clear(),this.logicNodeValues.clear(),this.justFiredTriggers.clear(),this.inputs.set("mouseX",0),this.inputs.set("mouseY",0),this.inputs.set("scrollX",0),this.inputs.set("scrollY",0),this.inputs.set("isMouseDown",!1),this.physicsEngine&&(this.physicsEngine.destroy(),this.physicsEngine=null),this._layoutAnimCache.clear(),this._springChainState.clear(),this._emitterPools.clear(),this.artboard.objects.forEach(s=>{var n,a,r,l,h,c,g;const o=s.width??((n=s.geometry)==null?void 0:n.width)??0,e=s.height??((a=s.geometry)==null?void 0:a.height)??0,i=s.cornerRadius??s.corner_radius??((r=s.geometry)==null?void 0:r.corner_radius)??((l=s.geometry)==null?void 0:l.cornerRadius)??0;this.objectStates.set(s.id,{...s.transform||{},x:((h=s.transform)==null?void 0:h.x)??s.x??0,y:((c=s.transform)==null?void 0:c.y)??s.y??0,width:o,height:e,cornerRadius:i,corner_radius:i,clipContent:s.clipContent??!1,autoLayout:s.autoLayout?JSON.parse(JSON.stringify(s.autoLayout)):void 0,layoutProps:s.layoutProps?JSON.parse(JSON.stringify(s.layoutProps)):void 0,opacity:((g=s.transform)==null?void 0:g.opacity)!==void 0?s.transform.opacity:s.opacity!==void 0?s.opacity:100,visible:s.visible!==void 0?s.visible:s.isVisible!==void 0?s.isVisible:!0,blendMode:s.blendMode||"Normal",style:JSON.parse(JSON.stringify(s.style||{})),geometry:JSON.parse(JSON.stringify(s.geometry||{})),options:s.options?JSON.parse(JSON.stringify(s.options)):{},masks:s.masks?JSON.parse(JSON.stringify(s.masks)):[],zIndex:s.zIndex!==void 0?s.zIndex:void 0})}),this.artboard.objects.some(s=>{var o;return(o=s.physics)==null?void 0:o.enabled})){this.physicsEngine=new Ts;const s=this.artboard.physics?{x:this.artboard.physics.gravity.x,y:this.artboard.physics.gravity.y}:{x:0,y:1};this.physicsEngine.init(s).then(()=>{var o;this.physicsEngine&&((o=this.artboard)==null||o.objects.forEach(e=>{var i,n;if((i=e.physics)!=null&&i.enabled&&e.type==="Shape"){const a=this.objectStates.get(e.id);if(!a)return;const r=e.geometry.width||100,l=e.geometry.height||100;this.physicsEngine.createBody({id:e.id,type:((n=e.geometry)==null?void 0:n.type)||"Rectangle",x:a.x,y:a.y,width:r,height:l,rotation:a.rotation*(Math.PI/180),isStatic:e.physics.bodyType==="Static",mass:e.physics.mass,friction:e.physics.friction,restitution:e.physics.restitution,frictionAir:e.physics.frictionAir,density:e.physics.density,isSensor:e.physics.isSensor})}}))})}this.artboard.stateVariables&&this.artboard.stateVariables.forEach(s=>{this.inputs.set(s.id,s.value);const o=this.inputNameMap.get(s.name)||[];o.includes(s.id)||o.push(s.id),this.inputNameMap.set(s.name,o)}),this.artboard.stateMachine&&(this.activeStateMachine=this.artboard.stateMachine,this.activeStateMachine.inputs.forEach(s=>{this.inputs.set(s.id,s.value.value);const o=this.inputNameMap.get(s.name)||[];o.push(s.id),this.inputNameMap.set(s.name,o)}),this.activeStateMachine.layers.forEach(s=>{let o=s.states.find(e=>e.id===s.entryStateId);!o&&s.states.length>0&&(console.warn(`[ExodeUI] Invalid entryStateId "${s.entryStateId}" in layer "${s.name}". Falling back to first state.`),o=s.states[0]),o&&this.enterStates(s.name,[o.id])}),this.evaluateTransitions()),this.initGlobalAnimationTriggers(),this.updateAutoLayout(!0),this.loadFonts()}updateAutoLayout(t=!1){var i;if(!this.artboard)return;const s=new Map;this.artboard.objects.forEach(n=>s.set(n.id,n));const o=.15,e=n=>{n.forEach(a=>{const r=this.objectStates.get(a.id);if(r){const l=Math.abs(r.x-a.x),h=Math.abs(r.y-a.y);!t&&(l>20||h>20)?(r.x+=(a.x-r.x)*o,r.y+=(a.y-r.y)*o):(r.x=a.x,r.y=a.y),a.width!==void 0&&(r.width=a.width),a.height!==void 0&&(r.height=a.height)}})};if((i=this.artboard.autoLayout)!=null&&i.enabled){const n=this.artboard.objects.filter(r=>!r.parentId),a=Ve(this.artboard,n,r=>this.objectStates.get(r));e(a.childUpdates)}this.artboard.objects.forEach(n=>{var a;if(n.type==="Frame"&&((a=n.autoLayout)!=null&&a.enabled)&&n.children&&n.children.length>0){const r=n.children.map(c=>s.get(c)).filter(c=>!!c),l=this.objectStates.get(n.id);if(!l)return;const h=Ve(l,r,c=>this.objectStates.get(c));h.frameWidth!==void 0&&(l.width=h.frameWidth),h.frameHeight!==void 0&&(l.height=h.frameHeight),e(h.childUpdates)}})}loadFonts(){if(!this.artboard)return;const t=new Set;if(this.artboard.objects.forEach(n=>{n.geometry&&n.geometry.type==="Text"&&n.geometry.fontFamily&&t.add(n.geometry.fontFamily)}),this.artboard.animations.forEach(n=>{n.tracks.forEach(a=>{(a.property==="geometry.fontFamily"||a.property==="fontFamily")&&a.keyframes.forEach(r=>{r.value&&typeof r.value=="string"&&t.add(r.value)})})}),t.size===0)return;let s="";t.forEach(n=>{const a=n.replace(/ /g,"+");s+=`&family=${a}:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900`});const o="exodeui-google-fonts",e="exodeui-fontshare-fonts";if(s.length>0){const n=`https://fonts.googleapis.com/css2?display=swap${s}`;let a=document.getElementById(o);a||(a=document.createElement("link"),a.id=o,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}const i=[];if(t.forEach(n=>{n.toLowerCase().includes("clash display")&&i.push("clash-display@200,300,400,500,600,700")}),i.length>0){const n=`https://api.fontshare.com/v2/css?f[]=${i.join("&f[]=")}&display=swap`;let a=document.getElementById(e);a||(a=document.createElement("link"),a.id=e,a.rel="stylesheet",document.head.appendChild(a)),a.href!==n&&(a.href=n)}document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.pretextCache.clear(),this.advance(0)})}enterStates(t,s){var n;if(s.length===0)return;const o=this.layerStates.get(t);if(o&&o.currentStateIds.length===s.length&&s.every(r=>o.currentStateIds.includes(r))&&this.justFiredTriggers.size===0)return;const e=[];let i=0;if(this.artboard&&this.activeStateMachine){const a=this.activeStateMachine.layers.find(r=>r.name===t);if(a)for(const r of s){const l=a.states.find(h=>h.id===r);if(l){let h=null;l.animationId&&(h=this.artboard.animations.find(c=>c.id===l.animationId)||null),h||(h=this.artboard.animations.find(c=>{var g,f;return c.name===l.name||c.id===l.name||(l.name==="Entry"||l.id==="entry")&&(((g=c.name)==null?void 0:g.toLowerCase())==="onload"||((f=c.name)==null?void 0:f.toLowerCase())==="intro")})||null),h&&((n=this.artboard.animationFlow)!=null&&n.some(g=>(g.trigger==="on_load"||g.trigger==="after_delay")&&g.targetAnimationId===(h==null?void 0:h.id))||(e.push({animation:h,state:l}),i=Math.max(i,h.duration)))}}}this.layerStates.set(t,{currentStateIds:s,animations:e,time:0,duration:i})}setInputBool(t,s){this.updateInput(t,s)}setInputNumber(t,s){this.updateInput(t,s)}fireTrigger(t){this.updateInput(t,!0)}setInputText(t,s){this.updateInput(t,s)}setInputNumberArray(t,s){this.updateInput(t,s)}setInputStringArray(t,s){this.updateInput(t,s)}updateObjectProperty(t,s,o){const e=this.objectStates.get(t);if(e)if(s.includes(".")){const i=s.split(".");let n=e;for(let a=0;a<i.length-1;a++)n[i[a]]||(n[i[a]]={}),n=n[i[a]];n[i[i.length-1]]=o}else e[s]=o}updateInput(t,s){var n,a,r;let o;if(this.inputs.has(t)){const l=(n=this.activeStateMachine)==null?void 0:n.inputs.find(h=>h.id===t);l&&typeof l.value=="object"&&(o=l.value.type)}else{const l=this.inputNameMap.get(t);if(l&&l.length>0){const h=(a=this.activeStateMachine)==null?void 0:a.inputs.find(c=>c.id===l[0]);h&&typeof h.value=="object"&&(o=h.value.type)}}let e=s;o==="Trigger"&&(s===1?e=!0:s===0&&(e=!1)),this.inputs.has(t)&&this.setInternalInput(t,e);const i=this.inputNameMap.get(t);i&&i.forEach(l=>this.setInternalInput(l,e)),o==="Trigger"&&e===!0&&(this.justFiredTriggers.add(t),i&&i.forEach(l=>this.justFiredTriggers.add(l))),Array.isArray(e)&&((r=this.artboard)==null||r.objects.forEach(l=>{if(l.inputId===t||l.name===t){const h=this.objectStates.get(l.id);h&&h.options&&(l.type==="ListView"||l.variant==="listview"?h.options.items=e:(l.type==="Dropdown"||l.variant==="dropdown")&&(h.options.optionsList=e))}})),this.evaluateTransitions(),this.evaluateVariableTriggers(t,e)}evaluateVariableTriggers(t,s){if(!this.artboard)return;const o=this.artboard.animationFlow||[],e=this.inputNameMap.get(t);o.forEach(i=>{if(i.trigger==="variable"&&i.conditionVariableId&&i.targetAnimationId&&(i.conditionVariableId===t||e&&e.includes(i.conditionVariableId))){const a=i.conditionOperator||"IsTrue",r=i.conditionValue;let l=!1;switch(a){case"Equal":case"==":l=s==r;break;case"NotEqual":case"!=":l=s!=r;break;case"GreaterThan":case">":l=s>r;break;case"LessThan":case"<":l=s<r;break;case"GreaterEqual":case">=":l=s>=r;break;case"LessEqual":case"<=":l=s<=r;break;case"IsTrue":l=!!s;break;case"IsFalse":l=!s;break}if(l){const h=i.delay||0;h<=0?this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id):setTimeout(()=>this.triggerGlobalAnimation(i.targetAnimationId,i.subAnimationIds,i.loop,i.id),h)}}})}evaluateTransitions(){this.activeStateMachine&&(this.activeStateMachine.layers.forEach(t=>{const s=this.layerStates.get(t.name);if(!s||s.currentStateIds.length===0)return;const o=[];let e=!1;for(const i of s.currentStateIds){const n=t.states.find(r=>r.id===i);if(!n)continue;let a=!1;for(const r of n.transitions||[])this.checkConditions(r.conditions)&&(o.push(r.targetStateId),a=!0,e=!0);a||o.push(i)}if(!e){const i=this.findGlobalTransition(t,s.currentStateIds);i&&(o.length=0,o.push(i.targetStateId),e=!0,i.conditions&&(i.conditions||[]).forEach(n=>{var r;const a=(r=this.activeStateMachine)==null?void 0:r.inputs.find(l=>l.id===n.inputId);a&&typeof a.value=="object"&&a.value.type==="Trigger"&&this.setInternalInput(n.inputId,!1)}))}if(e){const i=Array.from(new Set(o));this.enterStates(t.name,i)}}),this.justFiredTriggers.size>0&&(this.justFiredTriggers.forEach(t=>{var o,e;this.setInternalInput(t,!1);const s=(o=this.activeStateMachine)==null?void 0:o.inputs.find(i=>i.id===t);s&&this.inputNameMap.has(s.name)&&((e=this.inputNameMap.get(s.name))==null||e.forEach(i=>this.setInternalInput(i,!1)))}),this.justFiredTriggers.clear()))}findGlobalTransition(t,s){for(const o of t.states)if(!(s.includes(o.id)&&this.justFiredTriggers.size===0)){for(const i of o.transitions||[])if(!(s.includes(i.targetStateId)&&this.justFiredTriggers.size===0)&&this.checkConditions(i.conditions))return i}return null}checkConditions(t){return!t||t.length===0?!0:t.every(s=>{const o=s.inputId,e=s.op,i=s.value,n=this.evaluateLogicTree(o);if(n===void 0)return console.log(`[Engine] Condition Check Failed: Input ${o} is undefined`),!1;let a=!1;switch(e){case"Equal":case"==":a=n==i;break;case"NotEqual":case"!=":a=n!=i;break;case"GreaterThan":case">":a=n>i;break;case"LessThan":case"<":a=n<i;break;case"GreaterEqual":case">=":a=n>=i;break;case"LessEqual":case"<=":a=n<=i;break;case"IsTrue":a=!!n;break;case"IsFalse":a=!n;break;default:a=!1}return a||this.justFiredTriggers.has(o),a})}evaluateLogicTree(t,s=null,o=new Set){var a,r,l,h,c,g;if(o.has(t))return this.inputs.get(t)??this.logicNodeValues.get(t)??0;o.add(t);const e=(r=(a=this.activeStateMachine)==null?void 0:a.logicNodes)==null?void 0:r.find(f=>f.id===t);if(e){const f=(u,m)=>{const y=e.inputs.find(v=>v.id===u);return y?y.sourceId?this.evaluateLogicTree(y.sourceId,y.sourceHandleId,o):y.value!==void 0?y.value:m:m};let d=0;switch(e.op){case yt.AND:d=f("a",!1)&&f("b",!1);break;case yt.OR:d=f("a",!1)||f("b",!1);break;case yt.NOT:d=!f("in",!1);break;case yt.XOR:d=!!f("a",!1)!=!!f("b",!1);break;case yt.OBJECT:d=e.name;break;case yt.PROPERTY:case yt.GET_PROPERTY:{const u=f("id","");if(!u){d=0;break}const m=e.name;if(!m||m==="GET_PROPERTY"||m==="PROPERTY"){d=0;break}const y=this.objectStates.get(u);if(!y){d=0;break}m in y?d=y[m]:d=this.resolvePath(y,m);break}case yt.SET_PROPERTY:{const u=f("id",""),m=f("value",void 0);if(!u||m===void 0){d=0;break}const y=e.name;if(!y||y==="SET_PROPERTY"){d=0;break}const v=this.objectStates.get(u);if(!v){d=0;break}if(["x","y","rotation","scale_x","scale_y","opacity","width","height","cornerRadius","visible","zIndex"].includes(y))v[y]=m,d=m;else{const C=y.split(".");let S=v;for(let w=0;w<C.length-1;w++){const k=C[w];S[k]===void 0&&(S[k]={}),S=S[k]}const I=C[C.length-1];S[I]=m,d=m}break}case yt.ADD:d=f("a",0)+f("b",0);break;case yt.SUB:d=f("a",0)-f("b",0);break;case yt.MUL:d=f("a",0)*f("b",0);break;case yt.DIV:{const u=f("b",1);d=u===0?0:f("a",0)/u;break}case yt.MOD:d=f("a",0)%f("b",1);break;case yt.POW:d=Math.pow(f("a",0),f("b",1));break;case yt.ABS:d=Math.abs(f("in",0));break;case yt.ROUND:d=Math.round(f("in",0));break;case yt.FLOOR:d=Math.floor(f("in",0));break;case yt.CEIL:d=Math.ceil(f("in",0));break;case yt.SIN:d=Math.sin(f("in",0));break;case yt.COS:d=Math.cos(f("in",0));break;case yt.TAN:d=Math.tan(f("in",0));break;case yt.CLAMP:{const u=f("in",0),m=f("min",0),y=f("max",1);d=Math.max(m,Math.min(y,u));break}case yt.REMAP:{const u=f("in",0),m=f("inMin",0),y=f("inMax",100),v=f("outMin",0),b=f("outMax",1);d=y===m?v:v+(u-m)*(b-v)/(y-m);break}case yt.EQ:d=f("a",0)==f("b",0);break;case yt.NEQ:d=f("a",0)!=f("b",0);break;case yt.GT:d=f("a",0)>f("b",0);break;case yt.LT:d=f("a",0)<f("b",0);break;case yt.GTE:d=f("a",0)>=f("b",0);break;case yt.LTE:d=f("a",0)<=f("b",0);break;case yt.IF_ELSE:d=f("cond",!1)?f("then",0):f("else",0);break;case yt.VALUE:d=e.value!==void 0?e.value:0;break;case yt.INPUT:d=this.inputs.get(e.name)??0;break;case yt.LOG:{const u=f("in","");this.debugLog(`[User Logic] ${u}`),d=u;break}case yt.SCROLL_X:d=this.inputs.get("scrollX")??0;break;case yt.SCROLL_Y:d=this.inputs.get("scrollY")??0;break;case yt.MOUSE_X:d=this.inputs.get("mouseX")??0;break;case yt.MOUSE_Y:d=this.inputs.get("mouseY")??0;break;case yt.IS_MOUSE_DOWN:d=this.inputs.get("isMouseDown")??!1;break;case yt.EFFECTOR:{const u=f("id",""),m=f("intensity",1),y=f("trigger",!0);if(!u||!y){d=0;break}const v=e.name;if(!v){d=0;break}const b=this.objectStates.get(u);if(!b){d=0;break}if(["glitch","halftone","pixelate","noise","acid_gradient","acid_rave","shimmer"].includes(v))b.style||(b.style={}),b.style.artEffect={enabled:!0,type:v,intensity:m},d=1;else{b.behaviors||(b.behaviors=[]);let S=b.behaviors.find(I=>I.type===v);S?(S.enabled=!0,S.settings||(S.settings={}),S.settings.intensity=m):(S={id:`eff_${Date.now()}_${v}`,type:v,enabled:!0,sensors:[],settings:{intensity:m}},b.behaviors.push(S)),d=1}break}case yt.MONITOR:{d=f("in",0);break}case yt.SPRING_PULL:{const u=f("objectId",""),m=f("forceX",0),y=f("forceY",0);u&&((l=this.artboard)==null||l.objects.forEach(v=>{v.behaviors&&v.behaviors.forEach(b=>{var C;if(b.type===Y.SpringChain&&((C=b.settings)!=null&&C.connections)&&(b.settings.connections.some(I=>I.targetId===u)||v.id===u)){this._springChainState.has(v.id)||this._springChainState.set(v.id,new Map);const I=this._springChainState.get(v.id);if(!I.has(u)){const k=this.objectStates.get(u);I.set(u,{x:(k==null?void 0:k.x)??0,y:(k==null?void 0:k.y)??0,vx:0,vy:0})}const w=I.get(u);w&&(w.vx+=m,w.vy+=y)}})})),d=1;break}case yt.SPRING_SETTLE:{const u=f("objectId","");let m=!0;if(u){const y=f("threshold",1);this._springChainState.forEach(v=>{const b=v.get(u);b&&(Math.abs(b.vx)>y||Math.abs(b.vy)>y)&&(m=!1)})}d=m;break}case yt.EMIT:{const u=f("objectId",""),m=f("count",20);u&&((h=this.artboard)==null||h.objects.forEach(y=>{y.behaviors&&y.behaviors.forEach(v=>{v.type===Y.ParticleEmitter&&y.id===u&&(v._pendingBurst=(v._pendingBurst||0)+m)})})),d=1;break}default:d=0;break}if(this.logicNodeValues.set(t,d),e.op===yt.DELAY){const u=f("delay",0),m=f("in",0);let y=this.logicNodeState.get(t);for(y||(y={queue:[]},this.logicNodeState.set(t,y)),y.queue.push({time:this.currentTime+u,value:m});y.queue.length>0&&y.queue[0].time<=this.currentTime;)y.lastValue=y.queue.shift().value;d=y.lastValue??0}return d}const i=(c=this.activeStateMachine)==null?void 0:c.inputs.find(f=>f.id===t||f.name===t);if(i&&i.sourceId&&!o.has(i.sourceId)){const f=this.evaluateLogicTree(i.sourceId,i.sourceHandleId,o);return this.inputs.set(i.id,f),f}let n=this.inputs.get(t)??(i?this.inputs.get(i.id):void 0);if((this.justFiredTriggers.has(t)||i&&this.justFiredTriggers.has(i.id))&&(n=!0),s&&n!==void 0){const f=(g=this.activeStateMachine)==null?void 0:g.inputs.find(d=>d.id===t);if(f&&f.value.type==="Number"&&typeof n=="number"){const d=f.value.defaultValue??f.value.value;if(s==="source-greater")return n>d;if(s==="source-less")return n<d;if(s==="source-equal")return n===d}if(s==="source-true")return n===!0;if(s==="source-false")return n===!1;if(s==="source-fire")return this.justFiredTriggers.has(t)}return n!==void 0?n:0}runLogicNodes(){!this.activeStateMachine||!this.activeStateMachine.logicNodes||this.activeStateMachine.logicNodes.forEach(t=>{(t.op===yt.SET_PROPERTY||t.op===yt.EFFECTOR)&&this.evaluateLogicTree(t.id)})}resolvePath(t,s){const o=s.split(".");let e=t;for(const i of o)if(e&&typeof e=="object"&&i in e)e=e[i];else return;return e}seek(t){this.artboard&&(this.currentTime=t,this.layerStates.forEach(s=>{s.time=t,s.time>(s.duration||0)&&(s.animations.some(e=>{var i;return((i=e.state)==null?void 0:i.loop)===!0})?s.time%=s.duration||1:s.time=s.duration)}),this.advance(0))}advance(t){if(!this.artboard)return;this.currentTime+=t,this.isMouseDown&&this.pointerDownTimes.forEach((o,e)=>{e&&this.currentTime-o>=.5&&(console.log(`[Engine] onHold detected for ${e}`),this.fireEventForObject(e,"onHold"),this.pointerDownTimes.delete(e))}),this.frameCount++,this.physicsEngine&&(this.physicsEngine.step(t),this.artboard.objects.forEach(o=>{var e;if((e=o.physics)!=null&&e.enabled){const i=this.physicsEngine.getPosition(o.id),n=this.physicsEngine.getRotation(o.id),a=this.objectStates.get(o.id);a&&i!==null&&n!==null&&(a.x=i.x,a.y=i.y,a.rotation=n*(180/Math.PI))}})),this.activeStateMachine&&(this.runLogicNodes(),this.evaluateTransitions(),this.onLogicUpdate&&this.logicNodeValues.size>0&&this.onLogicUpdate(Object.fromEntries(this.logicNodeValues)));const s=[];this.layerStates.forEach((o,e)=>{if(o.animations.length>0){if(o.time+=t,this.frameCount%240===0&&this.debugLog(`Advancing Layer time: ${o.time.toFixed(3)} / ${o.duration.toFixed(3)}`),o.time>o.duration)if(o.animations.some(n=>{var a;return((a=n.state)==null?void 0:a.loop)===!0}))o.time%=o.duration;else{const n=o.time<o.duration+.1;o.time=o.duration,n&&(o.currentStateIds.length>0&&this.handleAnimationFinished(o.currentStateIds[0],o.ruleId),e.startsWith("global_")&&s.push(e))}o.animations.forEach(i=>{this.applyAnimation(i.animation,o.time,i.filterObjectIds)})}}),s.forEach(o=>{this.layerStates.delete(o),this.debugLog(`[Engine] Cleaned up completed global layer: ${o}`)}),this.solveConstraints(t),this.solveBehaviors(t),this.activeTriggers.forEach((o,e)=>{var i,n,a,r,l,h,c;if(o.phase==="entry")o.time+=t,o.time>=o.animation.duration&&((a=(n=(i=this.artboard)==null?void 0:i.objects.find(g=>g.id===e))==null?void 0:n.triggers)==null||a.find(g=>g.id===o.triggerId),o.phase="hold",o.elapsedHold=0,o.time=o.animation.duration),this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0);else if(o.phase==="hold"){const g=(h=(l=(r=this.artboard)==null?void 0:r.objects.find(u=>u.id===e))==null?void 0:l.triggers)==null?void 0:h.find(u=>u.id===o.triggerId),f=(g==null?void 0:g.duration)||0;o.elapsedHold+=t*1e3;let d=o.elapsedHold>=f;if((g==null?void 0:g.eventType)==="hover"&&!this.activeHoverIds.has(e)&&(d=!0),((g==null?void 0:g.eventType)==="onHold"||(g==null?void 0:g.eventType)==="pointerDown")&&!this.isMouseDown&&(d=!0),d)if(g!=null&&g.exitAnimationId){const u=(c=this.artboard)==null?void 0:c.animations.find(m=>m.id===g.exitAnimationId);u?(o.phase="exit",o.animation=u,o.time=0):this.activeTriggers.delete(e)}else this.activeTriggers.delete(e)}else o.phase==="exit"&&(o.time+=t,o.time>=o.animation.duration?this.activeTriggers.delete(e):this.applyAnimation(o.animation,o.time,o.filterObjectIds||o.filterObjectId||void 0))}),this.evaluateContinuousInteractions(t)}evaluateContinuousInteractions(t){this.artboard&&(this.artboard.objects.forEach(s=>{var e,i,n;const o=(e=s.style)==null?void 0:e.analytics;if(o&&o.isEnabled&&o.triggerType==="visible"){const a=this.objectStates.get(s.id);if(a&&a.visible!==!1){const r=this.getGlobalTransform(s.id),l=(((i=s.geometry)==null?void 0:i.width)||100)*(r.scale_x||1),h=(((n=s.geometry)==null?void 0:n.height)||100)*(r.scale_y||1),c=50,g=r.x+l/2>=-this.canvasWidth/2-c&&r.x-l/2<=this.canvasWidth/2+c&&r.y+h/2>=-this.canvasHeight/2-c&&r.y-h/2<=this.canvasHeight/2+c,f=`analytics_${s.id}`,d=this.wasInView.has(f);g&&!d&&this.fireAnalyticsEvent(s.id,"visible"),g?this.wasInView.add(f):this.wasInView.delete(f)}}}),this.artboard.objects.forEach(s=>{const o=s.interactions||[];o.length!==0&&o.forEach(e=>{const i=e.triggers||[e.event||e.trigger];i&&i.forEach(n=>{var r,l,h;const a=n.toLowerCase();if(a==="on interval"||a==="oninterval"){const c=e.intervalValue||2e3,g=this.periodicTriggerTimes.get(e.id)||0;this.currentTime*1e3-g>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Interval"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="on delay"||a==="ondelay"){const c=e.delayValue||1e3;!this.periodicTriggerTimes.has(e.id)&&this.currentTime*1e3>=c&&(!e.conditions||this.checkConditions(e.conditions))&&(this.fireEventForObject(s.id,"On Delay"),this.periodicTriggerTimes.set(e.id,this.currentTime*1e3))}if(a==="scroll into view"||a==="scrollintoview"){const c=this.objectStates.get(s.id);if(c&&c.visible!==!1){const g=this.getGlobalTransform(s.id),f=(((r=s.geometry)==null?void 0:r.width)||100)*(g.scale_x||1),d=(((l=s.geometry)==null?void 0:l.height)||100)*(g.scale_y||1),u=50,m=g.x+f/2>=-this.canvasWidth/2-u&&g.x-f/2<=this.canvasWidth/2+u&&g.y+d/2>=-this.canvasHeight/2-u&&g.y-d/2<=this.canvasHeight/2+u,y=this.wasInView.has(s.id);m&&!y&&(!e.conditions||this.checkConditions(e.conditions))&&this.fireEventForObject(s.id,"Scroll Into View"),m?this.wasInView.add(s.id):this.wasInView.delete(s.id)}}if(a==="scroll progress"||a==="scrollprogress"){const c=Math.abs(this.scrollOffset.y)/(((h=this.artboard)==null?void 0:h.height)||1e3),g=this.scrollProgressLastValue.get(e.id)||0;Math.abs(c-g)>.001&&(this.scrollProgressLastValue.set(e.id,c),(e.action==="Set Input"||e.action==="setInput")&&this.updateInput(e.targetInputId,c))}})})}))}solveConstraints(t){this.artboard&&this.artboard.objects.forEach(s=>{if(!s.constraints||s.constraints.length===0)return;const o=this.objectStates.get(s.id);if(!o)return;const e=this.getGlobalTransform(s.id);if(s.constraints.forEach((i,n)=>{var h,c,g,f,d,u,m,y,v;const a=((h=o.constraints)==null?void 0:h[n])||{},r={...i,...a},l=r.strength??1;if(r.type==="Translation"){const b=this.getGlobalTransform(r.targetId);if(b){const C=r.offsetX||0,S=r.offsetY||0,I=b.x+C,w=b.y+S,k=r.useSpring;if(k){const T=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:W,y:M,vx:_,vy:R}=this.computeSpring(e.x,e.y,T.vx,T.vy,I,w,r,t);r.copyX&&(e.x=e.x+(W-e.x)*l),r.copyY&&(e.y=e.y+(M-e.y)*l),this.objectVelocities.set(s.id,{vx:_,vy:R})}else r.copyX&&(e.x=e.x+(I-e.x)*l),r.copyY&&(e.y=e.y+(w-e.y)*l);let E=!1;if((c=r.limitX)!=null&&c.enabled){const T=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==T&&(E=!0)}if((g=r.limitY)!=null&&g.enabled){const T=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==T&&(E=!0)}E&&k&&this.objectVelocities.set(s.id,{vx:0,vy:0})}}else if(r.type==="Rotation"){const b=this.getGlobalTransform(r.targetId);if(b){let S=(b.rotation+(r.offset||0)-e.rotation)%360;S>180&&(S-=360),S<-180&&(S+=360),e.rotation=e.rotation+S*l}}else if(r.type==="Scale"){const b=this.getGlobalTransform(r.targetId);b&&(r.copyX&&(e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l),r.copyY&&(e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l))}else if(r.type==="Transform"){const b=this.getGlobalTransform(r.targetId);if(b){e.x=e.x+(b.x-e.x)*l,e.y=e.y+(b.y-e.y)*l;let C=(b.rotation-e.rotation)%360;C>180&&(C-=360),C<-180&&(C+=360),e.rotation=e.rotation+C*l,e.scale_x=e.scale_x+(b.scale_x-e.scale_x)*l,e.scale_y=e.scale_y+(b.scale_y-e.scale_y)*l}}else if(r.type==="FollowPointer"){const b=((f=this._lastPointerPos)==null?void 0:f.x)??e.x,C=((d=this._lastPointerPos)==null?void 0:d.y)??e.y,S=r.useSpring;if(S){const w=this.objectVelocities.get(s.id)||{vx:0,vy:0},{x:k,y:E,vx:T,vy:W}=this.computeSpring(e.x,e.y,w.vx,w.vy,b,C,r,t);e.x=k,e.y=E,this.objectVelocities.set(s.id,{vx:T,vy:W})}else e.x=e.x+(b-e.x)*l,e.y=e.y+(C-e.y)*l;let I=!1;if((u=r.limitX)!=null&&u.enabled){const w=e.x;e.x=Math.max(r.limitX.min,Math.min(r.limitX.max,e.x)),e.x!==w&&(I=!0)}if((m=r.limitY)!=null&&m.enabled){const w=e.y;e.y=Math.max(r.limitY.min,Math.min(r.limitY.max,e.y)),e.y!==w&&(I=!0)}I&&S&&this.objectVelocities.set(s.id,{vx:0,vy:0})}else if(r.type==="Distance"){const b=this.getGlobalTransform(r.targetId);if(b){const C=e.x-b.x,S=e.y-b.y,I=Math.sqrt(C*C+S*S),w=r.distance||0;let k=I;switch(r.mode){case"exact":k=w;break;case"minimum":k=Math.max(w,I);break;case"maximum":k=Math.min(w,I);break;case"clamped":k=Math.max(0,Math.min(w,I));break}if(I>0){const E=e.x===b.x&&e.y===b.y?1:k/I;e.x=e.x+(b.x+C*E-e.x)*l,e.y=e.y+(b.y+S*E-e.y)*l}}}else if(r.type==="FollowPath"){const b=(y=this.artboard)==null?void 0:y.objects.find(C=>C.id===r.targetId);if(b){const C=this.getGlobalTransform(b.id);if(C){let S=b.geometry;if(b.type==="Frame"||b.type==="Group"||!S||S.type!=="Path"&&S.type!=="Ellipse"&&S.type!=="Rectangle"){const F=(v=this.artboard)==null?void 0:v.objects.find(q=>q.parentId===b.id&&q.type==="Shape"&&q.geometry&&(q.geometry.type==="Path"||q.geometry.type==="Ellipse"||q.geometry.type==="Rectangle"));F&&(S=F.geometry)}if(!S)return;const I=(r.distance||0)/100,w=C.width||S.width||0,k=C.height||S.height||0,E=this.getPointOnPath(S,w,k,I),T=C.rotation*Math.PI/180,W=Math.cos(T),M=Math.sin(T),_=E.x*C.scale_x*W-E.y*C.scale_y*M,R=E.x*C.scale_x*M+E.y*C.scale_y*W;let x=C.rotation+(r.offsetRotation||0);if(r.orient){const F=Math.cos(E.angle),q=Math.sin(E.angle),Q=F*C.scale_x*W-q*C.scale_y*M,it=F*C.scale_x*M+q*C.scale_y*W;x=Math.atan2(it,Q)*180/Math.PI+(r.offsetRotation||0)}const L=x*Math.PI/180,$=Math.cos(L),A=Math.sin(L),V=(r.offsetX||0)*$-(r.offsetY||0)*A,H=(r.offsetX||0)*A+(r.offsetY||0)*$,et=C.x+_+V,P=C.y+R+H;if(e.x=e.x+(et-e.x)*l,e.y=e.y+(P-e.y)*l,r.orient){let F=(x-e.rotation)%360;F>180&&(F-=360),F<-180&&(F+=360),e.rotation=e.rotation+F*l}}}}else if(r.type==="IK"){const b=this.getGlobalTransform(r.targetId);b&&this.solveIK(s,b,r.boneCount||2,l)}}),s.constraints.some(i=>i.type!=="IK")){const i=this.globalToLocal(s.parentId,e);o.x=i.x,o.y=i.y,o.rotation=i.rotation,o.flip_x=i.scale_x<0,o.scale_x=Math.abs(i.scale_x),o.flip_y=i.scale_y<0,o.scale_y=Math.abs(i.scale_y)}})}getGlobalTransform(t){var h;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,rotation:0,scale_x:1,scale_y:1};const o=(h=this.artboard)==null?void 0:h.objects.find(c=>c.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,rotation:s.rotation,scale_x:(s.scale_x??1)*(s.flip_x?-1:1),scale_y:(s.scale_y??1)*(s.flip_y?-1:1)};const e=this.getGlobalTransform(o.parentId),i=e.rotation*Math.PI/180,n=Math.cos(i),a=Math.sin(i),r=e.x+(s.x*e.scale_x*n-s.y*e.scale_y*a),l=e.y+(s.x*e.scale_x*a+s.y*e.scale_y*n);return{x:r,y:l,rotation:e.rotation+s.rotation,scale_x:e.scale_x*(s.scale_x??1)*(s.flip_x?-1:1),scale_y:e.scale_y*(s.scale_y??1)*(s.flip_y?-1:1)}}globalToLocal(t,s){if(!t)return s;const o=this.getGlobalTransform(t),e=o.scale_x===0?0:1/o.scale_x,i=o.scale_y===0?0:1/o.scale_y,n=-o.rotation*Math.PI/180,a=Math.cos(n),r=Math.sin(n),l=s.x-o.x,h=s.y-o.y,c=(l*a-h*r)*e,g=(l*r+h*a)*i;return{x:c,y:g,rotation:s.rotation-o.rotation,scale_x:s.scale_x/(o.scale_x||1),scale_y:s.scale_y/(o.scale_y||1)}}solveIK(t,s,o,e){var l;const i=[];let n=t.id;for(let h=0;h<o&&n;h++){const c=(l=this.artboard)==null?void 0:l.objects.find(g=>g.id===n);if(!c)break;i.push({id:n,local:this.objectStates.get(n),global:this.getGlobalTransform(n)}),n=c.parentId}if(i.length<2)return;const a=i.reverse(),r=5;for(let h=0;h<r;h++){const c=this.getGlobalTransform(t.id);for(let g=a.length-2;g>=0;g--){const f=a[g],d=this.getGlobalTransform(f.id),u=c.x-d.x,m=c.y-d.y,y=s.x-d.x,v=s.y-d.y,b=Math.sqrt(u*u+m*m),C=Math.sqrt(y*y+v*v);if(b>.001&&C>.001){const S=Math.atan2(m,u);let w=(Math.atan2(v,y)-S)*180/Math.PI;w*=e;const k=this.objectStates.get(f.id);k&&(k.rotation+=w)}}}}computeSpring(t,s,o,e,i,n,a,r){const l=a.stiffness??100,h=a.damping??10,c=a.mass??1,g=-l*(t-i),f=-l*(s-n),d=-h*o,u=-h*e,m=(g+d)/c,y=(f+u)/c,v=o+m*r,b=e+y*r,C=t+v*r,S=s+b*r;return{x:C,y:S,vx:v,vy:b}}handlePointerInput(t,s,o,e,i){if(!this.artboard)return;const n=this.calculateTransform(e,i,this.artboard.width,this.artboard.height,this.layout.fit,this.layout.alignment),a=(s-n.tx)/n.scaleX-this.artboard.width/2,r=(o-n.ty)/n.scaleY-this.artboard.height/2;this._prevPointerPos=this._lastPointerPos,this._lastPointerPos={x:a,y:r},this.updateInput("mouseX",a),this.updateInput("mouseY",r),this.handlePointerEvent(t,a,r)}handleScroll(t,s){const o=this.scrollOffset.x,e=this.scrollOffset.y;this.scrollOffset={x:t,y:s},this._totalScroll.x+=t-o,this._totalScroll.y+=s-e,this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handleWheel(t,s){this._totalScroll.x+=t,this._totalScroll.y+=s,this.scrollOffset={x:this._totalScroll.x,y:this._totalScroll.y},this.updateInput("scrollX",this._totalScroll.x),this.updateInput("scrollY",this._totalScroll.y)}handlePointerEvent(t,s,o){var r,l,h,c,g;if(!this.artboard)return;t==="down"?(this.isMouseDown=!0,this.updateInput("isMouseDown",!0)):(t==="up"||t==="blur")&&(this.isMouseDown=!1,this.updateInput("isMouseDown",!1));let e=null;const i=(f,d)=>{var C;let u=d;d==="click"?u="onClick":d==="down"?u="onPointerDown":d==="up"?u="onPointerUp":d==="blur"&&(u="onPointerLeave");const m=new Set([u]);d==="move"&&m.add("onPointerEnter").add("hover").add("onPointerLeave").add("blur"),u==="onClick"&&m.add("click"),u==="onPointerDown"&&m.add("pointerDown"),u==="onPointerUp"&&m.add("pointerUp");const y=["button","toggle","toggle_button","dropdown","listview","inputbox","slider","checkbox","radiogroup"];return!!(f.type==="Component"&&y.includes(f.variant)||y.includes((C=f.type)==null?void 0:C.toLowerCase())||(f.interactions||[]).some(S=>m.has(S.event))||(f.triggers||[]).some(S=>m.has(S.eventType)))};let n=null;for(let f=this.artboard.objects.length-1;f>=0;f--){const d=this.artboard.objects[f],u=this.objectStates.get(d.id);if(u&&u.visible!==!1&&u.opacity>0&&this.hitTest(d,s,o)&&(n||(n=d),i(d,t))){e=d;break}}!e&&n&&(e=n),this.pointerHistory.push({x:s,y:o,time:Date.now()}),this.pointerHistory.length>this.MAX_HISTORY&&this.pointerHistory.shift();const a=(e==null?void 0:e.id)||null;if(t==="move"){if(this.draggingSliderId){const f=this.artboard.objects.find(d=>d.id===this.draggingSliderId);f&&this.updateSliderValueFromPointer(f,s,o);return}if(this.draggingListViewId){const f=this.artboard.objects.find(d=>d.id===this.draggingListViewId);f&&this.updateListViewScrollFromPointer(f);return}e&&e.type==="Component"&&e.variant==="listview"&&this.updateListViewHoverFromPointer(e,s,o),this.isMouseDown&&a&&this.fireEventForObject(a,"Drag"),a!==this.lastHoveredObjectId&&(console.log(`[Engine] HOVER CHANGE: ${this.lastHoveredObjectId} -> ${a}`),this.lastHoveredObjectId&&this.fireEventForObject(this.lastHoveredObjectId,"onPointerLeave"),a&&this.fireEventForObject(a,"onPointerEnter"),this.lastHoveredObjectId=a);return}if((t==="up"||t==="blur")&&(this.draggingSliderId=null,this.draggingListViewId=null,this.draggingBehaviors.clear(),this.pointerDownTimes.delete(a),this.activeObjectId=null),t==="down"&&(this.pointerDownTimes.set(a,this.currentTime),this.activeObjectId=a,e&&((r=e.behaviors)!=null&&r.some(f=>f.type===Y.Draggable))&&this.draggingBehaviors.add(a)),t==="move"?(a&&!this.activeHoverIds.has(a)&&this.activeHoverIds.add(a),this.activeHoverIds.forEach(f=>{f!==a&&this.activeHoverIds.delete(f)})):t==="blur"&&this.activeHoverIds.clear(),this.activeDropdownId&&t==="down"){const f=this.artboard.objects.find(d=>d.id===this.activeDropdownId);if(f&&(f.type==="Dropdown"||f.variant==="dropdown")){const d=this.objectStates.get(f.id),u=(d==null?void 0:d.options)||f.options||{},m=f.geometry||{},y=m.width??f.width??200,v=m.height??f.height??40,b=u.optionsList||[],C=u.itemHeight||32,S=u.listPadding??4,I=b.length*C+S*2,w=this.getWorldTransform(f.id),k=y*Math.abs(w.scaleX),E=v*Math.abs(w.scaleY),T=w.y+E/2+4,W=Math.abs(s-w.x)<=k/2,M=o>=T&&o<=T+I*Math.abs(w.scaleY);if(W&&M){const _=Math.abs(w.scaleY),R=o-(T+S*_),x=Math.floor(R/(C*_));if(x>=0&&x<b.length){const L=b[x];u.selectedOption=L,u.isOpen=!1,this.activeDropdownId=null,f.inputId&&this.setInternalInput(f.inputId,L),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"dropdown",property:"selectedOption",value:L})}return}else a!==this.activeDropdownId&&(u.isOpen=!1,this.activeDropdownId=null)}}if(e){let f=e,d=e;for(;d&&d.parentId;){const m=this.artboard.objects.find(y=>y.id===d.parentId);if(m&&m.type==="Component"){f=m;break}d=m}let u=t;if(t==="click"?u="onClick":t==="down"?u="onPointerDown":t==="up"?u="onPointerUp":t==="blur"&&(u="onPointerLeave"),this.fireEventForObject(e.id,u),f!==e&&this.fireEventForObject(f.id,u),f.type==="Component"&&f.variant==="toggle_button"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"toggle_button",property:"checked",value:y.checked}),this.fireEventForObject(f.id,"Toggle"),this.fireEventForObject(f.id,y.checked?"Toggle True":"Toggle False")}if(f.type==="Component"&&f.variant==="toggle"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"toggle",property:"checked",value:y.checked}),this.onToggle&&this.onToggle(f.name,y.checked),this.fireEventForObject(f.id,"Toggle"),this.fireEventForObject(f.id,y.checked?"Toggle True":"Toggle False")}if(f.type==="Component"&&f.variant==="dropdown"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{},v=!y.isOpen;if(v&&this.activeDropdownId&&this.activeDropdownId!==f.id){const b=this.artboard.objects.find(C=>C.id===this.activeDropdownId);b&&b.options&&(b.options.isOpen=!1)}y.isOpen=v,this.activeDropdownId=v?f.id:null}if(f.type==="Component"&&f.variant==="button"&&t==="down"&&(this.onButtonClick&&this.onButtonClick(f.name,f.id),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"button",property:"click",value:!0})),f.type==="Component"&&f.variant==="listview"&&t==="down"){this.draggingListViewId=f.id;const m=this.getListViewItemIndexAtPointer(f,s,o);if(m!==null){const y=f.options||{};y.activeItemIndex=m;const v=this.objectStates.get(f.id);v&&v.options&&(v.options.activeItemIndex=m);const b=(y.items||[])[m],C=typeof b=="string"?b:b.label||b.value||m;v&&v.options&&(v.options.selectedValue=C),f.inputId&&this.setInternalInput(f.inputId,C),this.onComponentChange&&(this.onComponentChange({objectId:f.id,componentName:f.name,variant:"listview",property:"activeItemIndex",value:m}),this.onComponentChange({objectId:f.id,componentName:f.name,variant:"listview",property:"selected",value:C}))}}if(f.type==="Component"&&f.variant==="slider"&&t==="down"&&(this.draggingSliderId=f.id,this.updateSliderValueFromPointer(f,s,o)),f.type==="Component"&&f.variant==="checkbox"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{};y.checked=!y.checked,f.inputId&&this.setInternalInput(f.inputId,y.checked),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"checkbox",property:"checked",value:y.checked}),this.fireEventForObject(f.id,"Click"),this.fireEventForObject(f.id,y.checked?"Checked":"Unchecked")}if(f.type==="Component"&&f.variant==="radiogroup"&&t==="down"){const m=this.objectStates.get(f.id),y=(m==null?void 0:m.options)||f.options||{},v=y.optionsList||[],b=this.getRadioGroupItemIndexAtPointer(f,s,o);if(b!==null&&b>=0&&b<v.length){const C=v[b];y.selectedValue=C,f.inputId&&this.setInternalInput(f.inputId,C),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"radiogroup",property:"selectedValue",value:C}),this.fireEventForObject(f.id,"Click"),this.fireEventForObject(f.id,`Selected: ${C}`)}}if(f.type==="LineGraph"&&(t==="down"||t==="click")){const m=f.geometry,y=(m==null?void 0:m.datasets)||[],v=this.objectStates.get(f.id),b=(v==null?void 0:v.width)||(m==null?void 0:m.width)||200,C=(v==null?void 0:v.height)||(m==null?void 0:m.height)||150,S=this.getWorldTransform(f.id),I=30,w=20,k=b-I,E=C-w;let T=1;y.forEach(_=>{const R=Math.max(..._.data||[0]);R>T&&(T=R)});let W=1/0,M=null;y.forEach((_,R)=>{const x=_.data||[],L=k/Math.max(x.length-1,1);x.forEach(($,A)=>{const V=S.x-b/2+I+A*L,H=S.y+C/2-w-$/T*E,et=Math.sqrt((s-V)**2+(o-H)**2);et<W&&(W=et,M={dIdx:R,pIdx:A,val:$,label:_.label||`Dataset ${R+1}`})})}),M&&W<20&&this.onGraphPointClick&&this.onGraphPointClick({objectId:f.id,componentName:f.name,datasetIndex:M.dIdx,pointIndex:M.pIdx,value:M.val,label:M.label}),this.onComponentChange&&this.onComponentChange({objectId:f.id,componentName:f.name,variant:"linegraph",property:"click",value:(M==null?void 0:M.val)??null})}if(t==="click"){const m=(l=this.artboard)==null?void 0:l.objects.find(b=>b.id===e.id),y=this.focusedId,v=(m==null?void 0:m.type)==="InputBox"||(m==null?void 0:m.type)==="Component"&&m.variant==="inputbox";if(m&&v){if(this.focusedId=e.id,console.log(`[Engine] Focus set to: ${e.id}`),y!==this.focusedId){if(y){const b=(h=this.artboard)==null?void 0:h.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}this.onInputFocus&&this.onInputFocus(m.name)}}else if(this.focusedId=null,y){const b=(c=this.artboard)==null?void 0:c.objects.find(C=>C.id===y);b&&this.onInputBlur&&this.onInputBlur(b.name)}}}else if(t==="click"){const f=this.focusedId;if(this.focusedId=null,f){const d=(g=this.artboard)==null?void 0:g.objects.find(u=>u.id===f);d&&this.onInputBlur&&this.onInputBlur(d.name)}}}handleKeyDown(t){if(!this.artboard||!this.focusedId)return;const s=this.artboard.objects.find(a=>a.id===this.focusedId),o=(s==null?void 0:s.type)==="InputBox"||(s==null?void 0:s.type)==="Component"&&s.variant==="inputbox";if(!s||!o)return;const e=s.options||{};let i=e.text||"";if(t.key==="Backspace")i=i.slice(0,-1);else if(t.key==="Enter")if(e.multiline)i+=`
7
+ `;else{this.focusedId=null;return}else if(t.key.length===1)i+=t.key;else return;e.text=i;const n=s.geometry;n.textInputId&&this.updateInput(n.textInputId,i),this.onComponentChange&&this.onComponentChange({objectId:s.id,componentName:s.name,variant:"inputbox",property:"text",value:i}),this.onInputChange&&this.onInputChange(s.name,i),this.onInputUpdate&&this.onInputUpdate(this.focusedId,i)}fireEventForObject(t,s){var h,c,g,f,d;const o=(h=this.artboard)==null?void 0:h.objects.find(u=>u.id===t);if(!o)return;const e=new Set([s,s.toLowerCase()]),i=s.toLowerCase();i==="onclick"||i==="click"||i==="onpointerdown"||i==="pointerdown"?this.fireAnalyticsEvent(t,"click"):(i==="onpointerenter"||i==="hover"||i==="move")&&this.fireAnalyticsEvent(t,"hover"),i==="onclick"||i==="click"?(e.add("click"),e.add("onclick")):i==="onpointerdown"||i==="pointerdown"?(e.add("pointerdown"),e.add("onpointerdown")):i==="onpointerup"||i==="pointerup"?(e.add("pointerup"),e.add("onpointerup")):i==="onpointerenter"||i==="hover"||i==="move"?(e.add("hover"),e.add("onpointerenter")):i==="onpointerleave"||i==="blur"?(e.add("onpointerleave"),e.add("blur")):i==="drag"||i==="ondrag"?(e.add("drag"),e.add("ondrag")):i==="toggle"||i==="ontoggle"?(e.add("toggle"),e.add("ontoggle")):i==="toggle true"||i==="toggle_true"||i==="toggletrue"?(e.add("toggle true"),e.add("toggle_true"),e.add("toggletrue")):(i==="toggle false"||i==="toggle_false"||i==="togglefalse")&&(e.add("toggle false"),e.add("toggle_false"),e.add("togglefalse"));const a=(o.interactions||[]).find(u=>{const m=u.triggers||[u.event||u.trigger||"click"];return((u.triggerLogic||"OR")==="AND"?m.every(b=>e.has(b.toLowerCase())):m.some(b=>e.has(b.toLowerCase())))?u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):!0:!1});if(a){if(console.log(`[Engine] Interaction matched: ${s} -> Action: ${a.action}`),a.action==="setInput"||a.action==="Set Input"){let u=a.value||a.inputValue;u==="toggle"&&(u=!this.inputs.get(a.targetInputId)),this.updateInput(a.targetInputId,u)}else if(a.action==="Toggle Boolean"){const u=this.inputs.get(a.targetInputId);this.updateInput(a.targetInputId,!u)}else if(a.action==="fireTrigger")this.updateInput(a.targetInputId,!0);else if(a.action==="setProperty"){const u=a.targetObjectId||o.id,m=a.targetProperty;m&&this.updateObjectProperty(u,m,a.value)}else if(a.action==="Navigate Artboard"||a.action==="navigate")this.onNavigation&&this.onNavigation({type:"artboard",value:a.targetArtboard||a.value});else if(a.action==="Navigate URL")this.onNavigation&&this.onNavigation({type:"url",value:a.navigateUrl});else if(a.action==="Play Animation"){const u=a.targetAnimationId;u==="__all__"?(g=(c=this.artboard)==null?void 0:c.animations)==null||g.forEach(m=>{this.triggerGlobalAnimation(m.id,a.subAnimationIds)}):u&&this.triggerGlobalAnimation(u,a.subAnimationIds)}else if(a.action==="setState"||a.action==="Set State"){const u=a.targetObjectId||o.id,y={...this.objectStates.get(u)||{},...a.value||{}};this.objectStates.set(u,y),console.log(`[Engine] State updated for ${u}:`,y)}else if(a.action==="Stop Animation"||a.action==="Pause Animation"){const u=a.targetAnimationId;u==="__all__"?this.layerStates.forEach((m,y)=>{y.startsWith("global_")&&this.layerStates.delete(y)}):u&&this.layerStates.forEach((m,y)=>{y.startsWith(`global_${u}_`)&&this.layerStates.delete(y)})}else if(a.action==="Switch to State"&&this.activeStateMachine){const u=a.targetState,m=this.activeStateMachine.layers.find(y=>y.states.some(v=>v.id===u||v.name===u));m&&(console.log(`[Engine] Switching Layer ${m.name} to State ${u}`),this.enterStates(m.name,[u]))}this.onTrigger&&this.onTrigger(s,a.action)}const l=(o.triggers||[]).find(u=>{const m=u.eventType.toLowerCase();let y=!1;return(e.has(m)||m==="click"&&e.has("onclick")||m==="hover"&&(e.has("onpointerenter")||e.has("hover"))||m==="pointerdown"&&e.has("onpointerdown")||m==="pointerup"&&e.has("onpointerup"))&&(y=!0),y&&u.conditions&&u.conditions.length>0?this.checkConditions(u.conditions):y});if(l&&l.entryAnimationId){console.log(`[Engine] Trigger matched: ${s} (as ${l.eventType}) -> Animation ${l.entryAnimationId}`);const u=(d=(f=this.artboard)==null?void 0:f.animations)==null?void 0:d.find(m=>m.id===l.entryAnimationId);u&&(this.activeTriggers.set(o.id,{triggerId:l.id,animation:u,time:0,phase:"entry",elapsedHold:0,filterObjectId:l.targetObjectId}),this.onTrigger&&this.onTrigger(l.name,u.name))}}fireAnalyticsEvent(t,s){var r,l;const o=(r=this.artboard)==null?void 0:r.objects.find(h=>h.id===t);if(!o)return;const e=(l=o.style)==null?void 0:l.analytics;if(!e||!e.isEnabled||e.triggerType!==s)return;const i=e.eventName||`${o.name.toLowerCase().replace(/\s+/g,"_")}_interacted`,n={};e.parameters&&Array.isArray(e.parameters)&&e.parameters.forEach(h=>{if(h.type==="literal")n[h.key]=h.value;else if(h.type==="variable"){const c=this.inputs.get(h.value);n[h.key]=c!==void 0?c:""}}),console.log(`[ExodeUI Analytics] Dispatching event "${i}" via ${s} trigger:`,n);const a=e.platforms||{ga4:!0,meta:!0,mixpanel:!1};if(a.ga4){const h=window;typeof h.gtag=="function"?(h.gtag("event",i,n),console.log(`[ExodeUI Analytics] GA4: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] GA4: window.gtag is not a function. Event "${i}" skipped.`)}if(a.meta){const h=window;typeof h.fbq=="function"?(h.fbq("track",i,n),console.log(`[ExodeUI Analytics] Meta Pixel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Meta Pixel: window.fbq is not a function. Event "${i}" skipped.`)}if(a.mixpanel){const h=window;h.mixpanel&&typeof h.mixpanel.track=="function"?(h.mixpanel.track(i,n),console.log(`[ExodeUI Analytics] Mixpanel: Event "${i}" sent successfully.`)):console.warn(`[ExodeUI Analytics] Mixpanel: window.mixpanel.track is not a function. Event "${i}" skipped.`)}}initGlobalAnimationTriggers(){if(!this.artboard)return;const t=this.artboard.animationFlow||[];let s=!1;t.forEach(o=>{if((o.trigger==="on_load"||o.trigger==="after_delay")&&o.targetAnimationId){s=!0;const e=o.delay||0;e<=0?this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id):setTimeout(()=>this.triggerGlobalAnimation(o.targetAnimationId,o.subAnimationIds,o.loop,o.id),e)}}),!s&&this.artboard.startupAnimationId&&this.triggerGlobalAnimation(this.artboard.startupAnimationId,this.artboard.startupSubAnimationIds)}triggerGlobalAnimation(t,s,o=!1,e){if(!this.artboard)return;const i=this.artboard.animations.find(a=>a.id===t);if(!i)return;const n=`global_${t}_${Math.random().toString(36).substr(2,5)}`;this.layerStates.set(n,{currentStateIds:[t],animations:[{animation:i,state:{loop:o},filterObjectIds:s}],time:0,duration:i.duration,ruleId:e}),this.debugLog(`[Engine] Triggered global animation: ${i.name} (Loop: ${o}, Sub-Anims: ${(s==null?void 0:s.length)||"All"})`)}handleAnimationFinished(t,s){if(!this.artboard)return;(this.artboard.animationFlow||[]).forEach(e=>{if(e.trigger==="after_anim"&&e.targetAnimationId&&(e.afterAnim===t||s&&e.afterAnim===s)){const n=e.delay||0;n<=0?this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id):setTimeout(()=>this.triggerGlobalAnimation(e.targetAnimationId,e.subAnimationIds,e.loop,e.id),n)}})}getWorldTransform(t){var g;const s=this.objectStates.get(t);if(!s)return{x:0,y:0,scaleX:1,scaleY:1,rotation:0};const o=(g=this.artboard)==null?void 0:g.objects.find(f=>f.id===t);if(!o||!o.parentId)return{x:s.x,y:s.y,scaleX:s.scale_x??1,scaleY:s.scale_y??1,rotation:s.rotation??0};const e=this.getWorldTransform(o.parentId),i=e.rotation*(Math.PI/180),n=Math.cos(i),a=Math.sin(i),r=s.x*e.scaleX,l=s.y*e.scaleY,h=e.x+(r*n-l*a),c=e.y+(r*a+l*n);return{x:h,y:c,scaleX:(s.scale_x??1)*e.scaleX,scaleY:(s.scale_y??1)*e.scaleY,rotation:e.rotation+(s.rotation??0)}}hitTest(t,s,o){var b,C;if(!this.objectStates.get(t.id))return!1;const i=((b=t.geometry)==null?void 0:b.width)??t.width??100,n=((C=t.geometry)==null?void 0:C.height)??t.height??100,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),c=Math.cos(h),g=Math.sin(h),f=r*c-l*g,d=r*g+l*c,u=a.scaleX,m=a.scaleY,y=i*Math.abs(u),v=n*Math.abs(m);return Math.abs(f)<=y/2&&Math.abs(d)<=v/2}updateSliderValueFromPointer(t,s,o){var w;const e=this.objectStates.get(t.id);if(!e)return;const i=t.options||{},n=((w=t.geometry)==null?void 0:w.width)??t.width??200,a=this.getWorldTransform(t.id),r=s-a.x,l=o-a.y,h=-a.rotation*(Math.PI/180),c=Math.cos(h),g=Math.sin(h),f=r*c-l*g,d=i.thumbWidth??16,u=n-d;let y=(f+u/2)/u;y=Math.max(0,Math.min(1,y));const v=i.min??0,b=i.max??100,C=i.step||1;let S=v+y*(b-v);C>0&&(S=Math.round(S/C)*C),S=Math.max(v,Math.min(b,S));const I=e.options||{};I.value!==S&&(e.options={...I,value:S},t.inputId&&this.setInternalInput(t.inputId,S),this.onComponentChange&&this.onComponentChange({objectId:t.id,componentName:t.name,variant:"slider",property:"value",value:S}))}applyAnimation(t,s,o){!t||!t.tracks||t.tracks.forEach(e=>{var c,g,f;const i=e.object_id||e.objectId;if(o){if(Array.isArray(o)){if(!o.includes(i))return}else if(i!==o)return}const n=(c=this.artboard)==null?void 0:c.objects.find(d=>d.id===i),a=((g=n==null?void 0:n.physics)==null?void 0:g.enabled)&&n.physics.bodyType!=="Static";let r=e.property;if(a&&(r==="x"||r==="y"||r==="rotation"))return;const l=this.objectStates.get(i);if(!l){this.frameCount%600===0&&this.debugLog(`Skipping track: Object ${i} not found in state`);return}const h=this.interpolate(e.keyframes,s);if(h!==void 0){if(this.frameCount%240===0){const d=(n==null?void 0:n.name)||i,u=typeof h=="object"?JSON.stringify(h).slice(0,50):h;this.debugLog(`[Anim] Applying ${r} = ${u} to ${d}`)}if(r.includes(".")){const d=(r||"").split(".");let u=l;for(let m=0;m<d.length-1;m++){if(typeof u[d[m]]!="object"||u[d[m]]===null){let y=n;for(let v=0;v<=m;v++)y=y?y[d[v]]:null;if(d[m]==="corner_radius"||d[m]==="cornerRadius"){const v=typeof u[d[m]]=="number"?u[d[m]]:typeof y=="number"?y:0;u[d[m]]={tl:v,tr:v,bl:v,br:v}}else u[d[m]]=y?JSON.parse(JSON.stringify(y)):{}}u=u[d[m]]}u[d[d.length-1]]=h,d[d.length-1]==="color"&&(d[d.length-2]==="fill"||d[d.length-2]==="stroke")&&(u.type="Solid")}else r==="fill"?(l.style||(l.style={}),l.style.fill=h):r==="stroke"?(l.style||(l.style={}),l.style.stroke=h):l[r]=h;if(this.physicsEngine&&((f=n==null?void 0:n.physics)!=null&&f.enabled)&&n.physics.bodyType==="Static")if(r==="x"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,h,d.y)}else if(r==="y"){const d=this.physicsEngine.getPosition(i);d&&this.physicsEngine.setPosition(i,d.x,h)}else r==="rotation"&&this.physicsEngine.setRotation(i,h*(Math.PI/180))}})}interpolate(t,s){if(t.length===0)return;let o=t[0],e=t[t.length-1];if(s<=o.time)return o.value;if(s>=e.time)return e.value;for(let a=0;a<t.length-1;a++)if(s>=t[a].time&&s<t[a+1].time){o=t[a],e=t[a+1];break}const i=e.time-o.time;let n=(s-o.time)/i;if(o.easing&&(n=si(o.easing)(n)),typeof o.value=="string"){if(o.value.startsWith("#"))return this.interpolateColor(o.value,e.value,n);const a=parseFloat(o.value),r=parseFloat(e.value);return!isNaN(a)&&!isNaN(r)?Math.round(a+(r-a)*n).toString():o.value}if(Array.isArray(o.value)&&Array.isArray(e.value))return o.value.length===e.value.length?o.value.map((a,r)=>{const l=e.value[r];return typeof a=="number"&&typeof l=="number"?a+(l-a)*n:n<.5?a:l}):n<.5?o.value:e.value;if(typeof o.value=="object"&&typeof e.value=="object"&&o.value!==null&&e.value!==null){if(o.value.width!==void 0&&o.value.color!==void 0)return this.interpolateStroke(o.value,e.value,n);if(o.value.type&&e.value.type)return this.interpolateFill(o.value,e.value,n);const a={};return new Set([...Object.keys(o.value),...Object.keys(e.value)]).forEach(l=>{const h=o.value[l],c=e.value[l];typeof h=="number"&&typeof c=="number"?a[l]=h+(c-h)*n:h===void 0?a[l]=c:c===void 0?a[l]=h:a[l]=n<.5?h:c}),a}return typeof o.value=="number"&&typeof e.value=="number"?o.value+(e.value-o.value)*n:n<.5?o.value:e.value}interpolateColor(t,s,o){var d,u;const e=((u=(d=this.artboard)==null?void 0:d.tokens)==null?void 0:u.colors)||{},i=e[t]||t,n=e[s]||s,a=m=>{if(!m)return{r:0,g:0,b:0};const y=m.startsWith("#")?m.replace("#",""):"000000";return y.length===3?{r:parseInt(y[0]+y[0],16),g:parseInt(y[1]+y[1],16),b:parseInt(y[2]+y[2],16)}:{r:parseInt(y.substring(0,2),16),g:parseInt(y.substring(2,4),16),b:parseInt(y.substring(4,6),16)}},r=a(i),l=a(n),h=Math.round(r.r+(l.r-r.r)*o),c=Math.round(r.g+(l.g-r.g)*o),g=Math.round(r.b+(l.b-r.b)*o),f=m=>{const y=Math.max(0,Math.min(255,m)).toString(16);return y.length===1?"0"+y:y};return`#${f(h)}${f(c)}${f(g)}`}interpolateStops(t,s,o){return!t||!s||t.length!==s.length?o<.5?t:s:t.map((e,i)=>{const n=s[i];return{offset:e.offset+(n.offset-e.offset)*o,color:this.interpolateColor(e.color,n.color,o),opacity:(e.opacity??1)+((n.opacity??1)-(e.opacity??1))*o}})}interpolateFill(t,s,o){if(!t||!s||t.type!==s.type)return o<.5?t:s;const e={...t,opacity:(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o};return t.type==="Solid"?e.color=this.interpolateColor(t.color,s.color,o):(t.type==="LinearGradient"||t.type==="RadialGradient")&&(t.start&&s.start&&(e.start=[t.start[0]+(s.start[0]-t.start[0])*o,t.start[1]+(s.start[1]-t.start[1])*o]),t.end&&s.end&&(e.end=[t.end[0]+(s.end[0]-t.end[0])*o,t.end[1]+(s.end[1]-t.end[1])*o]),t.center&&s.center&&(e.center=[t.center[0]+(s.center[0]-t.center[0])*o,t.center[1]+(s.center[1]-t.center[1])*o]),t.radius!==void 0&&s.radius!==void 0&&(e.radius=t.radius+(s.radius-t.radius)*o),e.stops=this.interpolateStops(t.stops,s.stops,o)),e}interpolateStroke(t,s,o){if(!t||!s)return o<.5?t:s;const e={...t};return e.width=(t.width??0)+((s.width??0)-(t.width??0))*o,e.opacity=(t.opacity??1)+((s.opacity??1)-(t.opacity??1))*o,t.fill&&s.fill?e.fill=this.interpolateFill(t.fill,s.fill,o):t.color&&s.color&&t.color.startsWith("#")&&s.color.startsWith("#")&&(e.color=this.interpolateColor(t.color,s.color,o)),e.trimStart=(t.trimStart??0)+((s.trimStart??0)-(t.trimStart??0))*o,e.trimEnd=(t.trimEnd??1)+((s.trimEnd??1)-(t.trimEnd??1))*o,e.trimOffset=(t.trimOffset??0)+((s.trimOffset??0)-(t.trimOffset??0))*o,e.dashOffset=(t.dashOffset??0)+((s.dashOffset??0)-(t.dashOffset??0))*o,e}render(t,s,o){var h;this.debug_objectsTotal=((h=this.artboard)==null?void 0:h.objects.length)||0,this.debug_objectsRendered=0;const e=performance.now();if(this.canvasWidth=s,this.canvasHeight=o,!this.artboard)return;t.clearRect(0,0,s,o);const i=this.artboard.width,n=this.artboard.height,a=this.calculateTransform(s,o,i,n,this.layout.fit,this.layout.alignment);if(t.save(),t.translate(Math.round(a.tx),Math.round(a.ty)),t.scale(a.scaleX,a.scaleY),t.translate(i/2,n/2),this.rootTransform=t.getTransform(),this.artboard.backgroundVisible!==!1&&(t.fillStyle=this.artboard.backgroundColor||"#000000",t.fillRect(-i/2,-n/2,i,n)),this.artboard.backgroundImage){const c=this.artboard.backgroundImage;let g=this.imageCache.get(c);if(g||(g=new Image,g.src=c,this.imageCache.set(c,g)),g.complete&&g.naturalWidth>0){t.save(),t.globalAlpha=this.normalizeOpacity(this.artboard.backgroundOpacity??100);const f=g.naturalWidth/g.naturalHeight,d=i/n;let u,m,y,v;d>f?(u=i,m=i/f):(m=n,u=n*f),y=-u/2,v=-m/2,t.drawImage(g,y,v,u,m),t.restore()}}t.beginPath(),t.rect(-i/2,-n/2,i,n),t.clip();const r=new Map;this.artboard.objects.forEach(c=>r.set(c.id,c)),this.artboard.objects.filter(c=>!c.parentId).map((c,g)=>{const f=this.objectStates.get(c.id),d=(f==null?void 0:f.zIndex)??g;return{obj:c,zIndex:d}}).sort((c,g)=>c.zIndex-g.zIndex).forEach(({obj:c})=>{this.renderObject(t,c,r)}),this._emitterPools.forEach((c,g)=>{if(!(c.length===0||!r.get(g)))for(const d of c)t.save(),t.globalAlpha=d.opacity,t.fillStyle=d.color,t.beginPath(),t.arc(d.x,d.y,Math.max(1,d.size*d.opacity),0,Math.PI*2),t.fill(),t.restore()}),this.lastRenderTime=performance.now()-e,this.debugMode&&this.frameCount%60===0&&console.log(`[Engine Debug] Rendered ${this.debug_objectsRendered}/${this.debug_objectsTotal} objects in ${this.lastRenderTime.toFixed(2)}ms`),t.restore()}isObjectInView(t,s,o,e,i,n=0){const a=t.getTransform(),r=s*a.a+o*a.c+a.e,l=s*a.b+o*a.d+a.f,h=Math.sqrt(a.a*a.a+a.b*a.b),c=Math.sqrt(a.c*a.c+a.d*a.d),g=(e/2+n)*h,f=(i/2+n)*c;return r+g>=0&&r-g<=this.canvasWidth&&l+f>=0&&l-f<=this.canvasHeight}calculateTransform(t,s,o,e,i,n){let a=1,r=1,l=1;const h=o/e,c=t/s;switch(i){case"Contain":c>h?l=s/e:l=t/o,a=r=l;break;case"Cover":c>h?l=t/o:l=s/e,a=r=l;break;case"Fill":a=t/o,r=s/e;break;case"FitWidth":l=t/o,a=r=l;break;case"FitHeight":l=s/e,a=r=l;break;case"None":a=r=1;break;case"ScaleDown":l=Math.min(t/o,s/e),l>1&&(l=1),a=r=l;break;default:a=r=1;break}const g=o*a,f=e*r;let d=0,u=0;return n.includes("Left")?d=0:n.includes("Right")?d=t-g:d=(t-g)/2,n.includes("Top")?u=0:n.includes("Bottom")?u=s-f:u=(s-f)/2,{scaleX:a,scaleY:r,tx:d,ty:u}}mapFontWeight(t){const s=t.toLowerCase();return s==="thin"||s==="100"?"100":s==="extralight"||s==="200"?"200":s==="light"||s==="300"?"300":s==="regular"||s==="normal"||s==="400"?"400":s==="medium"||s==="500"?"500":s==="semibold"||s==="600"?"600":s==="bold"||s==="700"?"700":s==="extrabold"||s==="800"?"800":s==="black"||s==="900"?"900":t}drawTextDecoration(t,s,o,e,i,n){t.beginPath();const a=Math.max(1,n/14);let r=e;s==="underline"?r=e+n*.12:s==="line-through"&&(r=e-n*.3),t.lineWidth=a,t.strokeStyle=t.fillStyle,t.moveTo(o-i/2,r),t.lineTo(o+i/2,r),t.stroke()}renderObject(t,s,o){var u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x;const e=this.objectStates.get(s.id);if(!e){console.warn("No state for object:",s.id);return}this.frameCount%60,t.roundRect||(t.roundRect=(L,$,A,V,H)=>(this.drawRoundRect(t,L,$,A,V,H),t));const i=e.geometry?this.deepMerge(s.geometry,e.geometry):s.geometry,n=e.style?this.deepMerge(s.style,e.style):s.style;let a=(i==null?void 0:i.width)||((u=s.geometry)==null?void 0:u.width)||s.width||0,r=(i==null?void 0:i.height)||((m=s.geometry)==null?void 0:m.height)||s.height||0;if((a===0||r===0)&&(i!=null&&i.points)&&Array.isArray(i.points)&&i.points.length>0){let L=1/0,$=-1/0,A=1/0,V=-1/0;i.points.forEach(H=>{L=Math.min(L,H.x),$=Math.max($,H.x),A=Math.min(A,H.y),V=Math.max(V,H.y)}),a===0&&(a=$-L),r===0&&(r=V-A)}const l=L=>{if(L)return L.corner_radius??L.cornerRadius},h=l(e)??l(n)??l(i)??l(s.style)??l(s.geometry)??0,c={...i,width:a,height:r};if(delete c.cornerRadius,c.corner_radius=h,e.visible===!1)return;const g=s.repeaterConfig,f=g&&g.isEnabled&&g.count>1,d=f?g.count:1;for(let L=0;L<d;L++){let $=e.x,A=e.y,V=e.rotation,H=e.scale_x??1,et=e.scale_y??1;if(f&&L>0){if(g.type==="Linear"){const J=g.offsetX||0,ft=g.offsetY||0,U=g.rotation||0,G=g.scale!==void 0?g.scale:1;$+=L*J,A+=L*ft,V+=L*U,H*=Math.pow(G,L),et*=Math.pow(G,L)}else if(g.type==="Grid"){const J=g.cols||Math.ceil(Math.sqrt(g.count)),ft=g.gapX||0,U=g.gapY||0,G=Math.floor(L/J),K=L%J,Z=a+ft,Ot=r+U;$+=K*Z,A+=G*Ot}else if(g.type==="Radial"){const J=g.radius||100,ft=g.startAngle||0,G=(g.endAngle||360)-ft,K=g.count>1?G/(G===360?g.count:g.count-1):0,Z=ft+L*K,Ot=Z*Math.PI/180;$=e.x+J*Math.cos(Ot),A=e.y+J*Math.sin(Ot),V+=Z}}const P=s.type==="Group"||s.type==="Frame"||s.type==="Component",F=a>0&&r>0;if(!P&&F){const J=(((y=n.shadow)==null?void 0:y.isEnabled)!==!1?(((v=n.shadow)==null?void 0:v.blur)||0)+10:0)+(((b=n.blur)==null?void 0:b.isEnabled)!==!1&&((C=n.blur)==null?void 0:C.radius)||0)+20;if(!this.isObjectInView(t,$,A,a,r,J))continue}this.debug_objectsRendered++,t.save();const q=[],Q=n.blur||((S=s.style)==null?void 0:S.blur);Q&&Q.amount>0&&q.push(`blur(${Q.amount}px)`);const it=n.effect||((I=s.style)==null?void 0:I.effect),dt=(it==null?void 0:it.isEnabled)===!0,St=it==null?void 0:it.type,ht=(it==null?void 0:it.radius)??10;dt&&St==="LayerBlur"&&q.push(`blur(${ht}px)`);const mt=((w=i==null?void 0:i.type)==null?void 0:w.toLowerCase().includes("image"))||((k=s.type)==null?void 0:k.toLowerCase().includes("image")),rt=n.adjustments&&Object.keys(n.adjustments).length>0?n.adjustments:null,Rt=i!=null&&i.adjustments&&Object.keys(i.adjustments).length>0?i.adjustments:null,Yt=mt?Rt||rt:rt||Rt,Pt=mt&&!Yt?{exposure:0,contrast:0,saturation:100,temperature:0,tint:0,highlights:0,shadows:0,blur:0,negative:0,hue:0}:Yt;if(e&&Pt&&(e.geometry=e.geometry||{},e.geometry.adjustments={...Pt}),Pt){const J=(Pt.exposure||0)/100,ft=Pt.contrast||0,U=1+(Pt.saturation||0)/100,G=(Pt.temperature||0)/200,K=(Pt.tint||0)/200,Z=(Pt.highlights||0)/500,Ot=(Pt.shadows||0)/500;let At="",kt="SourceGraphic";if(J!==0&&(At+=`
8
+ <feComponentTransfer in="${kt}" result="exposure">
9
+ <feFuncR type="linear" slope="1" intercept="${J}"/>
10
+ <feFuncG type="linear" slope="1" intercept="${J}"/>
11
+ <feFuncB type="linear" slope="1" intercept="${J}"/>
12
+ </feComponentTransfer>`,kt="exposure"),ft!==0){const bt=(ft+100)/100,O=.5*(1-bt);At+=`
13
+ <feComponentTransfer in="${kt}" result="contrast">
14
+ <feFuncR type="linear" slope="${bt}" intercept="${O}"/>
15
+ <feFuncG type="linear" slope="${bt}" intercept="${O}"/>
16
+ <feFuncB type="linear" slope="${bt}" intercept="${O}"/>
17
+ </feComponentTransfer>`,kt="contrast"}if(U!==1&&(At+=`<feColorMatrix in="${kt}" type="saturate" values="${U}" result="saturate"/>`,kt="saturate"),Pt.hue&&(At+=`<feColorMatrix in="${kt}" type="hueRotate" values="${Pt.hue}" result="hue"/>`,kt="hue"),Pt.negative){const bt=1-Pt.negative/50;At+=`
18
+ <feColorMatrix in="${kt}" type="matrix" result="invert"
19
+ values="${bt} 0 0 0 ${1-bt}
20
+ 0 ${bt} 0 0 ${1-bt}
21
+ 0 0 ${bt} 0 ${1-bt}
22
+ 0 0 0 1 0"/>`,kt="invert"}if(G!==0||K!==0||Z!==0||Ot!==0){const bt=1+Z+Ot,O=bt*(1+G-K/2),ct=bt*(1+K),Dt=bt*(1-G-K/2),xt=Pt.shadows*.1/255,ie=[O,0,0,0,xt,0,ct,0,0,xt,0,0,Dt,0,xt,0,0,0,1,0].join(" ");At+=`<feColorMatrix in="${kt}" type="matrix" values="${ie}" result="advanced"/>`,kt="advanced"}if(Pt.blur&&(At+=`<feGaussianBlur in="${kt}" stdDeviation="${Pt.blur}" result="blur"/>`,kt="blur"),At){const bt=`<svg xmlns="http://www.w3.org/2000/svg"><filter id="f" color-interpolation-filters="sRGB">${At}</filter></svg>`,O=btoa(bt);q.push(`url('data:image/svg+xml;base64,${O}#f')`)}}q.length>0?t.filter=q.join(" "):t.filter="none",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high";const zt=t.globalAlpha,Xt=this.normalizeOpacity(e.opacity!==void 0?e.opacity:100);t.globalAlpha=zt*Xt;const B=e.compositeOperation||e.blendMode;if(B&&B!=="Normal"){const J=B.toLowerCase();["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","copy","xor","multiply","screen"].includes(J)&&(t.globalCompositeOperation=J)}const lt=t,Vt=e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[]);let Mt=!1;const Tt=Vt.filter(J=>J.isVisible!==!1&&o.has(J.maskId));if(Tt.length>0){const J=Tt[0],ft=o.get(J.maskId),U=this.objectStates.get(ft.id);U&&U.visible!==!1&&(Mt=!0,(!this.maskBuffer||this.maskBuffer.width!==this.canvasWidth||this.maskBuffer.height!==this.canvasHeight)&&(this.maskBuffer=document.createElement("canvas"),this.maskBuffer.width=this.canvasWidth,this.maskBuffer.height=this.canvasHeight,this.maskCtx=this.maskBuffer.getContext("2d",{willReadFrequently:!0}),this.maskCtx&&(this.maskCtx.imageSmoothingEnabled=!0,this.maskCtx.imageSmoothingQuality="high")),this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,this.maskBuffer.width,this.maskBuffer.height),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),s.parentId&&this.applyAbsoluteTransform(this.maskCtx,s.parentId,o),this.maskCtx.save(),this.maskCtx.globalAlpha=1,t=this.maskCtx,t.filter=lt.filter)}t.translate(Math.round($),Math.round(A)),t.rotate(V*Math.PI/180);const Nt=e.skew_x||0,Jt=e.skew_y||0;(Nt!==0||Jt!==0)&&t.transform(1,Math.tan(Jt*Math.PI/180),Math.tan(Nt*Math.PI/180),1,0,0);const Kt=e.rotate_x||0,Qt=e.rotate_y||0,te=(e.flip_x===!0?-1:1)*Math.cos(Qt*Math.PI/180),ce=(e.flip_y===!0?-1:1)*Math.cos(Kt*Math.PI/180);t.scale(H*te,et*ce),n.shadow&&n.shadow.isEnabled!==!0&&((n.shadow.blur||0)>0||Math.abs(n.shadow.offsetX||0)>0||Math.abs(n.shadow.offsetY||0)>0)&&(n.shadow.isEnabled=!0);const se=n.shadow;if(se&&se.isEnabled!==!1){let J=se.color||"#000000";(T=(E=this.artboard)==null?void 0:E.tokens)!=null&&T.colors&&this.artboard.tokens.colors[J]&&(J=this.artboard.tokens.colors[J]);const ft=this.normalizeOpacity(se.opacity??100),U=se.spread||0,K=(se.blur||0)+U*1.5;let Z=J;if(J.startsWith("#")){const kt=J.replace("#",""),Ut=parseInt(kt.substring(0,2),16),bt=parseInt(kt.substring(2,4),16),O=parseInt(kt.substring(4,6),16);Z=`rgba(${Ut}, ${bt}, ${O}, ${ft})`}else if(J.startsWith("rgba")){const kt=J.match(/[\d.]+/g);if(kt&&kt.length>=4){const Ut=kt[0],bt=kt[1],O=kt[2],ct=kt[3];Z=`rgba(${Ut}, ${bt}, ${O}, ${parseFloat(ct)*ft})`}}const Ot=t.getTransform(),At=Math.sqrt(Ot.a*Ot.a+Ot.b*Ot.b)||1;t.shadowColor=Z,t.shadowBlur=K*At,t.shadowOffsetX=(se.offsetX||0)*At,t.shadowOffsetY=(se.offsetY||0)*At}const ne=s.liquidFill||((W=s.style)==null?void 0:W.liquidFill);if(ne&&ne.enabled){t.save();const J=ne.fillLevel??.5;t.beginPath();const ft=r/2-r*J;t.rect(-a/2,ft,a,r*J),t.clip(),t.fillStyle=ne.color||"#3b82f6",t.globalAlpha=t.globalAlpha*(ne.opacity??1)}if((i==null?void 0:i.type)==="Text")this._renderText(t,s,c,n,e,a,r);else if((i==null?void 0:i.type)==="Image"){const J=i.originalSrc||i.src;if(J){let ft=this.imageCache.get(J);ft||(ft=new Image,ft.onload=()=>{console.log(`[ExodeUI] Image loaded successfully, size: ${ft.naturalWidth}x${ft.naturalHeight}`)},ft.onerror=K=>{console.error("[ExodeUI] Image load failed:",K,`Src preview: ${J.substring(0,100)}...`)},ft.src=J,this.imageCache.set(J,ft));const U=n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1,G=(((M=n.stroke)==null?void 0:M.alignment)||"center").toLowerCase();if(U&&(G==="outside"||G==="center")&&this.applyStrokeAlignment(t,n,c,a,r,h),n.fill&&n.fill.type!=="None"){t.save();const K=t.globalAlpha,Z=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=Z||n.fill.color||"transparent",t.globalAlpha=K*this.normalizeOpacity(n.fill.opacity??100),h!==0?(this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.fill()):t.fillRect(-a/2,-r/2,a,r),t.globalAlpha=K,t.restore()}ft.complete&&ft.naturalWidth>0?(h!==0?(t.save(),this.drawRoundRect(t,-a/2,-r/2,a,r,h),t.clip(),t.drawImage(ft,-a/2,-r/2,a,r),t.restore()):t.drawImage(ft,-a/2,-r/2,a,r),U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,h)):U&&G==="inside"&&this.applyStrokeAlignment(t,n,c,a,r,h)}}else if(i.type==="SVG"){const J=i.svgContent;if(J){const ft=n.palette||[],U=n.fill,G=n.stroke,K=U?this.normalizeOpacity(U.opacity??100):1,Z=(U==null?void 0:U.type)==="Solid"&&(!G||G.isEnabled===!1||G.type==="Solid"&&G.color===U.color),Ot=U&&U.type!=="None"?Z?"monochrome":U.type==="Solid"?(U.color||"")+"|opacity:"+K:JSON.stringify(U.stops||[])+"|opacity:"+K:"",At=G&&G.isEnabled!==!1&&(G.width||0)>0?Z?["monochrome",G.width||0,G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):[G.width||0,G.fill?G.fill.type==="Solid"?G.fill.color||"":JSON.stringify(G.fill.stops||[]):G.color||"",G.opacity??1,G.lineCap||"",G.lineJoin||"",(G.dashArray||[]).join(","),G.trimStart??0,G.trimEnd??1,G.trimOffset??0,G.dashOffset??0].join("|"):"nostroke",kt=[s.id,ft.join("_"),Ot,At,e.opacity??100,e.visible!==!1?"v":"h"].join("_");let Ut=this.imageCache.get(kt);if(!Ut){Ut=new Image,Ut.crossOrigin="anonymous";let O=J;O.match(/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i)||(O=O.replace(/<svg([^>]*)>/i,(ot,It)=>`<svg xmlns="http://www.w3.org/2000/svg"${It}>`));let ct=i.width||a||100,Dt=i.height||r||100;const xt=O.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(xt&&(ct=parseFloat(xt[1]),Dt=parseFloat(xt[2])),O=O.replace(/<svg([^>]*)>/i,(ot,It)=>{let vt=It.replace(/\b(?:width|height)=["'][^"']*["']/gi," ");return vt.match(/\bviewBox=/i)||(vt+=` viewBox="0 0 ${ct} ${Dt}"`),vt.match(/\bpreserveAspectRatio=/i)||(vt+=' preserveAspectRatio="none"'),vt+=' width="100%" height="100%"',`<svg${vt}>`}),i.colors&&i.colors.length>0&&ft.length>0&&i.colors.forEach((ot,It)=>{if(ft[It]){const vt=ot.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),Ct=new RegExp(vt,"gi");O=O.replace(Ct,ft[It])}}),U&&U.type&&U.type!=="None"){if(U.type==="Solid"&&U.color){const ot=Z?"#FFFFFF":U.color,It=Z?1:this.normalizeOpacity(U.opacity??100);O=O.replace(/\bfill\s*=\s*["'][^"']*["']/gi,vt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(vt)?vt:`fill="${ot}"`),O=O.replace(/fill\s*:\s*[^;"')]+/gi,vt=>/fill\s*:\s*(none|transparent)/i.test(vt)?vt:`fill:${ot}`),It<1&&(O=O.replace(/\bfill-opacity\s*=\s*["'][^"']*["']/gi,`fill-opacity="${It}"`),O=O.replace(/fill-opacity\s*:\s*[^;"')]+/gi,`fill-opacity:${It}`),O.match(/\bfill-opacity\s*=/i)||(O=O.replace(/(<svg[^>]*>)/i,`$1<g fill-opacity="${It}">`),O=O.replace(/<\/svg>/i,"</g></svg>")))}else if(U.type==="LinearGradient"||U.type==="RadialGradient"||U.type==="Linear"||U.type==="Radial"){const ot="exode-fill",It=this.normalizeOpacity(U.opacity??100),vt=(U.stops||[]).map(gt=>{const Lt=gt.offset!==void 0?gt.offset:gt.pos??0,at=this.normalizeOpacity(gt.opacity??100)*It;return`<stop offset="${Lt*100}%" stop-color="${gt.color||"#000"}" stop-opacity="${at}"/>`}).join("");let Ct="";if(U.type==="LinearGradient"||U.type==="Linear"){const gt=(wt,z)=>Array.isArray(wt)?wt[z]??(z===0?0:1):wt&&typeof wt=="object"?wt[z===0?"x":"y"]??(z===0?0:1):z===0?0:1,Lt=gt(U.start,0)*100,at=gt(U.start,1)*100,st=gt(U.end,0)*100,nt=gt(U.end,1)*100;Ct=`<linearGradient id="${ot}" x1="${Lt}%" y1="${at}%" x2="${st}%" y2="${nt}%" gradientUnits="objectBoundingBox">${vt}</linearGradient>`}else{const gt=(nt,wt)=>Array.isArray(nt)?nt[wt]??.5:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??.5:.5,Lt=gt(U.center,0)*100,at=gt(U.center,1)*100,st=(U.radius??.5)*100;Ct=`<radialGradient id="${ot}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${vt}</radialGradient>`}/<defs>/i.test(O)?O=O.replace(/<defs>/i,`<defs>${Ct}`):O=O.replace(/<svg([^>]*)>/i,`<svg$1><defs>${Ct}</defs>`),O=O.replace(/\bfill\s*=\s*["'][^"']*["']/gi,gt=>/fill\s*=\s*["']\s*(none|transparent)\s*["']/i.test(gt)?gt:`fill="url(#${ot})"`),O=O.replace(/fill\s*:\s*[^;"')]+/gi,gt=>/fill\s*:\s*(none|transparent)/i.test(gt)?gt:`fill:url(#${ot})`)}}const ie=(ot,It,vt=1)=>{const Ct=(ot.stops||[]).map(nt=>{const wt=nt.offset!==void 0?nt.offset:nt.pos??0,z=this.normalizeOpacity(nt.opacity??100)*vt;return`<stop offset="${wt*100}%" stop-color="${nt.color||"#000"}" stop-opacity="${z}"/>`}).join(""),gt=(nt,wt,z=.5)=>Array.isArray(nt)?nt[wt]??z:nt&&typeof nt=="object"?nt[wt===0?"x":"y"]??z:z;if(ot.type==="LinearGradient"||ot.type==="Linear"){const nt=gt(ot.start,0,0)*100,wt=gt(ot.start,1,0)*100,z=gt(ot.end,0,1)*100,pt=gt(ot.end,1,1)*100;return`<linearGradient id="${It}" x1="${nt}%" y1="${wt}%" x2="${z}%" y2="${pt}%" gradientUnits="objectBoundingBox">${Ct}</linearGradient>`}const Lt=gt(ot.center,0,.5)*100,at=gt(ot.center,1,.5)*100,st=(ot.radius??.5)*100;return`<radialGradient id="${It}" cx="${Lt}%" cy="${at}%" r="${st}%" gradientUnits="objectBoundingBox">${Ct}</radialGradient>`},Wt=(ot,It)=>/<defs>/i.test(ot)?ot.replace(/<defs>/i,`<defs>${It}`):ot.replace(/(<svg[^>]*>)/i,`$1<defs>${It}</defs>`);if(G&&G.isEnabled!==!1&&(G.width||0)>0){const ot=Z?1:this.normalizeOpacity(G.opacity??100),It=Z?"#FFFFFF":G.color||(U==null?void 0:U.color)||"#000000";let vt="";const Ct=G.fill;if(Ct&&Ct.type){if(Ct.type==="Solid")vt=Ct.color||G.color||"#000000";else if(Ct.type==="LinearGradient"||Ct.type==="RadialGradient"||Ct.type==="Linear"||Ct.type==="Radial"){const qt="exode-stroke";O=Wt(O,ie(Ct,qt,ot)),vt=`url(#${qt})`}}vt||(vt=It),O.match(/\bstroke\s*=\s*["']/i)?O=O.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,qt=>/stroke\s*=\s*["']\s*(none|transparent)\s*["']/i.test(qt)?qt:`stroke="${vt}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke="${vt}"`),O=O.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),`stroke:${vt}`);let gt=i.width||a||100,Lt=i.height||r||100;const at=J.match(/viewBox=["']\s*0\s+0\s+([\d.]+)\s+([\d.]+)\s*["']/i);if(at){const qt=parseFloat(at[1]),oe=parseFloat(at[2]);!isNaN(qt)&&!isNaN(oe)&&(gt=qt,Lt=oe)}const st=Math.max(.001,a/gt),nt=Math.max(.001,r/Lt),wt=(st+nt)/2,z=(G.width||1)/wt;O.match(/\bstroke-width\s*=\s*["']/i)?O=O.replace(/\bstroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${z}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-width="${z}"`),O=O.replace(/stroke-width\s*:\s*[^;"')]+/gi,`stroke-width:${z}`),O.match(/\bstroke-opacity\s*=\s*["']/i)?O=O.replace(/\bstroke-opacity\s*=\s*["'][^"']*["']/gi,`stroke-opacity="${ot}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-opacity="${ot}"`),O=O.replace(/stroke-opacity\s*:\s*[^;"')]+/gi,`stroke-opacity:${ot}`);const pt=G.lineCap||"round";O.match(/\bstroke-linecap\s*=\s*["']/i)?O=O.replace(/\bstroke-linecap\s*=\s*["'][^"']*["']/gi,`stroke-linecap="${pt}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linecap="${pt}"`),O=O.replace(/stroke-linecap\s*:\s*[^;"')]+/gi,`stroke-linecap:${pt}`);const ut=G.lineJoin||"round";O.match(/\bstroke-linejoin\s*=\s*["']/i)?O=O.replace(/\bstroke-linejoin\s*=\s*["'][^"']*["']/gi,`stroke-linejoin="${ut}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-linejoin="${ut}"`),O=O.replace(/stroke-linejoin\s*:\s*[^;"')]+/gi,`stroke-linejoin:${ut}`);const de=G.trimStart??0,be=G.trimEnd??1,Se=G.trimOffset??0,Ie=G.dashOffset??0,_e=de!==0||be!==1||Se!==0||Ie!==0;if(_e){const qt=Math.max(0,Math.min(1,de)),oe=Math.max(0,Math.min(1,be));this.frameCount%600===0&&this.debugLog(`SVG Trim - Object: ${s.name||s.id}, Start: ${qt}, End: ${oe}`);const ye=(gt+Lt)*2,we=(Se%1+1)%1,Me=(Ie%1+1)%1;let pe="",fe=0;if(qt>=oe)pe=`0 ${ye}`,fe=0;else{const he=ye*(oe-qt),ve=ye-he;fe=-(ye*(qt+we+Me)),pe=`${he} ${ve}`}O.match(/\bstroke-dasharray\s*=/i)?O=O.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${pe}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dasharray="${pe}"`),O=O.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${pe}`),O.match(/\bstroke-dashoffset\s*=/i)?O=O.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${fe}"`):O=O.replace(/<(path|circle|rect|ellipse|polygon|polyline)/gi,`<$1 stroke-dashoffset="${fe}"`),O=O.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${fe}`)}else if(G.dashArray&&G.dashArray.length>0){const qt=G.dashArray.join(" ");O=O.replace(/\bstroke-dasharray\s*=\s*["'][^"']*["']/gi,`stroke-dasharray="${qt}"`),O=O.replace(/stroke-dasharray\s*:\s*[^;"')]+/gi,`stroke-dasharray:${qt}`),G.dashOffset&&(O=O.replace(/\bstroke-dashoffset\s*=\s*["'][^"']*["']/gi,`stroke-dashoffset="${G.dashOffset}"`),O=O.replace(/stroke-dashoffset\s*:\s*[^;"')]+/gi,`stroke-dashoffset:${G.dashOffset}`))}if(!/\bstroke\s*=\s*["']/i.test(J)&&!new RegExp("(?<![a-z-])stroke\\s*:","i").test(J)){let qt="",oe="";if(_e){const pe=i.width||a||100,fe=i.height||r||100,he=(pe+fe)*2,ve=Math.max(0,Math.min(1,de)),Pe=Math.max(0,Math.min(1,be)),Fe=(Se%1+1)%1,$e=(Ie%1+1)%1;if(ve>=Pe)qt=` stroke-dasharray="0 ${he}"`,oe=' stroke-dashoffset="0"';else{const Ee=he*(Pe-ve),We=he-Ee,Be=-(he*(ve+Fe+$e));qt=` stroke-dasharray="${Ee} ${We}"`,oe=` stroke-dashoffset="${Be}"`}}else(_=G.dashArray)!=null&&_.length&&(qt=` stroke-dasharray="${G.dashArray.join(" ")}"`,G.dashOffset&&(oe=` stroke-dashoffset="${G.dashOffset}"`));const ye=` stroke-linecap="${G.lineCap||"round"}"`,we=` stroke-linejoin="${G.lineJoin||"round"}"`,Me=`stroke="${vt}" stroke-width="${z}" stroke-opacity="${ot}"${ye}${we}${qt}${oe}`;O=O.replace(/(<svg[^>]*>)(\s*(?:<defs>[\s\S]*?<\/defs>)?)/i,(pe,fe,he)=>`${fe}${he}<g ${Me}>`),O=O.replace(/<\/svg>/i,"</g></svg>")}}else G&&G.isEnabled===!1&&(O=O.replace(/\bstroke\s*=\s*["'][^"']*["']/gi,'stroke="none"'),O=O.replace(new RegExp(`(?<![a-z-])stroke\\s*:\\s*(?!none|transparent)[^;"')]+`,"gi"),"stroke:none"));const Bt=new Blob([O],{type:"image/svg+xml"}),Ft=URL.createObjectURL(Bt);Ut.onload=()=>{if(URL.revokeObjectURL(Ft),this.frameCount%900===0){const ot=this.imageCache.get(kt);ot&&this.debugLog(`SVG Payload Ready: ${s.name||s.id} (${ot.naturalWidth}x${ot.naturalHeight})`)}},Ut.onerror=()=>{URL.revokeObjectURL(Ft),this.debugLog(`SVG Error: Failed to load payload for ${s.name||s.id}`)},Ut.src=Ft,this.imageCache.set(kt,Ut)}let bt=null;if(Ut.complete&&Ut.naturalWidth>0?(bt=Ut,this.lastValidSvgImgMap.set(s.id,Ut)):bt=this.lastValidSvgImgMap.get(s.id)||null,bt&&bt.complete&&bt.naturalWidth>0){const O=Math.max(1,a),ct=Math.max(1,r);if(Z&&(U==null?void 0:U.type)==="Solid"){this.maskBuffer||(this.maskBuffer=document.createElement("canvas"),this.maskCtx=this.maskBuffer.getContext("2d")),this.maskBuffer.width=O,this.maskBuffer.height=ct,this.maskCtx.setTransform(1,0,0,1,0,0),this.maskCtx.globalCompositeOperation="source-over",this.maskCtx.globalAlpha=1,this.maskCtx.filter="none",this.maskCtx.clearRect(0,0,O,ct),this.maskCtx.drawImage(bt,0,0,O,ct),this.maskCtx.globalCompositeOperation="source-in";const Dt=U.color||"#000000",xt=this.normalizeOpacity(U.opacity??100);this.maskCtx.fillStyle=Dt,this.maskCtx.globalAlpha=xt,this.maskCtx.fillRect(0,0,O,ct),t.drawImage(this.maskBuffer,-O/2,-ct/2,O,ct)}else h!==0?(t.save(),this.drawRoundRect(t,-O/2,-ct/2,O,ct,h),t.clip(),t.drawImage(bt,-O/2,-ct/2,O,ct),t.restore()):t.drawImage(bt,-O/2,-ct/2,O,ct)}}}else if(c.type==="LineGraph")this.renderLineGraph(t,c,a,r);else if(s.type==="Shape"){if(this.applyPath(t,c,a,r,h),t.save(),n.blur&&n.blur.amount>0&&(t.filter=`blur(${n.blur.amount}px)`),n.fill){const J=t.globalAlpha;if(((R=n.fill)==null?void 0:R.type)==="Image"&&(n.fill.originalSrc||n.fill.src)){const ft=n.fill.originalSrc||n.fill.src;let U=this.imageCache.get(ft);U||(U=new Image,U.src=ft,this.imageCache.set(ft,U)),U.complete&&U.naturalWidth>0&&(t.save(),this.applyPath(t,c,a,r,h),t.clip(),this.renderFittedImage(t,U,-a/2,-r/2,a,r,n.fill.fillMode),t.restore())}else{const ft=this.createCanvasFill(t,n.fill,a,r);t.fillStyle=ft||(typeof n.fill=="string"?n.fill:n.fill.color||"transparent"),t.globalAlpha=J*this.normalizeOpacity(n.fill.opacity??100),this.applyPath(t,c,a,r,h),t.fill()}t.globalAlpha=J}t.restore(),n.stroke&&n.stroke.width>0&&this.applyStrokeAlignment(t,n,c,a,r,h)}else if(s.type==="Frame"||s.type==="Group"&&!s.isStructuralGroup){const J=e.width??i.width??s.width??a,ft=e.height??i.height??s.height??r,U=h;if(t.save(),t.beginPath(),this.drawRoundRect(t,-J/2,-ft/2,J,ft,U),n.fill&&n.fill.type!=="None"){const G=t.globalAlpha,K=this.createCanvasFill(t,n.fill,J,ft);t.fillStyle=K||n.fill.color||"transparent",t.globalAlpha=G*this.normalizeOpacity(n.fill.opacity??100),t.fill(),t.globalAlpha=G}if(t.restore(),n.stroke&&n.stroke.width>0&&n.stroke.isEnabled!==!1){const G={type:"Rectangle"};this.applyStrokeAlignment(t,n,G,J,ft,U)}}else s.type==="Group"&&s.isStructuralGroup||(s.type==="Component"&&s.variant==="inputbox"?this.renderInputBox(t,s):s.type==="Component"&&s.variant==="button"?this.renderButton(t,s):s.type==="Component"&&s.variant==="toggle_button"?this.renderToggleButton(t,s):s.type==="Toggle"||s.type==="Component"&&s.variant==="toggle"?this.renderToggle(t,s):s.type==="Slider"||s.type==="Component"&&s.variant==="slider"?this.renderSlider(t,s):s.type==="Dropdown"||s.type==="Component"&&s.variant==="dropdown"?this.renderDropdown(t,s):s.type==="ListView"||s.type==="Component"&&s.variant==="listview"?this.renderListView(t,s):s.type==="Checkbox"||s.type==="Component"&&s.variant==="checkbox"?this.renderCheckbox(t,s):s.type==="RadioGroup"||s.type==="Component"&&s.variant==="radiogroup"?this.renderRadioGroup(t,s):s.type==="BarChart"||s.type==="Component"&&s.variant==="barchart"?this.renderBarChart(t,s):s.type==="PieChart"||s.type==="Component"&&s.variant==="piechart"?this.renderPieChart(t,s):this.frameCount%60===0&&console.warn("[Engine] Unhandled object type in renderObject:",s.type,"Geo:",(x=s.geometry)==null?void 0:x.type));if(this.applyArtEffectOverlay(t,s,c,a,r,h),dt&&St==="BackgroundBlur"&&this.applyBackgroundBlurGlass(t,c,a,r,h,it),ne&&ne.enabled&&t.restore(),s.children&&s.children.length>0){const ft=s.type==="Frame",U=s.clipsContent!==void 0?s.clipsContent:s.clipContent!==void 0?s.clipContent:ft;if(t.save(),U){t.beginPath();const K=e.width??(i==null?void 0:i.width)??s.width??0,Z=e.height??(i==null?void 0:i.height)??s.height??0,Ot=e.cornerRadius??(i==null?void 0:i.corner_radius)??s.cornerRadius??0;this.drawRoundRect(t,-K/2,-Z/2,K,Z,Ot),t.clip()}let G=0;for(s.children.forEach(K=>{const Z=o.get(K);if(!Z)return;const Ot=this.objectStates.get(K),At=(Ot==null?void 0:Ot.geometry)||Z.geometry;if(At&&At.isMask&&(Ot==null?void 0:Ot.visible)!==!1){const kt=At.width||0,Ut=At.height||0;this.applyObjectTransform(t,K);const bt=(Ot==null?void 0:Ot.corner_radius)??(At==null?void 0:At.corner_radius)??0;this.applyPath(t,At,kt,Ut,bt),t.clip(),G++}else this.renderObject(t,Z,o)});G>0;)t.restore(),G--;t.restore()}if(Mt){this.maskCtx.restore(),(e.masks||(s.maskedBy?[{maskId:s.maskedBy,inverted:s.maskInverted===!0,type:s.maskType||"alpha",opacity:s.maskOpacity!==void 0?s.maskOpacity/100:1,feather:s.maskFeather||0,isVisible:!0}]:[])).filter(G=>G.isVisible!==!1&&o.has(G.maskId)).forEach(G=>{var bt,O,ct,Dt,xt,ie;const K=o.get(G.maskId),Z=this.objectStates.get(K.id),Ot=G.feather||0,At=G.inverted===!0,kt=G.opacity!==void 0?typeof G.opacity=="number"?G.opacity:G.opacity/100:1;if((G.type||"alpha")==="luma"){(!this.lumaBuffer||this.lumaBuffer.width!==this.maskBuffer.width||this.lumaBuffer.height!==this.maskBuffer.height)&&(this.lumaBuffer=document.createElement("canvas"),this.lumaBuffer.width=this.maskBuffer.width,this.lumaBuffer.height=this.maskBuffer.height,this.lumaCtx=this.lumaBuffer.getContext("2d",{willReadFrequently:!0}),this.lumaCtx&&(this.lumaCtx.imageSmoothingEnabled=!0,this.lumaCtx.imageSmoothingQuality="high")),this.lumaCtx.setTransform(1,0,0,1,0,0),this.lumaCtx.globalCompositeOperation="source-over",this.lumaCtx.globalAlpha=1,this.lumaCtx.filter="none",this.lumaCtx.clearRect(0,0,this.lumaBuffer.width,this.lumaBuffer.height),this.lumaCtx.save(),this.rootTransform&&this.lumaCtx.setTransform(this.rootTransform),this.applyAbsoluteTransform(this.lumaCtx,K.id,o),Ot>0&&(this.lumaCtx.filter=`blur(${Ot}px)`),this.lumaCtx.globalAlpha=kt;const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((bt=K.geometry)==null?void 0:bt.type)==="Text"){const Ct=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,gt=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.lumaCtx,K,{...Ct,width:Wt,height:Bt,corner_radius:Ft},gt,Z,Wt,Bt,!0)}else if(((O=K.geometry)==null?void 0:O.type)==="Image"){const Ct=K.geometry.src;if(Ct){let gt=this.imageCache.get(Ct);gt||(gt=new Image,gt.src=Ct,this.imageCache.set(Ct,gt)),gt.complete&&gt.naturalWidth>0?this.lumaCtx.drawImage(gt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else if(((ct=K.geometry)==null?void 0:ct.type)==="SVG"){const Ct=K.geometry.svgContent;if(Ct){const gt=`__lumamask_${K.id}`;let Lt=this.imageCache.get(gt);if(!Lt){Lt=new Image;const at=new Blob([Ct],{type:"image/svg+xml"});Lt.src=URL.createObjectURL(at),Lt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(gt,Lt)}Lt.complete&&Lt.naturalWidth>0?this.lumaCtx.drawImage(Lt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill())}}else this.applyPath(this.lumaCtx,K.geometry,Wt,Bt,Ft),this.lumaCtx.fillStyle="#ffffff",this.lumaCtx.fill();this.lumaCtx.restore();const ot=this.maskCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight),It=this.lumaCtx.getImageData(0,0,this.canvasWidth,this.canvasHeight).data,vt=ot.data;for(let Ct=0;Ct<vt.length;Ct+=4){const gt=It[Ct],Lt=It[Ct+1],at=It[Ct+2];let st=(.299*gt+.587*Lt+.114*at)/255;At&&(st=1-st),vt[Ct+3]*=st}this.maskCtx.putImageData(ot,0,0)}else{this.maskCtx.save(),this.rootTransform&&this.maskCtx.setTransform(this.rootTransform),this.maskCtx.globalCompositeOperation=At?"destination-out":"destination-in",Ot>0&&(this.maskCtx.filter=`blur(${Ot}px)`),this.maskCtx.globalAlpha=kt,this.applyAbsoluteTransform(this.maskCtx,K.id,o);const Wt=(Z==null?void 0:Z.width)||K.geometry.width||0,Bt=(Z==null?void 0:Z.height)||K.geometry.height||0,Ft=(Z==null?void 0:Z.corner_radius)??K.corner_radius??0;if(((Dt=K.geometry)==null?void 0:Dt.type)==="Text"){const ot=Z!=null&&Z.geometry?this.deepMerge(K.geometry,Z.geometry):K.geometry,It=Z!=null&&Z.style?this.deepMerge(K.style,Z.style):K.style;this._renderText(this.maskCtx,K,{...ot,width:Wt,height:Bt,corner_radius:Ft},It,Z,Wt,Bt,!0)}else if(((xt=K.geometry)==null?void 0:xt.type)==="Image"){const ot=K.geometry.src;if(ot){let It=this.imageCache.get(ot);It||(It=new Image,It.src=ot,this.imageCache.set(ot,It)),It.complete&&It.naturalWidth>0?this.maskCtx.drawImage(It,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else if(((ie=K.geometry)==null?void 0:ie.type)==="SVG"){const ot=K.geometry.svgContent;if(ot){const It=`__alphamask_${K.id}`;let vt=this.imageCache.get(It);if(!vt){vt=new Image;const Ct=new Blob([ot],{type:"image/svg+xml"});vt.src=URL.createObjectURL(Ct),vt.onload=()=>{this.artboard&&this.reset()},this.imageCache.set(It,vt)}vt.complete&&vt.naturalWidth>0?this.maskCtx.drawImage(vt,-Wt/2,-Bt/2,Wt,Bt):(this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill())}}else this.applyPath(this.maskCtx,K.geometry,Wt,Bt,Ft),this.maskCtx.fillStyle="#ffffff",this.maskCtx.fill();this.maskCtx.restore()}}),lt.save(),lt.setTransform(1,0,0,1,0,0);const U=s.maskBlendMode||s.blendMode;U&&U!=="Normal"&&(lt.globalCompositeOperation=U.toLowerCase()),lt.drawImage(this.maskBuffer,0,0),lt.restore(),lt.restore()}else t.restore()}}_renderText(t,s,o,e,i,n,a,r=!1,l=!1){var St,ht,mt,rt,Rt,Yt,Pt,zt,Xt;let h=o.text||"";if(o.textInputId&&!r){const B=this.inputs.get(o.textInputId);B!==void 0&&(h=String(B),i.geometry&&i.geometry.type==="Text"&&(i.geometry.text=h))}if(o.svgPath){const B=o.svgPath;t.save();const lt=((St=e==null?void 0:e.fill)==null?void 0:St.color)||"#000000",Vt=((ht=e==null?void 0:e.fill)==null?void 0:ht.opacity)!==void 0?(mt=e==null?void 0:e.fill)==null?void 0:mt.opacity:1;t.fillStyle=lt,t.globalAlpha*=Vt;const Mt=new Path2D(B);t.fill(Mt),t.restore();return}let c=h||"";o.enableSegments===!0&&o.segments&&Array.isArray(o.segments)&&(c=o.segments.map(B=>B&&B.text?B.text:"").join(""));const g=o.textCase||"none";g==="uppercase"?c=c.toUpperCase():g==="lowercase"?c=c.toLowerCase():g==="capitalize"&&(c=c.replace(/\b\w/g,B=>B.toUpperCase()));let f=((rt=o.fontWeight)==null?void 0:rt.toString())||"400",d=o.fontStyle||"normal";f.toLowerCase().includes("italic")&&(d="italic",f=f.replace(/italic/gi,"").trim()||"400");const u=this.mapFontWeight(f),m=Math.max(1,o.fontSize||32);let y=o.fontFamily||"Inter";const v=["Bold","SemiBold","Medium","Regular","Light","Thin","ExtraBold","Black","Italic"];v.forEach(B=>{const lt=new RegExp(`[\\s-]${B}$`,"i");lt.test(y)&&(y=y.replace(lt,"").trim())});const S=`${o.smallCaps===!0?"small-caps ":""}${d} ${u} ${m}px "${y}", sans-serif`;t.font=S;const I=o.textVerticalAlign||"top";t.textBaseline="top";const w=o.textAlign||"left";t.textAlign=w;let k=0;if(typeof o.letterSpacing=="number")k=o.letterSpacing;else if(typeof o.letterSpacing=="object"&&o.letterSpacing.value!==void 0){const B=o.letterSpacing;k=B.unit==="PERCENT"?B.value/100*m:B.value}t.letterSpacing!==void 0&&(t.letterSpacing=`${k}px`);const E=o.kerning||"auto",T=o.kerningValue||0;E==="manual"&&T!==0&&(t.letterSpacing=`${k+T}px`);const W=o.paragraphSpacing||0;let M=o.lineHeight??1.2;typeof M=="string"&&(M=parseFloat(M)),M>5&&m>0&&(M=M/m);const _=(M||1.2)*m,R=o.isPointText===!0||!o.width||o.width<=0,x=((Rt=o.padding)==null?void 0:Rt.left)||((Yt=o.padding)==null?void 0:Yt.right)||0,L=R?1e5:o.width&&o.width>0?Math.ceil(o.width)-x*2:1e5;o.autoHeight;const $=De({text:c,fontFamily:y,fontSize:m,fontWeight:u,fontStyle:d,lineHeight:M,width:L,letterSpacing:k,paragraphSpacing:W,paragraphIndent:o.paragraphIndent||0,segments:o.segments,enableSegments:o.enableSegments,textCase:g,hyphenation:o.hyphenation,composer:o.composer,balanceRaggedLines:o.balanceRaggedLines}),A=$.lines||[],V=$.maxFontSize||m,H=this.fontLeadingFactors[y]??.5,et=(_-m)*H;let P=$.height,F=-P/2;a>0&&a>P&&(I==="top"?F=-a/2:I==="middle"||I==="center"?F=-P/2:I==="bottom"&&(F=a/2-P)),F+=et;let q=null,Q=0;if(o.pathId&&this.artboard){const B=this.artboard.objects.find(lt=>lt.id===o.pathId);if(B&&B.type==="Shape"&&((Pt=B.geometry)==null?void 0:Pt.type)==="Path"){const lt=this.objectStates.get(B.id),Vt=lt!=null&&lt.geometry?this.deepMerge(B.geometry,lt.geometry):B.geometry,Mt=(lt==null?void 0:lt.scale_x)!==void 0?(B.width||0)*lt.scale_x:B.width||0,Tt=(lt==null?void 0:lt.scale_y)!==void 0?(B.height||0)*lt.scale_y:B.height||0;q={geo:Vt,obj:B,w:Mt,h:Tt},Q=this.getPerimeter(Vt,Mt,Tt)}}const it=(B,lt)=>{var Mt,Tt;if(k===0&&(!o.enableSegments||!((Mt=o.segments)!=null&&Mt.length)))return t.measureText(B).width;let Vt=0;for(let Nt=0;Nt<B.length;Nt++){const Jt=lt+Nt;let Kt=0;if(o.enableSegments===!0&&((Tt=o.segments)==null?void 0:Tt.length)>0){let Qt=0,te=null;for(const ce of o.segments){if(Jt<Qt+(ce.text||"").length){te=ce;break}Qt+=(ce.text||"").length}if(te){t.save();let ce=te.fontFamily||o.fontFamily||"Inter";const se=this.mapFontWeight((te.fontWeight||o.fontWeight||"400").toString()),ne=te.fontStyle||d,J=te.fontSize||m;t.font=`${ne} ${se} ${J}px "${ce}", sans-serif`,Kt=t.measureText(B[Nt]).width,t.restore()}else Kt=t.measureText(B[Nt]).width}else Kt=t.measureText(B[Nt]).width;Vt+=Kt+k}return Vt-(B.length>0?k:0)},dt=(B,lt,Vt,Mt,Tt)=>{var se,ne;const Jt=(Tt===0||c[Tt-1]===`
23
+ `||c[Tt-1]==="\r")&&o.paragraphIndent?o.paragraphIndent:0,Kt=(!r||l)&&(s.behaviors||[]).some(J=>J.enabled&&(J.type.toString().includes("Text")||["Typewriter","Scramble","Wave","Bounce","GlitchText","Reveal3D","RevealSlide","RevealBlur"].includes(J.type))),Qt=!o.pathId&&!Kt&&(o.enableSegments!==!0||!o.segments||o.segments.length===0),te=o.baselineShift||0,ce=Vt+te;if(Qt)t.font=S,Mt?t.strokeText(B,lt+Jt,ce):t.fillText(B,lt+Jt,ce);else{const J=it(B,Tt);let ft=lt+Jt;w==="center"?ft-=J/2:w==="right"&&(ft-=J);const U=Tt+B.length>=c.length||c[Tt+B.length]===`
24
+ `||c[Tt+B.length]==="\r";let G=0,K=0;const Z=o.justifyMinWordSpacing,Ot=o.justifyMaxWordSpacing;if(w==="justify"&&!U&&J>0&&!o.pathId){const bt=R?J:L-x*2+0,O=Math.max(0,bt-J);for(let ct=0;ct<B.length;ct++)B[ct]===" "&&K++;if(K>0){const ct=t.measureText(" ").width;let Dt=Z||ct*.5,xt=Ot||ct*2.5;G=Math.max(0,Math.min(O/K,xt-Dt))}}let At=o.pathOffset||0;o.pathId&&Q>0&&q&&(w==="center"?At+=Q/2-J/2:w==="right"&&(At+=Q-J));let kt=ft;const Ut=r&&!l?[]:((se=s.behaviors)==null?void 0:se.filter(bt=>[Y.Typewriter,Y.Scramble,Y.Wave,Y.Bounce,Y.GlitchText,Y.TextTrail,Y.Reveal3D,Y.RevealSlide,Y.RevealBlur,Y.TextLiquid,Y.TextVortex,Y.TextExplosion,Y.TextRain,Y.TextGravity,Y.TextElastic,Y.TextMatrix,Y.TextNeon,Y.TextGlitch3D,Y.TextDissolve,Y.TextOrganic,Y.TextBreathe,Y.TextFloral,Y.TextSmoke,Y.TextVariable,Y.TextMagnet,Y.TextSpin,Y.TextZing,Y.TextPerspective,Y.TextMirror].includes(bt.type)&&bt.enabled))||[];for(let bt=0;bt<B.length;bt++){let O=B[bt];const ct=Tt+bt;let Dt=0,xt=0,ie=1,Wt=1,Bt=0,Ft=1,ot=O;Ut.forEach(at=>{const st=at.settings||{},nt=st.strength||1,wt=Date.now();if(at.type===Y.Typewriter)this.currentTime*(st.speed||1)-ct*(st.stagger||.05)<0&&(Ft=0);else if(at.type===Y.Scramble)Math.max(0,Math.min(1,this.currentTime/(st.duration||1.5))-ct*.02)<1&&Math.random()<.3&&(ot="$%#@!*&"[Math.floor(Math.random()*7)]);else if(at.type===Y.Wave)xt+=Math.sin(this.currentTime*5*(st.speed||1)+ct*(st.frequency||1))*(st.amplitude||20)*nt;else if(at.type===Y.Bounce){const z=Math.max(0,this.currentTime%2-ct*(st.stagger||.1));z<1&&(xt-=Math.abs(Math.sin(z*Math.PI))*(st.height||50)*nt)}else if(at.type===Y.TextTrail){const z=this.pointerHistory[Math.max(0,this.pointerHistory.length-1-ct*(st.delay||5))];z&&(Dt+=(z.x-(i.x+kt))*nt*.2,xt+=(z.y-(i.y+Vt+xt))*nt*.2)}else if(at.type===Y.Reveal3D){const z=Math.max(0,Math.min(1,this.currentTime*(st.speed||1)-ct*(st.stagger||.1)));ie*=z,Wt*=z,Ft=z}else if(at.type===Y.RevealSlide){const z=Math.max(0,Math.min(1,this.currentTime*1.5-ct*.05)),pt=(1-z)*(st.distance||40)*nt,ut=st.direction||"up";ut==="up"?xt-=pt:ut==="down"?xt+=pt:ut==="left"?Dt-=pt:ut==="right"&&(Dt+=pt),Ft=z}else if(at.type===Y.RevealBlur){const z=Math.max(0,Math.min(1,this.currentTime*1.2-ct*.1));Ft=z,Dt+=(1-z)*5}else if(at.type===Y.TextLiquid){const z=Math.max(0,Math.sin(wt*.001*(st.speed||1)+ct*.5));xt+=z*(st.amplitude||10)*nt,Wt*=1+z*.2}else if(at.type===Y.TextVortex){const z=wt*.002*(st.speed||1)+ct*.2,pt=(1-(Math.sin(wt*.001)*.5+.5))*(st.radius||50);Dt+=Math.cos(z)*pt*nt,xt+=Math.sin(z)*pt*nt}else if(at.type===Y.TextExplosion){const z=st.force||1,pt=this.currentTime%2;if(pt<1){const ut=(ct/B.length-.5)*Math.PI*2,de=pt*100*z;Dt+=Math.cos(ut)*de*nt,xt+=Math.sin(ut)*de*nt,Ft=1-pt}}else if(at.type===Y.TextRain){const z=st.speed||1,pt=st.height||100,ut=(wt*.001*z+ct*.1)%1;xt-=(1-ut)*pt*nt,Ft=ut>.1?1:ut*10}else if(at.type===Y.TextGravity){const z=st.gravity||9.8,pt=this.currentTime%3/3,ut=.5*z*Math.pow(pt*10,2);ut<100?xt+=ut*nt:xt+=100*nt}else if(at.type===Y.TextMatrix){const z=st.speed||1;if(Math.random()<.1*z){const ut="0123456789ABCDEF!@#$%^&*";ot=ut[Math.floor(Math.random()*ut.length)]}Ft=.3+(Math.sin(wt*.01*z+ct)+1)/2*.7}else if(at.type===Y.TextNeon){const z=Math.random()>.95?.5:1;Ft=(.7+(Math.sin(wt*.005)+1)/2*.3)*z}else if(at.type===Y.TextDissolve)Math.sin(ct*1.5+wt*.002*(st.speed||1))>.5&&(Ft=0);else if(at.type===Y.TextOrganic){const z=st.speed||1,pt=st.amplitude||10;Dt+=Math.sin(wt*.002*z+ct)*pt*nt,xt+=Math.cos(wt*.0015*z+ct*.7)*pt*nt}else if(at.type===Y.TextBreathe){const pt=1+(Math.sin(wt*.003+ct*.2)+1)/2*.2*nt;ie*=pt,Wt*=pt}else if(at.type===Y.TextSpin){const z=st.speed||1;Bt+=wt*.01*z+ct}else if(at.type===Y.TextMagnet){const z=this.pointerHistory[this.pointerHistory.length-1];if(z){const pt=z.x-(i.x+kt),ut=z.y-(i.y+Vt);Bt=Math.atan2(ut,pt)}}else if(at.type===Y.TextPerspective){const z=B.length/2,pt=(ct-z)/z,ut=1-Math.abs(pt)*.3*nt;ie*=ut,Wt*=ut,Dt+=pt*20*nt}else if(at.type===Y.TextMirror)Ft*=.8;else if(at.type===Y.TextFloral){const z=st.speed||1,pt=st.stagger||.1,ut=(wt*.001*z+ct*pt)%2;ut<1&&(ie*=ut,Wt*=ut,Bt+=ut*Math.PI)}else if(at.type===Y.TextSmoke){const z=st.speed||1,pt=st.height||50,ut=(wt*5e-4*z+ct*.2)%1;xt-=ut*pt*nt,Dt+=Math.sin(wt*.002+ct)*5*nt,Ft=1-ut}else if(at.type===Y.TextVariable){const z=st.speed||1,pt=st.intensity||1.5,ut=(Math.sin(wt*.004*z+ct*.3)+1)/2;ie*=1+ut*(pt-1)*nt}else if(at.type===Y.TextZing){const z=st.speed||2,pt=st.distance||100,ut=(wt*.002*z+ct*.05)%1;Dt+=(1-ut)*pt*nt,Ft=ut}else if(at.type===Y.TextElastic){const z=st.stiffness||.2,pt=st.damping||.1,ut=Math.sin(wt*.01)*Math.exp(-wt*.001*pt);Wt*=1+ut*z*nt}else if(at.type===Y.TextGlitch3D){const z=st.intensity||5;Math.random()<.2&&(Dt+=(Math.random()-.5)*z,xt+=(Math.random()-.5)*z,Ft=.8)}else if(at.type===Y.GlitchText){const z=st.intensity||5;Math.random()<.1&&(Dt+=(Math.random()-.5)*z,xt+=(Math.random()-.5)*z,Math.random()<.05&&(Ft=.5))}});let It=null,vt=o.textDecoration||"none",Ct=m;if(o.enableSegments===!0&&((ne=o.segments)==null?void 0:ne.length)>0){let at=0,st=null;for(const nt of o.segments){if(ct<at+(nt.text||"").length){st=nt;break}at+=(nt.text||"").length}if(st){let nt=st.fontFamily||o.fontFamily||"Inter";v.forEach(pt=>{const ut=new RegExp(`[\\s-]${pt}$`,"i");ut.test(nt)&&(nt=nt.replace(ut,"").trim())});const wt=this.mapFontWeight((st.fontWeight||o.fontWeight||"400").toString()),z=st.fontStyle||d;Ct=st.fontSize||m,t.font=`${z} ${wt} ${Ct}px "${nt}", sans-serif`,st.fill&&(It=st.fill),st.textDecoration&&(vt=st.textDecoration),Ct<V&&(xt+=(V-Ct)*.85)}}else t.font=S;const gt=t.globalAlpha;t.globalAlpha*=Ft,t.save();const Lt=t.measureText(ot).width;if(q&&Q>0){const at=kt-ft+Lt/2,nt=(At+at)/Q,wt=this.getPointOnPath(q.geo,q.w,q.h,Math.abs(nt%1)),z=wt.angle,pt=Vt+xt+(o.pathOffsetY||0),ut=o.pathSide==="right"?-1:1,de=Math.cos(z+Math.PI/2)*pt*ut,be=Math.sin(z+Math.PI/2)*pt*ut;t.translate(wt.x+de+Dt,wt.y+be),t.rotate(z+Bt+(ut===-1?Math.PI:0))}else t.translate(kt+Dt+Lt/2,Vt+xt),Bt!==0&&t.rotate(Bt);if(t.scale(ie,Wt),It&&!r&&!l){const at=this.createCanvasFill(t,It,n,a);t.fillStyle=at||It.color||"#000000"}else if(!r&&!l){const at=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=at||e.fill.color||"#000000"}if(Ft>0)if(r||l){const at=l?"#000000":this.createCanvasFill(t,e.fill,n,a);t.fillStyle=at||e.fill.color||"#ffffff",t.fillText(ot,-Lt/2,0)}else Mt?t.strokeText(ot,-Lt/2,0):t.fillText(ot,-Lt/2,0);vt!=="none"&&!r&&this.drawTextDecoration(t,vt,0,0,Lt,Ct),t.restore(),t.globalAlpha=gt,w==="justify"&&G>0&&ot===" "&&!U?kt+=Lt+k+G:kt+=Lt+k}}};if(r){let B=0,lt=F;(A||[]).forEach(Vt=>{const Mt=Vt.text||"",Tt=c.indexOf(Mt,B);Tt!==-1&&(B=Tt);let Nt=-n/2;w==="center"?Nt=0:w==="right"&&(Nt=n/2),dt(Mt,Nt,lt,!1,B),B+=Mt.length,lt+=_})}else if(l){let B=0,lt=F;(A||[]).forEach(Vt=>{const Mt=Vt.text||"";let Tt=-n/2;w==="center"?Tt=0:w==="right"&&(Tt=n/2),dt(Mt,Tt,lt,!1,B),B+=Mt.length,B<c.length&&(c[B]===`
25
+ `||c[B]==="\r")&&(B++,c[B-1]==="\r"&&c[B]===`
26
+ `&&B++),lt+=_})}else{if(e.fill){const lt=t.globalAlpha,Vt=this.createCanvasFill(t,e.fill,n,a);t.fillStyle=Vt||e.fill.color||"#000000",t.globalAlpha=lt*this.normalizeOpacity(e.fill.opacity??100);const Mt=$.fullText||(o.enableSegments?(o.segments||[]).map(Jt=>{let Kt=Jt.text||"";const Qt=Jt.textCase||o.textCase||"none";return Qt==="uppercase"?Kt.toUpperCase():Qt==="lowercase"?Kt.toLowerCase():Qt==="capitalize"?Kt.replace(/\b\w/g,te=>te.toUpperCase()):Kt}).join(""):c);let Tt=0,Nt=F;(A||[]).forEach(Jt=>{const Kt=Jt.text||"";let Qt=-n/2;w==="center"?Qt=0:w==="right"&&(Qt=n/2),dt(Kt,Qt,Nt,!1,Tt),Tt+=Kt.length,Nt+=_,Tt<Mt.length&&(Mt[Tt]===`
27
+ `||Mt[Tt]==="\r")&&(W>0&&(Nt+=W),Tt++,Mt[Tt-1]==="\r"&&Mt[Tt]===`
28
+ `&&Tt++)}),t.globalAlpha=lt}const B=o.paragraphRule;if(B&&(((zt=B.top)==null?void 0:zt.width)>0||((Xt=B.bottom)==null?void 0:Xt.width)>0)){let lt=0;(A||[]).forEach((Vt,Mt)=>{var Jt,Kt;const Nt=lt===0||lt<c.length&&(c[lt]===`
29
+ `||c[lt]==="\r");if(Nt&&Mt>0&&lt++,Nt){if(((Jt=B.top)==null?void 0:Jt.width)>0){const Qt=F+Mt*_-B.top.offset;t.strokeStyle=B.top.color||"#000000",t.lineWidth=B.top.width,t.beginPath();const te=-n/2+_*.2;t.moveTo(te,Qt),t.lineTo(n/2-_*.2,Qt),t.stroke()}if(((Kt=B.bottom)==null?void 0:Kt.width)>0){const Qt=F+(Mt+1)*_-B.bottom.offset;t.strokeStyle=B.bottom.color||"#000000",t.lineWidth=B.bottom.width,t.beginPath();const te=-n/2+_*.2;t.moveTo(te,Qt),t.lineTo(n/2-_*.2,Qt),t.stroke()}}lt+=(Vt.text||"").length})}if(e.stroke&&e.stroke.width>0){const lt=t.globalAlpha;e.fill&&e.fill.type!=="None"&&e.fill.isEnabled!==!1&&e.fill.opacity!==0&&e.fill.color!=="transparent"&&e.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=e.stroke.color,t.lineWidth=e.stroke.width,t.globalAlpha=lt*this.normalizeOpacity(e.stroke.opacity??100);let Mt=0,Tt=F;(A||[]).forEach(Nt=>{let Jt=-n/2;w==="center"?Jt=0:w==="right"&&(Jt=n/2),dt(Nt.text,Jt,Tt,!0,Mt),Mt+=(Nt.text||"").length,Tt+=_,Mt<c.length&&(c[Mt]===`
30
+ `||c[Mt]==="\r")&&(W>0&&(Tt+=W),Mt++,c[Mt-1]==="\r"&&c[Mt]===`
31
+ `&&Mt++)}),t.globalAlpha=lt}}}applyStrokeAlignment(t,s,o,e,i,n){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=a.width,l=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,i);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const c=t.globalAlpha;t.globalAlpha=c*this.normalizeOpacity(a.opacity??100),t.lineWidth=r,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const g=a.trimStart??0,f=a.trimEnd??1,d=a.trimOffset??0,u=a.dashOffset??0,m=a.dashArray||[];if(g!==0||f!==1||d!==0){const y=this.getPerimeter(o,e,i);if(y>0){const v=Math.max(0,Math.min(1,g)),b=Math.max(0,Math.min(1,f));if(v<b){const C=y*(b-v),S=y-C,I=-(y*(v+d%1));t.setLineDash([C,S]),t.lineDashOffset=I+u*y}else if(v===b)t.setLineDash([0,y]);else{const C=y*(1-v+b),S=y-C,I=-(y*v);t.setLineDash([C,S]),t.lineDashOffset=I+u*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=u);(o==null?void 0:o.type)==="Line"||e===0||i===0?(this.applyPath(t,o,e,i,n),t.stroke()):l==="inside"?(t.lineWidth=r*2,t.save(),this.applyPath(t,o,e,i,n),t.clip(),t.stroke(),t.restore()):l==="outside"?(t.lineWidth=r*2,this.applyPath(t,o,e,i,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,i,n),t.fill(),t.restore()):(t.lineWidth=r,this.applyPath(t,o,e,i,n),t.stroke()),t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,i=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+i)-Math.sqrt((3*e+i)*(e+3*i)));if(n>=360&&a<=0)return r;let l=n/360*r;if(a>0){const h=Math.PI*(3*(e*a+i*a)-Math.sqrt((3*e*a+i*a)*(e*a+3*i*a)));l+=n/360*h,n<360&&(l+=2*Math.sqrt((e-e*a)**2+(i-i*a)**2))}else n<360&&(l+=2*Math.max(e,i));return isNaN(l)?0:l}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,i=t.radius||Math.min(s,o)/2;return 2*e*i*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,i=t.outer_radius||Math.min(s,o)/2,n=t.inner_radius||i/2,a=Math.PI/e;return Math.sqrt(i*i+n*n-2*i*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let i=0,n=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){n=l.x,a=l.y;continue}const h=n,c=a,g=e[r-1].out_x,f=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?i+=this.getBezierLength(h,c,g??h,f??c,l.in_x??l.x,l.in_y??l.y,l.x,l.y):i+=Math.sqrt((l.x-h)**2+(l.y-c)**2),n=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const d=n,u=a,m=[...e.slice(0,r+1)].reverse().find(w=>w.moveTo)||e[0],y=m.x,v=m.y,b=e[r].out_x,C=e[r].out_y,S=m.in_x,I=m.in_y;b!==void 0||S!==void 0?i+=this.getBezierLength(d,u,b??d,C??u,S??y,I??v,y,v):i+=Math.sqrt((y-d)**2+(v-u)**2)}}return i}default:return(s+o)*2}}getBezierLength(t,s,o,e,i,n,a,r,l=10){let h=0,c=t,g=s;for(let f=1;f<=l;f++){const d=f/l,u=1-d,m=d*d,y=u*u,v=y*u,b=m*d,C=v*t+3*y*d*o+3*u*m*i+b*a,S=v*s+3*y*d*e+3*u*m*n+b*r,I=C-c,w=S-g;h+=Math.sqrt(I*I+w*w),c=C,g=S}return h}getBezierTAtLength(t,s,o,e,i,n,a,r,l,h=20){if(t<=0)return 0;let c=0,g=s,f=o;for(let d=1;d<=h;d++){const u=d/h,m=1-u,y=u*u,v=m*m,b=v*m,C=y*u,S=b*s+3*v*u*e+3*m*y*n+C*r,I=b*o+3*v*u*i+3*m*y*a+C*l,w=S-g,k=I-f,E=Math.sqrt(w*w+k*k);if(c+E>=t){const T=t-c,W=E===0?0:T/E;return(d-1+W)/h}c+=E,g=S,f=I}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const i=t.points||[];if(i.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,r=1/0,l=-1/0;i.forEach(v=>{typeof v.x=="number"&&typeof v.y=="number"&&(n=Math.min(n,v.x),a=Math.max(a,v.x),r=Math.min(r,v.y),l=Math.max(l,v.y),v.out_x!==void 0&&(n=Math.min(n,v.out_x),a=Math.max(a,v.out_x)),v.out_y!==void 0&&(r=Math.min(r,v.out_y),l=Math.max(l,v.out_y)),v.in_x!==void 0&&(n=Math.min(n,v.in_x),a=Math.max(a,v.in_x)),v.in_y!==void 0&&(r=Math.min(r,v.in_y),l=Math.max(l,v.in_y)))});const h=(n+a)/2,c=(r+l)/2,f=this.getPerimeter(t,s,o)*e;let d=0;const u=[];let m=i[0],y=i[0];for(let v=1;v<i.length;v++){const b=i[v];if(b.moveTo){m=b,y=b;continue}u.push({p0:m,p1:b}),(b.closePath||v===i.length-1&&(t.is_closed||t.isClosed))&&u.push({p0:b,p1:y}),m=b}for(const v of u){const b=v.p0,C=v.p1;let S=0;const I=b.out_x!==void 0||C.in_x!==void 0;if(I?S=this.getBezierLength(b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y):S=Math.sqrt((C.x-b.x)**2+(C.y-b.y)**2),d+S>=f||v===u[u.length-1]){let w=0;if(I)return w=this.getBezierTAtLength(f-d,b.x,b.y,b.out_x??b.x,b.out_y??b.y,C.in_x??C.x,C.in_y??C.y,C.x,C.y,20),this.getBezierPointAndAngle(w,b,C,h,c);{w=S===0?0:(f-d)/S;const k=b.x+(C.x-b.x)*w-h,E=b.y+(C.y-b.y)*w-c,T=Math.atan2(C.y-b.y,C.x-b.x);return{x:k,y:E,angle:T}}}d+=S}}else if(t.type==="Ellipse"){const i=Math.abs(s)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,h=i*Math.cos(l),c=n*Math.sin(l),g=-i*Math.sin(l),f=n*Math.cos(l),d=Math.atan2(f,g);return{x:h,y:c,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const i=Math.abs(s),n=Math.abs(o),r=(i+n)*2*e;let l=0,h=0,c=0;return r<i?(l=-i/2+r,h=-n/2,c=0):r<i+n?(l=i/2,h=-n/2+(r-i),c=Math.PI/2):r<2*i+n?(l=i/2-(r-(i+n)),h=n/2,c=Math.PI):(l=-i/2,h=n/2-(r-(2*i+n)),c=-Math.PI/2),{x:l,y:h,angle:c}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,i){const n=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,h=o.in_x??o.x,c=o.in_y??o.y,g=o.x,f=o.y,d=1-t,u=t*t,m=d*d,y=m*d,v=u*t,b=y*n+3*m*t*r+3*d*u*h+v*g-e,C=y*a+3*m*t*l+3*d*u*c+v*f-i,S=3*m*(r-n)+6*d*t*(h-r)+3*u*(g-h),I=3*m*(l-a)+6*d*t*(c-l)+3*u*(f-c),w=Math.atan2(I,S);return{x:b,y:C,angle:w}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const i=[];let n=s;for(;n;){i.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}i.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),i=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,i)}applyArtEffectOverlay(t,s,o,e,i,n){var f,d,u,m,y;const a=this.objectStates.get(s.id),r=((f=a==null?void 0:a.style)==null?void 0:f.artEffect)||s.artEffect||((d=s.style)==null?void 0:d.artEffect);if(!r||!r.enabled)return;const l=r.type,h=r.intensity??.5,c=r.speed??1,g=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,i,n),t.clip(),l==="shimmer"){const b=this.currentTime*c%2/2,C=t.createLinearGradient(-e,-i,e,i);C.addColorStop(Math.max(0,b-.2),"rgba(255,255,255,0)"),C.addColorStop(b,`rgba(255,255,255,${h*.8})`),C.addColorStop(Math.min(1,b+.2),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let C=((this._lastPointerPos||{x:0}).x-(((u=s.transform)==null?void 0:u.x)??0)+300)/600;C=Math.max(-.2,Math.min(1.2,C));const S=t.createLinearGradient(-e,-i,e,i);S.addColorStop(Math.max(0,C-.15),"rgba(255,255,255,0)"),S.addColorStop(Math.max(0,Math.min(1,C)),`rgba(255,255,255,${h})`),S.addColorStop(Math.min(1,C+.15),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const v=this._lastPointerPos||{x:0,y:0},b=v.x-(((m=s.transform)==null?void 0:m.x)??0),C=v.y-(((y=s.transform)==null?void 0:y.y)??0),S=t.createLinearGradient(b>0?-e/2:e/2,C>0?-i/2:i/2,b>0?e/2:-e/2,C>0?i/2:-i/2);S.addColorStop(0,`rgba(0,0,0,${h*.6})`),S.addColorStop(.4,"rgba(0,0,0,0)"),S.addColorStop(.5,`rgba(255,255,255,${h*.4})`),S.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=S,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-i/2,e,i),t.globalCompositeOperation="source-over",t.beginPath(),b>0&&C>0?(t.moveTo(e/2-40,i/2),t.lineTo(e/2,i/2-40),t.lineTo(e/2-40,i/2-40)):b<0&&C>0?(t.moveTo(-e/2+40,i/2),t.lineTo(-e/2,i/2-40),t.lineTo(-e/2+40,i/2-40)):b>0&&C<0?(t.moveTo(e/2-40,-i/2),t.lineTo(e/2,-i/2+40),t.lineTo(e/2-40,-i/2+40)):(t.moveTo(-e/2+40,-i/2),t.lineTo(-e/2,-i/2+40),t.lineTo(-e/2+40,-i/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=b>0?-2:2,t.shadowOffsetY=C>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const v=Math.floor(e/g),b=document.createElement("canvas");b.width=v,b.height=Math.floor(i/g);const C=b.getContext("2d"),S=C.createImageData(b.width,b.height);for(let I=0;I<S.data.length;I+=4){const w=Math.random()>.95?150:255;S.data[I]=w,S.data[I+1]=w,S.data[I+2]=w,S.data[I+3]=255*h}C.putImageData(S,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(b,-e/2,-i/2,e,i)}else if(l==="acid_gradient"||l==="acid_rave"){const v=this.currentTime*c,b=r.color1,C=r.color2,S=t.createLinearGradient(-e/2,-i/2,e/2,i/2);if(b&&C){const I=v*60%360;S.addColorStop(0,this._shiftHue(b,I,h*.7)),S.addColorStop(1,this._shiftHue(C,(I+180)%360,h*.7))}else{const I=v*100%360,w=(I+180)%360;S.addColorStop(0,`hsla(${I}, 80%, 50%, ${h*.5})`),S.addColorStop(1,`hsla(${w}, 80%, 50%, ${h*.5})`)}t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-i/2,e,i)}else if(l==="halftone"){const v=Math.max(2,g*(1-h*.8)),b=document.createElement("canvas");b.width=v,b.height=v;const C=b.getContext("2d");if(C){C.fillStyle="black",C.beginPath(),C.arc(v/2,v/2,v/2*h,0,Math.PI*2),C.fill();const S=t.createPattern(b,"repeat");S&&(t.globalAlpha=.3*h,t.fillStyle=S,t.fillRect(-e/2,-i/2,e,i))}}else if(l==="noise"){const v=Math.floor(e*i*h*.02);t.globalAlpha=.4*h;for(let b=0;b<v;b++){const C=Math.random()>.5?255:0;t.fillStyle=`rgba(${C}, ${C}, ${C}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-i/2+Math.random()*i,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let v=-i/2;v<i/2;v+=4)t.beginPath(),t.moveTo(-e/2,v),t.lineTo(e/2,v),t.stroke()}else if(l==="chromatic_aberration"){const v=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-v,-i/2,e,i),t.fillStyle="magenta",t.fillRect(-e/2+v,-i/2,e,i)}else if(l==="pixelate"){const v=Math.max(2,Math.round(g*(1-h*.5))),b=document.createElement("canvas"),C=Math.max(1,Math.ceil(e/v)),S=Math.max(1,Math.ceil(i/v));b.width=C,b.height=S;const I=b.getContext("2d");if(I){I.imageSmoothingEnabled=!1;const w=t.getTransform(),k=w.e-e/2,E=w.f-i/2;I.drawImage(t.canvas,k,E,e,i,0,0,C,S),t.imageSmoothingEnabled=!1,t.drawImage(b,0,0,C,S,-e/2,-i/2,e,i),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const v=this.currentTime*c,b=r.chaosAmount??.2,C=Math.max(3,Math.floor(8*h)),S=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const I=S*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+I,-i/2,e,i),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-I,-i/2,e,i),t.globalCompositeOperation="source-over",t.globalAlpha=1;const w=i/C;for(let k=0;k<C;k++){const E=Math.sin(k*127.1+v*311.7*c)*43758.5,T=E-Math.floor(E);if(T>1-b){const W=(T-(1-b))/b*S*(Math.random()>.5?1:-1),M=-i/2+k*w,_=t.getTransform(),R=_.e-e/2+W,x=_.f+M;t.save(),t.beginPath(),t.rect(-e/2,M,e,w),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,R,x,e,w,-e/2+W,M,e,w),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,i=0,n=0;if(t.startsWith("#")){const f=t.replace("#","");e=parseInt(f.substring(0,2),16)/255,i=parseInt(f.substring(2,4),16)/255,n=parseInt(f.substring(4,6),16)/255}const a=Math.max(e,i,n),r=Math.min(e,i,n);let l=0,h=0,c=(a+r)/2;if(a!==r){const f=a-r;switch(h=c>.5?f/(2-a-r):f/(a+r),a){case e:l=((i-n)/f+(i<n?6:0))/6;break;case i:l=((n-e)/f+2)/6;break;case n:l=((e-i)/f+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(c*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,i,n){const a=n.radius??10,r=n.color??"rgba(255,255,255,0.2)",l=n.opacity??.5,h=n.noise??0;t.save(),this.applyPath(t,s,o,e,i),t.clip();const c=t.getTransform(),g=c.e-o/2,f=c.f-e/2;try{const u=document.createElement("canvas");u.width=Math.max(1,Math.ceil(o)),u.height=Math.max(1,Math.ceil(e));const m=u.getContext("2d");if(m){m.drawImage(t.canvas,g,f,o,e,0,0,o,e),m.filter=`blur(${a}px)`;const y=document.createElement("canvas");y.width=u.width,y.height=u.height;const v=y.getContext("2d");v.filter=`blur(${a}px)`,v.drawImage(u,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(y,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=r,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1,t.globalCompositeOperation="source-atop";const d=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(d.addColorStop(0,"rgba(255,255,255,0.12)"),d.addColorStop(.3,"rgba(255,255,255,0.04)"),d.addColorStop(.5,"rgba(255,255,255,0.0)"),d.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=d,t.fillRect(-o/2,-e/2,o,e),h>0){if(t.globalAlpha=h/100,!this._noiseTileCanvas){const m=document.createElement("canvas");m.width=64,m.height=64;const y=m.getContext("2d"),v=y.createImageData(64,64),b=v.data;for(let C=0;C<b.length;C+=4){const S=Math.floor(Math.random()*255);b[C]=S,b[C+1]=S,b[C+2]=S,b[C+3]=18}y.putImageData(v,0,0),this._noiseTileCanvas=m}const u=t.createPattern(this._noiseTileCanvas,"repeat");u&&(t.fillStyle=u,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,i),t.stroke(),t.restore()}applyPath(t,s,o,e,i){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,i)}_tracePath(t,s,o,e,i){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const n=i!==void 0?i:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,h=e/2,c=n*Math.PI/180,g=a*Math.PI/180,f=c+g;a>=360&&r<=0?t.ellipse(0,0,l,h,0,0,Math.PI*2):(t.ellipse(0,0,l,h,0,c,f,!1),r>0?t.ellipse(0,0,l*r,h*r,0,f,c,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const n=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<n;r++){const l=r*2*Math.PI/n-Math.PI/2,h=a*Math.cos(l),c=a*Math.sin(l);r===0?t.moveTo(h,c):t.lineTo(h,c)}t.closePath()}else if(s.type==="Star"){const n=s.points||5,a=s.outer_radius||Math.min(o,e)/2;let r=s.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let l=0;l<n*2;l++){const h=l*Math.PI/n-Math.PI/2,c=l%2===0?a:r,g=c*Math.cos(h),f=c*Math.sin(h);l===0?t.moveTo(g,f):t.lineTo(g,f)}t.closePath()}else if(((s==null?void 0:s.type)==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type==="BooleanOperation")&&s.points){this.frameCount%10===0&&console.log("[Engine] Tracing Path:",s.points.length,"points");let n=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(n=Math.min(n,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(n=Math.min(n,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.in_y)))}),n===1/0)return;const h=(n+a)/2,c=(r+l)/2;if(isNaN(h)||isNaN(c)){console.warn("[Engine] Invalid path center:",h,c);return}s.points.forEach((g,f)=>{if(f===0||g.moveTo)t.moveTo(g.x-h,g.y-c);else{const d=s.points[f-1];if(!d)return;const u=(d.out_x??d.x)-h,m=(d.out_y??d.y)-c,y=(g.in_x??g.x)-h,v=(g.in_y??g.y)-c;isNaN(u)||isNaN(y)||isNaN(g.x)?t.lineTo(g.x-h,g.y-c):t.bezierCurveTo(u,m,y,v,g.x-h,g.y-c)}if(g.closePath||f===s.points.length-1&&(s.is_closed||s.isClosed)){const d=[...s.points.slice(0,f+1)].reverse().find(u=>u.moveTo)||s.points[0];d&&(g.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-h,(g.out_y??g.y)-c,(d.in_x??d.x)-h,(d.in_y??d.y)-c,d.x-h,d.y-c),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let n=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(g=>{n=Math.min(n,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const h=(n+a)/2,c=(r+l)/2;s.points.forEach((g,f)=>{if(f===0)t.moveTo(g.x-h,g.y-c);else{const d=s.points[f-1];d.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-c,(g.in_x??g.x)-h,(g.in_y??g.y)-c,g.x-h,g.y-c):t.lineTo(g.x-h,g.y-c)}(g.closePath||f===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var dt,St;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((dt=s.geometry)==null?void 0:dt.width)||250,n=((St=s.geometry)==null?void 0:St.height)||45,a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",h=l!=="default"?l:a?"focused":r?"hovered":"default",c=e.label||{visible:!0,text:"Label"},g=e.helperText||{visible:!1,text:"Helper text"},f=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},u=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},v=[y.tl,y.tr,y.br,y.bl];let b=e.backgroundColor||"rgba(31, 41, 55, 1)",C=e.borderColor||"rgba(55, 65, 81, 1)",S=e.borderWidth??1.5,I=e.color||"#ffffff",w=e.placeholderColor||"rgba(156, 163, 175, 1)",k=e.fontSize||14;const E=`${h}Style`,T=e[E];T?(T.backgroundColor!==void 0&&(b=T.backgroundColor),T.borderColor!==void 0&&(C=T.borderColor),T.borderWidth!==void 0&&(S=T.borderWidth),T.color!==void 0&&(I=T.color),T.placeholderColor!==void 0&&(w=T.placeholderColor),T.fontSize!==void 0&&(k=T.fontSize)):h==="focused"?(C=e.focusBorderColor||"rgba(59, 130, 246, 1)",S=Math.max(S,2)):h==="hovered"||h==="hover"?(C=e.hoverBorderColor||C,b=e.hoverBackgroundColor||b):h==="disabled"?(b=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",C=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(C="rgba(239, 68, 68, 1)",S=Math.max(S,2)),t.beginPath(),this.drawRoundRect(t,-i/2,-n/2,i,n,v);const W=this.createCanvasFill(t,b,i,n);if(W&&(t.fillStyle=W,t.fill()),S>0){const ht=this.createCanvasFill(t,C,i,n);if(ht&&(t.strokeStyle=ht,t.lineWidth=S,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const mt=v.map(rt=>rt+2);this.drawRoundRect(t,-i/2-2,-n/2-2,i+4,n+4,mt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const M=(ht,mt)=>{if(!ht.visible||!ht.svgPath)return;const rt=ht.size||14,Rt=ht.offset??16,Yt=ht.color||"#ffffff",Pt=mt?-(i/2)+Rt:i/2-Rt,zt=ht.svgPath;if(t.save(),t.translate(Pt,0),!zt.startsWith("<svg")){const Xt=new Path2D(zt),B=rt/24;t.scale(B,B),t.translate(-12,-12),t.fillStyle=Yt,t.fill(Xt)}t.restore()};M(f,!0),M(d,!1);const _=e.text||"",R=e.placeholder||"Enter text...",x=!_,L=_||R,$=x?w:I,A=k,V=e.fontFamily||"Inter",H=e.fontWeight||400;t.font=`${H} ${A}px "${V}", sans-serif`,t.fillStyle=$,t.textAlign="left",t.textBaseline=u?"top":"middle";const et=e.inputPadding??16,P=f.visible?(f.offset??16)+(f.size||14)/2+8:et,F=d.visible?(d.offset??16)+(d.size||14)/2+8:et,q=-(i/2)+P,Q=i-P-F,it=e.inputType==="password"?"•".repeat(L.length):L;if(t.save(),t.beginPath(),t.rect(q-2,-n/2+4,Q+4,n-8),t.clip(),u){const ht=it.split(`
32
+ `);let mt=-n/2+et;const rt=A*1.2;let Rt=0;ht.forEach((Yt,Pt)=>{const zt=Yt.split(" ");let Xt="";for(let B=0;B<zt.length;B++){const lt=Xt+zt[B]+" ";t.measureText(lt).width>Q&&B>0?(t.fillText(Xt,q,mt),Xt=zt[B]+" ",mt+=rt):Xt=lt}t.fillText(Xt,q,mt),Rt=t.measureText(Xt).width,Pt<ht.length-1&&(mt+=rt,Rt=0)}),a&&!x&&Math.floor(performance.now()/500)%2===0&&t.fillRect(q+Rt,mt,1.5,A)}else{const mt=t.measureText(it).width;let rt=0;if(mt>Q&&(rt=mt-Q),t.fillText(it,q-rt,0),a&&!x&&Math.floor(performance.now()/500)%2===0){const Yt=q+mt-rt;t.fillRect(Yt,-(A/2),1.5,A)}}if(t.restore(),c.visible!==!1){const ht=c.text||"Label",mt=c.fontSize||12,rt=c.color||"rgba(156, 163, 175, 1)",Rt=c.offset??8;t.font=`600 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="bottom";const Yt=-(i/2),Pt=-(n/2)-Rt;t.fillText(ht,Yt,Pt)}if(g.visible===!0){const ht=g.text||"Helper text",mt=g.fontSize||11,rt=h==="error"?"rgba(239, 68, 68, 1)":g.color||"rgba(156, 163, 175, 1)",Rt=g.offset??6;t.font=`400 ${mt}px "${V}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top";const Yt=-(i/2),Pt=n/2+Rt;t.fillText(ht,Yt,Pt)}}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,i=(o==null?void 0:o.options)||s.options||{},n=e.width||200,a=i.value??50,r=i.min??0,h=(i.max??100)-r,c=h===0?0:(a-r)/h,g=i.trackHeight||4,f=i.trackRoundedness??2,d=i.trackShape??"Rectangle",u=i.trackPath||"",m=i.accentColor||"#3b82f6",y=i.inactiveColor||"#374151",v=i.thumbShape||"Ellipse",b=i.thumbWidth??16,C=i.thumbHeight??16,S=i.thumbRoundedness??0,I=i.thumbColor||"#ffffff",w=i.thumbPath||"",k=i.thumbIcon||"",E=i.showValueTooltip??!1,T=i.tooltipBgColor||"#333333",W=i.tooltipColor||"#ffffff",M=i.tooltipOffsetX??0,_=i.tooltipOffsetY??-25,R=(Q,it,dt,St,ht,mt,rt)=>{if((Q==="Custom"||Q==="Icon")&&rt)try{const Rt=new Path2D(rt);if(t.save(),t.translate(it,dt),Q==="Icon"){const Yt=Math.min(St,ht)/24;t.scale(Yt,Yt),t.translate(-12,-12)}t.fill(Rt),t.restore();return}catch(Rt){console.error("Error drawing slider shape in engine:",Rt)}if(t.beginPath(),Q==="Ellipse")t.ellipse(it,dt,St/2,ht/2,0,0,Math.PI*2);else if(Q==="Rectangle")this.drawRoundRect(t,it-St/2,dt-ht/2,St,ht,mt);else if(Q==="Triangle")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt+ht/2),t.lineTo(it-St/2,dt+ht/2),t.closePath();else if(Q==="Diamond")t.moveTo(it,dt-ht/2),t.lineTo(it+St/2,dt),t.lineTo(it,dt+ht/2),t.lineTo(it-St/2,dt),t.closePath();else if(Q==="Polygon"){const Rt=s.geometry.sides||3,Yt=s.geometry.radius||Math.min(St,ht)/2;for(let Pt=0;Pt<Rt;Pt++){const zt=Pt*2*Math.PI/Rt-Math.PI/2,Xt=it+Yt*Math.cos(zt),B=dt+Yt*Math.sin(zt);Pt===0?t.moveTo(Xt,B):t.lineTo(Xt,B)}t.closePath()}else if(Q==="Star"){const Yt=Math.min(St,ht)/2,Pt=Yt/2;for(let zt=0;zt<5*2;zt++){const Xt=zt%2===0?Yt:Pt,B=zt*Math.PI/5-Math.PI/2;t.lineTo(it+Xt*Math.cos(B),dt+Xt*Math.sin(B))}t.closePath()}else Q==="Line"&&(t.moveTo(it-St/2,dt),t.lineTo(it+St/2,dt));t.fill()},x=this.createCanvasFill(t,y,n,g);x&&(t.fillStyle=x,t.strokeStyle=x),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):R(d,0,0,n,g,f,u);const L=n-b,$=-n/2+b/2+c*L,A=$- -n/2;if(A>0){const Q=this.createCanvasFill(t,m,n,g);Q&&(t.fillStyle=Q,t.strokeStyle=Q),d==="Line"?(t.lineWidth=g,t.beginPath(),t.moveTo(-n/2,0),t.lineTo($,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-g/2,A,g,f),t.fill())}t.save(),t.translate($,0);const V=t.getTransform(),H=Math.sqrt(V.a*V.a+V.b*V.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*H,t.shadowOffsetY=1*H;const et=this.createCanvasFill(t,I,b,C);if(et&&(t.fillStyle=et),R(v,0,0,b,C,S,v==="Icon"?k:w),t.restore(),E){t.save(),t.translate($+M,_);const Q=Math.round(a).toString();t.font="10px Inter, sans-serif";const it=t.measureText(Q),dt=6,St=4,ht=it.width+dt*2,mt=14+St;t.beginPath(),this.drawRoundRect(t,-ht/2,-mt/2,ht,mt,4),t.fillStyle=T,t.fill(),t.fillStyle=W,t.textAlign="center",t.textBaseline="middle",t.fillText(Q,0,0),t.restore()}const P=i.label||{},F=i.helperText||{},q=i.fontFamily||"Inter";if(P.visible!==!1){const Q=P.text||"Label",it=P.fontSize||12,dt=P.color||"rgba(156, 163, 175, 1)",St=P.offset??8;t.font=`600 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="bottom";const ht=-(n/2),mt=-(g/2)-St;t.fillText(Q,ht,mt)}if(F.visible===!0){const Q=F.text||"Helper text",it=F.fontSize||11,dt=F.color||"rgba(156, 163, 175, 1)",St=F.offset??6;t.font=`400 ${it}px "${q}", sans-serif`,t.fillStyle=dt,t.textAlign="left",t.textBaseline="top";const ht=-(n/2),mt=g/2+St;t.fillText(Q,ht,mt)}}renderDropdown(t,s){var _;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},i=s.geometry.width||160,n=s.geometry.height||40,a=-i/2,r=-n/2,l=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",c=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!h;let f=e.backgroundColor,d=e.borderColor,u=e.color||"#333333";h?(f=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",u=e.disabledColor||"#9ca3af"):g?(f=e.activeBackgroundColor||f,d=e.activeBorderColor||d,u=e.activeColor||u):c&&(f=e.hoverBackgroundColor||f,d=e.hoverBorderColor||d,u=e.hoverColor||u),f||(f="#ffffff"),d||(d="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,r,i,n,l),t.fillStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,i,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,i,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const v=12,b=e.chevronType||"chevron",C=e.chevronSize||16,S=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(b!=="none"){const R=a+i-v-C/2;t.save(),t.translate(R,0);const x=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(x*Math.PI/180),t.strokeStyle=S,t.fillStyle=S,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",b==="chevron")t.beginPath(),t.moveTo(-C/2,-C*.2),t.lineTo(0,C*.2),t.lineTo(C/2,-C*.2),t.stroke();else if(b==="custom"||b==="path"){const L=g&&e.openIconPath||e.closedIconPath;if(L){const $=new Path2D(L);t.save();const A=C/24;t.scale(A,A),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const I=e.selectedOption||e.placeholder||"Select...",w=e.fontSize||14,k=e.fontWeight||400,E=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${w}px ${E}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":u;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,i,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const W=b==="none"?0:C+8,M=i-v*2-W;if(t.save(),t.beginPath(),t.rect(a+v,r,M,n),t.clip(),t.fillText(I,a+v,0),t.restore(),g&&!h){const R=r+n+4,x=e.optionsList||[],L=e.itemHeight||32,$=e.listPadding??4,A=x.length*L+$*2,V=e.listCornerRadius??l;t.save();const H=e.listShadow||{},et=t.getTransform(),P=Math.sqrt(et.a*et.a+et.b*et.b)||1;t.shadowColor=typeof H.color=="string"?H.color:((_=H.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(H.blur??12)*P,t.shadowOffsetY=(H.offsetY??6)*P,t.shadowOffsetX=(H.offsetX??0)*P,t.beginPath(),this.drawRoundRect(t,a,R,i,A,V),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},i,A)||"#ffffff",t.fill();const F=e.listBorderWidth??1;F>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},i,A)||"#e5e7eb",t.lineWidth=F,t.stroke()),t.restore();const q=e.itemFontSize||w,Q=e.itemFontFamily||E;t.font=`${k} ${q}px ${Q}`,x.forEach((it,dt)=>{const St=R+$+dt*L;if(it===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},i,L)||"#f3f4f6",t.fillRect(a+F,St,i-F*2,L),t.fillStyle=e.itemSelectedColor||e.accentColor||u||"#374151";else if(t.fillStyle=e.listTextColor||u||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const mt=this._lastPointerPos.y-(R+$),rt=Math.floor(mt/L);dt===rt&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},i,L)||"#f9fafb",t.fillRect(a+F,St,i-F*2,L),t.fillStyle=e.itemHoverColor||u)}t.fillText(it,a+v,St+L/2)})}t.globalAlpha=m}renderButton(t,s){if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=s.geometry||{},n=i.width||120,a=i.height||40,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,h=e.label||{},c=e.hoverStyle||{},g=e.activeStyle||{},f=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",u=h.color||"#ffffff",m=h.text||"Button",y=i.cornerRadius??8,v=e.borderColor||"transparent",b=e.borderWidth||0,C=1;l&&g?(d=g.backgroundColor||d,u=g.color||u,m=g.text||m,C=g.scale??.95,y=g.cornerRadius??y):r&&c&&(d=c.backgroundColor||d,u=c.color||u,m=c.text||m,C=c.scale??1,y=c.cornerRadius??y,v=c.borderColor||v);const S=-n/2,I=-a/2;t.save(),t.scale(C,C),t.beginPath(),this.drawRoundRect(t,S,I,n,a,y);const w=this.createCanvasFill(t,d,n,a);w&&(t.fillStyle=w,t.fill()),(b>0||r&&c.borderColor)&&(t.strokeStyle=v,t.lineWidth=b||(r?1:0),t.stroke());const k=h.fontSize||14,E=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${k}px "${E}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle";let W=0;if(f.enabled&&f.svgPath){const M=k*1.1,_=f.gap||8,R=t.measureText(m),L=-(R.width+M+_)/2,$=f.position==="left"?L+M/2:L+R.width+_+M/2;W=f.position==="left"?L+M+_+R.width/2:L+R.width/2,t.save(),t.translate($,0);const A=new Path2D(f.svgPath),V=M/24;t.scale(V,V),t.translate(-12,-12),t.fillStyle=u,t.fill(A),t.restore()}t.fillText(m,W,0),t.restore()}renderToggleButton(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=e.checked??!1,n=((m=s.geometry)==null?void 0:m.width)||120,a=((y=s.geometry)==null?void 0:y.height)||40,r=-n/2,l=-a/2,h=e.corner_radius??8,c=e.label||{},g=i?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",f=i?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,n,a,h),t.fillStyle=g,t.fill();const d=c.fontSize||14,u=c.fontFamily||"Inter";t.font=`${c.fontWeight||600} ${d}px "${u}", sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle",t.fillText(c.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var V,H,et,P,F,q,Q,it,dt,St,ht,mt;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((V=s.geometry)==null?void 0:V.width)||52,n=((H=s.geometry)==null?void 0:H.height)||30,a=-i/2,r=-n/2,l=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,c=e.toggleStyle||{},g=c.backgroundColor||e.activeColor||"#10b981",f=c.borderColor||e.borderColor||"transparent",d=c.borderWidth??e.borderWidth??0,u=c.knobColor||e.knobColor||"#ffffff",m=l?g:e.inactiveColor||"#374151",y=l?f:e.borderColor||"transparent",v=l?d:e.borderWidth??0,b=l?u:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,h);const C=this.createCanvasFill(t,m,i,n);if(C&&(t.fillStyle=C,t.fill()),v>0){t.lineWidth=v;const rt=this.createCanvasFill(t,y,i,n);rt&&(t.strokeStyle=rt,t.stroke())}const S=2,I=n-S*2,w=I/2,k=a+S,E=a+i-S-I,T=l?E:k,W=r+S;t.beginPath(),t.arc(T+w,W+w,w,0,Math.PI*2);const M=this.createCanvasFill(t,b,I,I);M&&(t.fillStyle=M,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,R=!1;const x=(l?(et=c.leftLabel)==null?void 0:et.text:null)||((P=e.leftLabel)==null?void 0:P.text)||"",L=(l?(F=c.leftLabel)==null?void 0:F.color:null)||((q=e.leftLabel)==null?void 0:q.color)||"#f3f4f6";if((Q=e.leftLabel)!=null&&Q.enabled&&x){const rt=e.leftLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=L,t.textBaseline="middle",t.textAlign="right",t.fillText(x,a-(rt.gap||8),0),_=!0}const $=(l?(it=c.rightLabel)==null?void 0:it.text:null)||((dt=e.rightLabel)==null?void 0:dt.text)||"",A=(l?(St=c.rightLabel)==null?void 0:St.color:null)||((ht=e.rightLabel)==null?void 0:ht.color)||"#f3f4f6";if((mt=e.rightLabel)!=null&&mt.enabled&&$){const rt=e.rightLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=A,t.textBaseline="middle",t.textAlign="left",t.fillText($,a+i+(rt.gap||8),0),R=!0}if(!_&&!R&&e.label&&e.label.text){const rt=e.label,Rt=rt.fontSize||14,Yt=rt.fontWeight||400,Pt=rt.fontFamily||"Inter";t.font=`${Yt} ${Rt}px "${Pt}", sans-serif`,t.fillStyle=rt.color||"#f3f4f6",t.textBaseline="middle";const zt=rt.gap||10;let Xt=0,B=0;rt.position==="left"?(t.textAlign="right",Xt=a-zt,B=0):rt.position==="right"?(t.textAlign="left",Xt=a+i+zt,B=0):rt.position==="top"?(t.textAlign="center",Xt=0,B=r-zt,t.textBaseline="bottom"):rt.position==="bottom"?(t.textAlign="center",Xt=0,B=r+n+zt,t.textBaseline="top"):(t.textAlign="left",Xt=a+i+zt,B=0),t.fillText(rt.text,Xt,B)}}renderCheckbox(t,s){var C,S;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((C=s.geometry)==null?void 0:C.width)||20,n=((S=s.geometry)==null?void 0:S.height)||20,a=-i/2,r=-n/2,l=e.cornerRadius??4,h=e.checked??!1,c=e.activeColor||"#3b82f6",g=e.inactiveColor||"transparent",f=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",u=e.borderWidth??2,m=h?c:g,y=h?"transparent":d,v=h?0:u;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,r,i,n,l);const b=this.createCanvasFill(t,m,i,n);if(b&&(t.fillStyle=b,t.fill()),v>0){t.lineWidth=v;const I=this.createCanvasFill(t,y,i,n);I&&(t.strokeStyle=I,t.stroke())}else if(h){t.lineWidth=1;const I=this.createCanvasFill(t,c,i,n);I&&(t.strokeStyle=I,t.stroke())}if(h){t.save(),t.beginPath();const I=this.createCanvasFill(t,f,i,n);t.strokeStyle=I||f,t.lineWidth=Math.max(2,i*.12),t.lineCap="round",t.lineJoin="round";const w=a+i*.25,k=r+n*.5,E=a+i*.45,T=r+n*.7,W=a+i*.75,M=r+n*.25;t.moveTo(w,k),t.lineTo(E,T),t.lineTo(W,M),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const I=e.label;t.save(),t.font=`${I.fontWeight||400} ${I.fontSize||14}px "${I.fontFamily||"Inter"}", sans-serif`,t.fillStyle=I.color||"#f3f4f6",t.textBaseline="middle";const w=I.gap||8;let k=0,E=0;I.position==="left"?(t.textAlign="right",k=a-w,E=0):I.position==="right"?(t.textAlign="left",k=a+i+w,E=0):I.position==="top"?(t.textAlign="center",k=0,E=r-w,t.textBaseline="bottom"):I.position==="bottom"&&(t.textAlign="center",k=0,E=r+n+w,t.textBaseline="top"),t.fillText(I.text,k,E),t.restore()}}renderRadioGroup(t,s){var S,I;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i=((S=s.geometry)==null?void 0:S.width)||180,n=((I=s.geometry)==null?void 0:I.height)||100,a=-i/2,r=-n/2,l=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],c=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,f=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",u=e.textColor||"#ffffff",m=e.fontSize||14,y=e.fontFamily||"Inter",v=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const b=8,C=b*2;if(t.save(),t.font=`${v} ${m}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",c==="vertical"){const w=Math.max(C,m)+g;h.forEach((k,E)=>{const T=r+E*w+b;t.beginPath(),t.arc(a+b,T,b,0,Math.PI*2);const W=l===k,M=this.createCanvasFill(t,f,C,C),_=this.createCanvasFill(t,d,C,C);W?(t.strokeStyle=M||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+b,T,b/2,0,Math.PI*2),t.fillStyle=M||f,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,a+C+8,T)})}else{let w=a;h.forEach(k=>{const E=l===k,T=t.measureText(k).width;t.beginPath(),t.arc(w+b,0,b,0,Math.PI*2);const W=this.createCanvasFill(t,f,C,C),M=this.createCanvasFill(t,d,C,C);E?(t.strokeStyle=W||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(w+b,0,b/2,0,Math.PI*2),t.fillStyle=W||f,t.fill()):(t.strokeStyle=M||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=u,t.fillText(k,w+C+6,0),w+=C+6+T+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#9ca3af",t.textBaseline="middle";const k=w.gap||8;let E=0,T=0;w.position==="left"?(t.textAlign="right",E=a-k,T=0):w.position==="right"?(t.textAlign="left",E=a+i+k,T=0):w.position==="top"?(t.textAlign="center",E=0,T=r-k,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",E=0,T=r+n+k,t.textBaseline="top"),t.fillText(w.text,E,T),t.restore()}}renderBarChart(t,s){var T,W;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((T=s.geometry)==null?void 0:T.width)||300,height:((W=s.geometry)==null?void 0:W.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,_getPreset:function(){return es[this.stylePreset]||es.default},_resolveColor:function(M,_){const R=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(M)?R.colors[_%R.colors.length]:typeof M=="string"?M:R.colors[_%R.colors.length]},_makeGradient:function(M,_,R,x,L,$){if(!this._getPreset().barGradient&&!this.barGradient)return _;const V=M.createLinearGradient(R,x,L,$);return V.addColorStop(0,_),V.addColorStop(1,_+"44"),V},_drawRoundedBar:function(M,_,R,x,L,$,A){if($=Math.min($,Math.min(Math.abs(x),Math.abs(L))/2),$<=0||x===0||L===0){M.rect(_,R,x,L);return}M.beginPath(),A?(M.moveTo(_,R+L),M.lineTo(_,R+$),M.quadraticCurveTo(_,R,_+$,R),M.lineTo(_+x-$,R),M.quadraticCurveTo(_+x,R,_+x,R+$),M.lineTo(_+x,R+L),M.lineTo(_,R+L)):(M.moveTo(_,R),M.lineTo(_+x-$,R),M.quadraticCurveTo(_+x,R,_+x,R+$),M.lineTo(_+x,R+L-$),M.quadraticCurveTo(_+x,R+L,_+x-$,R+L),M.lineTo(_,R+L),M.lineTo(_,R)),M.closePath()}},n=i.width,a=i.height,r=-n/2,l=-a/2;if(!i.datasets||i.datasets.length===0||i.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=i._getPreset();let c=-1/0,g=1/0;const f=i.categories.length,d=i.datasets.length;if(i.chartType==="stacked")for(let M=0;M<f;M++){let _=0,R=0;i.datasets.forEach(x=>{const L=x.data[M]??0;L>=0?_+=L:R+=L}),_>c&&(c=_),R<g&&(g=R)}else i.datasets.forEach(M=>{M.data&&M.data.forEach(_=>{_>c&&(c=_),_<g&&(g=_)})});isFinite(c)||(c=10),isFinite(g)||(g=0),c=Math.max(c,0),g=Math.min(g,0);const u=c-g||10;t.save(),t.font=`${i.axisLabelFontSize}px Inter, sans-serif`;const m=i.showYLabels?t.measureText(c.toFixed(0)).width+14:10,y=i.showXLabels?i.axisLabelFontSize+12:8,b=(i.showLegend&&d>0?i.legendFontSize+10:0)+8,C=10,S=r+m,I=l+b,w=n-m-C,k=a-b-y;if(t.beginPath(),t.roundRect(r,l,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&d>0){t.font=`${i.legendFontSize}px Inter, sans-serif`,t.textBaseline="middle";const M=l+12;let _=S;i.datasets.forEach((R,x)=>{const L=i._resolveColor(R.color,x),$=R.label||`Series ${x+1}`,A=7;t.beginPath(),t.roundRect(_,M-A/2,A,A,2),t.fillStyle=L,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText($,_+A+4,M),_+=t.measureText($).width+A+16})}const E=4;if(i.showGridLines){t.setLineDash([3,4]),t.lineWidth=1,t.strokeStyle=h.gridColor;for(let M=0;M<=E;M++){const _=I+M/E*k;t.beginPath(),t.moveTo(S,_),t.lineTo(S+w,_),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let M=0;M<=E;M++){const _=c-M/E*u,R=I+M/E*k;t.fillText(_.toFixed(0),S-6,R)}}if(t.lineWidth=1,t.setLineDash([]),i.showXAxis&&(t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(S,I+k),t.lineTo(S+w,I+k),t.stroke()),i.showYAxis&&(t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(S,I),t.lineTo(S,I+k),t.stroke()),i.chartType==="stacked"){const M=w/f;for(let _=0;_<f;_++){const R=S+_*M+M/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.fillText(i.categories[_]||"",R,I+k+5));let x=I+k;i.datasets.forEach((L,$)=>{const A=L.data[_]??0;if(A===0)return;const V=A/u*k,H=Math.min(i.barWidth*d+i.barGap,M-8),et=R-H/2,P=x-V;x-=V;const F=i._resolveColor(L.color,$);t.beginPath(),t.fillStyle=i._makeGradient(t,F,et,P,et,P+V),i._drawRoundedBar(t,et,P,H,V,$===d-1?i.barCornerRadius:0,!0),t.fill()})}}else{const M=w/f,_=d*i.barWidth+Math.max(0,(d-1)*i.barGap),R=I+k-(0-g)/u*k;for(let x=0;x<f;x++){const L=S+x*M+M/2;i.showXLabels&&(t.font=`${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.fillText(i.categories[x]||"",L,I+k+5));const $=L-_/2;i.datasets.forEach((A,V)=>{const H=A.data[x]??0,et=Math.abs(H/u*k);if(et<1)return;const P=$+V*(i.barWidth+i.barGap),F=H>=0?R-et:R,q=i._resolveColor(A.color,V);t.beginPath(),t.fillStyle=i._makeGradient(t,q,P,F,P,F+et),i._drawRoundedBar(t,P,F,i.barWidth,et,i.barCornerRadius,!0),t.fill(),i.showValueOnTop&&H!==0&&(t.font=`bold ${i.axisLabelFontSize}px Inter, sans-serif`,t.textAlign="center",t.textBaseline="bottom",t.fillStyle=q,t.fillText(H.toString(),P+i.barWidth/2,F-2))})}}t.restore()}renderPieChart(t,s){var m,y;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},i={width:((m=s.geometry)==null?void 0:m.width)||180,height:((y=s.geometry)==null?void 0:y.height)||180,chartType:e.chartType||"donut",stylePreset:e.stylePreset||"default",slices:e.slices||[{id:"slice-1",label:"Item 1",value:45,color:"#6366f1"}],innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#ffffff",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#ffffff",centerLabelColor:e.centerLabelColor||"rgba(255,255,255,0.4)",_getPreset:function(){return ss[this.stylePreset]||ss.default},_resolveSliceColor:function(v,b){const C=v.color,S=b,I=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(C)?I.colors[S%I.colors.length]:typeof C=="string"?C:I.colors[S%I.colors.length]}},n=i.width,a=i.height;if(!i.slices||i.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const r=i.slices.reduce((v,b)=>v+(b.value||0),0);if(r<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const l=i._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=l.cardBackground,t.fill(),t.strokeStyle=l.cardBorderColor,t.lineWidth=1,t.stroke();const h=i.showLegend?Math.ceil(i.slices.length/2):0,c=h>0?h*(i.legendFontSize+8)+10:0,g=a-c-16,f=Math.min(n-24,g)/2,d=0,u=-c/2;if(i.chartType==="rose"){const v=Math.max(...i.slices.map(S=>S.value||0)),b=Math.PI*2/i.slices.length,C=f>0?i.sliceGap/f:0;i.slices.forEach((S,I)=>{const w=S.value||0;if(w===0)return;const k=w/v*f,E=-Math.PI/2+I*b+C/2,T=E+b-C,W=i._resolveSliceColor(S,I);if(t.beginPath(),t.moveTo(d,u),t.arc(d,u,k,E,T),t.closePath(),t.fillStyle=W+"cc",t.fill(),t.strokeStyle=W,t.lineWidth=1.5,t.stroke(),i.showLabels){const M=E+(T-E)/2,_=d+k*.65*Math.cos(M),R=u+k*.65*Math.sin(M),x=Math.round(w/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,_,R),t.restore()}})}else{const v=i.chartType==="pie"?0:i.innerRadius,b=f*Math.max(0,v),C=f>0?i.sliceGap/f:0;let S=-Math.PI/2;if(i.slices.forEach((I,w)=>{const k=I.value||0;if(k===0){S+=k/r*Math.PI*2;return}const E=k/r*Math.PI*2,T=S+C/2,W=S+E-C/2;if(W<=T){S+=E;return}const M=i._resolveSliceColor(I,w);if(t.beginPath(),t.fillStyle=M,b<=0?(t.moveTo(d,u),t.arc(d,u,f,T,W),t.lineTo(d,u)):(t.moveTo(d+f*Math.cos(T),u+f*Math.sin(T)),t.arc(d,u,f,T,W),t.arc(d,u,b,W,T,!0),t.closePath()),t.fill(),i.showLabels){const _=T+(W-T)/2,R=b+(f-b)/2,x=d+R*Math.cos(_),L=u+R*Math.sin(_),$=Math.round(k/r*100);t.save(),t.font=`bold ${i.labelFontSize}px Inter, sans-serif`,t.fillStyle=l.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${$}%`,x,L),t.restore()}S+=E}),i.chartType==="donut"&&i.showCenterText&&b>14){const I=Math.round(r),w=Math.min(Math.floor(b*.52),20),k=Math.min(Math.floor(b*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${w}px Inter, sans-serif`,t.fillStyle=l.centerTextColor,t.fillText(I.toString(),d,u-k*.5),i.centerLabel&&(t.font=`${k}px Inter, sans-serif`,t.fillStyle=l.centerLabelColor,t.fillText(i.centerLabel,d,u+w*.6))}}if(i.showLegend&&i.slices.length>0){t.font=`${i.legendFontSize}px Inter, sans-serif`;const v=2,b=n/v,C=i.legendFontSize+8,S=a/2-c+10,I=-n/2+10;i.slices.forEach((w,k)=>{const E=k%v,T=Math.floor(k/v),W=I+E*b,M=S+T*C,_=i._resolveSliceColor(w,k),R=7;t.beginPath(),t.roundRect(W,M-R/2,R,R,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=l.legendColor;const x=Math.round((w.value||0)/r*100),L=`${w.label||"Item"} ${x}%`,$=b-R-20;let A=L;for(;t.measureText(A).width>$&&A.length>4;)A=A.slice(0,-4)+"…";t.fillText(A,W+R+4,M)})}t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var k,E;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((k=t.geometry)==null?void 0:k.width)||180,r=i.height!==void 0?i.height:((E=t.geometry)==null?void 0:E.height)||100,l=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,c=e.fontSize||14,g=this.getWorldTransform(t.id),f=s-g.x,d=o-g.y,u=-g.rotation*(Math.PI/180),m=Math.cos(u),y=Math.sin(u),v=f*m-d*y,b=f*y+d*m,S=8*2,I=-a/2,w=-r/2;if(l==="vertical"){const T=Math.max(S,c)+h;for(let W=0;W<n.length;W++){const M=w+W*T;if(v>=I&&v<=I+a&&b>=M&&b<=M+T)return W}}else{let T=I;for(let W=0;W<n.length;W++){const _=n[W].length*8,R=S+6+_+h;if(v>=T&&v<=T+R&&b>=w&&b<=w+r)return W;T+=R}}return null}renderLineGraph(t,s,o,e){let i=s.datasets||[];if((!i||i.length===0)&&(s.data||s.graphData)&&(i=[{id:"line-1",label:"Series 1",data:s.data||s.graphData||[],lineColor:s.lineColor||"#3b82f6",lineWidth:s.lineWidth||2,showArea:s.showArea||!1,areaColor:s.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:s.smoothing||!1,showPoints:s.showPoints!==void 0?s.showPoints:!0,pointSize:s.pointSize||6,pointFill:s.pointFill||"#ffffff",pointStrokeColor:s.pointStrokeColor||s.lineColor||"#3b82f6",pointStrokeWidth:s.pointStrokeWidth||2}]),!i||i.length===0||!i.some(u=>u.data&&u.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,r=0;if(i.forEach(u=>{let m=u.data;if(u.isVarEnabled&&u.inputId){let y=this.inputs.get(u.inputId);if(y===void 0){const v=this.inputNameMap.get(u.inputId);v&&v.length>0&&(y=this.inputs.get(v[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(v=>typeof v=="number"&&!isNaN(v));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),r=Math.max(r,m.length))}u._resolvedData=m}),r<2)return;const l=a-n,h=o/(r-1),c=u=>{const m=l===0?.5:(u-n)/l;return e/2-m*e},g=u=>u*h-o/2,f=s.axisColor||"#333333";if(s.showXAxis&&(t.beginPath(),t.strokeStyle=s.xAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),s.showYAxis&&(t.beginPath(),t.strokeStyle=s.yAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=s.axisLabelColor||"#333333",t.font=`${s.axisLabelFontSize||10}px Inter, sans-serif`,s.showXLabels){t.textAlign="center",t.textBaseline="top";for(let u=0;u<r;u++){const m=g(u);t.fillText(`${u+1}`,m,e/2+5)}}if(s.showYLabels){t.textAlign="right",t.textBaseline="middle";const u=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),u,c(a)),t.fillText(m.toFixed(1),u,c(m)),t.fillText(n.toFixed(1),u,c(n))}const d=10;if(i.forEach(u=>{const m=u._resolvedData;if(!(!m||m.length<2)){if(u.showArea){if(t.beginPath(),t.moveTo(g(0),e/2),t.lineTo(g(0),c(m[0])),u.smoothing&&m.length>2)for(let v=0;v<m.length-1;v++){const b=m[v===0?v:v-1],C=m[v],S=m[v+1],I=m[v+1===m.length-1?v+1:v+2];for(let w=1;w<=d;w++){const k=w/d,E=this._catmullRom(b,C,S,I,k);t.lineTo(g(v+k),c(E))}}else for(let v=1;v<m.length;v++)t.lineTo(g(v),c(m[v]));t.lineTo(g(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(s.areaOpacity??.3),t.fillStyle=u.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=y}if(t.beginPath(),t.strokeStyle=u.lineColor||"#3b82f6",t.lineWidth=u.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(g(0),c(m[0])),u.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const v=m[y===0?y:y-1],b=m[y],C=m[y+1],S=m[y+1===m.length-1?y+1:y+2];for(let I=1;I<=d;I++){const w=I/d,k=this._catmullRom(v,b,C,S,w);t.lineTo(g(y+w),c(k))}}else for(let y=1;y<m.length;y++)t.lineTo(g(y),c(m[y]));t.stroke(),u.showPoints&&m.forEach((y,v)=>{const b=g(v),C=c(y);t.beginPath(),t.arc(b,C,(u.pointSize||6)/2,0,Math.PI*2),t.fillStyle=u.pointFill||"#ffffff",t.fill(),t.strokeStyle=u.pointStrokeColor||u.lineColor||"#3b82f6",t.lineWidth=u.pointStrokeWidth||1,t.stroke()})}}),s.showLegend&&i.length>0){const u=o/2-10;let m=-e/2+15;const y=s.legendFontSize||10,v=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",i.forEach(b=>{const S=b.label||"Series",I=t.measureText(S).width;t.beginPath(),t.rect(u-I-8-5,m-(8/2+2),8,8),t.fillStyle=b.lineColor||"#3b82f6",t.fill(),t.fillStyle=s.legendColor||"#333333",t.fillText(S,u,m),m+=v})}}_catmullRom(t,s,o,e,i){const n=(o-t)*.5,a=(e-s)*.5,r=i*i,l=i*r;return(2*s-2*o+n+a)*l+(-3*s+3*o-2*n-a)*r+n*i+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var i,n,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if(s.type==="Solid"&&s.color){const r=s.color,h=(((n=(i=this.artboard)==null?void 0:i.tokens)==null?void 0:n.colors)||{})[r]||r;return t.fillStyle=h,h}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,h=100)=>{var C,S;const g=(((S=(C=this.artboard)==null?void 0:C.tokens)==null?void 0:S.colors)||{})[l]||l,f=this.normalizeOpacity(s.opacity??100),u=this.normalizeOpacity(h)*f;if(u>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),v=parseInt(m.substring(2,4),16),b=parseInt(m.substring(4,6),16);return`rgba(${y}, ${v}, ${b}, ${u})`};if(s.type==="LinearGradient"){const l=(u,m,y)=>Array.isArray(u)?u[m]??(m===0?0:1):u&&typeof u=="object"?u[y]??(m===0?0:1):m===0?0:1,h=l(s.start,0,"x")*o-o/2,c=l(s.start,1,"y")*e-e/2,g=l(s.end,0,"x")*o-o/2,f=l(s.end,1,"y")*e-e/2,d=t.createLinearGradient(h,c,g,f);if(s.stops.forEach(u=>{const m=u.offset!==void 0?u.offset:u.pos!==void 0?u.pos:u.position!==void 0?u.position:0,y=r(u.color||"#000000",u.opacity??100);d.addColorStop(Math.max(0,Math.min(1,m)),y)}),s.gradientTransform&&d.setTransform){const[u,m,y,v,b,C]=s.gradientTransform;d.setTransform({a:u,b:m,c:y,d:v,e:b,f:C})}return d}else if(s.type==="RadialGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center,0,"x")*o-o/2,c=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),f=t.createRadialGradient(h,c,0,h,c,g);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return f}else if(s.type==="AngularGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),f=(a=t.createConicGradient)==null?void 0:a.call(t,g,h,c);if(f){if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return f}}else if(s.type==="DiamondGradient"){const l=(d,u,m)=>Array.isArray(d)?d[u]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=l(s.center||[.5,.5],0,"x")*o-o/2,c=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(h,c),t.rotate(Math.PI/4);const f=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(d=>{const u=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=r(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,u)),m)}),s.gradientTransform&&f.setTransform){const[d,u,m,y,v,b]=s.gradientTransform;f.setTransform({a:d,b:u,c:m,d:y,e:v,f:b})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=f,t.restore(),f}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const h=new DOMMatrix,c=s.scaleX??1,g=s.scaleY??1,f=s.offsetX??0,d=s.offsetY??0,u=s.rotation??0;h.translateSelf(f,d),h.rotateSelf(u),h.scaleSelf(c,g),l.setTransform(h)}return l}}return s.color||null}drawRoundRect(t,s,o,e,i,n){if(n===0||n===void 0||n===null){t.rect(s,o,e,i);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,h=0,c=0;typeof a=="number"?r=l=h=c=a:Array.isArray(a)?a.length===1?r=l=h=c=a[0]:a.length===2?(r=h=a[0],l=c=a[1]):a.length===3?(r=a[0],l=c=a[1],h=a[2]):a.length>=4&&(r=a[0],l=a[1],h=a[2],c=a[3]):a&&typeof a=="object"&&(r=a.tl??a.corner_radius??a.cornerRadius??0,l=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,c=a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(i)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),h=Math.min(Math.max(0,h),g),c=Math.min(Math.max(0,c),g),t.roundRect){t.roundRect(s,o,e,i,[r,l,h,c]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+i-h),t.arcTo(s+e,o+i,s+e-h,o+i,h),t.lineTo(s+c,o+i),t.arcTo(s,o+i,s,o+i-c,c),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,x,L,$;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},i=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,n=o.height!==void 0?o.height:((x=s.geometry)==null?void 0:x.height)||300,a=-i/2,r=-n/2,l=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",c=e.items||[],g=e.itemGap??10,f=e.itemHeight??50,d=e.itemWidth??200,u=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,v=e.accentColor||"#3b82f6",b=e.itemTextColor||"#333333",C=e.itemBackgroundColor||"#ffffff",S=e.hoveredIndex??null,I=e.activeItemIndex??null,w=e.glowIntensity??0,k=e.glowColor||"#3b82f6",E=typeof k=="string"?k:k.color||(($=(L=k.stops)==null?void 0:L[0])==null?void 0:$.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,w>0){const A=t.getTransform(),V=Math.sqrt(A.a*A.a+A.b*A.b)||1;t.shadowColor=E,t.shadowBlur=w*2*V,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const A=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",V=this.createCanvasFill(t,A,i,n);t.fillStyle=V||"rgba(31, 41, 55, 0.4)",this.drawListViewRect(t,a,r,i,n,l),t.fill();const H=t.createLinearGradient(a,r,a+i,r+n);H.addColorStop(0,"rgba(255, 255, 255, 0.15)"),H.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),H.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=H,this.drawListViewRect(t,a,r,i,n,l),t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,this.drawListViewRect(t,a,r,i,n,l),t.stroke()}else{const A=e.listBackgroundColor||"transparent",V=this.createCanvasFill(t,A,i,n);V&&(t.fillStyle=V,this.drawListViewRect(t,a,r,i,n,l),t.fill());const H=e.borderWidth??0;H>0&&(t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=H,this.drawListViewRect(t,a,r,i,n,l),t.stroke())}t.shadowBlur=0,t.save(),this.drawListViewRect(t,a,r,i,n,l),t.clip();const W=typeof m=="number"?m:h==="vertical"?m[0]:m[3];let M=(h==="vertical"?r:a)+u+W;if(t.textBaseline="middle",c.forEach((A,V)=>{const H=h==="vertical"?i:d,et=h==="vertical"?f:n,P=h==="vertical"?a:M,F=h==="vertical"?M:r,q=S===V,Q=I===V;if(Q){const mt=this.createCanvasFill(t,v,H,et);t.fillStyle=mt||v;const rt=t.globalAlpha;t.globalAlpha=rt*.8,t.fillRect(P,F,H,et),t.globalAlpha=rt}else if(q)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.fillRect(P,F,H,et);else if(C!=="transparent"){const mt=this.createCanvasFill(t,C,H,et);t.fillStyle=mt||C,t.fillRect(P,F,H,et)}if(Q||q){const mt=this.createCanvasFill(t,v,h==="vertical"?3:H,h==="vertical"?et:3);t.fillStyle=mt||v,h==="vertical"?t.fillRect(P,F,3,et):t.fillRect(P,F+et-3,H,3)}const it=Q?"#ffffff":y?"rgba(255, 255, 255, 0.9)":b;t.fillStyle=it,t.font=Q||q?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const dt=typeof A=="string"?A:(A==null?void 0:A.label)||`Item ${V+1}`,St=P+(h==="vertical"?16:H/2),ht=F+et/2;h==="horizontal"?t.textAlign="center":t.textAlign="left",t.fillText(dt,St,ht),M+=(h==="vertical"?f:d)+g}),t.restore(),e.showScrollbar!==!1){const A=(c.length||0)*(h==="vertical"?f:d)+((c.length||0)-1)*g,V=h==="vertical"?n:i;if(A>V){const H=V/A,et=V*H,P=-u/A*V,F=e.scrollbarColor||"rgba(255,255,255,0.3)",q=e.scrollbarWidth||4;t.fillStyle=F,h==="vertical"?t.fillRect(a+i-q-2,r+P,q,et):t.fillRect(a+P,r+n-q-2,et,q)}}t.restore()}updateListViewScrollFromPointer(t){var m,y;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=t.options||{},o=s.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?s.scrollOffset=(s.scrollOffset||0)+i:s.scrollOffset=(s.scrollOffset||0)+e;const n=this.objectStates.get(t.id)||{},a=s.items||[],r=s.itemGap??10,l=s.itemHeight??50,h=s.itemWidth??200,c=n.width!==void 0?n.width:((m=t.geometry)==null?void 0:m.width)||200,g=n.height!==void 0?n.height:((y=t.geometry)==null?void 0:y.height)||300,f=(a.length||0)*(o==="vertical"?l:h)+((a.length||0)-1)*r,u=Math.max(0,f-(o==="vertical"?g:c)+(s.padding*2||0));s.scrollOffset>0&&(s.scrollOffset=0),s.scrollOffset<-u&&(s.scrollOffset=-u)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}getListViewItemIndexAtPointer(t,s,o){var W,M;const e=t.options||{},i=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=i.width!==void 0?i.width:((W=t.geometry)==null?void 0:W.width)||200,r=i.height!==void 0?i.height:((M=t.geometry)==null?void 0:M.height)||300,l=e.orientation||"vertical",h=e.itemGap??10,c=e.itemHeight??50,g=e.itemWidth??200,f=e.scrollOffset??0,d=e.padding??0,u=this.getWorldTransform(t.id),m=s-u.x,y=o-u.y,v=-u.rotation*(Math.PI/180),b=Math.cos(v),C=Math.sin(v),S=m*b-y*C,I=m*C+y*b,w=-a/2,k=-r/2,E=typeof d=="number"?d:l==="vertical"?d[0]:d[3];let T=(l==="vertical"?k:w)+f+E;for(let _=0;_<n.length;_++){const R=l==="vertical"?a:g,x=l==="vertical"?c:r,L=l==="vertical"?w:T,$=l==="vertical"?T:k;if(S>=L&&S<=L+R&&I>=$&&I<=$+x)return _;T+=(l==="vertical"?c:g)+h}return null}drawListViewRect(t,s,o,e,i,n){t.beginPath(),this.drawRoundRect(t,s,o,e,i,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const i=this.objectStates.get(e.id);i&&e.behaviors.forEach(n=>{var g,f,d,u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x,L,$,A,V,H,et,P,F,q,Q,it,dt,St,ht,mt,rt,Rt,Yt,Pt,zt,Xt,B,lt,Vt,Mt,Tt,Nt,Jt,Kt,Qt,te,ce,se,ne,J,ft,U,G,K,Z,Ot,At,kt,Ut,bt,O,ct,Dt,xt,ie,Wt,Bt,Ft,ot,It,vt,Ct,gt,Lt,at,st,nt,wt,z,pt,ut,de,be,Se,Ie,_e,qt,oe,ye,we,Me,pe,fe,he,ve,Pe,Fe,$e,Ee,We,Be,ns,os,as,rs,ls,cs,fs,hs,ds,ps,us,gs;if(!n.enabled)return;const a=n.startTime||0,r=n.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=i.x-s,h=i.y-o,c=Math.sqrt(l*l+h*h);if(this.frameCount%240===0&&Math.random()<.1&&console.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===Y.Proximity){const X=((g=n.settings)==null?void 0:g.radius)||300,N=((f=n.settings)==null?void 0:f.falloff)||"smooth";let D=0;c<X&&(N==="linear"?D=1-c/X:D=Math.pow(1-c/X,2)),n.sensors.forEach(j=>{this.applyBehaviorSensor(i,j,D,t,n.settings,e,l,h,c)})}else if(n.type===Y.Magnetic){const X=((d=n.settings)==null?void 0:d.radius)||400,N=((u=n.settings)==null?void 0:u.strength)||.5;if(c<X&&c>5){const D=1-c/X,j=l*D*N,_t=h*D*N;i.x-=j*t*10,i.y-=_t*t*10}}else if(n.type===Y.Repel){const X=((m=n.settings)==null?void 0:m.radius)||300,N=((y=n.settings)==null?void 0:y.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x+=l/(c||1)*D*60*N*t*5,i.y+=h/(c||1)*D*60*N*t*5}}else if(n.type===Y.Orbit){const X=((v=n.settings)==null?void 0:v.speed)||1,N=((b=n.settings)==null?void 0:b.radius)||30,D=this.currentTime*X*Math.PI*2;i.x+=Math.cos(D)*N*t*5,i.y+=Math.sin(D)*N*t*5,i.rotation+=2*t*5}else if(n.type===Y.Vortex){const X=((C=n.settings)==null?void 0:C.radius)||400,N=((S=n.settings)==null?void 0:S.speed)||2,D=((I=n.settings)==null?void 0:I.strength)||1;if(c<X){const j=Math.pow(1-c/X,1.5),_t=this.currentTime*N*Math.PI*2,Et=Math.cos(_t)*30-l*.4,Gt=Math.sin(_t)*30-h*.4;i.x+=Et*j*D*t*5,i.y+=Gt*j*D*t*5,i.rotation+=5*j*D*t*5,i.scale_x*=1-j*.1*D*t,i.scale_y*=1-j*.1*D*t}}else if(n.type===Y.Fluid){const X=((w=n.settings)==null?void 0:w.radius)||300,N=((k=n.settings)==null?void 0:k.strength)||1;if(c<X){const D=Math.pow(1-c/X,1.2),j=l/(c||1)*D*1.2*N,_t=h/(c||1)*D*1.2*N;i.x+=j*10*t*5,i.y+=_t*10*t*5,i.scale_x*=1+D*.3*N*t,i.scale_y*=1+D*.3*N*t}}else if(n.type===Y.Elastic){const X=((E=n.settings)==null?void 0:E.radius)||300,N=((T=n.settings)==null?void 0:T.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.4*N*t,i.scale_y*=1+D*.4*N*t}}else if(n.type===Y.Holographic){const X=i.x-this.canvasWidth/2,N=i.y-this.canvasHeight/2,D=((W=n.settings)==null?void 0:W.factor)||25;if(i.x-=X/1e3*D*t*5,i.y-=N/1e3*D*t*5,i.style){const j=1-Math.min(1,c/400);i.style.exposure=(i.style.exposure||1)+j*.5*t}}else if(n.type===Y.Sticky){const X=((M=n.settings)==null?void 0:M.radius)||80,N=((_=n.settings)==null?void 0:_.strength)||1;if(c<X){const D=Math.pow(1-c/X,2);i.x-=l*D*N*t*10,i.y-=h*D*N*t*10,i.scale_x*=1-D*.1*N*t,i.scale_y*=1-D*.1*N*t}}else if(n.type===Y.Dilation){const X=((R=n.settings)==null?void 0:R.size)||120,N=((x=n.settings)==null?void 0:x.strength)||1;if(c<X){const D=1-c/X;i.scale_x*=1+D*.5*N*t,i.scale_y*=1+D*.5*N*t}}else if(n.type===Y.Parallax){const X=((L=n.settings)==null?void 0:L.factor)||15,N=(($=n.settings)==null?void 0:$.strength)||1,D=this.canvasWidth/2,j=this.canvasHeight/2,_t=this._lastPointerPos||{x:D,y:j},Et=(_t.x-D)/D,Gt=(_t.y-j)/j,ee=(((A=e.transform)==null?void 0:A.x)??0)+Et*X*N,ue=(((V=e.transform)==null?void 0:V.y)??0)+Gt*X*N,Ce=(((H=e.transform)==null?void 0:H.rotate_x)??0)-Gt*X*1.5*N,ae=(((et=e.transform)==null?void 0:et.rotate_y)??0)+Et*X*1.5*N,me=Math.min(1,10*t);i.x=this.lerp(i.x??((P=e.transform)==null?void 0:P.x)??0,ee,me),i.y=this.lerp(i.y??((F=e.transform)==null?void 0:F.y)??0,ue,me),i.rotate_x=this.lerp(i.rotate_x??((q=e.transform)==null?void 0:q.rotate_x)??0,Ce,me),i.rotate_y=this.lerp(i.rotate_y??((Q=e.transform)==null?void 0:Q.rotate_y)??0,ae,me)}else if(n.type===Y.Fold){if(c<300){const X=1-c/300,N=(l>0?-1:1)*X*10,D=1-X*.1,j=h/300*X*20,_t=-(l/300)*X*20,Et=Math.min(1,10*t);i.skew_x=this.lerp(i.skew_x??((it=e.transform)==null?void 0:it.skew_x)??0,N,Et),i.scale_y=this.lerp(i.scale_y??((dt=e.transform)==null?void 0:dt.scale_y)??1,(((St=e.transform)==null?void 0:St.scale_y)??1)*D,Et),i.rotate_x=this.lerp(i.rotate_x??((ht=e.transform)==null?void 0:ht.rotate_x)??0,j,Et),i.rotate_y=this.lerp(i.rotate_y??((mt=e.transform)==null?void 0:mt.rotate_y)??0,_t,Et),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((rt=n.settings)==null?void 0:rt.opacity)??.5}}}else if(n.type===Y.Crumple){if(c<300){const X=1-c/300,N=X*(Math.random()-.5)*5,D=X*(Math.random()-.5)*.05,j=Math.min(1,15*t);i.skew_x=this.lerp(i.skew_x??((Rt=e.transform)==null?void 0:Rt.skew_x)??0,N,j),i.scale_x=this.lerp(i.scale_x??((Yt=e.transform)==null?void 0:Yt.scale_x)??1,(((Pt=e.transform)==null?void 0:Pt.scale_x)??1)*(1+D),j),i.scale_y=this.lerp(i.scale_y??((zt=e.transform)==null?void 0:zt.scale_y)??1,(((Xt=e.transform)==null?void 0:Xt.scale_y)??1)*(1+D),j),i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((B=n.settings)==null?void 0:B.intensity)??1,scale:((lt=n.settings)==null?void 0:lt.scale)??2}}}else if(n.type===Y.Squash){const X=((Vt=n.settings)==null?void 0:Vt.strength)||.8;c<(e.width||100)&&this.isMouseDown?(i.scale_y=this.lerp(i.scale_y??1,(((Mt=e.transform)==null?void 0:Mt.scale_y)??1)*X,.3),i.scale_x=this.lerp(i.scale_x??1,(((Tt=e.transform)==null?void 0:Tt.scale_x)??1)*(1+(1-X)*.4),.3)):(i.scale_y=this.lerp(i.scale_y??1,((Nt=e.transform)==null?void 0:Nt.scale_y)??1,.2),i.scale_x=this.lerp(i.scale_x??1,((Jt=e.transform)==null?void 0:Jt.scale_x)??1,.2))}else if(n.type===Y.TextCounter){const X=((Kt=n.settings)==null?void 0:Kt.duration)||2,N=((Qt=n.settings)==null?void 0:Qt.from)||0,D=((te=n.settings)==null?void 0:te.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const j=this.currentTime-n._runtimeStart,_t=Math.min(1,j/X),Et=Math.floor(N+(D-N)*_t);if(((ce=e.geometry)==null?void 0:ce.type)==="Text"){const Gt=((se=n.settings)==null?void 0:se.prefix)||"",ee=((ne=n.settings)==null?void 0:ne.suffix)||"";i.geometry||(i.geometry={...e.geometry}),i.geometry.text=`${Gt}${Et}${ee}`}}else if(n.type===Y.Spotlight){const X=((J=n.settings)==null?void 0:J.radius)||250,N=((ft=n.settings)==null?void 0:ft.strength)||1.5;if(c<X){const D=Math.pow(1-c/X,2);i.style||(i.style={...e.style}),i.style.adjustments||(i.style.adjustments={...(U=e.style)==null?void 0:U.adjustments}),i.style.adjustments.exposure=(((K=(G=e.style)==null?void 0:G.adjustments)==null?void 0:K.exposure)||0)+D*N*50}else(Z=i.style)!=null&&Z.adjustments&&(i.style.adjustments.exposure=this.lerp(i.style.adjustments.exposure||0,((At=(Ot=e.style)==null?void 0:Ot.adjustments)==null?void 0:At.exposure)||0,.1))}else if(n.type===Y.Noise||n.type===Y.Float){const X=(((kt=n.settings)==null?void 0:kt.frequency)||((Ut=n.settings)==null?void 0:Ut.speed)||1)*.002,N=(((bt=n.settings)==null?void 0:bt.amplitude)||((O=n.settings)==null?void 0:O.range)||50)*(((ct=n.settings)==null?void 0:ct.strength)||1),D=Date.now();i.x+=Math.sin(D*X)*N*t,i.y+=Math.cos(D*X*.8)*N*t,i.rotation+=Math.sin(D*X*.5)*5*t}else if(n.type===Y.Pulse){const X=(((Dt=n.settings)==null?void 0:Dt.speed)||1)*.005,N=(((xt=n.settings)==null?void 0:xt.scale)||1.2)-1,D=Math.sin(Date.now()*X),j=((ie=n.settings)==null?void 0:ie.strength)||1;i.scale_x*=1+D*N*j*t,i.scale_y*=1+D*N*j*t,i.style&&(i.style.exposure=(i.style.exposure||1)+Math.max(0,D)*.1*j*t)}else if(n.type===Y.Draggable){const X=((Wt=n.settings)==null?void 0:Wt.radius)||150,N=this.draggingBehaviors.has(e.id);if(c<X||N){const D=((Bt=n.settings)==null?void 0:Bt.strength)||1,j=N?1:Math.max(0,1-c/X);this.applyBehaviorSensor(i,jt.PositionX,j*D,t,n.settings),this.applyBehaviorSensor(i,jt.PositionY,j*D,t,n.settings)}}else if(n.type===Y.Scroll){const X=((Ft=n.settings)==null?void 0:Ft.axis)||"vertical",N=((ot=n.settings)==null?void 0:ot.factor)||.5,D=((It=n.settings)==null?void 0:It.strength)||1,j=((vt=n.settings)==null?void 0:vt.scaleFactor)||0;(X==="vertical"||X==="both")&&(i.y+=this.scrollOffset.y*N*D*t),(X==="horizontal"||X==="both")&&(i.x+=this.scrollOffset.x*N*D*t),j!==0&&(i.scale_x*=1+this.scrollOffset.y*j*t,i.scale_y*=1+this.scrollOffset.y*j*t)}else if(n.type===Y.LookAt){const X=((Ct=n.settings)==null?void 0:Ct.factor)||1,N=((gt=n.settings)==null?void 0:gt.strength)||1,D=Math.atan2(-h,-l)*(180/Math.PI),j=i.rotation,_t=(D-j+180)%360-180;i.rotation+=_t*X*N*t*10}else if(n.type===Y.Scan){const X=(((Lt=n.settings)==null?void 0:Lt.speed)||1)*.004,N=((at=n.settings)==null?void 0:at.strength)||1,D=(Math.sin(Date.now()*X)+1)/2;i.style&&(i.style.exposure=(i.style.exposure||1)+D*N*t*5),i.x+=(D-.5)*20*N*t}else if(n.type===Y.Glint)i.style=i.style||{...e.style},i.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((st=n.settings)==null?void 0:st.strength)??.8};else if(n.type===Y.Ratchet){const X=((nt=n.settings)==null?void 0:nt.steps)||12,N=(((wt=n.settings)==null?void 0:wt.speed)||1)*30,D=Math.floor(i.rotation/(360/X))*(360/X);i.rotation=this.lerp(i.rotation,D+N*t,.1)}else if(n.type===Y.Jitter&&c<300){const X=((z=n.settings)==null?void 0:z.strength)||1,N=(((pt=n.settings)==null?void 0:pt.intensity)||5)*X;i.x+=(Math.random()-.5)*N*t*60,i.y+=(Math.random()-.5)*N*t*60,i.rotation+=(Math.random()-.5)*N*t*120}else if(n.type===Y.Follower){const X=(ut=n.settings)==null?void 0:ut.targetId;if(X){const N=this.objectStates.get(X);if(N){const D=((de=n.settings)==null?void 0:de.stiffness)||.1,j=N.x-i.x,_t=N.y-i.y;i.x+=j*D*t*60,i.y+=_t*D*t*60}}}else if(n.type===Y.Wrap)i.x<0?i.x=this.canvasWidth:i.x>this.canvasWidth&&(i.x=0),i.y<0?i.y=this.canvasHeight:i.y>this.canvasHeight&&(i.y=0);else if(n.type===Y.Gravity){const X=((be=n.settings)==null?void 0:be.strength)||9.8;i.y+=X*t*10}else if(n.type===Y.Velocity){const X=((Se=n.settings)==null?void 0:Se.vx)||0,N=((Ie=n.settings)==null?void 0:Ie.vy)||0;i.x+=X*t*10,i.y+=N*t*10}else if(n.type===Y.Shear){const X=((_e=n.settings)==null?void 0:_e.strength)||1,N=((qt=n.settings)==null?void 0:qt.radius)||300;if(c<N){const D=1-c/N;i.skew_x=this.lerp(i.skew_x||0,(((oe=e.transform)==null?void 0:oe.skew_x)||0)+D*X*30,.1)}else i.skew_x=this.lerp(i.skew_x||0,((ye=e.transform)==null?void 0:ye.skew_x)||0,.05)}else if(n.type===Y.Lens){const X=((we=n.settings)==null?void 0:we.radius)||200,N=((Me=n.settings)==null?void 0:Me.strength)||.5;if(c<X){const D=Math.pow(1-c/X,2);i.scale_x=this.lerp(i.scale_x??1,(((pe=e.transform)==null?void 0:pe.scale_x)??1)*(1+D*N),.2),i.scale_y=this.lerp(i.scale_y??1,(((fe=e.transform)==null?void 0:fe.scale_y)??1)*(1+D*N),.2)}else i.scale_x=this.lerp(i.scale_x??1,((he=e.transform)==null?void 0:he.scale_x)??1,.1),i.scale_y=this.lerp(i.scale_y??1,((ve=e.transform)==null?void 0:ve.scale_y)??1,.1)}else if(n.type===Y.LayoutAnimation){const X=((Pe=n.settings)==null?void 0:Pe.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],N=((Fe=n.settings)==null?void 0:Fe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const D=this._layoutAnimCache.get(e.id);for(const j of X){const _t=this.getObjectProperty(i,e,j);if(_t===void 0)continue;const Et=D.get(j);if(!Et)D.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);D.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:(($e=n.settings)==null?void 0:$e.duration)??N})}const Gt=D.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,ue=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(ue,((Ee=n.settings)==null?void 0:Ee.easing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const X=this._layoutAnimCache.get(e.id),N=((We=n.settings)==null?void 0:We.defaultDuration)||.3,D=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const j of D){const _t=this.getObjectProperty(i,e,j);if(_t===void 0||typeof _t!="number")continue;const Et=X.get(j);if(!Et)X.set(j,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(Et.to!==_t){const ee=this.getObjectProperty(i,e,j);X.set(j,{from:ee??Et.from,to:_t,startTime:this.currentTime,duration:N})}const Gt=X.get(j);if(Gt.duration>0&&Gt.from!==Gt.to){const ee=this.currentTime-Gt.startTime,ue=Math.min(1,ee/Gt.duration),Ce=this.applyEasing(ue,((Be=n.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),ae=Gt.from+(Gt.to-Gt.from)*Ce;this.setObjectProperty(i,e,j,ae)}}}else if(n.type===Y.SpringChain){const X=((ns=n.settings)==null?void 0:ns.connections)||[],N=((os=n.settings)==null?void 0:os.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const D=this._springChainState.get(e.id);for(const _t of X){if(!D.has(_t.targetId)){const Et=this.objectStates.get(_t.targetId);D.set(_t.targetId,{x:(Et==null?void 0:Et.x)??0,y:(Et==null?void 0:Et.y)??0,vx:0,vy:0})}D.has(e.id)||D.set(e.id,{x:i.x,y:i.y,vx:0,vy:0})}const j=D.get(e.id);if(j){j.x=i.x,j.y=i.y;for(const _t of X){const Et=D.get(_t.targetId);if(!Et)continue;const Gt=Et.x-j.x,ee=Et.y-j.y,ue=Math.sqrt(Gt*Gt+ee*ee)||.001,ae=(ue-(_t.restLength||50))*(_t.stiffness||.8),me=Gt/ue*ae,Ge=ee/ue*ae;j.vx+=me*t*10,j.vy+=Ge*t*10,Et.vx-=me*t*10,Et.vy-=Ge*t*10,j.vx*=1-N*t*10,j.vy*=1-N*t*10,Et.vx*=1-N*t*10,Et.vy*=1-N*t*10;const ge=this.objectStates.get(_t.targetId);ge&&(ge.x+=Et.vx*t,ge.y+=Et.vy*t)}i.x+=j.vx*t,i.y+=j.vy*t}}else if(n.type===Y.ParticleEmitter){const X=((as=n.settings)==null?void 0:as.rate)||10,N=((rs=n.settings)==null?void 0:rs.speed)||100,D=((ls=n.settings)==null?void 0:ls.size)||5,j=((cs=n.settings)==null?void 0:cs.lifetime)||2,_t=((fs=n.settings)==null?void 0:fs.gravity)||0,Et=((hs=n.settings)==null?void 0:hs.color)||"#ffffff",Gt=((ds=n.settings)==null?void 0:ds.maxParticles)||200,ee=(ps=n.settings)!=null&&ps.rateInputId?this.inputs.get(n.settings.rateInputId)??X:X,ue=(us=n.settings)!=null&&us.gravityInputId?this.inputs.get(n.settings.gravityInputId)??_t:_t,Ce=(gs=n.settings)!=null&&gs.speedInputId?this.inputs.get(n.settings.speedInputId)??N:N;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const ae=this._emitterPools.get(e.id);let me=0;n._pendingBurst&&n._pendingBurst>0&&(me=n._pendingBurst,n._pendingBurst=0);const Ge=Math.floor(ee*t)+(me||0);for(let ge=0;ge<Math.min(Ge,Gt-ae.length);ge++){const re=Math.random()*Math.PI*2,ms=Ce*(.5+Math.random()*.5);ae.push({x:i.x,y:i.y,vx:Math.cos(re)*ms,vy:Math.sin(re)*ms,life:0,maxLife:j*(.5+Math.random()*.5),size:D*(.5+Math.random()),color:Et,opacity:1})}for(let ge=ae.length-1;ge>=0;ge--){const re=ae[ge];re.vy+=ue*t*10,re.x+=re.vx*t,re.y+=re.vy*t,re.life+=t,re.opacity=Math.max(0,1-re.life/re.maxLife),re.life>=re.maxLife&&ae.splice(ge,1)}}})})}applyBehaviorSensor(t,s,o,e,i,n,a=0,r=0,l=1){var d,u,m,y,v,b,C,S,I,w,k,E,T,W,M,_,R,x,L,$,A,V,H,et;const h=(i==null?void 0:i.intensity)||(i==null?void 0:i.strength)||1,c=Math.min(1,15*e),g=l>0?a/l:0,f=l>0?r/l:0;switch(s){case jt.Scale:{const P=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,F=((u=n==null?void 0:n.transform)==null?void 0:u.scale_y)??1,q=P*(1+o*h*.4),Q=F*(1+o*h*.4);t.scale_x=(t.scale_x??P)*(1-c)+q*c,t.scale_y=(t.scale_y??F)*(1-c)+Q*c;break}case jt.Opacity:{const P=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,F=Math.max(0,Math.min(100,P-o*h*100));t.opacity=(t.opacity??P)*(1-c)+F*c;break}case jt.RotateZ:{const P=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,F=P+o*h*45;t.rotation=(t.rotation??P)*(1-c)+F*c;break}case jt.RotateX:{const P=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_x)??0,F=P-f*o*h*60;t.rotate_x=(t.rotate_x??P)*(1-c)+F*c;break}case jt.RotateY:{const P=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_y)??0,F=P+g*o*h*60;t.rotate_y=(t.rotate_y??P)*(1-c)+F*c;break}case jt.PositionX:{const P=((C=n==null?void 0:n.transform)==null?void 0:C.x)??0,F=P-g*o*h*40;t.x=(t.x??P)*(1-c)+F*c;break}case jt.PositionY:{const P=((S=n==null?void 0:n.transform)==null?void 0:S.y)??0,F=P-f*o*h*40;t.y=(t.y??P)*(1-c)+F*c;break}case jt.SkewX:{const P=((I=n==null?void 0:n.transform)==null?void 0:I.skew_x)??0,F=P+g*o*h*45;t.skew_x=(t.skew_x??P)*(1-c)+F*c,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case jt.Blur:{t.style||(t.style={...n==null?void 0:n.style}),t.style.blur||(t.style.blur={...(w=n==null?void 0:n.style)==null?void 0:w.blur});const P=((E=(k=n==null?void 0:n.style)==null?void 0:k.blur)==null?void 0:E.amount)||0,F=P+o*((i==null?void 0:i.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??P)*(1-c)+F*c;break}case jt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const P=((M=(W=n==null?void 0:n.style)==null?void 0:W.adjustments)==null?void 0:M.exposure)||0,F=P+o*((i==null?void 0:i.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??P)*(1-c)+F*c;break}case jt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const P=((x=(R=n==null?void 0:n.style)==null?void 0:R.adjustments)==null?void 0:x.hue)||0,F=P+o*((i==null?void 0:i.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??P)*(1-c)+F*c;break}case jt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(L=n==null?void 0:n.style)==null?void 0:L.adjustments});const P=((A=($=n==null?void 0:n.style)==null?void 0:$.adjustments)==null?void 0:A.negative)||0,F=P+o*((i==null?void 0:i.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??P)*(1-c)+F*c;break}case jt.CornerRadius:{const P=((V=n==null?void 0:n.transform)==null?void 0:V.corner_radius)||0,F=P+o*h*50;t.corner_radius=(t.corner_radius??P)*(1-c)+F*c;break}case jt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const P=((H=n==null?void 0:n.style)==null?void 0:H.borderWidth)||0,F=P+o*h*10;t.style.borderWidth=(t.style.borderWidth??P)*(1-c)+F*c;break}case jt.LetterSpacing:{t.geometry||(t.geometry={});const P=((et=n==null?void 0:n.geometry)==null?void 0:et.letterSpacing)||0,F=P+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??P)*(1-c)+F*c;break}}}getObjectProperty(t,s,o){const e=o.split(".");let i=t;for(const n of e){if(i==null||typeof i!="object")return;if(n==="style"&&t.style===void 0){i=s.style;continue}i=i[n]}return typeof i=="number"?i:void 0}setObjectProperty(t,s,o,e){const i=o.split(".");let n=t;for(let r=0;r<i.length-1;r++){const l=i[r];if(n[l]===void 0||n[l]===null){const h=s,c=i.slice(0,r+1).reduce((g,f)=>g==null?void 0:g[f],h);n[l]=c!==void 0?{...c}:{}}n=n[l]}const a=i[i.length-1];n!=null&&(n[a]=e)}applyEasing(t,s){switch(s){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}renderFittedImage(t,s,o,e,i,n,a="cover"){const r=s.naturalWidth,l=s.naturalHeight,h=r/l,c=i/n;let g=i,f=n,d=o,u=e;a==="cover"?h>c?(g=n*h,d=o-(g-i)/2):(f=i/h,u=e-(f-n)/2):a==="contain"&&(h>c?(f=i/h,u=e+(n-f)/2):(g=n*h,d=o+(i-g)/2)),t.drawImage(s,d,u,g,f)}}const ii=$t.forwardRef(({artboard:p,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:i="Center",onReady:n,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:h,onInputChange:c,onInputFocus:g,onInputBlur:f,onLog:d,onLogicUpdate:u,onButtonClick:m,onGraphPointClick:y,currentTime:v,revision:b=0,scrollY:C,scrollX:S,mouseX:I,mouseY:w,isMouseDown:k,inputs:E,interactive:T=!0,onNavigation:W},M)=>{const _=$t.useRef(null),R=$t.useRef(new is),x=$t.useRef(void 0),L=$t.useRef(0),$=$t.useRef(null),A=$t.useRef(b),[,V]=$t.useState(p||null),H=$t.useRef(!0);$t.useImperativeHandle(M,()=>_.current),$t.useEffect(()=>(H.current=!0,()=>{H.current=!1,x.current&&cancelAnimationFrame(x.current)}),[]),$t.useEffect(()=>{R.current.setLayout(e,i)},[e,i]),$t.useEffect(()=>{const P=R.current;a&&P.setTriggerCallback(a),r&&P.setInputUpdateCallback((F,q)=>r({[F]:q})),l&&P.setComponentChangeCallback(F=>l(F)),h&&P.setToggleCallback(h),c&&P.setInputChangeCallback(c),g&&P.setInputFocusCallback(g),f&&P.setInputBlurCallback(f),d&&P.setOnLogCallback(F=>d(F,"info")),u&&P.setLogicUpdateCallback(u),m&&P.setButtonClickCallback(m),y&&P.setGraphPointClickCallback(F=>y(F.objectId,F)),W&&P.setNavigationCallback(W)},[a,r,l,h,c,g,f,d,u,m,y,W]),$t.useEffect(()=>{(async()=>{let F=p;if(t&&!p)try{t.startsWith("{")?F=JSON.parse(t):F=await(await fetch(t)).json()}catch(q){console.error("[ExodeUI] Failed to load src:",q)}if(F){const q=R.current,Q=F.id||F.name||"default";($.current!==Q||A.current!==b)&&(q.load(F),$.current=Q,A.current=b,V(F),L.current=0,q.advance(0)),n&&n(q)}})()},[p==null?void 0:p.id,t,b]),$t.useEffect(()=>{const P=F=>{if(!R.current||!H.current)return;const q=R.current,Q=_.current;if(!Q)return;const it=Q.getContext("2d");if(!it)return;const dt=F/1e3;L.current===0&&(L.current=dt);let St=dt-L.current;St>.1&&(St=.1),L.current=dt;const ht=Q.getBoundingClientRect(),mt=window.devicePixelRatio||1,rt=Math.round(ht.width*mt),Rt=Math.round(ht.height*mt);(Q.width!==rt||Q.height!==Rt)&&(Q.width=rt,Q.height=Rt),o?q.advance(St):v!==void 0&&q.seek(v),q.render(it,Q.width,Q.height),x.current=requestAnimationFrame(P)};return x.current=requestAnimationFrame(P),()=>{x.current&&cancelAnimationFrame(x.current)}},[o,v]),$t.useEffect(()=>{const P=R.current;C!==void 0&&P.updateInput("scrollY",C),S!==void 0&&P.updateInput("scrollX",S),I!==void 0&&P.updateInput("mouseX",I),w!==void 0&&P.updateInput("mouseY",w),k!==void 0&&P.updateInput("isMouseDown",k),E&&Object.entries(E).forEach(([F,q])=>P.updateInput(F,q))},[C,S,I,w,k,E]);const et=(P,F)=>{if(!T||!_.current)return;const q=_.current,Q=q.getBoundingClientRect(),it=P.clientX-Q.left,dt=P.clientY-Q.top,St=window.devicePixelRatio||1;R.current.handlePointerInput(F,it*St,dt*St,q.width,q.height)};return Zt.jsx("canvas",{ref:_,onPointerDown:P=>{var F;et(P,"down"),(F=_.current)==null||F.focus()},onPointerMove:P=>et(P,"move"),onPointerUp:P=>et(P,"up"),onPointerCancel:P=>et(P,"up"),onClick:P=>et(P,"click"),onWheel:P=>{R.current.handleWheel(P.deltaX,P.deltaY)},onKeyDown:P=>R.current.handleKeyDown(P.nativeEvent),onContextMenu:P=>P.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}})});function ni(){const[p,t]=$t.useState(null),s=$t.useCallback((c,g)=>{p==null||p.setInputBool(c,g)},[p]),o=$t.useCallback((c,g)=>{p==null||p.setInputNumber(c,g)},[p]),e=$t.useCallback(c=>{p==null||p.fireTrigger(c)},[p]),i=$t.useCallback((c,g)=>{p==null||p.setInputText(c,g)},[p]),n=$t.useCallback((c,g)=>{p==null||p.setInputNumberArray(c,g)},[p]),a=$t.useCallback((c,g)=>{p==null||p.setInputStringArray(c,g)},[p]),r=$t.useCallback((c,g)=>{p==null||p.updateObjectOptions(c,g)},[p]),l=$t.useCallback((c,g,f)=>{p==null||p.updateConstraint(c,g,f)},[p]),h=$t.useCallback((c,g)=>{p==null||p.updateGraphData(c,g)},[p]);return{setEngine:t,engine:p,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:i,setInputNumberArray:n,setInputStringArray:a,updateConstraint:l,updateGraphData:h,updateObjectOptions:r}}const oi=({artboard:p,config:t})=>{const s={...p.seo,...t},o=s.enableSmartExtraction!==!1;$t.useEffect(()=>{const a=s.title||p.name;a&&(document.title=a);let r=s.description;if(!r&&o){const c=p.objects.filter(g=>{var f;return((f=g.geometry)==null?void 0:f.type)==="Text"}).sort((g,f)=>{var d,u;return(((d=f.geometry.text)==null?void 0:d.length)||0)-(((u=g.geometry.text)==null?void 0:u.length)||0)});c.length>0&&(r=c[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||p.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,p,o]);const e=(a,r,l)=>{let h=document.querySelector(`meta[${a}="${r}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,r),document.head.appendChild(h)),h.setAttribute("content",l)},i=()=>{const a=[];return a.push(Zt.jsx("h1",{children:s.title||p.name},"artboard-title")),p.objects.forEach((l,h)=>{var c,g;if(!(l.visible===!1||l.isVisible===!1))if(((c=l.geometry)==null?void 0:c.type)==="Text"){const f=l.geometry.text;f&&(l.geometry.fontSize>24?a.push(Zt.jsx("h2",{children:f},l.id||h)):a.push(Zt.jsx("p",{children:f},l.id||h)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const f=l.geometry.src,d=l.altText||l.name||"Illustration";a.push(Zt.jsx("img",{src:f,alt:d},l.id||h))}else l.type==="Button"&&a.push(Zt.jsx("button",{children:l.name||"Button"},l.id||h))}),a},n=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||p.name,description:s.description,image:s.ogImage||p.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Zt.jsxs("div",{id:`exode-seo-${p.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[i(),Zt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ai={version:"6.3.18"}.version;Ht.BehaviorSensor=jt,Ht.BehaviorType=Y,Ht.ConditionOp=Xe,Ht.ExodeSEO=oi,Ht.ExodeUICanvas=ii,Ht.ExodeUIEngine=is,Ht.LogicOp=yt,Ht.VERSION=ai,Ht.useExodeUI=ni,Object.defineProperty(Ht,Symbol.toStringTag,{value:"Module"})});