@wick-charts/react 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react"),C=require("react/jsx-runtime");var ls=Object.defineProperty,Si=s=>{throw TypeError(s)},hs=(s,t,e)=>t in s?ls(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,w=(s,t,e)=>hs(s,typeof t!="symbol"?t+"":t,e),je=(s,t,e)=>t.has(s)||Si("Cannot "+e),h=(s,t,e)=>(je(s,t,"read from private field"),e?e.call(s):t.get(s)),A=(s,t,e)=>t.has(s)?Si("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),F=(s,t,e,i)=>(je(s,t,"write to private field"),t.set(s,e),e),j=(s,t,e)=>(je(s,t,"access private method"),e),Ae=(s,t,e,i)=>({set _(n){F(s,t,n)},get _(){return h(s,t,i)}});class ce{constructor(){w(this,"listeners",new Map)}on(t,e){let i=this.listeners.get(t);i||(i=new Set,this.listeners.set(t,i)),i.add(e)}off(t,e){var i;(i=this.listeners.get(t))==null||i.delete(e)}emit(t,...e){var i;(i=this.listeners.get(t))==null||i.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function Qe(s,t){const e=new Map;return new Proxy(s,{get(i,n){const r=Reflect.get(i,n,i);if(typeof r!="function")return r;const a=e.get(n);if(a)return a;const o=typeof n=="string"?n:String(n),l=r,u=(...c)=>(t.set(o,(t.get(o)??0)+1),l.apply(i,c));return e.set(n,u),u},set(i,n,r){return Reflect.set(i,n,r,i)}})}function Ze(s,t,e){const i=document.createElement("canvas");return i.style.position="absolute",i.style.inset="0",i.style.width="100%",i.style.height="100%",i.style.display="block",i.style.zIndex=String(t),s.appendChild(i),i}class cs extends ce{constructor(t,e){super(),w(this,"mainCanvas"),w(this,"mainCtx"),w(this,"overlayCanvas"),w(this,"overlayCtx"),w(this,"resizeObserver"),w(this,"_size"),w(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=Ze(t,0),this.overlayCanvas=Ze(t,1);const i=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!i||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?Qe(i,e.drawCallsMain):i,this.overlayCtx=e?Qe(n,e.drawCallsOverlay):n;const r=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:r,verticalPixelRatio:r},this.resizeObserver=new ResizeObserver(o=>{this.handleResize(o[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const a=t.getBoundingClientRect();if(a.width>0&&a.height>0){const o=window.devicePixelRatio||1,l=o,u=Math.round(a.width*o),c=Math.round(a.height*l);this.mainCanvas.width=u,this.mainCanvas.height=c,this.overlayCanvas.width=u,this.overlayCanvas.height=c,this._size={media:{width:a.width,height:a.height},bitmap:{width:u,height:c},horizontalPixelRatio:u/a.width,verticalPixelRatio:c/a.height}}}handleResize(t){var e,i;let n,r,a,o;if(this.supportsDevicePixelContentBox&&(e=t.devicePixelContentBoxSize)!=null&&e[0]){const c=t.devicePixelContentBoxSize[0];n=c.inlineSize,r=c.blockSize;const d=t.contentBoxSize[0];a=d.inlineSize,o=d.blockSize}else{const c=(i=t.contentBoxSize)==null?void 0:i[0];if(c)a=c.inlineSize,o=c.blockSize;else{const f=t.contentRect;a=f.width,o=f.height}const d=window.devicePixelRatio||1;n=Math.round(a*d),r=Math.round(o*d)}if(n===0||r===0)return;this.mainCanvas.width=n,this.mainCanvas.height=r,this.overlayCanvas.width=n,this.overlayCanvas.height=r;const l=n/a,u=r/o;this._size={media:{width:a,height:o},bitmap:{width:n,height:r},horizontalPixelRatio:l,verticalPixelRatio:u},this.emit("resize",this._size)}get size(){return this._size}useMainLayer(t){this.mainCtx.save(),t({context:this.mainCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.mainCtx.restore()}useOverlayLayer(t){const{width:e,height:i}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,i),this.overlayCtx.save(),t({context:this.overlayCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.overlayCtx.restore()}get canvas(){return this.overlayCanvas}destroy(){this.resizeObserver.disconnect(),this.mainCanvas.remove(),this.overlayCanvas.remove(),this.removeAllListeners()}}function us(s,t,e,i){const{context:n,bitmapSize:r,horizontalPixelRatio:a}=s;n.strokeStyle=i.crosshair.color,n.lineWidth=1,n.setLineDash([4*a,4*a]);const o=Math.round(t)+.5,l=Math.round(e)+.5;n.beginPath(),n.moveTo(o,0),n.lineTo(o,r.height),n.moveTo(0,l),n.lineTo(r.width,l),n.stroke(),n.setLineDash([])}const ds=3,fs=8,ti=900,ms=24,gs=11,ps=10,bs=18;function vs(s){const{state:t}=s;if(t==="idle"||t==="has-more")return;const e=s.timeScale.timeToX(s.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){ys(s,e);return}t==="no-data"&&xs(s,e)}}function ys({scope:s,theme:t,chartMediaHeight:e,side:i,now:n},r){const{context:a,horizontalPixelRatio:o,verticalPixelRatio:l}=s,u=ds*o,c=fs*o,d=ms*o,f=r*o,m=i==="right"?f+d:f-d,p=e/2*l,g=n%ti/ti,v=Math.floor(g*3),y=wi(t.axis.textColor??"#787b86",.3),x=t.axis.textColor??"#787b86";a.save();for(let S=0;S<3;S++){const k=(S-1)*c,M=m+k;a.beginPath(),a.arc(M,p,u,0,Math.PI*2),a.fillStyle=S===v?x:y,a.fill()}a.restore()}function xs({scope:s,theme:t,chartMediaHeight:e,side:i},n){const{context:r,horizontalPixelRatio:a,verticalPixelRatio:o}=s,l=Math.round(n*a)+.5;r.save(),r.strokeStyle=wi(t.axis.textColor??"#787b86",.6),r.lineWidth=1,r.setLineDash([4*a,4*a]),r.beginPath(),r.moveTo(l,0),r.lineTo(l,e*o),r.stroke(),r.setLineDash([]);const u=ps*a,c=i==="right"?l-u:l+u,d=bs*o;r.fillStyle=t.axis.textColor??"#787b86",r.font=`${gs*a}px ${t.typography.fontFamily}`,r.textAlign=i==="right"?"right":"left",r.textBaseline="top",r.fillText("No more data",c,d),r.restore()}function wi(s,t){const e=/^#([0-9a-f]{6})$/i.exec(s.trim());if(!e)return s;const i=parseInt(e[1].slice(0,2),16),n=parseInt(e[1].slice(2,4),16),r=parseInt(e[1].slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${t})`}function Ss(s,t,e,i,n){const{context:r,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=s;r.strokeStyle=i.grid.color,r.lineWidth=1,i.grid.style==="dashed"?r.setLineDash([4*o,4*o]):i.grid.style==="dotted"&&r.setLineDash([1*o,3*o]);const u=e.niceTickValues();r.beginPath();for(const d of u){const f=Math.round(e.valueToBitmapY(d))+.5;r.moveTo(0,f),r.lineTo(a.width,f)}r.stroke();const{ticks:c}=t.niceTickValues(n);r.beginPath();for(const d of c){const f=Math.round(t.timeToBitmapX(d))+.5;r.moveTo(f,0),r.lineTo(f,a.height)}r.stroke(),r.setLineDash([])}function Gt(s,t,e){return Math.max(t,Math.min(e,s))}function ct(s,t,e){return s+(t-s)*e}function Pt(s,t,e,i){const n=Math.exp(-e*i);return t+(s-t)*n}function Ci(s){return 1-(1-s)**3}function Ie(s,t,e){let i=0,n=s.length-1;for(;i<=n;){const r=i+n>>>1,a=e(s[r]);if(a<t)i=r+1;else if(a>t)n=r-1;else return r}return i}class Mi extends ce{constructor(){super(...arguments),w(this,"data",[]),w(this,"_visible",!0),w(this,"cachedRange",null),w(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let i=1;i<t.length;i++)if(t[i].time<t[i-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((i,n)=>i.time-n.time),this.cachedRange=null,this.emit("update")}append(t){if(this.data.length>0&&t.time<=this.data[this.data.length-1].time){this.updateLast(t);return}this.data.push(t),this.cachedRange=null,this.emit("update")}updateLast(t){this.data.length!==0&&(this.data[this.data.length-1]=t,this.cachedRange=null,this.emit("update"))}getAll(){return this.data}getVisibleData(t,e){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===e)return this.cachedResult;const i=Math.max(0,Ie(this.data,t,r=>r.time)-1),n=Math.min(this.data.length,Ie(this.data,e,r=>r.time)+1);return this.cachedResult=this.data.slice(i,n),this.cachedRange={from:t,to:e},this.cachedResult}first(){return this.data[0]}last(){return this.data[this.data.length-1]}get length(){return this.data.length}isEmpty(){return this.data.length===0}findNearest(t,e){if(this.data.length===0)return null;const i=Ie(this.data,t,a=>a.time);let n=null,r=e;for(let a=Math.max(0,i-1);a<=Math.min(this.data.length-1,i+1);a++){const o=Math.abs(this.data[a].time-t);o<=r&&(r=o,n=this.data[a])}return n}}class ws{constructor(t,e,i){w(this,"dragging",!1),w(this,"lastX",0),this.viewport=t,this.timeScale=e,this.canvas=i}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const e=t.clientX-this.lastX;this.lastX=t.clientX;const i=this.timeScale.pixelDeltaToTimeDelta(-e);this.viewport.pan(i,this.timeScale.getMediaWidth())}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair",this.viewport.startRebound(this.timeScale.getMediaWidth()))}isDragging(){return this.dragging}}const Cs=150;class Ms{constructor(t,e){w(this,"reboundTimer",null),this.viewport=t,this.timeScale=e}handleWheel(t){t.preventDefault();const e=ks(t.deltaY,t.deltaMode),i=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),r=Math.min(t.offsetX,n),a=this.timeScale.xToTime(r);this.viewport.zoomAt(a,i,n),this.reboundTimer!==null&&clearTimeout(this.reboundTimer),this.reboundTimer=setTimeout(()=>{this.reboundTimer=null,this.viewport.startRebound(n)},Cs)}cancelPendingRebound(){this.reboundTimer!==null&&(clearTimeout(this.reboundTimer),this.reboundTimer=null)}}function ks(s,t){return t===WheelEvent.DOM_DELTA_LINE?s*8:t===WheelEvent.DOM_DELTA_PAGE?s*24:s}class Ts extends ce{constructor(t,e,i,n){super(),w(this,"zoom"),w(this,"pan"),w(this,"canvas"),w(this,"timeScale"),w(this,"yScale"),w(this,"viewport"),w(this,"onWheel",r=>{this.zoom.handleWheel(r)}),w(this,"onMouseDown",r=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(r)}),w(this,"onMouseMove",r=>{this.pan.isDragging()&&this.pan.handleMouseMove(r),this.emitCrosshair(r.offsetX,r.offsetY)}),w(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),w(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),w(this,"onDblClick",()=>{}),w(this,"lastTouchDist",0),w(this,"lastTouchCenter",0),w(this,"touchCount",0),w(this,"onTouchStart",r=>{r.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=r.touches.length,r.touches.length===1?this.pan.handleMouseDown({button:0,clientX:r.touches[0].clientX}):r.touches.length===2&&(this.lastTouchDist=Math.abs(r.touches[0].clientX-r.touches[1].clientX),this.lastTouchCenter=(r.touches[0].clientX+r.touches[1].clientX)/2)}),w(this,"onTouchMove",r=>{if(r.preventDefault(),r.touches.length===1&&this.touchCount===1){this.pan.handleMouseMove({clientX:r.touches[0].clientX});const a=this.canvas.getBoundingClientRect();this.emitCrosshair(r.touches[0].clientX-a.left,r.touches[0].clientY-a.top)}else if(r.touches.length===2){const a=Math.abs(r.touches[0].clientX-r.touches[1].clientX),o=(r.touches[0].clientX+r.touches[1].clientX)/2,l=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const u=this.lastTouchDist/a,c=this.timeScale.xToTime(o-l.left);this.viewport.zoomAt(c,u,this.timeScale.getMediaWidth())}this.lastTouchDist=a,this.lastTouchCenter=o}}),w(this,"onTouchEnd",r=>{if(r.touches.length===0){const a=this.touchCount===2;this.pan.handleMouseUp(),a&&this.viewport.startRebound(this.timeScale.getMediaWidth()),this.touchCount=0,this.lastTouchDist=0}}),this.canvas=t,this.viewport=e,this.timeScale=i,this.yScale=n,this.zoom=new Ms(e,i),this.pan=new ws(e,i,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd)}emitCrosshair(t,e){const i=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:i,y:n})}destroy(){this.zoom.cancelPendingRebound(),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.removeAllListeners()}}const Rs=new WeakMap;function Ls(s,t){Rs.set(s,t)}const Is=100,Ds={position:"absolute",top:"4px",right:"4px",padding:"4px 6px",background:"rgba(0, 0, 0, 0.6)",color:"#e0e0e0",font:"11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace",borderRadius:"3px",pointerEvents:"none",zIndex:"20",whiteSpace:"pre",letterSpacing:"0.01em"};function ei(s){let t=0;for(const e of Object.values(s))t+=e;return t}const he=9,_e=7,yt=6,He=9;function Fs(s,t){return Math.round(s*t).toLocaleString("en-US")}function ii(s,t,e,i,n){return[s.padEnd(he),t.toFixed(1).padStart(_e),e.toFixed(2).padStart(yt),i.toFixed(2).padStart(yt),Fs(n,t).padStart(He)].join(" ")}function si(s){return[s.padEnd(he),"—".padStart(_e),"—".padStart(yt),"—".padStart(yt),"idle".padStart(He)].join(" ")}function Bs(){return["".padEnd(he),"FPS".padStart(_e),"ms".padStart(yt),"worst".padStart(yt),"calls/s".padStart(He)].join(" ")}function Ps(s){const t=ei(s.drawCalls.main),e=ei(s.drawCalls.overlay),i=s.frameCount.main===0?si("Main"):ii("Main",s.mainRendersPerSec,s.mainFrameMs.last,s.mainFrameMs.p95,t),n=s.frameCount.overlay===0?si("Overlay"):ii("Overlay",s.overlayRendersPerSec,s.overlayFrameMs.last,s.overlayFrameMs.p95,e),r=[Bs(),i,n],a=Object.keys(s.perSeries);if(a.length>1){r.push(""),r.push("Per series (main pass)"),r.push(["".padEnd(he),"ms".padStart(yt),"worst".padStart(yt)].join(" "));for(const o of a){const l=s.perSeries[o];r.push([` ${o}`.padEnd(he),l.last.toFixed(2).padStart(yt),l.p95.toFixed(2).padStart(yt)].join(" "))}}return r.join(`
2
- `)}class zs{constructor(t,e,i=Is){w(this,"element"),w(this,"unsubscribe"),w(this,"updateIntervalMs"),w(this,"lastUpdate",0),this.updateIntervalMs=i;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,Ds),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=Ps(t))}}const As=5e3,Ws=2e3,Es=30;function De(s,t,e){let i=0;for(;i<t.length&&t[i]<e;)i++;i>0&&(s.splice(0,i),t.splice(0,i))}function Fe(s,t,e){const i=s.length-e;i>0&&(s.splice(0,i),t.splice(0,i))}function Be(s){if(s.length===0)return{last:0,p50:0,p95:0};const t=[...s].sort((e,i)=>e-i);return{last:s[s.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function ni(s){if(s.length<2)return 0;const t=s[s.length-1]-s[0];return t<=0?0:(s.length-1)*1e3/t}function ri(s){const t={};for(const[e,i]of s)t[e]=i;return t}class Pe{constructor(t={}){w(this,"drawCallsMain",new Map),w(this,"drawCallsOverlay",new Map),w(this,"mainMs",[]),w(this,"overlayMs",[]),w(this,"mainStamps",[]),w(this,"overlayStamps",[]),w(this,"perSeriesMs",new Map),w(this,"perSeriesStamps",new Map),w(this,"listeners",new Set),w(this,"windowMs"),w(this,"maxSamples"),w(this,"heapInterval"),w(this,"heapCounter",0),w(this,"heapMb",null),w(this,"mainFrameCount",0),w(this,"overlayFrameCount",0),w(this,"lastStamp",0),this.windowMs=t.windowMs??As,this.maxSamples=t.maxSamples??Ws,this.heapInterval=t.heapSampleEveryNFrames??Es}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,i){if(this.lastStamp=i,t==="main"?(this.mainMs.push(e),this.mainStamps.push(i),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(i),this.overlayFrameCount++),this.trimAll(i),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,i=this.lastStamp){let n=this.perSeriesMs.get(t),r=this.perSeriesStamps.get(t);(!n||!r)&&(n=[],r=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,r)),n.push(e),r.push(i)}trimAll(t){const e=t-this.windowMs;De(this.mainMs,this.mainStamps,e),De(this.overlayMs,this.overlayStamps,e),Fe(this.mainMs,this.mainStamps,this.maxSamples),Fe(this.overlayMs,this.overlayStamps,this.maxSamples);for(const i of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(i),r=this.perSeriesStamps.get(i);!n||!r||(De(n,r,e),Fe(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[i,n]of this.perSeriesMs)t[i]=Be(n);const e=ni(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:ni(this.overlayStamps),fps:e,mainFrameMs:Be(this.mainMs),overlayFrameMs:Be(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:ri(this.drawCallsMain),overlay:ri(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}class me{constructor(t){w(this,"dirty",!1),w(this,"rafId",null),w(this,"callback"),w(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const _t=6e4,Et=36e5,Dt=864e5;function at(s){return s instanceof Date?s.getTime():s}function Vs(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:at(t.time)}))}function Ys(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:at(t.time)}))}function ki(s){if(s.length<2)return Dt;const t=[];for(let e=1;e<Math.min(s.length,20);e++)t.push(s[e]-s[e-1]);return t.sort((e,i)=>e-i),t[Math.floor(t.length/2)]}function ue(s,t){const e=new Date(s);return t>=Dt?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=Et?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Ti(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function js(s){const t=[1e3,5e3,1e4,15e3,3e4],e=[_t,5*_t,10*_t,15*_t,30*_t],i=[Et,2*Et,4*Et,6*Et,12*Et],n=[Dt,7*Dt,30*Dt,90*Dt,365*Dt];return s<_t?[...t,...e,...i,...n]:s<Et?[...e,...i,...n]:s<Dt?[...i,...n]:n}const _s=50,Hs=80;class Os{constructor(){w(this,"from",0),w(this,"to",0),w(this,"width",1),w(this,"pixelRatio",1),w(this,"dataInterval",null),w(this,"labelCountHintValue",null),w(this,"minSpacingValue",null),w(this,"resolvedInterval",null),w(this,"lastInterval",null),w(this,"lastWant",null),w(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Hs}update(t,e,i,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=i,n!==void 0&&n>0){const r=ai(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=$s(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Xs(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const a=ai(t);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,i=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(_s,Math.floor((this.to-i)/e)+1)),r=[];for(let a=0;a<n;a++)r.push(i+a*e);return{ticks:r,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=js(this.dataInterval),e=this.to-this.from,i=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const o=Math.max(1,this.labelCountHint);n=Math.max(e/o,i)}else n=i;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const o=n>=this.lastWant*.8&&n<=this.lastWant*1.25,l=this.lastInterval>=i;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],a=t.length-1;for(let o=0;o<t.length;o++)if(t[o]>=n){r=t[o],a=o;break}if(this.labelCountHint!=null&&a>0&&this.countTicks(r)<this.labelCountHint){const o=t[a-1];o>=i&&(r=o)}this.resolvedInterval=r,this.lastInterval=r,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function ai(s){return s<6e4?0:s<36e5?1:s<864e5?2:3}function $s(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function Xs(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Ri(s){const t=Math.abs(s);if(t===0)return"0";if(t<1e-12)return s.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),i=Math.min(12,e+4),n=s.toFixed(i);return n.includes(".")?n.replace(/\.?0+$/,""):n}function Li(s){return Number.isNaN(s)?"—":s===1/0?"∞":s===-1/0?"−∞":null}function At(s,t){const e=Li(s);if(e!==null)return e;const i=Math.abs(s),n=(t==null?void 0:t.decimals)??2,r=(a,o,l)=>{const u=a/o,c=Number.parseFloat(u.toFixed(n));return Math.abs(c)>=1e3?null:`${u.toFixed(n)}${l}`};return i>=1e15?s.toExponential(2):i>=1e12?r(s,1e12,"T")??s.toExponential(2):i>=1e9?r(s,1e9,"B")??`${(s/1e12).toFixed(n)}T`:i>=1e6?r(s,1e6,"M")??`${(s/1e9).toFixed(n)}B`:i>=1e3?r(s,1e3,"K")??`${(s/1e6).toFixed(n)}M`:i<1?Ri(s):i<100?s.toFixed(2):s.toFixed(0)}function Oe(s){const t=Li(s);if(t!==null)return t;const e=Math.abs(s);return e===0?"0":e<1?Ri(s):e<100?s.toFixed(4):e>=1e7?At(s):e<1e4?s.toFixed(2):s.toFixed(0)}function Ns(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function Us(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e>=5?5:e>=2?2:1)*t}const Gs=50,Ks=50;class qs{constructor(){w(this,"min",0),w(this,"max",0),w(this,"height",1),w(this,"pixelRatio",1),w(this,"labelCountHintValue",null),w(this,"minSpacingValue",null),w(this,"resolvedInterval",null),w(this,"lastInterval",null),w(this,"lastRawInterval",null),w(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Ks}update(t,e,i){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=i,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Js(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Qs(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,i=Math.max(0,Math.min(Gs,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<i;r++)n.push(e+r*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return At(t);const e=this.resolvedInterval,i=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(i)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,i=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/i;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const a=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,o=this.lastInterval>=e;if(a&&o){this.resolvedInterval=this.lastInterval;return}}let r=Ns(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const a=Us(n);a>=e&&a>0&&(r=a)}this.resolvedInterval=r,this.lastInterval=r,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function Js(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function Qs(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function zt(s,t){return s===!1?0:s===void 0?t:s}function Ht(s,t){const e=Math.max(1e-4,Math.abs(t)*1e-5);return Math.abs(s-t)>e}function Zs(s,t,e,i){const n=s==null?void 0:s.get(t);if(!n)return 1;if(i<=0)return s==null||s.delete(t),1;const r=Gt((e-n.startTime)/i,0,1),a=Ci(r);return r>=1&&(s==null||s.delete(t)),a}function tn(s){let t=0,e=0;for(const i of s)i>0?t+=i:i<0&&(e+=i);return{positive:t,negative:e}}function en(s){return s.positive>0?s.positive:s.negative<0?s.negative:0}function sn(s){return s.positive>0?100:s.negative<0?-100:0}class Ii{constructor(t){w(this,"stores"),w(this,"displayedLastValues"),w(this,"lastSeededTimes"),w(this,"entries"),w(this,"lastRenderTime",0),this.stores=Array.from({length:t},()=>new Mi),this.displayedLastValues=new Array(t).fill(null),this.lastSeededTimes=new Array(t).fill(Number.NaN),this.entries=Array.from({length:t},()=>new Map)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=Ys(t??[]);n.setData(r),(i=this.entries[e])==null||i.clear()}appendPoint(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=t,a=at(r.time),o=this.createEntry(e,a,performance.now());n.append({...r,time:a}),o&&((i=this.entries[e])==null||i.set(a,o))}updateLastPoint(t,e=0){const i=this.stores[e];if(!i)return;const n=t;i.updateLast({...n,time:at(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var i;(i=this.stores[t])==null||i.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners();for(const t of this.entries)t.clear();this.displayedLastValues=this.displayedLastValues.map(()=>null),this.lastSeededTimes=this.lastSeededTimes.map(()=>Number.NaN),this.lastRenderTime=0}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}get needsAnimation(){for(const t of this.entries)if(t.size>0)return!0;for(let t=0;t<this.stores.length;t++){const e=this.displayedLastValues[t],i=this.stores[t].last();if(!(e==null||!i)&&this.lastSeededTimes[t]===i.time&&Ht(e,i.value))return!0}return!1}advanceLiveTracking(t){if(t===this.lastRenderTime)return;const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=zt(this.getCommonOptions().smoothMs,70),n=i>0?1e3/i:0;for(let r=0;r<this.stores.length;r++){const a=this.stores[r].last();if(!a){this.displayedLastValues[r]=null,this.lastSeededTimes[r]=Number.NaN;continue}const o=this.displayedLastValues[r],l=this.lastSeededTimes[r]!==a.time;if(o===null||l||n<=0){this.displayedLastValues[r]=a.value,this.lastSeededTimes[r]=a.time;continue}this.displayedLastValues[r]=Pt(o,a.value,n,e)}}entranceProgress(t,e,i){const n=zt(this.getCommonOptions().entryMs,400);return Zs(this.entries[t],e,i,n)}effectiveValue(t,e,i){const n=this.displayedLastValues[t];return n==null||this.lastSeededTimes[t]!==e?i:n}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var i;return((i=this.stores[0])==null?void 0:i.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const i=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const a=this.stores[r].getVisibleData(t-e,t+e);if(a.length===0)continue;let o=a[0],l=Math.abs(a[0].time-t);for(let u=1;u<a.length;u++){const c=Math.abs(a[u].time-t);c<=l&&(l=c,o=a[u])}n.push({layerIndex:r,time:o.time,value:o.value,color:i[r%i.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const a=(t=this.stores[0])==null?void 0:t.last();return a?{value:a.value,isLive:!0}:null}let e=-1/0;for(const a of this.stores){if(!a.isVisible())continue;const o=a.last();o&&o.time>e&&(e=o.time)}if(e===-1/0)return null;const i=this.getCommonOptions().stacking;if(i==="off"){for(let a=this.stores.length-1;a>=0;a--){if(!this.stores[a].isVisible())continue;const o=this.stores[a].last();if(o)return{value:o.value,isLive:!0}}return null}const n=[];for(const a of this.stores){if(!a.isVisible())continue;const o=a.last();n.push(o&&o.time===e?o.value:0)}const r=tn(n);return{value:i==="percent"?sn(r):en(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();n&&e.push({layerIndex:i,time:n.time,value:n.value,color:t[i%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getValueRange(t,e){const i=this.getCommonOptions().stacking;if(i==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(l=>l.isVisible()?l.getVisibleData(t,e):[]);if(i==="off"){let l=1/0,u=-1/0;for(const c of n)for(const d of c)d.value<l&&(l=d.value),d.value>u&&(u=d.value);return l<1/0?{min:l,max:u}:null}const r=new Map;for(let l=0;l<n.length;l++)for(const u of n[l]){let c=r.get(u.time);c||(c=new Array(n.length).fill(0),r.set(u.time,c)),c[l]=u.value}let a=0,o=0;for(const l of r.values()){let u=0,c=0;for(const d of l)d>0?u+=d:c+=d;u>o&&(o=u),c<a&&(a=c)}return o>a?{min:a,max:o}:null}}const nn={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function oi(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class rn extends Ii{constructor(t,e){super(t),w(this,"options"),this.options={...nn,...oi(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...oi(t)}}getCommonOptions(){return this.options}createEntry(t,e,i){const n=this.options.entryAnimation??"fade-grow",r=zt(this.options.entryMs,400);return n==="none"||r<=0?null:{startTime:i}}applyTheme(t,e){this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)})}applyBarTransform(t,e,i,n,r,a){const o=this.options.entryAnimation??"fade-grow";if(t>=1||o==="none")return{topY:i,barHeight:n,x:r,barWidth:a,alpha:1};let l=i,u=n,c=r,d=1;if((o==="fade"||o==="fade-grow")&&(d=t),o==="grow"||o==="fade-grow"){const f=n*t;i<e?l=e-f:l=e,u=Math.max(1,f)}return o==="slide"&&(c=r+(1-t)*a,d=t),{topY:l,barHeight:u,x:c,barWidth:a,alpha:d}}render(t){switch(this.advanceLiveTracking(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a}=e,o=i.getRange(),l=performance.now(),u=i.barWidthBitmap(r),c=Math.max(1,Math.round(u*this.options.barWidthRatio)-2),d=Math.floor(c/2),f=n.getRange().min<0,m=f?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const p=this.options.colors[0],g=this.options.colors.length>1?this.options.colors[1]:p,v=this.stores[0].getVisibleData(o.from,o.to);for(const y of v){const x=this.effectiveValue(0,y.time,y.value),S=this.entranceProgress(0,y.time,l),k=i.timeToBitmapX(y.time);if(x>=0){const M=n.valueToBitmapY(x),I=Math.max(1,m-M);this.drawAnimatedBar(a,S,m,M,I,k-d,c,x>=0?p:g)}else{const M=n.valueToBitmapY(x),I=Math.max(1,M-m);this.drawAnimatedBar(a,S,m,m,I,k-d,c,g)}}}else{const p=this.stores.map(v=>v.isVisible()?v.getVisibleData(o.from,o.to):[]),g=new Map;for(let v=0;v<p.length;v++)for(const y of p[v]){let x=g.get(y.time);x||(x=[],g.set(y.time,x)),x.push({layer:v,value:this.effectiveValue(v,y.time,y.value)})}for(const[v,y]of g){y.sort((S,k)=>Math.abs(k.value)-Math.abs(S.value));const x=i.timeToBitmapX(v);for(const{layer:S,value:k}of y){const M=this.options.colors[S%this.options.colors.length],I=this.entranceProgress(S,v,l);if(k>=0){const b=n.valueToBitmapY(k),T=Math.max(1,m-b);this.drawAnimatedBar(a,I,m,b,T,x-d,c,M)}else{const b=n.valueToBitmapY(k),T=Math.max(1,b-m);this.drawAnimatedBar(a,I,m,m,T,x-d,c,M)}}}}if(f){a.strokeStyle=t.theme.grid.color,a.lineWidth=1;const p=Math.round(m)+.5;a.beginPath(),a.moveTo(0,p),a.lineTo(e.bitmapSize.width,p),a.stroke()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r,dataInterval:a}=t,{context:o}=i,l=n.getRange(),u=performance.now(),c=n.barWidthBitmap(a),d=Math.max(1,Math.round(c*this.options.barWidthRatio)-2),f=Math.floor(d/2),m=this.stores.map(g=>g.isVisible()?g.getVisibleData(l.from,l.to):[]);if(m.every(g=>g.length===0))return;const p=new Map;for(let g=0;g<m.length;g++)for(const v of m[g]){let y=p.get(v.time);y||(y=new Array(m.length).fill(0),p.set(v.time,y)),y[g]=this.stores[g].isVisible()?this.effectiveValue(g,v.time,v.value):0}for(let g=0;g<m.length;g++){const v=this.options.colors[g%this.options.colors.length];for(const[y,x]of p){const S=x[g];if(S===0)continue;const k=n.timeToBitmapX(y);let M=0,I=0;for(let T=0;T<g;T++){const R=x[T];R>0?M+=R:I+=R}const b=this.entranceProgress(g,y,u);if(e){let T=0,R=0;for(const D of x)D>0?T+=D:R+=D;if(S>0&&T>0){const D=M/T*100,B=(M+S)/T*100,Y=r.valueToBitmapY(B),V=r.valueToBitmapY(D),P=Math.max(1,V-Y);this.drawAnimatedBar(o,b,V,Y,P,k-f,d,v)}else if(S<0&&R<0){const D=I/R*-100,B=(I+S)/R*-100,Y=r.valueToBitmapY(D),V=r.valueToBitmapY(B),P=Math.max(1,V-Y);this.drawAnimatedBar(o,b,Y,Y,P,k-f,d,v)}}else if(S>0){const T=r.valueToBitmapY(M+S),R=r.valueToBitmapY(M),D=Math.max(1,R-T);this.drawAnimatedBar(o,b,R,T,D,k-f,d,v)}else{const T=r.valueToBitmapY(I),R=r.valueToBitmapY(I+S),D=Math.max(1,R-T);this.drawAnimatedBar(o,b,T,T,D,k-f,d,v)}}}}fillBar(t,e,i,n,r,a){t.fillStyle=a,t.fillRect(e,i,n,r)}drawAnimatedBar(t,e,i,n,r,a,o,l){const u=this.options.entryAnimation??"fade-grow";if(e>=1||u==="none"){this.fillBar(t,a,n,o,r,l);return}const c=this.applyBarTransform(e,i,n,r,a,o);t.save(),t.globalAlpha=c.alpha,t.fillStyle=l,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function li(s,t){return s.length<=t?s:on(s,t,e=>e.time,e=>e.value)}function an(s,t){if(s.length<=t)return s;const e=Math.ceil(s.length/t),i=[];for(let n=0;n<s.length;n+=e){const r=Math.min(n+e,s.length);let a=-1/0,o=1/0,l=0;for(let u=n;u<r;u++)s[u].high>a&&(a=s[u].high),s[u].low<o&&(o=s[u].low),l+=s[u].volume??0;i.push({time:s[n].time,open:s[n].open,high:a,low:o,close:s[r-1].close,volume:l})}return i}function on(s,t,e,i){if(t>=s.length||t<3)return s;const n=[s[0]],r=(s.length-2)/(t-2);let a=0;for(let o=0;o<t-2;o++){const l=Math.floor((o+1)*r)+1,u=Math.min(Math.floor((o+2)*r)+1,s.length-1);let c=0,d=0;const f=u,m=Math.min(Math.floor((o+3)*r)+1,s.length),p=m-f;if(p>0){for(let S=f;S<m;S++)c+=e(s[S]),d+=i(s[S]);c/=p,d/=p}let g=-1,v=l;const y=e(s[a]),x=i(s[a]);for(let S=l;S<u;S++){const k=Math.abs((y-c)*(i(s[S])-x)-(y-e(s[S]))*(d-x));k>g&&(g=k,v=S)}n.push(s[v]),a=v}return n.push(s[s.length-1]),n}const hi=new Map,ci=new Map,ui=new Map;function $e(s){return[parseInt(s.slice(1,3),16),parseInt(s.slice(3,5),16),parseInt(s.slice(5,7),16)]}function Di(s,t,e){return`#${s.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}`}function Nt(s,t){if(s.startsWith("rgba"))return s.replace(/[\d.]+\)\s*$/,`${t})`);if(s.startsWith("rgb("))return s.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=s+t;let i=hi.get(e);if(i)return i;const[n,r,a]=$e(s);return i=`rgba(${n}, ${r}, ${a}, ${t})`,hi.set(e,i),i}function ln(s,t){const e=s+t;let i=ci.get(e);if(i)return i;const[n,r,a]=$e(s);return i=Di(Math.min(255,Math.round(n+(255-n)*t)),Math.min(255,Math.round(r+(255-r)*t)),Math.min(255,Math.round(a+(255-a)*t))),ci.set(e,i),i}function hn(s,t){const e=s+t;let i=ui.get(e);if(i)return i;const[n,r,a]=$e(s);return i=Di(Math.max(0,Math.round(n*(1-t))),Math.max(0,Math.round(r*(1-t))),Math.max(0,Math.round(a*(1-t)))),ui.set(e,i),i}const cn={upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350",bodyWidthRatio:.6};function di(s){if(!s)return{};const t={...s};return s.candleGradient!==void 0&&s.bodyGradient===void 0&&(t.bodyGradient=s.candleGradient),s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class un{constructor(t,e){w(this,"store"),w(this,"options"),w(this,"displayedLast",null),w(this,"lastSeededTime",Number.NaN),w(this,"lastRenderTime",0),w(this,"entries",new Map),this.store=t,this.options={...cn,...di(e)}}updateOptions(t){this.options={...this.options,...di(t)}}getColor(){return this.options.upColor}setData(t){this.store.setData(Vs(t??[])),this.entries.clear()}appendPoint(t){const e=t,i=at(e.time);this.store.append({...e,time:i});const n=this.options.entryAnimation??"unfold",r=zt(this.options.entryMs,400);n!=="none"&&r>0&&this.entries.set(i,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:at(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.options.upColor]}applyTheme(t,e){this.updateOptions({upColor:t.candlestick.upColor,downColor:t.candlestick.downColor,wickUpColor:t.candlestick.wickUpColor,wickDownColor:t.candlestick.wickDownColor})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners(),this.displayedLast=null,this.lastSeededTime=Number.NaN,this.lastRenderTime=0,this.entries.clear()}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}cancelEntranceAnimations(){this.entries.clear()}get needsAnimation(){if(this.entries.size>0)return!0;if(!this.displayedLast)return!1;const t=this.store.last();if(!t||t.time!==this.displayedLast.time)return!1;if(Ht(this.displayedLast.open,t.open)||Ht(this.displayedLast.high,t.high)||Ht(this.displayedLast.low,t.low)||Ht(this.displayedLast.close,t.close))return!0;const e=this.displayedLast.volume,i=t.volume;return e===void 0||i===void 0?!1:Ht(e,i)}entranceProgress(t,e){const i=this.entries.get(t);if(!i)return 1;const n=zt(this.options.entryMs,400);if(n<=0)return this.entries.delete(t),1;const r=Gt((e-i.startTime)/n,0,1),a=Ci(r);return r>=1&&this.entries.delete(t),a}advanceLiveTracking(t){const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=this.store.last();if(!i){this.displayedLast=null,this.lastSeededTime=Number.NaN;return}const n=this.lastSeededTime!==i.time,r=zt(this.options.smoothMs,70),a=r>0?1e3/r:0;if(this.displayedLast===null||n||a<=0){this.displayedLast={...i},this.lastSeededTime=i.time;return}const o=this.displayedLast,l=o.volume??0,u=i.volume??0;this.displayedLast={time:i.time,open:Pt(o.open,i.open,a,e),high:Pt(o.high,i.high,a,e),low:Pt(o.low,i.low,a,e),close:Pt(o.close,i.close,a,e),volume:i.volume===void 0?void 0:Pt(l,u,a,e)}}render(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:o}=e,l=i.getRange(),u=performance.now();this.advanceLiveTracking(u);let c=this.store.getVisibleData(l.from,l.to);const d=e.mediaSize.width,f=c.length>d*2;if(f&&(c=an(c,Math.round(d*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const I=c.length-1;c[I].time===this.displayedLast.time&&(c=[...c.slice(0,I),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const I of c)this.entries.has(I.time)&&m.set(I.time,this.entranceProgress(I.time,u));const p=i.barWidthBitmap(r),g=Math.max(1,Math.round(p*this.options.bodyWidthRatio)-2),v=Math.floor(g/2),y=Math.max(1,Math.round(o)),x=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:a,data:c,timeScale:i,chartHeight:x,barWidth:p,entranceByTime:m});const S=[],k=[];for(const I of c)I.close>=I.open?S.push(I):k.push(I);const M={ctx:a,timeScale:i,yScale:n,halfBody:v,bodyWidth:g,wickWidth:y,entranceByTime:m};this.drawCandles({...M,candles:S,bodyColor:this.options.upColor,wickColor:this.options.wickUpColor}),this.drawCandles({...M,candles:k,bodyColor:this.options.downColor,wickColor:this.options.wickDownColor})}drawVolume({ctx:t,data:e,timeScale:i,chartHeight:n,barWidth:r,entranceByTime:a}){let o=0;for(const p of e)p.volume!==void 0&&p.volume>o&&(o=p.volume);if(o===0)return;const l=n*.2,u=Math.max(1,r-2),c=Math.floor(u/2),d=Nt(this.options.upColor,.2),f=Nt(this.options.downColor,.2),m=this.options.entryAnimation??"unfold";for(const p of e){if(p.volume===void 0||p.volume===0)continue;const g=i.timeToBitmapX(p.time),v=Math.max(1,p.volume/o*l),y=p.close>=p.open;t.fillStyle=y?d:f;const x=(a==null?void 0:a.get(p.time))??1;if(x>=1||m==="none"){t.fillRect(g-c,n-v,u,v);continue}const S=ze(x,m,{x:g-c,barWidth:u,anchorY:n,topY:n-v,bottomY:n});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,u,Math.max(1,S.bottomY-S.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:i,yScale:n,halfBody:r,bodyWidth:a,wickWidth:o,bodyColor:l,wickColor:u,entranceByTime:c}){if(e.length===0)return;const d=this.options.entryAnimation??"unfold",f=a+2;t.fillStyle=u;for(const v of e){const y=(c==null?void 0:c.get(v.time))??1,x=i.timeToBitmapX(v.time),S=n.valueToBitmapY(v.open),k=n.valueToBitmapY(v.high),M=n.valueToBitmapY(v.low),I=x-Math.floor(o/2);if(y>=1||d==="none"){t.fillRect(I,k,o,M-k);continue}const b=ze(y,d,{x:I,barWidth:f,anchorY:S,topY:k,bottomY:M});t.save(),t.globalAlpha=b.alpha,t.fillRect(b.x,b.topY,o,Math.max(1,b.bottomY-b.topY)),t.restore()}const m=this.options.bodyGradient!==!1,p=m?ln(l,.2):l,g=m?hn(l,.15):l;m||(t.fillStyle=l);for(const v of e){const y=(c==null?void 0:c.get(v.time))??1,x=i.timeToBitmapX(v.time),S=n.valueToBitmapY(v.open),k=n.valueToBitmapY(v.close),M=Math.min(S,k),I=Math.max(S,k),b=Math.max(1,I-M),T=y<1&&d!=="none";let R=x-r,D=M,B=b,Y=1;if(T){const V=ze(y,d,{x:x-r,barWidth:f,anchorY:S,topY:M,bottomY:I});R=V.x,D=V.topY,B=Math.max(1,V.bottomY-V.topY),Y=V.alpha}if(T&&t.save(),m&&B>2){const V=t.createLinearGradient(0,D,0,D+B);V.addColorStop(0,p),V.addColorStop(.5,l),V.addColorStop(1,g),t.fillStyle=V}T&&(t.globalAlpha=Y),t.fillRect(R,D,a,B),T&&t.restore()}}}function ze(s,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:s};case"unfold":return{x:e.x,topY:ct(e.anchorY,e.topY,s),bottomY:ct(e.anchorY,e.bottomY,s),alpha:1};case"slide":return{x:e.x+(1-s)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:s};case"fade-unfold":return{x:e.x,topY:ct(e.anchorY,e.topY,s),bottomY:ct(e.anchorY,e.bottomY,s),alpha:s}}}const dn={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function fi(s){if(!s)return{};const t={...s};return s.areaFill!==void 0&&s.area===void 0&&(t.area={visible:!!s.areaFill}),s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class fn extends Ii{constructor(t,e){super(t),w(this,"options"),w(this,"areaGradientCache",new Map),this.options={...dn,...fi(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...fi(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,i){var n;const r=this.options.entryAnimation??"grow",a=zt(this.options.entryMs,400);if(r==="none"||a<=0)return null;const o=(n=this.stores[t])==null?void 0:n.last();return{startTime:i,fromTime:o?o.time:e}}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)})}peekEntry(t,e){var i;return(i=this.entries[t])==null?void 0:i.get(e)}resolvedPulseMs(){return zt(this.options.pulseMs,600)}get hasPulse(){return this.options.pulse&&this.resolvedPulseMs()>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();if(n&&n.time>=t)return!0}return!1}render(t){this.advanceLiveTracking(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e,i,n){const r=this.stores[t],a=r.last();if(!a)return null;const o=e.timeToBitmapX(a.time),l=i.valueToBitmapY(this.effectiveValue(t,a.time,a.value)),u=this.options.entryAnimation??"grow";if(!this.peekEntry(t,a.time)||u!=="grow")return{x:o,y:l};const c=this.entranceProgress(t,a.time,n);if(c>=1)return{x:o,y:l};const d=r.getAll();if(d.length<2)return{x:o,y:l};const f=d[d.length-2],m=e.timeToBitmapX(f.time),p=i.valueToBitmapY(f.value);return{x:ct(m,o,c),y:ct(p,l,c)}}renderOff(t){const{scope:e,timeScale:i,yScale:n}=t,{context:r}=e,a=i.getRange(),{verticalPixelRatio:o}=e,l=this.options.strokeWidth>0,u=Math.max(1,Math.round(this.options.strokeWidth*o)),c=performance.now(),d=this.options.entryAnimation??"grow";for(let f=0;f<this.stores.length;f++){if(!this.stores[f].isVisible())continue;let m=this.stores[f].getVisibleData(a.from,a.to);const p=e.mediaSize.width;if(m.length>p*2&&(m=li(m,Math.round(p*1.5))),m.length<2)continue;const g=this.options.colors[f%this.options.colors.length],v=m[m.length-1],y=this.peekEntry(f,v.time),x=this.entranceProgress(f,v.time,c),S=y&&d==="fade"&&x<1,k=this.trailingEndpoint(f,i,n,c)??{x:i.timeToBitmapX(v.time),y:n.valueToBitmapY(this.effectiveValue(f,v.time,v.value))},M=k.x,I=k.y;S&&(r.save(),r.globalAlpha=x),r.beginPath(),r.moveTo(i.timeToBitmapX(m[0].time),n.valueToBitmapY(m[0].value));for(let b=1;b<m.length-1;b++)r.lineTo(i.timeToBitmapX(m[b].time),n.valueToBitmapY(m[b].value));if(r.lineTo(M,I),l&&(r.strokeStyle=g,r.lineWidth=u,r.lineJoin="round",r.lineCap="round",r.stroke()),this.options.area.visible){const b=i.timeToBitmapX(m[0].time),T=e.bitmapSize.height;r.lineTo(M,T),r.lineTo(b,T),r.closePath();const R=String(f),D=this.areaGradientCache.get(R);let B;D&&D.bottomY===T&&D.color===g?B=D.gradient:(B=r.createLinearGradient(0,0,0,T),B.addColorStop(0,Nt(g,.12)),B.addColorStop(1,Nt(g,.01)),this.areaGradientCache.set(R,{gradient:B,bottomY:T,color:g})),r.fillStyle=B,r.fill()}S&&r.restore()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,o=n.getRange(),{verticalPixelRatio:l}=i,u=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*l)),d=i.mediaSize.width,f=this.stores.map(b=>{let T=b.getVisibleData(o.from,o.to);return T.length>d*2&&(T=li(T,Math.round(d*1.5))),T}),m=new Set;for(const b of f)for(const T of b)m.add(T.time);const p=Array.from(m).sort((b,T)=>b-T);if(p.length<2)return;const g=f.map((b,T)=>{const R=new Map;for(const D of b)R.set(D.time,this.effectiveValue(T,D.time,D.value));return R}),v=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let b=0;b<p.length;b++){const T=p[b];let R=0;if(e)for(let B=0;B<this.stores.length;B++)this.stores[B].isVisible()&&(R+=g[B].get(T)??0);let D=0;for(let B=0;B<this.stores.length;B++){const Y=this.stores[B].isVisible()?g[B].get(T)??0:0;D+=e&&R>0?Y/R*100:Y,v[B][b]=D}}const y=performance.now(),x=this.options.entryAnimation??"grow",S=new Map;for(let b=0;b<p.length;b++)S.set(p[b],b);const k=p.length-1,M=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const T=this.stores[b].last();if(!T)continue;const R=this.peekEntry(b,T.time);if(!R)continue;const D=S.get(T.time);D!==k||S.get(R.fromTime)!==D-1||(M[b]=this.entranceProgress(b,T.time,y))}const I=(b,T)=>{if(T>=1||b.length<2)return;const R=b.length-1,D=b[R-1],B=b[R];b[R]=[ct(D[0],B[0],T),ct(D[1],B[1],T)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const T=this.options.colors[b%this.options.colors.length],R=M[b],D=b>0&&this.stores[b-1].isVisible()?M[b-1]:1,B=[];for(let P=0;P<p.length;P++)B.push([n.timeToBitmapX(p[P]),r.valueToBitmapY(v[b][P])]);x==="grow"&&I(B,R);const Y=[];for(let P=0;P<p.length;P++){const W=b>0?v[b-1][P]:0;Y.push([n.timeToBitmapX(p[P]),r.valueToBitmapY(W)])}x==="grow"&&I(Y,D);const V=x==="fade"&&R<1;if(V&&(a.save(),a.globalAlpha=R),this.options.area.visible){a.beginPath(),a.moveTo(B[0][0],B[0][1]);for(let P=1;P<B.length;P++)a.lineTo(B[P][0],B[P][1]);for(let P=Y.length-1;P>=0;P--)a.lineTo(Y[P][0],Y[P][1]);a.closePath(),a.fillStyle=Nt(T,.25),a.fill()}if(u){a.beginPath(),a.moveTo(B[0][0],B[0][1]);for(let P=1;P<B.length;P++)a.lineTo(B[P][0],B[P][1]);a.strokeStyle=T,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}V&&a.restore()}}drawOverlay(t){const{scope:e,timeScale:i,yScale:n,crosshair:r,dataInterval:a}=t,o=e,l=this.resolvedPulseMs();if(r){const u=this.options.colors,c=this.options.stacking,d=4*o.horizontalPixelRatio,f=[],m=[];for(let g=0;g<this.stores.length;g++){const v=this.stores[g].findNearest(r.time,a);v?(f.push(v.value),m.push(v.time)):(f.push(0),m.push(null))}const p=[];if(c==="off")for(const g of f)p.push(g);else{let g=0;if(c==="percent")for(let y=0;y<f.length;y++)this.stores[y].isVisible()&&(g+=f[y]);let v=0;for(let y=0;y<f.length;y++){const x=this.stores[y].isVisible()?f[y]:0;v+=c==="percent"&&g>0?x/g*100:x,p.push(v)}}for(let g=0;g<this.stores.length;g++){const v=m[g];if(v===null||!this.stores[g].isVisible())continue;const y=u[g%u.length],x=i.timeToBitmapX(v),S=n.valueToBitmapY(p[g]);e.context.beginPath(),e.context.arc(x,S,d+3*o.horizontalPixelRatio,0,Math.PI*2);const k=y.startsWith("#")?y+"40":/^rgb\(/i.test(y)?y.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):y.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=k,e.context.fill(),e.context.beginPath(),e.context.arc(x,S,d,0,Math.PI*2),e.context.fillStyle=y,e.context.fill()}}if(this.hasPulse&&l>0){const u=performance.now();this.advanceLiveTracking(u);const c=this.options.stacking;for(let d=0;d<this.stores.length;d++){if(!this.stores[d].isVisible())continue;const f=this.options.colors[d%this.options.colors.length];if(c==="off"){const M=this.trailingEndpoint(d,i,n,u);if(!M)continue;this.drawPulse({ctx:e.context,x:M.x,y:M.y,color:f,pixelRatio:o.horizontalPixelRatio,pulseMs:l});continue}const m=this.stores[d].last();if(!m)continue;const p=m.time,g=c==="percent",v=M=>{const I=R=>{const D=R===d&&M===p?m:this.stores[R].findNearest(M,0);return!D||D.time!==M?0:this.effectiveValue(R,M,D.value)};let b=0;if(g)for(let R=0;R<this.stores.length;R++)this.stores[R].isVisible()&&(b+=I(R));let T=0;for(let R=0;R<=d;R++){if(!this.stores[R].isVisible())continue;const D=I(R);T+=g&&b>0?D/b*100:D}return T};let y=i.timeToBitmapX(p),x=n.valueToBitmapY(v(p));const S=this.options.entryAnimation??"grow",k=this.peekEntry(d,p);if(S==="grow"&&k){const M=this.entranceProgress(d,p,u);if(M<1&&k.fromTime!==p){const I=i.timeToBitmapX(k.fromTime),b=n.valueToBitmapY(v(k.fromTime));y=ct(I,y,M),x=ct(b,x,M)}}this.drawPulse({ctx:e.context,x:y,y:x,color:f,pixelRatio:o.horizontalPixelRatio,pulseMs:l})}}}drawPulse({ctx:t,x:e,y:i,color:n,pixelRatio:r,pulseMs:a}){const o=3*r,l=.4+.6*Math.abs(Math.sin(performance.now()/a)),u=o+4*r*l;t.beginPath(),t.arc(e,i,u,0,Math.PI*2),t.fillStyle=Nt(n,l*.3),t.fill(),t.beginPath(),t.arc(e,i,o,0,Math.PI*2),t.fillStyle=n,t.fill()}}const Fi={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},mn={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...Fi},animate:!1},We=Math.PI/180;function gn(s,t){return{...s??{},...t}}function pn(s){return{...Fi,...s??{}}}function bn(s){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return s===!0||s===!1?t:{...t,...s}}function vn(s){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return s===!0||s===!1?t:{...t,...s}}const Ut=Math.PI*2,Bi=.85;function mi(s){const{bitmapWidth:t,bitmapHeight:e,padTop:i,padBottom:n}=s,r=Math.max(0,s.labelReserve??0),a=Math.min(Math.max(0,i),e),o=Math.min(Math.max(0,n),e-a),l=e-a-o,u=Math.max(0,t-2*r),c=t/2,d=a+l/2,f=Math.max(0,Math.min(u,l)/2*Bi);return{cx:c,cy:d,maxR:f}}function yn(s){if(!s.startsWith("#"))return!1;const t=parseInt(s.slice(1,3),16),e=parseInt(s.slice(3,5),16),i=parseInt(s.slice(5,7),16);return t*.299+e*.587+i*.114>150}function xn(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,parseInt(s.slice(1,3),16)+Math.round(255*t)),i=Math.min(255,parseInt(s.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(s.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function gi(s){if(s.startsWith("#"))return{r:parseInt(s.slice(1,3),16)||0,g:parseInt(s.slice(3,5),16)||0,b:parseInt(s.slice(5,7),16)||0,a:1};const t=s.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(i=>i.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function Sn(s,t){const e=gi(s),i=gi(t),n=i.a,r=Math.round(i.r*n+e.r*(1-n)),a=Math.round(i.g*n+e.g*(1-n)),o=Math.round(i.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}var _,O,pt,Z,Ot,It,ft,Vt,vt,Ee,pe,Pi,zi,Ai;class be{constructor(t){A(this,vt),A(this,_,[]),A(this,O),A(this,pt,-1),A(this,Z,[]),A(this,Ot,0),A(this,It,1),A(this,ft,null),A(this,Vt,[]),F(this,O,j(this,vt,Ee).call(this,mn,t??{}))}getData(){return h(this,_)}setData(t){const e=t??[];F(this,_,e),F(this,Z,new Array(e.length).fill(0)),F(this,It,h(this,O).animate?0:1),F(this,ft,null);for(const i of h(this,Vt))i()}onDataChanged(t){return h(this,Vt).push(t),()=>{const e=h(this,Vt).indexOf(t);e>=0&&h(this,Vt).splice(e,1)}}updateOptions(t){var e,i;const n=(e=h(this,O).sliceLabels)==null?void 0:e.mode;F(this,O,j(this,vt,Ee).call(this,h(this,O),t??{})),((i=h(this,O).sliceLabels)==null?void 0:i.mode)==="outside"&&n!=="outside"&&F(this,It,h(this,O).animate?0:1),F(this,ft,null)}getColor(){var t,e;return((t=h(this,_)[0])==null?void 0:t.color)??((e=h(this,O).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&F(this,ft,null)}hitTest(t,e,i,n,r){var a;if(h(this,_).length===0)return-1;const o=h(this,_).reduce((S,k)=>S+k.value,0);if(o<=0)return-1;const l=((a=h(this,ft))==null?void 0:a.reserve)??0,{cx:u,cy:c,maxR:d}=mi({bitmapWidth:i,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:l}),f=d,m=f*h(this,O).innerRadiusRatio,p=t-u,g=e-c,v=Math.sqrt(p*p+g*g);if(v>f||v<m)return-1;let y=Math.atan2(g,p)+Math.PI/2;y<0&&(y+=Ut);let x=0;for(let S=0;S<h(this,_).length;S++){const k=h(this,_)[S].value/o*Ut;if(y>=x&&y<x+k)return S;x+=k}return-1}setHoverIndex(t){return h(this,pt)===t?!1:(F(this,pt,t),!0)}getHoverIndex(){return h(this,pt)}getHoverInfo(t){if(h(this,pt)<0)return null;const e=h(this,_)[h(this,pt)];if(!e)return null;const i=h(this,_).reduce((r,a)=>r+a.value,0),n=h(this,O).colors??t.seriesColors;return{label:e.label,value:e.value,percent:i>0?e.value/i*100:0,color:e.color??n[h(this,pt)%n.length]}}getSliceInfo(t){if(h(this,_).length===0)return null;const e=h(this,_).reduce((n,r)=>n+r.value,0),i=h(this,O).colors??t.seriesColors;return h(this,_).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??i[r%i.length]}))}get needsAnimation(){var t;if(!h(this,O).animate)return!1;for(let e=0;e<h(this,Z).length;e++){const i=e===h(this,pt)?1:0;if(Math.abs(h(this,Z)[e]-i)>.01)return!0}return((t=h(this,O).sliceLabels)==null?void 0:t.mode)==="outside"&&h(this,It)<.99}dispose(){F(this,Vt,[]),F(this,_,[]),F(this,Z,[]),F(this,Ot,0)}_inspectSliceOffsets(){return h(this,Z)}render(t){if(h(this,_).length===0)return;const{scope:e,theme:i,padding:n}=t,{context:r,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=e,u=performance.now(),c=h(this,Ot)?Math.min(.05,(u-h(this,Ot))/1e3):0;F(this,Ot,u);const d=h(this,_).reduce((W,J)=>W+J.value,0);if(d<=0)return;const f=12;for(;h(this,Z).length<h(this,_).length;)h(this,Z).push(0);if(h(this,O).animate)for(let W=0;W<h(this,_).length;W++){const J=W===h(this,pt)?1:0;h(this,Z)[W]=Pt(h(this,Z)[W],J,f,c)}const m=pn(h(this,O).sliceLabels);r.font=`${m.fontSize*o}px ${i.typography.fontFamily}`,m.mode==="outside"&&h(this,O).animate&&F(this,It,Pt(h(this,It),1,6,c));const p=h(this,O).colors??i.seriesColors,g=m.mode==="outside"?j(this,vt,Pi).call(this,r,m,d,o):0,{cx:v,cy:y,maxR:x}=mi({bitmapWidth:a.width,bitmapHeight:a.height,padTop:n.top*l,padBottom:n.bottom*l,labelReserve:g}),S=x,k=S*h(this,O).innerRadiusRatio,M=h(this,O).padAngle*We,I=8*o,b=h(this,O).shadow??!1,T=bn(b),R=h(this,O).innerShadow??!1,D=vn(R);let B=-Math.PI/2;for(let W=0;W<h(this,_).length;W++){const J=h(this,_)[W],X=J.value/d*Ut,H=B+M/2,it=B+X-M/2,ot=B+X/2,st=J.color??p[W%p.length];if(it<=H){B+=X;continue}const xt=h(this,Z)[W]*I,Tt=Math.cos(ot)*xt,Rt=Math.sin(ot)*xt,lt=v+Tt,nt=y+Rt;r.beginPath(),r.arc(lt,nt,S,H,it),k>0?r.arc(lt,nt,k,it,H,!0):r.lineTo(lt,nt),r.closePath();const ht=r.createRadialGradient(lt,nt,k||0,lt,nt,S);if(ht.addColorStop(0,xn(st,.15)),R){const mt=Math.max(0,Math.min(.999,1-D.depth));ht.addColorStop(mt,st),ht.addColorStop(1,Sn(st,D.color))}else ht.addColorStop(1,st);r.fillStyle=ht;const St=h(this,Z)[W];if(b||St>.01){const mt=b?1:0,gt=St;r.shadowColor=b?T.color:"rgba(0,0,0,0.25)",r.shadowBlur=(T.blur*mt+12*gt)*o,r.shadowOffsetX=T.offsetX*mt*o+Tt*.3*gt,r.shadowOffsetY=T.offsetY*mt*l+Rt*.3*gt}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,B+=X}if(m.mode==="none")return;B=-Math.PI/2;const Y=i.tooltip.textColor;if(m.mode==="outside"){const W=j(this,vt,Ai).call(this,{cx:v,cy:y,outerR:S,total:d,palette:p,labels:m,hpr:o,bitmapHeight:a.height}),J=W.length>1?Math.min(.06,.9/(W.length-1)):0;for(let X=0;X<W.length;X++){const H=W[X];if(H===null)continue;const it=X*J,ot=Gt((h(this,It)-it)/(1-it),0,1);j(this,vt,zi).call(this,{context:r,entry:H,textColor:Y,labels:m,hpr:o,progress:ot})}return}const V=k>0?(S+k)/2:S*.65;r.textAlign="center",r.textBaseline="middle";const P=m.minSliceAngle*We;for(let W=0;W<h(this,_).length;W++){const J=h(this,_)[W],X=J.value/d*Ut;if(X>=P){const H=B+X/2,it=h(this,Z)[W]*I,ot=J.color??p[W%p.length],st=j(this,vt,pe).call(this,J,d,m.content),xt=r.measureText(st).width,Tt=m.fontSize*1.2*o,Rt=X<Math.PI?2*V*Math.sin(X/2):2*V,lt=xt>Rt-4*o,nt=k>0&&V-k<Tt;if(!lt&&!nt){const ht=v+Math.cos(H)*(V+it),St=y+Math.sin(H)*(V+it);r.fillStyle=yn(ot)?"#000000":"#ffffff",r.fillText(st,ht,St)}}B+=X}}}_=new WeakMap,O=new WeakMap,pt=new WeakMap,Z=new WeakMap,Ot=new WeakMap,It=new WeakMap,ft=new WeakMap,Vt=new WeakMap,vt=new WeakSet,Ee=function(s,t){const e={...s,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=gn(s.sliceLabels,t.sliceLabels)),e},pe=function(s,t,e){const i=t>0?s.value/t*100:0,n=`${i.toFixed(i>=10?0:1)}%`;return e==="percent"?n:e==="label"?s.label:`${s.label} ${n}`},Pi=function(s,t,e,i){const n=s.font;if(h(this,ft)&&h(this,ft).fontScale===i&&h(this,ft).font===n)return h(this,ft).reserve;let r=0;for(const l of h(this,_)){const u=j(this,vt,pe).call(this,l,e,t.content),c=s.measureText(u).width;c>r&&(r=c)}const a=Math.max(t.distance,t.elbowLen),o=(r+(a+Math.max(0,t.railWidth)+t.legPad+4)*i)/Bi;return F(this,ft,{fontScale:i,font:n,reserve:o}),o},zi=function(s){const{context:t,entry:e,textColor:i,labels:n,hpr:r,progress:a}=s;if(a<=0)return;const{anchorX:o,anchorY:l,elbowX:u,elbowY:c,side:d,text:f,color:m,labelX:p,labelY:g}=e,v=p+d*n.legPad*r,y=Gt(a/.15,0,1),x=Gt((a-.15)/.45,0,1),S=Gt((a-.6)/.4,0,1);if(t.save(),t.globalAlpha=y,t.fillStyle=m,t.beginPath(),t.arc(o,l,2.5*r,0,Ut),t.fill(),t.restore(),x>0){t.save(),t.globalAlpha=x,t.strokeStyle=m,t.lineWidth=1*r,t.lineCap="round",t.beginPath(),t.moveTo(o,l);const k=o+(u-o)*x,M=l+(c-l)*x;if(t.lineTo(k,M),S>0){const I=u+(p-u)*S,b=c+(g-c)*S;t.lineTo(I,b)}t.stroke(),t.restore()}S>0&&(t.save(),t.globalAlpha=S,t.fillStyle=i,t.textAlign=d>=0?"left":"right",t.textBaseline="middle",t.fillText(f,v,g),t.restore())},Ai=function(s){const{cx:t,cy:e,outerR:i,total:n,palette:r,labels:a,hpr:o,bitmapHeight:l}=s,u=new Array(h(this,_).length).fill(null),c=a.elbowLen*o,d=Math.max(a.distance,a.elbowLen)*o,f=Math.max(0,a.railWidth)*o,m=[];let p=-Math.PI/2;const g=a.minSliceAngle*We;for(let S=0;S<h(this,_).length;S++){const k=h(this,_)[S],M=k.value/n*Ut;if(M>=g){const I=p+M/2,b=h(this,Z)[S]*(8*o),T=Math.cos(I),R=Math.sin(I),D=T>=0?1:-1,B=t+T*(i+b),Y=e+R*(i+b),V=t+T*(i+b+c),P=e+R*(i+b+c),W=t+T*(i+b+d)+D*f,J=e+R*(i+b+d),X={anchorX:B,anchorY:Y,elbowX:V,elbowY:P,side:D,labelX:W,labelY:J,text:j(this,vt,pe).call(this,k,n,a.content),color:k.color??r[S%r.length]};u[S]=X,m.push({entry:X})}p+=M}const v=Math.max(1,a.fontSize*a.labelGap)*o,y=a.fontSize*o,x=l-a.fontSize*o;for(const S of[1,-1]){const k=[];for(const b of m)b.entry.side===S&&k.push(b.entry);if(k.length===0)continue;k.sort((b,T)=>b.labelY-T.labelY);const M=[];for(let b=0;b<k.length;b++)for(M.push({count:1,sumIdeal:k[b].labelY,startIdx:b});M.length>=2;){const T=M[M.length-2],R=M[M.length-1],D=T.sumIdeal/T.count,B=R.sumIdeal/R.count,Y=D+(T.count-1)*v/2;if(B-(R.count-1)*v/2>=Y+v)break;T.count+=R.count,T.sumIdeal+=R.sumIdeal,M.pop()}if(M.length>0){const b=M[0],T=b.sumIdeal/b.count-(b.count-1)*v/2;if(T<y)for(b.sumIdeal+=(y-T)*b.count;M.length>=2;){const R=M[0],D=M[1],B=R.sumIdeal/R.count,Y=D.sumIdeal/D.count,V=B+(R.count-1)*v/2;if(Y-(D.count-1)*v/2>=V+v)break;R.count+=D.count,R.sumIdeal+=D.sumIdeal,M.splice(1,1)}}if(M.length>0){const b=M[M.length-1],T=b.sumIdeal/b.count+(b.count-1)*v/2;if(T>x)for(b.sumIdeal-=(T-x)*b.count;M.length>=2;){const R=M[M.length-2],D=M[M.length-1],B=R.sumIdeal/R.count,Y=D.sumIdeal/D.count,V=B+(R.count-1)*v/2;if(Y-(D.count-1)*v/2>=V+v)break;R.count+=D.count,R.sumIdeal+=D.sumIdeal,M.pop()}}const I=(y+x)/2;for(const b of M){const T=(b.count-1)*v,R=b.sumIdeal/b.count;T>x-y&&R-T/2<y&&(b.sumIdeal=I*b.count)}for(const b of M){const T=b.sumIdeal/b.count;for(let R=0;R<b.count;R++)k[b.startIdx+R].labelY=T+(R-(b.count-1)/2)*v}}for(const S of m){const k=S.entry,M=k.labelY-k.anchorY;let I;if(Math.abs(M)<=c){const R=k.side*Math.sqrt(Math.max(0,c*c-M*M));I=k.anchorX+R}else I=(k.anchorX+k.labelX)/2;const b=Math.min(k.anchorX,k.labelX),T=Math.max(k.anchorX,k.labelX);k.elbowX=Math.max(b,Math.min(T,I)),k.elbowY=k.labelY}return u};const Wi={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"}},Lt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},wn=.1,Cn=.3,Mn=.4,kn=.5,Tn=4;class Rn extends ce{constructor({padding:t,reboundMs:e}={}){super(),w(this,"_visibleRange",{from:0,to:0}),w(this,"_yRange",{min:0,max:0}),w(this,"_autoScroll",!0),w(this,"padding"),w(this,"reboundMs"),w(this,"dataInterval",6e4),w(this,"_dataStart",null),w(this,"_dataEnd",null),w(this,"_prevDataEnd",null),w(this,"_animating",!1),w(this,"animStartTime",0),w(this,"animDuration",0),w(this,"animFrom",{from:0,to:0}),w(this,"animTo",{from:0,to:0}),w(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??Lt.top,bottom:(t==null?void 0:t.bottom)??Lt.bottom,right:(t==null?void 0:t.right)??Lt.right,left:(t==null?void 0:t.left)??Lt.left},this.reboundMs=e??350}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,i){return typeof t=="object"?t.intervals*this.dataInterval:i<=0?0:t/i*e}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??Lt.top,bottom:(t==null?void 0:t.bottom)??Lt.bottom,right:(t==null?void 0:t.right)??Lt.right,left:(t==null?void 0:t.left)??Lt.left}}getPadding(){return this.padding}setDataStart(t){this._dataStart=t}setDataEnd(t){this._prevDataEnd=this._dataEnd,this._dataEnd=t}cancelAnimation(){this._animating=!1}getSoftBounds(t,e){const i=a=>typeof a=="object"||a===0||e>0,n=this._dataStart!==null&&i(this.padding.left)?this._dataStart-this.resolveHPad(this.padding.left,t,e):null,r=this._dataEnd!==null&&i(this.padding.right)?this._dataEnd+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}softMaxRange(){if(this._dataStart===null||this._dataEnd===null)return null;const t=this._dataEnd-this._dataStart;if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,i=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||i!==null?t+(e??0)+(i??0):t+this.dataInterval*5}setRange(t){const{from:e,to:i}=t;if(!Number.isFinite(e)||!Number.isFinite(i)||i<=e||(i-e)/this.dataInterval<2)return;this.cancelAnimation();const n=this._dataEnd!==null&&this._dataEnd>=e&&this._dataEnd<=i;this._autoScroll=n,this.applyRange(e,i)}applyRange(t,e){e<=t||(e-t)/this.dataInterval<2||(this._visibleRange={from:t,to:e},this.emit("change"))}animateTo(t,e,i=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:e},this.animDuration=i,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this.animStartTime,i=Math.min(1,e/this.animDuration),n=1-(1-i)**3,r=ct(this.animFrom.from,this.animTo.from,n),a=ct(this.animFrom.to,this.animTo.to,n);return a>r&&this.applyRange(r,a),i>=1&&(this._animating=!1),this._animating}setYRange(t,e,i,n=!1,r=!1){const a=e-t,o=i>0?this.padding.top/i*a:0,l=i>0?this.padding.bottom/i*a:0;this._yRange={min:n?t:t-l,max:r?e:e+o}}zoomAt(t,e,i=this._lastChartWidth){this.cancelAnimation(),i>0&&(this._lastChartWidth=i);const{from:n,to:r}=this._visibleRange,a=r-n;if(a<=0)return;const o=this.softMinRange,{left:l,right:u}=this.getSoftBounds(a,i),c=l!==null&&u!==null?u-l:this.softMaxRange();let d=e;const f=o*Mn;if(e<1&&a<o){const y=o-a,x=(1-Math.min(1,y/f))**2;d=1-(1-e)*x}let m=a*d;m<o-f&&(m=o-f),e>1&&c!==null&&m>c&&(m=c);const p=(t-n)/a;let g=t-p*m,v=g+m;if(e<1&&v<r){const y=r-v;g+=y,v+=y}if(e>1){if(u!==null&&v>u){const y=v-u;g-=y,v-=y}if(l!==null&&g<l){const y=l-g;g+=y,v+=y}}this.applyRange(g,v),this.emit("interact")}pan(t,e=0){this.cancelAnimation(),e>0&&(this._lastChartWidth=e);const{from:i,to:n}=this._visibleRange,r=n-i;if(r<=0)return;const{left:a,right:o}=this.getSoftBounds(r,e),l=r*Cn;let u=t;if(t>0&&o!==null){const m=Math.max(0,n-o);m>0&&(u*=1/(m/l+1))}else if(t<0&&a!==null){const m=Math.max(0,a-i);m>0&&(u*=1/(m/l+1))}let c=i+u,d=n+u;if(o!==null&&d>o+l){const m=d-(o+l);c-=m,d-=m}if(a!==null&&c<a-l){const m=a-l-c;c+=m,d+=m}const f=this._dataEnd!==null&&this._dataEnd>=c&&this._dataEnd<=d;this._autoScroll=f,this.applyRange(c,d),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:i}=this._visibleRange,n=i-e;if(n<=0)return;const r=this.softMinRange,a=this.softMaxRange();let o=n;o<r&&(o=r),a!==null&&o>a&&(o=a);let l=e,u=i;if(o!==n){const x=(e+i)/2;l=x-o/2,u=x+o/2}const{left:c,right:d}=this.getSoftBounds(o,t);if(d!==null&&u>d){const x=u-d;l-=x,u-=x}if(c!==null&&l<c){const x=c-l;l+=x,u+=x}const f=Math.abs(l-e),m=Math.abs(u-i);if(f<1&&m<1)return;const p=n*wn;let g=null,v=0,y=0;d!==null&&i-d>p?(g="right",v=i-d,y=d):c!==null&&c-e>p&&(g="left",v=c-e,y=c),this.reboundMs<=0?this.applyRange(l,u):this.animateTo(l,u,this.reboundMs),g!==null&&this.emit("edgeReached",{side:g,overshoot:v,boundaryTime:y})}fitToData(t,e,i=0,n=!1){this._autoScroll=!0,i>0&&(this._lastChartWidth=i);const r=400*this.dataInterval,a=e-t,o=a>0?a:this.dataInterval*10,l=this.resolveHPad(this.padding.right,o,i),u=this.resolveHPad(this.padding.left,o,i);let c=e+l,d=t-u;c-d>r&&(c=e+l,d=c-r),n&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(d,c,450):this.applyRange(d,c)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const i=this._visibleRange.to-this._visibleRange.from;if(i<=0)return;const n=this.resolveHPad(this.padding.right,i,e),r=this._animating?this.animTo.to:this._visibleRange.to,a=this._prevDataEnd!==null?r-this._prevDataEnd:n,o=Math.max(0,Math.min(n,a)),l=t+o,u=l-i;this._autoScroll=!0;const c=kn*this.dataInterval,d=e>0?Tn/e*i:c,f=Math.min(c,d);if(this._animating){if(Math.abs(l-this.animTo.to)<f)return;this.animFrom={...this._visibleRange},this.animTo={from:u,to:l},this._prevDataEnd=this._dataEnd}else{if(Math.abs(l-this._visibleRange.to)<f)return;this.animateTo(u,l,150),this._prevDataEnd=this._dataEnd}}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}function Kt(s,t){return s===!1||s===0?0:s===void 0?t:s}function Ln(s){if(s===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0}};const t=s===!0||s===void 0?void 0:s,e=t==null?void 0:t.points,i=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:Kt(e==null?void 0:e.enterMs,400),smoothMs:Kt(e==null?void 0:e.smoothMs,70),pulseMs:Kt(e==null?void 0:e.pulseMs,600)},r=i===!1?{reboundMs:0,yAxisMs:0}:{reboundMs:Kt(i==null?void 0:i.reboundMs,350),yAxisMs:Kt(i==null?void 0:i.yAxisMs,80)};return{points:n,viewport:r}}function In(s){if(!s)return{monitor:null,ownsMonitor:!1,showHud:!1};if(s===!0)return{monitor:new Pe,ownsMonitor:!0,showHud:!0};if(s instanceof Pe)return{monitor:s,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...i}=s,n=e!==void 0;return{monitor:e??new Pe(i),ownsMonitor:!n,showHud:t??!n}}let Dn=0;var K,E,U,wt,Zt,z,N,te,rt,Ct,Q,Ft,Ve,$t,bt,ve,ye,kt,ee,Yt,le,we,jt,Mt,ie,se,$,Bt,pi,xe,ne,re,Ei,Vi,Se,ut,dt,Xt;class Yi extends ce{constructor(t,e){var i,n,r,a;super(),A(this,$),A(this,K),A(this,E),A(this,U),A(this,wt),w(this,"timeScale"),w(this,"yScale"),A(this,Zt),A(this,z,[]),A(this,N),A(this,te),A(this,rt,6e4),A(this,Ct,null),A(this,Q,{}),A(this,Ft,null),A(this,Ve,!1),A(this,$t,{}),A(this,bt,{left:"idle",right:"idle"}),A(this,ve,{left:null,right:null}),A(this,ye),A(this,kt,0),A(this,ee,!1),A(this,Yt,!1),A(this,le,!1),A(this,we,0),A(this,jt),A(this,Mt),A(this,ie,!1),A(this,se,null),A(this,Se,0),A(this,ut,0),A(this,dt,0),A(this,Xt,!1),e!=null&&e.axis&&(F(this,$t,e.axis),F(this,Q,{min:(i=e.axis.y)==null?void 0:i.min,max:(n=e.axis.y)==null?void 0:n.max})),F(this,N,(e==null?void 0:e.theme)??Wi),F(this,te,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),F(this,jt,Ln(e==null?void 0:e.animations)),F(this,ye,e==null?void 0:e.onEdgeReached);const o=In(e==null?void 0:e.perf);F(this,Mt,o.monitor),F(this,ie,o.ownsMonitor),F(this,K,new cs(t,h(this,Mt)??void 0)),F(this,E,new Rn({padding:e==null?void 0:e.padding,reboundMs:h(this,jt).viewport.reboundMs})),Ls(this,h(this,E)),this.timeScale=new Os,this.yScale=new qs;const l=h(this,Mt);l?(F(this,U,new me(c=>{l.resetDrawCalls("main");const d=performance.now();this.renderMain(c),l.recordFrame("main",performance.now()-d,c)})),F(this,wt,new me(c=>{l.resetDrawCalls("overlay");const d=performance.now();this.renderOverlay(c),l.recordFrame("overlay",performance.now()-d,c)})),o.showHud&&F(this,se,new zs(t,l))):(F(this,U,new me(c=>this.renderMain(c))),F(this,wt,new me(c=>this.renderOverlay(c))));const u=(e==null?void 0:e.interactive)!==!1;F(this,Zt,u?new Ts(h(this,K).canvas,h(this,E),this.timeScale,this.yScale):null),h(this,E).on("change",()=>{this.syncScales(),h(this,U).markDirty(),this.emit("viewportChange")}),h(this,E).on("edgeReached",c=>{var d;h(this,ve)[c.side]=c.boundaryTime,(d=h(this,ye))==null||d.call(this,c)}),h(this,K).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(a=h(this,Zt))==null||a.on("crosshairMove",c=>{F(this,Ct,c),h(this,wt).markDirty(),this.emit("crosshairMove",c),j(this,$,Vi).call(this,c)})}get yAxisWidth(){const t=h(this,$t).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=h(this,$t).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return h(this,we)}addCandlestickSeries(t){const e=new Mi,i=new un(e,{upColor:h(this,N).candlestick.upColor,downColor:h(this,N).candlestick.downColor,wickUpColor:h(this,N).candlestick.wickUpColor,wickDownColor:h(this,N).candlestick.wickDownColor,bodyWidthRatio:.6,...j(this,$,xe).call(this,"candle"),...t,...j(this,$,ne).call(this)});return j(this,$,re).call(this,i,i.store,t??{})}addLineSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new fn(n,{colors:n===1?[h(this,N).line.color]:h(this,N).seriesColors.slice(0,n),strokeWidth:h(this,N).line.width,area:{visible:!0},...j(this,$,xe).call(this,"line"),...i,...j(this,$,ne).call(this)});return j(this,$,re).call(this,r,r.store,i)}addBarSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new rn(n,{colors:h(this,N).seriesColors.slice(0,n),barWidthRatio:.6,...j(this,$,xe).call(this,"bar"),...i,...j(this,$,ne).call(this)});return j(this,$,re).call(this,r,r.store,i)}addPieSeries(t){const e=new be(t);return j(this,$,re).call(this,e,null,t??{})}removeSeries(t){const e=h(this,z).findIndex(i=>i.id===t);e>=0&&(h(this,z)[e].renderer.dispose(),h(this,z).splice(e,1),F(this,Ft,null),this.updateViewportPadding(),h(this,U).markDirty(),this.emit("seriesChange"),j(this,$,Bt).call(this))}setSeriesData(t,e,i){const n=h(this,z).find(r=>r.id===t);n==null||n.renderer.setData(e,i)}appendData(t,e,i){var n,r;const a=h(this,z).find(o=>o.id===t);(r=a==null?void 0:(n=a.renderer).appendPoint)==null||r.call(n,e,i)}updateData(t,e,i){var n,r;const a=h(this,z).find(o=>o.id===t);(r=a==null?void 0:(n=a.renderer).updateLastPoint)==null||r.call(n,e,i)}updateSeriesOptions(t,e){const i=h(this,z).find(u=>u.id===t);if(!i)return;const n=i.label,r=i.renderer.getLayerColors().slice();i.renderer.updateOptions({...e,...j(this,$,ne).call(this)}),"label"in e&&typeof e.label=="string"&&(i.label=e.label),h(this,U).markDirty();const a=i.renderer.getLayerColors(),o=r.length!==a.length||r.some((u,c)=>u!==a[c]),l=n!==i.label;(o||l)&&j(this,$,Bt).call(this)}batch(t){Ae(this,kt)._++;try{t()}finally{--Ae(this,kt)._<=0&&(F(this,kt,0),h(this,ee)?(F(this,ee,!1),F(this,Yt,!1),this.onDataChanged()):h(this,Yt)&&(F(this,Yt,!1),this.updateYRange(!0),h(this,U).markDirty()),h(this,le)&&(F(this,le,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const i=h(this,z).find(n=>n.id===t);if(!(!i||i.visible===e)){if(i.visible=e,j(this,$,Bt).call(this),h(this,kt)>0){F(this,Yt,!0);return}this.updateYRange(!0),h(this,U).markDirty()}}isSeriesVisible(t){var e;return((e=h(this,z).find(i=>i.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,i){const n=h(this,z).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==i){if(n.renderer.setLayerVisible(e,i),j(this,$,Bt).call(this),h(this,kt)>0){F(this,Yt,!0);return}this.updateYRange(!0),h(this,U).markDirty()}}isLayerVisible(t,e){const i=h(this,z).find(n=>n.id===t);return(i==null?void 0:i.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const i=h(this,K).size.media.width-this.yAxisWidth;h(this,E).fitToData(t,e,i,!0)}getVisibleRange(){return h(this,E).visibleRange}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:i}=this.getDataBounds();if(e===void 0||i===void 0)return;const n=Math.max(e,i-(t-1)*h(this,rt)),r=h(this,K).size.media.width-this.yAxisWidth;h(this,E).fitToData(n,i,r,!1);return}h(this,E).setRange(t)}getYRange(){return h(this,E).yRange}getCrosshairPosition(){return h(this,Ct)}getLastValue(t){const e=h(this,z).find(l=>l.id===t);if(!(e!=null&&e.store))return null;const i=e.store.last();if(!i)return null;const n=l=>"close"in l?l.close:l.value,{from:r,to:a}=h(this,E).visibleRange;if(i.time>=r&&i.time<=a)return{value:n(i),isLive:!0};const o=e.store.getVisibleData(r,a);return o.length===0?null:{value:n(o[o.length-1]),isLive:!1}}getPreviousClose(t){const e=h(this,z).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const i=e.store.getAll();if(i.length<2)return null;const n=i[i.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=h(this,z).find(i=>i.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var i,n;const r=h(this,z).find(a=>a.id===t);return r?((n=(i=r.renderer).getDataAtTime)==null?void 0:n.call(i,e,h(this,rt)))??null:null}getLayerSnapshots(t,e){var i,n;const r=h(this,z).find(a=>a.id===t);return r!=null&&r.visible?((n=(i=r.renderer).getLayerSnapshots)==null?void 0:n.call(i,e,h(this,rt)))??null:null}getSeriesIds(){return h(this,Ft)||F(this,Ft,h(this,z).map(t=>t.id)),h(this,Ft).slice()}getSeriesType(t){const e=h(this,z).find(i=>i.id===t);return e?e.renderer instanceof be?"pie":"time":null}getSeriesIdsByType(t,e){const i=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const a of h(this,z)){const o=a.renderer instanceof be;if(t==="pie"&&!o||t==="time"&&o)continue;const l=a.renderer.getLayerCount();if(!(n&&l>1)){if(i){if(!a.visible)continue;if(l>1){let u=!1;for(let c=0;c<l;c++)if(a.renderer.isLayerVisible(c)){u=!0;break}if(!u)continue}}r.push(a.id)}}return r}getStackedLastValue(t){var e,i;const n=h(this,z).find(a=>a.id===t);return n?((i=(e=n.renderer).getStackedLastValue)==null?void 0:i.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,i;const n=h(this,z).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:i.call(e))??null}listSeriesForTest(){return h(this,z).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=h(this,z).find(i=>i.id===t);return e?e.renderer.getLayerColors()[0]??h(this,N).line.color:null}getSeriesLabel(t){var e;return(e=h(this,z).find(i=>i.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=h(this,z).find(r=>r.id===t);if(!e)return null;const i=e.renderer.getLayerCount();if(i<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:i},(r,a)=>({color:n[a%n.length]}))}getSliceInfo(t){var e,i;const n=h(this,z).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:i.call(e,h(this,N)))??null}getHoverInfo(t){var e,i;const n=h(this,z).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:i.call(e,h(this,N)))??null}setTheme(t){const e=h(this,N);F(this,N,t);for(const i of h(this,z))i.renderer.applyTheme(t,e);h(this,U).markDirty(),j(this,$,Bt).call(this)}getTheme(){return h(this,N)}setAxis(t){var e,i;const n=this.yAxisWidth,r=this.xAxisHeight;F(this,$t,t),F(this,Q,{min:(e=t.y)==null?void 0:e.min,max:(i=t.y)==null?void 0:i.max}),F(this,Xt,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),h(this,U).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),h(this,U).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),h(this,U).markDirty())}getMediaSize(){return h(this,K).size.media}getLayout(){const t=h(this,K).size.media,e=this.yAxisWidth,i=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-i},yAxisWidth:e,xAxisHeight:i}}getDataInterval(){return h(this,rt)}setPadding(t){const e=h(this,E).getPadding();h(this,E).setPadding(t);const i=h(this,E).getPadding(),n=!bi(e.left,i.left)||!bi(e.right,i.right),r=e.top!==i.top||e.bottom!==i.bottom;if(n){const{first:a,last:o}=this.getDataBounds();if(a!==void 0&&o!==void 0){const l=h(this,K).size.media.width-this.yAxisWidth;h(this,E).fitToData(a,o,l,!1)}}r&&this.updateYRange(!0),this.syncScales(),h(this,U).markDirty(),r&&this.emit("viewportChange")}setGrid(t){F(this,te,t.visible),h(this,U).markDirty()}setEdgeState(t,e){h(this,bt)[t]!==e&&(h(this,bt)[t]=e,h(this,wt).markDirty())}getEdgeState(t){return h(this,bt)[t]}setYLabel(t){F(this,Ve,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,i;for(const n of h(this,z))n.renderer.dispose();F(this,z,[]),F(this,Ft,null),h(this,E).destroy(),h(this,U).destroy(),h(this,wt).destroy(),(t=h(this,Zt))==null||t.destroy(),h(this,K).destroy(),(e=h(this,se))==null||e.destroy(),F(this,se,null),h(this,ie)&&((i=h(this,Mt))==null||i.destroy()),F(this,Mt,null),F(this,ie,!1),this.removeAllListeners()}getPerfMonitor(){return h(this,Mt)}getDataBounds(){let t,e;for(const i of h(this,z)){if(!i.visible||!i.store)continue;const n=i.store.first(),r=i.store.last();n&&(t===void 0||n.time<t)&&(t=n.time),r&&(e===void 0||r.time>e)&&(e=r.time)}return{first:t,last:e}}onDataChanged(){if(h(this,kt)>0){F(this,ee,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&h(this,E).setDataStart(t),e!==void 0&&h(this,E).setDataEnd(e);let i=0;for(const r of h(this,z))r.renderer.getTotalLength?i+=r.renderer.getTotalLength():r.store&&(i+=r.store.length);const n=i-h(this,Se)>5;if(F(this,Se,i),t!==void 0&&e!==void 0){const{from:r,to:a}=h(this,E).visibleRange,o=r===0&&a===0,l=h(this,K).size.media.width-this.yAxisWidth;o?h(this,E).fitToData(t,e,l,!1):n&&h(this,E).autoScroll?h(this,E).fitToData(t,e,l,!0):!n&&h(this,E).autoScroll&&h(this,E).scrollToEnd(e,l)}this.updateYRange(n),this.syncScales(),h(this,U).markDirty(),this.emit("dataUpdate"),j(this,$,Bt).call(this)}updateDataInterval(){for(const t of h(this,z)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const i=e.slice(0,20).map(n=>n.time);F(this,rt,ki(i)),h(this,E).setDataInterval(h(this,rt));break}}}updateYRange(t=!1){let e=1/0,i=-1/0;const n=h(this,E).visibleRange,r=h(this,Q).min!==void 0&&h(this,Q).min!=="auto"&&typeof h(this,Q).min!="number"||h(this,Q).max!==void 0&&h(this,Q).max!=="auto"&&typeof h(this,Q).max!="number"?[]:null;for(const c of h(this,z)){if(!c.visible)continue;if(c.renderer.getValueRange){const f=c.renderer.getValueRange(n.from,n.to);if(f){f.max>i&&(i=f.max),f.min<e&&(e=f.min),r==null||r.push(f.min,f.max);continue}}if(!c.store)continue;const d=c.store.getVisibleData(n.from,n.to);for(const f of d)if("high"in f){const m=f;m.high>i&&(i=m.high),m.low<e&&(e=m.low),r==null||r.push(m.high,m.low)}else{const m=f;m.value>i&&(i=m.value),m.value<e&&(e=m.value),r==null||r.push(m.value)}}if(e===1/0||i===-1/0){F(this,Xt,!1);return}e=this.resolveBound(h(this,Q).min,e,i,r??[],"min"),i=this.resolveBound(h(this,Q).max,i,e,r??[],"max");const a=h(this,jt).viewport.yAxisMs;if(!h(this,Xt)||t||a<=0)F(this,ut,e),F(this,dt,i),F(this,Xt,!0);else{const c=Math.min(1,16/a);F(this,ut,h(this,ut)+(e-h(this,ut))*c),F(this,dt,h(this,dt)+(i-h(this,dt))*c),e<h(this,ut)&&F(this,ut,e),i>h(this,dt)&&F(this,dt,i);const d=Math.max(Math.abs(h(this,dt)-h(this,ut))*1e-4,.001);(Math.abs(h(this,ut)-e)>d||Math.abs(h(this,dt)-i)>d)&&h(this,U).markDirty()}const o=h(this,Q).min!==void 0&&h(this,Q).min!=="auto",l=h(this,Q).max!==void 0&&h(this,Q).max!=="auto",u=h(this,K).size.media.height-this.xAxisHeight;h(this,E).setYRange(h(this,ut),h(this,dt),u,o,l)}resolveBound(t,e,i,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const a=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const o=a[1]==="-"?-1:1,l=parseFloat(a[2])/100,u=Math.abs(i-e)||Math.abs(e)||1;return e+o*l*u*(r==="max"?1:-1)}return e}syncScales(){const t=h(this,K).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,i=t.media.height-this.xAxisHeight;this.timeScale.update(h(this,E).visibleRange,e,t.horizontalPixelRatio,h(this,rt)),this.yScale.update(h(this,E).yRange,i,t.verticalPixelRatio)}updateScales(t=!1){const e=h(this,K).size;if(e.media.width===0||e.media.height===0)return;const i=e.media.width-this.yAxisWidth,n=e.media.height-this.xAxisHeight;this.timeScale.update(h(this,E).visibleRange,i,e.horizontalPixelRatio,h(this,rt)),this.yScale.update(h(this,E).yRange,n,e.verticalPixelRatio),this.updateYRange(t),this.yScale.update(h(this,E).yRange,n,e.verticalPixelRatio)}renderMain(t){const e=h(this,K).size;if(e.media.width===0||e.media.height===0)return;const i=typeof t=="number"?t:performance.now();h(this,E).tick(i)&&h(this,U).markDirty(),this.updateScales(),h(this,K).useMainLayer(n=>{const{context:r,bitmapSize:a}=n,o=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,l=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,a.width,a.height),r.save(),r.beginPath(),r.rect(0,0,o,l),r.clip(),h(this,te)&&Ss(n,this.timeScale,this.yScale,h(this,N),h(this,rt));const u=h(this,E).getPadding(),c={top:u.top,bottom:u.bottom},d=h(this,Mt);for(const f of h(this,z)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:h(this,N),dataInterval:h(this,rt),padding:c};if(d){const p=performance.now();f.renderer.render(m),d.recordSeries(f.id,performance.now()-p,i)}else f.renderer.render(m)}r.restore()});for(const n of h(this,z))if(n.renderer.needsAnimation){h(this,U).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,i;const n=h(this,K).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const l of h(this,z))if(l.visible&&l.renderer.overlayNeedsAnimation){r=!0;break}const a=h(this,bt).left==="loading"||h(this,bt).right==="loading",o=h(this,bt).left!=="idle"||h(this,bt).right!=="idle";if(h(this,K).useOverlayLayer(l=>{var u,c;if(!h(this,Ct)&&!r&&!o)return;const d=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(l.context.save(),l.context.beginPath(),l.context.rect(0,0,d,f),l.context.clip(),h(this,Ct)&&j(this,$,Ei).call(this)){const g=h(this,Ct).mediaX*n.horizontalPixelRatio,v=h(this,Ct).mediaY*n.verticalPixelRatio;us(l,g,v,h(this,N))}const m=h(this,E).getPadding(),p={top:m.top,bottom:m.bottom};for(const g of h(this,z))g.visible&&((c=(u=g.renderer).drawOverlay)==null||c.call(u,{scope:l,timeScale:this.timeScale,yScale:this.yScale,theme:h(this,N),dataInterval:h(this,rt),padding:p,crosshair:h(this,Ct)}));o&&this.drawEdgeIndicators(l,n.media.height-this.xAxisHeight),l.context.restore()}),r){const{from:l,to:u}=this.timeScale.getRange();let c=!1;for(const d of h(this,z))if(!(!d.visible||!d.renderer.overlayNeedsAnimation)&&(((i=(e=d.renderer).hasOverlayContentInRange)==null?void 0:i.call(e,l,u))??!0)){c=!0;break}c&&h(this,wt).markDirty()}a&&h(this,wt).markDirty()}drawEdgeIndicators(t,e){const i=performance.now();for(const n of["left","right"]){const r=h(this,bt)[n];if(r==="idle"||r==="has-more")continue;const a=this.resolveEdgeBoundary(n);a!==null&&vs({scope:t,timeScale:this.timeScale,theme:h(this,N),chartMediaHeight:e,boundaryTime:a,side:n,state:r,now:i})}}resolveEdgeBoundary(t){const e=h(this,ve)[t];if(e!==null)return e;const{first:i,last:n}=this.getDataBounds();return t==="left"?i??null:n??null}}K=new WeakMap,E=new WeakMap,U=new WeakMap,wt=new WeakMap,Zt=new WeakMap,z=new WeakMap,N=new WeakMap,te=new WeakMap,rt=new WeakMap,Ct=new WeakMap,Q=new WeakMap,Ft=new WeakMap,Ve=new WeakMap,$t=new WeakMap,bt=new WeakMap,ve=new WeakMap,ye=new WeakMap,kt=new WeakMap,ee=new WeakMap,Yt=new WeakMap,le=new WeakMap,we=new WeakMap,jt=new WeakMap,Mt=new WeakMap,ie=new WeakMap,se=new WeakMap,$=new WeakSet,Bt=function(){if(Ae(this,we)._++,h(this,kt)>0){F(this,le,!0);return}this.emit("overlayChange")},pi=function(s){if(s&&!h(this,z).some(e=>e.id===s))return s;let t;do t=`series_${++Dn}`;while(h(this,z).some(e=>e.id===t));return t},xe=function(s){const{enterMs:t,smoothMs:e,pulseMs:i}=h(this,jt).points;return s==="line"?{enterMs:t,smoothMs:e,pulseMs:i}:{enterMs:t,smoothMs:e}},ne=function(){const{enterMs:s,smoothMs:t,pulseMs:e}=h(this,jt).points,i={};return s===0&&(i.enterMs=0),t===0&&(i.smoothMs=0),e===0&&(i.pulseMs=0),i},re=function(s,t,e){var i;const n=j(this,$,pi).call(this,e.id);return(i=s.onDataChanged)==null||i.call(s,()=>this.onDataChanged()),h(this,z).push({id:n,label:e.label,renderer:s,store:t,visible:!0}),F(this,Ft,null),this.updateViewportPadding(),this.emit("seriesChange"),j(this,$,Bt).call(this),n},Ei=function(){for(const s of h(this,z))if(s.visible&&!(s.renderer instanceof be))return!0;return!1},Vi=function(s){const t=h(this,K).size,e=h(this,E).getPadding(),i={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of h(this,z)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let a=-1;if(s){const o=s.mediaX*t.horizontalPixelRatio,l=s.mediaY*t.verticalPixelRatio;a=r.renderer.hitTest(o,l,t.bitmap.width,t.bitmap.height,i)}r.renderer.setHoverIndex(a)&&(n=!0)}n&&h(this,U).markDirty()},Se=new WeakMap,ut=new WeakMap,dt=new WeakMap,Xt=new WeakMap;function bi(s,t){return typeof s=="number"&&typeof t=="number"?s===t:typeof s=="object"&&typeof t=="object"?s.intervals===t.intervals:!1}const Ye=new WeakMap;function ji(s,t){var e;return(e=Ye.get(s))==null?void 0:e.get(t)}function _i(s,t,e){let i=Ye.get(s);i||(i=new Map,Ye.set(s,i)),i.set(t,e)}function vi(s){return"close"in s?s.close:s.value}function Hi(s,t){if(t==="none"||s.length<=1)return s;const e=[...s];return e.sort((i,n)=>{const r=vi(i.data),a=vi(n.data);return t==="asc"?r-a:a-r}),e}function Ce(s){const t=Object.freeze({...s.data}),e={id:s.id,seriesId:s.seriesId,layerIndex:s.layerIndex,label:s.label,data:t,color:s.color};return Object.freeze(e)}function Xe(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=ji(s,t.cacheKey);if(n&&n.version===i&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const o of s.getSeriesIds()){if(!s.isSeriesVisible(o))continue;const l=s.getSeriesLabel(o);if(s.getSeriesLayers(o)!==null){const c=s.getLayerSnapshots(o,t.time);if(!c)continue;for(const d of c)r.push(Ce({id:`${o}_layer${d.layerIndex}`,seriesId:o,layerIndex:d.layerIndex,label:l,data:{time:d.time,value:d.value},color:d.color}));continue}const u=s.getDataAtTime(o,t.time);u&&r.push(Ce({id:o,seriesId:o,label:l,data:u,color:s.getSeriesColor(o)??"#888"}))}const a=Object.freeze(Hi(r,e));return _i(s,t.cacheKey,{version:i,time:t.time,sort:e,data:a}),a}function Oi(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=ji(s,t.cacheKey);if(n&&n.version===i&&n.time===null&&n.sort===e)return n.data;const r=[];for(const o of s.getSeriesIds()){if(!s.isSeriesVisible(o))continue;const l=s.getSeriesLabel(o),u=s.getLayerLastSnapshots(o);if(u){for(const d of u)r.push(Ce({id:`${o}_layer${d.layerIndex}`,seriesId:o,layerIndex:d.layerIndex,label:l,data:{time:d.time,value:d.value},color:d.color}));continue}const c=s.getLastData(o);c&&r.push(Ce({id:o,seriesId:o,label:l,data:c,color:s.getSeriesColor(o)??"#888"}))}const a=Object.freeze(Hi(r,e));return _i(s,t.cacheKey,{version:i,time:null,sort:e,data:a}),a}const Fn={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{upColor:"#089981",downColor:"#f23645",wickUpColor:"#089981",wickDownColor:"#f23645"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"}};function Bn(s){return parseInt(s.slice(1,3),16)*.299+parseInt(s.slice(3,5),16)*.587+parseInt(s.slice(5,7),16)*.114<128}function G(s){var t,e,i,n,r,a,o,l,u,c,d,f,m,p,g,v,y,x,S,k,M,I,b,T,R,D,B,Y,V;const{background:P,name:W="Custom",description:J,fontUrl:X=null}=s,H=Bn(P),it=H?"#d1d4dc":"#24292f",ot=H?"#787b86":"#8b949e",st=H?"#26a69a":"#2da44e",xt=H?"#ef5350":"#cf222e",Tt=H?"#2962ff":"#0969da",Rt=H?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",lt=H?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",nt=H?ge(P,.1):yi(P,.05),ht=H?qt(P,.92):qt(P,.95),St=H?qt(ge(P,.15),.6):"rgba(200,200,200,0.5)",mt=Te,gt=((t=s.candlestick)==null?void 0:t.upColor)??st,q=((e=s.candlestick)==null?void 0:e.downColor)??xt,tt=((i=s.line)==null?void 0:i.color)??Tt,Wt=((n=s.tooltip)==null?void 0:n.textColor)??it,rs=((r=s.axis)==null?void 0:r.textColor)??ot,as=((a=s.typography)==null?void 0:a.fontFamily)??mt,os={background:P,chartGradient:s.chartGradient??(H?[ge(P,.04),yi(P,.06)]:[ge(P,.06),P]),typography:{fontFamily:as,fontSize:((o=s.typography)==null?void 0:o.fontSize)??12,axisFontSize:((l=s.typography)==null?void 0:l.axisFontSize)??10,yFontSize:((u=s.typography)==null?void 0:u.yFontSize)??11,tooltipFontSize:((c=s.typography)==null?void 0:c.tooltipFontSize)??((d=s.typography)==null?void 0:d.fontSize)??12},grid:{color:((f=s.grid)==null?void 0:f.color)??Rt,style:((m=s.grid)==null?void 0:m.style)??"dashed"},candlestick:{upColor:gt,downColor:q,wickUpColor:((p=s.candlestick)==null?void 0:p.wickUpColor)??gt,wickDownColor:((g=s.candlestick)==null?void 0:g.wickDownColor)??q},line:{color:tt,width:((v=s.line)==null?void 0:v.width)??1,areaTopColor:((y=s.line)==null?void 0:y.areaTopColor)??qt(tt,.08),areaBottomColor:((x=s.line)==null?void 0:x.areaBottomColor)??qt(tt,.01)},seriesColors:s.seriesColors??[tt,st,xt],bands:{upper:((S=s.bands)==null?void 0:S.upper)??tt,lower:((k=s.bands)==null?void 0:k.lower)??q},crosshair:{color:((M=s.crosshair)==null?void 0:M.color)??lt,labelBackground:((I=s.crosshair)==null?void 0:I.labelBackground)??nt,labelTextColor:((b=s.crosshair)==null?void 0:b.labelTextColor)??Wt},axis:{textColor:rs},yLabel:{upBackground:((T=s.yLabel)==null?void 0:T.upBackground)??gt,downBackground:((R=s.yLabel)==null?void 0:R.downBackground)??q,neutralBackground:((D=s.yLabel)==null?void 0:D.neutralBackground)??nt,textColor:((B=s.yLabel)==null?void 0:B.textColor)??"#ffffff"},tooltip:{background:((Y=s.tooltip)==null?void 0:Y.background)??ht,textColor:Wt,borderColor:((V=s.tooltip)==null?void 0:V.borderColor)??St}};return{name:W,description:J,fontUrl:X,dark:H,theme:os}}function qt(s,t){const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function ge(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,Math.round(parseInt(s.slice(1,3),16)+255*t)),i=Math.min(255,Math.round(parseInt(s.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(s.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function yi(s,t){if(!s.startsWith("#"))return s;const e=Math.max(0,Math.round(parseInt(s.slice(1,3),16)*(1-t))),i=Math.max(0,Math.round(parseInt(s.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(s.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}const Me="'JetBrains Mono', 'Fira Code', monospace",ke="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Te="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Ne="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",$i="'Roboto Mono', monospace",Xi="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Pn="'IBM Plex Mono', monospace",zn="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Ue="'Fira Code', monospace",Ge="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",Ni="'Source Code Pro', monospace",Ui="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",An="'Space Mono', monospace",Wn="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",Ke="'Plus Jakarta Sans', sans-serif",qe="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",En="'Caveat', 'Comic Sans MS', cursive",Vn="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Yn=G({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{upColor:"#96e072",downColor:"#ee5d43"},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:$i},fontUrl:Xi}),jn=G({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{upColor:"#bae67e",downColor:"#f27983"},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:Te},fontUrl:Ne}),_n=G({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{upColor:"#a6e3a1",downColor:"#f38ba8"},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:Te},fontUrl:Ne}),Hn=G({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{upColor:"#50fa7b",downColor:"#ff5555"},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Ue},fontUrl:Ge}),On=G({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{upColor:"#2da44e",downColor:"#cf222e"},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:Ke},fontUrl:qe}),$n=G({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{upColor:"#b8bb26",downColor:"#fb4934"},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:Me},fontUrl:ke}),Xn={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Vn,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:En,fontSize:18,axisFontSize:13,yFontSize:15,tooltipFontSize:14},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{upColor:"#7a9a5e",downColor:"#b07060",wickUpColor:"#7a9a5e",wickDownColor:"#b07060"},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{textColor:"#a09880"},yLabel:{upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"}}},Nn="'Silkscreen', cursive",Un="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Gn=G({name:"Matrix",background:"#000000",candlestick:{upColor:"#00ff41",downColor:"#00802a"},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Nn},fontUrl:Un,chartGradient:["#010a01","#000000"]}),Kn=G({name:"Lavender Mist",background:"#f5f0f4",candlestick:{upColor:"#6b8e5e",downColor:"#b85468"},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:Ke},fontUrl:qe,chartGradient:["#f8f4f7","#f5f0f4"]}),qn=G({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{upColor:"#6a9a6e",downColor:"#c45070"},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:Te},fontUrl:Ne}),Jn=G({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{upColor:"#c3e88d",downColor:"#f07178"},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:$i},fontUrl:Xi}),Qn="'Silkscreen', cursive",Zn="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",tr=G({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{upColor:"#111111",downColor:"#bbbbbb"},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:Qn,tooltipFontSize:9},fontUrl:Zn}),er=G({name:"Mint Breeze",background:"#f6f5ee",candlestick:{upColor:"#2e9070",downColor:"#d04848"},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:An},fontUrl:Wn,chartGradient:["#f8f7f0","#f6f5ee"]}),ir=G({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{upColor:"#8ab862",downColor:"#d05470"},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Ue},fontUrl:Ge}),sr=G({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{upColor:"#7ec699",downColor:"#e06c75"},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#495a5a"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Me},fontUrl:ke}),nr=G({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{upColor:"#98c379",downColor:"#e06c75"},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:Me},fontUrl:ke}),rr=G({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{upColor:"#19f9d8",downColor:"#ff75b5"},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Ue},fontUrl:Ge}),ar=G({name:"Peach Cream",background:"#fef6f0",candlestick:{upColor:"#5a9a68",downColor:"#d06848"},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:Ke},fontUrl:qe,chartGradient:["#fff8f2","#fef6f0"]}),or=G({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",grid:{color:"rgba(200,200,200,0.5)"},candlestick:{upColor:"#448c27",downColor:"#aa3731"},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Pn},fontUrl:zn}),lr=G({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{upColor:"#56949f",downColor:"#b4637a"},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:Ni},fontUrl:Ui}),hr=G({name:"Sand Dune",background:"#f4f0e8",candlestick:{upColor:"#5a8a50",downColor:"#b85040"},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:Ni},fontUrl:Ui,chartGradient:["#f8f4ec","#f4f0e8"]}),cr=G({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{upColor:"#859900",downColor:"#dc322f"},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:Me},fontUrl:ke});function de(s){const{x:t,y:e,chartWidth:i,chartHeight:n,tooltipWidth:r,tooltipHeight:a,offsetX:o=16,offsetY:l=16}=s,u=t+o+r>i?t-o-r:t+o,c=e+l+a>n?e-l-a:e+l,d=Math.max(0,i-r),f=Math.max(0,n-a);return{left:Math.max(0,Math.min(d,u)),top:Math.max(0,Math.min(f,c))}}const ae=L.createContext(null);function et(){const s=L.useContext(ae);if(!s)throw new Error("useChartInstance must be used within <ChartContainer>");return s}const ur=20;function Gi({data:s,options:t,id:e}){var l;const i=et(),n=L.useRef(null),r=L.useRef([]),a=L.useRef([]),o=L.useRef([]);return L.useLayoutEffect(()=>{const u=i.addBarSeries({...t,layers:s.length,id:e});return n.current=u,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),o.current=new Array(s.length).fill(null),()=>{i.removeSeries(u),n.current=null,r.current=[],a.current=[],o.current=[]}},[i,s.length,e]),L.useLayoutEffect(()=>{const u=n.current;u&&i.batch(()=>{for(let c=0;c<s.length;c++){const d=s[c],f=r.current[c]??0,m=a.current[c]??null;if(d.length===0){i.setSeriesData(u,[],c),r.current[c]=0,a.current[c]=null,o.current[c]=null;continue}const p=at(d[0].time),g=at(d[d.length-1].time),v=o.current[c]??null,y=m!==null&&m!==p,x=d.length-f;if(y&&x===0&&(v!==null&&v!==g))i.setSeriesData(u,d.slice(0,-1),c),i.appendData(u,d[d.length-1],c);else if(f===0||d.length<f||x>ur||y)i.setSeriesData(u,d,c);else if(d.length===f)i.updateData(u,d[d.length-1],c);else for(let k=f;k<d.length;k++)i.appendData(u,d[k],c);r.current[c]=d.length,a.current[c]=p,o.current[c]=g}})},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(l=t==null?void 0:t.colors)==null?void 0:l.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const dr=20;function fr({data:s,options:t,id:e}){const i=et(),n=L.useRef(null),r=L.useRef(0),a=L.useRef(null),o=L.useRef(null);return L.useLayoutEffect(()=>{const l=i.addCandlestickSeries({...t,id:e});return n.current=l,()=>{i.removeSeries(l),n.current=null,r.current=0,a.current=null,o.current=null}},[i,e]),L.useLayoutEffect(()=>{const l=n.current;if(!l)return;if(s.length===0){i.setSeriesData(l,[]),r.current=0,a.current=null,o.current=null;return}const u=r.current,c=a.current,d=o.current,f=at(s[0].time),m=at(s[s.length-1].time),p=c!==null&&c!==f,g=s.length-u;if(p&&g===0&&(d!==null&&d!==m))i.setSeriesData(l,s.slice(0,-1)),i.appendData(l,s[s.length-1]);else if(u===0||s.length<u||g>dr||p)i.setSeriesData(l,s);else if(s.length===u)i.updateData(l,s[s.length-1]);else for(let y=u;y<s.length;y++)i.appendData(l,s[y]);r.current=s.length,a.current=f,o.current=m},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,t==null?void 0:t.upColor,t==null?void 0:t.downColor,t==null?void 0:t.wickUpColor,t==null?void 0:t.wickDownColor,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.bodyGradient,t==null?void 0:t.candleGradient,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const Je=L.createContext(null),oe=Je.Provider;function Re(){const s=L.useContext(Je);if(!s)throw new Error("useTheme must be used within <ThemeProvider>");return s}function mr(){return L.useContext(Je)}function Le(s,t,e){const i=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const a of i)s.on(a,r);return()=>{for(const a of i)s.off(a,r)}},getSnapshot:e}}function Ki(s){const t=L.useMemo(()=>Le(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getVisibleRange()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}function qi(s){const t=L.useMemo(()=>Le(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getYRange()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}function gr(s,t){const e=L.useMemo(()=>{let i=s.getLastValue(t),n=i?s.yScale.valueToY(i.value):null;const r=()=>i,a=()=>{const o=s.getLastValue(t),l=o?s.yScale.valueToY(o.value):null;return(i==null?void 0:i.value)===(o==null?void 0:o.value)&&(i==null?void 0:i.isLive)===(o==null?void 0:o.isLive)&&n===l?!1:(i=o,n=l,!0)};return{subscribe:o=>{a();const l=()=>{a()&&o()};return s.on("dataUpdate",l),s.on("viewportChange",l),()=>{s.off("dataUpdate",l),s.off("viewportChange",l)}},getSnapshot:r}},[s,t]);return L.useSyncExternalStore(e.subscribe,e.getSnapshot)}function pr(s,t){const e=L.useMemo(()=>Le(s,"dataUpdate",()=>s.getPreviousClose(t)),[s,t]);return L.useSyncExternalStore(e.subscribe,e.getSnapshot)}function fe(s){const t=L.useMemo(()=>Le(s,"crosshairMove",()=>s.getCrosshairPosition()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}const br=(s,t)=>t==="volume"?At(s):Oe(s);function Ji({sort:s="none",format:t=br,children:e}){const i=et(),n=Re(),r=fe(i),[,a]=L.useState(0);L.useLayoutEffect(()=>{const f=()=>a(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&a(m=>m+1),()=>{i.off("overlayChange",f)}},[i]);const o=Oi(i,{sort:s,cacheKey:"infobar-last"});let l=o,u=o.length===0?0:Math.max(...o.map(f=>f.data.time)),c=!1;if(r!==null){const f=Xe(i,{time:r.time,sort:s,cacheKey:"infobar-hover"});f.length>0&&(l=f,u=r.time,c=!0)}if(l.length===0)return null;if(e)return C.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:l,time:u,isHover:c})});const d=i.getDataInterval();return C.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[C.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:ue(u,d)}),l.map(f=>{if("open"in f.data){const g=f.data,y=g.close>=g.open?n.candlestick.upColor:n.candlestick.downColor;return C.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[C.jsx(Jt,{label:"O",display:t(g.open,"open"),color:y,dim:n.axis.textColor}),C.jsx(Jt,{label:"H",display:t(g.high,"high"),color:y,dim:n.axis.textColor}),C.jsx(Jt,{label:"L",display:t(g.low,"low"),color:y,dim:n.axis.textColor}),C.jsx(Jt,{label:"C",display:t(g.close,"close"),color:y,dim:n.axis.textColor}),g.volume!=null&&C.jsx(Jt,{label:"V",display:t(g.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const p=f.data;return C.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[C.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.color,flexShrink:0}}),C.jsx("span",{style:{color:f.color,fontWeight:500},children:t(p.value,"value")})]},f.id)})]})}function Jt({label:s,display:t,color:e,dim:i}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{color:i,opacity:.5,marginLeft:5},children:s}),C.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function vr({chart:s,isolatedIdRef:t,setIsolatedId:e}){const i=[],n=s.getSeriesIds();for(const r of n){const a=s.getSeriesLayers(r);if(a){const o=s.getSeriesLabel(r);for(let l=0;l<a.length;l++){const u=`${r}_layer${l}`,c=s.isSeriesVisible(r)&&s.isLayerVisible(r,l);i.push(xi({id:u,seriesId:r,layerIndex:l,label:o?`${o} ${l+1}`:`Series ${l+1}`,color:a[l].color,isDisabled:!c,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}else{const o=s.getSeriesColor(r);if(!o)continue;const l=s.getSeriesLabel(r),u=s.isSeriesVisible(r);i.push(xi({id:r,seriesId:r,layerIndex:void 0,label:l??"Series",color:o,isDisabled:!u,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}return i}function xi(s){const{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,chart:o,isolatedIdRef:l,setIsolatedId:u}=s;return{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,toggle:()=>{i!==void 0?o.setLayerVisible(e,i,!o.isLayerVisible(e,i)):o.setSeriesVisible(e,!o.isSeriesVisible(e))},isolate:()=>{if(l.current===t){o.batch(()=>{for(const f of o.getSeriesIds()){o.setSeriesVisible(f,!0);const m=o.getSeriesLayers(f);if(m)for(let p=0;p<m.length;p++)o.setLayerVisible(f,p,!0)}}),l.current=null,u(null);return}o.batch(()=>{for(const f of o.getSeriesIds()){const m=o.getSeriesLayers(f);if(m){o.setSeriesVisible(f,f===e);for(let p=0;p<m.length;p++)o.setLayerVisible(f,p,f===e&&p===i)}else o.setSeriesVisible(f,f===t)}}),l.current=t,u(t)}}}function Qi({items:s,position:t="bottom",mode:e="toggle",children:i}){const n=et(),r=Re(),[a,o]=L.useState(null),[l,u]=L.useState(0),c=L.useRef(a);c.current=a,L.useLayoutEffect(()=>{const g=()=>u(y=>y+1),v=()=>o(null);return n.on("overlayChange",g),n.on("seriesChange",v),n.getSeriesIds().length>0&&u(y=>y+1),()=>{n.off("overlayChange",g),n.off("seriesChange",v)}},[n]);const d=L.useMemo(()=>vr({chart:n,isolatedIdRef:c,setIsolatedId:o}),[n,a,l]),f=t==="right",m={display:"flex",flexDirection:f?"column":"row",flexWrap:"wrap",gap:f?6:14,padding:f?"8px 6px":"6px 8px",alignItems:f?"flex-start":"center",justifyContent:f?"flex-start":"center",fontFamily:r.typography.fontFamily,fontSize:r.typography.axisFontSize,color:r.axis.textColor,pointerEvents:"auto",flexShrink:0};if(i)return d.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:i({items:d})});if(s)return s.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:s.map((g,v)=>C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},v))});if(d.length===0)return null;const p=g=>{e==="isolate"||e==="solo"?g.isolate():g.toggle()};return C.jsx("div",{"data-legend":t,style:m,children:d.map(g=>C.jsxs("div",{onClick:()=>p(g),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:g.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},g.id))})}function yr(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function Zi({seriesId:s,mode:t,format:e,position:i,children:n}){const r=t??"both",a=i??"bottom",o=e??At,l=et(),u=l.getTheme(),[,c]=L.useState(0);L.useLayoutEffect(()=>{const p=()=>c(g=>g+1);return l.on("overlayChange",p),l.getSeriesIds().length>0&&p(),()=>{l.off("overlayChange",p)}},[l]);const d=yr(l,s),f=d!==null?l.getSliceInfo(d):null;if(!f||f.length===0)return null;if(n)return C.jsx(C.Fragment,{children:n({slices:f,mode:r,format:o})});const m=a==="overlay";return C.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":a,style:{display:"flex",flexDirection:"column",gap:6,padding:m?"8px 12px":"6px 10px",fontFamily:u.typography.fontFamily,fontSize:u.typography.fontSize,color:u.tooltip.textColor,pointerEvents:"auto"},children:f.map((p,g)=>C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:p.color,flexShrink:0}}),C.jsx("span",{style:{flex:1,opacity:.8},children:p.label}),(r==="value"||r==="both")&&C.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:o(p.value)}),(r==="percent"||r==="both")&&C.jsxs("span",{style:{opacity:r==="percent"?1:.5,fontWeight:r==="percent"?600:400,fontSize:r==="percent"?u.typography.fontSize:u.typography.axisFontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[p.percent.toFixed(1),"%"]})]},g))})}function ts({children:s,sub:t,style:e}){const i=Re();return C.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:i.typography.fontFamily,fontSize:i.typography.fontSize,fontWeight:600,color:i.tooltip.textColor,pointerEvents:"none",...e},children:[s!=null&&s!==!1&&C.jsx("span",{children:s}),t!=null&&t!==!1&&C.jsx("span",{style:{fontWeight:400,color:i.axis.textColor,fontSize:i.typography.axisFontSize},children:t})]})}function xr(s){let t=null,e=null,i=null,n=null;const r=[],a=o=>{if(L.isValidElement(o)&&o.type===L.Fragment){L.Children.forEach(o.props.children,a);return}if(L.isValidElement(o)){if(o.type===ts){t=o;return}if(o.type===Qi){e=o;return}if(o.type===Zi){const l=o;l.props.position==="overlay"?r.push(o):i=l;return}if(o.type===Ji){n=o;return}}r.push(o)};return L.Children.forEach(s,a),{titleEl:t,legendEl:e,pieLegendEl:i,tooltipLegendEl:n,overlay:r}}function es({children:s,theme:t,axis:e,padding:i,gradient:n=!0,interactive:r,grid:a,headerLayout:o="overlay",perf:l,style:u,className:c}){var lt,nt,ht,St,mt,gt;const d=L.useRef(l),f=mr(),m=t??f??void 0,p=L.useRef(null),g=L.useRef(null),[v,y]=L.useState(0);L.useLayoutEffect(()=>{if(!p.current||g.current)return;const q={};return e&&(q.axis=e),m&&(q.theme=m),i&&(q.padding=i),r!==void 0&&(q.interactive=r),a!==void 0&&(q.grid=a),d.current!==void 0&&(q.perf=d.current),g.current=new Yi(p.current,q),y(tt=>tt+1),()=>{var tt;(tt=g.current)==null||tt.destroy(),g.current=null}},[]),L.useEffect(()=>{g.current&&m&&g.current.setTheme(m)},[m]),L.useEffect(()=>{g.current&&e&&g.current.setAxis(e)},[(lt=e==null?void 0:e.y)==null?void 0:lt.width,(nt=e==null?void 0:e.y)==null?void 0:nt.min,(ht=e==null?void 0:e.y)==null?void 0:ht.max,(St=e==null?void 0:e.y)==null?void 0:St.visible,(mt=e==null?void 0:e.x)==null?void 0:mt.height,(gt=e==null?void 0:e.x)==null?void 0:gt.visible]);const x=L.useRef(null),[S,k]=L.useState(0),M=o==="overlay"?S:0;L.useEffect(()=>{const q=g.current;if(!q)return;const Wt={top:((i==null?void 0:i.top)??20)+M,...(i==null?void 0:i.bottom)!==void 0?{bottom:i.bottom}:{},...(i==null?void 0:i.right)!==void 0?{right:i.right}:{},...(i==null?void 0:i.left)!==void 0?{left:i.left}:{}};q.setPadding(Wt)},[i==null?void 0:i.top,i==null?void 0:i.bottom,typeof(i==null?void 0:i.right)=="object"?i.right.intervals:i==null?void 0:i.right,typeof(i==null?void 0:i.left)=="object"?i.left.intervals:i==null?void 0:i.left,M]),L.useEffect(()=>{g.current&&a!==void 0&&g.current.setGrid(a)},[a==null?void 0:a.visible]);const I=g.current,{titleEl:b,legendEl:T,pieLegendEl:R,tooltipLegendEl:D,overlay:B}=xr(s),Y=(T==null?void 0:T.props.position)??"bottom",V=(R==null?void 0:R.props.position)??"bottom",P=Y==="right"||V==="right",W=m??(I==null?void 0:I.getTheme()),[J,X]=(W==null?void 0:W.chartGradient)??["transparent","transparent"],H=(W==null?void 0:W.background)??"transparent",it=n?`linear-gradient(to bottom, ${J} 0%, ${H} 70%, ${X} 100%)`:H;L.useLayoutEffect(()=>{if(o!=="overlay"){k(0);return}const q=x.current;if(!q){k(0);return}const tt=()=>k(q.getBoundingClientRect().height);tt();const Wt=new ResizeObserver(tt);return Wt.observe(q),()=>Wt.disconnect()},[b!==null,D!==null,o,I!==null]);const ot=(b||D)&&C.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":o==="overlay"?"":void 0,ref:x,style:o==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[b,D]}),st=C.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:I&&C.jsx(ae.Provider,{value:I,children:C.jsxs(oe,{value:m??I.getTheme(),children:[o==="overlay"&&ot,C.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:B})]})})}),xt=o==="inline"?C.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[I&&ot&&C.jsx(ae.Provider,{value:I,children:C.jsx(oe,{value:m??I.getTheme(),children:ot})}),st]}):st,Tt=I&&T&&C.jsx(ae.Provider,{value:I,children:C.jsx(oe,{value:m??I.getTheme(),children:T})}),Rt=I&&R&&C.jsx(ae.Provider,{value:I,children:C.jsx(oe,{value:m??I.getTheme(),children:R})});return C.jsx("div",{className:c,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:it,...u},children:C.jsxs("div",{style:{display:"flex",flexDirection:P?"row":"column",flex:1,minHeight:0,minWidth:0},children:[xt,Tt,Rt]})})}const Sr=20;function is({data:s,options:t,id:e}){var l,u;const i=et(),n=L.useRef(null),r=L.useRef([]),a=L.useRef([]),o=L.useRef([]);return L.useLayoutEffect(()=>{const c=i.addLineSeries({...t,layers:s.length,id:e});return n.current=c,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),o.current=new Array(s.length).fill(null),()=>{i.removeSeries(c),n.current=null,r.current=[],a.current=[],o.current=[]}},[i,s.length,e]),L.useLayoutEffect(()=>{const c=n.current;c&&i.batch(()=>{for(let d=0;d<s.length;d++){const f=s[d],m=r.current[d]??0,p=a.current[d]??null;if(f.length===0){i.setSeriesData(c,[],d),r.current[d]=0,a.current[d]=null,o.current[d]=null;continue}const g=at(f[0].time),v=at(f[f.length-1].time),y=o.current[d]??null,x=p!==null&&p!==g,S=f.length-m;if(x&&S===0&&(y!==null&&y!==v))i.setSeriesData(c,f.slice(0,-1),d),i.appendData(c,f[f.length-1],d);else if(m===0||f.length<m||S>Sr||x)i.setSeriesData(c,f,d);else if(f.length===m)i.updateData(c,f[f.length-1],d);else for(let M=m;M<f.length;M++)i.appendData(c,f[M],d);r.current[d]=f.length,a.current[d]=g,o.current[d]=v}})},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(l=t==null?void 0:t.colors)==null?void 0:l.join(","),t==null?void 0:t.strokeWidth,(u=t==null?void 0:t.area)==null?void 0:u.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}function wr({data:s,options:t,id:e}){var r,a,o,l,u,c,d,f,m,p;const i=et(),n=L.useRef(null);return L.useLayoutEffect(()=>{const g=i.addPieSeries({...t,id:e});return n.current=g,()=>{i.removeSeries(g),n.current=null}},[i,e]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(r=t==null?void 0:t.sliceLabels)==null?void 0:r.mode,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.content,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.fontSize,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.minSliceAngle,(u=t==null?void 0:t.sliceLabels)==null?void 0:u.elbowLen,(c=t==null?void 0:t.sliceLabels)==null?void 0:c.legPad,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.labelGap,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.distance,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.railWidth,(p=t==null?void 0:t.sliceLabels)==null?void 0:p.balanceSides]),L.useLayoutEffect(()=>{n.current&&i.setSeriesData(n.current,s)},[i,s]),null}function Cr(){const s=et(),t=fe(s);if(!t)return null;const e=s.getTheme(),i=s.getDataInterval(),n={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.typography.axisFontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:s.yScale.formatY(t.y)}),C.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:ue(t.time,i)})]})}const Mr=["0","1","2","3","4","5","6","7","8","9"];function kr(s){const t=[];for(const e of s)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function ss({value:s,format:t,locale:e="en-US",spinDuration:i=350,className:n,style:r}){const o=L.useMemo(()=>{if(typeof t=="function")return t;const u=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return c=>u.format(c)},[t,e])(s),l=kr(o);return C.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:l.map((u,c)=>u.type==="digit"?C.jsx(Tr,{digit:parseInt(u.value,10),duration:i},`d${c}`):C.jsx("span",{style:{display:"inline-block"},children:u.value},`s${c}`))})}function Tr({digit:s,duration:t}){const e=L.useRef(!1);return L.useEffect(()=>{e.current=!0},[]),C.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:C.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-s*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Mr.map(i=>C.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:i},i))})})}function Rr(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Lr=160,Ir=70;function Dr({seriesId:s,format:t=At,children:e}){const i=et(),n=fe(i),[,r]=L.useState(0);L.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),()=>{i.off("overlayChange",f)}},[i]);const a=Rr(i,s),o=a!==null?i.getHoverInfo(a):null;if(!o||!n)return null;const l=i.getTheme(),u=i.getMediaSize();if(e)return C.jsx(Fr,{x:n.mediaX,y:n.mediaY,chartWidth:u.width,chartHeight:u.height,children:e({info:o,format:t})});const{left:c,top:d}=de({x:n.mediaX,y:n.mediaY,chartWidth:u.width,chartHeight:u.height,tooltipWidth:Lr,tooltipHeight:Ir,offsetX:16,offsetY:16});return C.jsxs("div",{style:{position:"absolute",left:c,top:d,pointerEvents:"none",zIndex:10,background:l.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${l.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:l.typography.fontSize,fontFamily:l.typography.fontFamily,color:l.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:o.color,flexShrink:0}}),C.jsx("span",{style:{fontWeight:600},children:o.label})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[C.jsx("span",{style:{opacity:.6},children:t(o.value)}),C.jsxs("span",{style:{fontWeight:600},children:[o.percent.toFixed(1),"%"]})]})]})}function Fr({x:s,y:t,chartWidth:e,chartHeight:i,children:n}){const r=L.useRef(null),[a,o]=L.useState(null);L.useEffect(()=>{const u=r.current;if(!u||typeof ResizeObserver>"u")return;const c=new ResizeObserver(d=>{var m;const f=(m=d[0])==null?void 0:m.contentRect;f&&o(p=>p&&p.width===f.width&&p.height===f.height?p:{width:f.width,height:f.height})});return c.observe(u),()=>c.disconnect()},[]);const l=a?de({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:a.width,tooltipHeight:a.height,offsetX:16,offsetY:16}):{left:0,top:0};return C.jsx("div",{ref:r,"data-measured":a?"true":"false",style:{position:"absolute",left:l.left,top:l.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:a?"visible":"hidden"},children:n})}function Br(s,t){if(s.startsWith("rgba")||!s.startsWith("#"))return s;const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function Pr(s){if(s.length<2)return{value:0,pct:0,positive:!0};const t=s[0].value,i=s[s.length-1].value-t,n=t!==0?i/t*100:0;return{value:i,pct:n,positive:i>=0}}function zr({data:s,theme:t,variant:e="line",valuePosition:i="right",formatValue:n=At,label:r,sublabel:a,color:o,negativeColor:l,area:u,areaFill:c,width:d=140,height:f=48,strokeWidth:m=1.5,gradient:p=!0,style:g}){const v=(u==null?void 0:u.visible)??c??!0,y=s.length>0?s[s.length-1].value:0,x=L.useMemo(()=>Pr(s),[s]),S=o??t.seriesColors[0],k=l??t.candlestick.downColor,M=x.positive?t.candlestick.upColor:t.candlestick.downColor,I=i!=="none"&&C.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[r&&C.jsx("div",{style:{fontSize:t.typography.axisFontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),C.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(y)}),a!==void 0?C.jsx("div",{style:{fontSize:t.typography.axisFontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:a}):C.jsxs("div",{style:{fontSize:t.typography.axisFontSize-1,fontWeight:500,color:M,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[x.positive?"+":"",x.pct.toFixed(1),"%"]})]}),b=C.jsx("div",{style:{width:d,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:C.jsx(es,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:{visible:!1},children:e==="line"?C.jsx(is,{data:[s],options:{colors:[S],strokeWidth:m,area:{visible:v},pulse:!1,stacking:"off"}}):C.jsx(Gi,{data:[s],options:{colors:[S,k],barWidthRatio:.7,stacking:"off"}})})});return C.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Br(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...g},children:[i==="left"&&I,b,i==="right"&&I]})}function ns({labelCount:s,minLabelSpacing:t}={}){const e=et();Ki(e),L.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:s??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,s,t]);const i=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:a}=e.timeScale.niceTickValues(n),o=new Set(r),u=L.useRef(new Map).current,c=performance.now();for(const f of r)u.has(f)?u.get(f).opacity=1:u.set(f,{opacity:1,addedAt:c});for(const[f,m]of u)o.has(f)||m.opacity!==0&&(m.opacity=0,m.fadedAt=c);for(const[f,m]of u)m.opacity===0&&m.fadedAt!==void 0&&c-m.fadedAt>600&&u.delete(f);const d=Array.from(u.entries());return C.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:d.map(([f,m])=>{const p=e.timeScale.timeToX(f);return C.jsx("span",{style:{position:"absolute",left:p,transform:"translateX(-50%)",color:i.axis.textColor,fontSize:i.typography.axisFontSize,fontFamily:i.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:ue(f,a)},f)})})}const Ar=(s,t)=>t==="volume"?At(s):Oe(s);function Wr({sort:s="none",format:t=Ar,children:e}){const i=et(),n=fe(i),[,r]=L.useState(0);if(L.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&r(m=>m+1),()=>{i.off("overlayChange",f)}},[i]),!n)return null;const a=Xe(i,{time:n.time,sort:s,cacheKey:"tooltip"});if(a.length===0)return null;const o=i.getTheme(),l=i.getDataInterval(),u=i.getMediaSize(),c=u.width-i.yAxisWidth,d=u.height-i.xAxisHeight;return e?C.jsx(Er,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:d,theme:o,children:e({snapshots:a,time:n.time})}):C.jsx(Vr,{snapshots:a,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:d,theme:o,dataInterval:l,format:t})}function Er({x:s,y:t,chartWidth:e,chartHeight:i,theme:n,children:r}){const a=L.useRef(null),[o,l]=L.useState(null);L.useEffect(()=>{const c=a.current;if(!c||typeof ResizeObserver>"u")return;const d=new ResizeObserver(f=>{var p;const m=(p=f[0])==null?void 0:p.contentRect;m&&l(g=>g&&g.width===m.width&&g.height===m.height?g:{width:m.width,height:m.height})});return d.observe(c),()=>d.disconnect()},[]);const u=o?de({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:o.width,tooltipHeight:o.height}):{left:0,top:0};return C.jsx("div",{ref:a,"data-measured":o?"true":"false",style:{position:"absolute",left:u.left,top:u.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.typography.tooltipFontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:o?"visible":"hidden"},children:r})}function Vr({snapshots:s,displayTime:t,x:e,y:i,chartWidth:n,chartHeight:r,theme:a,dataInterval:o,format:l}){const u=s.some(x=>"open"in x.data),c=s.filter(x=>!("open"in x.data)).length,d=160,f=u?140:40+c*22,{left:m,top:p}=de({x:e,y:i,chartWidth:n,chartHeight:r,tooltipWidth:d,tooltipHeight:f}),g=a.tooltip.background,v=a.tooltip.borderColor;return C.jsxs("div",{style:{position:"absolute",left:m,top:p,pointerEvents:"none",background:g,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${v}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:a.typography.tooltipFontSize,fontFamily:a.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:a.tooltip.textColor,width:d,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[C.jsxs("div",{style:{fontSize:a.typography.axisFontSize,color:a.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${v}`,letterSpacing:"0.02em"},children:[Ti(t)," ",ue(t,o)]}),s.map(x=>{if("open"in x.data){const M=x.data,I=M.close>=M.open,b=a.candlestick.upColor,T=a.candlestick.downColor,R=I?b:T;return C.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[C.jsx(Qt,{label:"Open",color:R,display:l(M.open,"open")}),C.jsx(Qt,{label:"High",color:R,display:l(M.high,"high")}),C.jsx(Qt,{label:"Low",color:R,display:l(M.low,"low")}),C.jsx(Qt,{label:"Close",color:R,display:l(M.close,"close")}),M.volume!=null&&C.jsx(Qt,{label:"Volume",color:a.tooltip.textColor,display:l(M.volume,"volume")})]},x.id)}const k=x.data;return C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[C.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:x.color,flexShrink:0}}),C.jsx("span",{style:{opacity:.6,flex:1},children:x.label??"Value"}),C.jsx("span",{style:{fontWeight:600,color:x.color},children:l(k.value,"value")})]},x.id)})]})}function Qt({label:s,color:t,display:e}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{opacity:.5},children:s}),C.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function Yr({format:s,labelCount:t,minLabelSpacing:e}={}){const i=et();qi(i),L.useLayoutEffect(()=>(i.yScale.setFormat(s??null),()=>i.yScale.setFormat(null)),[i,s]),L.useLayoutEffect(()=>(i.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{i.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[i,t,e]);const n=i.getTheme(),r=i.yScale.niceTickValues(),a=new Set(r),l=L.useRef(new Map).current,u=performance.now();for(const d of r)l.has(d)?l.get(d).opacity=1:l.set(d,{opacity:1,addedAt:u});for(const[d,f]of l)a.has(d)||f.opacity!==0&&(f.opacity=0,f.fadedAt=u);for(const[d,f]of l)f.opacity===0&&f.fadedAt!==void 0&&u-f.fadedAt>600&&l.delete(d);const c=Array.from(l.entries());return C.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:i.xAxisHeight,width:i.yAxisWidth,pointerEvents:"none"},children:c.map(([d,f])=>{const m=i.yScale.valueToY(d);return C.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:n.axis.textColor,fontSize:n.typography.axisFontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:i.yScale.formatY(d)},d)})})}function jr(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const i=s.getSeriesIdsByType("time",{visibleOnly:!0});return i.length>0?i[0]:null}function _r({seriesId:s,color:t,format:e,children:i}){const n=et();L.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=L.useState(0);L.useLayoutEffect(()=>{const S=()=>r(k=>k+1);return n.on("overlayChange",S),n.on("viewportChange",S),n.getSeriesIds().length>0&&r(k=>k+1),()=>{n.off("overlayChange",S),n.off("viewportChange",S)}},[n]);const a=jr(n,s),o=a!==null?n.getStackedLastValue(a):null,l=a!==null?n.getPreviousClose(a):null,u=n.yScale.getRange(),c=u.max-u.min,d=c<.1?6:c<10?4:c<1e3?2:0,f=L.useMemo(()=>{if(e)return e;const S=new Intl.NumberFormat("en-US",{minimumFractionDigits:d,maximumFractionDigits:d,useGrouping:!1});return k=>S.format(k)},[e,d]);if(!o||a===null)return null;const{value:m,isLive:p}=o,g=n.getTheme(),v=n.yScale.valueToY(m),y=l===null?"neutral":m>l?"up":m<l?"down":"neutral";let x;return p?t?x=t:x=y==="up"?g.yLabel.upBackground:y==="down"?g.yLabel.downBackground:g.yLabel.neutralBackground:x=g.axis.textColor,i?C.jsx(C.Fragment,{children:i({value:m,y:v,bgColor:x,isLive:p,direction:y,format:f})}):C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:v,height:0,borderTop:`1px dashed ${x}`,opacity:.5,pointerEvents:"none",zIndex:2}}),C.jsx("div",{style:{position:"absolute",right:4,top:v,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:x,color:g.yLabel.textColor,fontSize:g.typography.yFontSize,fontFamily:g.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:C.jsx(ss,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=Gi;exports.CandlestickSeries=fr;exports.ChartContainer=es;exports.ChartInstance=Yi;exports.Crosshair=Cr;exports.InfoBar=Ji;exports.Legend=Qi;exports.LineSeries=is;exports.NumberFlow=ss;exports.PieLegend=Zi;exports.PieSeries=wr;exports.PieTooltip=Dr;exports.Sparkline=zr;exports.ThemeProvider=oe;exports.TimeAxis=ns;exports.Title=ts;exports.Tooltip=Wr;exports.XAxis=ns;exports.YAxis=Yr;exports.YLabel=_r;exports.andromeda=Yn;exports.ayuMirage=jn;exports.buildHoverSnapshots=Xe;exports.buildLastSnapshots=Oi;exports.catppuccin=_n;exports.computeTooltipPosition=de;exports.createTheme=G;exports.darkTheme=Wi;exports.detectInterval=ki;exports.dracula=Hn;exports.formatCompact=At;exports.formatDate=Ti;exports.formatPriceAdaptive=Oe;exports.formatTime=ue;exports.githubLight=On;exports.gruvbox=$n;exports.handwritten=Xn;exports.highContrast=Gn;exports.lavenderMist=Kn;exports.lightPink=qn;exports.lightTheme=Fn;exports.materialPalenight=Jn;exports.minimalLight=tr;exports.mintBreeze=er;exports.monokaiPro=ir;exports.nightOwl=sr;exports.normalizeTime=at;exports.oneDarkPro=nr;exports.panda=rr;exports.peachCream=ar;exports.quietLight=or;exports.rosePineDawn=lr;exports.sandDune=hr;exports.solarizedLight=cr;exports.useChartInstance=et;exports.useCrosshairPosition=fe;exports.useLastYValue=gr;exports.usePreviousClose=pr;exports.useTheme=Re;exports.useVisibleRange=Ki;exports.useYRange=qi;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react"),M=require("react/jsx-runtime");var ps=Object.defineProperty,Ii=s=>{throw TypeError(s)},bs=(s,t,e)=>t in s?ps(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,w=(s,t,e)=>bs(s,typeof t!="symbol"?t+"":t,e),Xe=(s,t,e)=>t.has(s)||Ii("Cannot "+e),h=(s,t,e)=>(Xe(s,t,"read from private field"),e?e.call(s):t.get(s)),F=(s,t,e)=>t.has(s)?Ii("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),B=(s,t,e,i)=>(Xe(s,t,"write to private field"),t.set(s,e),e),j=(s,t,e)=>(Xe(s,t,"access private method"),e),Ye=(s,t,e,i)=>({set _(n){B(s,t,n)},get _(){return h(s,t,i)}});class me{constructor(){w(this,"listeners",new Map)}on(t,e){let i=this.listeners.get(t);i||(i=new Set,this.listeners.set(t,i)),i.add(e)}off(t,e){var i;(i=this.listeners.get(t))==null||i.delete(e)}emit(t,...e){var i;(i=this.listeners.get(t))==null||i.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function hi(s,t){const e=new Map;return new Proxy(s,{get(i,n){const r=Reflect.get(i,n,i);if(typeof r!="function")return r;const a=e.get(n);if(a)return a;const o=typeof n=="string"?n:String(n),l=r,d=(...c)=>(t.set(o,(t.get(o)??0)+1),l.apply(i,c));return e.set(n,d),d},set(i,n,r){return Reflect.set(i,n,r,i)}})}function ci(s,t,e){const i=document.createElement("canvas");return i.style.position="absolute",i.style.inset="0",i.style.width="100%",i.style.height="100%",i.style.display="block",i.style.zIndex=String(t),s.appendChild(i),i}class ys extends me{constructor(t,e){super(),w(this,"mainCanvas"),w(this,"mainCtx"),w(this,"overlayCanvas"),w(this,"overlayCtx"),w(this,"resizeObserver"),w(this,"_size"),w(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=ci(t,0),this.overlayCanvas=ci(t,1);const i=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!i||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?hi(i,e.drawCallsMain):i,this.overlayCtx=e?hi(n,e.drawCallsOverlay):n;const r=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:r,verticalPixelRatio:r},this.resizeObserver=new ResizeObserver(o=>{this.handleResize(o[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const a=t.getBoundingClientRect();if(a.width>0&&a.height>0){const o=window.devicePixelRatio||1,l=o,d=Math.round(a.width*o),c=Math.round(a.height*l);this.mainCanvas.width=d,this.mainCanvas.height=c,this.overlayCanvas.width=d,this.overlayCanvas.height=c,this._size={media:{width:a.width,height:a.height},bitmap:{width:d,height:c},horizontalPixelRatio:d/a.width,verticalPixelRatio:c/a.height}}}handleResize(t){var e,i;let n,r,a,o;if(this.supportsDevicePixelContentBox&&(e=t.devicePixelContentBoxSize)!=null&&e[0]){const c=t.devicePixelContentBoxSize[0];n=c.inlineSize,r=c.blockSize;const u=t.contentBoxSize[0];a=u.inlineSize,o=u.blockSize}else{const c=(i=t.contentBoxSize)==null?void 0:i[0];if(c)a=c.inlineSize,o=c.blockSize;else{const f=t.contentRect;a=f.width,o=f.height}const u=window.devicePixelRatio||1;n=Math.round(a*u),r=Math.round(o*u)}if(n===0||r===0)return;this.mainCanvas.width=n,this.mainCanvas.height=r,this.overlayCanvas.width=n,this.overlayCanvas.height=r;const l=n/a,d=r/o;this._size={media:{width:a,height:o},bitmap:{width:n,height:r},horizontalPixelRatio:l,verticalPixelRatio:d},this.emit("resize",this._size)}get size(){return this._size}useMainLayer(t){this.mainCtx.save(),t({context:this.mainCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.mainCtx.restore()}useOverlayLayer(t){const{width:e,height:i}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,i),this.overlayCtx.save(),t({context:this.overlayCtx,bitmapSize:this._size.bitmap,mediaSize:this._size.media,horizontalPixelRatio:this._size.horizontalPixelRatio,verticalPixelRatio:this._size.verticalPixelRatio}),this.overlayCtx.restore()}get canvas(){return this.overlayCanvas}destroy(){this.resizeObserver.disconnect(),this.mainCanvas.remove(),this.overlayCanvas.remove(),this.removeAllListeners()}}function vs(s,t,e,i){const{context:n,bitmapSize:r,horizontalPixelRatio:a}=s;n.strokeStyle=i.crosshair.color,n.lineWidth=1,n.setLineDash([4*a,4*a]);const o=Math.round(t)+.5,l=Math.round(e)+.5;n.beginPath(),n.moveTo(o,0),n.lineTo(o,r.height),n.moveTo(0,l),n.lineTo(r.width,l),n.stroke(),n.setLineDash([])}const xs=3,Ss=8,ui=900,ws=24,Ms=11,Cs=10,ks=18;function Ts(s){const{state:t}=s;if(t==="idle"||t==="has-more")return;const e=s.timeScale.timeToX(s.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){Rs(s,e);return}t==="no-data"&&Ls(s,e)}}function Rs({scope:s,theme:t,chartMediaHeight:e,side:i,now:n},r){const{context:a,horizontalPixelRatio:o,verticalPixelRatio:l}=s,d=xs*o,c=Ss*o,u=ws*o,f=r*o,m=i==="right"?f+u:f-u,p=e/2*l,g=n%ui/ui,y=Math.floor(g*3),v=Di(t.axis.textColor??"#787b86",.3),x=t.axis.textColor??"#787b86";a.save();for(let S=0;S<3;S++){const k=(S-1)*c,C=m+k;a.beginPath(),a.arc(C,p,d,0,Math.PI*2),a.fillStyle=S===y?x:v,a.fill()}a.restore()}function Ls({scope:s,theme:t,chartMediaHeight:e,side:i},n){const{context:r,horizontalPixelRatio:a,verticalPixelRatio:o}=s,l=Math.round(n*a)+.5;r.save(),r.strokeStyle=Di(t.axis.textColor??"#787b86",.6),r.lineWidth=1,r.setLineDash([4*a,4*a]),r.beginPath(),r.moveTo(l,0),r.lineTo(l,e*o),r.stroke(),r.setLineDash([]);const d=Cs*a,c=i==="right"?l-d:l+d,u=ks*o;r.fillStyle=t.axis.textColor??"#787b86",r.font=`${Ms*a}px ${t.typography.fontFamily}`,r.textAlign=i==="right"?"right":"left",r.textBaseline="top",r.fillText("No more data",c,u),r.restore()}function Di(s,t){const e=/^#([0-9a-f]{6})$/i.exec(s.trim());if(!e)return s;const i=parseInt(e[1].slice(0,2),16),n=parseInt(e[1].slice(2,4),16),r=parseInt(e[1].slice(4,6),16);return`rgba(${i}, ${n}, ${r}, ${t})`}function Is(s,t,e,i,n){const{context:r,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=s;r.strokeStyle=i.grid.color,r.lineWidth=1,i.grid.style==="dashed"?r.setLineDash([4*o,4*o]):i.grid.style==="dotted"&&r.setLineDash([1*o,3*o]);const d=e.niceTickValues();r.beginPath();for(const u of d){const f=Math.round(e.valueToBitmapY(u))+.5;r.moveTo(0,f),r.lineTo(a.width,f)}r.stroke();const{ticks:c}=t.niceTickValues(n);r.beginPath();for(const u of c){const f=Math.round(t.timeToBitmapX(u))+.5;r.moveTo(f,0),r.lineTo(f,a.height)}r.stroke(),r.setLineDash([])}function qt(s,t,e){return Math.max(t,Math.min(e,s))}function ut(s,t,e){return s+(t-s)*e}function Ft(s,t,e,i){const n=Math.exp(-e*i);return t+(s-t)*n}function zi(s){return 1-(1-s)**3}function Pe(s,t,e){let i=0,n=s.length-1;for(;i<=n;){const r=i+n>>>1,a=e(s[r]);if(a<t)i=r+1;else if(a>t)n=r-1;else return r}return i}class Bi extends me{constructor(){super(...arguments),w(this,"data",[]),w(this,"_visible",!0),w(this,"cachedRange",null),w(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let i=1;i<t.length;i++)if(t[i].time<t[i-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((i,n)=>i.time-n.time),this.cachedRange=null,this.emit("update")}append(t){if(this.data.length>0&&t.time<=this.data[this.data.length-1].time){this.updateLast(t);return}this.data.push(t),this.cachedRange=null,this.emit("update")}updateLast(t){this.data.length!==0&&(this.data[this.data.length-1]=t,this.cachedRange=null,this.emit("update"))}getAll(){return this.data}getVisibleData(t,e){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===e)return this.cachedResult;const i=Math.max(0,Pe(this.data,t,r=>r.time)-1),n=Math.min(this.data.length,Pe(this.data,e,r=>r.time)+1);return this.cachedResult=this.data.slice(i,n),this.cachedRange={from:t,to:e},this.cachedResult}first(){return this.data[0]}last(){return this.data[this.data.length-1]}get length(){return this.data.length}isEmpty(){return this.data.length===0}findNearest(t,e){if(this.data.length===0)return null;const i=Pe(this.data,t,a=>a.time);let n=null,r=e;for(let a=Math.max(0,i-1);a<=Math.min(this.data.length-1,i+1);a++){const o=Math.abs(this.data[a].time-t);o<=r&&(r=o,n=this.data[a])}return n}}class Ds{constructor(t,e,i){w(this,"dragging",!1),w(this,"lastX",0),this.viewport=t,this.timeScale=e,this.canvas=i}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const e=t.clientX-this.lastX;this.lastX=t.clientX;const i=this.timeScale.pixelDeltaToTimeDelta(-e);this.viewport.pan(i,this.timeScale.getMediaWidth())}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair",this.viewport.startRebound(this.timeScale.getMediaWidth()))}isDragging(){return this.dragging}}const zs=150;class Bs{constructor(t,e){w(this,"reboundTimer",null),this.viewport=t,this.timeScale=e}handleWheel(t){t.preventDefault();const e=Ps(t.deltaY,t.deltaMode),i=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),r=Math.min(t.offsetX,n),a=this.timeScale.xToTime(r);this.viewport.zoomAt(a,i,n),this.reboundTimer!==null&&clearTimeout(this.reboundTimer),this.reboundTimer=setTimeout(()=>{this.reboundTimer=null,this.viewport.startRebound(n)},zs)}cancelPendingRebound(){this.reboundTimer!==null&&(clearTimeout(this.reboundTimer),this.reboundTimer=null)}}function Ps(s,t){return t===WheelEvent.DOM_DELTA_LINE?s*8:t===WheelEvent.DOM_DELTA_PAGE?s*24:s}class As extends me{constructor(t,e,i,n){super(),w(this,"zoom"),w(this,"pan"),w(this,"canvas"),w(this,"timeScale"),w(this,"yScale"),w(this,"viewport"),w(this,"onWheel",r=>{this.zoom.handleWheel(r)}),w(this,"onMouseDown",r=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(r)}),w(this,"onMouseMove",r=>{this.pan.isDragging()&&this.pan.handleMouseMove(r),this.emitCrosshair(r.offsetX,r.offsetY)}),w(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),w(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),w(this,"onDblClick",()=>{}),w(this,"lastTouchDist",0),w(this,"lastTouchCenter",0),w(this,"touchCount",0),w(this,"onTouchStart",r=>{r.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=r.touches.length,r.touches.length===1?this.pan.handleMouseDown({button:0,clientX:r.touches[0].clientX}):r.touches.length===2&&(this.lastTouchDist=Math.abs(r.touches[0].clientX-r.touches[1].clientX),this.lastTouchCenter=(r.touches[0].clientX+r.touches[1].clientX)/2)}),w(this,"onTouchMove",r=>{if(r.preventDefault(),r.touches.length===1&&this.touchCount===1){this.pan.handleMouseMove({clientX:r.touches[0].clientX});const a=this.canvas.getBoundingClientRect();this.emitCrosshair(r.touches[0].clientX-a.left,r.touches[0].clientY-a.top)}else if(r.touches.length===2){const a=Math.abs(r.touches[0].clientX-r.touches[1].clientX),o=(r.touches[0].clientX+r.touches[1].clientX)/2,l=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const d=this.lastTouchDist/a,c=this.timeScale.xToTime(o-l.left);this.viewport.zoomAt(c,d,this.timeScale.getMediaWidth())}this.lastTouchDist=a,this.lastTouchCenter=o}}),w(this,"onTouchEnd",r=>{if(r.touches.length===0){const a=this.touchCount===2;this.pan.handleMouseUp(),a&&this.viewport.startRebound(this.timeScale.getMediaWidth()),this.touchCount=0,this.lastTouchDist=0}}),this.canvas=t,this.viewport=e,this.timeScale=i,this.yScale=n,this.zoom=new Bs(e,i),this.pan=new Ds(e,i,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd)}emitCrosshair(t,e){const i=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:i,y:n})}destroy(){this.zoom.cancelPendingRebound(),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("mousedown",this.onMouseDown),this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseup",this.onMouseUp),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("touchstart",this.onTouchStart),this.canvas.removeEventListener("touchmove",this.onTouchMove),this.canvas.removeEventListener("touchend",this.onTouchEnd),this.removeAllListeners()}}const Fs=new WeakMap;function Ws(s,t){Fs.set(s,t)}const Es=100,Vs={position:"absolute",top:"4px",right:"4px",padding:"4px 6px",background:"rgba(0, 0, 0, 0.6)",color:"#e0e0e0",font:"11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace",borderRadius:"3px",pointerEvents:"none",zIndex:"20",whiteSpace:"pre",letterSpacing:"0.01em"};function di(s){let t=0;for(const e of Object.values(s))t+=e;return t}const fe=9,Ne=7,St=6,Ue=9;function Ys(s,t){return Math.round(s*t).toLocaleString("en-US")}function fi(s,t,e,i,n){return[s.padEnd(fe),t.toFixed(1).padStart(Ne),e.toFixed(2).padStart(St),i.toFixed(2).padStart(St),Ys(n,t).padStart(Ue)].join(" ")}function mi(s){return[s.padEnd(fe),"—".padStart(Ne),"—".padStart(St),"—".padStart(St),"idle".padStart(Ue)].join(" ")}function js(){return["".padEnd(fe),"FPS".padStart(Ne),"ms".padStart(St),"worst".padStart(St),"calls/s".padStart(Ue)].join(" ")}function Hs(s){const t=di(s.drawCalls.main),e=di(s.drawCalls.overlay),i=s.frameCount.main===0?mi("Main"):fi("Main",s.mainRendersPerSec,s.mainFrameMs.last,s.mainFrameMs.p95,t),n=s.frameCount.overlay===0?mi("Overlay"):fi("Overlay",s.overlayRendersPerSec,s.overlayFrameMs.last,s.overlayFrameMs.p95,e),r=[js(),i,n],a=Object.keys(s.perSeries);if(a.length>1){r.push(""),r.push("Per series (main pass)"),r.push(["".padEnd(fe),"ms".padStart(St),"worst".padStart(St)].join(" "));for(const o of a){const l=s.perSeries[o];r.push([` ${o}`.padEnd(fe),l.last.toFixed(2).padStart(St),l.p95.toFixed(2).padStart(St)].join(" "))}}return r.join(`
2
+ `)}class Os{constructor(t,e,i=Es){w(this,"element"),w(this,"unsubscribe"),w(this,"updateIntervalMs"),w(this,"lastUpdate",0),this.updateIntervalMs=i;for(const n of t.querySelectorAll("[data-chart-perf-hud]"))n.remove();this.element=document.createElement("div"),this.element.setAttribute("data-chart-perf-hud",""),Object.assign(this.element.style,Vs),this.element.textContent="perf: waiting for first frame…",t.appendChild(this.element),this.unsubscribe=e.onFrame(n=>this.onFrame(n))}destroy(){this.unsubscribe(),this.element.remove()}onFrame(t){const e=performance.now();e-this.lastUpdate<this.updateIntervalMs||(this.lastUpdate=e,this.element.textContent=Hs(t))}}const _s=5e3,$s=2e3,Xs=30;function Ae(s,t,e){let i=0;for(;i<t.length&&t[i]<e;)i++;i>0&&(s.splice(0,i),t.splice(0,i))}function Fe(s,t,e){const i=s.length-e;i>0&&(s.splice(0,i),t.splice(0,i))}function We(s){if(s.length===0)return{last:0,p50:0,p95:0};const t=[...s].sort((e,i)=>e-i);return{last:s[s.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function gi(s){if(s.length<2)return 0;const t=s[s.length-1]-s[0];return t<=0?0:(s.length-1)*1e3/t}function pi(s){const t={};for(const[e,i]of s)t[e]=i;return t}class Ee{constructor(t={}){w(this,"drawCallsMain",new Map),w(this,"drawCallsOverlay",new Map),w(this,"mainMs",[]),w(this,"overlayMs",[]),w(this,"mainStamps",[]),w(this,"overlayStamps",[]),w(this,"perSeriesMs",new Map),w(this,"perSeriesStamps",new Map),w(this,"listeners",new Set),w(this,"windowMs"),w(this,"maxSamples"),w(this,"heapInterval"),w(this,"heapCounter",0),w(this,"heapMb",null),w(this,"mainFrameCount",0),w(this,"overlayFrameCount",0),w(this,"lastStamp",0),this.windowMs=t.windowMs??_s,this.maxSamples=t.maxSamples??$s,this.heapInterval=t.heapSampleEveryNFrames??Xs}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,i){if(this.lastStamp=i,t==="main"?(this.mainMs.push(e),this.mainStamps.push(i),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(i),this.overlayFrameCount++),this.trimAll(i),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,i=this.lastStamp){let n=this.perSeriesMs.get(t),r=this.perSeriesStamps.get(t);(!n||!r)&&(n=[],r=[],this.perSeriesMs.set(t,n),this.perSeriesStamps.set(t,r)),n.push(e),r.push(i)}trimAll(t){const e=t-this.windowMs;Ae(this.mainMs,this.mainStamps,e),Ae(this.overlayMs,this.overlayStamps,e),Fe(this.mainMs,this.mainStamps,this.maxSamples),Fe(this.overlayMs,this.overlayStamps,this.maxSamples);for(const i of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(i),r=this.perSeriesStamps.get(i);!n||!r||(Ae(n,r,e),Fe(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[i,n]of this.perSeriesMs)t[i]=We(n);const e=gi(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:gi(this.overlayStamps),fps:e,mainFrameMs:We(this.mainMs),overlayFrameMs:We(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:pi(this.drawCallsMain),overlay:pi(this.drawCallsOverlay)},perSeries:t,heapMb:this.heapMb}}destroy(){this.listeners.clear(),this.mainMs.length=0,this.overlayMs.length=0,this.mainStamps.length=0,this.overlayStamps.length=0,this.perSeriesMs.clear(),this.perSeriesStamps.clear(),this.drawCallsMain.clear(),this.drawCallsOverlay.clear(),this.mainFrameCount=0,this.overlayFrameCount=0,this.lastStamp=0,this.heapCounter=0,this.heapMb=null}sampleHeap(){if(this.heapCounter++,this.heapCounter<this.heapInterval)return;this.heapCounter=0;const t=performance.memory;this.heapMb=t?t.usedJSHeapSize/(1024*1024):null}}class ye{constructor(t){w(this,"dirty",!1),w(this,"rafId",null),w(this,"callback"),w(this,"render",e=>{this.dirty=!1,this.rafId=null,this.callback(e)}),this.callback=t}markDirty(){this.dirty||(this.dirty=!0,this.rafId=requestAnimationFrame(this.render))}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.dirty=!1}}const _t=6e4,Vt=36e5,Bt=864e5;function ot(s){return s instanceof Date?s.getTime():s}function Ns(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ot(t.time)}))}function Us(s){return s.length===0||!s.some(t=>t.time instanceof Date)?s:s.map(t=>({...t,time:ot(t.time)}))}function Pi(s){if(s.length<2)return Bt;const t=[];for(let e=1;e<Math.min(s.length,20);e++)t.push(s[e]-s[e-1]);return t.sort((e,i)=>e-i),t[Math.floor(t.length/2)]}function ge(s,t){const e=new Date(s);return t>=Bt?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=Vt?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Ai(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Gs(s){const t=[1e3,5e3,1e4,15e3,3e4],e=[_t,5*_t,10*_t,15*_t,30*_t],i=[Vt,2*Vt,4*Vt,6*Vt,12*Vt],n=[Bt,7*Bt,30*Bt,90*Bt,365*Bt];return s<_t?[...t,...e,...i,...n]:s<Vt?[...e,...i,...n]:s<Bt?[...i,...n]:n}const Ks=50,qs=80;class Js{constructor(){w(this,"from",0),w(this,"to",0),w(this,"width",1),w(this,"pixelRatio",1),w(this,"dataInterval",null),w(this,"labelCountHintValue",null),w(this,"minSpacingValue",null),w(this,"resolvedInterval",null),w(this,"lastInterval",null),w(this,"lastWant",null),w(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??qs}update(t,e,i,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=i,n!==void 0&&n>0){const r=bi(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Qs(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Zs(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastWant=null}timeToX(t){return this.to<=this.from?0:(t-this.from)/(this.to-this.from)*this.width}timeToBitmapX(t){return Math.round(this.timeToX(t)*this.pixelRatio)}xToTime(t){return this.to<=this.from?this.from:this.from+t/this.width*(this.to-this.from)}pixelDeltaToTimeDelta(t){return this.to<=this.from?0:t/this.width*(this.to-this.from)}barWidthMedia(t){return this.to<=this.from?0:t/(this.to-this.from)*this.width}barWidthBitmap(t){return Math.max(1,Math.round(this.barWidthMedia(t)*this.pixelRatio))}niceTickValues(t){if(this.to<=this.from)return{ticks:[],tickInterval:0};if(this.dataInterval!==t){const a=bi(t);this.lastBucketKey!==null&&this.lastBucketKey!==a&&this.resetHysteresis(),this.lastBucketKey=a,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,i=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(Ks,Math.floor((this.to-i)/e)+1)),r=[];for(let a=0;a<n;a++)r.push(i+a*e);return{ticks:r,tickInterval:e}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}resolveInterval(){if(this.to<=this.from||this.width<=0||this.dataInterval==null||this.dataInterval<=0){this.resolvedInterval=null;return}const t=Gs(this.dataInterval),e=this.to-this.from,i=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const o=Math.max(1,this.labelCountHint);n=Math.max(e/o,i)}else n=i;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const o=n>=this.lastWant*.8&&n<=this.lastWant*1.25,l=this.lastInterval>=i;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],a=t.length-1;for(let o=0;o<t.length;o++)if(t[o]>=n){r=t[o],a=o;break}if(this.labelCountHint!=null&&a>0&&this.countTicks(r)<this.labelCountHint){const o=t[a-1];o>=i&&(r=o)}this.resolvedInterval=r,this.lastInterval=r,this.lastWant=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.from/t)*t;return Math.max(0,Math.floor((this.to-e)/t)+1)}}function bi(s){return s<6e4?0:s<36e5?1:s<864e5?2:3}function Qs(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function Zs(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Fi(s){const t=Math.abs(s);if(t===0)return"0";if(t<1e-12)return s.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),i=Math.min(12,e+4),n=s.toFixed(i);return n.includes(".")?n.replace(/\.?0+$/,""):n}function Wi(s){return Number.isNaN(s)?"—":s===1/0?"∞":s===-1/0?"−∞":null}function Et(s,t){const e=Wi(s);if(e!==null)return e;const i=Math.abs(s),n=(t==null?void 0:t.decimals)??2,r=(a,o,l)=>{const d=a/o,c=Number.parseFloat(d.toFixed(n));return Math.abs(c)>=1e3?null:`${d.toFixed(n)}${l}`};return i>=1e15?s.toExponential(2):i>=1e12?r(s,1e12,"T")??s.toExponential(2):i>=1e9?r(s,1e9,"B")??`${(s/1e12).toFixed(n)}T`:i>=1e6?r(s,1e6,"M")??`${(s/1e9).toFixed(n)}B`:i>=1e3?r(s,1e3,"K")??`${(s/1e6).toFixed(n)}M`:i<1?Fi(s):i<100?s.toFixed(2):s.toFixed(0)}function Ge(s){const t=Wi(s);if(t!==null)return t;const e=Math.abs(s);return e===0?"0":e<1?Fi(s):e<100?s.toFixed(4):e>=1e7?Et(s):e<1e4?s.toFixed(2):s.toFixed(0)}function tn(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function en(s){if(!Number.isFinite(s)||s<=0)return 1;const t=10**Math.floor(Math.log10(s)),e=s/t;return(e>=5?5:e>=2?2:1)*t}const sn=50,nn=50;class rn{constructor(){w(this,"min",0),w(this,"max",0),w(this,"height",1),w(this,"pixelRatio",1),w(this,"labelCountHintValue",null),w(this,"minSpacingValue",null),w(this,"resolvedInterval",null),w(this,"lastInterval",null),w(this,"lastRawInterval",null),w(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??nn}update(t,e,i){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=i,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=an(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=on(t),this.resetHysteresis(),this.resolveInterval()}resetHysteresis(){this.lastInterval=null,this.lastRawInterval=null}setFormat(t){this.customFormat=t}getFormat(){return this.customFormat}valueToY(t){const e=this.max-this.min;return e===0?this.height/2:(1-(t-this.min)/e)*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){const e=this.max-this.min;return e===0?this.min:this.max-t/this.height*e}niceTickValues(){if(this.resolvedInterval==null)return[];const t=this.resolvedInterval,e=Math.ceil(this.min/t)*t,i=Math.max(0,Math.min(sn,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<i;r++)n.push(e+r*t);return n}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){if(this.customFormat)return this.customFormat(t);if(this.max-this.min>=1e6)return Et(t);const e=this.resolvedInterval,i=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(i)}resolveInterval(){if(this.max<=this.min||this.height<=0){this.resolvedInterval=null;return}const t=this.max-this.min,e=t*this.minLabelSpacing/this.height,i=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/i;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const a=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,o=this.lastInterval>=e;if(a&&o){this.resolvedInterval=this.lastInterval;return}}let r=tn(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const a=en(n);a>=e&&a>0&&(r=a)}this.resolvedInterval=r,this.lastInterval=r,this.lastRawInterval=n}countTicks(t){if(!(t>0))return 0;const e=Math.ceil(this.min/t)*t;return Math.max(0,Math.floor((this.max-e)/t)+1)}}function an(s){return typeof s=="number"&&Number.isFinite(s)&&s>=2?Math.floor(s):null}function on(s){return typeof s=="number"&&Number.isFinite(s)&&s>0?s:null}function Wt(s,t){return s===!1?0:s===void 0?t:s}function $t(s,t){const e=Math.max(1e-4,Math.abs(t)*1e-5);return Math.abs(s-t)>e}function ln(s,t,e,i){const n=s==null?void 0:s.get(t);if(!n)return 1;if(i<=0)return s==null||s.delete(t),1;const r=qt((e-n.startTime)/i,0,1),a=zi(r);return r>=1&&(s==null||s.delete(t)),a}function hn(s){let t=0,e=0;for(const i of s)i>0?t+=i:i<0&&(e+=i);return{positive:t,negative:e}}function cn(s){return s.positive>0?s.positive:s.negative<0?s.negative:0}function un(s){return s.positive>0?100:s.negative<0?-100:0}class Ei{constructor(t){w(this,"stores"),w(this,"displayedLastValues"),w(this,"lastSeededTimes"),w(this,"entries"),w(this,"lastRenderTime",0),this.stores=Array.from({length:t},()=>new Bi),this.displayedLastValues=new Array(t).fill(null),this.lastSeededTimes=new Array(t).fill(Number.NaN),this.entries=Array.from({length:t},()=>new Map)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=Us(t??[]);n.setData(r),(i=this.entries[e])==null||i.clear()}appendPoint(t,e=0){var i;const n=this.stores[e];if(!n)return;const r=t,a=ot(r.time),o=this.createEntry(e,a,performance.now());n.append({...r,time:a}),o&&((i=this.entries[e])==null||i.set(a,o))}updateLastPoint(t,e=0){const i=this.stores[e];if(!i)return;const n=t;i.updateLast({...n,time:ot(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var i;(i=this.stores[t])==null||i.setVisible(e)}isLayerVisible(t){var e;return((e=this.stores[t])==null?void 0:e.isVisible())??!0}getLayerColors(){return this.getColors()}onDataChanged(t){for(const e of this.stores)e.on("update",t);return()=>{for(const e of this.stores)e.off("update",t)}}dispose(){for(const t of this.stores)t.removeAllListeners();for(const t of this.entries)t.clear();this.displayedLastValues=this.displayedLastValues.map(()=>null),this.lastSeededTimes=this.lastSeededTimes.map(()=>Number.NaN),this.lastRenderTime=0}cancelEntranceAnimations(){for(const t of this.entries)t.clear()}get needsAnimation(){for(const t of this.entries)if(t.size>0)return!0;for(let t=0;t<this.stores.length;t++){const e=this.displayedLastValues[t],i=this.stores[t].last();if(!(e==null||!i)&&this.lastSeededTimes[t]===i.time&&$t(e,i.value))return!0}return!1}advanceLiveTracking(t){if(t===this.lastRenderTime)return;const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=Wt(this.getCommonOptions().smoothMs,70),n=i>0?1e3/i:0;for(let r=0;r<this.stores.length;r++){const a=this.stores[r].last();if(!a){this.displayedLastValues[r]=null,this.lastSeededTimes[r]=Number.NaN;continue}const o=this.displayedLastValues[r],l=this.lastSeededTimes[r]!==a.time;if(o===null||l||n<=0){this.displayedLastValues[r]=a.value,this.lastSeededTimes[r]=a.time;continue}this.displayedLastValues[r]=Ft(o,a.value,n,e)}}entranceProgress(t,e,i){const n=Wt(this.getCommonOptions().entryMs,400);return ln(this.entries[t],e,i,n)}effectiveValue(t,e,i){const n=this.displayedLastValues[t];return n==null||this.lastSeededTimes[t]!==e?i:n}getLastValue(){for(let t=this.stores.length-1;t>=0;t--){const e=this.stores[t].last();if(e)return e.value}return null}getDataAtTime(t,e){var i;return((i=this.stores[0])==null?void 0:i.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const i=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const a=this.stores[r].getVisibleData(t-e,t+e);if(a.length===0)continue;let o=a[0],l=Math.abs(a[0].time-t);for(let d=1;d<a.length;d++){const c=Math.abs(a[d].time-t);c<=l&&(l=c,o=a[d])}n.push({layerIndex:r,time:o.time,value:o.value,color:i[r%i.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const a=(t=this.stores[0])==null?void 0:t.last();return a?{value:a.value,isLive:!0}:null}let e=-1/0;for(const a of this.stores){if(!a.isVisible())continue;const o=a.last();o&&o.time>e&&(e=o.time)}if(e===-1/0)return null;const i=this.getCommonOptions().stacking;if(i==="off"){for(let a=this.stores.length-1;a>=0;a--){if(!this.stores[a].isVisible())continue;const o=this.stores[a].last();if(o)return{value:o.value,isLive:!0}}return null}const n=[];for(const a of this.stores){if(!a.isVisible())continue;const o=a.last();n.push(o&&o.time===e?o.value:0)}const r=hn(n);return{value:i==="percent"?un(r):cn(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();n&&e.push({layerIndex:i,time:n.time,value:n.value,color:t[i%t.length]})}return e.length>0?e:null}getTotalLength(){let t=0;for(const e of this.stores)t+=e.length;return t}getValueRange(t,e){const i=this.getCommonOptions().stacking;if(i==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(l=>l.isVisible()?l.getVisibleData(t,e):[]);if(i==="off"){let l=1/0,d=-1/0;for(const c of n)for(const u of c)u.value<l&&(l=u.value),u.value>d&&(d=u.value);return l<1/0?{min:l,max:d}:null}const r=new Map;for(let l=0;l<n.length;l++)for(const d of n[l]){let c=r.get(d.time);c||(c=new Array(n.length).fill(0),r.set(d.time,c)),c[l]=d.value}let a=0,o=0;for(const l of r.values()){let d=0,c=0;for(const u of l)u>0?d+=u:c+=u;d>o&&(o=d),c<a&&(a=c)}return o>a?{min:a,max:o}:null}}const dn={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function yi(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class fn extends Ei{constructor(t,e){super(t),w(this,"options"),this.options={...dn,...yi(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...yi(t)}}getCommonOptions(){return this.options}createEntry(t,e,i){const n=this.options.entryAnimation??"fade-grow",r=Wt(this.options.entryMs,400);return n==="none"||r<=0?null:{startTime:i}}applyTheme(t,e){this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)})}applyBarTransform(t,e,i,n,r,a){const o=this.options.entryAnimation??"fade-grow";if(t>=1||o==="none")return{topY:i,barHeight:n,x:r,barWidth:a,alpha:1};let l=i,d=n,c=r,u=1;if((o==="fade"||o==="fade-grow")&&(u=t),o==="grow"||o==="fade-grow"){const f=n*t;i<e?l=e-f:l=e,d=Math.max(1,f)}return o==="slide"&&(c=r+(1-t)*a,u=t),{topY:l,barHeight:d,x:c,barWidth:a,alpha:u}}render(t){switch(this.advanceLiveTracking(performance.now()),this.options.stacking){case"normal":this.renderStacked(t,!1);break;case"percent":this.renderStacked(t,!0);break;default:this.renderOff(t);break}}renderOff(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a}=e,o=i.getRange(),l=performance.now(),d=i.barWidthBitmap(r),c=Math.max(1,Math.round(d*this.options.barWidthRatio)-2),u=Math.floor(c/2),f=n.getRange().min<0,m=f?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const p=this.options.colors[0],g=this.options.colors.length>1?this.options.colors[1]:p,y=this.stores[0].getVisibleData(o.from,o.to);for(const v of y){const x=this.effectiveValue(0,v.time,v.value),S=this.entranceProgress(0,v.time,l),k=i.timeToBitmapX(v.time);if(x>=0){const C=n.valueToBitmapY(x),I=Math.max(1,m-C);this.drawAnimatedBar(a,S,m,C,I,k-u,c,x>=0?p:g)}else{const C=n.valueToBitmapY(x),I=Math.max(1,C-m);this.drawAnimatedBar(a,S,m,m,I,k-u,c,g)}}}else{const p=this.stores.map(y=>y.isVisible()?y.getVisibleData(o.from,o.to):[]),g=new Map;for(let y=0;y<p.length;y++)for(const v of p[y]){let x=g.get(v.time);x||(x=[],g.set(v.time,x)),x.push({layer:y,value:this.effectiveValue(y,v.time,v.value)})}for(const[y,v]of g){v.sort((S,k)=>Math.abs(k.value)-Math.abs(S.value));const x=i.timeToBitmapX(y);for(const{layer:S,value:k}of v){const C=this.options.colors[S%this.options.colors.length],I=this.entranceProgress(S,y,l);if(k>=0){const b=n.valueToBitmapY(k),T=Math.max(1,m-b);this.drawAnimatedBar(a,I,m,b,T,x-u,c,C)}else{const b=n.valueToBitmapY(k),T=Math.max(1,b-m);this.drawAnimatedBar(a,I,m,m,T,x-u,c,C)}}}}if(f){a.strokeStyle=t.theme.grid.color,a.lineWidth=1;const p=Math.round(m)+.5;a.beginPath(),a.moveTo(0,p),a.lineTo(e.bitmapSize.width,p),a.stroke()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r,dataInterval:a}=t,{context:o}=i,l=n.getRange(),d=performance.now(),c=n.barWidthBitmap(a),u=Math.max(1,Math.round(c*this.options.barWidthRatio)-2),f=Math.floor(u/2),m=this.stores.map(g=>g.isVisible()?g.getVisibleData(l.from,l.to):[]);if(m.every(g=>g.length===0))return;const p=new Map;for(let g=0;g<m.length;g++)for(const y of m[g]){let v=p.get(y.time);v||(v=new Array(m.length).fill(0),p.set(y.time,v)),v[g]=this.stores[g].isVisible()?this.effectiveValue(g,y.time,y.value):0}for(let g=0;g<m.length;g++){const y=this.options.colors[g%this.options.colors.length];for(const[v,x]of p){const S=x[g];if(S===0)continue;const k=n.timeToBitmapX(v);let C=0,I=0;for(let T=0;T<g;T++){const R=x[T];R>0?C+=R:I+=R}const b=this.entranceProgress(g,v,d);if(e){let T=0,R=0;for(const z of x)z>0?T+=z:R+=z;if(S>0&&T>0){const z=C/T*100,D=(C+S)/T*100,Y=r.valueToBitmapY(D),O=r.valueToBitmapY(z),V=Math.max(1,O-Y);this.drawAnimatedBar(o,b,O,Y,V,k-f,u,y)}else if(S<0&&R<0){const z=I/R*-100,D=(I+S)/R*-100,Y=r.valueToBitmapY(z),O=r.valueToBitmapY(D),V=Math.max(1,O-Y);this.drawAnimatedBar(o,b,Y,Y,V,k-f,u,y)}}else if(S>0){const T=r.valueToBitmapY(C+S),R=r.valueToBitmapY(C),z=Math.max(1,R-T);this.drawAnimatedBar(o,b,R,T,z,k-f,u,y)}else{const T=r.valueToBitmapY(I),R=r.valueToBitmapY(I+S),z=Math.max(1,R-T);this.drawAnimatedBar(o,b,T,T,z,k-f,u,y)}}}}fillBar(t,e,i,n,r,a){t.fillStyle=a,t.fillRect(e,i,n,r)}drawAnimatedBar(t,e,i,n,r,a,o,l){const d=this.options.entryAnimation??"fade-grow";if(e>=1||d==="none"){this.fillBar(t,a,n,o,r,l);return}const c=this.applyBarTransform(e,i,n,r,a,o);t.save(),t.globalAlpha=c.alpha,t.fillStyle=l,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function vi(s,t){return s.length<=t?s:gn(s,t,e=>e.time,e=>e.value)}function mn(s,t){if(s.length<=t)return s;const e=Math.ceil(s.length/t),i=[];for(let n=0;n<s.length;n+=e){const r=Math.min(n+e,s.length);let a=-1/0,o=1/0,l=0;for(let d=n;d<r;d++)s[d].high>a&&(a=s[d].high),s[d].low<o&&(o=s[d].low),l+=s[d].volume??0;i.push({time:s[n].time,open:s[n].open,high:a,low:o,close:s[r-1].close,volume:l})}return i}function gn(s,t,e,i){if(t>=s.length||t<3)return s;const n=[s[0]],r=(s.length-2)/(t-2);let a=0;for(let o=0;o<t-2;o++){const l=Math.floor((o+1)*r)+1,d=Math.min(Math.floor((o+2)*r)+1,s.length-1);let c=0,u=0;const f=d,m=Math.min(Math.floor((o+3)*r)+1,s.length),p=m-f;if(p>0){for(let S=f;S<m;S++)c+=e(s[S]),u+=i(s[S]);c/=p,u/=p}let g=-1,y=l;const v=e(s[a]),x=i(s[a]);for(let S=l;S<d;S++){const k=Math.abs((v-c)*(i(s[S])-x)-(v-e(s[S]))*(u-x));k>g&&(g=k,y=S)}n.push(s[y]),a=y}return n.push(s[s.length-1]),n}function Ke(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.fontSize)!==void 0?s.axis.x.fontSize:t==="y"&&((i=s.axis.y)==null?void 0:i.fontSize)!==void 0?s.axis.y.fontSize:s.axis.fontSize}function qe(s,t){var e,i;return t==="x"&&((e=s.axis.x)==null?void 0:e.textColor)!==void 0?s.axis.x.textColor:t==="y"&&((i=s.axis.y)==null?void 0:i.textColor)!==void 0?s.axis.y.textColor:s.axis.textColor}function gt(s){return Array.isArray(s)?s.source??s[0]:s}const xi=new Map;function pn(s){return[parseInt(s.slice(1,3),16),parseInt(s.slice(3,5),16),parseInt(s.slice(5,7),16)]}function Gt(s,t){if(s.startsWith("rgba"))return s.replace(/[\d.]+\)\s*$/,`${t})`);if(s.startsWith("rgb("))return s.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=s+t;let i=xi.get(e);if(i)return i;const[n,r,a]=pn(s);return i=`rgba(${n}, ${r}, ${a}, ${t})`,xi.set(e,i),i}const bn={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6};function Si(s){if(!s)return{};const t={...s};return s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class yn{constructor(t,e){w(this,"store"),w(this,"options"),w(this,"displayedLast",null),w(this,"lastSeededTime",Number.NaN),w(this,"lastRenderTime",0),w(this,"entries",new Map),this.store=t,this.options={...bn,...Si(e)}}updateOptions(t){this.options={...this.options,...Si(t)}}getColor(){return gt(this.options.up.body)}setData(t){this.store.setData(Ns(t??[])),this.entries.clear()}appendPoint(t){const e=t,i=ot(e.time);this.store.append({...e,time:i});const n=this.options.entryAnimation??"unfold",r=Wt(this.options.entryMs,400);n!=="none"&&r>0&&this.entries.set(i,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:ot(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[gt(this.options.up.body)]}applyTheme(t,e){this.updateOptions({up:{...t.candlestick.up},down:{...t.candlestick.down}})}onDataChanged(t){return this.store.on("update",t),()=>this.store.off("update",t)}dispose(){this.store.removeAllListeners(),this.displayedLast=null,this.lastSeededTime=Number.NaN,this.lastRenderTime=0,this.entries.clear()}getLastValue(){const t=this.store.last();return t?t.close:null}getDataAtTime(t,e){return this.store.findNearest(t,e)}cancelEntranceAnimations(){this.entries.clear()}get needsAnimation(){if(this.entries.size>0)return!0;if(!this.displayedLast)return!1;const t=this.store.last();if(!t||t.time!==this.displayedLast.time)return!1;if($t(this.displayedLast.open,t.open)||$t(this.displayedLast.high,t.high)||$t(this.displayedLast.low,t.low)||$t(this.displayedLast.close,t.close))return!0;const e=this.displayedLast.volume,i=t.volume;return e===void 0||i===void 0?!1:$t(e,i)}entranceProgress(t,e){const i=this.entries.get(t);if(!i)return 1;const n=Wt(this.options.entryMs,400);if(n<=0)return this.entries.delete(t),1;const r=qt((e-i.startTime)/n,0,1),a=zi(r);return r>=1&&this.entries.delete(t),a}advanceLiveTracking(t){const e=this.lastRenderTime?Math.min(.05,(t-this.lastRenderTime)/1e3):0;this.lastRenderTime=t;const i=this.store.last();if(!i){this.displayedLast=null,this.lastSeededTime=Number.NaN;return}const n=this.lastSeededTime!==i.time,r=Wt(this.options.smoothMs,70),a=r>0?1e3/r:0;if(this.displayedLast===null||n||a<=0){this.displayedLast={...i},this.lastSeededTime=i.time;return}const o=this.displayedLast,l=o.volume??0,d=i.volume??0;this.displayedLast={time:i.time,open:Ft(o.open,i.open,a,e),high:Ft(o.high,i.high,a,e),low:Ft(o.low,i.low,a,e),close:Ft(o.close,i.close,a,e),volume:i.volume===void 0?void 0:Ft(l,d,a,e)}}render(t){const{scope:e,timeScale:i,yScale:n,dataInterval:r}=t,{context:a,horizontalPixelRatio:o}=e,l=i.getRange(),d=performance.now();this.advanceLiveTracking(d);let c=this.store.getVisibleData(l.from,l.to);const u=e.mediaSize.width,f=c.length>u*2;if(f&&(c=mn(c,Math.round(u*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const I=c.length-1;c[I].time===this.displayedLast.time&&(c=[...c.slice(0,I),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const I of c)this.entries.has(I.time)&&m.set(I.time,this.entranceProgress(I.time,d));const p=i.barWidthBitmap(r),g=Math.max(1,Math.round(p*this.options.bodyWidthRatio)-2),y=Math.floor(g/2),v=Math.max(1,Math.round(o)),x=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:a,data:c,timeScale:i,chartHeight:x,barWidth:p,entranceByTime:m});const S=[],k=[];for(const I of c)I.close>=I.open?S.push(I):k.push(I);const C={ctx:a,timeScale:i,yScale:n,halfBody:y,bodyWidth:g,wickWidth:v,entranceByTime:m};this.drawCandles({...C,candles:S,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...C,candles:k,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:i,chartHeight:n,barWidth:r,entranceByTime:a}){let o=0;for(const p of e)p.volume!==void 0&&p.volume>o&&(o=p.volume);if(o===0)return;const l=n*.2,d=Math.max(1,r-2),c=Math.floor(d/2),u=Gt(gt(this.options.up.body),.2),f=Gt(gt(this.options.down.body),.2),m=this.options.entryAnimation??"unfold";for(const p of e){if(p.volume===void 0||p.volume===0)continue;const g=i.timeToBitmapX(p.time),y=Math.max(1,p.volume/o*l),v=p.close>=p.open;t.fillStyle=v?u:f;const x=(a==null?void 0:a.get(p.time))??1;if(x>=1||m==="none"){t.fillRect(g-c,n-y,d,y);continue}const S=Ve(x,m,{x:g-c,barWidth:d,anchorY:n,topY:n-y,bottomY:n});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,d,Math.max(1,S.bottomY-S.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:i,yScale:n,halfBody:r,bodyWidth:a,wickWidth:o,body:l,wickColor:d,entranceByTime:c}){if(e.length===0)return;const u=this.options.entryAnimation??"unfold",f=a+2;t.fillStyle=d;for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,y=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),x=n.valueToBitmapY(p.high),S=n.valueToBitmapY(p.low),k=y-Math.floor(o/2);if(g>=1||u==="none"){t.fillRect(k,x,o,S-x);continue}const C=Ve(g,u,{x:k,barWidth:f,anchorY:v,topY:x,bottomY:S});t.save(),t.globalAlpha=C.alpha,t.fillRect(C.x,C.topY,o,Math.max(1,C.bottomY-C.topY)),t.restore()}const m=Array.isArray(l);for(const p of e){const g=(c==null?void 0:c.get(p.time))??1,y=i.timeToBitmapX(p.time),v=n.valueToBitmapY(p.open),x=n.valueToBitmapY(p.close),S=Math.min(v,x),k=Math.max(v,x),C=Math.max(1,k-S),I=g<1&&u!=="none";let b=y-r,T=S,R=C,z=1;if(I){const D=Ve(g,u,{x:y-r,barWidth:f,anchorY:v,topY:S,bottomY:k});b=D.x,T=D.topY,R=Math.max(1,D.bottomY-D.topY),z=D.alpha}if(I&&t.save(),m&&R>2){const D=t.createLinearGradient(0,T,0,T+R);D.addColorStop(0,l[0]),D.addColorStop(1,l[1]),t.fillStyle=D}else t.fillStyle=m?l[0]:l;I&&(t.globalAlpha=z),t.fillRect(b,T,a,R),I&&t.restore()}}}function Ve(s,t,e){switch(t){case"none":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:1};case"fade":return{x:e.x,topY:e.topY,bottomY:e.bottomY,alpha:s};case"unfold":return{x:e.x,topY:ut(e.anchorY,e.topY,s),bottomY:ut(e.anchorY,e.bottomY,s),alpha:1};case"slide":return{x:e.x+(1-s)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:s};case"fade-unfold":return{x:e.x,topY:ut(e.anchorY,e.topY,s),bottomY:ut(e.anchorY,e.bottomY,s),alpha:s}}}const vn={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function wi(s){if(!s)return{};const t={...s};return s.areaFill!==void 0&&s.area===void 0&&(t.area={visible:!!s.areaFill}),s.enterAnimation!==void 0&&s.entryAnimation===void 0&&(t.entryAnimation=s.enterAnimation),s.enterMs!==void 0&&s.entryMs===void 0&&(t.entryMs=s.enterMs),t}class xn extends Ei{constructor(t,e){super(t),w(this,"options"),w(this,"areaGradientCache",new Map),this.options={...vn,...wi(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...wi(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,i){var n;const r=this.options.entryAnimation??"grow",a=Wt(this.options.entryMs,400);if(r==="none"||a<=0)return null;const o=(n=this.stores[t])==null?void 0:n.last();return{startTime:i,fromTime:o?o.time:e}}applyTheme(t,e){this.stores.length===1?this.getColor()===e.line.color&&this.updateOptions({colors:[t.line.color]}):this.updateOptions({colors:t.seriesColors.slice(0,this.stores.length)}),this.options.strokeWidth===e.line.width&&this.updateOptions({strokeWidth:t.line.width})}peekEntry(t,e){var i;return(i=this.entries[t])==null?void 0:i.get(e)}resolvedPulseMs(){return Wt(this.options.pulseMs,600)}get hasPulse(){return this.options.pulse&&this.resolvedPulseMs()>0&&this.stores.some(t=>t.isVisible()&&t.length>0)}get overlayNeedsAnimation(){return this.hasPulse}hasOverlayContentInRange(t,e){for(let i=0;i<this.stores.length;i++){if(!this.stores[i].isVisible())continue;const n=this.stores[i].last();if(n&&n.time>=t)return!0}return!1}render(t){this.advanceLiveTracking(performance.now()),this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}trailingEndpoint(t,e,i,n){const r=this.stores[t],a=r.last();if(!a)return null;const o=e.timeToBitmapX(a.time),l=i.valueToBitmapY(this.effectiveValue(t,a.time,a.value)),d=this.options.entryAnimation??"grow";if(!this.peekEntry(t,a.time)||d!=="grow")return{x:o,y:l};const c=this.entranceProgress(t,a.time,n);if(c>=1)return{x:o,y:l};const u=r.getAll();if(u.length<2)return{x:o,y:l};const f=u[u.length-2],m=e.timeToBitmapX(f.time),p=i.valueToBitmapY(f.value);return{x:ut(m,o,c),y:ut(p,l,c)}}renderOff(t){const{scope:e,timeScale:i,yScale:n}=t,{context:r}=e,a=i.getRange(),{verticalPixelRatio:o}=e,l=this.options.strokeWidth>0,d=Math.max(1,Math.round(this.options.strokeWidth*o)),c=performance.now(),u=this.options.entryAnimation??"grow";for(let f=0;f<this.stores.length;f++){if(!this.stores[f].isVisible())continue;let m=this.stores[f].getVisibleData(a.from,a.to);const p=e.mediaSize.width;if(m.length>p*2&&(m=vi(m,Math.round(p*1.5))),m.length<2)continue;const g=this.options.colors[f%this.options.colors.length],y=m[m.length-1],v=this.peekEntry(f,y.time),x=this.entranceProgress(f,y.time,c),S=v&&u==="fade"&&x<1,k=this.trailingEndpoint(f,i,n,c)??{x:i.timeToBitmapX(y.time),y:n.valueToBitmapY(this.effectiveValue(f,y.time,y.value))},C=k.x,I=k.y;S&&(r.save(),r.globalAlpha=x),r.beginPath(),r.moveTo(i.timeToBitmapX(m[0].time),n.valueToBitmapY(m[0].value));for(let b=1;b<m.length-1;b++)r.lineTo(i.timeToBitmapX(m[b].time),n.valueToBitmapY(m[b].value));if(r.lineTo(C,I),l&&(r.strokeStyle=g,r.lineWidth=d,r.lineJoin="round",r.lineCap="round",r.stroke()),this.options.area.visible){const b=i.timeToBitmapX(m[0].time),T=e.bitmapSize.height;r.lineTo(C,T),r.lineTo(b,T),r.closePath();const R=String(f),z=this.areaGradientCache.get(R);let D;z&&z.bottomY===T&&z.color===g?D=z.gradient:(D=r.createLinearGradient(0,0,0,T),D.addColorStop(0,Gt(g,.12)),D.addColorStop(1,Gt(g,.01)),this.areaGradientCache.set(R,{gradient:D,bottomY:T,color:g})),r.fillStyle=D,r.fill()}S&&r.restore()}}renderStacked(t,e){const{scope:i,timeScale:n,yScale:r}=t,{context:a}=i,o=n.getRange(),{verticalPixelRatio:l}=i,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*l)),u=i.mediaSize.width,f=this.stores.map(b=>{let T=b.getVisibleData(o.from,o.to);return T.length>u*2&&(T=vi(T,Math.round(u*1.5))),T}),m=new Set;for(const b of f)for(const T of b)m.add(T.time);const p=Array.from(m).sort((b,T)=>b-T);if(p.length<2)return;const g=f.map((b,T)=>{const R=new Map;for(const z of b)R.set(z.time,this.effectiveValue(T,z.time,z.value));return R}),y=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let b=0;b<p.length;b++){const T=p[b];let R=0;if(e)for(let D=0;D<this.stores.length;D++)this.stores[D].isVisible()&&(R+=g[D].get(T)??0);let z=0;for(let D=0;D<this.stores.length;D++){const Y=this.stores[D].isVisible()?g[D].get(T)??0:0;z+=e&&R>0?Y/R*100:Y,y[D][b]=z}}const v=performance.now(),x=this.options.entryAnimation??"grow",S=new Map;for(let b=0;b<p.length;b++)S.set(p[b],b);const k=p.length-1,C=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const T=this.stores[b].last();if(!T)continue;const R=this.peekEntry(b,T.time);if(!R)continue;const z=S.get(T.time);z!==k||S.get(R.fromTime)!==z-1||(C[b]=this.entranceProgress(b,T.time,v))}const I=(b,T)=>{if(T>=1||b.length<2)return;const R=b.length-1,z=b[R-1],D=b[R];b[R]=[ut(z[0],D[0],T),ut(z[1],D[1],T)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const T=this.options.colors[b%this.options.colors.length],R=C[b],z=b>0&&this.stores[b-1].isVisible()?C[b-1]:1,D=[];for(let V=0;V<p.length;V++)D.push([n.timeToBitmapX(p[V]),r.valueToBitmapY(y[b][V])]);x==="grow"&&I(D,R);const Y=[];for(let V=0;V<p.length;V++){const W=b>0?y[b-1][V]:0;Y.push([n.timeToBitmapX(p[V]),r.valueToBitmapY(W)])}x==="grow"&&I(Y,z);const O=x==="fade"&&R<1;if(O&&(a.save(),a.globalAlpha=R),this.options.area.visible){a.beginPath(),a.moveTo(D[0][0],D[0][1]);for(let V=1;V<D.length;V++)a.lineTo(D[V][0],D[V][1]);for(let V=Y.length-1;V>=0;V--)a.lineTo(Y[V][0],Y[V][1]);a.closePath(),a.fillStyle=Gt(T,.25),a.fill()}if(d){a.beginPath(),a.moveTo(D[0][0],D[0][1]);for(let V=1;V<D.length;V++)a.lineTo(D[V][0],D[V][1]);a.strokeStyle=T,a.lineWidth=c,a.lineJoin="round",a.lineCap="round",a.stroke()}O&&a.restore()}}drawOverlay(t){const{scope:e,timeScale:i,yScale:n,crosshair:r,dataInterval:a}=t,o=e,l=this.resolvedPulseMs();if(r){const d=this.options.colors,c=this.options.stacking,u=4*o.horizontalPixelRatio,f=[],m=[];for(let g=0;g<this.stores.length;g++){const y=this.stores[g].findNearest(r.time,a);y?(f.push(y.value),m.push(y.time)):(f.push(0),m.push(null))}const p=[];if(c==="off")for(const g of f)p.push(g);else{let g=0;if(c==="percent")for(let v=0;v<f.length;v++)this.stores[v].isVisible()&&(g+=f[v]);let y=0;for(let v=0;v<f.length;v++){const x=this.stores[v].isVisible()?f[v]:0;y+=c==="percent"&&g>0?x/g*100:x,p.push(y)}}for(let g=0;g<this.stores.length;g++){const y=m[g];if(y===null||!this.stores[g].isVisible())continue;const v=d[g%d.length],x=i.timeToBitmapX(y),S=n.valueToBitmapY(p[g]);e.context.beginPath(),e.context.arc(x,S,u+3*o.horizontalPixelRatio,0,Math.PI*2);const k=v.startsWith("#")?v+"40":/^rgb\(/i.test(v)?v.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):v.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=k,e.context.fill(),e.context.beginPath(),e.context.arc(x,S,u,0,Math.PI*2),e.context.fillStyle=v,e.context.fill()}}if(this.hasPulse&&l>0){const d=performance.now();this.advanceLiveTracking(d);const c=this.options.stacking;for(let u=0;u<this.stores.length;u++){if(!this.stores[u].isVisible())continue;const f=this.options.colors[u%this.options.colors.length];if(c==="off"){const C=this.trailingEndpoint(u,i,n,d);if(!C)continue;this.drawPulse({ctx:e.context,x:C.x,y:C.y,color:f,pixelRatio:o.horizontalPixelRatio,pulseMs:l});continue}const m=this.stores[u].last();if(!m)continue;const p=m.time,g=c==="percent",y=C=>{const I=R=>{const z=R===u&&C===p?m:this.stores[R].findNearest(C,0);return!z||z.time!==C?0:this.effectiveValue(R,C,z.value)};let b=0;if(g)for(let R=0;R<this.stores.length;R++)this.stores[R].isVisible()&&(b+=I(R));let T=0;for(let R=0;R<=u;R++){if(!this.stores[R].isVisible())continue;const z=I(R);T+=g&&b>0?z/b*100:z}return T};let v=i.timeToBitmapX(p),x=n.valueToBitmapY(y(p));const S=this.options.entryAnimation??"grow",k=this.peekEntry(u,p);if(S==="grow"&&k){const C=this.entranceProgress(u,p,d);if(C<1&&k.fromTime!==p){const I=i.timeToBitmapX(k.fromTime),b=n.valueToBitmapY(y(k.fromTime));v=ut(I,v,C),x=ut(b,x,C)}}this.drawPulse({ctx:e.context,x:v,y:x,color:f,pixelRatio:o.horizontalPixelRatio,pulseMs:l})}}}drawPulse({ctx:t,x:e,y:i,color:n,pixelRatio:r,pulseMs:a}){const o=3*r,l=.4+.6*Math.abs(Math.sin(performance.now()/a)),d=o+4*r*l;t.beginPath(),t.arc(e,i,d,0,Math.PI*2),t.fillStyle=Gt(n,l*.3),t.fill(),t.beginPath(),t.arc(e,i,o,0,Math.PI*2),t.fillStyle=n,t.fill()}}const Vi={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},Sn={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...Vi},animate:!1},je=Math.PI/180;function wn(s,t){return{...s??{},...t}}function Mn(s){return{...Vi,...s??{}}}function Cn(s){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return s===!0||s===!1?t:{...t,...s}}function kn(s){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return s===!0||s===!1?t:{...t,...s}}const Kt=Math.PI*2,Yi=.85;function Mi(s){const{bitmapWidth:t,bitmapHeight:e,padTop:i,padBottom:n}=s,r=Math.max(0,s.labelReserve??0),a=Math.min(Math.max(0,i),e),o=Math.min(Math.max(0,n),e-a),l=e-a-o,d=Math.max(0,t-2*r),c=t/2,u=a+l/2,f=Math.max(0,Math.min(d,l)/2*Yi);return{cx:c,cy:u,maxR:f}}function Tn(s){if(!s.startsWith("#"))return!1;const t=parseInt(s.slice(1,3),16),e=parseInt(s.slice(3,5),16),i=parseInt(s.slice(5,7),16);return t*.299+e*.587+i*.114>150}function Rn(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,parseInt(s.slice(1,3),16)+Math.round(255*t)),i=Math.min(255,parseInt(s.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(s.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Ci(s){if(s.startsWith("#"))return{r:parseInt(s.slice(1,3),16)||0,g:parseInt(s.slice(3,5),16)||0,b:parseInt(s.slice(5,7),16)||0,a:1};const t=s.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(i=>i.trim());return{r:Number.parseFloat(e[0])||0,g:Number.parseFloat(e[1])||0,b:Number.parseFloat(e[2])||0,a:e[3]===void 0?1:Number.parseFloat(e[3])}}return{r:0,g:0,b:0,a:1}}function Ln(s,t){const e=Ci(s),i=Ci(t),n=i.a,r=Math.round(i.r*n+e.r*(1-n)),a=Math.round(i.g*n+e.g*(1-n)),o=Math.round(i.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}var H,X,yt,it,Xt,zt,mt,Yt,xt,He,ve,ji,Hi,Oi;class xe{constructor(t){F(this,xt),F(this,H,[]),F(this,X),F(this,yt,-1),F(this,it,[]),F(this,Xt,0),F(this,zt,1),F(this,mt,null),F(this,Yt,[]),B(this,X,j(this,xt,He).call(this,Sn,t??{}))}getData(){return h(this,H)}setData(t){const e=t??[];B(this,H,e),B(this,it,new Array(e.length).fill(0)),B(this,zt,h(this,X).animate?0:1),B(this,mt,null);for(const i of h(this,Yt))i()}onDataChanged(t){return h(this,Yt).push(t),()=>{const e=h(this,Yt).indexOf(t);e>=0&&h(this,Yt).splice(e,1)}}updateOptions(t){var e,i;const n=(e=h(this,X).sliceLabels)==null?void 0:e.mode;B(this,X,j(this,xt,He).call(this,h(this,X),t??{})),((i=h(this,X).sliceLabels)==null?void 0:i.mode)==="outside"&&n!=="outside"&&B(this,zt,h(this,X).animate?0:1),B(this,mt,null)}getColor(){var t,e;return((t=h(this,H)[0])==null?void 0:t.color)??((e=h(this,X).colors)==null?void 0:e[0])??"#888"}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[this.getColor()]}applyTheme(t,e){t.typography.fontFamily!==e.typography.fontFamily&&B(this,mt,null)}hitTest(t,e,i,n,r){var a;if(h(this,H).length===0)return-1;const o=h(this,H).reduce((S,k)=>S+k.value,0);if(o<=0)return-1;const l=((a=h(this,mt))==null?void 0:a.reserve)??0,{cx:d,cy:c,maxR:u}=Mi({bitmapWidth:i,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:l}),f=u,m=f*h(this,X).innerRadiusRatio,p=t-d,g=e-c,y=Math.sqrt(p*p+g*g);if(y>f||y<m)return-1;let v=Math.atan2(g,p)+Math.PI/2;v<0&&(v+=Kt);let x=0;for(let S=0;S<h(this,H).length;S++){const k=h(this,H)[S].value/o*Kt;if(v>=x&&v<x+k)return S;x+=k}return-1}setHoverIndex(t){return h(this,yt)===t?!1:(B(this,yt,t),!0)}getHoverIndex(){return h(this,yt)}getHoverInfo(t){if(h(this,yt)<0)return null;const e=h(this,H)[h(this,yt)];if(!e)return null;const i=h(this,H).reduce((r,a)=>r+a.value,0),n=h(this,X).colors??t.seriesColors;return{label:e.label,value:e.value,percent:i>0?e.value/i*100:0,color:e.color??n[h(this,yt)%n.length]}}getSliceInfo(t){if(h(this,H).length===0)return null;const e=h(this,H).reduce((n,r)=>n+r.value,0),i=h(this,X).colors??t.seriesColors;return h(this,H).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??i[r%i.length]}))}get needsAnimation(){var t;if(!h(this,X).animate)return!1;for(let e=0;e<h(this,it).length;e++){const i=e===h(this,yt)?1:0;if(Math.abs(h(this,it)[e]-i)>.01)return!0}return((t=h(this,X).sliceLabels)==null?void 0:t.mode)==="outside"&&h(this,zt)<.99}dispose(){B(this,Yt,[]),B(this,H,[]),B(this,it,[]),B(this,Xt,0)}_inspectSliceOffsets(){return h(this,it)}render(t){if(h(this,H).length===0)return;const{scope:e,theme:i,padding:n}=t,{context:r,bitmapSize:a,horizontalPixelRatio:o,verticalPixelRatio:l}=e,d=performance.now(),c=h(this,Xt)?Math.min(.05,(d-h(this,Xt))/1e3):0;B(this,Xt,d);const u=h(this,H).reduce((W,J)=>W+J.value,0);if(u<=0)return;const f=12;for(;h(this,it).length<h(this,H).length;)h(this,it).push(0);if(h(this,X).animate)for(let W=0;W<h(this,H).length;W++){const J=W===h(this,yt)?1:0;h(this,it)[W]=Ft(h(this,it)[W],J,f,c)}const m=Mn(h(this,X).sliceLabels);r.font=`${m.fontSize*o}px ${i.typography.fontFamily}`,m.mode==="outside"&&h(this,X).animate&&B(this,zt,Ft(h(this,zt),1,6,c));const p=h(this,X).colors??i.seriesColors,g=m.mode==="outside"?j(this,xt,ji).call(this,r,m,u,o):0,{cx:y,cy:v,maxR:x}=Mi({bitmapWidth:a.width,bitmapHeight:a.height,padTop:n.top*l,padBottom:n.bottom*l,labelReserve:g}),S=x,k=S*h(this,X).innerRadiusRatio,C=h(this,X).padAngle*je,I=8*o,b=h(this,X).shadow??!1,T=Cn(b),R=h(this,X).innerShadow??!1,z=kn(R);let D=-Math.PI/2;for(let W=0;W<h(this,H).length;W++){const J=h(this,H)[W],_=J.value/u*Kt,et=D+C/2,$=D+_-C/2,lt=D+_/2,ht=J.color??p[W%p.length];if($<=et){D+=_;continue}const Rt=h(this,it)[W]*I,Q=Math.cos(lt)*Rt,Lt=Math.sin(lt)*Rt,ct=y+Q,nt=v+Lt;r.beginPath(),r.arc(ct,nt,S,et,$),k>0?r.arc(ct,nt,k,$,et,!0):r.lineTo(ct,nt),r.closePath();const rt=r.createRadialGradient(ct,nt,k||0,ct,nt,S);if(rt.addColorStop(0,Rn(ht,.15)),R){const pt=Math.max(0,Math.min(.999,1-z.depth));rt.addColorStop(pt,ht),rt.addColorStop(1,Ln(ht,z.color))}else rt.addColorStop(1,ht);r.fillStyle=rt;const wt=h(this,it)[W];if(b||wt>.01){const pt=b?1:0,It=wt;r.shadowColor=b?T.color:"rgba(0,0,0,0.25)",r.shadowBlur=(T.blur*pt+12*It)*o,r.shadowOffsetX=T.offsetX*pt*o+Q*.3*It,r.shadowOffsetY=T.offsetY*pt*l+Lt*.3*It}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,D+=_}if(m.mode==="none")return;D=-Math.PI/2;const Y=i.tooltip.textColor;if(m.mode==="outside"){const W=j(this,xt,Oi).call(this,{cx:y,cy:v,outerR:S,total:u,palette:p,labels:m,hpr:o,bitmapHeight:a.height}),J=W.length>1?Math.min(.06,.9/(W.length-1)):0;for(let _=0;_<W.length;_++){const et=W[_];if(et===null)continue;const $=_*J,lt=qt((h(this,zt)-$)/(1-$),0,1);j(this,xt,Hi).call(this,{context:r,entry:et,textColor:Y,labels:m,hpr:o,progress:lt})}return}const O=k>0?(S+k)/2:S*.65;r.textAlign="center",r.textBaseline="middle";const V=m.minSliceAngle*je;for(let W=0;W<h(this,H).length;W++){const J=h(this,H)[W],_=J.value/u*Kt;if(_>=V){const et=D+_/2,$=h(this,it)[W]*I,lt=J.color??p[W%p.length],ht=j(this,xt,ve).call(this,J,u,m.content),Rt=r.measureText(ht).width,Q=m.fontSize*1.2*o,Lt=_<Math.PI?2*O*Math.sin(_/2):2*O,ct=Rt>Lt-4*o,nt=k>0&&O-k<Q;if(!ct&&!nt){const rt=y+Math.cos(et)*(O+$),wt=v+Math.sin(et)*(O+$);r.fillStyle=Tn(lt)?"#000000":"#ffffff",r.fillText(ht,rt,wt)}}D+=_}}}H=new WeakMap,X=new WeakMap,yt=new WeakMap,it=new WeakMap,Xt=new WeakMap,zt=new WeakMap,mt=new WeakMap,Yt=new WeakMap,xt=new WeakSet,He=function(s,t){const e={...s,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=wn(s.sliceLabels,t.sliceLabels)),e},ve=function(s,t,e){const i=t>0?s.value/t*100:0,n=`${i.toFixed(i>=10?0:1)}%`;return e==="percent"?n:e==="label"?s.label:`${s.label} ${n}`},ji=function(s,t,e,i){const n=s.font;if(h(this,mt)&&h(this,mt).fontScale===i&&h(this,mt).font===n)return h(this,mt).reserve;let r=0;for(const l of h(this,H)){const d=j(this,xt,ve).call(this,l,e,t.content),c=s.measureText(d).width;c>r&&(r=c)}const a=Math.max(t.distance,t.elbowLen),o=(r+(a+Math.max(0,t.railWidth)+t.legPad+4)*i)/Yi;return B(this,mt,{fontScale:i,font:n,reserve:o}),o},Hi=function(s){const{context:t,entry:e,textColor:i,labels:n,hpr:r,progress:a}=s;if(a<=0)return;const{anchorX:o,anchorY:l,elbowX:d,elbowY:c,side:u,text:f,color:m,labelX:p,labelY:g}=e,y=p+u*n.legPad*r,v=qt(a/.15,0,1),x=qt((a-.15)/.45,0,1),S=qt((a-.6)/.4,0,1);if(t.save(),t.globalAlpha=v,t.fillStyle=m,t.beginPath(),t.arc(o,l,2.5*r,0,Kt),t.fill(),t.restore(),x>0){t.save(),t.globalAlpha=x,t.strokeStyle=m,t.lineWidth=1*r,t.lineCap="round",t.beginPath(),t.moveTo(o,l);const k=o+(d-o)*x,C=l+(c-l)*x;if(t.lineTo(k,C),S>0){const I=d+(p-d)*S,b=c+(g-c)*S;t.lineTo(I,b)}t.stroke(),t.restore()}S>0&&(t.save(),t.globalAlpha=S,t.fillStyle=i,t.textAlign=u>=0?"left":"right",t.textBaseline="middle",t.fillText(f,y,g),t.restore())},Oi=function(s){const{cx:t,cy:e,outerR:i,total:n,palette:r,labels:a,hpr:o,bitmapHeight:l}=s,d=new Array(h(this,H).length).fill(null),c=a.elbowLen*o,u=Math.max(a.distance,a.elbowLen)*o,f=Math.max(0,a.railWidth)*o,m=[];let p=-Math.PI/2;const g=a.minSliceAngle*je;for(let S=0;S<h(this,H).length;S++){const k=h(this,H)[S],C=k.value/n*Kt;if(C>=g){const I=p+C/2,b=h(this,it)[S]*(8*o),T=Math.cos(I),R=Math.sin(I),z=T>=0?1:-1,D=t+T*(i+b),Y=e+R*(i+b),O=t+T*(i+b+c),V=e+R*(i+b+c),W=t+T*(i+b+u)+z*f,J=e+R*(i+b+u),_={anchorX:D,anchorY:Y,elbowX:O,elbowY:V,side:z,labelX:W,labelY:J,text:j(this,xt,ve).call(this,k,n,a.content),color:k.color??r[S%r.length]};d[S]=_,m.push({entry:_})}p+=C}const y=Math.max(1,a.fontSize*a.labelGap)*o,v=a.fontSize*o,x=l-a.fontSize*o;for(const S of[1,-1]){const k=[];for(const b of m)b.entry.side===S&&k.push(b.entry);if(k.length===0)continue;k.sort((b,T)=>b.labelY-T.labelY);const C=[];for(let b=0;b<k.length;b++)for(C.push({count:1,sumIdeal:k[b].labelY,startIdx:b});C.length>=2;){const T=C[C.length-2],R=C[C.length-1],z=T.sumIdeal/T.count,D=R.sumIdeal/R.count,Y=z+(T.count-1)*y/2;if(D-(R.count-1)*y/2>=Y+y)break;T.count+=R.count,T.sumIdeal+=R.sumIdeal,C.pop()}if(C.length>0){const b=C[0],T=b.sumIdeal/b.count-(b.count-1)*y/2;if(T<v)for(b.sumIdeal+=(v-T)*b.count;C.length>=2;){const R=C[0],z=C[1],D=R.sumIdeal/R.count,Y=z.sumIdeal/z.count,O=D+(R.count-1)*y/2;if(Y-(z.count-1)*y/2>=O+y)break;R.count+=z.count,R.sumIdeal+=z.sumIdeal,C.splice(1,1)}}if(C.length>0){const b=C[C.length-1],T=b.sumIdeal/b.count+(b.count-1)*y/2;if(T>x)for(b.sumIdeal-=(T-x)*b.count;C.length>=2;){const R=C[C.length-2],z=C[C.length-1],D=R.sumIdeal/R.count,Y=z.sumIdeal/z.count,O=D+(R.count-1)*y/2;if(Y-(z.count-1)*y/2>=O+y)break;R.count+=z.count,R.sumIdeal+=z.sumIdeal,C.pop()}}const I=(v+x)/2;for(const b of C){const T=(b.count-1)*y,R=b.sumIdeal/b.count;T>x-v&&R-T/2<v&&(b.sumIdeal=I*b.count)}for(const b of C){const T=b.sumIdeal/b.count;for(let R=0;R<b.count;R++)k[b.startIdx+R].labelY=T+(R-(b.count-1)/2)*y}}for(const S of m){const k=S.entry,C=k.labelY-k.anchorY;let I;if(Math.abs(C)<=c){const R=k.side*Math.sqrt(Math.max(0,c*c-C*C));I=k.anchorX+R}else I=(k.anchorX+k.labelX)/2;const b=Math.min(k.anchorX,k.labelX),T=Math.max(k.anchorX,k.labelX);k.elbowX=Math.max(b,Math.min(T,I)),k.elbowY=k.labelY}return d};function In(s){return parseInt(s.slice(1,3),16)*.299+parseInt(s.slice(3,5),16)*.587+parseInt(s.slice(5,7),16)*.114<128}function G(s){var t,e,i,n,r,a,o,l,d,c,u,f,m,p,g,y,v,x,S,k,C,I,b,T,R,z,D,Y,O,V,W,J,_,et;const{background:$,name:lt="Custom",description:ht,fontUrl:Rt=null}=s,Q=In($),Lt=Q?"#d1d4dc":"#24292f",ct=Q?"#787b86":"#8b949e",nt=Q?"#26a69a":"#2da44e",rt=Q?"#ef5350":"#cf222e",wt=Q?"#2962ff":"#0969da",pt=Q?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",It=Q?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Z=Q?ie($,.1):Oe($,.05),bt=Q?Qt($,.92):Qt($,.95),Ot=Q?Qt(ie($,.15),.6):"rgba(200,200,200,0.5)",ds=Ie,ni=((e=(t=s.candlestick)==null?void 0:t.up)==null?void 0:e.body)??nt,ri=((n=(i=s.candlestick)==null?void 0:i.down)==null?void 0:n.body)??rt,ai=gt(ni),Be=gt(ri),Jt=((r=s.line)==null?void 0:r.color)??wt,oi=((a=s.tooltip)==null?void 0:a.textColor)??Lt,fs=((o=s.axis)==null?void 0:o.textColor)??ct,ms=((l=s.typography)==null?void 0:l.fontFamily)??ds,li=((d=s.typography)==null?void 0:d.fontSize)??12,gs={background:$,chartGradient:s.chartGradient??(Q?[ie($,.04),Oe($,.06)]:[ie($,.06),$]),typography:{fontFamily:ms,fontSize:li},grid:{color:((c=s.grid)==null?void 0:c.color)??pt,style:((u=s.grid)==null?void 0:u.style)??"dashed"},candlestick:{up:{body:ni,wick:((m=(f=s.candlestick)==null?void 0:f.up)==null?void 0:m.wick)??ai},down:{body:ri,wick:((g=(p=s.candlestick)==null?void 0:p.down)==null?void 0:g.wick)??Be}},line:{color:Jt,width:((y=s.line)==null?void 0:y.width)??1,areaTopColor:((v=s.line)==null?void 0:v.areaTopColor)??Qt(Jt,.08),areaBottomColor:((x=s.line)==null?void 0:x.areaBottomColor)??Qt(Jt,.01)},seriesColors:s.seriesColors??[Jt,nt,rt],bands:{upper:((S=s.bands)==null?void 0:S.upper)??Jt,lower:((k=s.bands)==null?void 0:k.lower)??Be},crosshair:{color:((C=s.crosshair)==null?void 0:C.color)??It,labelBackground:((I=s.crosshair)==null?void 0:I.labelBackground)??Z,labelTextColor:((b=s.crosshair)==null?void 0:b.labelTextColor)??oi},axis:{fontSize:((T=s.axis)==null?void 0:T.fontSize)??10,textColor:fs,...(R=s.axis)!=null&&R.x?{x:{...s.axis.x}}:{},...(z=s.axis)!=null&&z.y?{y:{...s.axis.y}}:{}},yLabel:{fontSize:((D=s.yLabel)==null?void 0:D.fontSize)??11,upBackground:((Y=s.yLabel)==null?void 0:Y.upBackground)??ai,downBackground:((O=s.yLabel)==null?void 0:O.downBackground)??Be,neutralBackground:((V=s.yLabel)==null?void 0:V.neutralBackground)??Z,textColor:((W=s.yLabel)==null?void 0:W.textColor)??"#ffffff"},tooltip:{fontSize:((J=s.tooltip)==null?void 0:J.fontSize)??li,background:((_=s.tooltip)==null?void 0:_.background)??bt,textColor:oi,borderColor:((et=s.tooltip)==null?void 0:et.borderColor)??Ot}};return{name:lt,description:ht,fontUrl:Rt,dark:Q,theme:gs}}function Qt(s,t){const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function ie(s,t){if(!s.startsWith("#"))return s;const e=Math.min(255,Math.round(parseInt(s.slice(1,3),16)+255*t)),i=Math.min(255,Math.round(parseInt(s.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(s.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Oe(s,t){if(!s.startsWith("#"))return s;const e=Math.max(0,Math.round(parseInt(s.slice(1,3),16)*(1-t))),i=Math.max(0,Math.round(parseInt(s.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(s.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function P(s){const t=s.startsWith("#")&&s.length===7?[ie(s,.2),Oe(s,.15)]:[s,s];return Object.defineProperty(t,"source",{value:s,enumerable:!1}),t}const Re="'JetBrains Mono', 'Fira Code', monospace",Le="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Ie="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Je="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",_i="'Roboto Mono', monospace",$i="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Dn="'IBM Plex Mono', monospace",zn="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Qe="'Fira Code', monospace",Ze="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",Xi="'Source Code Pro', monospace",Ni="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",Bn="'Space Mono', monospace",Pn="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",ti="'Plus Jakarta Sans', sans-serif",ei="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",An="'Caveat', 'Comic Sans MS', cursive",Fn="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Ui={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{up:{body:P("#26a69a"),wick:"#26a69a"},down:{body:P("#ef5350"),wick:"#ef5350"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"}},Dt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},Wn=.1,En=.3,Vn=.4,Yn=.5,jn=4;class Hn extends me{constructor({padding:t,reboundMs:e}={}){super(),w(this,"_visibleRange",{from:0,to:0}),w(this,"_yRange",{min:0,max:0}),w(this,"_autoScroll",!0),w(this,"padding"),w(this,"reboundMs"),w(this,"dataInterval",6e4),w(this,"_dataStart",null),w(this,"_dataEnd",null),w(this,"_prevDataEnd",null),w(this,"_animating",!1),w(this,"animStartTime",0),w(this,"animDuration",0),w(this,"animFrom",{from:0,to:0}),w(this,"animTo",{from:0,to:0}),w(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??Dt.top,bottom:(t==null?void 0:t.bottom)??Dt.bottom,right:(t==null?void 0:t.right)??Dt.right,left:(t==null?void 0:t.left)??Dt.left},this.reboundMs=e??350}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,i){return typeof t=="object"?t.intervals*this.dataInterval:i<=0?0:t/i*e}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??Dt.top,bottom:(t==null?void 0:t.bottom)??Dt.bottom,right:(t==null?void 0:t.right)??Dt.right,left:(t==null?void 0:t.left)??Dt.left}}getPadding(){return this.padding}setDataStart(t){this._dataStart=t}setDataEnd(t){this._prevDataEnd=this._dataEnd,this._dataEnd=t}cancelAnimation(){this._animating=!1}getSoftBounds(t,e){const i=a=>typeof a=="object"||a===0||e>0,n=this._dataStart!==null&&i(this.padding.left)?this._dataStart-this.resolveHPad(this.padding.left,t,e):null,r=this._dataEnd!==null&&i(this.padding.right)?this._dataEnd+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}softMaxRange(){if(this._dataStart===null||this._dataEnd===null)return null;const t=this._dataEnd-this._dataStart;if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,i=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||i!==null?t+(e??0)+(i??0):t+this.dataInterval*5}setRange(t){const{from:e,to:i}=t;if(!Number.isFinite(e)||!Number.isFinite(i)||i<=e||(i-e)/this.dataInterval<2)return;this.cancelAnimation();const n=this._dataEnd!==null&&this._dataEnd>=e&&this._dataEnd<=i;this._autoScroll=n,this.applyRange(e,i)}applyRange(t,e){e<=t||(e-t)/this.dataInterval<2||(this._visibleRange={from:t,to:e},this.emit("change"))}animateTo(t,e,i=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:e},this.animDuration=i,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this.animStartTime,i=Math.min(1,e/this.animDuration),n=1-(1-i)**3,r=ut(this.animFrom.from,this.animTo.from,n),a=ut(this.animFrom.to,this.animTo.to,n);return a>r&&this.applyRange(r,a),i>=1&&(this._animating=!1),this._animating}setYRange(t,e,i,n=!1,r=!1){const a=e-t,o=i>0?this.padding.top/i*a:0,l=i>0?this.padding.bottom/i*a:0;this._yRange={min:n?t:t-l,max:r?e:e+o}}zoomAt(t,e,i=this._lastChartWidth){this.cancelAnimation(),i>0&&(this._lastChartWidth=i);const{from:n,to:r}=this._visibleRange,a=r-n;if(a<=0)return;const o=this.softMinRange,{left:l,right:d}=this.getSoftBounds(a,i),c=l!==null&&d!==null?d-l:this.softMaxRange();let u=e;const f=o*Vn;if(e<1&&a<o){const v=o-a,x=(1-Math.min(1,v/f))**2;u=1-(1-e)*x}let m=a*u;m<o-f&&(m=o-f),e>1&&c!==null&&m>c&&(m=c);const p=(t-n)/a;let g=t-p*m,y=g+m;if(e<1&&y<r){const v=r-y;g+=v,y+=v}if(e>1){if(d!==null&&y>d){const v=y-d;g-=v,y-=v}if(l!==null&&g<l){const v=l-g;g+=v,y+=v}}this.applyRange(g,y),this.emit("interact")}pan(t,e=0){this.cancelAnimation(),e>0&&(this._lastChartWidth=e);const{from:i,to:n}=this._visibleRange,r=n-i;if(r<=0)return;const{left:a,right:o}=this.getSoftBounds(r,e),l=r*En;let d=t;if(t>0&&o!==null){const m=Math.max(0,n-o);m>0&&(d*=1/(m/l+1))}else if(t<0&&a!==null){const m=Math.max(0,a-i);m>0&&(d*=1/(m/l+1))}let c=i+d,u=n+d;if(o!==null&&u>o+l){const m=u-(o+l);c-=m,u-=m}if(a!==null&&c<a-l){const m=a-l-c;c+=m,u+=m}const f=this._dataEnd!==null&&this._dataEnd>=c&&this._dataEnd<=u;this._autoScroll=f,this.applyRange(c,u),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:i}=this._visibleRange,n=i-e;if(n<=0)return;const r=this.softMinRange,a=this.softMaxRange();let o=n;o<r&&(o=r),a!==null&&o>a&&(o=a);let l=e,d=i;if(o!==n){const x=(e+i)/2;l=x-o/2,d=x+o/2}const{left:c,right:u}=this.getSoftBounds(o,t);if(u!==null&&d>u){const x=d-u;l-=x,d-=x}if(c!==null&&l<c){const x=c-l;l+=x,d+=x}const f=Math.abs(l-e),m=Math.abs(d-i);if(f<1&&m<1)return;const p=n*Wn;let g=null,y=0,v=0;u!==null&&i-u>p?(g="right",y=i-u,v=u):c!==null&&c-e>p&&(g="left",y=c-e,v=c),this.reboundMs<=0?this.applyRange(l,d):this.animateTo(l,d,this.reboundMs),g!==null&&this.emit("edgeReached",{side:g,overshoot:y,boundaryTime:v})}fitToData(t,e,i=0,n=!1){this._autoScroll=!0,i>0&&(this._lastChartWidth=i);const r=400*this.dataInterval,a=e-t,o=a>0?a:this.dataInterval*10,l=this.resolveHPad(this.padding.right,o,i),d=this.resolveHPad(this.padding.left,o,i);let c=e+l,u=t-d;c-u>r&&(c=e+l,u=c-r),n&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(u,c,450):this.applyRange(u,c)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const i=this._visibleRange.to-this._visibleRange.from;if(i<=0)return;const n=this.resolveHPad(this.padding.right,i,e),r=this._animating?this.animTo.to:this._visibleRange.to,a=this._prevDataEnd!==null?r-this._prevDataEnd:n,o=Math.max(0,Math.min(n,a)),l=t+o,d=l-i;this._autoScroll=!0;const c=Yn*this.dataInterval,u=e>0?jn/e*i:c,f=Math.min(c,u);if(this._animating){if(Math.abs(l-this.animTo.to)<f)return;this.animFrom={...this._visibleRange},this.animTo={from:d,to:l},this._prevDataEnd=this._dataEnd}else{if(Math.abs(l-this._visibleRange.to)<f)return;this.animateTo(d,l,150),this._prevDataEnd=this._dataEnd}}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}function Zt(s,t){return s===!1||s===0?0:s===void 0?t:s}function On(s){if(s===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0}};const t=s===!0||s===void 0?void 0:s,e=t==null?void 0:t.points,i=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:Zt(e==null?void 0:e.enterMs,400),smoothMs:Zt(e==null?void 0:e.smoothMs,70),pulseMs:Zt(e==null?void 0:e.pulseMs,600)},r=i===!1?{reboundMs:0,yAxisMs:0}:{reboundMs:Zt(i==null?void 0:i.reboundMs,350),yAxisMs:Zt(i==null?void 0:i.yAxisMs,80)};return{points:n,viewport:r}}function _n(s){if(!s)return{monitor:null,ownsMonitor:!1,showHud:!1};if(s===!0)return{monitor:new Ee,ownsMonitor:!0,showHud:!0};if(s instanceof Ee)return{monitor:s,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...i}=s,n=e!==void 0;return{monitor:e??new Ee(i),ownsMonitor:!n,showHud:t??!n}}let $n=0;var q,E,U,Mt,se,A,K,ne,at,Ct,tt,Pt,_e,Nt,vt,Se,we,Tt,re,jt,de,ke,Ht,kt,ae,oe,N,At,ki,Me,le,he,Gi,Ki,Ce,dt,ft,Ut;class qi extends me{constructor(t,e){var i,n,r,a;super(),F(this,N),F(this,q),F(this,E),F(this,U),F(this,Mt),w(this,"timeScale"),w(this,"yScale"),F(this,se),F(this,A,[]),F(this,K),F(this,ne),F(this,at,6e4),F(this,Ct,null),F(this,tt,{}),F(this,Pt,null),F(this,_e,!1),F(this,Nt,{}),F(this,vt,{left:"idle",right:"idle"}),F(this,Se,{left:null,right:null}),F(this,we),F(this,Tt,0),F(this,re,!1),F(this,jt,!1),F(this,de,!1),F(this,ke,0),F(this,Ht),F(this,kt),F(this,ae,!1),F(this,oe,null),F(this,Ce,0),F(this,dt,0),F(this,ft,0),F(this,Ut,!1),e!=null&&e.axis&&(B(this,Nt,e.axis),B(this,tt,{min:(i=e.axis.y)==null?void 0:i.min,max:(n=e.axis.y)==null?void 0:n.max})),B(this,K,(e==null?void 0:e.theme)??Ui),B(this,ne,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),B(this,Ht,On(e==null?void 0:e.animations)),B(this,we,e==null?void 0:e.onEdgeReached);const o=_n(e==null?void 0:e.perf);B(this,kt,o.monitor),B(this,ae,o.ownsMonitor),B(this,q,new ys(t,h(this,kt)??void 0)),B(this,E,new Hn({padding:e==null?void 0:e.padding,reboundMs:h(this,Ht).viewport.reboundMs})),Ws(this,h(this,E)),this.timeScale=new Js,this.yScale=new rn;const l=h(this,kt);l?(B(this,U,new ye(c=>{l.resetDrawCalls("main");const u=performance.now();this.renderMain(c),l.recordFrame("main",performance.now()-u,c)})),B(this,Mt,new ye(c=>{l.resetDrawCalls("overlay");const u=performance.now();this.renderOverlay(c),l.recordFrame("overlay",performance.now()-u,c)})),o.showHud&&B(this,oe,new Os(t,l))):(B(this,U,new ye(c=>this.renderMain(c))),B(this,Mt,new ye(c=>this.renderOverlay(c))));const d=(e==null?void 0:e.interactive)!==!1;B(this,se,d?new As(h(this,q).canvas,h(this,E),this.timeScale,this.yScale):null),h(this,E).on("change",()=>{this.syncScales(),h(this,U).markDirty(),this.emit("viewportChange")}),h(this,E).on("edgeReached",c=>{var u;h(this,Se)[c.side]=c.boundaryTime,(u=h(this,we))==null||u.call(this,c)}),h(this,q).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(a=h(this,se))==null||a.on("crosshairMove",c=>{B(this,Ct,c),h(this,Mt).markDirty(),this.emit("crosshairMove",c),j(this,N,Ki).call(this,c)})}get yAxisWidth(){const t=h(this,Nt).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=h(this,Nt).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return h(this,ke)}addCandlestickSeries(t){const e=new Bi,i=new yn(e,{up:{...h(this,K).candlestick.up},down:{...h(this,K).candlestick.down},bodyWidthRatio:.6,...j(this,N,Me).call(this,"candle"),...t,...j(this,N,le).call(this)});return j(this,N,he).call(this,i,i.store,t??{})}addLineSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new xn(n,{colors:n===1?[h(this,K).line.color]:h(this,K).seriesColors.slice(0,n),strokeWidth:h(this,K).line.width,area:{visible:!0},...j(this,N,Me).call(this,"line"),...i,...j(this,N,le).call(this)});return j(this,N,he).call(this,r,r.store,i)}addBarSeries(t){const{layers:e,...i}=t??{},n=e??1,r=new fn(n,{colors:h(this,K).seriesColors.slice(0,n),barWidthRatio:.6,...j(this,N,Me).call(this,"bar"),...i,...j(this,N,le).call(this)});return j(this,N,he).call(this,r,r.store,i)}addPieSeries(t){const e=new xe(t);return j(this,N,he).call(this,e,null,t??{})}removeSeries(t){const e=h(this,A).findIndex(i=>i.id===t);e>=0&&(h(this,A)[e].renderer.dispose(),h(this,A).splice(e,1),B(this,Pt,null),this.updateViewportPadding(),h(this,U).markDirty(),this.emit("seriesChange"),j(this,N,At).call(this))}setSeriesData(t,e,i){const n=h(this,A).find(r=>r.id===t);n==null||n.renderer.setData(e,i)}appendData(t,e,i){var n,r;const a=h(this,A).find(o=>o.id===t);(r=a==null?void 0:(n=a.renderer).appendPoint)==null||r.call(n,e,i)}updateData(t,e,i){var n,r;const a=h(this,A).find(o=>o.id===t);(r=a==null?void 0:(n=a.renderer).updateLastPoint)==null||r.call(n,e,i)}updateSeriesOptions(t,e){const i=h(this,A).find(d=>d.id===t);if(!i)return;const n=i.label,r=i.renderer.getLayerColors().slice();i.renderer.updateOptions({...e,...j(this,N,le).call(this)}),"label"in e&&typeof e.label=="string"&&(i.label=e.label),h(this,U).markDirty();const a=i.renderer.getLayerColors(),o=r.length!==a.length||r.some((d,c)=>d!==a[c]),l=n!==i.label;(o||l)&&j(this,N,At).call(this)}batch(t){Ye(this,Tt)._++;try{t()}finally{--Ye(this,Tt)._<=0&&(B(this,Tt,0),h(this,re)?(B(this,re,!1),B(this,jt,!1),this.onDataChanged()):h(this,jt)&&(B(this,jt,!1),this.updateYRange(!0),h(this,U).markDirty()),h(this,de)&&(B(this,de,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const i=h(this,A).find(n=>n.id===t);if(!(!i||i.visible===e)){if(i.visible=e,j(this,N,At).call(this),h(this,Tt)>0){B(this,jt,!0);return}this.updateYRange(!0),h(this,U).markDirty()}}isSeriesVisible(t){var e;return((e=h(this,A).find(i=>i.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,i){const n=h(this,A).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==i){if(n.renderer.setLayerVisible(e,i),j(this,N,At).call(this),h(this,Tt)>0){B(this,jt,!0);return}this.updateYRange(!0),h(this,U).markDirty()}}isLayerVisible(t,e){const i=h(this,A).find(n=>n.id===t);return(i==null?void 0:i.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const i=h(this,q).size.media.width-this.yAxisWidth;h(this,E).fitToData(t,e,i,!0)}getVisibleRange(){return h(this,E).visibleRange}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:i}=this.getDataBounds();if(e===void 0||i===void 0)return;const n=Math.max(e,i-(t-1)*h(this,at)),r=h(this,q).size.media.width-this.yAxisWidth;h(this,E).fitToData(n,i,r,!1);return}h(this,E).setRange(t)}getYRange(){return h(this,E).yRange}getCrosshairPosition(){return h(this,Ct)}getLastValue(t){const e=h(this,A).find(l=>l.id===t);if(!(e!=null&&e.store))return null;const i=e.store.last();if(!i)return null;const n=l=>"close"in l?l.close:l.value,{from:r,to:a}=h(this,E).visibleRange;if(i.time>=r&&i.time<=a)return{value:n(i),isLive:!0};const o=e.store.getVisibleData(r,a);return o.length===0?null:{value:n(o[o.length-1]),isLive:!1}}getPreviousClose(t){const e=h(this,A).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const i=e.store.getAll();if(i.length<2)return null;const n=i[i.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=h(this,A).find(i=>i.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var i,n;const r=h(this,A).find(a=>a.id===t);return r?((n=(i=r.renderer).getDataAtTime)==null?void 0:n.call(i,e,h(this,at)))??null:null}getLayerSnapshots(t,e){var i,n;const r=h(this,A).find(a=>a.id===t);return r!=null&&r.visible?((n=(i=r.renderer).getLayerSnapshots)==null?void 0:n.call(i,e,h(this,at)))??null:null}getSeriesIds(){return h(this,Pt)||B(this,Pt,h(this,A).map(t=>t.id)),h(this,Pt).slice()}getSeriesType(t){const e=h(this,A).find(i=>i.id===t);return e?e.renderer instanceof xe?"pie":"time":null}getSeriesIdsByType(t,e){const i=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const a of h(this,A)){const o=a.renderer instanceof xe;if(t==="pie"&&!o||t==="time"&&o)continue;const l=a.renderer.getLayerCount();if(!(n&&l>1)){if(i){if(!a.visible)continue;if(l>1){let d=!1;for(let c=0;c<l;c++)if(a.renderer.isLayerVisible(c)){d=!0;break}if(!d)continue}}r.push(a.id)}}return r}getStackedLastValue(t){var e,i;const n=h(this,A).find(a=>a.id===t);return n?((i=(e=n.renderer).getStackedLastValue)==null?void 0:i.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,i;const n=h(this,A).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:i.call(e))??null}listSeriesForTest(){return h(this,A).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=h(this,A).find(i=>i.id===t);return e?e.renderer.getLayerColors()[0]??h(this,K).line.color:null}getSeriesLabel(t){var e;return(e=h(this,A).find(i=>i.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=h(this,A).find(r=>r.id===t);if(!e)return null;const i=e.renderer.getLayerCount();if(i<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:i},(r,a)=>({color:n[a%n.length]}))}getSliceInfo(t){var e,i;const n=h(this,A).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:i.call(e,h(this,K)))??null}getHoverInfo(t){var e,i;const n=h(this,A).find(r=>r.id===t);return((i=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:i.call(e,h(this,K)))??null}setTheme(t){const e=h(this,K);B(this,K,t);for(const i of h(this,A))i.renderer.applyTheme(t,e);h(this,U).markDirty(),j(this,N,At).call(this)}getTheme(){return h(this,K)}setAxis(t){var e,i;const n=this.yAxisWidth,r=this.xAxisHeight;B(this,Nt,t),B(this,tt,{min:(e=t.y)==null?void 0:e.min,max:(i=t.y)==null?void 0:i.max}),B(this,Ut,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),h(this,U).markDirty()}setYAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.yScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.yScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),h(this,U).markDirty())}setTimeAxisLabelDensity(t){let e=!1;"labelCount"in t&&(this.timeScale.setLabelCount(t.labelCount??null),e=!0),"minLabelSpacing"in t&&(this.timeScale.setMinSpacing(t.minLabelSpacing??null),e=!0),e&&(this.syncScales(),this.emit("viewportChange"),h(this,U).markDirty())}getMediaSize(){return h(this,q).size.media}getLayout(){const t=h(this,q).size.media,e=this.yAxisWidth,i=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-i},yAxisWidth:e,xAxisHeight:i}}getDataInterval(){return h(this,at)}setPadding(t){const e=h(this,E).getPadding();h(this,E).setPadding(t);const i=h(this,E).getPadding(),n=!Ti(e.left,i.left)||!Ti(e.right,i.right),r=e.top!==i.top||e.bottom!==i.bottom;if(n){const{first:a,last:o}=this.getDataBounds();if(a!==void 0&&o!==void 0){const l=h(this,q).size.media.width-this.yAxisWidth;h(this,E).fitToData(a,o,l,!1)}}r&&this.updateYRange(!0),this.syncScales(),h(this,U).markDirty(),r&&this.emit("viewportChange")}setGrid(t){B(this,ne,t.visible),h(this,U).markDirty()}setEdgeState(t,e){h(this,vt)[t]!==e&&(h(this,vt)[t]=e,h(this,Mt).markDirty())}getEdgeState(t){return h(this,vt)[t]}setYLabel(t){B(this,_e,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,i;for(const n of h(this,A))n.renderer.dispose();B(this,A,[]),B(this,Pt,null),h(this,E).destroy(),h(this,U).destroy(),h(this,Mt).destroy(),(t=h(this,se))==null||t.destroy(),h(this,q).destroy(),(e=h(this,oe))==null||e.destroy(),B(this,oe,null),h(this,ae)&&((i=h(this,kt))==null||i.destroy()),B(this,kt,null),B(this,ae,!1),this.removeAllListeners()}getPerfMonitor(){return h(this,kt)}getDataBounds(){let t,e;for(const i of h(this,A)){if(!i.visible||!i.store)continue;const n=i.store.first(),r=i.store.last();n&&(t===void 0||n.time<t)&&(t=n.time),r&&(e===void 0||r.time>e)&&(e=r.time)}return{first:t,last:e}}onDataChanged(){if(h(this,Tt)>0){B(this,re,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&h(this,E).setDataStart(t),e!==void 0&&h(this,E).setDataEnd(e);let i=0;for(const r of h(this,A))r.renderer.getTotalLength?i+=r.renderer.getTotalLength():r.store&&(i+=r.store.length);const n=i-h(this,Ce)>5;if(B(this,Ce,i),t!==void 0&&e!==void 0){const{from:r,to:a}=h(this,E).visibleRange,o=r===0&&a===0,l=h(this,q).size.media.width-this.yAxisWidth;o?h(this,E).fitToData(t,e,l,!1):n&&h(this,E).autoScroll?h(this,E).fitToData(t,e,l,!0):!n&&h(this,E).autoScroll&&h(this,E).scrollToEnd(e,l)}this.updateYRange(n),this.syncScales(),h(this,U).markDirty(),this.emit("dataUpdate"),j(this,N,At).call(this)}updateDataInterval(){for(const t of h(this,A)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const i=e.slice(0,20).map(n=>n.time);B(this,at,Pi(i)),h(this,E).setDataInterval(h(this,at));break}}}updateYRange(t=!1){let e=1/0,i=-1/0;const n=h(this,E).visibleRange,r=h(this,tt).min!==void 0&&h(this,tt).min!=="auto"&&typeof h(this,tt).min!="number"||h(this,tt).max!==void 0&&h(this,tt).max!=="auto"&&typeof h(this,tt).max!="number"?[]:null;for(const c of h(this,A)){if(!c.visible)continue;if(c.renderer.getValueRange){const f=c.renderer.getValueRange(n.from,n.to);if(f){f.max>i&&(i=f.max),f.min<e&&(e=f.min),r==null||r.push(f.min,f.max);continue}}if(!c.store)continue;const u=c.store.getVisibleData(n.from,n.to);for(const f of u)if("high"in f){const m=f;m.high>i&&(i=m.high),m.low<e&&(e=m.low),r==null||r.push(m.high,m.low)}else{const m=f;m.value>i&&(i=m.value),m.value<e&&(e=m.value),r==null||r.push(m.value)}}if(e===1/0||i===-1/0){B(this,Ut,!1);return}e=this.resolveBound(h(this,tt).min,e,i,r??[],"min"),i=this.resolveBound(h(this,tt).max,i,e,r??[],"max");const a=h(this,Ht).viewport.yAxisMs;if(!h(this,Ut)||t||a<=0)B(this,dt,e),B(this,ft,i),B(this,Ut,!0);else{const c=Math.min(1,16/a);B(this,dt,h(this,dt)+(e-h(this,dt))*c),B(this,ft,h(this,ft)+(i-h(this,ft))*c),e<h(this,dt)&&B(this,dt,e),i>h(this,ft)&&B(this,ft,i);const u=Math.max(Math.abs(h(this,ft)-h(this,dt))*1e-4,.001);(Math.abs(h(this,dt)-e)>u||Math.abs(h(this,ft)-i)>u)&&h(this,U).markDirty()}const o=h(this,tt).min!==void 0&&h(this,tt).min!=="auto",l=h(this,tt).max!==void 0&&h(this,tt).max!=="auto",d=h(this,q).size.media.height-this.xAxisHeight;h(this,E).setYRange(h(this,dt),h(this,ft),d,o,l)}resolveBound(t,e,i,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const a=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(a){const o=a[1]==="-"?-1:1,l=parseFloat(a[2])/100,d=Math.abs(i-e)||Math.abs(e)||1;return e+o*l*d*(r==="max"?1:-1)}return e}syncScales(){const t=h(this,q).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,i=t.media.height-this.xAxisHeight;this.timeScale.update(h(this,E).visibleRange,e,t.horizontalPixelRatio,h(this,at)),this.yScale.update(h(this,E).yRange,i,t.verticalPixelRatio)}updateScales(t=!1){const e=h(this,q).size;if(e.media.width===0||e.media.height===0)return;const i=e.media.width-this.yAxisWidth,n=e.media.height-this.xAxisHeight;this.timeScale.update(h(this,E).visibleRange,i,e.horizontalPixelRatio,h(this,at)),this.yScale.update(h(this,E).yRange,n,e.verticalPixelRatio),this.updateYRange(t),this.yScale.update(h(this,E).yRange,n,e.verticalPixelRatio)}renderMain(t){const e=h(this,q).size;if(e.media.width===0||e.media.height===0)return;const i=typeof t=="number"?t:performance.now();h(this,E).tick(i)&&h(this,U).markDirty(),this.updateScales(),h(this,q).useMainLayer(n=>{const{context:r,bitmapSize:a}=n,o=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,l=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,a.width,a.height),r.save(),r.beginPath(),r.rect(0,0,o,l),r.clip(),h(this,ne)&&Is(n,this.timeScale,this.yScale,h(this,K),h(this,at));const d=h(this,E).getPadding(),c={top:d.top,bottom:d.bottom},u=h(this,kt);for(const f of h(this,A)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:h(this,K),dataInterval:h(this,at),padding:c};if(u){const p=performance.now();f.renderer.render(m),u.recordSeries(f.id,performance.now()-p,i)}else f.renderer.render(m)}r.restore()});for(const n of h(this,A))if(n.renderer.needsAnimation){h(this,U).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,i;const n=h(this,q).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const l of h(this,A))if(l.visible&&l.renderer.overlayNeedsAnimation){r=!0;break}const a=h(this,vt).left==="loading"||h(this,vt).right==="loading",o=h(this,vt).left!=="idle"||h(this,vt).right!=="idle";if(h(this,q).useOverlayLayer(l=>{var d,c;if(!h(this,Ct)&&!r&&!o)return;const u=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(l.context.save(),l.context.beginPath(),l.context.rect(0,0,u,f),l.context.clip(),h(this,Ct)&&j(this,N,Gi).call(this)){const g=h(this,Ct).mediaX*n.horizontalPixelRatio,y=h(this,Ct).mediaY*n.verticalPixelRatio;vs(l,g,y,h(this,K))}const m=h(this,E).getPadding(),p={top:m.top,bottom:m.bottom};for(const g of h(this,A))g.visible&&((c=(d=g.renderer).drawOverlay)==null||c.call(d,{scope:l,timeScale:this.timeScale,yScale:this.yScale,theme:h(this,K),dataInterval:h(this,at),padding:p,crosshair:h(this,Ct)}));o&&this.drawEdgeIndicators(l,n.media.height-this.xAxisHeight),l.context.restore()}),r){const{from:l,to:d}=this.timeScale.getRange();let c=!1;for(const u of h(this,A))if(!(!u.visible||!u.renderer.overlayNeedsAnimation)&&(((i=(e=u.renderer).hasOverlayContentInRange)==null?void 0:i.call(e,l,d))??!0)){c=!0;break}c&&h(this,Mt).markDirty()}a&&h(this,Mt).markDirty()}drawEdgeIndicators(t,e){const i=performance.now();for(const n of["left","right"]){const r=h(this,vt)[n];if(r==="idle"||r==="has-more")continue;const a=this.resolveEdgeBoundary(n);a!==null&&Ts({scope:t,timeScale:this.timeScale,theme:h(this,K),chartMediaHeight:e,boundaryTime:a,side:n,state:r,now:i})}}resolveEdgeBoundary(t){const e=h(this,Se)[t];if(e!==null)return e;const{first:i,last:n}=this.getDataBounds();return t==="left"?i??null:n??null}}q=new WeakMap,E=new WeakMap,U=new WeakMap,Mt=new WeakMap,se=new WeakMap,A=new WeakMap,K=new WeakMap,ne=new WeakMap,at=new WeakMap,Ct=new WeakMap,tt=new WeakMap,Pt=new WeakMap,_e=new WeakMap,Nt=new WeakMap,vt=new WeakMap,Se=new WeakMap,we=new WeakMap,Tt=new WeakMap,re=new WeakMap,jt=new WeakMap,de=new WeakMap,ke=new WeakMap,Ht=new WeakMap,kt=new WeakMap,ae=new WeakMap,oe=new WeakMap,N=new WeakSet,At=function(){if(Ye(this,ke)._++,h(this,Tt)>0){B(this,de,!0);return}this.emit("overlayChange")},ki=function(s){if(s&&!h(this,A).some(e=>e.id===s))return s;let t;do t=`series_${++$n}`;while(h(this,A).some(e=>e.id===t));return t},Me=function(s){const{enterMs:t,smoothMs:e,pulseMs:i}=h(this,Ht).points;return s==="line"?{enterMs:t,smoothMs:e,pulseMs:i}:{enterMs:t,smoothMs:e}},le=function(){const{enterMs:s,smoothMs:t,pulseMs:e}=h(this,Ht).points,i={};return s===0&&(i.enterMs=0),t===0&&(i.smoothMs=0),e===0&&(i.pulseMs=0),i},he=function(s,t,e){var i;const n=j(this,N,ki).call(this,e.id);return(i=s.onDataChanged)==null||i.call(s,()=>this.onDataChanged()),h(this,A).push({id:n,label:e.label,renderer:s,store:t,visible:!0}),B(this,Pt,null),this.updateViewportPadding(),this.emit("seriesChange"),j(this,N,At).call(this),n},Gi=function(){for(const s of h(this,A))if(s.visible&&!(s.renderer instanceof xe))return!0;return!1},Ki=function(s){const t=h(this,q).size,e=h(this,E).getPadding(),i={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of h(this,A)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let a=-1;if(s){const o=s.mediaX*t.horizontalPixelRatio,l=s.mediaY*t.verticalPixelRatio;a=r.renderer.hitTest(o,l,t.bitmap.width,t.bitmap.height,i)}r.renderer.setHoverIndex(a)&&(n=!0)}n&&h(this,U).markDirty()},Ce=new WeakMap,dt=new WeakMap,ft=new WeakMap,Ut=new WeakMap;function Ti(s,t){return typeof s=="number"&&typeof t=="number"?s===t:typeof s=="object"&&typeof t=="object"?s.intervals===t.intervals:!1}const $e=new WeakMap;function Ji(s,t){var e;return(e=$e.get(s))==null?void 0:e.get(t)}function Qi(s,t,e){let i=$e.get(s);i||(i=new Map,$e.set(s,i)),i.set(t,e)}function Ri(s){return"close"in s?s.close:s.value}function Zi(s,t){if(t==="none"||s.length<=1)return s;const e=[...s];return e.sort((i,n)=>{const r=Ri(i.data),a=Ri(n.data);return t==="asc"?r-a:a-r}),e}function Te(s){const t=Object.freeze({...s.data}),e={id:s.id,seriesId:s.seriesId,layerIndex:s.layerIndex,label:s.label,data:t,color:s.color};return Object.freeze(e)}function ii(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=Ji(s,t.cacheKey);if(n&&n.version===i&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const o of s.getSeriesIds()){if(!s.isSeriesVisible(o))continue;const l=s.getSeriesLabel(o);if(s.getSeriesLayers(o)!==null){const c=s.getLayerSnapshots(o,t.time);if(!c)continue;for(const u of c)r.push(Te({id:`${o}_layer${u.layerIndex}`,seriesId:o,layerIndex:u.layerIndex,label:l,data:{time:u.time,value:u.value},color:u.color}));continue}const d=s.getDataAtTime(o,t.time);d&&r.push(Te({id:o,seriesId:o,label:l,data:d,color:s.getSeriesColor(o)??"#888"}))}const a=Object.freeze(Zi(r,e));return Qi(s,t.cacheKey,{version:i,time:t.time,sort:e,data:a}),a}function ts(s,t){const e=t.sort??"none",i=s.getOverlayVersion(),n=Ji(s,t.cacheKey);if(n&&n.version===i&&n.time===null&&n.sort===e)return n.data;const r=[];for(const o of s.getSeriesIds()){if(!s.isSeriesVisible(o))continue;const l=s.getSeriesLabel(o),d=s.getLayerLastSnapshots(o);if(d){for(const u of d)r.push(Te({id:`${o}_layer${u.layerIndex}`,seriesId:o,layerIndex:u.layerIndex,label:l,data:{time:u.time,value:u.value},color:u.color}));continue}const c=s.getLastData(o);c&&r.push(Te({id:o,seriesId:o,label:l,data:c,color:s.getSeriesColor(o)??"#888"}))}const a=Object.freeze(Zi(r,e));return Qi(s,t.cacheKey,{version:i,time:null,sort:e,data:a}),a}const Xn={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{up:{body:P("#089981"),wick:"#089981"},down:{body:P("#f23645"),wick:"#f23645"}},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{fontSize:10,textColor:"#787b86"},yLabel:{fontSize:11,upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{fontSize:12,background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"}},Nn=G({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{up:{body:P("#96e072"),wick:"#96e072"},down:{body:P("#ee5d43"),wick:"#ee5d43"}},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:_i},fontUrl:$i}),Un=G({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{up:{body:P("#bae67e"),wick:"#bae67e"},down:{body:P("#f27983"),wick:"#f27983"}},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:Ie},fontUrl:Je}),Gn=G({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{up:{body:P("#a6e3a1"),wick:"#a6e3a1"},down:{body:P("#f38ba8"),wick:"#f38ba8"}},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:Ie},fontUrl:Je}),Kn=G({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{up:{body:P("#50fa7b"),wick:"#50fa7b"},down:{body:P("#ff5555"),wick:"#ff5555"}},line:{color:"#bd93f9"},seriesColors:["#bd93f9","#8be9fd","#50fa7b","#ff79c6","#ffb86c","#f1fa8c","#ff5555","#6272a4","#ff5555","#ff79c6"],bands:{upper:"#8be9fd",lower:"#ff79c6"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#a0b0d0"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Qe},fontUrl:Ze}),qn=G({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{up:{body:P("#2da44e"),wick:"#2da44e"},down:{body:P("#cf222e"),wick:"#cf222e"}},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:ti},fontUrl:ei}),Jn=G({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{up:{body:P("#b8bb26"),wick:"#b8bb26"},down:{body:P("#fb4934"),wick:"#fb4934"}},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:Re},fontUrl:Le}),Qn={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Fn,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:An,fontSize:18},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{up:{body:P("#7a9a5e"),wick:"#7a9a5e"},down:{body:P("#b07060"),wick:"#b07060"}},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{fontSize:13,textColor:"#a09880"},yLabel:{fontSize:15,upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{fontSize:14,background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"}}},Zn="'Silkscreen', cursive",tr="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",er=G({name:"Matrix",background:"#000000",candlestick:{up:{body:P("#00ff41"),wick:"#00ff41"},down:{body:P("#00802a"),wick:"#00802a"}},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Zn},fontUrl:tr,chartGradient:["#010a01","#000000"]}),ir=G({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:P("#6b8e5e"),wick:"#6b8e5e"},down:{body:P("#b85468"),wick:"#b85468"}},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:ti},fontUrl:ei,chartGradient:["#f8f4f7","#f5f0f4"]}),sr=G({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{up:{body:P("#6a9a6e"),wick:"#6a9a6e"},down:{body:P("#c45070"),wick:"#c45070"}},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:Ie},fontUrl:Je}),nr=G({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{up:{body:P("#c3e88d"),wick:"#c3e88d"},down:{body:P("#f07178"),wick:"#f07178"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:_i},fontUrl:$i}),rr="'Silkscreen', cursive",ar="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",or=G({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{up:{body:P("#111111"),wick:"#111111"},down:{body:P("#bbbbbb"),wick:"#bbbbbb"}},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{fontSize:9,background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:rr},fontUrl:ar}),lr=G({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:P("#2e9070"),wick:"#2e9070"},down:{body:P("#d04848"),wick:"#d04848"}},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:Bn},fontUrl:Pn,chartGradient:["#f8f7f0","#f6f5ee"]}),hr=G({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{up:{body:P("#8ab862"),wick:"#8ab862"},down:{body:P("#d05470"),wick:"#d05470"}},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Qe},fontUrl:Ze}),cr=G({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{up:{body:P("#7ec699"),wick:"#7ec699"},down:{body:P("#e06c75"),wick:"#e06c75"}},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#495a5a"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Re},fontUrl:Le}),ur=G({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{up:{body:P("#98c379"),wick:"#98c379"},down:{body:P("#e06c75"),wick:"#e06c75"}},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:Re},fontUrl:Le}),dr=G({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{up:{body:P("#19f9d8"),wick:"#19f9d8"},down:{body:P("#ff75b5"),wick:"#ff75b5"}},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Qe},fontUrl:Ze}),fr=G({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:P("#5a9a68"),wick:"#5a9a68"},down:{body:P("#d06848"),wick:"#d06848"}},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:ti},fontUrl:ei,chartGradient:["#fff8f2","#fef6f0"]}),mr=G({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",grid:{color:"rgba(200,200,200,0.5)"},candlestick:{up:{body:P("#448c27"),wick:"#448c27"},down:{body:P("#aa3731"),wick:"#aa3731"}},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Dn},fontUrl:zn}),gr=G({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:P("#56949f"),wick:"#56949f"},down:{body:P("#b4637a"),wick:"#b4637a"}},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:Xi},fontUrl:Ni}),pr=G({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:P("#5a8a50"),wick:"#5a8a50"},down:{body:P("#b85040"),wick:"#b85040"}},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:Xi},fontUrl:Ni,chartGradient:["#f8f4ec","#f4f0e8"]}),br=G({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{up:{body:P("#859900"),wick:"#859900"},down:{body:P("#dc322f"),wick:"#dc322f"}},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:Re},fontUrl:Le});function pe(s){const{x:t,y:e,chartWidth:i,chartHeight:n,tooltipWidth:r,tooltipHeight:a,offsetX:o=16,offsetY:l=16}=s,d=t+o+r>i?t-o-r:t+o,c=e+l+a>n?e-l-a:e+l,u=Math.max(0,i-r),f=Math.max(0,n-a);return{left:Math.max(0,Math.min(u,d)),top:Math.max(0,Math.min(f,c))}}const ce=L.createContext(null);function st(){const s=L.useContext(ce);if(!s)throw new Error("useChartInstance must be used within <ChartContainer>");return s}const yr=20;function es({data:s,options:t,id:e}){var l;const i=st(),n=L.useRef(null),r=L.useRef([]),a=L.useRef([]),o=L.useRef([]);return L.useLayoutEffect(()=>{const d=i.addBarSeries({...t,layers:s.length,id:e});return n.current=d,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),o.current=new Array(s.length).fill(null),()=>{i.removeSeries(d),n.current=null,r.current=[],a.current=[],o.current=[]}},[i,s.length,e]),L.useLayoutEffect(()=>{const d=n.current;d&&i.batch(()=>{for(let c=0;c<s.length;c++){const u=s[c],f=r.current[c]??0,m=a.current[c]??null;if(u.length===0){i.setSeriesData(d,[],c),r.current[c]=0,a.current[c]=null,o.current[c]=null;continue}const p=ot(u[0].time),g=ot(u[u.length-1].time),y=o.current[c]??null,v=m!==null&&m!==p,x=u.length-f;if(v&&x===0&&(y!==null&&y!==g))i.setSeriesData(d,u.slice(0,-1),c),i.appendData(d,u[u.length-1],c);else if(f===0||u.length<f||x>yr||v)i.setSeriesData(d,u,c);else if(u.length===f)i.updateData(d,u[u.length-1],c);else for(let k=f;k<u.length;k++)i.appendData(d,u[k],c);r.current[c]=u.length,a.current[c]=p,o.current[c]=g}})},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(l=t==null?void 0:t.colors)==null?void 0:l.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const vr=20;function xr({data:s,options:t,id:e}){var l,d,c,u,f,m;const i=st(),n=L.useRef(null),r=L.useRef(0),a=L.useRef(null),o=L.useRef(null);return L.useLayoutEffect(()=>{const p=i.addCandlestickSeries({...t,id:e});return n.current=p,()=>{i.removeSeries(p),n.current=null,r.current=0,a.current=null,o.current=null}},[i,e]),L.useLayoutEffect(()=>{const p=n.current;if(!p)return;if(s.length===0){i.setSeriesData(p,[]),r.current=0,a.current=null,o.current=null;return}const g=r.current,y=a.current,v=o.current,x=ot(s[0].time),S=ot(s[s.length-1].time),k=y!==null&&y!==x,C=s.length-g;if(k&&C===0&&(v!==null&&v!==S))i.setSeriesData(p,s.slice(0,-1)),i.appendData(p,s[s.length-1]);else if(g===0||s.length<g||C>vr||k)i.setSeriesData(p,s);else if(s.length===g)i.updateData(p,s[s.length-1]);else for(let b=g;b<s.length;b++)i.appendData(p,s[b]);r.current=s.length,a.current=x,o.current=S},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,Array.isArray((l=t==null?void 0:t.up)==null?void 0:l.body)?t.up.body.join(","):(d=t==null?void 0:t.up)==null?void 0:d.body,Array.isArray((c=t==null?void 0:t.down)==null?void 0:c.body)?t.down.body.join(","):(u=t==null?void 0:t.down)==null?void 0:u.body,(f=t==null?void 0:t.up)==null?void 0:f.wick,(m=t==null?void 0:t.down)==null?void 0:m.wick,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}const si=L.createContext(null),ue=si.Provider;function De(){const s=L.useContext(si);if(!s)throw new Error("useTheme must be used within <ThemeProvider>");return s}function Sr(){return L.useContext(si)}function ze(s,t,e){const i=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const a of i)s.on(a,r);return()=>{for(const a of i)s.off(a,r)}},getSnapshot:e}}function is(s){const t=L.useMemo(()=>ze(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getVisibleRange()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}function ss(s){const t=L.useMemo(()=>ze(s,["viewportChange","dataUpdate","seriesChange"],()=>s.getYRange()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}function wr(s,t){const e=L.useMemo(()=>{let i=s.getLastValue(t),n=i?s.yScale.valueToY(i.value):null;const r=()=>i,a=()=>{const o=s.getLastValue(t),l=o?s.yScale.valueToY(o.value):null;return(i==null?void 0:i.value)===(o==null?void 0:o.value)&&(i==null?void 0:i.isLive)===(o==null?void 0:o.isLive)&&n===l?!1:(i=o,n=l,!0)};return{subscribe:o=>{a();const l=()=>{a()&&o()};return s.on("dataUpdate",l),s.on("viewportChange",l),()=>{s.off("dataUpdate",l),s.off("viewportChange",l)}},getSnapshot:r}},[s,t]);return L.useSyncExternalStore(e.subscribe,e.getSnapshot)}function Mr(s,t){const e=L.useMemo(()=>ze(s,"dataUpdate",()=>s.getPreviousClose(t)),[s,t]);return L.useSyncExternalStore(e.subscribe,e.getSnapshot)}function be(s){const t=L.useMemo(()=>ze(s,"crosshairMove",()=>s.getCrosshairPosition()),[s]);return L.useSyncExternalStore(t.subscribe,t.getSnapshot)}const Cr=(s,t)=>t==="volume"?Et(s):Ge(s);function ns({sort:s="none",format:t=Cr,children:e}){const i=st(),n=De(),r=be(i),[,a]=L.useState(0);L.useLayoutEffect(()=>{const f=()=>a(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&a(m=>m+1),()=>{i.off("overlayChange",f)}},[i]);const o=ts(i,{sort:s,cacheKey:"infobar-last"});let l=o,d=o.length===0?0:Math.max(...o.map(f=>f.data.time)),c=!1;if(r!==null){const f=ii(i,{time:r.time,sort:s,cacheKey:"infobar-hover"});f.length>0&&(l=f,d=r.time,c=!0)}if(l.length===0)return null;if(e)return M.jsx("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",flexShrink:0,fontFamily:n.typography.fontFamily,fontSize:n.typography.fontSize,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:e({snapshots:l,time:d,isHover:c})});const u=i.getDataInterval();return M.jsxs("div",{"data-tooltip-legend":"",style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",padding:"4px 8px",flexShrink:0,fontSize:n.typography.fontSize,fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:c?1:.6,transition:"opacity 0.2s ease",pointerEvents:"none"},children:[M.jsx("span",{style:{color:n.axis.textColor,marginRight:2},children:ge(d,u)}),l.map(f=>{if("open"in f.data){const g=f.data,y=g.close>=g.open,v=gt(y?n.candlestick.up.body:n.candlestick.down.body);return M.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[M.jsx(te,{label:"O",display:t(g.open,"open"),color:v,dim:n.axis.textColor}),M.jsx(te,{label:"H",display:t(g.high,"high"),color:v,dim:n.axis.textColor}),M.jsx(te,{label:"L",display:t(g.low,"low"),color:v,dim:n.axis.textColor}),M.jsx(te,{label:"C",display:t(g.close,"close"),color:v,dim:n.axis.textColor}),g.volume!=null&&M.jsx(te,{label:"V",display:t(g.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const p=f.data;return M.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[M.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.color,flexShrink:0}}),M.jsx("span",{style:{color:f.color,fontWeight:500},children:t(p.value,"value")})]},f.id)})]})}function te({label:s,display:t,color:e,dim:i}){return M.jsxs(M.Fragment,{children:[M.jsx("span",{style:{color:i,opacity:.5,marginLeft:5},children:s}),M.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function kr({chart:s,isolatedIdRef:t,setIsolatedId:e}){const i=[],n=s.getSeriesIds();for(const r of n){const a=s.getSeriesLayers(r);if(a){const o=s.getSeriesLabel(r);for(let l=0;l<a.length;l++){const d=`${r}_layer${l}`,c=s.isSeriesVisible(r)&&s.isLayerVisible(r,l);i.push(Li({id:d,seriesId:r,layerIndex:l,label:o?`${o} ${l+1}`:`Series ${l+1}`,color:a[l].color,isDisabled:!c,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}else{const o=s.getSeriesColor(r);if(!o)continue;const l=s.getSeriesLabel(r),d=s.isSeriesVisible(r);i.push(Li({id:r,seriesId:r,layerIndex:void 0,label:l??"Series",color:o,isDisabled:!d,chart:s,isolatedIdRef:t,setIsolatedId:e}))}}return i}function Li(s){const{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,chart:o,isolatedIdRef:l,setIsolatedId:d}=s;return{id:t,seriesId:e,layerIndex:i,label:n,color:r,isDisabled:a,toggle:()=>{i!==void 0?o.setLayerVisible(e,i,!o.isLayerVisible(e,i)):o.setSeriesVisible(e,!o.isSeriesVisible(e))},isolate:()=>{if(l.current===t){o.batch(()=>{for(const f of o.getSeriesIds()){o.setSeriesVisible(f,!0);const m=o.getSeriesLayers(f);if(m)for(let p=0;p<m.length;p++)o.setLayerVisible(f,p,!0)}}),l.current=null,d(null);return}o.batch(()=>{for(const f of o.getSeriesIds()){const m=o.getSeriesLayers(f);if(m){o.setSeriesVisible(f,f===e);for(let p=0;p<m.length;p++)o.setLayerVisible(f,p,f===e&&p===i)}else o.setSeriesVisible(f,f===t)}}),l.current=t,d(t)}}}function rs({items:s,position:t="bottom",mode:e="toggle",children:i}){const n=st(),r=De(),[a,o]=L.useState(null),[l,d]=L.useState(0),c=L.useRef(a);c.current=a,L.useLayoutEffect(()=>{const g=()=>d(v=>v+1),y=()=>o(null);return n.on("overlayChange",g),n.on("seriesChange",y),n.getSeriesIds().length>0&&d(v=>v+1),()=>{n.off("overlayChange",g),n.off("seriesChange",y)}},[n]);const u=L.useMemo(()=>kr({chart:n,isolatedIdRef:c,setIsolatedId:o}),[n,a,l]),f=t==="right",m={display:"flex",flexDirection:f?"column":"row",flexWrap:"wrap",gap:f?6:14,padding:f?"8px 6px":"6px 8px",alignItems:f?"flex-start":"center",justifyContent:f?"flex-start":"center",fontFamily:r.typography.fontFamily,fontSize:r.axis.fontSize,color:r.axis.textColor,pointerEvents:"auto",flexShrink:0};if(i)return u.length===0?null:M.jsx("div",{"data-legend":t,style:m,children:i({items:u})});if(s)return s.length===0?null:M.jsx("div",{"data-legend":t,style:m,children:s.map((g,y)=>M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,userSelect:"none"},children:[M.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),M.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},y))});if(u.length===0)return null;const p=g=>{e==="isolate"||e==="solo"?g.isolate():g.toggle()};return M.jsx("div",{"data-legend":t,style:m,children:u.map(g=>M.jsxs("div",{onClick:()=>p(g),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:g.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[M.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g.color,flexShrink:0}}),M.jsx("span",{style:{whiteSpace:"nowrap"},children:g.label})]},g.id))})}function Tr(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function as({seriesId:s,mode:t,format:e,position:i,children:n}){const r=t??"both",a=i??"bottom",o=e??Et,l=st(),d=l.getTheme(),[,c]=L.useState(0);L.useLayoutEffect(()=>{const p=()=>c(g=>g+1);return l.on("overlayChange",p),l.getSeriesIds().length>0&&p(),()=>{l.off("overlayChange",p)}},[l]);const u=Tr(l,s),f=u!==null?l.getSliceInfo(u):null;if(!f||f.length===0)return null;if(n)return M.jsx(M.Fragment,{children:n({slices:f,mode:r,format:o})});const m=a==="overlay";return M.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":a,style:{display:"flex",flexDirection:"column",gap:6,padding:m?"8px 12px":"6px 10px",fontFamily:d.typography.fontFamily,fontSize:d.typography.fontSize,color:d.tooltip.textColor,pointerEvents:"auto"},children:f.map((p,g)=>M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[M.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:p.color,flexShrink:0}}),M.jsx("span",{style:{flex:1,opacity:.8},children:p.label}),(r==="value"||r==="both")&&M.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:o(p.value)}),(r==="percent"||r==="both")&&M.jsxs("span",{style:{opacity:r==="percent"?1:.5,fontWeight:r==="percent"?600:400,fontSize:r==="percent"?d.typography.fontSize:d.axis.fontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[p.percent.toFixed(1),"%"]})]},g))})}function os({children:s,sub:t,style:e}){const i=De();return M.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:i.typography.fontFamily,fontSize:i.typography.fontSize,fontWeight:600,color:i.tooltip.textColor,pointerEvents:"none",...e},children:[s!=null&&s!==!1&&M.jsx("span",{children:s}),t!=null&&t!==!1&&M.jsx("span",{style:{fontWeight:400,color:i.axis.textColor,fontSize:i.axis.fontSize},children:t})]})}function Rr(s){let t=null,e=null,i=null,n=null;const r=[],a=o=>{if(L.isValidElement(o)&&o.type===L.Fragment){L.Children.forEach(o.props.children,a);return}if(L.isValidElement(o)){if(o.type===os){t=o;return}if(o.type===rs){e=o;return}if(o.type===as){const l=o;l.props.position==="overlay"?r.push(o):i=l;return}if(o.type===ns){n=o;return}}r.push(o)};return L.Children.forEach(s,a),{titleEl:t,legendEl:e,pieLegendEl:i,tooltipLegendEl:n,overlay:r}}function ls({children:s,theme:t,axis:e,padding:i,gradient:n=!0,interactive:r,grid:a,headerLayout:o="overlay",perf:l,style:d,className:c}){var ct,nt,rt,wt,pt,It;const u=L.useRef(l),f=Sr(),m=t??f??void 0,p=L.useRef(null),g=L.useRef(null),[y,v]=L.useState(0);L.useLayoutEffect(()=>{if(!p.current||g.current)return;const Z={};return e&&(Z.axis=e),m&&(Z.theme=m),i&&(Z.padding=i),r!==void 0&&(Z.interactive=r),a!==void 0&&(Z.grid=a),u.current!==void 0&&(Z.perf=u.current),g.current=new qi(p.current,Z),v(bt=>bt+1),()=>{var bt;(bt=g.current)==null||bt.destroy(),g.current=null}},[]),L.useEffect(()=>{g.current&&m&&g.current.setTheme(m)},[m]),L.useEffect(()=>{g.current&&e&&g.current.setAxis(e)},[(ct=e==null?void 0:e.y)==null?void 0:ct.width,(nt=e==null?void 0:e.y)==null?void 0:nt.min,(rt=e==null?void 0:e.y)==null?void 0:rt.max,(wt=e==null?void 0:e.y)==null?void 0:wt.visible,(pt=e==null?void 0:e.x)==null?void 0:pt.height,(It=e==null?void 0:e.x)==null?void 0:It.visible]);const x=L.useRef(null),[S,k]=L.useState(0),C=o==="overlay"?S:0;L.useEffect(()=>{const Z=g.current;if(!Z)return;const Ot={top:((i==null?void 0:i.top)??20)+C,...(i==null?void 0:i.bottom)!==void 0?{bottom:i.bottom}:{},...(i==null?void 0:i.right)!==void 0?{right:i.right}:{},...(i==null?void 0:i.left)!==void 0?{left:i.left}:{}};Z.setPadding(Ot)},[i==null?void 0:i.top,i==null?void 0:i.bottom,typeof(i==null?void 0:i.right)=="object"?i.right.intervals:i==null?void 0:i.right,typeof(i==null?void 0:i.left)=="object"?i.left.intervals:i==null?void 0:i.left,C]),L.useEffect(()=>{g.current&&a!==void 0&&g.current.setGrid(a)},[a==null?void 0:a.visible]);const I=g.current,{titleEl:b,legendEl:T,pieLegendEl:R,tooltipLegendEl:z,overlay:D}=Rr(s),Y=(T==null?void 0:T.props.position)??"bottom",O=(R==null?void 0:R.props.position)??"bottom",V=Y==="right"||O==="right",W=m??(I==null?void 0:I.getTheme()),[J,_]=(W==null?void 0:W.chartGradient)??["transparent","transparent"],et=(W==null?void 0:W.background)??"transparent",$=n?`linear-gradient(to bottom, ${J} 0%, ${et} 70%, ${_} 100%)`:et;L.useLayoutEffect(()=>{if(o!=="overlay"){k(0);return}const Z=x.current;if(!Z){k(0);return}const bt=()=>k(Z.getBoundingClientRect().height);bt();const Ot=new ResizeObserver(bt);return Ot.observe(Z),()=>Ot.disconnect()},[b!==null,z!==null,o,I!==null]);const lt=(b||z)&&M.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":o==="overlay"?"":void 0,ref:x,style:o==="overlay"?{position:"absolute",top:0,left:0,right:0,zIndex:2,pointerEvents:"none",display:"flex",flexDirection:"column"}:{flexShrink:0,display:"flex",flexDirection:"column",pointerEvents:"none"},children:[b,z]}),ht=M.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:I&&M.jsx(ce.Provider,{value:I,children:M.jsxs(ue,{value:m??I.getTheme(),children:[o==="overlay"&&lt,M.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:D})]})})}),Rt=o==="inline"?M.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[I&&lt&&M.jsx(ce.Provider,{value:I,children:M.jsx(ue,{value:m??I.getTheme(),children:lt})}),ht]}):ht,Q=I&&T&&M.jsx(ce.Provider,{value:I,children:M.jsx(ue,{value:m??I.getTheme(),children:T})}),Lt=I&&R&&M.jsx(ce.Provider,{value:I,children:M.jsx(ue,{value:m??I.getTheme(),children:R})});return M.jsx("div",{className:c,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:$,...d},children:M.jsxs("div",{style:{display:"flex",flexDirection:V?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Rt,Q,Lt]})})}const Lr=20;function hs({data:s,options:t,id:e}){var l,d;const i=st(),n=L.useRef(null),r=L.useRef([]),a=L.useRef([]),o=L.useRef([]);return L.useLayoutEffect(()=>{const c=i.addLineSeries({...t,layers:s.length,id:e});return n.current=c,r.current=new Array(s.length).fill(0),a.current=new Array(s.length).fill(null),o.current=new Array(s.length).fill(null),()=>{i.removeSeries(c),n.current=null,r.current=[],a.current=[],o.current=[]}},[i,s.length,e]),L.useLayoutEffect(()=>{const c=n.current;c&&i.batch(()=>{for(let u=0;u<s.length;u++){const f=s[u],m=r.current[u]??0,p=a.current[u]??null;if(f.length===0){i.setSeriesData(c,[],u),r.current[u]=0,a.current[u]=null,o.current[u]=null;continue}const g=ot(f[0].time),y=ot(f[f.length-1].time),v=o.current[u]??null,x=p!==null&&p!==g,S=f.length-m;if(x&&S===0&&(v!==null&&v!==y))i.setSeriesData(c,f.slice(0,-1),u),i.appendData(c,f[f.length-1],u);else if(m===0||f.length<m||S>Lr||x)i.setSeriesData(c,f,u);else if(f.length===m)i.updateData(c,f[f.length-1],u);else for(let C=m;C<f.length;C++)i.appendData(c,f[C],u);r.current[u]=f.length,a.current[u]=g,o.current[u]=y}})},[i,s]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,(l=t==null?void 0:t.colors)==null?void 0:l.join(","),t==null?void 0:t.strokeWidth,(d=t==null?void 0:t.area)==null?void 0:d.visible,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking,t==null?void 0:t.entryAnimation,t==null?void 0:t.enterAnimation,t==null?void 0:t.entryMs,t==null?void 0:t.enterMs,t==null?void 0:t.smoothMs]),null}function Ir({data:s,options:t,id:e}){var r,a,o,l,d,c,u,f,m,p;const i=st(),n=L.useRef(null);return L.useLayoutEffect(()=>{const g=i.addPieSeries({...t,id:e});return n.current=g,()=>{i.removeSeries(g),n.current=null}},[i,e]),L.useEffect(()=>{n.current&&t&&i.updateSeriesOptions(n.current,t)},[i,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.animate,t==null?void 0:t.shadow,t==null?void 0:t.innerShadow,t==null?void 0:t.colors,(r=t==null?void 0:t.sliceLabels)==null?void 0:r.mode,(a=t==null?void 0:t.sliceLabels)==null?void 0:a.content,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.fontSize,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.minSliceAngle,(d=t==null?void 0:t.sliceLabels)==null?void 0:d.elbowLen,(c=t==null?void 0:t.sliceLabels)==null?void 0:c.legPad,(u=t==null?void 0:t.sliceLabels)==null?void 0:u.labelGap,(f=t==null?void 0:t.sliceLabels)==null?void 0:f.distance,(m=t==null?void 0:t.sliceLabels)==null?void 0:m.railWidth,(p=t==null?void 0:t.sliceLabels)==null?void 0:p.balanceSides]),L.useLayoutEffect(()=>{n.current&&i.setSeriesData(n.current,s)},[i,s]),null}function Dr(){const s=st(),t=be(s);if(!t)return null;const e=s.getTheme(),i=s.getDataInterval(),n={background:`color-mix(in srgb, ${e.crosshair.labelBackground} 80%, transparent)`,color:e.crosshair.labelTextColor,fontSize:e.axis.fontSize,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none",zIndex:2};return M.jsxs(M.Fragment,{children:[M.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:s.yScale.formatY(t.y)}),M.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:ge(t.time,i)})]})}const zr=["0","1","2","3","4","5","6","7","8","9"];function Br(s){const t=[];for(const e of s)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function cs({value:s,format:t,locale:e="en-US",spinDuration:i=350,className:n,style:r}){const o=L.useMemo(()=>{if(typeof t=="function")return t;const d=new Intl.NumberFormat(e,typeof t=="object"?t:void 0);return c=>d.format(c)},[t,e])(s),l=Br(o);return M.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:l.map((d,c)=>d.type==="digit"?M.jsx(Pr,{digit:parseInt(d.value,10),duration:i},`d${c}`):M.jsx("span",{style:{display:"inline-block"},children:d.value},`s${c}`))})}function Pr({digit:s,duration:t}){const e=L.useRef(!1);return L.useEffect(()=>{e.current=!0},[]),M.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:M.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-s*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:zr.map(i=>M.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:i},i))})})}function Ar(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Fr=160,Wr=70;function Er({seriesId:s,format:t=Et,children:e}){const i=st(),n=be(i),[,r]=L.useState(0);L.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),()=>{i.off("overlayChange",f)}},[i]);const a=Ar(i,s),o=a!==null?i.getHoverInfo(a):null;if(!o||!n)return null;const l=i.getTheme(),d=i.getMediaSize();if(e)return M.jsx(Vr,{x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,children:e({info:o,format:t})});const{left:c,top:u}=pe({x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,tooltipWidth:Fr,tooltipHeight:Wr,offsetX:16,offsetY:16});return M.jsxs("div",{style:{position:"absolute",left:c,top:u,pointerEvents:"none",zIndex:10,background:l.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${l.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:l.typography.fontSize,fontFamily:l.typography.fontFamily,color:l.tooltip.textColor,display:"flex",flexDirection:"column",gap:6},children:[M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[M.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:o.color,flexShrink:0}}),M.jsx("span",{style:{fontWeight:600},children:o.label})]}),M.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[M.jsx("span",{style:{opacity:.6},children:t(o.value)}),M.jsxs("span",{style:{fontWeight:600},children:[o.percent.toFixed(1),"%"]})]})]})}function Vr({x:s,y:t,chartWidth:e,chartHeight:i,children:n}){const r=L.useRef(null),[a,o]=L.useState(null);L.useEffect(()=>{const d=r.current;if(!d||typeof ResizeObserver>"u")return;const c=new ResizeObserver(u=>{var m;const f=(m=u[0])==null?void 0:m.contentRect;f&&o(p=>p&&p.width===f.width&&p.height===f.height?p:{width:f.width,height:f.height})});return c.observe(d),()=>c.disconnect()},[]);const l=a?pe({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:a.width,tooltipHeight:a.height,offsetX:16,offsetY:16}):{left:0,top:0};return M.jsx("div",{ref:r,"data-measured":a?"true":"false",style:{position:"absolute",left:l.left,top:l.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:a?"visible":"hidden"},children:n})}function Yr(s,t){if(s.startsWith("rgba")||!s.startsWith("#"))return s;const e=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),n=parseInt(s.slice(5,7),16);return`rgba(${e}, ${i}, ${n}, ${t})`}function jr(s){if(s.length<2)return{value:0,pct:0,positive:!0};const t=s[0].value,i=s[s.length-1].value-t,n=t!==0?i/t*100:0;return{value:i,pct:n,positive:i>=0}}function Hr({data:s,theme:t,variant:e="line",valuePosition:i="right",formatValue:n=Et,label:r,sublabel:a,color:o,negativeColor:l,area:d,areaFill:c,width:u=140,height:f=48,strokeWidth:m=1.5,gradient:p=!0,style:g}){const y=(d==null?void 0:d.visible)??c??!0,v=s.length>0?s[s.length-1].value:0,x=L.useMemo(()=>jr(s),[s]),S=o??t.seriesColors[0],k=l??gt(t.candlestick.down.body),C=gt(x.positive?t.candlestick.up.body:t.candlestick.down.body),I=i!=="none"&&M.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[r&&M.jsx("div",{style:{fontSize:t.axis.fontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),M.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:n(v)}),a!==void 0?M.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:a}):M.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:C,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[x.positive?"+":"",x.pct.toFixed(1),"%"]})]}),b=M.jsx("div",{style:{width:u,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:M.jsx(ls,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:{visible:!1},children:e==="line"?M.jsx(hs,{data:[s],options:{colors:[S],strokeWidth:m,area:{visible:y},pulse:!1,stacking:"off"}}):M.jsx(es,{data:[s],options:{colors:[S,k],barWidthRatio:.7,stacking:"off"}})})});return M.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Yr(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...g},children:[i==="left"&&I,b,i==="right"&&I]})}function us({labelCount:s,minLabelSpacing:t}={}){const e=st();is(e),L.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:s??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,s,t]);const i=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:a}=e.timeScale.niceTickValues(n),o=new Set(r),d=L.useRef(new Map).current,c=performance.now();for(const f of r)d.has(f)?d.get(f).opacity=1:d.set(f,{opacity:1,addedAt:c});for(const[f,m]of d)o.has(f)||m.opacity!==0&&(m.opacity=0,m.fadedAt=c);for(const[f,m]of d)m.opacity===0&&m.fadedAt!==void 0&&c-m.fadedAt>600&&d.delete(f);const u=Array.from(d.entries());return M.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:e.yAxisWidth,height:e.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:u.map(([f,m])=>{const p=e.timeScale.timeToX(f);return M.jsx("span",{style:{position:"absolute",left:p,transform:"translateX(-50%)",color:qe(i,"x"),fontSize:Ke(i,"x"),fontFamily:i.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:ge(f,a)},f)})})}const Or=(s,t)=>t==="volume"?Et(s):Ge(s);function _r({sort:s="none",format:t=Or,children:e}){const i=st(),n=be(i),[,r]=L.useState(0);if(L.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return i.on("overlayChange",f),i.getSeriesIds().length>0&&r(m=>m+1),()=>{i.off("overlayChange",f)}},[i]),!n)return null;const a=ii(i,{time:n.time,sort:s,cacheKey:"tooltip"});if(a.length===0)return null;const o=i.getTheme(),l=i.getDataInterval(),d=i.getMediaSize(),c=d.width-i.yAxisWidth,u=d.height-i.xAxisHeight;return e?M.jsx($r,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:o,children:e({snapshots:a,time:n.time})}):M.jsx(Xr,{snapshots:a,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:o,dataInterval:l,format:t})}function $r({x:s,y:t,chartWidth:e,chartHeight:i,theme:n,children:r}){const a=L.useRef(null),[o,l]=L.useState(null);L.useEffect(()=>{const c=a.current;if(!c||typeof ResizeObserver>"u")return;const u=new ResizeObserver(f=>{var p;const m=(p=f[0])==null?void 0:p.contentRect;m&&l(g=>g&&g.width===m.width&&g.height===m.height?g:{width:m.width,height:m.height})});return u.observe(c),()=>u.disconnect()},[]);const d=o?pe({x:s,y:t,chartWidth:e,chartHeight:i,tooltipWidth:o.width,tooltipHeight:o.height}):{left:0,top:0};return M.jsx("div",{ref:a,"data-measured":o?"true":"false",style:{position:"absolute",left:d.left,top:d.top,pointerEvents:"none",background:n.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${n.tooltip.borderColor}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontFamily:n.typography.fontFamily,fontSize:n.tooltip.fontSize,fontVariantNumeric:"tabular-nums",color:n.tooltip.textColor,width:"max-content",maxWidth:e,boxSizing:"border-box",zIndex:10,visibility:o?"visible":"hidden"},children:r})}function Xr({snapshots:s,displayTime:t,x:e,y:i,chartWidth:n,chartHeight:r,theme:a,dataInterval:o,format:l}){const d=s.some(x=>"open"in x.data),c=s.filter(x=>!("open"in x.data)).length,u=160,f=d?140:40+c*22,{left:m,top:p}=pe({x:e,y:i,chartWidth:n,chartHeight:r,tooltipWidth:u,tooltipHeight:f}),g=a.tooltip.background,y=a.tooltip.borderColor;return M.jsxs("div",{style:{position:"absolute",left:m,top:p,pointerEvents:"none",background:g,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${y}`,borderRadius:8,padding:"10px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",fontSize:a.tooltip.fontSize,fontFamily:a.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:a.tooltip.textColor,width:u,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[M.jsxs("div",{style:{fontSize:a.axis.fontSize,color:a.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${y}`,letterSpacing:"0.02em"},children:[Ai(t)," ",ge(t,o)]}),s.map(x=>{if("open"in x.data){const C=x.data,I=C.close>=C.open,b=gt(I?a.candlestick.up.body:a.candlestick.down.body);return M.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[M.jsx(ee,{label:"Open",color:b,display:l(C.open,"open")}),M.jsx(ee,{label:"High",color:b,display:l(C.high,"high")}),M.jsx(ee,{label:"Low",color:b,display:l(C.low,"low")}),M.jsx(ee,{label:"Close",color:b,display:l(C.close,"close")}),C.volume!=null&&M.jsx(ee,{label:"Volume",color:a.tooltip.textColor,display:l(C.volume,"volume")})]},x.id)}const k=x.data;return M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[M.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:x.color,flexShrink:0}}),M.jsx("span",{style:{opacity:.6,flex:1},children:x.label??"Value"}),M.jsx("span",{style:{fontWeight:600,color:x.color},children:l(k.value,"value")})]},x.id)})]})}function ee({label:s,color:t,display:e}){return M.jsxs(M.Fragment,{children:[M.jsx("span",{style:{opacity:.5},children:s}),M.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function Nr({format:s,labelCount:t,minLabelSpacing:e}={}){const i=st();ss(i),L.useLayoutEffect(()=>(i.yScale.setFormat(s??null),()=>i.yScale.setFormat(null)),[i,s]),L.useLayoutEffect(()=>(i.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{i.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[i,t,e]);const n=i.getTheme(),r=i.yScale.niceTickValues(),a=new Set(r),l=L.useRef(new Map).current,d=performance.now();for(const u of r)l.has(u)?l.get(u).opacity=1:l.set(u,{opacity:1,addedAt:d});for(const[u,f]of l)a.has(u)||f.opacity!==0&&(f.opacity=0,f.fadedAt=d);for(const[u,f]of l)f.opacity===0&&f.fadedAt!==void 0&&d-f.fadedAt>600&&l.delete(u);const c=Array.from(l.entries());return M.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:i.xAxisHeight,width:i.yAxisWidth,pointerEvents:"none"},children:c.map(([u,f])=>{const m=i.yScale.valueToY(u);return M.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:qe(n,"y"),fontSize:Ke(n,"y"),fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:i.yScale.formatY(u)},u)})})}function Ur(s,t){if(t!==void 0)return t;const e=s.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const i=s.getSeriesIdsByType("time",{visibleOnly:!0});return i.length>0?i[0]:null}function Gr({seriesId:s,color:t,format:e,children:i}){const n=st();L.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=L.useState(0);L.useLayoutEffect(()=>{const S=()=>r(k=>k+1);return n.on("overlayChange",S),n.on("viewportChange",S),n.getSeriesIds().length>0&&r(k=>k+1),()=>{n.off("overlayChange",S),n.off("viewportChange",S)}},[n]);const a=Ur(n,s),o=a!==null?n.getStackedLastValue(a):null,l=a!==null?n.getPreviousClose(a):null,d=n.yScale.getRange(),c=d.max-d.min,u=c<.1?6:c<10?4:c<1e3?2:0,f=L.useMemo(()=>{if(e)return e;const S=new Intl.NumberFormat("en-US",{minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!1});return k=>S.format(k)},[e,u]);if(!o||a===null)return null;const{value:m,isLive:p}=o,g=n.getTheme(),y=n.yScale.valueToY(m),v=l===null?"neutral":m>l?"up":m<l?"down":"neutral";let x;return p?t?x=t:x=v==="up"?g.yLabel.upBackground:v==="down"?g.yLabel.downBackground:g.yLabel.neutralBackground:x=g.axis.textColor,i?M.jsx(M.Fragment,{children:i({value:m,y,bgColor:x,isLive:p,direction:v,format:f})}):M.jsxs(M.Fragment,{children:[M.jsx("div",{style:{position:"absolute",left:0,right:n.yAxisWidth,top:y,height:0,borderTop:`1px dashed ${x}`,opacity:.5,pointerEvents:"none",zIndex:2}}),M.jsx("div",{style:{position:"absolute",right:4,top:y,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:x,color:g.yLabel.textColor,fontSize:g.yLabel.fontSize,fontFamily:g.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:M.jsx(cs,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=es;exports.CandlestickSeries=xr;exports.ChartContainer=ls;exports.ChartInstance=qi;exports.Crosshair=Dr;exports.InfoBar=ns;exports.Legend=rs;exports.LineSeries=hs;exports.NumberFlow=cs;exports.PieLegend=as;exports.PieSeries=Ir;exports.PieTooltip=Er;exports.Sparkline=Hr;exports.ThemeProvider=ue;exports.TimeAxis=us;exports.Title=os;exports.Tooltip=_r;exports.XAxis=us;exports.YAxis=Nr;exports.YLabel=Gr;exports.andromeda=Nn;exports.autoGradient=P;exports.ayuMirage=Un;exports.buildHoverSnapshots=ii;exports.buildLastSnapshots=ts;exports.catppuccin=Gn;exports.computeTooltipPosition=pe;exports.createTheme=G;exports.darkTheme=Ui;exports.detectInterval=Pi;exports.dracula=Kn;exports.formatCompact=Et;exports.formatDate=Ai;exports.formatPriceAdaptive=Ge;exports.formatTime=ge;exports.githubLight=qn;exports.gruvbox=Jn;exports.handwritten=Qn;exports.highContrast=er;exports.lavenderMist=ir;exports.lightPink=sr;exports.lightTheme=Xn;exports.materialPalenight=nr;exports.minimalLight=or;exports.mintBreeze=lr;exports.monokaiPro=hr;exports.nightOwl=cr;exports.normalizeTime=ot;exports.oneDarkPro=ur;exports.panda=dr;exports.peachCream=fr;exports.quietLight=mr;exports.resolveAxisFontSize=Ke;exports.resolveAxisTextColor=qe;exports.resolveCandlestickBodyColor=gt;exports.rosePineDawn=gr;exports.sandDune=pr;exports.solarizedLight=br;exports.useChartInstance=st;exports.useCrosshairPosition=be;exports.useLastYValue=wr;exports.usePreviousClose=Mr;exports.useTheme=De;exports.useVisibleRange=is;exports.useYRange=ss;