kline-orderbook-chart 2.1.0 → 2.2.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.
@@ -11,16 +11,374 @@
11
11
  * Web: https://tapedelta.com
12
12
  * NPM: https://www.npmjs.com/package/kline-orderbook-chart
13
13
  */
14
- var rt=-Math.PI/2,zt=new WeakMap;function ce(e,r){let o=zt.get(e);o||(o=new Map,zt.set(e,o));let f=o.get(r);if(f)return f;o.size>=128&&o.clear();let _=r*.259,E=r*.432,T=e.createRadialGradient(_,E,0,_,E,r*1.45);T.addColorStop(0,"rgba(0,0,0,0)"),T.addColorStop(1,"rgba(0,0,0,0.59)");let F=r*.135,P=r*.225,n=e.createRadialGradient(F,P,0,F,P,r*.38);return n.addColorStop(0,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),f={dark:T,spec:n},o.set(r,f),f}function Vt(e,r,o,f,_,E,T,F,P,n,a,t,w,D){if(!(f>0))return;let S=Math.min(1,Math.max(0,_)),W=S*Math.PI;if(e.save(),e.translate(r,o),e.globalAlpha*=.82,S>=.999||S<=.001){let i=S>=.999?[E,T,F,P]:[n,a,t,w];e.beginPath(),e.arc(0,0,f,0,Math.PI*2),e.fillStyle=`rgba(${i[0]},${i[1]},${i[2]},${(i[3]/255).toFixed(3)})`,e.fill()}else e.beginPath(),e.moveTo(0,0),e.arc(0,0,f,rt-W,rt+W),e.closePath(),e.fillStyle=`rgba(${E},${T},${F},${(P/255).toFixed(3)})`,e.fill(),e.beginPath(),e.moveTo(0,0),e.arc(0,0,f,rt+W,rt-W+Math.PI*2),e.closePath(),e.fillStyle=`rgba(${n},${a},${t},${(w/255).toFixed(3)})`,e.fill(),f>=4&&(e.strokeStyle="rgba(20,20,20,0.45)",e.lineWidth=Math.max(1,f*.08),e.beginPath(),e.moveTo(0,0),e.lineTo(f*Math.cos(rt-W),f*Math.sin(rt-W)),e.moveTo(0,0),e.lineTo(f*Math.cos(rt+W),f*Math.sin(rt+W)),e.stroke());if(D&&f>=4){let i=ce(e,Math.round(f));e.beginPath(),e.arc(0,0,f,0,Math.PI*2),e.fillStyle=i.dark,e.fill(),e.fillStyle=i.spec,e.fill()}e.restore()}var k={FILL_RECT:1,FILL_ROUND_RECT:27,FILL_ELLIPSE:38,FILL_RECT_SMOOTH_X:30,STROKE_RECT:2,LINE:3,CANDLE:34,CANDLE_BORDERED:36,OHLC_BAR:37,DASHED_LINE:4,POLYLINE:5,TEXT:6,STYLED_TEXT:33,CIRCLE:7,TRIANGLE:8,SAVE:9,RESTORE:10,CLIP_RECT:11,ROTATED_TEXT:12,BUBBLE_3D:13,BUBBLE_PIE:39,FILL_POLYGON:14,DASHED_POLYLINE:15,GRADIENT_RECT:16,GRADIENT_RECT_H:28,GRADIENT_RECT_H_MULTI:29,LINEAR_POLYLINE:17,SMOOTH_POLYLINE:24,BEGIN_HEATMAP_LAYER:18,END_HEATMAP_LAYER:19,HEATMAP_BITMAP:20,LINE_WITH_EXTEND:21,LABEL_CALLOUT:22,HEATMAP_WORLD:23,HEATMAP_BG:31,HEATMAP_WORLD_INTENSITY:32,OB_HEATMAP:35,DRAW_IMAGE:25,FILL_SMOOTH_BAND:26,END_FRAME:255},ue=(()=>{try{return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}catch{return!1}})(),fe=ue?1.5:1/0;function he(){return typeof window<"u"&&window.devicePixelRatio||1}function ge(e,r){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(e,r):Object.assign(document.createElement("canvas"),{width:e,height:r})}var lt=null,Kt=null;function de(e,r){return lt?(lt.width!==e||lt.height!==r)&&(lt.width=e,lt.height=r):(lt=ge(e,r),Kt=lt.getContext("2d")),Kt}var Bt=new Float32Array(0);function ye(e){return Bt.length<e&&(Bt=new Float32Array(e)),Bt}var mt=new Float64Array(0),Ut=new Float64Array(0),Ot=new Float64Array(0),_t=new Float64Array(0);function be(e){return mt.length<e&&(mt=new Float64Array(e)),mt}function me(e){return Ut.length<e&&(Ut=new Float64Array(e)),Ut}function _e(e){return Ot.length<e&&(Ot=new Float64Array(e)),Ot}function pe(e){return _t.length<e&&(_t=new Float64Array(e)),_t}function $t(e,r){if(r<2)return;let o=r-1,f=be(o),_=me(o),E=_e(o);for(let F=0;F<o;F++){let P=e[F*2],n=e[F*2+1],a=e[(F+1)*2],t=e[(F+1)*2+1];f[F]=a-P,_[F]=t-n,E[F]=f[F]>0?_[F]/f[F]:0}let T=pe(r);T[0]=E[0],T[r-1]=E[o-1];for(let F=1;F<o;F++){let P=E[F-1],n=E[F];T[F]=P*n<=0?0:(P+n)*.5}for(let F=0;F<o;F++){let P=E[F];if(P===0){T[F]=0,T[F+1]=0;continue}let n=T[F]/P,a=T[F+1]/P,t=n*n+a*a;if(t>9){let w=3/Math.sqrt(t);T[F]=w*n*P,T[F+1]=w*a*P}}}function qt(e,r,o){let f=o-1,_=mt,E=_t;for(let T=0;T<f;T++){let F=r[T*2],P=r[T*2+1],n=r[(T+1)*2],a=r[(T+1)*2+1],t=_[T];if(t<=0){e.lineTo(n,a);continue}let w=t/3;e.bezierCurveTo(F+w,P+E[T]*w,n-w,a-E[T+1]*w,n,a)}}function Te(e,r,o){let f=o-1,_=mt,E=_t;for(let T=f-1;T>=0;T--){let F=r[T*2],P=r[T*2+1],n=r[(T+1)*2],a=r[(T+1)*2+1],t=_[T];if(t<=0){e.lineTo(F,P);continue}let w=t/3;e.bezierCurveTo(n-w,a-E[T+1]*w,F+w,P+E[T]*w,F,P)}}var Jt=["left","center","right"],At=new Map,we=4096;function Fe(e,r,o,f){return e<<24|r<<16|o<<8|f}function $(e,r,o,f){let _=Fe(e,r,o,f),E=At.get(_);return E||(E=`rgba(${e},${r},${o},${(f/255).toFixed(3)})`,At.size>=we&&At.clear(),At.set(_,E),E)}var Rt=new TextDecoder;function dt(e,r){return Math.round(e*r)/r}var Lt=new Map;function vt(e,r){let o=Lt.get(r);if(o!==void 0)return o;let f=e.font,_=e.textBaseline;e.font=r,e.textBaseline="alphabetic";let E=e.measureText("0"),T=E.actualBoundingBoxAscent||0,F=E.actualBoundingBoxDescent||0;return o=(T-F)/2,(!Number.isFinite(o)||o===0)&&(o=(parseFloat(r)||11)*.35),Lt.size>=256&&Lt.clear(),Lt.set(r,o),e.font=f,e.textBaseline=_,o}var Qt=new WeakMap;function Ee(e,r,o,f,_){let E=Qt.get(e);E||(E=new Map,Qt.set(e,E));let T=Math.round(r),F=`${T}|${o}|${f}|${_}`,P=E.get(F);if(P)return P;let n=-T*.25,a=-T*.25,t=e.createRadialGradient(n,a,T*.08,0,0,T);t.addColorStop(0,f),t.addColorStop(1,o);let w=null;_&&(w=e.createRadialGradient(0,0,T*.85,0,0,T*1.2),w.addColorStop(0,_),w.addColorStop(1,_.replace(/[\d.]+\)$/,"0)")));let D=T*.2,S=e.createRadialGradient(n,a,0,n,a,D);return S.addColorStop(0,"rgba(255,255,255,0.22)"),S.addColorStop(1,"rgba(255,255,255,0)"),P={body:t,glow:w,spec:S,hlX:n,hlY:a,specR:D},E.set(F,P),P}function Q(e,r,o){let f=Math.max(1,Math.round(r*o)),_=Math.round(e*o)/o;return f&1?_+.5/o:_}function ut(e,r,o,f,_){let E=Math.round(e*_),T=Math.round(r*_),F=Math.round((e+o)*_),P=Math.round((r+f)*_);return{x:E/_,y:T/_,w:(F-E)/_,h:(P-T)/_}}function Me(e,r,o,f,_){return{x:Math.round(e*_)/_,y:Math.round(r*_)/_,w:Math.max(1,Math.round(o*_))/_,h:Math.max(1,Math.round(f*_))/_}}function Ae(e,r,o,f,_){let E=Math.round(r*_),T=Math.round((r+f)*_);return{x:e,y:E/_,w:o,h:(T-E)/_}}function jt(e,r,o,f,_=null,E=null,T=null,F=null){let P=r.buffer;if(o+f>P.byteLength)return;let n=new DataView(P,o,f),a=new Uint8Array(P,o,f),t=0,w="",D="",S=-1,W="",i=Math.max(1,Math.abs(e.getTransform?.().a||he())),it=null,v=[],L=F&&F.geom&&F.geom.available?F.geom:null,z=e,tt=!1,ot="";for(;t<f;){let ct=a[t];if(t+=1,ct===k.END_FRAME)break;switch(ct){case k.FILL_RECT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];if(t+=4,L){L.rect(l,u,g,s,c,h,y,m,0,0,0,0,0,0,0);break}let d=$(c,h,y,m);d!==w&&(e.fillStyle=d,w=d);let p=ut(l,u,g,s,i);e.fillRect(p.x,p.y,p.w,p.h);break}case k.FILL_RECT_SMOOTH_X:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];if(t+=4,L){L.rect(l,u,g,s,c,h,y,m,0,0,0,0,0,0,1);break}let d=$(c,h,y,m);d!==w&&(e.fillStyle=d,w=d);let p=Ae(l,u,g,s,i);e.fillRect(p.x,p.y,p.w,p.h);break}case k.FILL_ELLIPSE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];if(t+=4,L){L.rect(l-g,u-s,g*2,s*2,c,h,y,m,-1,0,0,0,0,0,2);break}let d=$(c,h,y,m);d!==w&&(e.fillStyle=d,w=d),e.beginPath(),e.ellipse(l,u,Math.max(g,.1),Math.max(s,.1),0,0,Math.PI*2),e.fill();break}case k.FILL_ROUND_RECT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];t+=4;let d=n.getFloat32(t,!0);if(t+=4,L){L.rect(l,u,g,s,c,h,y,m,d,0,0,0,0,0,0);break}let p=$(c,h,y,m);p!==w&&(e.fillStyle=p,w=p);let b=ut(l,u,g,s,i),M=Math.min(d,b.w*.5,b.h*.5);M<=.5?e.fillRect(b.x,b.y,b.w,b.h):(e.beginPath(),e.moveTo(b.x+M,b.y),e.lineTo(b.x+b.w-M,b.y),e.arcTo(b.x+b.w,b.y,b.x+b.w,b.y+M,M),e.lineTo(b.x+b.w,b.y+b.h-M),e.arcTo(b.x+b.w,b.y+b.h,b.x+b.w-M,b.y+b.h,M),e.lineTo(b.x+M,b.y+b.h),e.arcTo(b.x,b.y+b.h,b.x,b.y+b.h-M,M),e.lineTo(b.x,b.y+M),e.arcTo(b.x,b.y,b.x+M,b.y,M),e.closePath(),e.fill());break}case k.STROKE_RECT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];t+=4;let d=n.getFloat32(t,!0);if(t+=4,L){let H=d*.5;L.rect(l-H,u-H,g+d,s+d,0,0,0,0,0,d,c,h,y,m,0);break}let p=$(c,h,y,m);p!==D&&(e.strokeStyle=p,D=p),d!==S&&(e.lineWidth=d,S=d);let b=Q(l,d,i),M=Q(u,d,i),C=Math.round(g*i)/i,R=Math.round(s*i)/i;e.strokeRect(b,M,C,R);break}case k.LINE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];t+=4;let d=n.getFloat32(t,!0);if(t+=4,L){L.seg(l,u,g,s,c,h,y,m,d,0,0);break}let p=$(c,h,y,m);e.beginPath(),p!==D&&(e.strokeStyle=p,D=p),d!==S&&(e.lineWidth=d,S=d),e.setLineDash([]),e.moveTo(Q(l,d,i),Q(u,d,i)),e.lineTo(Q(g,d,i),Q(s,d,i)),e.stroke();break}case k.CANDLE:case k.CANDLE_BORDERED:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let m=n.getFloat32(t,!0);t+=4;let d=a[t+3],p=$(a[t],a[t+1],a[t+2],d);t+=4;let b=a[t+3],M=$(a[t],a[t+1],a[t+2],b);t+=4;let C=null;ct===k.CANDLE_BORDERED&&(C=$(a[t],a[t+1],a[t+2],a[t+3]),t+=4);let R=Math.max(1,Math.floor(y*i)),H=Math.max(1,Math.floor(m*i));R>H&&(R=H);let B=Math.min(Math.max(1,Math.floor(h*i)),H);B<R?B=R:(B^R)&1&&(B-=1);let U=l*i,G=R&1?Math.round(U-.5)+.5:Math.round(U),O=Math.max(1,Math.round(i)),I=Math.round(Math.min(s,c)*i),N=Math.max(I+O,Math.round(Math.max(s,c)*i)),Y=Math.round(Math.min(u,g)*i),A=Math.max(Y+1,Math.round(Math.max(u,g)*i)),x=Math.min(u,g),Mt=Math.max(u,g),Ct=Math.min(s,c),Pt=Math.max(s,c);if(x<Ct&&Y>=I&&(Y=I-1),Mt>Pt&&A<=N&&(A=N+1),b>0&&(Y<I||A>N)){M!==w&&(e.fillStyle=M,w=M);let Dt=(G-R/2)/i,It=R/i;d===255?e.fillRect(Dt,Y/i,It,(A-Y)/i):(Y<I&&e.fillRect(Dt,Y/i,It,(I-Y)/i),A>N&&e.fillRect(Dt,N/i,It,(A-N)/i))}let K=G-B/2,j=N-I;if(C===null){d>0&&(p!==w&&(e.fillStyle=p,w=p),e.fillRect(K/i,I/i,B/i,j/i));break}let J=Math.max(1,Math.floor(i));if(C!==w&&(e.fillStyle=C,w=C),B<=2*J||j<=2*J){e.fillRect(K/i,I/i,B/i,j/i);break}d===255?e.fillRect(K/i,I/i,B/i,j/i):(e.fillRect(K/i,I/i,B/i,J/i),e.fillRect(K/i,(N-J)/i,B/i,J/i),e.fillRect(K/i,(I+J)/i,J/i,(j-2*J)/i),e.fillRect((K+B-J)/i,(I+J)/i,J/i,(j-2*J)/i)),d>0&&(p!==w&&(e.fillStyle=p,w=p),e.fillRect((K+J)/i,(I+J)/i,(B-2*J)/i,(j-2*J)/i));break}case k.OHLC_BAR:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let m=a[t];t+=1;let d=Math.max(1,Math.floor(h*i)),p=Math.max(1,Math.floor(i)),b=m&1?p:Math.max(p,Math.floor(d/6));b>d&&(b=d);let M=l*i,R=(b&1?Math.round(M-.5)+.5:Math.round(M))-b/2,H=Math.round(Math.min(g,s)*i),B=Math.max(H+1,Math.round(Math.max(g,s)*i));y!==w&&(e.fillStyle=y,w=y),e.fillRect(R/i,H/i,b/i,(B-H)/i);let U=Math.floor((Math.floor(d*.8)-b)/2);if(U>=1){if(!(m&2)){let O=Math.round(u*i-b/2);e.fillRect((R-U)/i,O/i,U/i,b/i)}let G=Math.round(c*i-b/2);e.fillRect((R+b)/i,G/i,U/i,b/i)}break}case k.DASHED_LINE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];t+=4;let d=n.getFloat32(t,!0);t+=4;let p=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);if(t+=4,L){L.seg(l,u,g,s,c,h,y,m,d,p,b);break}let M=$(c,h,y,m);e.beginPath(),M!==D&&(e.strokeStyle=M,D=M),d!==S&&(e.lineWidth=d,S=d),e.setLineDash([p,b]),e.moveTo(Q(l,d,i),Q(u,d,i)),e.lineTo(Q(g,d,i),Q(s,d,i)),e.stroke(),e.setLineDash([]);break}case k.LINEAR_POLYLINE:{let l=n.getUint16(t,!0);t+=2;let u=a[t],g=a[t+1],s=a[t+2],c=a[t+3];t+=4;let h=n.getFloat32(t,!0);if(t+=4,L){let m=0,d=0;for(let p=0;p<l;p++){let b=n.getFloat32(t,!0),M=n.getFloat32(t+4,!0);t+=8,p>0&&L.seg(m,d,b,M,u,g,s,c,h,0,0),m=b,d=M}break}let y=$(u,g,s,c);if(l>1){e.beginPath(),y!==D&&(e.strokeStyle=y,D=y),h!==S&&(e.lineWidth=h,S=h),e.setLineDash([]),e.lineJoin="miter",e.lineCap="butt",e.miterLimit=10;let m=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4,e.moveTo(m,d);for(let p=1;p<l;p++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.stroke()}else t+=l*8;break}case k.SMOOTH_POLYLINE:{let l=n.getUint16(t,!0);t+=2;let u=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let g=n.getFloat32(t,!0);if(t+=4,l>1){let s=new Float32Array(l*2);for(let c=0;c<l;c++)s[c*2]=n.getFloat32(t,!0),t+=4,s[c*2+1]=n.getFloat32(t,!0),t+=4;e.beginPath(),u!==D&&(e.strokeStyle=u,D=u),g!==S&&(e.lineWidth=g,S=g),e.setLineDash([]),e.lineJoin="round",e.lineCap="round",l===2?(e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3])):($t(s,l),e.moveTo(s[0],s[1]),qt(e,s,l)),e.stroke()}else t+=l*8;break}case k.POLYLINE:{let l=n.getUint16(t,!0);t+=2;let u=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let g=n.getFloat32(t,!0);if(t+=4,l>0){let s=new Float32Array(l*2);for(let c=0;c<l;c++)s[c*2]=n.getFloat32(t,!0),t+=4,s[c*2+1]=n.getFloat32(t,!0),t+=4;if(e.beginPath(),u!==D&&(e.strokeStyle=u,D=u),g!==S&&(e.lineWidth=g,S=g),e.setLineDash([]),e.lineJoin="round",e.lineCap="round",l===2)e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3]);else{e.moveTo(s[0],s[1]);for(let c=0;c<l-1;c++){let h=c>0?c-1:0,y=c,m=c+1,d=c<l-2?c+2:l-1,p=s[h*2],b=s[h*2+1],M=s[y*2],C=s[y*2+1],R=s[m*2],H=s[m*2+1],B=s[d*2],U=s[d*2+1],G=M+(R-p)/6,O=C+(H-b)/6,I=R-(B-M)/6,N=H-(U-C)/6;e.bezierCurveTo(G,O,I,N,R,H)}}e.stroke()}break}case k.TEXT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t];t+=1;let h=n.getUint16(t,!0);t+=2;let y=Rt.decode(new Uint8Array(r.buffer,o+t,h));t+=h,g!==w&&(e.fillStyle=g,w=g);let m=`${Math.round(s)}px "IBM Plex Mono",monospace`;m!==W&&(e.font=m,W=m),e.textAlign=Jt[c]||"left",e.textBaseline="alphabetic";let d=u+vt(e,m);e.fillText(y,dt(l,i),dt(d,i));break}case k.STYLED_TEXT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t];t+=1;let h=a[t];t+=1;let y=n.getUint16(t,!0);t+=2;let m=Rt.decode(new Uint8Array(r.buffer,o+t,y));t+=y,g!==w&&(e.fillStyle=g,w=g);let d=h&2?"italic ":"",p=h&1?"700 ":"",b=`${d}${p}${Math.round(s)}px "IBM Plex Mono",monospace`;b!==W&&(e.font=b,W=b),e.textAlign=Jt[c]||"left",e.textBaseline="alphabetic";let M=u+vt(e,b);e.fillText(m,dt(l,i),dt(M,i));break}case k.CIRCLE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=a[t],c=a[t+1],h=a[t+2],y=a[t+3],m=L?"":$(s,c,h,y);t+=4;let d=a[t],p=a[t+1],b=a[t+2],M=a[t+3],C=L?"":$(d,p,b,M);t+=4;let R=n.getFloat32(t,!0);if(t+=4,L){L.disc(l,u,g,s,c,h,y,d,p,b,M,0,0,0,0,R,0);break}e.beginPath(),e.arc(l,u,g,0,Math.PI*2),m!==w&&(e.fillStyle=m,w=m),e.fill(),R>0&&(C!==D&&(e.strokeStyle=C,D=C),R!==S&&(e.lineWidth=R,S=R),e.stroke());break}case k.TRIANGLE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=a[t],m=a[t+1],d=a[t+2],p=a[t+3];if(t+=4,L){L.tri(l,u,g,s,c,h,y,m,d,p);break}let b=$(y,m,d,p);e.beginPath(),e.moveTo(l,u),e.lineTo(g,s),e.lineTo(c,h),e.closePath(),b!==w&&(e.fillStyle=b,w=b),e.fill();break}case k.SAVE:{e.save(),v.push(it);break}case k.RESTORE:{e.restore(),it=v.length?v.pop():null,L&&L.setClip(it),w="",D="",S=-1,W="";break}case k.CLIP_RECT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=ut(l,u,g,s,i);e.beginPath(),e.rect(c.x,c.y,c.w,c.h),e.clip(),it=c,L&&L.setClip(c);break}case k.ROTATED_TEXT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);t+=4;let h=n.getUint16(t,!0);t+=2;let y=Rt.decode(a.subarray(t,t+h));t+=h;let m=`${s}px sans-serif`;m!==W&&(e.font=m,W=m),g!==w&&(e.fillStyle=g,w=g),e.textAlign="center",e.textBaseline="alphabetic";let d=vt(e,m);e.save(),e.translate(l,u),e.rotate(c),e.fillText(y,0,d),e.restore();break}case k.BUBBLE_PIE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t],h=a[t+1],y=a[t+2],m=a[t+3];t+=4;let d=a[t],p=a[t+1],b=a[t+2],M=a[t+3];t+=4;let C=a[t]!==0;if(t+=1,L){L.pie(l,u,g,s,c,h,y,m,d,p,b,M,C);break}Vt(e,l,u,g,s,c,h,y,m,d,p,b,M,C),w="";break}case k.BUBBLE_3D:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=a[t],c=a[t+1],h=a[t+2],y=a[t+3];t+=4;let m=a[t],d=a[t+1],p=a[t+2],b=a[t+3];t+=4;let M=a[t],C=a[t+1],R=a[t+2],H=a[t+3];t+=4;let B=n.getFloat32(t,!0);t+=4;let U=g;if(L){L.disc(l,u,U,s,c,h,y,M,C,R,H,m,d,p,b,B,U<4?0:1);break}if(U<4){let G=`rgba(${s},${c},${h},${(y/255).toFixed(3)})`;e.beginPath(),e.arc(l,u,U,0,Math.PI*2),e.fillStyle=G,e.fill(),w=""}else{let G=Math.round(U),O=U>=6,I=U>=16,N=`rgba(${s},${c},${h},${(y/255).toFixed(3)})`,Y=`rgba(${m},${d},${p},${(b/255).toFixed(3)})`,A=I?`rgba(${M},${C},${R},${(H/255*.5).toFixed(3)})`:null,x=Ee(e,G,N,Y,A);e.save(),e.translate(l,u),I&&x.glow&&(e.beginPath(),e.arc(0,0,G*1.2,0,Math.PI*2),e.fillStyle=x.glow,e.fill()),e.beginPath(),e.arc(0,0,G,0,Math.PI*2),e.fillStyle=x.body,e.fill(),O&&(e.beginPath(),e.arc(x.hlX,x.hlY,x.specR,0,Math.PI*2),e.fillStyle=x.spec,e.fill()),e.restore(),w=""}break}case k.FILL_POLYGON:{let l=n.getUint16(t,!0);t+=2;let u=a[t],g=a[t+1],s=a[t+2],c=a[t+3];if(t+=4,L){let y=ye(l*2);for(let m=0;m<l;m++)y[m*2]=n.getFloat32(t,!0),y[m*2+1]=n.getFloat32(t+4,!0),t+=8;L.poly(y,l,u,g,s,c);break}let h=$(u,g,s,c);if(l>2){e.beginPath();let y=n.getFloat32(t,!0);t+=4;let m=n.getFloat32(t,!0);t+=4,e.moveTo(y,m);for(let d=1;d<l;d++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.closePath(),h!==w&&(e.fillStyle=h,w=h),e.fill()}else t+=l*8;break}case k.FILL_SMOOTH_BAND:{let l=n.getUint16(t,!0);t+=2;let u=n.getUint16(t,!0);t+=2;let g=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let s=new Float32Array(l*2);for(let h=0;h<l;h++)s[h*2]=n.getFloat32(t,!0),t+=4,s[h*2+1]=n.getFloat32(t,!0),t+=4;let c=new Float32Array(u*2);for(let h=0;h<u;h++)c[h*2]=n.getFloat32(t,!0),t+=4,c[h*2+1]=n.getFloat32(t,!0),t+=4;l>=2&&u>=2&&(e.beginPath(),g!==w&&(e.fillStyle=g,w=g),l===2?(e.moveTo(s[0],s[1]),e.lineTo(s[2],s[3])):($t(s,l),e.moveTo(s[0],s[1]),qt(e,s,l)),e.lineTo(c[(u-1)*2],c[(u-1)*2+1]),u===2?e.lineTo(c[0],c[1]):($t(c,u),Te(e,c,u)),e.closePath(),e.fill());break}case k.DASHED_POLYLINE:{let l=n.getUint16(t,!0);t+=2;let u=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);if(t+=4,l>1){e.beginPath(),u!==D&&(e.strokeStyle=u,D=u),g!==S&&(e.lineWidth=g,S=g),e.setLineDash([s,c]),e.lineJoin="round";let h=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4,e.moveTo(h,y);for(let m=1;m<l;m++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.stroke(),e.setLineDash([])}else t+=l*8;break}case k.GRADIENT_RECT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let h=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let y=ut(l,u,g,s,i),m=e.createLinearGradient(y.x,y.y,y.x,y.y+y.h);m.addColorStop(0,c),m.addColorStop(1,h),e.fillStyle=m,w="",e.fillRect(y.x,y.y,y.w,y.h);break}case k.GRADIENT_RECT_H:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let h=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let y=ut(l,u,g,s,i),m=e.createLinearGradient(y.x,y.y,y.x+y.w,y.y);m.addColorStop(0,c),m.addColorStop(1,h),e.fillStyle=m,w="",e.fillRect(y.x,y.y,y.w,y.h);break}case k.GRADIENT_RECT_H_MULTI:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=a[t];t+=1;let h=ut(l,u,g,s,i),y=e.createLinearGradient(h.x,h.y,h.x+h.w,h.y);for(let m=0;m<c;m++){let d=n.getFloat32(t,!0);t+=4;let p=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4,y.addColorStop(d<0?0:d>1?1:d,p)}e.fillStyle=y,w="",e.fillRect(h.x,h.y,h.w,h.h);break}case k.BEGIN_HEATMAP_LAYER:{let l=t-1,u=n.getUint32(t,!0);t+=4;let g=n.getUint32(t,!0);t+=4;let s=n.getUint32(t,!0);if(t+=4,!_||s===0)break;let c=z.canvas.width,h=z.canvas.height,y=`${u}|${g}|${c}|${h}|${i}`;if(_.getKey()===y&&_.getCanvas()){let m=c/i,d=h/i;z.drawImage(_.getCanvas(),0,0,m,d),t=l+s}else{let m=Math.min(i,fe),d=Math.max(1,Math.round(c/i*m)),p=Math.max(1,Math.round(h/i*m)),b=_.ensureSize(d,p,m);if(!b)break;b.save(),b.setTransform(1,0,0,1,0,0),b.clearRect(0,0,d,p),b.restore(),e=b,w="",D="",S=-1,W="",tt=!0,ot=y}break}case k.END_HEATMAP_LAYER:{if(!tt)break;let l=z.canvas.width/i,u=z.canvas.height/i;z.drawImage(_.getCanvas(),0,0,l,u),_.setKey(ot),e=z,w="",D="",S=-1,W="",tt=!1,ot="";break}case k.HEATMAP_BITMAP:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getUint32(t,!0);t+=4;let s=n.getUint32(t,!0);t+=4;let c=g*s*4;if(t+c>a.byteLength){t=a.byteLength;break}let h=new Uint8ClampedArray(a.buffer,a.byteOffset+t,c);t+=c;let y=new ImageData(h,g,s),m=de(g,s);if(!m)break;m.putImageData(y,0,0),e.drawImage(lt,l,u,g,s);break}case k.HEATMAP_WORLD:{let l=n.getUint32(t,!0);t+=4;let u=n.getUint32(t,!0);t+=4;let g=n.getUint32(t,!0);t+=4;let s=n.getUint32(t,!0);t+=4;let c=n.getUint32(t,!0);t+=4;let h=n.getUint32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let m=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let p=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4;let M=n.getFloat32(t,!0);t+=4;let C=n.getFloat32(t,!0);t+=4;let R=n.getFloat32(t,!0);t+=4;let H=a[t];t+=1;let B=(H&1)!==0,U=c*h*4;if(t+U>a.byteLength){t=a.byteLength;break}if(!E||l===0||u===0){t+=U;break}let G=E.ensureSize(l,u);if(!G){t+=U;break}if(B&&G.clearRect(0,0,l,u),U>0){let O=new Uint8ClampedArray(a.buffer,a.byteOffset+t,U),I=new ImageData(O,c,h);G.putImageData(I,g,s)}if(t+=U,d>0&&p>0&&C>0&&R>0){let O=Me(b,M,C,R,i);if(O.w>0&&O.h>0){let I=e.imageSmoothingEnabled;e.imageSmoothingEnabled=!1,e.drawImage(E.getCanvas(),y,m,d,p,O.x,O.y,O.w,O.h),e.imageSmoothingEnabled=I}}break}case k.LINE_WITH_EXTEND:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let m=n.getFloat32(t,!0);t+=4;let d=a[t];t+=1,c!==D&&(e.strokeStyle=c,D=c),h!==S&&(e.lineWidth=h,S=h),e.setLineDash(y>0?[y,m]:[]);let p=1e5,b=l,M=u,C=g,R=s,H=g-l,B=s-u,U=Math.hypot(H,B);if(U>0&&d!==0){let G=H/U,O=B/U;d&1&&(b=l-G*p,M=u-O*p),d&2&&(C=g+G*p,R=s+O*p),d&4&&O<0&&(b=l-G*p,M=u-O*p),d&8&&O>0&&(C=g+G*p,R=s+O*p)}e.beginPath(),e.moveTo(Q(b,h,i),Q(M,h,i)),e.lineTo(Q(C,h,i),Q(R,h,i)),e.stroke(),y>0&&e.setLineDash([]);break}case k.LABEL_CALLOUT:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let s=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let c=$(a[t],a[t+1],a[t+2],a[t+3]);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let m=a[t];t+=1;let d=a[t];t+=1;let p=n.getUint16(t,!0);t+=2;let b=Rt.decode(a.subarray(t,t+p));t+=p;let M=`${Math.round(h)}px "IBM Plex Mono",monospace`;M!==W&&(e.font=M,W=M);let C=4,R=6,H=b.indexOf(`
15
- `)>=0?b.split(`
16
- `):[b],B=Math.round(h),U=3,G=0;for(let K=0;K<H.length;K++){let j=e.measureText(H[K]).width;j>G&&(G=j)}let O=H.length*B+(H.length-1)*U+C*2,I=Math.ceil(G)+C*2,N,Y;switch(d){case 1:Y=u-R-O,N=l-I/2;break;case 2:Y=u+R,N=l-I/2;break;case 3:Y=u-O/2,N=l+R;break;case 4:Y=u-O/2,N=l-R-I;break;default:Y=u-O/2,m===1?N=l-I/2:m===2?N=l-I:N=l;break}let A=ut(N,Y,I,O,i),x=Math.min(3,A.w*.5,A.h*.5),Mt=()=>{e.beginPath(),x<=.5?e.rect(A.x,A.y,A.w,A.h):(e.moveTo(A.x+x,A.y),e.lineTo(A.x+A.w-x,A.y),e.arcTo(A.x+A.w,A.y,A.x+A.w,A.y+x,x),e.lineTo(A.x+A.w,A.y+A.h-x),e.arcTo(A.x+A.w,A.y+A.h,A.x+A.w-x,A.y+A.h,x),e.lineTo(A.x+x,A.y+A.h),e.arcTo(A.x,A.y+A.h,A.x,A.y+A.h-x,x),e.lineTo(A.x,A.y+x),e.arcTo(A.x,A.y,A.x+x,A.y,x)),e.closePath()};if(g!==w&&(e.fillStyle=g,w=g),Mt(),e.fill(),y>0&&(s!==D&&(e.strokeStyle=s,D=s),y!==S&&(e.lineWidth=y,S=y),e.setLineDash([]),Mt(),e.stroke()),d>=1&&d<=4){switch(g!==w&&(e.fillStyle=g,w=g),e.beginPath(),d){case 1:e.moveTo(l-R/2,Y+O),e.lineTo(l+R/2,Y+O),e.lineTo(l,u);break;case 2:e.moveTo(l-R/2,Y),e.lineTo(l+R/2,Y),e.lineTo(l,u);break;case 3:e.moveTo(N,u-R/2),e.lineTo(N,u+R/2),e.lineTo(l,u);break;case 4:e.moveTo(N+I,u-R/2),e.lineTo(N+I,u+R/2),e.lineTo(l,u);break}e.closePath(),e.fill()}c!==w&&(e.fillStyle=c,w=c),e.textAlign="center",e.textBaseline="alphabetic";let Ct=vt(e,M),Pt=N+I/2;for(let K=0;K<H.length;K++){let j=Y+C+B/2+K*(B+U);e.fillText(H[K],dt(Pt,i),dt(j+Ct,i))}break}case k.DRAW_IMAGE:{let l=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getUint32(t,!0);if(t+=4,!T||c===0||g<=0||s<=0)break;let h=T.get(c);if(!h)break;try{e.drawImage(h,l,u,g,s)}catch(y){T.delete(c),console.warn("[canvasRenderer] drawImage failed for id="+c,y?.message||y)}break}case k.HEATMAP_BG:{let l=a[t],u=a[t+1],g=a[t+2],s=a[t+3],c=a[t+4],h=a[t+5],y=a[t+6],m=a[t+7],d=a[t+8]!==0;t+=9,F&&(e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,e.canvas.width,e.canvas.height),e.restore(),F.bg(l,u,g,s,c,h,y,m,d));break}case k.HEATMAP_WORLD_INTENSITY:{let l=n.getUint32(t,!0);t+=4;let u=n.getUint32(t,!0);t+=4;let g=n.getUint32(t,!0);t+=4;let s=n.getUint32(t,!0);t+=4;let c=n.getUint32(t,!0);t+=4;let h=n.getUint32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let m=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let p=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4;let M=n.getFloat32(t,!0);t+=4;let C=n.getFloat32(t,!0);t+=4;let R=n.getFloat32(t,!0);t+=4;let H=n.getUint32(t,!0);t+=4;let B=a[t];t+=1;let U=n.getFloat32(t,!0);t+=4;let G=(B&2)!==0,O=(B&4)!==0,I=B&8?1:0,N=c*h;if(t+N>a.byteLength){t=a.byteLength;break}if(F){let Y=N>0?new Uint8Array(a.buffer,a.byteOffset+t,N):null;F.heatmap({worldCols:l,worldRows:u,patchX:g,patchY:s,patchW:c,patchH:h,srcX:y,srcY:m,srcW:d,srcH:p,destX:b,destY:M,destW:C,destH:R,lutSeq:H,hd:G,subpx:O,subTexelX:U,fullRebuild:(B&1)!==0,layer:I,clip:it},Y)}t+=N;break}case k.OB_HEATMAP:{let l=n.getUint32(t,!0);t+=4;let u=n.getUint32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let s=n.getFloat32(t,!0);t+=4;let c=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let y=a[t],m=a[t+1],d=a[t+2],p=a[t+3];t+=4;let b=n.getFloat32(t,!0);t+=4;let M=n.getUint32(t,!0);t+=4,t+=1;let C=l*u*2;if(t+C>a.byteLength){t=a.byteLength;break}F&&typeof F.obHeatmap=="function"&&F.obHeatmap({cols:l,rows:u,destX:g,destY:s,destW:c,destH:h,bgR:y,bgG:m,bgB:d,bgA:p,alphaMul:b,lutSeq:M},C>0?new Uint8Array(a.buffer,a.byteOffset+t,C):null),t+=C;break}default:t=f;break}}if(tt&&_){let ct=z.canvas.width/i,l=z.canvas.height/i;z.drawImage(_.getCanvas(),0,0,ct,l),_.invalidate()}L&&L.flush()}var Re=`#version 300 es
14
+ var ce=-Math.PI/2,lt=new WeakMap;function Ht(t,a){let o=lt.get(t);o||(o=new Map,lt.set(t,o));let i=o.get(a);if(i)return i;o.size>=128&&o.clear();let u=a*.259,p=a*.432,E=t.createRadialGradient(u,p,0,u,p,a*1.45);E.addColorStop(0,"rgba(0,0,0,0)"),E.addColorStop(1,"rgba(0,0,0,0.59)");let y=a*.135,v=a*.225,n=t.createRadialGradient(y,v,0,y,v,a*.38);return n.addColorStop(0,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),i={dark:E,spec:n},o.set(a,i),i}function ft(t,a,o,i,u,p,E,y,v,n,r,e,A,P){if(!(i>0))return;let x=Math.min(1,Math.max(0,u)),X=x*Math.PI;if(t.save(),t.translate(a,o),x>=.999||x<=.001){let c=x>=.999?[p,E,y,v]:[n,r,e,A];t.beginPath(),t.arc(0,0,i,0,Math.PI*2),t.fillStyle=`rgba(${c[0]},${c[1]},${c[2]},${(c[3]/255).toFixed(3)})`,t.fill()}else t.beginPath(),t.moveTo(0,0),t.arc(0,0,i,ce-X,ce+X),t.closePath(),t.fillStyle=`rgba(${p},${E},${y},${(v/255).toFixed(3)})`,t.fill(),t.beginPath(),t.moveTo(0,0),t.arc(0,0,i,ce+X,ce-X+Math.PI*2),t.closePath(),t.fillStyle=`rgba(${n},${r},${e},${(A/255).toFixed(3)})`,t.fill(),i>=4&&(t.strokeStyle="rgba(20,20,20,0.45)",t.lineWidth=Math.max(1,i*.08),t.beginPath(),t.moveTo(0,0),t.lineTo(i*Math.cos(ce-X),i*Math.sin(ce-X)),t.moveTo(0,0),t.lineTo(i*Math.cos(ce+X),i*Math.sin(ce+X)),t.stroke());if(P&&i>=4){let c=Ht(t,Math.round(i));t.beginPath(),t.arc(0,0,i,0,Math.PI*2),t.fillStyle=c.dark,t.fill(),t.fillStyle=c.spec,t.fill()}t.restore()}var ne=`#version 300 es
15
+ precision highp float;
16
+ precision highp int;
17
+ precision highp sampler2D;
18
+ `,ve=`
19
+ uniform ivec2 uSize;
20
+ uniform ivec2 uOff;
21
+ ivec2 _phys(int x, int y) { return ivec2((x + uOff.x) % uSize.x, (y + uOff.y) % uSize.y); }
22
+ // A raw field is R32F signed, or RG32F per side (the GPU book raster): the bigger
23
+ // side wins, signed \u2014 gpu.rs \`flush_price_band\`.
24
+ float _raw(sampler2D t, ivec2 p, int rg) {
25
+ vec4 v = texelFetch(t, p, 0);
26
+ return rg != 0 ? (v.r >= v.g ? v.r : -v.g) : v.r;
27
+ }
28
+ // Low mantissa bit of a raw cell = "short-lived noise" (render::buffer::is_noise).
29
+ // The bit is SET on an honest cell, clear on noise \u2014 cells fold by MAX and the honest
30
+ // copy of a run must win (buffer::field_cell).
31
+ bool isNoise(float v) { return v != 0.0 && (floatBitsToUint(v) & 1u) == 0u; }
32
+ float cellSize(float v) { return uintBitsToFloat(floatBitsToUint(v) & ~1u); }
33
+ float fieldCell(float v, bool noise) {
34
+ if (v == 0.0) return v;
35
+ uint b = floatBitsToUint(v);
36
+ return uintBitsToFloat(noise ? (b & ~1u) : (b | 1u));
37
+ }
38
+ // The flag is cleared BEFORE the multiply: left in, it is a 1-ulp term that compounds
39
+ // per path and the GPU raster drifts from the CPU walk. Mirrors buffer::scale_noise.
40
+ float scaleNoise(float v, float f) { return fieldCell(cellSize(v) * f, isNoise(v)); }
41
+ `,Xt=`${ne}
42
+ void main() {
43
+ vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
44
+ gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
45
+ }`,$t=`${ne}${ve}
46
+ uniform sampler2D uAcc;
47
+ uniform int uAccRG;
48
+ uniform int uRadius;
49
+ uniform float uInv2S2;
50
+ out vec4 frag;
51
+ void main() {
52
+ ivec2 p = ivec2(gl_FragCoord.xy);
53
+ int ly = (p.y - uOff.y + uSize.y) % uSize.y;
54
+ float c = _raw(uAcc, p, uAccRG);
55
+ float pos = max(c, 0.0);
56
+ float neg = max(-c, 0.0);
57
+ for (int i = 1; i <= 64; i++) {
58
+ if (i > uRadius) break;
59
+ float w = exp(-float(i * i) * uInv2S2);
60
+ int yu = ly - i;
61
+ if (yu >= 0) {
62
+ float u = _raw(uAcc, _phys(p.x - uOff.x + uSize.x, yu), uAccRG) * w;
63
+ pos = max(pos, u);
64
+ neg = max(neg, -u);
65
+ }
66
+ int yd = ly + i;
67
+ if (yd < uSize.y) {
68
+ float d = _raw(uAcc, _phys(p.x - uOff.x + uSize.x, yd), uAccRG) * w;
69
+ pos = max(pos, d);
70
+ neg = max(neg, -d);
71
+ }
72
+ }
73
+ frag = vec4(pos - neg, 0.0, 0.0, 1.0);
74
+ }`,Wt=`${ne}${ve}
75
+ uniform sampler2D uCol;
76
+ uniform int uBase;
77
+ uniform int uOpenEnd;
78
+ uniform int uFadeFrom;
79
+ uniform float uFadeSpan;
80
+ out vec4 frag;
81
+ void main() {
82
+ ivec2 p = ivec2(gl_FragCoord.xy);
83
+ int lx = (p.x - uOff.x + uSize.x) % uSize.x;
84
+ float tb = 1.0 - float(uBase - uFadeFrom) / uFadeSpan;
85
+ vec2 v = vec2(0.0);
86
+ if (tb > 0.0 && lx < uOpenEnd) {
87
+ float tc = 1.0 - float(lx - uFadeFrom) / uFadeSpan;
88
+ // Both channels: an RG field scales per side, an R field uses .r alone.
89
+ vec2 src = texelFetch(uCol, ivec2(0, p.y), 0).rg;
90
+ // A multiply wipes the noise bit; carry it onto the projected column.
91
+ float f = tc / tb;
92
+ v = vec2(scaleNoise(src.r, f), scaleNoise(src.g, f));
93
+ }
94
+ frag = vec4(v, 0.0, 1.0);
95
+ }`,Vt=`${ne}${ve}
96
+ uniform sampler2D uField;
97
+ uniform int uFieldRG;
98
+ uniform int uVisTop;
99
+ uniform int uVisRows;
100
+ out vec4 frag;
101
+ void main() {
102
+ int lx = int(gl_FragCoord.x);
103
+ float m = 0.0;
104
+ for (int i = 0; i < 8192; i++) {
105
+ if (i >= uVisRows) break;
106
+ m = max(m, abs(_raw(uField, _phys(lx, uVisTop + i), uFieldRG)));
107
+ }
108
+ frag = vec4(m, 0.0, 0.0, 1.0);
109
+ }`,zt=`${ne}
110
+ uniform sampler2D uCol;
111
+ uniform int uCols;
112
+ out vec4 frag;
113
+ void main() {
114
+ float m = 0.0;
115
+ for (int i = 0; i < 8192; i++) {
116
+ if (i >= uCols) break;
117
+ m = max(m, texelFetch(uCol, ivec2(i, 0), 0).r);
118
+ }
119
+ frag = vec4(m, 0.0, 0.0, 1.0);
120
+ }`,Ne=256,Yt=`${ne}${ve}
121
+ uniform sampler2D uField;
122
+ uniform int uFieldRG;
123
+ uniform sampler2D uMax;
124
+ uniform int uCols;
125
+ uniform int uVisTop;
126
+ void main() {
127
+ int lx = gl_VertexID % uCols;
128
+ int ly = uVisTop + gl_VertexID / uCols;
129
+ float m = abs(_raw(uField, _phys(lx, ly), uFieldRG));
130
+ gl_PointSize = 1.0;
131
+ if (!(m > 0.0)) { gl_Position = vec4(2.0, 2.0, 0.0, 1.0); return; }
132
+ float mx = texelFetch(uMax, ivec2(0, 0), 0).r;
133
+ float logMin = log(1e-10);
134
+ float range = log(max(mx, 1e-10)) - logMin;
135
+ if (!(range > 0.0)) range = 1.0;
136
+ int slot = clamp(int((log(max(m, 1e-10)) - logMin) * (255.0 / range)), 0, 255);
137
+ float lane = float(gl_VertexID % ${Ne});
138
+ gl_Position = vec4((float(slot) + 0.5) / 128.0 - 1.0, (lane + 0.5) / ${Ne/2}.0 - 1.0, 0.0, 1.0);
139
+ }`,Kt=`${ne}
140
+ out vec4 frag;
141
+ void main() { frag = vec4(1.0, 0.0, 0.0, 1.0); }`,qt=`${ne}
142
+ uniform sampler2D uHist;
143
+ out vec4 frag;
144
+ void main() {
145
+ int x = int(gl_FragCoord.x);
146
+ float n = 0.0;
147
+ for (int i = 0; i < ${Ne}; i++) n += texelFetch(uHist, ivec2(x, i), 0).r;
148
+ frag = vec4(n, 0.0, 0.0, 1.0);
149
+ }`,jt=`${ne}${ve}
150
+ uniform sampler2D uField;
151
+ uniform int uFieldRG;
152
+ uniform sampler2D uAcc;
153
+ uniform int uAccRG;
154
+ uniform sampler2D uMax;
155
+ uniform float uSat;
156
+ uniform float uFloor;
157
+ uniform float uInvSpan;
158
+ uniform float uGain;
159
+ uniform float uBp;
160
+ uniform float uCurveB;
161
+ uniform float uPowFloor;
162
+ uniform float uPowInvSpan;
163
+ uniform float uFilter;
164
+ uniform float uDim;
165
+ uniform int uLog;
166
+ uniform int uPaintFloor;
167
+ out vec4 frag;
168
+ float crisp(float r) {
169
+ r = clamp(r, 0.0, 1.0);
170
+ return log(1.0 + 10.0 * r) / log(11.0);
171
+ }
172
+ void main() {
173
+ ivec2 l = ivec2(gl_FragCoord.xy);
174
+ ivec2 p = _phys(l.x, l.y);
175
+ float a = _raw(uField, p, uFieldRG);
176
+ float rawCell = _raw(uAcc, p, uAccRG);
177
+ float mag = abs(a);
178
+ // Short-lived noise keeps its honest size (the window was measured on it) and is
179
+ // attenuated on the RAMP below. Scaling the size instead does almost nothing: above
180
+ // the saturation reference every size shares the same 1 - uBp tail. Read off the raw
181
+ // cell \u2014 the blur averages the flag away. Mirrors gpu.rs byte_of.
182
+ bool noise = isNoise(rawCell);
183
+ if (!(mag > 0.0)) { frag = vec4(0.0); return; }
184
+ float raw;
185
+ if (mag <= uFloor) {
186
+ if (uPaintFloor == 0 || rawCell == 0.0) { frag = vec4(0.0); return; }
187
+ raw = 0.0;
188
+ } else if (mag >= uSat) {
189
+ float mx = texelFetch(uMax, ivec2(0, 0), 0).r;
190
+ float invTail = mx > uSat ? 1.0 / (mx - uSat) : 0.0;
191
+ raw = invTail <= 0.0 ? 1.0 : uBp + clamp((mag - uSat) * invTail, 0.0, 1.0) * (1.0 - uBp);
192
+ } else {
193
+ float band = uLog != 0
194
+ ? crisp((mag - uFloor) * uInvSpan * uGain)
195
+ : clamp((pow(mag, uCurveB) - uPowFloor) * uPowInvSpan * uGain, 0.0, 1.0);
196
+ raw = band * uBp;
197
+ }
198
+ if (noise) raw *= uDim;
199
+ float lvl = (!noise && uFilter > 0.0 && mag >= uFilter) ? 127.0 : 1.0 + floor(raw * 125.0 + 0.5);
200
+ float b = a >= 0.0 ? lvl : 128.0 + lvl;
201
+ frag = vec4(b / 255.0, 0.0, 0.0, 1.0);
202
+ }`;var Se=`#version 300 es
203
+ precision highp float;
204
+ precision highp int;
205
+ precision highp usampler2D;
206
+ precision highp isampler2D;
207
+ `,dt=`
208
+ // EVERY cell is normalised, and the bit is SET on an honest one: cells fold by MAX,
209
+ // so of two copies of a run at one size the honest copy has to win.
210
+ bool isNoise(float v) { return v != 0.0 && (floatBitsToUint(v) & 1u) == 0u; }
211
+ float cellSize(float v) { return uintBitsToFloat(floatBitsToUint(v) & ~1u); }
212
+ float fieldCell(float v, bool noise) {
213
+ if (v == 0.0) return v;
214
+ uint b = floatBitsToUint(v);
215
+ return uintBitsToFloat(noise ? (b & ~1u) : (b | 1u));
216
+ }
217
+ // The flag is cleared BEFORE the multiply \u2014 left in it is a 1-ulp term that compounds
218
+ // per path and this raster drifts from the CPU walk. Mirrors buffer::scale_noise.
219
+ float scaleNoise(float v, float f) { return fieldCell(cellSize(v) * f, isNoise(v)); }
220
+ `,Jt=`${Se}${dt}
221
+ uniform usampler2D uStore;
222
+ uniform int uStoreW;
223
+ uniform uint uBase;
224
+ uniform uint uCap;
225
+ uniform int uNewest;
226
+ uniform isampler2D uColLut;
227
+ uniform int uNB;
228
+ uniform isampler2D uBandLut;
229
+ uniform int uNK;
230
+ uniform int uLutW;
231
+ uniform int uBucket;
232
+ uniform int uShiftE;
233
+ uniform int uShiftK;
234
+ uniform int uRowAgg;
235
+ uniform int uT0Ceil;
236
+ uniform int uTmaxFloor;
237
+ uniform int uOpenFloor;
238
+ uniform int uOpenOk;
239
+ uniform int uOpenC1;
240
+ uniform uint uTip;
241
+ uniform uint uLiveUntil;
242
+ uniform int uCols;
243
+ uniform ivec2 uSize;
244
+ uniform ivec2 uOff;
245
+ uniform ivec2 uCopy;
246
+ uniform int uDimLife;
247
+ flat out float vMag;
248
+ flat out int vBid;
249
+
250
+ const uint LIVE = 0xFFFFFFFFu;
251
+
252
+ // Floor division using only non-negative operands (ES 3.00 leaves negative / undefined).
253
+ int floorDiv(int a, int b) { return a >= 0 ? a / b : -((-a + b - 1) / b); }
254
+
255
+ int colAt(int i) {
256
+ if (i < 0) return -1;
257
+ if (i >= uNB) return uCols + 1;
258
+ return texelFetch(uColLut, ivec2(i % uLutW, i / uLutW), 0).r;
259
+ }
260
+
261
+ void cull() { gl_Position = vec4(-2.0, -2.0, 0.0, 1.0); vMag = 0.0; vBid = 0; }
262
+
263
+ // Low 13 mantissa bits of a wire size carry the run rest-lead CODE (render::buffer::lead_code),
264
+ // the next 3 its held-base code (eighths of the size). Mirrors render::buffer::WIRE_MASK.
265
+ const uint LEAD_MASK = 0x1FFFu;
266
+ const uint WIRE_MASK = 0xFFFFu;
267
+ int leadMs(uint c) {
268
+ if (c < 4096u) return int(c);
269
+ if (c < 6144u) return 4096 + int(c - 4096u) * 64;
270
+ return 135168 + int(c - 6144u) * 4096;
271
+ }
272
+
273
+ void main() {
274
+ uint idx = uNewest != 0 ? uint(gl_InstanceID) : ((uBase + uint(gl_InstanceID)) % uCap);
275
+ uvec4 r = texelFetch(uStore, ivec2(int(idx) % uStoreW, int(idx) / uStoreW), 0);
276
+ float q = uintBitsToFloat(r.w & ~WIRE_MASK);
277
+ uint leadCode = r.w & LEAD_MASK;
278
+ uint baseCode = (r.w >> 13u) & 7u;
279
+ if (q == 0.0) { cull(); return; }
280
+ int start = int(r.y);
281
+ int until = int(r.z == LIVE ? uLiveUntil : r.z);
282
+ if (until < uT0Ceil) { cull(); return; }
283
+ // Key + 2^30: a long-held retired run the live store parks (never open).
284
+ int key = int(r.x);
285
+ bool held = key >= 0x20000000;
286
+ if (held) key -= 0x40000000;
287
+ bool open = uNewest != 0 && !held && uint(until) >= uTip;
288
+ if (open) {
289
+ if (uOpenOk == 0 || start > uOpenFloor) { cull(); return; }
290
+ } else if (start > uTmaxFloor) { cull(); return; }
291
+ int bLo = floorDiv(start + uShiftE, uBucket);
292
+ int c0 = colAt(bLo);
293
+ int c1;
294
+ if (open) {
295
+ c1 = max(uOpenC1, c0);
296
+ } else {
297
+ int bHi = floorDiv(until + uShiftE, uBucket) - 1;
298
+ if (bHi < bLo) { cull(); return; }
299
+ c1 = colAt(bHi);
300
+ }
301
+ int band = floorDiv(key + uShiftK, uRowAgg);
302
+ if (band < 0 || band >= uNK) { cull(); return; }
303
+ ivec2 rows = texelFetch(uBandLut, ivec2(band % uLutW, band / uLutW), 0).rg;
304
+ if (rows.y < rows.x) { cull(); return; }
305
+ int v = gl_VertexID;
306
+ float cx = (v == 1 || v == 2 || v == 4) ? 1.0 : 0.0;
307
+ float cy = (v == 2 || v == 4 || v == 5) ? 1.0 : 0.0;
308
+ // Logical cell edges \u2192 physical (ring offset + the copy this draw covers).
309
+ float x = mix(float(c0), float(c1 + 1), cx) + float(uOff.x + uCopy.x);
310
+ float y = mix(float(rows.x), float(rows.y + 1), cy) + float(uOff.y + uCopy.y);
311
+ gl_Position = vec4(x / float(uSize.x) * 2.0 - 1.0, y / float(uSize.y) * 2.0 - 1.0, 0.0, 1.0);
312
+ vBid = q > 0.0 ? 1 : 0;
313
+ // Short rest: FLAG the whole rect (extend included) \u2014 the dim itself lands at
314
+ // colour time, past the window. Life is the tip, not the painted edge.
315
+ bool noise = false;
316
+ if (uDimLife > 0 && leadCode < LEAD_MASK) {
317
+ // Life ends at min(until, tip) \u2014 from the run alone, like every other path.
318
+ uint lifeUntil = min(uint(max(until, 0)), uTip);
319
+ uint lead = uint(leadMs(leadCode));
320
+ uint restStart = r.y >= lead ? r.y - lead : 0u;
321
+ noise = lifeUntil >= restStart && lifeUntil - restStart < uint(uDimLife);
322
+ }
323
+ // Grew out of a held size: paint that size, honest (data::rest_cell).
324
+ bool based = noise && baseCode > 0u;
325
+ vMag = fieldCell(based ? abs(q) * (float(baseCode) * 0.125) : abs(q), noise && !based);
326
+ }`,Qt=`${Se}${dt}
327
+ uniform ivec2 uSize;
328
+ uniform ivec2 uOff;
329
+ uniform int uFadeFrom;
330
+ uniform float uFadeSpan;
331
+ flat in float vMag;
332
+ flat in int vBid;
333
+ out vec4 frag;
334
+ void main() {
335
+ int lx = (int(gl_FragCoord.x) - uOff.x + uSize.x) % uSize.x;
336
+ float v = vMag;
337
+ // The taper is a multiply: carry the noise bit across it.
338
+ if (lx >= uFadeFrom) v = scaleNoise(v, 1.0 - float(lx - uFadeFrom) / uFadeSpan);
339
+ frag = vBid != 0 ? vec4(v, 0.0, 0.0, 0.0) : vec4(0.0, v, 0.0, 0.0);
340
+ }`,Zt=`${Se}
341
+ in uint aId;
342
+ in uvec4 aRun;
343
+ uniform int uStoreW;
344
+ uniform ivec2 uStoreSize;
345
+ flat out uvec4 vRun;
346
+ void main() {
347
+ int id = int(aId);
348
+ vec2 p = (vec2(float(id % uStoreW), float(id / uStoreW)) + 0.5) / vec2(uStoreSize);
349
+ gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
350
+ gl_PointSize = 1.0;
351
+ vRun = aRun;
352
+ }`,eo=`${Se}
353
+ flat in uvec4 vRun;
354
+ out uvec4 frag;
355
+ void main() { frag = vRun; }`,to=`${Se}
356
+ uniform usampler2D uOld;
357
+ uniform uint uTail;
358
+ uniform uint uOldCap;
359
+ uniform uint uNewCap;
360
+ uniform int uStoreW;
361
+ uniform ivec2 uNewSize;
362
+ flat out uvec4 vRun;
363
+ void main() {
364
+ uint a = uTail + uint(gl_VertexID);
365
+ uint w = uint(uStoreW);
366
+ uint s = a % uOldCap;
367
+ uint d = a % uNewCap;
368
+ vRun = texelFetch(uOld, ivec2(int(s % w), int(s / w)), 0);
369
+ vec2 p = (vec2(float(d % w), float(d / w)) + 0.5) / vec2(uNewSize);
370
+ gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
371
+ gl_PointSize = 1.0;
372
+ }`;var ht=[null,null,null,null];function Oe(t,a,o,i){if(a%4===0)return new Uint32Array(t,a,o);let u=ht[i];return(!u||u.length<o)&&(u=ht[i]=new Uint32Array(Math.max(o,16384))),new Uint8Array(u.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),u.subarray(0,o)}function mt(t,a,o){let i=a.byteLength;if(o+27>i)return{p:null,next:i};let u={layer:a[o],flags:a[o+1]},p=o+3,E=()=>{let r=t.getUint32(p,!0);return p+=4,r};u.head=E(),u.tail=E(),u.histN=E(),u.liveN=E(),u.idCap=E(),u.preN=E();let y=u.histN*4,v=u.liveN*5,n=u.preN*4;return p+(y+v+n)*4>i?{p:null,next:i}:(u.hist=y?Oe(a.buffer,a.byteOffset+p,y,0):null,p+=y*4,u.live=v?Oe(a.buffer,a.byteOffset+p,v,1):null,p+=v*4,u.pre=n?Oe(a.buffer,a.byteOffset+p,n,3):null,p+=n*4,{p:u,next:p})}function bt(t,a,o){let i=()=>{let E=t.getInt32(o,!0);return o+=4,E},u=()=>{let E=t.getUint32(o,!0);return o+=4,E},p={bucket:i(),shiftE:i(),nB:u(),shiftK:i(),rowAgg:i(),nK:u(),t0Ceil:i(),tmaxFloor:i(),openFloor:i(),openOk:u(),openC1:i(),tip:u(),liveUntil:u(),histFrom:u(),walkHi:u(),aTo:u(),bFrom:u(),bTo:u(),hFrom:u(),hTo:u(),dimLife:i(),dim:0};return p.dim=t.getFloat32(o,!0),o+=4,{k:p,o}}function _t(t,a,o){let i=o.nB+2*o.nK;if(a+i*4>t.byteLength)return null;let u=Oe(t.buffer,t.byteOffset+a,i,2),p=new Int32Array(u.buffer,u.byteOffset,i);return o.colLut=p.subarray(0,o.nB),o.bandLut=p.subarray(o.nB),a+i*4}var no=32,ro=4294967295;var xe=null;function ao(t,a,o){return a%4===0?new Float32Array(t,a,o):((!xe||xe.length<o)&&(xe=new Float32Array(Math.max(o,65536))),new Uint8Array(xe.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),xe.subarray(0,o))}function Tt(t,a,o){let i=a.byteLength;if(o+104>i)return{p:null,data:null,next:i};let u=a[o],p=a[o+1],E=o+3,y=()=>{let x=t.getUint32(E,!0);return E+=4,x},v=()=>{let x=t.getInt32(E,!0);return E+=4,x},n=()=>{let x=t.getFloat32(E,!0);return E+=4,x},r={layer:u,flags:p,seq:y(),baseSeq:y(),cols:y(),rows:y(),shiftX:v(),shiftY:v(),dirtyLo:y(),openR0:y(),openR1:y(),dilateLo:y(),sigma:n(),radius:y(),visTop:y(),rowsVis:y(),hi:n(),lo:n(),gain:n(),curveB:n(),breakpoint:n(),filter:n(),projBase:y(),openEnd:y(),fadeFrom:y(),fadeSpan:n(),headHi:y()};if(p&no){if(E+81>i)return{p:null,data:null,next:i};let x=bt(t,a,E);r.raster=x.k,E=x.o}if(E+=1+a[E],r.raster){let x=_t(a,E,r.raster);if(x===null)return{p:null,data:null,next:i};E=x}r.aLo=Math.min(r.dirtyLo,r.cols),r.head=Math.min(r.headHi,r.aLo),r.aHi=Math.max(r.aLo,r.projBase===ro?r.cols:Math.min(r.projBase+1,r.cols)),r.r1=Math.min(r.openR1,r.rows);let e=Math.max(0,r.r1-r.openR0),A=r.raster?0:r.rows*(r.aHi-r.aLo)+e*(r.aLo-r.head)+r.rows*r.head;if(E+A*4>i)return{p:null,data:null,next:i};let P=A>0?ao(a.buffer,a.byteOffset+E,A):null;return{p:r,data:P,next:E+A*4}}var re=new Float32Array(16384);function Et(t,a,o){let i=a.byteLength;if(o+47>i)return{p:null,col:null,next:i};let u=o+3,p=()=>{let n=t.getFloat32(u,!0);return u+=4,n},E=()=>{let n=t.getUint32(u,!0);return u+=4,n},y={x:p(),y:p(),w:p(),h:p(),barFrac:p(),zoneFrac:p(),opacity:p(),steepness:p(),normMax:p(),backdrop:E(),rows:E()},v=y.rows;if(u+v*8>i)return{p:null,col:null,next:i};re.length<v*8&&(re=new Float32Array(Math.max(v*8,re.length*2)));for(let n=0;n<v;n++,u+=4){let r=n*8;re[r]=t.getFloat32(u,!0),re[r+1]=re[r+2]=re[r+3]=0}for(let n=0;n<v;n++){let r=n*8+4;for(let e=0;e<4;e++,u++)re[r+e]=a[u]/255}return{p:y,col:re.subarray(0,v*8),next:u}}var qo=new Float32Array(4);var C={FILL_RECT:1,FILL_ROUND_RECT:27,FILL_ELLIPSE:38,FILL_RECT_SMOOTH_X:30,STROKE_RECT:2,LINE:3,CANDLE:34,CANDLE_BORDERED:36,OHLC_BAR:37,DASHED_LINE:4,POLYLINE:5,TEXT:6,STYLED_TEXT:33,CIRCLE:7,TRIANGLE:8,SAVE:9,RESTORE:10,CLIP_RECT:11,ROTATED_TEXT:12,BUBBLE_3D:13,BUBBLE_PIE:39,FILL_POLYGON:14,DASHED_POLYLINE:15,GRADIENT_RECT:16,GRADIENT_RECT_H:28,GRADIENT_RECT_H_MULTI:29,LINEAR_POLYLINE:17,SMOOTH_POLYLINE:24,BEGIN_HEATMAP_LAYER:18,END_HEATMAP_LAYER:19,HEATMAP_BITMAP:20,LINE_WITH_EXTEND:21,LABEL_CALLOUT:22,HEATMAP_WORLD:23,HEATMAP_BG:31,HEATMAP_WORLD_INTENSITY:32,HEATMAP_FIELD:40,HEATMAP_BOOK_SYNC:41,HEATMAP_DEPTH:42,OVERLAY:43,OB_HEATMAP:35,DRAW_IMAGE:25,FILL_SMOOTH_BAND:26,END_FRAME:255},io=(()=>{try{return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}catch{return!1}})(),so=io?1.5:1/0;function uo(){return typeof window<"u"&&window.devicePixelRatio||1}function co(t,a){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,a):Object.assign(document.createElement("canvas"),{width:t,height:a})}var le=null,yt=null;function lo(t,a){return le?(le.width!==t||le.height!==a)&&(le.width=t,le.height=a):(le=co(t,a),yt=le.getContext("2d")),yt}var Qe=new Float32Array(0);function fo(t){return Qe.length<t&&(Qe=new Float32Array(t)),Qe}var Le=new Float64Array(0),Ze=new Float64Array(0),et=new Float64Array(0),Me=new Float64Array(0);function ho(t){return Le.length<t&&(Le=new Float64Array(t)),Le}function mo(t){return Ze.length<t&&(Ze=new Float64Array(t)),Ze}function bo(t){return et.length<t&&(et=new Float64Array(t)),et}function _o(t){return Me.length<t&&(Me=new Float64Array(t)),Me}function tt(t,a){if(a<2)return;let o=a-1,i=ho(o),u=mo(o),p=bo(o);for(let y=0;y<o;y++){let v=t[y*2],n=t[y*2+1],r=t[(y+1)*2],e=t[(y+1)*2+1];i[y]=r-v,u[y]=e-n,p[y]=i[y]>0?u[y]/i[y]:0}let E=_o(a);E[0]=p[0],E[a-1]=p[o-1];for(let y=1;y<o;y++){let v=p[y-1],n=p[y];E[y]=v*n<=0?0:(v+n)*.5}for(let y=0;y<o;y++){let v=p[y];if(v===0){E[y]=0,E[y+1]=0;continue}let n=E[y]/v,r=E[y+1]/v,e=n*n+r*r;if(e>9){let A=3/Math.sqrt(e);E[y]=A*n*v,E[y+1]=A*r*v}}}function pt(t,a,o){let i=o-1,u=Le,p=Me;for(let E=0;E<i;E++){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(n,r);continue}let A=e/3;t.bezierCurveTo(y+A,v+p[E]*A,n-A,r-p[E+1]*A,n,r)}}function To(t,a,o){let i=o-1,u=Le,p=Me;for(let E=i-1;E>=0;E--){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(y,v);continue}let A=e/3;t.bezierCurveTo(n-A,r-p[E+1]*A,y+A,v+p[E]*A,y,v)}}var Rt=["left","center","right"],ge=new Map,Eo=4096;function yo(t,a,o,i){return t<<24|a<<16|o<<8|i}function g(t,a,o,i){let u=yo(t,a,o,i),p=ge.get(u);return p||(p=`rgba(${t},${a},${o},${(i/255).toFixed(3)})`,ge.size>=Eo&&ge.clear(),ge.set(u,p),p)}var po=new TextDecoder,Ft=typeof SharedArrayBuffer>"u"?null:SharedArrayBuffer,at=t=>Ft&&t.buffer instanceof Ft?t.slice():t,ke=(t,a,o)=>po.decode(at(t.subarray(a,a+o))),Ro=.0137;function Te(t){return Math.round(t+Ro)}function Xe(t,a){return Te(t*a)/a}function ot(t,a){return $e?Ce(t,a):t}var Ge=new Map;function He(t,a){let o=Ge.get(a);if(o!==void 0)return o;let i=t.font,u=t.textBaseline;t.font=a,t.textBaseline="alphabetic";let p=t.measureText("0"),E=p.actualBoundingBoxAscent||0,y=p.actualBoundingBoxDescent||0;return o=(E-y)/2,(!Number.isFinite(o)||o===0)&&(o=(parseFloat(a)||11)*.35),Ge.size>=256&&Ge.clear(),Ge.set(a,o),t.font=i,t.textBaseline=u,o}var At=new WeakMap;function Fo(t,a,o,i,u){let p=At.get(t);p||(p=new Map,At.set(t,p));let E=Math.round(a),y=`${E}|${o}|${i}|${u}`,v=p.get(y);if(v)return v;let n=-E*.25,r=-E*.25,e=t.createRadialGradient(n,r,E*.08,0,0,E);e.addColorStop(0,i),e.addColorStop(1,o);let A=null;u&&(A=t.createRadialGradient(0,0,E*.85,0,0,E*1.2),A.addColorStop(0,u),A.addColorStop(1,u.replace(/[\d.]+\)$/,"0)")));let P=E*.2,x=t.createRadialGradient(n,r,0,n,r,P);return x.addColorStop(0,"rgba(255,255,255,0.22)"),x.addColorStop(1,"rgba(255,255,255,0)"),v={body:e,glow:A,spec:x,hlX:n,hlY:r,specR:P},p.set(y,v),v}function me(t,a,o){let i=Math.max(1,Math.round(a*o)),u=Te(t*o)/o;return i&1?u+.5/o:u}var $e=!0;var wt=0,vt=!1;function nt(t,a){return vt?Ce(t,a):t}function rt(t,a){return vt?Xe(t,a):t}function Ce(t,a){return(Te(t*a+wt)-wt)/a}function be(t,a,o){if(!$e)return t;let i=Ce(t,o);return Math.max(1,Math.round(a*o))&1?i+.5/o:i}function _e(t,a,o,i,u){if(!$e)return St(t,a,o,i,u);let p=Ce(t,u),E=Te(a*u),y=Ce(t+o,u),v=Te((a+i)*u);return{x:p,y:E/u,w:y-p,h:(v-E)/u}}function Ao(t,a,o,i,u){return{x:Math.round(t*u)/u,y:Math.round(a*u)/u,w:Math.max(1,Math.round(o*u))/u,h:Math.max(1,Math.round(i*u))/u}}function St(t,a,o,i,u){let p=Te(a*u),E=Te((a+i)*u);return{x:t,y:p/u,w:o,h:(E-p)/u}}function xt(t,a,o,i,u=null,p=null,E=null,y=null){let v=a.buffer;if(o+i>v.byteLength)return;let n=new DataView(v,o,i),r=new Uint8Array(v,o,i),e=0,A="",P="",x=-1,X="",c=Math.max(1,Math.abs(t.getTransform?.().a||uo())),de=null,I=[],L=y&&y.geom&&y.geom.available?y.geom:null,z=t,te=!1,oe="";for(;e<i;){let he=r[e];if(e+=1,he===C.END_FRAME)break;switch(he){case C.FILL_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,R,0,0,0,0,0,0,0);break}let b=g(f,h,_,R);b!==A&&(t.fillStyle=b,A=b);let F=_e(s,d,m,l,c);t.fillRect(F.x,F.y,F.w,F.h);break}case C.FILL_RECT_SMOOTH_X:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,R,0,0,0,0,0,0,1);break}let b=g(f,h,_,R);b!==A&&(t.fillStyle=b,A=b);let F=St(s,d,m,l,c);t.fillRect(F.x,F.y,F.w,F.h);break}case C.FILL_ELLIPSE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];if(e+=4,L){L.rect(s-m,d-l,m*2,l*2,f,h,_,R,-1,0,0,0,0,0,2);break}let b=g(f,h,_,R);b!==A&&(t.fillStyle=b,A=b),t.beginPath(),t.ellipse(s,d,Math.max(m,.1),Math.max(l,.1),0,0,Math.PI*2),t.fill();break}case C.FILL_ROUND_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.rect(s,d,m,l,f,h,_,R,b,0,0,0,0,0,0);break}let F=g(f,h,_,R);F!==A&&(t.fillStyle=F,A=F);let T=_e(s,d,m,l,c),w=Math.min(b,T.w*.5,T.h*.5);w<=.5?t.fillRect(T.x,T.y,T.w,T.h):(t.beginPath(),t.moveTo(T.x+w,T.y),t.lineTo(T.x+T.w-w,T.y),t.arcTo(T.x+T.w,T.y,T.x+T.w,T.y+w,w),t.lineTo(T.x+T.w,T.y+T.h-w),t.arcTo(T.x+T.w,T.y+T.h,T.x+T.w-w,T.y+T.h,w),t.lineTo(T.x+w,T.y+T.h),t.arcTo(T.x,T.y+T.h,T.x,T.y+T.h-w,w),t.lineTo(T.x,T.y+w),t.arcTo(T.x,T.y,T.x+w,T.y,w),t.closePath(),t.fill());break}case C.STROKE_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){let k=b*.5;L.rect(s-k,d-k,m+b,l+b,0,0,0,0,0,b,f,h,_,R,0);break}let F=g(f,h,_,R);F!==P&&(t.strokeStyle=F,P=F),b!==x&&(t.lineWidth=b,x=b);let T=be(s,b,c),w=me(d,b,c),D=$e?Math.round(m*c)/c:m,M=Math.round(l*c)/c;t.strokeRect(T,w,D,M);break}case C.LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,R,b,0,0);break}let F=g(f,h,_,R);t.beginPath(),F!==P&&(t.strokeStyle=F,P=F),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke();break}case C.CANDLE:case C.CANDLE_BORDERED:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let b=r[e+3],F=g(r[e],r[e+1],r[e+2],b);e+=4;let T=r[e+3],w=g(r[e],r[e+1],r[e+2],T);e+=4;let D=null;he===C.CANDLE_BORDERED&&(D=g(r[e],r[e+1],r[e+2],r[e+3]),e+=4);let M=Math.max(1,Math.floor(_*c)),k=Math.max(1,Math.floor(R*c));M>k&&(M=k);let B=Math.min(Math.max(1,Math.floor(h*c)),k);B<M?B=M:(B^M)&1&&(B-=1);let N=s*c,$=M&1?Math.round(N-.5)+.5:Math.round(N),O=Math.max(1,Math.round(c)),U=Math.round(Math.min(l,f)*c),G=Math.max(U+O,Math.round(Math.max(l,f)*c)),W=Math.round(Math.min(d,m)*c),S=Math.max(W+1,Math.round(Math.max(d,m)*c)),V=Math.min(d,m),Be=Math.max(d,m),Ke=Math.min(l,f),qe=Math.max(l,f);if(V<Ke&&W>=U&&(W=U-1),Be>qe&&S<=G&&(S=G+1),T>0&&(W<U||S>G)){w!==A&&(t.fillStyle=w,A=w);let je=($-M/2)/c,Je=M/c;b===255?t.fillRect(je,W/c,Je,(S-W)/c):(W<U&&t.fillRect(je,W/c,Je,(U-W)/c),S>G&&t.fillRect(je,G/c,Je,(S-G)/c))}let K=$-B/2,J=G-U;if(D===null){b>0&&(F!==A&&(t.fillStyle=F,A=F),t.fillRect(K/c,U/c,B/c,J/c));break}let j=Math.max(1,Math.floor(c));if(D!==A&&(t.fillStyle=D,A=D),B<=2*j||J<=2*j){t.fillRect(K/c,U/c,B/c,J/c);break}b===255?t.fillRect(K/c,U/c,B/c,J/c):(t.fillRect(K/c,U/c,B/c,j/c),t.fillRect(K/c,(G-j)/c,B/c,j/c),t.fillRect(K/c,(U+j)/c,j/c,(J-2*j)/c),t.fillRect((K+B-j)/c,(U+j)/c,j/c,(J-2*j)/c)),b>0&&(F!==A&&(t.fillStyle=F,A=F),t.fillRect((K+j)/c,(U+j)/c,(B-2*j)/c,(J-2*j)/c));break}case C.OHLC_BAR:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let R=r[e];e+=1;let b=Math.max(1,Math.floor(h*c)),F=Math.max(1,Math.floor(c)),T=R&1?F:Math.max(F,Math.floor(b/6));T>b&&(T=b);let w=s*c,M=(T&1?Math.round(w-.5)+.5:Math.round(w))-T/2,k=Math.round(Math.min(m,l)*c),B=Math.max(k+1,Math.round(Math.max(m,l)*c));_!==A&&(t.fillStyle=_,A=_),t.fillRect(M/c,k/c,T/c,(B-k)/c);let N=Math.floor((Math.floor(b*.8)-T)/2);if(N>=1){if(!(R&2)){let O=Math.round(d*c-T/2);t.fillRect((M-N)/c,O/c,N/c,T/c)}let $=Math.round(f*c-T/2);t.fillRect((M+T)/c,$/c,N/c,T/c)}break}case C.DASHED_LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];e+=4;let b=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,R,b,F,T);break}let w=g(f,h,_,R);t.beginPath(),w!==P&&(t.strokeStyle=w,P=w),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([F,T]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke(),t.setLineDash([]);break}case C.LINEAR_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];e+=4;let h=n.getFloat32(e,!0);if(e+=4,L){let R=0,b=0;for(let F=0;F<s;F++){let T=n.getFloat32(e,!0),w=n.getFloat32(e+4,!0);e+=8,F>0&&L.seg(R,b,T,w,d,m,l,f,h,0,0),R=T,b=w}break}let _=g(d,m,l,f);if(s>1){t.beginPath(),_!==P&&(t.strokeStyle=_,P=_),h!==x&&(t.lineWidth=h,x=h),t.setLineDash([]),t.lineJoin="miter",t.lineCap="butt",t.miterLimit=10;let R=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4,t.moveTo(R,b);for(let F=1;F<s;F++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke()}else e+=s*8;break}case C.SMOOTH_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>1){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.stroke()}else e+=s*8;break}case C.POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>0){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;if(t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2)t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3]);else{t.moveTo(l[0],l[1]);for(let f=0;f<s-1;f++){let h=f>0?f-1:0,_=f,R=f+1,b=f<s-2?f+2:s-1,F=l[h*2],T=l[h*2+1],w=l[_*2],D=l[_*2+1],M=l[R*2],k=l[R*2+1],B=l[b*2],N=l[b*2+1],$=w+(M-F)/6,O=D+(k-T)/6,U=M-(B-w)/6,G=k-(N-D)/6;t.bezierCurveTo($,O,U,G,M,k)}}t.stroke()}break}case C.TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h,m!==A&&(t.fillStyle=m,A=m);let R=`${Math.round(l)}px "IBM Plex Mono",monospace`;R!==X&&(t.font=R,X=R),t.textAlign=Rt[f]||"left",t.textBaseline="alphabetic";let b=d+He(t,R);t.fillText(_,ot(s,c),Xe(b,c));break}case C.STYLED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=r[e];e+=1;let _=n.getUint16(e,!0);e+=2;let R=ke(r,e,_);e+=_,m!==A&&(t.fillStyle=m,A=m);let b=h&2?"italic ":"",F=h&1?"700 ":"",T=`${b}${F}${Math.round(l)}px "IBM Plex Mono",monospace`;T!==X&&(t.font=T,X=T),t.textAlign=Rt[f]||"left",t.textBaseline="alphabetic";let w=d+He(t,T);t.fillText(R,ot(s,c),Xe(w,c));break}case C.CIRCLE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3],R=L?"":g(l,f,h,_);e+=4;let b=r[e],F=r[e+1],T=r[e+2],w=r[e+3],D=L?"":g(b,F,T,w);e+=4;let M=n.getFloat32(e,!0);if(e+=4,L){L.disc(s,d,m,l,f,h,_,b,F,T,w,0,0,0,0,M,0);break}t.beginPath(),t.arc(s,d,m,0,Math.PI*2),R!==A&&(t.fillStyle=R,A=R),t.fill(),M>0&&(D!==P&&(t.strokeStyle=D,P=D),M!==x&&(t.lineWidth=M,x=M),t.stroke());break}case C.TRIANGLE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=r[e],R=r[e+1],b=r[e+2],F=r[e+3];if(e+=4,L){L.tri(s,d,m,l,f,h,_,R,b,F);break}let T=g(_,R,b,F);t.beginPath(),t.moveTo(s,d),t.lineTo(m,l),t.lineTo(f,h),t.closePath(),T!==A&&(t.fillStyle=T,A=T),t.fill();break}case C.SAVE:{t.save(),I.push(de);break}case C.RESTORE:{t.restore(),de=I.length?I.pop():null,L&&L.setClip(de),A="",P="",x=-1,X="";break}case C.CLIP_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=_e(s,d,m,l,c);t.beginPath(),t.rect(f.x,f.y,f.w,f.h),t.clip(),de=f,L&&L.setClip(f);break}case C.ROTATED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h;let R=`${l}px sans-serif`;R!==X&&(t.font=R,X=R),m!==A&&(t.fillStyle=m,A=m),t.textAlign="center",t.textBaseline="alphabetic";let b=He(t,R);t.save(),t.translate(s,d),t.rotate(f),t.fillText(_,0,b),t.restore();break}case C.BUBBLE_PIE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],R=r[e+3];e+=4;let b=r[e],F=r[e+1],T=r[e+2],w=r[e+3];e+=4;let D=r[e]!==0;if(e+=1,L){L.pie(s,d,m,l,f,h,_,R,b,F,T,w,D);break}ft(t,s,d,m,l,f,h,_,R,b,F,T,w,D),A="";break}case C.BUBBLE_3D:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3];e+=4;let R=r[e],b=r[e+1],F=r[e+2],T=r[e+3];e+=4;let w=r[e],D=r[e+1],M=r[e+2],k=r[e+3];e+=4;let B=n.getFloat32(e,!0);e+=4;let N=m;if(L){L.disc(s,d,N,l,f,h,_,w,D,M,k,R,b,F,T,B,N<4?0:1);break}if(N<4){let $=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`;t.beginPath(),t.arc(s,d,N,0,Math.PI*2),t.fillStyle=$,t.fill(),A=""}else{let $=Math.round(N),O=N>=6,U=N>=16,G=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`,W=`rgba(${R},${b},${F},${(T/255).toFixed(3)})`,S=U?`rgba(${w},${D},${M},${(k/255*.5).toFixed(3)})`:null,V=Fo(t,$,G,W,S);t.save(),t.translate(s,d),U&&V.glow&&(t.beginPath(),t.arc(0,0,$*1.2,0,Math.PI*2),t.fillStyle=V.glow,t.fill()),t.beginPath(),t.arc(0,0,$,0,Math.PI*2),t.fillStyle=V.body,t.fill(),O&&(t.beginPath(),t.arc(V.hlX,V.hlY,V.specR,0,Math.PI*2),t.fillStyle=V.spec,t.fill()),t.restore(),A=""}break}case C.FILL_POLYGON:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];if(e+=4,L){let _=fo(s*2);for(let R=0;R<s;R++)_[R*2]=n.getFloat32(e,!0),_[R*2+1]=n.getFloat32(e+4,!0),e+=8;L.poly(_,s,d,m,l,f);break}let h=g(d,m,l,f);if(s>2){t.beginPath();let _=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4,t.moveTo(_,R);for(let b=1;b<s;b++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.closePath(),h!==A&&(t.fillStyle=h,A=h),t.fill()}else e+=s*8;break}case C.FILL_SMOOTH_BAND:{let s=n.getUint16(e,!0);e+=2;let d=n.getUint16(e,!0);e+=2;let m=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=new Float32Array(s*2);for(let h=0;h<s;h++)l[h*2]=n.getFloat32(e,!0),e+=4,l[h*2+1]=n.getFloat32(e,!0),e+=4;let f=new Float32Array(d*2);for(let h=0;h<d;h++)f[h*2]=n.getFloat32(e,!0),e+=4,f[h*2+1]=n.getFloat32(e,!0),e+=4;s>=2&&d>=2&&(t.beginPath(),m!==A&&(t.fillStyle=m,A=m),s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.lineTo(f[(d-1)*2],f[(d-1)*2+1]),d===2?t.lineTo(f[0],f[1]):(tt(f,d),To(t,f,d)),t.closePath(),t.fill());break}case C.DASHED_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);if(e+=4,s>1){t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([l,f]),t.lineJoin="round";let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4,t.moveTo(h,_);for(let R=1;R<s;R++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke(),t.setLineDash([])}else e+=s*8;break}case C.GRADIENT_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),R=t.createLinearGradient(_.x,_.y,_.x,_.y+_.h);R.addColorStop(0,f),R.addColorStop(1,h),t.fillStyle=R,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),R=t.createLinearGradient(_.x,_.y,_.x+_.w,_.y);R.addColorStop(0,f),R.addColorStop(1,h),t.fillStyle=R,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H_MULTI:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=_e(s,d,m,l,c),_=t.createLinearGradient(h.x,h.y,h.x+h.w,h.y);for(let R=0;R<f;R++){let b=n.getFloat32(e,!0);e+=4;let F=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4,_.addColorStop(b<0?0:b>1?1:b,F)}t.fillStyle=_,A="",t.fillRect(h.x,h.y,h.w,h.h);break}case C.BEGIN_HEATMAP_LAYER:{let s=e-1,d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);if(e+=4,!u||l===0)break;let f=z.canvas.width,h=z.canvas.height,_=`${d}|${m}|${f}|${h}|${c}`;if(u.getKey()===_&&u.getCanvas()){let R=f/c,b=h/c;z.drawImage(u.getCanvas(),0,0,R,b),e=s+l}else{let R=Math.min(c,so),b=Math.max(1,Math.round(f/c*R)),F=Math.max(1,Math.round(h/c*R)),T=u.ensureSize(b,F,R);if(!T)break;T.save(),T.setTransform(1,0,0,1,0,0),T.clearRect(0,0,b,F),T.restore(),t=T,A="",P="",x=-1,X="",te=!0,oe=_}break}case C.END_HEATMAP_LAYER:{if(!te)break;let s=z.canvas.width/c,d=z.canvas.height/c;z.drawImage(u.getCanvas(),0,0,s,d),u.setKey(oe),t=z,A="",P="",x=-1,X="",te=!1,oe="";break}case C.HEATMAP_BITMAP:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=m*l*4;if(e+f>r.byteLength){e=r.byteLength;break}let h=new Uint8ClampedArray(r.buffer,r.byteOffset+e,f);e+=f;let _=new ImageData(at(h),m,l),R=lo(m,l);if(!R)break;R.putImageData(_,0,0),t.drawImage(le,s,d,m,l);break}case C.HEATMAP_WORLD:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=n.getUint32(e,!0);e+=4;let h=n.getUint32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getFloat32(e,!0);e+=4;let D=n.getFloat32(e,!0);e+=4;let M=n.getFloat32(e,!0);e+=4;let k=r[e];e+=1;let B=(k&1)!==0,N=f*h*4;if(e+N>r.byteLength){e=r.byteLength;break}if(!p||s===0||d===0){e+=N;break}let $=p.ensureSize(s,d);if(!$){e+=N;break}if(B&&$.clearRect(0,0,s,d),N>0){let O=new Uint8ClampedArray(r.buffer,r.byteOffset+e,N),U=new ImageData(at(O),f,h);$.putImageData(U,m,l)}if(e+=N,b>0&&F>0&&D>0&&M>0){let O=Ao(T,w,D,M,c);if(O.w>0&&O.h>0){let U=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(p.getCanvas(),_,R,b,F,O.x,O.y,O.w,O.h),t.imageSmoothingEnabled=U}}break}case C.LINE_WITH_EXTEND:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let b=r[e];e+=1,f!==P&&(t.strokeStyle=f,P=f),h!==x&&(t.lineWidth=h,x=h),t.setLineDash(_>0?[_,R]:[]);let F=1e5,T=s,w=d,D=m,M=l,k=m-s,B=l-d,N=Math.hypot(k,B);if(N>0&&b!==0){let $=k/N,O=B/N;b&1&&(T=s-$*F,w=d-O*F),b&2&&(D=m+$*F,M=l+O*F),b&4&&O<0&&(T=s-$*F,w=d-O*F),b&8&&O>0&&(D=m+$*F,M=l+O*F)}t.beginPath(),t.moveTo(be(T,h,c),me(w,h,c)),t.lineTo(be(D,h,c),me(M,h,c)),t.stroke(),_>0&&t.setLineDash([]);break}case C.LABEL_CALLOUT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let f=g(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let R=r[e];e+=1;let b=r[e];e+=1;let F=n.getUint16(e,!0);e+=2;let T=ke(r,e,F);e+=F;let w=`${Math.round(h)}px "IBM Plex Mono",monospace`;w!==X&&(t.font=w,X=w);let D=4,M=6,k=T.indexOf(`
373
+ `)>=0?T.split(`
374
+ `):[T],B=Math.round(h),N=3,$=0;for(let K=0;K<k.length;K++){let J=t.measureText(k[K]).width;J>$&&($=J)}let O=k.length*B+(k.length-1)*N+D*2,U=Math.ceil($)+D*2,G,W;switch(b){case 1:W=d-M-O,G=s-U/2;break;case 2:W=d+M,G=s-U/2;break;case 3:W=d-O/2,G=s+M;break;case 4:W=d-O/2,G=s-M-U;break;default:W=d-O/2,R===1?G=s-U/2:R===2?G=s-U:G=s;break}let S=_e(G,W,U,O,c),V=Math.min(3,S.w*.5,S.h*.5),Be=()=>{t.beginPath(),V<=.5?t.rect(S.x,S.y,S.w,S.h):(t.moveTo(S.x+V,S.y),t.lineTo(S.x+S.w-V,S.y),t.arcTo(S.x+S.w,S.y,S.x+S.w,S.y+V,V),t.lineTo(S.x+S.w,S.y+S.h-V),t.arcTo(S.x+S.w,S.y+S.h,S.x+S.w-V,S.y+S.h,V),t.lineTo(S.x+V,S.y+S.h),t.arcTo(S.x,S.y+S.h,S.x,S.y+S.h-V,V),t.lineTo(S.x,S.y+V),t.arcTo(S.x,S.y,S.x+V,S.y,V)),t.closePath()};if(m!==A&&(t.fillStyle=m,A=m),Be(),t.fill(),_>0&&(l!==P&&(t.strokeStyle=l,P=l),_!==x&&(t.lineWidth=_,x=_),t.setLineDash([]),Be(),t.stroke()),b>=1&&b<=4){switch(m!==A&&(t.fillStyle=m,A=m),t.beginPath(),b){case 1:t.moveTo(s-M/2,W+O),t.lineTo(s+M/2,W+O),t.lineTo(s,d);break;case 2:t.moveTo(s-M/2,W),t.lineTo(s+M/2,W),t.lineTo(s,d);break;case 3:t.moveTo(G,d-M/2),t.lineTo(G,d+M/2),t.lineTo(s,d);break;case 4:t.moveTo(G+U,d-M/2),t.lineTo(G+U,d+M/2),t.lineTo(s,d);break}t.closePath(),t.fill()}f!==A&&(t.fillStyle=f,A=f),t.textAlign="center",t.textBaseline="alphabetic";let Ke=He(t,w),qe=G+U/2;for(let K=0;K<k.length;K++){let J=W+D+B/2+K*(B+N);t.fillText(k[K],ot(qe,c),Xe(J+Ke,c))}break}case C.DRAW_IMAGE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getUint32(e,!0);if(e+=4,!E||f===0||m<=0||l<=0)break;let h=E.get(f);if(!h)break;try{t.drawImage(h,s,d,m,l)}catch(_){E.delete(f),console.warn("[canvasRenderer] drawImage failed for id="+f,_?.message||_)}break}case C.HEATMAP_BG:{let s=r[e],d=r[e+1],m=r[e+2],l=r[e+3],f=r[e+4],h=r[e+5],_=r[e+6],R=r[e+7],b=r[e+8]!==0;e+=9,y&&(t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.restore(),y.bg(s,d,m,l,f,h,_,R,b));break}case C.HEATMAP_WORLD_INTENSITY:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=n.getUint32(e,!0);e+=4;let h=n.getUint32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getFloat32(e,!0);e+=4;let D=n.getFloat32(e,!0);e+=4;let M=n.getFloat32(e,!0);e+=4;let k=n.getUint32(e,!0);e+=4;let B=r[e];e+=1;let N=n.getFloat32(e,!0);e+=4;let $=(B&2)!==0,O=(B&4)!==0,U=B&8?1:0,G=f*h;if(e+G>r.byteLength){e=r.byteLength;break}if(y){let W=G>0?new Uint8Array(r.buffer,r.byteOffset+e,G):null;y.heatmap({worldCols:s,worldRows:d,patchX:m,patchY:l,patchW:f,patchH:h,srcX:_,srcY:R,srcW:b,srcH:F,destX:T,destY:w,destW:D,destH:M,lutSeq:k,hd:$,subpx:O,subTexelX:N,fullRebuild:(B&1)!==0,layer:U,clip:de},W)}e+=G;break}case C.HEATMAP_FIELD:{let s=Tt(n,r,e);if(e=s.next,s.p&&y&&typeof y.heatField=="function"&&y.heatField(s.p,s.data),a.buffer!==v)return;break}case C.HEATMAP_BOOK_SYNC:{let s=mt(n,r,e);e=s.next,s.p&&y&&typeof y.heatBook=="function"&&y.heatBook(s.p);break}case C.HEATMAP_DEPTH:{let s=Et(n,r,e);e=s.next,s.p&&y&&typeof y.heatDepth=="function"&&y.heatDepth(s.p,s.col);break}case C.OVERLAY:{e+=3,L&&(L.setClip(null),L.flush(),L=null);break}case C.OB_HEATMAP:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=r[e],R=r[e+1],b=r[e+2],F=r[e+3];e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getUint32(e,!0);e+=4,e+=1;let D=s*d*2;if(e+D>r.byteLength){e=r.byteLength;break}y&&typeof y.obHeatmap=="function"&&y.obHeatmap({cols:s,rows:d,destX:m,destY:l,destW:f,destH:h,bgR:_,bgG:R,bgB:b,bgA:F,alphaMul:T,lutSeq:w},D>0?new Uint8Array(r.buffer,r.byteOffset+e,D):null),e+=D;break}default:e=i;break}}if(te&&u){let he=z.canvas.width/c,s=z.canvas.height/c;z.drawImage(u.getCanvas(),0,0,he,s),u.invalidate()}L&&L.flush()}var wo=`#version 300 es
17
375
  in vec2 aPos;
18
376
  uniform vec4 uRect; // clip-space x0,y0 (bottom-left) .. x1,y1 (top-right)
19
377
  out vec2 vUv;
20
378
  void main() {
21
379
  vUv = aPos;
22
380
  gl_Position = vec4(mix(uRect.xy, uRect.zw, aPos), 0.0, 1.0);
23
- }`,Le=`#version 300 es
381
+ }`,vo=`#version 300 es
24
382
  precision highp float;
25
383
  in vec2 vUv;
26
384
  uniform sampler2D uCells; // RG8: R = intensity (0 = empty), G = 0 bid / 1 ask
@@ -53,4 +411,4 @@ void main() {
53
411
  // best is the normalised byte; land on the matching LUT texel centre.
54
412
  vec4 lut = texture(uLut, vec2((best * 255.0 + 0.5) / 256.0, side > 0.5 ? 0.75 : 0.25));
55
413
  outColor = vec4(lut.rgb, lut.a * uAlpha);
56
- }`;function Zt(e,r,o){let f=e.createShader(r);if(e.shaderSource(f,o),e.compileShader(f),!e.getShaderParameter(f,e.COMPILE_STATUS)){let _=e.getShaderInfoLog(f);throw e.deleteShader(f),new Error(`ob shader compile failed: ${_}`)}return f}function te(e,r={}){let o=null,f=null,_=null,E=null,T=null,F=null,P=null,n=null,a=null,t=null,w=-1,D=1,S=1,W=1,i=!1;try{o=e.getContext("webgl2",{alpha:!0,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,desynchronized:!1,premultipliedAlpha:!1})}catch{o=null}if(o)try{let v=Zt(o,o.VERTEX_SHADER,Re),L=Zt(o,o.FRAGMENT_SHADER,Le);if(f=o.createProgram(),o.attachShader(f,v),o.attachShader(f,L),o.linkProgram(f),o.deleteShader(v),o.deleteShader(L),!o.getProgramParameter(f,o.LINK_STATUS))throw new Error(`ob program link failed: ${o.getProgramInfoLog(f)}`);_=o.createVertexArray(),o.bindVertexArray(_),E=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,E),o.bufferData(o.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),o.STATIC_DRAW);let z=o.getAttribLocation(f,"aPos");o.enableVertexAttribArray(z),o.vertexAttribPointer(z,2,o.FLOAT,!1,0,0),o.bindVertexArray(null),T=o.createTexture(),o.bindTexture(o.TEXTURE_2D,T);for(let[tt,ot]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,tt,ot);F=o.createTexture(),o.bindTexture(o.TEXTURE_2D,F);for(let[tt,ot]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,tt,ot);P=o.getUniformLocation(f,"uRect"),n=o.getUniformLocation(f,"uGrid"),a=o.getUniformLocation(f,"uAlpha"),t=o.getUniformLocation(f,"uPool"),o.useProgram(f),o.uniform1i(o.getUniformLocation(f,"uCells"),0),o.uniform1i(o.getUniformLocation(f,"uLut"),1),o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_ALIGNMENT,1),S=e.width,W=e.height,o.viewport(0,0,S,W),i=!0}catch(v){console.warn("[ObWebgl] init failed:",v?.message||v),i=!1}o&&typeof e.addEventListener=="function"&&e.addEventListener("webglcontextlost",v=>{v.preventDefault(),i=!1;try{r.onContextLost?.()}catch{}});function it(v){if(v===w)return;let L=r.fetchLut?.();!L||L.length<512*4||(o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,F),o.texImage2D(o.TEXTURE_2D,0,o.RGBA8,256,2,0,o.RGBA,o.UNSIGNED_BYTE,L),w=v)}return{get available(){return i},obHeatmap(v,L){if(!i||(o.viewport(0,0,S,W),o.clearColor(v.bgR/255,v.bgG/255,v.bgB/255,v.bgA/255),o.clear(o.COLOR_BUFFER_BIT),!v.cols||!v.rows||!L||v.destW<=0||v.destH<=0)||L.length<v.cols*v.rows*2)return;o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T),o.texImage2D(o.TEXTURE_2D,0,o.RG8,v.cols,v.rows,0,o.RG,o.UNSIGNED_BYTE,L),it(v.lutSeq);let z=v.destX*D/S*2-1,tt=(v.destX+v.destW)*D/S*2-1,ot=1-v.destY*D/W*2,ct=1-(v.destY+v.destH)*D/W*2;o.useProgram(f),o.bindVertexArray(_),o.uniform4f(P,z,ct,tt,ot),o.uniform2f(n,v.cols,v.rows),o.uniform1f(a,v.alphaMul),o.uniform1f(t,Math.min(32,Math.max(1,Math.ceil(v.rows/Math.max(v.destH*D,1))))),o.drawArrays(o.TRIANGLE_STRIP,0,4),o.bindVertexArray(null)},resize(v,L,z){S=Math.max(1,v),W=Math.max(1,L),D=z>0?z:1,i&&o.viewport(0,0,S,W)},destroy(){if(i=!1,!!o){try{o.deleteTexture(T),o.deleteTexture(F),o.deleteBuffer(E),o.deleteVertexArray(_),o.deleteProgram(f),o.getExtension("WEBGL_lose_context")?.loseContext()}catch{}o=null}}}}function ee(e,r,o){let f=e&&e[r];typeof f=="function"&&f.apply(e,o||[])}var Ht=null,Nt=null,yt=null;async function ve(){let e=typeof globalThis>"u"?null:globalThis,r=e&&e.__mrdWasmResp;if(!r)return null;e.__mrdWasmResp=null;try{let o=await r;return o&&o.ok?o:null}catch{return null}}function ke(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let e=r=>new URL(r+self.location.search,self.location.href).href;return{glue:e("./chart_engine.js"),wasm:e("./chart_engine_bg.wasm")}}async function oe(){return Ht?{module:Ht,memory:Nt}:yt||(yt=(async()=>{let e=ke(),r=e?await import(e.glue):await import("./chart_engine.js"),o=e?null:await ve(),f=e?e.wasm:o;try{await(f?r.default({module_or_path:f}):r.default())}catch(_){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",_);let E=e?e.wasm:new URL("../wasm/chart_engine_bg.wasm",import.meta.url),T=await fetch(E);if(!T.ok)throw new Error(`WASM fetch failed (${T.status} ${T.statusText}) at ${E}`);let F=await T.arrayBuffer();await r.default(F)}return Nt=r.wasm_memory(),Ht=r,{module:r,memory:Nt}})(),yt.catch(()=>{yt=null}),yt)}async function ne(e){if(!Array.isArray(e)||!e.length||typeof FontFace!="function"||!self.fonts)return;let r=!1,o=new Promise(_=>setTimeout(()=>{r=!0,_()},1500)),f=e.map(async _=>{try{let E={weight:_.weight,style:_.style};_.unicodeRange&&(E.unicodeRange=_.unicodeRange);let T=new FontFace(_.family,`url(${_.src})`,E);await T.load(),r||self.fonts.add(T)}catch{}});await Promise.race([Promise.all(f),o])}function ae(e){let r=e.get_hover_price();return r>0?{price:r,qty:e.get_hover_qty(),side:e.get_hover_side()===2?"ask":"bid"}:null}var Se={OrderbookEngine:{gl:!0,readState(e){let r=ae(e),o=null;if(e.is_range_active()){let f=e.get_range_low_price(),_=e.get_range_high_price();_>f&&(o={low:f,high:_,delta:_-f,deltaPct:f>0?(_-f)/f*100:0,bidQty:e.get_range_bid_qty(),askQty:e.get_range_ask_qty(),ticks:e.get_range_tick_count(),mode:e.get_range_mode()===2?"hover":"measure"})}return{hover:r,range:o}},sig:e=>`${e.hover?`${e.hover.price}|${e.hover.qty}|${e.hover.side}`:""}#${e.range?`${e.range.low}|${e.range.high}|${e.range.bidQty}|${e.range.askQty}|${e.range.mode}`:""}`,clickHover:ae},DomLadderEngine:{gl:!0,lut:"dom",readState(e){let r=e.get_hover_price();return{hover:r>0?{price:r,side:e.get_hover_side()===1?"ask":"bid"}:null,viewLocked:e.is_view_locked(),m1:e.momentum_1m(),buy1m:e.buy_volume_1m(),sell1m:e.sell_volume_1m(),map:typeof e.ladder_view_map=="function"?e.ladder_view_map():null,lanes:typeof e.ladder_lane_map=="function"?e.ladder_lane_map():null,colScroll:typeof e.column_scroll_state=="function"?e.column_scroll_state():null}},sig:e=>{let r=e.map,o=r&&r.length?`${r.length}|${r[0]}|${r[1]}|${r[2]}|${r[3]}|${r[r.length-1]}`:"",f=e.lanes,_=f&&f.length?f.join("|"):"",E=e.colScroll,T=E&&E.length>=2?`${E[0]}|${E[1]}`:"";return`${e.hover?`${e.hover.price}|${e.hover.side}`:""}#${e.viewLocked}#${e.m1}|${e.buy1m}|${e.sell1m}#${o}#${_}#${T}`},clickHover(e){let r=e.get_hover_price();return r>0?{price:r,side:e.get_hover_side()===1?"ask":"bid"}:null}}},X=null,st=null,Xt=null,V=null,q=null,Z=null,at=null,nt=1,Tt=!1,Yt=!1,et=!1,wt=!1,Ft=!1,ft=!0,ht=null,re="",se=typeof self.requestAnimationFrame=="function",Wt=!0,Gt=0,Ce=1500;function gt(e,r,o){try{self.postMessage({t:e,...r},o||[])}catch{}}function Et(e){et||(et=!0,kt(),gt("dead",{err:String(e&&e.message?e.message:e)}))}function bt(){Yt||!Tt||et||Ft||ht!==null||Wt&&(ht=se?self.requestAnimationFrame(le):setTimeout(le,16))}function kt(){ht!==null&&(se?self.cancelAnimationFrame(ht):clearTimeout(ht),ht=null)}function pt(){ft=!0,bt()}function ie(){try{q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,V.width,V.height),q.fillStyle="#787b86",q.font=`600 ${Math.round(12*nt)}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`,q.textAlign="center",q.textBaseline="middle",q.fillText("Enterprise license required",V.width/2,V.height/2),q.restore()}catch{}}function xt(){if(et)return!1;if(Ft)return ie(),!0;try{if(X.render()>0){let r=X.get_command_buffer_ptr(),o=X.get_command_buffer_len();q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,V.width,V.height),q.restore(),jt(q,Xt,r,o,null,null,null,at)}return!0}catch(e){return e instanceof WebAssembly.RuntimeError&&Et(e),!1}}function le(){if(ht=null,Yt||!Tt||et||Ft)return;let e=!1;try{X.set_now_ms?.(Date.now()),e=ft||X.is_dirty()}catch(f){Et(f);return}let r=wt&&Gt>0&&Date.now()-Gt>Ce;e&&wt&&!r?ft=!0:e&&(ft=!xt(),De());let o=ft;if(!o)try{o=X.is_dirty()}catch{o=!1}o&&bt()}function Pe(){if(et||!V)return null;let e=V.width,r=V.height;if(!(e>0)||!(r>0)||!xt())return null;try{let o=new OffscreenCanvas(e,r),f=o.getContext("2d");return f?(at&&Z&&f.drawImage(Z,0,0),f.drawImage(V,0,0),o.transferToImageBitmap()):null}catch{return null}}function De(){if(et||!st)return;let e=null;try{e=st.readState(X)}catch{return}let r=st.sig(e);r!==re&&(re=r,gt("state",e,e.map&&e.map.buffer?[e.map.buffer]:[]))}function Ie(){try{X?.set_render_backend(0)}catch{}try{at?.destroy()}catch{}at=null,pt()}function Be(){if(!(!Z||!st.gl||typeof X.set_render_backend!="function"))try{let e=st.lut==="dom"?()=>X.dom_lut_rgba():()=>X.ob_lut_rgba(),r=te(Z,{fetchLut:e,onContextLost:Ie});if(!r.available){r.destroy();return}r.resize(Z.width,Z.height,nt),at=r,X.set_render_backend(1)}catch(e){console.warn("[PanelEngine/worker] GL band unavailable, using Canvas2D:",e?.message||e),at=null}}function St(e,r){if(!(et||!X))try{ee(X,e,r),ft=!0}catch(o){o instanceof WebAssembly.RuntimeError&&Et(o)}}async function Ue(e){if(st=Se[e.engine],!st)throw new Error(`unknown panel engine: ${e.engine}`);V=e.canvas,Z=e.gl||null,nt=e.dpr||1,Ft=!!e.blocked;let[{module:r,memory:o}]=await Promise.all([oe(),ne(e.opts.fonts)]);Xt=o,q=V.getContext("2d"),q.setTransform(nt,0,0,nt,0,0);let f=r[e.engine];if(typeof f!="function")throw new Error(`engine missing in wasm: ${e.engine}`);X=new f(e.cssW,e.cssH);try{X.set_license_token?.(e.opts.licenseToken||"",Date.now(),e.opts.host||"")}catch(_){console.warn("[PanelEngine/worker] set_license_token failed:",_.message)}for(let[_,E]of e.opts.boot||[])St(_,E);Be(),Ft&&ie(),gt("ready",{})}self.onmessage=e=>{let r=e.data;if(r)switch(r.t){case"init":Ue(r).catch(o=>Et(o));return;case"call":St(r.m,r.a),bt();return;case"calls":for(let[o,f]of r.batch)St(o,f);bt();return;case"query":{let o=null;try{let f=X&&X[r.m];typeof f=="function"&&(o=f.apply(X,r.a||[]))}catch{o=null}gt("reply",{id:r.id,v:o});return}case"capture":{let o=Pe();gt("reply",{id:r.id,v:o},o?[o]:[]);return}case"domVol":{let o=r.flat;if(!o)return;for(let f=0;f+2<o.length;f+=3)St("push_dom_vol",[o[f],o[f+1],o[f+2]]);bt();return}case"click":{if(et||!X)return;let o=null;try{X.set_hover(r.x,r.y),o=st.clickHover(X)}catch{return}ft=!0,bt(),o&&gt("click",{hover:o});return}case"resize":{if(et||!X)return;nt=r.dpr||1;let o=V.width!==r.bufW||V.height!==r.bufH;V.width!==r.bufW&&(V.width=r.bufW),V.height!==r.bufH&&(V.height=r.bufH),q.setTransform(nt,0,0,nt,0,0),Z&&(Z.width!==r.bufW&&(Z.width=r.bufW),Z.height!==r.bufH&&(Z.height=r.bufH),at?.resize(r.bufW,r.bufH,nt));try{X.resize(r.cssW,r.cssH)}catch(f){Et(f);return}o&&xt(),pt();return}case"life":if(r.v==="start")Tt=!0,pt();else if(r.v==="stop")Tt=!1,kt();else if(r.v==="destroy"){Yt=!0,Tt=!1,kt();try{at?.destroy()}catch{}at=null;try{X?.free()}catch{}X=null}return;case"vis":Wt=!!r.v,Wt?pt():kt();return;case"busy":wt=!!r.v,Gt=wt?Date.now():0,wt||pt();return;case"heap":gt("heap",{bytes:Xt?.buffer?.byteLength||0});return;default:}};
414
+ }`;function Lt(t,a,o){let i=t.createShader(a);if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){let u=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`ob shader compile failed: ${u}`)}return i}function Mt(t,a={}){let o=null,i=null,u=null,p=null,E=null,y=null,v=null,n=null,r=null,e=null,A=-1,P=1,x=1,X=1,c=!1;try{o=t.getContext("webgl2",{alpha:!0,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,desynchronized:!1,premultipliedAlpha:!1})}catch{o=null}if(o)try{let I=Lt(o,o.VERTEX_SHADER,wo),L=Lt(o,o.FRAGMENT_SHADER,vo);if(i=o.createProgram(),o.attachShader(i,I),o.attachShader(i,L),o.linkProgram(i),o.deleteShader(I),o.deleteShader(L),!o.getProgramParameter(i,o.LINK_STATUS))throw new Error(`ob program link failed: ${o.getProgramInfoLog(i)}`);u=o.createVertexArray(),o.bindVertexArray(u),p=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,p),o.bufferData(o.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),o.STATIC_DRAW);let z=o.getAttribLocation(i,"aPos");o.enableVertexAttribArray(z),o.vertexAttribPointer(z,2,o.FLOAT,!1,0,0),o.bindVertexArray(null),E=o.createTexture(),o.bindTexture(o.TEXTURE_2D,E);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);y=o.createTexture(),o.bindTexture(o.TEXTURE_2D,y);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);v=o.getUniformLocation(i,"uRect"),n=o.getUniformLocation(i,"uGrid"),r=o.getUniformLocation(i,"uAlpha"),e=o.getUniformLocation(i,"uPool"),o.useProgram(i),o.uniform1i(o.getUniformLocation(i,"uCells"),0),o.uniform1i(o.getUniformLocation(i,"uLut"),1),o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_ALIGNMENT,1),x=t.width,X=t.height,o.viewport(0,0,x,X),c=!0}catch(I){console.warn("[ObWebgl] init failed:",I?.message||I),c=!1}o&&typeof t.addEventListener=="function"&&t.addEventListener("webglcontextlost",I=>{I.preventDefault(),c=!1;try{a.onContextLost?.()}catch{}});function de(I){if(I===A)return;let L=a.fetchLut?.();!L||L.length<512*4||(o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,y),o.texImage2D(o.TEXTURE_2D,0,o.RGBA8,256,2,0,o.RGBA,o.UNSIGNED_BYTE,L),A=I)}return{get available(){return c},obHeatmap(I,L){if(!c||(o.viewport(0,0,x,X),o.clearColor(I.bgR/255,I.bgG/255,I.bgB/255,I.bgA/255),o.clear(o.COLOR_BUFFER_BIT),!I.cols||!I.rows||!L||I.destW<=0||I.destH<=0)||L.length<I.cols*I.rows*2)return;o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,E),o.texImage2D(o.TEXTURE_2D,0,o.RG8,I.cols,I.rows,0,o.RG,o.UNSIGNED_BYTE,L),de(I.lutSeq);let z=I.destX*P/x*2-1,te=(I.destX+I.destW)*P/x*2-1,oe=1-I.destY*P/X*2,he=1-(I.destY+I.destH)*P/X*2;o.useProgram(i),o.bindVertexArray(u),o.uniform4f(v,z,he,te,oe),o.uniform2f(n,I.cols,I.rows),o.uniform1f(r,I.alphaMul),o.uniform1f(e,Math.min(32,Math.max(1,Math.ceil(I.rows/Math.max(I.destH*P,1))))),o.drawArrays(o.TRIANGLE_STRIP,0,4),o.bindVertexArray(null)},resize(I,L,z){x=Math.max(1,I),X=Math.max(1,L),P=z>0?z:1,c&&o.viewport(0,0,x,X)},destroy(){if(c=!1,!!o){try{o.deleteTexture(E),o.deleteTexture(y),o.deleteBuffer(p),o.deleteVertexArray(u),o.deleteProgram(i),o.getExtension("WEBGL_lose_context")?.loseContext()}catch{}o=null}}}}function Ct(t,a,o){let i=t&&t[a];typeof i=="function"&&i.apply(t,o||[])}var It=Object.freeze({COL:0,PRICE:1,BID:2,ASK:3,BUY:4,SELL:5,SESS_BUY:6,SESS_SELL:7,TIME_MS:8,CUM:9,PEAK_BID:10,PEAK_ASK:11,LTQ:12,LTQ_AGE:13,LTQ_BUY:14,IMB:15,IMB_BUY:16,PULL:17,PULL_AGE:18,PULL_BID:19,ABSORB:20,MARKER:21,WALL:22,LEN:23});function Dt(t){if(!t||!t.length)return"";let a="";for(let o=0;o<t.length;o++){let i=o===It.LTQ_AGE||o===It.PULL_AGE?Math.floor(t[o]/250):t[o];a+=`${i}|`}return a}var We=null,Ie=null,pe=null;async function So(){let t=typeof globalThis>"u"?null:globalThis,a=t&&t.__mrdWasmResp;if(!a)return null;t.__mrdWasmResp=null;try{let o=await a;return o&&o.ok?o:null}catch{return null}}function xo(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let t=a=>new URL(a+self.location.search,self.location.href).href;return{glue:t("./chart_engine.js"),wasm:t("./chart_engine_bg.wasm")}}var Pt=null,Lo=!1;function Mo(){return!!Pt&&typeof WorkerGlobalScope>"u"&&globalThis.crossOriginIsolated===!0&&typeof SharedArrayBuffer<"u"}async function Co(){let t=new URL(Pt,globalThis.location?.href),a=new URL(t.pathname.replace(/\.js$/,"_bg.wasm")+t.search,t),o=await import(t.href);return await o.default({module_or_path:a.href}),o}async function Ut(){return We?{module:We,memory:Ie}:pe||(pe=(async()=>{let t=globalThis.__mrdBoot;if(t?.("engine"),Mo())try{let p=await Co();return Ie=p.wasm_memory(),We=p,Lo=!0,t?.("engineReady"),{module:p,memory:Ie}}catch(p){console.warn("[mrd-chart] shared-memory engine failed, using the standard build:",p?.message||p)}let a=xo(),o=a?await import(a.glue):await import("./chart_engine.js"),i=a?null:await So(),u=a?a.wasm:i;try{await(u?o.default({module_or_path:u}):o.default())}catch(p){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",p);let E=a?a.wasm:new URL("./chart_engine_bg.wasm",import.meta.url),y=await fetch(E);if(!y.ok)throw new Error(`kline-orderbook-chart: engine file request failed (${y.status} ${y.statusText}) at ${E}`);let v=await y.arrayBuffer(),n=new Uint8Array(v,0,Math.min(4,v.byteLength));if(n[0]!==0||n[1]!==97||n[2]!==115||n[3]!==109)throw new Error(`kline-orderbook-chart: ${E} did not return the engine file (got HTML or a 404 page). With Vite, add optimizeDeps: { exclude: ['kline-orderbook-chart'] } to vite.config. See https://tapedelta.com/docs/charting-library/getting-started#bundlers`);await o.default(v)}return Ie=o.wasm_memory(),We=o,t?.("engineReady"),{module:o,memory:Ie}})(),pe.catch(()=>{pe=null}),pe)}async function Bt(t){if(!Array.isArray(t)||!t.length||typeof FontFace!="function"||!self.fonts)return;let a=!1,o=new Promise(u=>setTimeout(()=>{a=!0,u()},1500)),i=t.map(async u=>{try{let p={weight:u.weight,style:u.style};u.unicodeRange&&(p.unicodeRange=u.unicodeRange);let E=new FontFace(u.family,`url(${u.src})`,p);await E.load(),a||self.fonts.add(E)}catch{}});await Promise.race([Promise.all(i),o])}function Nt(t){let a=t.get_hover_price();return a>0?{price:a,qty:t.get_hover_qty(),side:t.get_hover_side()===2?"ask":"bid"}:null}var Io={OrderbookEngine:{gl:!0,readState(t){let a=Nt(t),o=null;if(t.is_range_active()){let i=t.get_range_low_price(),u=t.get_range_high_price();u>i&&(o={low:i,high:u,delta:u-i,deltaPct:i>0?(u-i)/i*100:0,bidQty:t.get_range_bid_qty(),askQty:t.get_range_ask_qty(),ticks:t.get_range_tick_count(),mode:t.get_range_mode()===2?"hover":"measure"})}return{hover:a,range:o}},sig:t=>`${t.hover?`${t.hover.price}|${t.hover.qty}|${t.hover.side}`:""}#${t.range?`${t.range.low}|${t.range.high}|${t.range.bidQty}|${t.range.askQty}|${t.range.mode}`:""}`,clickHover:Nt},DomLadderEngine:{gl:!0,lut:"dom",readState(t){let a=t.get_hover_price();return{hover:a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null,info:a>0&&typeof t.hover_row_info=="function"?t.hover_row_info():null,viewLocked:t.is_view_locked(),m1:t.momentum_1m(),buy1m:t.buy_volume_1m(),sell1m:t.sell_volume_1m(),map:typeof t.ladder_view_map=="function"?t.ladder_view_map():null,lanes:typeof t.ladder_lane_map=="function"?t.ladder_lane_map():null,colScroll:typeof t.column_scroll_state=="function"?t.column_scroll_state():null}},sig:t=>{let a=t.map,o=a&&a.length?`${a.length}|${a[0]}|${a[1]}|${a[2]}|${a[3]}|${a[a.length-1]}`:"",i=t.lanes,u=i&&i.length?i.join("|"):"",p=t.colScroll,E=p&&p.length>=2?`${p[0]}|${p[1]}`:"";return`${t.hover?`${t.hover.price}|${t.hover.side}`:""}#${t.viewLocked}#${t.m1}|${t.buy1m}|${t.sell1m}#${o}#${u}#${E}#${Dt(t.info)}`},clickHover(t){let a=t.get_hover_price();return a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null}},MboScannerEngine:{gl:!1,selfPaced:!0,idleTickMs:250,readState(t){try{return JSON.parse(t.status_json())}catch{return{}}},sig:t=>`${t.rows}|${t.live}|${t.since}|${t.sort}|${t.desc}|${Math.floor((t.frames||0)/500)}|${(t.quietMs||0)>5e3}`,clickHover:()=>null,ports:{s:"mbo_summary",e:"mbo_events"}}},De=new Map,H=null,Z=null,ut=null,gt=null,Y=null,q=null,Q=null,se=null,ie=1,Fe=!1,Ye=!1,ee=!1,Ue=!1,we=!1,Ee=!0,fe=null,Ot="",kt=typeof self.requestAnimationFrame=="function",ze=!0,it=0,Do=1500;function ye(t,a,o){try{self.postMessage({t,...a},o||[])}catch{}}function Ae(t){ee||(ee=!0,Ve(),ye("dead",{err:String(t&&t.message?t.message:t)}))}function ae(){Ye||!Fe||ee||we||fe!==null||ze&&(fe=kt?self.requestAnimationFrame(st):setTimeout(st,16))}function Ve(){ue!==null&&(clearTimeout(ue),ue=null),fe!==null&&(kt?self.cancelAnimationFrame(fe):clearTimeout(fe),fe=null)}var ue=null;function Po(){Ye||!Fe||ee||we||!ze||fe!==null||ue!==null||(ue=setTimeout(()=>{ue=null,st()},Z.idleTickMs))}function Pe(){Ee=!0,ae()}function Gt(){try{q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.fillStyle="#787b86",q.font=`600 ${Math.round(12*ie)}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`,q.textAlign="center",q.textBaseline="middle",q.fillText("Enterprise license required",Y.width/2,Y.height/2),q.restore()}catch{}}function ct(){if(ee)return!1;if(we)return Gt(),!0;try{if(H.render()>0){let a=H.get_command_buffer_ptr(),o=H.get_command_buffer_len();q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.restore(),xt(q,ut,a,o,null,null,null,se)}return!0}catch(t){return t instanceof WebAssembly.RuntimeError&&Ae(t),!1}}function st(){if(fe=null,Ye||!Fe||ee||we)return;let t=!1;try{H.set_now_ms?.(Date.now()),t=Ee||H.is_dirty()}catch(i){Ae(i);return}ue!==null&&(clearTimeout(ue),ue=null);let a=Ue&&it>0&&Date.now()-it>Do;t&&Ue&&!a?Ee=!0:t&&(Ee=!ct(),Bo());let o=Ee;if(!o)try{o=Z.selfPaced?H.wants_frame():H.is_dirty()}catch{o=!1}o?ae():Z.idleTickMs&&Po()}function Uo(){if(ee||!Y)return null;let t=Y.width,a=Y.height;if(!(t>0)||!(a>0)||!ct())return null;try{let o=new OffscreenCanvas(t,a),i=o.getContext("2d");return i?(se&&Q&&i.drawImage(Q,0,0),i.drawImage(Y,0,0),o.transferToImageBitmap()):null}catch{return null}}function Bo(){if(ee||!Z)return;let t=null;try{t=Z.readState(H)}catch{return}let a=Z.sig(t);a!==Ot&&(Ot=a,ye("state",t,t.map&&t.map.buffer?[t.map.buffer]:[]))}function No(){try{H?.set_render_backend(0)}catch{}try{se?.destroy()}catch{}se=null,Pe()}function Oo(){if(!(!Q||!Z.gl||typeof H.set_render_backend!="function"))try{let t=Z.lut==="dom"?()=>H.dom_lut_rgba():()=>H.ob_lut_rgba(),a=Mt(Q,{fetchLut:t,onContextLost:No});if(!a.available){a.destroy();return}a.resize(Q.width,Q.height,ie),se=a,H.set_render_backend(1)}catch(t){console.warn("[PanelEngine/worker] GL band unavailable, using Canvas2D:",t?.message||t),se=null}}function Re(t,a){if(!(ee||!H))try{Ct(H,t,a),Ee=!0}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o)}}async function go(t){if(Z=Io[t.engine],!Z)throw new Error(`unknown panel engine: ${t.engine}`);Y=t.canvas,Q=t.gl||null,ie=t.dpr||1,we=!!t.blocked;let[{module:a,memory:o}]=await Promise.all([Ut(),Bt(t.opts.fonts)]);ut=o,gt=a,q=Y.getContext("2d"),q.setTransform(ie,0,0,ie,0,0);let i=a[t.engine];if(typeof i!="function")throw new Error(`engine missing in wasm: ${t.engine}`);H=new i(t.cssW,t.cssH);try{H.set_license_token?.(t.opts.licenseToken||"",Date.now(),t.opts.host||"")}catch(u){console.warn("[PanelEngine/worker] set_license_token failed:",u.message)}for(let[u,p]of t.opts.boot||[])Re(u,p);Oo(),we&&Gt(),ye("ready",{})}self.onmessage=t=>{let a=t.data;if(a)switch(a.t){case"init":go(a).catch(o=>Ae(o));return;case"call":Re(a.m,a.a),ae();return;case"calls":for(let[o,i]of a.batch)Re(o,i);ae();return;case"query":{let o=null;try{let i=H&&H[a.m];typeof i=="function"&&(o=i.apply(H,a.a||[]))}catch{o=null}ye("reply",{id:a.id,v:o});return}case"capture":{let o=Uo();ye("reply",{id:a.id,v:o},o?[o]:[]);return}case"domVol":{let o=a.flat;if(!o)return;for(let i=0;i+2<o.length;i+=3)Re("push_dom_vol",[o[i],o[i+1],o[i+2]]);ae();return}case"ingest":{if(ee||!H||!a.buf)return;try{H.ingest(new Uint8Array(a.buf))}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o);return}ae();return}case"mbo":{let o=a.flat;if(!o)return;Re("set_mbo_blocks",[o]),ae();return}case"port":{let o=De.get(a.key);if(o){o.onmessage=null;try{o.close()}catch{}De.delete(a.key)}let i=Z?.ports;if(!a.port||!i)return;De.set(a.key,a.port),a.port.onmessage=u=>{let p=u.data,E=p&&i[p.t];!E||!p.f||(Re(E,[a.key,p.f]),ae())};return}case"click":{if(ee||!H)return;let o=null;try{H.set_hover(a.x,a.y),o=Z.clickHover(H)}catch{return}Ee=!0,ae(),o&&ye("click",{hover:o});return}case"resize":{if(ee||!H)return;ie=a.dpr||1;let o=Y.width!==a.bufW||Y.height!==a.bufH;Y.width!==a.bufW&&(Y.width=a.bufW),Y.height!==a.bufH&&(Y.height=a.bufH),q.setTransform(ie,0,0,ie,0,0),Q&&(Q.width!==a.bufW&&(Q.width=a.bufW),Q.height!==a.bufH&&(Q.height=a.bufH),se?.resize(a.bufW,a.bufH,ie));try{H.resize(a.cssW,a.cssH)}catch(i){Ae(i);return}o&&ct(),Pe();return}case"life":if(a.v==="start")Fe=!0,Pe();else if(a.v==="stop")Fe=!1,Ve();else if(a.v==="destroy"){Ye=!0,Fe=!1,Ve();for(let o of De.values()){o.onmessage=null;try{o.close()}catch{}}De.clear();try{se?.destroy()}catch{}se=null;try{H?.free()}catch{}H=null}return;case"vis":ze=!!a.v,ze?Pe():Ve();return;case"busy":Ue=!!a.v,it=Ue?Date.now():0,Ue||Pe();return;case"heap":{let o=0;try{o=gt?.wasm_heap_used?.()||0}catch{}ye("heap",{bytes:ut?.buffer?.byteLength||0,used:o});return}default:}};