exodeui 6.3.33 → 6.3.34

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
@@ -30,5 +30,5 @@
30
30
  `&&Mt++)}),t.globalAlpha=yt}const et=o.paragraphRule;if(et&&(((Tt=et.top)==null?void 0:Tt.width)>0||((zt=et.bottom)==null?void 0:zt.width)>0)){let yt=0;(B||[]).forEach((Ot,gt)=>{var Vt,Yt;const Ft=yt===0||yt<r.length&&(r[yt]===`
31
31
  `||r[yt]==="\r");if(Ft&&gt>0&&yt++,Ft){if(((Vt=et.top)==null?void 0:Vt.width)>0){const Ht=z+gt*_-et.top.offset;t.strokeStyle=et.top.color||"#000000",t.lineWidth=et.top.width,t.beginPath();const Kt=-n/2+_*.2;t.moveTo(Kt,Ht),t.lineTo(n/2-_*.2,Ht),t.stroke()}if(((Yt=et.bottom)==null?void 0:Yt.width)>0){const Ht=z+(gt+1)*_-et.bottom.offset;t.strokeStyle=et.bottom.color||"#000000",t.lineWidth=et.bottom.width,t.beginPath();const Kt=-n/2+_*.2;t.moveTo(Kt,Ht),t.lineTo(n/2-_*.2,Ht),t.stroke()}}yt+=(Ot.text||"").length})}if(e.stroke&&e.stroke.width>0){const yt=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=yt*this.normalizeOpacity(e.stroke.opacity??100);let gt=0,Mt=z;(B||[]).forEach(Ft=>{let Vt=-L/2;M==="center"?Vt=0:M==="right"&&(Vt=L/2),V(Ft.text,Vt,Mt,!0,gt),gt+=(Ft.text||"").length,Mt+=_,gt<r.length&&(r[gt]===`
32
32
  `||r[gt]==="\r")&&(O>0&&(Mt+=O),gt++,r[gt-1]==="\r"&&r[gt]===`
33
- `&&gt++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,i,o,e,s,n){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const a=i.stroke,l=a.width,c=(a.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,s);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const r=t.globalAlpha;t.globalAlpha=r*this.normalizeOpacity(a.opacity??100),t.lineWidth=l,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const u=a.trimStart??0,f=a.trimEnd??1,d=a.trimOffset??0,p=a.dashOffset??0,m=a.dashArray||[];if(u!==0||f!==1||d!==0){const y=this.getPerimeter(o,e,s);if(y>0){const b=Math.max(0,Math.min(1,u)),v=Math.max(0,Math.min(1,f));if(b<v){const S=y*(v-b),C=y-S,w=-(y*(b+d%1));t.setLineDash([S,C]),t.lineDashOffset=w+p*y}else if(b===v)t.setLineDash([0,y]);else{const S=y*(1-b+v),C=y-S,w=-(y*b);t.setLineDash([S,C]),t.lineDashOffset=w+p*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=p);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):c==="inside"?(t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):c==="outside"?(t.lineWidth=l*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke()),t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,l=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return l;let c=n/360*l;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));c+=n/360*h,n<360&&(c+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(c+=2*Math.max(e,s));return isNaN(c)?0:c}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let l=1;l<e.length;l++){const c=e[l];if(c.moveTo){n=c.x,a=c.y;continue}const h=n,r=a,u=e[l-1].out_x,f=e[l-1].out_y;if(u!==void 0||c.in_x!==void 0?s+=this.getBezierLength(h,r,u??h,f??r,c.in_x??c.x,c.in_y??c.y,c.x,c.y):s+=Math.sqrt((c.x-h)**2+(c.y-r)**2),n=c.x,a=c.y,c.closePath||l===e.length-1&&(t.is_closed||t.isClosed)){const d=n,p=a,m=[...e.slice(0,l+1)].reverse().find(M=>M.moveTo)||e[0],y=m.x,b=m.y,v=e[l].out_x,S=e[l].out_y,C=m.in_x,w=m.in_y;v!==void 0||C!==void 0?s+=this.getBezierLength(d,p,v??d,S??p,C??y,w??b,y,b):s+=Math.sqrt((y-d)**2+(b-p)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,l,c=10){let h=0,r=t,u=i;for(let f=1;f<=c;f++){const d=f/c,p=1-d,m=d*d,y=p*p,b=y*p,v=m*d,S=b*t+3*y*d*o+3*p*m*s+v*a,C=b*i+3*y*d*e+3*p*m*n+v*l,w=S-r,M=C-u;h+=Math.sqrt(w*w+M*M),r=S,u=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,l,c,h=20){if(t<=0)return 0;let r=0,u=i,f=o;for(let d=1;d<=h;d++){const p=d/h,m=1-p,y=p*p,b=m*m,v=b*m,S=y*p,C=v*i+3*b*p*e+3*m*y*n+S*l,w=v*o+3*b*p*s+3*m*y*a+S*c,M=C-u,I=w-f,k=Math.sqrt(M*M+I*I);if(r+k>=t){const T=t-r,O=k===0?0:T/k;return(d-1+O)/h}r+=k,u=C,f=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,l=1/0,c=-1/0;s.forEach(b=>{typeof b.x=="number"&&typeof b.y=="number"&&(n=Math.min(n,b.x),a=Math.max(a,b.x),l=Math.min(l,b.y),c=Math.max(c,b.y),b.out_x!==void 0&&(n=Math.min(n,b.out_x),a=Math.max(a,b.out_x)),b.out_y!==void 0&&(l=Math.min(l,b.out_y),c=Math.max(c,b.out_y)),b.in_x!==void 0&&(n=Math.min(n,b.in_x),a=Math.max(a,b.in_x)),b.in_y!==void 0&&(l=Math.min(l,b.in_y),c=Math.max(c,b.in_y)))});const h=(n+a)/2,r=(l+c)/2,f=this.getPerimeter(t,i,o)*e;let d=0;const p=[];let m=s[0],y=s[0];for(let b=1;b<s.length;b++){const v=s[b];if(v.moveTo){m=v,y=v;continue}p.push({p0:m,p1:v}),(v.closePath||b===s.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:v,p1:y}),m=v}for(const b of p){const v=b.p0,S=b.p1;let C=0;const w=v.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-v.x)**2+(S.y-v.y)**2),d+C>=f||b===p[p.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(f-d,v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,v,S,h,r);{M=C===0?0:(f-d)/C;const I=v.x+(S.x-v.x)*M-h,k=v.y+(S.y-v.y)*M-r,T=Math.atan2(S.y-v.y,S.x-v.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,c=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(c),r=n*Math.sin(c),u=-s*Math.sin(c),f=n*Math.cos(c),d=Math.atan2(f,u);return{x:h,y:r,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),l=(s+n)*2*e;let c=0,h=0,r=0;return l<s?(c=-s/2+l,h=-n/2,r=0):l<s+n?(c=s/2,h=-n/2+(l-s),r=Math.PI/2):l<2*s+n?(c=s/2-(l-(s+n)),h=n/2,r=Math.PI):(c=-s/2,h=n/2-(l-(2*s+n)),r=-Math.PI/2),{x:c,y:h,angle:r}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,l=i.out_x??i.x,c=i.out_y??i.y,h=o.in_x??o.x,r=o.in_y??o.y,u=o.x,f=o.y,d=1-t,p=t*t,m=d*d,y=m*d,b=p*t,v=y*n+3*m*t*l+3*d*p*h+b*u-e,S=y*a+3*m*t*c+3*d*p*r+b*f-s,C=3*m*(l-n)+6*d*t*(h-l)+3*p*(u-h),w=3*m*(c-a)+6*d*t*(r-c)+3*p*(f-r),M=Math.atan2(w,C);return{x:v,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate(o.rotation*Math.PI/180);const e=(o.scale_x??1)*(o.flip_x===!0?-1:1),s=(o.scale_y??1)*(o.flip_y===!0?-1:1);t.scale(e,s)}applyArtEffectOverlay(t,i,o,e,s,n){var f,d,p,m,y;const a=this.objectStates.get(i.id),l=((f=a==null?void 0:a.style)==null?void 0:f.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!l||!l.enabled)return;const c=l.type,h=l.intensity??.5,r=l.speed??1,u=l.scale??10;if(c==="acid_gradient"||c==="acid_rave"||c==="shimmer"||c==="glint_overlay"||c==="halftone"||c==="noise"||c==="scanlines"||c==="chromatic_aberration"||c==="pixelate"||c==="glitch"||c==="fold_overlay"||c==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),c==="shimmer"){const v=this.currentTime*r%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),S.addColorStop(v,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((p=i.transform)==null?void 0:p.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((m=i.transform)==null?void 0:m.x)??0),S=b.y-(((y=i.transform)==null?void 0:y.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,S>0?-s/2:s/2,v>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):v<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):v>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=v>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(c==="crumple_overlay"){const b=Math.floor(e/u),v=document.createElement("canvas");v.width=b,v.height=Math.floor(s/u);const S=v.getContext("2d"),C=S.createImageData(v.width,v.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-s/2,e,s)}else if(c==="acid_gradient"||c==="acid_rave"){const b=this.currentTime*r,v=l.color1,S=l.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(v&&S){const w=b*60%360;C.addColorStop(0,this._shiftHue(v,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=b*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(c==="halftone"){const b=Math.max(2,u*(1-h*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const S=v.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(b/2,b/2,b/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(c==="noise"){const b=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let v=0;v<b;v++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(c==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-s/2;b<s/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(c==="chromatic_aberration"){const b=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+b,-s/2,e,s)}else if(c==="pixelate"){const b=Math.max(2,Math.round(u*(1-h*.5))),v=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/b)),C=Math.max(1,Math.ceil(s/b));v.width=S,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(c==="glitch"){const b=this.currentTime*r,v=l.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+b*311.7*r)*43758.5,T=k-Math.floor(k);if(T>1-v){const O=(T-(1-v))/v*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),A=_.e-e/2+O,x=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,A,x,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const f=t.replace("#","");e=parseInt(f.substring(0,2),16)/255,s=parseInt(f.substring(2,4),16)/255,n=parseInt(f.substring(4,6),16)/255}const a=Math.max(e,s,n),l=Math.min(e,s,n);let c=0,h=0,r=(a+l)/2;if(a!==l){const f=a-l;switch(h=r>.5?f/(2-a-l):f/(a+l),a){case e:c=((s-n)/f+(s<n?6:0))/6;break;case s:c=((n-e)/f+2)/6;break;case n:c=((e-s)/f+4)/6;break}}return`hsla(${(((c*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(r*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,l=n.color??"rgba(255,255,255,0.2)",c=n.opacity??.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const r=t.getTransform(),u=r.e-o/2,f=r.f-e/2;try{const p=document.createElement("canvas");p.width=Math.max(1,Math.ceil(o)),p.height=Math.max(1,Math.ceil(e));const m=p.getContext("2d");if(m){m.drawImage(t.canvas,u,f,o,e,0,0,o,e),m.filter=`blur(${a}px)`;const y=document.createElement("canvas");y.width=p.width,y.height=p.height;const b=y.getContext("2d");b.filter=`blur(${a}px)`,b.drawImage(p,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(y,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=c,t.fillStyle=l,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"),b=y.createImageData(64,64),v=b.data;for(let S=0;S<v.length;S+=4){const C=Math.floor(Math.random()*255);v[S]=C,v[S+1]=C,v[S+2]=C,v[S+3]=18}y.putImageData(b,0,0),this._noiseTileCanvas=m}const p=t.createPattern(this._noiseTileCanvas,"repeat");p&&(t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:l=0}=i,c=o/2,h=e/2,r=n*Math.PI/180,u=a*Math.PI/180,f=r+u;a>=360&&l<=0?t.ellipse(0,0,c,h,0,0,Math.PI*2):(t.ellipse(0,0,c,h,0,r,f,!1),l>0?t.ellipse(0,0,c*l,h*l,0,f,r,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let l=0;l<n;l++){const c=l*2*Math.PI/n-Math.PI/2,h=a*Math.cos(c),r=a*Math.sin(c);l===0?t.moveTo(h,r):t.lineTo(h,r)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let l=i.inner_radius;l==null?l=a*.382:l<=1&&(l=a*l);for(let c=0;c<n*2;c++){const h=c*Math.PI/n-Math.PI/2,r=c%2===0?a:l,u=r*Math.cos(h),f=r*Math.sin(h);c===0?t.moveTo(u,f):t.lineTo(u,f)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,l=1/0,c=-1/0;if(i.points.forEach(u=>{typeof u.x=="number"&&typeof u.y=="number"&&(n=Math.min(n,u.x),a=Math.max(a,u.x),l=Math.min(l,u.y),c=Math.max(c,u.y),u.out_x!==void 0&&(n=Math.min(n,u.out_x),a=Math.max(a,u.out_x)),u.out_y!==void 0&&(l=Math.min(l,u.out_y),c=Math.max(c,u.out_y)),u.in_x!==void 0&&(n=Math.min(n,u.in_x),a=Math.max(a,u.in_x)),u.in_y!==void 0&&(l=Math.min(l,u.in_y),c=Math.max(c,u.in_y)))}),n===1/0)return;const h=(n+a)/2,r=(l+c)/2;if(isNaN(h)||isNaN(r)){this.warn("[Engine] Invalid path center:",h,r);return}i.points.forEach((u,f)=>{if(f===0||u.moveTo)t.moveTo(u.x-h,u.y-r);else{const d=i.points[f-1];if(!d)return;const p=(d.out_x??d.x)-h,m=(d.out_y??d.y)-r,y=(u.in_x??u.x)-h,b=(u.in_y??u.y)-r;isNaN(p)||isNaN(y)||isNaN(u.x)?t.lineTo(u.x-h,u.y-r):t.bezierCurveTo(p,m,y,b,u.x-h,u.y-r)}if(u.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,f+1)].reverse().find(p=>p.moveTo)||i.points[0];d&&(u.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((u.out_x??u.x)-h,(u.out_y??u.y)-r,(d.in_x??d.x)-h,(d.in_y??d.y)-r,d.x-h,d.y-r),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,l=1/0,c=-1/0;i.points.forEach(u=>{n=Math.min(n,u.x),a=Math.max(a,u.x),l=Math.min(l,u.y),c=Math.max(c,u.y)});const h=(n+a)/2,r=(l+c)/2;i.points.forEach((u,f)=>{if(f===0)t.moveTo(u.x-h,u.y-r);else{const d=i.points[f-1];d.out_x!==void 0||u.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-r,(u.in_x??u.x)-h,(u.in_y??u.y)-r,u.x-h,u.y-r):t.lineTo(u.x-h,u.y-r)}(u.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var F,$;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((F=i.geometry)==null?void 0:F.width)||250,n=(($=i.geometry)==null?void 0:$.height)||45,a=this.focusedId===i.id,l=this.lastHoveredObjectId===i.id,c=e.previewState||"default",h=c!=="default"?c:a?"focused":l?"hovered":"default",r=e.label||{visible:!0,text:"Label"},u=e.helperText||{visible:!1,text:"Helper text"},f=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},p=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},b=[y.tl,y.tr,y.br,y.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(v=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,v=e.hoverBackgroundColor||v):h==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,b);const O=this.createCanvasFill(t,v,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const V=this.createCanvasFill(t,S,s,n);if(V&&(t.strokeStyle=V,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const tt=b.map(rt=>rt+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,tt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(V,tt)=>{if(!V.visible||!V.svgPath)return;const rt=V.size||14,mt=V.offset??16,Ct=V.color||"#ffffff",ct=tt?-(s/2)+mt:s/2-mt,Pt=V.svgPath;if(t.save(),t.translate(ct,0),!Pt.startsWith("<svg")){const kt=new Path2D(Pt),Tt=rt/24;t.scale(Tt,Tt),t.translate(-12,-12),t.fillStyle=Ct,t.fill(kt)}t.restore()};P(f,!0),P(d,!1);const _=e.text||"",A=e.placeholder||"Enter text...",x=!_,W=_||A,Y=x?M:w,B=I,X=e.fontFamily||"Inter",q=e.fontWeight||400;t.font=`${q} ${B}px "${X}", sans-serif`,t.fillStyle=Y,t.textAlign="left",t.textBaseline=p?"top":"middle";const j=e.inputPadding??16,E=f.visible?(f.offset??16)+(f.size||14)/2+8:j,L=d.visible?(d.offset??16)+(d.size||14)/2+8:j,G=-(s/2)+E,z=s-E-L,it=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(G-2,-n/2+4,z+4,n-8),t.clip(),p){const V=it.split(`
34
- `);let tt=-n/2+j;const rt=B*1.2;let mt=0;V.forEach((Ct,ct)=>{const Pt=Ct.split(" ");let kt="";for(let Tt=0;Tt<Pt.length;Tt++){const zt=kt+Pt[Tt]+" ";t.measureText(zt).width>z&&Tt>0?(t.fillText(kt,G,tt),kt=Pt[Tt]+" ",tt+=rt):kt=zt}t.fillText(kt,G,tt),mt=t.measureText(kt).width,ct<V.length-1&&(tt+=rt,mt=0)}),a&&!x&&Math.floor(performance.now()/500)%2===0&&t.fillRect(G+mt,tt,1.5,B)}else{const tt=t.measureText(it).width;let rt=0;if(tt>z&&(rt=tt-z),t.fillText(it,G-rt,0),a&&!x&&Math.floor(performance.now()/500)%2===0){const Ct=G+tt-rt;t.fillRect(Ct,-(B/2),1.5,B)}}if(t.restore(),r.visible!==!1){const V=r.text||"Label",tt=r.fontSize||12,rt=r.color||"rgba(156, 163, 175, 1)",mt=r.offset??8;t.font=`600 ${tt}px "${X}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="bottom";const Ct=-(s/2),ct=-(n/2)-mt;t.fillText(V,Ct,ct)}if(u.visible===!0){const V=u.text||"Helper text",tt=u.fontSize||11,rt=h==="error"?"rgba(239, 68, 68, 1)":u.color||"rgba(156, 163, 175, 1)",mt=u.offset??6;t.font=`400 ${tt}px "${X}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top";const Ct=-(s/2),ct=n/2+mt;t.fillText(V,Ct,ct)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,l=s.min??0,h=(s.max??100)-l,r=h===0?0:(a-l)/h,u=s.trackHeight||4,f=s.trackRoundedness??2,d=s.trackShape??"Rectangle",p=s.trackPath||"",m=s.accentColor||"#3b82f6",y=s.inactiveColor||"#374151",b=s.thumbShape||"Ellipse",v=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,A=(z,it,F,$,V,tt,rt)=>{if((z==="Custom"||z==="Icon")&&rt)try{const mt=new Path2D(rt);if(t.save(),t.translate(it,F),z==="Icon"){const Ct=Math.min($,V)/24;t.scale(Ct,Ct),t.translate(-12,-12)}t.fill(mt),t.restore();return}catch(mt){console.error("Error drawing slider shape in engine:",mt)}if(t.beginPath(),z==="Ellipse")t.ellipse(it,F,$/2,V/2,0,0,Math.PI*2);else if(z==="Rectangle")this.drawRoundRect(t,it-$/2,F-V/2,$,V,tt);else if(z==="Triangle")t.moveTo(it,F-V/2),t.lineTo(it+$/2,F+V/2),t.lineTo(it-$/2,F+V/2),t.closePath();else if(z==="Diamond")t.moveTo(it,F-V/2),t.lineTo(it+$/2,F),t.lineTo(it,F+V/2),t.lineTo(it-$/2,F),t.closePath();else if(z==="Polygon"){const mt=i.geometry.sides||3,Ct=i.geometry.radius||Math.min($,V)/2;for(let ct=0;ct<mt;ct++){const Pt=ct*2*Math.PI/mt-Math.PI/2,kt=it+Ct*Math.cos(Pt),Tt=F+Ct*Math.sin(Pt);ct===0?t.moveTo(kt,Tt):t.lineTo(kt,Tt)}t.closePath()}else if(z==="Star"){const Ct=Math.min($,V)/2,ct=Ct/2;for(let Pt=0;Pt<10;Pt++){const kt=Pt%2===0?Ct:ct,Tt=Pt*Math.PI/5-Math.PI/2;t.lineTo(it+kt*Math.cos(Tt),F+kt*Math.sin(Tt))}t.closePath()}else z==="Line"&&(t.moveTo(it-$/2,F),t.lineTo(it+$/2,F));t.fill()},x=this.createCanvasFill(t,y,n,u);x&&(t.fillStyle=x,t.strokeStyle=x),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):A(d,0,0,n,u,f,p);const W=n-v,Y=-n/2+v/2+r*W,B=Y- -n/2;if(B>0){const z=this.createCanvasFill(t,m,n,u);z&&(t.fillStyle=z,t.strokeStyle=z),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(Y,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-u/2,B,u,f),t.fill())}t.save(),t.translate(Y,0);const X=t.getTransform(),q=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*q,t.shadowOffsetY=1*q;const j=this.createCanvasFill(t,w,v,S);if(j&&(t.fillStyle=j),A(b,0,0,v,S,C,b==="Icon"?I:M),t.restore(),k){t.save(),t.translate(Y+P,_);const z=Math.round(a).toString();t.font="10px Inter, sans-serif";const it=t.measureText(z),F=6,$=4,V=it.width+F*2,tt=14+$;t.beginPath(),this.drawRoundRect(t,-V/2,-tt/2,V,tt,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(z,0,0),t.restore()}const E=s.label||{},L=s.helperText||{},G=s.fontFamily||"Inter";if(E.visible!==!1){const z=E.text||"Label",it=E.fontSize||12,F=E.color||"rgba(156, 163, 175, 1)",$=E.offset??8;t.font=`600 ${it}px "${G}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="bottom";const V=-(n/2),tt=-(u/2)-$;t.fillText(z,V,tt)}if(L.visible===!0){const z=L.text||"Helper text",it=L.fontSize||11,F=L.color||"rgba(156, 163, 175, 1)",$=L.offset??6;t.font=`400 ${it}px "${G}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="top";const V=-(n/2),tt=u/2+$;t.fillText(z,V,tt)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,l=-n/2,c=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",r=this.lastHoveredObjectId===i.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!h;let f=e.backgroundColor,d=e.borderColor,p=e.color||"#333333";h?(f=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):u?(f=e.activeBackgroundColor||f,d=e.activeBorderColor||d,p=e.activeColor||p):r&&(f=e.hoverBackgroundColor||f,d=e.hoverBorderColor||d,p=e.hoverColor||p),f||(f="#ffffff"),d||(d="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,l,s,n,c),t.fillStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,s,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const b=12,v=e.chevronType||"chevron",S=e.chevronSize||16,C=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const A=a+s-b-S/2;t.save(),t.translate(A,0);const x=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(x*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(v==="custom"||v==="path"){const W=u&&e.openIconPath||e.closedIconPath;if(W){const Y=new Path2D(W);t.save();const B=S/24;t.scale(B,B),t.translate(-12,-12),t.fill(Y),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=v==="none"?0:S+8,P=s-b*2-O;if(t.save(),t.beginPath(),t.rect(a+b,l,P,n),t.clip(),t.fillText(w,a+b,0),t.restore(),u&&!h){const A=l+n+4,x=e.optionsList||[],W=e.itemHeight||32,Y=e.listPadding??4,B=x.length*W+Y*2,X=e.listCornerRadius??c;t.save();const q=e.listShadow||{},j=t.getTransform(),E=Math.sqrt(j.a*j.a+j.b*j.b)||1;t.shadowColor=typeof q.color=="string"?q.color:((_=q.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(q.blur??12)*E,t.shadowOffsetY=(q.offsetY??6)*E,t.shadowOffsetX=(q.offsetX??0)*E,t.beginPath(),this.drawRoundRect(t,a,A,s,B,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,B)||"#ffffff",t.fill();const L=e.listBorderWidth??1;L>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,B)||"#e5e7eb",t.lineWidth=L,t.stroke()),t.restore();const G=e.itemFontSize||M,z=e.itemFontFamily||k;t.font=`${I} ${G}px ${z}`,x.forEach((it,F)=>{const $=A+Y+F*W;if(it===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+L,$,s-L*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const tt=this._lastPointerPos.y-(A+Y),rt=Math.floor(tt/W);F===rt&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+L,$,s-L*2,W),t.fillStyle=e.itemHoverColor||p)}t.fillText(it,a+b,$+W/2)})}t.globalAlpha=m}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,l=this.lastHoveredObjectId===i.id,c=this.activeObjectId===i.id,h=e.label||{},r=e.hoverStyle||{},u=e.activeStyle||{},f=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",p=h.color||"#ffffff",m=h.text||"Button",y=s.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,S=1;c&&u?(d=u.backgroundColor||d,p=u.color||p,m=u.text||m,S=u.scale??.95,y=u.cornerRadius??y):l&&r&&(d=r.backgroundColor||d,p=r.color||p,m=r.text||m,S=r.scale??1,y=r.cornerRadius??y,b=r.borderColor||b);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,y);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(v>0||l&&r.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(l?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let O=0;if(f.enabled&&f.svgPath){const P=I*1.1,_=f.gap||8,A=t.measureText(m),W=-(A.width+P+_)/2,Y=f.position==="left"?W+P/2:W+A.width+_+P/2;O=f.position==="left"?W+P+_+A.width/2:W+A.width/2,t.save(),t.translate(Y,0);const B=new Path2D(f.svgPath),X=P/24;t.scale(X,X),t.translate(-12,-12),t.fillStyle=p,t.fill(B),t.restore()}t.fillText(m,O,0),t.restore()}renderToggleButton(t,i){var m,y;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((m=i.geometry)==null?void 0:m.width)||120,a=((y=i.geometry)==null?void 0:y.height)||40,l=-n/2,c=-a/2,h=e.corner_radius??8,r=e.label||{},u=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",f=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,l,c,n,a,h),t.fillStyle=u,t.fill();const d=r.fontSize||14,p=r.fontFamily||"Inter";t.font=`${r.fontWeight||600} ${d}px "${p}", sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle",t.fillText(r.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var X,q,j,E,L,G,z,it,F,$,V,tt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((X=i.geometry)==null?void 0:X.width)||52,n=((q=i.geometry)==null?void 0:q.height)||30,a=-s/2,l=-n/2,c=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,r=e.toggleStyle||{},u=r.backgroundColor||e.activeColor||"#10b981",f=r.borderColor||e.borderColor||"transparent",d=r.borderWidth??e.borderWidth??0,p=r.knobColor||e.knobColor||"#ffffff",m=c?u:e.inactiveColor||"#374151",y=c?f:e.borderColor||"transparent",b=c?d:e.borderWidth??0,v=c?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,h);const S=this.createCanvasFill(t,m,s,n);if(S&&(t.fillStyle=S,t.fill()),b>0){t.lineWidth=b;const rt=this.createCanvasFill(t,y,s,n);rt&&(t.strokeStyle=rt,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=c?k:I,O=l+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,v,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,A=!1;const x=(c?(j=r.leftLabel)==null?void 0:j.text:null)||((E=e.leftLabel)==null?void 0:E.text)||"",W=(c?(L=r.leftLabel)==null?void 0:L.color:null)||((G=e.leftLabel)==null?void 0:G.color)||"#f3f4f6";if((z=e.leftLabel)!=null&&z.enabled&&x){const rt=e.leftLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(x,a-(rt.gap||8),0),_=!0}const Y=(c?(it=r.rightLabel)==null?void 0:it.text:null)||((F=e.rightLabel)==null?void 0:F.text)||"",B=(c?($=r.rightLabel)==null?void 0:$.color:null)||((V=e.rightLabel)==null?void 0:V.color)||"#f3f4f6";if((tt=e.rightLabel)!=null&&tt.enabled&&Y){const rt=e.rightLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=B,t.textBaseline="middle",t.textAlign="left",t.fillText(Y,a+s+(rt.gap||8),0),A=!0}if(!_&&!A&&e.label&&e.label.text){const rt=e.label,mt=rt.fontSize||14,Ct=rt.fontWeight||400,ct=rt.fontFamily||"Inter";t.font=`${Ct} ${mt}px "${ct}", sans-serif`,t.fillStyle=rt.color||"#f3f4f6",t.textBaseline="middle";const Pt=rt.gap||10;let kt=0,Tt=0;rt.position==="left"?(t.textAlign="right",kt=a-Pt,Tt=0):rt.position==="right"?(t.textAlign="left",kt=a+s+Pt,Tt=0):rt.position==="top"?(t.textAlign="center",kt=0,Tt=l-Pt,t.textBaseline="bottom"):rt.position==="bottom"?(t.textAlign="center",kt=0,Tt=l+n+Pt,t.textBaseline="top"):(t.textAlign="left",kt=a+s+Pt,Tt=0),t.fillText(rt.text,kt,Tt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,l=-n/2,c=e.cornerRadius??4,h=e.checked??!1,r=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",f=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",p=e.borderWidth??2,m=h?r:u,y=h?"transparent":d,b=h?0:p;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,c);const v=this.createCanvasFill(t,m,s,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const w=this.createCanvasFill(t,y,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,r,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,f,s,n);t.strokeStyle=w||f,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=l+n*.5,k=a+s*.45,T=l+n*.7,O=a+s*.75,P=l+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=l-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=l+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,l=-n/2,c=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],r=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,f=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",p=e.textColor||"#ffffff",m=e.fontSize||14,y=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,S=v*2;if(t.save(),t.font=`${b} ${m}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",r==="vertical"){const M=Math.max(S,m)+u;h.forEach((I,k)=>{const T=l+k*M+v;t.beginPath(),t.arc(a+v,T,v,0,Math.PI*2);const O=c===I,P=this.createCanvasFill(t,f,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,T,v/2,0,Math.PI*2),t.fillStyle=P||f,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=c===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+v,0,v,0,Math.PI*2);const O=this.createCanvasFill(t,f,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+v,0,v/2,0,Math.PI*2),t.fillStyle=O||f,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,M+S+6,0),M+=S+6+T+u})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=l-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=l+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ds[this.stylePreset]||ds.default},_resolveColor:function(P,_){const A=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?A.colors[_%A.colors.length]:typeof P=="string"?P:A.colors[_%A.colors.length]},_makeGradient:function(P,_,A,x,W,Y){if(!this._getPreset().barGradient&&!this.barGradient)return _;const X=P.createLinearGradient(A,x,W,Y);return X.addColorStop(0,_),X.addColorStop(1,_+"44"),X},_drawRoundedBar:function(P,_,A,x,W,Y,B){if(Y=Math.min(Y,Math.min(Math.abs(x),Math.abs(W))/2),Y<=0||x===0||W===0){P.rect(_,A,x,W);return}P.beginPath(),B?(P.moveTo(_,A+W),P.lineTo(_,A+Y),P.quadraticCurveTo(_,A,_+Y,A),P.lineTo(_+x-Y,A),P.quadraticCurveTo(_+x,A,_+x,A+Y),P.lineTo(_+x,A+W),P.lineTo(_,A+W)):(P.moveTo(_,A),P.lineTo(_+x-Y,A),P.quadraticCurveTo(_+x,A,_+x,A+Y),P.lineTo(_+x,A+W-Y),P.quadraticCurveTo(_+x,A+W,_+x-Y,A+W),P.lineTo(_,A+W),P.lineTo(_,A)),P.closePath()}},n=s.width,a=s.height,l=-n/2,c=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let r=-1/0,u=1/0;const f=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<f;P++){let _=0,A=0;s.datasets.forEach(x=>{const W=x.data[P]??0;W>=0?_+=W:A+=W}),_>r&&(r=_),A<u&&(u=A)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>r&&(r=_),_<u&&(u=_)})});isFinite(r)||(r=10),isFinite(u)||(u=0),r=Math.max(r,0),u=Math.min(u,0);const p=r-u||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const m=s.showYLabels?t.measureText(r.toFixed(0)).width+14:10,y=s.showXLabels?s.axisLabelFontSize+12:8,v=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=l+m,w=c+v,M=n-m-S,I=a-v-y;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,c,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=c+12;let _=C;s.datasets.forEach((A,x)=>{const W=s._resolveColor(A.color,x),Y=A.label||"Series "+(x+1),B=7;t.beginPath(),t.roundRect(_,P-B/2,B,B,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(Y,_+B+4,P),_+=t.measureText(Y).width+B+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=u+P/k*p,A=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),A,w+I+s.axisLabelFontSize)}else{const _=r-P/k*p,A=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,A)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/f;for(let _=0;_<f;_++){const A=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,A),s.enableShadows&&(t.shadowColor=s.shadowColor));let x=C;s.datasets.forEach((W,Y)=>{const B=W.data[_]??0;if(B===0)return;const X=B/p*M,q=Math.min(s.barWidth*d+s.barGap,P-8),j=A-q/2,E=x;x+=X;const L=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,L,E,j,E+X,j),s._drawRoundedBar(t,E,j,X,q,Y===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?L:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/f;for(let _=0;_<f;_++){const A=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",A,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let x=w+I;s.datasets.forEach((W,Y)=>{const B=W.data[_]??0;if(B===0)return;const X=B/p*I,q=Math.min(s.barWidth*d+s.barGap,P-8),j=A-q/2,E=x-X;x-=X;const L=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,L,j,E,j,E+X),s._drawRoundedBar(t,j,E,q,X,Y===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?L:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/f,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),A=C+(0-u)/p*M;for(let x=0;x<f;x++){const W=w+x*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[x]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const Y=W-_/2;s.datasets.forEach((B,X)=>{const q=B.data[x]??0,j=Math.abs(q/p*M);if(j<1)return;const E=Y+X*(s.barWidth+s.barGap),L=q>=0?A:A-j,G=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,G,L,E,L+j,E),s._drawRoundedBar(t,L,E,j,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&q!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=q>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),q>=0?L+j+4:L-4,E+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/f,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),A=w+I-(0-u)/p*I;for(let x=0;x<f;x++){const W=C+x*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[x]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const Y=W-_/2;s.datasets.forEach((B,X)=>{const q=B.data[x]??0,j=Math.abs(q/p*I);if(j<1)return;const E=Y+X*(s.barWidth+s.barGap),L=q>=0?A-j:A,G=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,G,E,L,E,L+j),s._drawRoundedBar(t,E,L,s.barWidth,j,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&q!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=q>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),E+s.barWidth/2,q>=0?L-4:L+j+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var m,y;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((m=i.geometry)==null?void 0:m.width)||180,height:((y=i.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 us[this.stylePreset]||us.default},_resolveSliceColor:function(b,v){const S=b.color,C=v,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const l=s.slices.reduce((b,v)=>b+(v.value||0),0);if(l<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const c=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=c.cardBackground,t.fill(),t.strokeStyle=c.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,r=h>0?h*(s.legendFontSize+8)+10:0,u=a-r-16,f=Math.min(n-24,u)/2,d=0,p=-r/2;if(s.chartType==="rose"){const b=Math.max(...s.slices.map(C=>C.value||0)),v=Math.PI*2/s.slices.length,S=f>0?s.sliceGap/f:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/b*f,k=-Math.PI/2+w*v+S/2,T=k+v-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,p),t.arc(d,p,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),A=p+I*.65*Math.sin(P),x=Math.round(M/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,_,A),t.restore()}})}else{const b=s.chartType==="pie"?0:s.innerRadius,v=f*Math.max(0,b),S=f>0?s.sliceGap/f:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/l*Math.PI*2;return}const k=I/l*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,v<=0?(t.moveTo(d,p),t.arc(d,p,f,T,O),t.lineTo(d,p)):(t.moveTo(d+f*Math.cos(T),p+f*Math.sin(T)),t.arc(d,p,f,T,O),t.arc(d,p,v,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,A=v+(f-v)/2,x=d+A*Math.cos(_),W=p+A*Math.sin(_),Y=Math.round(I/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${Y}%`,x,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&v>14){const w=Math.round(l),M=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=c.centerTextColor,t.fillText(w.toString(),d,p-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=c.centerLabelColor,t.fillText(s.centerLabel,d,p+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,S=s.legendFontSize+8,C=a/2-r+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%b,T=Math.floor(I/b),O=w+k*v,P=C+T*S,_=s._resolveSliceColor(M,I),A=7;t.beginPath(),t.roundRect(O,P-A/2,A,A,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=c.legendColor;const x=Math.round((M.value||0)/l*100),W=`${M.label||"Item"} ${x}%`,Y=v-A-20;let B=W;for(;t.measureText(B).width>Y&&B.length>4;)B=B.slice(0,-4)+"…";t.fillText(B,O+A+4,P)})}t.restore()}renderJoystick(t,i){var p,m,y,b,v;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((p=i.geometry)==null?void 0:p.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((m=i.geometry)==null?void 0:m.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let l=i.handleX||0,c=i.handleY||0;o&&o.handleX!==void 0&&(l=o.handleX),o&&o.handleY!==void 0&&(c=o.handleY),t.save();let h=0,r=0;i.handleOrigin==="top-left"?(h=e/2,r=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,r=-s/2),t.translate(h,r),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(y=i.style)!=null&&y.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(b=i.style)!=null&&b.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(v=i.style)!=null&&v.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const u=n-a;let f=0,d=0;i.joystickType==="2D"?(f=l*u,d=c*u):i.joystickType==="1D_X"?(f=l*u,d=0):i.joystickType==="1D_Y"&&(f=0,d=c*u),t.beginPath(),t.arc(f,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,l=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,c=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,r=e.fontSize||14,u=this.getWorldTransform(t.id),f=i-u.x,d=o-u.y,p=-u.rotation*(Math.PI/180),m=Math.cos(p),y=Math.sin(p),b=f*m-d*y,v=f*y+d*m,C=8*2,w=-a/2,M=-l/2;if(c==="vertical"){const T=Math.max(C,r)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(b>=w&&b<=w+a&&v>=P&&v<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,A=C+6+_+h;if(b>=T&&b<=T+A&&v>=M&&v<=M+l)return O;T+=A}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(p=>p.data&&p.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,l=0;if(s.forEach(p=>{let m=p.data;if(p.isVarEnabled&&p.inputId){let y=this.inputs.get(p.inputId);if(y===void 0){const b=this.inputNameMap.get(p.inputId);b&&b.length>0&&(y=this.inputs.get(b[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(b=>typeof b=="number"&&!isNaN(b));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),l=Math.max(l,m.length))}p._resolvedData=m}),l<2)return;const c=a-n,h=o/(l-1),r=p=>{const m=c===0?.5:(p-n)/c;return e/2-m*e},u=p=>p*h-o/2,f=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<l;p++){const m=u(p);t.fillText(`${p+1}`,m,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),p,r(a)),t.fillText(m.toFixed(1),p,r(m)),t.fillText(n.toFixed(1),p,r(n))}const d=10;if(s.forEach(p=>{const m=p._resolvedData;if(!(!m||m.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),r(m[0])),p.smoothing&&m.length>2)for(let b=0;b<m.length-1;b++){const v=m[b===0?b:b-1],S=m[b],C=m[b+1],w=m[b+1===m.length-1?b+1:b+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(v,S,C,w,I);t.lineTo(u(b+I),r(k))}}else for(let b=1;b<m.length;b++)t.lineTo(u(b),r(m[b]));t.lineTo(u(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(i.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(u(0),r(m[0])),p.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const b=m[y===0?y:y-1],v=m[y],S=m[y+1],C=m[y+1===m.length-1?y+1:y+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(b,v,S,C,M);t.lineTo(u(y+M),r(I))}}else for(let y=1;y<m.length;y++)t.lineTo(u(y),r(m[y]));t.stroke(),p.showPoints&&m.forEach((y,b)=>{const v=u(b),S=r(y);t.beginPath(),t.arc(v,S,(p.pointSize||6)/2,0,Math.PI*2),t.fillStyle=p.pointFill||"#ffffff",t.fill(),t.strokeStyle=p.pointStrokeColor||p.lineColor||"#3b82f6",t.lineWidth=p.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const p=o/2-10;let m=-e/2+15;const y=i.legendFontSize||10,b=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(v=>{const C=v.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(p-w-8-5,m-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,p,m),m+=b})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,l=s*s,c=s*l;return(2*i-2*o+n+a)*c+(-3*i+3*o-2*n-a)*l+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const l=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[l]||l;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const l=(c,h=100)=>{var S,C;const u=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[c]||c,f=this.normalizeOpacity(i.opacity??100),p=this.normalizeOpacity(h)*f;if(p>=1&&u.startsWith("#"))return u;const m=u.startsWith("#")?u.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),b=parseInt(m.substring(2,4),16),v=parseInt(m.substring(4,6),16);return`rgba(${y}, ${b}, ${v}, ${p})`};if(i.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,h=c(i.start,0,"x")*o-o/2,r=c(i.start,1,"y")*e-e/2,u=c(i.end,0,"x")*o-o/2,f=c(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,r,u,f);if(i.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=l(p.color||"#000000",p.opacity??100);d.addColorStop(Math.max(0,Math.min(1,m)),y)}),i.gradientTransform&&d.setTransform){const[p,m,y,b,v,S]=i.gradientTransform;d.setTransform({a:p,b:m,c:y,d:b,e:v,f:S})}return d}else if(i.type==="RadialGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center,0,"x")*o-o/2,r=c(i.center,1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e),f=t.createRadialGradient(h,r,0,h,r,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return f}else if(i.type==="AngularGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,r=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.degree||i.angle||0)*(Math.PI/180),f=(a=t.createConicGradient)==null?void 0:a.call(t,u,h,r);if(f){if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return f}}else if(i.type==="DiamondGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,r=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,r),t.rotate(Math.PI/4);const f=t.createRadialGradient(0,0,0,0,0,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=f,t.restore(),f}}if(i.type==="Pattern"&&i.url){let l=this.imageCache.get(i.url);if(l||(l=new Image,l.src=i.url,this.imageCache.set(i.url,l)),l.complete&&l.naturalWidth>0){const c=t.createPattern(l,"repeat");if(c&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,r=i.scaleX??1,u=i.scaleY??1,f=i.offsetX??0,d=i.offsetY??0,p=i.rotation??0;h.translateSelf(f,d),h.rotateSelf(p),h.scaleSelf(r,u),c.setTransform(h)}return c}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let l=0,c=0,h=0,r=0;typeof a=="number"?l=c=h=r=a:Array.isArray(a)?a.length===1?l=c=h=r=a[0]:a.length===2?(l=h=a[0],c=r=a[1]):a.length===3?(l=a[0],c=r=a[1],h=a[2]):a.length>=4&&(l=a[0],c=a[1],h=a[2],r=a[3]):a&&typeof a=="object"&&(l=a.tl??a.corner_radius??a.cornerRadius??0,c=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,r=a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(l=Math.min(Math.max(0,l),u),c=Math.min(Math.max(0,c),u),h=Math.min(Math.max(0,h),u),r=Math.min(Math.max(0,r),u),t.roundRect){t.roundRect(i,o,e,s,[l,c,h,r]);return}t.moveTo(i+l,o),t.lineTo(i+e-c,o),t.arcTo(i+e,o,i+e,o+c,c),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+r,o+s),t.arcTo(i,o+s,i,o+s-r,r),t.lineTo(i,o+l),t.arcTo(i,o,i+l,o,l),t.closePath()}renderListView(t,i){var x,W,Y,B;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((x=i.geometry)==null?void 0:x.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,l=-n/2,c=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",r=e.items||[],u=e.itemGap??10,f=e.itemHeight??50,d=e.itemWidth??200,p=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((B=(Y=I.stops)==null?void 0:Y[0])==null?void 0:B.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const X=t.getTransform(),q=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor=k,t.shadowBlur=M*2*q,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const X=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",q=this.createCanvasFill(t,X,s,n);t.fillStyle=q||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.fill();const E=t.createLinearGradient(a,l,a+s,l+n);E.addColorStop(0,"rgba(255, 255, 255, 0.15)"),E.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),E.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=E,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.stroke()}else{const X=e.backgroundColor||e.listBackgroundColor||"transparent",q=this.createCanvasFill(t,X,s,n);if(q){t.fillStyle=q,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);t.fill()}const j=e.borderWidth??0;if(j>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=j,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const X=new Path2D(e.containerPath);t.translate(a,l),t.scale(s/100,n/100),t.clip(X),t.scale(100/s,100/n),t.translate(-a,-l)}catch{}else t.clip();const P=typeof m=="number"?m:h==="vertical"?m[0]:m[3];let _=(h==="vertical"?l:a)+p+P;if(t.textBaseline="middle",r.forEach((X,q)=>{const j=e.listLayout||"linear",E=j==="circular"?d:h==="vertical"?s:d,L=j==="circular"||h==="vertical"?f:n;let G=0,z=0,it=0;if(j==="circular"){const Tt=r.length||1,zt=Math.PI*2/Tt,et=e.circularStartAngle||0,yt=e.circularRadius||100,Ot=p*.01+et*Math.PI/180,gt=q*zt+Ot,Mt=a+s/2,Ft=l+n/2;G=Mt+Math.cos(gt)*yt-E/2,z=Ft+Math.sin(gt)*yt-L/2,it=gt+(e.itemRotation||0)*Math.PI/180}else G=h==="vertical"?a:_,z=h==="vertical"?_:l,it=(e.itemRotation||0)*Math.PI/180;const F=C===q,$=w===q,V=$&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",tt=$&&e.activeItemShape?e.activeItemPath:e.itemPath||"",rt=e.itemCornerRadius||0;if(t.save(),it!==0&&(t.translate(G+E/2,z+L/2),t.rotate(it),t.translate(-(G+E/2),-(z+L/2))),$){const Tt=this.createCanvasFill(t,b,E,L);t.fillStyle=Tt||b;const zt=t.globalAlpha;t.globalAlpha=zt*.8,t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill()),t.globalAlpha=zt}else if(F)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill());else if(S!=="transparent"){const Tt=this.createCanvasFill(t,S,E,L);t.fillStyle=Tt||S,t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill())}if($||F){const Tt=this.createCanvasFill(t,b,h==="vertical"?3:E,h==="vertical"?L:3);t.fillStyle=Tt||b,h==="vertical"?t.fillRect(G,z,3,L):t.fillRect(G,z+L-3,E,3)}const mt=$?"#ffffff":y?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=mt,t.font=$||F?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ct=typeof X=="string"?X:(X==null?void 0:X.label)||`Item ${q+1}`,ct=G+(h==="vertical"?16:E/2),Pt=z+L/2;h==="horizontal"||j==="circular"?t.textAlign="center":t.textAlign="left";const kt=j==="circular"?G+E/2:ct;t.fillText(Ct,kt,Pt),t.restore(),_+=(h==="vertical"?f:d)+u}),t.restore(),e.showScrollbar!==!1){const X=(r.length||0)*(h==="vertical"?f:d)+((r.length||0)-1)*u,q=h==="vertical"?n:s,j=e.listLayout||"linear",E=e.containerShape==="circle"||j==="circular";if(X>q||j==="circular"&&r.length>0){const L=e.scrollbarColor||"rgba(255,255,255,0.3)",G=e.scrollbarWidth||4;if(E){const z=Math.min(s,n)/2-G/2-2,it=a+s/2,F=l+n/2;if(t.strokeStyle=L,t.lineWidth=G,t.lineCap="round",t.beginPath(),j==="circular"){const $=Math.PI/4,V=-(p*.01)-Math.PI/2;t.arc(it,F,z,V,V+$)}else{const $=Math.PI/2,V=q/X,tt=$*V,rt=-p/X*$,Ct=-Math.PI/4+rt;t.arc(it,F,z,Ct,Ct+tt)}t.stroke()}else{const z=q/X,it=q*z,F=-p/X*q;t.fillStyle=L,h==="vertical"?t.fillRect(a+s-G-2,l+F,G,it):t.fillRect(a+F,l+n-G-2,it,G)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,l){if(i==="circle"){const c=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,c,0,Math.PI*2),!1}else if(i==="pill"){const c=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,c),!1}else if(i==="custom"&&o)try{const c=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(c),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,l),!1}return this.drawListViewRect(t,e,s,n,a,l),!1}updateListViewScrollFromPointer(t){var y,b;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},l=i.items||[],c=i.itemGap??10,h=i.itemHeight??50,r=i.itemWidth??200,u=a.width!==void 0?a.width:((y=t.geometry)==null?void 0:y.width)||200,f=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const d=(l.length||0)*(o==="vertical"?h:r)+((l.length||0)-1)*c,m=Math.max(0,d-(o==="vertical"?f:u)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-m&&(i.scrollOffset=-m)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var Y,B;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((Y=t.geometry)==null?void 0:Y.width)||200,l=s.height!==void 0?s.height:((B=t.geometry)==null?void 0:B.height)||300,c=e.orientation||"vertical",h=e.itemGap??10,r=e.itemHeight??50,u=e.itemWidth??200,f=e.scrollOffset??0,d=e.padding??0,p=this.getWorldTransform(t.id),m=i-p.x,y=o-p.y,b=-p.rotation*(Math.PI/180),v=Math.cos(b),S=Math.sin(b),C=m*v-y*S,w=m*S+y*v,M=-a/2,I=-l/2,k=typeof d=="number"?d:c==="vertical"?d[0]:d[3];let T=(c==="vertical"?I:M)+f+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,A=e.circularStartAngle||0,x=e.circularRadius||100,W=f*.01+A*Math.PI/180;for(let X=0;X<n.length;X++){const q=O==="circular"?u:c==="vertical"?a:u,j=O==="circular"||c==="vertical"?r:l;let E=0,L=0,G=0;if(O==="circular"){const z=X*_+W,it=M+a/2,F=I+l/2;E=it+Math.cos(z)*x-q/2,L=F+Math.sin(z)*x-j/2,G=z+(e.itemRotation||0)*Math.PI/180}else E=c==="vertical"?M:T,L=c==="vertical"?T:I,G=(e.itemRotation||0)*Math.PI/180;if(G!==0){const z=E+q/2,it=L+j/2,F=C-z,$=w-it,V=-G,tt=F*Math.cos(V)-$*Math.sin(V)+z,rt=F*Math.sin(V)+$*Math.cos(V)+it;if(tt>=E&&tt<=E+q&&rt>=L&&rt<=L+j)return X}else if(C>=E&&C<=E+q&&w>=L&&w<=L+j)return X;T+=(c==="vertical"?r:u)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var u,f,d,p,m,y,b,v,S,C,w,M,I,k,T,O,P,_,A,x,W,Y,B,X,q,j,E,L,G,z,it,F,$,V,tt,rt,mt,Ct,ct,Pt,kt,Tt,zt,et,yt,Ot,gt,Mt,Ft,Vt,Yt,Ht,Kt,ie,ye,me,te,ve,Te,Se,we,_e,ce,ne,ft,bt,st,H,N,ot,vt,xt,It,Wt,St,R,Rt,se,Ut,de,Lt,ut,dt,nt,pt,D,at,Q,$t,Jt,oe,Gt,Qt,qt,Me,Pe,Ee,Ae,xe,Oe,Be,Nt,ae,Ce,Le,Fe,ue,fe,he,Ie,We,Ne,He,Ye,Ue,qe,gs,ys;if(!n.enabled)return;const a=n.startTime||0,l=n.endTime||1/0;if(this.currentTime<a||this.currentTime>l)return;const c=s.x-i,h=s.y-o,r=Math.sqrt(c*c+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===U.Proximity){const K=((u=n.settings)==null?void 0:u.radius)||300,Z=((f=n.settings)==null?void 0:f.falloff)||"smooth";let J=0;r<K&&(Z==="linear"?J=1-r/K:J=Math.pow(1-r/K,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,J,t,n.settings,e,c,h,r)})}else if(n.type===U.Magnetic){const K=((d=n.settings)==null?void 0:d.radius)||400,Z=((p=n.settings)==null?void 0:p.strength)||.5;if(r<K&&r>5){const J=1-r/K,ht=c*J*Z,_t=h*J*Z;s.x-=ht*t*10,s.y-=_t*t*10}}else if(n.type===U.Repel){const K=((m=n.settings)==null?void 0:m.radius)||300,Z=((y=n.settings)==null?void 0:y.strength)||1;if(r<K){const J=Math.pow(1-r/K,2);s.x+=c/(r||1)*J*60*Z*t*5,s.y+=h/(r||1)*J*60*Z*t*5}}else if(n.type===U.Orbit){const K=((b=n.settings)==null?void 0:b.speed)||1,Z=((v=n.settings)==null?void 0:v.radius)||30,J=this.currentTime*K*Math.PI*2;s.x+=Math.cos(J)*Z*t*5,s.y+=Math.sin(J)*Z*t*5,s.rotation+=2*t*5}else if(n.type===U.Vortex){const K=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,J=((w=n.settings)==null?void 0:w.strength)||1;if(r<K){const ht=Math.pow(1-r/K,1.5),_t=this.currentTime*Z*Math.PI*2,At=Math.cos(_t)*30-c*.4,Bt=Math.sin(_t)*30-h*.4;s.x+=At*ht*J*t*5,s.y+=Bt*ht*J*t*5,s.rotation+=5*ht*J*t*5,s.scale_x*=1-ht*.1*J*t,s.scale_y*=1-ht*.1*J*t}}else if(n.type===U.Fluid){const K=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(r<K){const J=Math.pow(1-r/K,1.2),ht=c/(r||1)*J*1.2*Z,_t=h/(r||1)*J*1.2*Z;s.x+=ht*10*t*5,s.y+=_t*10*t*5,s.scale_x*=1+J*.3*Z*t,s.scale_y*=1+J*.3*Z*t}}else if(n.type===U.Elastic){const K=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(r<K){const J=1-r/K;s.scale_x*=1+J*.4*Z*t,s.scale_y*=1+J*.4*Z*t}}else if(n.type===U.Holographic){const K=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,J=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=K/1e3*J*t*5,s.y-=Z/1e3*J*t*5,s.style){const ht=1-Math.min(1,r/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===U.Sticky){const K=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(r<K){const J=Math.pow(1-r/K,2);s.x-=c*J*Z*t*10,s.y-=h*J*Z*t*10,s.scale_x*=1-J*.1*Z*t,s.scale_y*=1-J*.1*Z*t}}else if(n.type===U.Dilation){const K=((A=n.settings)==null?void 0:A.size)||120,Z=((x=n.settings)==null?void 0:x.strength)||1;if(r<K){const J=1-r/K;s.scale_x*=1+J*.5*Z*t,s.scale_y*=1+J*.5*Z*t}}else if(n.type===U.Parallax){const K=((W=n.settings)==null?void 0:W.factor)||15,Z=((Y=n.settings)==null?void 0:Y.strength)||1,J=this.canvasWidth/2,ht=this.canvasHeight/2,_t=this._lastPointerPos||{x:J,y:ht},At=(_t.x-J)/J,Bt=(_t.y-ht)/ht,ee=(((B=e.transform)==null?void 0:B.x)??0)+At*K*Z,pe=(((X=e.transform)==null?void 0:X.y)??0)+Bt*K*Z,ke=(((q=e.transform)==null?void 0:q.rotate_x)??0)-Bt*K*1.5*Z,re=(((j=e.transform)==null?void 0:j.rotate_y)??0)+At*K*1.5*Z,be=Math.min(1,10*t);s.x=this.lerp(s.x??((E=e.transform)==null?void 0:E.x)??0,ee,be),s.y=this.lerp(s.y??((L=e.transform)==null?void 0:L.y)??0,pe,be),s.rotate_x=this.lerp(s.rotate_x??((G=e.transform)==null?void 0:G.rotate_x)??0,ke,be),s.rotate_y=this.lerp(s.rotate_y??((z=e.transform)==null?void 0:z.rotate_y)??0,re,be)}else if(n.type===U.Fold){if(r<300){const K=1-r/300,Z=(c>0?-1:1)*K*10,J=1-K*.1,ht=h/300*K*20,_t=-(c/300)*K*20,At=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((it=e.transform)==null?void 0:it.skew_x)??0,Z,At),s.scale_y=this.lerp(s.scale_y??((F=e.transform)==null?void 0:F.scale_y)??1,((($=e.transform)==null?void 0:$.scale_y)??1)*J,At),s.rotate_x=this.lerp(s.rotate_x??((V=e.transform)==null?void 0:V.rotate_x)??0,ht,At),s.rotate_y=this.lerp(s.rotate_y??((tt=e.transform)==null?void 0:tt.rotate_y)??0,_t,At),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((rt=n.settings)==null?void 0:rt.opacity)??.5}}}else if(n.type===U.Crumple){if(r<300){const K=1-r/300,Z=K*(Math.random()-.5)*5,J=K*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((mt=e.transform)==null?void 0:mt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((Ct=e.transform)==null?void 0:Ct.scale_x)??1,(((ct=e.transform)==null?void 0:ct.scale_x)??1)*(1+J),ht),s.scale_y=this.lerp(s.scale_y??((Pt=e.transform)==null?void 0:Pt.scale_y)??1,(((kt=e.transform)==null?void 0:kt.scale_y)??1)*(1+J),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((Tt=n.settings)==null?void 0:Tt.intensity)??1,scale:((zt=n.settings)==null?void 0:zt.scale)??2}}}else if(n.type===U.Squash){const K=((et=n.settings)==null?void 0:et.strength)||.8;r<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((yt=e.transform)==null?void 0:yt.scale_y)??1)*K,.3),s.scale_x=this.lerp(s.scale_x??1,(((Ot=e.transform)==null?void 0:Ot.scale_x)??1)*(1+(1-K)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((gt=e.transform)==null?void 0:gt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Mt=e.transform)==null?void 0:Mt.scale_x)??1,.2))}else if(n.type===U.TextCounter){const K=((Ft=n.settings)==null?void 0:Ft.duration)||2,Z=((Vt=n.settings)==null?void 0:Vt.from)||0,J=((Yt=n.settings)==null?void 0:Yt.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,_t=Math.min(1,ht/K),At=Math.floor(Z+(J-Z)*_t);if(((Ht=e.geometry)==null?void 0:Ht.type)==="Text"){const Bt=((Kt=n.settings)==null?void 0:Kt.prefix)||"",ee=((ie=n.settings)==null?void 0:ie.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Bt}${At}${ee}`}}else if(n.type===U.Spotlight){const K=((ye=n.settings)==null?void 0:ye.radius)||250,Z=((me=n.settings)==null?void 0:me.strength)||1.5;if(r<K){const J=Math.pow(1-r/K,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(te=e.style)==null?void 0:te.adjustments}),s.style.adjustments.exposure=(((Te=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Te.exposure)||0)+J*Z*50}else(Se=s.style)!=null&&Se.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((_e=(we=e.style)==null?void 0:we.adjustments)==null?void 0:_e.exposure)||0,.1))}else if(n.type===U.Noise||n.type===U.Float){const K=(((ce=n.settings)==null?void 0:ce.frequency)||((ne=n.settings)==null?void 0:ne.speed)||1)*.002,Z=(((ft=n.settings)==null?void 0:ft.amplitude)||((bt=n.settings)==null?void 0:bt.range)||50)*(((st=n.settings)==null?void 0:st.strength)||1),J=Date.now();s.x+=Math.sin(J*K)*Z*t,s.y+=Math.cos(J*K*.8)*Z*t,s.rotation+=Math.sin(J*K*.5)*5*t}else if(n.type===U.Pulse){const K=(((H=n.settings)==null?void 0:H.speed)||1)*.005,Z=(((N=n.settings)==null?void 0:N.scale)||1.2)-1,J=Math.sin(Date.now()*K),ht=((ot=n.settings)==null?void 0:ot.strength)||1;s.scale_x*=1+J*Z*ht*t,s.scale_y*=1+J*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,J)*.1*ht*t)}else if(n.type===U.Draggable){const K=((vt=n.settings)==null?void 0:vt.radius)||150,Z=this.draggingBehaviors.has(e.id);if(r<K||Z){const J=((xt=n.settings)==null?void 0:xt.strength)||1,ht=Z?1:Math.max(0,1-r/K);this.applyBehaviorSensor(s,jt.PositionX,ht*J,t,n.settings),this.applyBehaviorSensor(s,jt.PositionY,ht*J,t,n.settings)}}else if(n.type===U.Scroll){const K=((It=n.settings)==null?void 0:It.axis)||"vertical",Z=((Wt=n.settings)==null?void 0:Wt.factor)||.5,J=((St=n.settings)==null?void 0:St.strength)||1,ht=((R=n.settings)==null?void 0:R.scaleFactor)||0;(K==="vertical"||K==="both")&&(s.y+=this.scrollOffset.y*Z*J*t),(K==="horizontal"||K==="both")&&(s.x+=this.scrollOffset.x*Z*J*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===U.LookAt){const K=((Rt=n.settings)==null?void 0:Rt.factor)||1,Z=((se=n.settings)==null?void 0:se.strength)||1,J=Math.atan2(-h,-c)*(180/Math.PI),ht=s.rotation,_t=(J-ht+180)%360-180;s.rotation+=_t*K*Z*t*10}else if(n.type===U.Scan){const K=(((Ut=n.settings)==null?void 0:Ut.speed)||1)*.004,Z=((de=n.settings)==null?void 0:de.strength)||1,J=(Math.sin(Date.now()*K)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+J*Z*t*5),s.x+=(J-.5)*20*Z*t}else if(n.type===U.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Lt=n.settings)==null?void 0:Lt.strength)??.8};else if(n.type===U.Ratchet){const K=((ut=n.settings)==null?void 0:ut.steps)||12,Z=(((dt=n.settings)==null?void 0:dt.speed)||1)*30,J=Math.floor(s.rotation/(360/K))*(360/K);s.rotation=this.lerp(s.rotation,J+Z*t,.1)}else if(n.type===U.Jitter&&r<300){const K=((nt=n.settings)==null?void 0:nt.strength)||1,Z=(((pt=n.settings)==null?void 0:pt.intensity)||5)*K;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===U.Follower){const K=(D=n.settings)==null?void 0:D.targetId;if(K){const Z=this.objectStates.get(K);if(Z){const J=((at=n.settings)==null?void 0:at.stiffness)||.1,ht=Z.x-s.x,_t=Z.y-s.y;s.x+=ht*J*t*60,s.y+=_t*J*t*60}}}else if(n.type===U.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===U.Gravity){const K=((Q=n.settings)==null?void 0:Q.strength)||9.8;s.y+=K*t*10}else if(n.type===U.Velocity){const K=(($t=n.settings)==null?void 0:$t.vx)||0,Z=((Jt=n.settings)==null?void 0:Jt.vy)||0;s.x+=K*t*10,s.y+=Z*t*10}else if(n.type===U.Shear){const K=((oe=n.settings)==null?void 0:oe.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(r<Z){const J=1-r/Z;s.skew_x=this.lerp(s.skew_x||0,(((Qt=e.transform)==null?void 0:Qt.skew_x)||0)+J*K*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((qt=e.transform)==null?void 0:qt.skew_x)||0,.05)}else if(n.type===U.Lens){const K=((Me=n.settings)==null?void 0:Me.radius)||200,Z=((Pe=n.settings)==null?void 0:Pe.strength)||.5;if(r<K){const J=Math.pow(1-r/K,2);s.scale_x=this.lerp(s.scale_x??1,(((Ee=e.transform)==null?void 0:Ee.scale_x)??1)*(1+J*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ae=e.transform)==null?void 0:Ae.scale_y)??1)*(1+J*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===U.LayoutAnimation){const K=((Be=n.settings)==null?void 0:Be.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Nt=n.settings)==null?void 0:Nt.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const J=this._layoutAnimCache.get(e.id);for(const ht of K){const _t=this.getObjectProperty(s,e,ht);if(_t===void 0)continue;const At=J.get(ht);if(!At)J.set(ht,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(At.to!==_t){const ee=this.getObjectProperty(s,e,ht);J.set(ht,{from:ee??At.from,to:_t,startTime:this.currentTime,duration:((ae=n.settings)==null?void 0:ae.duration)??Z})}const Bt=J.get(ht);if(Bt.duration>0&&Bt.from!==Bt.to){const ee=this.currentTime-Bt.startTime,pe=Math.min(1,ee/Bt.duration),ke=this.applyEasing(pe,((Ce=n.settings)==null?void 0:Ce.easing)||"easeOutCubic"),re=Bt.from+(Bt.to-Bt.from)*ke;this.setObjectProperty(s,e,ht,re)}}}else if(n.type===U.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id),Z=((Le=n.settings)==null?void 0:Le.defaultDuration)||.3,J=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of J){const _t=this.getObjectProperty(s,e,ht);if(_t===void 0||typeof _t!="number")continue;const At=K.get(ht);if(!At)K.set(ht,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(At.to!==_t){const ee=this.getObjectProperty(s,e,ht);K.set(ht,{from:ee??At.from,to:_t,startTime:this.currentTime,duration:Z})}const Bt=K.get(ht);if(Bt.duration>0&&Bt.from!==Bt.to){const ee=this.currentTime-Bt.startTime,pe=Math.min(1,ee/Bt.duration),ke=this.applyEasing(pe,((Fe=n.settings)==null?void 0:Fe.defaultEasing)||"easeOutCubic"),re=Bt.from+(Bt.to-Bt.from)*ke;this.setObjectProperty(s,e,ht,re)}}}else if(n.type===U.SpringChain){const K=((ue=n.settings)==null?void 0:ue.connections)||[],Z=((fe=n.settings)==null?void 0:fe.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const J=this._springChainState.get(e.id);for(const _t of K){if(!J.has(_t.targetId)){const At=this.objectStates.get(_t.targetId);J.set(_t.targetId,{x:(At==null?void 0:At.x)??0,y:(At==null?void 0:At.y)??0,vx:0,vy:0})}J.has(e.id)||J.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=J.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const _t of K){const At=J.get(_t.targetId);if(!At)continue;const Bt=At.x-ht.x,ee=At.y-ht.y,pe=Math.sqrt(Bt*Bt+ee*ee)||.001,re=(pe-(_t.restLength||50))*(_t.stiffness||.8),be=Bt/pe*re,Ke=ee/pe*re;ht.vx+=be*t*10,ht.vy+=Ke*t*10,At.vx-=be*t*10,At.vy-=Ke*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,At.vx*=1-Z*t*10,At.vy*=1-Z*t*10;const ge=this.objectStates.get(_t.targetId);ge&&(ge.x+=At.vx*t,ge.y+=At.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===U.ParticleEmitter){const K=((he=n.settings)==null?void 0:he.rate)||10,Z=((Ie=n.settings)==null?void 0:Ie.speed)||100,J=((We=n.settings)==null?void 0:We.size)||5,ht=((Ne=n.settings)==null?void 0:Ne.lifetime)||2,_t=((He=n.settings)==null?void 0:He.gravity)||0,At=((Ye=n.settings)==null?void 0:Ye.color)||"#ffffff",Bt=((Ue=n.settings)==null?void 0:Ue.maxParticles)||200,ee=(qe=n.settings)!=null&&qe.rateInputId?this.inputs.get(n.settings.rateInputId)??K:K,pe=(gs=n.settings)!=null&&gs.gravityInputId?this.inputs.get(n.settings.gravityInputId)??_t:_t,ke=(ys=n.settings)!=null&&ys.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const re=this._emitterPools.get(e.id);let be=0;n._pendingBurst&&n._pendingBurst>0&&(be=n._pendingBurst,n._pendingBurst=0);const Ke=Math.floor(ee*t)+(be||0);for(let ge=0;ge<Math.min(Ke,Bt-re.length);ge++){const le=Math.random()*Math.PI*2,ms=ke*(.5+Math.random()*.5);re.push({x:s.x,y:s.y,vx:Math.cos(le)*ms,vy:Math.sin(le)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:J*(.5+Math.random()),color:At,opacity:1})}for(let ge=re.length-1;ge>=0;ge--){const le=re[ge];le.vy+=pe*t*10,le.x+=le.vx*t,le.y+=le.vy*t,le.life+=t,le.opacity=Math.max(0,1-le.life/le.maxLife),le.life>=le.maxLife&&re.splice(ge,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,l=0,c=1){var d,p,m,y,b,v,S,C,w,M,I,k,T,O,P,_,A,x,W,Y,B,X,q,j;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,r=Math.min(1,15*e),u=c>0?a/c:0,f=c>0?l/c:0;switch(i){case jt.Scale:{const E=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,L=((p=n==null?void 0:n.transform)==null?void 0:p.scale_y)??1,G=E*(1+o*h*.4),z=L*(1+o*h*.4);t.scale_x=(t.scale_x??E)*(1-r)+G*r,t.scale_y=(t.scale_y??L)*(1-r)+z*r;break}case jt.Opacity:{const E=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,L=Math.max(0,Math.min(100,E-o*h*100));t.opacity=(t.opacity??E)*(1-r)+L*r;break}case jt.RotateZ:{const E=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,L=E+o*h*45;t.rotation=(t.rotation??E)*(1-r)+L*r;break}case jt.RotateX:{const E=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,L=E-f*o*h*60;t.rotate_x=(t.rotate_x??E)*(1-r)+L*r;break}case jt.RotateY:{const E=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,L=E+u*o*h*60;t.rotate_y=(t.rotate_y??E)*(1-r)+L*r;break}case jt.PositionX:{const E=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,L=E-u*o*h*40;t.x=(t.x??E)*(1-r)+L*r;break}case jt.PositionY:{const E=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,L=E-f*o*h*40;t.y=(t.y??E)*(1-r)+L*r;break}case jt.SkewX:{const E=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,L=E+u*o*h*45;t.skew_x=(t.skew_x??E)*(1-r)+L*r,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={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const E=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,L=E+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??E)*(1-r)+L*r;break}case jt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const E=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,L=E+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??E)*(1-r)+L*r;break}case jt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const E=((x=(A=n==null?void 0:n.style)==null?void 0:A.adjustments)==null?void 0:x.hue)||0,L=E+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??E)*(1-r)+L*r;break}case jt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const E=((B=(Y=n==null?void 0:n.style)==null?void 0:Y.adjustments)==null?void 0:B.negative)||0,L=E+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??E)*(1-r)+L*r;break}case jt.CornerRadius:{const E=((X=n==null?void 0:n.transform)==null?void 0:X.corner_radius)||0,L=E+o*h*50;t.corner_radius=(t.corner_radius??E)*(1-r)+L*r;break}case jt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const E=((q=n==null?void 0:n.style)==null?void 0:q.borderWidth)||0,L=E+o*h*10;t.style.borderWidth=(t.style.borderWidth??E)*(1-r)+L*r;break}case jt.LetterSpacing:{t.geometry||(t.geometry={});const E=((j=n==null?void 0:n.geometry)==null?void 0:j.letterSpacing)||0,L=E+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??E)*(1-r)+L*r;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let l=0;l<s.length-1;l++){const c=s[l];if(n[c]===void 0||n[c]===null){const h=i,r=s.slice(0,l+1).reduce((u,f)=>u==null?void 0:u[f],h);n[c]=r!==void 0?{...r}:{}}n=n[c]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const l=i.naturalWidth,c=i.naturalHeight,h=l/c,r=s/n;let u=s,f=n,d=o,p=e;a==="cover"?h>r?(u=n*h,d=o-(u-s)/2):(f=s/h,p=e-(f-n)/2):a==="contain"&&(h>r?(f=s/h,p=e+(n-f)/2):(u=n*h,d=o+(s-u)/2)),t.drawImage(i,d,p,u,f)}}const ni=Et.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:l,onComponentChange:c,onToggle:h,onInputChange:r,onInputFocus:u,onInputBlur:f,onLog:d,onLogicUpdate:p,onButtonClick:m,onGraphPointClick:y,currentTime:b,revision:v=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=Et.useRef(null),A=Et.useRef(null);A.current||(A.current=new ps);const x=Et.useRef(void 0),W=Et.useRef(0),Y=Et.useRef(null),B=Et.useRef(v),X=Et.useRef(null),[,q]=Et.useState(g||null),j=Et.useRef(!0);Et.useImperativeHandle(P,()=>_.current),Et.useEffect(()=>(j.current=!0,()=>{j.current=!1,x.current&&cancelAnimationFrame(x.current)}),[]),Et.useEffect(()=>{A.current.setLayout(e,s)},[e,s]),Et.useEffect(()=>{const F=A.current;a&&F.setTriggerCallback(a),l&&F.setInputUpdateCallback(($,V)=>l({[$]:V})),c&&F.setComponentChangeCallback($=>c($)),h&&F.setToggleCallback(h),r&&F.setInputChangeCallback(r),u&&F.setInputFocusCallback(u),f&&F.setInputBlurCallback(f),d&&F.setOnLogCallback($=>d($,"info")),p&&F.setLogicUpdateCallback(p),m&&F.setButtonClickCallback(m),y&&F.setGraphPointClickCallback($=>y($.objectId,$)),O&&F.setNavigationCallback(O)},[a,l,c,h,r,u,f,d,p,m,y,O]),Et.useEffect(()=>{(async()=>{let $=g;if(t&&!g)try{t.startsWith("{")?$=JSON.parse(t):$=await(await fetch(t)).json()}catch(V){console.error("[ExodeUI] Failed to load src:",V)}if($){const V=A.current,tt=$.id||$.name||"default";(Y.current!==tt||B.current!==v||X.current!==$)&&(V.load($),Y.current=tt,B.current=v,X.current=$,q($),W.current=0,V.advance(0)),n&&n(V)}})()},[g,t,v]),Et.useEffect(()=>{const F=$=>{if(!A.current||!j.current)return;const V=A.current,tt=_.current;if(!tt)return;const rt=tt.getContext("2d");if(!rt)return;const mt=$/1e3;W.current===0&&(W.current=mt);let Ct=mt-W.current;Ct>.1&&(Ct=.1),W.current=mt;const ct=tt.getBoundingClientRect(),Pt=window.devicePixelRatio||1,kt=Math.round(ct.width*Pt),Tt=Math.round(ct.height*Pt);(tt.width!==kt||tt.height!==Tt)&&(tt.width=kt,tt.height=Tt);try{o?V.advance(Ct):b!==void 0&&V.seek(b),V.render(rt,tt.width,tt.height)}catch(zt){console.error("[ExodeUICanvas] Error in animation loop:",zt),d&&d(`[Error] Animation loop crashed: ${zt}`,"error")}x.current=requestAnimationFrame(F)};return x.current=requestAnimationFrame(F),()=>{x.current&&cancelAnimationFrame(x.current)}},[o,b]),Et.useEffect(()=>{const F=A.current;S!==void 0&&F.updateInput("scrollY",S),C!==void 0&&F.updateInput("scrollX",C),w!==void 0&&F.updateInput("mouseX",w),M!==void 0&&F.updateInput("mouseY",M),I!==void 0&&F.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([$,V])=>F.updateInput($,V))},[S,C,w,M,I,k]);const E=(F,$)=>{if(!T||!_.current)return;F.stopPropagation(),"nativeEvent"in F&&F.nativeEvent&&typeof F.nativeEvent.stopImmediatePropagation=="function"?F.nativeEvent.stopImmediatePropagation():typeof F.stopImmediatePropagation=="function"&&F.stopImmediatePropagation();const V=_.current,tt=V.getBoundingClientRect(),rt=F.clientX-tt.left,mt=F.clientY-tt.top,Ct=window.devicePixelRatio||1;($==="click"||$==="down"||$==="up")&&d&&d(`[Canvas] Pointer ${$} at rect(${Math.round(rt)},${Math.round(mt)}) mapped to buffer(${Math.round(rt*Ct)},${Math.round(mt*Ct)})`,"info"),A.current.handlePointerInput($,rt*Ct,mt*Ct,V.width,V.height)};Et.useEffect(()=>{if(!T)return;const F=V=>{var tt,rt,mt;((tt=document.activeElement)==null?void 0:tt.tagName)==="INPUT"||((rt=document.activeElement)==null?void 0:rt.tagName)==="TEXTAREA"||(mt=A.current)==null||mt.handleKeyDown(V)},$=V=>{var tt,rt,mt;((tt=document.activeElement)==null?void 0:tt.tagName)==="INPUT"||((rt=document.activeElement)==null?void 0:rt.tagName)==="TEXTAREA"||(mt=A.current)==null||mt.handleKeyUp(V)};return window.addEventListener("keydown",F),window.addEventListener("keyup",$),()=>{window.removeEventListener("keydown",F),window.removeEventListener("keyup",$)}},[T]);const[L,G]=Et.useState([]);Et.useEffect(()=>{if(g&&g.objects){const F=g.objects.filter($=>{var V,tt;return $.type==="Joystick"&&((V=$.inputBinding)==null?void 0:V.type)==="keyboard"&&((tt=$.inputBinding.keyboardConfig)==null?void 0:tt.showVirtualKeyboard)});G(F)}},[g]);const[,z]=Et.useState(0);Et.useEffect(()=>{if(L.length===0)return;let F;const $=()=>{z(V=>V+1),F=requestAnimationFrame($)};return F=requestAnimationFrame($),()=>cancelAnimationFrame(F)},[L.length]);const it=()=>L.map(F=>{const $=F.inputBinding.keyboardConfig,V=ct=>{var kt;const Pt={key:ct,code:ct,preventDefault:()=>{}};(kt=A.current)==null||kt.handleKeyDown(Pt)},tt=ct=>{var kt;const Pt={key:ct,code:ct,preventDefault:()=>{}};(kt=A.current)==null||kt.handleKeyUp(Pt)},rt=A.current,mt=ct=>rt&&rt.activeKeys?rt.activeKeys.has(ct.toLowerCase()):!1,Ct=ct=>({width:"50px",height:"50px",background:ct?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:ct?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:Ct(mt($.upKey)),onMouseDown:()=>V($.upKey),onMouseUp:()=>tt($.upKey),onMouseLeave:()=>tt($.upKey),onTouchStart:ct=>{ct.preventDefault(),V($.upKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.upKey)},children:$.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:Ct(mt($.leftKey)),onMouseDown:()=>V($.leftKey),onMouseUp:()=>tt($.leftKey),onMouseLeave:()=>tt($.leftKey),onTouchStart:ct=>{ct.preventDefault(),V($.leftKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.leftKey)},children:$.leftKey.toUpperCase()}),Xt.jsx("div",{style:Ct(mt($.downKey)),onMouseDown:()=>V($.downKey),onMouseUp:()=>tt($.downKey),onMouseLeave:()=>tt($.downKey),onTouchStart:ct=>{ct.preventDefault(),V($.downKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.downKey)},children:$.downKey.toUpperCase()}),Xt.jsx("div",{style:Ct(mt($.rightKey)),onMouseDown:()=>V($.rightKey),onMouseUp:()=>tt($.rightKey),onMouseLeave:()=>tt($.rightKey),onTouchStart:ct=>{ct.preventDefault(),V($.rightKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.rightKey)},children:$.rightKey.toUpperCase()})]})]},F.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:F=>{var $;E(F,"down"),($=_.current)==null||$.focus()},onPointerMove:F=>E(F,"move"),onPointerUp:F=>E(F,"up"),onPointerCancel:F=>E(F,"up"),onClick:F=>E(F,"click"),onWheel:F=>{A.current.handleWheel(F.deltaX,F.deltaY)},onKeyDown:F=>A.current.handleKeyDown(F.nativeEvent),onKeyUp:F=>A.current.handleKeyUp(F.nativeEvent),onContextMenu:F=>F.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),it()]})});function oi(){const[g,t]=Et.useState(null),i=Et.useCallback((r,u)=>{g==null||g.setInputBool(r,u)},[g]),o=Et.useCallback((r,u)=>{g==null||g.setInputNumber(r,u)},[g]),e=Et.useCallback(r=>{g==null||g.fireTrigger(r)},[g]),s=Et.useCallback((r,u)=>{g==null||g.setInputText(r,u)},[g]),n=Et.useCallback((r,u)=>{g==null||g.setInputNumberArray(r,u)},[g]),a=Et.useCallback((r,u)=>{g==null||g.setInputStringArray(r,u)},[g]),l=Et.useCallback((r,u)=>{g==null||g.updateObjectOptions(r,u)},[g]),c=Et.useCallback((r,u,f)=>{g==null||g.updateConstraint(r,u,f)},[g]),h=Et.useCallback((r,u)=>{g==null||g.updateGraphData(r,u)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:c,updateGraphData:h,updateObjectOptions:l}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;Et.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let l=i.description;if(!l&&o){const r=g.objects.filter(u=>{var f;return((f=u.geometry)==null?void 0:f.type)==="Text"}).sort((u,f)=>{var d,p;return(((d=f.geometry.text)==null?void 0:d.length)||0)-(((p=u.geometry.text)==null?void 0:p.length)||0)});r.length>0&&(l=r[0].geometry.text)}l&&(e("name","description",l),e("property","og:description",l)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const c=i.ogImage||g.backgroundImage;c&&e("property","og:image",c),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,l,c)=>{let h=document.querySelector(`meta[${a}="${l}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,l),document.head.appendChild(h)),h.setAttribute("content",c)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((c,h)=>{var r,u;if(!(c.visible===!1||c.isVisible===!1))if(((r=c.geometry)==null?void 0:r.type)==="Text"){const f=c.geometry.text;f&&(c.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:f},c.id||h)):a.push(Xt.jsx("p",{children:f},c.id||h)))}else if(((u=c.geometry)==null?void 0:u.type)==="Image"){const f=c.geometry.src,d=c.altText||c.name||"Illustration";a.push(Xt.jsx("img",{src:f,alt:d},c.id||h))}else c.type==="Button"&&a.push(Xt.jsx("button",{children:c.name||"Button"},c.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.33"}.version;Dt.BehaviorSensor=jt,Dt.BehaviorType=U,Dt.ConditionOp=Qe,Dt.ExodeSEO=ai,Dt.ExodeUICanvas=ni,Dt.ExodeUIEngine=ps,Dt.LogicOp=wt,Dt.RapierPhysics=es,Dt.VERSION=ri,Dt.useExodeUI=oi,Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"})}));
33
+ `&&gt++)}),t.globalAlpha=yt}}}applyStrokeAlignment(t,i,o,e,s,n){if(!i.stroke||i.stroke.width<=0||i.stroke.isEnabled===!1)return;const a=i.stroke,l=a.width,c=(a.alignment||"center").toLowerCase();if(t.save(),i.fill&&i.fill.type!=="None"&&i.fill.isEnabled!==!1&&i.fill.opacity!==0&&i.fill.color!=="transparent"&&i.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const y=this.createCanvasFill(t,a.fill,e,s);y?t.strokeStyle=y:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const r=t.globalAlpha;t.globalAlpha=r*this.normalizeOpacity(a.opacity??100),t.lineWidth=l,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const u=a.trimStart??0,f=a.trimEnd??1,d=a.trimOffset??0,p=a.dashOffset??0,m=a.dashArray||[];if(u!==0||f!==1||d!==0){const y=this.getPerimeter(o,e,s);if(y>0){const b=Math.max(0,Math.min(1,u)),v=Math.max(0,Math.min(1,f));if(b<v){const S=y*(v-b),C=y-S,w=-(y*(b+d%1));t.setLineDash([S,C]),t.lineDashOffset=w+p*y}else if(b===v)t.setLineDash([0,y]);else{const S=y*(1-b+v),C=y-S,w=-(y*b);t.setLineDash([S,C]),t.lineDashOffset=w+p*y}}}else m.length>0&&(t.setLineDash(m),t.lineDashOffset=p);(o==null?void 0:o.type)==="Line"||e===0||s===0?(this.applyPath(t,o,e,s,n),t.stroke()):c==="inside"?(t.lineWidth=l*2,t.save(),this.applyPath(t,o,e,s,n),t.clip(),t.stroke(),t.restore()):c==="outside"?(t.lineWidth=l*2,this.applyPath(t,o,e,s,n),t.stroke(),t.save(),t.globalCompositeOperation="destination-out",this.applyPath(t,o,e,s,n),t.fill(),t.restore()):(t.lineWidth=l,this.applyPath(t,o,e,s,n),t.stroke()),t.restore()}getPerimeter(t,i,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(i+o)*2;case"Ellipse":{const e=Math.abs(i)/2,s=Math.abs(o)/2,n=Math.abs(t.sweepAngle??360),a=t.ratio||0,l=Math.PI*(3*(e+s)-Math.sqrt((3*e+s)*(e+3*s)));if(n>=360&&a<=0)return l;let c=n/360*l;if(a>0){const h=Math.PI*(3*(e*a+s*a)-Math.sqrt((3*e*a+s*a)*(e*a+3*s*a)));c+=n/360*h,n<360&&(c+=2*Math.sqrt((e-e*a)**2+(s-s*a)**2))}else n<360&&(c+=2*Math.max(e,s));return isNaN(c)?0:c}case"Line":return t.length||Math.sqrt(i*i+o*o);case"Triangle":return i+Math.sqrt((i/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,s=t.radius||Math.min(i,o)/2;return 2*e*s*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,s=t.outer_radius||Math.min(i,o)/2,n=t.inner_radius||s/2,a=Math.PI/e;return Math.sqrt(s*s+n*n-2*s*n*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let s=0,n=e[0].x,a=e[0].y;for(let l=1;l<e.length;l++){const c=e[l];if(c.moveTo){n=c.x,a=c.y;continue}const h=n,r=a,u=e[l-1].out_x,f=e[l-1].out_y;if(u!==void 0||c.in_x!==void 0?s+=this.getBezierLength(h,r,u??h,f??r,c.in_x??c.x,c.in_y??c.y,c.x,c.y):s+=Math.sqrt((c.x-h)**2+(c.y-r)**2),n=c.x,a=c.y,c.closePath||l===e.length-1&&(t.is_closed||t.isClosed)){const d=n,p=a,m=[...e.slice(0,l+1)].reverse().find(M=>M.moveTo)||e[0],y=m.x,b=m.y,v=e[l].out_x,S=e[l].out_y,C=m.in_x,w=m.in_y;v!==void 0||C!==void 0?s+=this.getBezierLength(d,p,v??d,S??p,C??y,w??b,y,b):s+=Math.sqrt((y-d)**2+(b-p)**2)}}return s}default:return(i+o)*2}}getBezierLength(t,i,o,e,s,n,a,l,c=10){let h=0,r=t,u=i;for(let f=1;f<=c;f++){const d=f/c,p=1-d,m=d*d,y=p*p,b=y*p,v=m*d,S=b*t+3*y*d*o+3*p*m*s+v*a,C=b*i+3*y*d*e+3*p*m*n+v*l,w=S-r,M=C-u;h+=Math.sqrt(w*w+M*M),r=S,u=C}return h}getBezierTAtLength(t,i,o,e,s,n,a,l,c,h=20){if(t<=0)return 0;let r=0,u=i,f=o;for(let d=1;d<=h;d++){const p=d/h,m=1-p,y=p*p,b=m*m,v=b*m,S=y*p,C=v*i+3*b*p*e+3*m*y*n+S*l,w=v*o+3*b*p*s+3*m*y*a+S*c,M=C-u,I=w-f,k=Math.sqrt(M*M+I*I);if(r+k>=t){const T=t-r,O=k===0?0:T/k;return(d-1+O)/h}r+=k,u=C,f=w}return 1}getPointOnPath(t,i,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const s=t.points||[];if(s.length<2)return{x:0,y:0,angle:0};let n=1/0,a=-1/0,l=1/0,c=-1/0;s.forEach(b=>{typeof b.x=="number"&&typeof b.y=="number"&&(n=Math.min(n,b.x),a=Math.max(a,b.x),l=Math.min(l,b.y),c=Math.max(c,b.y),b.out_x!==void 0&&(n=Math.min(n,b.out_x),a=Math.max(a,b.out_x)),b.out_y!==void 0&&(l=Math.min(l,b.out_y),c=Math.max(c,b.out_y)),b.in_x!==void 0&&(n=Math.min(n,b.in_x),a=Math.max(a,b.in_x)),b.in_y!==void 0&&(l=Math.min(l,b.in_y),c=Math.max(c,b.in_y)))});const h=(n+a)/2,r=(l+c)/2,f=this.getPerimeter(t,i,o)*e;let d=0;const p=[];let m=s[0],y=s[0];for(let b=1;b<s.length;b++){const v=s[b];if(v.moveTo){m=v,y=v;continue}p.push({p0:m,p1:v}),(v.closePath||b===s.length-1&&(t.is_closed||t.isClosed))&&p.push({p0:v,p1:y}),m=v}for(const b of p){const v=b.p0,S=b.p1;let C=0;const w=v.out_x!==void 0||S.in_x!==void 0;if(w?C=this.getBezierLength(v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y):C=Math.sqrt((S.x-v.x)**2+(S.y-v.y)**2),d+C>=f||b===p[p.length-1]){let M=0;if(w)return M=this.getBezierTAtLength(f-d,v.x,v.y,v.out_x??v.x,v.out_y??v.y,S.in_x??S.x,S.in_y??S.y,S.x,S.y,20),this.getBezierPointAndAngle(M,v,S,h,r);{M=C===0?0:(f-d)/C;const I=v.x+(S.x-v.x)*M-h,k=v.y+(S.y-v.y)*M-r,T=Math.atan2(S.y-v.y,S.x-v.x);return{x:I,y:k,angle:T}}}d+=C}}else if(t.type==="Ellipse"){const s=Math.abs(i)/2,n=Math.abs(o)/2,a=t.sweepAngle??360,c=((t.startAngle??0)+a*e)*Math.PI/180,h=s*Math.cos(c),r=n*Math.sin(c),u=-s*Math.sin(c),f=n*Math.cos(c),d=Math.atan2(f,u);return{x:h,y:r,angle:d}}else if((t==null?void 0:t.type)==="Rectangle"){const s=Math.abs(i),n=Math.abs(o),l=(s+n)*2*e;let c=0,h=0,r=0;return l<s?(c=-s/2+l,h=-n/2,r=0):l<s+n?(c=s/2,h=-n/2+(l-s),r=Math.PI/2):l<2*s+n?(c=s/2-(l-(s+n)),h=n/2,r=Math.PI):(c=-s/2,h=n/2-(l-(2*s+n)),r=-Math.PI/2),{x:c,y:h,angle:r}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,i,o,e,s){const n=i.x,a=i.y,l=i.out_x??i.x,c=i.out_y??i.y,h=o.in_x??o.x,r=o.in_y??o.y,u=o.x,f=o.y,d=1-t,p=t*t,m=d*d,y=m*d,b=p*t,v=y*n+3*m*t*l+3*d*p*h+b*u-e,S=y*a+3*m*t*c+3*d*p*r+b*f-s,C=3*m*(l-n)+6*d*t*(h-l)+3*p*(u-h),w=3*m*(c-a)+6*d*t*(r-c)+3*p*(f-r),M=Math.atan2(w,C);return{x:v,y:S,angle:M}}applyAbsoluteTransform(t,i,o){if(!o.get(i))return;const s=[];let n=i;for(;n;){s.unshift(n);const a=o.get(n);n=a==null?void 0:a.parentId}s.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,i){var d,p,m;const o=this.objectStates.get(i);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,s=o.skew_y||0;if(e!==0||s!==0){const y=Math.tan(e*Math.PI/180),b=Math.tan(s*Math.PI/180);t.transform(1+y*b,b,y,1,0,0)}const n=o.rotate_x!==void 0?o.rotate_x:((d=o.transform)==null?void 0:d.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((p=o.transform)==null?void 0:p.rotate_y)??0,c=1+(o.translate_z!==void 0?o.translate_z:((m=o.transform)==null?void 0:m.translate_z)??0)/1e3,h=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*c,r=(o.flip_y===!0?-1:1)*Math.cos(n*Math.PI/180)*c,u=(o.scale_x??1)*h,f=(o.scale_y??1)*r;t.scale(u,f)}applyArtEffectOverlay(t,i,o,e,s,n){var f,d,p,m,y;const a=this.objectStates.get(i.id),l=((f=a==null?void 0:a.style)==null?void 0:f.artEffect)||i.artEffect||((d=i.style)==null?void 0:d.artEffect);if(!l||!l.enabled)return;const c=l.type,h=l.intensity??.5,r=l.speed??1,u=l.scale??10;if(c==="acid_gradient"||c==="acid_rave"||c==="shimmer"||c==="glint_overlay"||c==="halftone"||c==="noise"||c==="scanlines"||c==="chromatic_aberration"||c==="pixelate"||c==="glitch"||c==="fold_overlay"||c==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,s,n),t.clip(),c==="shimmer"){const v=this.currentTime*r%2/2,S=t.createLinearGradient(-e,-s,e,s);S.addColorStop(Math.max(0,v-.2),"rgba(255,255,255,0)"),S.addColorStop(v,`rgba(255,255,255,${h*.8})`),S.addColorStop(Math.min(1,v+.2),"rgba(255,255,255,0)"),t.fillStyle=S,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="glint_overlay"){let S=((this._lastPointerPos||{x:0}).x-(((p=i.transform)==null?void 0:p.x)??0)+300)/600;S=Math.max(-.2,Math.min(1.2,S));const C=t.createLinearGradient(-e,-s,e,s);C.addColorStop(Math.max(0,S-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,S)),`rgba(255,255,255,${h})`),C.addColorStop(Math.min(1,S+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over"}else if(c==="fold_overlay"){const b=this._lastPointerPos||{x:0,y:0},v=b.x-(((m=i.transform)==null?void 0:m.x)??0),S=b.y-(((y=i.transform)==null?void 0:y.y)??0),C=t.createLinearGradient(v>0?-e/2:e/2,S>0?-s/2:s/2,v>0?e/2:-e/2,S>0?s/2:-s/2);C.addColorStop(0,`rgba(0,0,0,${h*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${h*.4})`),C.addColorStop(1,`rgba(0,0,0,${h*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-s/2,e,s),t.globalCompositeOperation="source-over",t.beginPath(),v>0&&S>0?(t.moveTo(e/2-40,s/2),t.lineTo(e/2,s/2-40),t.lineTo(e/2-40,s/2-40)):v<0&&S>0?(t.moveTo(-e/2+40,s/2),t.lineTo(-e/2,s/2-40),t.lineTo(-e/2+40,s/2-40)):v>0&&S<0?(t.moveTo(e/2-40,-s/2),t.lineTo(e/2,-s/2+40),t.lineTo(e/2-40,-s/2+40)):(t.moveTo(-e/2+40,-s/2),t.lineTo(-e/2,-s/2+40),t.lineTo(-e/2+40,-s/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=v>0?-2:2,t.shadowOffsetY=S>0?-2:2,t.fill()}else if(c==="crumple_overlay"){const b=Math.floor(e/u),v=document.createElement("canvas");v.width=b,v.height=Math.floor(s/u);const S=v.getContext("2d"),C=S.createImageData(v.width,v.height);for(let w=0;w<C.data.length;w+=4){const M=Math.random()>.95?150:255;C.data[w]=M,C.data[w+1]=M,C.data[w+2]=M,C.data[w+3]=255*h}S.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(v,-e/2,-s/2,e,s)}else if(c==="acid_gradient"||c==="acid_rave"){const b=this.currentTime*r,v=l.color1,S=l.color2,C=t.createLinearGradient(-e/2,-s/2,e/2,s/2);if(v&&S){const w=b*60%360;C.addColorStop(0,this._shiftHue(v,w,h*.7)),C.addColorStop(1,this._shiftHue(S,(w+180)%360,h*.7))}else{const w=b*100%360,M=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${h*.5})`),C.addColorStop(1,`hsla(${M}, 80%, 50%, ${h*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-s/2,e,s)}else if(c==="halftone"){const b=Math.max(2,u*(1-h*.8)),v=document.createElement("canvas");v.width=b,v.height=b;const S=v.getContext("2d");if(S){S.fillStyle="black",S.beginPath(),S.arc(b/2,b/2,b/2*h,0,Math.PI*2),S.fill();const C=t.createPattern(v,"repeat");C&&(t.globalAlpha=.3*h,t.fillStyle=C,t.fillRect(-e/2,-s/2,e,s))}}else if(c==="noise"){const b=Math.floor(e*s*h*.02);t.globalAlpha=.4*h;for(let v=0;v<b;v++){const S=Math.random()>.5?255:0;t.fillStyle=`rgba(${S}, ${S}, ${S}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-s/2+Math.random()*s,2,2)}}else if(c==="scanlines"){t.globalAlpha=.2*h,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let b=-s/2;b<s/2;b+=4)t.beginPath(),t.moveTo(-e/2,b),t.lineTo(e/2,b),t.stroke()}else if(c==="chromatic_aberration"){const b=5*h;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-b,-s/2,e,s),t.fillStyle="magenta",t.fillRect(-e/2+b,-s/2,e,s)}else if(c==="pixelate"){const b=Math.max(2,Math.round(u*(1-h*.5))),v=document.createElement("canvas"),S=Math.max(1,Math.ceil(e/b)),C=Math.max(1,Math.ceil(s/b));v.width=S,v.height=C;const w=v.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const M=t.getTransform(),I=M.e-e/2,k=M.f-s/2;w.drawImage(t.canvas,I,k,e,s,0,0,S,C),t.imageSmoothingEnabled=!1,t.drawImage(v,0,0,S,C,-e/2,-s/2,e,s),t.imageSmoothingEnabled=!0}}else if(c==="glitch"){const b=this.currentTime*r,v=l.chaosAmount??.2,S=Math.max(3,Math.floor(8*h)),C=h*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=h*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-s/2,e,s),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-s/2,e,s),t.globalCompositeOperation="source-over",t.globalAlpha=1;const M=s/S;for(let I=0;I<S;I++){const k=Math.sin(I*127.1+b*311.7*r)*43758.5,T=k-Math.floor(k);if(T>1-v){const O=(T-(1-v))/v*C*(Math.random()>.5?1:-1),P=-s/2+I*M,_=t.getTransform(),A=_.e-e/2+O,x=_.f+P;t.save(),t.beginPath(),t.rect(-e/2,P,e,M),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,A,x,e,M,-e/2+O,P,e,M),t.restore()}}}t.restore()}}_shiftHue(t,i,o){let e=0,s=0,n=0;if(t.startsWith("#")){const f=t.replace("#","");e=parseInt(f.substring(0,2),16)/255,s=parseInt(f.substring(2,4),16)/255,n=parseInt(f.substring(4,6),16)/255}const a=Math.max(e,s,n),l=Math.min(e,s,n);let c=0,h=0,r=(a+l)/2;if(a!==l){const f=a-l;switch(h=r>.5?f/(2-a-l):f/(a+l),a){case e:c=((s-n)/f+(s<n?6:0))/6;break;case s:c=((n-e)/f+2)/6;break;case n:c=((e-s)/f+4)/6;break}}return`hsla(${(((c*360+i)%360+360)%360).toFixed(0)}, ${(h*100).toFixed(0)}%, ${(r*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,i,o,e,s,n){const a=n.radius??10,l=n.color??"rgba(255,255,255,0.2)",c=n.opacity??.5,h=n.noise??0;t.save(),this.applyPath(t,i,o,e,s),t.clip();const r=t.getTransform(),u=r.e-o/2,f=r.f-e/2;try{const p=document.createElement("canvas");p.width=Math.max(1,Math.ceil(o)),p.height=Math.max(1,Math.ceil(e));const m=p.getContext("2d");if(m){m.drawImage(t.canvas,u,f,o,e,0,0,o,e),m.filter=`blur(${a}px)`;const y=document.createElement("canvas");y.width=p.width,y.height=p.height;const b=y.getContext("2d");b.filter=`blur(${a}px)`,b.drawImage(p,0,0),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(y,-o/2,-e/2,o,e)}}catch{}t.globalCompositeOperation="source-over",t.globalAlpha=c,t.fillStyle=l,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"),b=y.createImageData(64,64),v=b.data;for(let S=0;S<v.length;S+=4){const C=Math.floor(Math.random()*255);v[S]=C,v[S+1]=C,v[S+2]=C,v[S+3]=18}y.putImageData(b,0,0),this._noiseTileCanvas=m}const p=t.createPattern(this._noiseTileCanvas,"repeat");p&&(t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,i,o,e,s),t.stroke(),t.restore()}applyPath(t,i,o,e,s){i!=null&&i.data&&(i.type==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type),t.beginPath(),this._tracePath(t,i,o,e,s)}_tracePath(t,i,o,e,s){if(i){if(this.ensurePathPoints(i),(i==null?void 0:i.type)==="Rectangle"||i.type==="Image"){const n=s!==void 0?s:i.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,n)}else if(i.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(i.type==="Ellipse"){const{startAngle:n=0,sweepAngle:a=360,ratio:l=0}=i,c=o/2,h=e/2,r=n*Math.PI/180,u=a*Math.PI/180,f=r+u;a>=360&&l<=0?t.ellipse(0,0,c,h,0,0,Math.PI*2):(t.ellipse(0,0,c,h,0,r,f,!1),l>0?t.ellipse(0,0,c*l,h*l,0,f,r,!0):t.lineTo(0,0),t.closePath())}else if(i.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(i.type==="Polygon"){const n=i.sides||3,a=i.radius||Math.min(o,e)/2;for(let l=0;l<n;l++){const c=l*2*Math.PI/n-Math.PI/2,h=a*Math.cos(c),r=a*Math.sin(c);l===0?t.moveTo(h,r):t.lineTo(h,r)}t.closePath()}else if(i.type==="Star"){const n=i.points||5,a=i.outer_radius||Math.min(o,e)/2;let l=i.inner_radius;l==null?l=a*.382:l<=1&&(l=a*l);for(let c=0;c<n*2;c++){const h=c*Math.PI/n-Math.PI/2,r=c%2===0?a:l,u=r*Math.cos(h),f=r*Math.sin(h);c===0?t.moveTo(u,f):t.lineTo(u,f)}t.closePath()}else if(((i==null?void 0:i.type)==="Path"||i.type==="Subtract"||i.type==="Union"||i.type==="Intersect"||i.type==="Exclude"||i.type==="BooleanOperation")&&i.points){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",i.points.length,"points");let n=1/0,a=-1/0,l=1/0,c=-1/0;if(i.points.forEach(u=>{typeof u.x=="number"&&typeof u.y=="number"&&(n=Math.min(n,u.x),a=Math.max(a,u.x),l=Math.min(l,u.y),c=Math.max(c,u.y),u.out_x!==void 0&&(n=Math.min(n,u.out_x),a=Math.max(a,u.out_x)),u.out_y!==void 0&&(l=Math.min(l,u.out_y),c=Math.max(c,u.out_y)),u.in_x!==void 0&&(n=Math.min(n,u.in_x),a=Math.max(a,u.in_x)),u.in_y!==void 0&&(l=Math.min(l,u.in_y),c=Math.max(c,u.in_y)))}),n===1/0)return;const h=(n+a)/2,r=(l+c)/2;if(isNaN(h)||isNaN(r)){this.warn("[Engine] Invalid path center:",h,r);return}i.points.forEach((u,f)=>{if(f===0||u.moveTo)t.moveTo(u.x-h,u.y-r);else{const d=i.points[f-1];if(!d)return;const p=(d.out_x??d.x)-h,m=(d.out_y??d.y)-r,y=(u.in_x??u.x)-h,b=(u.in_y??u.y)-r;isNaN(p)||isNaN(y)||isNaN(u.x)?t.lineTo(u.x-h,u.y-r):t.bezierCurveTo(p,m,y,b,u.x-h,u.y-r)}if(u.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed)){const d=[...i.points.slice(0,f+1)].reverse().find(p=>p.moveTo)||i.points[0];d&&(u.out_x!==void 0||d.in_x!==void 0)&&t.bezierCurveTo((u.out_x??u.x)-h,(u.out_y??u.y)-r,(d.in_x??d.x)-h,(d.in_y??d.y)-r,d.x-h,d.y-r),t.closePath()}})}else if(i.points&&Array.isArray(i.points)){let n=1/0,a=-1/0,l=1/0,c=-1/0;i.points.forEach(u=>{n=Math.min(n,u.x),a=Math.max(a,u.x),l=Math.min(l,u.y),c=Math.max(c,u.y)});const h=(n+a)/2,r=(l+c)/2;i.points.forEach((u,f)=>{if(f===0)t.moveTo(u.x-h,u.y-r);else{const d=i.points[f-1];d.out_x!==void 0||u.in_x!==void 0?t.bezierCurveTo((d.out_x??d.x)-h,(d.out_y??d.y)-r,(u.in_x??u.x)-h,(u.in_y??u.y)-r,u.x-h,u.y-r):t.lineTo(u.x-h,u.y-r)}(u.closePath||f===i.points.length-1&&(i.is_closed||i.isClosed))&&t.closePath()})}}}renderInputBox(t,i){var F,$;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((F=i.geometry)==null?void 0:F.width)||250,n=(($=i.geometry)==null?void 0:$.height)||45,a=this.focusedId===i.id,l=this.lastHoveredObjectId===i.id,c=e.previewState||"default",h=c!=="default"?c:a?"focused":l?"hovered":"default",r=e.label||{visible:!0,text:"Label"},u=e.helperText||{visible:!1,text:"Helper text"},f=e.leftIcon||{visible:!1},d=e.rightIcon||{visible:!1},p=e.multiline===!0,m=e.corner_radius??8,y=e.corners||{tl:m,tr:m,bl:m,br:m},b=[y.tl,y.tr,y.br,y.bl];let v=e.backgroundColor||"rgba(31, 41, 55, 1)",S=e.borderColor||"rgba(55, 65, 81, 1)",C=e.borderWidth??1.5,w=e.color||"#ffffff",M=e.placeholderColor||"rgba(156, 163, 175, 1)",I=e.fontSize||14;const k=`${h}Style`,T=e[k];T?(T.backgroundColor!==void 0&&(v=T.backgroundColor),T.borderColor!==void 0&&(S=T.borderColor),T.borderWidth!==void 0&&(C=T.borderWidth),T.color!==void 0&&(w=T.color),T.placeholderColor!==void 0&&(M=T.placeholderColor),T.fontSize!==void 0&&(I=T.fontSize)):h==="focused"?(S=e.focusBorderColor||"rgba(59, 130, 246, 1)",C=Math.max(C,2)):h==="hovered"||h==="hover"?(S=e.hoverBorderColor||S,v=e.hoverBackgroundColor||v):h==="disabled"?(v=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",S=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):h==="error"&&(S="rgba(239, 68, 68, 1)",C=Math.max(C,2)),t.beginPath(),this.drawRoundRect(t,-s/2,-n/2,s,n,b);const O=this.createCanvasFill(t,v,s,n);if(O&&(t.fillStyle=O,t.fill()),C>0){const V=this.createCanvasFill(t,S,s,n);if(V&&(t.strokeStyle=V,t.lineWidth=C,t.stroke()),h==="focused"||h==="focus"){t.save(),t.beginPath();const tt=b.map(rt=>rt+2);this.drawRoundRect(t,-s/2-2,-n/2-2,s+4,n+4,tt),t.strokeStyle="rgba(59, 130, 246, 0.3)",t.lineWidth=2,t.stroke(),t.restore()}}const P=(V,tt)=>{if(!V.visible||!V.svgPath)return;const rt=V.size||14,mt=V.offset??16,Ct=V.color||"#ffffff",ct=tt?-(s/2)+mt:s/2-mt,Pt=V.svgPath;if(t.save(),t.translate(ct,0),!Pt.startsWith("<svg")){const kt=new Path2D(Pt),Tt=rt/24;t.scale(Tt,Tt),t.translate(-12,-12),t.fillStyle=Ct,t.fill(kt)}t.restore()};P(f,!0),P(d,!1);const _=e.text||"",A=e.placeholder||"Enter text...",x=!_,W=_||A,Y=x?M:w,B=I,X=e.fontFamily||"Inter",q=e.fontWeight||400;t.font=`${q} ${B}px "${X}", sans-serif`,t.fillStyle=Y,t.textAlign="left",t.textBaseline=p?"top":"middle";const j=e.inputPadding??16,E=f.visible?(f.offset??16)+(f.size||14)/2+8:j,L=d.visible?(d.offset??16)+(d.size||14)/2+8:j,G=-(s/2)+E,z=s-E-L,it=e.inputType==="password"?"•".repeat(W.length):W;if(t.save(),t.beginPath(),t.rect(G-2,-n/2+4,z+4,n-8),t.clip(),p){const V=it.split(`
34
+ `);let tt=-n/2+j;const rt=B*1.2;let mt=0;V.forEach((Ct,ct)=>{const Pt=Ct.split(" ");let kt="";for(let Tt=0;Tt<Pt.length;Tt++){const zt=kt+Pt[Tt]+" ";t.measureText(zt).width>z&&Tt>0?(t.fillText(kt,G,tt),kt=Pt[Tt]+" ",tt+=rt):kt=zt}t.fillText(kt,G,tt),mt=t.measureText(kt).width,ct<V.length-1&&(tt+=rt,mt=0)}),a&&!x&&Math.floor(performance.now()/500)%2===0&&t.fillRect(G+mt,tt,1.5,B)}else{const tt=t.measureText(it).width;let rt=0;if(tt>z&&(rt=tt-z),t.fillText(it,G-rt,0),a&&!x&&Math.floor(performance.now()/500)%2===0){const Ct=G+tt-rt;t.fillRect(Ct,-(B/2),1.5,B)}}if(t.restore(),r.visible!==!1){const V=r.text||"Label",tt=r.fontSize||12,rt=r.color||"rgba(156, 163, 175, 1)",mt=r.offset??8;t.font=`600 ${tt}px "${X}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="bottom";const Ct=-(s/2),ct=-(n/2)-mt;t.fillText(V,Ct,ct)}if(u.visible===!0){const V=u.text||"Helper text",tt=u.fontSize||11,rt=h==="error"?"rgba(239, 68, 68, 1)":u.color||"rgba(156, 163, 175, 1)",mt=u.offset??6;t.font=`400 ${tt}px "${X}", sans-serif`,t.fillStyle=rt,t.textAlign="left",t.textBaseline="top";const Ct=-(s/2),ct=n/2+mt;t.fillText(V,Ct,ct)}}renderSlider(t,i){const o=this.objectStates.get(i.id),e=(o==null?void 0:o.geometry)||i.geometry,s=(o==null?void 0:o.options)||i.options||{},n=e.width||200,a=s.value??50,l=s.min??0,h=(s.max??100)-l,r=h===0?0:(a-l)/h,u=s.trackHeight||4,f=s.trackRoundedness??2,d=s.trackShape??"Rectangle",p=s.trackPath||"",m=s.accentColor||"#3b82f6",y=s.inactiveColor||"#374151",b=s.thumbShape||"Ellipse",v=s.thumbWidth??16,S=s.thumbHeight??16,C=s.thumbRoundedness??0,w=s.thumbColor||"#ffffff",M=s.thumbPath||"",I=s.thumbIcon||"",k=s.showValueTooltip??!1,T=s.tooltipBgColor||"#333333",O=s.tooltipColor||"#ffffff",P=s.tooltipOffsetX??0,_=s.tooltipOffsetY??-25,A=(z,it,F,$,V,tt,rt)=>{if((z==="Custom"||z==="Icon")&&rt)try{const mt=new Path2D(rt);if(t.save(),t.translate(it,F),z==="Icon"){const Ct=Math.min($,V)/24;t.scale(Ct,Ct),t.translate(-12,-12)}t.fill(mt),t.restore();return}catch(mt){console.error("Error drawing slider shape in engine:",mt)}if(t.beginPath(),z==="Ellipse")t.ellipse(it,F,$/2,V/2,0,0,Math.PI*2);else if(z==="Rectangle")this.drawRoundRect(t,it-$/2,F-V/2,$,V,tt);else if(z==="Triangle")t.moveTo(it,F-V/2),t.lineTo(it+$/2,F+V/2),t.lineTo(it-$/2,F+V/2),t.closePath();else if(z==="Diamond")t.moveTo(it,F-V/2),t.lineTo(it+$/2,F),t.lineTo(it,F+V/2),t.lineTo(it-$/2,F),t.closePath();else if(z==="Polygon"){const mt=i.geometry.sides||3,Ct=i.geometry.radius||Math.min($,V)/2;for(let ct=0;ct<mt;ct++){const Pt=ct*2*Math.PI/mt-Math.PI/2,kt=it+Ct*Math.cos(Pt),Tt=F+Ct*Math.sin(Pt);ct===0?t.moveTo(kt,Tt):t.lineTo(kt,Tt)}t.closePath()}else if(z==="Star"){const Ct=Math.min($,V)/2,ct=Ct/2;for(let Pt=0;Pt<10;Pt++){const kt=Pt%2===0?Ct:ct,Tt=Pt*Math.PI/5-Math.PI/2;t.lineTo(it+kt*Math.cos(Tt),F+kt*Math.sin(Tt))}t.closePath()}else z==="Line"&&(t.moveTo(it-$/2,F),t.lineTo(it+$/2,F));t.fill()},x=this.createCanvasFill(t,y,n,u);x&&(t.fillStyle=x,t.strokeStyle=x),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(n/2,0),t.stroke()):A(d,0,0,n,u,f,p);const W=n-v,Y=-n/2+v/2+r*W,B=Y- -n/2;if(B>0){const z=this.createCanvasFill(t,m,n,u);z&&(t.fillStyle=z,t.strokeStyle=z),d==="Line"?(t.lineWidth=u,t.beginPath(),t.moveTo(-n/2,0),t.lineTo(Y,0),t.stroke()):d==="Rectangle"&&(t.beginPath(),this.drawRoundRect(t,-n/2,-u/2,B,u,f),t.fill())}t.save(),t.translate(Y,0);const X=t.getTransform(),q=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*q,t.shadowOffsetY=1*q;const j=this.createCanvasFill(t,w,v,S);if(j&&(t.fillStyle=j),A(b,0,0,v,S,C,b==="Icon"?I:M),t.restore(),k){t.save(),t.translate(Y+P,_);const z=Math.round(a).toString();t.font="10px Inter, sans-serif";const it=t.measureText(z),F=6,$=4,V=it.width+F*2,tt=14+$;t.beginPath(),this.drawRoundRect(t,-V/2,-tt/2,V,tt,4),t.fillStyle=T,t.fill(),t.fillStyle=O,t.textAlign="center",t.textBaseline="middle",t.fillText(z,0,0),t.restore()}const E=s.label||{},L=s.helperText||{},G=s.fontFamily||"Inter";if(E.visible!==!1){const z=E.text||"Label",it=E.fontSize||12,F=E.color||"rgba(156, 163, 175, 1)",$=E.offset??8;t.font=`600 ${it}px "${G}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="bottom";const V=-(n/2),tt=-(u/2)-$;t.fillText(z,V,tt)}if(L.visible===!0){const z=L.text||"Helper text",it=L.fontSize||11,F=L.color||"rgba(156, 163, 175, 1)",$=L.offset??6;t.font=`400 ${it}px "${G}", sans-serif`,t.fillStyle=F,t.textAlign="left",t.textBaseline="top";const V=-(n/2),tt=u/2+$;t.fillText(z,V,tt)}}renderDropdown(t,i){var _;const o=this.objectStates.get(i.id);if(!o)return;const e=o.options||i.options||{},s=i.geometry.width||160,n=i.geometry.height||40,a=-s/2,l=-n/2,c=e.corner_radius??6,h=e.disabled||e.previewState==="disabled",r=this.lastHoveredObjectId===i.id||e.previewState==="hover",u=(e.isOpen||e.previewState==="active")&&!h;let f=e.backgroundColor,d=e.borderColor,p=e.color||"#333333";h?(f=e.disabledBackgroundColor||"#f3f4f6",d=e.disabledBorderColor||"#e5e7eb",p=e.disabledColor||"#9ca3af"):u?(f=e.activeBackgroundColor||f,d=e.activeBorderColor||d,p=e.activeColor||p):r&&(f=e.hoverBackgroundColor||f,d=e.hoverBorderColor||d,p=e.hoverColor||p),f||(f="#ffffff"),d||(d="#e5e7eb");const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),this.drawRoundRect(t,a,l,s,n,c),t.fillStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,s,n)||"#ffffff",t.fill();const y=e.borderWidth??1;y>0&&(t.strokeStyle=this.createCanvasFill(t,typeof d=="string"?{type:"Solid",color:d}:d,s,n)||"#e5e7eb",t.lineWidth=y,t.stroke());const b=12,v=e.chevronType||"chevron",S=e.chevronSize||16,C=(u?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(v!=="none"){const A=a+s-b-S/2;t.save(),t.translate(A,0);const x=u?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(x*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",v==="chevron")t.beginPath(),t.moveTo(-S/2,-S*.2),t.lineTo(0,S*.2),t.lineTo(S/2,-S*.2),t.stroke();else if(v==="custom"||v==="path"){const W=u&&e.openIconPath||e.closedIconPath;if(W){const Y=new Path2D(W);t.save();const B=S/24;t.scale(B,B),t.translate(-12,-12),t.fill(Y),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",M=e.fontSize||14,I=e.fontWeight||400,k=e.fontFamily||"Inter, sans-serif";t.font=`${I} ${M}px ${k}`;const T=h?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":p;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,s,n)||"#333333",t.textAlign="left",t.textBaseline="middle";const O=v==="none"?0:S+8,P=s-b*2-O;if(t.save(),t.beginPath(),t.rect(a+b,l,P,n),t.clip(),t.fillText(w,a+b,0),t.restore(),u&&!h){const A=l+n+4,x=e.optionsList||[],W=e.itemHeight||32,Y=e.listPadding??4,B=x.length*W+Y*2,X=e.listCornerRadius??c;t.save();const q=e.listShadow||{},j=t.getTransform(),E=Math.sqrt(j.a*j.a+j.b*j.b)||1;t.shadowColor=typeof q.color=="string"?q.color:((_=q.color)==null?void 0:_.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(q.blur??12)*E,t.shadowOffsetY=(q.offsetY??6)*E,t.shadowOffsetX=(q.offsetX??0)*E,t.beginPath(),this.drawRoundRect(t,a,A,s,B,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},s,B)||"#ffffff",t.fill();const L=e.listBorderWidth??1;L>0&&(t.shadowColor="transparent",t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:d},s,B)||"#e5e7eb",t.lineWidth=L,t.stroke()),t.restore();const G=e.itemFontSize||M,z=e.itemFontFamily||k;t.font=`${I} ${G}px ${z}`,x.forEach((it,F)=>{const $=A+Y+F*W;if(it===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},s,W)||"#f3f4f6",t.fillRect(a+L,$,s-L*2,W),t.fillStyle=e.itemSelectedColor||e.accentColor||p||"#374151";else if(t.fillStyle=e.listTextColor||p||"#333333",this.activeDropdownId===i.id&&this._lastPointerPos){const tt=this._lastPointerPos.y-(A+Y),rt=Math.floor(tt/W);F===rt&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},s,W)||"#f9fafb",t.fillRect(a+L,$,s-L*2,W),t.fillStyle=e.itemHoverColor||p)}t.fillText(it,a+b,$+W/2)})}t.globalAlpha=m}renderButton(t,i){if(i.children&&i.children.length>0)return;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=i.geometry||{},n=s.width||120,a=s.height||40,l=this.lastHoveredObjectId===i.id,c=this.activeObjectId===i.id,h=e.label||{},r=e.hoverStyle||{},u=e.activeStyle||{},f=e.icon||{enabled:!1};let d=e.backgroundColor||"#3b82f6",p=h.color||"#ffffff",m=h.text||"Button",y=s.cornerRadius??8,b=e.borderColor||"transparent",v=e.borderWidth||0,S=1;c&&u?(d=u.backgroundColor||d,p=u.color||p,m=u.text||m,S=u.scale??.95,y=u.cornerRadius??y):l&&r&&(d=r.backgroundColor||d,p=r.color||p,m=r.text||m,S=r.scale??1,y=r.cornerRadius??y,b=r.borderColor||b);const C=-n/2,w=-a/2;t.save(),t.scale(S,S),t.beginPath(),this.drawRoundRect(t,C,w,n,a,y);const M=this.createCanvasFill(t,d,n,a);M&&(t.fillStyle=M,t.fill()),(v>0||l&&r.borderColor)&&(t.strokeStyle=b,t.lineWidth=v||(l?1:0),t.stroke());const I=h.fontSize||14,k=h.fontFamily||"Inter",T=h.fontWeight||600;t.font=`${T} ${I}px "${k}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=p,t.textAlign="center",t.textBaseline="middle";let O=0;if(f.enabled&&f.svgPath){const P=I*1.1,_=f.gap||8,A=t.measureText(m),W=-(A.width+P+_)/2,Y=f.position==="left"?W+P/2:W+A.width+_+P/2;O=f.position==="left"?W+P+_+A.width/2:W+A.width/2,t.save(),t.translate(Y,0);const B=new Path2D(f.svgPath),X=P/24;t.scale(X,X),t.translate(-12,-12),t.fillStyle=p,t.fill(B),t.restore()}t.fillText(m,O,0),t.restore()}renderToggleButton(t,i){var m,y;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=e.checked??!1,n=((m=i.geometry)==null?void 0:m.width)||120,a=((y=i.geometry)==null?void 0:y.height)||40,l=-n/2,c=-a/2,h=e.corner_radius??8,r=e.label||{},u=s?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",f=s?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,l,c,n,a,h),t.fillStyle=u,t.fill();const d=r.fontSize||14,p=r.fontFamily||"Inter";t.font=`${r.fontWeight||600} ${d}px "${p}", sans-serif`,t.fillStyle=f,t.textAlign="center",t.textBaseline="middle",t.fillText(r.text||"Toggle",0,0),t.restore()}renderToggle(t,i){var X,q,j,E,L,G,z,it,F,$,V,tt;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((X=i.geometry)==null?void 0:X.width)||52,n=((q=i.geometry)==null?void 0:q.height)||30,a=-s/2,l=-n/2,c=e.checked??!1,h=e.cornerRadius??e.corner_radius??n/2,r=e.toggleStyle||{},u=r.backgroundColor||e.activeColor||"#10b981",f=r.borderColor||e.borderColor||"transparent",d=r.borderWidth??e.borderWidth??0,p=r.knobColor||e.knobColor||"#ffffff",m=c?u:e.inactiveColor||"#374151",y=c?f:e.borderColor||"transparent",b=c?d:e.borderWidth??0,v=c?p:e.knobColor||"#ffffff";e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,h);const S=this.createCanvasFill(t,m,s,n);if(S&&(t.fillStyle=S,t.fill()),b>0){t.lineWidth=b;const rt=this.createCanvasFill(t,y,s,n);rt&&(t.strokeStyle=rt,t.stroke())}const C=2,w=n-C*2,M=w/2,I=a+C,k=a+s-C-w,T=c?k:I,O=l+C;t.beginPath(),t.arc(T+M,O+M,M,0,Math.PI*2);const P=this.createCanvasFill(t,v,w,w);P&&(t.fillStyle=P,t.fill()),e.disabled&&(t.globalAlpha*=2);let _=!1,A=!1;const x=(c?(j=r.leftLabel)==null?void 0:j.text:null)||((E=e.leftLabel)==null?void 0:E.text)||"",W=(c?(L=r.leftLabel)==null?void 0:L.color:null)||((G=e.leftLabel)==null?void 0:G.color)||"#f3f4f6";if((z=e.leftLabel)!=null&&z.enabled&&x){const rt=e.leftLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=W,t.textBaseline="middle",t.textAlign="right",t.fillText(x,a-(rt.gap||8),0),_=!0}const Y=(c?(it=r.rightLabel)==null?void 0:it.text:null)||((F=e.rightLabel)==null?void 0:F.text)||"",B=(c?($=r.rightLabel)==null?void 0:$.color:null)||((V=e.rightLabel)==null?void 0:V.color)||"#f3f4f6";if((tt=e.rightLabel)!=null&&tt.enabled&&Y){const rt=e.rightLabel;t.font=`${rt.fontWeight||400} ${rt.fontSize||12}px "${rt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=B,t.textBaseline="middle",t.textAlign="left",t.fillText(Y,a+s+(rt.gap||8),0),A=!0}if(!_&&!A&&e.label&&e.label.text){const rt=e.label,mt=rt.fontSize||14,Ct=rt.fontWeight||400,ct=rt.fontFamily||"Inter";t.font=`${Ct} ${mt}px "${ct}", sans-serif`,t.fillStyle=rt.color||"#f3f4f6",t.textBaseline="middle";const Pt=rt.gap||10;let kt=0,Tt=0;rt.position==="left"?(t.textAlign="right",kt=a-Pt,Tt=0):rt.position==="right"?(t.textAlign="left",kt=a+s+Pt,Tt=0):rt.position==="top"?(t.textAlign="center",kt=0,Tt=l-Pt,t.textBaseline="bottom"):rt.position==="bottom"?(t.textAlign="center",kt=0,Tt=l+n+Pt,t.textBaseline="top"):(t.textAlign="left",kt=a+s+Pt,Tt=0),t.fillText(rt.text,kt,Tt)}}renderCheckbox(t,i){var S,C;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((S=i.geometry)==null?void 0:S.width)||20,n=((C=i.geometry)==null?void 0:C.height)||20,a=-s/2,l=-n/2,c=e.cornerRadius??4,h=e.checked??!1,r=e.activeColor||"#3b82f6",u=e.inactiveColor||"transparent",f=e.checkColor||"#ffffff",d=e.borderColor||"#4b5563",p=e.borderWidth??2,m=h?r:u,y=h?"transparent":d,b=h?0:p;e.disabled&&(t.globalAlpha*=.5),t.beginPath(),this.drawRoundRect(t,a,l,s,n,c);const v=this.createCanvasFill(t,m,s,n);if(v&&(t.fillStyle=v,t.fill()),b>0){t.lineWidth=b;const w=this.createCanvasFill(t,y,s,n);w&&(t.strokeStyle=w,t.stroke())}else if(h){t.lineWidth=1;const w=this.createCanvasFill(t,r,s,n);w&&(t.strokeStyle=w,t.stroke())}if(h){t.save(),t.beginPath();const w=this.createCanvasFill(t,f,s,n);t.strokeStyle=w||f,t.lineWidth=Math.max(2,s*.12),t.lineCap="round",t.lineJoin="round";const M=a+s*.25,I=l+n*.5,k=a+s*.45,T=l+n*.7,O=a+s*.75,P=l+n*.25;t.moveTo(M,I),t.lineTo(k,T),t.lineTo(O,P),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const w=e.label;t.save(),t.font=`${w.fontWeight||400} ${w.fontSize||14}px "${w.fontFamily||"Inter"}", sans-serif`,t.fillStyle=w.color||"#f3f4f6",t.textBaseline="middle";const M=w.gap||8;let I=0,k=0;w.position==="left"?(t.textAlign="right",I=a-M,k=0):w.position==="right"?(t.textAlign="left",I=a+s+M,k=0):w.position==="top"?(t.textAlign="center",I=0,k=l-M,t.textBaseline="bottom"):w.position==="bottom"&&(t.textAlign="center",I=0,k=l+n+M,t.textBaseline="top"),t.fillText(w.text,I,k),t.restore()}}renderRadioGroup(t,i){var C,w;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s=((C=i.geometry)==null?void 0:C.width)||180,n=((w=i.geometry)==null?void 0:w.height)||100,a=-s/2,l=-n/2,c=e.selectedValue,h=e.optionsList||["Option 1","Option 2","Option 3"],r=e.orientation||"vertical",u=e.itemGap!==void 0?e.itemGap:16,f=e.activeColor||"#3b82f6",d=e.inactiveColor||"#4b5563",p=e.textColor||"#ffffff",m=e.fontSize||14,y=e.fontFamily||"Inter",b=e.fontWeight||400;e.disabled&&(t.globalAlpha*=.5);const v=8,S=v*2;if(t.save(),t.font=`${b} ${m}px "${y}", sans-serif`,t.textBaseline="middle",t.textAlign="left",r==="vertical"){const M=Math.max(S,m)+u;h.forEach((I,k)=>{const T=l+k*M+v;t.beginPath(),t.arc(a+v,T,v,0,Math.PI*2);const O=c===I,P=this.createCanvasFill(t,f,S,S),_=this.createCanvasFill(t,d,S,S);O?(t.strokeStyle=P||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(a+v,T,v/2,0,Math.PI*2),t.fillStyle=P||f,t.fill()):(t.strokeStyle=_||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,a+S+8,T)})}else{let M=a;h.forEach(I=>{const k=c===I,T=t.measureText(I).width;t.beginPath(),t.arc(M+v,0,v,0,Math.PI*2);const O=this.createCanvasFill(t,f,S,S),P=this.createCanvasFill(t,d,S,S);k?(t.strokeStyle=O||f,t.lineWidth=2,t.stroke(),t.beginPath(),t.arc(M+v,0,v/2,0,Math.PI*2),t.fillStyle=O||f,t.fill()):(t.strokeStyle=P||d,t.lineWidth=1.5,t.stroke()),t.fillStyle=p,t.fillText(I,M+S+6,0),M+=S+6+T+u})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const M=e.label;t.save(),t.font=`${M.fontWeight||400} ${M.fontSize||14}px "${M.fontFamily||"Inter"}", sans-serif`,t.fillStyle=M.color||"#9ca3af",t.textBaseline="middle";const I=M.gap||8;let k=0,T=0;M.position==="left"?(t.textAlign="right",k=a-I,T=0):M.position==="right"?(t.textAlign="left",k=a+s+I,T=0):M.position==="top"?(t.textAlign="center",k=0,T=l-I,t.textBaseline="bottom"):M.position==="bottom"&&(t.textAlign="center",k=0,T=l+n+I,t.textBaseline="top"),t.fillText(M.text,k,T),t.restore()}}renderBarChart(t,i){var T,O;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((T=i.geometry)==null?void 0:T.width)||300,height:((O=i.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"grouped",stylePreset:e.stylePreset||"default",datasets:e.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:e.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:e.orientation||"vertical",barWidth:e.barWidth!==void 0?e.barWidth:14,barGap:e.barGap!==void 0?e.barGap:4,barCornerRadius:e.barCornerRadius!==void 0?e.barCornerRadius:5,showXAxis:!!e.showXAxis,showYAxis:!!e.showYAxis,xAxisColor:e.xAxisColor||"rgba(255,255,255,0.12)",yAxisColor:e.yAxisColor||"rgba(255,255,255,0.12)",showXLabels:e.showXLabels!==void 0?!!e.showXLabels:!0,showYLabels:!!e.showYLabels,axisLabelColor:e.axisLabelColor||"rgba(255,255,255,0.5)",axisLabelFontSize:e.axisLabelFontSize||9,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(255,255,255,0.7)",legendFontSize:e.legendFontSize||9,showGridLines:e.showGridLines!==void 0?!!e.showGridLines:!0,gridColor:e.gridColor||"rgba(255,255,255,0.06)",cardBackground:e.cardBackground||"rgba(255,255,255,0.04)",cardBorderColor:e.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:e.barGradient!==void 0?!!e.barGradient:!0,showValueOnTop:!!e.showValueOnTop,chartBackground:e.chartBackground||"transparent",barStyle:e.barStyle||"solid",barBorderWidth:e.barBorderWidth!==void 0?e.barBorderWidth:1,barBorderColor:e.barBorderColor||"auto",enableShadows:!!e.enableShadows,shadowColor:e.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:e.shadowBlur!==void 0?e.shadowBlur:4,shadowOffsetY:e.shadowOffsetY!==void 0?e.shadowOffsetY:2,valueFontSize:e.valueFontSize||10,valueColor:e.valueColor||"auto",valueFontWeight:e.valueFontWeight||"bold",xAxisLineWidth:e.xAxisLineWidth!==void 0?e.xAxisLineWidth:1,yAxisLineWidth:e.yAxisLineWidth!==void 0?e.yAxisLineWidth:1,gridLineWidth:e.gridLineWidth!==void 0?e.gridLineWidth:1,gridLineDash:e.gridLineDash||[3,4],_getPreset:function(){return ds[this.stylePreset]||ds.default},_resolveColor:function(P,_){const A=this._getPreset();return["#6366f1","#f59e0b","#10b981","#3b82f6","#a855f7"].includes(P)?A.colors[_%A.colors.length]:typeof P=="string"?P:A.colors[_%A.colors.length]},_makeGradient:function(P,_,A,x,W,Y){if(!this._getPreset().barGradient&&!this.barGradient)return _;const X=P.createLinearGradient(A,x,W,Y);return X.addColorStop(0,_),X.addColorStop(1,_+"44"),X},_drawRoundedBar:function(P,_,A,x,W,Y,B){if(Y=Math.min(Y,Math.min(Math.abs(x),Math.abs(W))/2),Y<=0||x===0||W===0){P.rect(_,A,x,W);return}P.beginPath(),B?(P.moveTo(_,A+W),P.lineTo(_,A+Y),P.quadraticCurveTo(_,A,_+Y,A),P.lineTo(_+x-Y,A),P.quadraticCurveTo(_+x,A,_+x,A+Y),P.lineTo(_+x,A+W),P.lineTo(_,A+W)):(P.moveTo(_,A),P.lineTo(_+x-Y,A),P.quadraticCurveTo(_+x,A,_+x,A+Y),P.lineTo(_+x,A+W-Y),P.quadraticCurveTo(_+x,A+W,_+x-Y,A+W),P.lineTo(_,A+W),P.lineTo(_,A)),P.closePath()}},n=s.width,a=s.height,l=-n/2,c=-a/2;if(!s.datasets||s.datasets.length===0||s.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}const h=s._getPreset();let r=-1/0,u=1/0;const f=s.categories.length,d=s.datasets.length;if(s.chartType==="stacked")for(let P=0;P<f;P++){let _=0,A=0;s.datasets.forEach(x=>{const W=x.data[P]??0;W>=0?_+=W:A+=W}),_>r&&(r=_),A<u&&(u=A)}else s.datasets.forEach(P=>{P.data&&P.data.forEach(_=>{_>r&&(r=_),_<u&&(u=_)})});isFinite(r)||(r=10),isFinite(u)||(u=0),r=Math.max(r,0),u=Math.min(u,0);const p=r-u||10;t.save(),s.enableShadows&&(t.shadowColor=s.shadowColor,t.shadowBlur=s.shadowBlur,t.shadowOffsetY=s.shadowOffsetY),t.font=s.axisLabelFontSize+"px Inter, sans-serif";const m=s.showYLabels?t.measureText(r.toFixed(0)).width+14:10,y=s.showXLabels?s.axisLabelFontSize+12:8,v=(s.showLegend&&d>0?s.legendFontSize+10:0)+8,S=10,C=l+m,w=c+v,M=n-m-S,I=a-v-y;if(s.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,c,n,a,10),t.fillStyle=h.cardBackground,t.fill(),t.strokeStyle=h.cardBorderColor,t.lineWidth=1,t.stroke(),s.chartBackground&&s.chartBackground!=="transparent"&&(t.beginPath(),t.rect(C,w,M,I),t.fillStyle=s.chartBackground,t.fill()),s.showLegend&&d>0){t.font=s.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const P=c+12;let _=C;s.datasets.forEach((A,x)=>{const W=s._resolveColor(A.color,x),Y=A.label||"Series "+(x+1),B=7;t.beginPath(),t.roundRect(_,P-B/2,B,B,2),t.fillStyle=W,t.fill(),t.fillStyle=h.legendColor,t.textAlign="left",t.fillText(Y,_+B+4,P),_+=t.measureText(Y).width+B+16})}const k=4;if(s.showGridLines){t.setLineDash(s.gridLineDash||[]),t.lineWidth=s.gridLineWidth||1,t.strokeStyle=h.gridColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=C+P/k*M;t.beginPath(),t.moveTo(_,w),t.lineTo(_,w+I),t.stroke()}else{const _=w+P/k*I;t.beginPath(),t.moveTo(C,_),t.lineTo(C+M,_),t.stroke()}t.setLineDash([])}if(s.showYLabels){t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor;for(let P=0;P<=k;P++)if(s.orientation==="horizontal"){const _=u+P/k*p,A=C+P/k*M;t.textAlign="center",t.fillText(_.toFixed(0),A,w+I+s.axisLabelFontSize)}else{const _=r-P/k*p,A=w+P/k*I;t.textAlign="right",t.fillText(_.toFixed(0),C-6,A)}}if(t.setLineDash([]),s.showXAxis&&(t.lineWidth=s.xAxisLineWidth||1,t.strokeStyle=s.xAxisColor,t.beginPath(),t.moveTo(C,w+I),t.lineTo(C+M,w+I),t.stroke()),s.showYAxis&&(t.lineWidth=s.yAxisLineWidth||1,t.strokeStyle=s.yAxisColor,t.beginPath(),t.moveTo(C,w),t.lineTo(C,w+I),t.stroke()),s.enableShadows&&(t.shadowColor=s.shadowColor),s.chartType==="stacked")if(s.orientation==="horizontal"){const P=I/f;for(let _=0;_<f;_++){const A=w+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",C-5,A),s.enableShadows&&(t.shadowColor=s.shadowColor));let x=C;s.datasets.forEach((W,Y)=>{const B=W.data[_]??0;if(B===0)return;const X=B/p*M,q=Math.min(s.barWidth*d+s.barGap,P-8),j=A-q/2,E=x;x+=X;const L=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,L,E,j,E+X,j),s._drawRoundedBar(t,E,j,X,q,Y===d-1?s.barCornerRadius:0,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?L:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else{const P=M/f;for(let _=0;_<f;_++){const A=C+_*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[_]||"",A,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));let x=w+I;s.datasets.forEach((W,Y)=>{const B=W.data[_]??0;if(B===0)return;const X=B/p*I,q=Math.min(s.barWidth*d+s.barGap,P-8),j=A-q/2,E=x-X;x-=X;const L=s._resolveColor(W.color,Y);t.beginPath(),t.fillStyle=s._makeGradient(t,L,j,E,j,E+X),s._drawRoundedBar(t,j,E,q,X,Y===d-1?s.barCornerRadius:0,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?L:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill()})}}else if(s.orientation==="horizontal"){const P=I/f,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),A=C+(0-u)/p*M;for(let x=0;x<f;x++){const W=w+x*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[x]||"",C-5,W),s.enableShadows&&(t.shadowColor=s.shadowColor));const Y=W-_/2;s.datasets.forEach((B,X)=>{const q=B.data[x]??0,j=Math.abs(q/p*M);if(j<1)return;const E=Y+X*(s.barWidth+s.barGap),L=q>=0?A:A-j,G=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,G,L,E,L+j,E),s._drawRoundedBar(t,L,E,j,s.barWidth,s.barCornerRadius,!1),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&q!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=q>=0?"left":"right",t.textBaseline="middle",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),q>=0?L+j+4:L-4,E+s.barWidth/2),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}else{const P=M/f,_=d*s.barWidth+Math.max(0,(d-1)*s.barGap),A=w+I-(0-u)/p*I;for(let x=0;x<f;x++){const W=C+x*P+P/2;s.showXLabels&&(t.font=s.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=h.axisLabelColor,t.shadowColor="transparent",t.fillText(s.categories[x]||"",W,w+I+5),s.enableShadows&&(t.shadowColor=s.shadowColor));const Y=W-_/2;s.datasets.forEach((B,X)=>{const q=B.data[x]??0,j=Math.abs(q/p*I);if(j<1)return;const E=Y+X*(s.barWidth+s.barGap),L=q>=0?A-j:A,G=s._resolveColor(B.color,X);t.beginPath(),t.fillStyle=s._makeGradient(t,G,E,L,E,L+j),s._drawRoundedBar(t,E,L,s.barWidth,j,s.barCornerRadius,!0),s.barStyle==="outline"||s.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=s.barBorderColor==="auto"?G:s.barBorderColor,t.lineWidth=s.barBorderWidth,s.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),s.showValueOnTop&&q!==0&&(t.font=(s.valueFontWeight||"bold")+" "+(s.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=q>=0?"bottom":"top",t.fillStyle=s.valueColor==="auto"?G:s.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),E+s.barWidth/2,q>=0?L-4:L+j+4),s.enableShadows&&(t.shadowColor=s.shadowColor))})}}t.restore()}renderPieChart(t,i){var m,y;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.options)||i.options||{},s={width:((m=i.geometry)==null?void 0:m.width)||180,height:((y=i.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 us[this.stylePreset]||us.default},_resolveSliceColor:function(b,v){const S=b.color,C=v,w=this._getPreset();return["#6366f1","#22d3ee","#f59e0b","#ec4899","#34d399","#a855f7","#f87171"].includes(S)?w.colors[C%w.colors.length]:typeof S=="string"?S:w.colors[C%w.colors.length]}},n=s.width,a=s.height;if(!s.slices||s.slices.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO PIE DATA",0,0),t.restore();return}const l=s.slices.reduce((b,v)=>b+(v.value||0),0);if(l<=0){t.save(),t.fillStyle="rgba(99,102,241,0.8)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("EMPTY DATA",0,0),t.restore();return}const c=s._getPreset();t.save(),t.beginPath(),t.roundRect(-n/2,-a/2,n,a,10),t.fillStyle=c.cardBackground,t.fill(),t.strokeStyle=c.cardBorderColor,t.lineWidth=1,t.stroke();const h=s.showLegend?Math.ceil(s.slices.length/2):0,r=h>0?h*(s.legendFontSize+8)+10:0,u=a-r-16,f=Math.min(n-24,u)/2,d=0,p=-r/2;if(s.chartType==="rose"){const b=Math.max(...s.slices.map(C=>C.value||0)),v=Math.PI*2/s.slices.length,S=f>0?s.sliceGap/f:0;s.slices.forEach((C,w)=>{const M=C.value||0;if(M===0)return;const I=M/b*f,k=-Math.PI/2+w*v+S/2,T=k+v-S,O=s._resolveSliceColor(C,w);if(t.beginPath(),t.moveTo(d,p),t.arc(d,p,I,k,T),t.closePath(),t.fillStyle=O+"cc",t.fill(),t.strokeStyle=O,t.lineWidth=1.5,t.stroke(),s.showLabels){const P=k+(T-k)/2,_=d+I*.65*Math.cos(P),A=p+I*.65*Math.sin(P),x=Math.round(M/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,_,A),t.restore()}})}else{const b=s.chartType==="pie"?0:s.innerRadius,v=f*Math.max(0,b),S=f>0?s.sliceGap/f:0;let C=-Math.PI/2;if(s.slices.forEach((w,M)=>{const I=w.value||0;if(I===0){C+=I/l*Math.PI*2;return}const k=I/l*Math.PI*2,T=C+S/2,O=C+k-S/2;if(O<=T){C+=k;return}const P=s._resolveSliceColor(w,M);if(t.beginPath(),t.fillStyle=P,v<=0?(t.moveTo(d,p),t.arc(d,p,f,T,O),t.lineTo(d,p)):(t.moveTo(d+f*Math.cos(T),p+f*Math.sin(T)),t.arc(d,p,f,T,O),t.arc(d,p,v,O,T,!0),t.closePath()),t.fill(),s.showLabels){const _=T+(O-T)/2,A=v+(f-v)/2,x=d+A*Math.cos(_),W=p+A*Math.sin(_),Y=Math.round(I/l*100);t.save(),t.font=`bold ${s.labelFontSize}px Inter, sans-serif`,t.fillStyle=c.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${Y}%`,x,W),t.restore()}C+=k}),s.chartType==="donut"&&s.showCenterText&&v>14){const w=Math.round(l),M=Math.min(Math.floor(v*.52),20),I=Math.min(Math.floor(v*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${M}px Inter, sans-serif`,t.fillStyle=c.centerTextColor,t.fillText(w.toString(),d,p-I*.5),s.centerLabel&&(t.font=`${I}px Inter, sans-serif`,t.fillStyle=c.centerLabelColor,t.fillText(s.centerLabel,d,p+M*.6))}}if(s.showLegend&&s.slices.length>0){t.font=`${s.legendFontSize}px Inter, sans-serif`;const b=2,v=n/b,S=s.legendFontSize+8,C=a/2-r+10,w=-n/2+10;s.slices.forEach((M,I)=>{const k=I%b,T=Math.floor(I/b),O=w+k*v,P=C+T*S,_=s._resolveSliceColor(M,I),A=7;t.beginPath(),t.roundRect(O,P-A/2,A,A,2),t.fillStyle=_,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=c.legendColor;const x=Math.round((M.value||0)/l*100),W=`${M.label||"Item"} ${x}%`,Y=v-A-20;let B=W;for(;t.measureText(B).width>Y&&B.length>4;)B=B.slice(0,-4)+"…";t.fillText(B,O+A+4,P)})}t.restore()}renderJoystick(t,i){var p,m,y,b,v;const o=this.objectStates.get(i.id),e=(o==null?void 0:o.width)!==void 0?o.width:((p=i.geometry)==null?void 0:p.width)??i.width??100,s=(o==null?void 0:o.height)!==void 0?o.height:((m=i.geometry)==null?void 0:m.height)??i.height??100,n=Math.min(e,s)*.45,a=Math.min(e,s)*.15;let l=i.handleX||0,c=i.handleY||0;o&&o.handleX!==void 0&&(l=o.handleX),o&&o.handleY!==void 0&&(c=o.handleY),t.save();let h=0,r=0;i.handleOrigin==="top-left"?(h=e/2,r=s/2):i.handleOrigin==="bottom-right"&&(h=-e/2,r=-s/2),t.translate(h,r),t.beginPath(),i.boundsShape==="square"?t.rect(-n,-n,n*2,n*2):t.arc(0,0,n,0,Math.PI*2),t.fillStyle="rgba(0,0,0,0.2)",(y=i.style)!=null&&y.fill&&typeof i.style.fill=="string"?t.fillStyle=i.style.fill:(b=i.style)!=null&&b.fill&&i.style.fill.type==="solid"&&(t.fillStyle=i.style.fill.color),t.fill(),(v=i.style)!=null&&v.stroke&&i.style.stroke.isEnabled!==!1&&(t.lineWidth=i.style.stroke.width||1,t.strokeStyle=i.style.stroke.color||"#000",t.stroke());const u=n-a;let f=0,d=0;i.joystickType==="2D"?(f=l*u,d=c*u):i.joystickType==="1D_X"?(f=l*u,d=0):i.joystickType==="1D_Y"&&(f=0,d=c*u),t.beginPath(),t.arc(f,d,a,0,Math.PI*2),t.fillStyle="#fff",t.fill(),t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1,t.stroke(),t.restore()}getRadioGroupItemIndexAtPointer(t,i,o){var I,k;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.optionsList||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((I=t.geometry)==null?void 0:I.width)||180,l=s.height!==void 0?s.height:((k=t.geometry)==null?void 0:k.height)||100,c=e.orientation||"vertical",h=e.itemGap!==void 0?e.itemGap:16,r=e.fontSize||14,u=this.getWorldTransform(t.id),f=i-u.x,d=o-u.y,p=-u.rotation*(Math.PI/180),m=Math.cos(p),y=Math.sin(p),b=f*m-d*y,v=f*y+d*m,C=8*2,w=-a/2,M=-l/2;if(c==="vertical"){const T=Math.max(C,r)+h;for(let O=0;O<n.length;O++){const P=M+O*T;if(b>=w&&b<=w+a&&v>=P&&v<=P+T)return O}}else{let T=w;for(let O=0;O<n.length;O++){const _=n[O].length*8,A=C+6+_+h;if(b>=T&&b<=T+A&&v>=M&&v<=M+l)return O;T+=A}}return null}renderLineGraph(t,i,o,e){let s=i.datasets||[];if((!s||s.length===0)&&(i.data||i.graphData)&&(s=[{id:"line-1",label:"Series 1",data:i.data||i.graphData||[],lineColor:i.lineColor||"#3b82f6",lineWidth:i.lineWidth||2,showArea:i.showArea||!1,areaColor:i.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:i.smoothing||!1,showPoints:i.showPoints!==void 0?i.showPoints:!0,pointSize:i.pointSize||6,pointFill:i.pointFill||"#ffffff",pointStrokeColor:i.pointStrokeColor||i.lineColor||"#3b82f6",pointStrokeWidth:i.pointStrokeWidth||2}]),!s||s.length===0||!s.some(p=>p.data&&p.data.length>=2)){t.save(),t.fillStyle="#6366f1",t.font="12px Inter, system-ui, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO DATA",0,0),t.restore();return}let n=1/0,a=-1/0,l=0;if(s.forEach(p=>{let m=p.data;if(p.isVarEnabled&&p.inputId){let y=this.inputs.get(p.inputId);if(y===void 0){const b=this.inputNameMap.get(p.inputId);b&&b.length>0&&(y=this.inputs.get(b[0]))}y&&Array.isArray(y)&&(m=y)}if(m&&m.length>0){const y=m.filter(b=>typeof b=="number"&&!isNaN(b));y.length>0&&(n=Math.min(n,...y),a=Math.max(a,...y),l=Math.max(l,m.length))}p._resolvedData=m}),l<2)return;const c=a-n,h=o/(l-1),r=p=>{const m=c===0?.5:(p-n)/c;return e/2-m*e},u=p=>p*h-o/2,f=i.axisColor||"#333333";if(i.showXAxis&&(t.beginPath(),t.strokeStyle=i.xAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,e/2),t.lineTo(o/2,e/2),t.stroke()),i.showYAxis&&(t.beginPath(),t.strokeStyle=i.yAxisColor||f,t.lineWidth=1,t.moveTo(-o/2,-e/2),t.lineTo(-o/2,e/2),t.stroke()),t.fillStyle=i.axisLabelColor||"#333333",t.font=`${i.axisLabelFontSize||10}px Inter, sans-serif`,i.showXLabels){t.textAlign="center",t.textBaseline="top";for(let p=0;p<l;p++){const m=u(p);t.fillText(`${p+1}`,m,e/2+5)}}if(i.showYLabels){t.textAlign="right",t.textBaseline="middle";const p=-o/2-5,m=(a+n)/2;t.fillText(a.toFixed(1),p,r(a)),t.fillText(m.toFixed(1),p,r(m)),t.fillText(n.toFixed(1),p,r(n))}const d=10;if(s.forEach(p=>{const m=p._resolvedData;if(!(!m||m.length<2)){if(p.showArea){if(t.beginPath(),t.moveTo(u(0),e/2),t.lineTo(u(0),r(m[0])),p.smoothing&&m.length>2)for(let b=0;b<m.length-1;b++){const v=m[b===0?b:b-1],S=m[b],C=m[b+1],w=m[b+1===m.length-1?b+1:b+2];for(let M=1;M<=d;M++){const I=M/d,k=this._catmullRom(v,S,C,w,I);t.lineTo(u(b+I),r(k))}}else for(let b=1;b<m.length;b++)t.lineTo(u(b),r(m[b]));t.lineTo(u(m.length-1),e/2),t.closePath();const y=t.globalAlpha;t.globalAlpha=y*(i.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(u(0),r(m[0])),p.smoothing&&m.length>2)for(let y=0;y<m.length-1;y++){const b=m[y===0?y:y-1],v=m[y],S=m[y+1],C=m[y+1===m.length-1?y+1:y+2];for(let w=1;w<=d;w++){const M=w/d,I=this._catmullRom(b,v,S,C,M);t.lineTo(u(y+M),r(I))}}else for(let y=1;y<m.length;y++)t.lineTo(u(y),r(m[y]));t.stroke(),p.showPoints&&m.forEach((y,b)=>{const v=u(b),S=r(y);t.beginPath(),t.arc(v,S,(p.pointSize||6)/2,0,Math.PI*2),t.fillStyle=p.pointFill||"#ffffff",t.fill(),t.strokeStyle=p.pointStrokeColor||p.lineColor||"#3b82f6",t.lineWidth=p.pointStrokeWidth||1,t.stroke()})}}),i.showLegend&&s.length>0){const p=o/2-10;let m=-e/2+15;const y=i.legendFontSize||10,b=y+5;t.font=`${y}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",s.forEach(v=>{const C=v.label||"Series",w=t.measureText(C).width;t.beginPath(),t.rect(p-w-8-5,m-(8/2+2),8,8),t.fillStyle=v.lineColor||"#3b82f6",t.fill(),t.fillStyle=i.legendColor||"#333333",t.fillText(C,p,m),m+=b})}}_catmullRom(t,i,o,e,s){const n=(o-t)*.5,a=(e-i)*.5,l=s*s,c=s*l;return(2*i-2*o+n+a)*c+(-3*i+3*o-2*n-a)*l+n*s+i}normalizeOpacity(t){const i=typeof t=="number"?t:parseFloat(String(t));return isNaN(i)?1:i>1?Math.min(1,i/100):Math.max(0,Math.min(1,i))}createCanvasFill(t,i,o,e){var s,n,a;if(!i||i.type==="None")return null;if(typeof i=="string")return i;if(i.type==="Solid"&&i.color){const l=i.color,h=(((n=(s=this.artboard)==null?void 0:s.tokens)==null?void 0:n.colors)||{})[l]||l;return t.fillStyle=h,h}if((i.type==="LinearGradient"||i.type==="RadialGradient"||i.type==="AngularGradient"||i.type==="DiamondGradient")&&i.stops){const l=(c,h=100)=>{var S,C;const u=(((C=(S=this.artboard)==null?void 0:S.tokens)==null?void 0:C.colors)||{})[c]||c,f=this.normalizeOpacity(i.opacity??100),p=this.normalizeOpacity(h)*f;if(p>=1&&u.startsWith("#"))return u;const m=u.startsWith("#")?u.replace("#",""):"ffffff",y=parseInt(m.substring(0,2),16),b=parseInt(m.substring(2,4),16),v=parseInt(m.substring(4,6),16);return`rgba(${y}, ${b}, ${v}, ${p})`};if(i.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,h=c(i.start,0,"x")*o-o/2,r=c(i.start,1,"y")*e-e/2,u=c(i.end,0,"x")*o-o/2,f=c(i.end,1,"y")*e-e/2,d=t.createLinearGradient(h,r,u,f);if(i.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=l(p.color||"#000000",p.opacity??100);d.addColorStop(Math.max(0,Math.min(1,m)),y)}),i.gradientTransform&&d.setTransform){const[p,m,y,b,v,S]=i.gradientTransform;d.setTransform({a:p,b:m,c:y,d:b,e:v,f:S})}return d}else if(i.type==="RadialGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center,0,"x")*o-o/2,r=c(i.center,1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e),f=t.createRadialGradient(h,r,0,h,r,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return f}else if(i.type==="AngularGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,r=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.degree||i.angle||0)*(Math.PI/180),f=(a=t.createConicGradient)==null?void 0:a.call(t,u,h,r);if(f){if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return f}}else if(i.type==="DiamondGradient"){const c=(d,p,m)=>Array.isArray(d)?d[p]??.5:d&&typeof d=="object"?d[m]??.5:.5,h=c(i.center||[.5,.5],0,"x")*o-o/2,r=c(i.center||[.5,.5],1,"y")*e-e/2,u=(i.radius??.5)*Math.max(o,e);t.save(),t.translate(h,r),t.rotate(Math.PI/4);const f=t.createRadialGradient(0,0,0,0,0,u);if(i.stops.forEach(d=>{const p=d.offset!==void 0?d.offset:d.pos!==void 0?d.pos:d.position!==void 0?d.position:0,m=l(d.color||"#000000",d.opacity??100);f.addColorStop(Math.max(0,Math.min(1,p)),m)}),i.gradientTransform&&f.setTransform){const[d,p,m,y,b,v]=i.gradientTransform;f.setTransform({a:d,b:p,c:m,d:y,e:b,f:v})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=f,t.restore(),f}}if(i.type==="Pattern"&&i.url){let l=this.imageCache.get(i.url);if(l||(l=new Image,l.src=i.url,this.imageCache.set(i.url,l)),l.complete&&l.naturalWidth>0){const c=t.createPattern(l,"repeat");if(c&&(i.scaleX!==void 0||i.offsetX!==void 0)){const h=new DOMMatrix,r=i.scaleX??1,u=i.scaleY??1,f=i.offsetX??0,d=i.offsetY??0,p=i.rotation??0;h.translateSelf(f,d),h.rotateSelf(p),h.scaleSelf(r,u),c.setTransform(h)}return c}}return i.color||null}drawRoundRect(t,i,o,e,s,n){if(n===0||n===void 0||n===null){t.rect(i,o,e,s);return}let a=n;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let l=0,c=0,h=0,r=0;typeof a=="number"?l=c=h=r=a:Array.isArray(a)?a.length===1?l=c=h=r=a[0]:a.length===2?(l=h=a[0],c=r=a[1]):a.length===3?(l=a[0],c=r=a[1],h=a[2]):a.length>=4&&(l=a[0],c=a[1],h=a[2],r=a[3]):a&&typeof a=="object"&&(l=a.tl??a.corner_radius??a.cornerRadius??0,c=a.tr??a.corner_radius??a.cornerRadius??0,h=a.br??a.corner_radius??a.cornerRadius??0,r=a.bl??a.corner_radius??a.cornerRadius??0);const u=Math.min(Math.abs(e)/2,Math.abs(s)/2);if(l=Math.min(Math.max(0,l),u),c=Math.min(Math.max(0,c),u),h=Math.min(Math.max(0,h),u),r=Math.min(Math.max(0,r),u),t.roundRect){t.roundRect(i,o,e,s,[l,c,h,r]);return}t.moveTo(i+l,o),t.lineTo(i+e-c,o),t.arcTo(i+e,o,i+e,o+c,c),t.lineTo(i+e,o+s-h),t.arcTo(i+e,o+s,i+e-h,o+s,h),t.lineTo(i+r,o+s),t.arcTo(i,o+s,i,o+s-r,r),t.lineTo(i,o+l),t.arcTo(i,o,i+l,o,l),t.closePath()}renderListView(t,i){var x,W,Y,B;const o=this.objectStates.get(i.id)||{},e=o.options||i.options||{},s=o.width!==void 0?o.width:((x=i.geometry)==null?void 0:x.width)||200,n=o.height!==void 0?o.height:((W=i.geometry)==null?void 0:W.height)||300,a=-s/2,l=-n/2,c=o.corner_radius!==void 0?o.corner_radius:e.corner_radius??0,h=e.orientation||"vertical",r=e.items||[],u=e.itemGap??10,f=e.itemHeight??50,d=e.itemWidth??200,p=e.scrollOffset??0,m=e.padding??0,y=e.glassEffect!==!1,b=e.accentColor||"#3b82f6",v=e.itemTextColor||"#333333",S=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,M=e.glowIntensity??0,I=e.glowColor||"#3b82f6",k=typeof I=="string"?I:I.color||((B=(Y=I.stops)==null?void 0:Y[0])==null?void 0:B.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:i.opacity!==void 0?i.opacity:1;if(t.save(),t.globalAlpha*=T,M>0){const X=t.getTransform(),q=Math.sqrt(X.a*X.a+X.b*X.b)||1;t.shadowColor=k,t.shadowBlur=M*2*q,t.shadowOffsetX=0,t.shadowOffsetY=0}if(y){const X=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",q=this.createCanvasFill(t,X,s,n);t.fillStyle=q||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.fill();const E=t.createLinearGradient(a,l,a+s,l+n);E.addColorStop(0,"rgba(255, 255, 255, 0.15)"),E.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),E.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=E,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c)||t.stroke()}else{const X=e.backgroundColor||e.listBackgroundColor||"transparent",q=this.createCanvasFill(t,X,s,n);if(q){t.fillStyle=q,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);t.fill()}const j=e.borderWidth??0;if(j>0){t.strokeStyle=e.borderColor||"#cccccc",t.lineWidth=j,t.beginPath();const E=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);t.stroke()}}t.shadowBlur=0,t.save(),t.beginPath();const O=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,l,s,n,c);if(e.listLayout!=="circular")if(O&&e.containerShape==="custom")try{const X=new Path2D(e.containerPath);t.translate(a,l),t.scale(s/100,n/100),t.clip(X),t.scale(100/s,100/n),t.translate(-a,-l)}catch{}else t.clip();const P=typeof m=="number"?m:h==="vertical"?m[0]:m[3];let _=(h==="vertical"?l:a)+p+P;if(t.textBaseline="middle",r.forEach((X,q)=>{const j=e.listLayout||"linear",E=j==="circular"?d:h==="vertical"?s:d,L=j==="circular"||h==="vertical"?f:n;let G=0,z=0,it=0;if(j==="circular"){const Tt=r.length||1,zt=Math.PI*2/Tt,et=e.circularStartAngle||0,yt=e.circularRadius||100,Ot=p*.01+et*Math.PI/180,gt=q*zt+Ot,Mt=a+s/2,Ft=l+n/2;G=Mt+Math.cos(gt)*yt-E/2,z=Ft+Math.sin(gt)*yt-L/2,it=gt+(e.itemRotation||0)*Math.PI/180}else G=h==="vertical"?a:_,z=h==="vertical"?_:l,it=(e.itemRotation||0)*Math.PI/180;const F=C===q,$=w===q,V=$&&e.activeItemShape?e.activeItemShape:e.itemShape||"rectangle",tt=$&&e.activeItemShape?e.activeItemPath:e.itemPath||"",rt=e.itemCornerRadius||0;if(t.save(),it!==0&&(t.translate(G+E/2,z+L/2),t.rotate(it),t.translate(-(G+E/2),-(z+L/2))),$){const Tt=this.createCanvasFill(t,b,E,L);t.fillStyle=Tt||b;const zt=t.globalAlpha;t.globalAlpha=zt*.8,t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill()),t.globalAlpha=zt}else if(F)t.fillStyle=y?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill());else if(S!=="transparent"){const Tt=this.createCanvasFill(t,S,E,L);t.fillStyle=Tt||S,t.beginPath(),this.drawCustomShape(t,V,tt,G,z,E,L,rt)||(t.rect(G,z,E,L),t.fill())}if($||F){const Tt=this.createCanvasFill(t,b,h==="vertical"?3:E,h==="vertical"?L:3);t.fillStyle=Tt||b,h==="vertical"?t.fillRect(G,z,3,L):t.fillRect(G,z+L-3,E,3)}const mt=$?"#ffffff":y?"rgba(255, 255, 255, 0.9)":v;t.fillStyle=mt,t.font=$||F?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ct=typeof X=="string"?X:(X==null?void 0:X.label)||`Item ${q+1}`,ct=G+(h==="vertical"?16:E/2),Pt=z+L/2;h==="horizontal"||j==="circular"?t.textAlign="center":t.textAlign="left";const kt=j==="circular"?G+E/2:ct;t.fillText(Ct,kt,Pt),t.restore(),_+=(h==="vertical"?f:d)+u}),t.restore(),e.showScrollbar!==!1){const X=(r.length||0)*(h==="vertical"?f:d)+((r.length||0)-1)*u,q=h==="vertical"?n:s,j=e.listLayout||"linear",E=e.containerShape==="circle"||j==="circular";if(X>q||j==="circular"&&r.length>0){const L=e.scrollbarColor||"rgba(255,255,255,0.3)",G=e.scrollbarWidth||4;if(E){const z=Math.min(s,n)/2-G/2-2,it=a+s/2,F=l+n/2;if(t.strokeStyle=L,t.lineWidth=G,t.lineCap="round",t.beginPath(),j==="circular"){const $=Math.PI/4,V=-(p*.01)-Math.PI/2;t.arc(it,F,z,V,V+$)}else{const $=Math.PI/2,V=q/X,tt=$*V,rt=-p/X*$,Ct=-Math.PI/4+rt;t.arc(it,F,z,Ct,Ct+tt)}t.stroke()}else{const z=q/X,it=q*z,F=-p/X*q;t.fillStyle=L,h==="vertical"?t.fillRect(a+s-G-2,l+F,G,it):t.fillRect(a+F,l+n-G-2,it,G)}}}t.restore()}drawCustomShape(t,i,o,e,s,n,a,l){if(i==="circle"){const c=Math.min(n,a)/2;return t.arc(e+n/2,s+a/2,c,0,Math.PI*2),!1}else if(i==="pill"){const c=Math.min(n,a)/2;return this.drawListViewRect(t,e,s,n,a,c),!1}else if(i==="custom"&&o)try{const c=new Path2D(o);return t.save(),t.translate(e,s),t.scale(n/100,a/100),t.fill(c),t.restore(),!0}catch{return this.drawListViewRect(t,e,s,n,a,l),!1}return this.drawListViewRect(t,e,s,n,a,l),!1}updateListViewScrollFromPointer(t){var y,b;if(!this._lastPointerPos||!this._prevPointerPos)return;const i=t.options||{},o=i.orientation||"vertical",e=this._lastPointerPos.x-this._prevPointerPos.x,s=this._lastPointerPos.y-this._prevPointerPos.y;o==="vertical"?i.scrollOffset=(i.scrollOffset||0)+s:i.scrollOffset=(i.scrollOffset||0)+e;const n=i.listLayout||"linear",a=this.objectStates.get(t.id)||{},l=i.items||[],c=i.itemGap??10,h=i.itemHeight??50,r=i.itemWidth??200,u=a.width!==void 0?a.width:((y=t.geometry)==null?void 0:y.width)||200,f=a.height!==void 0?a.height:((b=t.geometry)==null?void 0:b.height)||300;if(n==="circular")return;const d=(l.length||0)*(o==="vertical"?h:r)+((l.length||0)-1)*c,m=Math.max(0,d-(o==="vertical"?f:u)+(i.padding*2||0));i.scrollOffset>0&&(i.scrollOffset=0),i.scrollOffset<-m&&(i.scrollOffset=-m)}updateListViewHoverFromPointer(t,i,o){const e=this.getListViewItemIndexAtPointer(t,i,o),s=t.options||{};s.hoveredIndex!==e&&(s.hoveredIndex=e)}getListViewItemIndexAtPointer(t,i,o){var Y,B;const e=t.options||{},s=this.objectStates.get(t.id)||{},n=e.items||[];if(n.length===0)return null;const a=s.width!==void 0?s.width:((Y=t.geometry)==null?void 0:Y.width)||200,l=s.height!==void 0?s.height:((B=t.geometry)==null?void 0:B.height)||300,c=e.orientation||"vertical",h=e.itemGap??10,r=e.itemHeight??50,u=e.itemWidth??200,f=e.scrollOffset??0,d=e.padding??0,p=this.getWorldTransform(t.id),m=i-p.x,y=o-p.y,b=-p.rotation*(Math.PI/180),v=Math.cos(b),S=Math.sin(b),C=m*v-y*S,w=m*S+y*v,M=-a/2,I=-l/2,k=typeof d=="number"?d:c==="vertical"?d[0]:d[3];let T=(c==="vertical"?I:M)+f+k;const O=e.listLayout||"linear",P=n.length||1,_=Math.PI*2/P,A=e.circularStartAngle||0,x=e.circularRadius||100,W=f*.01+A*Math.PI/180;for(let X=0;X<n.length;X++){const q=O==="circular"?u:c==="vertical"?a:u,j=O==="circular"||c==="vertical"?r:l;let E=0,L=0,G=0;if(O==="circular"){const z=X*_+W,it=M+a/2,F=I+l/2;E=it+Math.cos(z)*x-q/2,L=F+Math.sin(z)*x-j/2,G=z+(e.itemRotation||0)*Math.PI/180}else E=c==="vertical"?M:T,L=c==="vertical"?T:I,G=(e.itemRotation||0)*Math.PI/180;if(G!==0){const z=E+q/2,it=L+j/2,F=C-z,$=w-it,V=-G,tt=F*Math.cos(V)-$*Math.sin(V)+z,rt=F*Math.sin(V)+$*Math.cos(V)+it;if(tt>=E&&tt<=E+q&&rt>=L&&rt<=L+j)return X}else if(C>=E&&C<=E+q&&w>=L&&w<=L+j)return X;T+=(c==="vertical"?r:u)+h}return null}drawListViewRect(t,i,o,e,s,n){t.beginPath(),this.drawRoundRect(t,i,o,e,s,n),t.fill()}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:i,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const s=this.objectStates.get(e.id);s&&e.behaviors.forEach(n=>{var u,f,d,p,m,y,b,v,S,C,w,M,I,k,T,O,P,_,A,x,W,Y,B,X,q,j,E,L,G,z,it,F,$,V,tt,rt,mt,Ct,ct,Pt,kt,Tt,zt,et,yt,Ot,gt,Mt,Ft,Vt,Yt,Ht,Kt,ie,ye,me,te,ve,Te,Se,we,_e,ce,ne,ft,bt,st,H,N,ot,vt,xt,It,Wt,St,R,Rt,se,Ut,de,Lt,ut,dt,nt,pt,D,at,Q,$t,Jt,oe,Gt,Qt,qt,Me,Pe,Ee,Ae,xe,Oe,Be,Nt,ae,Ce,Le,Fe,ue,fe,he,Ie,We,Ne,He,Ye,Ue,qe,gs,ys;if(!n.enabled)return;const a=n.startTime||0,l=n.endTime||1/0;if(this.currentTime<a||this.currentTime>l)return;const c=s.x-i,h=s.y-o,r=Math.sqrt(c*c+h*h);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${n.type} on ${e.name}`),n.type===U.Proximity){const K=((u=n.settings)==null?void 0:u.radius)||300,Z=((f=n.settings)==null?void 0:f.falloff)||"smooth";let J=0;r<K&&(Z==="linear"?J=1-r/K:J=Math.pow(1-r/K,2)),n.sensors.forEach(ht=>{this.applyBehaviorSensor(s,ht,J,t,n.settings,e,c,h,r)})}else if(n.type===U.Magnetic){const K=((d=n.settings)==null?void 0:d.radius)||400,Z=((p=n.settings)==null?void 0:p.strength)||.5;if(r<K&&r>5){const J=1-r/K,ht=c*J*Z,_t=h*J*Z;s.x-=ht*t*10,s.y-=_t*t*10}}else if(n.type===U.Repel){const K=((m=n.settings)==null?void 0:m.radius)||300,Z=((y=n.settings)==null?void 0:y.strength)||1;if(r<K){const J=Math.pow(1-r/K,2);s.x+=c/(r||1)*J*60*Z*t*5,s.y+=h/(r||1)*J*60*Z*t*5}}else if(n.type===U.Orbit){const K=((b=n.settings)==null?void 0:b.speed)||1,Z=((v=n.settings)==null?void 0:v.radius)||30,J=this.currentTime*K*Math.PI*2;s.x+=Math.cos(J)*Z*t*5,s.y+=Math.sin(J)*Z*t*5,s.rotation+=2*t*5}else if(n.type===U.Vortex){const K=((S=n.settings)==null?void 0:S.radius)||400,Z=((C=n.settings)==null?void 0:C.speed)||2,J=((w=n.settings)==null?void 0:w.strength)||1;if(r<K){const ht=Math.pow(1-r/K,1.5),_t=this.currentTime*Z*Math.PI*2,At=Math.cos(_t)*30-c*.4,Bt=Math.sin(_t)*30-h*.4;s.x+=At*ht*J*t*5,s.y+=Bt*ht*J*t*5,s.rotation+=5*ht*J*t*5,s.scale_x*=1-ht*.1*J*t,s.scale_y*=1-ht*.1*J*t}}else if(n.type===U.Fluid){const K=((M=n.settings)==null?void 0:M.radius)||300,Z=((I=n.settings)==null?void 0:I.strength)||1;if(r<K){const J=Math.pow(1-r/K,1.2),ht=c/(r||1)*J*1.2*Z,_t=h/(r||1)*J*1.2*Z;s.x+=ht*10*t*5,s.y+=_t*10*t*5,s.scale_x*=1+J*.3*Z*t,s.scale_y*=1+J*.3*Z*t}}else if(n.type===U.Elastic){const K=((k=n.settings)==null?void 0:k.radius)||300,Z=((T=n.settings)==null?void 0:T.strength)||1;if(r<K){const J=1-r/K;s.scale_x*=1+J*.4*Z*t,s.scale_y*=1+J*.4*Z*t}}else if(n.type===U.Holographic){const K=s.x-this.canvasWidth/2,Z=s.y-this.canvasHeight/2,J=((O=n.settings)==null?void 0:O.factor)||25;if(s.x-=K/1e3*J*t*5,s.y-=Z/1e3*J*t*5,s.style){const ht=1-Math.min(1,r/400);s.style.exposure=(s.style.exposure||1)+ht*.5*t}}else if(n.type===U.Sticky){const K=((P=n.settings)==null?void 0:P.radius)||80,Z=((_=n.settings)==null?void 0:_.strength)||1;if(r<K){const J=Math.pow(1-r/K,2);s.x-=c*J*Z*t*10,s.y-=h*J*Z*t*10,s.scale_x*=1-J*.1*Z*t,s.scale_y*=1-J*.1*Z*t}}else if(n.type===U.Dilation){const K=((A=n.settings)==null?void 0:A.size)||120,Z=((x=n.settings)==null?void 0:x.strength)||1;if(r<K){const J=1-r/K;s.scale_x*=1+J*.5*Z*t,s.scale_y*=1+J*.5*Z*t}}else if(n.type===U.Parallax){const K=((W=n.settings)==null?void 0:W.factor)||15,Z=((Y=n.settings)==null?void 0:Y.strength)||1,J=this.canvasWidth/2,ht=this.canvasHeight/2,_t=this._lastPointerPos||{x:J,y:ht},At=(_t.x-J)/J,Bt=(_t.y-ht)/ht,ee=(((B=e.transform)==null?void 0:B.x)??0)+At*K*Z,pe=(((X=e.transform)==null?void 0:X.y)??0)+Bt*K*Z,ke=(((q=e.transform)==null?void 0:q.rotate_x)??0)-Bt*K*1.5*Z,re=(((j=e.transform)==null?void 0:j.rotate_y)??0)+At*K*1.5*Z,be=Math.min(1,10*t);s.x=this.lerp(s.x??((E=e.transform)==null?void 0:E.x)??0,ee,be),s.y=this.lerp(s.y??((L=e.transform)==null?void 0:L.y)??0,pe,be),s.rotate_x=this.lerp(s.rotate_x??((G=e.transform)==null?void 0:G.rotate_x)??0,ke,be),s.rotate_y=this.lerp(s.rotate_y??((z=e.transform)==null?void 0:z.rotate_y)??0,re,be)}else if(n.type===U.Fold){if(r<300){const K=1-r/300,Z=(c>0?-1:1)*K*10,J=1-K*.1,ht=h/300*K*20,_t=-(c/300)*K*20,At=Math.min(1,10*t);s.skew_x=this.lerp(s.skew_x??((it=e.transform)==null?void 0:it.skew_x)??0,Z,At),s.scale_y=this.lerp(s.scale_y??((F=e.transform)==null?void 0:F.scale_y)??1,((($=e.transform)==null?void 0:$.scale_y)??1)*J,At),s.rotate_x=this.lerp(s.rotate_x??((V=e.transform)==null?void 0:V.rotate_x)??0,ht,At),s.rotate_y=this.lerp(s.rotate_y??((tt=e.transform)==null?void 0:tt.rotate_y)??0,_t,At),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((rt=n.settings)==null?void 0:rt.opacity)??.5}}}else if(n.type===U.Crumple){if(r<300){const K=1-r/300,Z=K*(Math.random()-.5)*5,J=K*(Math.random()-.5)*.05,ht=Math.min(1,15*t);s.skew_x=this.lerp(s.skew_x??((mt=e.transform)==null?void 0:mt.skew_x)??0,Z,ht),s.scale_x=this.lerp(s.scale_x??((Ct=e.transform)==null?void 0:Ct.scale_x)??1,(((ct=e.transform)==null?void 0:ct.scale_x)??1)*(1+J),ht),s.scale_y=this.lerp(s.scale_y??((Pt=e.transform)==null?void 0:Pt.scale_y)??1,(((kt=e.transform)==null?void 0:kt.scale_y)??1)*(1+J),ht),s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((Tt=n.settings)==null?void 0:Tt.intensity)??1,scale:((zt=n.settings)==null?void 0:zt.scale)??2}}}else if(n.type===U.Squash){const K=((et=n.settings)==null?void 0:et.strength)||.8;r<(e.width||100)&&this.isMouseDown?(s.scale_y=this.lerp(s.scale_y??1,(((yt=e.transform)==null?void 0:yt.scale_y)??1)*K,.3),s.scale_x=this.lerp(s.scale_x??1,(((Ot=e.transform)==null?void 0:Ot.scale_x)??1)*(1+(1-K)*.4),.3)):(s.scale_y=this.lerp(s.scale_y??1,((gt=e.transform)==null?void 0:gt.scale_y)??1,.2),s.scale_x=this.lerp(s.scale_x??1,((Mt=e.transform)==null?void 0:Mt.scale_x)??1,.2))}else if(n.type===U.TextCounter){const K=((Ft=n.settings)==null?void 0:Ft.duration)||2,Z=((Vt=n.settings)==null?void 0:Vt.from)||0,J=((Yt=n.settings)==null?void 0:Yt.to)||100;n._runtimeStart===void 0&&(n._runtimeStart=this.currentTime);const ht=this.currentTime-n._runtimeStart,_t=Math.min(1,ht/K),At=Math.floor(Z+(J-Z)*_t);if(((Ht=e.geometry)==null?void 0:Ht.type)==="Text"){const Bt=((Kt=n.settings)==null?void 0:Kt.prefix)||"",ee=((ie=n.settings)==null?void 0:ie.suffix)||"";s.geometry||(s.geometry={...e.geometry}),s.geometry.text=`${Bt}${At}${ee}`}}else if(n.type===U.Spotlight){const K=((ye=n.settings)==null?void 0:ye.radius)||250,Z=((me=n.settings)==null?void 0:me.strength)||1.5;if(r<K){const J=Math.pow(1-r/K,2);s.style||(s.style={...e.style}),s.style.adjustments||(s.style.adjustments={...(te=e.style)==null?void 0:te.adjustments}),s.style.adjustments.exposure=(((Te=(ve=e.style)==null?void 0:ve.adjustments)==null?void 0:Te.exposure)||0)+J*Z*50}else(Se=s.style)!=null&&Se.adjustments&&(s.style.adjustments.exposure=this.lerp(s.style.adjustments.exposure||0,((_e=(we=e.style)==null?void 0:we.adjustments)==null?void 0:_e.exposure)||0,.1))}else if(n.type===U.Noise||n.type===U.Float){const K=(((ce=n.settings)==null?void 0:ce.frequency)||((ne=n.settings)==null?void 0:ne.speed)||1)*.002,Z=(((ft=n.settings)==null?void 0:ft.amplitude)||((bt=n.settings)==null?void 0:bt.range)||50)*(((st=n.settings)==null?void 0:st.strength)||1),J=Date.now();s.x+=Math.sin(J*K)*Z*t,s.y+=Math.cos(J*K*.8)*Z*t,s.rotation+=Math.sin(J*K*.5)*5*t}else if(n.type===U.Pulse){const K=(((H=n.settings)==null?void 0:H.speed)||1)*.005,Z=(((N=n.settings)==null?void 0:N.scale)||1.2)-1,J=Math.sin(Date.now()*K),ht=((ot=n.settings)==null?void 0:ot.strength)||1;s.scale_x*=1+J*Z*ht*t,s.scale_y*=1+J*Z*ht*t,s.style&&(s.style.exposure=(s.style.exposure||1)+Math.max(0,J)*.1*ht*t)}else if(n.type===U.Draggable){const K=((vt=n.settings)==null?void 0:vt.radius)||150,Z=this.draggingBehaviors.has(e.id);if(r<K||Z){const J=((xt=n.settings)==null?void 0:xt.strength)||1,ht=Z?1:Math.max(0,1-r/K);this.applyBehaviorSensor(s,jt.PositionX,ht*J,t,n.settings),this.applyBehaviorSensor(s,jt.PositionY,ht*J,t,n.settings)}}else if(n.type===U.Scroll){const K=((It=n.settings)==null?void 0:It.axis)||"vertical",Z=((Wt=n.settings)==null?void 0:Wt.factor)||.5,J=((St=n.settings)==null?void 0:St.strength)||1,ht=((R=n.settings)==null?void 0:R.scaleFactor)||0;(K==="vertical"||K==="both")&&(s.y+=this.scrollOffset.y*Z*J*t),(K==="horizontal"||K==="both")&&(s.x+=this.scrollOffset.x*Z*J*t),ht!==0&&(s.scale_x*=1+this.scrollOffset.y*ht*t,s.scale_y*=1+this.scrollOffset.y*ht*t)}else if(n.type===U.LookAt){const K=((Rt=n.settings)==null?void 0:Rt.factor)||1,Z=((se=n.settings)==null?void 0:se.strength)||1,J=Math.atan2(-h,-c)*(180/Math.PI),ht=s.rotation,_t=(J-ht+180)%360-180;s.rotation+=_t*K*Z*t*10}else if(n.type===U.Scan){const K=(((Ut=n.settings)==null?void 0:Ut.speed)||1)*.004,Z=((de=n.settings)==null?void 0:de.strength)||1,J=(Math.sin(Date.now()*K)+1)/2;s.style&&(s.style.exposure=(s.style.exposure||1)+J*Z*t*5),s.x+=(J-.5)*20*Z*t}else if(n.type===U.Glint)s.style=s.style||{...e.style},s.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Lt=n.settings)==null?void 0:Lt.strength)??.8};else if(n.type===U.Ratchet){const K=((ut=n.settings)==null?void 0:ut.steps)||12,Z=(((dt=n.settings)==null?void 0:dt.speed)||1)*30,J=Math.floor(s.rotation/(360/K))*(360/K);s.rotation=this.lerp(s.rotation,J+Z*t,.1)}else if(n.type===U.Jitter&&r<300){const K=((nt=n.settings)==null?void 0:nt.strength)||1,Z=(((pt=n.settings)==null?void 0:pt.intensity)||5)*K;s.x+=(Math.random()-.5)*Z*t*60,s.y+=(Math.random()-.5)*Z*t*60,s.rotation+=(Math.random()-.5)*Z*t*120}else if(n.type===U.Follower){const K=(D=n.settings)==null?void 0:D.targetId;if(K){const Z=this.objectStates.get(K);if(Z){const J=((at=n.settings)==null?void 0:at.stiffness)||.1,ht=Z.x-s.x,_t=Z.y-s.y;s.x+=ht*J*t*60,s.y+=_t*J*t*60}}}else if(n.type===U.Wrap)s.x<0?s.x=this.canvasWidth:s.x>this.canvasWidth&&(s.x=0),s.y<0?s.y=this.canvasHeight:s.y>this.canvasHeight&&(s.y=0);else if(n.type===U.Gravity){const K=((Q=n.settings)==null?void 0:Q.strength)||9.8;s.y+=K*t*10}else if(n.type===U.Velocity){const K=(($t=n.settings)==null?void 0:$t.vx)||0,Z=((Jt=n.settings)==null?void 0:Jt.vy)||0;s.x+=K*t*10,s.y+=Z*t*10}else if(n.type===U.Shear){const K=((oe=n.settings)==null?void 0:oe.strength)||1,Z=((Gt=n.settings)==null?void 0:Gt.radius)||300;if(r<Z){const J=1-r/Z;s.skew_x=this.lerp(s.skew_x||0,(((Qt=e.transform)==null?void 0:Qt.skew_x)||0)+J*K*30,.1)}else s.skew_x=this.lerp(s.skew_x||0,((qt=e.transform)==null?void 0:qt.skew_x)||0,.05)}else if(n.type===U.Lens){const K=((Me=n.settings)==null?void 0:Me.radius)||200,Z=((Pe=n.settings)==null?void 0:Pe.strength)||.5;if(r<K){const J=Math.pow(1-r/K,2);s.scale_x=this.lerp(s.scale_x??1,(((Ee=e.transform)==null?void 0:Ee.scale_x)??1)*(1+J*Z),.2),s.scale_y=this.lerp(s.scale_y??1,(((Ae=e.transform)==null?void 0:Ae.scale_y)??1)*(1+J*Z),.2)}else s.scale_x=this.lerp(s.scale_x??1,((xe=e.transform)==null?void 0:xe.scale_x)??1,.1),s.scale_y=this.lerp(s.scale_y??1,((Oe=e.transform)==null?void 0:Oe.scale_y)??1,.1)}else if(n.type===U.LayoutAnimation){const K=((Be=n.settings)==null?void 0:Be.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],Z=((Nt=n.settings)==null?void 0:Nt.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const J=this._layoutAnimCache.get(e.id);for(const ht of K){const _t=this.getObjectProperty(s,e,ht);if(_t===void 0)continue;const At=J.get(ht);if(!At)J.set(ht,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(At.to!==_t){const ee=this.getObjectProperty(s,e,ht);J.set(ht,{from:ee??At.from,to:_t,startTime:this.currentTime,duration:((ae=n.settings)==null?void 0:ae.duration)??Z})}const Bt=J.get(ht);if(Bt.duration>0&&Bt.from!==Bt.to){const ee=this.currentTime-Bt.startTime,pe=Math.min(1,ee/Bt.duration),ke=this.applyEasing(pe,((Ce=n.settings)==null?void 0:Ce.easing)||"easeOutCubic"),re=Bt.from+(Bt.to-Bt.from)*ke;this.setObjectProperty(s,e,ht,re)}}}else if(n.type===U.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const K=this._layoutAnimCache.get(e.id),Z=((Le=n.settings)==null?void 0:Le.defaultDuration)||.3,J=["x","y","scale_x","scale_y","opacity","rotation","style.fill.color","style.stroke.width","geometry.cornerRadius","style.blur.value","style.shadow.blur","style.shadow.offsetX","style.shadow.offsetY"];for(const ht of J){const _t=this.getObjectProperty(s,e,ht);if(_t===void 0||typeof _t!="number")continue;const At=K.get(ht);if(!At)K.set(ht,{from:_t,to:_t,startTime:this.currentTime,duration:0});else if(At.to!==_t){const ee=this.getObjectProperty(s,e,ht);K.set(ht,{from:ee??At.from,to:_t,startTime:this.currentTime,duration:Z})}const Bt=K.get(ht);if(Bt.duration>0&&Bt.from!==Bt.to){const ee=this.currentTime-Bt.startTime,pe=Math.min(1,ee/Bt.duration),ke=this.applyEasing(pe,((Fe=n.settings)==null?void 0:Fe.defaultEasing)||"easeOutCubic"),re=Bt.from+(Bt.to-Bt.from)*ke;this.setObjectProperty(s,e,ht,re)}}}else if(n.type===U.SpringChain){const K=((ue=n.settings)==null?void 0:ue.connections)||[],Z=((fe=n.settings)==null?void 0:fe.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const J=this._springChainState.get(e.id);for(const _t of K){if(!J.has(_t.targetId)){const At=this.objectStates.get(_t.targetId);J.set(_t.targetId,{x:(At==null?void 0:At.x)??0,y:(At==null?void 0:At.y)??0,vx:0,vy:0})}J.has(e.id)||J.set(e.id,{x:s.x,y:s.y,vx:0,vy:0})}const ht=J.get(e.id);if(ht){ht.x=s.x,ht.y=s.y;for(const _t of K){const At=J.get(_t.targetId);if(!At)continue;const Bt=At.x-ht.x,ee=At.y-ht.y,pe=Math.sqrt(Bt*Bt+ee*ee)||.001,re=(pe-(_t.restLength||50))*(_t.stiffness||.8),be=Bt/pe*re,Ke=ee/pe*re;ht.vx+=be*t*10,ht.vy+=Ke*t*10,At.vx-=be*t*10,At.vy-=Ke*t*10,ht.vx*=1-Z*t*10,ht.vy*=1-Z*t*10,At.vx*=1-Z*t*10,At.vy*=1-Z*t*10;const ge=this.objectStates.get(_t.targetId);ge&&(ge.x+=At.vx*t,ge.y+=At.vy*t)}s.x+=ht.vx*t,s.y+=ht.vy*t}}else if(n.type===U.ParticleEmitter){const K=((he=n.settings)==null?void 0:he.rate)||10,Z=((Ie=n.settings)==null?void 0:Ie.speed)||100,J=((We=n.settings)==null?void 0:We.size)||5,ht=((Ne=n.settings)==null?void 0:Ne.lifetime)||2,_t=((He=n.settings)==null?void 0:He.gravity)||0,At=((Ye=n.settings)==null?void 0:Ye.color)||"#ffffff",Bt=((Ue=n.settings)==null?void 0:Ue.maxParticles)||200,ee=(qe=n.settings)!=null&&qe.rateInputId?this.inputs.get(n.settings.rateInputId)??K:K,pe=(gs=n.settings)!=null&&gs.gravityInputId?this.inputs.get(n.settings.gravityInputId)??_t:_t,ke=(ys=n.settings)!=null&&ys.speedInputId?this.inputs.get(n.settings.speedInputId)??Z:Z;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const re=this._emitterPools.get(e.id);let be=0;n._pendingBurst&&n._pendingBurst>0&&(be=n._pendingBurst,n._pendingBurst=0);const Ke=Math.floor(ee*t)+(be||0);for(let ge=0;ge<Math.min(Ke,Bt-re.length);ge++){const le=Math.random()*Math.PI*2,ms=ke*(.5+Math.random()*.5);re.push({x:s.x,y:s.y,vx:Math.cos(le)*ms,vy:Math.sin(le)*ms,life:0,maxLife:ht*(.5+Math.random()*.5),size:J*(.5+Math.random()),color:At,opacity:1})}for(let ge=re.length-1;ge>=0;ge--){const le=re[ge];le.vy+=pe*t*10,le.x+=le.vx*t,le.y+=le.vy*t,le.life+=t,le.opacity=Math.max(0,1-le.life/le.maxLife),le.life>=le.maxLife&&re.splice(ge,1)}}})})}applyBehaviorSensor(t,i,o,e,s,n,a=0,l=0,c=1){var d,p,m,y,b,v,S,C,w,M,I,k,T,O,P,_,A,x,W,Y,B,X,q,j;const h=(s==null?void 0:s.intensity)||(s==null?void 0:s.strength)||1,r=Math.min(1,15*e),u=c>0?a/c:0,f=c>0?l/c:0;switch(i){case jt.Scale:{const E=((d=n==null?void 0:n.transform)==null?void 0:d.scale_x)??1,L=((p=n==null?void 0:n.transform)==null?void 0:p.scale_y)??1,G=E*(1+o*h*.4),z=L*(1+o*h*.4);t.scale_x=(t.scale_x??E)*(1-r)+G*r,t.scale_y=(t.scale_y??L)*(1-r)+z*r;break}case jt.Opacity:{const E=((m=n==null?void 0:n.transform)==null?void 0:m.opacity)??100,L=Math.max(0,Math.min(100,E-o*h*100));t.opacity=(t.opacity??E)*(1-r)+L*r;break}case jt.RotateZ:{const E=((y=n==null?void 0:n.transform)==null?void 0:y.rotation)??0,L=E+o*h*45;t.rotation=(t.rotation??E)*(1-r)+L*r;break}case jt.RotateX:{const E=((b=n==null?void 0:n.transform)==null?void 0:b.rotate_x)??0,L=E-f*o*h*60;t.rotate_x=(t.rotate_x??E)*(1-r)+L*r;break}case jt.RotateY:{const E=((v=n==null?void 0:n.transform)==null?void 0:v.rotate_y)??0,L=E+u*o*h*60;t.rotate_y=(t.rotate_y??E)*(1-r)+L*r;break}case jt.PositionX:{const E=((S=n==null?void 0:n.transform)==null?void 0:S.x)??0,L=E-u*o*h*40;t.x=(t.x??E)*(1-r)+L*r;break}case jt.PositionY:{const E=((C=n==null?void 0:n.transform)==null?void 0:C.y)??0,L=E-f*o*h*40;t.y=(t.y??E)*(1-r)+L*r;break}case jt.SkewX:{const E=((w=n==null?void 0:n.transform)==null?void 0:w.skew_x)??0,L=E+u*o*h*45;t.skew_x=(t.skew_x??E)*(1-r)+L*r,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={...(M=n==null?void 0:n.style)==null?void 0:M.blur});const E=((k=(I=n==null?void 0:n.style)==null?void 0:I.blur)==null?void 0:k.amount)||0,L=E+o*((s==null?void 0:s.blur)||20)*h;t.style.blur.amount=(t.style.blur.amount??E)*(1-r)+L*r;break}case jt.Exposure:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(T=n==null?void 0:n.style)==null?void 0:T.adjustments});const E=((P=(O=n==null?void 0:n.style)==null?void 0:O.adjustments)==null?void 0:P.exposure)||0,L=E+o*((s==null?void 0:s.exposure)||50)*h;t.style.adjustments.exposure=(t.style.adjustments.exposure??E)*(1-r)+L*r;break}case jt.HueShift:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(_=n==null?void 0:n.style)==null?void 0:_.adjustments});const E=((x=(A=n==null?void 0:n.style)==null?void 0:A.adjustments)==null?void 0:x.hue)||0,L=E+o*((s==null?void 0:s.hue)||180)*h;t.style.adjustments.hue=(t.style.adjustments.hue??E)*(1-r)+L*r;break}case jt.Negative:{t.style||(t.style={...n==null?void 0:n.style}),t.style.adjustments||(t.style.adjustments={...(W=n==null?void 0:n.style)==null?void 0:W.adjustments});const E=((B=(Y=n==null?void 0:n.style)==null?void 0:Y.adjustments)==null?void 0:B.negative)||0,L=E+o*((s==null?void 0:s.negative)||100)*h;t.style.adjustments.negative=(t.style.adjustments.negative??E)*(1-r)+L*r;break}case jt.CornerRadius:{const E=((X=n==null?void 0:n.transform)==null?void 0:X.corner_radius)||0,L=E+o*h*50;t.corner_radius=(t.corner_radius??E)*(1-r)+L*r;break}case jt.StrokeWidth:{t.style||(t.style={...n==null?void 0:n.style});const E=((q=n==null?void 0:n.style)==null?void 0:q.borderWidth)||0,L=E+o*h*10;t.style.borderWidth=(t.style.borderWidth??E)*(1-r)+L*r;break}case jt.LetterSpacing:{t.geometry||(t.geometry={});const E=((j=n==null?void 0:n.geometry)==null?void 0:j.letterSpacing)||0,L=E+o*h*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??E)*(1-r)+L*r;break}}}getObjectProperty(t,i,o){const e=o.split(".");let s=t;for(const n of e){if(s==null||typeof s!="object")return;if(n==="style"&&t.style===void 0){s=i.style;continue}s=s[n]}return typeof s=="number"?s:void 0}setObjectProperty(t,i,o,e){const s=o.split(".");let n=t;for(let l=0;l<s.length-1;l++){const c=s[l];if(n[c]===void 0||n[c]===null){const h=i,r=s.slice(0,l+1).reduce((u,f)=>u==null?void 0:u[f],h);n[c]=r!==void 0?{...r}:{}}n=n[c]}const a=s[s.length-1];n!=null&&(n[a]=e)}applyEasing(t,i){switch(i){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,i,o){return t*(1-o)+i*o}deepMerge(t,i){if(!t)return i;if(!i)return t;if(typeof t!="object"||typeof i!="object"||t===null||i===null)return i;const o={...t};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(i[e]&&typeof i[e]=="object"&&!Array.isArray(i[e])?o[e]=this.deepMerge(t[e],i[e]):o[e]=i[e]);return o}renderFittedImage(t,i,o,e,s,n,a="cover"){const l=i.naturalWidth,c=i.naturalHeight,h=l/c,r=s/n;let u=s,f=n,d=o,p=e;a==="cover"?h>r?(u=n*h,d=o-(u-s)/2):(f=s/h,p=e-(f-n)/2):a==="contain"&&(h>r?(f=s/h,p=e+(n-f)/2):(u=n*h,d=o+(s-u)/2)),t.drawImage(i,d,p,u,f)}}const ni=Et.forwardRef(({artboard:g,src:t,style:i,autoPlay:o=!0,fit:e="Contain",alignment:s="Center",onReady:n,onTrigger:a,onInputUpdate:l,onComponentChange:c,onToggle:h,onInputChange:r,onInputFocus:u,onInputBlur:f,onLog:d,onLogicUpdate:p,onButtonClick:m,onGraphPointClick:y,currentTime:b,revision:v=0,scrollY:S,scrollX:C,mouseX:w,mouseY:M,isMouseDown:I,inputs:k,interactive:T=!0,onNavigation:O},P)=>{const _=Et.useRef(null),A=Et.useRef(null);A.current||(A.current=new ps);const x=Et.useRef(void 0),W=Et.useRef(0),Y=Et.useRef(null),B=Et.useRef(v),X=Et.useRef(null),[,q]=Et.useState(g||null),j=Et.useRef(!0);Et.useImperativeHandle(P,()=>_.current),Et.useEffect(()=>(j.current=!0,()=>{j.current=!1,x.current&&cancelAnimationFrame(x.current)}),[]),Et.useEffect(()=>{A.current.setLayout(e,s)},[e,s]),Et.useEffect(()=>{const F=A.current;a&&F.setTriggerCallback(a),l&&F.setInputUpdateCallback(($,V)=>l({[$]:V})),c&&F.setComponentChangeCallback($=>c($)),h&&F.setToggleCallback(h),r&&F.setInputChangeCallback(r),u&&F.setInputFocusCallback(u),f&&F.setInputBlurCallback(f),d&&F.setOnLogCallback($=>d($,"info")),p&&F.setLogicUpdateCallback(p),m&&F.setButtonClickCallback(m),y&&F.setGraphPointClickCallback($=>y($.objectId,$)),O&&F.setNavigationCallback(O)},[a,l,c,h,r,u,f,d,p,m,y,O]),Et.useEffect(()=>{(async()=>{let $=g;if(t&&!g)try{t.startsWith("{")?$=JSON.parse(t):$=await(await fetch(t)).json()}catch(V){console.error("[ExodeUI] Failed to load src:",V)}if($){const V=A.current,tt=$.id||$.name||"default";(Y.current!==tt||B.current!==v||X.current!==$)&&(V.load($),Y.current=tt,B.current=v,X.current=$,q($),W.current=0,V.advance(0)),n&&n(V)}})()},[g,t,v]),Et.useEffect(()=>{const F=$=>{if(!A.current||!j.current)return;const V=A.current,tt=_.current;if(!tt)return;const rt=tt.getContext("2d");if(!rt)return;const mt=$/1e3;W.current===0&&(W.current=mt);let Ct=mt-W.current;Ct>.1&&(Ct=.1),W.current=mt;const ct=tt.getBoundingClientRect(),Pt=window.devicePixelRatio||1,kt=Math.round(ct.width*Pt),Tt=Math.round(ct.height*Pt);(tt.width!==kt||tt.height!==Tt)&&(tt.width=kt,tt.height=Tt);try{o?V.advance(Ct):b!==void 0&&V.seek(b),V.render(rt,tt.width,tt.height)}catch(zt){console.error("[ExodeUICanvas] Error in animation loop:",zt),d&&d(`[Error] Animation loop crashed: ${zt}`,"error")}x.current=requestAnimationFrame(F)};return x.current=requestAnimationFrame(F),()=>{x.current&&cancelAnimationFrame(x.current)}},[o,b]),Et.useEffect(()=>{const F=A.current;S!==void 0&&F.updateInput("scrollY",S),C!==void 0&&F.updateInput("scrollX",C),w!==void 0&&F.updateInput("mouseX",w),M!==void 0&&F.updateInput("mouseY",M),I!==void 0&&F.updateInput("isMouseDown",I),k&&Object.entries(k).forEach(([$,V])=>F.updateInput($,V))},[S,C,w,M,I,k]);const E=(F,$)=>{if(!T||!_.current)return;F.stopPropagation(),"nativeEvent"in F&&F.nativeEvent&&typeof F.nativeEvent.stopImmediatePropagation=="function"?F.nativeEvent.stopImmediatePropagation():typeof F.stopImmediatePropagation=="function"&&F.stopImmediatePropagation();const V=_.current,tt=V.getBoundingClientRect(),rt=F.clientX-tt.left,mt=F.clientY-tt.top,Ct=window.devicePixelRatio||1;($==="click"||$==="down"||$==="up")&&d&&d(`[Canvas] Pointer ${$} at rect(${Math.round(rt)},${Math.round(mt)}) mapped to buffer(${Math.round(rt*Ct)},${Math.round(mt*Ct)})`,"info"),A.current.handlePointerInput($,rt*Ct,mt*Ct,V.width,V.height)};Et.useEffect(()=>{if(!T)return;const F=V=>{var tt,rt,mt;((tt=document.activeElement)==null?void 0:tt.tagName)==="INPUT"||((rt=document.activeElement)==null?void 0:rt.tagName)==="TEXTAREA"||(mt=A.current)==null||mt.handleKeyDown(V)},$=V=>{var tt,rt,mt;((tt=document.activeElement)==null?void 0:tt.tagName)==="INPUT"||((rt=document.activeElement)==null?void 0:rt.tagName)==="TEXTAREA"||(mt=A.current)==null||mt.handleKeyUp(V)};return window.addEventListener("keydown",F),window.addEventListener("keyup",$),()=>{window.removeEventListener("keydown",F),window.removeEventListener("keyup",$)}},[T]);const[L,G]=Et.useState([]);Et.useEffect(()=>{if(g&&g.objects){const F=g.objects.filter($=>{var V,tt;return $.type==="Joystick"&&((V=$.inputBinding)==null?void 0:V.type)==="keyboard"&&((tt=$.inputBinding.keyboardConfig)==null?void 0:tt.showVirtualKeyboard)});G(F)}},[g]);const[,z]=Et.useState(0);Et.useEffect(()=>{if(L.length===0)return;let F;const $=()=>{z(V=>V+1),F=requestAnimationFrame($)};return F=requestAnimationFrame($),()=>cancelAnimationFrame(F)},[L.length]);const it=()=>L.map(F=>{const $=F.inputBinding.keyboardConfig,V=ct=>{var kt;const Pt={key:ct,code:ct,preventDefault:()=>{}};(kt=A.current)==null||kt.handleKeyDown(Pt)},tt=ct=>{var kt;const Pt={key:ct,code:ct,preventDefault:()=>{}};(kt=A.current)==null||kt.handleKeyUp(Pt)},rt=A.current,mt=ct=>rt&&rt.activeKeys?rt.activeKeys.has(ct.toLowerCase()):!1,Ct=ct=>({width:"50px",height:"50px",background:ct?"rgba(255, 255, 255, 0.4)":"rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontWeight:"bold",fontSize:"18px",userSelect:"none",cursor:"pointer",backdropFilter:"blur(8px)",transition:"background 0.1s",boxShadow:ct?"none":"0 4px 6px rgba(0,0,0,0.1)"});return Xt.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[Xt.jsx("div",{style:Ct(mt($.upKey)),onMouseDown:()=>V($.upKey),onMouseUp:()=>tt($.upKey),onMouseLeave:()=>tt($.upKey),onTouchStart:ct=>{ct.preventDefault(),V($.upKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.upKey)},children:$.upKey.toUpperCase()}),Xt.jsxs("div",{style:{display:"flex",gap:"8px"},children:[Xt.jsx("div",{style:Ct(mt($.leftKey)),onMouseDown:()=>V($.leftKey),onMouseUp:()=>tt($.leftKey),onMouseLeave:()=>tt($.leftKey),onTouchStart:ct=>{ct.preventDefault(),V($.leftKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.leftKey)},children:$.leftKey.toUpperCase()}),Xt.jsx("div",{style:Ct(mt($.downKey)),onMouseDown:()=>V($.downKey),onMouseUp:()=>tt($.downKey),onMouseLeave:()=>tt($.downKey),onTouchStart:ct=>{ct.preventDefault(),V($.downKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.downKey)},children:$.downKey.toUpperCase()}),Xt.jsx("div",{style:Ct(mt($.rightKey)),onMouseDown:()=>V($.rightKey),onMouseUp:()=>tt($.rightKey),onMouseLeave:()=>tt($.rightKey),onTouchStart:ct=>{ct.preventDefault(),V($.rightKey)},onTouchEnd:ct=>{ct.preventDefault(),tt($.rightKey)},children:$.rightKey.toUpperCase()})]})]},F.id)});return Xt.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[Xt.jsx("canvas",{ref:_,onPointerDown:F=>{var $;E(F,"down"),($=_.current)==null||$.focus()},onPointerMove:F=>E(F,"move"),onPointerUp:F=>E(F,"up"),onPointerCancel:F=>E(F,"up"),onClick:F=>E(F,"click"),onWheel:F=>{A.current.handleWheel(F.deltaX,F.deltaY)},onKeyDown:F=>A.current.handleKeyDown(F.nativeEvent),onKeyUp:F=>A.current.handleKeyUp(F.nativeEvent),onContextMenu:F=>F.preventDefault(),tabIndex:0,style:{...i,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),it()]})});function oi(){const[g,t]=Et.useState(null),i=Et.useCallback((r,u)=>{g==null||g.setInputBool(r,u)},[g]),o=Et.useCallback((r,u)=>{g==null||g.setInputNumber(r,u)},[g]),e=Et.useCallback(r=>{g==null||g.fireTrigger(r)},[g]),s=Et.useCallback((r,u)=>{g==null||g.setInputText(r,u)},[g]),n=Et.useCallback((r,u)=>{g==null||g.setInputNumberArray(r,u)},[g]),a=Et.useCallback((r,u)=>{g==null||g.setInputStringArray(r,u)},[g]),l=Et.useCallback((r,u)=>{g==null||g.updateObjectOptions(r,u)},[g]),c=Et.useCallback((r,u,f)=>{g==null||g.updateConstraint(r,u,f)},[g]),h=Et.useCallback((r,u)=>{g==null||g.updateGraphData(r,u)},[g]);return{setEngine:t,engine:g,setInputBool:i,setInputNumber:o,fireTrigger:e,setInputText:s,setInputNumberArray:n,setInputStringArray:a,updateConstraint:c,updateGraphData:h,updateObjectOptions:l}}const ai=({artboard:g,config:t})=>{const i={...g.seo,...t},o=i.enableSmartExtraction!==!1;Et.useEffect(()=>{const a=i.title||g.name;a&&(document.title=a);let l=i.description;if(!l&&o){const r=g.objects.filter(u=>{var f;return((f=u.geometry)==null?void 0:f.type)==="Text"}).sort((u,f)=>{var d,p;return(((d=f.geometry.text)==null?void 0:d.length)||0)-(((p=u.geometry.text)==null?void 0:p.length)||0)});r.length>0&&(l=r[0].geometry.text)}l&&(e("name","description",l),e("property","og:description",l)),i.keywords&&i.keywords.length>0&&e("name","keywords",i.keywords.join(", "));const c=i.ogImage||g.backgroundImage;c&&e("property","og:image",c),a&&e("property","og:title",a),e("property","og:type","website")},[i,g,o]);const e=(a,l,c)=>{let h=document.querySelector(`meta[${a}="${l}"]`);h||(h=document.createElement("meta"),h.setAttribute(a,l),document.head.appendChild(h)),h.setAttribute("content",c)},s=()=>{const a=[];return a.push(Xt.jsx("h1",{children:i.title||g.name},"artboard-title")),g.objects.forEach((c,h)=>{var r,u;if(!(c.visible===!1||c.isVisible===!1))if(((r=c.geometry)==null?void 0:r.type)==="Text"){const f=c.geometry.text;f&&(c.geometry.fontSize>24?a.push(Xt.jsx("h2",{children:f},c.id||h)):a.push(Xt.jsx("p",{children:f},c.id||h)))}else if(((u=c.geometry)==null?void 0:u.type)==="Image"){const f=c.geometry.src,d=c.altText||c.name||"Illustration";a.push(Xt.jsx("img",{src:f,alt:d},c.id||h))}else c.type==="Button"&&a.push(Xt.jsx("button",{children:c.name||"Button"},c.id||h))}),a},n=i.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:i.title||g.name,description:i.description,image:i.ogImage||g.backgroundImage,abstract:"Animated interface created with ExodeUI"};return Xt.jsxs("div",{id:`exode-seo-${g.id||"default"}`,"aria-hidden":"false",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0",zIndex:-1},children:[s(),Xt.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})]})},ri={version:"6.3.34"}.version;Dt.BehaviorSensor=jt,Dt.BehaviorType=U,Dt.ConditionOp=Qe,Dt.ExodeSEO=ai,Dt.ExodeUICanvas=ni,Dt.ExodeUIEngine=ps,Dt.LogicOp=wt,Dt.RapierPhysics=es,Dt.VERSION=ri,Dt.useExodeUI=oi,Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -4059,11 +4059,17 @@ class ci {
4059
4059
  });
4060
4060
  }
4061
4061
  applyObjectTransform(t, i) {
4062
+ var d, p, y;
4062
4063
  const o = this.objectStates.get(i);
4063
4064
  if (!o) return;
4064
- t.translate(o.x, o.y), t.rotate(o.rotation * Math.PI / 180);
4065
- const e = (o.scale_x ?? 1) * (o.flip_x === !0 ? -1 : 1), s = (o.scale_y ?? 1) * (o.flip_y === !0 ? -1 : 1);
4066
- t.scale(e, s);
4065
+ t.translate(o.x, o.y), t.rotate((o.rotation ?? 0) * Math.PI / 180);
4066
+ const e = o.skew_x || 0, s = o.skew_y || 0;
4067
+ if (e !== 0 || s !== 0) {
4068
+ const m = Math.tan(e * Math.PI / 180), b = Math.tan(s * Math.PI / 180);
4069
+ t.transform(1 + m * b, b, m, 1, 0, 0);
4070
+ }
4071
+ const n = o.rotate_x !== void 0 ? o.rotate_x : ((d = o.transform) == null ? void 0 : d.rotate_x) ?? 0, a = o.rotate_y !== void 0 ? o.rotate_y : ((p = o.transform) == null ? void 0 : p.rotate_y) ?? 0, c = 1 + (o.translate_z !== void 0 ? o.translate_z : ((y = o.transform) == null ? void 0 : y.translate_z) ?? 0) / 1e3, f = (o.flip_x === !0 ? -1 : 1) * Math.cos(a * Math.PI / 180) * c, r = (o.flip_y === !0 ? -1 : 1) * Math.cos(n * Math.PI / 180) * c, u = (o.scale_x ?? 1) * f, h = (o.scale_y ?? 1) * r;
4072
+ t.scale(u, h);
4067
4073
  }
4068
4074
  applyArtEffectOverlay(t, i, o, e, s, n) {
4069
4075
  var h, d, p, y, m;
@@ -6106,7 +6112,7 @@ const vi = ({ artboard: g, config: t }) => {
6106
6112
  ]
6107
6113
  }
6108
6114
  );
6109
- }, hi = "6.3.33", fi = {
6115
+ }, hi = "6.3.34", fi = {
6110
6116
  version: hi
6111
6117
  }, Si = fi.version;
6112
6118
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodeui",
3
- "version": "6.3.33",
3
+ "version": "6.3.34",
4
4
  "description": "React Runtime for ExodeUI Animation Engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",