exodeui 6.4.6 → 7.0.0

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
@@ -16,4 +16,4 @@
16
16
  `||p[ut]==="\r");if(Ft&&St>0&&ut++,Ft){if(((lt=J.top)==null?void 0:lt.width)>0){const dt=U+St*Y-J.top.offset;t.strokeStyle=J.top.color||"#000000",t.lineWidth=J.top.width,t.beginPath();const At=-i/2+Y*.2;t.moveTo(At,dt),t.lineTo(i/2-Y*.2,dt),t.stroke()}if(((ht=J.bottom)==null?void 0:ht.width)>0){const dt=U+(St+1)*Y-J.bottom.offset;t.strokeStyle=J.bottom.color||"#000000",t.lineWidth=J.bottom.width,t.beginPath();const At=-i/2+Y*.2;t.moveTo(At,dt),t.lineTo(i/2-Y*.2,dt),t.stroke()}}ut+=($t.text||"").length})}if(e.stroke&&e.stroke.width>0){const ut=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;const St=t.getTransform(),Pt=Math.sqrt(St.a*St.a+St.b*St.b)||1,Ft=window.devicePixelRatio||1;t.lineWidth=(e.stroke.width||1)*Ft/Pt,t.globalAlpha=ut*this.normalizeOpacity(e.stroke.opacity??100);let lt=0,ht=U;(F||[]).forEach(dt=>{let At=-_/2;I==="center"?At=0:I==="right"&&(At=_/2),z(dt.text,At,ht,!0,lt),lt+=(dt.text||"").length,ht+=Y,lt<p.length&&(p[lt]===`
17
17
  `||p[lt]==="\r")&&(A>0&&(ht+=A),lt++,p[lt-1]==="\r"&&p[lt]===`
18
18
  `&&lt++)}),t.globalAlpha=ut}}}applyStrokeAlignment(t,s,o,e,n,i){if(!s.stroke||s.stroke.width<=0||s.stroke.isEnabled===!1)return;const a=s.stroke,r=t.getTransform(),l=Math.sqrt(r.a*r.a+r.b*r.b)||1,d=window.devicePixelRatio||1,p=(a.width||1)*d/l,g=(a.alignment||"center").toLowerCase();if(t.save(),s.fill&&s.fill.type!=="None"&&s.fill.isEnabled!==!1&&s.fill.opacity!==0&&s.fill.color!=="transparent"&&s.fill.color!=="rgba(0,0,0,0)"&&(t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),a.fill){const v=this.createCanvasFill(t,a.fill,e,n);v?t.strokeStyle=v:t.strokeStyle=a.color||"#000000"}else t.strokeStyle=a.color||"#000000";const f=t.globalAlpha;t.globalAlpha=f*this.normalizeOpacity(a.opacity??100),t.lineWidth=p,t.lineCap=a.lineCap||"round",t.lineJoin=a.lineJoin||"round",a.miterLimit!==void 0&&(t.miterLimit=a.miterLimit);const h=a.trimStart??0,m=a.trimEnd??1,b=a.trimOffset??0,c=a.dashOffset??0,S=a.dashArray||[];if(h!==0||m!==1||b!==0){const v=this.getPerimeter(o,e,n);if(v>0){const C=Math.max(0,Math.min(1,h)),w=Math.max(0,Math.min(1,m));if(C<w){const I=v*(w-C),k=v-I,O=-(v*(C+b%1));t.setLineDash([I,k]),t.lineDashOffset=O-c*v}else if(C===w)t.setLineDash([0,v]);else{const I=v*(1-C+w),k=v-I,O=-(v*C);t.setLineDash([I,k]),t.lineDashOffset=O-c*v}}}else if(S.length>0||c!==0){S.length>0&&t.setLineDash(S);const v=this.getPerimeter(o,e,n);t.lineDashOffset=-(c*v)}if((o==null?void 0:o.type)==="Line"||e===0||n===0)this.applyPath(t,o,e,n,i),t.stroke();else if(g==="inside")t.lineWidth=p*2,t.save(),this.applyPath(t,o,e,n,i),t.clip(),t.stroke(),t.restore();else if(g==="outside"){t.save(),t.beginPath();const v=Math.max(e,n,2e4);t.rect(-v,-v,v*2,v*2),this._tracePath(t,o,e,n,i),t.clip("evenodd"),t.lineWidth=p*2,t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke(),t.restore()}else t.lineWidth=p,this.applyPath(t,o,e,n,i),t.stroke();t.restore()}getPerimeter(t,s,o){switch(this.ensurePathPoints(t),t==null?void 0:t.type){case"Rectangle":return(s+o)*2;case"Ellipse":{const e=Math.abs(s)/2,n=Math.abs(o)/2,i=Math.abs(t.sweepAngle??360),a=t.ratio||0,r=Math.PI*(3*(e+n)-Math.sqrt((3*e+n)*(e+3*n)));if(i>=360&&a<=0)return r;let l=i/360*r;if(a>0){const d=Math.PI*(3*(e*a+n*a)-Math.sqrt((3*e*a+n*a)*(e*a+3*n*a)));l+=i/360*d,i<360&&(l+=2*Math.sqrt((e-e*a)**2+(n-n*a)**2))}else i<360&&(l+=2*Math.max(e,n));return isNaN(l)?0:l}case"Line":return t.length||Math.sqrt(s*s+o*o);case"Triangle":return s+Math.sqrt((s/2)**2+o**2)*2;case"Polygon":{const e=t.sides||3,n=t.radius||Math.min(s,o)/2;return 2*e*n*Math.sin(Math.PI/e)}case"Star":{const e=t.points||5,n=t.outer_radius||Math.min(s,o)/2,i=t.inner_radius||n/2,a=Math.PI/e;return Math.sqrt(n*n+i*i-2*n*i*Math.cos(a))*e*2}case"Path":{const e=t.points||[];if(e.length<2)return t.length||0;let n=0,i=e[0].x,a=e[0].y;for(let r=1;r<e.length;r++){const l=e[r];if(l.moveTo){i=l.x,a=l.y;continue}const d=i,p=a,g=e[r-1].out_x,u=e[r-1].out_y;if(g!==void 0||l.in_x!==void 0?n+=this.getBezierLength(d,p,g??d,u??p,l.in_x??l.x,l.in_y??l.y,l.x,l.y):n+=Math.sqrt((l.x-d)**2+(l.y-p)**2),i=l.x,a=l.y,l.closePath||r===e.length-1&&(t.is_closed||t.isClosed)){const f=i,h=a,m=[...e.slice(0,r+1)].reverse().find(I=>I.moveTo)||e[0],b=m.x,c=m.y,S=e[r].out_x,v=e[r].out_y,C=m.in_x,w=m.in_y;S!==void 0||C!==void 0?n+=this.getBezierLength(f,h,S??f,v??h,C??b,w??c,b,c):n+=Math.sqrt((b-f)**2+(c-h)**2)}}return n}default:return(s+o)*2}}getBezierLength(t,s,o,e,n,i,a,r,l=10){let d=0,p=t,g=s;for(let u=1;u<=l;u++){const f=u/l,h=1-f,m=f*f,b=h*h,c=b*h,S=m*f,v=c*t+3*b*f*o+3*h*m*n+S*a,C=c*s+3*b*f*e+3*h*m*i+S*r,w=v-p,I=C-g;d+=Math.sqrt(w*w+I*I),p=v,g=C}return d}getBezierTAtLength(t,s,o,e,n,i,a,r,l,d=20){if(t<=0)return 0;let p=0,g=s,u=o;for(let f=1;f<=d;f++){const h=f/d,m=1-h,b=h*h,c=m*m,S=c*m,v=b*h,C=S*s+3*c*h*e+3*m*b*i+v*r,w=S*o+3*c*h*n+3*m*b*a+v*l,I=C-g,k=w-u,O=Math.sqrt(I*I+k*k);if(p+O>=t){const T=t-p,A=O===0?0:T/O;return(f-1+A)/d}p+=O,g=C,u=w}return 1}getPointOnPath(t,s,o,e){if(this.ensurePathPoints(t),(t==null?void 0:t.type)==="Path"){const n=t.points||[];if(n.length<2)return{x:0,y:0,angle:0};let i=1/0,a=-1/0,r=1/0,l=-1/0;n.forEach(c=>{typeof c.x=="number"&&typeof c.y=="number"&&(i=Math.min(i,c.x),a=Math.max(a,c.x),r=Math.min(r,c.y),l=Math.max(l,c.y),c.out_x!==void 0&&(i=Math.min(i,c.out_x),a=Math.max(a,c.out_x)),c.out_y!==void 0&&(r=Math.min(r,c.out_y),l=Math.max(l,c.out_y)),c.in_x!==void 0&&(i=Math.min(i,c.in_x),a=Math.max(a,c.in_x)),c.in_y!==void 0&&(r=Math.min(r,c.in_y),l=Math.max(l,c.in_y)))});const d=(i+a)/2,p=(r+l)/2,u=this.getPerimeter(t,s,o)*e;let f=0;const h=[];let m=n[0],b=n[0];for(let c=1;c<n.length;c++){const S=n[c];if(S.moveTo){m=S,b=S;continue}h.push({p0:m,p1:S}),(S.closePath||c===n.length-1&&(t.is_closed||t.isClosed))&&h.push({p0:S,p1:b}),m=S}for(const c of h){const S=c.p0,v=c.p1;let C=0;const w=S.out_x!==void 0||v.in_x!==void 0;if(w?C=this.getBezierLength(S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y):C=Math.sqrt((v.x-S.x)**2+(v.y-S.y)**2),f+C>=u||c===h[h.length-1]){let I=0;if(w)return I=this.getBezierTAtLength(u-f,S.x,S.y,S.out_x??S.x,S.out_y??S.y,v.in_x??v.x,v.in_y??v.y,v.x,v.y,20),this.getBezierPointAndAngle(I,S,v,d,p);{I=C===0?0:(u-f)/C;const k=S.x+(v.x-S.x)*I-d,O=S.y+(v.y-S.y)*I-p,T=Math.atan2(v.y-S.y,v.x-S.x);return{x:k,y:O,angle:T}}}f+=C}}else if(t.type==="Ellipse"){const n=Math.abs(s)/2,i=Math.abs(o)/2,a=t.sweepAngle??360,l=((t.startAngle??0)+a*e)*Math.PI/180,d=n*Math.cos(l),p=i*Math.sin(l),g=-n*Math.sin(l),u=i*Math.cos(l),f=Math.atan2(u,g);return{x:d,y:p,angle:f}}else if((t==null?void 0:t.type)==="Rectangle"){const n=Math.abs(s),i=Math.abs(o),r=(n+i)*2*e;let l=0,d=0,p=0;return r<n?(l=-n/2+r,d=-i/2,p=0):r<n+i?(l=n/2,d=-i/2+(r-n),p=Math.PI/2):r<2*n+i?(l=n/2-(r-(n+i)),d=i/2,p=Math.PI):(l=-n/2,d=i/2-(r-(2*n+i)),p=-Math.PI/2),{x:l,y:d,angle:p}}return{x:0,y:0,angle:0}}getBezierPointAndAngle(t,s,o,e,n){const i=s.x,a=s.y,r=s.out_x??s.x,l=s.out_y??s.y,d=o.in_x??o.x,p=o.in_y??o.y,g=o.x,u=o.y,f=1-t,h=t*t,m=f*f,b=m*f,c=h*t,S=b*i+3*m*t*r+3*f*h*d+c*g-e,v=b*a+3*m*t*l+3*f*h*p+c*u-n,C=3*m*(r-i)+6*f*t*(d-r)+3*h*(g-d),w=3*m*(l-a)+6*f*t*(p-l)+3*h*(u-p),I=Math.atan2(w,C);return{x:S,y:v,angle:I}}applyAbsoluteTransform(t,s,o){if(!o.get(s))return;const n=[];let i=s;for(;i;){n.unshift(i);const a=o.get(i);i=a==null?void 0:a.parentId}n.forEach(a=>{this.applyObjectTransform(t,a)})}applyObjectTransform(t,s){var f,h,m;const o=this.objectStates.get(s);if(!o)return;t.translate(o.x,o.y),t.rotate((o.rotation??0)*Math.PI/180);const e=o.skew_x||0,n=o.skew_y||0;if(e!==0||n!==0){const b=Math.tan(e*Math.PI/180),c=Math.tan(n*Math.PI/180);t.transform(1+b*c,c,b,1,0,0)}const i=o.rotate_x!==void 0?o.rotate_x:((f=o.transform)==null?void 0:f.rotate_x)??0,a=o.rotate_y!==void 0?o.rotate_y:((h=o.transform)==null?void 0:h.rotate_y)??0,l=1+(o.translate_z!==void 0?o.translate_z:((m=o.transform)==null?void 0:m.translate_z)??0)/1e3,d=(o.flip_x===!0?-1:1)*Math.cos(a*Math.PI/180)*l,p=(o.flip_y===!0?-1:1)*Math.cos(i*Math.PI/180)*l,g=(o.scale_x??1)*d,u=(o.scale_y??1)*p;t.scale(g,u)}applyInnerGlowOverlay(t,s,o,e,n,i,a){var b,c;const r=a||s.style||{},l=r==null?void 0:r.effect,p=((r==null?void 0:r.effects)||(l?[l]:[])).find(S=>S.isEnabled!==!1&&S.type==="Glow"&&(S.mode==="inner"||S.mode==="Inner Glow"));if(!p)return;t.save(),t.beginPath(),this.applyPath(t,o,e,n,i),t.clip();const g=p.blur||10,u=1e4,f=t.getTransform();let h=p.color||"white";(c=(b=this.artboard)==null?void 0:b.tokens)!=null&&c.colors&&this.artboard.tokens.colors[h]&&(h=this.artboard.tokens.colors[h]),t.shadowColor=h,t.shadowBlur=g,t.shadowOffsetX=u*f.a,t.shadowOffsetY=u*f.b,t.translate(-u,0),t.lineWidth=g+5,t.strokeStyle=h;const m=Math.min(p.intensity||1,5);for(let S=0;S<m;S++)t.beginPath(),this.applyPath(t,o,e,n,i),t.stroke();t.restore()}applyArtEffectOverlay(t,s,o,e,n,i){var u,f,h,m,b;const a=this.objectStates.get(s.id),r=((u=a==null?void 0:a.style)==null?void 0:u.artEffect)||s.artEffect||((f=s.style)==null?void 0:f.artEffect);if(!r||!r.enabled)return;const l=r.type,d=r.intensity??.5,p=r.speed??1,g=r.scale??10;if(l==="acid_gradient"||l==="acid_rave"||l==="shimmer"||l==="glint_overlay"||l==="halftone"||l==="noise"||l==="scanlines"||l==="chromatic_aberration"||l==="pixelate"||l==="glitch"||l==="fold_overlay"||l==="crumple_overlay"){if(t.save(),this.applyPath(t,o,e,n,i),t.clip(),l==="shimmer"){const S=this.currentTime*p%2/2,v=t.createLinearGradient(-e,-n,e,n);v.addColorStop(Math.max(0,S-.2),"rgba(255,255,255,0)"),v.addColorStop(S,`rgba(255,255,255,${d*.8})`),v.addColorStop(Math.min(1,S+.2),"rgba(255,255,255,0)"),t.fillStyle=v,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="glint_overlay"){let v=((this._lastPointerPos||{x:0}).x-(((h=s.transform)==null?void 0:h.x)??0)+300)/600;v=Math.max(-.2,Math.min(1.2,v));const C=t.createLinearGradient(-e,-n,e,n);C.addColorStop(Math.max(0,v-.15),"rgba(255,255,255,0)"),C.addColorStop(Math.max(0,Math.min(1,v)),`rgba(255,255,255,${d})`),C.addColorStop(Math.min(1,v+.15),"rgba(255,255,255,0)"),t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over"}else if(l==="fold_overlay"){const c=this._lastPointerPos||{x:0,y:0},S=c.x-(((m=s.transform)==null?void 0:m.x)??0),v=c.y-(((b=s.transform)==null?void 0:b.y)??0),C=t.createLinearGradient(S>0?-e/2:e/2,v>0?-n/2:n/2,S>0?e/2:-e/2,v>0?n/2:-n/2);C.addColorStop(0,`rgba(0,0,0,${d*.6})`),C.addColorStop(.4,"rgba(0,0,0,0)"),C.addColorStop(.5,`rgba(255,255,255,${d*.4})`),C.addColorStop(1,`rgba(0,0,0,${d*.2})`),t.fillStyle=C,t.globalCompositeOperation="overlay",t.fillRect(-e/2,-n/2,e,n),t.globalCompositeOperation="source-over",t.beginPath(),S>0&&v>0?(t.moveTo(e/2-40,n/2),t.lineTo(e/2,n/2-40),t.lineTo(e/2-40,n/2-40)):S<0&&v>0?(t.moveTo(-e/2+40,n/2),t.lineTo(-e/2,n/2-40),t.lineTo(-e/2+40,n/2-40)):S>0&&v<0?(t.moveTo(e/2-40,-n/2),t.lineTo(e/2,-n/2+40),t.lineTo(e/2-40,-n/2+40)):(t.moveTo(-e/2+40,-n/2),t.lineTo(-e/2,-n/2+40),t.lineTo(-e/2+40,-n/2+40)),t.closePath(),t.fillStyle="#ffffff",t.shadowColor="rgba(0,0,0,0.5)",t.shadowBlur=10,t.shadowOffsetX=S>0?-2:2,t.shadowOffsetY=v>0?-2:2,t.fill()}else if(l==="crumple_overlay"){const c=Math.floor(e/g),S=document.createElement("canvas");S.width=c,S.height=Math.floor(n/g);const v=S.getContext("2d"),C=v.createImageData(S.width,S.height);for(let w=0;w<C.data.length;w+=4){const I=Math.random()>.95?150:255;C.data[w]=I,C.data[w+1]=I,C.data[w+2]=I,C.data[w+3]=255*d}v.putImageData(C,0,0),t.globalCompositeOperation="multiply",t.imageSmoothingEnabled=!1,t.drawImage(S,-e/2,-n/2,e,n)}else if(l==="acid_gradient"||l==="acid_rave"){const c=this.currentTime*p,S=r.color1,v=r.color2,C=t.createLinearGradient(-e/2,-n/2,e/2,n/2);if(S&&v){const w=c*60%360;C.addColorStop(0,this._shiftHue(S,w,d*.7)),C.addColorStop(1,this._shiftHue(v,(w+180)%360,d*.7))}else{const w=c*100%360,I=(w+180)%360;C.addColorStop(0,`hsla(${w}, 80%, 50%, ${d*.5})`),C.addColorStop(1,`hsla(${I}, 80%, 50%, ${d*.5})`)}t.fillStyle=C,t.globalCompositeOperation="screen",t.fillRect(-e/2,-n/2,e,n)}else if(l==="halftone"){const c=Math.max(2,g*(1-d*.8)),S=document.createElement("canvas");S.width=c,S.height=c;const v=S.getContext("2d");if(v){v.fillStyle="black",v.beginPath(),v.arc(c/2,c/2,c/2*d,0,Math.PI*2),v.fill();const C=t.createPattern(S,"repeat");C&&(t.globalAlpha=.3*d,t.fillStyle=C,t.fillRect(-e/2,-n/2,e,n))}}else if(l==="noise"){const c=Math.floor(e*n*d*.02);t.globalAlpha=.4*d;for(let S=0;S<c;S++){const v=Math.random()>.5?255:0;t.fillStyle=`rgba(${v}, ${v}, ${v}, ${.5+Math.random()*.5})`,t.fillRect(-e/2+Math.random()*e,-n/2+Math.random()*n,2,2)}}else if(l==="scanlines"){t.globalAlpha=.2*d,t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=1;for(let c=-n/2;c<n/2;c+=4)t.beginPath(),t.moveTo(-e/2,c),t.lineTo(e/2,c),t.stroke()}else if(l==="chromatic_aberration"){const c=5*d;t.globalCompositeOperation="screen",t.globalAlpha=.5,t.fillStyle="cyan",t.fillRect(-e/2-c,-n/2,e,n),t.fillStyle="magenta",t.fillRect(-e/2+c,-n/2,e,n)}else if(l==="pixelate"){const c=Math.max(2,Math.round(g*(1-d*.5))),S=document.createElement("canvas"),v=Math.max(1,Math.ceil(e/c)),C=Math.max(1,Math.ceil(n/c));S.width=v,S.height=C;const w=S.getContext("2d");if(w){w.imageSmoothingEnabled=!1;const I=t.getTransform(),k=I.e-e/2,O=I.f-n/2;w.drawImage(t.canvas,k,O,e,n,0,0,v,C),t.imageSmoothingEnabled=!1,t.drawImage(S,0,0,v,C,-e/2,-n/2,e,n),t.imageSmoothingEnabled=!0}}else if(l==="glitch"){const c=this.currentTime*p,S=r.chaosAmount??.2,v=Math.max(3,Math.floor(8*d)),C=d*e*.15;t.globalCompositeOperation="screen",t.globalAlpha=d*.4;const w=C*.3;t.fillStyle="rgba(255, 0, 0, 0.4)",t.fillRect(-e/2+w,-n/2,e,n),t.fillStyle="rgba(0, 255, 255, 0.4)",t.fillRect(-e/2-w,-n/2,e,n),t.globalCompositeOperation="source-over",t.globalAlpha=1;const I=n/v;for(let k=0;k<v;k++){const O=Math.sin(k*127.1+c*311.7*p)*43758.5,T=O-Math.floor(O);if(T>1-S){const A=(T-(1-S))/S*C*(Math.random()>.5?1:-1),D=-n/2+k*I,Y=t.getTransform(),B=Y.e-e/2+A,R=Y.f+D;t.save(),t.beginPath(),t.rect(-e/2,D,e,I),t.clip(),t.globalAlpha=.8,t.drawImage(t.canvas,B,R,e,I,-e/2+A,D,e,I),t.restore()}}}t.restore()}}_shiftHue(t,s,o){let e=0,n=0,i=0;if(t.startsWith("#")){const u=t.replace("#","");e=parseInt(u.substring(0,2),16)/255,n=parseInt(u.substring(2,4),16)/255,i=parseInt(u.substring(4,6),16)/255}const a=Math.max(e,n,i),r=Math.min(e,n,i);let l=0,d=0,p=(a+r)/2;if(a!==r){const u=a-r;switch(d=p>.5?u/(2-a-r):u/(a+r),a){case e:l=((n-i)/u+(n<i?6:0))/6;break;case n:l=((i-e)/u+2)/6;break;case i:l=((e-n)/u+4)/6;break}}return`hsla(${(((l*360+s)%360+360)%360).toFixed(0)}, ${(d*100).toFixed(0)}%, ${(p*100).toFixed(0)}%, ${o})`}applyBackgroundBlurGlass(t,s,o,e,n,i,a){const r=i.radius??10,l=i.opacity!==void 0?this.normalizeOpacity(i.opacity):.5,d=i.noise??0,p=i.color??"rgba(255,255,255,0.2)";t.save(),this.applyPath(t,s,o,e,n),t.clip();const g=t.getTransform(),u=t.canvas;try{const m=document.createElement("canvas");m.width=Math.max(1,Math.ceil(o)),m.height=Math.max(1,Math.ceil(e));const b=m.getContext("2d");if(b){b.save(),b.translate(o/2,e/2);const c=i.magnification||1;if(c!==1&&b.scale(c,c),typeof g.inverse=="function"){const C=g.inverse();b.transform(C.a,C.b,C.c,C.d,C.e,C.f)}else{const C=g.a*g.d-g.b*g.c;C!==0&&b.transform(g.d/C,-g.b/C,-g.c/C,g.a/C,(g.c*g.f-g.d*g.e)/C,(g.b*g.e-g.a*g.f)/C)}b.drawImage(u,0,0),b.restore();const S=document.createElement("canvas");S.width=m.width,S.height=m.height;const v=S.getContext("2d");v.filter=`blur(${r}px)`,v.drawImage(m,0,0),t.globalCompositeOperation="destination-out",t.fillRect(-o/2,-e/2,o,e),t.globalCompositeOperation="source-over",t.globalAlpha=1,t.drawImage(S,-o/2,-e/2,o,e)}}catch(m){console.error("Background blur failed:",m)}t.globalCompositeOperation="source-over",t.globalAlpha=l,t.fillStyle=p,t.fillRect(-o/2,-e/2,o,e),t.globalAlpha=1;const f=t.createLinearGradient(-o/2,-e/2,o/2,e/2);if(f.addColorStop(0,"rgba(255,255,255,0.12)"),f.addColorStop(.3,"rgba(255,255,255,0.04)"),f.addColorStop(.5,"rgba(255,255,255,0.0)"),f.addColorStop(1,"rgba(255,255,255,0.0)"),t.fillStyle=f,t.fillRect(-o/2,-e/2,o,e),d>0){if(t.globalAlpha=d/100,!this._noiseTileCanvas){const b=document.createElement("canvas");b.width=64,b.height=64;const c=b.getContext("2d"),S=c.createImageData(64,64),v=S.data;for(let C=0;C<v.length;C+=4){const w=Math.floor(Math.random()*255);v[C]=w,v[C+1]=w,v[C+2]=w,v[C+3]=18}c.putImageData(S,0,0),this._noiseTileCanvas=b}const m=t.createPattern(this._noiseTileCanvas,"repeat");m&&(t.fillStyle=m,t.fillRect(-o/2,-e/2,o,e))}t.restore(),t.save(),t.globalAlpha=1,(a==null?void 0:a.stroke)&&a.stroke.width>0&&a.stroke.isEnabled!==!1?(this.applyPath(t,s,o,e,n),this.applyStrokeAlignment(t,a,s,o,e,n)):(t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1.5,this.applyPath(t,s,o,e,n),t.stroke()),t.restore()}applyPath(t,s,o,e,n){s!=null&&s.data&&(s.type==="Path"||s.type==="Subtract"||s.type==="Union"||s.type==="Intersect"||s.type==="Exclude"||s.type),t.beginPath(),this._tracePath(t,s,o,e,n)}_tracePath(t,s,o,e,n){if(s){if(this.ensurePathPoints(s),(s==null?void 0:s.type)==="Rectangle"||s.type==="Image"){const i=n!==void 0?n:s.corner_radius??0;this.drawRoundRect(t,-o/2,-e/2,o,e,i)}else if(s.type==="Line")t.moveTo(-o/2,0),t.lineTo(o/2,0);else if(s.type==="Ellipse"||s.type==="circle"){const{startAngle:i=0,sweepAngle:a=360,ratio:r=0}=s,l=o/2,d=e/2,p=i*Math.PI/180,g=a*Math.PI/180,u=p+g;a>=360&&r<=0?t.ellipse(0,0,l,d,0,0,Math.PI*2):(t.ellipse(0,0,l,d,0,p,u,!1),r>0?t.ellipse(0,0,l*r,d*r,0,u,p,!0):t.lineTo(0,0),t.closePath())}else if(s.type==="Triangle")t.moveTo(0,-e/2),t.lineTo(o/2,e/2),t.lineTo(-o/2,e/2),t.closePath();else if(s.type==="Polygon"){const i=s.sides||3,a=s.radius||Math.min(o,e)/2;for(let r=0;r<i;r++){const l=r*2*Math.PI/i-Math.PI/2,d=a*Math.cos(l),p=a*Math.sin(l);r===0?t.moveTo(d,p):t.lineTo(d,p)}t.closePath()}else if(s.type==="Star"){const i=s.points||5,a=s.outer_radius||Math.min(o,e)/2;let r=s.inner_radius;r==null?r=a*.382:r<=1&&(r=a*r);for(let l=0;l<i*2;l++){const d=l*Math.PI/i-Math.PI/2,p=l%2===0?a:r,g=p*Math.cos(d),u=p*Math.sin(d);l===0?t.moveTo(g,u):t.lineTo(g,u)}t.closePath()}else if(s!=null&&s.points&&["path","custom","customshape","shape","subtract","union","intersect","exclude","booleanoperation"].includes((s.type||"").toLowerCase())){this.frameCount%300===0&&this.log("[Engine] Tracing Path:",s.points.length,"points");let i=1/0,a=-1/0,r=1/0,l=-1/0;if(s.points.forEach(g=>{typeof g.x=="number"&&typeof g.y=="number"&&(i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y),g.out_x!==void 0&&(i=Math.min(i,g.out_x),a=Math.max(a,g.out_x)),g.out_y!==void 0&&(r=Math.min(r,g.out_y),l=Math.max(l,g.out_y)),g.in_x!==void 0&&(i=Math.min(i,g.in_x),a=Math.max(a,g.in_x)),g.in_y!==void 0&&(r=Math.min(r,g.in_y),l=Math.max(l,g.in_y)))}),i===1/0)return;let d=(i+a)/2,p=(r+l)/2;if(isNaN(d)||isNaN(p)){this.warn("[Engine] Invalid path center:",d,p);return}s.points.forEach((g,u)=>{if(u===0||g.moveTo)t.moveTo(g.x-d,g.y-p);else{const f=s.points[u-1];if(!f)return;const h=(f.out_x??f.x)-d,m=(f.out_y??f.y)-p,b=(g.in_x??g.x)-d,c=(g.in_y??g.y)-p;isNaN(h)||isNaN(b)||isNaN(g.x)?t.lineTo(g.x-d,g.y-p):t.bezierCurveTo(h,m,b,c,g.x-d,g.y-p)}if(g.closePath||u===s.points.length-1&&(s.is_closed||s.isClosed)){const f=[...s.points.slice(0,u+1)].reverse().find(h=>h.moveTo)||s.points[0];f&&(g.out_x!==void 0||f.in_x!==void 0)&&t.bezierCurveTo((g.out_x??g.x)-d,(g.out_y??g.y)-p,(f.in_x??f.x)-d,(f.in_y??f.y)-p,f.x-d,f.y-p),t.closePath()}})}else if(s.points&&Array.isArray(s.points)){let i=1/0,a=-1/0,r=1/0,l=-1/0;s.points.forEach(g=>{i=Math.min(i,g.x),a=Math.max(a,g.x),r=Math.min(r,g.y),l=Math.max(l,g.y)});const d=(i+a)/2,p=(r+l)/2;s.points.forEach((g,u)=>{if(u===0)t.moveTo(g.x-d,g.y-p);else{const f=s.points[u-1];f.out_x!==void 0||g.in_x!==void 0?t.bezierCurveTo((f.out_x??f.x)-d,(f.out_y??f.y)-p,(g.in_x??g.x)-d,(g.in_y??g.y)-p,g.x-d,g.y-p):t.lineTo(g.x-d,g.y-p)}(g.closePath||u===s.points.length-1&&(s.is_closed||s.isClosed))&&t.closePath()})}}}renderInputBox(t,s){var qt,Se,Ce,Ie,de,Re,ye,ke,Vt,ee,j,bt,st,K,rt,ft,Rt,Qt,Kt,ae,Jt,Et;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=s.style||{},a=this.focusedId===s.id,r=this.lastHoveredObjectId===s.id,l=e.previewState||"default",d=l==="focused"||l==="active"||!e.disabled&&a,p=l==="hover"||!e.disabled&&r&&!d,g=l==="disabled"||!!e.disabled,u=l==="error"||!!e.error,f=e.inputType==="textarea"||e.multiline===!0;let h={};g&&e.disabledStyle&&Object.keys(e.disabledStyle).length>0?h=e.disabledStyle:u&&e.errorStyle&&Object.keys(e.errorStyle).length>0?h=e.errorStyle:d?h={...e.focusedStyle||{},...e.activeStyle||{}}:p&&(h={...e.hoveredStyle||{},...e.hoverStyle||{}});const m=Number(h.scale??1);m!==1&&t.scale(m,m);const b=Number(h.translateX??0),c=Number(h.translateY??0);(b||c)&&t.translate(b,c);const S=Number(h.rotate??0);S&&t.rotate(S*Math.PI/180);const v=Number(h.opacity??1);v!==1&&(t.globalAlpha=v);const C=Number(h.width??n.width)||250,w=Number(h.height??n.height)||45,I=e.label||{visible:!0,text:"Label"},k=e.helperText||{visible:!1,text:"Helper text"},O=e.leftIcon||{visible:!1},T=e.rightIcon||{visible:!1},A=((qt=h.leftIcon)==null?void 0:qt.color)||h.leftIconColor||h.iconColor,D=((Se=h.rightIcon)==null?void 0:Se.color)||h.rightIconColor||h.iconColor,Y={...O,...h.leftIcon||{},...A?{color:A}:{}},B={...T,...h.rightIcon||{},...D?{color:D}:{}};h.leftIconVisible!==void 0&&(Y.visible=h.leftIconVisible),h.rightIconVisible!==void 0&&(B.visible=h.rightIconVisible),((Ce=h.leftIcon)==null?void 0:Ce.visible)!==void 0&&(Y.visible=h.leftIcon.visible),((Ie=h.rightIcon)==null?void 0:Ie.visible)!==void 0&&(B.visible=h.rightIcon.visible);const R=n.corner_radius??n.cornerRadius,L=Array.isArray(R)?{tl:R[0],tr:R[1],br:R[2],bl:R[3]}:R&&typeof R=="object"?R:void 0,$=h.cornerRadius??h.corner_radius,F=Number($??e.cornerRadius??e.corner_radius??R??e.radius??8),X=h.corners??($!==void 0?{tl:F,tr:F,bl:F,br:F}:e.corners??L??{tl:F,tr:F,bl:F,br:F}),M=[Number(X.tl??F),Number(X.tr??F),Number(X.br??F),Number(X.bl??F)],E=(W,nt,Lt,tt,gt,Q=0)=>{const Ut=Math.max(0,Lt-Q*2),zt=Math.max(0,tt-Q*2);let[yt,Bt,_t,Xt]=gt.map(ce=>Math.max(0,(Number(ce)||0)-Q));const Dt=Math.min(Ut,zt)/2;yt=Math.min(yt,Dt),Bt=Math.min(Bt,Dt),_t=Math.min(_t,Dt),Xt=Math.min(Xt,Dt),t.beginPath(),t.roundRect?t.roundRect(W+Q,nt+Q,Ut,zt,[yt,Bt,_t,Xt]):(t.moveTo(W+Q+yt,nt+Q),t.lineTo(W+Q+Ut-Bt,nt+Q),t.arcTo(W+Q+Ut,nt+Q,W+Q+Ut,nt+Q+Bt,Bt),t.lineTo(W+Q+Ut,nt+Q+zt-_t),t.arcTo(W+Q+Ut,nt+Q+zt,W+Q+Ut-_t,nt+Q+zt,_t),t.lineTo(W+Q+Xt,nt+Q+zt),t.arcTo(W+Q,nt+Q+zt,W+Q,nt+Q+zt-Xt,Xt),t.lineTo(W+Q+yt,nt+Q),t.arcTo(W+Q,nt+Q,W+Q+yt,nt+Q,yt),t.closePath())};let P=h.backgroundColor??e.backgroundColor??((de=i.fill)==null?void 0:de.color)??"rgba(31, 41, 55, 1)",_=h.borderColor??e.borderColor??((ye=(Re=i.stroke)==null?void 0:Re.fill)==null?void 0:ye.color)??((ke=i.stroke)==null?void 0:ke.color)??"rgba(55, 65, 81, 1)",V=Number(h.borderWidth??e.borderWidth??((Vt=i.stroke)==null?void 0:Vt.width)??1),G=h.color??e.color??((ee=i.fill)==null?void 0:ee.color)??"#ffffff",x=h.placeholderColor??e.placeholderColor??"rgba(156, 163, 175, 1)",U=Number(h.fontSize??e.fontSize??14),q=h.caretColor??e.caretColor??e.accentColor??"#3b82f6";!h.borderColor&&!h.borderWidth&&(d&&!g?(_=e.focusBorderColor||e.accentColor||"#3b82f6",V=Math.max(V,1.5)):p&&!g?(_=e.hoverBorderColor||"#64748b",P=e.hoverBackgroundColor||P):g?(P=e.disabledBackgroundColor||"rgba(31, 41, 55, 0.6)",_=e.disabledBorderColor||"rgba(55, 65, 81, 0.4)"):u&&(_="rgba(239, 68, 68, 1)",V=Math.max(V,2)));const N=V>0?V/2:0,H=this.createCanvasFill(t,P,C,w);if(H&&P!=="transparent"&&(E(-C/2,-w/2,C,w,M,N),t.fillStyle=H,t.fill()),V>0){const W=this.createCanvasFill(t,_,C,w);W&&_!=="transparent"&&(E(-C/2,-w/2,C,w,M,N),t.strokeStyle=W,t.lineWidth=V,t.lineCap="round",t.lineJoin="round",t.stroke())}if(h.boxShadow&&h.boxShadow.color&&h.boxShadow.color!=="transparent"){t.save();const W=h.boxShadow;t.shadowColor=W.color,t.shadowOffsetX=Number(W.offsetX??0),t.shadowOffsetY=Number(W.offsetY??2),t.shadowBlur=Number(W.blur??8),E(-C/2,-w/2,C,w,M,N),t.fillStyle=P!=="transparent"?H||P:"rgba(0,0,0,0.01)",t.fill(),t.restore()}if(d&&!g){t.save();const W=-3,nt=M.map(gt=>Math.max(0,gt+3));E(-C/2+W,-w/2+W,C-W*2,w-W*2,nt);const Lt=h.borderColor||((j=e.activeStyle)==null?void 0:j.borderColor)||q||"rgba(59, 130, 246, 0.4)",tt=this.createCanvasFill(t,Lt,C,w)||"rgba(59, 130, 246, 0.4)";t.strokeStyle=tt,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(),t.restore()}const z=h.fontFamily||e.fontFamily||"Inter",et=(h.fontWeight??e.fontWeight)||400,Mt=Number(h.fontSize??U),ct=e.inputType==="number"&&((bt=e.number)==null?void 0:bt.showSteppers)!==!1,It=24,mt=ct?It+4:0,kt=String(e.text??e.value??"");let Ot="Enter text...";if(e.inputType==="tel")Ot=`${((st=e.tel)==null?void 0:st.dialCode)||"+1"} (555) 000-0000`;else if(e.inputType==="number"){const W=(K=e.number)!=null&&K.prefix?`${e.number.prefix} `:"",nt=(rt=e.number)!=null&&rt.suffix?` ${e.number.suffix}`:"";Ot=`${W}0.00${nt}`}else e.inputType==="email"?Ot="user@example.com":e.inputType==="search"?Ot="Search anything...":e.inputType==="url"?Ot="https://example.com":e.inputType==="password"?Ot="••••••••":e.inputType==="textarea"&&(Ot="Enter text...");const vt=e.placeholder||Ot,Wt=!kt,J=e.inputType==="password",ut=B.mode==="password-toggle"||J&&B.visible!==!1,$t=B.mode==="clear"||e.inputType==="search"&&!!kt,St=(W,nt)=>{var Bt;let Lt=W.svgPath||"";const tt=W.char||"";if(!Lt&&!tt&&(nt?e.inputType==="search"&&(Lt="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"):ut?Lt=e.passwordVisible?"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24M1 1l22 22":"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z M12 9a3 3 0 100 6 3 3 0 000-6z":$t&&(Lt="M18 6L6 18M6 6l12 12")),!(W.visible||!!(Lt||tt)&&(!nt&&(ut||$t)||nt&&e.inputType==="search")))return;const Q=W.size||16,Ut=(W.offset??16)+(nt?0:mt),zt=typeof W.color=="string"?W.color:((Bt=W.color)==null?void 0:Bt.color)||"#9ca3af",yt=nt?-(C/2)+Ut:C/2-Ut;if(Lt){if(t.save(),t.translate(yt,0),!Lt.startsWith("<svg")){const _t=new Path2D(Lt),Xt=Q/24;t.scale(Xt,Xt),t.translate(-12,-12),Lt.includes("M18 6L6 18")||Lt.includes("M1 1l22 22")||Lt.includes("M21 21")||Lt.includes("M11 19a8")?(t.strokeStyle=zt,t.lineWidth=2/Xt,t.lineCap="round",t.lineJoin="round",t.stroke(_t)):(t.fillStyle=zt,t.fill(_t))}t.restore()}else tt&&(t.save(),t.translate(yt,0),t.fillStyle=zt,t.font=`${Q}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(tt,0,0),t.restore())};if(St(Y,!0),St(B,!1),ct){const W=C/2-It-4;t.save(),t.strokeStyle=_||"rgba(55, 65, 81, 0.5)",t.lineWidth=1,t.beginPath(),t.moveTo(W,-w/2+6),t.lineTo(W,w/2-6),t.stroke(),t.beginPath(),t.moveTo(W,0),t.lineTo(C/2-4,0),t.stroke(),t.fillStyle=G||"rgba(156, 163, 175, 0.8)",t.font=`600 8px "${z}", sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText("▲",W+It/2,-w/4),t.fillText("▼",W+It/2,w/4),t.restore()}const Pt=h.padding||e.padding||{},Ft=Pt.left??((ft=e.padding)==null?void 0:ft.left)??e.inputPadding??12,lt=Pt.right??((Rt=e.padding)==null?void 0:Rt.right)??e.inputPadding??12,ht=Y.visible||e.inputType==="search",dt=B.visible||ut||$t,At=ht?(Y.offset??16)+(Y.size||16)/2+8:Ft,Tt=dt?(B.offset??16)+(B.size||16)/2+8+mt:lt+mt,Ct=-(C/2)+At,Yt=Math.max(0,C-At-Tt);let ie=kt||vt;if(e.inputType==="number"&&kt){const W=(Qt=e.number)!=null&&Qt.prefix?`${e.number.prefix} `:"",nt=(Kt=e.number)!=null&&Kt.suffix?` ${e.number.suffix}`:"";ie=`${W}${kt}${nt}`}const te=J&&kt?e.passwordVisible?kt:"•".repeat(kt.length):ie,Zt=Wt?x:G;if(t.font=`${et} ${Mt}px "${z}", sans-serif`,t.fillStyle=Zt,t.textAlign="left",t.save(),t.beginPath(),t.rect(Ct-2,-w/2+4,Yt+4,w-8),t.clip(),f){t.textBaseline="top";const W=te.split(`
19
- `);let nt=-w/2+(((ae=e.padding)==null?void 0:ae.top)??8);const Lt=Mt*1.4,tt=e.rows||3;let gt=0,Q=0;for(const Ut of W){if(gt>=tt)break;const zt=Ut.split(" ");let yt="";for(let Bt=0;Bt<zt.length;Bt++){const _t=yt+zt[Bt]+" ";if(t.measureText(_t).width>Yt&&Bt>0){if(gt>=tt)break;t.fillText(yt.trim(),Ct,nt),yt=zt[Bt]+" ",nt+=Lt,gt++}else yt=_t}gt<tt&&(t.fillText(yt.trim(),Ct,nt),Q=t.measureText(yt.trim()).width,nt+=Lt,gt++)}if(d&&!Wt&&Math.floor(performance.now()/500)%2===0){const Ut=nt-Lt;t.fillStyle=q,t.fillRect(Ct+Math.min(Q,Yt),Ut,1.5,Mt)}}else{t.textBaseline="middle";const nt=t.measureText(te).width;let Lt=0;if(nt>Yt&&(Lt=nt-Yt),t.fillText(te,Ct-Lt,0),d&&Math.floor(performance.now()/500)%2===0){const tt=Wt?Ct:Ct+nt-Lt;t.fillStyle=q,t.fillRect(tt,-(Mt/2),1.5,Mt)}}if(t.restore(),e.showCharCounter){t.save();const W=Number(e.maxLength||0),nt=W>0?`${kt.length}/${W}`:`${kt.length}`;t.font=`400 10px "${z}", sans-serif`,t.fillStyle=W>0&&kt.length>=W?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(nt,-(C/2)+C-8,-(w/2)+w+4),t.restore()}if(I.visible!==!1){const W=!!(I.required||(Jt=e.validation)!=null&&Jt.required),nt=(I.text||"Label")+(W?" *":""),Lt=I.fontSize||12,tt=I.color||"rgba(156, 163, 175, 1)",gt=I.position||"top",Q=I.gap??I.offset??6;let Ut=-(C/2),zt=-(w/2)-Q,yt="left",Bt="bottom",_t=`600 ${Lt}px "${I.fontFamily||z}", sans-serif`;gt==="left"?(Ut=-(C/2)-Q,zt=0,yt="right",Bt="middle"):gt==="bottom"?(Ut=-(C/2),zt=w/2+Q,yt="left",Bt="top"):gt==="floating"&&(!!kt||a?(Ut=-(C/2)+12,zt=-(w/2)+4,yt="left",Bt="top",_t=`600 ${Math.max(9,Lt-2)}px "${I.fontFamily||z}", sans-serif`):_t=null),_t&&(t.save(),t.font=_t,t.fillStyle=tt,t.textAlign=yt,t.textBaseline=Bt,t.fillText(nt,Ut,zt),t.restore())}const le=(Et=e.validation)==null?void 0:Et.errorMessage;if(u&&le||k.visible===!0&&k.text){t.save();const W=k.fontSize||11,nt=u?"#ef4444":k.color||"rgba(156, 163, 175, 1)",Lt=k.offset??6,tt=u&&le?le:k.text;t.font=`400 ${W}px "${z}", sans-serif`,t.fillStyle=nt,t.textAlign="left",t.textBaseline="top",t.fillText(tt,-(C/2),w/2+Lt),t.restore()}g&&(t.save(),E(-C/2,-w/2,C,w,M),t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.restore()),v!==1&&(t.globalAlpha=1)}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,n=(o==null?void 0:o.options)||s.options||{},i=e.width||200,a=n.value??50,r=n.min??0,d=(n.max??100)-r,p=d===0?0:(a-r)/d,g=n.trackHeight||4,u=n.trackRoundedness??2,f=n.trackShape??"Rectangle",h=n.trackPath||"",m=n.activeColor||n.accentColor||"#3b82f6",b=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",S=n.thumbWidth??16,v=n.thumbHeight??16,C=n.thumbRoundedness??0,w=n.thumbColor||"#ffffff",I=n.thumbPath||"",k=n.thumbIcon||"",O=n.trackStrokeWidth??0,T=n.trackStrokeColor||"",A=n.thumbStrokeWidth??0,D=n.thumbStrokeColor||"",Y=n.showValueTooltip??!1,B=n.tooltipBgColor||"#333333",R=n.tooltipColor||"#ffffff",L=n.tooltipOffsetX??0,$=n.tooltipOffsetY??-25,F=this.lastHoveredObjectId===s.id,X=this.isMouseDown&&F,M=n.hoverStyle||{},E=n.activeStyle||{};let P=g,_=m,V=b,G=c,x=S,U=v,q=C,N=w,H=O,z=T,et=A,Mt=D,ct=1;X&&E?(ct=E.scale??1,P=E.trackHeight??P,_=E.activeColor??_,V=E.inactiveColor??V,N=E.thumbColor??N,x=E.thumbWidth??x,U=E.thumbHeight??U,q=E.thumbRoundedness??q,G=E.thumbShape||G,H=E.trackStrokeWidth??H,z=E.trackStrokeColor??z,et=E.thumbStrokeWidth??et,Mt=E.thumbStrokeColor??Mt):F&&M&&(ct=M.scale??1,P=M.trackHeight??P,_=M.activeColor??_,V=M.inactiveColor??V,N=M.thumbColor??N,x=M.thumbWidth??x,U=M.thumbHeight??U,q=M.thumbRoundedness??q,G=M.thumbShape||G,H=M.trackStrokeWidth??H,z=M.trackStrokeColor??z,et=M.thumbStrokeWidth??et,Mt=M.thumbStrokeColor??Mt);const It=X&&E.thumbPath?E.thumbPath:F&&M.thumbPath?M.thumbPath:I;ct!==1&&(t.save(),t.scale(ct,ct));const mt=(ht,dt,At,Tt,Ct,Yt,ie)=>{const te=xe[ht]||ie||(ht&&(ht.startsWith("M")||ht.startsWith("m"))?ht:"");if((ht==="Custom"||ht==="Icon"||te)&&te)try{const Zt=new Path2D(te),le=We(te),fe=Math.min(Tt/le.width,Ct/le.height);t.save(),t.translate(dt,At),t.scale(fe,fe),t.translate(-le.cx,-le.cy);const qt=!te.includes("z")&&!te.includes("Z");qt?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/fe),t.lineCap="round",t.lineJoin="round",t.stroke(Zt)):t.fill(Zt),t.strokeStyle&&t.lineWidth>0&&!qt&&t.stroke(Zt),t.restore();return}catch(Zt){console.error("Error drawing slider shape in engine:",Zt)}if(t.beginPath(),ht==="Ellipse")t.ellipse(dt,At,Tt/2,Ct/2,0,0,Math.PI*2);else if(ht==="Rectangle")this.drawRoundRect(t,dt-Tt/2,At-Ct/2,Tt,Ct,Yt);else if(ht==="Triangle")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At+Ct/2),t.lineTo(dt-Tt/2,At+Ct/2),t.closePath();else if(ht==="Diamond")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At),t.lineTo(dt,At+Ct/2),t.lineTo(dt-Tt/2,At),t.closePath();else if(ht==="Polygon"){const Zt=s.geometry.sides||3,le=s.geometry.radius||Math.min(Tt,Ct)/2;for(let fe=0;fe<Zt;fe++){const qt=fe*2*Math.PI/Zt-Math.PI/2,Se=dt+le*Math.cos(qt),Ce=At+le*Math.sin(qt);fe===0?t.moveTo(Se,Ce):t.lineTo(Se,Ce)}t.closePath()}else if(ht==="Star"){const le=Math.min(Tt,Ct)/2,fe=le/2;for(let qt=0;qt<10;qt++){const Se=qt%2===0?le:fe,Ce=qt*Math.PI/5-Math.PI/2;t.lineTo(dt+Se*Math.cos(Ce),At+Se*Math.sin(Ce))}t.closePath()}else ht==="Line"&&(t.moveTo(dt-Tt/2,At),t.lineTo(dt+Tt/2,At));t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()},kt=this.createCanvasFill(t,V,i,P);kt&&(t.fillStyle=kt,t.strokeStyle=kt),f==="Line"?(t.strokeStyle=H>0&&z?z:kt,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),mt(f,0,0,i,P,u,h));const Ot=i-x,vt=-i/2+x/2+p*Ot,Wt=vt- -i/2;if(Wt>0){const ht=this.createCanvasFill(t,_,i,P);if(ht&&(t.fillStyle=ht),f==="Line")t.strokeStyle=H>0&&z?z:ht||_,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(vt,0),t.stroke();else{if(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),t.beginPath(),f==="Rectangle")this.drawRoundRect(t,-i/2,-P/2,Wt,P,u);else{const dt=xe[f]||h||"";if(dt)try{const At=new Path2D(dt),Tt=We(dt),Ct=Math.min(Wt/Tt.width,P/Tt.height);t.save(),t.translate(-i/2+Wt/2,0),t.scale(Ct,Ct),t.translate(-Tt.cx,-Tt.cy),t.fill(At),t.strokeStyle&&t.lineWidth>0&&t.stroke(At),t.restore()}catch{this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}else this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()}}t.save(),t.translate(vt,0);const J=t.getTransform(),ut=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*ut,t.shadowOffsetY=1*ut;const $t=this.createCanvasFill(t,N,x,U);$t&&(t.fillStyle=$t),et>0&&Mt&&(t.strokeStyle=Mt,t.lineWidth=et);const St=X&&E.thumbShape==="Icon"?E.thumbPath||k:F&&M.thumbShape==="Icon"&&M.thumbPath||k;if(mt(G,0,0,x,U,q,G==="Icon"?St:It),t.restore(),Y){t.save(),t.translate(vt+L,$);const ht=Math.round(a).toString();t.font="10px Inter, sans-serif";const dt=t.measureText(ht),At=6,Tt=4,Ct=dt.width+At*2,Yt=14+Tt;t.beginPath(),this.drawRoundRect(t,-Ct/2,-Yt/2,Ct,Yt,4),t.fillStyle=B,t.fill(),t.fillStyle=R,t.textAlign="center",t.textBaseline="middle",t.fillText(ht,0,0),t.restore()}const Pt=n.label||{},Ft=n.helperText||{},lt=n.fontFamily||"Inter";if(Pt.visible!==!1){const ht=Pt.text||"Label",dt=Pt.fontSize||12,At=Pt.color||"rgba(156, 163, 175, 1)",Tt=Pt.offset??8;t.font=`600 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="bottom";const Ct=-(i/2),Yt=-(P/2)-Tt;t.fillText(ht,Ct,Yt)}if(Ft.visible===!0){const ht=Ft.text||"Helper text",dt=Ft.fontSize||11,At=Ft.color||"rgba(156, 163, 175, 1)",Tt=Ft.offset??6;t.font=`400 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="top";const Ct=-(i/2),Yt=P/2+Tt;t.fillText(ht,Ct,Yt)}ct!==1&&t.restore()}renderDropdown(t,s){var Y;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},n=s.geometry.width||180,i=s.geometry.height||40,a=-n/2,r=-i/2,l=e.cornerRadius??e.corner_radius??6,d=e.disabled||e.previewState==="disabled",p=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!d;let u=e.backgroundColor,f=e.borderColor,h=e.color||"#333333";d?(u=e.disabledBackgroundColor||"#f3f4f6",f=e.disabledBorderColor||"#e5e7eb",h=e.disabledColor||"#9ca3af"):g?(u=e.activeBackgroundColor||u,f=e.activeBorderColor||f,h=e.activeColor||h):p&&(u=e.hoverBackgroundColor||u,f=e.hoverBorderColor||f,h=e.hoverColor||h),u||(u="#ffffff"),f||(f="#e5e7eb"),t.save();const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof u=="string"?{type:"Solid",color:u}:u,n,i)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,n,i)||"#e5e7eb",t.lineWidth=b,t.stroke());const c=12,S=e.chevronType||"chevron",v=e.chevronSize||16,C=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(S!=="none"){const B=a+n-c-v/2;t.save(),t.translate(B,0);const R=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(R*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",S==="chevron")t.beginPath(),t.moveTo(-v/2,-v*.2),t.lineTo(0,v*.2),t.lineTo(v/2,-v*.2),t.stroke();else if(S==="custom"||S==="path"){const L=g&&e.openIconPath||e.closedIconPath;if(L){const $=new Path2D(L);t.save();const F=v/24;t.scale(F,F),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",I=e.fontSize||14,k=e.fontWeight||400,O=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${I}px ${O}`;const T=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":h;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const A=S==="none"?0:v+8,D=n-c*2-A;if(t.save(),t.beginPath(),t.rect(a+c,r,D,i),t.clip(),t.fillText(w,a+c,0),t.restore(),g&&!d){const B=r+i+4,R=this.getResolvedDropdownOptions(s,e),L=e.itemHeight||32,$=e.listPadding??4,F=R.length*L+$*2,X=e.listCornerRadius??l;t.save();const M=e.listShadow||{},E=t.getTransform(),P=Math.sqrt(E.a*E.a+E.b*E.b)||1;t.shadowColor=typeof M.color=="string"?M.color:((Y=M.color)==null?void 0:Y.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(M.blur??12)*P,t.shadowOffsetY=(M.offsetY??6)*P,t.shadowOffsetX=(M.offsetX??0)*P,t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,F)||"#ffffff",t.fill();const _=e.listBorderWidth??1;_>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:f},n,F)||"#e5e7eb",t.lineWidth=_,t.stroke()),t.restore();const V=e.itemFontSize||I,G=e.itemFontFamily||O;t.font=`${k} ${V}px ${G}`,R.forEach((x,U)=>{const q=B+$+U*L;if(x===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,L)||"#f3f4f6",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemSelectedColor||e.accentColor||h||"#374151";else if(t.fillStyle=e.listTextColor||h||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const H=this._lastPointerPos.y-(B+$),z=Math.floor(H/L);U===z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,L)||"#f9fafb",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemHoverColor||h)}t.fillText(x,a+c,q+L/2)})}t.restore()}renderButton(t,s){var U;if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||s.width||160,a=n.height||s.height||45,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,d=e.label||{},p=e.hoverStyle||{},g=e.activeStyle||{},u=e.icon||{enabled:!1};let f=e.backgroundColor||e.buttonBgColor||((U=s.style)==null?void 0:U.fill)||"#3b82f6",h=(typeof d=="object"?d.color:null)||"#ffffff",m=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),b=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",S=e.borderWidth||0,v=1;l&&g?(f=g.backgroundColor||f,h=g.color||h,m=g.text||m,v=g.scale??.95,b=g.cornerRadius??b):r&&p&&(f=p.backgroundColor||f,h=p.color||h,m=p.text||m,v=p.scale??1,b=p.cornerRadius??b,c=p.borderColor||c);const C=-i/2,w=-a/2;t.save(),t.scale(v,v),t.beginPath(),this.drawRoundRect(t,C,w,i,a,b);const I=this.createCanvasFill(t,f,i,a);I&&(t.fillStyle=I,t.fill()),(S>0||r&&p.borderColor)&&(t.strokeStyle=c,t.lineWidth=S||(r?1:0),t.stroke());const k=d.fontSize||14,O=d.fontFamily||"Inter",T=d.fontWeight||600;t.font=`${T} ${k}px "${O}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=h,t.textAlign="center",t.textBaseline="middle";const A=u.enabled===!0||u.enabled==="true",D=Number(u.size)||Math.round(k*1.15)||16,Y=u.color||h,B=Number(u.gap)??8,R=u.position||"left",L=u.margin||{left:0,right:0,top:0,bottom:0},$=(Number(L.left)||0)-(Number(L.right)||0),F=(Number(L.top)||0)-(Number(L.bottom)||0),X=!!(m&&String(m).trim().length>0),E=(X?t.measureText(String(m)):{width:0}).width,P=k*1.2;let _=0,V=0,G=0,x=0;if(A){if(!X||R==="center")G=$,x=F,_=0,V=0;else if(R==="left"){const q=D+B+E;G=-q/2+D/2+$,x=F,_=-q/2+D+B+E/2+$,V=0}else if(R==="right"){const q=E+B+D;_=-q/2+E/2+$,V=0,G=-q/2+E+B+D/2+$,x=F}else if(R==="top"){const q=D+B+P;G=$,x=-q/2+D/2+F,_=$,V=-q/2+D+B+P/2+F}else if(R==="bottom"){const q=P+B+D;_=$,V=-q/2+P/2+F,G=$,x=-q/2+P+B+D/2+F}this.drawButtonIcon(t,u,G,x,D,Y,O)}X&&R!=="center"&&(t.fillStyle=h,t.fillText(String(m),_,V)),t.restore()}drawButtonIcon(t,s,o,e,n,i,a="Inter"){const r=(s.svgPath||"").trim(),l=(s.character||s.char||"").trim(),d="M12 3L10.088 8.813A2 2 0 0 1 8.813 10.088L3 12L8.813 13.912A2 2 0 0 1 10.088 15.187L12 21L13.912 15.187A2 2 0 0 1 15.187 13.912L21 12L15.187 10.088A2 2 0 0 1 13.912 8.813L12 3Z";if(t.save(),l){t.font=`${Math.round(n)}px "${a}", -apple-system, sans-serif`,t.fillStyle=i,t.textAlign="center",t.textBaseline="middle",t.fillText(l,o,e),t.restore();return}if(r.startsWith("<svg")){const u=s.fill&&s.fill.type!=="None";let f=r.replace(/stroke\s*=\s*(['"])currentColor\1/gi,`stroke="${i}"`).replace(/stroke\s*:\s*currentColor/gi,`stroke: ${i}`);u?f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,`fill="${i}"`).replace(/fill\s*:\s*currentColor/gi,`fill: ${i}`):f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,'fill="none"').replace(/fill\s*:\s*currentColor/gi,"fill: none"),f.includes("xmlns=")||(f=f.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));const h=`svg_icon_${i}_${n}_${btoa(f.slice(0,80))}`;let m=this.imageCache.get(h);if(m||(m=new Image,m.crossOrigin="anonymous",m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(f)))}`,this.imageCache.set(h,m)),m.complete&&m.naturalWidth>0){t.drawImage(m,o-n/2,e-n/2,n,n),t.restore();return}const b=[...f.matchAll(/<path[^>]*\bd=["']([^"']+)["']/gi)];if(b.length>0){t.translate(o,e);const c=n/24;t.scale(c,c),t.translate(-12,-12);const S=new Path2D(b.map(v=>v[1]).join(" "));u?(t.fillStyle=i,t.fill(S)):(t.strokeStyle=i,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(S)),t.restore();return}}if(r&&!r.startsWith("<")){t.translate(o,e);const u=n/24;t.scale(u,u),t.translate(-12,-12);const f=new Path2D(r);t.fillStyle=i,t.fill(f),t.strokeStyle=i,t.lineWidth=1,t.stroke(f),t.restore();return}t.translate(o,e);const p=n/24;t.scale(p,p),t.translate(-12,-12);const g=new Path2D(d);t.fillStyle=i,t.fill(g),t.restore()}renderToggleButton(t,s){var m,b;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((m=s.geometry)==null?void 0:m.width)||120,a=((b=s.geometry)==null?void 0:b.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,p=e.label||{},g=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",u=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=g,t.fill();const f=p.fontSize||14,h=p.fontFamily||"Inter";t.font=`${p.fontWeight||600} ${f}px "${h}", sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle",t.fillText(p.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||52,a=n.height||30,r=e.checked??!1,l=e.toggleStyle||{},d=l.width,p=l.height,g=l.cornerRadius,u=r&&d?d:i,f=r&&p?p:a,h=-u/2,m=-f/2,b=r&&g!==void 0?g:e.cornerRadius??e.corner_radius??a/2,c=l.backgroundColor||e.activeColor||"#10b981",S=l.borderColor||e.borderColor||"transparent",v=l.borderWidth??e.borderWidth??0,C=l.knobColor||e.knobColor||"#ffffff",w=r?c:e.inactiveColor||"#374151",I=r?S:e.borderColor||"transparent",k=r?v:e.borderWidth??0,O=r?C:e.knobColor||"#ffffff",T=r&&l.knobShape||e.knobShape||"Circle",A=r&&l.knobSize||e.knobSize||0,D=r&&l.trackShape||e.trackShape||"Pill";e.disabled&&(t.globalAlpha*=.5);const Y=(lt,ht,dt,At,Tt,Ct)=>{try{const Yt=new Path2D(lt),ie=We(lt),te=Math.min(At/ie.width,Tt/ie.height),Zt=!lt.includes("z")&&!lt.includes("Z");t.save(),t.translate(ht,dt),t.scale(te,te),t.translate(-ie.cx,-ie.cy),Zt?(t.strokeStyle=Ct,t.lineWidth=Math.max(1.8,2.2/te),t.lineCap="round",t.lineJoin="round",t.stroke(Yt)):(t.fillStyle=Ct,t.fill(Yt)),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.fillStyle=Ct),t.fill()}},B=(lt,ht,dt,At,Tt,Ct,Yt)=>{try{const ie=new Path2D(lt),te=We(lt),Zt=Math.min(At/te.width,Tt/te.height);t.save(),t.translate(ht,dt),t.scale(Zt,Zt),t.translate(-te.cx,-te.cy),t.strokeStyle=Ct,t.lineWidth=Yt/Zt,t.lineCap="round",t.lineJoin="round",t.stroke(ie),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.strokeStyle=Ct),t.lineWidth=Yt,t.stroke()}},R=xe[D]||D,L=!["Pill","Rectangle","Circle"].includes(R),$=xe[T]||T,F=!["Circle","Square","Diamond","Star"].includes($),X=this.createCanvasFill(t,w,u,f);if(L?Y(R,h+u/2,m+f/2,u,f,X):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),X&&(t.fillStyle=X,t.fill())),k>0){const lt=this.createCanvasFill(t,I,u,f);L?B(R,h+u/2,m+f/2,u,f,lt,k):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),t.lineWidth=k,lt&&(t.strokeStyle=lt,t.stroke()))}const M=e.knobPadding??2,E=f-M*2,P=A>0?A:E,_=P/2,V=h+M,G=h+u-M-P,x=r?G:V,U=m+(f-P)/2,q=this.createCanvasFill(t,O,P,P);if(F)Y($,x+_,U+_,P,P,q);else{if(t.beginPath(),T==="Square"){const lt=Math.min(4,_/2);t.roundRect(x,U,P,P,lt)}else if(T==="Diamond"){const lt=x+_,ht=U+_;t.moveTo(lt,ht-_),t.lineTo(lt+_,ht),t.lineTo(lt,ht+_),t.lineTo(lt-_,ht),t.closePath()}else if(T==="Star"){const lt=x+_,ht=U+_,dt=5,At=_,Tt=_*.4;for(let Ct=0;Ct<dt*2;Ct++){const Yt=Ct%2===0?At:Tt,ie=Ct*Math.PI/dt-Math.PI/2,te=lt+Yt*Math.cos(ie),Zt=ht+Yt*Math.sin(ie);Ct===0?t.moveTo(te,Zt):t.lineTo(te,Zt)}t.closePath()}else t.arc(x+_,U+_,_,0,Math.PI*2);q&&(t.fillStyle=q,t.fill())}e.disabled&&(t.globalAlpha*=2);const N=((Mt=e.leftLabel)==null?void 0:Mt.enabled)&&((ct=e.leftLabel)==null?void 0:ct.text),H=((It=e.rightLabel)==null?void 0:It.enabled)&&((mt=e.rightLabel)==null?void 0:mt.text),z=((kt=e.leftLabel)==null?void 0:kt.gap)||8,et=((Ot=e.rightLabel)==null?void 0:Ot.gap)||8;if(N){const lt=(r?(vt=l.leftLabel)==null?void 0:vt.text:null)||((Wt=e.leftLabel)==null?void 0:Wt.text)||"",ht=(r?(J=l.leftLabel)==null?void 0:J.color:null)||((ut=e.leftLabel)==null?void 0:ut.color)||"#f3f4f6",dt=e.leftLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="right",t.fillText(lt,h-z,0)}if(H){const lt=(r?($t=l.rightLabel)==null?void 0:$t.text:null)||((St=e.rightLabel)==null?void 0:St.text)||"",ht=(r?(Pt=l.rightLabel)==null?void 0:Pt.color:null)||((Ft=e.rightLabel)==null?void 0:Ft.color)||"#f3f4f6",dt=e.rightLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="left",t.fillText(lt,h+u+et,0)}if(!N&&!H&&e.label&&e.label.text){const lt=e.label,ht=lt.fontSize||14,dt=lt.fontWeight||400,At=lt.fontFamily||"Inter";t.font=`${dt} ${ht}px "${At}", sans-serif`,t.fillStyle=lt.color||"#f3f4f6",t.textBaseline="middle";const Tt=lt.gap||10;let Ct=0,Yt=0;lt.position==="left"?(t.textAlign="right",Ct=h-Tt,Yt=0):lt.position==="right"?(t.textAlign="left",Ct=h+u+Tt,Yt=0):lt.position==="top"?(t.textAlign="center",Ct=0,Yt=m-Tt,t.textBaseline="bottom"):lt.position==="bottom"?(t.textAlign="center",Ct=0,Yt=m+f+Tt,t.textBaseline="top"):(t.textAlign="left",Ct=h+u+Tt,Yt=0),t.fillText(lt.text,Ct,Yt)}}renderCheckbox(t,s){var E,P,_,V;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((E=s.geometry)==null?void 0:E.width)||140,i=((P=s.geometry)==null?void 0:P.height)||24,a=-n/2,r=-i/2,l=Math.max(12,Math.min(e.boxSize||18,i,n)),d=Math.min(e.cornerRadius??4,l/2),p=e.checked??!1,g=!!e.indeterminate,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6";const c=e.inactiveColor||"transparent";let S=e.checkColor||"#ffffff",v=e.borderColor||"#9ca3af";const C=e.borderWidth??1.5;let w=1;f&&m?(m.backgroundColor&&(b=m.backgroundColor),m.borderColor&&(v=m.borderColor),m.checkColor&&(S=m.checkColor),w=m.scale??.95):u&&h&&(h.backgroundColor&&(b=h.backgroundColor),h.borderColor&&(v=h.borderColor),h.checkColor&&(S=h.checkColor),w=h.scale??1);const I=!!(e.label&&e.label.text),k=((_=e.label)==null?void 0:_.gap)??8,O=((V=e.label)==null?void 0:V.position)||"right";let T=a,A=r+(i-l)/2,D=0,Y=0,B="left",R="middle";I?O==="right"?(T=a,A=r+(i-l)/2,D=T+l+k,Y=0,B="left",R="middle"):O==="left"?(T=a+n-l,A=r+(i-l)/2,D=T-k,Y=0,B="right",R="middle"):O==="top"?(T=a+(n-l)/2,A=r+i-l,D=0,Y=A-k,B="center",R="bottom"):O==="bottom"&&(T=a+(n-l)/2,A=r,D=0,Y=A+l+k,B="center",R="top"):(T=a+(n-l)/2,A=r+(i-l)/2);const L=p||g,$=L?b:c,F=L?b:v,X=L?0:C;e.disabled&&(t.globalAlpha*=.5),t.save(),w!==1&&t.scale(w,w),t.beginPath(),this.drawRoundRect(t,T,A,l,l,d);const M=this.createCanvasFill(t,$,l,l);if(M&&(t.fillStyle=M,t.fill()),X>0){t.lineWidth=X;const G=this.createCanvasFill(t,F,l,l);G&&(t.strokeStyle=G,t.stroke())}else if(L){t.lineWidth=1;const G=this.createCanvasFill(t,b,l,l);G&&(t.strokeStyle=G,t.stroke())}if(g){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.moveTo(T+l*.25,A+l*.5),t.lineTo(T+l*.75,A+l*.5),t.stroke(),t.restore()}else if(p){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.lineJoin="round";const x=T+l*.24,U=A+l*.5,q=T+l*.44,N=A+l*.7,H=T+l*.76,z=A+l*.28;t.moveTo(x,U),t.lineTo(q,N),t.lineTo(H,z),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),I&&e.label&&e.label.text){const G=e.label;t.save(),t.font=`${G.fontWeight||400} ${G.fontSize||14}px "${G.fontFamily||"Inter"}", sans-serif`,t.fillStyle=G.color||"#111827",t.textAlign=B,t.textBaseline=R,t.fillText(G.text,D,Y),t.restore()}t.restore()}renderRadioGroup(t,s){var B,R;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((B=s.geometry)==null?void 0:B.width)||180,i=((R=s.geometry)==null?void 0:R.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let L=this.inputs.get(e.dataInputId);if(L===void 0){const $=this.inputNameMap.get(e.dataInputId);$&&$.length>0&&(L=this.inputs.get($[0]))}L&&Array.isArray(L)&&(l=L.map($=>typeof $=="string"?$:String($)))}const d=e.selectedValue,p=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6",c=e.inactiveColor||"#4b5563",S=e.textColor||"#ffffff",v=1;f&&m?(m.activeColor&&(b=m.activeColor),m.inactiveColor&&(c=m.inactiveColor),m.textColor&&(S=m.textColor),v=m.scale??.95):u&&h&&(h.activeColor&&(b=h.activeColor),h.inactiveColor&&(c=h.inactiveColor),h.textColor&&(S=h.textColor),v=h.scale??1);const C=e.fontSize||14,w=e.fontFamily||"Inter",I=e.fontWeight||400;t.save(),e.disabled&&(t.globalAlpha*=.5),v!==1&&t.scale(v,v);const k=8,O=k*2,T=e.radioShape||"circle",A=e.borderWidth!==void 0?e.borderWidth:2,D=e.fillEmpty||"transparent",Y=(L,$,F,X)=>{if(t.beginPath(),X==="custom"&&e.customShapePath)try{const M=new Path2D(e.customShapePath),E=We(e.customShapePath),P=Math.min(F*2/E.width,F*2/E.height);t.save(),t.translate(L,$),t.scale(P,P),t.translate(-E.cx,-E.cy),!e.customShapePath.includes("z")&&!e.customShapePath.includes("Z")?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/P),t.lineCap="round",t.lineJoin="round",t.stroke(M)):t.fill(M),t.restore();return}catch{t.arc(L,$,F,0,Math.PI*2);return}if(X==="square"){const M=F*1.6;t.rect(L-M/2,$-M/2,M,M)}else if(X==="diamond"){const M=F*1.4;t.moveTo(L,$-M),t.lineTo(L+M,$),t.lineTo(L,$+M),t.lineTo(L-M,$),t.closePath()}else if(X==="heart"){const M=F*.9;t.moveTo(L,$+M*.7),t.bezierCurveTo(L-M*1.5,$-M*.3,L-M*.5,$-M*1.5,L,$-M*.5),t.bezierCurveTo(L+M*.5,$-M*1.5,L+M*1.5,$-M*.3,L,$+M*.7)}else if(X==="star"){const M=F*1.1,E=F*.5;for(let P=0;P<5;P++){const _=(P*72-90)*Math.PI/180,V=(P*72+36-90)*Math.PI/180;P===0?t.moveTo(L+M*Math.cos(_),$+M*Math.sin(_)):t.lineTo(L+M*Math.cos(_),$+M*Math.sin(_)),t.lineTo(L+E*Math.cos(V),$+E*Math.sin(V))}t.closePath()}else t.arc(L,$,F,0,Math.PI*2)};if(t.font=`${I} ${C}px "${w}", sans-serif`,t.textBaseline="middle",t.textAlign="left",p==="vertical"){const L=Math.max(O,C)+g,$=l.length*L-g,F=r+Math.max(0,(i-$)/2);l.forEach((X,M)=>{const E=F+k+M*L,P=d===X,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);P?(t.fillStyle=_||b,Y(a+k,E,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(a+k,E,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()),t.fillStyle=S,t.fillText(X,a+O+8,E)})}else{const L=r+i/2;let $=0;t.font=`${I} ${C}px "${w}", sans-serif`,l.forEach(M=>{$+=O+6+t.measureText(M).width+g}),$-=g;let X=a+Math.max(0,(n-$)/2);l.forEach(M=>{const E=d===M,P=t.measureText(M).width,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);E?(t.fillStyle=_||b,Y(X+k,L,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(X+k,L,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()),t.fillStyle=S,t.fillText(M,X+O+6,L),X+=O+6+P+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const L=e.label;t.save(),t.font=`${L.fontWeight||400} ${L.fontSize||14}px "${L.fontFamily||"Inter"}", sans-serif`,t.fillStyle=L.color||"#9ca3af",t.textBaseline="middle";const $=L.gap||8;let F=0,X=0;L.position==="left"?(t.textAlign="right",F=a-$,X=0):L.position==="right"?(t.textAlign="left",F=a+n+$,X=0):L.position==="top"?(t.textAlign="center",F=0,X=r-$,t.textBaseline="bottom"):L.position==="bottom"&&(t.textAlign="center",F=0,X=r+i+$,t.textBaseline="top"),t.fillText(L.text,F,X),t.restore()}}renderBarChart(t,s){var $,F,X;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{};let n={...e};if(e.isDataVarEnabled&&e.dataInputId){let M=this.inputs.get(e.dataInputId);if(M===void 0){const E=this.inputNameMap.get(e.dataInputId);E&&E.length>0&&(M=this.inputs.get(E[0]))}M&&Array.isArray(M)&&(n.categories=M.map(E=>typeof E=="string"?E:String(E)))}if(e.isDatasetsVarEnabled&&(($=e.datasetInputIds)==null?void 0:$.length)>0){const M=e.datasetInputIds.map((E,P)=>{var G;let _=this.inputs.get(E);if(_===void 0){const x=this.inputNameMap.get(E);x&&x.length>0&&(_=this.inputs.get(x[0]))}const V=((G=e.datasets)==null?void 0:G[P])||{id:`ds-${P}`,label:`Series ${P+1}`,data:[],color:"#6366f1"};return _&&Array.isArray(_)?{...V,data:_.map(x=>typeof x=="number"?x:parseFloat(x)||0)}:V});n.datasets=M}const i={width:((F=s.geometry)==null?void 0:F.width)||300,height:((X=s.geometry)==null?void 0:X.height)||180,chartType:n.chartType||"grouped",datasets:n.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:n.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:n.orientation||"vertical",barWidth:n.barWidth!==void 0?n.barWidth:14,barGap:n.barGap!==void 0?n.barGap:4,barCornerRadius:n.barCornerRadius!==void 0?n.barCornerRadius:5,showXAxis:!!n.showXAxis,showYAxis:!!n.showYAxis,xAxisColor:n.xAxisColor||"rgba(255,255,255,0.15)",yAxisColor:n.yAxisColor||"rgba(255,255,255,0.15)",showXLabels:n.showXLabels!==void 0?!!n.showXLabels:!0,showYLabels:!!n.showYLabels,axisLabelColor:n.axisLabelColor||"rgba(255,255,255,0.55)",axisLabelFontSize:n.axisLabelFontSize||9,showLegend:n.showLegend!==void 0?!!n.showLegend:!0,legendColor:n.legendColor||"rgba(255,255,255,0.7)",legendFontSize:n.legendFontSize||9,showGridLines:n.showGridLines!==void 0?!!n.showGridLines:!0,gridColor:n.gridColor||"rgba(255,255,255,0.06)",cardBackground:n.cardBackground||"#ffffff",cardBackgroundOpacity:n.cardBackgroundOpacity!==void 0?n.cardBackgroundOpacity:.04,cardBorderColor:n.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:n.barGradient!==void 0?!!n.barGradient:!0,gradientStartColor:n.gradientStartColor||"",gradientEndOpacity:n.gradientEndOpacity!==void 0?n.gradientEndOpacity:.27,showValueOnTop:!!n.showValueOnTop,valueFontSize:n.valueFontSize||10,valueColor:n.valueColor||"",valueFontWeight:n.valueFontWeight||"bold",barStyle:n.barStyle||"solid",barBorderWidth:n.barBorderWidth!==void 0?n.barBorderWidth:1,barBorderColor:n.barBorderColor||"auto",enableShadows:!!n.enableShadows,shadowColor:n.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:n.shadowBlur!==void 0?n.shadowBlur:4,shadowOffsetY:n.shadowOffsetY!==void 0?n.shadowOffsetY:2,xAxisLineWidth:n.xAxisLineWidth!==void 0?n.xAxisLineWidth:1,yAxisLineWidth:n.yAxisLineWidth!==void 0?n.yAxisLineWidth:1,gridLineWidth:n.gridLineWidth!==void 0?n.gridLineWidth:1,gridLineDash:n.gridLineDash||[3,4],showHoverTooltip:n.showHoverTooltip!==void 0?!!n.showHoverTooltip:!0,hoverHighlight:n.hoverHighlight!==void 0?!!n.hoverHighlight:!0,hoverHighlightColor:n.hoverHighlightColor||"rgba(255, 255, 255, 0.22)",tooltipBg:n.tooltipBg||"#111827",tooltipTextColor:n.tooltipTextColor||"#f9fafb",tooltipRadius:n.tooltipRadius!==void 0?n.tooltipRadius:6,_hexToRgb:function(M,E){if(M.startsWith("rgba")||M.startsWith("rgb"))return M;M.startsWith("#")||(M="#"+M),M.length===4&&(M="#"+M[1]+M[1]+M[2]+M[2]+M[3]+M[3]);const P=parseInt(M.slice(1,3),16),_=parseInt(M.slice(3,5),16),V=parseInt(M.slice(5,7),16);return`rgba(${P},${_},${V},${E})`},_resolveColor:function(M,E){return typeof M=="string"?M:"#6366f1"},_makeGradient:function(M,E,P,_,V,G){if(!this.barGradient)return E;const x=this.gradientStartColor||E,U=M.createLinearGradient(P,_,V,G);return U.addColorStop(0,E),U.addColorStop(1,this._hexToRgb(x,this.gradientEndOpacity)),U},_drawRoundedBar:function(M,E,P,_,V,G,x){if(G=Math.min(G,Math.min(Math.abs(_),Math.abs(V))/2),G<=0||_===0||V===0){M.rect(E,P,_,V);return}M.beginPath(),x?(M.moveTo(E,P+V),M.lineTo(E,P+G),M.quadraticCurveTo(E,P,E+G,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V),M.lineTo(E,P+V)):(M.moveTo(E,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V-G),M.quadraticCurveTo(E+_,P+V,E+_-G,P+V),M.lineTo(E,P+V),M.lineTo(E,P)),M.closePath()}},a=i.width,r=i.height,l=-a/2,d=-r/2;if(!i.datasets||i.datasets.length===0||i.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}let p=-1/0,g=1/0;const u=i.categories.length,f=i.datasets.length;if(i.chartType==="stacked")for(let M=0;M<u;M++){let E=0,P=0;i.datasets.forEach(_=>{const V=_.data[M]??0;V>=0?E+=V:P+=V}),E>p&&(p=E),P<g&&(g=P)}else i.datasets.forEach(M=>{M.data&&M.data.forEach(E=>{E>p&&(p=E),E<g&&(g=E)})});isFinite(p)||(p=10),isFinite(g)||(g=0),p=Math.max(p,0),g=Math.min(g,0);const h=p-g||10;t.save();const m=n.entranceStyle||{},b=m.type||"none",c=this.getEntranceProgress(s.id,m,n.previewState||"default");if(b!=="none"){if(b==="fade")t.globalAlpha*=c;else if(b==="draw")t.beginPath(),t.rect(-a/2-10,-r/2-10,(a+20)*c,r+20),t.clip();else if(b==="barGrow"){const M=-r/2+r*(1-c);t.beginPath(),t.rect(-a/2-10,M,a+20,r+20),t.clip()}else if(b==="slideUp"){const M=(1-c)*r*.4;t.translate(0,M),t.globalAlpha*=Math.min(1,c*2)}else b==="stagger"&&(i._staggerProg=c);m.showLegend===!1&&(i.showLegend=!1),m.showAxes===!1&&(i.showXAxis=!1,i.showYAxis=!1),m.showLabels===!1&&(i.showXLabels=!1,i.showYLabels=!1),m.showGrid===!1&&(i.showGridLines=!1)}i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const S=i.showYLabels?t.measureText(p.toFixed(0)).width+14:10,v=i.showXLabels?i.axisLabelFontSize+12:8,w=(i.showLegend&&f>0?i.legendFontSize+10:0)+8,I=10,k=l+S,O=d+w,T=a-S-I,A=r-w-v;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,d,a,r,10),t.fillStyle=i._hexToRgb(i.cardBackground,i.cardBackgroundOpacity),t.fill(),t.strokeStyle=i.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&f>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const M=d+12;let E=k;i.datasets.forEach((P,_)=>{const V=i._resolveColor(P.color,_),G=P.label||"Series "+(_+1),x=7;t.beginPath(),t.roundRect(E,M-x/2,x,x,2),t.fillStyle=V,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(G,E+x+4,M),E+=t.measureText(G).width+x+16})}const D=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=k+M/D*T;t.beginPath(),t.moveTo(E,O),t.lineTo(E,O+A),t.stroke()}else{const E=O+M/D*A;t.beginPath(),t.moveTo(k,E),t.lineTo(k+T,E),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor;for(let M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=g+M/D*h,P=k+M/D*T;t.textAlign="center",t.fillText(E.toFixed(0),P,O+A+i.axisLabelFontSize)}else{const E=p-M/D*h,P=O+M/D*A;t.textAlign="right",t.fillText(E.toFixed(0),k-6,P)}}t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(k,O+A),t.lineTo(k+T,O+A),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(k,O),t.lineTo(k,O+A),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor);const Y=[],B=this.graphHoverStates.get(s.id),R=B==null?void 0:B.hoveredCatIdx,L=B==null?void 0:B.hoveredDsIdx;if(i.chartType==="stacked")if(i.orientation==="horizontal"){const M=A/u;for(let E=0;E<u;E++){const P=O+E*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[E]||"",k-5,P),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=k;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*T,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_;_+=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:H,y:N,w:U,h:q}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,H,N,H+U,N);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),t.fill(),t.restore())})}}else{const M=T/u;for(let E=0;E<u;E++){const P=k+E*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[E]||"",P,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=O+A;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*A,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_-U;_-=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:N,y:H,w:q,h:U}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,N,H,N,H+U);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),t.fill(),t.restore())})}}else if(i.orientation==="horizontal"){const M=A/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=k+(0-g)/h*T;for(let _=0;_<u;_++){const V=O+_*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[_]||"",k-5,V),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*T);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P:P-N,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:z,y:H,w:N,h:i.barWidth}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,z,H,z+N,H);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=q>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),q>=0?z+N+4:z-4,H+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const M=T/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=O+A-(0-g)/h*A;for(let _=0;_<u;_++){const V=k+_*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[_]||"",V,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*A);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P-N:P,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:H,y:z,w:i.barWidth,h:N}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,H,z,H,z+N);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=q>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),H+i.barWidth/2,q>=0?z-4:z+N+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}if(this.barChartRenderedBars.set(s.id,Y),i.showHoverTooltip&&R!==null&&R!==void 0&&L!==null&&L!==void 0){const M=Y.find(E=>E.catIdx===R&&E.dsIdx===L);if(M){t.save();const E=10,P=8,_=14,V=12,x=P*2+_+V+16,U=Math.max(...Y.map(Ot=>Math.abs(Ot.val))),q=U>0?Math.round(Math.abs(M.val)/U*100):0;t.font="bold 10px Inter, system-ui, sans-serif";const N=t.measureText(M.category||"Category").width;t.font="8px Inter, system-ui, sans-serif";const H=`${q}% of max (${U})`,z=t.measureText(H).width;t.font="9px Inter, system-ui, sans-serif";const et=t.measureText(`${M.label}: ${M.val}`).width+16,Mt=Math.max(N,z,et)+E*2;let ct=M.x+M.w/2-Mt/2,It=M.y-x-8;ct<-a/2+6&&(ct=-a/2+6),ct+Mt>a/2-6&&(ct=a/2-Mt-6),It<-r/2+6&&(It=M.y+M.h+8),It+x>r/2-6&&(It=r/2-x-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,ct,It,Mt,x,i.tooltipRadius),t.fillStyle=i.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(M.category,ct+E,It+P),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(H,ct+E,It+P+_);const mt=It+P+_+V+2;t.beginPath(),t.arc(ct+E+4,mt+5,3.5,0,Math.PI*2),t.fillStyle=M.color,t.fill(),t.font="9px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.fillText(`${M.label}: `,ct+E+12,mt);const kt=t.measureText(`${M.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle=M.color,t.fillText(`${M.val}`,ct+E+12+kt,mt),t.restore()}}t.restore()}renderPieChart(t,s){var k,O;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.colorPalette==="custom"&&Array.isArray(e.customPalette)&&e.customPalette.length>0?e.customPalette:ys[e.colorPalette||"vibrant"]||ys.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let T=this.inputs.get(e.dataInputId);if(T===void 0){const A=this.inputNameMap.get(e.dataInputId);A&&A.length>0&&(T=this.inputs.get(A[0]))}T&&Array.isArray(T)&&(i=T.map((A,D)=>{var Y,B;return{id:`slice-${D}`,label:((Y=i[D])==null?void 0:Y.label)||`Item ${D+1}`,value:typeof A=="number"?A:0,color:((B=i[D])==null?void 0:B.color)||""}}))}const a={width:((k=s.geometry)==null?void 0:k.width)||180,height:((O=s.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"donut",slices:i,innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#000000",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(0,0,0,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#000000",centerLabelColor:e.centerLabelColor||"rgba(0,0,0,0.4)",cardBackground:e.cardBackground||"#ffffff",cardBackgroundOpacity:e.cardBackgroundOpacity!==void 0?e.cardBackgroundOpacity:.04,cardBorderColor:e.cardBorderColor||"rgba(0,0,0,0.08)",showHoverTooltip:e.showHoverTooltip!==void 0?!!e.showHoverTooltip:!0,hoverExplode:e.hoverExplode!==void 0?!!e.hoverExplode:!0,tooltipBg:e.tooltipBg||"#111827",tooltipTextColor:e.tooltipTextColor||"#f9fafb",tooltipRadius:e.tooltipRadius!==void 0?e.tooltipRadius:6,_resolveSliceColor:function(T,A){return T.color?T.color:n[A%n.length]},_hexToRgb:function(T){if(T.startsWith("rgba")||T.startsWith("rgb"))return T;const A=T.replace("#",""),D=parseInt(A.substring(0,2),16),Y=parseInt(A.substring(2,4),16),B=parseInt(A.substring(4,6),16);return`rgba(${D},${Y},${B},${a.cardBackgroundOpacity})`}},r=a.width,l=a.height;if(!a.slices||a.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 d=a.slices.reduce((T,A)=>T+(A.value||0),0);if(d<=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}t.save();const p=e.entranceStyle||{},g=p.type||"none",u=this.getEntranceProgress(s.id,p,e.previewState||"default");if(g!=="none"){if(g==="fade")t.globalAlpha*=u;else if(g==="draw")t.beginPath(),t.rect(-r/2-10,-l/2-10,(r+20)*u,l+20),t.clip();else if(g==="radial"){const T=Math.sqrt(r*r+l*l)/2;t.beginPath(),t.arc(0,0,T*u,0,Math.PI*2),t.clip()}else if(g==="sliceReveal"){if(i.reduce((A,D)=>A+(D.value||0),0)>0){const A=-Math.PI/2+u*Math.PI*2;t.beginPath(),t.moveTo(0,0),t.arc(0,0,Math.max(r,l),-Math.PI/2,A),t.lineTo(0,0),t.clip()}}else if(g==="spinIn"){const T=(1-u)*Math.PI*2;t.rotate(T),t.globalAlpha*=u}else if(g==="grow"){const T=u;t.scale(T,T),t.globalAlpha*=Math.min(1,u*2)}p.showLegend===!1&&(a.showLegend=!1),p.showLabels===!1&&(a.showLabels=!1),p.showCenterText===!1&&(a.showCenterText=!1)}const f=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=f,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const h=a.showLegend?Math.ceil(a.slices.length/2):0,m=h>0?h*(a.legendFontSize+8)+10:0,b=l-m-16,c=Math.min(r-24,b)/2,S=0,v=-m/2,C=[],w=this.graphHoverStates.get(s.id),I=(w==null?void 0:w.hoveredSliceIndex)??null;if(a.chartType==="rose"){const T=Math.max(...a.slices.map(Y=>Y.value||0)),A=Math.PI*2/a.slices.length,D=c>0?a.sliceGap/c:0;a.slices.forEach((Y,B)=>{const R=Y.value||0;if(R===0)return;const L=R/T*c,$=-Math.PI/2+B*A+D/2,F=$+A-D,X=a._resolveSliceColor(Y,B),M=$+(F-$)/2,E=I===B;let P=S,_=v;if(E&&a.hoverExplode&&(P+=Math.cos(M)*6,_+=Math.sin(M)*6),C.push({index:B,startA:$,endA:F,innerR:0,outerR:L,cx:P,cy:_,slice:Y,color:X,pct:Math.round(R/d*100)}),t.beginPath(),t.moveTo(P,_),t.arc(P,_,L,$,F),t.closePath(),t.fillStyle=X+"cc",t.fill(),t.strokeStyle=X,t.lineWidth=E?2.5:1.5,t.stroke(),a.showLabels){const V=P+L*.65*Math.cos(M),G=_+L*.65*Math.sin(M),x=Math.round(R/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,V,G),t.restore()}})}else{const T=a.chartType==="pie"?0:a.innerRadius,A=c*Math.max(0,T),D=c>0?a.sliceGap/c:0;let Y=-Math.PI/2;if(a.slices.forEach((B,R)=>{const L=B.value||0;if(L===0){Y+=L/d*Math.PI*2;return}const $=L/d*Math.PI*2,F=Y+D/2,X=Y+$-D/2;if(X<=F){Y+=$;return}const M=a._resolveSliceColor(B,R),E=F+(X-F)/2,P=I===R;let _=S,V=v;if(P&&a.hoverExplode&&(_+=Math.cos(E)*6,V+=Math.sin(E)*6),C.push({index:R,startA:F,endA:X,innerR:A,outerR:c,cx:_,cy:V,slice:B,color:M,pct:Math.round(L/d*100)}),t.beginPath(),t.fillStyle=M,A<=0?(t.moveTo(_,V),t.arc(_,V,c,F,X),t.lineTo(_,V)):(t.moveTo(_+c*Math.cos(F),V+c*Math.sin(F)),t.arc(_,V,c,F,X),t.arc(_,V,A,X,F,!0),t.closePath()),t.fill(),P&&(t.lineWidth=2,t.strokeStyle="#ffffff",t.stroke()),a.showLabels){const G=A+(c-A)/2,x=_+G*Math.cos(E),U=V+G*Math.sin(E),q=Math.round(L/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${q}%`,x,U),t.restore()}Y+=$}),a.chartType==="donut"&&a.showCenterText&&A>14){const B=Math.round(d),R=Math.min(Math.floor(A*.52),20),L=Math.min(Math.floor(A*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${R}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(B.toString(),S,v-L*.5),t.font=`${L}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,S,v+R*.6)}}if(this.pieChartRenderedSlices.set(s.id,C),a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const T=2,A=r/T,D=a.legendFontSize+8,Y=l/2-m+10,B=-r/2+10;a.slices.forEach((R,L)=>{const $=L%T,F=Math.floor(L/T),X=B+$*A,M=Y+F*D,E=a._resolveSliceColor(R,L),P=7;t.beginPath(),t.roundRect(X,M-P/2,P,P,2),t.fillStyle=E,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const _=Math.round((R.value||0)/d*100),V=`${R.label||"Item"} ${_}%`,G=A-P-20;let x=V;for(;t.measureText(x).width>G&&x.length>4;)x=x.slice(0,-4)+"…";t.fillText(x,X+P+4,M)})}if(a.showHoverTooltip&&I!==null&&I!==void 0){const T=C.find(A=>A.index===I);if(T){t.save();const A=10,D=8,Y=14,B=12,L=D*2+Y+B+16,$=i.reduce((N,H)=>N+(H.value||0),0);t.font="bold 10px Inter, system-ui, sans-serif";const F=t.measureText(T.slice.label||"Item").width;t.font="8px Inter, system-ui, sans-serif";const X=`of ${$} total`,M=t.measureText(X).width;t.font="9px Inter, system-ui, sans-serif";const E=`${T.slice.value} (${T.pct}%)`,P=t.measureText(E).width+16,_=Math.max(F,M,P)+A*2,V=T.startA+(T.endA-T.startA)/2,G=(T.innerR+T.outerR)/2;let x=T.cx+Math.cos(V)*(G+10)-_/2,U=T.cy+Math.sin(V)*(G+10)-L/2;x<-r/2+6&&(x=-r/2+6),x+_>r/2-6&&(x=r/2-_-6),U<-l/2+6&&(U=-l/2+6),U+L>l/2-6&&(U=l/2-L-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,x,U,_,L,a.tooltipRadius),t.fillStyle=a.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=a.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(T.slice.label||"Item",x+A,U+D),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(X,x+A,U+D+Y);const q=U+D+Y+B+2;t.beginPath(),t.arc(x+A+4,q+5,3.5,0,Math.PI*2),t.fillStyle=T.color,t.fill(),t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(E,x+A+12,q),t.restore()}}t.restore()}renderJoystick(t,s){var m,b,c,S,v,C,w,I,k,O,T,A;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((m=s.geometry)==null?void 0:m.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((b=s.geometry)==null?void 0:b.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((S=s.style)==null?void 0:S.handleSize)??.14);let r=s.handleX||0,l=s.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(l=o.handleY),t.save();let d=0,p=0;s.handleOrigin==="top-left"?(d=e/2,p=n/2):s.handleOrigin==="bottom-right"&&(d=-e/2,p=-n/2),t.translate(d,p);const g=t.globalAlpha;if(t.globalAlpha=g*(((v=s.style)==null?void 0:v.baseOpacity)??1),t.beginPath(),s.boundsShape==="square"){const D=s.joystickType==="2D"?12:18;t.roundRect(-i,-i,i*2,i*2,D)}else t.arc(0,0,i,0,Math.PI*2);t.fillStyle=((C=s.style)==null?void 0:C.baseColor)||"rgba(0,0,0,0.04)",t.fill(),(w=s.style)!=null&&w.baseBorderWidth?(t.lineWidth=s.style.baseBorderWidth,t.strokeStyle=s.style.baseBorderColor||"rgba(0,0,0,0.1)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((I=s.style)==null?void 0:I.baseBorderColor)||"rgba(0,0,0,0.08)",t.stroke());const u=s.overflowHandle?i:Math.max(.1,i-a);let f=0,h=0;s.joystickType==="2D"?(f=r*u,h=l*u):s.joystickType==="1D_X"?(f=r*u,h=0):s.joystickType==="1D_Y"&&(f=0,h=l*u),t.globalAlpha=g*(((k=s.style)==null?void 0:k.handleOpacity)??1),t.beginPath(),t.arc(f,h,a,0,Math.PI*2),t.fillStyle=((O=s.style)==null?void 0:O.handleColor)||"#3b82f6",t.fill(),(T=s.style)!=null&&T.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((A=s.style)==null?void 0:A.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=g,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var k,O;const e=t.options||{},n=this.objectStates.get(t.id)||{},i=e.optionsList||[];if(i.length===0)return null;const a=n.width!==void 0?n.width:((k=t.geometry)==null?void 0:k.width)||180,r=n.height!==void 0?n.height:((O=t.geometry)==null?void 0:O.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,p=e.fontSize||14,g=this.getWorldTransform(t.id),u=s-g.x,f=o-g.y,h=-g.rotation*(Math.PI/180),m=Math.cos(h),b=Math.sin(h),c=u*m-f*b,S=u*b+f*m,C=8*2,w=-a/2,I=-r/2;if(l==="vertical"){const T=Math.max(C,p)+d;for(let A=0;A<i.length;A++){const D=I+A*T;if(c>=w&&c<=w+a&&S>=D&&S<=D+T)return A}}else{let T=w;for(let A=0;A<i.length;A++){const Y=i[A].length*8,B=C+6+Y+d;if(c>=T&&c<=T+B&&S>=I&&S<=I+r)return A;T+=B}}return null}renderLineGraph(t,s,o,e,n){const i=this.objectStates.get(s.id),a=(i==null?void 0:i.options)||s.options||{},r=a.hoverStyle||{},l=a.loadingStyle||{},d=a.entranceStyle||{},p=a.pressedStyle||{};let g=o.datasets||[];(!g||g.length===0)&&(o.data||o.graphData)&&(g=[{id:"line-1",label:"Series 1",data:o.data||o.graphData||[],lineColor:o.lineColor||"#3b82f6",lineWidth:o.lineWidth||2,showArea:o.showArea||!1,areaColor:o.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:o.smoothing||!1,showPoints:o.showPoints!==void 0?o.showPoints:!0,pointSize:o.pointSize||6,pointFill:o.pointFill||"#ffffff",pointStrokeColor:o.pointStrokeColor||o.lineColor||"#3b82f6",pointStrokeWidth:o.pointStrokeWidth||2}]);let u=1/0,f=-1/0,h=0;g.forEach(B=>{let R=B.data;if(B.isVarEnabled&&B.inputId){let L=this.inputs.get(B.inputId);if(L===void 0){const $=this.inputNameMap.get(B.inputId);$&&$.length>0&&(L=this.inputs.get($[0]))}if(L!=null){if(typeof L=="string")try{L=JSON.parse(L)}catch{L=L.split(",").map($=>Number($.trim()))}Array.isArray(L)&&(R=L)}}if(R&&R.length>0){const L=R.map($=>Number($)).filter($=>!isNaN($));L.length>0&&(u=Math.min(u,...L),f=Math.max(f,...L),h=Math.max(h,L.length))}B._resolvedData=R});const m=a.previewState||"default";if(a.simulateLoading||m==="loading"||h<2){const B=l.skeletonColor||"rgba(100, 116, 139, 0.4)",R=l.pulseSpeed||1.5,L=l.minOpacity||.3,$=this.currentTime,F=L+(1-L)*(.5*(1+Math.sin($*Math.PI*2*R)));t.save(),t.globalAlpha=F,t.strokeStyle=B,t.lineWidth=o.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.beginPath();const X=40;for(let M=0;M<=X;M++){const E=-e/2+e/X*M,P=Math.sin(M*.4-$*4)*(n/8);M===0?t.moveTo(E,P):t.lineTo(E,P)}t.stroke(),t.restore();return}const c=f-u,S=e/(h-1),v=B=>{const R=c===0?.5:(B-u)/c;return n/2-R*n},C=B=>B*S-e/2,w=o.axisColor||"#333333";if(o.showXAxis&&(t.beginPath(),t.strokeStyle=o.xAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,n/2),t.lineTo(e/2,n/2),t.stroke()),o.showYAxis&&(t.beginPath(),t.strokeStyle=o.yAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,-n/2),t.lineTo(-e/2,n/2),t.stroke()),t.fillStyle=o.axisLabelColor||"#333333",t.font=`${o.axisLabelFontSize||10}px Inter, sans-serif`,o.showXLabels){t.textAlign="center",t.textBaseline="top";for(let B=0;B<h;B++){const R=C(B);t.fillText(`${B+1}`,R,n/2+5)}}if(o.showYLabels){t.textAlign="right",t.textBaseline="middle";const B=-e/2-5,R=(f+u)/2;t.fillText(f.toFixed(1),B,v(f)),t.fillText(R.toFixed(1),B,v(R)),t.fillText(u.toFixed(1),B,v(u))}const I=10,k=d.type||"none",O=this.getEntranceProgress(s.id,d,m);if(t.save(),k==="fade"?t.globalAlpha*=O:k==="draw"&&(t.beginPath(),t.rect(-e/2-10,-n/2-10,(e+20)*O,n+20),t.clip()),k!=="none"&&(d.showAxes===!1&&(o.showXAxis=!1,o.showYAxis=!1),d.showLabels===!1&&(o.showXLabels=!1,o.showYLabels=!1)),g.forEach(B=>{const R=B._resolvedData;if(!(!R||R.length<2)){if(B.showArea){if(t.beginPath(),t.moveTo(C(0),n/2),t.lineTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let $=0;$<R.length-1;$++){const F=R[$===0?$:$-1],X=R[$],M=R[$+1],E=R[$+1===R.length-1?$+1:$+2];for(let P=1;P<=I;P++){const _=P/I,V=this._catmullRom(F,X,M,E,_);t.lineTo(C($+_),v(V))}}else for(let $=1;$<R.length;$++)t.lineTo(C($),v(R[$]));t.lineTo(C(R.length-1),n/2),t.closePath();const L=t.globalAlpha;t.globalAlpha=L*(o.areaOpacity??.3),t.fillStyle=B.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=L}if(t.beginPath(),t.strokeStyle=B.lineColor||"#3b82f6",t.lineWidth=B.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let L=0;L<R.length-1;L++){const $=R[L===0?L:L-1],F=R[L],X=R[L+1],M=R[L+1===R.length-1?L+1:L+2];for(let E=1;E<=I;E++){const P=E/I,_=this._catmullRom($,F,X,M,P);t.lineTo(C(L+P),v(_))}}else for(let L=1;L<R.length;L++)t.lineTo(C(L),v(R[L]));t.stroke(),(B.showPoints||m==="hover"||m==="pressed")&&R.forEach((L,$)=>{const F=C($),X=v(L);let M=(B.pointSize||6)/2,E=!1,P=!1;const _=$===Math.floor(R.length/2);m==="pressed"&&_?P=!0:m==="hover"&&_&&(E=!0),!(!B.showPoints&&!E&&!P)&&(P?(M*=p.scale||1.5,t.beginPath(),t.arc(F,X,M*1.5,0,Math.PI*2),t.fillStyle=p.rippleColor||"rgba(59, 130, 246, 0.4)",t.fill()):E&&(M*=r.scale||1.02),t.beginPath(),t.arc(F,X,M,0,Math.PI*2),t.fillStyle=B.pointFill||"#ffffff",t.fill(),t.strokeStyle=B.pointStrokeColor||B.lineColor||"#3b82f6",t.lineWidth=B.pointStrokeWidth||1,t.stroke())})}}),t.restore(),o.showLegend&&g.length>0){const B=e/2-10;let R=-n/2+15;const L=o.legendFontSize||10,$=L+5;t.font=`${L}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",g.forEach(F=>{const M=F.label||"Series",E=t.measureText(M).width;t.beginPath(),t.rect(B-E-8-5,R-(8/2+2),8,8),t.fillStyle=F.lineColor||"#3b82f6",t.fill(),t.fillStyle=o.legendColor||"#333333",t.fillText(M,B,R),R+=$})}const T=this.graphHoverStates.get(s==null?void 0:s.id),A=T==null?void 0:T.hoveredIndex,D=o.showHoverTooltip!==!1,Y=o.showHoverLine!==!1;if(A!=null&&(D||Y)){const B=C(A);Y&&(t.save(),t.beginPath(),t.strokeStyle=o.hoverLineColor||"rgba(255, 255, 255, 0.35)",t.lineWidth=1,t.setLineDash([3,3]),t.moveTo(B,-n/2),t.lineTo(B,n/2),t.stroke(),t.setLineDash([]),t.restore());const R=[];if(g.forEach(L=>{const $=L._resolvedData||L.data;if($&&$[A]!==void 0&&typeof $[A]=="number"&&!isNaN($[A])){const F=$[A],X=v(F),M=L.lineColor||"#3b82f6";R.push({y:X,color:M,label:L.label||"Series",val:F});const E=this.isMouseDown,P=E?p.scale||1.5:1,_=E?p.rippleColor||"rgba(59, 130, 246, 0.4)":typeof M=="string"&&M.startsWith("#")?`${M}33`:"rgba(59, 130, 246, 0.2)";t.save(),t.beginPath();const V=o.pointHighlightRadius||5;t.arc(B,X,(V+3)*P,0,Math.PI*2),t.fillStyle=_,t.fill(),t.beginPath(),t.arc(B,X,V*P,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.strokeStyle=M,t.lineWidth=2.5*P,t.stroke(),t.restore()}}),D&&R.length>0){t.save();const L=10,$=8,F=16,X=14,M=$*2+X+R.length*F;t.font="bold 10px Inter, system-ui, sans-serif";let E=t.measureText(`Point #${A+1}`).width;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{const q=t.measureText(`${U.label}: ${U.val.toFixed(1)}`).width+16;q>E&&(E=q)});const P=E+L*2;let _=B+12;_+P>e/2-4&&(_=B-P-12),_<-e/2+4&&(_=-e/2+4);let G=R.reduce((U,q)=>U+q.y,0)/R.length-M/2;G<-n/2+6&&(G=-n/2+6),G+M>n/2-6&&(G=n/2-M-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,_,G,P,M,o.tooltipRadius||6),t.fillStyle=o.tooltipBg||"#111827",t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=o.tooltipTextColor||"#f9fafb",t.textAlign="left",t.textBaseline="top",t.fillText(`Point #${A+1}`,_+L,G+$);let x=G+$+X+2;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{t.beginPath(),t.arc(_+L+4,x+5,3.5,0,Math.PI*2),t.fillStyle=U.color,t.fill(),t.fillStyle=o.tooltipTextColor||"#f9fafb",t.fillText(`${U.label}: `,_+L+12,x);const q=t.measureText(`${U.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(`${U.val.toFixed(1)}`,_+L+12+q,x),t.font="9px Inter, system-ui, sans-serif",x+=F}),t.restore()}}}_catmullRom(t,s,o,e,n){const i=(o-t)*.5,a=(e-s)*.5,r=n*n,l=n*r;return(2*s-2*o+i+a)*l+(-3*s+3*o-2*i-a)*r+i*n+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var n,i,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if((s.type==="Solid"||!s.type)&&s.color){const r=typeof s.color=="string"?s.color:s.color.color||"#000000",d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if(typeof s=="object"&&"r"in s&&"g"in s&&"b"in s){const r=s.a!==void 0?s.a:s.opacity!==void 0?s.opacity:1;return`rgba(${s.r}, ${s.g}, ${s.b}, ${r})`}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var v,C;const g=(((C=(v=this.artboard)==null?void 0:v.tokens)==null?void 0:C.colors)||{})[l]||l,u=this.normalizeOpacity(s.opacity??100),h=this.normalizeOpacity(d)*u;if(h>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",b=parseInt(m.substring(0,2),16),c=parseInt(m.substring(2,4),16),S=parseInt(m.substring(4,6),16);return`rgba(${b}, ${c}, ${S}, ${h})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,p=0,g=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const f=(s.angle-90)*Math.PI/180,h=Math.max(o,e)/2;l=Math.cos(f)*-h,d=Math.sin(f)*-h,p=Math.cos(f)*h,g=Math.sin(f)*h}else if(s.start||s.end){const f=(h,m,b)=>Array.isArray(h)?h[m]??.5:h&&typeof h=="object"?h[b]??.5:.5;l=f(s.start,0,"x")*o-o/2,d=f(s.start,1,"y")*e-e/2,p=f(s.end,0,"x")*o-o/2,g=f(s.end,1,"y")*e-e/2}Math.abs(l-p)<.001&&Math.abs(d-g)<.001&&(l=0,d=-e/2,p=0,g=e/2);const u=t.createLinearGradient(l,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="RadialGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center,0,"x")*o-o/2,p=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),u=t.createRadialGradient(d,p,0,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="AngularGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),u=(a=t.createConicGradient)==null?void 0:a.call(t,g,d,p);if(u){if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}}else if(s.type==="DiamondGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,p),t.rotate(Math.PI/4);const u=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=u,t.restore(),u}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const d=new DOMMatrix,p=s.scaleX??1,g=s.scaleY??1,u=s.offsetX??0,f=s.offsetY??0,h=s.rotation??0;d.translateSelf(u,f),d.rotateSelf(h),d.scaleSelf(p,g),l.setTransform(d)}return l}}return s.color||null}drawRoundRect(t,s,o,e,n,i){if(i===0||i===void 0||i===null){t.rect(s,o,e,n);return}let a=i;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,d=0,p=0;typeof a=="number"?r=l=d=p=a:Array.isArray(a)?a.length===1?r=l=d=p=a[0]:a.length===2?(r=d=a[0],l=p=a[1]):a.length===3?(r=a[0],l=p=a[1],d=a[2]):a.length>=4&&(r=a[0],l=a[1],d=a[2],p=a[3]):a&&typeof a=="object"&&(r=a[0]??a.tl??a.corner_radius??a.cornerRadius??0,l=a[1]??a.tr??a.corner_radius??a.cornerRadius??0,d=a[2]??a.br??a.corner_radius??a.cornerRadius??0,p=a[3]??a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),d=Math.min(Math.max(0,d),g),p=Math.min(Math.max(0,p),g),t.roundRect){t.roundRect(s,o,e,n,[r,l,d,p]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+n-d),t.arcTo(s+e,o+n,s+e-d,o+n,d),t.lineTo(s+p,o+n),t.arcTo(s,o+n,s,o+n-p,p),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,L,$,F,X,M,E,P,_,V;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,i=o.height!==void 0?o.height:((L=s.geometry)==null?void 0:L.height)||300,a=-n/2,r=-i/2,l=e.cornerRadius!==void 0?e.cornerRadius:o.cornerRadius!==void 0?o.cornerRadius:o.corner_radius??e.corner_radius??(($=s.geometry)==null?void 0:$.cornerRadius)??((F=s.geometry)==null?void 0:F.corner_radius)??0,d=e.orientation||"vertical",p=this.getResolvedListViewItems(s,e),g=e.itemGap??10,u=e.itemHeight??50,f=e.itemWidth??200,h=e.scrollOffset??0,m=e.padding??0,b=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",S=e.itemTextColor||"#333333",v=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,I=e.glowIntensity??0,k=e.glowColor||"#3b82f6",O=typeof k=="string"?k:k.color||((M=(X=k.stops)==null?void 0:X[0])==null?void 0:M.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,I>0){const G=t.getTransform(),x=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=O,t.shadowBlur=I*2*x,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",x=this.createCanvasFill(t,G,n,i);t.fillStyle=x||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const q=t.createLinearGradient(a,r,a+n,r+i);q.addColorStop(0,"rgba(255, 255, 255, 0.15)"),q.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),q.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=q,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const H=e.borderWidth??0;if(H>0&&e.borderColor&&e.borderColor!=="transparent"){const et=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=et||"rgba(255, 255, 255, 0.25)",t.lineWidth=H}else t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1;t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.stroke()}else{const G=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",x=this.createCanvasFill(t,G,n,i);if(x){t.fillStyle=x,t.beginPath();const q=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const U=e.borderWidth??0;if(U>0){const q=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=q||"#cccccc",t.lineWidth=U,t.beginPath();const N=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const A=e.clipContent!==!1&&e.listLayout!=="circular";if(A)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const x=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(x),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const D=typeof m=="number"?m:d==="vertical"?m[0]:m[3];let Y=(d==="vertical"?r:a)+h+D;if(t.textBaseline="middle",p.forEach((G,x)=>{var ut,$t,St,Pt;const U=e.listLayout||"linear",q=U==="circular"?f:d==="vertical"?n:f,N=U==="circular"||d==="vertical"?u:i;let H=0,z=0,et=0;if(U==="circular"){const Ft=p.length||1,lt=Math.PI*2/Ft,ht=e.circularStartAngle||0,dt=e.circularRadius||100,At=h*.01+ht*Math.PI/180,Tt=x*lt+At,Ct=a+n/2,Yt=r+i/2;H=Ct+Math.cos(Tt)*dt-q/2,z=Yt+Math.sin(Tt)*dt-N/2,et=Tt+(e.itemRotation||0)*Math.PI/180}else H=d==="vertical"?a:Y,z=d==="vertical"?Y:r,et=(e.itemRotation||0)*Math.PI/180;const Mt=C===x,ct=w===x,It=e.itemBorderWidth??0;t.save(),et!==0&&(t.translate(H+q/2,z+N/2),t.rotate(et),t.translate(-(H+q/2),-(z+N/2)));const mt=Mt?((ut=e.hoverStyle)==null?void 0:ut.scale)??1:ct?(($t=e.activeStyle)==null?void 0:$t.scale)??1:1;if(mt!==1&&(t.translate(H+q/2,z+N/2),t.scale(mt,mt),t.translate(-(H+q/2),-(z+N/2))),ct){const Ft=((St=e.activeStyle)==null?void 0:St.itemBackgroundColor)||e.activeBackgroundColor||(b?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(Mt){const Ft=((Pt=e.hoverStyle)==null?void 0:Pt.itemBackgroundColor)||e.hoverBackgroundColor||(b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(v!=="transparent"){const Ft=this.createCanvasFill(t,v,q,N);t.fillStyle=Ft||(typeof v=="string"?v:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}if(It>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const Ft=this.createCanvasFill(t,e.itemBorderColor,q,N);t.strokeStyle=Ft||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=It,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.stroke()}if(ct){const Ft=this.createCanvasFill(t,c,d==="vertical"?3:q,d==="vertical"?N:3);t.fillStyle=Ft||c,d==="vertical"?t.fillRect(H,z,3,N):t.fillRect(H,z+N-3,q,3)}const kt=ct?"#ffffff":b?"rgba(255, 255, 255, 0.9)":S;t.fillStyle=kt,t.font=ct||Mt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ot=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${x+1}`,vt=H+(d==="vertical"?16:q/2),Wt=z+N/2;d==="horizontal"||U==="circular"?t.textAlign="center":t.textAlign="left";const J=U==="circular"?H+q/2:vt;t.fillText(Ot,J,Wt),t.restore(),t.beginPath(),Y+=(d==="vertical"?u:f)+g}),A&&t.restore(),e.showScrollbar!==!1){const G=typeof m=="number"?m:d==="vertical"?m[0]:m[3],U=(p.length||0)*(d==="vertical"?u:f)+Math.max(0,(p.length||0)-1)*g+G*2,q=d==="vertical"?i:n,N=e.listLayout||"linear",H=e.containerShape==="circle"||N==="circular",z=e.scrollbarColor||"rgba(255,255,255,0.3)";let et=typeof z=="object"?z.color||((P=(E=z.stops)==null?void 0:E[0])==null?void 0:P.color)||"rgba(255,255,255,0.3)":z;const Mt=((V=(_=this.artboard)==null?void 0:_.tokens)==null?void 0:V.colors)||{};Mt[et]&&(et=Mt[et]);const ct=e.scrollbarWidth||2;if(t.save(),H){const It=Math.min(n,i)/2-ct/2-2,mt=a+n/2,kt=r+i/2;if(t.strokeStyle=et,t.lineWidth=ct,t.lineCap="round",t.beginPath(),N==="circular"){const Ot=Math.PI/4,vt=-(h*.01)-Math.PI/2;t.arc(mt,kt,It,vt,vt+Ot)}else{const Ot=Math.PI/2,vt=U>0?Math.min(1,q/U):1,Wt=Ot*vt,J=U>0?-h/U*Ot:0,$t=-Math.PI/4+J;t.arc(mt,kt,It,$t,$t+Wt)}t.stroke()}else{let It=q,mt=0;if(U>q){const kt=q/U;It=Math.max(16,q*kt);const Ot=q-It,vt=U-q;mt=vt>0?Math.max(0,Math.min(Ot,-h/vt*Ot)):0}if(t.fillStyle=et,d==="vertical"){const kt=a+n-ct-2,Ot=r+mt,vt=ct,Wt=It;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else{const kt=a+mt,Ot=r+i-ct-2,vt=It,Wt=ct;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}}t.restore()}t.beginPath(),t.restore()}drawCustomShape(t,s,o,e,n,i,a,r){if(s==="circle"){const l=Math.min(i,a)/2;return t.arc(e+i/2,n+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(i,a)/2;return this.drawListViewRect(t,e,n,i,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,n),t.scale(i/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,n,i,a,r),!1}return this.drawListViewRect(t,e,n,i,a,r),!1}updateListViewScrollFromPointer(t){var v,C,w,I;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=this.objectStates.get(t.id);s&&!s.options&&(s.options=JSON.parse(JSON.stringify(t.options||{})));const o=(s==null?void 0:s.options)||t.options||{},e=o.orientation||"vertical",n=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;let a=o.scrollOffset||0;const r=this.getResolvedListViewItems(t,o),l=o.itemGap??10,d=o.itemHeight??50,p=o.itemWidth??200,g=(s==null?void 0:s.width)!==void 0?s.width:((v=t.geometry)==null?void 0:v.width)||200,u=(s==null?void 0:s.height)!==void 0?s.height:((C=t.geometry)==null?void 0:C.height)||300,f=typeof o.padding=="number"?o.padding:e==="vertical"?((w=o.padding)==null?void 0:w[0])||0:((I=o.padding)==null?void 0:I[3])||0,m=(r.length||0)*(e==="vertical"?d:p)+Math.max(0,(r.length||0)-1)*l+f*2,b=e==="vertical"?u:g,c=Math.max(0,m-b);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const k=m>0?b/m:1,O=Math.max(16,b*k),T=Math.max(1,b-O),A=c>0?c/T:1;e==="vertical"?a-=i*A:a-=n*A}else e==="vertical"?a+=i:a+=n;if((o.listLayout||"linear")==="circular"){o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a);return}a>0&&(a=0),a<-c&&(a=-c),o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),n=this.objectStates.get(t.id);if(n&&n.options)n.options.hoveredIndex!==e&&(n.options.hoveredIndex=e);else{const i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}}getListViewItemIndexAtPointer(t,s,o){var $,F;const e=this.objectStates.get(t.id),n=(e==null?void 0:e.options)||t.options||{},i=this.getResolvedListViewItems(t,n);if(i.length===0)return null;const a=(e==null?void 0:e.width)!==void 0?e.width:(($=t.geometry)==null?void 0:$.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((F=t.geometry)==null?void 0:F.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,p=n.itemHeight??50,g=n.itemWidth??200,u=n.scrollOffset??0,f=n.padding??0,h=this.getWorldTransform(t.id),m=s-h.x,b=o-h.y,c=-h.rotation*(Math.PI/180),S=Math.cos(c),v=Math.sin(c),C=m*S-b*v,w=m*v+b*S,I=-a/2,k=-r/2,O=typeof f=="number"?f:l==="vertical"?f[0]:f[3];let T=(l==="vertical"?k:I)+u+O;const A=n.listLayout||"linear",D=i.length||1,Y=Math.PI*2/D,B=n.circularStartAngle||0,R=n.circularRadius||100,L=u*.01+B*Math.PI/180;for(let X=0;X<i.length;X++){const M=A==="circular"?g:l==="vertical"?a:g,E=A==="circular"||l==="vertical"?p:r;let P=0,_=0,V=0;if(A==="circular"){const G=X*Y+L,x=I+a/2,U=k+r/2;P=x+Math.cos(G)*R-M/2,_=U+Math.sin(G)*R-E/2,V=G+(n.itemRotation||0)*Math.PI/180}else P=l==="vertical"?I:T,_=l==="vertical"?T:k,V=(n.itemRotation||0)*Math.PI/180;if(V!==0){const G=P+M/2,x=_+E/2,U=C-G,q=w-x,N=-V,H=U*Math.cos(N)-q*Math.sin(N)+G,z=U*Math.sin(N)+q*Math.cos(N)+x;if(H>=P&&H<=P+M&&z>=_&&z<=_+E)return X}else if(C>=P&&C<=P+M&&w>=_&&w<=_+E)return X;T+=(l==="vertical"?p:g)+d}return null}drawListViewRect(t,s,o,e,n,i){this.drawRoundRect(t,s,o,e,n,i)}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const n=this.objectStates.get(e.id);n&&e.behaviors.forEach(i=>{var g,u,f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E,P,_,V,G,x,U,q,N,H,z,et,Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft,lt,ht,dt,At,Tt,Ct,Yt,ie,te,Zt,le,fe,qt,Se,Ce,Ie,de,Re,ye,ke,Vt,ee,j,bt,st,K,rt,ft,Rt,Qt,Kt,ae,Jt,Et,W,nt,Lt,tt,gt,Q,Ut,zt,yt,Bt,_t,Xt,Dt,ce,be,Le,oe,pe,he,$e,Be,Ye,De,Xe,Ne,Ue,re,ve,Te,He,Ve,_e,Pe;if(!i.enabled)return;const a=i.startTime||0,r=i.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=n.x-s,d=n.y-o,p=Math.sqrt(l*l+d*d);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${i.type} on ${e.name}`),i.type===it.Proximity){const Z=((g=i.settings)==null?void 0:g.radius)||300,ot=((u=i.settings)==null?void 0:u.falloff)||"smooth";let at=0;p<Z&&(ot==="linear"?at=1-p/Z:at=Math.pow(1-p/Z,2)),i.sensors.forEach(wt=>{this.applyBehaviorSensor(n,wt,at,t,i.settings,e,l,d,p)})}else if(i.type===it.Magnetic){const Z=((f=i.settings)==null?void 0:f.radius)||400,ot=((h=i.settings)==null?void 0:h.strength)||.5;if(p<Z&&p>5){const at=1-p/Z,wt=l*at*ot,Gt=d*at*ot;n.x-=wt*t*10,n.y-=Gt*t*10}}else if(i.type===it.Repel){const Z=((m=i.settings)==null?void 0:m.radius)||300,ot=((b=i.settings)==null?void 0:b.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x+=l/(p||1)*at*60*ot*t*5,n.y+=d/(p||1)*at*60*ot*t*5}}else if(i.type===it.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,ot=((S=i.settings)==null?void 0:S.radius)||30,at=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(at)*ot*t*5,n.y+=Math.sin(at)*ot*t*5,n.rotation+=2*t*5}else if(i.type===it.Vortex){const Z=((v=i.settings)==null?void 0:v.radius)||400,ot=((C=i.settings)==null?void 0:C.speed)||2,at=((w=i.settings)==null?void 0:w.strength)||1;if(p<Z){const wt=Math.pow(1-p/Z,1.5),Gt=this.currentTime*ot*Math.PI*2,xt=Math.cos(Gt)*30-l*.4,jt=Math.sin(Gt)*30-d*.4;n.x+=xt*wt*at*t*5,n.y+=jt*wt*at*t*5,n.rotation+=5*wt*at*t*5,n.scale_x*=1-wt*.1*at*t,n.scale_y*=1-wt*.1*at*t}}else if(i.type===it.Fluid){const Z=((I=i.settings)==null?void 0:I.radius)||300,ot=((k=i.settings)==null?void 0:k.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,1.2),wt=l/(p||1)*at*1.2*ot,Gt=d/(p||1)*at*1.2*ot;n.x+=wt*10*t*5,n.y+=Gt*10*t*5,n.scale_x*=1+at*.3*ot*t,n.scale_y*=1+at*.3*ot*t}}else if(i.type===it.Elastic){const Z=((O=i.settings)==null?void 0:O.radius)||300,ot=((T=i.settings)==null?void 0:T.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.4*ot*t,n.scale_y*=1+at*.4*ot*t}}else if(i.type===it.Holographic){const Z=n.x-this.canvasWidth/2,ot=n.y-this.canvasHeight/2,at=((A=i.settings)==null?void 0:A.factor)||25;if(n.x-=Z/1e3*at*t*5,n.y-=ot/1e3*at*t*5,n.style){const wt=1-Math.min(1,p/400);n.style.exposure=(n.style.exposure||1)+wt*.5*t}}else if(i.type===it.Sticky){const Z=((D=i.settings)==null?void 0:D.radius)||80,ot=((Y=i.settings)==null?void 0:Y.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x-=l*at*ot*t*10,n.y-=d*at*ot*t*10,n.scale_x*=1-at*.1*ot*t,n.scale_y*=1-at*.1*ot*t}}else if(i.type===it.Dilation){const Z=((B=i.settings)==null?void 0:B.size)||120,ot=((R=i.settings)==null?void 0:R.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.5*ot*t,n.scale_y*=1+at*.5*ot*t}}else if(i.type===it.Parallax){const Z=((L=i.settings)==null?void 0:L.factor)||15,ot=(($=i.settings)==null?void 0:$.strength)||1,at=this.canvasWidth/2,wt=this.canvasHeight/2,Gt=this._lastPointerPos||{x:at,y:wt},xt=(Gt.x-at)/at,jt=(Gt.y-wt)/wt,me=(((F=e.transform)==null?void 0:F.x)??0)+xt*Z*ot,Ae=(((X=e.transform)==null?void 0:X.y)??0)+jt*Z*ot,Fe=(((M=e.transform)==null?void 0:M.rotate_x)??0)-jt*Z*1.5*ot,we=(((E=e.transform)==null?void 0:E.rotate_y)??0)+xt*Z*1.5*ot,Oe=Math.min(1,10*t);n.x=this.lerp(n.x??((P=e.transform)==null?void 0:P.x)??0,me,Oe),n.y=this.lerp(n.y??((_=e.transform)==null?void 0:_.y)??0,Ae,Oe),n.rotate_x=this.lerp(n.rotate_x??((V=e.transform)==null?void 0:V.rotate_x)??0,Fe,Oe),n.rotate_y=this.lerp(n.rotate_y??((G=e.transform)==null?void 0:G.rotate_y)??0,we,Oe)}else if(i.type===it.Fold){if(p<300){const Z=1-p/300,ot=(l>0?-1:1)*Z*10,at=1-Z*.1,wt=d/300*Z*20,Gt=-(l/300)*Z*20,xt=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((x=e.transform)==null?void 0:x.skew_x)??0,ot,xt),n.scale_y=this.lerp(n.scale_y??((U=e.transform)==null?void 0:U.scale_y)??1,(((q=e.transform)==null?void 0:q.scale_y)??1)*at,xt),n.rotate_x=this.lerp(n.rotate_x??((N=e.transform)==null?void 0:N.rotate_x)??0,wt,xt),n.rotate_y=this.lerp(n.rotate_y??((H=e.transform)==null?void 0:H.rotate_y)??0,Gt,xt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((z=i.settings)==null?void 0:z.opacity)??.5}}}else if(i.type===it.Crumple){if(p<300){const Z=1-p/300,ot=Z*(Math.random()-.5)*5,at=Z*(Math.random()-.5)*.05,wt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((et=e.transform)==null?void 0:et.skew_x)??0,ot,wt),n.scale_x=this.lerp(n.scale_x??((Mt=e.transform)==null?void 0:Mt.scale_x)??1,(((ct=e.transform)==null?void 0:ct.scale_x)??1)*(1+at),wt),n.scale_y=this.lerp(n.scale_y??((It=e.transform)==null?void 0:It.scale_y)??1,(((mt=e.transform)==null?void 0:mt.scale_y)??1)*(1+at),wt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((kt=i.settings)==null?void 0:kt.intensity)??1,scale:((Ot=i.settings)==null?void 0:Ot.scale)??2}}}else if(i.type===it.Squash){const Z=((vt=i.settings)==null?void 0:vt.strength)||.8;p<(e.width||100)&&this.isMouseDown?(n.scale_y=this.lerp(n.scale_y??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*Z,.3),n.scale_x=this.lerp(n.scale_x??1,(((J=e.transform)==null?void 0:J.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ut=e.transform)==null?void 0:ut.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,(($t=e.transform)==null?void 0:$t.scale_x)??1,.2))}else if(i.type===it.TextCounter){const Z=((St=i.settings)==null?void 0:St.duration)||2,ot=((Pt=i.settings)==null?void 0:Pt.from)||0,at=((Ft=i.settings)==null?void 0:Ft.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const wt=this.currentTime-i._runtimeStart,Gt=Math.min(1,wt/Z),xt=Math.floor(ot+(at-ot)*Gt);if(((lt=e.geometry)==null?void 0:lt.type)==="Text"){const jt=((ht=i.settings)==null?void 0:ht.prefix)||"",me=((dt=i.settings)==null?void 0:dt.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${jt}${xt}${me}`}}else if(i.type===it.Spotlight){const Z=((At=i.settings)==null?void 0:At.radius)||250,ot=((Tt=i.settings)==null?void 0:Tt.strength)||1.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(Ct=e.style)==null?void 0:Ct.adjustments}),n.style.adjustments.exposure=(((ie=(Yt=e.style)==null?void 0:Yt.adjustments)==null?void 0:ie.exposure)||0)+at*ot*50}else(te=n.style)!=null&&te.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((le=(Zt=e.style)==null?void 0:Zt.adjustments)==null?void 0:le.exposure)||0,.1))}else if(i.type===it.Noise||i.type===it.Float){const Z=(((fe=i.settings)==null?void 0:fe.frequency)||((qt=i.settings)==null?void 0:qt.speed)||1)*.002,ot=(((Se=i.settings)==null?void 0:Se.amplitude)||((Ce=i.settings)==null?void 0:Ce.range)||50)*(((Ie=i.settings)==null?void 0:Ie.strength)||1),at=Date.now();n.x+=Math.sin(at*Z)*ot*t,n.y+=Math.cos(at*Z*.8)*ot*t,n.rotation+=Math.sin(at*Z*.5)*5*t}else if(i.type===it.Pulse){const Z=(((de=i.settings)==null?void 0:de.speed)||1)*.005,ot=(((Re=i.settings)==null?void 0:Re.scale)||1.2)-1,at=Math.sin(Date.now()*Z),wt=((ye=i.settings)==null?void 0:ye.strength)||1;n.scale_x*=1+at*ot*wt*t,n.scale_y*=1+at*ot*wt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,at)*.1*wt*t)}else if(i.type===it.Draggable){if(!this.draggingBehaviors.has(e.id)){const ot=((ke=i.settings)==null?void 0:ke.radius)||150;if(p<ot){const at=((Vt=i.settings)==null?void 0:Vt.strength)||1,wt=Math.max(0,1-p/ot);this.applyBehaviorSensor(n,ge.PositionX,wt*at,t,i.settings,e,l,d,p),this.applyBehaviorSensor(n,ge.PositionY,wt*at,t,i.settings,e,l,d,p)}}}else if(i.type===it.Scroll){const Z=((ee=i.settings)==null?void 0:ee.axis)||"vertical",ot=((j=i.settings)==null?void 0:j.factor)||.5,at=((bt=i.settings)==null?void 0:bt.strength)||1,wt=((st=i.settings)==null?void 0:st.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*ot*at*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*ot*at*t),wt!==0&&(n.scale_x*=1+this.scrollOffset.y*wt*t,n.scale_y*=1+this.scrollOffset.y*wt*t)}else if(i.type===it.LookAt){const Z=((K=i.settings)==null?void 0:K.factor)||1,ot=((rt=i.settings)==null?void 0:rt.strength)||1,at=Math.atan2(-d,-l)*(180/Math.PI),wt=n.rotation,Gt=(at-wt+180)%360-180;n.rotation+=Gt*Z*ot*t*10}else if(i.type===it.Scan){const Z=(((ft=i.settings)==null?void 0:ft.speed)||1)*.004,ot=((Rt=i.settings)==null?void 0:Rt.strength)||1,at=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+at*ot*t*5),n.x+=(at-.5)*20*ot*t}else if(i.type===it.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Qt=i.settings)==null?void 0:Qt.strength)??.8};else if(i.type===it.Ratchet){const Z=((Kt=i.settings)==null?void 0:Kt.steps)||12,ot=(((ae=i.settings)==null?void 0:ae.speed)||1)*30,at=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,at+ot*t,.1)}else if(i.type===it.Jitter&&p<300){const Z=((Jt=i.settings)==null?void 0:Jt.strength)||1,ot=(((Et=i.settings)==null?void 0:Et.intensity)||5)*Z;n.x+=(Math.random()-.5)*ot*t*60,n.y+=(Math.random()-.5)*ot*t*60,n.rotation+=(Math.random()-.5)*ot*t*120}else if(i.type===it.Follower){const Z=(W=i.settings)==null?void 0:W.targetId;if(Z){const ot=this.objectStates.get(Z);if(ot){const at=((nt=i.settings)==null?void 0:nt.stiffness)||.1,wt=ot.x-n.x,Gt=ot.y-n.y;n.x+=wt*at*t*60,n.y+=Gt*at*t*60}}}else if(i.type===it.Wrap)n.x<0?n.x=this.canvasWidth:n.x>this.canvasWidth&&(n.x=0),n.y<0?n.y=this.canvasHeight:n.y>this.canvasHeight&&(n.y=0);else if(i.type===it.Gravity){const Z=((Lt=i.settings)==null?void 0:Lt.strength)||9.8;n.y+=Z*t*10}else if(i.type===it.Velocity){const Z=((tt=i.settings)==null?void 0:tt.vx)||0,ot=((gt=i.settings)==null?void 0:gt.vy)||0;n.x+=Z*t*10,n.y+=ot*t*10}else if(i.type===it.Shear){const Z=((Q=i.settings)==null?void 0:Q.strength)||1,ot=((Ut=i.settings)==null?void 0:Ut.radius)||300;if(p<ot){const at=1-p/ot;n.skew_x=this.lerp(n.skew_x||0,(((zt=e.transform)==null?void 0:zt.skew_x)||0)+at*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((yt=e.transform)==null?void 0:yt.skew_x)||0,.05)}else if(i.type===it.Lens){const Z=((Bt=i.settings)==null?void 0:Bt.radius)||200,ot=((_t=i.settings)==null?void 0:_t.strength)||.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Xt=e.transform)==null?void 0:Xt.scale_x)??1)*(1+at*ot),.2),n.scale_y=this.lerp(n.scale_y??1,(((Dt=e.transform)==null?void 0:Dt.scale_y)??1)*(1+at*ot),.2)}else n.scale_x=this.lerp(n.scale_x??1,((ce=e.transform)==null?void 0:ce.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((be=e.transform)==null?void 0:be.scale_y)??1,.1)}else if(i.type===it.LayoutAnimation){const Z=((Le=i.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],ot=((oe=i.settings)==null?void 0:oe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const at=this._layoutAnimCache.get(e.id);for(const wt of Z){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0)continue;const xt=at.get(wt);if(!xt)at.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);at.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:((pe=i.settings)==null?void 0:pe.duration)??ot})}const jt=at.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((he=i.settings)==null?void 0:he.easing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),ot=(($e=i.settings)==null?void 0:$e.defaultDuration)||.3,at=["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 wt of at){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0||typeof Gt!="number")continue;const xt=Z.get(wt);if(!xt)Z.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);Z.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:ot})}const jt=Z.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((Be=i.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.SpringChain){const Z=((Ye=i.settings)==null?void 0:Ye.connections)||[],ot=((De=i.settings)==null?void 0:De.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const at=this._springChainState.get(e.id);for(const Gt of Z){if(!at.has(Gt.targetId)){const xt=this.objectStates.get(Gt.targetId);at.set(Gt.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}at.has(e.id)||at.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const wt=at.get(e.id);if(wt){wt.x=n.x,wt.y=n.y;for(const Gt of Z){const xt=at.get(Gt.targetId);if(!xt)continue;const jt=xt.x-wt.x,me=xt.y-wt.y,Ae=Math.sqrt(jt*jt+me*me)||.001,we=(Ae-(Gt.restLength||50))*(Gt.stiffness||.8),Oe=jt/Ae*we,je=me/Ae*we;wt.vx+=Oe*t*10,wt.vy+=je*t*10,xt.vx-=Oe*t*10,xt.vy-=je*t*10,wt.vx*=1-ot*t*10,wt.vy*=1-ot*t*10,xt.vx*=1-ot*t*10,xt.vy*=1-ot*t*10;const Ee=this.objectStates.get(Gt.targetId);Ee&&(Ee.x+=xt.vx*t,Ee.y+=xt.vy*t)}n.x+=wt.vx*t,n.y+=wt.vy*t}}else if(i.type===it.ParticleEmitter){const Z=((Xe=i.settings)==null?void 0:Xe.rate)||10,ot=((Ne=i.settings)==null?void 0:Ne.speed)||100,at=((Ue=i.settings)==null?void 0:Ue.size)||5,wt=((re=i.settings)==null?void 0:re.lifetime)||2,Gt=((ve=i.settings)==null?void 0:ve.gravity)||0,xt=((Te=i.settings)==null?void 0:Te.color)||"#ffffff",jt=((He=i.settings)==null?void 0:He.maxParticles)||200,me=(Ve=i.settings)!=null&&Ve.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Ae=(_e=i.settings)!=null&&_e.gravityInputId?this.inputs.get(i.settings.gravityInputId)??Gt:Gt,Fe=(Pe=i.settings)!=null&&Pe.speedInputId?this.inputs.get(i.settings.speedInputId)??ot:ot;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const we=this._emitterPools.get(e.id);let Oe=0;i._pendingBurst&&i._pendingBurst>0&&(Oe=i._pendingBurst,i._pendingBurst=0);const je=Math.floor(me*t)+(Oe||0);for(let Ee=0;Ee<Math.min(je,jt-we.length);Ee++){const Me=Math.random()*Math.PI*2,vs=Fe*(.5+Math.random()*.5);we.push({x:n.x,y:n.y,vx:Math.cos(Me)*vs,vy:Math.sin(Me)*vs,life:0,maxLife:wt*(.5+Math.random()*.5),size:at*(.5+Math.random()),color:xt,opacity:1})}for(let Ee=we.length-1;Ee>=0;Ee--){const Me=we[Ee];Me.vy+=Ae*t*10,Me.x+=Me.vx*t,Me.y+=Me.vy*t,Me.life+=t,Me.opacity=Math.max(0,1-Me.life/Me.maxLife),Me.life>=Me.maxLife&&we.splice(Ee,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,p=Math.min(1,15*e),g=l>0?a/l:0,u=l>0?r/l:0;switch(s){case ge.Scale:{const P=((f=i==null?void 0:i.transform)==null?void 0:f.scale_x)??1,_=((h=i==null?void 0:i.transform)==null?void 0:h.scale_y)??1,V=P*(1+o*d*.4),G=_*(1+o*d*.4);t.scale_x=(t.scale_x??P)*(1-p)+V*p,t.scale_y=(t.scale_y??_)*(1-p)+G*p;break}case ge.Opacity:{const P=((m=i==null?void 0:i.transform)==null?void 0:m.opacity)??100,_=Math.max(0,Math.min(100,P-o*d*100));t.opacity=(t.opacity??P)*(1-p)+_*p;break}case ge.RotateZ:{const P=((b=i==null?void 0:i.transform)==null?void 0:b.rotation)??0,_=P+o*d*45;t.rotation=(t.rotation??P)*(1-p)+_*p;break}case ge.RotateX:{const P=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,_=P-u*o*d*60;t.rotate_x=(t.rotate_x??P)*(1-p)+_*p;break}case ge.RotateY:{const P=((S=i==null?void 0:i.transform)==null?void 0:S.rotate_y)??0,_=P+g*o*d*60;t.rotate_y=(t.rotate_y??P)*(1-p)+_*p;break}case ge.PositionX:{const P=((v=i==null?void 0:i.transform)==null?void 0:v.x)??0,_=P-g*o*d*40;t.x=(t.x??P)*(1-p)+_*p;break}case ge.PositionY:{const P=((C=i==null?void 0:i.transform)==null?void 0:C.y)??0,_=P-u*o*d*40;t.y=(t.y??P)*(1-p)+_*p;break}case ge.SkewX:{const P=((w=i==null?void 0:i.transform)==null?void 0:w.skew_x)??0,_=P+g*o*d*45;t.skew_x=(t.skew_x??P)*(1-p)+_*p,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case ge.Blur:{t.style||(t.style={...i==null?void 0:i.style}),t.style.blur||(t.style.blur={...(I=i==null?void 0:i.style)==null?void 0:I.blur});const P=((O=(k=i==null?void 0:i.style)==null?void 0:k.blur)==null?void 0:O.amount)||0,_=P+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??P)*(1-p)+_*p;break}case ge.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(T=i==null?void 0:i.style)==null?void 0:T.adjustments});const P=((D=(A=i==null?void 0:i.style)==null?void 0:A.adjustments)==null?void 0:D.exposure)||0,_=P+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??P)*(1-p)+_*p;break}case ge.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(Y=i==null?void 0:i.style)==null?void 0:Y.adjustments});const P=((R=(B=i==null?void 0:i.style)==null?void 0:B.adjustments)==null?void 0:R.hue)||0,_=P+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??P)*(1-p)+_*p;break}case ge.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(L=i==null?void 0:i.style)==null?void 0:L.adjustments});const P=((F=($=i==null?void 0:i.style)==null?void 0:$.adjustments)==null?void 0:F.negative)||0,_=P+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??P)*(1-p)+_*p;break}case ge.CornerRadius:{const P=((X=i==null?void 0:i.transform)==null?void 0:X.corner_radius)||0,_=P+o*d*50;t.corner_radius=(t.corner_radius??P)*(1-p)+_*p;break}case ge.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const P=((M=i==null?void 0:i.style)==null?void 0:M.borderWidth)||0,_=P+o*d*10;t.style.borderWidth=(t.style.borderWidth??P)*(1-p)+_*p;break}case ge.LetterSpacing:{t.geometry||(t.geometry={});const P=((E=i==null?void 0:i.geometry)==null?void 0:E.letterSpacing)||0,_=P+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??P)*(1-p)+_*p;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(const i of e){if(n==null||typeof n!="object")return;if(i==="style"&&t.style===void 0){n=s.style;continue}n=n[i]}return typeof n=="number"?n:void 0}setObjectProperty(t,s,o,e){const n=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(let r=0;r<n.length-1;r++){const l=n[r];if(i[l]===void 0||i[l]===null){const d=s,p=n.slice(0,r+1).reduce((f,h)=>f==null?void 0:f[h],d),g=n[r+1],u=!isNaN(Number(g));i[l]=p!==void 0?Array.isArray(p)?[...p]:{...p}:u?[]:{}}i=i[l]}const a=n[n.length-1];i!=null&&(i[a]=e)}applyEasing(t,s){switch(s){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;if(Array.isArray(s)){if(!Array.isArray(t))return s;const e=[...t];for(let n=0;n<s.length;n++)s[n]&&typeof s[n]=="object"&&!Array.isArray(s[n])&&t[n]&&typeof t[n]=="object"?e[n]=this.deepMerge(t[n],s[n]):e[n]=s[n];return e}const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}processFabricAdjustmentsCanvas(t,s,o,e){if(!e)return t;const n=(e.exposure||0)/100,i=(e.contrast||0)/100,a=(e.saturation||0)/100,r=(e.temperature||0)/200,l=(e.tint||0)/200,d=(e.highlights||0)/500,p=(e.shadows||0)/500,g=e.hue||0,u=(e.negative||0)/100,f=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||p!==0||g!==0||u!==0||f>0))return t;const m=t.naturalWidth||Math.max(1,Math.round(s)),b=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=m,c.height=b;const S=c.getContext("2d");if(!S)return t;const v=[];f>0&&v.push(`blur(${f}px)`),g!==0&&v.push(`hue-rotate(${Math.round(g)}deg)`),v.length>0&&(S.filter=v.join(" ")),S.drawImage(t,0,0,m,b);try{const C=S.getImageData(0,0,m,b),w=C.data,I=w.length,k=n*255,O=i>=0?(1+i)/Math.max(.01,1-i):1+i,T=1+a,A=1+r-l/2,D=1+l,Y=1-r-l/2,B=1+d+p,R=p*25.5,L=1-u/50,$=(1-L)*255;for(let F=0;F<I;F+=4){let X=w[F],M=w[F+1],E=w[F+2];if(n!==0&&(X+=k,M+=k,E+=k),i!==0&&(X=(X-127.5)*O+127.5,M=(M-127.5)*O+127.5,E=(E-127.5)*O+127.5),a!==0){const P=.2989*X+.587*M+.114*E;X=P+(X-P)*T,M=P+(M-P)*T,E=P+(E-P)*T}(r!==0||l!==0)&&(X=X*A,M=M*D,E=E*Y),(d!==0||p!==0)&&(X=X*B+R,M=M*B+R,E=E*B+R),u!==0&&(X=X*L+$,M=M*L+$,E=E*L+$),w[F]=Math.min(255,Math.max(0,X)),w[F+1]=Math.min(255,Math.max(0,M)),w[F+2]=Math.min(255,Math.max(0,E))}return S.putImageData(C,0,0),c}catch{return c}}renderFittedImage(t,s,o,e,n,i,a="cover"){const r=s.naturalWidth||s.width||n,l=s.naturalHeight||s.height||i,d=r/l,p=n/i;let g=n,u=i,f=o,h=e;a==="cover"?d>p?(g=i*d,f=o-(g-n)/2):(u=n/d,h=e-(u-i)/2):a==="contain"&&(d>p?(u=n/d,h=e+(i-u)/2):(g=i*d,f=o+(n-g)/2)),t.drawImage(s,f,h,g,u)}}const li=Nt.forwardRef(({artboard:y,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:n="Center",onReady:i,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:d,onInputChange:p,onInputFocus:g,onInputBlur:u,onLog:f,onLogicUpdate:h,onButtonClick:m,onGraphPointClick:b,currentTime:c,revision:S=0,scrollY:v,scrollX:C,mouseX:w,mouseY:I,isMouseDown:k,inputs:O,interactive:T=!0,onNavigation:A},D)=>{const Y=Nt.useRef(null),B=Nt.useRef(null);B.current||(B.current=new bs);const R=Nt.useRef(void 0),L=Nt.useRef(0),$=Nt.useRef(null),F=Nt.useRef(S),X=Nt.useRef(null),[,M]=Nt.useState(y||null),E=Nt.useRef(!0),P=Nt.useRef(o),_=Nt.useRef(c);Nt.useEffect(()=>{P.current=o},[o]),Nt.useEffect(()=>{_.current=c},[c]),Nt.useImperativeHandle(D,()=>Y.current),Nt.useEffect(()=>(E.current=!0,()=>{E.current=!1,R.current&&cancelAnimationFrame(R.current)}),[]),Nt.useEffect(()=>{B.current.setLayout(e,n)},[e,n]),Nt.useEffect(()=>{const N=B.current;a&&N.setTriggerCallback(a),r&&N.setInputUpdateCallback((H,z)=>r({[H]:z})),l&&N.setComponentChangeCallback(H=>l(H)),d&&N.setToggleCallback(d),p&&N.setInputChangeCallback(p),g&&N.setInputFocusCallback(g),u&&N.setInputBlurCallback(u),f&&N.setOnLogCallback(H=>f(H,"info")),h&&N.setLogicUpdateCallback(h),m&&N.setButtonClickCallback(m),b&&N.setGraphPointClickCallback(H=>b(H.objectId,H)),A&&N.setNavigationCallback(A)},[a,r,l,d,p,g,u,f,h,m,b,A]),Nt.useEffect(()=>{(async()=>{let H=y;if(t&&!y)try{t.startsWith("{")?H=JSON.parse(t):H=await(await fetch(t)).json()}catch(z){console.error("[ExodeUI] Failed to load src:",z)}if(H){const z=B.current,et=H.id||H.name||"default";($.current!==et||F.current!==S||X.current!==H)&&(z.load(H),$.current=et,F.current=S,X.current=H,M(H),L.current=-1,z.advance(0)),i&&i(z)}})()},[y,t,S]),Nt.useEffect(()=>{const N=H=>{if(!B.current||!E.current)return;const z=B.current,et=Y.current;if(!et)return;const Mt=et.getContext("2d");if(!Mt)return;const ct=H/1e3;L.current<0&&(L.current=ct),L.current===0&&(L.current=ct);let It=ct-L.current;It>.1&&(It=.1),L.current=ct;const mt=et.getBoundingClientRect(),kt=window.devicePixelRatio||1,Ot=Math.round(mt.width*kt),vt=Math.round(mt.height*kt);(et.width!==Ot||et.height!==vt)&&(et.width=Ot,et.height=vt);try{P.current?z.advance(It):_.current!==void 0&&z.seek(_.current),z.render(Mt,et.width,et.height)}catch(Wt){console.error("[ExodeUICanvas] Error in animation loop:",Wt),f&&f(`[Error] Animation loop crashed: ${Wt}`,"error")}R.current=requestAnimationFrame(N)};return R.current=requestAnimationFrame(N),()=>{R.current&&cancelAnimationFrame(R.current)}},[]),Nt.useEffect(()=>{const N=B.current;v!==void 0&&N.updateInput("scrollY",v),C!==void 0&&N.updateInput("scrollX",C),w!==void 0&&N.updateInput("mouseX",w),I!==void 0&&N.updateInput("mouseY",I),k!==void 0&&N.updateInput("isMouseDown",k),O&&Object.entries(O).forEach(([H,z])=>N.updateInput(H,z))},[v,C,w,I,k,O]);const V=(N,H)=>{var mt,kt,Ot;if(!T||!Y.current)return;N.stopPropagation(),"nativeEvent"in N&&N.nativeEvent&&typeof N.nativeEvent.stopImmediatePropagation=="function"?N.nativeEvent.stopImmediatePropagation():typeof N.stopImmediatePropagation=="function"&&N.stopImmediatePropagation();const z=Y.current,et=z.getBoundingClientRect(),Mt=N.clientX-et.left,ct=N.clientY-et.top,It=window.devicePixelRatio||1;if((H==="click"||H==="down"||H==="up")&&f&&f(`[Canvas] Pointer ${H} at rect(${Math.round(Mt)},${Math.round(ct)}) mapped to buffer(${Math.round(Mt*It)},${Math.round(ct*It)})`,"info"),B.current.handlePointerInput(H,Mt*It,ct*It,z.width,z.height),H==="move"){const vt=(mt=B.current)==null?void 0:mt.getLastHoveredObject();vt?(kt=B.current)!=null&&kt.isInputBoxObject(vt)?z.style.cursor="text":(Ot=B.current)!=null&&Ot.isClickableObject(vt)?z.style.cursor="pointer":z.style.cursor="default":z.style.cursor="default"}else H==="blur"&&(z.style.cursor="default")};Nt.useEffect(()=>{if(!T)return;const N=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyDown(z)},H=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyUp(z)};return window.addEventListener("keydown",N),window.addEventListener("keyup",H),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",H)}},[T]),Nt.useEffect(()=>{const N=Y.current;if(!N||!T)return;const H=z=>{if(z.preventDefault(),z.stopPropagation(),B.current){const et=N.getBoundingClientRect(),Mt=window.devicePixelRatio||1,ct=(z.clientX-et.left)*Mt,It=(z.clientY-et.top)*Mt;let mt=z.deltaX,kt=z.deltaY;z.deltaMode===1?(mt*=25,kt*=25):z.deltaMode===2&&(mt*=100,kt*=100),B.current.handlePointerInput("move",ct,It,N.width,N.height),B.current.handleWheel(mt,kt,ct,It,N.width,N.height)}};return N.addEventListener("wheel",H,{passive:!1}),()=>{N.removeEventListener("wheel",H)}},[T]);const[G,x]=Nt.useState([]);Nt.useEffect(()=>{if(y&&y.objects){const N=y.objects.filter(H=>{var z,et;return H.type==="Joystick"&&((z=H.inputBinding)==null?void 0:z.type)==="keyboard"&&((et=H.inputBinding.keyboardConfig)==null?void 0:et.showVirtualKeyboard)});x(N)}},[y]);const[,U]=Nt.useState(0);Nt.useEffect(()=>{if(G.length===0)return;let N;const H=()=>{U(z=>z+1),N=requestAnimationFrame(H)};return N=requestAnimationFrame(H),()=>cancelAnimationFrame(N)},[G.length]);const q=()=>G.map(N=>{const H=N.inputBinding.keyboardConfig,z=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyDown(kt)},et=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyUp(kt)},Mt=B.current,ct=mt=>Mt&&Mt.activeKeys?Mt.activeKeys.has(mt.toLowerCase()):!1,It=mt=>({width:"50px",height:"50px",background:mt?"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:mt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return ne.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[ne.jsx("div",{style:It(ct(H.upKey)),onMouseDown:()=>z(H.upKey),onMouseUp:()=>et(H.upKey),onMouseLeave:()=>et(H.upKey),onTouchStart:mt=>{mt.preventDefault(),z(H.upKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.upKey)},children:H.upKey.toUpperCase()}),ne.jsxs("div",{style:{display:"flex",gap:"8px"},children:[ne.jsx("div",{style:It(ct(H.leftKey)),onMouseDown:()=>z(H.leftKey),onMouseUp:()=>et(H.leftKey),onMouseLeave:()=>et(H.leftKey),onTouchStart:mt=>{mt.preventDefault(),z(H.leftKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.leftKey)},children:H.leftKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.downKey)),onMouseDown:()=>z(H.downKey),onMouseUp:()=>et(H.downKey),onMouseLeave:()=>et(H.downKey),onTouchStart:mt=>{mt.preventDefault(),z(H.downKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.downKey)},children:H.downKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.rightKey)),onMouseDown:()=>z(H.rightKey),onMouseUp:()=>et(H.rightKey),onMouseLeave:()=>et(H.rightKey),onTouchStart:mt=>{mt.preventDefault(),z(H.rightKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.rightKey)},children:H.rightKey.toUpperCase()})]})]},N.id)});return ne.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ne.jsx("canvas",{ref:Y,onPointerDown:N=>{var H;V(N,"down"),N.currentTarget.setPointerCapture(N.pointerId),(H=Y.current)==null||H.focus()},onPointerMove:N=>V(N,"move"),onPointerUp:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerCancel:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerLeave:N=>V(N,"blur"),onClick:N=>V(N,"click"),onKeyDown:N=>B.current.handleKeyDown(N.nativeEvent),onKeyUp:N=>B.current.handleKeyUp(N.nativeEvent),onContextMenu:N=>N.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),q()]})});function ci(){const[y,t]=Nt.useState(null),s=Nt.useCallback((b,c)=>{y==null||y.setInputBool(b,c)},[y]),o=Nt.useCallback((b,c)=>{y==null||y.setInputNumber(b,c)},[y]),e=Nt.useCallback(b=>{y==null||y.fireTrigger(b)},[y]),n=Nt.useCallback((b,c)=>{y==null||y.setInputText(b,c)},[y]),i=Nt.useCallback((b,c)=>{y==null||y.setInputNumberArray(b,c)},[y]),a=Nt.useCallback((b,c)=>{y==null||y.setInputStringArray(b,c)},[y]),r=Nt.useCallback((b,c)=>{y==null||y.updateInput(b,c)},[y]),l=r,d=Nt.useCallback((b,c)=>{y==null||y.updateObjectOptions(b,c)},[y]),p=Nt.useCallback((b,c,S)=>{y==null||y.updateConstraint(b,c,S)},[y]),g=Nt.useCallback((b,c,S)=>{y==null||y.updateGraphData(b,c,S)},[y]),u=Nt.useCallback((b,c,S)=>{y==null||y.updateBarChartData(b,c,S)},[y]),f=Nt.useCallback((b,c)=>{y==null||y.updatePieChartData(b,c)},[y]),h=Nt.useCallback((b,c)=>{y==null||y.setDropdownOptions(b,c)},[y]),m=Nt.useCallback(b=>y==null?void 0:y.getInputValue(b),[y]);return{setEngine:t,engine:y,updateInput:r,setInputValue:l,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:n,setInputNumberArray:i,setInputStringArray:a,updateConstraint:p,updateGraphData:g,updateBarChartData:u,updatePieChartData:f,setDropdownOptions:h,updateObjectOptions:d,getInputValue:m}}const hi=({artboard:y,config:t})=>{const s={...y.seo,...t},o=s.enableSmartExtraction!==!1;Nt.useEffect(()=>{const a=s.title||y.name;a&&(document.title=a);let r=s.description;if(!r&&o){const p=y.objects.filter(g=>{var u;return((u=g.geometry)==null?void 0:u.type)==="Text"}).sort((g,u)=>{var f,h;return(((f=u.geometry.text)==null?void 0:f.length)||0)-(((h=g.geometry.text)==null?void 0:h.length)||0)});p.length>0&&(r=p[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||y.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,y,o]);const e=(a,r,l)=>{let d=document.querySelector(`meta[${a}="${r}"]`);d||(d=document.createElement("meta"),d.setAttribute(a,r),document.head.appendChild(d)),d.setAttribute("content",l)},n=()=>{const a=[];return a.push(ne.jsx("h1",{children:s.title||y.name},"artboard-title")),y.objects.forEach((l,d)=>{var p,g;if(!(l.visible===!1||l.isVisible===!1))if(((p=l.geometry)==null?void 0:p.type)==="Text"){const u=l.geometry.text;u&&(l.geometry.fontSize>24?a.push(ne.jsx("h2",{children:u},l.id||d)):a.push(ne.jsx("p",{children:u},l.id||d)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const u=l.geometry.src,f=l.altText||l.name||"Illustration";a.push(ne.jsx("img",{src:u,alt:f},l.id||d))}else l.type==="Button"&&a.push(ne.jsx("button",{children:l.name||"Button"},l.id||d))}),a},i=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||y.name,description:s.description,image:s.ogImage||y.backgroundImage,abstract:"Animated interface created with ExodeUI"};return ne.jsxs("div",{id:`exode-seo-${y.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:[n(),ne.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},fi={version:"6.4.6"}.version;se.BAR_STYLE_PRESETS=ri,se.BehaviorSensor=ge,se.BehaviorType=it,se.ConditionOp=es,se.ExodeSEO=hi,se.ExodeUICanvas=li,se.ExodeUIEngine=bs,se.LogicOp=Ht,se.RapierPhysics=os,se.TOGGLE_SHAPE_NAME_MAP=xe,se.VERSION=fi,se.getToggleSvgPathBounds=We,se.useExodeUI=ci,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})}));
19
+ `);let nt=-w/2+(((ae=e.padding)==null?void 0:ae.top)??8);const Lt=Mt*1.4,tt=e.rows||3;let gt=0,Q=0;for(const Ut of W){if(gt>=tt)break;const zt=Ut.split(" ");let yt="";for(let Bt=0;Bt<zt.length;Bt++){const _t=yt+zt[Bt]+" ";if(t.measureText(_t).width>Yt&&Bt>0){if(gt>=tt)break;t.fillText(yt.trim(),Ct,nt),yt=zt[Bt]+" ",nt+=Lt,gt++}else yt=_t}gt<tt&&(t.fillText(yt.trim(),Ct,nt),Q=t.measureText(yt.trim()).width,nt+=Lt,gt++)}if(d&&!Wt&&Math.floor(performance.now()/500)%2===0){const Ut=nt-Lt;t.fillStyle=q,t.fillRect(Ct+Math.min(Q,Yt),Ut,1.5,Mt)}}else{t.textBaseline="middle";const nt=t.measureText(te).width;let Lt=0;if(nt>Yt&&(Lt=nt-Yt),t.fillText(te,Ct-Lt,0),d&&Math.floor(performance.now()/500)%2===0){const tt=Wt?Ct:Ct+nt-Lt;t.fillStyle=q,t.fillRect(tt,-(Mt/2),1.5,Mt)}}if(t.restore(),e.showCharCounter){t.save();const W=Number(e.maxLength||0),nt=W>0?`${kt.length}/${W}`:`${kt.length}`;t.font=`400 10px "${z}", sans-serif`,t.fillStyle=W>0&&kt.length>=W?"#ef4444":"rgba(156, 163, 175, 0.6)",t.textAlign="right",t.textBaseline="top",t.fillText(nt,-(C/2)+C-8,-(w/2)+w+4),t.restore()}if(I.visible!==!1){const W=!!(I.required||(Jt=e.validation)!=null&&Jt.required),nt=(I.text||"Label")+(W?" *":""),Lt=I.fontSize||12,tt=I.color||"rgba(156, 163, 175, 1)",gt=I.position||"top",Q=I.gap??I.offset??6;let Ut=-(C/2),zt=-(w/2)-Q,yt="left",Bt="bottom",_t=`600 ${Lt}px "${I.fontFamily||z}", sans-serif`;gt==="left"?(Ut=-(C/2)-Q,zt=0,yt="right",Bt="middle"):gt==="bottom"?(Ut=-(C/2),zt=w/2+Q,yt="left",Bt="top"):gt==="floating"&&(!!kt||a?(Ut=-(C/2)+12,zt=-(w/2)+4,yt="left",Bt="top",_t=`600 ${Math.max(9,Lt-2)}px "${I.fontFamily||z}", sans-serif`):_t=null),_t&&(t.save(),t.font=_t,t.fillStyle=tt,t.textAlign=yt,t.textBaseline=Bt,t.fillText(nt,Ut,zt),t.restore())}const le=(Et=e.validation)==null?void 0:Et.errorMessage;if(u&&le||k.visible===!0&&k.text){t.save();const W=k.fontSize||11,nt=u?"#ef4444":k.color||"rgba(156, 163, 175, 1)",Lt=k.offset??6,tt=u&&le?le:k.text;t.font=`400 ${W}px "${z}", sans-serif`,t.fillStyle=nt,t.textAlign="left",t.textBaseline="top",t.fillText(tt,-(C/2),w/2+Lt),t.restore()}g&&(t.save(),E(-C/2,-w/2,C,w,M),t.fillStyle="rgba(0, 0, 0, 0.3)",t.fill(),t.restore()),v!==1&&(t.globalAlpha=1)}renderSlider(t,s){const o=this.objectStates.get(s.id),e=(o==null?void 0:o.geometry)||s.geometry,n=(o==null?void 0:o.options)||s.options||{},i=e.width||200,a=n.value??50,r=n.min??0,d=(n.max??100)-r,p=d===0?0:(a-r)/d,g=n.trackHeight||4,u=n.trackRoundedness??2,f=n.trackShape??"Rectangle",h=n.trackPath||"",m=n.activeColor||n.accentColor||"#3b82f6",b=n.inactiveColor||"#374151",c=n.thumbShape||"Ellipse",S=n.thumbWidth??16,v=n.thumbHeight??16,C=n.thumbRoundedness??0,w=n.thumbColor||"#ffffff",I=n.thumbPath||"",k=n.thumbIcon||"",O=n.trackStrokeWidth??0,T=n.trackStrokeColor||"",A=n.thumbStrokeWidth??0,D=n.thumbStrokeColor||"",Y=n.showValueTooltip??!1,B=n.tooltipBgColor||"#333333",R=n.tooltipColor||"#ffffff",L=n.tooltipOffsetX??0,$=n.tooltipOffsetY??-25,F=this.lastHoveredObjectId===s.id,X=this.isMouseDown&&F,M=n.hoverStyle||{},E=n.activeStyle||{};let P=g,_=m,V=b,G=c,x=S,U=v,q=C,N=w,H=O,z=T,et=A,Mt=D,ct=1;X&&E?(ct=E.scale??1,P=E.trackHeight??P,_=E.activeColor??_,V=E.inactiveColor??V,N=E.thumbColor??N,x=E.thumbWidth??x,U=E.thumbHeight??U,q=E.thumbRoundedness??q,G=E.thumbShape||G,H=E.trackStrokeWidth??H,z=E.trackStrokeColor??z,et=E.thumbStrokeWidth??et,Mt=E.thumbStrokeColor??Mt):F&&M&&(ct=M.scale??1,P=M.trackHeight??P,_=M.activeColor??_,V=M.inactiveColor??V,N=M.thumbColor??N,x=M.thumbWidth??x,U=M.thumbHeight??U,q=M.thumbRoundedness??q,G=M.thumbShape||G,H=M.trackStrokeWidth??H,z=M.trackStrokeColor??z,et=M.thumbStrokeWidth??et,Mt=M.thumbStrokeColor??Mt);const It=X&&E.thumbPath?E.thumbPath:F&&M.thumbPath?M.thumbPath:I;ct!==1&&(t.save(),t.scale(ct,ct));const mt=(ht,dt,At,Tt,Ct,Yt,ie)=>{const te=xe[ht]||ie||(ht&&(ht.startsWith("M")||ht.startsWith("m"))?ht:"");if((ht==="Custom"||ht==="Icon"||te)&&te)try{const Zt=new Path2D(te),le=We(te),fe=Math.min(Tt/le.width,Ct/le.height);t.save(),t.translate(dt,At),t.scale(fe,fe),t.translate(-le.cx,-le.cy);const qt=!te.includes("z")&&!te.includes("Z");qt?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/fe),t.lineCap="round",t.lineJoin="round",t.stroke(Zt)):t.fill(Zt),t.strokeStyle&&t.lineWidth>0&&!qt&&t.stroke(Zt),t.restore();return}catch(Zt){console.error("Error drawing slider shape in engine:",Zt)}if(t.beginPath(),ht==="Ellipse")t.ellipse(dt,At,Tt/2,Ct/2,0,0,Math.PI*2);else if(ht==="Rectangle")this.drawRoundRect(t,dt-Tt/2,At-Ct/2,Tt,Ct,Yt);else if(ht==="Triangle")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At+Ct/2),t.lineTo(dt-Tt/2,At+Ct/2),t.closePath();else if(ht==="Diamond")t.moveTo(dt,At-Ct/2),t.lineTo(dt+Tt/2,At),t.lineTo(dt,At+Ct/2),t.lineTo(dt-Tt/2,At),t.closePath();else if(ht==="Polygon"){const Zt=s.geometry.sides||3,le=s.geometry.radius||Math.min(Tt,Ct)/2;for(let fe=0;fe<Zt;fe++){const qt=fe*2*Math.PI/Zt-Math.PI/2,Se=dt+le*Math.cos(qt),Ce=At+le*Math.sin(qt);fe===0?t.moveTo(Se,Ce):t.lineTo(Se,Ce)}t.closePath()}else if(ht==="Star"){const le=Math.min(Tt,Ct)/2,fe=le/2;for(let qt=0;qt<10;qt++){const Se=qt%2===0?le:fe,Ce=qt*Math.PI/5-Math.PI/2;t.lineTo(dt+Se*Math.cos(Ce),At+Se*Math.sin(Ce))}t.closePath()}else ht==="Line"&&(t.moveTo(dt-Tt/2,At),t.lineTo(dt+Tt/2,At));t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()},kt=this.createCanvasFill(t,V,i,P);kt&&(t.fillStyle=kt,t.strokeStyle=kt),f==="Line"?(t.strokeStyle=H>0&&z?z:kt,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(i/2,0),t.stroke()):(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),mt(f,0,0,i,P,u,h));const Ot=i-x,vt=-i/2+x/2+p*Ot,Wt=vt- -i/2;if(Wt>0){const ht=this.createCanvasFill(t,_,i,P);if(ht&&(t.fillStyle=ht),f==="Line")t.strokeStyle=H>0&&z?z:ht||_,t.lineWidth=H>0?H:P,t.beginPath(),t.moveTo(-i/2,0),t.lineTo(vt,0),t.stroke();else{if(H>0&&z&&(t.strokeStyle=z,t.lineWidth=H),t.beginPath(),f==="Rectangle")this.drawRoundRect(t,-i/2,-P/2,Wt,P,u);else{const dt=xe[f]||h||"";if(dt)try{const At=new Path2D(dt),Tt=We(dt),Ct=Math.min(Wt/Tt.width,P/Tt.height);t.save(),t.translate(-i/2+Wt/2,0),t.scale(Ct,Ct),t.translate(-Tt.cx,-Tt.cy),t.fill(At),t.strokeStyle&&t.lineWidth>0&&t.stroke(At),t.restore()}catch{this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}else this.drawRoundRect(t,-i/2,-P/2,Wt,P,u)}t.fill(),t.strokeStyle&&t.lineWidth>0&&t.stroke()}}t.save(),t.translate(vt,0);const J=t.getTransform(),ut=Math.sqrt(J.a*J.a+J.b*J.b)||1;t.shadowColor="rgba(0,0,0,0.2)",t.shadowBlur=4*ut,t.shadowOffsetY=1*ut;const $t=this.createCanvasFill(t,N,x,U);$t&&(t.fillStyle=$t),et>0&&Mt&&(t.strokeStyle=Mt,t.lineWidth=et);const St=X&&E.thumbShape==="Icon"?E.thumbPath||k:F&&M.thumbShape==="Icon"&&M.thumbPath||k;if(mt(G,0,0,x,U,q,G==="Icon"?St:It),t.restore(),Y){t.save(),t.translate(vt+L,$);const ht=Math.round(a).toString();t.font="10px Inter, sans-serif";const dt=t.measureText(ht),At=6,Tt=4,Ct=dt.width+At*2,Yt=14+Tt;t.beginPath(),this.drawRoundRect(t,-Ct/2,-Yt/2,Ct,Yt,4),t.fillStyle=B,t.fill(),t.fillStyle=R,t.textAlign="center",t.textBaseline="middle",t.fillText(ht,0,0),t.restore()}const Pt=n.label||{},Ft=n.helperText||{},lt=n.fontFamily||"Inter";if(Pt.visible!==!1){const ht=Pt.text||"Label",dt=Pt.fontSize||12,At=Pt.color||"rgba(156, 163, 175, 1)",Tt=Pt.offset??8;t.font=`600 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="bottom";const Ct=-(i/2),Yt=-(P/2)-Tt;t.fillText(ht,Ct,Yt)}if(Ft.visible===!0){const ht=Ft.text||"Helper text",dt=Ft.fontSize||11,At=Ft.color||"rgba(156, 163, 175, 1)",Tt=Ft.offset??6;t.font=`400 ${dt}px "${lt}", sans-serif`,t.fillStyle=At,t.textAlign="left",t.textBaseline="top";const Ct=-(i/2),Yt=P/2+Tt;t.fillText(ht,Ct,Yt)}ct!==1&&t.restore()}renderDropdown(t,s){var Y;const o=this.objectStates.get(s.id);if(!o)return;const e=o.options||s.options||{},n=s.geometry.width||180,i=s.geometry.height||40,a=-n/2,r=-i/2,l=e.cornerRadius??e.corner_radius??6,d=e.disabled||e.previewState==="disabled",p=this.lastHoveredObjectId===s.id||e.previewState==="hover",g=(e.isOpen||e.previewState==="active")&&!d;let u=e.backgroundColor,f=e.borderColor,h=e.color||"#333333";d?(u=e.disabledBackgroundColor||"#f3f4f6",f=e.disabledBorderColor||"#e5e7eb",h=e.disabledColor||"#9ca3af"):g?(u=e.activeBackgroundColor||u,f=e.activeBorderColor||f,h=e.activeColor||h):p&&(u=e.hoverBackgroundColor||u,f=e.hoverBorderColor||f,h=e.hoverColor||h),u||(u="#ffffff"),f||(f="#e5e7eb"),t.save();const m=t.globalAlpha;t.globalAlpha=m*(e.opacity??1),t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.fillStyle=this.createCanvasFill(t,typeof u=="string"?{type:"Solid",color:u}:u,n,i)||"#ffffff",t.fill();const b=e.borderWidth??1;b>0&&(t.beginPath(),this.drawRoundRect(t,a,r,n,i,l),t.strokeStyle=this.createCanvasFill(t,typeof f=="string"?{type:"Solid",color:f}:f,n,i)||"#e5e7eb",t.lineWidth=b,t.stroke());const c=12,S=e.chevronType||"chevron",v=e.chevronSize||16,C=(g?e.openIconColor:e.closedIconColor)||e.chevronColor||"#6b7280";if(S!=="none"){const B=a+n-c-v/2;t.save(),t.translate(B,0);const R=g?e.openIconAngle??180:e.closedIconAngle??0;if(t.rotate(R*Math.PI/180),t.strokeStyle=C,t.fillStyle=C,t.lineWidth=1.5,t.lineCap="round",t.lineJoin="round",S==="chevron")t.beginPath(),t.moveTo(-v/2,-v*.2),t.lineTo(0,v*.2),t.lineTo(v/2,-v*.2),t.stroke();else if(S==="custom"||S==="path"){const L=g&&e.openIconPath||e.closedIconPath;if(L){const $=new Path2D(L);t.save();const F=v/24;t.scale(F,F),t.translate(-12,-12),t.fill($),t.restore()}}t.restore()}const w=e.selectedOption||e.placeholder||"Select...",I=e.fontSize||14,k=e.fontWeight||400,O=e.fontFamily||"Inter, sans-serif";t.font=`${k} ${I}px ${O}`;const T=d?e.disabledColor||"#9ca3af":!e.selectedOption&&e.placeholder?"#9ca3af":h;t.fillStyle=this.createCanvasFill(t,typeof T=="string"?{type:"Solid",color:T}:T,n,i)||"#333333",t.textAlign="left",t.textBaseline="middle";const A=S==="none"?0:v+8,D=n-c*2-A;if(t.save(),t.beginPath(),t.rect(a+c,r,D,i),t.clip(),t.fillText(w,a+c,0),t.restore(),g&&!d){const B=r+i+4,R=this.getResolvedDropdownOptions(s,e),L=e.itemHeight||32,$=e.listPadding??4,F=R.length*L+$*2,X=e.listCornerRadius??l;t.save();const M=e.listShadow||{},E=t.getTransform(),P=Math.sqrt(E.a*E.a+E.b*E.b)||1;t.shadowColor=typeof M.color=="string"?M.color:((Y=M.color)==null?void 0:Y.color)||"rgba(0,0,0,0.15)",t.shadowBlur=(M.blur??12)*P,t.shadowOffsetY=(M.offsetY??6)*P,t.shadowOffsetX=(M.offsetX??0)*P,t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.fillStyle=this.createCanvasFill(t,typeof e.listBackgroundColor=="string"?{type:"Solid",color:e.listBackgroundColor}:e.listBackgroundColor||{type:"Solid",color:"#ffffff"},n,F)||"#ffffff",t.fill();const _=e.listBorderWidth??1;_>0&&(t.shadowColor="transparent",t.beginPath(),this.drawRoundRect(t,a,B,n,F,X),t.strokeStyle=this.createCanvasFill(t,typeof e.listBorderColor=="string"?{type:"Solid",color:e.listBorderColor}:e.listBorderColor||{type:"Solid",color:f},n,F)||"#e5e7eb",t.lineWidth=_,t.stroke()),t.restore();const V=e.itemFontSize||I,G=e.itemFontFamily||O;t.font=`${k} ${V}px ${G}`,R.forEach((x,U)=>{const q=B+$+U*L;if(x===e.selectedOption)t.fillStyle=this.createCanvasFill(t,typeof e.itemSelectedBackgroundColor=="string"?{type:"Solid",color:e.itemSelectedBackgroundColor}:e.itemSelectedBackgroundColor||{type:"Solid",color:"#f3f4f6"},n,L)||"#f3f4f6",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemSelectedColor||e.accentColor||h||"#374151";else if(t.fillStyle=e.listTextColor||h||"#333333",this.activeDropdownId===s.id&&this._lastPointerPos){const H=this._lastPointerPos.y-(B+$),z=Math.floor(H/L);U===z&&(t.fillStyle=this.createCanvasFill(t,typeof e.itemHoverBackgroundColor=="string"?{type:"Solid",color:e.itemHoverBackgroundColor}:e.itemHoverBackgroundColor||{type:"Solid",color:"#f9fafb"},n,L)||"#f9fafb",t.fillRect(a+_,q,n-_*2,L),t.fillStyle=e.itemHoverColor||h)}t.fillText(x,a+c,q+L/2)})}t.restore()}renderButton(t,s){var U;if(s.children&&s.children.length>0)return;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||s.width||160,a=n.height||s.height||45,r=this.lastHoveredObjectId===s.id,l=this.activeObjectId===s.id,d=e.label||{},p=e.hoverStyle||{},g=e.activeStyle||{},u=e.icon||{enabled:!1};let f=e.backgroundColor||e.buttonBgColor||((U=s.style)==null?void 0:U.fill)||"#3b82f6",h=(typeof d=="object"?d.color:null)||"#ffffff",m=typeof d=="string"?d:d.text||s.text||(s.name&&!s.name.toLowerCase().includes("component")?s.name:"Button"),b=n.cornerRadius??n.corner_radius??8,c=e.borderColor||"transparent",S=e.borderWidth||0,v=1;l&&g?(f=g.backgroundColor||f,h=g.color||h,m=g.text||m,v=g.scale??.95,b=g.cornerRadius??b):r&&p&&(f=p.backgroundColor||f,h=p.color||h,m=p.text||m,v=p.scale??1,b=p.cornerRadius??b,c=p.borderColor||c);const C=-i/2,w=-a/2;t.save(),t.scale(v,v),t.beginPath(),this.drawRoundRect(t,C,w,i,a,b);const I=this.createCanvasFill(t,f,i,a);I&&(t.fillStyle=I,t.fill()),(S>0||r&&p.borderColor)&&(t.strokeStyle=c,t.lineWidth=S||(r?1:0),t.stroke());const k=d.fontSize||14,O=d.fontFamily||"Inter",T=d.fontWeight||600;t.font=`${T} ${k}px "${O}", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=h,t.textAlign="center",t.textBaseline="middle";const A=u.enabled===!0||u.enabled==="true",D=Number(u.size)||Math.round(k*1.15)||16,Y=u.color||h,B=Number(u.gap)??8,R=u.position||"left",L=u.margin||{left:0,right:0,top:0,bottom:0},$=(Number(L.left)||0)-(Number(L.right)||0),F=(Number(L.top)||0)-(Number(L.bottom)||0),X=!!(m&&String(m).trim().length>0),E=(X?t.measureText(String(m)):{width:0}).width,P=k*1.2;let _=0,V=0,G=0,x=0;if(A){if(!X||R==="center")G=$,x=F,_=0,V=0;else if(R==="left"){const q=D+B+E;G=-q/2+D/2+$,x=F,_=-q/2+D+B+E/2+$,V=0}else if(R==="right"){const q=E+B+D;_=-q/2+E/2+$,V=0,G=-q/2+E+B+D/2+$,x=F}else if(R==="top"){const q=D+B+P;G=$,x=-q/2+D/2+F,_=$,V=-q/2+D+B+P/2+F}else if(R==="bottom"){const q=P+B+D;_=$,V=-q/2+P/2+F,G=$,x=-q/2+P+B+D/2+F}this.drawButtonIcon(t,u,G,x,D,Y,O)}X&&R!=="center"&&(t.fillStyle=h,t.fillText(String(m),_,V)),t.restore()}drawButtonIcon(t,s,o,e,n,i,a="Inter"){const r=(s.svgPath||"").trim(),l=(s.character||s.char||"").trim(),d="M12 3L10.088 8.813A2 2 0 0 1 8.813 10.088L3 12L8.813 13.912A2 2 0 0 1 10.088 15.187L12 21L13.912 15.187A2 2 0 0 1 15.187 13.912L21 12L15.187 10.088A2 2 0 0 1 13.912 8.813L12 3Z";if(t.save(),l){t.font=`${Math.round(n)}px "${a}", -apple-system, sans-serif`,t.fillStyle=i,t.textAlign="center",t.textBaseline="middle",t.fillText(l,o,e),t.restore();return}if(r.startsWith("<svg")){const u=s.fill&&s.fill.type!=="None";let f=r.replace(/stroke\s*=\s*(['"])currentColor\1/gi,`stroke="${i}"`).replace(/stroke\s*:\s*currentColor/gi,`stroke: ${i}`);u?f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,`fill="${i}"`).replace(/fill\s*:\s*currentColor/gi,`fill: ${i}`):f=f.replace(/fill\s*=\s*(['"])currentColor\1/gi,'fill="none"').replace(/fill\s*:\s*currentColor/gi,"fill: none"),f.includes("xmlns=")||(f=f.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));const h=`svg_icon_${i}_${n}_${btoa(f.slice(0,80))}`;let m=this.imageCache.get(h);if(m||(m=new Image,m.crossOrigin="anonymous",m.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(f)))}`,this.imageCache.set(h,m)),m.complete&&m.naturalWidth>0){t.drawImage(m,o-n/2,e-n/2,n,n),t.restore();return}const b=[...f.matchAll(/<path[^>]*\bd=["']([^"']+)["']/gi)];if(b.length>0){t.translate(o,e);const c=n/24;t.scale(c,c),t.translate(-12,-12);const S=new Path2D(b.map(v=>v[1]).join(" "));u?(t.fillStyle=i,t.fill(S)):(t.strokeStyle=i,t.lineWidth=2,t.lineCap="round",t.lineJoin="round",t.stroke(S)),t.restore();return}}if(r&&!r.startsWith("<")){t.translate(o,e);const u=n/24;t.scale(u,u),t.translate(-12,-12);const f=new Path2D(r);t.fillStyle=i,t.fill(f),t.strokeStyle=i,t.lineWidth=1,t.stroke(f),t.restore();return}t.translate(o,e);const p=n/24;t.scale(p,p),t.translate(-12,-12);const g=new Path2D(d);t.fillStyle=i,t.fill(g),t.restore()}renderToggleButton(t,s){var m,b;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.checked??!1,i=((m=s.geometry)==null?void 0:m.width)||120,a=((b=s.geometry)==null?void 0:b.height)||40,r=-i/2,l=-a/2,d=e.corner_radius??8,p=e.label||{},g=n?e.accentColor||"#3b82f6":e.inactiveColor||"#374151",u=n?e.activeTextColor||"#ffffff":e.inactiveTextColor||"#9ca3af";t.save(),t.beginPath(),this.drawRoundRect(t,r,l,i,a,d),t.fillStyle=g,t.fill();const f=p.fontSize||14,h=p.fontFamily||"Inter";t.font=`${p.fontWeight||600} ${f}px "${h}", sans-serif`,t.fillStyle=u,t.textAlign="center",t.textBaseline="middle",t.fillText(p.text||"Toggle",0,0),t.restore()}renderToggle(t,s){var Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=s.geometry||{},i=n.width||52,a=n.height||30,r=e.checked??!1,l=e.toggleStyle||{},d=l.width,p=l.height,g=l.cornerRadius,u=r&&d?d:i,f=r&&p?p:a,h=-u/2,m=-f/2,b=r&&g!==void 0?g:e.cornerRadius??e.corner_radius??a/2,c=l.backgroundColor||e.activeColor||"#10b981",S=l.borderColor||e.borderColor||"transparent",v=l.borderWidth??e.borderWidth??0,C=l.knobColor||e.knobColor||"#ffffff",w=r?c:e.inactiveColor||"#374151",I=r?S:e.borderColor||"transparent",k=r?v:e.borderWidth??0,O=r?C:e.knobColor||"#ffffff",T=r&&l.knobShape||e.knobShape||"Circle",A=r&&l.knobSize||e.knobSize||0,D=r&&l.trackShape||e.trackShape||"Pill";e.disabled&&(t.globalAlpha*=.5);const Y=(lt,ht,dt,At,Tt,Ct)=>{try{const Yt=new Path2D(lt),ie=We(lt),te=Math.min(At/ie.width,Tt/ie.height),Zt=!lt.includes("z")&&!lt.includes("Z");t.save(),t.translate(ht,dt),t.scale(te,te),t.translate(-ie.cx,-ie.cy),Zt?(t.strokeStyle=Ct,t.lineWidth=Math.max(1.8,2.2/te),t.lineCap="round",t.lineJoin="round",t.stroke(Yt)):(t.fillStyle=Ct,t.fill(Yt)),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.fillStyle=Ct),t.fill()}},B=(lt,ht,dt,At,Tt,Ct,Yt)=>{try{const ie=new Path2D(lt),te=We(lt),Zt=Math.min(At/te.width,Tt/te.height);t.save(),t.translate(ht,dt),t.scale(Zt,Zt),t.translate(-te.cx,-te.cy),t.strokeStyle=Ct,t.lineWidth=Yt/Zt,t.lineCap="round",t.lineJoin="round",t.stroke(ie),t.restore()}catch{t.beginPath(),t.arc(ht,dt,Math.min(At,Tt)/2,0,Math.PI*2),Ct&&(t.strokeStyle=Ct),t.lineWidth=Yt,t.stroke()}},R=xe[D]||D,L=!["Pill","Rectangle","Circle"].includes(R),$=xe[T]||T,F=!["Circle","Square","Diamond","Star"].includes($),X=this.createCanvasFill(t,w,u,f);if(L?Y(R,h+u/2,m+f/2,u,f,X):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),X&&(t.fillStyle=X,t.fill())),k>0){const lt=this.createCanvasFill(t,I,u,f);L?B(R,h+u/2,m+f/2,u,f,lt,k):(t.beginPath(),D==="Circle"?t.ellipse(h+u/2,m+f/2,u/2,f/2,0,0,Math.PI*2):D==="Pill"?this.drawRoundRect(t,h,m,u,f,f/2):this.drawRoundRect(t,h,m,u,f,b),t.lineWidth=k,lt&&(t.strokeStyle=lt,t.stroke()))}const M=e.knobPadding??2,E=f-M*2,P=A>0?A:E,_=P/2,V=h+M,G=h+u-M-P,x=r?G:V,U=m+(f-P)/2,q=this.createCanvasFill(t,O,P,P);if(F)Y($,x+_,U+_,P,P,q);else{if(t.beginPath(),T==="Square"){const lt=Math.min(4,_/2);t.roundRect(x,U,P,P,lt)}else if(T==="Diamond"){const lt=x+_,ht=U+_;t.moveTo(lt,ht-_),t.lineTo(lt+_,ht),t.lineTo(lt,ht+_),t.lineTo(lt-_,ht),t.closePath()}else if(T==="Star"){const lt=x+_,ht=U+_,dt=5,At=_,Tt=_*.4;for(let Ct=0;Ct<dt*2;Ct++){const Yt=Ct%2===0?At:Tt,ie=Ct*Math.PI/dt-Math.PI/2,te=lt+Yt*Math.cos(ie),Zt=ht+Yt*Math.sin(ie);Ct===0?t.moveTo(te,Zt):t.lineTo(te,Zt)}t.closePath()}else t.arc(x+_,U+_,_,0,Math.PI*2);q&&(t.fillStyle=q,t.fill())}e.disabled&&(t.globalAlpha*=2);const N=((Mt=e.leftLabel)==null?void 0:Mt.enabled)&&((ct=e.leftLabel)==null?void 0:ct.text),H=((It=e.rightLabel)==null?void 0:It.enabled)&&((mt=e.rightLabel)==null?void 0:mt.text),z=((kt=e.leftLabel)==null?void 0:kt.gap)||8,et=((Ot=e.rightLabel)==null?void 0:Ot.gap)||8;if(N){const lt=(r?(vt=l.leftLabel)==null?void 0:vt.text:null)||((Wt=e.leftLabel)==null?void 0:Wt.text)||"",ht=(r?(J=l.leftLabel)==null?void 0:J.color:null)||((ut=e.leftLabel)==null?void 0:ut.color)||"#f3f4f6",dt=e.leftLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="right",t.fillText(lt,h-z,0)}if(H){const lt=(r?($t=l.rightLabel)==null?void 0:$t.text:null)||((St=e.rightLabel)==null?void 0:St.text)||"",ht=(r?(Pt=l.rightLabel)==null?void 0:Pt.color:null)||((Ft=e.rightLabel)==null?void 0:Ft.color)||"#f3f4f6",dt=e.rightLabel;t.font=`${dt.fontWeight||400} ${dt.fontSize||12}px "${dt.fontFamily||"Inter"}", sans-serif`,t.fillStyle=ht,t.textBaseline="middle",t.textAlign="left",t.fillText(lt,h+u+et,0)}if(!N&&!H&&e.label&&e.label.text){const lt=e.label,ht=lt.fontSize||14,dt=lt.fontWeight||400,At=lt.fontFamily||"Inter";t.font=`${dt} ${ht}px "${At}", sans-serif`,t.fillStyle=lt.color||"#f3f4f6",t.textBaseline="middle";const Tt=lt.gap||10;let Ct=0,Yt=0;lt.position==="left"?(t.textAlign="right",Ct=h-Tt,Yt=0):lt.position==="right"?(t.textAlign="left",Ct=h+u+Tt,Yt=0):lt.position==="top"?(t.textAlign="center",Ct=0,Yt=m-Tt,t.textBaseline="bottom"):lt.position==="bottom"?(t.textAlign="center",Ct=0,Yt=m+f+Tt,t.textBaseline="top"):(t.textAlign="left",Ct=h+u+Tt,Yt=0),t.fillText(lt.text,Ct,Yt)}}renderCheckbox(t,s){var E,P,_,V;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((E=s.geometry)==null?void 0:E.width)||140,i=((P=s.geometry)==null?void 0:P.height)||24,a=-n/2,r=-i/2,l=Math.max(12,Math.min(e.boxSize||18,i,n)),d=Math.min(e.cornerRadius??4,l/2),p=e.checked??!1,g=!!e.indeterminate,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6";const c=e.inactiveColor||"transparent";let S=e.checkColor||"#ffffff",v=e.borderColor||"#9ca3af";const C=e.borderWidth??1.5;let w=1;f&&m?(m.backgroundColor&&(b=m.backgroundColor),m.borderColor&&(v=m.borderColor),m.checkColor&&(S=m.checkColor),w=m.scale??.95):u&&h&&(h.backgroundColor&&(b=h.backgroundColor),h.borderColor&&(v=h.borderColor),h.checkColor&&(S=h.checkColor),w=h.scale??1);const I=!!(e.label&&e.label.text),k=((_=e.label)==null?void 0:_.gap)??8,O=((V=e.label)==null?void 0:V.position)||"right";let T=a,A=r+(i-l)/2,D=0,Y=0,B="left",R="middle";I?O==="right"?(T=a,A=r+(i-l)/2,D=T+l+k,Y=0,B="left",R="middle"):O==="left"?(T=a+n-l,A=r+(i-l)/2,D=T-k,Y=0,B="right",R="middle"):O==="top"?(T=a+(n-l)/2,A=r+i-l,D=0,Y=A-k,B="center",R="bottom"):O==="bottom"&&(T=a+(n-l)/2,A=r,D=0,Y=A+l+k,B="center",R="top"):(T=a+(n-l)/2,A=r+(i-l)/2);const L=p||g,$=L?b:c,F=L?b:v,X=L?0:C;e.disabled&&(t.globalAlpha*=.5),t.save(),w!==1&&t.scale(w,w),t.beginPath(),this.drawRoundRect(t,T,A,l,l,d);const M=this.createCanvasFill(t,$,l,l);if(M&&(t.fillStyle=M,t.fill()),X>0){t.lineWidth=X;const G=this.createCanvasFill(t,F,l,l);G&&(t.strokeStyle=G,t.stroke())}else if(L){t.lineWidth=1;const G=this.createCanvasFill(t,b,l,l);G&&(t.strokeStyle=G,t.stroke())}if(g){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.moveTo(T+l*.25,A+l*.5),t.lineTo(T+l*.75,A+l*.5),t.stroke(),t.restore()}else if(p){t.save(),t.beginPath();const G=this.createCanvasFill(t,S,l,l);t.strokeStyle=G||S,t.lineWidth=Math.max(2,l*.12),t.lineCap="round",t.lineJoin="round";const x=T+l*.24,U=A+l*.5,q=T+l*.44,N=A+l*.7,H=T+l*.76,z=A+l*.28;t.moveTo(x,U),t.lineTo(q,N),t.lineTo(H,z),t.stroke(),t.restore()}if(e.disabled&&(t.globalAlpha*=2),I&&e.label&&e.label.text){const G=e.label;t.save(),t.font=`${G.fontWeight||400} ${G.fontSize||14}px "${G.fontFamily||"Inter"}", sans-serif`,t.fillStyle=G.color||"#111827",t.textAlign=B,t.textBaseline=R,t.fillText(G.text,D,Y),t.restore()}t.restore()}renderRadioGroup(t,s){var B,R;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=((B=s.geometry)==null?void 0:B.width)||180,i=((R=s.geometry)==null?void 0:R.height)||100,a=-n/2,r=-i/2;let l=e.optionsList||["Option 1","Option 2","Option 3"];if(e.isDataVarEnabled&&e.dataInputId){let L=this.inputs.get(e.dataInputId);if(L===void 0){const $=this.inputNameMap.get(e.dataInputId);$&&$.length>0&&(L=this.inputs.get($[0]))}L&&Array.isArray(L)&&(l=L.map($=>typeof $=="string"?$:String($)))}const d=e.selectedValue,p=e.orientation||"vertical",g=e.itemGap!==void 0?e.itemGap:16,u=this.lastHoveredObjectId===s.id,f=this.activeObjectId===s.id,h=e.hoverStyle||{},m=e.activeStyle||{};let b=e.activeColor||"#3b82f6",c=e.inactiveColor||"#4b5563",S=e.textColor||"#ffffff",v=1;f&&m?(m.activeColor&&(b=m.activeColor),m.inactiveColor&&(c=m.inactiveColor),m.textColor&&(S=m.textColor),v=m.scale??.95):u&&h&&(h.activeColor&&(b=h.activeColor),h.inactiveColor&&(c=h.inactiveColor),h.textColor&&(S=h.textColor),v=h.scale??1);const C=e.fontSize||14,w=e.fontFamily||"Inter",I=e.fontWeight||400;t.save(),e.disabled&&(t.globalAlpha*=.5),v!==1&&t.scale(v,v);const k=8,O=k*2,T=e.radioShape||"circle",A=e.borderWidth!==void 0?e.borderWidth:2,D=e.fillEmpty||"transparent",Y=(L,$,F,X)=>{if(t.beginPath(),X==="custom"&&e.customShapePath)try{const M=new Path2D(e.customShapePath),E=We(e.customShapePath),P=Math.min(F*2/E.width,F*2/E.height);t.save(),t.translate(L,$),t.scale(P,P),t.translate(-E.cx,-E.cy),!e.customShapePath.includes("z")&&!e.customShapePath.includes("Z")?(t.strokeStyle=t.fillStyle,t.lineWidth=Math.max(1.8,2.2/P),t.lineCap="round",t.lineJoin="round",t.stroke(M)):t.fill(M),t.restore();return}catch{t.arc(L,$,F,0,Math.PI*2);return}if(X==="square"){const M=F*1.6;t.rect(L-M/2,$-M/2,M,M)}else if(X==="diamond"){const M=F*1.4;t.moveTo(L,$-M),t.lineTo(L+M,$),t.lineTo(L,$+M),t.lineTo(L-M,$),t.closePath()}else if(X==="heart"){const M=F*.9;t.moveTo(L,$+M*.7),t.bezierCurveTo(L-M*1.5,$-M*.3,L-M*.5,$-M*1.5,L,$-M*.5),t.bezierCurveTo(L+M*.5,$-M*1.5,L+M*1.5,$-M*.3,L,$+M*.7)}else if(X==="star"){const M=F*1.1,E=F*.5;for(let P=0;P<5;P++){const _=(P*72-90)*Math.PI/180,V=(P*72+36-90)*Math.PI/180;P===0?t.moveTo(L+M*Math.cos(_),$+M*Math.sin(_)):t.lineTo(L+M*Math.cos(_),$+M*Math.sin(_)),t.lineTo(L+E*Math.cos(V),$+E*Math.sin(V))}t.closePath()}else t.arc(L,$,F,0,Math.PI*2)};if(t.font=`${I} ${C}px "${w}", sans-serif`,t.textBaseline="middle",t.textAlign="left",p==="vertical"){const L=Math.max(O,C)+g,$=l.length*L-g,F=r+Math.max(0,(i-$)/2);l.forEach((X,M)=>{const E=F+k+M*L,P=d===X,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);P?(t.fillStyle=_||b,Y(a+k,E,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(a+k,E,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(a+k,E,k,T),t.stroke()),t.fillStyle=S,t.fillText(X,a+O+8,E)})}else{const L=r+i/2;let $=0;t.font=`${I} ${C}px "${w}", sans-serif`,l.forEach(M=>{$+=O+6+t.measureText(M).width+g}),$-=g;let X=a+Math.max(0,(n-$)/2);l.forEach(M=>{const E=d===M,P=t.measureText(M).width,_=this.createCanvasFill(t,b,O,O),V=this.createCanvasFill(t,c,O,O);E?(t.fillStyle=_||b,Y(X+k,L,k,T),t.fill(),t.strokeStyle=_||b,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()):(D!=="transparent"&&(t.fillStyle=D,Y(X+k,L,k,T),t.fill()),t.strokeStyle=V||c,t.lineWidth=A,Y(X+k,L,k,T),t.stroke()),t.fillStyle=S,t.fillText(M,X+O+6,L),X+=O+6+P+g})}if(t.restore(),e.disabled&&(t.globalAlpha*=2),e.label&&e.label.text){const L=e.label;t.save(),t.font=`${L.fontWeight||400} ${L.fontSize||14}px "${L.fontFamily||"Inter"}", sans-serif`,t.fillStyle=L.color||"#9ca3af",t.textBaseline="middle";const $=L.gap||8;let F=0,X=0;L.position==="left"?(t.textAlign="right",F=a-$,X=0):L.position==="right"?(t.textAlign="left",F=a+n+$,X=0):L.position==="top"?(t.textAlign="center",F=0,X=r-$,t.textBaseline="bottom"):L.position==="bottom"&&(t.textAlign="center",F=0,X=r+i+$,t.textBaseline="top"),t.fillText(L.text,F,X),t.restore()}}renderBarChart(t,s){var $,F,X;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{};let n={...e};if(e.isDataVarEnabled&&e.dataInputId){let M=this.inputs.get(e.dataInputId);if(M===void 0){const E=this.inputNameMap.get(e.dataInputId);E&&E.length>0&&(M=this.inputs.get(E[0]))}M&&Array.isArray(M)&&(n.categories=M.map(E=>typeof E=="string"?E:String(E)))}if(e.isDatasetsVarEnabled&&(($=e.datasetInputIds)==null?void 0:$.length)>0){const M=e.datasetInputIds.map((E,P)=>{var G;let _=this.inputs.get(E);if(_===void 0){const x=this.inputNameMap.get(E);x&&x.length>0&&(_=this.inputs.get(x[0]))}const V=((G=e.datasets)==null?void 0:G[P])||{id:`ds-${P}`,label:`Series ${P+1}`,data:[],color:"#6366f1"};return _&&Array.isArray(_)?{...V,data:_.map(x=>typeof x=="number"?x:parseFloat(x)||0)}:V});n.datasets=M}const i={width:((F=s.geometry)==null?void 0:F.width)||300,height:((X=s.geometry)==null?void 0:X.height)||180,chartType:n.chartType||"grouped",datasets:n.datasets||[{id:"ds-1",label:"Revenue",data:[42,67,31,55,78,48],color:"#6366f1"}],categories:n.categories||["Jan","Feb","Mar","Apr","May","Jun"],orientation:n.orientation||"vertical",barWidth:n.barWidth!==void 0?n.barWidth:14,barGap:n.barGap!==void 0?n.barGap:4,barCornerRadius:n.barCornerRadius!==void 0?n.barCornerRadius:5,showXAxis:!!n.showXAxis,showYAxis:!!n.showYAxis,xAxisColor:n.xAxisColor||"rgba(255,255,255,0.15)",yAxisColor:n.yAxisColor||"rgba(255,255,255,0.15)",showXLabels:n.showXLabels!==void 0?!!n.showXLabels:!0,showYLabels:!!n.showYLabels,axisLabelColor:n.axisLabelColor||"rgba(255,255,255,0.55)",axisLabelFontSize:n.axisLabelFontSize||9,showLegend:n.showLegend!==void 0?!!n.showLegend:!0,legendColor:n.legendColor||"rgba(255,255,255,0.7)",legendFontSize:n.legendFontSize||9,showGridLines:n.showGridLines!==void 0?!!n.showGridLines:!0,gridColor:n.gridColor||"rgba(255,255,255,0.06)",cardBackground:n.cardBackground||"#ffffff",cardBackgroundOpacity:n.cardBackgroundOpacity!==void 0?n.cardBackgroundOpacity:.04,cardBorderColor:n.cardBorderColor||"rgba(255,255,255,0.08)",barGradient:n.barGradient!==void 0?!!n.barGradient:!0,gradientStartColor:n.gradientStartColor||"",gradientEndOpacity:n.gradientEndOpacity!==void 0?n.gradientEndOpacity:.27,showValueOnTop:!!n.showValueOnTop,valueFontSize:n.valueFontSize||10,valueColor:n.valueColor||"",valueFontWeight:n.valueFontWeight||"bold",barStyle:n.barStyle||"solid",barBorderWidth:n.barBorderWidth!==void 0?n.barBorderWidth:1,barBorderColor:n.barBorderColor||"auto",enableShadows:!!n.enableShadows,shadowColor:n.shadowColor||"rgba(0,0,0,0.5)",shadowBlur:n.shadowBlur!==void 0?n.shadowBlur:4,shadowOffsetY:n.shadowOffsetY!==void 0?n.shadowOffsetY:2,xAxisLineWidth:n.xAxisLineWidth!==void 0?n.xAxisLineWidth:1,yAxisLineWidth:n.yAxisLineWidth!==void 0?n.yAxisLineWidth:1,gridLineWidth:n.gridLineWidth!==void 0?n.gridLineWidth:1,gridLineDash:n.gridLineDash||[3,4],showHoverTooltip:n.showHoverTooltip!==void 0?!!n.showHoverTooltip:!0,hoverHighlight:n.hoverHighlight!==void 0?!!n.hoverHighlight:!0,hoverHighlightColor:n.hoverHighlightColor||"rgba(255, 255, 255, 0.22)",tooltipBg:n.tooltipBg||"#111827",tooltipTextColor:n.tooltipTextColor||"#f9fafb",tooltipRadius:n.tooltipRadius!==void 0?n.tooltipRadius:6,_hexToRgb:function(M,E){if(M.startsWith("rgba")||M.startsWith("rgb"))return M;M.startsWith("#")||(M="#"+M),M.length===4&&(M="#"+M[1]+M[1]+M[2]+M[2]+M[3]+M[3]);const P=parseInt(M.slice(1,3),16),_=parseInt(M.slice(3,5),16),V=parseInt(M.slice(5,7),16);return`rgba(${P},${_},${V},${E})`},_resolveColor:function(M,E){return typeof M=="string"?M:"#6366f1"},_makeGradient:function(M,E,P,_,V,G){if(!this.barGradient)return E;const x=this.gradientStartColor||E,U=M.createLinearGradient(P,_,V,G);return U.addColorStop(0,E),U.addColorStop(1,this._hexToRgb(x,this.gradientEndOpacity)),U},_drawRoundedBar:function(M,E,P,_,V,G,x){if(G=Math.min(G,Math.min(Math.abs(_),Math.abs(V))/2),G<=0||_===0||V===0){M.rect(E,P,_,V);return}M.beginPath(),x?(M.moveTo(E,P+V),M.lineTo(E,P+G),M.quadraticCurveTo(E,P,E+G,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V),M.lineTo(E,P+V)):(M.moveTo(E,P),M.lineTo(E+_-G,P),M.quadraticCurveTo(E+_,P,E+_,P+G),M.lineTo(E+_,P+V-G),M.quadraticCurveTo(E+_,P+V,E+_-G,P+V),M.lineTo(E,P+V),M.lineTo(E,P)),M.closePath()}},a=i.width,r=i.height,l=-a/2,d=-r/2;if(!i.datasets||i.datasets.length===0||i.categories.length===0){t.save(),t.fillStyle="rgba(99,102,241,0.7)",t.font="bold 11px Inter, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("NO CHART DATA",0,0),t.restore();return}let p=-1/0,g=1/0;const u=i.categories.length,f=i.datasets.length;if(i.chartType==="stacked")for(let M=0;M<u;M++){let E=0,P=0;i.datasets.forEach(_=>{const V=_.data[M]??0;V>=0?E+=V:P+=V}),E>p&&(p=E),P<g&&(g=P)}else i.datasets.forEach(M=>{M.data&&M.data.forEach(E=>{E>p&&(p=E),E<g&&(g=E)})});isFinite(p)||(p=10),isFinite(g)||(g=0),p=Math.max(p,0),g=Math.min(g,0);const h=p-g||10;t.save();const m=n.entranceStyle||{},b=m.type||"none",c=this.getEntranceProgress(s.id,m,n.previewState||"default");if(b!=="none"){if(b==="fade")t.globalAlpha*=c;else if(b==="draw")t.beginPath(),t.rect(-a/2-10,-r/2-10,(a+20)*c,r+20),t.clip();else if(b==="barGrow"){const M=-r/2+r*(1-c);t.beginPath(),t.rect(-a/2-10,M,a+20,r+20),t.clip()}else if(b==="slideUp"){const M=(1-c)*r*.4;t.translate(0,M),t.globalAlpha*=Math.min(1,c*2)}else b==="stagger"&&(i._staggerProg=c);m.showLegend===!1&&(i.showLegend=!1),m.showAxes===!1&&(i.showXAxis=!1,i.showYAxis=!1),m.showLabels===!1&&(i.showXLabels=!1,i.showYLabels=!1),m.showGrid===!1&&(i.showGridLines=!1)}i.enableShadows&&(t.shadowColor=i.shadowColor,t.shadowBlur=i.shadowBlur,t.shadowOffsetY=i.shadowOffsetY),t.font=i.axisLabelFontSize+"px Inter, sans-serif";const S=i.showYLabels?t.measureText(p.toFixed(0)).width+14:10,v=i.showXLabels?i.axisLabelFontSize+12:8,w=(i.showLegend&&f>0?i.legendFontSize+10:0)+8,I=10,k=l+S,O=d+w,T=a-S-I,A=r-w-v;if(i.enableShadows&&(t.shadowColor="transparent"),t.beginPath(),t.roundRect(l,d,a,r,10),t.fillStyle=i._hexToRgb(i.cardBackground,i.cardBackgroundOpacity),t.fill(),t.strokeStyle=i.cardBorderColor,t.lineWidth=1,t.stroke(),i.showLegend&&f>0){t.font=i.legendFontSize+"px Inter, sans-serif",t.textBaseline="middle";const M=d+12;let E=k;i.datasets.forEach((P,_)=>{const V=i._resolveColor(P.color,_),G=P.label||"Series "+(_+1),x=7;t.beginPath(),t.roundRect(E,M-x/2,x,x,2),t.fillStyle=V,t.fill(),t.fillStyle=i.legendColor,t.textAlign="left",t.fillText(G,E+x+4,M),E+=t.measureText(G).width+x+16})}const D=4;if(i.showGridLines){t.setLineDash(i.gridLineDash||[]),t.lineWidth=i.gridLineWidth||1,t.strokeStyle=i.gridColor;for(let M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=k+M/D*T;t.beginPath(),t.moveTo(E,O),t.lineTo(E,O+A),t.stroke()}else{const E=O+M/D*A;t.beginPath(),t.moveTo(k,E),t.lineTo(k+T,E),t.stroke()}t.setLineDash([])}if(i.showYLabels){t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor;for(let M=0;M<=D;M++)if(i.orientation==="horizontal"){const E=g+M/D*h,P=k+M/D*T;t.textAlign="center",t.fillText(E.toFixed(0),P,O+A+i.axisLabelFontSize)}else{const E=p-M/D*h,P=O+M/D*A;t.textAlign="right",t.fillText(E.toFixed(0),k-6,P)}}t.setLineDash([]),i.showXAxis&&(t.lineWidth=i.xAxisLineWidth||1,t.strokeStyle=i.xAxisColor,t.beginPath(),t.moveTo(k,O+A),t.lineTo(k+T,O+A),t.stroke()),i.showYAxis&&(t.lineWidth=i.yAxisLineWidth||1,t.strokeStyle=i.yAxisColor,t.beginPath(),t.moveTo(k,O),t.lineTo(k,O+A),t.stroke()),i.enableShadows&&(t.shadowColor=i.shadowColor);const Y=[],B=this.graphHoverStates.get(s.id),R=B==null?void 0:B.hoveredCatIdx,L=B==null?void 0:B.hoveredDsIdx;if(i.chartType==="stacked")if(i.orientation==="horizontal"){const M=A/u;for(let E=0;E<u;E++){const P=O+E*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[E]||"",k-5,P),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=k;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*T,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_;_+=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:H,y:N,w:U,h:q}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,H,N,H+U,N);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,N,U,q,G===f-1?i.barCornerRadius:0,!1),t.fill(),t.restore())})}}else{const M=T/u;for(let E=0;E<u;E++){const P=k+E*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[E]||"",P,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));let _=O+A;i.datasets.forEach((V,G)=>{const x=V.data[E]??0;if(x===0)return;const U=x/h*A,q=Math.min(i.barWidth*f+i.barGap,M-8),N=P-q/2,H=_-U;_-=U;const z=i._resolveColor(V.color,G);Y.push({catIdx:E,dsIdx:G,category:i.categories[E]||"",label:V.label||`Series ${G+1}`,val:x,color:z,x:N,y:H,w:q,h:U}),t.beginPath(),t.fillStyle=i._makeGradient(t,z,N,H,N,H+U);const et=i._staggerProg;if(et!==void 0&&b==="stagger"){const ct=u*f,It=E*f+G,mt=Math.max(0,Math.min(1,et*ct-It));t.globalAlpha*=mt}i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?z:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===E&&L===G&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,N,H,q,U,G===f-1?i.barCornerRadius:0,!0),t.fill(),t.restore())})}}else if(i.orientation==="horizontal"){const M=A/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=k+(0-g)/h*T;for(let _=0;_<u;_++){const V=O+_*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="right",t.textBaseline="middle",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[_]||"",k-5,V),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*T);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P:P-N,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:z,y:H,w:N,h:i.barWidth}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,z,H,z+N,H);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,z,H,N,i.barWidth,i.barCornerRadius,!1),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign=q>=0?"left":"right",t.textBaseline="middle",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),q>=0?z+N+4:z-4,H+i.barWidth/2),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}else{const M=T/u,E=f*i.barWidth+Math.max(0,(f-1)*i.barGap),P=O+A-(0-g)/h*A;for(let _=0;_<u;_++){const V=k+_*M+M/2;i.showXLabels&&(t.font=i.axisLabelFontSize+"px Inter, sans-serif",t.textAlign="center",t.textBaseline="top",t.fillStyle=i.axisLabelColor,t.shadowColor="transparent",t.fillText(i.categories[_]||"",V,O+A+5),i.enableShadows&&(t.shadowColor=i.shadowColor));const G=V-E/2;i.datasets.forEach((x,U)=>{const q=x.data[_]??0,N=Math.abs(q/h*A);if(N<1)return;const H=G+U*(i.barWidth+i.barGap),z=q>=0?P-N:P,et=i._resolveColor(x.color,U);Y.push({catIdx:_,dsIdx:U,category:i.categories[_]||"",label:x.label||`Series ${U+1}`,val:q,color:et,x:H,y:z,w:i.barWidth,h:N}),t.beginPath(),t.fillStyle=i._makeGradient(t,et,H,z,H,z+N);const Mt=i._staggerProg;if(Mt!==void 0&&b==="stagger"){const It=u*f,mt=_*f+U,kt=Math.max(0,Math.min(1,Mt*It-mt));t.globalAlpha*=kt}i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),i.barStyle==="outline"||i.barStyle==="dashed"?(t.fillStyle="transparent",t.strokeStyle=i.barBorderColor==="auto"?et:i.barBorderColor,t.lineWidth=i.barBorderWidth,i.barStyle==="dashed"&&t.setLineDash([4,4]),t.stroke(),t.setLineDash([])):t.fill(),R===_&&L===U&&i.hoverHighlight&&(t.save(),t.fillStyle=i.hoverHighlightColor,i._drawRoundedBar(t,H,z,i.barWidth,N,i.barCornerRadius,!0),t.fill(),t.restore()),i.showValueOnTop&&q!==0&&(t.font=(i.valueFontWeight||"bold")+" "+(i.valueFontSize||10)+"px Inter, sans-serif",t.textAlign="center",t.textBaseline=q>=0?"bottom":"top",t.fillStyle=i.valueColor==="auto"?et:i.valueColor||"#fff",t.shadowColor="transparent",t.fillText(q.toString(),H+i.barWidth/2,q>=0?z-4:z+N+4),i.enableShadows&&(t.shadowColor=i.shadowColor))})}}if(this.barChartRenderedBars.set(s.id,Y),i.showHoverTooltip&&R!==null&&R!==void 0&&L!==null&&L!==void 0){const M=Y.find(E=>E.catIdx===R&&E.dsIdx===L);if(M){t.save();const E=10,P=8,_=14,V=12,x=P*2+_+V+16,U=Math.max(...Y.map(Ot=>Math.abs(Ot.val))),q=U>0?Math.round(Math.abs(M.val)/U*100):0;t.font="bold 10px Inter, system-ui, sans-serif";const N=t.measureText(M.category||"Category").width;t.font="8px Inter, system-ui, sans-serif";const H=`${q}% of max (${U})`,z=t.measureText(H).width;t.font="9px Inter, system-ui, sans-serif";const et=t.measureText(`${M.label}: ${M.val}`).width+16,Mt=Math.max(N,z,et)+E*2;let ct=M.x+M.w/2-Mt/2,It=M.y-x-8;ct<-a/2+6&&(ct=-a/2+6),ct+Mt>a/2-6&&(ct=a/2-Mt-6),It<-r/2+6&&(It=M.y+M.h+8),It+x>r/2-6&&(It=r/2-x-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,ct,It,Mt,x,i.tooltipRadius),t.fillStyle=i.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(M.category,ct+E,It+P),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(H,ct+E,It+P+_);const mt=It+P+_+V+2;t.beginPath(),t.arc(ct+E+4,mt+5,3.5,0,Math.PI*2),t.fillStyle=M.color,t.fill(),t.font="9px Inter, system-ui, sans-serif",t.fillStyle=i.tooltipTextColor,t.fillText(`${M.label}: `,ct+E+12,mt);const kt=t.measureText(`${M.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle=M.color,t.fillText(`${M.val}`,ct+E+12+kt,mt),t.restore()}}t.restore()}renderPieChart(t,s){var k,O;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.options)||s.options||{},n=e.colorPalette==="custom"&&Array.isArray(e.customPalette)&&e.customPalette.length>0?e.customPalette:ys[e.colorPalette||"vibrant"]||ys.vibrant;let i=e.slices||[{id:"slice-1",label:"Item 1",value:45,color:""}];if(e.isDataVarEnabled&&e.dataInputId){let T=this.inputs.get(e.dataInputId);if(T===void 0){const A=this.inputNameMap.get(e.dataInputId);A&&A.length>0&&(T=this.inputs.get(A[0]))}T&&Array.isArray(T)&&(i=T.map((A,D)=>{var Y,B;return{id:`slice-${D}`,label:((Y=i[D])==null?void 0:Y.label)||`Item ${D+1}`,value:typeof A=="number"?A:0,color:((B=i[D])==null?void 0:B.color)||""}}))}const a={width:((k=s.geometry)==null?void 0:k.width)||180,height:((O=s.geometry)==null?void 0:O.height)||180,chartType:e.chartType||"donut",slices:i,innerRadius:e.innerRadius!==void 0?e.innerRadius:.55,sliceGap:e.sliceGap!==void 0?e.sliceGap:3,showLabels:!!e.showLabels,labelColor:e.labelColor||"#000000",labelFontSize:e.labelFontSize||10,showLegend:e.showLegend!==void 0?!!e.showLegend:!0,legendColor:e.legendColor||"rgba(0,0,0,0.65)",legendFontSize:e.legendFontSize||9,showCenterText:e.showCenterText!==void 0?!!e.showCenterText:!0,centerLabel:e.centerLabel||"Total",centerTextColor:e.centerTextColor||"#000000",centerLabelColor:e.centerLabelColor||"rgba(0,0,0,0.4)",cardBackground:e.cardBackground||"#ffffff",cardBackgroundOpacity:e.cardBackgroundOpacity!==void 0?e.cardBackgroundOpacity:.04,cardBorderColor:e.cardBorderColor||"rgba(0,0,0,0.08)",showHoverTooltip:e.showHoverTooltip!==void 0?!!e.showHoverTooltip:!0,hoverExplode:e.hoverExplode!==void 0?!!e.hoverExplode:!0,tooltipBg:e.tooltipBg||"#111827",tooltipTextColor:e.tooltipTextColor||"#f9fafb",tooltipRadius:e.tooltipRadius!==void 0?e.tooltipRadius:6,_resolveSliceColor:function(T,A){return T.color?T.color:n[A%n.length]},_hexToRgb:function(T){if(T.startsWith("rgba")||T.startsWith("rgb"))return T;const A=T.replace("#",""),D=parseInt(A.substring(0,2),16),Y=parseInt(A.substring(2,4),16),B=parseInt(A.substring(4,6),16);return`rgba(${D},${Y},${B},${a.cardBackgroundOpacity})`}},r=a.width,l=a.height;if(!a.slices||a.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 d=a.slices.reduce((T,A)=>T+(A.value||0),0);if(d<=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}t.save();const p=e.entranceStyle||{},g=p.type||"none",u=this.getEntranceProgress(s.id,p,e.previewState||"default");if(g!=="none"){if(g==="fade")t.globalAlpha*=u;else if(g==="draw")t.beginPath(),t.rect(-r/2-10,-l/2-10,(r+20)*u,l+20),t.clip();else if(g==="radial"){const T=Math.sqrt(r*r+l*l)/2;t.beginPath(),t.arc(0,0,T*u,0,Math.PI*2),t.clip()}else if(g==="sliceReveal"){if(i.reduce((A,D)=>A+(D.value||0),0)>0){const A=-Math.PI/2+u*Math.PI*2;t.beginPath(),t.moveTo(0,0),t.arc(0,0,Math.max(r,l),-Math.PI/2,A),t.lineTo(0,0),t.clip()}}else if(g==="spinIn"){const T=(1-u)*Math.PI*2;t.rotate(T),t.globalAlpha*=u}else if(g==="grow"){const T=u;t.scale(T,T),t.globalAlpha*=Math.min(1,u*2)}p.showLegend===!1&&(a.showLegend=!1),p.showLabels===!1&&(a.showLabels=!1),p.showCenterText===!1&&(a.showCenterText=!1)}const f=a._hexToRgb(a.cardBackground);t.beginPath(),t.roundRect(-r/2,-l/2,r,l,10),t.fillStyle=f,t.fill(),t.strokeStyle=a.cardBorderColor,t.lineWidth=1,t.stroke();const h=a.showLegend?Math.ceil(a.slices.length/2):0,m=h>0?h*(a.legendFontSize+8)+10:0,b=l-m-16,c=Math.min(r-24,b)/2,S=0,v=-m/2,C=[],w=this.graphHoverStates.get(s.id),I=(w==null?void 0:w.hoveredSliceIndex)??null;if(a.chartType==="rose"){const T=Math.max(...a.slices.map(Y=>Y.value||0)),A=Math.PI*2/a.slices.length,D=c>0?a.sliceGap/c:0;a.slices.forEach((Y,B)=>{const R=Y.value||0;if(R===0)return;const L=R/T*c,$=-Math.PI/2+B*A+D/2,F=$+A-D,X=a._resolveSliceColor(Y,B),M=$+(F-$)/2,E=I===B;let P=S,_=v;if(E&&a.hoverExplode&&(P+=Math.cos(M)*6,_+=Math.sin(M)*6),C.push({index:B,startA:$,endA:F,innerR:0,outerR:L,cx:P,cy:_,slice:Y,color:X,pct:Math.round(R/d*100)}),t.beginPath(),t.moveTo(P,_),t.arc(P,_,L,$,F),t.closePath(),t.fillStyle=X+"cc",t.fill(),t.strokeStyle=X,t.lineWidth=E?2.5:1.5,t.stroke(),a.showLabels){const V=P+L*.65*Math.cos(M),G=_+L*.65*Math.sin(M),x=Math.round(R/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${x}%`,V,G),t.restore()}})}else{const T=a.chartType==="pie"?0:a.innerRadius,A=c*Math.max(0,T),D=c>0?a.sliceGap/c:0;let Y=-Math.PI/2;if(a.slices.forEach((B,R)=>{const L=B.value||0;if(L===0){Y+=L/d*Math.PI*2;return}const $=L/d*Math.PI*2,F=Y+D/2,X=Y+$-D/2;if(X<=F){Y+=$;return}const M=a._resolveSliceColor(B,R),E=F+(X-F)/2,P=I===R;let _=S,V=v;if(P&&a.hoverExplode&&(_+=Math.cos(E)*6,V+=Math.sin(E)*6),C.push({index:R,startA:F,endA:X,innerR:A,outerR:c,cx:_,cy:V,slice:B,color:M,pct:Math.round(L/d*100)}),t.beginPath(),t.fillStyle=M,A<=0?(t.moveTo(_,V),t.arc(_,V,c,F,X),t.lineTo(_,V)):(t.moveTo(_+c*Math.cos(F),V+c*Math.sin(F)),t.arc(_,V,c,F,X),t.arc(_,V,A,X,F,!0),t.closePath()),t.fill(),P&&(t.lineWidth=2,t.strokeStyle="#ffffff",t.stroke()),a.showLabels){const G=A+(c-A)/2,x=_+G*Math.cos(E),U=V+G*Math.sin(E),q=Math.round(L/d*100);t.save(),t.font=`bold ${a.labelFontSize}px Inter, sans-serif`,t.fillStyle=a.labelColor,t.textAlign="center",t.textBaseline="middle",t.fillText(`${q}%`,x,U),t.restore()}Y+=$}),a.chartType==="donut"&&a.showCenterText&&A>14){const B=Math.round(d),R=Math.min(Math.floor(A*.52),20),L=Math.min(Math.floor(A*.26),10);t.textAlign="center",t.textBaseline="middle",t.font=`bold ${R}px Inter, sans-serif`,t.fillStyle=a.centerTextColor,t.fillText(B.toString(),S,v-L*.5),t.font=`${L}px Inter, sans-serif`,t.fillStyle=a.centerLabelColor,t.fillText(a.centerLabel,S,v+R*.6)}}if(this.pieChartRenderedSlices.set(s.id,C),a.showLegend&&a.slices.length>0){t.font=`${a.legendFontSize}px Inter, sans-serif`;const T=2,A=r/T,D=a.legendFontSize+8,Y=l/2-m+10,B=-r/2+10;a.slices.forEach((R,L)=>{const $=L%T,F=Math.floor(L/T),X=B+$*A,M=Y+F*D,E=a._resolveSliceColor(R,L),P=7;t.beginPath(),t.roundRect(X,M-P/2,P,P,2),t.fillStyle=E,t.fill(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=a.legendColor;const _=Math.round((R.value||0)/d*100),V=`${R.label||"Item"} ${_}%`,G=A-P-20;let x=V;for(;t.measureText(x).width>G&&x.length>4;)x=x.slice(0,-4)+"…";t.fillText(x,X+P+4,M)})}if(a.showHoverTooltip&&I!==null&&I!==void 0){const T=C.find(A=>A.index===I);if(T){t.save();const A=10,D=8,Y=14,B=12,L=D*2+Y+B+16,$=i.reduce((N,H)=>N+(H.value||0),0);t.font="bold 10px Inter, system-ui, sans-serif";const F=t.measureText(T.slice.label||"Item").width;t.font="8px Inter, system-ui, sans-serif";const X=`of ${$} total`,M=t.measureText(X).width;t.font="9px Inter, system-ui, sans-serif";const E=`${T.slice.value} (${T.pct}%)`,P=t.measureText(E).width+16,_=Math.max(F,M,P)+A*2,V=T.startA+(T.endA-T.startA)/2,G=(T.innerR+T.outerR)/2;let x=T.cx+Math.cos(V)*(G+10)-_/2,U=T.cy+Math.sin(V)*(G+10)-L/2;x<-r/2+6&&(x=-r/2+6),x+_>r/2-6&&(x=r/2-_-6),U<-l/2+6&&(U=-l/2+6),U+L>l/2-6&&(U=l/2-L-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,x,U,_,L,a.tooltipRadius),t.fillStyle=a.tooltipBg,t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=a.tooltipTextColor,t.textAlign="left",t.textBaseline="top",t.fillText(T.slice.label||"Item",x+A,U+D),t.font="8px Inter, system-ui, sans-serif",t.fillStyle="rgba(255,255,255,0.5)",t.fillText(X,x+A,U+D+Y);const q=U+D+Y+B+2;t.beginPath(),t.arc(x+A+4,q+5,3.5,0,Math.PI*2),t.fillStyle=T.color,t.fill(),t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(E,x+A+12,q),t.restore()}}t.restore()}renderJoystick(t,s){var m,b,c,S,v,C,w,I,k,O,T,A;const o=this.objectStates.get(s.id),e=(o==null?void 0:o.width)!==void 0?o.width:((m=s.geometry)==null?void 0:m.width)??s.width??100,n=(o==null?void 0:o.height)!==void 0?o.height:((b=s.geometry)==null?void 0:b.height)??s.height??100,i=Math.min(e,n)*(((c=s.style)==null?void 0:c.baseSize)??.45),a=Math.min(e,n)*(((S=s.style)==null?void 0:S.handleSize)??.14);let r=s.handleX||0,l=s.handleY||0;o&&o.handleX!==void 0&&(r=o.handleX),o&&o.handleY!==void 0&&(l=o.handleY),t.save();let d=0,p=0;s.handleOrigin==="top-left"?(d=e/2,p=n/2):s.handleOrigin==="bottom-right"&&(d=-e/2,p=-n/2),t.translate(d,p);const g=t.globalAlpha;if(t.globalAlpha=g*(((v=s.style)==null?void 0:v.baseOpacity)??1),t.beginPath(),s.boundsShape==="square"){const D=s.joystickType==="2D"?12:18;t.roundRect(-i,-i,i*2,i*2,D)}else t.arc(0,0,i,0,Math.PI*2);t.fillStyle=((C=s.style)==null?void 0:C.baseColor)||"rgba(255, 255, 255, 0.5)",t.fill(),(w=s.style)!=null&&w.baseBorderWidth?(t.lineWidth=s.style.baseBorderWidth,t.strokeStyle=s.style.baseBorderColor||"rgba(0,0,0,0.1)",t.stroke()):(t.lineWidth=1.5,t.strokeStyle=((I=s.style)==null?void 0:I.baseBorderColor)||"rgba(0, 0, 0, 0.15)",t.stroke());const u=s.overflowHandle?i:Math.max(.1,i-a);let f=0,h=0;s.joystickType==="2D"?(f=r*u,h=l*u):s.joystickType==="1D_X"?(f=r*u,h=0):s.joystickType==="1D_Y"&&(f=0,h=l*u),t.globalAlpha=g*(((k=s.style)==null?void 0:k.handleOpacity)??1),t.beginPath(),t.arc(f,h,a,0,Math.PI*2),t.fillStyle=((O=s.style)==null?void 0:O.handleColor)||"#3b82f6",t.fill(),(T=s.style)!=null&&T.handleBorderWidth?(t.lineWidth=s.style.handleBorderWidth,t.strokeStyle=s.style.handleBorderColor||"rgba(255,255,255,0.5)",t.stroke()):(t.lineWidth=1,t.strokeStyle=((A=s.style)==null?void 0:A.handleBorderColor)||"rgba(255,255,255,0.5)",t.stroke()),t.globalAlpha=g,t.restore()}getRadioGroupItemIndexAtPointer(t,s,o){var k,O;const e=t.options||{},n=this.objectStates.get(t.id)||{},i=e.optionsList||[];if(i.length===0)return null;const a=n.width!==void 0?n.width:((k=t.geometry)==null?void 0:k.width)||180,r=n.height!==void 0?n.height:((O=t.geometry)==null?void 0:O.height)||100,l=e.orientation||"vertical",d=e.itemGap!==void 0?e.itemGap:16,p=e.fontSize||14,g=this.getWorldTransform(t.id),u=s-g.x,f=o-g.y,h=-g.rotation*(Math.PI/180),m=Math.cos(h),b=Math.sin(h),c=u*m-f*b,S=u*b+f*m,C=8*2,w=-a/2,I=-r/2;if(l==="vertical"){const T=Math.max(C,p)+d;for(let A=0;A<i.length;A++){const D=I+A*T;if(c>=w&&c<=w+a&&S>=D&&S<=D+T)return A}}else{let T=w;for(let A=0;A<i.length;A++){const Y=i[A].length*8,B=C+6+Y+d;if(c>=T&&c<=T+B&&S>=I&&S<=I+r)return A;T+=B}}return null}renderLineGraph(t,s,o,e,n){const i=this.objectStates.get(s.id),a=(i==null?void 0:i.options)||s.options||{},r=a.hoverStyle||{},l=a.loadingStyle||{},d=a.entranceStyle||{},p=a.pressedStyle||{};let g=o.datasets||[];(!g||g.length===0)&&(o.data||o.graphData)&&(g=[{id:"line-1",label:"Series 1",data:o.data||o.graphData||[],lineColor:o.lineColor||"#3b82f6",lineWidth:o.lineWidth||2,showArea:o.showArea||!1,areaColor:o.areaColor||"rgba(139, 92, 246, 0.3)",smoothing:o.smoothing||!1,showPoints:o.showPoints!==void 0?o.showPoints:!0,pointSize:o.pointSize||6,pointFill:o.pointFill||"#ffffff",pointStrokeColor:o.pointStrokeColor||o.lineColor||"#3b82f6",pointStrokeWidth:o.pointStrokeWidth||2}]);let u=1/0,f=-1/0,h=0;g.forEach(B=>{let R=B.data;if(B.isVarEnabled&&B.inputId){let L=this.inputs.get(B.inputId);if(L===void 0){const $=this.inputNameMap.get(B.inputId);$&&$.length>0&&(L=this.inputs.get($[0]))}if(L!=null){if(typeof L=="string")try{L=JSON.parse(L)}catch{L=L.split(",").map($=>Number($.trim()))}Array.isArray(L)&&(R=L)}}if(R&&R.length>0){const L=R.map($=>Number($)).filter($=>!isNaN($));L.length>0&&(u=Math.min(u,...L),f=Math.max(f,...L),h=Math.max(h,L.length))}B._resolvedData=R});const m=a.previewState||"default";if(a.simulateLoading||m==="loading"||h<2){const B=l.skeletonColor||"rgba(100, 116, 139, 0.4)",R=l.pulseSpeed||1.5,L=l.minOpacity||.3,$=this.currentTime,F=L+(1-L)*(.5*(1+Math.sin($*Math.PI*2*R)));t.save(),t.globalAlpha=F,t.strokeStyle=B,t.lineWidth=o.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.beginPath();const X=40;for(let M=0;M<=X;M++){const E=-e/2+e/X*M,P=Math.sin(M*.4-$*4)*(n/8);M===0?t.moveTo(E,P):t.lineTo(E,P)}t.stroke(),t.restore();return}const c=f-u,S=e/(h-1),v=B=>{const R=c===0?.5:(B-u)/c;return n/2-R*n},C=B=>B*S-e/2,w=o.axisColor||"#333333";if(o.showXAxis&&(t.beginPath(),t.strokeStyle=o.xAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,n/2),t.lineTo(e/2,n/2),t.stroke()),o.showYAxis&&(t.beginPath(),t.strokeStyle=o.yAxisColor||w,t.lineWidth=1,t.moveTo(-e/2,-n/2),t.lineTo(-e/2,n/2),t.stroke()),t.fillStyle=o.axisLabelColor||"#333333",t.font=`${o.axisLabelFontSize||10}px Inter, sans-serif`,o.showXLabels){t.textAlign="center",t.textBaseline="top";for(let B=0;B<h;B++){const R=C(B);t.fillText(`${B+1}`,R,n/2+5)}}if(o.showYLabels){t.textAlign="right",t.textBaseline="middle";const B=-e/2-5,R=(f+u)/2;t.fillText(f.toFixed(1),B,v(f)),t.fillText(R.toFixed(1),B,v(R)),t.fillText(u.toFixed(1),B,v(u))}const I=10,k=d.type||"none",O=this.getEntranceProgress(s.id,d,m);if(t.save(),k==="fade"?t.globalAlpha*=O:k==="draw"&&(t.beginPath(),t.rect(-e/2-10,-n/2-10,(e+20)*O,n+20),t.clip()),k!=="none"&&(d.showAxes===!1&&(o.showXAxis=!1,o.showYAxis=!1),d.showLabels===!1&&(o.showXLabels=!1,o.showYLabels=!1)),g.forEach(B=>{const R=B._resolvedData;if(!(!R||R.length<2)){if(B.showArea){if(t.beginPath(),t.moveTo(C(0),n/2),t.lineTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let $=0;$<R.length-1;$++){const F=R[$===0?$:$-1],X=R[$],M=R[$+1],E=R[$+1===R.length-1?$+1:$+2];for(let P=1;P<=I;P++){const _=P/I,V=this._catmullRom(F,X,M,E,_);t.lineTo(C($+_),v(V))}}else for(let $=1;$<R.length;$++)t.lineTo(C($),v(R[$]));t.lineTo(C(R.length-1),n/2),t.closePath();const L=t.globalAlpha;t.globalAlpha=L*(o.areaOpacity??.3),t.fillStyle=B.areaColor||"rgba(139, 92, 246, 0.2)",t.fill(),t.globalAlpha=L}if(t.beginPath(),t.strokeStyle=B.lineColor||"#3b82f6",t.lineWidth=B.lineWidth||2,t.lineJoin="round",t.lineCap="round",t.moveTo(C(0),v(R[0])),B.smoothing&&R.length>2)for(let L=0;L<R.length-1;L++){const $=R[L===0?L:L-1],F=R[L],X=R[L+1],M=R[L+1===R.length-1?L+1:L+2];for(let E=1;E<=I;E++){const P=E/I,_=this._catmullRom($,F,X,M,P);t.lineTo(C(L+P),v(_))}}else for(let L=1;L<R.length;L++)t.lineTo(C(L),v(R[L]));t.stroke(),(B.showPoints||m==="hover"||m==="pressed")&&R.forEach((L,$)=>{const F=C($),X=v(L);let M=(B.pointSize||6)/2,E=!1,P=!1;const _=$===Math.floor(R.length/2);m==="pressed"&&_?P=!0:m==="hover"&&_&&(E=!0),!(!B.showPoints&&!E&&!P)&&(P?(M*=p.scale||1.5,t.beginPath(),t.arc(F,X,M*1.5,0,Math.PI*2),t.fillStyle=p.rippleColor||"rgba(59, 130, 246, 0.4)",t.fill()):E&&(M*=r.scale||1.02),t.beginPath(),t.arc(F,X,M,0,Math.PI*2),t.fillStyle=B.pointFill||"#ffffff",t.fill(),t.strokeStyle=B.pointStrokeColor||B.lineColor||"#3b82f6",t.lineWidth=B.pointStrokeWidth||1,t.stroke())})}}),t.restore(),o.showLegend&&g.length>0){const B=e/2-10;let R=-n/2+15;const L=o.legendFontSize||10,$=L+5;t.font=`${L}px Inter, sans-serif`,t.textAlign="right",t.textBaseline="alphabetic",g.forEach(F=>{const M=F.label||"Series",E=t.measureText(M).width;t.beginPath(),t.rect(B-E-8-5,R-(8/2+2),8,8),t.fillStyle=F.lineColor||"#3b82f6",t.fill(),t.fillStyle=o.legendColor||"#333333",t.fillText(M,B,R),R+=$})}const T=this.graphHoverStates.get(s==null?void 0:s.id),A=T==null?void 0:T.hoveredIndex,D=o.showHoverTooltip!==!1,Y=o.showHoverLine!==!1;if(A!=null&&(D||Y)){const B=C(A);Y&&(t.save(),t.beginPath(),t.strokeStyle=o.hoverLineColor||"rgba(255, 255, 255, 0.35)",t.lineWidth=1,t.setLineDash([3,3]),t.moveTo(B,-n/2),t.lineTo(B,n/2),t.stroke(),t.setLineDash([]),t.restore());const R=[];if(g.forEach(L=>{const $=L._resolvedData||L.data;if($&&$[A]!==void 0&&typeof $[A]=="number"&&!isNaN($[A])){const F=$[A],X=v(F),M=L.lineColor||"#3b82f6";R.push({y:X,color:M,label:L.label||"Series",val:F});const E=this.isMouseDown,P=E?p.scale||1.5:1,_=E?p.rippleColor||"rgba(59, 130, 246, 0.4)":typeof M=="string"&&M.startsWith("#")?`${M}33`:"rgba(59, 130, 246, 0.2)";t.save(),t.beginPath();const V=o.pointHighlightRadius||5;t.arc(B,X,(V+3)*P,0,Math.PI*2),t.fillStyle=_,t.fill(),t.beginPath(),t.arc(B,X,V*P,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.strokeStyle=M,t.lineWidth=2.5*P,t.stroke(),t.restore()}}),D&&R.length>0){t.save();const L=10,$=8,F=16,X=14,M=$*2+X+R.length*F;t.font="bold 10px Inter, system-ui, sans-serif";let E=t.measureText(`Point #${A+1}`).width;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{const q=t.measureText(`${U.label}: ${U.val.toFixed(1)}`).width+16;q>E&&(E=q)});const P=E+L*2;let _=B+12;_+P>e/2-4&&(_=B-P-12),_<-e/2+4&&(_=-e/2+4);let G=R.reduce((U,q)=>U+q.y,0)/R.length-M/2;G<-n/2+6&&(G=-n/2+6),G+M>n/2-6&&(G=n/2-M-6),t.shadowColor="rgba(0, 0, 0, 0.35)",t.shadowBlur=10,t.shadowOffsetX=0,t.shadowOffsetY=4,t.beginPath(),this.drawRoundRect(t,_,G,P,M,o.tooltipRadius||6),t.fillStyle=o.tooltipBg||"#111827",t.fill(),t.shadowColor="transparent",t.lineWidth=1,t.strokeStyle="rgba(255, 255, 255, 0.12)",t.stroke(),t.font="bold 10px Inter, system-ui, sans-serif",t.fillStyle=o.tooltipTextColor||"#f9fafb",t.textAlign="left",t.textBaseline="top",t.fillText(`Point #${A+1}`,_+L,G+$);let x=G+$+X+2;t.font="9px Inter, system-ui, sans-serif",R.forEach(U=>{t.beginPath(),t.arc(_+L+4,x+5,3.5,0,Math.PI*2),t.fillStyle=U.color,t.fill(),t.fillStyle=o.tooltipTextColor||"#f9fafb",t.fillText(`${U.label}: `,_+L+12,x);const q=t.measureText(`${U.label}: `).width;t.font="bold 9px Inter, system-ui, sans-serif",t.fillStyle="#60a5fa",t.fillText(`${U.val.toFixed(1)}`,_+L+12+q,x),t.font="9px Inter, system-ui, sans-serif",x+=F}),t.restore()}}}_catmullRom(t,s,o,e,n){const i=(o-t)*.5,a=(e-s)*.5,r=n*n,l=n*r;return(2*s-2*o+i+a)*l+(-3*s+3*o-2*i-a)*r+i*n+s}normalizeOpacity(t){const s=typeof t=="number"?t:parseFloat(String(t));return isNaN(s)?1:s>1?Math.min(1,s/100):Math.max(0,Math.min(1,s))}createCanvasFill(t,s,o,e){var n,i,a;if(!s||s.type==="None")return null;if(typeof s=="string")return s;if((s.type==="Solid"||!s.type)&&s.color){const r=typeof s.color=="string"?s.color:s.color.color||"#000000",d=(((i=(n=this.artboard)==null?void 0:n.tokens)==null?void 0:i.colors)||{})[r]||r;return t.fillStyle=d,d}if(typeof s=="object"&&"r"in s&&"g"in s&&"b"in s){const r=s.a!==void 0?s.a:s.opacity!==void 0?s.opacity:1;return`rgba(${s.r}, ${s.g}, ${s.b}, ${r})`}if((s.type==="LinearGradient"||s.type==="RadialGradient"||s.type==="AngularGradient"||s.type==="DiamondGradient")&&s.stops){const r=(l,d=100)=>{var v,C;const g=(((C=(v=this.artboard)==null?void 0:v.tokens)==null?void 0:C.colors)||{})[l]||l,u=this.normalizeOpacity(s.opacity??100),h=this.normalizeOpacity(d)*u;if(h>=1&&g.startsWith("#"))return g;const m=g.startsWith("#")?g.replace("#",""):"ffffff",b=parseInt(m.substring(0,2),16),c=parseInt(m.substring(2,4),16),S=parseInt(m.substring(4,6),16);return`rgba(${b}, ${c}, ${S}, ${h})`};if(s.type==="LinearGradient"){let l=0,d=-e/2,p=0,g=e/2;if(s.angle!==void 0&&(!s.start||!s.end)){const f=(s.angle-90)*Math.PI/180,h=Math.max(o,e)/2;l=Math.cos(f)*-h,d=Math.sin(f)*-h,p=Math.cos(f)*h,g=Math.sin(f)*h}else if(s.start||s.end){const f=(h,m,b)=>Array.isArray(h)?h[m]??.5:h&&typeof h=="object"?h[b]??.5:.5;l=f(s.start,0,"x")*o-o/2,d=f(s.start,1,"y")*e-e/2,p=f(s.end,0,"x")*o-o/2,g=f(s.end,1,"y")*e-e/2}Math.abs(l-p)<.001&&Math.abs(d-g)<.001&&(l=0,d=-e/2,p=0,g=e/2);const u=t.createLinearGradient(l,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="RadialGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center,0,"x")*o-o/2,p=l(s.center,1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e),u=t.createRadialGradient(d,p,0,d,p,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}else if(s.type==="AngularGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.degree||s.angle||0)*(Math.PI/180),u=(a=t.createConicGradient)==null?void 0:a.call(t,g,d,p);if(u){if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return u}}else if(s.type==="DiamondGradient"){const l=(f,h,m)=>Array.isArray(f)?f[h]??.5:f&&typeof f=="object"?f[m]??.5:.5,d=l(s.center||[.5,.5],0,"x")*o-o/2,p=l(s.center||[.5,.5],1,"y")*e-e/2,g=(s.radius??.5)*Math.max(o,e);t.save(),t.translate(d,p),t.rotate(Math.PI/4);const u=t.createRadialGradient(0,0,0,0,0,g);if(s.stops.forEach(f=>{const h=f.offset!==void 0?f.offset:f.pos!==void 0?f.pos:f.position!==void 0?f.position:0,m=r(f.color||"#000000",f.opacity??100);u.addColorStop(Math.max(0,Math.min(1,h)),m)}),s.gradientTransform&&u.setTransform){const[f,h,m,b,c,S]=s.gradientTransform;u.setTransform({a:f,b:h,c:m,d:b,e:c,f:S})}return t.scale(1/Math.SQRT2,1/Math.SQRT2),t.fillStyle=u,t.restore(),u}}if(s.type==="Pattern"&&s.url){let r=this.imageCache.get(s.url);if(r||(r=new Image,r.src=s.url,this.imageCache.set(s.url,r)),r.complete&&r.naturalWidth>0){const l=t.createPattern(r,"repeat");if(l&&(s.scaleX!==void 0||s.offsetX!==void 0)){const d=new DOMMatrix,p=s.scaleX??1,g=s.scaleY??1,u=s.offsetX??0,f=s.offsetY??0,h=s.rotation??0;d.translateSelf(u,f),d.rotateSelf(h),d.scaleSelf(p,g),l.setTransform(d)}return l}}return s.color||null}drawRoundRect(t,s,o,e,n,i){if(i===0||i===void 0||i===null){t.rect(s,o,e,n);return}let a=i;if(typeof a=="string")try{a=JSON.parse(a)}catch{a=parseFloat(a)||0}let r=0,l=0,d=0,p=0;typeof a=="number"?r=l=d=p=a:Array.isArray(a)?a.length===1?r=l=d=p=a[0]:a.length===2?(r=d=a[0],l=p=a[1]):a.length===3?(r=a[0],l=p=a[1],d=a[2]):a.length>=4&&(r=a[0],l=a[1],d=a[2],p=a[3]):a&&typeof a=="object"&&(r=a[0]??a.tl??a.corner_radius??a.cornerRadius??0,l=a[1]??a.tr??a.corner_radius??a.cornerRadius??0,d=a[2]??a.br??a.corner_radius??a.cornerRadius??0,p=a[3]??a.bl??a.corner_radius??a.cornerRadius??0);const g=Math.min(Math.abs(e)/2,Math.abs(n)/2);if(r=Math.min(Math.max(0,r),g),l=Math.min(Math.max(0,l),g),d=Math.min(Math.max(0,d),g),p=Math.min(Math.max(0,p),g),t.roundRect){t.roundRect(s,o,e,n,[r,l,d,p]);return}t.moveTo(s+r,o),t.lineTo(s+e-l,o),t.arcTo(s+e,o,s+e,o+l,l),t.lineTo(s+e,o+n-d),t.arcTo(s+e,o+n,s+e-d,o+n,d),t.lineTo(s+p,o+n),t.arcTo(s,o+n,s,o+n-p,p),t.lineTo(s,o+r),t.arcTo(s,o,s+r,o,r),t.closePath()}renderListView(t,s){var R,L,$,F,X,M,E,P,_,V;const o=this.objectStates.get(s.id)||{},e=o.options||s.options||{},n=o.width!==void 0?o.width:((R=s.geometry)==null?void 0:R.width)||200,i=o.height!==void 0?o.height:((L=s.geometry)==null?void 0:L.height)||300,a=-n/2,r=-i/2,l=e.cornerRadius!==void 0?e.cornerRadius:o.cornerRadius!==void 0?o.cornerRadius:o.corner_radius??e.corner_radius??(($=s.geometry)==null?void 0:$.cornerRadius)??((F=s.geometry)==null?void 0:F.corner_radius)??0,d=e.orientation||"vertical",p=this.getResolvedListViewItems(s,e),g=e.itemGap??10,u=e.itemHeight??50,f=e.itemWidth??200,h=e.scrollOffset??0,m=e.padding??0,b=e.glassEffect!==!1,c=e.accentColor||"#3b82f6",S=e.itemTextColor||"#333333",v=e.itemBackgroundColor||"#ffffff",C=e.hoveredIndex??null,w=e.activeItemIndex??null,I=e.glowIntensity??0,k=e.glowColor||"#3b82f6",O=typeof k=="string"?k:k.color||((M=(X=k.stops)==null?void 0:X[0])==null?void 0:M.color)||"#3b82f6",T=e.opacity!==void 0?e.opacity:s.opacity!==void 0?s.opacity:1;if(t.save(),t.globalAlpha*=T,I>0){const G=t.getTransform(),x=Math.sqrt(G.a*G.a+G.b*G.b)||1;t.shadowColor=O,t.shadowBlur=I*2*x,t.shadowOffsetX=0,t.shadowOffsetY=0}if(b){const G=e.listBackgroundColor||"rgba(31, 41, 55, 0.4)",x=this.createCanvasFill(t,G,n,i);t.fillStyle=x||"rgba(31, 41, 55, 0.4)",t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const q=t.createLinearGradient(a,r,a+n,r+i);q.addColorStop(0,"rgba(255, 255, 255, 0.15)"),q.addColorStop(.5,"rgba(255, 255, 255, 0.08)"),q.addColorStop(1,"rgba(255, 255, 255, 0.03)"),t.fillStyle=q,t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.fill();const H=e.borderWidth??0;if(H>0&&e.borderColor&&e.borderColor!=="transparent"){const et=this.createCanvasFill(t,e.borderColor,n,i);t.strokeStyle=et||"rgba(255, 255, 255, 0.25)",t.lineWidth=H}else t.strokeStyle="rgba(255, 255, 255, 0.25)",t.lineWidth=1;t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)||t.stroke()}else{const G=e.backgroundColor&&e.backgroundColor!=="transparent"?e.backgroundColor:e.listBackgroundColor||"transparent",x=this.createCanvasFill(t,G,n,i);if(x){t.fillStyle=x,t.beginPath();const q=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.fill()}const U=e.borderWidth??0;if(U>0){const q=this.createCanvasFill(t,e.borderColor||"#cccccc",n,i);t.strokeStyle=q||"#cccccc",t.lineWidth=U,t.beginPath();const N=this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l);t.stroke()}}t.shadowBlur=0;const A=e.clipContent!==!1&&e.listLayout!=="circular";if(A)if(t.save(),t.beginPath(),this.drawCustomShape(t,e.containerShape||"rectangle",e.containerPath||"",a,r,n,i,l)&&e.containerShape==="custom")try{const x=new Path2D(e.containerPath);t.translate(a,r),t.scale(n/100,i/100),t.clip(x),t.scale(100/n,100/i),t.translate(-a,-r)}catch{}else t.clip();const D=typeof m=="number"?m:d==="vertical"?m[0]:m[3];let Y=(d==="vertical"?r:a)+h+D;if(t.textBaseline="middle",p.forEach((G,x)=>{var ut,$t,St,Pt;const U=e.listLayout||"linear",q=U==="circular"?f:d==="vertical"?n:f,N=U==="circular"||d==="vertical"?u:i;let H=0,z=0,et=0;if(U==="circular"){const Ft=p.length||1,lt=Math.PI*2/Ft,ht=e.circularStartAngle||0,dt=e.circularRadius||100,At=h*.01+ht*Math.PI/180,Tt=x*lt+At,Ct=a+n/2,Yt=r+i/2;H=Ct+Math.cos(Tt)*dt-q/2,z=Yt+Math.sin(Tt)*dt-N/2,et=Tt+(e.itemRotation||0)*Math.PI/180}else H=d==="vertical"?a:Y,z=d==="vertical"?Y:r,et=(e.itemRotation||0)*Math.PI/180;const Mt=C===x,ct=w===x,It=e.itemBorderWidth??0;t.save(),et!==0&&(t.translate(H+q/2,z+N/2),t.rotate(et),t.translate(-(H+q/2),-(z+N/2)));const mt=Mt?((ut=e.hoverStyle)==null?void 0:ut.scale)??1:ct?(($t=e.activeStyle)==null?void 0:$t.scale)??1:1;if(mt!==1&&(t.translate(H+q/2,z+N/2),t.scale(mt,mt),t.translate(-(H+q/2),-(z+N/2))),ct){const Ft=((St=e.activeStyle)==null?void 0:St.itemBackgroundColor)||e.activeBackgroundColor||(b?"rgba(255, 255, 255, 0.15)":"rgba(0, 0, 0, 0.1)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.activeItemShape||e.itemShape||"rectangle",e.activeItemShape==="custom"?e.activeItemPath||"":e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(Mt){const Ft=((Pt=e.hoverStyle)==null?void 0:Pt.itemBackgroundColor)||e.hoverBackgroundColor||(b?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)"),lt=this.createCanvasFill(t,Ft,q,N);t.fillStyle=lt||(typeof Ft=="string"?Ft:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}else if(v!=="transparent"){const Ft=this.createCanvasFill(t,v,q,N);t.fillStyle=Ft||(typeof v=="string"?v:"transparent"),t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.fill()}if(It>0&&e.itemBorderColor&&e.itemBorderColor!=="transparent"){const Ft=this.createCanvasFill(t,e.itemBorderColor,q,N);t.strokeStyle=Ft||(typeof e.itemBorderColor=="string"?e.itemBorderColor:"#cccccc"),t.lineWidth=It,t.beginPath(),this.drawCustomShape(t,e.itemShape||"rectangle",e.itemPath||"",H,z,q,N,e.itemCornerRadius??0)||t.stroke()}if(ct){const Ft=this.createCanvasFill(t,c,d==="vertical"?3:q,d==="vertical"?N:3);t.fillStyle=Ft||c,d==="vertical"?t.fillRect(H,z,3,N):t.fillRect(H,z+N-3,q,3)}const kt=ct?"#ffffff":b?"rgba(255, 255, 255, 0.9)":S;t.fillStyle=kt,t.font=ct||Mt?"600 14px Inter, sans-serif":"400 14px Inter, sans-serif";const Ot=typeof G=="string"?G:(G==null?void 0:G.label)||`Item ${x+1}`,vt=H+(d==="vertical"?16:q/2),Wt=z+N/2;d==="horizontal"||U==="circular"?t.textAlign="center":t.textAlign="left";const J=U==="circular"?H+q/2:vt;t.fillText(Ot,J,Wt),t.restore(),t.beginPath(),Y+=(d==="vertical"?u:f)+g}),A&&t.restore(),e.showScrollbar!==!1){const G=typeof m=="number"?m:d==="vertical"?m[0]:m[3],U=(p.length||0)*(d==="vertical"?u:f)+Math.max(0,(p.length||0)-1)*g+G*2,q=d==="vertical"?i:n,N=e.listLayout||"linear",H=e.containerShape==="circle"||N==="circular",z=e.scrollbarColor||"rgba(255,255,255,0.3)";let et=typeof z=="object"?z.color||((P=(E=z.stops)==null?void 0:E[0])==null?void 0:P.color)||"rgba(255,255,255,0.3)":z;const Mt=((V=(_=this.artboard)==null?void 0:_.tokens)==null?void 0:V.colors)||{};Mt[et]&&(et=Mt[et]);const ct=e.scrollbarWidth||2;if(t.save(),H){const It=Math.min(n,i)/2-ct/2-2,mt=a+n/2,kt=r+i/2;if(t.strokeStyle=et,t.lineWidth=ct,t.lineCap="round",t.beginPath(),N==="circular"){const Ot=Math.PI/4,vt=-(h*.01)-Math.PI/2;t.arc(mt,kt,It,vt,vt+Ot)}else{const Ot=Math.PI/2,vt=U>0?Math.min(1,q/U):1,Wt=Ot*vt,J=U>0?-h/U*Ot:0,$t=-Math.PI/4+J;t.arc(mt,kt,It,$t,$t+Wt)}t.stroke()}else{let It=q,mt=0;if(U>q){const kt=q/U;It=Math.max(16,q*kt);const Ot=q-It,vt=U-q;mt=vt>0?Math.max(0,Math.min(Ot,-h/vt*Ot)):0}if(t.fillStyle=et,d==="vertical"){const kt=a+n-ct-2,Ot=r+mt,vt=ct,Wt=It;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else{const kt=a+mt,Ot=r+i-ct-2,vt=It,Wt=ct;if(ct>2){t.beginPath();const J=Math.min(ct/2,It/2);if(t.roundRect)try{t.roundRect(kt,Ot,vt,Wt,J),t.fill()}catch{t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}else t.fillRect(kt,Ot,vt,Wt)}}t.restore()}t.beginPath(),t.restore()}drawCustomShape(t,s,o,e,n,i,a,r){if(s==="circle"){const l=Math.min(i,a)/2;return t.arc(e+i/2,n+a/2,l,0,Math.PI*2),!1}else if(s==="pill"){const l=Math.min(i,a)/2;return this.drawListViewRect(t,e,n,i,a,l),!1}else if(s==="custom"&&o)try{const l=new Path2D(o);return t.save(),t.translate(e,n),t.scale(i/100,a/100),t.fill(l),t.restore(),!0}catch{return this.drawListViewRect(t,e,n,i,a,r),!1}return this.drawListViewRect(t,e,n,i,a,r),!1}updateListViewScrollFromPointer(t){var v,C,w,I;if(!this._lastPointerPos||!this._prevPointerPos)return;const s=this.objectStates.get(t.id);s&&!s.options&&(s.options=JSON.parse(JSON.stringify(t.options||{})));const o=(s==null?void 0:s.options)||t.options||{},e=o.orientation||"vertical",n=this._lastPointerPos.x-this._prevPointerPos.x,i=this._lastPointerPos.y-this._prevPointerPos.y;let a=o.scrollOffset||0;const r=this.getResolvedListViewItems(t,o),l=o.itemGap??10,d=o.itemHeight??50,p=o.itemWidth??200,g=(s==null?void 0:s.width)!==void 0?s.width:((v=t.geometry)==null?void 0:v.width)||200,u=(s==null?void 0:s.height)!==void 0?s.height:((C=t.geometry)==null?void 0:C.height)||300,f=typeof o.padding=="number"?o.padding:e==="vertical"?((w=o.padding)==null?void 0:w[0])||0:((I=o.padding)==null?void 0:I[3])||0,m=(r.length||0)*(e==="vertical"?d:p)+Math.max(0,(r.length||0)-1)*l+f*2,b=e==="vertical"?u:g,c=Math.max(0,m-b);if(this.draggingListViewIsScrollbar&&o.listLayout!=="circular"){const k=m>0?b/m:1,O=Math.max(16,b*k),T=Math.max(1,b-O),A=c>0?c/T:1;e==="vertical"?a-=i*A:a-=n*A}else e==="vertical"?a+=i:a+=n;if((o.listLayout||"linear")==="circular"){o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a);return}a>0&&(a=0),a<-c&&(a=-c),o.scrollOffset=a,s&&s.options&&(s.options.scrollOffset=a),t.options&&(t.options.scrollOffset=a)}updateListViewHoverFromPointer(t,s,o){const e=this.getListViewItemIndexAtPointer(t,s,o),n=this.objectStates.get(t.id);if(n&&n.options)n.options.hoveredIndex!==e&&(n.options.hoveredIndex=e);else{const i=t.options||{};i.hoveredIndex!==e&&(i.hoveredIndex=e)}}getListViewItemIndexAtPointer(t,s,o){var $,F;const e=this.objectStates.get(t.id),n=(e==null?void 0:e.options)||t.options||{},i=this.getResolvedListViewItems(t,n);if(i.length===0)return null;const a=(e==null?void 0:e.width)!==void 0?e.width:(($=t.geometry)==null?void 0:$.width)||200,r=(e==null?void 0:e.height)!==void 0?e.height:((F=t.geometry)==null?void 0:F.height)||300,l=n.orientation||"vertical",d=n.itemGap??10,p=n.itemHeight??50,g=n.itemWidth??200,u=n.scrollOffset??0,f=n.padding??0,h=this.getWorldTransform(t.id),m=s-h.x,b=o-h.y,c=-h.rotation*(Math.PI/180),S=Math.cos(c),v=Math.sin(c),C=m*S-b*v,w=m*v+b*S,I=-a/2,k=-r/2,O=typeof f=="number"?f:l==="vertical"?f[0]:f[3];let T=(l==="vertical"?k:I)+u+O;const A=n.listLayout||"linear",D=i.length||1,Y=Math.PI*2/D,B=n.circularStartAngle||0,R=n.circularRadius||100,L=u*.01+B*Math.PI/180;for(let X=0;X<i.length;X++){const M=A==="circular"?g:l==="vertical"?a:g,E=A==="circular"||l==="vertical"?p:r;let P=0,_=0,V=0;if(A==="circular"){const G=X*Y+L,x=I+a/2,U=k+r/2;P=x+Math.cos(G)*R-M/2,_=U+Math.sin(G)*R-E/2,V=G+(n.itemRotation||0)*Math.PI/180}else P=l==="vertical"?I:T,_=l==="vertical"?T:k,V=(n.itemRotation||0)*Math.PI/180;if(V!==0){const G=P+M/2,x=_+E/2,U=C-G,q=w-x,N=-V,H=U*Math.cos(N)-q*Math.sin(N)+G,z=U*Math.sin(N)+q*Math.cos(N)+x;if(H>=P&&H<=P+M&&z>=_&&z<=_+E)return X}else if(C>=P&&C<=P+M&&w>=_&&w<=_+E)return X;T+=(l==="vertical"?p:g)+d}return null}drawListViewRect(t,s,o,e,n,i){this.drawRoundRect(t,s,o,e,n,i)}solveBehaviors(t){if(!this.artboard)return;if(!this._lastPointerPos){this.frameCount%60;return}const{x:s,y:o}=this._lastPointerPos;this.artboard.objects.forEach(e=>{if(!e.behaviors||e.behaviors.length===0)return;const n=this.objectStates.get(e.id);n&&e.behaviors.forEach(i=>{var g,u,f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E,P,_,V,G,x,U,q,N,H,z,et,Mt,ct,It,mt,kt,Ot,vt,Wt,J,ut,$t,St,Pt,Ft,lt,ht,dt,At,Tt,Ct,Yt,ie,te,Zt,le,fe,qt,Se,Ce,Ie,de,Re,ye,ke,Vt,ee,j,bt,st,K,rt,ft,Rt,Qt,Kt,ae,Jt,Et,W,nt,Lt,tt,gt,Q,Ut,zt,yt,Bt,_t,Xt,Dt,ce,be,Le,oe,pe,he,$e,Be,Ye,De,Xe,Ne,Ue,re,ve,Te,He,Ve,_e,Pe;if(!i.enabled)return;const a=i.startTime||0,r=i.endTime||1/0;if(this.currentTime<a||this.currentTime>r)return;const l=n.x-s,d=n.y-o,p=Math.sqrt(l*l+d*d);if(this.frameCount%240===0&&Math.random()<.1&&this.log(`[ExodeUI] Executing ${i.type} on ${e.name}`),i.type===it.Proximity){const Z=((g=i.settings)==null?void 0:g.radius)||300,ot=((u=i.settings)==null?void 0:u.falloff)||"smooth";let at=0;p<Z&&(ot==="linear"?at=1-p/Z:at=Math.pow(1-p/Z,2)),i.sensors.forEach(wt=>{this.applyBehaviorSensor(n,wt,at,t,i.settings,e,l,d,p)})}else if(i.type===it.Magnetic){const Z=((f=i.settings)==null?void 0:f.radius)||400,ot=((h=i.settings)==null?void 0:h.strength)||.5;if(p<Z&&p>5){const at=1-p/Z,wt=l*at*ot,Gt=d*at*ot;n.x-=wt*t*10,n.y-=Gt*t*10}}else if(i.type===it.Repel){const Z=((m=i.settings)==null?void 0:m.radius)||300,ot=((b=i.settings)==null?void 0:b.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x+=l/(p||1)*at*60*ot*t*5,n.y+=d/(p||1)*at*60*ot*t*5}}else if(i.type===it.Orbit){const Z=((c=i.settings)==null?void 0:c.speed)||1,ot=((S=i.settings)==null?void 0:S.radius)||30,at=this.currentTime*Z*Math.PI*2;n.x+=Math.cos(at)*ot*t*5,n.y+=Math.sin(at)*ot*t*5,n.rotation+=2*t*5}else if(i.type===it.Vortex){const Z=((v=i.settings)==null?void 0:v.radius)||400,ot=((C=i.settings)==null?void 0:C.speed)||2,at=((w=i.settings)==null?void 0:w.strength)||1;if(p<Z){const wt=Math.pow(1-p/Z,1.5),Gt=this.currentTime*ot*Math.PI*2,xt=Math.cos(Gt)*30-l*.4,jt=Math.sin(Gt)*30-d*.4;n.x+=xt*wt*at*t*5,n.y+=jt*wt*at*t*5,n.rotation+=5*wt*at*t*5,n.scale_x*=1-wt*.1*at*t,n.scale_y*=1-wt*.1*at*t}}else if(i.type===it.Fluid){const Z=((I=i.settings)==null?void 0:I.radius)||300,ot=((k=i.settings)==null?void 0:k.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,1.2),wt=l/(p||1)*at*1.2*ot,Gt=d/(p||1)*at*1.2*ot;n.x+=wt*10*t*5,n.y+=Gt*10*t*5,n.scale_x*=1+at*.3*ot*t,n.scale_y*=1+at*.3*ot*t}}else if(i.type===it.Elastic){const Z=((O=i.settings)==null?void 0:O.radius)||300,ot=((T=i.settings)==null?void 0:T.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.4*ot*t,n.scale_y*=1+at*.4*ot*t}}else if(i.type===it.Holographic){const Z=n.x-this.canvasWidth/2,ot=n.y-this.canvasHeight/2,at=((A=i.settings)==null?void 0:A.factor)||25;if(n.x-=Z/1e3*at*t*5,n.y-=ot/1e3*at*t*5,n.style){const wt=1-Math.min(1,p/400);n.style.exposure=(n.style.exposure||1)+wt*.5*t}}else if(i.type===it.Sticky){const Z=((D=i.settings)==null?void 0:D.radius)||80,ot=((Y=i.settings)==null?void 0:Y.strength)||1;if(p<Z){const at=Math.pow(1-p/Z,2);n.x-=l*at*ot*t*10,n.y-=d*at*ot*t*10,n.scale_x*=1-at*.1*ot*t,n.scale_y*=1-at*.1*ot*t}}else if(i.type===it.Dilation){const Z=((B=i.settings)==null?void 0:B.size)||120,ot=((R=i.settings)==null?void 0:R.strength)||1;if(p<Z){const at=1-p/Z;n.scale_x*=1+at*.5*ot*t,n.scale_y*=1+at*.5*ot*t}}else if(i.type===it.Parallax){const Z=((L=i.settings)==null?void 0:L.factor)||15,ot=(($=i.settings)==null?void 0:$.strength)||1,at=this.canvasWidth/2,wt=this.canvasHeight/2,Gt=this._lastPointerPos||{x:at,y:wt},xt=(Gt.x-at)/at,jt=(Gt.y-wt)/wt,me=(((F=e.transform)==null?void 0:F.x)??0)+xt*Z*ot,Ae=(((X=e.transform)==null?void 0:X.y)??0)+jt*Z*ot,Fe=(((M=e.transform)==null?void 0:M.rotate_x)??0)-jt*Z*1.5*ot,we=(((E=e.transform)==null?void 0:E.rotate_y)??0)+xt*Z*1.5*ot,Oe=Math.min(1,10*t);n.x=this.lerp(n.x??((P=e.transform)==null?void 0:P.x)??0,me,Oe),n.y=this.lerp(n.y??((_=e.transform)==null?void 0:_.y)??0,Ae,Oe),n.rotate_x=this.lerp(n.rotate_x??((V=e.transform)==null?void 0:V.rotate_x)??0,Fe,Oe),n.rotate_y=this.lerp(n.rotate_y??((G=e.transform)==null?void 0:G.rotate_y)??0,we,Oe)}else if(i.type===it.Fold){if(p<300){const Z=1-p/300,ot=(l>0?-1:1)*Z*10,at=1-Z*.1,wt=d/300*Z*20,Gt=-(l/300)*Z*20,xt=Math.min(1,10*t);n.skew_x=this.lerp(n.skew_x??((x=e.transform)==null?void 0:x.skew_x)??0,ot,xt),n.scale_y=this.lerp(n.scale_y??((U=e.transform)==null?void 0:U.scale_y)??1,(((q=e.transform)==null?void 0:q.scale_y)??1)*at,xt),n.rotate_x=this.lerp(n.rotate_x??((N=e.transform)==null?void 0:N.rotate_x)??0,wt,xt),n.rotate_y=this.lerp(n.rotate_y??((H=e.transform)==null?void 0:H.rotate_y)??0,Gt,xt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"fold_overlay",intensity:((z=i.settings)==null?void 0:z.opacity)??.5}}}else if(i.type===it.Crumple){if(p<300){const Z=1-p/300,ot=Z*(Math.random()-.5)*5,at=Z*(Math.random()-.5)*.05,wt=Math.min(1,15*t);n.skew_x=this.lerp(n.skew_x??((et=e.transform)==null?void 0:et.skew_x)??0,ot,wt),n.scale_x=this.lerp(n.scale_x??((Mt=e.transform)==null?void 0:Mt.scale_x)??1,(((ct=e.transform)==null?void 0:ct.scale_x)??1)*(1+at),wt),n.scale_y=this.lerp(n.scale_y??((It=e.transform)==null?void 0:It.scale_y)??1,(((mt=e.transform)==null?void 0:mt.scale_y)??1)*(1+at),wt),n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"crumple_overlay",intensity:((kt=i.settings)==null?void 0:kt.intensity)??1,scale:((Ot=i.settings)==null?void 0:Ot.scale)??2}}}else if(i.type===it.Squash){const Z=((vt=i.settings)==null?void 0:vt.strength)||.8;p<(e.width||100)&&this.isMouseDown?(n.scale_y=this.lerp(n.scale_y??1,(((Wt=e.transform)==null?void 0:Wt.scale_y)??1)*Z,.3),n.scale_x=this.lerp(n.scale_x??1,(((J=e.transform)==null?void 0:J.scale_x)??1)*(1+(1-Z)*.4),.3)):(n.scale_y=this.lerp(n.scale_y??1,((ut=e.transform)==null?void 0:ut.scale_y)??1,.2),n.scale_x=this.lerp(n.scale_x??1,(($t=e.transform)==null?void 0:$t.scale_x)??1,.2))}else if(i.type===it.TextCounter){const Z=((St=i.settings)==null?void 0:St.duration)||2,ot=((Pt=i.settings)==null?void 0:Pt.from)||0,at=((Ft=i.settings)==null?void 0:Ft.to)||100;i._runtimeStart===void 0&&(i._runtimeStart=this.currentTime);const wt=this.currentTime-i._runtimeStart,Gt=Math.min(1,wt/Z),xt=Math.floor(ot+(at-ot)*Gt);if(((lt=e.geometry)==null?void 0:lt.type)==="Text"){const jt=((ht=i.settings)==null?void 0:ht.prefix)||"",me=((dt=i.settings)==null?void 0:dt.suffix)||"";n.geometry||(n.geometry={...e.geometry}),n.geometry.text=`${jt}${xt}${me}`}}else if(i.type===it.Spotlight){const Z=((At=i.settings)==null?void 0:At.radius)||250,ot=((Tt=i.settings)==null?void 0:Tt.strength)||1.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.style||(n.style={...e.style}),n.style.adjustments||(n.style.adjustments={...(Ct=e.style)==null?void 0:Ct.adjustments}),n.style.adjustments.exposure=(((ie=(Yt=e.style)==null?void 0:Yt.adjustments)==null?void 0:ie.exposure)||0)+at*ot*50}else(te=n.style)!=null&&te.adjustments&&(n.style.adjustments.exposure=this.lerp(n.style.adjustments.exposure||0,((le=(Zt=e.style)==null?void 0:Zt.adjustments)==null?void 0:le.exposure)||0,.1))}else if(i.type===it.Noise||i.type===it.Float){const Z=(((fe=i.settings)==null?void 0:fe.frequency)||((qt=i.settings)==null?void 0:qt.speed)||1)*.002,ot=(((Se=i.settings)==null?void 0:Se.amplitude)||((Ce=i.settings)==null?void 0:Ce.range)||50)*(((Ie=i.settings)==null?void 0:Ie.strength)||1),at=Date.now();n.x+=Math.sin(at*Z)*ot*t,n.y+=Math.cos(at*Z*.8)*ot*t,n.rotation+=Math.sin(at*Z*.5)*5*t}else if(i.type===it.Pulse){const Z=(((de=i.settings)==null?void 0:de.speed)||1)*.005,ot=(((Re=i.settings)==null?void 0:Re.scale)||1.2)-1,at=Math.sin(Date.now()*Z),wt=((ye=i.settings)==null?void 0:ye.strength)||1;n.scale_x*=1+at*ot*wt*t,n.scale_y*=1+at*ot*wt*t,n.style&&(n.style.exposure=(n.style.exposure||1)+Math.max(0,at)*.1*wt*t)}else if(i.type===it.Draggable){if(!this.draggingBehaviors.has(e.id)){const ot=((ke=i.settings)==null?void 0:ke.radius)||150;if(p<ot){const at=((Vt=i.settings)==null?void 0:Vt.strength)||1,wt=Math.max(0,1-p/ot);this.applyBehaviorSensor(n,ge.PositionX,wt*at,t,i.settings,e,l,d,p),this.applyBehaviorSensor(n,ge.PositionY,wt*at,t,i.settings,e,l,d,p)}}}else if(i.type===it.Scroll){const Z=((ee=i.settings)==null?void 0:ee.axis)||"vertical",ot=((j=i.settings)==null?void 0:j.factor)||.5,at=((bt=i.settings)==null?void 0:bt.strength)||1,wt=((st=i.settings)==null?void 0:st.scaleFactor)||0;(Z==="vertical"||Z==="both")&&(n.y+=this.scrollOffset.y*ot*at*t),(Z==="horizontal"||Z==="both")&&(n.x+=this.scrollOffset.x*ot*at*t),wt!==0&&(n.scale_x*=1+this.scrollOffset.y*wt*t,n.scale_y*=1+this.scrollOffset.y*wt*t)}else if(i.type===it.LookAt){const Z=((K=i.settings)==null?void 0:K.factor)||1,ot=((rt=i.settings)==null?void 0:rt.strength)||1,at=Math.atan2(-d,-l)*(180/Math.PI),wt=n.rotation,Gt=(at-wt+180)%360-180;n.rotation+=Gt*Z*ot*t*10}else if(i.type===it.Scan){const Z=(((ft=i.settings)==null?void 0:ft.speed)||1)*.004,ot=((Rt=i.settings)==null?void 0:Rt.strength)||1,at=(Math.sin(Date.now()*Z)+1)/2;n.style&&(n.style.exposure=(n.style.exposure||1)+at*ot*t*5),n.x+=(at-.5)*20*ot*t}else if(i.type===it.Glint)n.style=n.style||{...e.style},n.style.artEffect={enabled:!0,type:"glint_overlay",intensity:((Qt=i.settings)==null?void 0:Qt.strength)??.8};else if(i.type===it.Ratchet){const Z=((Kt=i.settings)==null?void 0:Kt.steps)||12,ot=(((ae=i.settings)==null?void 0:ae.speed)||1)*30,at=Math.floor(n.rotation/(360/Z))*(360/Z);n.rotation=this.lerp(n.rotation,at+ot*t,.1)}else if(i.type===it.Jitter&&p<300){const Z=((Jt=i.settings)==null?void 0:Jt.strength)||1,ot=(((Et=i.settings)==null?void 0:Et.intensity)||5)*Z;n.x+=(Math.random()-.5)*ot*t*60,n.y+=(Math.random()-.5)*ot*t*60,n.rotation+=(Math.random()-.5)*ot*t*120}else if(i.type===it.Follower){const Z=(W=i.settings)==null?void 0:W.targetId;if(Z){const ot=this.objectStates.get(Z);if(ot){const at=((nt=i.settings)==null?void 0:nt.stiffness)||.1,wt=ot.x-n.x,Gt=ot.y-n.y;n.x+=wt*at*t*60,n.y+=Gt*at*t*60}}}else if(i.type===it.Wrap)n.x<0?n.x=this.canvasWidth:n.x>this.canvasWidth&&(n.x=0),n.y<0?n.y=this.canvasHeight:n.y>this.canvasHeight&&(n.y=0);else if(i.type===it.Gravity){const Z=((Lt=i.settings)==null?void 0:Lt.strength)||9.8;n.y+=Z*t*10}else if(i.type===it.Velocity){const Z=((tt=i.settings)==null?void 0:tt.vx)||0,ot=((gt=i.settings)==null?void 0:gt.vy)||0;n.x+=Z*t*10,n.y+=ot*t*10}else if(i.type===it.Shear){const Z=((Q=i.settings)==null?void 0:Q.strength)||1,ot=((Ut=i.settings)==null?void 0:Ut.radius)||300;if(p<ot){const at=1-p/ot;n.skew_x=this.lerp(n.skew_x||0,(((zt=e.transform)==null?void 0:zt.skew_x)||0)+at*Z*30,.1)}else n.skew_x=this.lerp(n.skew_x||0,((yt=e.transform)==null?void 0:yt.skew_x)||0,.05)}else if(i.type===it.Lens){const Z=((Bt=i.settings)==null?void 0:Bt.radius)||200,ot=((_t=i.settings)==null?void 0:_t.strength)||.5;if(p<Z){const at=Math.pow(1-p/Z,2);n.scale_x=this.lerp(n.scale_x??1,(((Xt=e.transform)==null?void 0:Xt.scale_x)??1)*(1+at*ot),.2),n.scale_y=this.lerp(n.scale_y??1,(((Dt=e.transform)==null?void 0:Dt.scale_y)??1)*(1+at*ot),.2)}else n.scale_x=this.lerp(n.scale_x??1,((ce=e.transform)==null?void 0:ce.scale_x)??1,.1),n.scale_y=this.lerp(n.scale_y??1,((be=e.transform)==null?void 0:be.scale_y)??1,.1)}else if(i.type===it.LayoutAnimation){const Z=((Le=i.settings)==null?void 0:Le.watchProperties)||["x","y","scale_x","scale_y","opacity","rotation"],ot=((oe=i.settings)==null?void 0:oe.duration)||.3;this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const at=this._layoutAnimCache.get(e.id);for(const wt of Z){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0)continue;const xt=at.get(wt);if(!xt)at.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);at.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:((pe=i.settings)==null?void 0:pe.duration)??ot})}const jt=at.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((he=i.settings)==null?void 0:he.easing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.StateReactive){this._layoutAnimCache.has(e.id)||this._layoutAnimCache.set(e.id,new Map);const Z=this._layoutAnimCache.get(e.id),ot=(($e=i.settings)==null?void 0:$e.defaultDuration)||.3,at=["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 wt of at){const Gt=this.getObjectProperty(n,e,wt);if(Gt===void 0||typeof Gt!="number")continue;const xt=Z.get(wt);if(!xt)Z.set(wt,{from:Gt,to:Gt,startTime:this.currentTime,duration:0});else if(xt.to!==Gt){const me=this.getObjectProperty(n,e,wt);Z.set(wt,{from:me??xt.from,to:Gt,startTime:this.currentTime,duration:ot})}const jt=Z.get(wt);if(jt.duration>0&&jt.from!==jt.to){const me=this.currentTime-jt.startTime,Ae=Math.min(1,me/jt.duration),Fe=this.applyEasing(Ae,((Be=i.settings)==null?void 0:Be.defaultEasing)||"easeOutCubic"),we=jt.from+(jt.to-jt.from)*Fe;this.setObjectProperty(n,e,wt,we)}}}else if(i.type===it.SpringChain){const Z=((Ye=i.settings)==null?void 0:Ye.connections)||[],ot=((De=i.settings)==null?void 0:De.globalDamping)||.3;this._springChainState.has(e.id)||this._springChainState.set(e.id,new Map);const at=this._springChainState.get(e.id);for(const Gt of Z){if(!at.has(Gt.targetId)){const xt=this.objectStates.get(Gt.targetId);at.set(Gt.targetId,{x:(xt==null?void 0:xt.x)??0,y:(xt==null?void 0:xt.y)??0,vx:0,vy:0})}at.has(e.id)||at.set(e.id,{x:n.x,y:n.y,vx:0,vy:0})}const wt=at.get(e.id);if(wt){wt.x=n.x,wt.y=n.y;for(const Gt of Z){const xt=at.get(Gt.targetId);if(!xt)continue;const jt=xt.x-wt.x,me=xt.y-wt.y,Ae=Math.sqrt(jt*jt+me*me)||.001,we=(Ae-(Gt.restLength||50))*(Gt.stiffness||.8),Oe=jt/Ae*we,je=me/Ae*we;wt.vx+=Oe*t*10,wt.vy+=je*t*10,xt.vx-=Oe*t*10,xt.vy-=je*t*10,wt.vx*=1-ot*t*10,wt.vy*=1-ot*t*10,xt.vx*=1-ot*t*10,xt.vy*=1-ot*t*10;const Ee=this.objectStates.get(Gt.targetId);Ee&&(Ee.x+=xt.vx*t,Ee.y+=xt.vy*t)}n.x+=wt.vx*t,n.y+=wt.vy*t}}else if(i.type===it.ParticleEmitter){const Z=((Xe=i.settings)==null?void 0:Xe.rate)||10,ot=((Ne=i.settings)==null?void 0:Ne.speed)||100,at=((Ue=i.settings)==null?void 0:Ue.size)||5,wt=((re=i.settings)==null?void 0:re.lifetime)||2,Gt=((ve=i.settings)==null?void 0:ve.gravity)||0,xt=((Te=i.settings)==null?void 0:Te.color)||"#ffffff",jt=((He=i.settings)==null?void 0:He.maxParticles)||200,me=(Ve=i.settings)!=null&&Ve.rateInputId?this.inputs.get(i.settings.rateInputId)??Z:Z,Ae=(_e=i.settings)!=null&&_e.gravityInputId?this.inputs.get(i.settings.gravityInputId)??Gt:Gt,Fe=(Pe=i.settings)!=null&&Pe.speedInputId?this.inputs.get(i.settings.speedInputId)??ot:ot;this._emitterPools.has(e.id)||this._emitterPools.set(e.id,[]);const we=this._emitterPools.get(e.id);let Oe=0;i._pendingBurst&&i._pendingBurst>0&&(Oe=i._pendingBurst,i._pendingBurst=0);const je=Math.floor(me*t)+(Oe||0);for(let Ee=0;Ee<Math.min(je,jt-we.length);Ee++){const Me=Math.random()*Math.PI*2,vs=Fe*(.5+Math.random()*.5);we.push({x:n.x,y:n.y,vx:Math.cos(Me)*vs,vy:Math.sin(Me)*vs,life:0,maxLife:wt*(.5+Math.random()*.5),size:at*(.5+Math.random()),color:xt,opacity:1})}for(let Ee=we.length-1;Ee>=0;Ee--){const Me=we[Ee];Me.vy+=Ae*t*10,Me.x+=Me.vx*t,Me.y+=Me.vy*t,Me.life+=t,Me.opacity=Math.max(0,1-Me.life/Me.maxLife),Me.life>=Me.maxLife&&we.splice(Ee,1)}}})})}applyBehaviorSensor(t,s,o,e,n,i,a=0,r=0,l=1){var f,h,m,b,c,S,v,C,w,I,k,O,T,A,D,Y,B,R,L,$,F,X,M,E;const d=(n==null?void 0:n.intensity)||(n==null?void 0:n.strength)||1,p=Math.min(1,15*e),g=l>0?a/l:0,u=l>0?r/l:0;switch(s){case ge.Scale:{const P=((f=i==null?void 0:i.transform)==null?void 0:f.scale_x)??1,_=((h=i==null?void 0:i.transform)==null?void 0:h.scale_y)??1,V=P*(1+o*d*.4),G=_*(1+o*d*.4);t.scale_x=(t.scale_x??P)*(1-p)+V*p,t.scale_y=(t.scale_y??_)*(1-p)+G*p;break}case ge.Opacity:{const P=((m=i==null?void 0:i.transform)==null?void 0:m.opacity)??100,_=Math.max(0,Math.min(100,P-o*d*100));t.opacity=(t.opacity??P)*(1-p)+_*p;break}case ge.RotateZ:{const P=((b=i==null?void 0:i.transform)==null?void 0:b.rotation)??0,_=P+o*d*45;t.rotation=(t.rotation??P)*(1-p)+_*p;break}case ge.RotateX:{const P=((c=i==null?void 0:i.transform)==null?void 0:c.rotate_x)??0,_=P-u*o*d*60;t.rotate_x=(t.rotate_x??P)*(1-p)+_*p;break}case ge.RotateY:{const P=((S=i==null?void 0:i.transform)==null?void 0:S.rotate_y)??0,_=P+g*o*d*60;t.rotate_y=(t.rotate_y??P)*(1-p)+_*p;break}case ge.PositionX:{const P=((v=i==null?void 0:i.transform)==null?void 0:v.x)??0,_=P-g*o*d*40;t.x=(t.x??P)*(1-p)+_*p;break}case ge.PositionY:{const P=((C=i==null?void 0:i.transform)==null?void 0:C.y)??0,_=P-u*o*d*40;t.y=(t.y??P)*(1-p)+_*p;break}case ge.SkewX:{const P=((w=i==null?void 0:i.transform)==null?void 0:w.skew_x)??0,_=P+g*o*d*45;t.skew_x=(t.skew_x??P)*(1-p)+_*p,t.skew_x>85&&(t.skew_x=85),t.skew_x<-85&&(t.skew_x=-85);break}case ge.Blur:{t.style||(t.style={...i==null?void 0:i.style}),t.style.blur||(t.style.blur={...(I=i==null?void 0:i.style)==null?void 0:I.blur});const P=((O=(k=i==null?void 0:i.style)==null?void 0:k.blur)==null?void 0:O.amount)||0,_=P+o*((n==null?void 0:n.blur)||20)*d;t.style.blur.amount=(t.style.blur.amount??P)*(1-p)+_*p;break}case ge.Exposure:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(T=i==null?void 0:i.style)==null?void 0:T.adjustments});const P=((D=(A=i==null?void 0:i.style)==null?void 0:A.adjustments)==null?void 0:D.exposure)||0,_=P+o*((n==null?void 0:n.exposure)||50)*d;t.style.adjustments.exposure=(t.style.adjustments.exposure??P)*(1-p)+_*p;break}case ge.HueShift:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(Y=i==null?void 0:i.style)==null?void 0:Y.adjustments});const P=((R=(B=i==null?void 0:i.style)==null?void 0:B.adjustments)==null?void 0:R.hue)||0,_=P+o*((n==null?void 0:n.hue)||180)*d;t.style.adjustments.hue=(t.style.adjustments.hue??P)*(1-p)+_*p;break}case ge.Negative:{t.style||(t.style={...i==null?void 0:i.style}),t.style.adjustments||(t.style.adjustments={...(L=i==null?void 0:i.style)==null?void 0:L.adjustments});const P=((F=($=i==null?void 0:i.style)==null?void 0:$.adjustments)==null?void 0:F.negative)||0,_=P+o*((n==null?void 0:n.negative)||100)*d;t.style.adjustments.negative=(t.style.adjustments.negative??P)*(1-p)+_*p;break}case ge.CornerRadius:{const P=((X=i==null?void 0:i.transform)==null?void 0:X.corner_radius)||0,_=P+o*d*50;t.corner_radius=(t.corner_radius??P)*(1-p)+_*p;break}case ge.StrokeWidth:{t.style||(t.style={...i==null?void 0:i.style});const P=((M=i==null?void 0:i.style)==null?void 0:M.borderWidth)||0,_=P+o*d*10;t.style.borderWidth=(t.style.borderWidth??P)*(1-p)+_*p;break}case ge.LetterSpacing:{t.geometry||(t.geometry={});const P=((E=i==null?void 0:i.geometry)==null?void 0:E.letterSpacing)||0,_=P+o*d*10;t.geometry.letterSpacing=(t.geometry.letterSpacing??P)*(1-p)+_*p;break}}}getObjectProperty(t,s,o){const e=o.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(const i of e){if(n==null||typeof n!="object")return;if(i==="style"&&t.style===void 0){n=s.style;continue}n=n[i]}return typeof n=="number"?n:void 0}setObjectProperty(t,s,o,e){const n=o.replace(/\[(\d+)\]/g,".$1").split(".");let i=t;for(let r=0;r<n.length-1;r++){const l=n[r];if(i[l]===void 0||i[l]===null){const d=s,p=n.slice(0,r+1).reduce((f,h)=>f==null?void 0:f[h],d),g=n[r+1],u=!isNaN(Number(g));i[l]=p!==void 0?Array.isArray(p)?[...p]:{...p}:u?[]:{}}i=i[l]}const a=n[n.length-1];i!=null&&(i[a]=e)}applyEasing(t,s){switch(s){case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInCubic":return t*t*t;case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeOutQuad":return t*(2-t);case"easeInQuad":return t*t;case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeOutExpo":return t===1?1:1-Math.pow(2,-10*t);case"easeOutBack":return 1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2);case"easeOutElastic":{const o=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*o)+1}case"easeOutBounce":return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375;case"linear":return t;default:return 1-Math.pow(1-t,3)}}lerp(t,s,o){return t*(1-o)+s*o}deepMerge(t,s){if(!t)return s;if(!s)return t;if(typeof t!="object"||typeof s!="object"||t===null||s===null)return s;if(Array.isArray(s)){if(!Array.isArray(t))return s;const e=[...t];for(let n=0;n<s.length;n++)s[n]&&typeof s[n]=="object"&&!Array.isArray(s[n])&&t[n]&&typeof t[n]=="object"?e[n]=this.deepMerge(t[n],s[n]):e[n]=s[n];return e}const o={...t};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]&&typeof s[e]=="object"&&!Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):Array.isArray(s[e])?o[e]=this.deepMerge(t[e],s[e]):o[e]=s[e]);return o}processFabricAdjustmentsCanvas(t,s,o,e){if(!e)return t;const n=(e.exposure||0)/100,i=(e.contrast||0)/100,a=(e.saturation||0)/100,r=(e.temperature||0)/200,l=(e.tint||0)/200,d=(e.highlights||0)/500,p=(e.shadows||0)/500,g=e.hue||0,u=(e.negative||0)/100,f=e.blur||0;if(!(n!==0||i!==0||a!==0||r!==0||l!==0||d!==0||p!==0||g!==0||u!==0||f>0))return t;const m=t.naturalWidth||Math.max(1,Math.round(s)),b=t.naturalHeight||Math.max(1,Math.round(o)),c=document.createElement("canvas");c.width=m,c.height=b;const S=c.getContext("2d");if(!S)return t;const v=[];f>0&&v.push(`blur(${f}px)`),g!==0&&v.push(`hue-rotate(${Math.round(g)}deg)`),v.length>0&&(S.filter=v.join(" ")),S.drawImage(t,0,0,m,b);try{const C=S.getImageData(0,0,m,b),w=C.data,I=w.length,k=n*255,O=i>=0?(1+i)/Math.max(.01,1-i):1+i,T=1+a,A=1+r-l/2,D=1+l,Y=1-r-l/2,B=1+d+p,R=p*25.5,L=1-u/50,$=(1-L)*255;for(let F=0;F<I;F+=4){let X=w[F],M=w[F+1],E=w[F+2];if(n!==0&&(X+=k,M+=k,E+=k),i!==0&&(X=(X-127.5)*O+127.5,M=(M-127.5)*O+127.5,E=(E-127.5)*O+127.5),a!==0){const P=.2989*X+.587*M+.114*E;X=P+(X-P)*T,M=P+(M-P)*T,E=P+(E-P)*T}(r!==0||l!==0)&&(X=X*A,M=M*D,E=E*Y),(d!==0||p!==0)&&(X=X*B+R,M=M*B+R,E=E*B+R),u!==0&&(X=X*L+$,M=M*L+$,E=E*L+$),w[F]=Math.min(255,Math.max(0,X)),w[F+1]=Math.min(255,Math.max(0,M)),w[F+2]=Math.min(255,Math.max(0,E))}return S.putImageData(C,0,0),c}catch{return c}}renderFittedImage(t,s,o,e,n,i,a="cover"){const r=s.naturalWidth||s.width||n,l=s.naturalHeight||s.height||i,d=r/l,p=n/i;let g=n,u=i,f=o,h=e;a==="cover"?d>p?(g=i*d,f=o-(g-n)/2):(u=n/d,h=e-(u-i)/2):a==="contain"&&(d>p?(u=n/d,h=e+(i-u)/2):(g=i*d,f=o+(n-g)/2)),t.drawImage(s,f,h,g,u)}}const li=Nt.forwardRef(({artboard:y,src:t,style:s,autoPlay:o=!0,fit:e="Contain",alignment:n="Center",onReady:i,onTrigger:a,onInputUpdate:r,onComponentChange:l,onToggle:d,onInputChange:p,onInputFocus:g,onInputBlur:u,onLog:f,onLogicUpdate:h,onButtonClick:m,onGraphPointClick:b,currentTime:c,revision:S=0,scrollY:v,scrollX:C,mouseX:w,mouseY:I,isMouseDown:k,inputs:O,interactive:T=!0,onNavigation:A},D)=>{const Y=Nt.useRef(null),B=Nt.useRef(null);B.current||(B.current=new bs);const R=Nt.useRef(void 0),L=Nt.useRef(0),$=Nt.useRef(null),F=Nt.useRef(S),X=Nt.useRef(null),[,M]=Nt.useState(y||null),E=Nt.useRef(!0),P=Nt.useRef(o),_=Nt.useRef(c);Nt.useEffect(()=>{P.current=o},[o]),Nt.useEffect(()=>{_.current=c},[c]),Nt.useImperativeHandle(D,()=>Y.current),Nt.useEffect(()=>(E.current=!0,()=>{E.current=!1,R.current&&cancelAnimationFrame(R.current)}),[]),Nt.useEffect(()=>{B.current.setLayout(e,n)},[e,n]),Nt.useEffect(()=>{const N=B.current;a&&N.setTriggerCallback(a),r&&N.setInputUpdateCallback((H,z)=>r({[H]:z})),l&&N.setComponentChangeCallback(H=>l(H)),d&&N.setToggleCallback(d),p&&N.setInputChangeCallback(p),g&&N.setInputFocusCallback(g),u&&N.setInputBlurCallback(u),f&&N.setOnLogCallback(H=>f(H,"info")),h&&N.setLogicUpdateCallback(h),m&&N.setButtonClickCallback(m),b&&N.setGraphPointClickCallback(H=>b(H.objectId,H)),A&&N.setNavigationCallback(A)},[a,r,l,d,p,g,u,f,h,m,b,A]),Nt.useEffect(()=>{(async()=>{let H=y;if(t&&!y)try{t.startsWith("{")?H=JSON.parse(t):H=await(await fetch(t)).json()}catch(z){console.error("[ExodeUI] Failed to load src:",z)}if(H){const z=B.current,et=H.id||H.name||"default";($.current!==et||F.current!==S||X.current!==H)&&(z.load(H),$.current=et,F.current=S,X.current=H,M(H),L.current=-1,z.advance(0)),i&&i(z)}})()},[y,t,S]),Nt.useEffect(()=>{const N=H=>{if(!B.current||!E.current)return;const z=B.current,et=Y.current;if(!et)return;const Mt=et.getContext("2d");if(!Mt)return;const ct=H/1e3;L.current<0&&(L.current=ct),L.current===0&&(L.current=ct);let It=ct-L.current;It>.1&&(It=.1),L.current=ct;const mt=et.getBoundingClientRect(),kt=window.devicePixelRatio||1,Ot=Math.round(mt.width*kt),vt=Math.round(mt.height*kt);(et.width!==Ot||et.height!==vt)&&(et.width=Ot,et.height=vt);try{P.current?z.advance(It):_.current!==void 0&&z.seek(_.current),z.render(Mt,et.width,et.height)}catch(Wt){console.error("[ExodeUICanvas] Error in animation loop:",Wt),f&&f(`[Error] Animation loop crashed: ${Wt}`,"error")}R.current=requestAnimationFrame(N)};return R.current=requestAnimationFrame(N),()=>{R.current&&cancelAnimationFrame(R.current)}},[]),Nt.useEffect(()=>{const N=B.current;v!==void 0&&N.updateInput("scrollY",v),C!==void 0&&N.updateInput("scrollX",C),w!==void 0&&N.updateInput("mouseX",w),I!==void 0&&N.updateInput("mouseY",I),k!==void 0&&N.updateInput("isMouseDown",k),O&&Object.entries(O).forEach(([H,z])=>N.updateInput(H,z))},[v,C,w,I,k,O]);const V=(N,H)=>{var mt,kt,Ot;if(!T||!Y.current)return;N.stopPropagation(),"nativeEvent"in N&&N.nativeEvent&&typeof N.nativeEvent.stopImmediatePropagation=="function"?N.nativeEvent.stopImmediatePropagation():typeof N.stopImmediatePropagation=="function"&&N.stopImmediatePropagation();const z=Y.current,et=z.getBoundingClientRect(),Mt=N.clientX-et.left,ct=N.clientY-et.top,It=window.devicePixelRatio||1;if((H==="click"||H==="down"||H==="up")&&f&&f(`[Canvas] Pointer ${H} at rect(${Math.round(Mt)},${Math.round(ct)}) mapped to buffer(${Math.round(Mt*It)},${Math.round(ct*It)})`,"info"),B.current.handlePointerInput(H,Mt*It,ct*It,z.width,z.height),H==="move"){const vt=(mt=B.current)==null?void 0:mt.getLastHoveredObject();vt?(kt=B.current)!=null&&kt.isInputBoxObject(vt)?z.style.cursor="text":(Ot=B.current)!=null&&Ot.isClickableObject(vt)?z.style.cursor="pointer":z.style.cursor="default":z.style.cursor="default"}else H==="blur"&&(z.style.cursor="default")};Nt.useEffect(()=>{if(!T)return;const N=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyDown(z)},H=z=>{var et,Mt,ct;((et=document.activeElement)==null?void 0:et.tagName)==="INPUT"||((Mt=document.activeElement)==null?void 0:Mt.tagName)==="TEXTAREA"||(ct=B.current)==null||ct.handleKeyUp(z)};return window.addEventListener("keydown",N),window.addEventListener("keyup",H),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",H)}},[T]),Nt.useEffect(()=>{const N=Y.current;if(!N||!T)return;const H=z=>{if(z.preventDefault(),z.stopPropagation(),B.current){const et=N.getBoundingClientRect(),Mt=window.devicePixelRatio||1,ct=(z.clientX-et.left)*Mt,It=(z.clientY-et.top)*Mt;let mt=z.deltaX,kt=z.deltaY;z.deltaMode===1?(mt*=25,kt*=25):z.deltaMode===2&&(mt*=100,kt*=100),B.current.handlePointerInput("move",ct,It,N.width,N.height),B.current.handleWheel(mt,kt,ct,It,N.width,N.height)}};return N.addEventListener("wheel",H,{passive:!1}),()=>{N.removeEventListener("wheel",H)}},[T]);const[G,x]=Nt.useState([]);Nt.useEffect(()=>{if(y&&y.objects){const N=y.objects.filter(H=>{var z,et;return H.type==="Joystick"&&((z=H.inputBinding)==null?void 0:z.type)==="keyboard"&&((et=H.inputBinding.keyboardConfig)==null?void 0:et.showVirtualKeyboard)});x(N)}},[y]);const[,U]=Nt.useState(0);Nt.useEffect(()=>{if(G.length===0)return;let N;const H=()=>{U(z=>z+1),N=requestAnimationFrame(H)};return N=requestAnimationFrame(H),()=>cancelAnimationFrame(N)},[G.length]);const q=()=>G.map(N=>{const H=N.inputBinding.keyboardConfig,z=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyDown(kt)},et=mt=>{var Ot;const kt={key:mt,code:mt,preventDefault:()=>{}};(Ot=B.current)==null||Ot.handleKeyUp(kt)},Mt=B.current,ct=mt=>Mt&&Mt.activeKeys?Mt.activeKeys.has(mt.toLowerCase()):!1,It=mt=>({width:"50px",height:"50px",background:mt?"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:mt?"none":"0 4px 6px rgba(0,0,0,0.1)"});return ne.jsxs("div",{style:{position:"absolute",bottom:"40px",right:"40px",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",pointerEvents:"auto",zIndex:100},children:[ne.jsx("div",{style:It(ct(H.upKey)),onMouseDown:()=>z(H.upKey),onMouseUp:()=>et(H.upKey),onMouseLeave:()=>et(H.upKey),onTouchStart:mt=>{mt.preventDefault(),z(H.upKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.upKey)},children:H.upKey.toUpperCase()}),ne.jsxs("div",{style:{display:"flex",gap:"8px"},children:[ne.jsx("div",{style:It(ct(H.leftKey)),onMouseDown:()=>z(H.leftKey),onMouseUp:()=>et(H.leftKey),onMouseLeave:()=>et(H.leftKey),onTouchStart:mt=>{mt.preventDefault(),z(H.leftKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.leftKey)},children:H.leftKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.downKey)),onMouseDown:()=>z(H.downKey),onMouseUp:()=>et(H.downKey),onMouseLeave:()=>et(H.downKey),onTouchStart:mt=>{mt.preventDefault(),z(H.downKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.downKey)},children:H.downKey.toUpperCase()}),ne.jsx("div",{style:It(ct(H.rightKey)),onMouseDown:()=>z(H.rightKey),onMouseUp:()=>et(H.rightKey),onMouseLeave:()=>et(H.rightKey),onTouchStart:mt=>{mt.preventDefault(),z(H.rightKey)},onTouchEnd:mt=>{mt.preventDefault(),et(H.rightKey)},children:H.rightKey.toUpperCase()})]})]},N.id)});return ne.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[ne.jsx("canvas",{ref:Y,onPointerDown:N=>{var H;V(N,"down"),N.currentTarget.setPointerCapture(N.pointerId),(H=Y.current)==null||H.focus()},onPointerMove:N=>V(N,"move"),onPointerUp:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerCancel:N=>{V(N,"up"),N.currentTarget.releasePointerCapture(N.pointerId)},onPointerLeave:N=>V(N,"blur"),onClick:N=>V(N,"click"),onKeyDown:N=>B.current.handleKeyDown(N.nativeEvent),onKeyUp:N=>B.current.handleKeyUp(N.nativeEvent),onContextMenu:N=>N.preventDefault(),tabIndex:0,style:{...s,width:"100%",height:"100%",outline:"none",display:"block",touchAction:"none",pointerEvents:T?"auto":"none"}}),q()]})});function ci(){const[y,t]=Nt.useState(null),s=Nt.useCallback((b,c)=>{y==null||y.setInputBool(b,c)},[y]),o=Nt.useCallback((b,c)=>{y==null||y.setInputNumber(b,c)},[y]),e=Nt.useCallback(b=>{y==null||y.fireTrigger(b)},[y]),n=Nt.useCallback((b,c)=>{y==null||y.setInputText(b,c)},[y]),i=Nt.useCallback((b,c)=>{y==null||y.setInputNumberArray(b,c)},[y]),a=Nt.useCallback((b,c)=>{y==null||y.setInputStringArray(b,c)},[y]),r=Nt.useCallback((b,c)=>{y==null||y.updateInput(b,c)},[y]),l=r,d=Nt.useCallback((b,c)=>{y==null||y.updateObjectOptions(b,c)},[y]),p=Nt.useCallback((b,c,S)=>{y==null||y.updateConstraint(b,c,S)},[y]),g=Nt.useCallback((b,c,S)=>{y==null||y.updateGraphData(b,c,S)},[y]),u=Nt.useCallback((b,c,S)=>{y==null||y.updateBarChartData(b,c,S)},[y]),f=Nt.useCallback((b,c)=>{y==null||y.updatePieChartData(b,c)},[y]),h=Nt.useCallback((b,c)=>{y==null||y.setDropdownOptions(b,c)},[y]),m=Nt.useCallback(b=>y==null?void 0:y.getInputValue(b),[y]);return{setEngine:t,engine:y,updateInput:r,setInputValue:l,setInputBool:s,setInputNumber:o,fireTrigger:e,setInputText:n,setInputNumberArray:i,setInputStringArray:a,updateConstraint:p,updateGraphData:g,updateBarChartData:u,updatePieChartData:f,setDropdownOptions:h,updateObjectOptions:d,getInputValue:m}}const hi=({artboard:y,config:t})=>{const s={...y.seo,...t},o=s.enableSmartExtraction!==!1;Nt.useEffect(()=>{const a=s.title||y.name;a&&(document.title=a);let r=s.description;if(!r&&o){const p=y.objects.filter(g=>{var u;return((u=g.geometry)==null?void 0:u.type)==="Text"}).sort((g,u)=>{var f,h;return(((f=u.geometry.text)==null?void 0:f.length)||0)-(((h=g.geometry.text)==null?void 0:h.length)||0)});p.length>0&&(r=p[0].geometry.text)}r&&(e("name","description",r),e("property","og:description",r)),s.keywords&&s.keywords.length>0&&e("name","keywords",s.keywords.join(", "));const l=s.ogImage||y.backgroundImage;l&&e("property","og:image",l),a&&e("property","og:title",a),e("property","og:type","website")},[s,y,o]);const e=(a,r,l)=>{let d=document.querySelector(`meta[${a}="${r}"]`);d||(d=document.createElement("meta"),d.setAttribute(a,r),document.head.appendChild(d)),d.setAttribute("content",l)},n=()=>{const a=[];return a.push(ne.jsx("h1",{children:s.title||y.name},"artboard-title")),y.objects.forEach((l,d)=>{var p,g;if(!(l.visible===!1||l.isVisible===!1))if(((p=l.geometry)==null?void 0:p.type)==="Text"){const u=l.geometry.text;u&&(l.geometry.fontSize>24?a.push(ne.jsx("h2",{children:u},l.id||d)):a.push(ne.jsx("p",{children:u},l.id||d)))}else if(((g=l.geometry)==null?void 0:g.type)==="Image"){const u=l.geometry.src,f=l.altText||l.name||"Illustration";a.push(ne.jsx("img",{src:u,alt:f},l.id||d))}else l.type==="Button"&&a.push(ne.jsx("button",{children:l.name||"Button"},l.id||d))}),a},i=s.jsonLd||{"@context":"https://schema.org","@type":"VisualArtwork",name:s.title||y.name,description:s.description,image:s.ogImage||y.backgroundImage,abstract:"Animated interface created with ExodeUI"};return ne.jsxs("div",{id:`exode-seo-${y.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:[n(),ne.jsx("script",{type:"application/ld+json",children:JSON.stringify(i)})]})},fi={version:"7.0.0"}.version;se.BAR_STYLE_PRESETS=ri,se.BehaviorSensor=ge,se.BehaviorType=it,se.ConditionOp=es,se.ExodeSEO=hi,se.ExodeUICanvas=li,se.ExodeUIEngine=bs,se.LogicOp=Ht,se.RapierPhysics=os,se.TOGGLE_SHAPE_NAME_MAP=xe,se.VERSION=fi,se.getToggleSvgPathBounds=We,se.useExodeUI=ci,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -6069,7 +6069,7 @@ class di {
6069
6069
  t.roundRect(-i, -i, i * 2, i * 2, D);
6070
6070
  } else
6071
6071
  t.arc(0, 0, i, 0, Math.PI * 2);
6072
- t.fillStyle = ((C = s.style) == null ? void 0 : C.baseColor) || "rgba(0,0,0,0.04)", t.fill(), (w = s.style) != null && w.baseBorderWidth ? (t.lineWidth = s.style.baseBorderWidth, t.strokeStyle = s.style.baseBorderColor || "rgba(0,0,0,0.1)", t.stroke()) : (t.lineWidth = 1, t.strokeStyle = ((I = s.style) == null ? void 0 : I.baseBorderColor) || "rgba(0,0,0,0.08)", t.stroke());
6072
+ t.fillStyle = ((C = s.style) == null ? void 0 : C.baseColor) || "rgba(255, 255, 255, 0.5)", t.fill(), (w = s.style) != null && w.baseBorderWidth ? (t.lineWidth = s.style.baseBorderWidth, t.strokeStyle = s.style.baseBorderColor || "rgba(0,0,0,0.1)", t.stroke()) : (t.lineWidth = 1.5, t.strokeStyle = ((I = s.style) == null ? void 0 : I.baseBorderColor) || "rgba(0, 0, 0, 0.15)", t.stroke());
6073
6073
  const u = s.overflowHandle ? i : Math.max(0.1, i - a);
6074
6074
  let f = 0, h = 0;
6075
6075
  s.joystickType === "2D" ? (f = r * u, h = l * u) : s.joystickType === "1D_X" ? (f = r * u, h = 0) : s.joystickType === "1D_Y" && (f = 0, h = l * u), t.globalAlpha = g * (((k = s.style) == null ? void 0 : k.handleOpacity) ?? 1), t.beginPath(), t.arc(f, h, a, 0, Math.PI * 2), t.fillStyle = ((L = s.style) == null ? void 0 : L.handleColor) || "#3b82f6", t.fill(), (T = s.style) != null && T.handleBorderWidth ? (t.lineWidth = s.style.handleBorderWidth, t.strokeStyle = s.style.handleBorderColor || "rgba(255,255,255,0.5)", t.stroke()) : (t.lineWidth = 1, t.strokeStyle = ((A = s.style) == null ? void 0 : A.handleBorderColor) || "rgba(255,255,255,0.5)", t.stroke()), t.globalAlpha = g, t.restore();
@@ -7482,7 +7482,7 @@ const Mi = ({ artboard: y, config: t }) => {
7482
7482
  ]
7483
7483
  }
7484
7484
  );
7485
- }, pi = "6.4.6", ui = {
7485
+ }, pi = "7.0.0", ui = {
7486
7486
  version: pi
7487
7487
  }, Ii = ui.version;
7488
7488
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodeui",
3
- "version": "6.4.6",
3
+ "version": "7.0.0",
4
4
  "description": "React Runtime for ExodeUI Animation Engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",