kline-orderbook-chart 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/chart-engine.mjs +60 -34
- package/dist/chart_engine.js +13 -23292
- package/dist/chart_engine_bg.wasm +0 -0
- package/dist/ingestWorker.js +1 -1
- package/dist/panelWorker.js +5 -5
- package/dist/tickWorker.js +49 -23
- package/package.json +1 -1
|
Binary file
|
package/dist/ingestWorker.js
CHANGED
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* Web: https://tapedelta.com
|
|
12
12
|
* NPM: https://www.npmjs.com/package/kline-orderbook-chart
|
|
13
13
|
*/
|
|
14
|
-
var
|
|
14
|
+
var _=null,b=null,h=null;async function B(){let t=typeof globalThis>"u"?null:globalThis,e=t&&t.__mrdWasmResp;if(!e)return null;t.__mrdWasmResp=null;try{let s=await e;return s&&s.ok?s:null}catch{return null}}function R(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let t=e=>new URL(e+self.location.search,self.location.href).href;return{glue:t("./chart_engine.js"),wasm:t("./chart_engine_bg.wasm")}}async function y(){return _?{module:_,memory:b}:h||(h=(async()=>{let t=R(),e=t?await import(t.glue):await import("./chart_engine.js"),s=t?null:await B(),i=t?t.wasm:s;try{await(i?e.default({module_or_path:i}):e.default())}catch(n){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",n);let r=t?t.wasm:new URL("../wasm/chart_engine_bg.wasm",import.meta.url),o=await fetch(r);if(!o.ok)throw new Error(`WASM fetch failed (${o.status} ${o.statusText}) at ${r}`);let E=await o.arrayBuffer();await e.default(E)}return b=e.wasm_memory(),_=e,{module:e,memory:b}})(),h.catch(()=>{h=null}),h)}var l=class{constructor(e){this.url=e.url,this.role=e.role||"",this.binary=!!e.binary,this.viaGateway=!!e.viaGateway,this.h=e,this.ws=null,this.timer=null,this.backoffMs=1e3,this.lastMsgAt=0,this.stopped=!0}isOpen(){return!!this.ws&&this.ws.readyState===WebSocket.OPEN}open(){if(this.stopped=!1,this.ws)return;let e;try{e=new WebSocket(this.url),this.binary&&(e.binaryType="arraybuffer")}catch(i){console.warn(`[ingest] ws construct failed (${this.role}):`,i?.message||i),this.scheduleReconnect();return}this.ws=e;let s=!1;e.onopen=()=>{s=!0,this.backoffMs=1e3,this.lastMsgAt=Date.now(),this.h.onHandshake?.(!0),this.h.onOpen?.()},e.onmessage=i=>{this.ws===e&&(this.lastMsgAt=Date.now(),this.h.onMessage(i.data))},e.onclose=i=>{this.ws===e&&(this.ws=null,s||this.h.onHandshake?.(!1),!this.stopped&&(console.warn(`[ingest] ws closed (${this.role}, code ${i?.code}); reconnecting in ${this.backoffMs}ms`),this.scheduleReconnect()))},e.onerror=()=>{}}send(e){this.isOpen()&&this.ws.send(JSON.stringify(e))}scheduleReconnect(){this.timer||this.stopped||(this.timer=setTimeout(()=>{this.timer=null,this.backoffMs=Math.min(this.backoffMs*2,3e4),this.open()},this.backoffMs))}bounce(e){if(this.stopped)return;let s=this.isOpen();s&&Date.now()-this.lastMsgAt<e||(this.timer&&(clearTimeout(this.timer),this.timer=null),this.backoffMs=1e3,(s||this.ws)&&this.drop(),this.open())}kick(){if(this.ws)try{this.ws.close()}catch{}}drop(){let e=this.ws;if(this.ws=null,e)try{e.close()}catch{}}close(){this.stopped=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),this.drop()}};function a(t,e){self.postMessage(t,e||[])}var c=class{constructor(e,s){this.id=s,this.feed=new e.BookFeed,this.gen=0,this.lastBookAt=0,this.pendingTrades=0,this.closed=!1}resetFeed(e,s,i,n){this.gen=e,this.feed.reset(s,i,n,Date.now()),this.lastBookAt=0,this.pendingTrades=0}noteTrade(){++this.pendingTrades>=2048&&this.drain(Date.now(),!1)}drain(e,s){let i=s&&e-this.lastBookAt>=100,n=this.feed.drain(e,i);if(this.pendingTrades=0,!(n&3))return;let r={t:"frame",id:this.id,gen:this.gen,tMs:e,bits:n,mid:0,tick:0},o=[];n&1&&(this.lastBookAt=e,r.bids=this.feed.bids(),r.asks=this.feed.asks(),r.mid=this.feed.mid(),o.push(r.bids.buffer,r.asks.buffer)),n&16&&(r.tick=this.feed.rowTick()),n&2&&(r.trades=this.feed.trades(),o.push(r.trades.buffer)),a(r,o)}health(){}park(){}unpark(){}free(){this.closed=!0,this.feed.free()}};var C=12e3,u=class extends c{constructor(e,s){super(e,s.id),this.legs=[],this.restart(s)}restart({gen:e,symbol:s,legs:i}){this.closeLegs(),this.resetFeed(e,s,1,""),this.legs=(i||[]).map(n=>{let r=new l({url:n.url,role:n.role,viaGateway:n.viaGateway,onOpen:()=>{n.carriesDepth&&this.needSnapshot()},onHandshake:o=>a({t:"ws",id:this.id,role:n.role,ok:o,viaGateway:r.viaGateway,reportable:!!n.reportable}),onMessage:o=>this.onMessage(o)});return r});for(let n of this.legs)n.open()}onMessage(e){typeof e=="string"&&(this.feed.binance(e)&1&&this.needSnapshot(),e.includes('"aggTrade"')&&this.noteTrade())}needSnapshot(){a({t:"need-snapshot",id:this.id,gen:this.gen})}snapshot(e,s){e!==this.gen||typeof s!="string"||this.feed.snapshot(s)&1&&this.needSnapshot()}setUrl(e,s,i){let n=this.legs.find(r=>r.role===e);n&&s&&(n.url=s,n.viaGateway=!!i)}resume(){for(let e of this.legs)e.bounce(C)}closeLegs(){for(let e of this.legs)e.close();this.legs=[]}close(){this.closeLegs(),this.free()}};var x=12e3,F=9e4,d=class extends c{constructor(e,s){super(e,s.id),this.parked=!1,this.leg=new l({url:s.url,role:"obag",binary:!0,onOpen:()=>{this.resetFeed(this.gen,this.symbol,2,this.venues.join(",")),this.subscribe(!0)},onMessage:i=>this.onMessage(i)}),this.restart(s)}restart({gen:e,symbol:s,venues:i}){this.symbol=s||"",this.venues=Array.isArray(i)?i:[],this.resetFeed(e,this.symbol,2,this.venues.join(",")),this.leg.isOpen()?this.subscribe(!1):this.parked||this.leg.open()}subscribe(e){let s=this.leg;s.send({type:"change_symbol",symbol:this.symbol}),s.send({type:"get_server_info"}),e&&(s.send({type:"subscribe_orderbook_raw",exchanges:this.venues}),s.send({type:"subscribe_trades"}))}onMessage(e){let s=Date.now(),i;typeof e=="string"?(i=this.feed.obag(e,s),e.includes('"type":"trade"')&&this.noteTrade()):i=this.feed.obagBinary(new Uint8Array(e),s),i&2&&this.leg.send({type:"get_orderbook_raw_snapshot",exchanges:this.venues})}health(e){this.leg.isOpen()&&e-this.leg.lastMsgAt>F&&(console.warn(`[ingest] obAG silent ${Math.round((e-this.leg.lastMsgAt)/1e3)}s \u2014 reconnecting`),this.leg.kick())}resume(){this.parked||this.leg.bounce(x)}park(){this.parked||(this.parked=!0,this.leg.close())}unpark(){this.parked&&(this.parked=!1,this.leg.open())}close(){this.leg.close(),this.free()}};var K=33,v=1e3,N=250,U={binance:u,obag:d},A=null,g=!1,w=!1,p=null,S=0,f=new Map;function O(){let t=Date.now();for(let e of f.values())e.health(t),e.drain(t,!g||w)}function L(){let t=w?N:v,e=f.size===0?0:g?t:K;e!==S&&(p&&(clearInterval(p),p=null),S=e,e&&(p=setInterval(O,e)))}var m=0;function T(){if(m)for(let t of f.values())try{t.feed?.setRowBudget?.(m)}catch{}}function G(t){let e=t.id!=null?f.get(t.id):null;switch(t.t){case"open":{let s=U[t.kind||"binance"];!e&&s&&(f.set(t.id,new s(A,t)),T());break}case"symbol":e?.restart(t);break;case"urls":e?.setUrl?.(t.role,t.url,t.viaGateway);break;case"snapshot":e?.snapshot?.(t.gen,t.text);break;case"resume":e?.resume();break;case"park":e?.park();break;case"unpark":e?.unpark();break;case"close":e&&(e.close(),f.delete(t.id));break;case"budget":m=t.rows|0,T();break;case"vis":g=!!t.hidden,w=!!t.keepBook,g||O();break;default:return}L()}y().then(({module:t})=>{if(typeof t.BookFeed!="function")throw new Error("engine glue has no BookFeed (stale build)");A=t,self.onmessage=e=>{try{G(e.data||{})}catch(s){console.error("[ingest] message failed:",s)}},a({t:"ready"})}).catch(t=>a({t:"fatal",error:String(t?.message||t)}));
|
package/dist/panelWorker.js
CHANGED
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
* Web: https://tapedelta.com
|
|
12
12
|
* NPM: https://www.npmjs.com/package/kline-orderbook-chart
|
|
13
13
|
*/
|
|
14
|
-
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,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},se=(()=>{try{return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}catch{return!1}})(),le=se?1.5:1/0;function ie(){return typeof window<"u"&&window.devicePixelRatio||1}function ce(e,a){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(e,a):Object.assign(document.createElement("canvas"),{width:e,height:a})}var at=null,Yt=null;function ue(e,a){return at?(at.width!==e||at.height!==a)&&(at.width=e,at.height=a):(at=ce(e,a),Yt=at.getContext("2d")),Yt}var It=new Float32Array(0);function fe(e){return It.length<e&&(It=new Float32Array(e)),It}var bt=new Float64Array(0),Bt=new Float64Array(0),Ut=new Float64Array(0),mt=new Float64Array(0);function he(e){return bt.length<e&&(bt=new Float64Array(e)),bt}function ge(e){return Bt.length<e&&(Bt=new Float64Array(e)),Bt}function de(e){return Ut.length<e&&(Ut=new Float64Array(e)),Ut}function ye(e){return mt.length<e&&(mt=new Float64Array(e)),mt}function Ot(e,a){if(a<2)return;let o=a-1,m=he(o),_=ge(o),A=de(o);for(let F=0;F<o;F++){let O=e[F*2],n=e[F*2+1],r=e[(F+1)*2],t=e[(F+1)*2+1];m[F]=r-O,_[F]=t-n,A[F]=m[F]>0?_[F]/m[F]:0}let w=ye(a);w[0]=A[0],w[a-1]=A[o-1];for(let F=1;F<o;F++){let O=A[F-1],n=A[F];w[F]=O*n<=0?0:(O+n)*.5}for(let F=0;F<o;F++){let O=A[F];if(O===0){w[F]=0,w[F+1]=0;continue}let n=w[F]/O,r=w[F+1]/O,t=n*n+r*r;if(t>9){let T=3/Math.sqrt(t);w[F]=T*n*O,w[F+1]=T*r*O}}}function zt(e,a,o){let m=o-1,_=bt,A=mt;for(let w=0;w<m;w++){let F=a[w*2],O=a[w*2+1],n=a[(w+1)*2],r=a[(w+1)*2+1],t=_[w];if(t<=0){e.lineTo(n,r);continue}let T=t/3;e.bezierCurveTo(F+T,O+A[w]*T,n-T,r-A[w+1]*T,n,r)}}function be(e,a,o){let m=o-1,_=bt,A=mt;for(let w=m-1;w>=0;w--){let F=a[w*2],O=a[w*2+1],n=a[(w+1)*2],r=a[(w+1)*2+1],t=_[w];if(t<=0){e.lineTo(F,O);continue}let T=t/3;e.bezierCurveTo(n-T,r-A[w+1]*T,F+T,O+A[w]*T,F,O)}}var qt=["left","center","right"],At=new Map,me=4096;function _e(e,a,o,m){return e<<24|a<<16|o<<8|m}function H(e,a,o,m){let _=_e(e,a,o,m),A=At.get(_);return A||(A=`rgba(${e},${a},${o},${(m/255).toFixed(3)})`,At.size>=me&&At.clear(),At.set(_,A),A)}var Rt=new TextDecoder;function gt(e,a){return Math.round(e*a)/a}var Lt=new Map;function Mt(e,a){let o=Lt.get(a);if(o!==void 0)return o;let m=e.font,_=e.textBaseline;e.font=a,e.textBaseline="alphabetic";let A=e.measureText("0"),w=A.actualBoundingBoxAscent||0,F=A.actualBoundingBoxDescent||0;return o=(w-F)/2,(!Number.isFinite(o)||o===0)&&(o=(parseFloat(a)||11)*.35),Lt.size>=256&&Lt.clear(),Lt.set(a,o),e.font=m,e.textBaseline=_,o}var Vt=new WeakMap;function pe(e,a,o,m,_){let A=Vt.get(e);A||(A=new Map,Vt.set(e,A));let w=Math.round(a),F=`${w}|${o}|${m}|${_}`,O=A.get(F);if(O)return O;let n=-w*.25,r=-w*.25,t=e.createRadialGradient(n,r,w*.08,0,0,w);t.addColorStop(0,m),t.addColorStop(1,o);let T=null;_&&(T=e.createRadialGradient(0,0,w*.85,0,0,w*1.2),T.addColorStop(0,_),T.addColorStop(1,_.replace(/[\d.]+\)$/,"0)")));let P=w*.2,C=e.createRadialGradient(n,r,0,n,r,P);return C.addColorStop(0,"rgba(255,255,255,0.22)"),C.addColorStop(1,"rgba(255,255,255,0)"),O={body:t,glow:T,spec:C,hlX:n,hlY:r,specR:P},A.set(F,O),O}function Q(e,a,o){let m=Math.max(1,Math.round(a*o)),_=Math.round(e*o)/o;return m&1?_+.5/o:_}function ct(e,a,o,m,_){let A=Math.round(e*_),w=Math.round(a*_),F=Math.round((e+o)*_),O=Math.round((a+m)*_);return{x:A/_,y:w/_,w:(F-A)/_,h:(O-w)/_}}function Te(e,a,o,m,_){return{x:Math.round(e*_)/_,y:Math.round(a*_)/_,w:Math.max(1,Math.round(o*_))/_,h:Math.max(1,Math.round(m*_))/_}}function we(e,a,o,m,_){let A=Math.round(a*_),w=Math.round((a+m)*_);return{x:e,y:A/_,w:o,h:(w-A)/_}}function Kt(e,a,o,m,_=null,A=null,w=null,F=null){let O=a.buffer;if(o+m>O.byteLength)return;let n=new DataView(O,o,m),r=new Uint8Array(O,o,m),t=0,T="",P="",C=-1,Y="",c=Math.max(1,Math.abs(e.getTransform?.().a||ie())),lt=null,v=[],M=F&&F.geom&&F.geom.available?F.geom:null,z=e,tt=!1,ot="";for(;t<m;){let it=r[t];if(t+=1,it===k.END_FRAME)break;switch(it){case k.FILL_RECT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];if(t+=4,M){M.rect(s,u,h,l,i,f,d,b,0,0,0,0,0,0,0);break}let g=H(i,f,d,b);g!==T&&(e.fillStyle=g,T=g);let p=ct(s,u,h,l,c);e.fillRect(p.x,p.y,p.w,p.h);break}case k.FILL_RECT_SMOOTH_X:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];if(t+=4,M){M.rect(s,u,h,l,i,f,d,b,0,0,0,0,0,0,1);break}let g=H(i,f,d,b);g!==T&&(e.fillStyle=g,T=g);let p=we(s,u,h,l,c);e.fillRect(p.x,p.y,p.w,p.h);break}case k.FILL_ELLIPSE:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];if(t+=4,M){M.rect(s-h,u-l,h*2,l*2,i,f,d,b,-1,0,0,0,0,0,2);break}let g=H(i,f,d,b);g!==T&&(e.fillStyle=g,T=g),e.beginPath(),e.ellipse(s,u,Math.max(h,.1),Math.max(l,.1),0,0,Math.PI*2),e.fill();break}case k.FILL_ROUND_RECT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];t+=4;let g=n.getFloat32(t,!0);if(t+=4,M){M.rect(s,u,h,l,i,f,d,b,g,0,0,0,0,0,0);break}let p=H(i,f,d,b);p!==T&&(e.fillStyle=p,T=p);let y=ct(s,u,h,l,c),E=Math.min(g,y.w*.5,y.h*.5);E<=.5?e.fillRect(y.x,y.y,y.w,y.h):(e.beginPath(),e.moveTo(y.x+E,y.y),e.lineTo(y.x+y.w-E,y.y),e.arcTo(y.x+y.w,y.y,y.x+y.w,y.y+E,E),e.lineTo(y.x+y.w,y.y+y.h-E),e.arcTo(y.x+y.w,y.y+y.h,y.x+y.w-E,y.y+y.h,E),e.lineTo(y.x+E,y.y+y.h),e.arcTo(y.x,y.y+y.h,y.x,y.y+y.h-E,E),e.lineTo(y.x,y.y+E),e.arcTo(y.x,y.y,y.x+E,y.y,E),e.closePath(),e.fill());break}case k.STROKE_RECT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];t+=4;let g=n.getFloat32(t,!0);if(t+=4,M){let N=g*.5;M.rect(s-N,u-N,h+g,l+g,0,0,0,0,0,g,i,f,d,b,0);break}let p=H(i,f,d,b);p!==P&&(e.strokeStyle=p,P=p),g!==C&&(e.lineWidth=g,C=g);let y=Q(s,g,c),E=Q(u,g,c),S=Math.round(h*c)/c,L=Math.round(l*c)/c;e.strokeRect(y,E,S,L);break}case k.LINE:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];t+=4;let g=n.getFloat32(t,!0);if(t+=4,M){M.seg(s,u,h,l,i,f,d,b,g,0,0);break}let p=H(i,f,d,b);e.beginPath(),p!==P&&(e.strokeStyle=p,P=p),g!==C&&(e.lineWidth=g,C=g),e.setLineDash([]),e.moveTo(Q(s,g,c),Q(u,g,c)),e.lineTo(Q(h,g,c),Q(l,g,c)),e.stroke();break}case k.CANDLE:case k.CANDLE_BORDERED:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=n.getFloat32(t,!0);t+=4;let f=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4;let g=r[t+3],p=H(r[t],r[t+1],r[t+2],g);t+=4;let y=r[t+3],E=H(r[t],r[t+1],r[t+2],y);t+=4;let S=null;it===k.CANDLE_BORDERED&&(S=H(r[t],r[t+1],r[t+2],r[t+3]),t+=4);let L=Math.max(1,Math.floor(d*c)),N=Math.max(1,Math.floor(b*c));L>N&&(L=N);let I=Math.min(Math.max(1,Math.floor(f*c)),N);I<L?I=L:(I^L)&1&&(I-=1);let B=s*c,W=L&1?Math.round(B-.5)+.5:Math.round(B),U=Math.max(1,Math.round(c)),D=Math.round(Math.min(l,i)*c),$=Math.max(D+U,Math.round(Math.max(l,i)*c)),x=Math.round(Math.min(u,h)*c),R=Math.max(x+1,Math.round(Math.max(u,h)*c)),X=Math.min(u,h),Et=Math.max(u,h),St=Math.min(l,i),Ct=Math.max(l,i);if(X<St&&x>=D&&(x=D-1),Et>Ct&&R<=$&&(R=$+1),y>0&&(x<D||R>$)){E!==T&&(e.fillStyle=E,T=E);let Dt=(W-L/2)/c,Pt=L/c;g===255?e.fillRect(Dt,x/c,Pt,(R-x)/c):(x<D&&e.fillRect(Dt,x/c,Pt,(D-x)/c),R>$&&e.fillRect(Dt,$/c,Pt,(R-$)/c))}let V=W-I/2,j=$-D;if(S===null){g>0&&(p!==T&&(e.fillStyle=p,T=p),e.fillRect(V/c,D/c,I/c,j/c));break}let J=Math.max(1,Math.floor(c));if(S!==T&&(e.fillStyle=S,T=S),I<=2*J||j<=2*J){e.fillRect(V/c,D/c,I/c,j/c);break}g===255?e.fillRect(V/c,D/c,I/c,j/c):(e.fillRect(V/c,D/c,I/c,J/c),e.fillRect(V/c,($-J)/c,I/c,J/c),e.fillRect(V/c,(D+J)/c,J/c,(j-2*J)/c),e.fillRect((V+I-J)/c,(D+J)/c,J/c,(j-2*J)/c)),g>0&&(p!==T&&(e.fillStyle=p,T=p),e.fillRect((V+J)/c,(D+J)/c,(I-2*J)/c,(j-2*J)/c));break}case k.OHLC_BAR:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=n.getFloat32(t,!0);t+=4;let f=n.getFloat32(t,!0);t+=4;let d=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let b=r[t];t+=1;let g=Math.max(1,Math.floor(f*c)),p=Math.max(1,Math.floor(c)),y=b&1?p:Math.max(p,Math.floor(g/6));y>g&&(y=g);let E=s*c,L=(y&1?Math.round(E-.5)+.5:Math.round(E))-y/2,N=Math.round(Math.min(h,l)*c),I=Math.max(N+1,Math.round(Math.max(h,l)*c));d!==T&&(e.fillStyle=d,T=d),e.fillRect(L/c,N/c,y/c,(I-N)/c);let B=Math.floor((Math.floor(g*.8)-y)/2);if(B>=1){if(!(b&2)){let U=Math.round(u*c-y/2);e.fillRect((L-B)/c,U/c,B/c,y/c)}let W=Math.round(i*c-y/2);e.fillRect((L+y)/c,W/c,B/c,y/c)}break}case k.DASHED_LINE:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t],f=r[t+1],d=r[t+2],b=r[t+3];t+=4;let g=n.getFloat32(t,!0);t+=4;let p=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);if(t+=4,M){M.seg(s,u,h,l,i,f,d,b,g,p,y);break}let E=H(i,f,d,b);e.beginPath(),E!==P&&(e.strokeStyle=E,P=E),g!==C&&(e.lineWidth=g,C=g),e.setLineDash([p,y]),e.moveTo(Q(s,g,c),Q(u,g,c)),e.lineTo(Q(h,g,c),Q(l,g,c)),e.stroke(),e.setLineDash([]);break}case k.LINEAR_POLYLINE:{let s=n.getUint16(t,!0);t+=2;let u=r[t],h=r[t+1],l=r[t+2],i=r[t+3];t+=4;let f=n.getFloat32(t,!0);if(t+=4,M){let b=0,g=0;for(let p=0;p<s;p++){let y=n.getFloat32(t,!0),E=n.getFloat32(t+4,!0);t+=8,p>0&&M.seg(b,g,y,E,u,h,l,i,f,0,0),b=y,g=E}break}let d=H(u,h,l,i);if(s>1){e.beginPath(),d!==P&&(e.strokeStyle=d,P=d),f!==C&&(e.lineWidth=f,C=f),e.setLineDash([]),e.lineJoin="miter",e.lineCap="butt",e.miterLimit=10;let b=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4,e.moveTo(b,g);for(let p=1;p<s;p++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.stroke()}else t+=s*8;break}case k.SMOOTH_POLYLINE:{let s=n.getUint16(t,!0);t+=2;let u=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let h=n.getFloat32(t,!0);if(t+=4,s>1){let l=new Float32Array(s*2);for(let i=0;i<s;i++)l[i*2]=n.getFloat32(t,!0),t+=4,l[i*2+1]=n.getFloat32(t,!0),t+=4;e.beginPath(),u!==P&&(e.strokeStyle=u,P=u),h!==C&&(e.lineWidth=h,C=h),e.setLineDash([]),e.lineJoin="round",e.lineCap="round",s===2?(e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3])):(Ot(l,s),e.moveTo(l[0],l[1]),zt(e,l,s)),e.stroke()}else t+=s*8;break}case k.POLYLINE:{let s=n.getUint16(t,!0);t+=2;let u=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let h=n.getFloat32(t,!0);if(t+=4,s>0){let l=new Float32Array(s*2);for(let i=0;i<s;i++)l[i*2]=n.getFloat32(t,!0),t+=4,l[i*2+1]=n.getFloat32(t,!0),t+=4;if(e.beginPath(),u!==P&&(e.strokeStyle=u,P=u),h!==C&&(e.lineWidth=h,C=h),e.setLineDash([]),e.lineJoin="round",e.lineCap="round",s===2)e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3]);else{e.moveTo(l[0],l[1]);for(let i=0;i<s-1;i++){let f=i>0?i-1:0,d=i,b=i+1,g=i<s-2?i+2:s-1,p=l[f*2],y=l[f*2+1],E=l[d*2],S=l[d*2+1],L=l[b*2],N=l[b*2+1],I=l[g*2],B=l[g*2+1],W=E+(L-p)/6,U=S+(N-y)/6,D=L-(I-E)/6,$=N-(B-S)/6;e.bezierCurveTo(W,U,D,$,L,N)}}e.stroke()}break}case k.TEXT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t];t+=1;let f=n.getUint16(t,!0);t+=2;let d=Rt.decode(new Uint8Array(a.buffer,o+t,f));t+=f,h!==T&&(e.fillStyle=h,T=h);let b=`${Math.round(l)}px "IBM Plex Mono",monospace`;b!==Y&&(e.font=b,Y=b),e.textAlign=qt[i]||"left",e.textBaseline="alphabetic";let g=u+Mt(e,b);e.fillText(d,gt(s,c),gt(g,c));break}case k.STYLED_TEXT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t];t+=1;let f=r[t];t+=1;let d=n.getUint16(t,!0);t+=2;let b=Rt.decode(new Uint8Array(a.buffer,o+t,d));t+=d,h!==T&&(e.fillStyle=h,T=h);let g=f&2?"italic ":"",p=f&1?"700 ":"",y=`${g}${p}${Math.round(l)}px "IBM Plex Mono",monospace`;y!==Y&&(e.font=y,Y=y),e.textAlign=qt[i]||"left",e.textBaseline="alphabetic";let E=u+Mt(e,y);e.fillText(b,gt(s,c),gt(E,c));break}case k.CIRCLE:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=r[t],i=r[t+1],f=r[t+2],d=r[t+3],b=M?"":H(l,i,f,d);t+=4;let g=r[t],p=r[t+1],y=r[t+2],E=r[t+3],S=M?"":H(g,p,y,E);t+=4;let L=n.getFloat32(t,!0);if(t+=4,M){M.disc(s,u,h,l,i,f,d,g,p,y,E,0,0,0,0,L,0);break}e.beginPath(),e.arc(s,u,h,0,Math.PI*2),b!==T&&(e.fillStyle=b,T=b),e.fill(),L>0&&(S!==P&&(e.strokeStyle=S,P=S),L!==C&&(e.lineWidth=L,C=L),e.stroke());break}case k.TRIANGLE:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=n.getFloat32(t,!0);t+=4;let f=n.getFloat32(t,!0);t+=4;let d=r[t],b=r[t+1],g=r[t+2],p=r[t+3];if(t+=4,M){M.tri(s,u,h,l,i,f,d,b,g,p);break}let y=H(d,b,g,p);e.beginPath(),e.moveTo(s,u),e.lineTo(h,l),e.lineTo(i,f),e.closePath(),y!==T&&(e.fillStyle=y,T=y),e.fill();break}case k.SAVE:{e.save(),v.push(lt);break}case k.RESTORE:{e.restore(),lt=v.length?v.pop():null,M&&M.setClip(lt),T="",P="",C=-1,Y="";break}case k.CLIP_RECT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=ct(s,u,h,l,c);e.beginPath(),e.rect(i.x,i.y,i.w,i.h),e.clip(),lt=i,M&&M.setClip(i);break}case k.ROTATED_TEXT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=n.getFloat32(t,!0);t+=4;let f=n.getUint16(t,!0);t+=2;let d=Rt.decode(r.subarray(t,t+f));t+=f;let b=`${l}px sans-serif`;b!==Y&&(e.font=b,Y=b),h!==T&&(e.fillStyle=h,T=h),e.textAlign="center",e.textBaseline="alphabetic";let g=Mt(e,b);e.save(),e.translate(s,u),e.rotate(i),e.fillText(d,0,g),e.restore();break}case k.BUBBLE_3D:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=r[t],i=r[t+1],f=r[t+2],d=r[t+3];t+=4;let b=r[t],g=r[t+1],p=r[t+2],y=r[t+3];t+=4;let E=r[t],S=r[t+1],L=r[t+2],N=r[t+3];t+=4;let I=n.getFloat32(t,!0);t+=4;let B=h;if(M){M.disc(s,u,B,l,i,f,d,E,S,L,N,b,g,p,y,I,B<4?0:1);break}if(B<4){let W=`rgba(${l},${i},${f},${(d/255).toFixed(3)})`;e.beginPath(),e.arc(s,u,B,0,Math.PI*2),e.fillStyle=W,e.fill(),T=""}else{let W=Math.round(B),U=B>=6,D=B>=16,$=`rgba(${l},${i},${f},${(d/255).toFixed(3)})`,x=`rgba(${b},${g},${p},${(y/255).toFixed(3)})`,R=D?`rgba(${E},${S},${L},${(N/255*.5).toFixed(3)})`:null,X=pe(e,W,$,x,R);e.save(),e.translate(s,u),D&&X.glow&&(e.beginPath(),e.arc(0,0,W*1.2,0,Math.PI*2),e.fillStyle=X.glow,e.fill()),e.beginPath(),e.arc(0,0,W,0,Math.PI*2),e.fillStyle=X.body,e.fill(),U&&(e.beginPath(),e.arc(X.hlX,X.hlY,X.specR,0,Math.PI*2),e.fillStyle=X.spec,e.fill()),e.restore(),T=""}break}case k.FILL_POLYGON:{let s=n.getUint16(t,!0);t+=2;let u=r[t],h=r[t+1],l=r[t+2],i=r[t+3];if(t+=4,M){let d=fe(s*2);for(let b=0;b<s;b++)d[b*2]=n.getFloat32(t,!0),d[b*2+1]=n.getFloat32(t+4,!0),t+=8;M.poly(d,s,u,h,l,i);break}let f=H(u,h,l,i);if(s>2){e.beginPath();let d=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4,e.moveTo(d,b);for(let g=1;g<s;g++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.closePath(),f!==T&&(e.fillStyle=f,T=f),e.fill()}else t+=s*8;break}case k.FILL_SMOOTH_BAND:{let s=n.getUint16(t,!0);t+=2;let u=n.getUint16(t,!0);t+=2;let h=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(t,!0),t+=4,l[f*2+1]=n.getFloat32(t,!0),t+=4;let i=new Float32Array(u*2);for(let f=0;f<u;f++)i[f*2]=n.getFloat32(t,!0),t+=4,i[f*2+1]=n.getFloat32(t,!0),t+=4;s>=2&&u>=2&&(e.beginPath(),h!==T&&(e.fillStyle=h,T=h),s===2?(e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3])):(Ot(l,s),e.moveTo(l[0],l[1]),zt(e,l,s)),e.lineTo(i[(u-1)*2],i[(u-1)*2+1]),u===2?e.lineTo(i[0],i[1]):(Ot(i,u),be(e,i,u)),e.closePath(),e.fill());break}case k.DASHED_POLYLINE:{let s=n.getUint16(t,!0);t+=2;let u=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=n.getFloat32(t,!0);if(t+=4,s>1){e.beginPath(),u!==P&&(e.strokeStyle=u,P=u),h!==C&&(e.lineWidth=h,C=h),e.setLineDash([l,i]),e.lineJoin="round";let f=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4,e.moveTo(f,d);for(let b=1;b<s;b++)e.lineTo(n.getFloat32(t,!0),n.getFloat32(t+4,!0)),t+=8;e.stroke(),e.setLineDash([])}else t+=s*8;break}case k.GRADIENT_RECT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let f=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let d=ct(s,u,h,l,c),b=e.createLinearGradient(d.x,d.y,d.x,d.y+d.h);b.addColorStop(0,i),b.addColorStop(1,f),e.fillStyle=b,T="",e.fillRect(d.x,d.y,d.w,d.h);break}case k.GRADIENT_RECT_H:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let f=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let d=ct(s,u,h,l,c),b=e.createLinearGradient(d.x,d.y,d.x+d.w,d.y);b.addColorStop(0,i),b.addColorStop(1,f),e.fillStyle=b,T="",e.fillRect(d.x,d.y,d.w,d.h);break}case k.GRADIENT_RECT_H_MULTI:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=r[t];t+=1;let f=ct(s,u,h,l,c),d=e.createLinearGradient(f.x,f.y,f.x+f.w,f.y);for(let b=0;b<i;b++){let g=n.getFloat32(t,!0);t+=4;let p=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4,d.addColorStop(g<0?0:g>1?1:g,p)}e.fillStyle=d,T="",e.fillRect(f.x,f.y,f.w,f.h);break}case k.BEGIN_HEATMAP_LAYER:{let s=t-1,u=n.getUint32(t,!0);t+=4;let h=n.getUint32(t,!0);t+=4;let l=n.getUint32(t,!0);if(t+=4,!_||l===0)break;let i=z.canvas.width,f=z.canvas.height,d=`${u}|${h}|${i}|${f}|${c}`;if(_.getKey()===d&&_.getCanvas()){let b=i/c,g=f/c;z.drawImage(_.getCanvas(),0,0,b,g),t=s+l}else{let b=Math.min(c,le),g=Math.max(1,Math.round(i/c*b)),p=Math.max(1,Math.round(f/c*b)),y=_.ensureSize(g,p,b);if(!y)break;y.save(),y.setTransform(1,0,0,1,0,0),y.clearRect(0,0,g,p),y.restore(),e=y,T="",P="",C=-1,Y="",tt=!0,ot=d}break}case k.END_HEATMAP_LAYER:{if(!tt)break;let s=z.canvas.width/c,u=z.canvas.height/c;z.drawImage(_.getCanvas(),0,0,s,u),_.setKey(ot),e=z,T="",P="",C=-1,Y="",tt=!1,ot="";break}case k.HEATMAP_BITMAP:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getUint32(t,!0);t+=4;let l=n.getUint32(t,!0);t+=4;let i=h*l*4;if(t+i>r.byteLength){t=r.byteLength;break}let f=new Uint8ClampedArray(r.buffer,r.byteOffset+t,i);t+=i;let d=new ImageData(f,h,l),b=ue(h,l);if(!b)break;b.putImageData(d,0,0),e.drawImage(at,s,u,h,l);break}case k.HEATMAP_WORLD:{let s=n.getUint32(t,!0);t+=4;let u=n.getUint32(t,!0);t+=4;let h=n.getUint32(t,!0);t+=4;let l=n.getUint32(t,!0);t+=4;let i=n.getUint32(t,!0);t+=4;let f=n.getUint32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4;let g=n.getFloat32(t,!0);t+=4;let p=n.getFloat32(t,!0);t+=4;let y=n.getFloat32(t,!0);t+=4;let E=n.getFloat32(t,!0);t+=4;let S=n.getFloat32(t,!0);t+=4;let L=n.getFloat32(t,!0);t+=4;let N=r[t];t+=1;let I=(N&1)!==0,B=i*f*4;if(t+B>r.byteLength){t=r.byteLength;break}if(!A||s===0||u===0){t+=B;break}let W=A.ensureSize(s,u);if(!W){t+=B;break}if(I&&W.clearRect(0,0,s,u),B>0){let U=new Uint8ClampedArray(r.buffer,r.byteOffset+t,B),D=new ImageData(U,i,f);W.putImageData(D,h,l)}if(t+=B,g>0&&p>0&&S>0&&L>0){let U=Te(y,E,S,L,c);if(U.w>0&&U.h>0){let D=e.imageSmoothingEnabled;e.imageSmoothingEnabled=!1,e.drawImage(A.getCanvas(),d,b,g,p,U.x,U.y,U.w,U.h),e.imageSmoothingEnabled=D}}break}case k.LINE_WITH_EXTEND:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=n.getFloat32(t,!0);t+=4;let l=n.getFloat32(t,!0);t+=4;let i=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let f=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let b=n.getFloat32(t,!0);t+=4;let g=r[t];t+=1,i!==P&&(e.strokeStyle=i,P=i),f!==C&&(e.lineWidth=f,C=f),e.setLineDash(d>0?[d,b]:[]);let p=1e5,y=s,E=u,S=h,L=l,N=h-s,I=l-u,B=Math.hypot(N,I);if(B>0&&g!==0){let W=N/B,U=I/B;g&1&&(y=s-W*p,E=u-U*p),g&2&&(S=h+W*p,L=l+U*p),g&4&&U<0&&(y=s-W*p,E=u-U*p),g&8&&U>0&&(S=h+W*p,L=l+U*p)}e.beginPath(),e.moveTo(Q(y,f,c),Q(E,f,c)),e.lineTo(Q(S,f,c),Q(L,f,c)),e.stroke(),d>0&&e.setLineDash([]);break}case k.LABEL_CALLOUT:{let s=n.getFloat32(t,!0);t+=4;let u=n.getFloat32(t,!0);t+=4;let h=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let l=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let i=H(r[t],r[t+1],r[t+2],r[t+3]);t+=4;let f=n.getFloat32(t,!0);t+=4;let d=n.getFloat32(t,!0);t+=4;let b=r[t];t+=1;let g=r[t];t+=1;let p=n.getUint16(t,!0);t+=2;let y=Rt.decode(r.subarray(t,t+p));t+=p;let E=`${Math.round(f)}px "IBM Plex Mono",monospace`;E!==Y&&(e.font=E,Y=E);let S=4,L=6,N=y.indexOf(`
|
|
15
|
-
`)>=0?
|
|
16
|
-
`):[
|
|
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
|
|
17
17
|
in vec2 aPos;
|
|
18
18
|
uniform vec4 uRect; // clip-space x0,y0 (bottom-left) .. x1,y1 (top-right)
|
|
19
19
|
out vec2 vUv;
|
|
20
20
|
void main() {
|
|
21
21
|
vUv = aPos;
|
|
22
22
|
gl_Position = vec4(mix(uRect.xy, uRect.zw, aPos), 0.0, 1.0);
|
|
23
|
-
}`,
|
|
23
|
+
}`,Le=`#version 300 es
|
|
24
24
|
precision highp float;
|
|
25
25
|
in vec2 vUv;
|
|
26
26
|
uniform sampler2D uCells; // RG8: R = intensity (0 = empty), G = 0 bid / 1 ask
|
|
@@ -53,4 +53,4 @@ void main() {
|
|
|
53
53
|
// best is the normalised byte; land on the matching LUT texel centre.
|
|
54
54
|
vec4 lut = texture(uLut, vec2((best * 255.0 + 0.5) / 256.0, side > 0.5 ? 0.75 : 0.25));
|
|
55
55
|
outColor = vec4(lut.rgb, lut.a * uAlpha);
|
|
56
|
-
}`;function Jt(e,a,o){let m=e.createShader(a);if(e.shaderSource(m,o),e.compileShader(m),!e.getShaderParameter(m,e.COMPILE_STATUS)){let _=e.getShaderInfoLog(m);throw e.deleteShader(m),new Error(`ob shader compile failed: ${_}`)}return m}function Qt(e,a={}){let o=null,m=null,_=null,A=null,w=null,F=null,O=null,n=null,r=null,t=null,T=-1,P=1,C=1,Y=1,c=!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=Jt(o,o.VERTEX_SHADER,Fe),M=Jt(o,o.FRAGMENT_SHADER,Ee);if(m=o.createProgram(),o.attachShader(m,v),o.attachShader(m,M),o.linkProgram(m),o.deleteShader(v),o.deleteShader(M),!o.getProgramParameter(m,o.LINK_STATUS))throw new Error(`ob program link failed: ${o.getProgramInfoLog(m)}`);_=o.createVertexArray(),o.bindVertexArray(_),A=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,A),o.bufferData(o.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),o.STATIC_DRAW);let z=o.getAttribLocation(m,"aPos");o.enableVertexAttribArray(z),o.vertexAttribPointer(z,2,o.FLOAT,!1,0,0),o.bindVertexArray(null),w=o.createTexture(),o.bindTexture(o.TEXTURE_2D,w);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);O=o.getUniformLocation(m,"uRect"),n=o.getUniformLocation(m,"uGrid"),r=o.getUniformLocation(m,"uAlpha"),t=o.getUniformLocation(m,"uPool"),o.useProgram(m),o.uniform1i(o.getUniformLocation(m,"uCells"),0),o.uniform1i(o.getUniformLocation(m,"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),C=e.width,Y=e.height,o.viewport(0,0,C,Y),c=!0}catch(v){console.warn("[ObWebgl] init failed:",v?.message||v),c=!1}o&&typeof e.addEventListener=="function"&&e.addEventListener("webglcontextlost",v=>{v.preventDefault(),c=!1;try{a.onContextLost?.()}catch{}});function lt(v){if(v===T)return;let M=a.fetchLut?.();!M||M.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,M),T=v)}return{get available(){return c},obHeatmap(v,M){if(!c||(o.viewport(0,0,C,Y),o.clearColor(v.bgR/255,v.bgG/255,v.bgB/255,v.bgA/255),o.clear(o.COLOR_BUFFER_BIT),!v.cols||!v.rows||!M||v.destW<=0||v.destH<=0)||M.length<v.cols*v.rows*2)return;o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,w),o.texImage2D(o.TEXTURE_2D,0,o.RG8,v.cols,v.rows,0,o.RG,o.UNSIGNED_BYTE,M),lt(v.lutSeq);let z=v.destX*P/C*2-1,tt=(v.destX+v.destW)*P/C*2-1,ot=1-v.destY*P/Y*2,it=1-(v.destY+v.destH)*P/Y*2;o.useProgram(m),o.bindVertexArray(_),o.uniform4f(O,z,it,tt,ot),o.uniform2f(n,v.cols,v.rows),o.uniform1f(r,v.alphaMul),o.uniform1f(t,Math.min(32,Math.max(1,Math.ceil(v.rows/Math.max(v.destH*P,1))))),o.drawArrays(o.TRIANGLE_STRIP,0,4),o.bindVertexArray(null)},resize(v,M,z){C=Math.max(1,v),Y=Math.max(1,M),P=z>0?z:1,c&&o.viewport(0,0,C,Y)},destroy(){if(c=!1,!!o){try{o.deleteTexture(w),o.deleteTexture(F),o.deleteBuffer(A),o.deleteVertexArray(_),o.deleteProgram(m),o.getExtension("WEBGL_lose_context")?.loseContext()}catch{}o=null}}}}function jt(e,a,o){let m=e&&e[a];typeof m=="function"&&m.apply(e,o||[])}var Ht=null,Nt=null,dt=null;async function Ae(){let e=typeof globalThis>"u"?null:globalThis,a=e&&e.__mrdWasmResp;if(!a)return null;e.__mrdWasmResp=null;try{let o=await a;return o&&o.ok?o:null}catch{return null}}function Re(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let e=a=>new URL(a+self.location.search,self.location.href).href;return{glue:e("./chart_engine.js"),wasm:e("./chart_engine_bg.wasm")}}async function Zt(){return Ht?{module:Ht,memory:Nt}:dt||(dt=(async()=>{let e=Re(),a=e?await import(e.glue):await import("./chart_engine.js"),o=e?null:await Ae(),m=e?e.wasm:o;try{await(m?a.default({module_or_path:m}):a.default())}catch(_){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",_);let A=e?e.wasm:new URL("../wasm/chart_engine_bg.wasm",import.meta.url),w=await fetch(A);if(!w.ok)throw new Error(`WASM fetch failed (${w.status} ${w.statusText}) at ${A}`);let F=await w.arrayBuffer();await a.default(F)}return Nt=a.wasm_memory(),Ht=a,{module:a,memory:Nt}})(),dt.catch(()=>{dt=null}),dt)}async function te(e){if(!Array.isArray(e)||!e.length||typeof FontFace!="function"||!self.fonts)return;let a=!1,o=new Promise(_=>setTimeout(()=>{a=!0,_()},1500)),m=e.map(async _=>{try{let A={weight:_.weight,style:_.style};_.unicodeRange&&(A.unicodeRange=_.unicodeRange);let w=new FontFace(_.family,`url(${_.src})`,A);await w.load(),a||self.fonts.add(w)}catch{}});await Promise.race([Promise.all(m),o])}function ee(e){let a=e.get_hover_price();return a>0?{price:a,qty:e.get_hover_qty(),side:e.get_hover_side()===2?"ask":"bid"}:null}var Le={OrderbookEngine:{gl:!0,readState(e){let a=ee(e),o=null;if(e.is_range_active()){let m=e.get_range_low_price(),_=e.get_range_high_price();_>m&&(o={low:m,high:_,delta:_-m,deltaPct:m>0?(_-m)/m*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:a,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:ee},DomLadderEngine:{gl:!0,lut:"dom",readState(e){let a=e.get_hover_price();return{hover:a>0?{price:a,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 a=e.map,o=a&&a.length?`${a.length}|${a[0]}|${a[1]}|${a[2]}|${a[3]}|${a[a.length-1]}`:"",m=e.lanes,_=m&&m.length?m.join("|"):"",A=e.colScroll,w=A&&A.length>=2?`${A[0]}|${A[1]}`:"";return`${e.hover?`${e.hover.price}|${e.hover.side}`:""}#${e.viewLocked}#${e.m1}|${e.buy1m}|${e.sell1m}#${o}#${_}#${w}`},clickHover(e){let a=e.get_hover_price();return a>0?{price:a,side:e.get_hover_side()===1?"ask":"bid"}:null}}},G=null,st=null,Gt=null,q=null,K=null,Z=null,rt=null,nt=1,pt=!1,xt=!1,et=!1,Tt=!1,wt=!1,ut=!0,ft=null,oe="",re=typeof self.requestAnimationFrame=="function",$t=!0,Wt=0,Me=1500;function ht(e,a,o){try{self.postMessage({t:e,...a},o||[])}catch{}}function Ft(e){et||(et=!0,vt(),ht("dead",{err:String(e&&e.message?e.message:e)}))}function yt(){xt||!pt||et||wt||ft!==null||$t&&(ft=re?self.requestAnimationFrame(ne):setTimeout(ne,16))}function vt(){ft!==null&&(re?self.cancelAnimationFrame(ft):clearTimeout(ft),ft=null)}function _t(){ut=!0,yt()}function ae(){try{K.save(),K.setTransform(1,0,0,1,0,0),K.clearRect(0,0,q.width,q.height),K.fillStyle="#787b86",K.font=`600 ${Math.round(12*nt)}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`,K.textAlign="center",K.textBaseline="middle",K.fillText("Enterprise license required",q.width/2,q.height/2),K.restore()}catch{}}function Xt(){if(et)return!1;if(wt)return ae(),!0;try{if(G.render()>0){let a=G.get_command_buffer_ptr(),o=G.get_command_buffer_len();K.save(),K.setTransform(1,0,0,1,0,0),K.clearRect(0,0,q.width,q.height),K.restore(),Kt(K,Gt,a,o,null,null,null,rt)}return!0}catch(e){return e instanceof WebAssembly.RuntimeError&&Ft(e),!1}}function ne(){if(ft=null,xt||!pt||et||wt)return;let e=!1;try{G.set_now_ms?.(Date.now()),e=ut||G.is_dirty()}catch(m){Ft(m);return}let a=Tt&&Wt>0&&Date.now()-Wt>Me;e&&Tt&&!a?ut=!0:e&&(ut=!Xt(),ke());let o=ut;if(!o)try{o=G.is_dirty()}catch{o=!1}o&&yt()}function ve(){if(et||!q)return null;let e=q.width,a=q.height;if(!(e>0)||!(a>0)||!Xt())return null;try{let o=new OffscreenCanvas(e,a),m=o.getContext("2d");return m?(rt&&Z&&m.drawImage(Z,0,0),m.drawImage(q,0,0),o.transferToImageBitmap()):null}catch{return null}}function ke(){if(et||!st)return;let e=null;try{e=st.readState(G)}catch{return}let a=st.sig(e);a!==oe&&(oe=a,ht("state",e,e.map&&e.map.buffer?[e.map.buffer]:[]))}function Se(){try{G?.set_render_backend(0)}catch{}try{rt?.destroy()}catch{}rt=null,_t()}function Ce(){if(!(!Z||!st.gl||typeof G.set_render_backend!="function"))try{let e=st.lut==="dom"?()=>G.dom_lut_rgba():()=>G.ob_lut_rgba(),a=Qt(Z,{fetchLut:e,onContextLost:Se});if(!a.available){a.destroy();return}a.resize(Z.width,Z.height,nt),rt=a,G.set_render_backend(1)}catch(e){console.warn("[PanelEngine/worker] GL band unavailable, using Canvas2D:",e?.message||e),rt=null}}function kt(e,a){if(!(et||!G))try{jt(G,e,a),ut=!0}catch(o){o instanceof WebAssembly.RuntimeError&&Ft(o)}}async function De(e){if(st=Le[e.engine],!st)throw new Error(`unknown panel engine: ${e.engine}`);q=e.canvas,Z=e.gl||null,nt=e.dpr||1,wt=!!e.blocked;let[{module:a,memory:o}]=await Promise.all([Zt(),te(e.opts.fonts)]);Gt=o,K=q.getContext("2d"),K.setTransform(nt,0,0,nt,0,0);let m=a[e.engine];if(typeof m!="function")throw new Error(`engine missing in wasm: ${e.engine}`);G=new m(e.cssW,e.cssH);try{G.set_license_token?.(e.opts.licenseToken||"",Date.now(),e.opts.host||"")}catch(_){console.warn("[PanelEngine/worker] set_license_token failed:",_.message)}for(let[_,A]of e.opts.boot||[])kt(_,A);Ce(),wt&&ae(),ht("ready",{})}self.onmessage=e=>{let a=e.data;if(a)switch(a.t){case"init":De(a).catch(o=>Ft(o));return;case"call":kt(a.m,a.a),yt();return;case"calls":for(let[o,m]of a.batch)kt(o,m);yt();return;case"query":{let o=null;try{let m=G&&G[a.m];typeof m=="function"&&(o=m.apply(G,a.a||[]))}catch{o=null}ht("reply",{id:a.id,v:o});return}case"capture":{let o=ve();ht("reply",{id:a.id,v:o},o?[o]:[]);return}case"domVol":{let o=a.flat;if(!o)return;for(let m=0;m+2<o.length;m+=3)kt("push_dom_vol",[o[m],o[m+1],o[m+2]]);yt();return}case"click":{if(et||!G)return;let o=null;try{G.set_hover(a.x,a.y),o=st.clickHover(G)}catch{return}ut=!0,yt(),o&&ht("click",{hover:o});return}case"resize":{if(et||!G)return;nt=a.dpr||1;let o=q.width!==a.bufW||q.height!==a.bufH;q.width!==a.bufW&&(q.width=a.bufW),q.height!==a.bufH&&(q.height=a.bufH),K.setTransform(nt,0,0,nt,0,0),Z&&(Z.width!==a.bufW&&(Z.width=a.bufW),Z.height!==a.bufH&&(Z.height=a.bufH),rt?.resize(a.bufW,a.bufH,nt));try{G.resize(a.cssW,a.cssH)}catch(m){Ft(m);return}o&&Xt(),_t();return}case"life":if(a.v==="start")pt=!0,_t();else if(a.v==="stop")pt=!1,vt();else if(a.v==="destroy"){xt=!0,pt=!1,vt();try{rt?.destroy()}catch{}rt=null;try{G?.free()}catch{}G=null}return;case"vis":$t=!!a.v,$t?_t():vt();return;case"busy":Tt=!!a.v,Wt=Tt?Date.now():0,Tt||_t();return;case"heap":ht("heap",{bytes:Gt?.buffer?.byteLength||0});return;default:}};
|
|
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&>("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:}};
|