@wick-charts/react 0.3.4 → 0.3.5
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/README.md +3 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1071 -1071
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),C=require("react/jsx-runtime");var Un=Object.defineProperty,Ns=i=>{throw TypeError(i)},Gn=(i,t,e)=>t in i?Un(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,R=(i,t,e)=>Gn(i,typeof t!="symbol"?t+"":t,e),Ji=(i,t,e)=>t.has(i)||Ns("Cannot "+e),a=(i,t,e)=>(Ji(i,t,"read from private field"),e?e.call(i):t.get(i)),B=(i,t,e)=>t.has(i)?Ns("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),k=(i,t,e,s)=>(Ji(i,t,"write to private field"),t.set(i,e),e),D=(i,t,e)=>(Ji(i,t,"access private method"),e),Oi=(i,t,e,s)=>({set _(n){k(i,t,n)},get _(){return a(i,t,s)}});const me=i=>1-(1-i)**3;class Fe{constructor(t){R(this,"_current"),R(this,"_from"),R(this,"_to"),R(this,"_startTime",0),R(this,"_activeDuration"),R(this,"_defaultDuration"),R(this,"_easing"),R(this,"_lerp"),R(this,"_equals"),R(this,"_animating",!1),this._current=t.initial,this._from=t.initial,this._to=t.initial,this._defaultDuration=t.duration,this._activeDuration=t.duration,this._easing=t.easing??me,this._lerp=t.lerp,this._equals=t.equals??Object.is}get current(){return this._current}get target(){return this._to}get animating(){return this._animating}snap(t){this._current=t,this._from=t,this._to=t,this._animating=!1}setTarget(t,e={}){const s=e.now??performance.now();if(this._animating){if(this._equals(t,this._to))return;this.tick(s)}else if(this._equals(t,this._current))return;const n=e.duration??this._defaultDuration;if(n<=0){this.snap(t);return}this._from=this._current,this._to=t,this._activeDuration=n,this._startTime=s,this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this._startTime;if(e>=this._activeDuration)return this._current=this._to,this._animating=!1,!1;const s=e<=0?0:e/this._activeDuration;return this._current=this._lerp(this._from,this._to,this._easing(s)),!0}}const gs=250,pi={streamTick:gs,fit:gs},Li=250,pe=Li,Qi=Li,Xs=600,Us=Li,Kn=0,Hi=Li,ms=100;class oi{constructor(){R(this,"listeners",new Map)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){var s;(s=this.listeners.get(t))==null||s.delete(e)}emit(t,...e){var s;(s=this.listeners.get(t))==null||s.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function ps(i,t){const e=new Map;return new Proxy(i,{get(s,n){const r=Reflect.get(s,n,s);if(typeof r!="function")return r;const o=e.get(n);if(o)return o;const l=typeof n=="string"?n:String(n),h=r,d=(...c)=>(t.set(l,(t.get(l)??0)+1),h.apply(s,c));return e.set(n,d),d},set(s,n,r){return Reflect.set(s,n,r,s)}})}function bs(i,t,e){const s=document.createElement("canvas");return s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.display="block",s.style.zIndex=String(t),i.appendChild(s),s}class qn extends oi{constructor(t,e){super(),R(this,"mainCanvas"),R(this,"mainCtx"),R(this,"overlayCanvas"),R(this,"overlayCtx"),R(this,"resizeObserver"),R(this,"_size"),R(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=bs(t,0),this.overlayCanvas=bs(t,1);const s=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!s||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?ps(s,e.drawCallsMain):s,this.overlayCtx=e?ps(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(l=>{this.handleResize(l[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const o=t.getBoundingClientRect();if(o.width>0&&o.height>0){const l=window.devicePixelRatio||1,h=l,d=Math.round(o.width*l),c=Math.round(o.height*h);this.mainCanvas.width=d,this.mainCanvas.height=c,this.overlayCanvas.width=d,this.overlayCanvas.height=c,this._size={media:{width:o.width,height:o.height},bitmap:{width:d,height:c},horizontalPixelRatio:d/o.width,verticalPixelRatio:c/o.height}}}handleResize(t){var e,s;let n,r,o,l;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];o=u.inlineSize,l=u.blockSize}else{const c=(s=t.contentBoxSize)==null?void 0:s[0];if(c)o=c.inlineSize,l=c.blockSize;else{const f=t.contentRect;o=f.width,l=f.height}const u=window.devicePixelRatio||1;n=Math.round(o*u),r=Math.round(l*u)}if(n===0||r===0)return;this.mainCanvas.width=n,this.mainCanvas.height=r,this.overlayCanvas.width=n,this.overlayCanvas.height=r;const h=n/o,d=r/l;this._size={media:{width:o,height:l},bitmap:{width:n,height:r},horizontalPixelRatio:h,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:s}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,s),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 Jn(i,t,e,s){const{context:n,bitmapSize:r,horizontalPixelRatio:o}=i;n.strokeStyle=s.crosshair.color,n.lineWidth=1,n.setLineDash([4*o,4*o]);const l=Math.round(t)+.5,h=Math.round(e)+.5;n.beginPath(),n.moveTo(l,0),n.lineTo(l,r.height),n.moveTo(0,h),n.lineTo(r.width,h),n.stroke(),n.setLineDash([])}const Qn=3,Zn=8,vs=900,tr=24,er=11,ir=10,sr=18;function nr(i){const{state:t}=i;if(t==="idle"||t==="has-more")return;const e=i.timeScale.timeToX(i.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){rr(i,e);return}t==="no-data"&&or(i,e)}}function rr({scope:i,theme:t,chartMediaHeight:e,side:s,now:n},r){const{context:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i,d=Qn*l,c=Zn*l,u=tr*l,f=r*l,m=s==="right"?f+u:f-u,g=e/2*h,p=n%vs/vs,v=Math.floor(p*3),w=Gs(t.axis.textColor??"#787b86",.3),x=t.axis.textColor??"#787b86";o.save();for(let y=0;y<3;y++){const M=(y-1)*c,S=m+M;o.beginPath(),o.arc(S,g,d,0,Math.PI*2),o.fillStyle=y===v?x:w,o.fill()}o.restore()}function or({scope:i,theme:t,chartMediaHeight:e,side:s},n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.round(n*o)+.5;r.save(),r.strokeStyle=Gs(t.axis.textColor??"#787b86",.6),r.lineWidth=1,r.setLineDash([4*o,4*o]),r.beginPath(),r.moveTo(h,0),r.lineTo(h,e*l),r.stroke(),r.setLineDash([]);const d=ir*o,c=s==="right"?h-d:h+d,u=sr*l;r.fillStyle=t.axis.textColor??"#787b86",r.font=`${er*o}px ${t.typography.fontFamily}`,r.textAlign=s==="right"?"right":"left",r.textBaseline="top",r.fillText("No more data",c,u),r.restore()}function Gs(i,t){const e=/^#([0-9a-f]{6})$/i.exec(i.trim());if(!e)return i;const s=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(${s}, ${n}, ${r}, ${t})`}function ar(i,t,e,s,n){const{context:r,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i;r.strokeStyle=s.grid.color,r.lineWidth=1,s.grid.style==="dashed"?r.setLineDash([4*l,4*l]):s.grid.style==="dotted"&&r.setLineDash([1*l,3*l]);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(o.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,o.height)}r.stroke(),r.setLineDash([])}function We(i,t,e){return Math.max(t,Math.min(e,i))}function mt(i,t,e){return i+(t-i)*e}function ys(i,t,e,s){const n=Math.exp(-e*s);return t+(i-t)*n}function Ks(i){return 1-(1-i)**3}function Pi(i,t,e){let s=0,n=i.length-1;for(;s<=n;){const r=s+n>>>1,o=e(i[r]);if(o<t)s=r+1;else if(o>t)n=r-1;else return r}return s}class qs extends oi{constructor(){super(...arguments),R(this,"data",[]),R(this,"_visible",!0),R(this,"cachedRange",null),R(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let s=1;s<t.length;s++)if(t[s].time<t[s-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((s,n)=>s.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 s=Math.max(0,Pi(this.data,t,r=>r.time)-1),n=Math.min(this.data.length,Pi(this.data,e,r=>r.time)+1);return this.cachedResult=this.data.slice(s,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 s=Pi(this.data,t,o=>o.time);let n=null,r=e;for(let o=Math.max(0,s-1);o<=Math.min(this.data.length-1,s+1);o++){const l=Math.abs(this.data[o].time-t);l<=r&&(r=l,n=this.data[o])}return n}}class lr{constructor(t,e,s,n=0){R(this,"dragging",!1),R(this,"lastX",0),this.viewport=t,this.timeScale=e,this.canvas=s,this.inputResponseMs=n}setInputResponseMs(t){this.inputResponseMs=Math.max(0,t)}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 s=this.timeScale.pixelDeltaToTimeDelta(-e);this.viewport.pan(s,this.timeScale.getMediaWidth(),this.inputResponseMs)}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair",this.viewport.startRebound(this.timeScale.getMediaWidth()))}isDragging(){return this.dragging}}const hr=150;class cr{constructor(t,e,s=0){R(this,"reboundTimer",null),this.viewport=t,this.timeScale=e,this.inputResponseMs=s}setInputResponseMs(t){this.inputResponseMs=Math.max(0,t)}getInputResponseMs(){return this.inputResponseMs}handleWheel(t){t.preventDefault();const e=ur(t.deltaY,t.deltaMode),s=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),r=Math.min(t.offsetX,n),o=this.timeScale.xToTime(r);this.viewport.zoomAt(o,s,n,this.inputResponseMs),this.reboundTimer!==null&&clearTimeout(this.reboundTimer),this.reboundTimer=setTimeout(()=>{this.reboundTimer=null,this.viewport.startRebound(n)},hr)}cancelPendingRebound(){this.reboundTimer!==null&&(clearTimeout(this.reboundTimer),this.reboundTimer=null)}}function ur(i,t){return t===WheelEvent.DOM_DELTA_LINE?i*8:t===WheelEvent.DOM_DELTA_PAGE?i*24:i}class dr extends oi{constructor(t,e,s,n,r=0){super(),R(this,"zoom"),R(this,"pan"),R(this,"canvas"),R(this,"timeScale"),R(this,"yScale"),R(this,"viewport"),R(this,"onWheel",o=>{this.zoom.handleWheel(o)}),R(this,"onMouseDown",o=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(o)}),R(this,"onMouseMove",o=>{this.pan.isDragging()&&this.pan.handleMouseMove(o),this.emitCrosshair(o.offsetX,o.offsetY)}),R(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),R(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),R(this,"onDblClick",()=>{}),R(this,"lastTouchDist",0),R(this,"lastTouchCenter",0),R(this,"touchCount",0),R(this,"onTouchStart",o=>{o.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=o.touches.length,o.touches.length===1?this.pan.handleMouseDown({button:0,clientX:o.touches[0].clientX}):o.touches.length===2&&(this.lastTouchDist=Math.abs(o.touches[0].clientX-o.touches[1].clientX),this.lastTouchCenter=(o.touches[0].clientX+o.touches[1].clientX)/2)}),R(this,"onTouchMove",o=>{if(o.preventDefault(),o.touches.length===1&&this.touchCount===1)this.pan.handleMouseMove({clientX:o.touches[0].clientX});else if(o.touches.length===2){const l=Math.abs(o.touches[0].clientX-o.touches[1].clientX),h=(o.touches[0].clientX+o.touches[1].clientX)/2,d=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const c=this.lastTouchDist/l,u=this.timeScale.xToTime(h-d.left);this.viewport.zoomAt(u,c,this.timeScale.getMediaWidth(),this.zoom.getInputResponseMs())}this.lastTouchDist=l,this.lastTouchCenter=h}}),R(this,"onTouchEnd",o=>{if(o.touches.length===0){const l=this.touchCount===2;this.pan.handleMouseUp(),l&&this.viewport.startRebound(this.timeScale.getMediaWidth()),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null)}}),this.canvas=t,this.viewport=e,this.timeScale=s,this.yScale=n,this.zoom=new cr(e,s,r),this.pan=new lr(e,s,t,r),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)}setInputResponseMs(t){this.pan.setInputResponseMs(t),this.zoom.setInputResponseMs(t)}emitCrosshair(t,e){const s=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:s,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 fr=new WeakMap;function gr(i,t){fr.set(i,t)}const mr=100,pr={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 xs(i){let t=0;for(const e of Object.values(i))t+=e;return t}const ri=9,Zi=7,Ft=6,ts=9;function br(i,t){return Math.round(i*t).toLocaleString("en-US")}function ws(i,t,e,s,n){return[i.padEnd(ri),t.toFixed(1).padStart(Zi),e.toFixed(2).padStart(Ft),s.toFixed(2).padStart(Ft),br(n,t).padStart(ts)].join(" ")}function Ss(i){return[i.padEnd(ri),"—".padStart(Zi),"—".padStart(Ft),"—".padStart(Ft),"idle".padStart(ts)].join(" ")}function vr(){return["".padEnd(ri),"FPS".padStart(Zi),"ms".padStart(Ft),"worst".padStart(Ft),"calls/s".padStart(ts)].join(" ")}function yr(i){const t=xs(i.drawCalls.main),e=xs(i.drawCalls.overlay),s=i.frameCount.main===0?Ss("Main"):ws("Main",i.mainRendersPerSec,i.mainFrameMs.last,i.mainFrameMs.p95,t),n=i.frameCount.overlay===0?Ss("Overlay"):ws("Overlay",i.overlayRendersPerSec,i.overlayFrameMs.last,i.overlayFrameMs.p95,e),r=[vr(),s,n],o=Object.keys(i.perSeries);if(o.length>1){r.push(""),r.push("Per series (main pass)"),r.push(["".padEnd(ri),"ms".padStart(Ft),"worst".padStart(Ft)].join(" "));for(const l of o){const h=i.perSeries[l];r.push([` ${l}`.padEnd(ri),h.last.toFixed(2).padStart(Ft),h.p95.toFixed(2).padStart(Ft)].join(" "))}}return r.join(`
|
|
2
|
-
`)}class xr{constructor(t,e,s=mr){R(this,"element"),R(this,"unsubscribe"),R(this,"updateIntervalMs"),R(this,"lastUpdate",0),this.updateIntervalMs=s;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,pr),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=yr(t))}}const wr=5e3,Sr=2e3,Mr=30;function Di(i,t,e){let s=0;for(;s<t.length&&t[s]<e;)s++;s>0&&(i.splice(0,s),t.splice(0,s))}function zi(i,t,e){const s=i.length-e;s>0&&(i.splice(0,s),t.splice(0,s))}function Ei(i){if(i.length===0)return{last:0,p50:0,p95:0};const t=[...i].sort((e,s)=>e-s);return{last:i[i.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function Ms(i){if(i.length<2)return 0;const t=i[i.length-1]-i[0];return t<=0?0:(i.length-1)*1e3/t}function ks(i){const t={};for(const[e,s]of i)t[e]=s;return t}class Vi{constructor(t={}){R(this,"drawCallsMain",new Map),R(this,"drawCallsOverlay",new Map),R(this,"mainMs",[]),R(this,"overlayMs",[]),R(this,"mainStamps",[]),R(this,"overlayStamps",[]),R(this,"perSeriesMs",new Map),R(this,"perSeriesStamps",new Map),R(this,"listeners",new Set),R(this,"windowMs"),R(this,"maxSamples"),R(this,"heapInterval"),R(this,"heapCounter",0),R(this,"heapMb",null),R(this,"mainFrameCount",0),R(this,"overlayFrameCount",0),R(this,"lastStamp",0),this.windowMs=t.windowMs??wr,this.maxSamples=t.maxSamples??Sr,this.heapInterval=t.heapSampleEveryNFrames??Mr}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,s){if(this.lastStamp=s,t==="main"?(this.mainMs.push(e),this.mainStamps.push(s),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(s),this.overlayFrameCount++),this.trimAll(s),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,s=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(s)}trimAll(t){const e=t-this.windowMs;Di(this.mainMs,this.mainStamps,e),Di(this.overlayMs,this.overlayStamps,e),zi(this.mainMs,this.mainStamps,this.maxSamples),zi(this.overlayMs,this.overlayStamps,this.maxSamples);for(const s of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(s),r=this.perSeriesStamps.get(s);!n||!r||(Di(n,r,e),zi(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[s,n]of this.perSeriesMs)t[s]=Ei(n);const e=Ms(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:Ms(this.overlayStamps),fps:e,mainFrameMs:Ei(this.mainMs),overlayFrameMs:Ei(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:ks(this.drawCallsMain),overlay:ks(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 gi{constructor(t){R(this,"dirty",!1),R(this,"rafId",null),R(this,"callback"),R(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 be=6e4,ae=36e5,te=864e5;function ct(i){return i instanceof Date?i.getTime():i}function kr(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:ct(t.time)}))}function Cr(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:ct(t.time)}))}function Js(i){if(i.length<2)return te;const t=[];for(let e=1;e<Math.min(i.length,20);e++)t.push(i[e]-i[e-1]);return t.sort((e,s)=>e-s),t[Math.floor(t.length/2)]}function ai(i,t){const e=new Date(i);return t>=te?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=ae?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 Qs(i){return new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Tr(i){const t=[1e3,5e3,1e4,15e3,3e4],e=[be,5*be,10*be,15*be,30*be],s=[ae,2*ae,4*ae,6*ae,12*ae],n=[te,7*te,30*te,90*te,365*te];return i<be?[...t,...e,...s,...n]:i<ae?[...e,...s,...n]:i<te?[...s,...n]:n}const Rr=50,Lr=80;class Zs{constructor(){R(this,"from",0),R(this,"to",0),R(this,"width",1),R(this,"pixelRatio",1),R(this,"dataInterval",null),R(this,"labelCountHintValue",null),R(this,"minSpacingValue",null),R(this,"resolvedInterval",null),R(this,"lastInterval",null),R(this,"lastWant",null),R(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Lr}update(t,e,s,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=s,n!==void 0&&n>0){const r=Cs(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Ir(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Ar(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 o=Cs(t);this.lastBucketKey!==null&&this.lastBucketKey!==o&&this.resetHysteresis(),this.lastBucketKey=o,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,s=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(Rr,Math.floor((this.to-s)/e)+1)),r=[];for(let o=0;o<n;o++)r.push(s+o*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=Tr(this.dataInterval),e=this.to-this.from,s=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,s)}else n=s;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=s;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],o=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){r=t[l],o=l;break}if(this.labelCountHint!=null&&o>0&&this.countTicks(r)<this.labelCountHint){const l=t[o-1];l>=s&&(r=l)}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 Cs(i){return i<6e4?0:i<36e5?1:i<864e5?2:3}function Ir(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Ar(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function tn(i){const t=Math.abs(i);if(t===0)return"0";if(t<1e-12)return i.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),s=Math.min(12,e+4),n=i.toFixed(s);return n.includes(".")?n.replace(/\.?0+$/,""):n}function en(i){return Number.isNaN(i)?"—":i===1/0?"∞":i===-1/0?"−∞":null}function oe(i,t){const e=en(i);if(e!==null)return e;const s=Math.abs(i),n=(t==null?void 0:t.decimals)??2,r=(o,l,h)=>{const d=o/l,c=Number.parseFloat(d.toFixed(n));return Math.abs(c)>=1e3?null:`${d.toFixed(n)}${h}`};return s>=1e15?i.toExponential(2):s>=1e12?r(i,1e12,"T")??i.toExponential(2):s>=1e9?r(i,1e9,"B")??`${(i/1e12).toFixed(n)}T`:s>=1e6?r(i,1e6,"M")??`${(i/1e9).toFixed(n)}B`:s>=1e3?r(i,1e3,"K")??`${(i/1e6).toFixed(n)}M`:s<1?tn(i):s<100?i.toFixed(2):i.toFixed(0)}function es(i){const t=en(i);if(t!==null)return t;const e=Math.abs(i);return e===0?"0":e<1?tn(i):e<100?i.toFixed(4):e>=1e7?oe(i):e<1e4?i.toFixed(2):i.toFixed(0)}function Br(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function Wr(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e>=5?5:e>=2?2:1)*t}const Fr=50,Pr=50;class sn{constructor(){R(this,"min",0),R(this,"max",0),R(this,"height",1),R(this,"pixelRatio",1),R(this,"labelCountHintValue",null),R(this,"minSpacingValue",null),R(this,"resolvedInterval",null),R(this,"lastInterval",null),R(this,"lastRawInterval",null),R(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Pr}update(t,e,s){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=s,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Dr(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=zr(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,s=Math.max(0,Math.min(Fr,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<s;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 oe(t);const e=this.resolvedInterval,s=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(s)}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,s=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/s;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const o=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let r=Br(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const o=Wr(n);o>=e&&o>0&&(r=o)}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 Dr(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function zr(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function re(i,t){return i===!1?0:i===void 0?t:i}function Er(i,t,e,s){const n=i==null?void 0:i.get(t);if(!n)return 1;if(s<=0)return i==null||i.delete(t),1;const r=We((e-n.startTime)/s,0,1),o=Ks(r);return r>=1&&(i==null||i.delete(t)),o}function Vr(i){let t=0,e=0;for(const s of i)s>0?t+=s:s<0&&(e+=s);return{positive:t,negative:e}}function Yr(i){return i.positive>0?i.positive:i.negative<0?i.negative:0}function jr(i){return i.positive>0?100:i.negative<0?-100:0}const _r=16,Or=(i,t,e)=>i+(t-i)*e;var xt,Dt,le;class nn{constructor(t){R(this,"stores"),B(this,xt),B(this,Dt),B(this,le,0),R(this,"entries"),this.stores=Array.from({length:t},()=>new qs),k(this,xt,new Array(t).fill(null)),k(this,Dt,new Array(t).fill(Number.NaN)),this.entries=Array.from({length:t},()=>new Map)}get displayedLastValues(){return a(this,xt).map(t=>(t==null?void 0:t.current)??null)}get lastSeededTimes(){return a(this,Dt)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var s;const n=this.stores[e];if(!n)return;const r=Cr(t??[]);n.setData(r),(s=this.entries[e])==null||s.clear()}appendPoint(t,e=0){var s;const n=this.stores[e];if(!n)return;const r=t,o=ct(r.time),l=this.createEntry(e,o,performance.now());n.append({...r,time:o}),l&&((s=this.entries[e])==null||s.set(o,l))}updateLastPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t;s.updateLast({...n,time:ct(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var s;(s=this.stores[t])==null||s.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();for(let t=0;t<a(this,xt).length;t++)a(this,xt)[t]=null,a(this,Dt)[t]=Number.NaN;k(this,le,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(const t of a(this,xt))if(t!=null&&t.animating)return!0;return!1}advanceLiveTracking(t){if(t===a(this,le))return;const e=re(this.getCommonOptions().smoothMs,Qi),s=a(this,le)?Math.min(t-a(this,le),_r):0,n=t-s;for(let r=0;r<this.stores.length;r++){const o=this.stores[r].last();if(!o){a(this,xt)[r]=null,a(this,Dt)[r]=Number.NaN;continue}const l=a(this,Dt)[r]!==o.time,h=a(this,xt)[r];if(h===null||l||e<=0){a(this,xt)[r]=new Fe({initial:o.value,duration:e>0?e:0,easing:me,lerp:Or}),a(this,Dt)[r]=o.time;continue}h.setTarget(o.value,{duration:e,now:n}),h.tick(t)}k(this,le,t)}entranceProgress(t,e,s){const n=re(this.getCommonOptions().entryMs,pe);return Er(this.entries[t],e,s,n)}effectiveValue(t,e,s){var n;if(a(this,Dt)[t]!==e)return s;const r=(n=a(this,xt)[t])==null?void 0:n.current;return r===void 0?s:r}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 s;return((s=this.stores[0])==null?void 0:s.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const s=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const o=this.stores[r].getVisibleData(t-e,t+e);if(o.length===0)continue;let l=o[0],h=Math.abs(o[0].time-t);for(let d=1;d<o.length;d++){const c=Math.abs(o[d].time-t);c<=h&&(h=c,l=o[d])}n.push({layerIndex:r,time:l.time,value:l.value,color:s[r%s.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const o=(t=this.stores[0])==null?void 0:t.last();return o?{value:o.value,isLive:!0}:null}let e=-1/0;for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const s=this.getCommonOptions().stacking;if(s==="off"){for(let o=this.stores.length-1;o>=0;o--){if(!this.stores[o].isVisible())continue;const l=this.stores[o].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();n.push(l&&l.time===e?l.value:0)}const r=Vr(n);return{value:s==="percent"?jr(r):Yr(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].last();n&&e.push({layerIndex:s,time:n.time,value:n.value,color:t[s%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 s=this.getCommonOptions().stacking;if(s==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(s==="off"){let h=1/0,d=-1/0;for(const c of n)for(const u of c)Number.isFinite(u.value)&&(u.value<h&&(h=u.value),u.value>d&&(d=u.value));return h<1/0?{min:h,max:d}:null}const r=new Map;for(let h=0;h<n.length;h++)for(const d of n[h]){let c=r.get(d.time);c||(c=new Array(n.length).fill(0),r.set(d.time,c)),c[h]=Number.isFinite(d.value)?d.value:0}let o=0,l=0;for(const h of r.values()){let d=0,c=0;for(const u of h)u>0?d+=u:c+=u;d>l&&(l=d),c<o&&(o=c)}return l>o?{min:o,max:l}:null}}xt=new WeakMap,Dt=new WeakMap,le=new WeakMap;const Hr={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function Ts(i){if(!i)return{};const t={...i};return i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}class $r extends nn{constructor(t,e){super(t),R(this,"options"),this.options={...Hr,...Ts(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...Ts(t)}}getCommonOptions(){return this.options}createEntry(t,e,s){const n=this.options.entryAnimation??"fade-grow",r=re(this.options.entryMs,pe);return n==="none"||r<=0?null:{startTime:s}}applyTheme(t,e){const s=e.seriesColors,n=this.options.colors.map((r,o)=>r===s[o]?t.seriesColors[o]??r:r);this.updateOptions({colors:n})}applyBarTransform(t,e,s,n,r,o){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:s,barHeight:n,x:r,barWidth:o,alpha:1};let h=s,d=n,c=r,u=1;if((l==="fade"||l==="fade-grow")&&(u=t),l==="grow"||l==="fade-grow"){const f=n*t;s<e?h=e-f:h=e,d=Math.max(1,f)}return l==="slide"&&(c=r+(1-t)*o,u=t),{topY:h,barHeight:d,x:c,barWidth:o,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:s,yScale:n,dataInterval:r}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange(),d=performance.now();let c=0;for(const x of this.stores){if(!x.isVisible())continue;const y=x.getVisibleData(h.from,h.to).length;if(y>c&&(c=y),c>2)break}const u=s.barWidthBitmap(r),f=Math.round(30*l),m=c<=2?Math.min(f,u):u,g=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),p=Math.floor(g/2),v=n.getRange().min<0,w=v?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const x=this.options.colors[0],y=this.options.colors.length>1?this.options.colors[1]:x,M=this.stores[0].getVisibleData(h.from,h.to);for(const S of M){if(!Number.isFinite(S.value))continue;const P=this.effectiveValue(0,S.time,S.value),b=this.entranceProgress(0,S.time,d),L=s.timeToBitmapX(S.time);if(P>=0){const I=n.valueToBitmapY(P),T=Math.max(1,w-I);this.drawAnimatedBar(o,b,w,I,T,L-p,g,P>=0?x:y)}else{const I=n.valueToBitmapY(P),T=Math.max(1,I-w);this.drawAnimatedBar(o,b,w,w,T,L-p,g,y)}}}else{const x=this.stores.map(M=>M.isVisible()?M.getVisibleData(h.from,h.to):[]),y=new Map;for(let M=0;M<x.length;M++)for(const S of x[M]){if(!Number.isFinite(S.value))continue;let P=y.get(S.time);P||(P=[],y.set(S.time,P)),P.push({layer:M,value:this.effectiveValue(M,S.time,S.value)})}for(const[M,S]of y){S.sort((b,L)=>Math.abs(L.value)-Math.abs(b.value));const P=s.timeToBitmapX(M);for(const{layer:b,value:L}of S){const I=this.options.colors[b%this.options.colors.length],T=this.entranceProgress(b,M,d);if(L>=0){const W=n.valueToBitmapY(L),F=Math.max(1,w-W);this.drawAnimatedBar(o,T,w,W,F,P-p,g,I)}else{const W=n.valueToBitmapY(L),F=Math.max(1,W-w);this.drawAnimatedBar(o,T,w,w,F,P-p,g,I)}}}}if(v){o.strokeStyle=t.theme.grid.color,o.lineWidth=1;const x=Math.round(w)+.5;o.beginPath(),o.moveTo(0,x),o.lineTo(e.bitmapSize.width,x),o.stroke()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:r,dataInterval:o}=t,{context:l,horizontalPixelRatio:h}=s,d=n.getRange(),c=performance.now();let u=0;for(const y of this.stores){if(!y.isVisible())continue;const M=y.getVisibleData(d.from,d.to).length;if(M>u&&(u=M),u>2)break}const f=n.barWidthBitmap(o),m=Math.round(30*h),g=u<=2?Math.min(m,f):f,p=Math.max(1,Math.round(g*this.options.barWidthRatio)-2),v=Math.floor(p/2),w=this.stores.map(y=>y.isVisible()?y.getVisibleData(d.from,d.to):[]);if(w.every(y=>y.length===0))return;const x=new Map;for(let y=0;y<w.length;y++)for(const M of w[y]){let S=x.get(M.time);S||(S=new Array(w.length).fill(0),x.set(M.time,S));const P=Number.isFinite(M.value)?M.value:0;S[y]=this.stores[y].isVisible()?this.effectiveValue(y,M.time,P):0}for(let y=0;y<w.length;y++){const M=this.options.colors[y%this.options.colors.length];for(const[S,P]of x){const b=P[y];if(b===0)continue;const L=n.timeToBitmapX(S);let I=0,T=0;for(let F=0;F<y;F++){const V=P[F];V>0?I+=V:T+=V}const W=this.entranceProgress(y,S,c);if(e){let F=0,V=0;for(const z of P)z>0?F+=z:V+=z;if(b>0&&F>0){const z=I/F*100,_=(I+b)/F*100,N=r.valueToBitmapY(_),H=r.valueToBitmapY(z),it=Math.max(1,H-N);this.drawAnimatedBar(l,W,H,N,it,L-v,p,M)}else if(b<0&&V<0){const z=T/V*-100,_=(T+b)/V*-100,N=r.valueToBitmapY(z),H=r.valueToBitmapY(_),it=Math.max(1,H-N);this.drawAnimatedBar(l,W,N,N,it,L-v,p,M)}}else if(b>0){const F=r.valueToBitmapY(I+b),V=r.valueToBitmapY(I),z=Math.max(1,V-F);this.drawAnimatedBar(l,W,V,F,z,L-v,p,M)}else{const F=r.valueToBitmapY(T),V=r.valueToBitmapY(T+b),z=Math.max(1,V-F);this.drawAnimatedBar(l,W,F,F,z,L-v,p,M)}}}}fillBar(t,e,s,n,r,o){t.fillStyle=o,t.fillRect(e,s,n,r)}drawAnimatedBar(t,e,s,n,r,o,l,h){const d=this.options.entryAnimation??"fade-grow";if(e>=1||d==="none"){this.fillBar(t,o,n,l,r,h);return}const c=this.applyBarTransform(e,s,n,r,o,l);t.save(),t.globalAlpha=c.alpha,t.fillStyle=h,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function Rs(i,t){return i.length<=t?i:Xr(i,t,e=>e.time,e=>e.value)}function Nr(i,t){if(i.length<=t)return i;const e=Math.ceil(i.length/t),s=[];for(let n=0;n<i.length;n+=e){const r=Math.min(n+e,i.length);let o=-1/0,l=1/0,h=0;for(let d=n;d<r;d++)i[d].high>o&&(o=i[d].high),i[d].low<l&&(l=i[d].low),h+=i[d].volume??0;s.push({time:i[n].time,open:i[n].open,high:o,low:l,close:i[r-1].close,volume:h})}return s}function Xr(i,t,e,s){if(t>=i.length||t<3)return i;const n=[i[0]],r=(i.length-2)/(t-2);let o=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*r)+1,d=Math.min(Math.floor((l+2)*r)+1,i.length-1);let c=0,u=0;const f=d,m=Math.min(Math.floor((l+3)*r)+1,i.length),g=m-f;if(g>0){for(let y=f;y<m;y++)c+=e(i[y]),u+=s(i[y]);c/=g,u/=g}let p=-1,v=h;const w=e(i[o]),x=s(i[o]);for(let y=h;y<d;y++){const M=Math.abs((w-c)*(s(i[y])-x)-(w-e(i[y]))*(u-x));M>p&&(p=M,v=y)}n.push(i[v]),o=v}return n.push(i[i.length-1]),n}function is(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.fontSize)!==void 0?i.axis.x.fontSize:t==="y"&&((s=i.axis.y)==null?void 0:s.fontSize)!==void 0?i.axis.y.fontSize:i.axis.fontSize}function ss(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.textColor)!==void 0?i.axis.x.textColor:t==="y"&&((s=i.axis.y)==null?void 0:s.textColor)!==void 0?i.axis.y.textColor:i.axis.textColor}function pt(i){return Array.isArray(i)?i.source??i[0]:i}const Ls=new Map;function Ur(i){return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)]}function Ie(i,t){if(i.startsWith("rgba"))return i.replace(/[\d.]+\)\s*$/,`${t})`);if(i.startsWith("rgb("))return i.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=i+t;let s=Ls.get(e);if(s)return s;const[n,r,o]=Ur(i);return s=`rgba(${n}, ${r}, ${o}, ${t})`,Ls.set(e,s),s}const Gr=(i,t,e)=>({time:t.time,open:i.open+(t.open-i.open)*e,high:i.high+(t.high-i.high)*e,low:i.low+(t.low-i.low)*e,close:i.close+(t.close-i.close)*e,volume:i.volume===void 0||t.volume===void 0?t.volume:i.volume+(t.volume-i.volume)*e}),Kr=(i,t)=>i.time===t.time&&i.open===t.open&&i.high===t.high&&i.low===t.low&&i.close===t.close&&i.volume===t.volume,qr={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6};function Is(i){if(!i)return{};const t={...i};return i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}var kt,xe,we;class Jr{constructor(t,e){R(this,"store"),R(this,"options"),B(this,kt,null),B(this,xe,Number.NaN),B(this,we,0),R(this,"entries",new Map),this.store=t,this.options={...qr,...Is(e)}}get displayedLast(){var t;return((t=a(this,kt))==null?void 0:t.current)??null}updateOptions(t){this.options={...this.options,...Is(t)}}getColor(){return pt(this.options.up.body)}setData(t){this.store.setData(kr(t??[])),this.entries.clear()}appendPoint(t){const e=t,s=ct(e.time);this.store.append({...e,time:s});const n=this.options.entryAnimation??"unfold",r=re(this.options.entryMs,pe);n!=="none"&&r>0&&this.entries.set(s,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:ct(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[pt(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(),k(this,kt,null),k(this,xe,Number.NaN),k(this,we,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(){var t;return!!(this.entries.size>0||(t=a(this,kt))!=null&&t.animating)}entranceProgress(t,e){const s=this.entries.get(t);if(!s)return 1;const n=re(this.options.entryMs,pe);if(n<=0)return this.entries.delete(t),1;const r=We((e-s.startTime)/n,0,1),o=Ks(r);return r>=1&&this.entries.delete(t),o}advanceLiveTracking(t){const e=this.store.last();if(!e){k(this,kt,null),k(this,xe,Number.NaN);return}const s=a(this,xe)!==e.time,n=re(this.options.smoothMs,Qi);if(a(this,kt)===null||s||n<=0){k(this,kt,new Fe({initial:{...e},duration:n>0?n:0,easing:me,lerp:Gr,equals:Kr})),k(this,xe,e.time),k(this,we,t);return}const r=Math.min(t-a(this,we),16),o=t-r;a(this,kt).setTarget(e,{duration:n,now:o}),a(this,kt).tick(t),k(this,we,t)}render(t){const{scope:e,timeScale:s,yScale:n,dataInterval:r}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange(),d=performance.now();this.advanceLiveTracking(d);let c=this.store.getVisibleData(h.from,h.to);const u=e.mediaSize.width,f=c.length>u*2;if(f&&(c=Nr(c,Math.round(u*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const L=c.length-1;c[L].time===this.displayedLast.time&&(c=[...c.slice(0,L),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const L of c)this.entries.has(L.time)&&m.set(L.time,this.entranceProgress(L.time,d));const g=s.barWidthBitmap(r),p=Math.round(30*l),v=c.length<=2?Math.min(p,g):g,w=Math.max(1,Math.round(l));let x=Math.max(1,Math.round(v*this.options.bodyWidthRatio)-2);(x&1)!==(w&1)&&(x=x>1?x-1:2);const y=Math.floor(x/2),M=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:o,data:c,timeScale:s,chartHeight:M,barWidth:v,wickWidth:w,entranceByTime:m});const S=[],P=[];for(const L of c)L.close>=L.open?S.push(L):P.push(L);const b={ctx:o,timeScale:s,yScale:n,halfBody:y,bodyWidth:x,wickWidth:w,entranceByTime:m};this.drawCandles({...b,candles:S,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...b,candles:P,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:s,chartHeight:n,barWidth:r,wickWidth:o,entranceByTime:l}){let h=0;for(const p of e)Number.isFinite(p.volume)&&p.volume>h&&(h=p.volume);if(h===0)return;const d=n*.2;let c=Math.max(1,r-2);(c&1)!==(o&1)&&(c=c>1?c-1:2);const u=Math.floor(c/2),f=Ie(pt(this.options.up.body),.2),m=Ie(pt(this.options.down.body),.2),g=this.options.entryAnimation??"unfold";for(const p of e){if(!Number.isFinite(p.volume)||p.volume<=0)continue;const v=p.volume,w=s.timeToBitmapX(p.time),x=Math.max(1,v/h*d),y=p.close>=p.open;t.fillStyle=y?f:m;const M=(l==null?void 0:l.get(p.time))??1;if(M>=1||g==="none"){t.fillRect(w-u,n-x,c,x);continue}const S=Yi(M,g,{x:w-u,barWidth:c,anchorY:n,topY:n-x,bottomY:n});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,c,Math.max(1,S.bottomY-S.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:s,yScale:n,halfBody:r,bodyWidth:o,wickWidth:l,body:h,wickColor:d,entranceByTime:c}){if(e.length===0)return;const u=this.options.entryAnimation??"unfold",f=o+2;t.fillStyle=d;for(const g of e){const p=(c==null?void 0:c.get(g.time))??1,v=s.timeToBitmapX(g.time),w=n.valueToBitmapY(g.open),x=n.valueToBitmapY(g.high),y=n.valueToBitmapY(g.low),M=v-Math.floor(l/2);if(p>=1||u==="none"){t.fillRect(M,x,l,y-x);continue}const S=Yi(p,u,{x:M,barWidth:f,anchorY:w,topY:x,bottomY:y});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,l,Math.max(1,S.bottomY-S.topY)),t.restore()}const m=Array.isArray(h);for(const g of e){const p=(c==null?void 0:c.get(g.time))??1,v=s.timeToBitmapX(g.time),w=n.valueToBitmapY(g.open),x=n.valueToBitmapY(g.close),y=Math.min(w,x),M=Math.max(w,x),S=Math.max(1,M-y),P=p<1&&u!=="none";let b=v-r,L=y,I=S,T=1;if(P){const W=Yi(p,u,{x:v-r,barWidth:f,anchorY:w,topY:y,bottomY:M});b=W.x,L=W.topY,I=Math.max(1,W.bottomY-W.topY),T=W.alpha}if(P&&t.save(),m&&I>2){const W=t.createLinearGradient(0,L,0,L+I);W.addColorStop(0,h[0]),W.addColorStop(1,h[1]),t.fillStyle=W}else t.fillStyle=m?h[0]:h;P&&(t.globalAlpha=T),t.fillRect(b,L,o,I),P&&t.restore()}}}kt=new WeakMap,xe=new WeakMap,we=new WeakMap;function Yi(i,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:i};case"unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,i),bottomY:mt(e.anchorY,e.bottomY,i),alpha:1};case"slide":return{x:e.x+(1-i)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:i};case"fade-unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,i),bottomY:mt(e.anchorY,e.bottomY,i),alpha:i}}}const Qr={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function As(i){if(!i)return{};const t={...i};return i.areaFill!==void 0&&i.area===void 0&&(t.area={visible:!!i.areaFill}),i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}class Zr extends nn{constructor(t,e){super(t),R(this,"options"),R(this,"areaGradientCache",new Map),this.options={...Qr,...As(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...As(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,s){var n;const r=this.options.entryAnimation??"grow",o=re(this.options.entryMs,pe);if(r==="none"||o<=0)return null;const l=(n=this.stores[t])==null?void 0:n.last();return{startTime:s,fromTime:l?l.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 s;return(s=this.entries[t])==null?void 0:s.get(e)}resolvedPulseMs(){return re(this.options.pulseMs,Xs)}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 s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].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,s,n){const r=this.stores[t],o=r.last();if(!o)return null;const l=e.timeToBitmapX(o.time),h=s.valueToBitmapY(this.effectiveValue(t,o.time,o.value)),d=this.options.entryAnimation??"grow";if(!this.peekEntry(t,o.time)||d!=="grow")return{x:l,y:h};const c=this.entranceProgress(t,o.time,n);if(c>=1)return{x:l,y:h};const u=r.getAll();if(u.length<2)return{x:l,y:h};const f=u[u.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=e.timeToBitmapX(f.time),g=s.valueToBitmapY(f.value);return{x:mt(m,l,c),y:mt(g,h,c)}}renderOff(t){var e;const{scope:s,timeScale:n,yScale:r}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=performance.now(),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){if(!this.stores[m].isVisible())continue;let g=this.stores[m].getVisibleData(l.from,l.to);const p=s.mediaSize.width;if(g.length>p*2&&(g=Rs(g,Math.round(p*1.5))),g.length<2)continue;const v=this.options.colors[m%this.options.colors.length],w=g[g.length-1],x=this.peekEntry(m,w.time),y=this.entranceProgress(m,w.time,u),M=x&&f==="fade"&&y<1,S=this.trailingEndpoint(m,n,r,u)??{x:n.timeToBitmapX(w.time),y:r.valueToBitmapY(this.effectiveValue(m,w.time,w.value))},P=S.x,b=S.y;M&&(o.save(),o.globalAlpha=y);const L=g.length-1,I=[];let T=null;for(let F=0;F<L;F++){const V=g[F].value;if(!Number.isFinite(V)){T=null;continue}T||(T=[],I.push(T)),T.push({x:n.timeToBitmapX(g[F].time),y:r.valueToBitmapY(V)})}const W=(e=g[L])==null?void 0:e.value;if(Number.isFinite(P)&&Number.isFinite(b)&&Number.isFinite(W)&&(T?T.push({x:P,y:b}):I.push([{x:P,y:b}])),d&&I.some(F=>F.length>=2)){o.beginPath();for(const F of I)if(!(F.length<2)){o.moveTo(F[0].x,F[0].y);for(let V=1;V<F.length;V++)o.lineTo(F[V].x,F[V].y)}o.strokeStyle=v,o.lineWidth=c,o.lineJoin="round",o.lineCap="round",o.stroke()}if(d){const F=Math.max(1,c/2);let V=!1;for(const z of I)z.length===1&&(V||(o.beginPath(),V=!0),o.moveTo(z[0].x+F,z[0].y),o.arc(z[0].x,z[0].y,F,0,Math.PI*2));V&&(o.fillStyle=v,o.fill())}if(this.options.area.visible){const F=s.bitmapSize.height,V=String(m),z=this.areaGradientCache.get(V);let _;z&&z.bottomY===F&&z.color===v?_=z.gradient:(_=o.createLinearGradient(0,0,0,F),_.addColorStop(0,Ie(v,.12)),_.addColorStop(1,Ie(v,.01)),this.areaGradientCache.set(V,{gradient:_,bottomY:F,color:v})),o.fillStyle=_;for(const N of I)if(!(N.length<2)){o.beginPath(),o.moveTo(N[0].x,N[0].y);for(let H=1;H<N.length;H++)o.lineTo(N[H].x,N[H].y);o.lineTo(N[N.length-1].x,F),o.lineTo(N[0].x,F),o.closePath(),o.fill()}}M&&o.restore()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:r}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=s.mediaSize.width,f=this.stores.map(b=>{let L=b.getVisibleData(l.from,l.to);return L.length>u*2&&(L=Rs(L,Math.round(u*1.5))),L}),m=new Set;for(const b of f)for(const L of b)m.add(L.time);const g=Array.from(m).sort((b,L)=>b-L);if(g.length<2)return;const p=f.map((b,L)=>{const I=new Map;for(const T of b)I.set(T.time,this.effectiveValue(L,T.time,T.value));return I}),v=Array.from({length:this.stores.length},()=>new Array(g.length).fill(0));for(let b=0;b<g.length;b++){const L=g[b];let I=0;if(e)for(let W=0;W<this.stores.length;W++){if(!this.stores[W].isVisible())continue;const F=p[W].get(L);Number.isFinite(F)&&(I+=F)}let T=0;for(let W=0;W<this.stores.length;W++){const F=this.stores[W].isVisible()?p[W].get(L):0,V=Number.isFinite(F)?F:0;T+=e&&I>0?V/I*100:V,v[W][b]=T}}const w=performance.now(),x=this.options.entryAnimation??"grow",y=new Map;for(let b=0;b<g.length;b++)y.set(g[b],b);const M=g.length-1,S=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const L=this.stores[b].last();if(!L)continue;const I=this.peekEntry(b,L.time);if(!I)continue;const T=y.get(L.time);T!==M||y.get(I.fromTime)!==T-1||(S[b]=this.entranceProgress(b,L.time,w))}const P=(b,L)=>{if(L>=1||b.length<2)return;const I=b.length-1,T=b[I-1],W=b[I];b[I]=[mt(T[0],W[0],L),mt(T[1],W[1],L)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const L=this.options.colors[b%this.options.colors.length],I=S[b],T=b>0&&this.stores[b-1].isVisible()?S[b-1]:1,W=[];for(let z=0;z<g.length;z++)W.push([n.timeToBitmapX(g[z]),r.valueToBitmapY(v[b][z])]);x==="grow"&&P(W,I);const F=[];for(let z=0;z<g.length;z++){const _=b>0?v[b-1][z]:0;F.push([n.timeToBitmapX(g[z]),r.valueToBitmapY(_)])}x==="grow"&&P(F,T);const V=x==="fade"&&I<1;if(V&&(o.save(),o.globalAlpha=I),this.options.area.visible){o.beginPath(),o.moveTo(W[0][0],W[0][1]);for(let z=1;z<W.length;z++)o.lineTo(W[z][0],W[z][1]);for(let z=F.length-1;z>=0;z--)o.lineTo(F[z][0],F[z][1]);o.closePath(),o.fillStyle=Ie(L,.25),o.fill()}if(d){o.beginPath(),o.moveTo(W[0][0],W[0][1]);for(let z=1;z<W.length;z++)o.lineTo(W[z][0],W[z][1]);o.strokeStyle=L,o.lineWidth=c,o.lineJoin="round",o.lineCap="round",o.stroke()}V&&o.restore()}}drawOverlay(t){const{scope:e,timeScale:s,yScale:n,crosshair:r,dataInterval:o}=t,l=e,h=this.resolvedPulseMs();if(r){const d=this.options.colors,c=this.options.stacking,u=4*l.horizontalPixelRatio,f=[],m=[];for(let p=0;p<this.stores.length;p++){const v=this.stores[p].findNearest(r.time,o);v?(f.push(v.value),m.push(v.time)):(f.push(0),m.push(null))}const g=[];if(c==="off")for(const p of f)g.push(p);else{let p=0;if(c==="percent")for(let w=0;w<f.length;w++)this.stores[w].isVisible()&&(p+=f[w]);let v=0;for(let w=0;w<f.length;w++){const x=this.stores[w].isVisible()?f[w]:0;v+=c==="percent"&&p>0?x/p*100:x,g.push(v)}}for(let p=0;p<this.stores.length;p++){const v=m[p];if(v===null||!this.stores[p].isVisible())continue;const w=d[p%d.length],x=s.timeToBitmapX(v),y=n.valueToBitmapY(g[p]);e.context.beginPath(),e.context.arc(x,y,u+3*l.horizontalPixelRatio,0,Math.PI*2);const M=w.startsWith("#")?w+"40":/^rgb\(/i.test(w)?w.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):w.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=M,e.context.fill(),e.context.beginPath(),e.context.arc(x,y,u,0,Math.PI*2),e.context.fillStyle=w,e.context.fill()}}if(this.hasPulse&&h>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 S=this.trailingEndpoint(u,s,n,d);if(!S)continue;this.drawPulse({ctx:e.context,x:S.x,y:S.y,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h});continue}const m=this.stores[u].last();if(!m)continue;const g=m.time,p=c==="percent",v=S=>{const P=I=>{const T=I===u&&S===g?m:this.stores[I].findNearest(S,0);return!T||T.time!==S?0:this.effectiveValue(I,S,T.value)};let b=0;if(p)for(let I=0;I<this.stores.length;I++)this.stores[I].isVisible()&&(b+=P(I));let L=0;for(let I=0;I<=u;I++){if(!this.stores[I].isVisible())continue;const T=P(I);L+=p&&b>0?T/b*100:T}return L};let w=s.timeToBitmapX(g),x=n.valueToBitmapY(v(g));const y=this.options.entryAnimation??"grow",M=this.peekEntry(u,g);if(y==="grow"&&M){const S=this.entranceProgress(u,g,d);if(S<1&&M.fromTime!==g){const P=s.timeToBitmapX(M.fromTime),b=n.valueToBitmapY(v(M.fromTime));w=mt(P,w,S),x=mt(b,x,S)}}this.drawPulse({ctx:e.context,x:w,y:x,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h})}}}drawPulse({ctx:t,x:e,y:s,color:n,pixelRatio:r,pulseMs:o}){const l=3*r,h=.4+.6*Math.abs(Math.sin(performance.now()/o)),d=l+4*r*h;t.beginPath(),t.arc(e,s,d,0,Math.PI*2),t.fillStyle=Ie(n,h*.3),t.fill(),t.beginPath(),t.arc(e,s,l,0,Math.PI*2),t.fillStyle=n,t.fill()}}const rn={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},to={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...rn},animate:!1},$i=Math.PI/180;function eo(i,t){return{...i??{},...t}}function io(i){return{...rn,...i??{}}}function so(i){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return i===!0||i===!1?t:{...t,...i}}function no(i){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return i===!0||i===!1?t:{...t,...i}}const Ae=Math.PI*2,on=.85;function Bs(i){const{bitmapWidth:t,bitmapHeight:e,padTop:s,padBottom:n}=i,r=Math.max(0,i.labelReserve??0),o=Math.min(Math.max(0,s),e),l=Math.min(Math.max(0,n),e-o),h=e-o-l,d=Math.max(0,t-2*r),c=t/2,u=o+h/2,f=Math.max(0,Math.min(d,h)/2*on);return{cx:c,cy:u,maxR:f}}function ro(i){if(!i.startsWith("#"))return!1;const t=parseInt(i.slice(1,3),16),e=parseInt(i.slice(3,5),16),s=parseInt(i.slice(5,7),16);return t*.299+e*.587+s*.114>150}function oo(i,t){if(!i.startsWith("#"))return i;const e=Math.min(255,parseInt(i.slice(1,3),16)+Math.round(255*t)),s=Math.min(255,parseInt(i.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(i.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Ws(i){if(i.startsWith("#"))return{r:parseInt(i.slice(1,3),16)||0,g:parseInt(i.slice(3,5),16)||0,b:parseInt(i.slice(5,7),16)||0,a:1};const t=i.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(s=>s.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 ao(i,t){const e=Ws(i),s=Ws(t),n=s.a,r=Math.round(s.r*n+e.r*(1-n)),o=Math.round(s.g*n+e.g*(1-n)),l=Math.round(s.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var X,G,Ct,at,Se,qt,wt,he,It,Ni,bi,an,ln,hn;class vi{constructor(t){B(this,It),B(this,X,[]),B(this,G),B(this,Ct,-1),B(this,at,[]),B(this,Se,0),B(this,qt,1),B(this,wt,null),B(this,he,[]),k(this,G,D(this,It,Ni).call(this,to,t??{}))}getData(){return a(this,X)}setData(t){const e=t??[];k(this,X,e),k(this,at,new Array(e.length).fill(0)),k(this,qt,a(this,G).animate?0:1),k(this,wt,null);for(const s of a(this,he))s()}onDataChanged(t){return a(this,he).push(t),()=>{const e=a(this,he).indexOf(t);e>=0&&a(this,he).splice(e,1)}}updateOptions(t){var e,s;const n=(e=a(this,G).sliceLabels)==null?void 0:e.mode;k(this,G,D(this,It,Ni).call(this,a(this,G),t??{})),((s=a(this,G).sliceLabels)==null?void 0:s.mode)==="outside"&&n!=="outside"&&k(this,qt,a(this,G).animate?0:1),k(this,wt,null)}getColor(){var t,e;return((t=a(this,X)[0])==null?void 0:t.color)??((e=a(this,G).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&&k(this,wt,null)}hitTest(t,e,s,n,r){var o;if(a(this,X).length===0)return-1;const l=a(this,X).reduce((y,M)=>y+M.value,0);if(l<=0)return-1;const h=((o=a(this,wt))==null?void 0:o.reserve)??0,{cx:d,cy:c,maxR:u}=Bs({bitmapWidth:s,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:h}),f=u,m=f*a(this,G).innerRadiusRatio,g=t-d,p=e-c,v=Math.sqrt(g*g+p*p);if(v>f||v<m)return-1;let w=Math.atan2(p,g)+Math.PI/2;w<0&&(w+=Ae);let x=0;for(let y=0;y<a(this,X).length;y++){const M=a(this,X)[y].value/l*Ae;if(w>=x&&w<x+M)return y;x+=M}return-1}setHoverIndex(t){return a(this,Ct)===t?!1:(k(this,Ct,t),!0)}getHoverIndex(){return a(this,Ct)}getHoverInfo(t){if(a(this,Ct)<0)return null;const e=a(this,X)[a(this,Ct)];if(!e)return null;const s=a(this,X).reduce((r,o)=>r+o.value,0),n=a(this,G).colors??t.seriesColors;return{label:e.label,value:e.value,percent:s>0?e.value/s*100:0,color:e.color??n[a(this,Ct)%n.length]}}getSliceInfo(t){if(a(this,X).length===0)return null;const e=a(this,X).reduce((n,r)=>n+r.value,0),s=a(this,G).colors??t.seriesColors;return a(this,X).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??s[r%s.length]}))}get needsAnimation(){var t;if(!a(this,G).animate)return!1;for(let e=0;e<a(this,at).length;e++){const s=e===a(this,Ct)?1:0;if(Math.abs(a(this,at)[e]-s)>.01)return!0}return((t=a(this,G).sliceLabels)==null?void 0:t.mode)==="outside"&&a(this,qt)<.99}dispose(){k(this,he,[]),k(this,X,[]),k(this,at,[]),k(this,Se,0)}_inspectSliceOffsets(){return a(this,at)}render(t){if(a(this,X).length===0)return;const{scope:e,theme:s,padding:n}=t,{context:r,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=e,d=performance.now(),c=a(this,Se)?Math.min(.05,(d-a(this,Se))/1e3):0;k(this,Se,d);const u=a(this,X).reduce((_,N)=>_+N.value,0);if(u<=0)return;const f=12;for(;a(this,at).length<a(this,X).length;)a(this,at).push(0);if(a(this,G).animate)for(let _=0;_<a(this,X).length;_++){const N=_===a(this,Ct)?1:0;a(this,at)[_]=ys(a(this,at)[_],N,f,c)}const m=io(a(this,G).sliceLabels);r.font=`${m.fontSize*l}px ${s.typography.fontFamily}`,m.mode==="outside"&&a(this,G).animate&&k(this,qt,ys(a(this,qt),1,6,c));const g=a(this,G).colors??s.seriesColors,p=m.mode==="outside"?D(this,It,an).call(this,r,m,u,l):0,{cx:v,cy:w,maxR:x}=Bs({bitmapWidth:o.width,bitmapHeight:o.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:p}),y=x,M=y*a(this,G).innerRadiusRatio,S=a(this,G).padAngle*$i,P=8*l,b=a(this,G).shadow??!1,L=so(b),I=a(this,G).innerShadow??!1,T=no(I);let W=-Math.PI/2;for(let _=0;_<a(this,X).length;_++){const N=a(this,X)[_],H=N.value/u*Ae,it=W+S/2,U=W+H-S/2,bt=W+H/2,vt=N.color??g[_%g.length];if(U<=it){W+=H;continue}const St=a(this,at)[_]*P,Q=Math.cos(bt)*St,Xt=Math.sin(bt)*St,yt=v+Q,ut=w+Xt;r.beginPath(),r.arc(yt,ut,y,it,U),M>0?r.arc(yt,ut,M,U,it,!0):r.lineTo(yt,ut),r.closePath();const dt=r.createRadialGradient(yt,ut,M||0,yt,ut,y);if(dt.addColorStop(0,oo(vt,.15)),I){const Mt=Math.max(0,Math.min(.999,1-T.depth));dt.addColorStop(Mt,vt),dt.addColorStop(1,ao(vt,T.color))}else dt.addColorStop(1,vt);r.fillStyle=dt;const Pt=a(this,at)[_];if(b||Pt>.01){const Mt=b?1:0,Ut=Pt;r.shadowColor=b?L.color:"rgba(0,0,0,0.25)",r.shadowBlur=(L.blur*Mt+12*Ut)*l,r.shadowOffsetX=L.offsetX*Mt*l+Q*.3*Ut,r.shadowOffsetY=L.offsetY*Mt*h+Xt*.3*Ut}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,W+=H}if(m.mode==="none")return;W=-Math.PI/2;const F=s.tooltip.textColor;if(m.mode==="outside"){const _=D(this,It,hn).call(this,{cx:v,cy:w,outerR:y,total:u,palette:g,labels:m,hpr:l,bitmapHeight:o.height}),N=_.length>1?Math.min(.06,.9/(_.length-1)):0;for(let H=0;H<_.length;H++){const it=_[H];if(it===null)continue;const U=H*N,bt=We((a(this,qt)-U)/(1-U),0,1);D(this,It,ln).call(this,{context:r,entry:it,textColor:F,labels:m,hpr:l,progress:bt})}return}const V=M>0?(y+M)/2:y*.65;r.textAlign="center",r.textBaseline="middle";const z=m.minSliceAngle*$i;for(let _=0;_<a(this,X).length;_++){const N=a(this,X)[_],H=N.value/u*Ae;if(H>=z){const it=W+H/2,U=a(this,at)[_]*P,bt=N.color??g[_%g.length],vt=D(this,It,bi).call(this,N,u,m.content),St=r.measureText(vt).width,Q=m.fontSize*1.2*l,Xt=H<Math.PI?2*V*Math.sin(H/2):2*V,yt=St>Xt-4*l,ut=M>0&&V-M<Q;if(!yt&&!ut){const dt=v+Math.cos(it)*(V+U),Pt=w+Math.sin(it)*(V+U);r.fillStyle=ro(bt)?"#000000":"#ffffff",r.fillText(vt,dt,Pt)}}W+=H}}}X=new WeakMap,G=new WeakMap,Ct=new WeakMap,at=new WeakMap,Se=new WeakMap,qt=new WeakMap,wt=new WeakMap,he=new WeakMap,It=new WeakSet,Ni=function(i,t){const e={...i,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=eo(i.sliceLabels,t.sliceLabels)),e},bi=function(i,t,e){const s=t>0?i.value/t*100:0,n=`${s.toFixed(s>=10?0:1)}%`;return e==="percent"?n:e==="label"?i.label:`${i.label} ${n}`},an=function(i,t,e,s){const n=i.font;if(a(this,wt)&&a(this,wt).fontScale===s&&a(this,wt).font===n)return a(this,wt).reserve;let r=0;for(const h of a(this,X)){const d=D(this,It,bi).call(this,h,e,t.content),c=i.measureText(d).width;c>r&&(r=c)}const o=Math.max(t.distance,t.elbowLen),l=(r+(o+Math.max(0,t.railWidth)+t.legPad+4)*s)/on;return k(this,wt,{fontScale:s,font:n,reserve:l}),l},ln=function(i){const{context:t,entry:e,textColor:s,labels:n,hpr:r,progress:o}=i;if(o<=0)return;const{anchorX:l,anchorY:h,elbowX:d,elbowY:c,side:u,text:f,color:m,labelX:g,labelY:p}=e,v=g+u*n.legPad*r,w=We(o/.15,0,1),x=We((o-.15)/.45,0,1),y=We((o-.6)/.4,0,1);if(t.save(),t.globalAlpha=w,t.fillStyle=m,t.beginPath(),t.arc(l,h,2.5*r,0,Ae),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(l,h);const M=l+(d-l)*x,S=h+(c-h)*x;if(t.lineTo(M,S),y>0){const P=d+(g-d)*y,b=c+(p-c)*y;t.lineTo(P,b)}t.stroke(),t.restore()}y>0&&(t.save(),t.globalAlpha=y,t.fillStyle=s,t.textAlign=u>=0?"left":"right",t.textBaseline="middle",t.fillText(f,v,p),t.restore())},hn=function(i){const{cx:t,cy:e,outerR:s,total:n,palette:r,labels:o,hpr:l,bitmapHeight:h}=i,d=new Array(a(this,X).length).fill(null),c=o.elbowLen*l,u=Math.max(o.distance,o.elbowLen)*l,f=Math.max(0,o.railWidth)*l,m=[];let g=-Math.PI/2;const p=o.minSliceAngle*$i;for(let y=0;y<a(this,X).length;y++){const M=a(this,X)[y],S=M.value/n*Ae;if(S>=p){const P=g+S/2,b=a(this,at)[y]*(8*l),L=Math.cos(P),I=Math.sin(P),T=L>=0?1:-1,W=t+L*(s+b),F=e+I*(s+b),V=t+L*(s+b+c),z=e+I*(s+b+c),_=t+L*(s+b+u)+T*f,N=e+I*(s+b+u),H={anchorX:W,anchorY:F,elbowX:V,elbowY:z,side:T,labelX:_,labelY:N,text:D(this,It,bi).call(this,M,n,o.content),color:M.color??r[y%r.length]};d[y]=H,m.push({entry:H})}g+=S}const v=Math.max(1,o.fontSize*o.labelGap)*l,w=o.fontSize*l,x=h-o.fontSize*l;for(const y of[1,-1]){const M=[];for(const b of m)b.entry.side===y&&M.push(b.entry);if(M.length===0)continue;M.sort((b,L)=>b.labelY-L.labelY);const S=[];for(let b=0;b<M.length;b++)for(S.push({count:1,sumIdeal:M[b].labelY,startIdx:b});S.length>=2;){const L=S[S.length-2],I=S[S.length-1],T=L.sumIdeal/L.count,W=I.sumIdeal/I.count,F=T+(L.count-1)*v/2;if(W-(I.count-1)*v/2>=F+v)break;L.count+=I.count,L.sumIdeal+=I.sumIdeal,S.pop()}if(S.length>0){const b=S[0],L=b.sumIdeal/b.count-(b.count-1)*v/2;if(L<w)for(b.sumIdeal+=(w-L)*b.count;S.length>=2;){const I=S[0],T=S[1],W=I.sumIdeal/I.count,F=T.sumIdeal/T.count,V=W+(I.count-1)*v/2;if(F-(T.count-1)*v/2>=V+v)break;I.count+=T.count,I.sumIdeal+=T.sumIdeal,S.splice(1,1)}}if(S.length>0){const b=S[S.length-1],L=b.sumIdeal/b.count+(b.count-1)*v/2;if(L>x)for(b.sumIdeal-=(L-x)*b.count;S.length>=2;){const I=S[S.length-2],T=S[S.length-1],W=I.sumIdeal/I.count,F=T.sumIdeal/T.count,V=W+(I.count-1)*v/2;if(F-(T.count-1)*v/2>=V+v)break;I.count+=T.count,I.sumIdeal+=T.sumIdeal,S.pop()}}const P=(w+x)/2;for(const b of S){const L=(b.count-1)*v,I=b.sumIdeal/b.count;L>x-w&&I-L/2<w&&(b.sumIdeal=P*b.count)}for(const b of S){const L=b.sumIdeal/b.count;for(let I=0;I<b.count;I++)M[b.startIdx+I].labelY=L+(I-(b.count-1)/2)*v}}for(const y of m){const M=y.entry,S=M.labelY-M.anchorY;let P;if(Math.abs(S)<=c){const I=M.side*Math.sqrt(Math.max(0,c*c-S*S));P=M.anchorX+I}else P=(M.anchorX+M.labelX)/2;const b=Math.min(M.anchorX,M.labelX),L=Math.max(M.anchorX,M.labelX);M.elbowX=Math.max(b,Math.min(L,P)),M.elbowY=M.labelY}return d};function lo(i){return parseInt(i.slice(1,3),16)*.299+parseInt(i.slice(3,5),16)*.587+parseInt(i.slice(5,7),16)*.114<128}function J(i){var t,e,s,n,r,o,l,h,d,c,u,f,m,g,p,v,w,x,y,M,S,P,b,L,I,T,W,F,V,z,_,N,H,it;const{background:U,name:bt="Custom",description:vt,fontUrl:St=null}=i,Q=lo(U),Xt=Q?"#d1d4dc":"#24292f",yt=Q?"#787b86":"#8b949e",ut=Q?"#26a69a":"#2da44e",dt=Q?"#ef5350":"#cf222e",Pt=Q?"#2962ff":"#0969da",Mt=Q?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",Ut=Q?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Pe=Q?je(U,.1):Xi(U,.05),ui=Q?Me(U,.92):Me(U,.95),di=Q?Me(je(U,.15),.6):"rgba(200,200,200,0.5)",st=Bi,ft=((e=(t=i.candlestick)==null?void 0:t.up)==null?void 0:e.body)??ut,Gt=((n=(s=i.candlestick)==null?void 0:s.down)==null?void 0:n.body)??dt,Fi=pt(ft),fi=pt(Gt),De=((r=i.line)==null?void 0:r.color)??Pt,us=((o=i.tooltip)==null?void 0:o.textColor)??Xt,ds=((l=i.axis)==null?void 0:l.textColor)??yt,$n=((h=i.typography)==null?void 0:h.fontFamily)??st,fs=((d=i.typography)==null?void 0:d.fontSize)??12,Nn=i.chartGradient??(Q?[je(U,.04),Xi(U,.06)]:[je(U,.06),U]),Xn={background:U,chartGradient:Nn,typography:{fontFamily:$n,fontSize:fs},grid:{color:((c=i.grid)==null?void 0:c.color)??Mt,style:((u=i.grid)==null?void 0:u.style)??"dashed"},candlestick:{up:{body:ft,wick:((m=(f=i.candlestick)==null?void 0:f.up)==null?void 0:m.wick)??Fi},down:{body:Gt,wick:((p=(g=i.candlestick)==null?void 0:g.down)==null?void 0:p.wick)??fi}},line:{color:De,width:((v=i.line)==null?void 0:v.width)??1,areaTopColor:((w=i.line)==null?void 0:w.areaTopColor)??Me(De,.08),areaBottomColor:((x=i.line)==null?void 0:x.areaBottomColor)??Me(De,.01)},seriesColors:i.seriesColors??[De,ut,dt],bands:{upper:((y=i.bands)==null?void 0:y.upper)??De,lower:((M=i.bands)==null?void 0:M.lower)??fi},crosshair:{color:((S=i.crosshair)==null?void 0:S.color)??Ut,labelBackground:((P=i.crosshair)==null?void 0:P.labelBackground)??Pe,labelTextColor:((b=i.crosshair)==null?void 0:b.labelTextColor)??us},axis:{fontSize:((L=i.axis)==null?void 0:L.fontSize)??10,textColor:ds,...(I=i.axis)!=null&&I.x?{x:{...i.axis.x}}:{},...(T=i.axis)!=null&&T.y?{y:{...i.axis.y}}:{}},yLabel:{fontSize:((W=i.yLabel)==null?void 0:W.fontSize)??11,upBackground:((F=i.yLabel)==null?void 0:F.upBackground)??Fi,downBackground:((V=i.yLabel)==null?void 0:V.downBackground)??fi,neutralBackground:((z=i.yLabel)==null?void 0:z.neutralBackground)??Pe,textColor:((_=i.yLabel)==null?void 0:_.textColor)??"#ffffff"},tooltip:{fontSize:((N=i.tooltip)==null?void 0:N.fontSize)??fs,background:((H=i.tooltip)==null?void 0:H.background)??ui,textColor:us,borderColor:((it=i.tooltip)==null?void 0:it.borderColor)??di},navigator:ho({dark:Q,bg:U,neutralFg:ds,upBody:ft,downBody:Gt,upBase:Fi,downBase:fi,config:i.navigator})};return{name:bt,description:vt,fontUrl:St,dark:Q,theme:Xn}}function ho(i){var t,e,s,n,r,o,l,h,d,c,u,f,m,g,p,v,w,x;const{dark:y,bg:M,neutralFg:S,upBody:P,downBody:b,upBase:L,downBase:I,config:T}=i,W=(T==null?void 0:T.background)??"transparent",F=y?"rgba(255,255,255,1)":"rgba(0,0,0,1)",V=((t=T==null?void 0:T.handle)==null?void 0:t.color)??ze(F,.3),z=((e=T==null?void 0:T.mask)==null?void 0:e.fill)??ze(M,y?.78:.82);return{height:(T==null?void 0:T.height)??48,background:W,borderColor:(T==null?void 0:T.borderColor)??ze(S,y?.18:.22),line:{color:((s=T==null?void 0:T.line)==null?void 0:s.color)??S,width:((n=T==null?void 0:T.line)==null?void 0:n.width)??1,areaTopColor:((r=T==null?void 0:T.line)==null?void 0:r.areaTopColor)??ze(S,y?.22:.18),areaBottomColor:((o=T==null?void 0:T.line)==null?void 0:o.areaBottomColor)??ze(S,0)},candlestick:{up:{body:((h=(l=T==null?void 0:T.candlestick)==null?void 0:l.up)==null?void 0:h.body)??P,wick:((c=(d=T==null?void 0:T.candlestick)==null?void 0:d.up)==null?void 0:c.wick)??L},down:{body:((f=(u=T==null?void 0:T.candlestick)==null?void 0:u.down)==null?void 0:f.body)??b,wick:((g=(m=T==null?void 0:T.candlestick)==null?void 0:m.down)==null?void 0:g.wick)??I}},window:{fill:((p=T==null?void 0:T.window)==null?void 0:p.fill)??"transparent",border:((v=T==null?void 0:T.window)==null?void 0:v.border)??"transparent",borderWidth:((w=T==null?void 0:T.window)==null?void 0:w.borderWidth)??0},handle:{color:V,width:((x=T==null?void 0:T.handle)==null?void 0:x.width)??6},mask:{fill:z}}}function ze(i,t){if(i.startsWith("#")&&i.length===7)return Me(i,t);const e=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:i}function Me(i,t){const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function je(i,t){if(!i.startsWith("#"))return i;const e=Math.min(255,Math.round(parseInt(i.slice(1,3),16)+255*t)),s=Math.min(255,Math.round(parseInt(i.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(i.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Xi(i,t){if(!i.startsWith("#"))return i;const e=Math.max(0,Math.round(parseInt(i.slice(1,3),16)*(1-t))),s=Math.max(0,Math.round(parseInt(i.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(i.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function E(i){const t=i.startsWith("#")&&i.length===7?[je(i,.2),Xi(i,.15)]:[i,i];return Object.defineProperty(t,"source",{value:i,enumerable:!1}),t}const Ii="'JetBrains Mono', 'Fira Code', monospace",Ai="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Bi="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",ns="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",cn="'Roboto Mono', monospace",un="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",co="'IBM Plex Mono', monospace",uo="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",rs="'Fira Code', monospace",os="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",dn="'Source Code Pro', monospace",fn="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",fo="'Space Mono', monospace",go="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",as="'Plus Jakarta Sans', sans-serif",ls="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",mo="'Caveat', 'Comic Sans MS', cursive",po="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",gn={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:E("#26a69a"),wick:"#26a69a"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(120, 123, 134, 0.18)",line:{color:"#787b86",width:1,areaTopColor:"rgba(120, 123, 134, 0.22)",areaBottomColor:"rgba(120, 123, 134, 0)"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(255, 255, 255, 0.30)",width:6},mask:{fill:"rgba(19, 23, 34, 0.78)"}}},Kt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},bo=.1,vo=.3,yo=.4,xo=.5,wo=4,So=(i,t,e)=>({from:mt(i.from,t.from,e),to:mt(i.to,t.to,e)}),Mo=(i,t)=>i.from===t.from&&i.to===t.to;var ot,Tt,nt;class ko extends oi{constructor({padding:t,reboundMs:e}={}){super(),B(this,ot),R(this,"_yRange",{min:0,max:0}),R(this,"_autoScroll",!0),R(this,"padding"),R(this,"reboundMs"),R(this,"dataInterval",6e4),B(this,Tt,null),B(this,nt,null),R(this,"_prevDataEnd",null),R(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??Kt.top,bottom:(t==null?void 0:t.bottom)??Kt.bottom,right:(t==null?void 0:t.right)??Kt.right,left:(t==null?void 0:t.left)??Kt.left},this.reboundMs=e??Us,k(this,ot,new Fe({initial:{from:0,to:0},duration:pi.streamTick,easing:me,lerp:So,equals:Mo}))}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,s){return typeof t=="object"?t.intervals*this.dataInterval:s<=0?0:t/s*e}get visualRange(){return a(this,ot).current}get logicalRange(){return a(this,ot).target}get visibleRange(){return a(this,ot).current}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return a(this,ot).animating}get dataStart(){return a(this,Tt)}get dataEnd(){return a(this,nt)}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??Kt.top,bottom:(t==null?void 0:t.bottom)??Kt.bottom,right:(t==null?void 0:t.right)??Kt.right,left:(t==null?void 0:t.left)??Kt.left}}getPadding(){return this.padding}setDataStart(t){k(this,Tt,t)}setDataEnd(t){this._prevDataEnd=a(this,nt),k(this,nt,t)}cancelPendingAnimation(){a(this,ot).animating&&(a(this,ot).snap(a(this,ot).current),this.emit("change"))}applyLogical(t,e){e<=t||(e-t)/this.dataInterval<2||(a(this,ot).snap({from:t,to:e}),this.emit("change"))}retargetLogical(t,e,s,n){e<=t||(e-t)/this.dataInterval<2||(a(this,ot).setTarget({from:t,to:e},{duration:s,now:n}),this.emit("change"))}tick(t){if(!a(this,ot).animating)return!1;const e=a(this,ot).tick(t);return this.emit("change"),e}getSoftBounds(t,e){const s=o=>typeof o=="object"||o===0||e>0,n=a(this,Tt)!==null&&s(this.padding.left)?a(this,Tt)-this.resolveHPad(this.padding.left,t,e):null,r=a(this,nt)!==null&&s(this.padding.right)?a(this,nt)+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}dataFitsCurrentViewport(t=0){if(a(this,Tt)===null||a(this,nt)===null)return!1;const{from:e,to:s}=this.logicalRange,n=s-e;if(n<=0)return!1;t>0&&(this._lastChartWidth=t);const r=t>0?t:this._lastChartWidth,o=this.resolveHPad(this.padding.left,n,r),l=a(this,Tt)-o,h=this.dataInterval*.5;return Math.abs(e-l)<=h}softMaxRange(){if(a(this,Tt)===null||a(this,nt)===null)return null;const t=a(this,nt)-a(this,Tt);if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,s=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||s!==null?t+(e??0)+(s??0):t+this.dataInterval*5}setRange(t){const{from:e,to:s}=t;if(!Number.isFinite(e)||!Number.isFinite(s)||s<=e||(s-e)/this.dataInterval<2)return;const n=a(this,nt)!==null&&a(this,nt)>=e&&a(this,nt)<=s;this._autoScroll=n,this.applyLogical(e,s)}setYRange(t,e,s,n=!1,r=!1){const o=e-t,l=s>0?this.padding.top/s*o:0,h=s>0?this.padding.bottom/s*o:0;this._yRange={min:n?t:t-h,max:r?e:e+l}}zoomAt(t,e,s=this._lastChartWidth,n=0){s>0&&(this._lastChartWidth=s),this.cancelPendingAnimation();const{from:r,to:o}=this.logicalRange,l=o-r;if(l<=0)return;const h=this.softMinRange,{left:d,right:c}=this.getSoftBounds(l,s),u=d!==null&&c!==null?c-d:this.softMaxRange();let f=e;const m=h*yo;if(e<1&&l<h){const x=h-l,y=(1-Math.min(1,x/m))**2;f=1-(1-e)*y}let g=l*f;g<h-m&&(g=h-m),e>1&&u!==null&&g>u&&(g=u);const p=(t-r)/l;let v=t-p*g,w=v+g;if(e<1&&w<o){const x=o-w;v+=x,w+=x}if(e>1){if(c!==null&&w>c){const x=w-c;v-=x,w-=x}if(d!==null&&v<d){const x=d-v;v+=x,w+=x}}n>0?this.retargetLogical(v,w,n):this.applyLogical(v,w),this.emit("interact")}pan(t,e=0,s=0){e>0&&(this._lastChartWidth=e),this.cancelPendingAnimation();const{from:n,to:r}=this.logicalRange,o=r-n;if(o<=0)return;const{left:l,right:h}=this.getSoftBounds(o,e),d=o*vo;let c=t;if(t>0&&h!==null){const g=Math.max(0,r-h);g>0&&(c*=1/(g/d+1))}else if(t<0&&l!==null){const g=Math.max(0,l-n);g>0&&(c*=1/(g/d+1))}let u=n+c,f=r+c;if(h!==null&&f>h+d){const g=f-(h+d);u-=g,f-=g}if(l!==null&&u<l-d){const g=l-d-u;u+=g,f+=g}const m=a(this,nt)!==null&&a(this,nt)>=u&&a(this,nt)<=f;this._autoScroll=m,s>0?this.retargetLogical(u,f,s):this.applyLogical(u,f),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:s}=this.logicalRange,n=s-e;if(n<=0)return;const r=this.softMinRange,o=this.softMaxRange();let l=n;l<r&&(l=r),o!==null&&l>o&&(l=o);let h=e,d=s;if(l!==n){const x=(e+s)/2;h=x-l/2,d=x+l/2}const{left:c,right:u}=this.getSoftBounds(l,t);if(u!==null&&d>u){const x=d-u;h-=x,d-=x}if(c!==null&&h<c){const x=c-h;h+=x,d+=x}const f=Math.abs(h-e),m=Math.abs(d-s);if(f<1&&m<1)return;const g=n*bo;let p=null,v=0,w=0;u!==null&&s-u>g?(p="right",v=s-u,w=u):c!==null&&c-e>g&&(p="left",v=c-e,w=c),this.reboundMs<=0?this.applyLogical(h,d):this.retargetLogical(h,d,this.reboundMs),this.emit("interact"),p!==null&&this.emit("edgeReached",{side:p,overshoot:v,boundaryTime:w})}fitToData(t,e,s=0,n=!1,r){this._autoScroll=!0,s>0&&(this._lastChartWidth=s);const o=400*this.dataInterval,l=e-t,h=l>0?l:this.dataInterval*10,d=this.resolveHPad(this.padding.right,h,s),c=this.resolveHPad(this.padding.left,h,s);let u=e+d,f=t-c;u-f>o&&(u=e+d,f=u-o);const{from:m,to:g}=this.logicalRange;n&&!(m===0&&g===0)?this.retargetLogical(f,u,r??pi.fit):this.applyLogical(f,u)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const{from:s,to:n}=this.logicalRange,r=n-s;if(r<=0)return;const o=this.resolveHPad(this.padding.right,r,e),l=n,h=this._prevDataEnd!==null?l-this._prevDataEnd:o,d=Math.max(0,Math.min(o,h)),c=t+d,u=c-r;this._autoScroll=!0;const f=xo*this.dataInterval,m=e>0?wo/e*r:f,g=Math.min(f,m);Math.abs(c-n)<g||(this.retargetLogical(u,c,pi.streamTick),this._prevDataEnd=a(this,nt))}getVisibleBarsCount(){const{from:t,to:e}=a(this,ot).current;return(e-t)/this.dataInterval}destroy(){this.removeAllListeners()}}ot=new WeakMap,Tt=new WeakMap,nt=new WeakMap;function ve(i,t){return i===!1||i===0?0:i===void 0?t:i}function Fs(i){if(i===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0,inputResponseMs:0}};const t=i===!0||i===void 0?void 0:i,e=t==null?void 0:t.points,s=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:ve(e==null?void 0:e.enterMs,pe),smoothMs:ve(e==null?void 0:e.smoothMs,Qi),pulseMs:ve(e==null?void 0:e.pulseMs,Xs)},r=s===!1?{reboundMs:0,yAxisMs:0,inputResponseMs:0}:{reboundMs:ve(s==null?void 0:s.reboundMs,Us),yAxisMs:ve(s==null?void 0:s.yAxisMs,Hi),inputResponseMs:ve(s==null?void 0:s.inputResponseMs,Kn)};return{points:n,viewport:r}}function Co(i){if(!i)return{monitor:null,ownsMonitor:!1,showHud:!1};if(i===!0)return{monitor:new Vi,ownsMonitor:!0,showHud:!0};if(i instanceof Vi)return{monitor:i,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...s}=i,n=e!==void 0;return{monitor:e??new Vi(s),ownsMonitor:!n,showHud:t??!n}}let To=0;var tt,O,K,zt,ke,Y,Z,_e,ht,Et,rt,ee,Ui,Ce,Rt,yi,xi,jt,Oe,ce,si,Ci,At,Vt,He,$e,q,ie,Ps,wi,Ne,Xe,mn,pn,Si,Ue,Jt,Qt,Te,Ge;class bn extends oi{constructor(t,e){var s,n,r,o;super(),B(this,q),B(this,tt),B(this,O),B(this,K),B(this,zt),R(this,"timeScale"),R(this,"yScale"),B(this,ke),B(this,Y,[]),B(this,Z),B(this,_e),B(this,ht,6e4),B(this,Et,null),B(this,rt,{}),B(this,ee,null),B(this,Ui,!1),B(this,Ce,{}),B(this,Rt,{left:"idle",right:"idle"}),B(this,yi,{left:null,right:null}),B(this,xi),B(this,jt,0),B(this,Oe,!1),B(this,ce,!1),B(this,si,!1),B(this,Ci,0),B(this,At),B(this,Vt),B(this,He,!1),B(this,$e,null),B(this,Si,0),B(this,Ue,!1),B(this,Jt,new Fe({initial:0,duration:Hi,easing:me,lerp:(c,u,f)=>c+(u-c)*f})),B(this,Qt,new Fe({initial:0,duration:Hi,easing:me,lerp:(c,u,f)=>c+(u-c)*f})),B(this,Te,!1),B(this,Ge,!1),e!=null&&e.axis&&(k(this,Ce,e.axis),k(this,rt,{min:(s=e.axis.y)==null?void 0:s.min,max:(n=e.axis.y)==null?void 0:n.max})),k(this,Z,(e==null?void 0:e.theme)??gn),k(this,_e,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),k(this,At,Fs(e==null?void 0:e.animations)),k(this,xi,e==null?void 0:e.onEdgeReached);const l=Co(e==null?void 0:e.perf);k(this,Vt,l.monitor),k(this,He,l.ownsMonitor),k(this,tt,new qn(t,a(this,Vt)??void 0)),k(this,O,new ko({padding:e==null?void 0:e.padding,reboundMs:a(this,At).viewport.reboundMs})),gr(this,a(this,O)),this.timeScale=new Zs,this.yScale=new sn;const h=a(this,Vt);h?(k(this,K,new gi(c=>{h.resetDrawCalls("main");const u=performance.now();this.renderMain(c),h.recordFrame("main",performance.now()-u,c)})),k(this,zt,new gi(c=>{h.resetDrawCalls("overlay");const u=performance.now();this.renderOverlay(c),h.recordFrame("overlay",performance.now()-u,c)})),l.showHud&&k(this,$e,new xr(t,h))):(k(this,K,new gi(c=>this.renderMain(c))),k(this,zt,new gi(c=>this.renderOverlay(c))));const d=(e==null?void 0:e.interactive)!==!1;k(this,ke,d?new dr(a(this,tt).canvas,a(this,O),this.timeScale,this.yScale,a(this,At).viewport.inputResponseMs):null),a(this,O).on("change",()=>{this.syncScales(),a(this,K).markDirty(),this.emit("viewportChange")}),a(this,O).on("edgeReached",c=>{var u;a(this,yi)[c.side]=c.boundaryTime,(u=a(this,xi))==null||u.call(this,c)}),a(this,O).on("interact",()=>{k(this,Ge,!0)}),a(this,tt).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(o=a(this,ke))==null||o.on("crosshairMove",c=>{k(this,Et,c),a(this,zt).markDirty(),this.emit("crosshairMove",c),D(this,q,pn).call(this,c)})}get yAxisWidth(){const t=a(this,Ce).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=a(this,Ce).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return a(this,Ci)}addCandlestickSeries(t){const e=new qs,s=new Jr(e,{up:{...a(this,Z).candlestick.up},down:{...a(this,Z).candlestick.down},bodyWidthRatio:.6,...D(this,q,wi).call(this,"candle"),...t,...D(this,q,Ne).call(this)});return D(this,q,Xe).call(this,s,s.store,t??{})}addLineSeries(t){const{layers:e,...s}=t??{},n=e??1,r=new Zr(n,{colors:n===1?[a(this,Z).line.color]:a(this,Z).seriesColors.slice(0,n),strokeWidth:a(this,Z).line.width,area:{visible:!0},...D(this,q,wi).call(this,"line"),...s,...D(this,q,Ne).call(this)});return D(this,q,Xe).call(this,r,r.store,s)}addBarSeries(t){const{layers:e,...s}=t??{},n=e??1,r=new $r(n,{colors:a(this,Z).seriesColors.slice(0,n),barWidthRatio:.6,...D(this,q,wi).call(this,"bar"),...s,...D(this,q,Ne).call(this)});return D(this,q,Xe).call(this,r,r.store,s)}addPieSeries(t){const e=new vi(t);return D(this,q,Xe).call(this,e,null,t??{})}removeSeries(t){const e=a(this,Y).findIndex(s=>s.id===t);e>=0&&(a(this,Y)[e].renderer.dispose(),a(this,Y).splice(e,1),k(this,ee,null),this.updateViewportPadding(),a(this,K).markDirty(),this.emit("seriesChange"),D(this,q,ie).call(this))}setSeriesData(t,e,s){const n=a(this,Y).find(r=>r.id===t);n&&(k(this,Ue,!0),n.renderer.setData(e,s))}appendData(t,e,s){var n,r;const o=a(this,Y).find(l=>l.id===t);(r=o==null?void 0:(n=o.renderer).appendPoint)==null||r.call(n,e,s)}updateData(t,e,s){var n,r;const o=a(this,Y).find(l=>l.id===t);(r=o==null?void 0:(n=o.renderer).updateLastPoint)==null||r.call(n,e,s)}updateSeriesOptions(t,e){const s=a(this,Y).find(d=>d.id===t);if(!s)return;const n=s.label,r=s.renderer.getLayerColors().slice();s.renderer.updateOptions({...e,...D(this,q,Ne).call(this)}),"label"in e&&typeof e.label=="string"&&(s.label=e.label),a(this,K).markDirty();const o=s.renderer.getLayerColors(),l=r.length!==o.length||r.some((d,c)=>d!==o[c]),h=n!==s.label;(l||h)&&D(this,q,ie).call(this)}batch(t){Oi(this,jt)._++;try{t()}finally{--Oi(this,jt)._<=0&&(k(this,jt,0),a(this,Oe)?(k(this,Oe,!1),k(this,ce,!1),this.onDataChanged()):a(this,ce)&&(k(this,ce,!1),this.updateYRange(!0),a(this,K).markDirty()),a(this,si)&&(k(this,si,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const s=a(this,Y).find(n=>n.id===t);if(!(!s||s.visible===e)){if(s.visible=e,D(this,q,ie).call(this),a(this,jt)>0){k(this,ce,!0);return}this.updateYRange(!0),a(this,K).markDirty()}}isSeriesVisible(t){var e;return((e=a(this,Y).find(s=>s.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,s){const n=a(this,Y).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==s){if(n.renderer.setLayerVisible(e,s),D(this,q,ie).call(this),a(this,jt)>0){k(this,ce,!0);return}this.updateYRange(!0),a(this,K).markDirty()}}isLayerVisible(t,e){const s=a(this,Y).find(n=>n.id===t);return(s==null?void 0:s.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const s=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(t,e,s,!0)}getVisibleRange(){return a(this,O).visibleRange}getDataRange(){const t=a(this,O).dataStart,e=a(this,O).dataEnd;return t===null||e===null?null:{from:t,to:e}}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:s}=this.getDataBounds();if(e===void 0||s===void 0)return;const n=Math.max(e,s-(t-1)*a(this,ht)),r=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(n,s,r,!1);return}a(this,O).setRange(t)}getYRange(){return a(this,O).yRange}getCrosshairPosition(){return a(this,Et)}getLastValue(t){const e=a(this,Y).find(h=>h.id===t);if(!(e!=null&&e.store))return null;const s=e.store.last();if(!s)return null;const n=h=>"close"in h?h.close:h.value,{from:r,to:o}=a(this,O).visibleRange;if(s.time>=r&&s.time<=o)return{value:n(s),isLive:!0};const l=e.store.getVisibleData(r,o);return l.length===0?null:{value:n(l[l.length-1]),isLive:!1}}getPreviousClose(t){const e=a(this,Y).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const s=e.store.getAll();if(s.length<2)return null;const n=s[s.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=a(this,Y).find(s=>s.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var s,n;const r=a(this,Y).find(o=>o.id===t);return r?((n=(s=r.renderer).getDataAtTime)==null?void 0:n.call(s,e,a(this,ht)))??null:null}getLayerSnapshots(t,e){var s,n;const r=a(this,Y).find(o=>o.id===t);return r!=null&&r.visible?((n=(s=r.renderer).getLayerSnapshots)==null?void 0:n.call(s,e,a(this,ht)))??null:null}getSeriesIds(){return a(this,ee)||k(this,ee,a(this,Y).map(t=>t.id)),a(this,ee).slice()}getSeriesType(t){const e=a(this,Y).find(s=>s.id===t);return e?e.renderer instanceof vi?"pie":"time":null}getSeriesIdsByType(t,e){const s=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const o of a(this,Y)){const l=o.renderer instanceof vi;if(t==="pie"&&!l||t==="time"&&l)continue;const h=o.renderer.getLayerCount();if(!(n&&h>1)){if(s){if(!o.visible)continue;if(h>1){let d=!1;for(let c=0;c<h;c++)if(o.renderer.isLayerVisible(c)){d=!0;break}if(!d)continue}}r.push(o.id)}}return r}getStackedLastValue(t){var e,s;const n=a(this,Y).find(o=>o.id===t);return n?((s=(e=n.renderer).getStackedLastValue)==null?void 0:s.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:s.call(e))??null}listSeriesForTest(){return a(this,Y).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=a(this,Y).find(s=>s.id===t);return e?e.renderer.getLayerColors()[0]??a(this,Z).line.color:null}getSeriesLabel(t){var e;return(e=a(this,Y).find(s=>s.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=a(this,Y).find(r=>r.id===t);if(!e)return null;const s=e.renderer.getLayerCount();if(s<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:s},(r,o)=>({color:n[o%n.length]}))}getSliceInfo(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:s.call(e,a(this,Z)))??null}getHoverInfo(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:s.call(e,a(this,Z)))??null}setTheme(t){const e=a(this,Z);k(this,Z,t);for(const s of a(this,Y))s.renderer.applyTheme(t,e);a(this,K).markDirty(),D(this,q,ie).call(this)}getTheme(){return a(this,Z)}setAxis(t){var e,s;const n=this.yAxisWidth,r=this.xAxisHeight;k(this,Ce,t),k(this,rt,{min:(e=t.y)==null?void 0:e.min,max:(s=t.y)==null?void 0:s.max}),k(this,Te,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),a(this,K).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"),a(this,K).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"),a(this,K).markDirty())}getMediaSize(){return a(this,tt).size.media}getLayout(){const t=a(this,tt).size.media,e=this.yAxisWidth,s=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-s},yAxisWidth:e,xAxisHeight:s}}getDataInterval(){return a(this,ht)}setAnimations(t){var e,s,n;const r=Fs(t);k(this,At,r),a(this,O).setReboundMs(r.viewport.reboundMs),(e=a(this,ke))==null||e.setInputResponseMs(r.viewport.inputResponseMs);const o={};if(r.points.enterMs===0&&(o.entryMs=0),r.points.smoothMs===0&&(o.smoothMs=0),r.points.pulseMs===0&&(o.pulseMs=0),Object.keys(o).length>0)for(const l of a(this,Y))(n=(s=l.renderer).updateOptions)==null||n.call(s,o);a(this,K).markDirty()}setPadding(t){const e=a(this,O).getPadding();a(this,O).setPadding(t);const s=a(this,O).getPadding(),n=!Ds(e.left,s.left)||!Ds(e.right,s.right),r=e.top!==s.top||e.bottom!==s.bottom;if(n){const{first:o,last:l}=this.getDataBounds();if(o!==void 0&&l!==void 0){const h=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(o,l,h,!1)}}r&&this.updateYRange(!0),this.syncScales(),a(this,K).markDirty(),r&&this.emit("viewportChange")}setGrid(t){k(this,_e,t.visible),a(this,K).markDirty()}setEdgeState(t,e){a(this,Rt)[t]!==e&&(a(this,Rt)[t]=e,a(this,zt).markDirty())}getEdgeState(t){return a(this,Rt)[t]}setYLabel(t){k(this,Ui,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,s;for(const n of a(this,Y))n.renderer.dispose();k(this,Y,[]),k(this,ee,null),a(this,O).destroy(),a(this,K).destroy(),a(this,zt).destroy(),(t=a(this,ke))==null||t.destroy(),a(this,tt).destroy(),(e=a(this,$e))==null||e.destroy(),k(this,$e,null),a(this,He)&&((s=a(this,Vt))==null||s.destroy()),k(this,Vt,null),k(this,He,!1),this.removeAllListeners()}getPerfMonitor(){return a(this,Vt)}getDataBounds(){let t,e;for(const s of a(this,Y)){if(!s.visible||!s.store)continue;const n=s.store.first(),r=s.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(a(this,jt)>0){k(this,Oe,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&a(this,O).setDataStart(t),e!==void 0&&a(this,O).setDataEnd(e);let s=0;for(const o of a(this,Y))o.renderer.getTotalLength?s+=o.renderer.getTotalLength():o.store&&(s+=o.store.length);const n=s-a(this,Si)>5;if(k(this,Si,s),t!==void 0&&e!==void 0){const{from:o,to:l}=a(this,O).logicalRange,h=o===0&&l===0,d=a(this,tt).size.media.width-this.yAxisWidth;h?a(this,O).fitToData(t,e,d,!1):n&&a(this,O).autoScroll?a(this,O).fitToData(t,e,d,!0):!n&&a(this,O).autoScroll&&(a(this,O).dataFitsCurrentViewport(d)?a(this,O).fitToData(t,e,d,!0,pi.streamTick):a(this,O).scrollToEnd(e,d))}const r=a(this,Ue);k(this,Ue,!1),this.updateYRange(n||r),this.syncScales(),a(this,K).markDirty(),this.emit("dataUpdate"),D(this,q,ie).call(this)}updateDataInterval(){for(const t of a(this,Y)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const s=e.slice(0,20).map(n=>n.time);k(this,ht,Js(s)),a(this,O).setDataInterval(a(this,ht));break}}}computeTargetYRange(t,e){let s=1/0,n=-1/0;for(const r of a(this,Y)){if(!r.visible)continue;if(r.renderer.getValueRange){const l=r.renderer.getValueRange(t.from,t.to);if(l){l.max>n&&(n=l.max),l.min<s&&(s=l.min),e==null||e.push(l.min,l.max);continue}}if(!r.store)continue;const o=r.store.getVisibleData(t.from,t.to);for(const l of o)if("high"in l){const h=l;Number.isFinite(h.high)&&(h.high>n&&(n=h.high),e==null||e.push(h.high)),Number.isFinite(h.low)&&(h.low<s&&(s=h.low),e==null||e.push(h.low))}else{const h=l;Number.isFinite(h.value)&&(h.value>n&&(n=h.value),h.value<s&&(s=h.value),e==null||e.push(h.value))}}return s===1/0||n===-1/0?null:{min:s,max:n}}updateYRange(t=!1,e){const s=a(this,O).logicalRange,n=a(this,rt).min!==void 0&&a(this,rt).min!=="auto"&&typeof a(this,rt).min!="number"||a(this,rt).max!==void 0&&a(this,rt).max!=="auto"&&typeof a(this,rt).max!="number"?[]:null,r=this.computeTargetYRange(s,n);if(r===null){k(this,Te,!1);return}const o=this.resolveBound(a(this,rt).min,r.min,r.max,n??[],"min"),l=this.resolveBound(a(this,rt).max,r.max,r.min,n??[],"max"),h=a(this,At).viewport.yAxisMs,d=a(this,Ge);k(this,Ge,!1);const c=d&&h>ms?ms:h;if(!a(this,Te)||t||c<=0)a(this,Jt).snap(o),a(this,Qt).snap(l),k(this,Te,!0);else{const w=a(this,At).points.enterMs>0;o<a(this,Jt).current&&!w?a(this,Jt).snap(o):a(this,Jt).setTarget(o,{duration:c,now:e}),l>a(this,Qt).current&&!w?a(this,Qt).snap(l):a(this,Qt).setTarget(l,{duration:c,now:e})}const u=e??performance.now(),f=a(this,Jt).tick(u),m=a(this,Qt).tick(u);(f||m)&&a(this,K).markDirty();const g=a(this,rt).min!==void 0&&a(this,rt).min!=="auto",p=a(this,rt).max!==void 0&&a(this,rt).max!=="auto",v=a(this,tt).size.media.height-this.xAxisHeight;a(this,O).setYRange(a(this,Jt).current,a(this,Qt).current,v,g,p)}resolveBound(t,e,s,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const o=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(o){const l=o[1]==="-"?-1:1,h=parseFloat(o[2])/100,d=Math.abs(s-e)||Math.abs(e)||1;return e+l*h*d*(r==="max"?1:-1)}return e}syncScales(){const t=a(this,tt).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,s=t.media.height-this.xAxisHeight;this.timeScale.update(a(this,O).visibleRange,e,t.horizontalPixelRatio,a(this,ht)),this.yScale.update(a(this,O).yRange,s,t.verticalPixelRatio)}updateScales(t=!1,e){const s=a(this,tt).size;if(s.media.width===0||s.media.height===0)return;const n=s.media.width-this.yAxisWidth,r=s.media.height-this.xAxisHeight;this.timeScale.update(a(this,O).visibleRange,n,s.horizontalPixelRatio,a(this,ht)),this.yScale.update(a(this,O).yRange,r,s.verticalPixelRatio),this.updateYRange(t,e),this.yScale.update(a(this,O).yRange,r,s.verticalPixelRatio)}renderMain(t){const e=a(this,tt).size;if(e.media.width===0||e.media.height===0)return;const s=typeof t=="number"?t:performance.now();a(this,O).tick(s)&&a(this,K).markDirty(),this.updateScales(!1,s),a(this,tt).useMainLayer(n=>{const{context:r,bitmapSize:o}=n,l=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,h=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,o.width,o.height),r.save(),r.beginPath(),r.rect(0,0,l,h),r.clip(),a(this,_e)&&ar(n,this.timeScale,this.yScale,a(this,Z),a(this,ht));const d=a(this,O).getPadding(),c={top:d.top,bottom:d.bottom},u=a(this,Vt);for(const f of a(this,Y)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:a(this,Z),dataInterval:a(this,ht),padding:c};if(u){const g=performance.now();f.renderer.render(m),u.recordSeries(f.id,performance.now()-g,s)}else f.renderer.render(m)}r.restore()});for(const n of a(this,Y))if(n.renderer.needsAnimation){a(this,K).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,s;const n=a(this,tt).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const h of a(this,Y))if(h.visible&&h.renderer.overlayNeedsAnimation){r=!0;break}const o=a(this,Rt).left==="loading"||a(this,Rt).right==="loading",l=a(this,Rt).left!=="idle"||a(this,Rt).right!=="idle";if(a(this,tt).useOverlayLayer(h=>{var d,c;if(!a(this,Et)&&!r&&!l)return;const u=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,u,f),h.context.clip(),a(this,Et)&&D(this,q,mn).call(this)){const p=a(this,Et).mediaX*n.horizontalPixelRatio,v=a(this,Et).mediaY*n.verticalPixelRatio;Jn(h,p,v,a(this,Z))}const m=a(this,O).getPadding(),g={top:m.top,bottom:m.bottom};for(const p of a(this,Y))p.visible&&((c=(d=p.renderer).drawOverlay)==null||c.call(d,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:a(this,Z),dataInterval:a(this,ht),padding:g,crosshair:a(this,Et)}));l&&this.drawEdgeIndicators(h,n.media.height-this.xAxisHeight),h.context.restore()}),r){const{from:h,to:d}=this.timeScale.getRange();let c=!1;for(const u of a(this,Y))if(!(!u.visible||!u.renderer.overlayNeedsAnimation)&&(((s=(e=u.renderer).hasOverlayContentInRange)==null?void 0:s.call(e,h,d))??!0)){c=!0;break}c&&a(this,zt).markDirty()}o&&a(this,zt).markDirty()}drawEdgeIndicators(t,e){const s=performance.now();for(const n of["left","right"]){const r=a(this,Rt)[n];if(r==="idle"||r==="has-more")continue;const o=this.resolveEdgeBoundary(n);o!==null&&nr({scope:t,timeScale:this.timeScale,theme:a(this,Z),chartMediaHeight:e,boundaryTime:o,side:n,state:r,now:s})}}resolveEdgeBoundary(t){const e=a(this,yi)[t];if(e!==null)return e;const{first:s,last:n}=this.getDataBounds();return t==="left"?s??null:n??null}}tt=new WeakMap,O=new WeakMap,K=new WeakMap,zt=new WeakMap,ke=new WeakMap,Y=new WeakMap,Z=new WeakMap,_e=new WeakMap,ht=new WeakMap,Et=new WeakMap,rt=new WeakMap,ee=new WeakMap,Ui=new WeakMap,Ce=new WeakMap,Rt=new WeakMap,yi=new WeakMap,xi=new WeakMap,jt=new WeakMap,Oe=new WeakMap,ce=new WeakMap,si=new WeakMap,Ci=new WeakMap,At=new WeakMap,Vt=new WeakMap,He=new WeakMap,$e=new WeakMap,q=new WeakSet,ie=function(){if(Oi(this,Ci)._++,a(this,jt)>0){k(this,si,!0);return}this.emit("overlayChange")},Ps=function(i){if(i&&!a(this,Y).some(e=>e.id===i))return i;let t;do t=`series_${++To}`;while(a(this,Y).some(e=>e.id===t));return t},wi=function(i){const{enterMs:t,smoothMs:e,pulseMs:s}=a(this,At).points;return i==="line"?{enterMs:t,smoothMs:e,pulseMs:s}:{enterMs:t,smoothMs:e}},Ne=function(){const{enterMs:i,smoothMs:t,pulseMs:e}=a(this,At).points,s={};return i===0&&(s.enterMs=0),t===0&&(s.smoothMs=0),e===0&&(s.pulseMs=0),s},Xe=function(i,t,e){var s;const n=D(this,q,Ps).call(this,e.id);return(s=i.onDataChanged)==null||s.call(i,()=>this.onDataChanged()),a(this,Y).push({id:n,label:e.label,renderer:i,store:t,visible:!0}),k(this,ee,null),this.updateViewportPadding(),this.emit("seriesChange"),D(this,q,ie).call(this),n},mn=function(){for(const i of a(this,Y))if(i.visible&&!(i.renderer instanceof vi))return!0;return!1},pn=function(i){const t=a(this,tt).size,e=a(this,O).getPadding(),s={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of a(this,Y)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let o=-1;if(i){const l=i.mediaX*t.horizontalPixelRatio,h=i.mediaY*t.verticalPixelRatio;o=r.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,s)}r.renderer.setHoverIndex(o)&&(n=!0)}n&&a(this,K).markDirty()},Si=new WeakMap,Ue=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Te=new WeakMap,Ge=new WeakMap;function Ds(i,t){return typeof i=="number"&&typeof t=="number"?i===t:typeof i=="object"&&typeof t=="object"?i.intervals===t.intervals:!1}function Ro(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const r=n/t,o=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?s+1:e+(h+1)*r;let c=null,u=null;for(;l<i.length&&i[l].time<d;){const f=i[l];(c===null||f.value<c.value)&&(c=f),(u===null||f.value>u.value)&&(u=f),l++}if(!(c===null||u===null)){if(c===u){o.push(c);continue}c.time<u.time?o.push(c,u):o.push(u,c)}}return o}function Lo(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const r=n/t,o=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?s+1:e+(h+1)*r;let c=null;for(;l<i.length&&i[l].time<d;){const u=i[l];c===null?c={time:u.time,open:u.open,high:u.high,low:u.low,close:u.close}:(u.high>c.high&&(c.high=u.high),u.low<c.low&&(c.low=u.low),c.close=u.close),l++}c!==null&&o.push(c)}return o}const zs=8;function vn(i,t){return Math.abs(i-t.left)<=zs?{gesture:"resize-left",snapToCenter:!1}:Math.abs(i-t.right)<=zs?{gesture:"resize-right",snapToCenter:!1}:i>t.left&&i<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function Io(i){const{startVisible:t,deltaPx:e,pixelsPerTime:s,dataRange:n}=i,r=t.to-t.from,o=e/s;let l=t.from+o,h=t.to+o;return l<n.from&&(l=n.from,h=l+r),h>n.to&&(h=n.to,l=h-r),l<n.from&&(l=n.from),{from:l,to:h}}function Ao(i){const{edge:t,startVisible:e,deltaPx:s,pixelsPerTime:n,dataRange:r,minSpan:o}=i,l=s/n;if(t==="left"){let c=e.from+l,u=e.to;return c<r.from&&(c=r.from),u-c<o&&(c=u-o),c<r.from&&(c=r.from,u=Math.min(r.to,c+o)),{from:c,to:u}}let h=e.from,d=e.to+l;return d>r.to&&(d=r.to),d-h<o&&(d=h+o),d>r.to&&(d=r.to,h=Math.max(r.from,d-o)),{from:h,to:d}}function Bo(i){const{time:t,startVisible:e,dataRange:s}=i,n=e.to-e.from;let r=t-n/2,o=r+n;return r<s.from&&(r=s.from,o=r+n),o>s.to&&(o=s.to,r=o-n),r<s.from&&(r=s.from),{from:r,to:o}}function Wo(i){const{ctx:t,theme:e,mediaWidth:s,mediaHeight:n}=i;t.fillStyle=e.background,t.fillRect(0,0,s,n)}function Fo(i,t,e=!0,s=1){if(t.length<2)return;const{ctx:n,timeScale:r,yScale:o,mediaHeight:l,theme:h}=i,d=s<1&&t.length>=2,c=d?t.length-2:t.length-1;if(e){const u=n.createLinearGradient(0,0,0,l);u.addColorStop(0,h.line.areaTopColor),u.addColorStop(1,h.line.areaBottomColor),n.beginPath();for(let f=0;f<=c;f++){const m=t[f],g=r.timeToX(m.time),p=o.valueToY(m.value);f===0?n.moveTo(g,p):n.lineTo(g,p)}if(n.lineTo(r.timeToX(t[c].time),l),n.lineTo(r.timeToX(t[0].time),l),n.closePath(),n.fillStyle=u,n.fill(),d){n.save(),n.globalAlpha=s,n.beginPath();const f=t[c],m=t[t.length-1],g=r.timeToX(f.time),p=r.timeToX(m.time);n.moveTo(g,o.valueToY(f.value)),n.lineTo(p,o.valueToY(m.value)),n.lineTo(p,l),n.lineTo(g,l),n.closePath(),n.fillStyle=u,n.fill(),n.restore()}}n.beginPath();for(let u=0;u<=c;u++){const f=t[u],m=r.timeToX(f.time),g=o.valueToY(f.value);u===0?n.moveTo(m,g):n.lineTo(m,g)}if(n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),d){n.save(),n.globalAlpha=s,n.beginPath();const u=t[c],f=t[t.length-1];n.moveTo(r.timeToX(u.time),o.valueToY(u.value)),n.lineTo(r.timeToX(f.time),o.valueToY(f.value)),n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),n.restore()}}function Po(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:r,mediaHeight:o,theme:l}=i,h=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.8:2),d=e<1,c=t.length-1;s.fillStyle=l.line.color;for(let u=0;u<t.length;u++){const f=t[u],m=n.timeToX(f.time),g=r.valueToY(f.value),p=Math.max(1,o-g);d&&u===c?(s.save(),s.globalAlpha=e,s.fillRect(m-h/2,g,h,p),s.restore()):s.fillRect(m-h/2,g,h,p)}}function Do(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:r,theme:o}=i,l=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.75:2),h=e<1,d=t.length-1;for(let c=0;c<t.length;c++){const u=t[c],f=u.close>=u.open?o.candlestick.up:o.candlestick.down,m=pt(f.body),g=n.timeToX(u.time),p=r.valueToY(u.open),v=r.valueToY(u.close),w=r.valueToY(u.high),x=r.valueToY(u.low),y=h&&c===d;y&&(s.save(),s.globalAlpha=e),s.strokeStyle=f.wick,s.lineWidth=1,s.beginPath(),s.moveTo(g,w),s.lineTo(g,x),s.stroke();const M=Math.min(p,v),S=Math.max(1,Math.abs(v-p));s.fillStyle=m,s.fillRect(g-l/2,M,l,S),y&&s.restore()}}function zo(i,t,e){const s=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),r=i.timeToX(s),o=i.timeToX(n),l=Math.min(r,o),h=Math.max(r,o);return{left:l,right:h,width:Math.max(1,h-l)}}var Lt,$,Ti,et,Bt,ne,Ht,$t,_t,Ot,ge,Be,Zt,Mi,ki,ue,Yt,Nt,Ke,Wt,qe,ni,Je,fe,Qe,Ze,ti,ei,de,ii,j,Gi,gt,yn,Ki,se,Ee,ji,mi,Es,xn,wn,Sn,Vs,Ys,ye,js;class Mn{constructor(t){B(this,j),B(this,Lt),B(this,$),B(this,Ti),B(this,et),B(this,Bt),B(this,ne),B(this,Ht),B(this,$t),B(this,_t),B(this,Ot),B(this,ge),B(this,Be),B(this,Zt,new Zs),B(this,Mi,new sn),B(this,ki,0),B(this,ue,0),B(this,Yt,1),B(this,Nt,null),B(this,Ke,!0),B(this,Wt,null),B(this,qe,null),B(this,ni,-1),B(this,Je),B(this,fe,null),B(this,Qe),B(this,Ze),B(this,ti),B(this,ei),B(this,de),B(this,ii),k(this,Lt,t.container),k(this,et,t.chart),k(this,ge,t.data),k(this,Be,t.options??{}),window.getComputedStyle(a(this,Lt)).position==="static"&&(a(this,Lt).style.position="relative"),k(this,$,document.createElement("canvas")),a(this,$).style.position="absolute",a(this,$).style.left="0",a(this,$).style.top="0",a(this,$).style.height="100%",a(this,$).style.touchAction="none",a(this,Lt).appendChild(a(this,$));const e=a(this,$).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");k(this,Ti,e),k(this,Bt,document.createElement("div")),a(this,Bt).dataset.chartNavigatorOverlay="",a(this,Bt).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",k(this,ne,document.createElement("div")),a(this,ne).style.cssText="position:absolute;left:0;top:0;bottom:0;",k(this,Ht,document.createElement("div")),a(this,Ht).style.cssText="position:absolute;top:0;bottom:0;",k(this,$t,document.createElement("div")),a(this,$t).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",k(this,_t,Os()),k(this,Ot,Os()),a(this,Bt).append(a(this,ne),a(this,Ht),a(this,$t),a(this,_t),a(this,Ot)),a(this,Lt).appendChild(a(this,Bt)),k(this,Qe,()=>D(this,j,se).call(this)),k(this,Ze,()=>D(this,j,se).call(this)),a(this,et).on("viewportChange",a(this,Qe)),a(this,et).on("overlayChange",a(this,Ze)),k(this,ti,n=>D(this,j,xn).call(this,n)),k(this,ei,n=>D(this,j,wn).call(this,n)),k(this,de,n=>D(this,j,Sn).call(this,n)),k(this,ii,()=>{a(this,fe)===null&&(a(this,$).style.cursor="default")}),a(this,$).addEventListener("pointerdown",a(this,ti)),a(this,$).addEventListener("pointermove",a(this,ei)),a(this,$).addEventListener("pointerup",a(this,de)),a(this,$).addEventListener("pointercancel",a(this,de)),a(this,$).addEventListener("pointerleave",a(this,ii)),k(this,Je,new ResizeObserver(n=>D(this,j,yn).call(this,n[0]))),a(this,Je).observe(a(this,Lt)),D(this,j,Gi).call(this);const s=a(this,Lt).getBoundingClientRect();s.width>0&&s.height>0&&D(this,j,Ki).call(this,s.width,s.height),D(this,j,se).call(this)}setData(t){var e;const s=Eo(t),n=(s==null?void 0:s.time)??null;if(n!==null&&a(this,qe)!==null&&n!==a(this,qe)){const r=((e=a(this,Wt))==null?void 0:e.current)??0;k(this,Wt,new Fe({initial:r,duration:pe,easing:me,lerp:(o,l,h)=>o+(l-o)*h})),a(this,Wt).setTarget(1)}k(this,qe,n),k(this,ni,(s==null?void 0:s.seriesIndex)??-1),k(this,ge,t),D(this,j,se).call(this)}setOptions(t){k(this,Be,t),D(this,j,Gi).call(this),D(this,j,se).call(this)}destroy(){a(this,et).off("viewportChange",a(this,Qe)),a(this,et).off("overlayChange",a(this,Ze)),a(this,$).removeEventListener("pointerdown",a(this,ti)),a(this,$).removeEventListener("pointermove",a(this,ei)),a(this,$).removeEventListener("pointerup",a(this,de)),a(this,$).removeEventListener("pointercancel",a(this,de)),a(this,$).removeEventListener("pointerleave",a(this,ii)),a(this,Je).disconnect(),a(this,Nt)!==null&&(cancelAnimationFrame(a(this,Nt)),k(this,Nt,null)),a(this,$).remove(),a(this,Bt).remove()}get height(){return a(this,Be).height??a(this,et).getTheme().navigator.height}}Lt=new WeakMap,$=new WeakMap,Ti=new WeakMap,et=new WeakMap,Bt=new WeakMap,ne=new WeakMap,Ht=new WeakMap,$t=new WeakMap,_t=new WeakMap,Ot=new WeakMap,ge=new WeakMap,Be=new WeakMap,Zt=new WeakMap,Mi=new WeakMap,ki=new WeakMap,ue=new WeakMap,Yt=new WeakMap,Nt=new WeakMap,Ke=new WeakMap,Wt=new WeakMap,qe=new WeakMap,ni=new WeakMap,Je=new WeakMap,fe=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,ti=new WeakMap,ei=new WeakMap,de=new WeakMap,ii=new WeakMap,j=new WeakSet,Gi=function(){const i=a(this,Be).height;i!==void 0&&(a(this,Lt).style.height=`${i}px`)},gt=function(){return Math.max(0,a(this,ki)-a(this,et).yAxisWidth)},yn=function(i){var t;if(!i)return;const e=(t=i.contentBoxSize)==null?void 0:t[0],s=(e==null?void 0:e.inlineSize)??i.contentRect.width,n=(e==null?void 0:e.blockSize)??i.contentRect.height;s<=0||n<=0||(D(this,j,Ki).call(this,s,n),D(this,j,se).call(this))},Ki=function(i,t){const e=window.devicePixelRatio||1;k(this,ki,i),k(this,ue,t),k(this,Yt,e);const s=a(this,j,gt);a(this,$).width=Math.round(s*e),a(this,$).height=Math.round(t*e),a(this,$).style.width=`${s}px`,a(this,Bt).style.width=`${s}px`},se=function(){a(this,Ke)&&a(this,Nt)!==null||(k(this,Ke,!0),a(this,Nt)===null&&k(this,Nt,requestAnimationFrame(()=>{k(this,Nt,null),k(this,Ke,!1),D(this,j,Vs).call(this)})))},Ee=function(i){const t=a(this,$).getBoundingClientRect();return i.clientX-t.left},ji=function(){const i=D(this,j,ye).call(this),t=D(this,j,js).call(this);return a(this,Zt).update(i,a(this,j,gt),a(this,Yt)),a(this,Mi).update(t,a(this,ue),a(this,Yt)),{dataRange:i,yRange:t}},mi=function(){return D(this,j,ji).call(this),zo(a(this,Zt),a(this,et).getVisibleRange(),D(this,j,ye).call(this))},Es=function(){const i=D(this,j,ye).call(this),t=i.to-i.from;return t<=0||a(this,j,gt)<=0?0:a(this,j,gt)/t},xn=function(i){if(i.button!==void 0&&i.button!==0)return;const t=D(this,j,Ee).call(this,i),e=D(this,j,ye).call(this);if(e.to<=e.from)return;const s=D(this,j,mi).call(this),n=vn(t,s),r=D(this,j,Es).call(this);if(r===0)return;let o=a(this,et).getVisibleRange();if(n.snapToCenter){const l=a(this,Zt).xToTime(t),h=Bo({time:l,startVisible:o,dataRange:e});a(this,et).setVisibleRange(h),o=h}k(this,fe,{pointerId:i.pointerId,gesture:n.gesture,startX:t,startVisible:o,pixelsPerTime:r}),a(this,$).setPointerCapture(i.pointerId),a(this,$).style.cursor=kn(n.gesture,!0),i.preventDefault()},wn=function(i){const t=a(this,fe);if(t===null){a(this,$).style.cursor=_s(D(this,j,Ee).call(this,i),D(this,j,mi).call(this));return}if(i.pointerId!==t.pointerId)return;const e=D(this,j,Ee).call(this,i)-t.startX,s=D(this,j,ye).call(this);let n;if(t.gesture==="pan")n=Io({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s});else{const r=t.gesture==="resize-left"?"left":"right";n=Ao({edge:r,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s,minSpan:2*a(this,et).getDataInterval()})}a(this,et).setVisibleRange(n)},Sn=function(i){const t=a(this,fe);t===null||i.pointerId!==t.pointerId||(k(this,fe,null),a(this,$).hasPointerCapture(i.pointerId)&&a(this,$).releasePointerCapture(i.pointerId),a(this,$).style.cursor=_s(D(this,j,Ee).call(this,i),D(this,j,mi).call(this)))},Vs=function(){if(a(this,j,gt)<=0||a(this,ue)<=0)return;const i=a(this,et).getTheme().navigator,{dataRange:t}=D(this,j,ji).call(this);a(this,$).width=Math.round(a(this,j,gt)*a(this,Yt)),a(this,$).height=Math.round(a(this,ue)*a(this,Yt)),a(this,$).style.width=`${a(this,j,gt)}px`,a(this,Bt).style.width=`${a(this,j,gt)}px`;const e=a(this,Ti),s=a(this,$).width,n=a(this,$).height;e.save(),e.clearRect(0,0,s,n),e.scale(a(this,Yt),a(this,Yt));const r={ctx:e,timeScale:a(this,Zt),yScale:a(this,Mi),mediaWidth:a(this,j,gt),mediaHeight:a(this,ue),theme:i};a(this,$).style.boxShadow=`inset 0 1px 0 ${i.borderColor}, inset 0 -1px 0 ${i.borderColor}`,Wo(r);let o=1;a(this,Wt)!==null&&(a(this,Wt).tick(performance.now()),o=a(this,Wt).current,a(this,Wt).animating?D(this,j,se).call(this):k(this,Wt,null));const l=Math.max(1,Math.round(a(this,j,gt))),h=a(this,ge);if(h.type==="candlestick")Do(r,Lo(h.points,l),o);else{const d=_i(h),c=d.length===1,u=a(this,ni)>=0?a(this,ni):d.length-1;for(let f=0;f<d.length;f++){const m=Ro(d[f],l),g=f===u?o:1;h.type==="bar"?Po(r,m,g):Fo(r,m,c,g)}}e.restore(),D(this,j,Ys).call(this,i,t)},Ys=function(i,t){if(t.to<=t.from)return;const e=a(this,et).getVisibleRange(),s=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),r=a(this,Zt).timeToX(s),o=a(this,Zt).timeToX(n),l=Math.min(r,o),h=Math.max(r,o),d=Math.max(1,h-l);a(this,ne).style.width=`${l}px`,a(this,ne).style.background=i.mask.fill,a(this,ne).style.display=l>0?"block":"none";const c=Math.max(0,a(this,j,gt)-(l+d));a(this,Ht).style.left=`${l+d}px`,a(this,Ht).style.width=`${c}px`,a(this,Ht).style.background=i.mask.fill,a(this,Ht).style.display=c>0?"block":"none",a(this,$t).style.left=`${l}px`,a(this,$t).style.width=`${d}px`,a(this,$t).style.background=i.window.fill,a(this,$t).style.border=i.window.borderWidth>0?`${i.window.borderWidth}px solid ${i.window.border}`:"none";const u=i.handle.width,f=Math.max(1,u/2),m=a(this,et).getTheme().background;a(this,_t).style.left=`${l-u/2}px`,a(this,_t).style.width=`${u}px`,a(this,_t).style.background=i.handle.color,a(this,_t).style.borderRadius=`${f}px`,a(this,Ot).style.left=`${l+d-u/2}px`,a(this,Ot).style.width=`${u}px`,a(this,Ot).style.background=i.handle.color,a(this,Ot).style.borderRadius=`${f}px`;for(const g of a(this,_t).children)g.style.background=m;for(const g of a(this,Ot).children)g.style.background=m},ye=function(){const i=a(this,ge);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,s=0;if(i.type==="candlestick")s=i.points.length,s>0&&(t=i.points[0].time,e=i.points[s-1].time);else for(const r of _i(i))r.length!==0&&(s+=r.length,r[0].time<t&&(t=r[0].time),r[r.length-1].time>e&&(e=r[r.length-1].time));if(s>=2&&e>t)return{from:t,to:e};if(s===1)return{...a(this,et).getVisibleRange()};const n=a(this,et).getDataRange();return n&&n.to>n.from?n:{...a(this,et).getVisibleRange()}},js=function(){const i=a(this,ge);let t=1/0,e=-1/0;if(i.type==="candlestick")for(const n of i.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of _i(i))for(const r of n)r.value<t&&(t=r.value),r.value>e&&(e=r.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const s=(e-t)*.2;return{min:t-s,max:e+s}};function _i(i){return"series"in i?i.series:[i.points]}function Eo(i){if(i.type==="candlestick"){const n=i.points.length;return n===0?null:{time:i.points[n-1].time,seriesIndex:-1}}const t="series"in i?i.series:[i.points];let e=null,s=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r.length===0)continue;const o=r[r.length-1].time;(e===null||o>e)&&(e=o,s=n)}return e===null?null:{time:e,seriesIndex:s}}function kn(i,t){return i==="resize-left"||i==="resize-right"?"ew-resize":t?"grabbing":"grab"}function _s(i,t){return kn(Vo(i,t),!1)}function Vo(i,t){return vn(i,t).gesture}function Os(){const i=document.createElement("div");i.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",i.appendChild(e)}return i}const qi=new WeakMap;function Cn(i,t){var e;return(e=qi.get(i))==null?void 0:e.get(t)}function Tn(i,t,e){let s=qi.get(i);s||(s=new Map,qi.set(i,s)),s.set(t,e)}function Hs(i){return"close"in i?i.close:i.value}function Rn(i,t){if(t==="none"||i.length<=1)return i;const e=[...i];return e.sort((s,n)=>{const r=Hs(s.data),o=Hs(n.data);return t==="asc"?r-o:o-r}),e}function Ri(i){const t=Object.freeze({...i.data}),e={id:i.id,seriesId:i.seriesId,layerIndex:i.layerIndex,label:i.label,data:t,color:i.color};return Object.freeze(e)}function hs(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Cn(i,t.cacheKey);if(n&&n.version===s&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l);if(i.getSeriesLayers(l)!==null){const c=i.getLayerSnapshots(l,t.time);if(!c)continue;for(const u of c)r.push(Ri({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const d=i.getDataAtTime(l,t.time);d&&r.push(Ri({id:l,seriesId:l,label:h,data:d,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Rn(r,e));return Tn(i,t.cacheKey,{version:s,time:t.time,sort:e,data:o}),o}function Ln(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Cn(i,t.cacheKey);if(n&&n.version===s&&n.time===null&&n.sort===e)return n.data;const r=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l),d=i.getLayerLastSnapshots(l);if(d){for(const u of d)r.push(Ri({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const c=i.getLastData(l);c&&r.push(Ri({id:l,seriesId:l,label:h,data:c,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Rn(r,e));return Tn(i,t.cacheKey,{version:s,time:null,sort:e,data:o}),o}const Yo={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:E("#089981"),wick:"#089981"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(139, 148, 158, 0.22)",line:{color:"#8b949e",width:1,areaTopColor:"rgba(139, 148, 158, 0.18)",areaBottomColor:"rgba(139, 148, 158, 0)"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0, 0, 0, 0.30)",width:6},mask:{fill:"rgba(255, 255, 255, 0.82)"}}},jo=J({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{up:{body:E("#96e072"),wick:"#96e072"},down:{body:E("#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:cn},fontUrl:un}),_o=J({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{up:{body:E("#bae67e"),wick:"#bae67e"},down:{body:E("#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:Bi},fontUrl:ns}),Oo=J({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{up:{body:E("#a6e3a1"),wick:"#a6e3a1"},down:{body:E("#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:Bi},fontUrl:ns}),Ho=J({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{up:{body:E("#50fa7b"),wick:"#50fa7b"},down:{body:E("#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:rs},fontUrl:os}),$o=J({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:E("#2da44e"),wick:"#2da44e"},down:{body:E("#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:as},fontUrl:ls}),No=J({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{up:{body:E("#b8bb26"),wick:"#b8bb26"},down:{body:E("#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:Ii},fontUrl:Ai}),Xo={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:po,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:mo,fontSize:15},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},Uo="'Silkscreen', cursive",Go="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Ko=J({name:"Matrix",background:"#000000",candlestick:{up:{body:E("#00ff41"),wick:"#00ff41"},down:{body:E("#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:Uo},fontUrl:Go,chartGradient:["#010a01","#000000"]}),qo=J({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:E("#6b8e5e"),wick:"#6b8e5e"},down:{body:E("#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:as},fontUrl:ls,chartGradient:["#f8f4f7","#f5f0f4"]}),Jo=J({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{up:{body:E("#6a9a6e"),wick:"#6a9a6e"},down:{body:E("#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:Bi},fontUrl:ns}),Qo=J({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{up:{body:E("#c3e88d"),wick:"#c3e88d"},down:{body:E("#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:cn},fontUrl:un}),Zo="'Silkscreen', cursive",ta="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",ea=J({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:E("#111111"),wick:"#111111"},down:{body:E("#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:Zo},fontUrl:ta}),ia=J({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:E("#2e9070"),wick:"#2e9070"},down:{body:E("#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:fo},fontUrl:go,chartGradient:["#f8f7f0","#f6f5ee"]}),sa=J({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{up:{body:E("#8ab862"),wick:"#8ab862"},down:{body:E("#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:rs},fontUrl:os}),na=J({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{up:{body:E("#7ec699"),wick:"#7ec699"},down:{body:E("#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:"#4d5a6c"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Ii},fontUrl:Ai}),ra=J({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{up:{body:E("#98c379"),wick:"#98c379"},down:{body:E("#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:Ii},fontUrl:Ai}),oa=J({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{up:{body:E("#19f9d8"),wick:"#19f9d8"},down:{body:E("#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:rs},fontUrl:os}),aa=J({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:E("#5a9a68"),wick:"#5a9a68"},down:{body:E("#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:as},fontUrl:ls,chartGradient:["#fff8f2","#fef6f0"]}),la=J({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",chartGradient:["#fdfdfd","#f5f5f5"],grid:{color:"rgba(200,200,200,0.5)"},candlestick:{up:{body:E("#448c27"),wick:"#448c27"},down:{body:E("#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:co},fontUrl:uo}),ha=J({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:E("#56949f"),wick:"#56949f"},down:{body:E("#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:dn},fontUrl:fn}),ca=J({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:E("#5a8a50"),wick:"#5a8a50"},down:{body:E("#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:dn},fontUrl:fn,chartGradient:["#f8f4ec","#f4f0e8"]}),ua=J({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:E("#859900"),wick:"#859900"},down:{body:E("#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:Ii},fontUrl:Ai});function li(i){const{x:t,y:e,chartWidth:s,chartHeight:n,tooltipWidth:r,tooltipHeight:o,offsetX:l=16,offsetY:h=16}=i,d=t+l+r>s?t-l-r:t+l,c=e+h+o>n?e-h-o:e+h,u=Math.max(0,s-r),f=Math.max(0,n-o);return{left:Math.max(0,Math.min(u,d)),top:Math.max(0,Math.min(f,c))}}const Re=A.createContext(null);function lt(){const i=A.useContext(Re);if(!i)throw new Error("useChartInstance must be used within <ChartContainer>");return i}const da=20;function In({data:i,options:t,id:e}){var h;const s=lt(),n=A.useRef(null),r=A.useRef([]),o=A.useRef([]),l=A.useRef([]);return A.useLayoutEffect(()=>{const d=s.addBarSeries({...t,layers:i.length,id:e});return n.current=d,r.current=new Array(i.length).fill(0),o.current=new Array(i.length).fill(null),l.current=new Array(i.length).fill(null),()=>{s.removeSeries(d),n.current=null,r.current=[],o.current=[],l.current=[]}},[s,i.length,e]),A.useLayoutEffect(()=>{const d=n.current;d&&s.batch(()=>{for(let c=0;c<i.length;c++){const u=i[c],f=r.current[c]??0,m=o.current[c]??null;if(u.length===0){s.setSeriesData(d,[],c),r.current[c]=0,o.current[c]=null,l.current[c]=null;continue}const g=ct(u[0].time),p=ct(u[u.length-1].time),v=l.current[c]??null,w=m!==null&&m!==g,x=u.length-f;if(w&&x===0&&(v!==null&&v!==p))s.setSeriesData(d,u.slice(0,-1),c),s.appendData(d,u[u.length-1],c);else if(f===0||u.length<f||x>da||w)s.setSeriesData(d,u,c);else if(u.length===f)s.updateData(d,u[u.length-1],c);else for(let M=f;M<u.length;M++)s.appendData(d,u[M],c);r.current[c]=u.length,o.current[c]=g,l.current[c]=p}})},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(h=t==null?void 0:t.colors)==null?void 0:h.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 fa=20;function ga({data:i,options:t,id:e}){var h,d,c,u,f,m;const s=lt(),n=A.useRef(null),r=A.useRef(0),o=A.useRef(null),l=A.useRef(null);return A.useLayoutEffect(()=>{const g=s.addCandlestickSeries({...t,id:e});return n.current=g,()=>{s.removeSeries(g),n.current=null,r.current=0,o.current=null,l.current=null}},[s,e]),A.useLayoutEffect(()=>{const g=n.current;if(!g)return;if(i.length===0){s.setSeriesData(g,[]),r.current=0,o.current=null,l.current=null;return}const p=r.current,v=o.current,w=l.current,x=ct(i[0].time),y=ct(i[i.length-1].time),M=v!==null&&v!==x,S=i.length-p;if(M&&S===0&&(w!==null&&w!==y))s.setSeriesData(g,i.slice(0,-1)),s.appendData(g,i[i.length-1]);else if(p===0||i.length<p||S>fa||M)s.setSeriesData(g,i);else if(i.length===p)s.updateData(g,i[i.length-1]);else for(let b=p;b<i.length;b++)s.appendData(g,i[b]);r.current=i.length,o.current=x,l.current=y},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,Array.isArray((h=t==null?void 0:t.up)==null?void 0:h.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 cs=A.createContext(null),Le=cs.Provider;function hi(){const i=A.useContext(cs);if(!i)throw new Error("useTheme must be used within <ThemeProvider>");return i}function ma(){return A.useContext(cs)}function Wi(i,t,e){const s=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const o of s)i.on(o,r);return()=>{for(const o of s)i.off(o,r)}},getSnapshot:e}}function An(i){const t=A.useMemo(()=>Wi(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getVisibleRange()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Bn(i){const t=A.useMemo(()=>Wi(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getYRange()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}function pa(i,t){const e=A.useMemo(()=>{let s=i.getLastValue(t),n=s?i.yScale.valueToY(s.value):null;const r=()=>s,o=()=>{const l=i.getLastValue(t),h=l?i.yScale.valueToY(l.value):null;return(s==null?void 0:s.value)===(l==null?void 0:l.value)&&(s==null?void 0:s.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(s=l,n=h,!0)};return{subscribe:l=>{o();const h=()=>{o()&&l()};return i.on("dataUpdate",h),i.on("viewportChange",h),()=>{i.off("dataUpdate",h),i.off("viewportChange",h)}},getSnapshot:r}},[i,t]);return A.useSyncExternalStore(e.subscribe,e.getSnapshot)}function ba(i,t){const e=A.useMemo(()=>Wi(i,"dataUpdate",()=>i.getPreviousClose(t)),[i,t]);return A.useSyncExternalStore(e.subscribe,e.getSnapshot)}function ci(i){const t=A.useMemo(()=>Wi(i,"crosshairMove",()=>i.getCrosshairPosition()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}const va=(i,t)=>t==="volume"?oe(i):es(i);function Wn({sort:i="none",format:t=va,children:e}){const s=lt(),n=hi(),r=ci(s),[,o]=A.useState(0);A.useLayoutEffect(()=>{const f=()=>o(m=>m+1);return s.on("overlayChange",f),s.getSeriesIds().length>0&&o(m=>m+1),()=>{s.off("overlayChange",f)}},[s]);const l=Ln(s,{sort:i,cacheKey:"infobar-last"});let h=l,d=l.length===0?0:Math.max(...l.map(f=>f.data.time)),c=!1;if(r!==null){const f=hs(s,{time:r.time,sort:i,cacheKey:"infobar-hover"});f.length>0&&(h=f,d=r.time,c=!0)}if(h.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:h,time:d,isHover:c})});const u=s.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:ai(d,u)}),h.map(f=>{if("open"in f.data){const p=f.data,v=p.close>=p.open,w=pt(v?n.candlestick.up.body:n.candlestick.down.body);return C.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[C.jsx(Ve,{label:"O",display:t(p.open,"open"),color:w,dim:n.axis.textColor}),C.jsx(Ve,{label:"H",display:t(p.high,"high"),color:w,dim:n.axis.textColor}),C.jsx(Ve,{label:"L",display:t(p.low,"low"),color:w,dim:n.axis.textColor}),C.jsx(Ve,{label:"C",display:t(p.close,"close"),color:w,dim:n.axis.textColor}),p.volume!=null&&C.jsx(Ve,{label:"V",display:t(p.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const g=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(g.value,"value")})]},f.id)})]})}function Ve({label:i,display:t,color:e,dim:s}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{color:s,opacity:.5,marginLeft:5},children:i}),C.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function ya({chart:i,isolatedIdRef:t,setIsolatedId:e}){const s=[],n=i.getSeriesIds();for(const r of n){const o=i.getSeriesLayers(r);if(o){const l=i.getSeriesLabel(r);for(let h=0;h<o.length;h++){const d=`${r}_layer${h}`,c=i.isSeriesVisible(r)&&i.isLayerVisible(r,h);s.push($s({id:d,seriesId:r,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:o[h].color,isDisabled:!c,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=i.getSeriesColor(r);if(!l)continue;const h=i.getSeriesLabel(r),d=i.isSeriesVisible(r);s.push($s({id:r,seriesId:r,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!d,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}return s}function $s(i){const{id:t,seriesId:e,layerIndex:s,label:n,color:r,isDisabled:o,chart:l,isolatedIdRef:h,setIsolatedId:d}=i;return{id:t,seriesId:e,layerIndex:s,label:n,color:r,isDisabled:o,toggle:()=>{s!==void 0?l.setLayerVisible(e,s,!l.isLayerVisible(e,s)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const f of l.getSeriesIds()){l.setSeriesVisible(f,!0);const m=l.getSeriesLayers(f);if(m)for(let g=0;g<m.length;g++)l.setLayerVisible(f,g,!0)}}),h.current=null,d(null);return}l.batch(()=>{for(const f of l.getSeriesIds()){const m=l.getSeriesLayers(f);if(m){l.setSeriesVisible(f,f===e);for(let g=0;g<m.length;g++)l.setLayerVisible(f,g,f===e&&g===s)}else l.setSeriesVisible(f,f===t)}}),h.current=t,d(t)}}}function Fn({items:i,position:t="bottom",mode:e="toggle",children:s}){const n=lt(),r=hi(),[o,l]=A.useState(null),[h,d]=A.useState(0),c=A.useRef(o);c.current=o,A.useLayoutEffect(()=>{const p=()=>d(w=>w+1),v=()=>l(null);return n.on("overlayChange",p),n.on("seriesChange",v),n.getSeriesIds().length>0&&d(w=>w+1),()=>{n.off("overlayChange",p),n.off("seriesChange",v)}},[n]);const u=A.useMemo(()=>ya({chart:n,isolatedIdRef:c,setIsolatedId:l}),[n,o,h]),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(s)return u.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:s({items:u})});if(i)return i.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:i.map((p,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:p.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:p.label})]},v))});if(u.length===0)return null;const g=p=>{e==="isolate"||e==="solo"?p.isolate():p.toggle()};return C.jsx("div",{"data-legend":t,style:m,children:u.map(p=>C.jsxs("div",{onClick:()=>g(p),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:p.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:p.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:p.label})]},p.id))})}function Pn({data:i,height:t,style:e,className:s}){const n=lt(),r=hi(),o=A.useRef(null),l=A.useRef(null);A.useLayoutEffect(()=>{if(!o.current)return;const d=new Mn({container:o.current,chart:n,data:i,options:t!==void 0?{height:t}:void 0});return l.current=d,()=>{d.destroy(),l.current=null}},[n]),A.useEffect(()=>{var d;(d=l.current)==null||d.setData(i)},[i]),A.useEffect(()=>{var d;(d=l.current)==null||d.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??r.navigator.height;return C.jsx("div",{ref:o,className:s,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function xa(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function Dn({seriesId:i,mode:t,format:e,position:s,children:n}){const r=t??"both",o=s??"bottom",l=e??oe,h=lt(),d=h.getTheme(),[,c]=A.useState(0);A.useLayoutEffect(()=>{const g=()=>c(p=>p+1);return h.on("overlayChange",g),h.getSeriesIds().length>0&&g(),()=>{h.off("overlayChange",g)}},[h]);const u=xa(h,i),f=u!==null?h.getSliceInfo(u):null;if(!f||f.length===0)return null;if(n)return C.jsx(C.Fragment,{children:n({slices:f,mode:r,format:l})});const m=o==="overlay";return C.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":o,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((g,p)=>C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:g.color,flexShrink:0}}),C.jsx("span",{style:{flex:1,opacity:.8},children:g.label}),(r==="value"||r==="both")&&C.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:l(g.value)}),(r==="percent"||r==="both")&&C.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:[g.percent.toFixed(1),"%"]})]},p))})}function zn({children:i,sub:t,style:e}){const s=hi();return C.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:s.typography.fontFamily,fontSize:s.typography.fontSize,fontWeight:600,color:s.tooltip.textColor,pointerEvents:"none",...e},children:[i!=null&&i!==!1&&C.jsx("span",{children:i}),t!=null&&t!==!1&&C.jsx("span",{style:{fontWeight:400,color:s.axis.textColor,fontSize:s.axis.fontSize},children:t})]})}function wa(i){let t=null,e=null,s=null,n=null,r=null;const o=[],l=h=>{if(A.isValidElement(h)&&h.type===A.Fragment){A.Children.forEach(h.props.children,l);return}if(A.isValidElement(h)){if(h.type===zn){t=h;return}if(h.type===Fn){e=h;return}if(h.type===Dn){const d=h;d.props.position==="overlay"?o.push(h):s=d;return}if(h.type===Wn){n=h;return}if(h.type===Pn){r=h;return}}o.push(h)};return A.Children.forEach(i,l),{titleEl:t,legendEl:e,pieLegendEl:s,tooltipLegendEl:n,navigatorEl:r,overlay:o}}function En({children:i,theme:t,axis:e,padding:s,gradient:n=!0,interactive:r,grid:o,headerLayout:l="overlay",perf:h,animations:d,style:c,className:u}){var Pt,Mt,Ut,Pe,ui,di;const f=A.useRef(h),m=ma(),g=t??m??void 0,p=A.useRef(null),v=A.useRef(null),[w,x]=A.useState(0);A.useLayoutEffect(()=>{if(!p.current||v.current)return;const st={};return e&&(st.axis=e),g&&(st.theme=g),s&&(st.padding=s),r!==void 0&&(st.interactive=r),o!==void 0&&(st.grid=o),f.current!==void 0&&(st.perf=f.current),d!==void 0&&(st.animations=d),v.current=new bn(p.current,st),x(ft=>ft+1),()=>{var ft;(ft=v.current)==null||ft.destroy(),v.current=null}},[]),A.useEffect(()=>{v.current&&g&&v.current.setTheme(g)},[g]),A.useEffect(()=>{v.current&&e&&v.current.setAxis(e)},[(Pt=e==null?void 0:e.y)==null?void 0:Pt.width,(Mt=e==null?void 0:e.y)==null?void 0:Mt.min,(Ut=e==null?void 0:e.y)==null?void 0:Ut.max,(Pe=e==null?void 0:e.y)==null?void 0:Pe.visible,(ui=e==null?void 0:e.x)==null?void 0:ui.height,(di=e==null?void 0:e.x)==null?void 0:di.visible]),A.useEffect(()=>{v.current&&d!==void 0&&v.current.setAnimations(d)},[JSON.stringify(d)]);const y=A.useRef(null),[M,S]=A.useState(0),P=l==="overlay"?M:0;A.useEffect(()=>{const st=v.current;if(!st)return;const Gt={top:((s==null?void 0:s.top)??20)+P,...(s==null?void 0:s.bottom)!==void 0?{bottom:s.bottom}:{},...(s==null?void 0:s.right)!==void 0?{right:s.right}:{},...(s==null?void 0:s.left)!==void 0?{left:s.left}:{}};st.setPadding(Gt)},[s==null?void 0:s.top,s==null?void 0:s.bottom,typeof(s==null?void 0:s.right)=="object"?s.right.intervals:s==null?void 0:s.right,typeof(s==null?void 0:s.left)=="object"?s.left.intervals:s==null?void 0:s.left,P]),A.useEffect(()=>{v.current&&o!==void 0&&v.current.setGrid(o)},[o==null?void 0:o.visible]);const b=v.current,{titleEl:L,legendEl:I,pieLegendEl:T,tooltipLegendEl:W,navigatorEl:F,overlay:V}=wa(i),z=(I==null?void 0:I.props.position)??"bottom",_=(T==null?void 0:T.props.position)??"bottom",N=z==="right"||_==="right",H=g??(b==null?void 0:b.getTheme()),[it,U]=(H==null?void 0:H.chartGradient)??["transparent","transparent"],bt=(H==null?void 0:H.background)??"transparent",vt=n?`linear-gradient(to bottom, ${it} 0%, ${bt} 70%, ${U} 100%)`:bt;A.useLayoutEffect(()=>{if(l!=="overlay"){S(0);return}const st=y.current;if(!st){S(0);return}const ft=()=>S(st.getBoundingClientRect().height);ft();const Gt=new ResizeObserver(ft);return Gt.observe(st),()=>Gt.disconnect()},[L!==null,W!==null,l,b!==null]);const St=(L||W)&&C.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":l==="overlay"?"":void 0,ref:y,style:l==="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:[L,W]}),Q=C.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:b&&C.jsx(Re.Provider,{value:b,children:C.jsxs(Le,{value:g??b.getTheme(),children:[l==="overlay"&&St,C.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:V})]})})}),Xt=l==="inline"?C.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[b&&St&&C.jsx(Re.Provider,{value:b,children:C.jsx(Le,{value:g??b.getTheme(),children:St})}),Q]}):Q,yt=b&&I&&C.jsx(Re.Provider,{value:b,children:C.jsx(Le,{value:g??b.getTheme(),children:I})}),ut=b&&T&&C.jsx(Re.Provider,{value:b,children:C.jsx(Le,{value:g??b.getTheme(),children:T})}),dt=b&&F&&C.jsx(Re.Provider,{value:b,children:C.jsx(Le,{value:g??b.getTheme(),children:F})});return C.jsxs("div",{className:u,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:vt,...c},children:[C.jsxs("div",{style:{display:"flex",flexDirection:N?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Xt,yt,ut]}),dt]})}const Sa=20;function Vn({data:i,options:t,id:e}){var h,d;const s=lt(),n=A.useRef(null),r=A.useRef([]),o=A.useRef([]),l=A.useRef([]);return A.useLayoutEffect(()=>{const c=s.addLineSeries({...t,layers:i.length,id:e});return n.current=c,r.current=new Array(i.length).fill(0),o.current=new Array(i.length).fill(null),l.current=new Array(i.length).fill(null),()=>{s.removeSeries(c),n.current=null,r.current=[],o.current=[],l.current=[]}},[s,i.length,e]),A.useLayoutEffect(()=>{const c=n.current;c&&s.batch(()=>{for(let u=0;u<i.length;u++){const f=i[u],m=r.current[u]??0,g=o.current[u]??null;if(f.length===0){s.setSeriesData(c,[],u),r.current[u]=0,o.current[u]=null,l.current[u]=null;continue}const p=ct(f[0].time),v=ct(f[f.length-1].time),w=l.current[u]??null,x=g!==null&&g!==p,y=f.length-m;if(x&&y===0&&(w!==null&&w!==v))s.setSeriesData(c,f.slice(0,-1),u),s.appendData(c,f[f.length-1],u);else if(m===0||f.length<m||y>Sa||x)s.setSeriesData(c,f,u);else if(f.length===m)s.updateData(c,f[f.length-1],u);else for(let S=m;S<f.length;S++)s.appendData(c,f[S],u);r.current[u]=f.length,o.current[u]=p,l.current[u]=v}})},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(h=t==null?void 0:t.colors)==null?void 0:h.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 Ma({data:i,options:t,id:e}){var r,o,l,h,d,c,u,f,m,g;const s=lt(),n=A.useRef(null);return A.useLayoutEffect(()=>{const p=s.addPieSeries({...t,id:e});return n.current=p,()=>{s.removeSeries(p),n.current=null}},[s,e]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,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,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.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,(g=t==null?void 0:t.sliceLabels)==null?void 0:g.balanceSides]),A.useLayoutEffect(()=>{n.current&&s.setSeriesData(n.current,i)},[s,i]),null}function ka(){const i=lt(),t=ci(i);if(!t)return null;const e=i.getTheme(),s=i.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 C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:i.yScale.formatY(t.y)}),C.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:ai(t.time,s)})]})}const Ca=["0","1","2","3","4","5","6","7","8","9"];function Ta(i){const t=[];for(const e of i)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function Yn({value:i,format:t,locale:e="en-US",spinDuration:s=350,className:n,style:r}){const l=A.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])(i),h=Ta(l);return C.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:h.map((d,c)=>d.type==="digit"?C.jsx(Ra,{digit:parseInt(d.value,10),duration:s},`d${c}`):C.jsx("span",{style:{display:"inline-block"},children:d.value},`s${c}`))})}function Ra({digit:i,duration:t}){const e=A.useRef(!1);return A.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(${-i*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Ca.map(s=>C.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:s},s))})})}function La(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Ia=160,Aa=70;function Ba({seriesId:i,format:t=oe,children:e}){const s=lt(),n=ci(s),[,r]=A.useState(0);A.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return s.on("overlayChange",f),()=>{s.off("overlayChange",f)}},[s]);const o=La(s,i),l=o!==null?s.getHoverInfo(o):null;if(!l||!n)return null;const h=s.getTheme(),d=s.getMediaSize();if(e)return C.jsx(Wa,{x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,children:e({info:l,format:t})});const{left:c,top:u}=li({x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,tooltipWidth:Ia,tooltipHeight:Aa,offsetX:16,offsetY:16});return C.jsxs("div",{style:{position:"absolute",left:c,top:u,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.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:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.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:l.color,flexShrink:0}}),C.jsx("span",{style:{fontWeight:600},children:l.label})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[C.jsx("span",{style:{opacity:.6},children:t(l.value)}),C.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function Wa({x:i,y:t,chartWidth:e,chartHeight:s,children:n}){const r=A.useRef(null),[o,l]=A.useState(null);A.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&&l(g=>g&&g.width===f.width&&g.height===f.height?g:{width:f.width,height:f.height})});return c.observe(d),()=>c.disconnect()},[]);const h=o?li({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:o.width,tooltipHeight:o.height,offsetX:16,offsetY:16}):{left:0,top:0};return C.jsx("div",{ref:r,"data-measured":o?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:o?"visible":"hidden"},children:n})}function Fa(i,t){if(i.startsWith("rgba")||!i.startsWith("#"))return i;const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function Pa(i){if(i.length<2)return{value:0,pct:0,positive:!0};const t=i[0].value,s=i[i.length-1].value-t,n=t!==0?s/t*100:0;return{value:s,pct:n,positive:s>=0}}function Da({data:i,theme:t,variant:e="line",valuePosition:s="right",formatValue:n=oe,label:r,sublabel:o,color:l,negativeColor:h,area:d,areaFill:c,width:u=140,height:f=48,strokeWidth:m=1.5,gradient:g=!0,style:p}){const v=(d==null?void 0:d.visible)??c??!0,w=i.length>0?i[i.length-1].value:0,x=A.useMemo(()=>Pa(i),[i]),y=l??t.seriesColors[0],M=h??pt(t.candlestick.down.body),S=pt(x.positive?t.candlestick.up.body:t.candlestick.down.body),P=s!=="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.axis.fontSize,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(w)}),o!==void 0?C.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:o}):C.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:S,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[x.positive?"+":"",x.pct.toFixed(1),"%"]})]}),b=C.jsx("div",{style:{width:u,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:C.jsx(En,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:g,interactive:!1,grid:{visible:!1},children:e==="line"?C.jsx(Vn,{data:[i],options:{colors:[y],strokeWidth:m,area:{visible:v},pulse:!1,stacking:"off"}}):C.jsx(In,{data:[i],options:{colors:[y,M],barWidthRatio:.7,stacking:"off"}})})});return C.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Fa(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...p},children:[s==="left"&&P,b,s==="right"&&P]})}const jn=250,_n=`opacity ${jn/1e3}s ease`,On=jn*2;function Hn({labelCount:i,minLabelSpacing:t}={}){const e=lt();An(e),A.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:i??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,i,t]);const s=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:o}=e.timeScale.niceTickValues(n),l=new Set(r),d=A.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)l.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>On&&d.delete(f);const u=Array.from(d.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:u.map(([f,m])=>{const g=e.timeScale.timeToX(f);return C.jsx("span",{style:{position:"absolute",left:g,transform:"translateX(-50%)",color:ss(s,"x"),fontSize:is(s,"x"),fontFamily:s.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:_n,willChange:"opacity"},children:ai(f,o)},f)})})}const za=(i,t)=>t==="volume"?oe(i):es(i);function Ea({sort:i="none",format:t=za,children:e}){const s=lt(),n=ci(s),[,r]=A.useState(0);if(A.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return s.on("overlayChange",f),s.getSeriesIds().length>0&&r(m=>m+1),()=>{s.off("overlayChange",f)}},[s]),!n)return null;const o=hs(s,{time:n.time,sort:i,cacheKey:"tooltip"});if(o.length===0)return null;const l=s.getTheme(),h=s.getDataInterval(),d=s.getMediaSize(),c=d.width-s.yAxisWidth,u=d.height-s.xAxisHeight;return e?C.jsx(Va,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,children:e({snapshots:o,time:n.time})}):C.jsx(Ya,{snapshots:o,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,dataInterval:h,format:t})}function Va({x:i,y:t,chartWidth:e,chartHeight:s,theme:n,children:r}){const o=A.useRef(null),[l,h]=A.useState(null);A.useEffect(()=>{const c=o.current;if(!c||typeof ResizeObserver>"u")return;const u=new ResizeObserver(f=>{var g;const m=(g=f[0])==null?void 0:g.contentRect;m&&h(p=>p&&p.width===m.width&&p.height===m.height?p:{width:m.width,height:m.height})});return u.observe(c),()=>u.disconnect()},[]);const d=l?li({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return C.jsx("div",{ref:o,"data-measured":l?"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:l?"visible":"hidden"},children:r})}function Ya({snapshots:i,displayTime:t,x:e,y:s,chartWidth:n,chartHeight:r,theme:o,dataInterval:l,format:h}){const d=i.some(x=>"open"in x.data),c=i.filter(x=>!("open"in x.data)).length,u=160,f=d?140:40+c*22,{left:m,top:g}=li({x:e,y:s,chartWidth:n,chartHeight:r,tooltipWidth:u,tooltipHeight:f}),p=o.tooltip.background,v=o.tooltip.borderColor;return C.jsxs("div",{style:{position:"absolute",left:m,top:g,pointerEvents:"none",background:p,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:o.tooltip.fontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,width:u,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[C.jsxs("div",{style:{fontSize:o.axis.fontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${v}`,letterSpacing:"0.02em"},children:[Qs(t)," ",ai(t,l)]}),i.map(x=>{if("open"in x.data){const S=x.data,P=S.close>=S.open,b=pt(P?o.candlestick.up.body:o.candlestick.down.body);return C.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[C.jsx(Ye,{label:"Open",color:b,display:h(S.open,"open")}),C.jsx(Ye,{label:"High",color:b,display:h(S.high,"high")}),C.jsx(Ye,{label:"Low",color:b,display:h(S.low,"low")}),C.jsx(Ye,{label:"Close",color:b,display:h(S.close,"close")}),S.volume!=null&&C.jsx(Ye,{label:"Volume",color:o.tooltip.textColor,display:h(S.volume,"volume")})]},x.id)}const M=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:h(M.value,"value")})]},x.id)})]})}function Ye({label:i,color:t,display:e}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{opacity:.5},children:i}),C.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function ja({format:i,labelCount:t,minLabelSpacing:e}={}){const s=lt();Bn(s),A.useLayoutEffect(()=>(s.yScale.setFormat(i??null),()=>s.yScale.setFormat(null)),[s,i]),A.useLayoutEffect(()=>(s.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{s.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[s,t,e]);const n=s.getTheme(),r=s.yScale.niceTickValues(),o=new Set(r),h=A.useRef(new Map).current,d=performance.now();for(const u of r)h.has(u)?h.get(u).opacity=1:h.set(u,{opacity:1,addedAt:d});for(const[u,f]of h)o.has(u)||f.opacity!==0&&(f.opacity=0,f.fadedAt=d);for(const[u,f]of h)f.opacity===0&&f.fadedAt!==void 0&&d-f.fadedAt>On&&h.delete(u);const c=Array.from(h.entries());return C.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:s.xAxisHeight,width:s.yAxisWidth,pointerEvents:"none"},children:c.map(([u,f])=>{const m=s.yScale.valueToY(u);return C.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:ss(n,"y"),fontSize:is(n,"y"),fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:_n,willChange:"opacity"},children:s.yScale.formatY(u)},u)})})}function _a(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const s=i.getSeriesIdsByType("time",{visibleOnly:!0});return s.length>0?s[0]:null}function Oa({seriesId:i,color:t,format:e,children:s}){const n=lt();A.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=A.useState(0);A.useLayoutEffect(()=>{const y=()=>r(M=>M+1);return n.on("overlayChange",y),n.on("viewportChange",y),n.getSeriesIds().length>0&&r(M=>M+1),()=>{n.off("overlayChange",y),n.off("viewportChange",y)}},[n]);const o=_a(n,i),l=o!==null?n.getStackedLastValue(o):null,h=o!==null?n.getPreviousClose(o):null,d=n.yScale.getRange(),c=d.max-d.min,u=c<.1?6:c<10?4:c<1e3?2:0,f=A.useMemo(()=>{if(e)return e;const y=new Intl.NumberFormat("en-US",{minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!1});return M=>y.format(M)},[e,u]);if(!l||o===null)return null;const{value:m,isLive:g}=l,p=n.getTheme(),v=n.yScale.valueToY(m),w=h===null?"neutral":m>h?"up":m<h?"down":"neutral";let x;return g?t?x=t:x=w==="up"?p.yLabel.upBackground:w==="down"?p.yLabel.downBackground:p.yLabel.neutralBackground:x=p.axis.textColor,s?C.jsx(C.Fragment,{children:s({value:m,y:v,bgColor:x,isLive:g,direction:w,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:p.yLabel.textColor,fontSize:p.yLabel.fontSize,fontFamily:p.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:C.jsx(Yn,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=In;exports.CandlestickSeries=ga;exports.ChartContainer=En;exports.ChartInstance=bn;exports.Crosshair=ka;exports.InfoBar=Wn;exports.Legend=Fn;exports.LineSeries=Vn;exports.Navigator=Pn;exports.NavigatorController=Mn;exports.NumberFlow=Yn;exports.PieLegend=Dn;exports.PieSeries=Ma;exports.PieTooltip=Ba;exports.Sparkline=Da;exports.ThemeProvider=Le;exports.TimeAxis=Hn;exports.Title=zn;exports.Tooltip=Ea;exports.XAxis=Hn;exports.YAxis=ja;exports.YLabel=Oa;exports.andromeda=jo;exports.autoGradient=E;exports.ayuMirage=_o;exports.buildHoverSnapshots=hs;exports.buildLastSnapshots=Ln;exports.catppuccin=Oo;exports.computeTooltipPosition=li;exports.createTheme=J;exports.darkTheme=gn;exports.detectInterval=Js;exports.dracula=Ho;exports.formatCompact=oe;exports.formatDate=Qs;exports.formatPriceAdaptive=es;exports.formatTime=ai;exports.githubLight=$o;exports.gruvbox=No;exports.handwritten=Xo;exports.highContrast=Ko;exports.lavenderMist=qo;exports.lightPink=Jo;exports.lightTheme=Yo;exports.materialPalenight=Qo;exports.minimalLight=ea;exports.mintBreeze=ia;exports.monokaiPro=sa;exports.nightOwl=na;exports.normalizeTime=ct;exports.oneDarkPro=ra;exports.panda=oa;exports.peachCream=aa;exports.quietLight=la;exports.resolveAxisFontSize=is;exports.resolveAxisTextColor=ss;exports.resolveCandlestickBodyColor=pt;exports.rosePineDawn=ha;exports.sandDune=ca;exports.solarizedLight=ua;exports.useChartInstance=lt;exports.useCrosshairPosition=ci;exports.useLastYValue=pa;exports.usePreviousClose=ba;exports.useTheme=hi;exports.useVisibleRange=An;exports.useYRange=Bn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),C=require("react/jsx-runtime");var Gn=Object.defineProperty,Xs=i=>{throw TypeError(i)},Kn=(i,t,e)=>t in i?Gn(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,R=(i,t,e)=>Kn(i,typeof t!="symbol"?t+"":t,e),Qi=(i,t,e)=>t.has(i)||Xs("Cannot "+e),a=(i,t,e)=>(Qi(i,t,"read from private field"),e?e.call(i):t.get(i)),W=(i,t,e)=>t.has(i)?Xs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),k=(i,t,e,s)=>(Qi(i,t,"write to private field"),t.set(i,e),e),B=(i,t,e)=>(Qi(i,t,"access private method"),e),Hi=(i,t,e,s)=>({set _(n){k(i,t,n)},get _(){return a(i,t,s)}});const pe=i=>1-(1-i)**3;class Pe{constructor(t){R(this,"_current"),R(this,"_from"),R(this,"_to"),R(this,"_startTime",0),R(this,"_activeDuration"),R(this,"_defaultDuration"),R(this,"_easing"),R(this,"_lerp"),R(this,"_equals"),R(this,"_animating",!1),this._current=t.initial,this._from=t.initial,this._to=t.initial,this._defaultDuration=t.duration,this._activeDuration=t.duration,this._easing=t.easing??pe,this._lerp=t.lerp,this._equals=t.equals??Object.is}get current(){return this._current}get target(){return this._to}get animating(){return this._animating}snap(t){this._current=t,this._from=t,this._to=t,this._animating=!1}setTarget(t,e={}){const s=e.now??performance.now();if(this._animating){if(this._equals(t,this._to))return;this.tick(s)}else if(this._equals(t,this._current))return;const n=e.duration??this._defaultDuration;if(n<=0){this.snap(t);return}this._from=this._current,this._to=t,this._activeDuration=n,this._startTime=s,this._animating=!0}tick(t){if(!this._animating)return!1;const e=t-this._startTime;if(e>=this._activeDuration)return this._current=this._to,this._animating=!1,!1;const s=e<=0?0:e/this._activeDuration;return this._current=this._lerp(this._from,this._to,this._easing(s)),!0}}const ms=250,bi={streamTick:ms,fit:ms},Ii=250,be=Ii,Zi=Ii,Us=600,Gs=Ii,qn=0,Ni=Ii,ps=100;class ai{constructor(){R(this,"listeners",new Map)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){var s;(s=this.listeners.get(t))==null||s.delete(e)}emit(t,...e){var s;(s=this.listeners.get(t))==null||s.forEach(n=>n(...e))}removeAllListeners(){this.listeners.clear()}}function bs(i,t){const e=new Map;return new Proxy(i,{get(s,n){const r=Reflect.get(s,n,s);if(typeof r!="function")return r;const o=e.get(n);if(o)return o;const l=typeof n=="string"?n:String(n),h=r,d=(...c)=>(t.set(l,(t.get(l)??0)+1),h.apply(s,c));return e.set(n,d),d},set(s,n,r){return Reflect.set(s,n,r,s)}})}function vs(i,t,e){const s=document.createElement("canvas");return s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.display="block",s.style.zIndex=String(t),i.appendChild(s),s}class Jn extends ai{constructor(t,e){super(),R(this,"mainCanvas"),R(this,"mainCtx"),R(this,"overlayCanvas"),R(this,"overlayCtx"),R(this,"resizeObserver"),R(this,"_size"),R(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=vs(t,0),this.overlayCanvas=vs(t,1);const s=this.mainCanvas.getContext("2d",{alpha:!0}),n=this.overlayCanvas.getContext("2d",{alpha:!0});if(!s||!n)throw new Error("CanvasManager: failed to acquire 2D rendering context");this.mainCtx=e?bs(s,e.drawCallsMain):s,this.overlayCtx=e?bs(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(l=>{this.handleResize(l[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const o=t.getBoundingClientRect();if(o.width>0&&o.height>0){const l=window.devicePixelRatio||1,h=l,d=Math.round(o.width*l),c=Math.round(o.height*h);this.mainCanvas.width=d,this.mainCanvas.height=c,this.overlayCanvas.width=d,this.overlayCanvas.height=c,this._size={media:{width:o.width,height:o.height},bitmap:{width:d,height:c},horizontalPixelRatio:d/o.width,verticalPixelRatio:c/o.height}}}handleResize(t){var e,s;let n,r,o,l;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];o=u.inlineSize,l=u.blockSize}else{const c=(s=t.contentBoxSize)==null?void 0:s[0];if(c)o=c.inlineSize,l=c.blockSize;else{const f=t.contentRect;o=f.width,l=f.height}const u=window.devicePixelRatio||1;n=Math.round(o*u),r=Math.round(l*u)}if(n===0||r===0)return;this.mainCanvas.width=n,this.mainCanvas.height=r,this.overlayCanvas.width=n,this.overlayCanvas.height=r;const h=n/o,d=r/l;this._size={media:{width:o,height:l},bitmap:{width:n,height:r},horizontalPixelRatio:h,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:s}=this._size.bitmap;this.overlayCtx.clearRect(0,0,e,s),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 Qn(i,t,e,s){const{context:n,bitmapSize:r,horizontalPixelRatio:o}=i;n.strokeStyle=s.crosshair.color,n.lineWidth=1,n.setLineDash([4*o,4*o]);const l=Math.round(t)+.5,h=Math.round(e)+.5;n.beginPath(),n.moveTo(l,0),n.lineTo(l,r.height),n.moveTo(0,h),n.lineTo(r.width,h),n.stroke(),n.setLineDash([])}const Zn=3,tr=8,ys=900,er=24,ir=11,sr=10,nr=18;function rr(i){const{state:t}=i;if(t==="idle"||t==="has-more")return;const e=i.timeScale.timeToX(i.boundaryTime);if(Number.isFinite(e)){if(t==="loading"){or(i,e);return}t==="no-data"&&ar(i,e)}}function or({scope:i,theme:t,chartMediaHeight:e,side:s,now:n},r){const{context:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i,d=Zn*l,c=tr*l,u=er*l,f=r*l,m=s==="right"?f+u:f-u,g=e/2*h,p=n%ys/ys,v=Math.floor(p*3),w=Ks(t.axis.textColor??"#787b86",.3),x=t.axis.textColor??"#787b86";o.save();for(let y=0;y<3;y++){const M=(y-1)*c,S=m+M;o.beginPath(),o.arc(S,g,d,0,Math.PI*2),o.fillStyle=y===v?x:w,o.fill()}o.restore()}function ar({scope:i,theme:t,chartMediaHeight:e,side:s},n){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=i,h=Math.round(n*o)+.5;r.save(),r.strokeStyle=Ks(t.axis.textColor??"#787b86",.6),r.lineWidth=1,r.setLineDash([4*o,4*o]),r.beginPath(),r.moveTo(h,0),r.lineTo(h,e*l),r.stroke(),r.setLineDash([]);const d=sr*o,c=s==="right"?h-d:h+d,u=nr*l;r.fillStyle=t.axis.textColor??"#787b86",r.font=`${ir*o}px ${t.typography.fontFamily}`,r.textAlign=s==="right"?"right":"left",r.textBaseline="top",r.fillText("No more data",c,u),r.restore()}function Ks(i,t){const e=/^#([0-9a-f]{6})$/i.exec(i.trim());if(!e)return i;const s=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(${s}, ${n}, ${r}, ${t})`}function lr(i,t,e,s,n){const{context:r,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=i;r.strokeStyle=s.grid.color,r.lineWidth=1,s.grid.style==="dashed"?r.setLineDash([4*l,4*l]):s.grid.style==="dotted"&&r.setLineDash([1*l,3*l]);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(o.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,o.height)}r.stroke(),r.setLineDash([])}function Fe(i,t,e){return Math.max(t,Math.min(e,i))}function mt(i,t,e){return i+(t-i)*e}function xs(i,t,e,s){const n=Math.exp(-e*s);return t+(i-t)*n}function qs(i){return 1-(1-i)**3}function Bi(i,t,e){let s=0,n=i.length-1;for(;s<=n;){const r=s+n>>>1,o=e(i[r]);if(o<t)s=r+1;else if(o>t)n=r-1;else return r}return s}class Js extends ai{constructor(){super(...arguments),R(this,"data",[]),R(this,"_visible",!0),R(this,"cachedRange",null),R(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let e=!0;for(let s=1;s<t.length;s++)if(t[s].time<t[s-1].time){e=!1;break}this.data=e?t.slice():[...t].sort((s,n)=>s.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 s=Math.max(0,Bi(this.data,t,r=>r.time)-1),n=Math.min(this.data.length,Bi(this.data,e,r=>r.time)+1);return this.cachedResult=this.data.slice(s,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 s=Bi(this.data,t,o=>o.time);let n=null,r=e;for(let o=Math.max(0,s-1);o<=Math.min(this.data.length-1,s+1);o++){const l=Math.abs(this.data[o].time-t);l<=r&&(r=l,n=this.data[o])}return n}}class hr{constructor(t,e,s,n=0){R(this,"dragging",!1),R(this,"lastX",0),this.viewport=t,this.timeScale=e,this.canvas=s,this.inputResponseMs=n}setInputResponseMs(t){this.inputResponseMs=Math.max(0,t)}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 s=this.timeScale.pixelDeltaToTimeDelta(-e);this.viewport.pan(s,this.timeScale.getMediaWidth(),this.inputResponseMs)}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair",this.viewport.startRebound(this.timeScale.getMediaWidth()))}isDragging(){return this.dragging}}const cr=150;class ur{constructor(t,e,s=0){R(this,"reboundTimer",null),this.viewport=t,this.timeScale=e,this.inputResponseMs=s}setInputResponseMs(t){this.inputResponseMs=Math.max(0,t)}getInputResponseMs(){return this.inputResponseMs}handleWheel(t){t.preventDefault();const e=dr(t.deltaY,t.deltaMode),s=Math.exp(e*.005),n=this.timeScale.getMediaWidth(),r=Math.min(t.offsetX,n),o=this.timeScale.xToTime(r);this.viewport.zoomAt(o,s,n,this.inputResponseMs),this.reboundTimer!==null&&clearTimeout(this.reboundTimer),this.reboundTimer=setTimeout(()=>{this.reboundTimer=null,this.viewport.startRebound(n)},cr)}cancelPendingRebound(){this.reboundTimer!==null&&(clearTimeout(this.reboundTimer),this.reboundTimer=null)}}function dr(i,t){return t===WheelEvent.DOM_DELTA_LINE?i*8:t===WheelEvent.DOM_DELTA_PAGE?i*24:i}class fr extends ai{constructor(t,e,s,n,r=0){super(),R(this,"zoom"),R(this,"pan"),R(this,"canvas"),R(this,"timeScale"),R(this,"yScale"),R(this,"viewport"),R(this,"onWheel",o=>{this.zoom.handleWheel(o)}),R(this,"onMouseDown",o=>{this.zoom.cancelPendingRebound(),this.pan.handleMouseDown(o)}),R(this,"onMouseMove",o=>{this.pan.isDragging()&&this.pan.handleMouseMove(o),this.emitCrosshair(o.offsetX,o.offsetY)}),R(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),R(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),R(this,"onDblClick",()=>{}),R(this,"lastTouchDist",0),R(this,"lastTouchCenter",0),R(this,"touchCount",0),R(this,"onTouchStart",o=>{o.preventDefault(),this.zoom.cancelPendingRebound(),this.touchCount=o.touches.length,o.touches.length===1?this.pan.handleMouseDown({button:0,clientX:o.touches[0].clientX}):o.touches.length===2&&(this.lastTouchDist=Math.abs(o.touches[0].clientX-o.touches[1].clientX),this.lastTouchCenter=(o.touches[0].clientX+o.touches[1].clientX)/2)}),R(this,"onTouchMove",o=>{if(o.preventDefault(),o.touches.length===1&&this.touchCount===1)this.pan.handleMouseMove({clientX:o.touches[0].clientX});else if(o.touches.length===2){const l=Math.abs(o.touches[0].clientX-o.touches[1].clientX),h=(o.touches[0].clientX+o.touches[1].clientX)/2,d=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const c=this.lastTouchDist/l,u=this.timeScale.xToTime(h-d.left);this.viewport.zoomAt(u,c,this.timeScale.getMediaWidth(),this.zoom.getInputResponseMs())}this.lastTouchDist=l,this.lastTouchCenter=h}}),R(this,"onTouchEnd",o=>{if(o.touches.length===0){const l=this.touchCount===2;this.pan.handleMouseUp(),l&&this.viewport.startRebound(this.timeScale.getMediaWidth()),this.touchCount=0,this.lastTouchDist=0,this.emit("crosshairMove",null)}}),this.canvas=t,this.viewport=e,this.timeScale=s,this.yScale=n,this.zoom=new ur(e,s,r),this.pan=new hr(e,s,t,r),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)}setInputResponseMs(t){this.pan.setInputResponseMs(t),this.zoom.setInputResponseMs(t)}emitCrosshair(t,e){const s=this.timeScale.xToTime(t),n=this.yScale.yToValue(e);this.emit("crosshairMove",{mediaX:t,mediaY:e,time:s,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 gr=new WeakMap;function mr(i,t){gr.set(i,t)}const pr=100,br={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 ws(i){let t=0;for(const e of Object.values(i))t+=e;return t}const oi=9,ts=7,Ft=6,es=9;function vr(i,t){return Math.round(i*t).toLocaleString("en-US")}function Ss(i,t,e,s,n){return[i.padEnd(oi),t.toFixed(1).padStart(ts),e.toFixed(2).padStart(Ft),s.toFixed(2).padStart(Ft),vr(n,t).padStart(es)].join(" ")}function Ms(i){return[i.padEnd(oi),"—".padStart(ts),"—".padStart(Ft),"—".padStart(Ft),"idle".padStart(es)].join(" ")}function yr(){return["".padEnd(oi),"FPS".padStart(ts),"ms".padStart(Ft),"worst".padStart(Ft),"calls/s".padStart(es)].join(" ")}function xr(i){const t=ws(i.drawCalls.main),e=ws(i.drawCalls.overlay),s=i.frameCount.main===0?Ms("Main"):Ss("Main",i.mainRendersPerSec,i.mainFrameMs.last,i.mainFrameMs.p95,t),n=i.frameCount.overlay===0?Ms("Overlay"):Ss("Overlay",i.overlayRendersPerSec,i.overlayFrameMs.last,i.overlayFrameMs.p95,e),r=[yr(),s,n],o=Object.keys(i.perSeries);if(o.length>1){r.push(""),r.push("Per series (main pass)"),r.push(["".padEnd(oi),"ms".padStart(Ft),"worst".padStart(Ft)].join(" "));for(const l of o){const h=i.perSeries[l];r.push([` ${l}`.padEnd(oi),h.last.toFixed(2).padStart(Ft),h.p95.toFixed(2).padStart(Ft)].join(" "))}}return r.join(`
|
|
2
|
+
`)}class wr{constructor(t,e,s=pr){R(this,"element"),R(this,"unsubscribe"),R(this,"updateIntervalMs"),R(this,"lastUpdate",0),this.updateIntervalMs=s;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,br),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=xr(t))}}const Sr=5e3,Mr=2e3,kr=30;function zi(i,t,e){let s=0;for(;s<t.length&&t[s]<e;)s++;s>0&&(i.splice(0,s),t.splice(0,s))}function Ei(i,t,e){const s=i.length-e;s>0&&(i.splice(0,s),t.splice(0,s))}function Vi(i){if(i.length===0)return{last:0,p50:0,p95:0};const t=[...i].sort((e,s)=>e-s);return{last:i[i.length-1],p50:t[Math.floor(t.length*.5)]??0,p95:t[Math.floor(t.length*.95)]??0}}function ks(i){if(i.length<2)return 0;const t=i[i.length-1]-i[0];return t<=0?0:(i.length-1)*1e3/t}function Cs(i){const t={};for(const[e,s]of i)t[e]=s;return t}class Yi{constructor(t={}){R(this,"drawCallsMain",new Map),R(this,"drawCallsOverlay",new Map),R(this,"mainMs",[]),R(this,"overlayMs",[]),R(this,"mainStamps",[]),R(this,"overlayStamps",[]),R(this,"perSeriesMs",new Map),R(this,"perSeriesStamps",new Map),R(this,"listeners",new Set),R(this,"windowMs"),R(this,"maxSamples"),R(this,"heapInterval"),R(this,"heapCounter",0),R(this,"heapMb",null),R(this,"mainFrameCount",0),R(this,"overlayFrameCount",0),R(this,"lastStamp",0),this.windowMs=t.windowMs??Sr,this.maxSamples=t.maxSamples??Mr,this.heapInterval=t.heapSampleEveryNFrames??kr}resetDrawCalls(t){(t==="main"?this.drawCallsMain:this.drawCallsOverlay).clear()}recordFrame(t,e,s){if(this.lastStamp=s,t==="main"?(this.mainMs.push(e),this.mainStamps.push(s),this.mainFrameCount++,this.sampleHeap()):(this.overlayMs.push(e),this.overlayStamps.push(s),this.overlayFrameCount++),this.trimAll(s),this.listeners.size>0){const n=this.getStats();for(const r of this.listeners)r(n)}}recordSeries(t,e,s=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(s)}trimAll(t){const e=t-this.windowMs;zi(this.mainMs,this.mainStamps,e),zi(this.overlayMs,this.overlayStamps,e),Ei(this.mainMs,this.mainStamps,this.maxSamples),Ei(this.overlayMs,this.overlayStamps,this.maxSamples);for(const s of this.perSeriesMs.keys()){const n=this.perSeriesMs.get(s),r=this.perSeriesStamps.get(s);!n||!r||(zi(n,r,e),Ei(n,r,this.maxSamples))}}onFrame(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}getStats(){const t={};for(const[s,n]of this.perSeriesMs)t[s]=Vi(n);const e=ks(this.mainStamps);return{mainRendersPerSec:e,overlayRendersPerSec:ks(this.overlayStamps),fps:e,mainFrameMs:Vi(this.mainMs),overlayFrameMs:Vi(this.overlayMs),frameCount:{main:this.mainFrameCount,overlay:this.overlayFrameCount},drawCalls:{main:Cs(this.drawCallsMain),overlay:Cs(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 mi{constructor(t){R(this,"dirty",!1),R(this,"rafId",null),R(this,"callback"),R(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 ve=6e4,le=36e5,se=864e5,Bt=365*se;function ct(i){return i instanceof Date?i.getTime():i}function Cr(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:ct(t.time)}))}function Tr(i){return i.length===0||!i.some(t=>t.time instanceof Date)?i:i.map(t=>({...t,time:ct(t.time)}))}function Qs(i){if(i.length<2)return se;const t=[];for(let e=1;e<Math.min(i.length,20);e++)t.push(i[e]-i[e-1]);return t.sort((e,s)=>e-s),t[Math.floor(t.length/2)]}function li(i,t){const e=new Date(i);return t>=Bt?e.toLocaleDateString("en-US",{year:"numeric"}):t>=se?e.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=le?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 Zs(i){return new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Rr(i){const t=[1e3,5e3,1e4,15e3,3e4],e=[ve,5*ve,10*ve,15*ve,30*ve],s=[le,2*le,4*le,6*le,12*le],n=[se,7*se,30*se,90*se],r=[Bt,2*Bt,5*Bt,10*Bt,25*Bt,50*Bt,100*Bt];return i<ve?[...t,...e,...s,...n,...r]:i<le?[...e,...s,...n,...r]:i<se?[...s,...n,...r]:i<Bt?[...n,...r]:r}const Lr=50,Ir=80;class tn{constructor(){R(this,"from",0),R(this,"to",0),R(this,"width",1),R(this,"pixelRatio",1),R(this,"dataInterval",null),R(this,"labelCountHintValue",null),R(this,"minSpacingValue",null),R(this,"resolvedInterval",null),R(this,"lastInterval",null),R(this,"lastWant",null),R(this,"lastBucketKey",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Ir}update(t,e,s,n){if(this.from=t.from,this.to=t.to,this.width=e,this.pixelRatio=s,n!==void 0&&n>0){const r=Ts(n);this.lastBucketKey!==null&&this.lastBucketKey!==r&&this.resetHysteresis(),this.lastBucketKey=r,this.dataInterval=n}this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=Ar(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Wr(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 o=Ts(t);this.lastBucketKey!==null&&this.lastBucketKey!==o&&this.resetHysteresis(),this.lastBucketKey=o,this.dataInterval=t,this.resolveInterval()}if(this.resolvedInterval==null)return{ticks:[],tickInterval:0};const e=this.resolvedInterval,s=Math.ceil(this.from/e)*e,n=Math.max(0,Math.min(Lr,Math.floor((this.to-s)/e)+1)),r=[];for(let o=0;o<n;o++)r.push(s+o*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=Rr(this.dataInterval),e=this.to-this.from,s=e/this.width*this.minLabelSpacing;let n;if(this.labelCountHint!=null){const l=Math.max(1,this.labelCountHint);n=Math.max(e/l,s)}else n=s;if(this.lastInterval!=null&&this.lastWant!=null&&t.includes(this.lastInterval)){const l=n>=this.lastWant*.8&&n<=this.lastWant*1.25,h=this.lastInterval>=s;if(l&&h){this.resolvedInterval=this.lastInterval;return}}let r=t[t.length-1],o=t.length-1;for(let l=0;l<t.length;l++)if(t[l]>=n){r=t[l],o=l;break}if(this.labelCountHint!=null&&o>0&&this.countTicks(r)<this.labelCountHint){const l=t[o-1];l>=s&&(r=l)}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 Ts(i){return i<6e4?0:i<36e5?1:i<864e5?2:3}function Ar(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Wr(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function en(i){const t=Math.abs(i);if(t===0)return"0";if(t<1e-12)return i.toExponential(2);const e=Math.max(0,Math.ceil(-Math.log10(t))-1),s=Math.min(12,e+4),n=i.toFixed(s);return n.includes(".")?n.replace(/\.?0+$/,""):n}function sn(i){return Number.isNaN(i)?"—":i===1/0?"∞":i===-1/0?"−∞":null}function ae(i,t){const e=sn(i);if(e!==null)return e;const s=Math.abs(i),n=(t==null?void 0:t.decimals)??2,r=(o,l,h)=>{const d=o/l,c=Number.parseFloat(d.toFixed(n));return Math.abs(c)>=1e3?null:`${d.toFixed(n)}${h}`};return s>=1e15?i.toExponential(2):s>=1e12?r(i,1e12,"T")??i.toExponential(2):s>=1e9?r(i,1e9,"B")??`${(i/1e12).toFixed(n)}T`:s>=1e6?r(i,1e6,"M")??`${(i/1e9).toFixed(n)}B`:s>=1e3?r(i,1e3,"K")??`${(i/1e6).toFixed(n)}M`:s<1?en(i):s<100?i.toFixed(2):i.toFixed(0)}function is(i){const t=sn(i);if(t!==null)return t;const e=Math.abs(i);return e===0?"0":e<1?en(i):e<100?i.toFixed(4):e>=1e7?ae(i):e<1e4?i.toFixed(2):i.toFixed(0)}function Dr(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e<=1?1:e<=2?2:e<=5?5:10)*t}function Fr(i){if(!Number.isFinite(i)||i<=0)return 1;const t=10**Math.floor(Math.log10(i)),e=i/t;return(e>=5?5:e>=2?2:1)*t}const Pr=50,Br=50;class nn{constructor(){R(this,"min",0),R(this,"max",0),R(this,"height",1),R(this,"pixelRatio",1),R(this,"labelCountHintValue",null),R(this,"minSpacingValue",null),R(this,"resolvedInterval",null),R(this,"lastInterval",null),R(this,"lastRawInterval",null),R(this,"customFormat",null)}get labelCountHint(){return this.labelCountHintValue}get minLabelSpacing(){return this.minSpacingValue??Br}update(t,e,s){this.min=t.min,this.max=t.max,this.height=e,this.pixelRatio=s,this.resolveInterval()}setLabelCount(t){this.labelCountHintValue=zr(t),this.resetHysteresis(),this.resolveInterval()}setMinSpacing(t){this.minSpacingValue=Er(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,s=Math.max(0,Math.min(Pr,Math.floor((this.max-e)/t)+1)),n=[];for(let r=0;r<s;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 ae(t);const e=this.resolvedInterval,s=e!=null&&e>0?Math.max(0,-Math.floor(Math.log10(e))):1;return t.toFixed(s)}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,s=this.labelCountHint!=null?Math.max(1,this.labelCountHint):Math.max(1,Math.floor(this.height/this.minLabelSpacing));let n=t/s;if(n<e&&(n=e),this.lastInterval!=null&&this.lastRawInterval!=null){const o=n>=this.lastRawInterval*.8&&n<=this.lastRawInterval*1.25,l=this.lastInterval>=e;if(o&&l){this.resolvedInterval=this.lastInterval;return}}let r=Dr(n);if(this.labelCountHint!=null&&this.countTicks(r)<this.labelCountHint){const o=Fr(n);o>=e&&o>0&&(r=o)}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 zr(i){return typeof i=="number"&&Number.isFinite(i)&&i>=2?Math.floor(i):null}function Er(i){return typeof i=="number"&&Number.isFinite(i)&&i>0?i:null}function oe(i,t){return i===!1?0:i===void 0?t:i}function Vr(i,t,e,s){const n=i==null?void 0:i.get(t);if(!n)return 1;if(s<=0)return i==null||i.delete(t),1;const r=Fe((e-n.startTime)/s,0,1),o=qs(r);return r>=1&&(i==null||i.delete(t)),o}function Yr(i){let t=0,e=0;for(const s of i)s>0?t+=s:s<0&&(e+=s);return{positive:t,negative:e}}function jr(i){return i.positive>0?i.positive:i.negative<0?i.negative:0}function _r(i){return i.positive>0?100:i.negative<0?-100:0}const Or=16,Hr=(i,t,e)=>i+(t-i)*e;var xt,zt,he;class rn{constructor(t){R(this,"stores"),W(this,xt),W(this,zt),W(this,he,0),R(this,"entries"),this.stores=Array.from({length:t},()=>new Js),k(this,xt,new Array(t).fill(null)),k(this,zt,new Array(t).fill(Number.NaN)),this.entries=Array.from({length:t},()=>new Map)}get displayedLastValues(){return a(this,xt).map(t=>(t==null?void 0:t.current)??null)}get lastSeededTimes(){return a(this,zt)}getColor(){return this.getCommonOptions().colors[0]}getColors(){return this.getCommonOptions().colors}setData(t,e=0){var s;const n=this.stores[e];if(!n)return;const r=Tr(t??[]);n.setData(r),(s=this.entries[e])==null||s.clear()}appendPoint(t,e=0){var s;const n=this.stores[e];if(!n)return;const r=t,o=ct(r.time),l=this.createEntry(e,o,performance.now());n.append({...r,time:o}),l&&((s=this.entries[e])==null||s.set(o,l))}updateLastPoint(t,e=0){const s=this.stores[e];if(!s)return;const n=t;s.updateLast({...n,time:ct(n.time)})}getLayerCount(){return this.stores.length}setLayerVisible(t,e){var s;(s=this.stores[t])==null||s.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();for(let t=0;t<a(this,xt).length;t++)a(this,xt)[t]=null,a(this,zt)[t]=Number.NaN;k(this,he,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(const t of a(this,xt))if(t!=null&&t.animating)return!0;return!1}advanceLiveTracking(t){if(t===a(this,he))return;const e=oe(this.getCommonOptions().smoothMs,Zi),s=a(this,he)?Math.min(t-a(this,he),Or):0,n=t-s;for(let r=0;r<this.stores.length;r++){const o=this.stores[r].last();if(!o){a(this,xt)[r]=null,a(this,zt)[r]=Number.NaN;continue}const l=a(this,zt)[r]!==o.time,h=a(this,xt)[r];if(h===null||l||e<=0){a(this,xt)[r]=new Pe({initial:o.value,duration:e>0?e:0,easing:pe,lerp:Hr}),a(this,zt)[r]=o.time;continue}h.setTarget(o.value,{duration:e,now:n}),h.tick(t)}k(this,he,t)}entranceProgress(t,e,s){const n=oe(this.getCommonOptions().entryMs,be);return Vr(this.entries[t],e,s,n)}effectiveValue(t,e,s){var n;if(a(this,zt)[t]!==e)return s;const r=(n=a(this,xt)[t])==null?void 0:n.current;return r===void 0?s:r}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 s;return((s=this.stores[0])==null?void 0:s.findNearest(t,e))??null}getLayerSnapshots(t,e){if(this.stores.length<=1)return null;const s=this.getColors(),n=[];for(let r=0;r<this.stores.length;r++){if(!this.stores[r].isVisible())continue;const o=this.stores[r].getVisibleData(t-e,t+e);if(o.length===0)continue;let l=o[0],h=Math.abs(o[0].time-t);for(let d=1;d<o.length;d++){const c=Math.abs(o[d].time-t);c<=h&&(h=c,l=o[d])}n.push({layerIndex:r,time:l.time,value:l.value,color:s[r%s.length]})}return n.length>0?n:null}getStackedLastValue(){var t;if(this.stores.length<=1){const o=(t=this.stores[0])==null?void 0:t.last();return o?{value:o.value,isLive:!0}:null}let e=-1/0;for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();l&&l.time>e&&(e=l.time)}if(e===-1/0)return null;const s=this.getCommonOptions().stacking;if(s==="off"){for(let o=this.stores.length-1;o>=0;o--){if(!this.stores[o].isVisible())continue;const l=this.stores[o].last();if(l)return{value:l.value,isLive:!0}}return null}const n=[];for(const o of this.stores){if(!o.isVisible())continue;const l=o.last();n.push(l&&l.time===e?l.value:0)}const r=Yr(n);return{value:s==="percent"?_r(r):jr(r),isLive:!0}}getLayerLastSnapshots(){if(this.stores.length<=1)return null;const t=this.getColors(),e=[];for(let s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].last();n&&e.push({layerIndex:s,time:n.time,value:n.value,color:t[s%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 s=this.getCommonOptions().stacking;if(s==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const n=this.stores.map(h=>h.isVisible()?h.getVisibleData(t,e):[]);if(s==="off"){let h=1/0,d=-1/0;for(const c of n)for(const u of c)Number.isFinite(u.value)&&(u.value<h&&(h=u.value),u.value>d&&(d=u.value));return h<1/0?{min:h,max:d}:null}const r=new Map;for(let h=0;h<n.length;h++)for(const d of n[h]){let c=r.get(d.time);c||(c=new Array(n.length).fill(0),r.set(d.time,c)),c[h]=Number.isFinite(d.value)?d.value:0}let o=0,l=0;for(const h of r.values()){let d=0,c=0;for(const u of h)u>0?d+=u:c+=u;d>l&&(l=d),c<o&&(o=c)}return l>o?{min:o,max:l}:null}}xt=new WeakMap,zt=new WeakMap,he=new WeakMap;const Nr={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};function Rs(i){if(!i)return{};const t={...i};return i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}class $r extends rn{constructor(t,e){super(t),R(this,"options"),this.options={...Nr,...Rs(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...Rs(t)}}getCommonOptions(){return this.options}createEntry(t,e,s){const n=this.options.entryAnimation??"fade-grow",r=oe(this.options.entryMs,be);return n==="none"||r<=0?null:{startTime:s}}applyTheme(t,e){const s=e.seriesColors,n=this.options.colors.map((r,o)=>r===s[o]?t.seriesColors[o]??r:r);this.updateOptions({colors:n})}applyBarTransform(t,e,s,n,r,o){const l=this.options.entryAnimation??"fade-grow";if(t>=1||l==="none")return{topY:s,barHeight:n,x:r,barWidth:o,alpha:1};let h=s,d=n,c=r,u=1;if((l==="fade"||l==="fade-grow")&&(u=t),l==="grow"||l==="fade-grow"){const f=n*t;s<e?h=e-f:h=e,d=Math.max(1,f)}return l==="slide"&&(c=r+(1-t)*o,u=t),{topY:h,barHeight:d,x:c,barWidth:o,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:s,yScale:n,dataInterval:r}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange(),d=performance.now();let c=0;for(const x of this.stores){if(!x.isVisible())continue;const y=x.getVisibleData(h.from,h.to).length;if(y>c&&(c=y),c>2)break}const u=s.barWidthBitmap(r),f=Math.round(30*l),m=c<=2?Math.min(f,u):u,g=Math.max(1,Math.round(m*this.options.barWidthRatio)-2),p=Math.floor(g/2),v=n.getRange().min<0,w=v?n.valueToBitmapY(0):e.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const x=this.options.colors[0],y=this.options.colors.length>1?this.options.colors[1]:x,M=this.stores[0].getVisibleData(h.from,h.to);for(const S of M){if(!Number.isFinite(S.value))continue;const P=this.effectiveValue(0,S.time,S.value),b=this.entranceProgress(0,S.time,d),L=s.timeToBitmapX(S.time);if(P>=0){const I=n.valueToBitmapY(P),T=Math.max(1,w-I);this.drawAnimatedBar(o,b,w,I,T,L-p,g,P>=0?x:y)}else{const I=n.valueToBitmapY(P),T=Math.max(1,I-w);this.drawAnimatedBar(o,b,w,w,T,L-p,g,y)}}}else{const x=this.stores.map(M=>M.isVisible()?M.getVisibleData(h.from,h.to):[]),y=new Map;for(let M=0;M<x.length;M++)for(const S of x[M]){if(!Number.isFinite(S.value))continue;let P=y.get(S.time);P||(P=[],y.set(S.time,P)),P.push({layer:M,value:this.effectiveValue(M,S.time,S.value)})}for(const[M,S]of y){S.sort((b,L)=>Math.abs(L.value)-Math.abs(b.value));const P=s.timeToBitmapX(M);for(const{layer:b,value:L}of S){const I=this.options.colors[b%this.options.colors.length],T=this.entranceProgress(b,M,d);if(L>=0){const D=n.valueToBitmapY(L),F=Math.max(1,w-D);this.drawAnimatedBar(o,T,w,D,F,P-p,g,I)}else{const D=n.valueToBitmapY(L),F=Math.max(1,D-w);this.drawAnimatedBar(o,T,w,w,F,P-p,g,I)}}}}if(v){o.strokeStyle=t.theme.grid.color,o.lineWidth=1;const x=Math.round(w)+.5;o.beginPath(),o.moveTo(0,x),o.lineTo(e.bitmapSize.width,x),o.stroke()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:r,dataInterval:o}=t,{context:l,horizontalPixelRatio:h}=s,d=n.getRange(),c=performance.now();let u=0;for(const y of this.stores){if(!y.isVisible())continue;const M=y.getVisibleData(d.from,d.to).length;if(M>u&&(u=M),u>2)break}const f=n.barWidthBitmap(o),m=Math.round(30*h),g=u<=2?Math.min(m,f):f,p=Math.max(1,Math.round(g*this.options.barWidthRatio)-2),v=Math.floor(p/2),w=this.stores.map(y=>y.isVisible()?y.getVisibleData(d.from,d.to):[]);if(w.every(y=>y.length===0))return;const x=new Map;for(let y=0;y<w.length;y++)for(const M of w[y]){let S=x.get(M.time);S||(S=new Array(w.length).fill(0),x.set(M.time,S));const P=Number.isFinite(M.value)?M.value:0;S[y]=this.stores[y].isVisible()?this.effectiveValue(y,M.time,P):0}for(let y=0;y<w.length;y++){const M=this.options.colors[y%this.options.colors.length];for(const[S,P]of x){const b=P[y];if(b===0)continue;const L=n.timeToBitmapX(S);let I=0,T=0;for(let F=0;F<y;F++){const V=P[F];V>0?I+=V:T+=V}const D=this.entranceProgress(y,S,c);if(e){let F=0,V=0;for(const z of P)z>0?F+=z:V+=z;if(b>0&&F>0){const z=I/F*100,_=(I+b)/F*100,$=r.valueToBitmapY(_),H=r.valueToBitmapY(z),it=Math.max(1,H-$);this.drawAnimatedBar(l,D,H,$,it,L-v,p,M)}else if(b<0&&V<0){const z=T/V*-100,_=(T+b)/V*-100,$=r.valueToBitmapY(z),H=r.valueToBitmapY(_),it=Math.max(1,H-$);this.drawAnimatedBar(l,D,$,$,it,L-v,p,M)}}else if(b>0){const F=r.valueToBitmapY(I+b),V=r.valueToBitmapY(I),z=Math.max(1,V-F);this.drawAnimatedBar(l,D,V,F,z,L-v,p,M)}else{const F=r.valueToBitmapY(T),V=r.valueToBitmapY(T+b),z=Math.max(1,V-F);this.drawAnimatedBar(l,D,F,F,z,L-v,p,M)}}}}fillBar(t,e,s,n,r,o){t.fillStyle=o,t.fillRect(e,s,n,r)}drawAnimatedBar(t,e,s,n,r,o,l,h){const d=this.options.entryAnimation??"fade-grow";if(e>=1||d==="none"){this.fillBar(t,o,n,l,r,h);return}const c=this.applyBarTransform(e,s,n,r,o,l);t.save(),t.globalAlpha=c.alpha,t.fillStyle=h,t.fillRect(c.x,c.topY,c.barWidth,c.barHeight),t.restore()}}function Ls(i,t){return i.length<=t?i:Ur(i,t,e=>e.time,e=>e.value)}function Xr(i,t){if(i.length<=t)return i;const e=Math.ceil(i.length/t),s=[];for(let n=0;n<i.length;n+=e){const r=Math.min(n+e,i.length);let o=-1/0,l=1/0,h=0;for(let d=n;d<r;d++)i[d].high>o&&(o=i[d].high),i[d].low<l&&(l=i[d].low),h+=i[d].volume??0;s.push({time:i[n].time,open:i[n].open,high:o,low:l,close:i[r-1].close,volume:h})}return s}function Ur(i,t,e,s){if(t>=i.length||t<3)return i;const n=[i[0]],r=(i.length-2)/(t-2);let o=0;for(let l=0;l<t-2;l++){const h=Math.floor((l+1)*r)+1,d=Math.min(Math.floor((l+2)*r)+1,i.length-1);let c=0,u=0;const f=d,m=Math.min(Math.floor((l+3)*r)+1,i.length),g=m-f;if(g>0){for(let y=f;y<m;y++)c+=e(i[y]),u+=s(i[y]);c/=g,u/=g}let p=-1,v=h;const w=e(i[o]),x=s(i[o]);for(let y=h;y<d;y++){const M=Math.abs((w-c)*(s(i[y])-x)-(w-e(i[y]))*(u-x));M>p&&(p=M,v=y)}n.push(i[v]),o=v}return n.push(i[i.length-1]),n}function ss(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.fontSize)!==void 0?i.axis.x.fontSize:t==="y"&&((s=i.axis.y)==null?void 0:s.fontSize)!==void 0?i.axis.y.fontSize:i.axis.fontSize}function ns(i,t){var e,s;return t==="x"&&((e=i.axis.x)==null?void 0:e.textColor)!==void 0?i.axis.x.textColor:t==="y"&&((s=i.axis.y)==null?void 0:s.textColor)!==void 0?i.axis.y.textColor:i.axis.textColor}function pt(i){return Array.isArray(i)?i.source??i[0]:i}const Is=new Map;function Gr(i){return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)]}function Ae(i,t){if(i.startsWith("rgba"))return i.replace(/[\d.]+\)\s*$/,`${t})`);if(i.startsWith("rgb("))return i.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const e=i+t;let s=Is.get(e);if(s)return s;const[n,r,o]=Gr(i);return s=`rgba(${n}, ${r}, ${o}, ${t})`,Is.set(e,s),s}const Kr=(i,t,e)=>({time:t.time,open:i.open+(t.open-i.open)*e,high:i.high+(t.high-i.high)*e,low:i.low+(t.low-i.low)*e,close:i.close+(t.close-i.close)*e,volume:i.volume===void 0||t.volume===void 0?t.volume:i.volume+(t.volume-i.volume)*e}),qr=(i,t)=>i.time===t.time&&i.open===t.open&&i.high===t.high&&i.low===t.low&&i.close===t.close&&i.volume===t.volume,Jr={up:{body:"#26a69a",wick:"#26a69a"},down:{body:"#ef5350",wick:"#ef5350"},bodyWidthRatio:.6};function As(i){if(!i)return{};const t={...i};return i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}var kt,we,Se;class Qr{constructor(t,e){R(this,"store"),R(this,"options"),W(this,kt,null),W(this,we,Number.NaN),W(this,Se,0),R(this,"entries",new Map),this.store=t,this.options={...Jr,...As(e)}}get displayedLast(){var t;return((t=a(this,kt))==null?void 0:t.current)??null}updateOptions(t){this.options={...this.options,...As(t)}}getColor(){return pt(this.options.up.body)}setData(t){this.store.setData(Cr(t??[])),this.entries.clear()}appendPoint(t){const e=t,s=ct(e.time);this.store.append({...e,time:s});const n=this.options.entryAnimation??"unfold",r=oe(this.options.entryMs,be);n!=="none"&&r>0&&this.entries.set(s,{startTime:performance.now()})}updateLastPoint(t){const e=t;this.store.updateLast({...e,time:ct(e.time)})}getLayerCount(){return 1}setLayerVisible(t,e){}isLayerVisible(t){return!0}getLayerColors(){return[pt(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(),k(this,kt,null),k(this,we,Number.NaN),k(this,Se,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(){var t;return!!(this.entries.size>0||(t=a(this,kt))!=null&&t.animating)}entranceProgress(t,e){const s=this.entries.get(t);if(!s)return 1;const n=oe(this.options.entryMs,be);if(n<=0)return this.entries.delete(t),1;const r=Fe((e-s.startTime)/n,0,1),o=qs(r);return r>=1&&this.entries.delete(t),o}advanceLiveTracking(t){const e=this.store.last();if(!e){k(this,kt,null),k(this,we,Number.NaN);return}const s=a(this,we)!==e.time,n=oe(this.options.smoothMs,Zi);if(a(this,kt)===null||s||n<=0){k(this,kt,new Pe({initial:{...e},duration:n>0?n:0,easing:pe,lerp:Kr,equals:qr})),k(this,we,e.time),k(this,Se,t);return}const r=Math.min(t-a(this,Se),16),o=t-r;a(this,kt).setTarget(e,{duration:n,now:o}),a(this,kt).tick(t),k(this,Se,t)}render(t){const{scope:e,timeScale:s,yScale:n,dataInterval:r}=t,{context:o,horizontalPixelRatio:l}=e,h=s.getRange(),d=performance.now();this.advanceLiveTracking(d);let c=this.store.getVisibleData(h.from,h.to);const u=e.mediaSize.width,f=c.length>u*2;if(f&&(c=Xr(c,Math.round(u*1.5)),this.entries.clear()),c.length===0)return;if(!f&&this.displayedLast){const L=c.length-1;c[L].time===this.displayedLast.time&&(c=[...c.slice(0,L),this.displayedLast])}const m=this.entries.size>0?new Map:null;if(m)for(const L of c)this.entries.has(L.time)&&m.set(L.time,this.entranceProgress(L.time,d));const g=s.barWidthBitmap(r),p=Math.round(30*l),v=c.length<=2?Math.min(p,g):g,w=Math.max(1,Math.round(l));let x=Math.max(1,Math.round(v*this.options.bodyWidthRatio)-2);(x&1)!==(w&1)&&(x=x>1?x-1:2);const y=Math.floor(x/2),M=Math.round(n.getMediaHeight()*e.verticalPixelRatio);this.drawVolume({ctx:o,data:c,timeScale:s,chartHeight:M,barWidth:v,wickWidth:w,entranceByTime:m});const S=[],P=[];for(const L of c)L.close>=L.open?S.push(L):P.push(L);const b={ctx:o,timeScale:s,yScale:n,halfBody:y,bodyWidth:x,wickWidth:w,entranceByTime:m};this.drawCandles({...b,candles:S,body:this.options.up.body,wickColor:this.options.up.wick}),this.drawCandles({...b,candles:P,body:this.options.down.body,wickColor:this.options.down.wick})}drawVolume({ctx:t,data:e,timeScale:s,chartHeight:n,barWidth:r,wickWidth:o,entranceByTime:l}){let h=0;for(const p of e)Number.isFinite(p.volume)&&p.volume>h&&(h=p.volume);if(h===0)return;const d=n*.2;let c=Math.max(1,r-2);(c&1)!==(o&1)&&(c=c>1?c-1:2);const u=Math.floor(c/2),f=Ae(pt(this.options.up.body),.2),m=Ae(pt(this.options.down.body),.2),g=this.options.entryAnimation??"unfold";for(const p of e){if(!Number.isFinite(p.volume)||p.volume<=0)continue;const v=p.volume,w=s.timeToBitmapX(p.time),x=Math.max(1,v/h*d),y=p.close>=p.open;t.fillStyle=y?f:m;const M=(l==null?void 0:l.get(p.time))??1;if(M>=1||g==="none"){t.fillRect(w-u,n-x,c,x);continue}const S=ji(M,g,{x:w-u,barWidth:c,anchorY:n,topY:n-x,bottomY:n});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,c,Math.max(1,S.bottomY-S.topY)),t.restore()}}drawCandles({ctx:t,candles:e,timeScale:s,yScale:n,halfBody:r,bodyWidth:o,wickWidth:l,body:h,wickColor:d,entranceByTime:c}){if(e.length===0)return;const u=this.options.entryAnimation??"unfold",f=o+2;t.fillStyle=d;for(const g of e){const p=(c==null?void 0:c.get(g.time))??1,v=s.timeToBitmapX(g.time),w=n.valueToBitmapY(g.open),x=n.valueToBitmapY(g.high),y=n.valueToBitmapY(g.low),M=v-Math.floor(l/2);if(p>=1||u==="none"){t.fillRect(M,x,l,y-x);continue}const S=ji(p,u,{x:M,barWidth:f,anchorY:w,topY:x,bottomY:y});t.save(),t.globalAlpha=S.alpha,t.fillRect(S.x,S.topY,l,Math.max(1,S.bottomY-S.topY)),t.restore()}const m=Array.isArray(h);for(const g of e){const p=(c==null?void 0:c.get(g.time))??1,v=s.timeToBitmapX(g.time),w=n.valueToBitmapY(g.open),x=n.valueToBitmapY(g.close),y=Math.min(w,x),M=Math.max(w,x),S=Math.max(1,M-y),P=p<1&&u!=="none";let b=v-r,L=y,I=S,T=1;if(P){const D=ji(p,u,{x:v-r,barWidth:f,anchorY:w,topY:y,bottomY:M});b=D.x,L=D.topY,I=Math.max(1,D.bottomY-D.topY),T=D.alpha}if(P&&t.save(),m&&I>2){const D=t.createLinearGradient(0,L,0,L+I);D.addColorStop(0,h[0]),D.addColorStop(1,h[1]),t.fillStyle=D}else t.fillStyle=m?h[0]:h;P&&(t.globalAlpha=T),t.fillRect(b,L,o,I),P&&t.restore()}}}kt=new WeakMap,we=new WeakMap,Se=new WeakMap;function ji(i,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:i};case"unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,i),bottomY:mt(e.anchorY,e.bottomY,i),alpha:1};case"slide":return{x:e.x+(1-i)*e.barWidth,topY:e.topY,bottomY:e.bottomY,alpha:i};case"fade-unfold":return{x:e.x,topY:mt(e.anchorY,e.topY,i),bottomY:mt(e.anchorY,e.bottomY,i),alpha:i}}}const Zr={colors:["#2962FF"],strokeWidth:1,area:{visible:!0},pulse:!0,stacking:"off"};function Ws(i){if(!i)return{};const t={...i};return i.areaFill!==void 0&&i.area===void 0&&(t.area={visible:!!i.areaFill}),i.enterAnimation!==void 0&&i.entryAnimation===void 0&&(t.entryAnimation=i.enterAnimation),i.enterMs!==void 0&&i.entryMs===void 0&&(t.entryMs=i.enterMs),t}class to extends rn{constructor(t,e){super(t),R(this,"options"),R(this,"areaGradientCache",new Map),this.options={...Zr,...Ws(e)}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...Ws(t)}}getStacking(){return this.options.stacking}getCommonOptions(){return this.options}createEntry(t,e,s){var n;const r=this.options.entryAnimation??"grow",o=oe(this.options.entryMs,be);if(r==="none"||o<=0)return null;const l=(n=this.stores[t])==null?void 0:n.last();return{startTime:s,fromTime:l?l.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 s;return(s=this.entries[t])==null?void 0:s.get(e)}resolvedPulseMs(){return oe(this.options.pulseMs,Us)}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 s=0;s<this.stores.length;s++){if(!this.stores[s].isVisible())continue;const n=this.stores[s].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,s,n){const r=this.stores[t],o=r.last();if(!o)return null;const l=e.timeToBitmapX(o.time),h=s.valueToBitmapY(this.effectiveValue(t,o.time,o.value)),d=this.options.entryAnimation??"grow";if(!this.peekEntry(t,o.time)||d!=="grow")return{x:l,y:h};const c=this.entranceProgress(t,o.time,n);if(c>=1)return{x:l,y:h};const u=r.getAll();if(u.length<2)return{x:l,y:h};const f=u[u.length-2];if(!Number.isFinite(f.value))return{x:l,y:h};const m=e.timeToBitmapX(f.time),g=s.valueToBitmapY(f.value);return{x:mt(m,l,c),y:mt(g,h,c)}}renderOff(t){var e;const{scope:s,timeScale:n,yScale:r}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=performance.now(),f=this.options.entryAnimation??"grow";for(let m=0;m<this.stores.length;m++){if(!this.stores[m].isVisible())continue;let g=this.stores[m].getVisibleData(l.from,l.to);const p=s.mediaSize.width;if(g.length>p*2&&(g=Ls(g,Math.round(p*1.5))),g.length<2)continue;const v=this.options.colors[m%this.options.colors.length],w=g[g.length-1],x=this.peekEntry(m,w.time),y=this.entranceProgress(m,w.time,u),M=x&&f==="fade"&&y<1,S=this.trailingEndpoint(m,n,r,u)??{x:n.timeToBitmapX(w.time),y:r.valueToBitmapY(this.effectiveValue(m,w.time,w.value))},P=S.x,b=S.y;M&&(o.save(),o.globalAlpha=y);const L=g.length-1,I=[];let T=null;for(let F=0;F<L;F++){const V=g[F].value;if(!Number.isFinite(V)){T=null;continue}T||(T=[],I.push(T)),T.push({x:n.timeToBitmapX(g[F].time),y:r.valueToBitmapY(V)})}const D=(e=g[L])==null?void 0:e.value;if(Number.isFinite(P)&&Number.isFinite(b)&&Number.isFinite(D)&&(T?T.push({x:P,y:b}):I.push([{x:P,y:b}])),d&&I.some(F=>F.length>=2)){o.beginPath();for(const F of I)if(!(F.length<2)){o.moveTo(F[0].x,F[0].y);for(let V=1;V<F.length;V++)o.lineTo(F[V].x,F[V].y)}o.strokeStyle=v,o.lineWidth=c,o.lineJoin="round",o.lineCap="round",o.stroke()}if(d){const F=Math.max(1,c/2);let V=!1;for(const z of I)z.length===1&&(V||(o.beginPath(),V=!0),o.moveTo(z[0].x+F,z[0].y),o.arc(z[0].x,z[0].y,F,0,Math.PI*2));V&&(o.fillStyle=v,o.fill())}if(this.options.area.visible){const F=s.bitmapSize.height,V=String(m),z=this.areaGradientCache.get(V);let _;z&&z.bottomY===F&&z.color===v?_=z.gradient:(_=o.createLinearGradient(0,0,0,F),_.addColorStop(0,Ae(v,.12)),_.addColorStop(1,Ae(v,.01)),this.areaGradientCache.set(V,{gradient:_,bottomY:F,color:v})),o.fillStyle=_;for(const $ of I)if(!($.length<2)){o.beginPath(),o.moveTo($[0].x,$[0].y);for(let H=1;H<$.length;H++)o.lineTo($[H].x,$[H].y);o.lineTo($[$.length-1].x,F),o.lineTo($[0].x,F),o.closePath(),o.fill()}}M&&o.restore()}}renderStacked(t,e){const{scope:s,timeScale:n,yScale:r}=t,{context:o}=s,l=n.getRange(),{verticalPixelRatio:h}=s,d=this.options.strokeWidth>0,c=Math.max(1,Math.round(this.options.strokeWidth*h)),u=s.mediaSize.width,f=this.stores.map(b=>{let L=b.getVisibleData(l.from,l.to);return L.length>u*2&&(L=Ls(L,Math.round(u*1.5))),L}),m=new Set;for(const b of f)for(const L of b)m.add(L.time);const g=Array.from(m).sort((b,L)=>b-L);if(g.length<2)return;const p=f.map((b,L)=>{const I=new Map;for(const T of b)I.set(T.time,this.effectiveValue(L,T.time,T.value));return I}),v=Array.from({length:this.stores.length},()=>new Array(g.length).fill(0));for(let b=0;b<g.length;b++){const L=g[b];let I=0;if(e)for(let D=0;D<this.stores.length;D++){if(!this.stores[D].isVisible())continue;const F=p[D].get(L);Number.isFinite(F)&&(I+=F)}let T=0;for(let D=0;D<this.stores.length;D++){const F=this.stores[D].isVisible()?p[D].get(L):0,V=Number.isFinite(F)?F:0;T+=e&&I>0?V/I*100:V,v[D][b]=T}}const w=performance.now(),x=this.options.entryAnimation??"grow",y=new Map;for(let b=0;b<g.length;b++)y.set(g[b],b);const M=g.length-1,S=new Array(this.stores.length).fill(1);for(let b=0;b<this.stores.length;b++){if(!this.stores[b].isVisible())continue;const L=this.stores[b].last();if(!L)continue;const I=this.peekEntry(b,L.time);if(!I)continue;const T=y.get(L.time);T!==M||y.get(I.fromTime)!==T-1||(S[b]=this.entranceProgress(b,L.time,w))}const P=(b,L)=>{if(L>=1||b.length<2)return;const I=b.length-1,T=b[I-1],D=b[I];b[I]=[mt(T[0],D[0],L),mt(T[1],D[1],L)]};for(let b=this.stores.length-1;b>=0;b--){if(!this.stores[b].isVisible())continue;const L=this.options.colors[b%this.options.colors.length],I=S[b],T=b>0&&this.stores[b-1].isVisible()?S[b-1]:1,D=[];for(let z=0;z<g.length;z++)D.push([n.timeToBitmapX(g[z]),r.valueToBitmapY(v[b][z])]);x==="grow"&&P(D,I);const F=[];for(let z=0;z<g.length;z++){const _=b>0?v[b-1][z]:0;F.push([n.timeToBitmapX(g[z]),r.valueToBitmapY(_)])}x==="grow"&&P(F,T);const V=x==="fade"&&I<1;if(V&&(o.save(),o.globalAlpha=I),this.options.area.visible){o.beginPath(),o.moveTo(D[0][0],D[0][1]);for(let z=1;z<D.length;z++)o.lineTo(D[z][0],D[z][1]);for(let z=F.length-1;z>=0;z--)o.lineTo(F[z][0],F[z][1]);o.closePath(),o.fillStyle=Ae(L,.25),o.fill()}if(d){o.beginPath(),o.moveTo(D[0][0],D[0][1]);for(let z=1;z<D.length;z++)o.lineTo(D[z][0],D[z][1]);o.strokeStyle=L,o.lineWidth=c,o.lineJoin="round",o.lineCap="round",o.stroke()}V&&o.restore()}}drawOverlay(t){const{scope:e,timeScale:s,yScale:n,crosshair:r,dataInterval:o}=t,l=e,h=this.resolvedPulseMs();if(r){const d=this.options.colors,c=this.options.stacking,u=4*l.horizontalPixelRatio,f=[],m=[];for(let p=0;p<this.stores.length;p++){const v=this.stores[p].findNearest(r.time,o);v?(f.push(v.value),m.push(v.time)):(f.push(0),m.push(null))}const g=[];if(c==="off")for(const p of f)g.push(p);else{let p=0;if(c==="percent")for(let w=0;w<f.length;w++)this.stores[w].isVisible()&&(p+=f[w]);let v=0;for(let w=0;w<f.length;w++){const x=this.stores[w].isVisible()?f[w]:0;v+=c==="percent"&&p>0?x/p*100:x,g.push(v)}}for(let p=0;p<this.stores.length;p++){const v=m[p];if(v===null||!this.stores[p].isVisible())continue;const w=d[p%d.length],x=s.timeToBitmapX(v),y=n.valueToBitmapY(g[p]);e.context.beginPath(),e.context.arc(x,y,u+3*l.horizontalPixelRatio,0,Math.PI*2);const M=w.startsWith("#")?w+"40":/^rgb\(/i.test(w)?w.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):w.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=M,e.context.fill(),e.context.beginPath(),e.context.arc(x,y,u,0,Math.PI*2),e.context.fillStyle=w,e.context.fill()}}if(this.hasPulse&&h>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 S=this.trailingEndpoint(u,s,n,d);if(!S)continue;this.drawPulse({ctx:e.context,x:S.x,y:S.y,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h});continue}const m=this.stores[u].last();if(!m)continue;const g=m.time,p=c==="percent",v=S=>{const P=I=>{const T=I===u&&S===g?m:this.stores[I].findNearest(S,0);return!T||T.time!==S?0:this.effectiveValue(I,S,T.value)};let b=0;if(p)for(let I=0;I<this.stores.length;I++)this.stores[I].isVisible()&&(b+=P(I));let L=0;for(let I=0;I<=u;I++){if(!this.stores[I].isVisible())continue;const T=P(I);L+=p&&b>0?T/b*100:T}return L};let w=s.timeToBitmapX(g),x=n.valueToBitmapY(v(g));const y=this.options.entryAnimation??"grow",M=this.peekEntry(u,g);if(y==="grow"&&M){const S=this.entranceProgress(u,g,d);if(S<1&&M.fromTime!==g){const P=s.timeToBitmapX(M.fromTime),b=n.valueToBitmapY(v(M.fromTime));w=mt(P,w,S),x=mt(b,x,S)}}this.drawPulse({ctx:e.context,x:w,y:x,color:f,pixelRatio:l.horizontalPixelRatio,pulseMs:h})}}}drawPulse({ctx:t,x:e,y:s,color:n,pixelRatio:r,pulseMs:o}){const l=3*r,h=.4+.6*Math.abs(Math.sin(performance.now()/o)),d=l+4*r*h;t.beginPath(),t.arc(e,s,d,0,Math.PI*2),t.fillStyle=Ae(n,h*.3),t.fill(),t.beginPath(),t.arc(e,s,l,0,Math.PI*2),t.fillStyle=n,t.fill()}}const on={mode:"outside",content:"both",fontSize:11,minSliceAngle:2.5,elbowLen:12,legPad:6,distance:14,railWidth:16,labelGap:1.8,balanceSides:!0},eo={innerRadiusRatio:0,padAngle:1.15,sliceLabels:{...on},animate:!1},$i=Math.PI/180;function io(i,t){return{...i??{},...t}}function so(i){return{...on,...i??{}}}function no(i){const t={color:"rgba(0, 0, 0, 0.22)",blur:24,offsetX:0,offsetY:10};return i===!0||i===!1?t:{...t,...i}}function ro(i){const t={color:"rgba(0, 0, 0, 0.1)",depth:.3};return i===!0||i===!1?t:{...t,...i}}const We=Math.PI*2,an=.85;function Ds(i){const{bitmapWidth:t,bitmapHeight:e,padTop:s,padBottom:n}=i,r=Math.max(0,i.labelReserve??0),o=Math.min(Math.max(0,s),e),l=Math.min(Math.max(0,n),e-o),h=e-o-l,d=Math.max(0,t-2*r),c=t/2,u=o+h/2,f=Math.max(0,Math.min(d,h)/2*an);return{cx:c,cy:u,maxR:f}}function oo(i){if(!i.startsWith("#"))return!1;const t=parseInt(i.slice(1,3),16),e=parseInt(i.slice(3,5),16),s=parseInt(i.slice(5,7),16);return t*.299+e*.587+s*.114>150}function ao(i,t){if(!i.startsWith("#"))return i;const e=Math.min(255,parseInt(i.slice(1,3),16)+Math.round(255*t)),s=Math.min(255,parseInt(i.slice(3,5),16)+Math.round(255*t)),n=Math.min(255,parseInt(i.slice(5,7),16)+Math.round(255*t));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Fs(i){if(i.startsWith("#"))return{r:parseInt(i.slice(1,3),16)||0,g:parseInt(i.slice(3,5),16)||0,b:parseInt(i.slice(5,7),16)||0,a:1};const t=i.match(/^rgba?\s*\(([^)]+)\)$/i);if(t){const e=t[1].split(",").map(s=>s.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 lo(i,t){const e=Fs(i),s=Fs(t),n=s.a,r=Math.round(s.r*n+e.r*(1-n)),o=Math.round(s.g*n+e.g*(1-n)),l=Math.round(s.b*n+e.b*(1-n));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${l.toString(16).padStart(2,"0")}`}var X,G,Ct,at,Me,Jt,wt,ce,It,Xi,vi,ln,hn,cn;class yi{constructor(t){W(this,It),W(this,X,[]),W(this,G),W(this,Ct,-1),W(this,at,[]),W(this,Me,0),W(this,Jt,1),W(this,wt,null),W(this,ce,[]),k(this,G,B(this,It,Xi).call(this,eo,t??{}))}getData(){return a(this,X)}setData(t){const e=t??[];k(this,X,e),k(this,at,new Array(e.length).fill(0)),k(this,Jt,a(this,G).animate?0:1),k(this,wt,null);for(const s of a(this,ce))s()}onDataChanged(t){return a(this,ce).push(t),()=>{const e=a(this,ce).indexOf(t);e>=0&&a(this,ce).splice(e,1)}}updateOptions(t){var e,s;const n=(e=a(this,G).sliceLabels)==null?void 0:e.mode;k(this,G,B(this,It,Xi).call(this,a(this,G),t??{})),((s=a(this,G).sliceLabels)==null?void 0:s.mode)==="outside"&&n!=="outside"&&k(this,Jt,a(this,G).animate?0:1),k(this,wt,null)}getColor(){var t,e;return((t=a(this,X)[0])==null?void 0:t.color)??((e=a(this,G).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&&k(this,wt,null)}hitTest(t,e,s,n,r){var o;if(a(this,X).length===0)return-1;const l=a(this,X).reduce((y,M)=>y+M.value,0);if(l<=0)return-1;const h=((o=a(this,wt))==null?void 0:o.reserve)??0,{cx:d,cy:c,maxR:u}=Ds({bitmapWidth:s,bitmapHeight:n,padTop:(r==null?void 0:r.top)??0,padBottom:(r==null?void 0:r.bottom)??0,labelReserve:h}),f=u,m=f*a(this,G).innerRadiusRatio,g=t-d,p=e-c,v=Math.sqrt(g*g+p*p);if(v>f||v<m)return-1;let w=Math.atan2(p,g)+Math.PI/2;w<0&&(w+=We);let x=0;for(let y=0;y<a(this,X).length;y++){const M=a(this,X)[y].value/l*We;if(w>=x&&w<x+M)return y;x+=M}return-1}setHoverIndex(t){return a(this,Ct)===t?!1:(k(this,Ct,t),!0)}getHoverIndex(){return a(this,Ct)}getHoverInfo(t){if(a(this,Ct)<0)return null;const e=a(this,X)[a(this,Ct)];if(!e)return null;const s=a(this,X).reduce((r,o)=>r+o.value,0),n=a(this,G).colors??t.seriesColors;return{label:e.label,value:e.value,percent:s>0?e.value/s*100:0,color:e.color??n[a(this,Ct)%n.length]}}getSliceInfo(t){if(a(this,X).length===0)return null;const e=a(this,X).reduce((n,r)=>n+r.value,0),s=a(this,G).colors??t.seriesColors;return a(this,X).map((n,r)=>({label:n.label,value:n.value,percent:e>0?n.value/e*100:0,color:n.color??s[r%s.length]}))}get needsAnimation(){var t;if(!a(this,G).animate)return!1;for(let e=0;e<a(this,at).length;e++){const s=e===a(this,Ct)?1:0;if(Math.abs(a(this,at)[e]-s)>.01)return!0}return((t=a(this,G).sliceLabels)==null?void 0:t.mode)==="outside"&&a(this,Jt)<.99}dispose(){k(this,ce,[]),k(this,X,[]),k(this,at,[]),k(this,Me,0)}_inspectSliceOffsets(){return a(this,at)}render(t){if(a(this,X).length===0)return;const{scope:e,theme:s,padding:n}=t,{context:r,bitmapSize:o,horizontalPixelRatio:l,verticalPixelRatio:h}=e,d=performance.now(),c=a(this,Me)?Math.min(.05,(d-a(this,Me))/1e3):0;k(this,Me,d);const u=a(this,X).reduce((_,$)=>_+$.value,0);if(u<=0)return;const f=12;for(;a(this,at).length<a(this,X).length;)a(this,at).push(0);if(a(this,G).animate)for(let _=0;_<a(this,X).length;_++){const $=_===a(this,Ct)?1:0;a(this,at)[_]=xs(a(this,at)[_],$,f,c)}const m=so(a(this,G).sliceLabels);r.font=`${m.fontSize*l}px ${s.typography.fontFamily}`,m.mode==="outside"&&a(this,G).animate&&k(this,Jt,xs(a(this,Jt),1,6,c));const g=a(this,G).colors??s.seriesColors,p=m.mode==="outside"?B(this,It,ln).call(this,r,m,u,l):0,{cx:v,cy:w,maxR:x}=Ds({bitmapWidth:o.width,bitmapHeight:o.height,padTop:n.top*h,padBottom:n.bottom*h,labelReserve:p}),y=x,M=y*a(this,G).innerRadiusRatio,S=a(this,G).padAngle*$i,P=8*l,b=a(this,G).shadow??!1,L=no(b),I=a(this,G).innerShadow??!1,T=ro(I);let D=-Math.PI/2;for(let _=0;_<a(this,X).length;_++){const $=a(this,X)[_],H=$.value/u*We,it=D+S/2,U=D+H-S/2,bt=D+H/2,vt=$.color??g[_%g.length];if(U<=it){D+=H;continue}const St=a(this,at)[_]*P,Q=Math.cos(bt)*St,Ut=Math.sin(bt)*St,yt=v+Q,ut=w+Ut;r.beginPath(),r.arc(yt,ut,y,it,U),M>0?r.arc(yt,ut,M,U,it,!0):r.lineTo(yt,ut),r.closePath();const dt=r.createRadialGradient(yt,ut,M||0,yt,ut,y);if(dt.addColorStop(0,ao(vt,.15)),I){const Mt=Math.max(0,Math.min(.999,1-T.depth));dt.addColorStop(Mt,vt),dt.addColorStop(1,lo(vt,T.color))}else dt.addColorStop(1,vt);r.fillStyle=dt;const Pt=a(this,at)[_];if(b||Pt>.01){const Mt=b?1:0,Gt=Pt;r.shadowColor=b?L.color:"rgba(0,0,0,0.25)",r.shadowBlur=(L.blur*Mt+12*Gt)*l,r.shadowOffsetX=L.offsetX*Mt*l+Q*.3*Gt,r.shadowOffsetY=L.offsetY*Mt*h+Ut*.3*Gt}r.fill(),r.shadowColor="transparent",r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,D+=H}if(m.mode==="none")return;D=-Math.PI/2;const F=s.tooltip.textColor;if(m.mode==="outside"){const _=B(this,It,cn).call(this,{cx:v,cy:w,outerR:y,total:u,palette:g,labels:m,hpr:l,bitmapHeight:o.height}),$=_.length>1?Math.min(.06,.9/(_.length-1)):0;for(let H=0;H<_.length;H++){const it=_[H];if(it===null)continue;const U=H*$,bt=Fe((a(this,Jt)-U)/(1-U),0,1);B(this,It,hn).call(this,{context:r,entry:it,textColor:F,labels:m,hpr:l,progress:bt})}return}const V=M>0?(y+M)/2:y*.65;r.textAlign="center",r.textBaseline="middle";const z=m.minSliceAngle*$i;for(let _=0;_<a(this,X).length;_++){const $=a(this,X)[_],H=$.value/u*We;if(H>=z){const it=D+H/2,U=a(this,at)[_]*P,bt=$.color??g[_%g.length],vt=B(this,It,vi).call(this,$,u,m.content),St=r.measureText(vt).width,Q=m.fontSize*1.2*l,Ut=H<Math.PI?2*V*Math.sin(H/2):2*V,yt=St>Ut-4*l,ut=M>0&&V-M<Q;if(!yt&&!ut){const dt=v+Math.cos(it)*(V+U),Pt=w+Math.sin(it)*(V+U);r.fillStyle=oo(bt)?"#000000":"#ffffff",r.fillText(vt,dt,Pt)}}D+=H}}}X=new WeakMap,G=new WeakMap,Ct=new WeakMap,at=new WeakMap,Me=new WeakMap,Jt=new WeakMap,wt=new WeakMap,ce=new WeakMap,It=new WeakSet,Xi=function(i,t){const e={...i,...t};return t.sliceLabels!==void 0&&(e.sliceLabels=io(i.sliceLabels,t.sliceLabels)),e},vi=function(i,t,e){const s=t>0?i.value/t*100:0,n=`${s.toFixed(s>=10?0:1)}%`;return e==="percent"?n:e==="label"?i.label:`${i.label} ${n}`},ln=function(i,t,e,s){const n=i.font;if(a(this,wt)&&a(this,wt).fontScale===s&&a(this,wt).font===n)return a(this,wt).reserve;let r=0;for(const h of a(this,X)){const d=B(this,It,vi).call(this,h,e,t.content),c=i.measureText(d).width;c>r&&(r=c)}const o=Math.max(t.distance,t.elbowLen),l=(r+(o+Math.max(0,t.railWidth)+t.legPad+4)*s)/an;return k(this,wt,{fontScale:s,font:n,reserve:l}),l},hn=function(i){const{context:t,entry:e,textColor:s,labels:n,hpr:r,progress:o}=i;if(o<=0)return;const{anchorX:l,anchorY:h,elbowX:d,elbowY:c,side:u,text:f,color:m,labelX:g,labelY:p}=e,v=g+u*n.legPad*r,w=Fe(o/.15,0,1),x=Fe((o-.15)/.45,0,1),y=Fe((o-.6)/.4,0,1);if(t.save(),t.globalAlpha=w,t.fillStyle=m,t.beginPath(),t.arc(l,h,2.5*r,0,We),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(l,h);const M=l+(d-l)*x,S=h+(c-h)*x;if(t.lineTo(M,S),y>0){const P=d+(g-d)*y,b=c+(p-c)*y;t.lineTo(P,b)}t.stroke(),t.restore()}y>0&&(t.save(),t.globalAlpha=y,t.fillStyle=s,t.textAlign=u>=0?"left":"right",t.textBaseline="middle",t.fillText(f,v,p),t.restore())},cn=function(i){const{cx:t,cy:e,outerR:s,total:n,palette:r,labels:o,hpr:l,bitmapHeight:h}=i,d=new Array(a(this,X).length).fill(null),c=o.elbowLen*l,u=Math.max(o.distance,o.elbowLen)*l,f=Math.max(0,o.railWidth)*l,m=[];let g=-Math.PI/2;const p=o.minSliceAngle*$i;for(let y=0;y<a(this,X).length;y++){const M=a(this,X)[y],S=M.value/n*We;if(S>=p){const P=g+S/2,b=a(this,at)[y]*(8*l),L=Math.cos(P),I=Math.sin(P),T=L>=0?1:-1,D=t+L*(s+b),F=e+I*(s+b),V=t+L*(s+b+c),z=e+I*(s+b+c),_=t+L*(s+b+u)+T*f,$=e+I*(s+b+u),H={anchorX:D,anchorY:F,elbowX:V,elbowY:z,side:T,labelX:_,labelY:$,text:B(this,It,vi).call(this,M,n,o.content),color:M.color??r[y%r.length]};d[y]=H,m.push({entry:H})}g+=S}const v=Math.max(1,o.fontSize*o.labelGap)*l,w=o.fontSize*l,x=h-o.fontSize*l;for(const y of[1,-1]){const M=[];for(const b of m)b.entry.side===y&&M.push(b.entry);if(M.length===0)continue;M.sort((b,L)=>b.labelY-L.labelY);const S=[];for(let b=0;b<M.length;b++)for(S.push({count:1,sumIdeal:M[b].labelY,startIdx:b});S.length>=2;){const L=S[S.length-2],I=S[S.length-1],T=L.sumIdeal/L.count,D=I.sumIdeal/I.count,F=T+(L.count-1)*v/2;if(D-(I.count-1)*v/2>=F+v)break;L.count+=I.count,L.sumIdeal+=I.sumIdeal,S.pop()}if(S.length>0){const b=S[0],L=b.sumIdeal/b.count-(b.count-1)*v/2;if(L<w)for(b.sumIdeal+=(w-L)*b.count;S.length>=2;){const I=S[0],T=S[1],D=I.sumIdeal/I.count,F=T.sumIdeal/T.count,V=D+(I.count-1)*v/2;if(F-(T.count-1)*v/2>=V+v)break;I.count+=T.count,I.sumIdeal+=T.sumIdeal,S.splice(1,1)}}if(S.length>0){const b=S[S.length-1],L=b.sumIdeal/b.count+(b.count-1)*v/2;if(L>x)for(b.sumIdeal-=(L-x)*b.count;S.length>=2;){const I=S[S.length-2],T=S[S.length-1],D=I.sumIdeal/I.count,F=T.sumIdeal/T.count,V=D+(I.count-1)*v/2;if(F-(T.count-1)*v/2>=V+v)break;I.count+=T.count,I.sumIdeal+=T.sumIdeal,S.pop()}}const P=(w+x)/2;for(const b of S){const L=(b.count-1)*v,I=b.sumIdeal/b.count;L>x-w&&I-L/2<w&&(b.sumIdeal=P*b.count)}for(const b of S){const L=b.sumIdeal/b.count;for(let I=0;I<b.count;I++)M[b.startIdx+I].labelY=L+(I-(b.count-1)/2)*v}}for(const y of m){const M=y.entry,S=M.labelY-M.anchorY;let P;if(Math.abs(S)<=c){const I=M.side*Math.sqrt(Math.max(0,c*c-S*S));P=M.anchorX+I}else P=(M.anchorX+M.labelX)/2;const b=Math.min(M.anchorX,M.labelX),L=Math.max(M.anchorX,M.labelX);M.elbowX=Math.max(b,Math.min(L,P)),M.elbowY=M.labelY}return d};function ho(i){return parseInt(i.slice(1,3),16)*.299+parseInt(i.slice(3,5),16)*.587+parseInt(i.slice(5,7),16)*.114<128}function J(i){var t,e,s,n,r,o,l,h,d,c,u,f,m,g,p,v,w,x,y,M,S,P,b,L,I,T,D,F,V,z,_,$,H,it;const{background:U,name:bt="Custom",description:vt,fontUrl:St=null}=i,Q=ho(U),Ut=Q?"#d1d4dc":"#24292f",yt=Q?"#787b86":"#8b949e",ut=Q?"#26a69a":"#2da44e",dt=Q?"#ef5350":"#cf222e",Pt=Q?"#2962ff":"#0969da",Mt=Q?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",Gt=Q?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",Be=Q?_e(U,.1):Ui(U,.05),di=Q?ke(U,.92):ke(U,.95),fi=Q?ke(_e(U,.15),.6):"rgba(200,200,200,0.5)",st=Di,ft=((e=(t=i.candlestick)==null?void 0:t.up)==null?void 0:e.body)??ut,Kt=((n=(s=i.candlestick)==null?void 0:s.down)==null?void 0:n.body)??dt,Pi=pt(ft),gi=pt(Kt),ze=((r=i.line)==null?void 0:r.color)??Pt,ds=((o=i.tooltip)==null?void 0:o.textColor)??Ut,fs=((l=i.axis)==null?void 0:l.textColor)??yt,$n=((h=i.typography)==null?void 0:h.fontFamily)??st,gs=((d=i.typography)==null?void 0:d.fontSize)??12,Xn=i.chartGradient??(Q?[_e(U,.04),Ui(U,.06)]:[_e(U,.06),U]),Un={background:U,chartGradient:Xn,typography:{fontFamily:$n,fontSize:gs},grid:{color:((c=i.grid)==null?void 0:c.color)??Mt,style:((u=i.grid)==null?void 0:u.style)??"dashed"},candlestick:{up:{body:ft,wick:((m=(f=i.candlestick)==null?void 0:f.up)==null?void 0:m.wick)??Pi},down:{body:Kt,wick:((p=(g=i.candlestick)==null?void 0:g.down)==null?void 0:p.wick)??gi}},line:{color:ze,width:((v=i.line)==null?void 0:v.width)??1,areaTopColor:((w=i.line)==null?void 0:w.areaTopColor)??ke(ze,.08),areaBottomColor:((x=i.line)==null?void 0:x.areaBottomColor)??ke(ze,.01)},seriesColors:i.seriesColors??[ze,ut,dt],bands:{upper:((y=i.bands)==null?void 0:y.upper)??ze,lower:((M=i.bands)==null?void 0:M.lower)??gi},crosshair:{color:((S=i.crosshair)==null?void 0:S.color)??Gt,labelBackground:((P=i.crosshair)==null?void 0:P.labelBackground)??Be,labelTextColor:((b=i.crosshair)==null?void 0:b.labelTextColor)??ds},axis:{fontSize:((L=i.axis)==null?void 0:L.fontSize)??10,textColor:fs,...(I=i.axis)!=null&&I.x?{x:{...i.axis.x}}:{},...(T=i.axis)!=null&&T.y?{y:{...i.axis.y}}:{}},yLabel:{fontSize:((D=i.yLabel)==null?void 0:D.fontSize)??11,upBackground:((F=i.yLabel)==null?void 0:F.upBackground)??Pi,downBackground:((V=i.yLabel)==null?void 0:V.downBackground)??gi,neutralBackground:((z=i.yLabel)==null?void 0:z.neutralBackground)??Be,textColor:((_=i.yLabel)==null?void 0:_.textColor)??"#ffffff"},tooltip:{fontSize:(($=i.tooltip)==null?void 0:$.fontSize)??gs,background:((H=i.tooltip)==null?void 0:H.background)??di,textColor:ds,borderColor:((it=i.tooltip)==null?void 0:it.borderColor)??fi},navigator:co({dark:Q,bg:U,neutralFg:fs,upBody:ft,downBody:Kt,upBase:Pi,downBase:gi,config:i.navigator})};return{name:bt,description:vt,fontUrl:St,dark:Q,theme:Un}}function co(i){var t,e,s,n,r,o,l,h,d,c,u,f,m,g,p,v,w,x;const{dark:y,bg:M,neutralFg:S,upBody:P,downBody:b,upBase:L,downBase:I,config:T}=i,D=(T==null?void 0:T.background)??"transparent",F=y?"rgba(255,255,255,1)":"rgba(0,0,0,1)",V=((t=T==null?void 0:T.handle)==null?void 0:t.color)??Ee(F,.3),z=((e=T==null?void 0:T.mask)==null?void 0:e.fill)??Ee(M,y?.78:.82);return{height:(T==null?void 0:T.height)??48,background:D,borderColor:(T==null?void 0:T.borderColor)??Ee(S,y?.18:.22),line:{color:((s=T==null?void 0:T.line)==null?void 0:s.color)??S,width:((n=T==null?void 0:T.line)==null?void 0:n.width)??1,areaTopColor:((r=T==null?void 0:T.line)==null?void 0:r.areaTopColor)??Ee(S,y?.22:.18),areaBottomColor:((o=T==null?void 0:T.line)==null?void 0:o.areaBottomColor)??Ee(S,0)},candlestick:{up:{body:((h=(l=T==null?void 0:T.candlestick)==null?void 0:l.up)==null?void 0:h.body)??P,wick:((c=(d=T==null?void 0:T.candlestick)==null?void 0:d.up)==null?void 0:c.wick)??L},down:{body:((f=(u=T==null?void 0:T.candlestick)==null?void 0:u.down)==null?void 0:f.body)??b,wick:((g=(m=T==null?void 0:T.candlestick)==null?void 0:m.down)==null?void 0:g.wick)??I}},window:{fill:((p=T==null?void 0:T.window)==null?void 0:p.fill)??"transparent",border:((v=T==null?void 0:T.window)==null?void 0:v.border)??"transparent",borderWidth:((w=T==null?void 0:T.window)==null?void 0:w.borderWidth)??0},handle:{color:V,width:((x=T==null?void 0:T.handle)==null?void 0:x.width)??6},mask:{fill:z}}}function Ee(i,t){if(i.startsWith("#")&&i.length===7)return ke(i,t);const e=i.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?`rgba(${e[1]},${e[2]},${e[3]},${t})`:i}function ke(i,t){const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function _e(i,t){if(!i.startsWith("#"))return i;const e=Math.min(255,Math.round(parseInt(i.slice(1,3),16)+255*t)),s=Math.min(255,Math.round(parseInt(i.slice(3,5),16)+255*t)),n=Math.min(255,Math.round(parseInt(i.slice(5,7),16)+255*t));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Ui(i,t){if(!i.startsWith("#"))return i;const e=Math.max(0,Math.round(parseInt(i.slice(1,3),16)*(1-t))),s=Math.max(0,Math.round(parseInt(i.slice(3,5),16)*(1-t))),n=Math.max(0,Math.round(parseInt(i.slice(5,7),16)*(1-t)));return`#${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function E(i){const t=i.startsWith("#")&&i.length===7?[_e(i,.2),Ui(i,.15)]:[i,i];return Object.defineProperty(t,"source",{value:i,enumerable:!1}),t}const Ai="'JetBrains Mono', 'Fira Code', monospace",Wi="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Di="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",rs="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",un="'Roboto Mono', monospace",dn="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",uo="'IBM Plex Mono', monospace",fo="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",os="'Fira Code', monospace",as="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",fn="'Source Code Pro', monospace",gn="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",go="'Space Mono', monospace",mo="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",ls="'Plus Jakarta Sans', sans-serif",hs="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",po="'Caveat', 'Comic Sans MS', cursive",bo="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",mn=J({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{up:{body:E("#a6e3a1"),wick:"#a6e3a1"},down:{body:E("#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:Di},fontUrl:rs}),qt={top:20,bottom:20,right:{intervals:3},left:{intervals:0}},vo=.1,yo=.3,xo=.4,wo=.5,So=4,Mo=(i,t,e)=>({from:mt(i.from,t.from,e),to:mt(i.to,t.to,e)}),ko=(i,t)=>i.from===t.from&&i.to===t.to;var ot,Tt,nt;class Co extends ai{constructor({padding:t,reboundMs:e}={}){super(),W(this,ot),R(this,"_yRange",{min:0,max:0}),R(this,"_autoScroll",!0),R(this,"padding"),R(this,"reboundMs"),R(this,"dataInterval",6e4),W(this,Tt,null),W(this,nt,null),R(this,"_prevDataEnd",null),R(this,"_lastChartWidth",0),this.padding={top:(t==null?void 0:t.top)??qt.top,bottom:(t==null?void 0:t.bottom)??qt.bottom,right:(t==null?void 0:t.right)??qt.right,left:(t==null?void 0:t.left)??qt.left},this.reboundMs=e??Gs,k(this,ot,new Pe({initial:{from:0,to:0},duration:bi.streamTick,easing:pe,lerp:Mo,equals:ko}))}setReboundMs(t){this.reboundMs=Math.max(0,t)}resolveHPad(t,e,s){return typeof t=="object"?t.intervals*this.dataInterval:s<=0?0:t/s*e}get visualRange(){return a(this,ot).current}get logicalRange(){return a(this,ot).target}get visibleRange(){return a(this,ot).current}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return a(this,ot).animating}get dataStart(){return a(this,Tt)}get dataEnd(){return a(this,nt)}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??qt.top,bottom:(t==null?void 0:t.bottom)??qt.bottom,right:(t==null?void 0:t.right)??qt.right,left:(t==null?void 0:t.left)??qt.left}}getPadding(){return this.padding}setDataStart(t){k(this,Tt,t)}setDataEnd(t){this._prevDataEnd=a(this,nt),k(this,nt,t)}cancelPendingAnimation(){a(this,ot).animating&&(a(this,ot).snap(a(this,ot).current),this.emit("change"))}applyLogical(t,e){e<=t||(e-t)/this.dataInterval<2||(a(this,ot).snap({from:t,to:e}),this.emit("change"))}retargetLogical(t,e,s,n){e<=t||(e-t)/this.dataInterval<2||(a(this,ot).setTarget({from:t,to:e},{duration:s,now:n}),this.emit("change"))}tick(t){if(!a(this,ot).animating)return!1;const e=a(this,ot).tick(t);return this.emit("change"),e}getSoftBounds(t,e){const s=o=>typeof o=="object"||o===0||e>0,n=a(this,Tt)!==null&&s(this.padding.left)?a(this,Tt)-this.resolveHPad(this.padding.left,t,e):null,r=a(this,nt)!==null&&s(this.padding.right)?a(this,nt)+this.resolveHPad(this.padding.right,t,e):null;return{left:n,right:r}}get softMinRange(){return 10*this.dataInterval}dataFitsCurrentViewport(t=0){if(a(this,Tt)===null||a(this,nt)===null)return!1;const{from:e,to:s}=this.logicalRange,n=s-e;if(n<=0)return!1;t>0&&(this._lastChartWidth=t);const r=t>0?t:this._lastChartWidth,o=this.resolveHPad(this.padding.left,n,r),l=a(this,Tt)-o,h=this.dataInterval*.5;return Math.abs(e-l)<=h}softMaxRange(){if(a(this,Tt)===null||a(this,nt)===null)return null;const t=a(this,nt)-a(this,Tt);if(t<=0)return null;const e=typeof this.padding.left=="object"?this.padding.left.intervals*this.dataInterval:null,s=typeof this.padding.right=="object"?this.padding.right.intervals*this.dataInterval:null;return e!==null||s!==null?t+(e??0)+(s??0):t+this.dataInterval*5}setRange(t){const{from:e,to:s}=t;if(!Number.isFinite(e)||!Number.isFinite(s)||s<=e||(s-e)/this.dataInterval<2)return;const n=a(this,nt)!==null&&a(this,nt)>=e&&a(this,nt)<=s;this._autoScroll=n,this.applyLogical(e,s)}setYRange(t,e,s,n=!1,r=!1){const o=e-t,l=s>0?this.padding.top/s*o:0,h=s>0?this.padding.bottom/s*o:0;this._yRange={min:n?t:t-h,max:r?e:e+l}}zoomAt(t,e,s=this._lastChartWidth,n=0){s>0&&(this._lastChartWidth=s),this.cancelPendingAnimation();const{from:r,to:o}=this.logicalRange,l=o-r;if(l<=0)return;const h=this.softMinRange,{left:d,right:c}=this.getSoftBounds(l,s),u=d!==null&&c!==null?c-d:this.softMaxRange();let f=e;const m=h*xo;if(e<1&&l<h){const x=h-l,y=(1-Math.min(1,x/m))**2;f=1-(1-e)*y}let g=l*f;g<h-m&&(g=h-m),e>1&&u!==null&&g>u&&(g=u);const p=(t-r)/l;let v=t-p*g,w=v+g;if(e<1&&w<o){const x=o-w;v+=x,w+=x}if(e>1){if(c!==null&&w>c){const x=w-c;v-=x,w-=x}if(d!==null&&v<d){const x=d-v;v+=x,w+=x}}n>0?this.retargetLogical(v,w,n):this.applyLogical(v,w),this.emit("interact")}pan(t,e=0,s=0){e>0&&(this._lastChartWidth=e),this.cancelPendingAnimation();const{from:n,to:r}=this.logicalRange,o=r-n;if(o<=0)return;const{left:l,right:h}=this.getSoftBounds(o,e),d=o*yo;let c=t;if(t>0&&h!==null){const g=Math.max(0,r-h);g>0&&(c*=1/(g/d+1))}else if(t<0&&l!==null){const g=Math.max(0,l-n);g>0&&(c*=1/(g/d+1))}let u=n+c,f=r+c;if(h!==null&&f>h+d){const g=f-(h+d);u-=g,f-=g}if(l!==null&&u<l-d){const g=l-d-u;u+=g,f+=g}const m=a(this,nt)!==null&&a(this,nt)>=u&&a(this,nt)<=f;this._autoScroll=m,s>0?this.retargetLogical(u,f,s):this.applyLogical(u,f),this.emit("interact")}startRebound(t=this._lastChartWidth){const{from:e,to:s}=this.logicalRange,n=s-e;if(n<=0)return;const r=this.softMinRange,o=this.softMaxRange();let l=n;l<r&&(l=r),o!==null&&l>o&&(l=o);let h=e,d=s;if(l!==n){const x=(e+s)/2;h=x-l/2,d=x+l/2}const{left:c,right:u}=this.getSoftBounds(l,t);if(u!==null&&d>u){const x=d-u;h-=x,d-=x}if(c!==null&&h<c){const x=c-h;h+=x,d+=x}const f=Math.abs(h-e),m=Math.abs(d-s);if(f<1&&m<1)return;const g=n*vo;let p=null,v=0,w=0;u!==null&&s-u>g?(p="right",v=s-u,w=u):c!==null&&c-e>g&&(p="left",v=c-e,w=c),this.reboundMs<=0?this.applyLogical(h,d):this.retargetLogical(h,d,this.reboundMs),this.emit("interact"),p!==null&&this.emit("edgeReached",{side:p,overshoot:v,boundaryTime:w})}fitToData(t,e,s=0,n=!1,r){this._autoScroll=!0,s>0&&(this._lastChartWidth=s);const o=400*this.dataInterval,l=e-t,h=l>0?l:this.dataInterval*10,d=this.resolveHPad(this.padding.right,h,s),c=this.resolveHPad(this.padding.left,h,s);let u=e+d,f=t-c;u-f>o&&(u=e+d,f=u-o);const{from:m,to:g}=this.logicalRange;n&&!(m===0&&g===0)?this.retargetLogical(f,u,r??bi.fit):this.applyLogical(f,u)}scrollToEnd(t,e=0){e>0&&(this._lastChartWidth=e);const{from:s,to:n}=this.logicalRange,r=n-s;if(r<=0)return;const o=this.resolveHPad(this.padding.right,r,e),l=n,h=this._prevDataEnd!==null?l-this._prevDataEnd:o,d=Math.max(0,Math.min(o,h)),c=t+d,u=c-r;this._autoScroll=!0;const f=wo*this.dataInterval,m=e>0?So/e*r:f,g=Math.min(f,m);Math.abs(c-n)<g||(this.retargetLogical(u,c,bi.streamTick),this._prevDataEnd=a(this,nt))}getVisibleBarsCount(){const{from:t,to:e}=a(this,ot).current;return(e-t)/this.dataInterval}destroy(){this.removeAllListeners()}}ot=new WeakMap,Tt=new WeakMap,nt=new WeakMap;function ye(i,t){return i===!1||i===0?0:i===void 0?t:i}function Ps(i){if(i===!1)return{points:{enterMs:0,smoothMs:0,pulseMs:0},viewport:{reboundMs:0,yAxisMs:0,inputResponseMs:0}};const t=i===!0||i===void 0?void 0:i,e=t==null?void 0:t.points,s=t==null?void 0:t.viewport,n=e===!1?{enterMs:0,smoothMs:0,pulseMs:0}:{enterMs:ye(e==null?void 0:e.enterMs,be),smoothMs:ye(e==null?void 0:e.smoothMs,Zi),pulseMs:ye(e==null?void 0:e.pulseMs,Us)},r=s===!1?{reboundMs:0,yAxisMs:0,inputResponseMs:0}:{reboundMs:ye(s==null?void 0:s.reboundMs,Gs),yAxisMs:ye(s==null?void 0:s.yAxisMs,Ni),inputResponseMs:ye(s==null?void 0:s.inputResponseMs,qn)};return{points:n,viewport:r}}function To(i){if(!i)return{monitor:null,ownsMonitor:!1,showHud:!1};if(i===!0)return{monitor:new Yi,ownsMonitor:!0,showHud:!0};if(i instanceof Yi)return{monitor:i,ownsMonitor:!1,showHud:!1};const{hud:t,monitor:e,...s}=i,n=e!==void 0;return{monitor:e??new Yi(s),ownsMonitor:!n,showHud:t??!n}}let Ro=0;var tt,O,K,Et,Ce,Y,Z,Oe,ht,Vt,rt,ee,Gi,Te,Rt,xi,wi,_t,He,ue,ni,Ti,At,Yt,Ne,$e,q,ie,Bs,Si,Xe,Ue,pn,bn,Mi,Ge,Qt,Zt,Re,Ke;class vn extends ai{constructor(t,e){var s,n,r,o;super(),W(this,q),W(this,tt),W(this,O),W(this,K),W(this,Et),R(this,"timeScale"),R(this,"yScale"),W(this,Ce),W(this,Y,[]),W(this,Z),W(this,Oe),W(this,ht,6e4),W(this,Vt,null),W(this,rt,{}),W(this,ee,null),W(this,Gi,!1),W(this,Te,{}),W(this,Rt,{left:"idle",right:"idle"}),W(this,xi,{left:null,right:null}),W(this,wi),W(this,_t,0),W(this,He,!1),W(this,ue,!1),W(this,ni,!1),W(this,Ti,0),W(this,At),W(this,Yt),W(this,Ne,!1),W(this,$e,null),W(this,Mi,0),W(this,Ge,!1),W(this,Qt,new Pe({initial:0,duration:Ni,easing:pe,lerp:(c,u,f)=>c+(u-c)*f})),W(this,Zt,new Pe({initial:0,duration:Ni,easing:pe,lerp:(c,u,f)=>c+(u-c)*f})),W(this,Re,!1),W(this,Ke,!1),e!=null&&e.axis&&(k(this,Te,e.axis),k(this,rt,{min:(s=e.axis.y)==null?void 0:s.min,max:(n=e.axis.y)==null?void 0:n.max})),k(this,Z,(e==null?void 0:e.theme)??mn.theme),k(this,Oe,((r=e==null?void 0:e.grid)==null?void 0:r.visible)!==!1),k(this,At,Ps(e==null?void 0:e.animations)),k(this,wi,e==null?void 0:e.onEdgeReached);const l=To(e==null?void 0:e.perf);k(this,Yt,l.monitor),k(this,Ne,l.ownsMonitor),k(this,tt,new Jn(t,a(this,Yt)??void 0)),k(this,O,new Co({padding:e==null?void 0:e.padding,reboundMs:a(this,At).viewport.reboundMs})),mr(this,a(this,O)),this.timeScale=new tn,this.yScale=new nn;const h=a(this,Yt);h?(k(this,K,new mi(c=>{h.resetDrawCalls("main");const u=performance.now();this.renderMain(c),h.recordFrame("main",performance.now()-u,c)})),k(this,Et,new mi(c=>{h.resetDrawCalls("overlay");const u=performance.now();this.renderOverlay(c),h.recordFrame("overlay",performance.now()-u,c)})),l.showHud&&k(this,$e,new wr(t,h))):(k(this,K,new mi(c=>this.renderMain(c))),k(this,Et,new mi(c=>this.renderOverlay(c))));const d=(e==null?void 0:e.interactive)!==!1;k(this,Ce,d?new fr(a(this,tt).canvas,a(this,O),this.timeScale,this.yScale,a(this,At).viewport.inputResponseMs):null),a(this,O).on("change",()=>{this.syncScales(),a(this,K).markDirty(),this.emit("viewportChange")}),a(this,O).on("edgeReached",c=>{var u;a(this,xi)[c.side]=c.boundaryTime,(u=a(this,wi))==null||u.call(this,c)}),a(this,O).on("interact",()=>{k(this,Ke,!0)}),a(this,tt).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(o=a(this,Ce))==null||o.on("crosshairMove",c=>{k(this,Vt,c),a(this,Et).markDirty(),this.emit("crosshairMove",c),B(this,q,bn).call(this,c)})}get yAxisWidth(){const t=a(this,Te).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=a(this,Te).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}getOverlayVersion(){return a(this,Ti)}addCandlestickSeries(t){const e=new Js,s=new Qr(e,{up:{...a(this,Z).candlestick.up},down:{...a(this,Z).candlestick.down},bodyWidthRatio:.6,...B(this,q,Si).call(this,"candle"),...t,...B(this,q,Xe).call(this)});return B(this,q,Ue).call(this,s,s.store,t??{})}addLineSeries(t){const{layers:e,...s}=t??{},n=e??1,r=new to(n,{colors:n===1?[a(this,Z).line.color]:a(this,Z).seriesColors.slice(0,n),strokeWidth:a(this,Z).line.width,area:{visible:!0},...B(this,q,Si).call(this,"line"),...s,...B(this,q,Xe).call(this)});return B(this,q,Ue).call(this,r,r.store,s)}addBarSeries(t){const{layers:e,...s}=t??{},n=e??1,r=new $r(n,{colors:a(this,Z).seriesColors.slice(0,n),barWidthRatio:.6,...B(this,q,Si).call(this,"bar"),...s,...B(this,q,Xe).call(this)});return B(this,q,Ue).call(this,r,r.store,s)}addPieSeries(t){const e=new yi(t);return B(this,q,Ue).call(this,e,null,t??{})}removeSeries(t){const e=a(this,Y).findIndex(s=>s.id===t);e>=0&&(a(this,Y)[e].renderer.dispose(),a(this,Y).splice(e,1),k(this,ee,null),this.updateViewportPadding(),a(this,K).markDirty(),this.emit("seriesChange"),B(this,q,ie).call(this))}setSeriesData(t,e,s){const n=a(this,Y).find(r=>r.id===t);n&&(k(this,Ge,!0),n.renderer.setData(e,s))}appendData(t,e,s){var n,r;const o=a(this,Y).find(l=>l.id===t);(r=o==null?void 0:(n=o.renderer).appendPoint)==null||r.call(n,e,s)}updateData(t,e,s){var n,r;const o=a(this,Y).find(l=>l.id===t);(r=o==null?void 0:(n=o.renderer).updateLastPoint)==null||r.call(n,e,s)}updateSeriesOptions(t,e){const s=a(this,Y).find(d=>d.id===t);if(!s)return;const n=s.label,r=s.renderer.getLayerColors().slice();s.renderer.updateOptions({...e,...B(this,q,Xe).call(this)}),"label"in e&&typeof e.label=="string"&&(s.label=e.label),a(this,K).markDirty();const o=s.renderer.getLayerColors(),l=r.length!==o.length||r.some((d,c)=>d!==o[c]),h=n!==s.label;(l||h)&&B(this,q,ie).call(this)}batch(t){Hi(this,_t)._++;try{t()}finally{--Hi(this,_t)._<=0&&(k(this,_t,0),a(this,He)?(k(this,He,!1),k(this,ue,!1),this.onDataChanged()):a(this,ue)&&(k(this,ue,!1),this.updateYRange(!0),a(this,K).markDirty()),a(this,ni)&&(k(this,ni,!1),this.emit("overlayChange")))}}setSeriesVisible(t,e){const s=a(this,Y).find(n=>n.id===t);if(!(!s||s.visible===e)){if(s.visible=e,B(this,q,ie).call(this),a(this,_t)>0){k(this,ue,!0);return}this.updateYRange(!0),a(this,K).markDirty()}}isSeriesVisible(t){var e;return((e=a(this,Y).find(s=>s.id===t))==null?void 0:e.visible)??!0}setLayerVisible(t,e,s){const n=a(this,Y).find(r=>r.id===t);if(n&&!(n.renderer.getLayerCount()<=1)&&n.renderer.isLayerVisible(e)!==s){if(n.renderer.setLayerVisible(e,s),B(this,q,ie).call(this),a(this,_t)>0){k(this,ue,!0);return}this.updateYRange(!0),a(this,K).markDirty()}}isLayerVisible(t,e){const s=a(this,Y).find(n=>n.id===t);return(s==null?void 0:s.renderer.isLayerVisible(e))??!0}fitContent(){const{first:t,last:e}=this.getDataBounds();if(t===void 0||e===void 0)return;const s=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(t,e,s,!0)}getVisibleRange(){return a(this,O).visibleRange}getDataRange(){const t=a(this,O).dataStart,e=a(this,O).dataEnd;return t===null||e===null?null:{from:t,to:e}}setVisibleRange(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<2)return;const{first:e,last:s}=this.getDataBounds();if(e===void 0||s===void 0)return;const n=Math.max(e,s-(t-1)*a(this,ht)),r=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(n,s,r,!1);return}a(this,O).setRange(t)}getYRange(){return a(this,O).yRange}getCrosshairPosition(){return a(this,Vt)}getLastValue(t){const e=a(this,Y).find(h=>h.id===t);if(!(e!=null&&e.store))return null;const s=e.store.last();if(!s)return null;const n=h=>"close"in h?h.close:h.value,{from:r,to:o}=a(this,O).visibleRange;if(s.time>=r&&s.time<=o)return{value:n(s),isLive:!0};const l=e.store.getVisibleData(r,o);return l.length===0?null:{value:n(l[l.length-1]),isLive:!1}}getPreviousClose(t){const e=a(this,Y).find(r=>r.id===t);if(!(e!=null&&e.store))return null;const s=e.store.getAll();if(s.length<2)return null;const n=s[s.length-2];return"close"in n?n.close:n.value}getLastData(t){const e=a(this,Y).find(s=>s.id===t);return e!=null&&e.store?e.store.last()??null:null}getDataAtTime(t,e){var s,n;const r=a(this,Y).find(o=>o.id===t);return r?((n=(s=r.renderer).getDataAtTime)==null?void 0:n.call(s,e,a(this,ht)))??null:null}getLayerSnapshots(t,e){var s,n;const r=a(this,Y).find(o=>o.id===t);return r!=null&&r.visible?((n=(s=r.renderer).getLayerSnapshots)==null?void 0:n.call(s,e,a(this,ht)))??null:null}getSeriesIds(){return a(this,ee)||k(this,ee,a(this,Y).map(t=>t.id)),a(this,ee).slice()}getSeriesType(t){const e=a(this,Y).find(s=>s.id===t);return e?e.renderer instanceof yi?"pie":"time":null}getSeriesIdsByType(t,e){const s=(e==null?void 0:e.visibleOnly)===!0,n=(e==null?void 0:e.singleLayerOnly)===!0,r=[];for(const o of a(this,Y)){const l=o.renderer instanceof yi;if(t==="pie"&&!l||t==="time"&&l)continue;const h=o.renderer.getLayerCount();if(!(n&&h>1)){if(s){if(!o.visible)continue;if(h>1){let d=!1;for(let c=0;c<h;c++)if(o.renderer.isLayerVisible(c)){d=!0;break}if(!d)continue}}r.push(o.id)}}return r}getStackedLastValue(t){var e,s;const n=a(this,Y).find(o=>o.id===t);return n?((s=(e=n.renderer).getStackedLastValue)==null?void 0:s.call(e))||this.getLastValue(t):null}getLayerLastSnapshots(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getLayerLastSnapshots)==null?void 0:s.call(e))??null}listSeriesForTest(){return a(this,Y).map(t=>({id:t.id,renderer:t.renderer}))}getSeriesColor(t){const e=a(this,Y).find(s=>s.id===t);return e?e.renderer.getLayerColors()[0]??a(this,Z).line.color:null}getSeriesLabel(t){var e;return(e=a(this,Y).find(s=>s.id===t))==null?void 0:e.label}getSeriesLayers(t){const e=a(this,Y).find(r=>r.id===t);if(!e)return null;const s=e.renderer.getLayerCount();if(s<=1)return null;const n=e.renderer.getLayerColors();return Array.from({length:s},(r,o)=>({color:n[o%n.length]}))}getSliceInfo(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getSliceInfo)==null?void 0:s.call(e,a(this,Z)))??null}getHoverInfo(t){var e,s;const n=a(this,Y).find(r=>r.id===t);return((s=n==null?void 0:(e=n.renderer).getHoverInfo)==null?void 0:s.call(e,a(this,Z)))??null}setTheme(t){const e=a(this,Z);k(this,Z,t);for(const s of a(this,Y))s.renderer.applyTheme(t,e);a(this,K).markDirty(),B(this,q,ie).call(this)}getTheme(){return a(this,Z)}setAxis(t){var e,s;const n=this.yAxisWidth,r=this.xAxisHeight;k(this,Te,t),k(this,rt,{min:(e=t.y)==null?void 0:e.min,max:(s=t.y)==null?void 0:s.max}),k(this,Re,!1),this.updateYRange(!0),(this.yAxisWidth!==n||this.xAxisHeight!==r)&&this.updateScales(!0),a(this,K).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"),a(this,K).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"),a(this,K).markDirty())}getMediaSize(){return a(this,tt).size.media}getLayout(){const t=a(this,tt).size.media,e=this.yAxisWidth,s=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-e,height:t.height-s},yAxisWidth:e,xAxisHeight:s}}getDataInterval(){return a(this,ht)}setAnimations(t){var e,s,n;const r=Ps(t);k(this,At,r),a(this,O).setReboundMs(r.viewport.reboundMs),(e=a(this,Ce))==null||e.setInputResponseMs(r.viewport.inputResponseMs);const o={};if(r.points.enterMs===0&&(o.entryMs=0),r.points.smoothMs===0&&(o.smoothMs=0),r.points.pulseMs===0&&(o.pulseMs=0),Object.keys(o).length>0)for(const l of a(this,Y))(n=(s=l.renderer).updateOptions)==null||n.call(s,o);a(this,K).markDirty()}setPadding(t){const e=a(this,O).getPadding();a(this,O).setPadding(t);const s=a(this,O).getPadding(),n=!zs(e.left,s.left)||!zs(e.right,s.right),r=e.top!==s.top||e.bottom!==s.bottom;if(n){const{first:o,last:l}=this.getDataBounds();if(o!==void 0&&l!==void 0){const h=a(this,tt).size.media.width-this.yAxisWidth;a(this,O).fitToData(o,l,h,!1)}}r&&this.updateYRange(!0),this.syncScales(),a(this,K).markDirty(),r&&this.emit("viewportChange")}setGrid(t){k(this,Oe,t.visible),a(this,K).markDirty()}setEdgeState(t,e){a(this,Rt)[t]!==e&&(a(this,Rt)[t]=e,a(this,Et).markDirty())}getEdgeState(t){return a(this,Rt)[t]}setYLabel(t){k(this,Gi,t),this.updateViewportPadding()}updateViewportPadding(){}destroy(){var t,e,s;for(const n of a(this,Y))n.renderer.dispose();k(this,Y,[]),k(this,ee,null),a(this,O).destroy(),a(this,K).destroy(),a(this,Et).destroy(),(t=a(this,Ce))==null||t.destroy(),a(this,tt).destroy(),(e=a(this,$e))==null||e.destroy(),k(this,$e,null),a(this,Ne)&&((s=a(this,Yt))==null||s.destroy()),k(this,Yt,null),k(this,Ne,!1),this.removeAllListeners()}getPerfMonitor(){return a(this,Yt)}getDataBounds(){let t,e;for(const s of a(this,Y)){if(!s.visible||!s.store)continue;const n=s.store.first(),r=s.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(a(this,_t)>0){k(this,He,!0);return}this.updateDataInterval();const{first:t,last:e}=this.getDataBounds();t!==void 0&&a(this,O).setDataStart(t),e!==void 0&&a(this,O).setDataEnd(e);let s=0;for(const o of a(this,Y))o.renderer.getTotalLength?s+=o.renderer.getTotalLength():o.store&&(s+=o.store.length);const n=s-a(this,Mi)>5;if(k(this,Mi,s),t!==void 0&&e!==void 0){const{from:o,to:l}=a(this,O).logicalRange,h=o===0&&l===0,d=a(this,tt).size.media.width-this.yAxisWidth;h?a(this,O).fitToData(t,e,d,!1):n&&a(this,O).autoScroll?a(this,O).fitToData(t,e,d,!0):!n&&a(this,O).autoScroll&&(a(this,O).dataFitsCurrentViewport(d)?a(this,O).fitToData(t,e,d,!0,bi.streamTick):a(this,O).scrollToEnd(e,d))}const r=a(this,Ge);k(this,Ge,!1),this.updateYRange(n||r),this.syncScales(),a(this,K).markDirty(),this.emit("dataUpdate"),B(this,q,ie).call(this)}updateDataInterval(){for(const t of a(this,Y)){if(!t.store)continue;const e=t.store.getAll();if(e.length>=2){const s=e.slice(0,20).map(n=>n.time);k(this,ht,Qs(s)),a(this,O).setDataInterval(a(this,ht));break}}}computeTargetYRange(t,e){let s=1/0,n=-1/0;for(const r of a(this,Y)){if(!r.visible)continue;if(r.renderer.getValueRange){const l=r.renderer.getValueRange(t.from,t.to);if(l){l.max>n&&(n=l.max),l.min<s&&(s=l.min),e==null||e.push(l.min,l.max);continue}}if(!r.store)continue;const o=r.store.getVisibleData(t.from,t.to);for(const l of o)if("high"in l){const h=l;Number.isFinite(h.high)&&(h.high>n&&(n=h.high),e==null||e.push(h.high)),Number.isFinite(h.low)&&(h.low<s&&(s=h.low),e==null||e.push(h.low))}else{const h=l;Number.isFinite(h.value)&&(h.value>n&&(n=h.value),h.value<s&&(s=h.value),e==null||e.push(h.value))}}return s===1/0||n===-1/0?null:{min:s,max:n}}updateYRange(t=!1,e){const s=a(this,O).logicalRange,n=a(this,rt).min!==void 0&&a(this,rt).min!=="auto"&&typeof a(this,rt).min!="number"||a(this,rt).max!==void 0&&a(this,rt).max!=="auto"&&typeof a(this,rt).max!="number"?[]:null,r=this.computeTargetYRange(s,n);if(r===null){k(this,Re,!1);return}const o=this.resolveBound(a(this,rt).min,r.min,r.max,n??[],"min"),l=this.resolveBound(a(this,rt).max,r.max,r.min,n??[],"max"),h=a(this,At).viewport.yAxisMs,d=a(this,Ke);k(this,Ke,!1);const c=d&&h>ps?ps:h;if(!a(this,Re)||t||c<=0)a(this,Qt).snap(o),a(this,Zt).snap(l),k(this,Re,!0);else{const w=a(this,At).points.enterMs>0;o<a(this,Qt).current&&!w?a(this,Qt).snap(o):a(this,Qt).setTarget(o,{duration:c,now:e}),l>a(this,Zt).current&&!w?a(this,Zt).snap(l):a(this,Zt).setTarget(l,{duration:c,now:e})}const u=e??performance.now(),f=a(this,Qt).tick(u),m=a(this,Zt).tick(u);(f||m)&&a(this,K).markDirty();const g=a(this,rt).min!==void 0&&a(this,rt).min!=="auto",p=a(this,rt).max!==void 0&&a(this,rt).max!=="auto",v=a(this,tt).size.media.height-this.xAxisHeight;a(this,O).setYRange(a(this,Qt).current,a(this,Zt).current,v,g,p)}resolveBound(t,e,s,n,r){if(t===void 0||t==="auto")return e;if(typeof t=="number")return t;if(typeof t=="function")return t(n);const o=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(o){const l=o[1]==="-"?-1:1,h=parseFloat(o[2])/100,d=Math.abs(s-e)||Math.abs(e)||1;return e+l*h*d*(r==="max"?1:-1)}return e}syncScales(){const t=a(this,tt).size;if(t.media.width===0||t.media.height===0)return;const e=t.media.width-this.yAxisWidth,s=t.media.height-this.xAxisHeight;this.timeScale.update(a(this,O).visibleRange,e,t.horizontalPixelRatio,a(this,ht)),this.yScale.update(a(this,O).yRange,s,t.verticalPixelRatio)}updateScales(t=!1,e){const s=a(this,tt).size;if(s.media.width===0||s.media.height===0)return;const n=s.media.width-this.yAxisWidth,r=s.media.height-this.xAxisHeight;this.timeScale.update(a(this,O).visibleRange,n,s.horizontalPixelRatio,a(this,ht)),this.yScale.update(a(this,O).yRange,r,s.verticalPixelRatio),this.updateYRange(t,e),this.yScale.update(a(this,O).yRange,r,s.verticalPixelRatio)}renderMain(t){const e=a(this,tt).size;if(e.media.width===0||e.media.height===0)return;const s=typeof t=="number"?t:performance.now();a(this,O).tick(s)&&a(this,K).markDirty(),this.updateScales(!1,s),a(this,tt).useMainLayer(n=>{const{context:r,bitmapSize:o}=n,l=(e.media.width-this.yAxisWidth)*e.horizontalPixelRatio,h=(e.media.height-this.xAxisHeight)*e.verticalPixelRatio;r.clearRect(0,0,o.width,o.height),r.save(),r.beginPath(),r.rect(0,0,l,h),r.clip(),a(this,Oe)&&lr(n,this.timeScale,this.yScale,a(this,Z),a(this,ht));const d=a(this,O).getPadding(),c={top:d.top,bottom:d.bottom},u=a(this,Yt);for(const f of a(this,Y)){if(!f.visible)continue;const m={scope:n,timeScale:this.timeScale,yScale:this.yScale,theme:a(this,Z),dataInterval:a(this,ht),padding:c};if(u){const g=performance.now();f.renderer.render(m),u.recordSeries(f.id,performance.now()-g,s)}else f.renderer.render(m)}r.restore()});for(const n of a(this,Y))if(n.renderer.needsAnimation){a(this,K).markDirty();break}this.renderOverlay()}renderOverlay(t){var e,s;const n=a(this,tt).size;if(n.media.width===0||n.media.height===0)return;let r=!1;for(const h of a(this,Y))if(h.visible&&h.renderer.overlayNeedsAnimation){r=!0;break}const o=a(this,Rt).left==="loading"||a(this,Rt).right==="loading",l=a(this,Rt).left!=="idle"||a(this,Rt).right!=="idle";if(a(this,tt).useOverlayLayer(h=>{var d,c;if(!a(this,Vt)&&!r&&!l)return;const u=(n.media.width-this.yAxisWidth)*n.horizontalPixelRatio,f=(n.media.height-this.xAxisHeight)*n.verticalPixelRatio;if(h.context.save(),h.context.beginPath(),h.context.rect(0,0,u,f),h.context.clip(),a(this,Vt)&&B(this,q,pn).call(this)){const p=a(this,Vt).mediaX*n.horizontalPixelRatio,v=a(this,Vt).mediaY*n.verticalPixelRatio;Qn(h,p,v,a(this,Z))}const m=a(this,O).getPadding(),g={top:m.top,bottom:m.bottom};for(const p of a(this,Y))p.visible&&((c=(d=p.renderer).drawOverlay)==null||c.call(d,{scope:h,timeScale:this.timeScale,yScale:this.yScale,theme:a(this,Z),dataInterval:a(this,ht),padding:g,crosshair:a(this,Vt)}));l&&this.drawEdgeIndicators(h,n.media.height-this.xAxisHeight),h.context.restore()}),r){const{from:h,to:d}=this.timeScale.getRange();let c=!1;for(const u of a(this,Y))if(!(!u.visible||!u.renderer.overlayNeedsAnimation)&&(((s=(e=u.renderer).hasOverlayContentInRange)==null?void 0:s.call(e,h,d))??!0)){c=!0;break}c&&a(this,Et).markDirty()}o&&a(this,Et).markDirty()}drawEdgeIndicators(t,e){const s=performance.now();for(const n of["left","right"]){const r=a(this,Rt)[n];if(r==="idle"||r==="has-more")continue;const o=this.resolveEdgeBoundary(n);o!==null&&rr({scope:t,timeScale:this.timeScale,theme:a(this,Z),chartMediaHeight:e,boundaryTime:o,side:n,state:r,now:s})}}resolveEdgeBoundary(t){const e=a(this,xi)[t];if(e!==null)return e;const{first:s,last:n}=this.getDataBounds();return t==="left"?s??null:n??null}}tt=new WeakMap,O=new WeakMap,K=new WeakMap,Et=new WeakMap,Ce=new WeakMap,Y=new WeakMap,Z=new WeakMap,Oe=new WeakMap,ht=new WeakMap,Vt=new WeakMap,rt=new WeakMap,ee=new WeakMap,Gi=new WeakMap,Te=new WeakMap,Rt=new WeakMap,xi=new WeakMap,wi=new WeakMap,_t=new WeakMap,He=new WeakMap,ue=new WeakMap,ni=new WeakMap,Ti=new WeakMap,At=new WeakMap,Yt=new WeakMap,Ne=new WeakMap,$e=new WeakMap,q=new WeakSet,ie=function(){if(Hi(this,Ti)._++,a(this,_t)>0){k(this,ni,!0);return}this.emit("overlayChange")},Bs=function(i){if(i&&!a(this,Y).some(e=>e.id===i))return i;let t;do t=`series_${++Ro}`;while(a(this,Y).some(e=>e.id===t));return t},Si=function(i){const{enterMs:t,smoothMs:e,pulseMs:s}=a(this,At).points;return i==="line"?{enterMs:t,smoothMs:e,pulseMs:s}:{enterMs:t,smoothMs:e}},Xe=function(){const{enterMs:i,smoothMs:t,pulseMs:e}=a(this,At).points,s={};return i===0&&(s.enterMs=0),t===0&&(s.smoothMs=0),e===0&&(s.pulseMs=0),s},Ue=function(i,t,e){var s;const n=B(this,q,Bs).call(this,e.id);return(s=i.onDataChanged)==null||s.call(i,()=>this.onDataChanged()),a(this,Y).push({id:n,label:e.label,renderer:i,store:t,visible:!0}),k(this,ee,null),this.updateViewportPadding(),this.emit("seriesChange"),B(this,q,ie).call(this),n},pn=function(){for(const i of a(this,Y))if(i.visible&&!(i.renderer instanceof yi))return!0;return!1},bn=function(i){const t=a(this,tt).size,e=a(this,O).getPadding(),s={top:e.top*t.verticalPixelRatio,bottom:e.bottom*t.verticalPixelRatio};let n=!1;for(const r of a(this,Y)){if(!r.renderer.hitTest||!r.renderer.setHoverIndex)continue;let o=-1;if(i){const l=i.mediaX*t.horizontalPixelRatio,h=i.mediaY*t.verticalPixelRatio;o=r.renderer.hitTest(l,h,t.bitmap.width,t.bitmap.height,s)}r.renderer.setHoverIndex(o)&&(n=!0)}n&&a(this,K).markDirty()},Mi=new WeakMap,Ge=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Re=new WeakMap,Ke=new WeakMap;function zs(i,t){return typeof i=="number"&&typeof t=="number"?i===t:typeof i=="object"&&typeof t=="object"?i.intervals===t.intervals:!1}function Lo(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const r=n/t,o=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?s+1:e+(h+1)*r;let c=null,u=null;for(;l<i.length&&i[l].time<d;){const f=i[l];(c===null||f.value<c.value)&&(c=f),(u===null||f.value>u.value)&&(u=f),l++}if(!(c===null||u===null)){if(c===u){o.push(c);continue}c.time<u.time?o.push(c,u):o.push(u,c)}}return o}function Io(i,t){if(i.length<=t||t<=0)return i;const e=i[0].time,s=i[i.length-1].time,n=s-e;if(n<=0)return i;const r=n/t,o=[];let l=0;for(let h=0;h<t;h++){const d=h===t-1?s+1:e+(h+1)*r;let c=null;for(;l<i.length&&i[l].time<d;){const u=i[l];c===null?c={time:u.time,open:u.open,high:u.high,low:u.low,close:u.close}:(u.high>c.high&&(c.high=u.high),u.low<c.low&&(c.low=u.low),c.close=u.close),l++}c!==null&&o.push(c)}return o}const Es=8;function yn(i,t){return Math.abs(i-t.left)<=Es?{gesture:"resize-left",snapToCenter:!1}:Math.abs(i-t.right)<=Es?{gesture:"resize-right",snapToCenter:!1}:i>t.left&&i<t.right?{gesture:"pan",snapToCenter:!1}:{gesture:"pan",snapToCenter:!0}}function Ao(i){const{startVisible:t,deltaPx:e,pixelsPerTime:s,dataRange:n}=i,r=t.to-t.from,o=e/s;let l=t.from+o,h=t.to+o;return l<n.from&&(l=n.from,h=l+r),h>n.to&&(h=n.to,l=h-r),l<n.from&&(l=n.from),{from:l,to:h}}function Wo(i){const{edge:t,startVisible:e,deltaPx:s,pixelsPerTime:n,dataRange:r,minSpan:o}=i,l=s/n;if(t==="left"){let c=e.from+l,u=e.to;return c<r.from&&(c=r.from),u-c<o&&(c=u-o),c<r.from&&(c=r.from,u=Math.min(r.to,c+o)),{from:c,to:u}}let h=e.from,d=e.to+l;return d>r.to&&(d=r.to),d-h<o&&(d=h+o),d>r.to&&(d=r.to,h=Math.max(r.from,d-o)),{from:h,to:d}}function Do(i){const{time:t,startVisible:e,dataRange:s}=i,n=e.to-e.from;let r=t-n/2,o=r+n;return r<s.from&&(r=s.from,o=r+n),o>s.to&&(o=s.to,r=o-n),r<s.from&&(r=s.from),{from:r,to:o}}function Fo(i){const{ctx:t,theme:e,mediaWidth:s,mediaHeight:n}=i;t.fillStyle=e.background,t.fillRect(0,0,s,n)}function Po(i,t,e=!0,s=1){if(t.length<2)return;const{ctx:n,timeScale:r,yScale:o,mediaHeight:l,theme:h}=i,d=s<1&&t.length>=2,c=d?t.length-2:t.length-1;if(e){const u=n.createLinearGradient(0,0,0,l);u.addColorStop(0,h.line.areaTopColor),u.addColorStop(1,h.line.areaBottomColor),n.beginPath();for(let f=0;f<=c;f++){const m=t[f],g=r.timeToX(m.time),p=o.valueToY(m.value);f===0?n.moveTo(g,p):n.lineTo(g,p)}if(n.lineTo(r.timeToX(t[c].time),l),n.lineTo(r.timeToX(t[0].time),l),n.closePath(),n.fillStyle=u,n.fill(),d){n.save(),n.globalAlpha=s,n.beginPath();const f=t[c],m=t[t.length-1],g=r.timeToX(f.time),p=r.timeToX(m.time);n.moveTo(g,o.valueToY(f.value)),n.lineTo(p,o.valueToY(m.value)),n.lineTo(p,l),n.lineTo(g,l),n.closePath(),n.fillStyle=u,n.fill(),n.restore()}}n.beginPath();for(let u=0;u<=c;u++){const f=t[u],m=r.timeToX(f.time),g=o.valueToY(f.value);u===0?n.moveTo(m,g):n.lineTo(m,g)}if(n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),d){n.save(),n.globalAlpha=s,n.beginPath();const u=t[c],f=t[t.length-1];n.moveTo(r.timeToX(u.time),o.valueToY(u.value)),n.lineTo(r.timeToX(f.time),o.valueToY(f.value)),n.strokeStyle=h.line.color,n.lineWidth=h.line.width,n.stroke(),n.restore()}}function Bo(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:r,mediaHeight:o,theme:l}=i,h=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.8:2),d=e<1,c=t.length-1;s.fillStyle=l.line.color;for(let u=0;u<t.length;u++){const f=t[u],m=n.timeToX(f.time),g=r.valueToY(f.value),p=Math.max(1,o-g);d&&u===c?(s.save(),s.globalAlpha=e,s.fillRect(m-h/2,g,h,p),s.restore()):s.fillRect(m-h/2,g,h,p)}}function zo(i,t,e=1){if(t.length===0)return;const{ctx:s,timeScale:n,yScale:r,theme:o}=i,l=Math.max(1,t.length>1?Math.abs(n.timeToX(t[1].time)-n.timeToX(t[0].time))*.75:2),h=e<1,d=t.length-1;for(let c=0;c<t.length;c++){const u=t[c],f=u.close>=u.open?o.candlestick.up:o.candlestick.down,m=pt(f.body),g=n.timeToX(u.time),p=r.valueToY(u.open),v=r.valueToY(u.close),w=r.valueToY(u.high),x=r.valueToY(u.low),y=h&&c===d;y&&(s.save(),s.globalAlpha=e),s.strokeStyle=f.wick,s.lineWidth=1,s.beginPath(),s.moveTo(g,w),s.lineTo(g,x),s.stroke();const M=Math.min(p,v),S=Math.max(1,Math.abs(v-p));s.fillStyle=m,s.fillRect(g-l/2,M,l,S),y&&s.restore()}}function Eo(i,t,e){const s=Math.max(e.from,Math.min(e.to,t.from)),n=Math.max(e.from,Math.min(e.to,t.to)),r=i.timeToX(s),o=i.timeToX(n),l=Math.min(r,o),h=Math.max(r,o);return{left:l,right:h,width:Math.max(1,h-l)}}var Lt,N,Ri,et,Wt,re,Nt,$t,Ot,Ht,me,De,te,ki,Ci,de,jt,Xt,qe,Dt,Je,ri,Qe,ge,Ze,ti,ei,ii,fe,si,j,Ki,gt,xn,qi,ne,Ve,_i,pi,Vs,wn,Sn,Mn,Ys,js,xe,_s;class kn{constructor(t){W(this,j),W(this,Lt),W(this,N),W(this,Ri),W(this,et),W(this,Wt),W(this,re),W(this,Nt),W(this,$t),W(this,Ot),W(this,Ht),W(this,me),W(this,De),W(this,te,new tn),W(this,ki,new nn),W(this,Ci,0),W(this,de,0),W(this,jt,1),W(this,Xt,null),W(this,qe,!0),W(this,Dt,null),W(this,Je,null),W(this,ri,-1),W(this,Qe),W(this,ge,null),W(this,Ze),W(this,ti),W(this,ei),W(this,ii),W(this,fe),W(this,si),k(this,Lt,t.container),k(this,et,t.chart),k(this,me,t.data),k(this,De,t.options??{}),window.getComputedStyle(a(this,Lt)).position==="static"&&(a(this,Lt).style.position="relative"),k(this,N,document.createElement("canvas")),a(this,N).style.position="absolute",a(this,N).style.left="0",a(this,N).style.top="0",a(this,N).style.height="100%",a(this,N).style.touchAction="none",a(this,Lt).appendChild(a(this,N));const e=a(this,N).getContext("2d",{alpha:!0});if(!e)throw new Error("NavigatorController: failed to acquire 2D context");k(this,Ri,e),k(this,Wt,document.createElement("div")),a(this,Wt).dataset.chartNavigatorOverlay="",a(this,Wt).style.cssText="position:absolute;left:0;top:0;height:100%;pointer-events:none;",k(this,re,document.createElement("div")),a(this,re).style.cssText="position:absolute;left:0;top:0;bottom:0;",k(this,Nt,document.createElement("div")),a(this,Nt).style.cssText="position:absolute;top:0;bottom:0;",k(this,$t,document.createElement("div")),a(this,$t).style.cssText="position:absolute;top:0;bottom:0;box-sizing:border-box;",k(this,Ot,Hs()),k(this,Ht,Hs()),a(this,Wt).append(a(this,re),a(this,Nt),a(this,$t),a(this,Ot),a(this,Ht)),a(this,Lt).appendChild(a(this,Wt)),k(this,Ze,()=>B(this,j,ne).call(this)),k(this,ti,()=>B(this,j,ne).call(this)),a(this,et).on("viewportChange",a(this,Ze)),a(this,et).on("overlayChange",a(this,ti)),k(this,ei,n=>B(this,j,wn).call(this,n)),k(this,ii,n=>B(this,j,Sn).call(this,n)),k(this,fe,n=>B(this,j,Mn).call(this,n)),k(this,si,()=>{a(this,ge)===null&&(a(this,N).style.cursor="default")}),a(this,N).addEventListener("pointerdown",a(this,ei)),a(this,N).addEventListener("pointermove",a(this,ii)),a(this,N).addEventListener("pointerup",a(this,fe)),a(this,N).addEventListener("pointercancel",a(this,fe)),a(this,N).addEventListener("pointerleave",a(this,si)),k(this,Qe,new ResizeObserver(n=>B(this,j,xn).call(this,n[0]))),a(this,Qe).observe(a(this,Lt)),B(this,j,Ki).call(this);const s=a(this,Lt).getBoundingClientRect();s.width>0&&s.height>0&&B(this,j,qi).call(this,s.width,s.height),B(this,j,ne).call(this)}setData(t){var e;const s=Vo(t),n=(s==null?void 0:s.time)??null;if(n!==null&&a(this,Je)!==null&&n!==a(this,Je)){const r=((e=a(this,Dt))==null?void 0:e.current)??0;k(this,Dt,new Pe({initial:r,duration:be,easing:pe,lerp:(o,l,h)=>o+(l-o)*h})),a(this,Dt).setTarget(1)}k(this,Je,n),k(this,ri,(s==null?void 0:s.seriesIndex)??-1),k(this,me,t),B(this,j,ne).call(this)}setOptions(t){k(this,De,t),B(this,j,Ki).call(this),B(this,j,ne).call(this)}destroy(){a(this,et).off("viewportChange",a(this,Ze)),a(this,et).off("overlayChange",a(this,ti)),a(this,N).removeEventListener("pointerdown",a(this,ei)),a(this,N).removeEventListener("pointermove",a(this,ii)),a(this,N).removeEventListener("pointerup",a(this,fe)),a(this,N).removeEventListener("pointercancel",a(this,fe)),a(this,N).removeEventListener("pointerleave",a(this,si)),a(this,Qe).disconnect(),a(this,Xt)!==null&&(cancelAnimationFrame(a(this,Xt)),k(this,Xt,null)),a(this,N).remove(),a(this,Wt).remove()}get height(){return a(this,De).height??a(this,et).getTheme().navigator.height}}Lt=new WeakMap,N=new WeakMap,Ri=new WeakMap,et=new WeakMap,Wt=new WeakMap,re=new WeakMap,Nt=new WeakMap,$t=new WeakMap,Ot=new WeakMap,Ht=new WeakMap,me=new WeakMap,De=new WeakMap,te=new WeakMap,ki=new WeakMap,Ci=new WeakMap,de=new WeakMap,jt=new WeakMap,Xt=new WeakMap,qe=new WeakMap,Dt=new WeakMap,Je=new WeakMap,ri=new WeakMap,Qe=new WeakMap,ge=new WeakMap,Ze=new WeakMap,ti=new WeakMap,ei=new WeakMap,ii=new WeakMap,fe=new WeakMap,si=new WeakMap,j=new WeakSet,Ki=function(){const i=a(this,De).height;i!==void 0&&(a(this,Lt).style.height=`${i}px`)},gt=function(){return Math.max(0,a(this,Ci)-a(this,et).yAxisWidth)},xn=function(i){var t;if(!i)return;const e=(t=i.contentBoxSize)==null?void 0:t[0],s=(e==null?void 0:e.inlineSize)??i.contentRect.width,n=(e==null?void 0:e.blockSize)??i.contentRect.height;s<=0||n<=0||(B(this,j,qi).call(this,s,n),B(this,j,ne).call(this))},qi=function(i,t){const e=window.devicePixelRatio||1;k(this,Ci,i),k(this,de,t),k(this,jt,e);const s=a(this,j,gt);a(this,N).width=Math.round(s*e),a(this,N).height=Math.round(t*e),a(this,N).style.width=`${s}px`,a(this,Wt).style.width=`${s}px`},ne=function(){a(this,qe)&&a(this,Xt)!==null||(k(this,qe,!0),a(this,Xt)===null&&k(this,Xt,requestAnimationFrame(()=>{k(this,Xt,null),k(this,qe,!1),B(this,j,Ys).call(this)})))},Ve=function(i){const t=a(this,N).getBoundingClientRect();return i.clientX-t.left},_i=function(){const i=B(this,j,xe).call(this),t=B(this,j,_s).call(this);return a(this,te).update(i,a(this,j,gt),a(this,jt)),a(this,ki).update(t,a(this,de),a(this,jt)),{dataRange:i,yRange:t}},pi=function(){return B(this,j,_i).call(this),Eo(a(this,te),a(this,et).getVisibleRange(),B(this,j,xe).call(this))},Vs=function(){const i=B(this,j,xe).call(this),t=i.to-i.from;return t<=0||a(this,j,gt)<=0?0:a(this,j,gt)/t},wn=function(i){if(i.button!==void 0&&i.button!==0)return;const t=B(this,j,Ve).call(this,i),e=B(this,j,xe).call(this);if(e.to<=e.from)return;const s=B(this,j,pi).call(this),n=yn(t,s),r=B(this,j,Vs).call(this);if(r===0)return;let o=a(this,et).getVisibleRange();if(n.snapToCenter){const l=a(this,te).xToTime(t),h=Do({time:l,startVisible:o,dataRange:e});a(this,et).setVisibleRange(h),o=h}k(this,ge,{pointerId:i.pointerId,gesture:n.gesture,startX:t,startVisible:o,pixelsPerTime:r}),a(this,N).setPointerCapture(i.pointerId),a(this,N).style.cursor=Cn(n.gesture,!0),i.preventDefault()},Sn=function(i){const t=a(this,ge);if(t===null){a(this,N).style.cursor=Os(B(this,j,Ve).call(this,i),B(this,j,pi).call(this));return}if(i.pointerId!==t.pointerId)return;const e=B(this,j,Ve).call(this,i)-t.startX,s=B(this,j,xe).call(this);let n;if(t.gesture==="pan")n=Ao({startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s});else{const r=t.gesture==="resize-left"?"left":"right";n=Wo({edge:r,startVisible:t.startVisible,deltaPx:e,pixelsPerTime:t.pixelsPerTime,dataRange:s,minSpan:2*a(this,et).getDataInterval()})}a(this,et).setVisibleRange(n)},Mn=function(i){const t=a(this,ge);t===null||i.pointerId!==t.pointerId||(k(this,ge,null),a(this,N).hasPointerCapture(i.pointerId)&&a(this,N).releasePointerCapture(i.pointerId),a(this,N).style.cursor=Os(B(this,j,Ve).call(this,i),B(this,j,pi).call(this)))},Ys=function(){if(a(this,j,gt)<=0||a(this,de)<=0)return;const i=a(this,et).getTheme().navigator,{dataRange:t}=B(this,j,_i).call(this);a(this,N).width=Math.round(a(this,j,gt)*a(this,jt)),a(this,N).height=Math.round(a(this,de)*a(this,jt)),a(this,N).style.width=`${a(this,j,gt)}px`,a(this,Wt).style.width=`${a(this,j,gt)}px`;const e=a(this,Ri),s=a(this,N).width,n=a(this,N).height;e.save(),e.clearRect(0,0,s,n),e.scale(a(this,jt),a(this,jt));const r={ctx:e,timeScale:a(this,te),yScale:a(this,ki),mediaWidth:a(this,j,gt),mediaHeight:a(this,de),theme:i};a(this,N).style.boxShadow=`inset 0 1px 0 ${i.borderColor}, inset 0 -1px 0 ${i.borderColor}`,Fo(r);let o=1;a(this,Dt)!==null&&(a(this,Dt).tick(performance.now()),o=a(this,Dt).current,a(this,Dt).animating?B(this,j,ne).call(this):k(this,Dt,null));const l=Math.max(1,Math.round(a(this,j,gt))),h=a(this,me);if(h.type==="candlestick")zo(r,Io(h.points,l),o);else{const d=Oi(h),c=d.length===1,u=a(this,ri)>=0?a(this,ri):d.length-1;for(let f=0;f<d.length;f++){const m=Lo(d[f],l),g=f===u?o:1;h.type==="bar"?Bo(r,m,g):Po(r,m,c,g)}}e.restore(),B(this,j,js).call(this,i,t)},js=function(i,t){if(t.to<=t.from)return;const e=a(this,et).getVisibleRange(),s=Math.max(t.from,Math.min(t.to,e.from)),n=Math.max(t.from,Math.min(t.to,e.to)),r=a(this,te).timeToX(s),o=a(this,te).timeToX(n),l=Math.min(r,o),h=Math.max(r,o),d=Math.max(1,h-l);a(this,re).style.width=`${l}px`,a(this,re).style.background=i.mask.fill,a(this,re).style.display=l>0?"block":"none";const c=Math.max(0,a(this,j,gt)-(l+d));a(this,Nt).style.left=`${l+d}px`,a(this,Nt).style.width=`${c}px`,a(this,Nt).style.background=i.mask.fill,a(this,Nt).style.display=c>0?"block":"none",a(this,$t).style.left=`${l}px`,a(this,$t).style.width=`${d}px`,a(this,$t).style.background=i.window.fill,a(this,$t).style.border=i.window.borderWidth>0?`${i.window.borderWidth}px solid ${i.window.border}`:"none";const u=i.handle.width,f=Math.max(1,u/2),m=a(this,et).getTheme().background;a(this,Ot).style.left=`${l-u/2}px`,a(this,Ot).style.width=`${u}px`,a(this,Ot).style.background=i.handle.color,a(this,Ot).style.borderRadius=`${f}px`,a(this,Ht).style.left=`${l+d-u/2}px`,a(this,Ht).style.width=`${u}px`,a(this,Ht).style.background=i.handle.color,a(this,Ht).style.borderRadius=`${f}px`;for(const g of a(this,Ot).children)g.style.background=m;for(const g of a(this,Ht).children)g.style.background=m},xe=function(){const i=a(this,me);let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY,s=0;if(i.type==="candlestick")s=i.points.length,s>0&&(t=i.points[0].time,e=i.points[s-1].time);else for(const r of Oi(i))r.length!==0&&(s+=r.length,r[0].time<t&&(t=r[0].time),r[r.length-1].time>e&&(e=r[r.length-1].time));if(s>=2&&e>t)return{from:t,to:e};if(s===1)return{...a(this,et).getVisibleRange()};const n=a(this,et).getDataRange();return n&&n.to>n.from?n:{...a(this,et).getVisibleRange()}},_s=function(){const i=a(this,me);let t=1/0,e=-1/0;if(i.type==="candlestick")for(const n of i.points)n.low<t&&(t=n.low),n.high>e&&(e=n.high);else for(const n of Oi(i))for(const r of n)r.value<t&&(t=r.value),r.value>e&&(e=r.value);if(!Number.isFinite(t)||!Number.isFinite(e))return{min:0,max:1};if(t===e){const n=Math.abs(t)*.05||1;return{min:t-n,max:e+n}}const s=(e-t)*.2;return{min:t-s,max:e+s}};function Oi(i){return"series"in i?i.series:[i.points]}function Vo(i){if(i.type==="candlestick"){const n=i.points.length;return n===0?null:{time:i.points[n-1].time,seriesIndex:-1}}const t="series"in i?i.series:[i.points];let e=null,s=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r.length===0)continue;const o=r[r.length-1].time;(e===null||o>e)&&(e=o,s=n)}return e===null?null:{time:e,seriesIndex:s}}function Cn(i,t){return i==="resize-left"||i==="resize-right"?"ew-resize":t?"grabbing":"grab"}function Os(i,t){return Cn(Yo(i,t),!1)}function Yo(i,t){return yn(i,t).gesture}function Hs(){const i=document.createElement("div");i.style.cssText="position:absolute;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;";for(let t=0;t<3;t++){const e=document.createElement("div");e.style.cssText="width:2px;height:2px;border-radius:50%;flex-shrink:0;",i.appendChild(e)}return i}const Ji=new WeakMap;function Tn(i,t){var e;return(e=Ji.get(i))==null?void 0:e.get(t)}function Rn(i,t,e){let s=Ji.get(i);s||(s=new Map,Ji.set(i,s)),s.set(t,e)}function Ns(i){return"close"in i?i.close:i.value}function Ln(i,t){if(t==="none"||i.length<=1)return i;const e=[...i];return e.sort((s,n)=>{const r=Ns(s.data),o=Ns(n.data);return t==="asc"?r-o:o-r}),e}function Li(i){const t=Object.freeze({...i.data}),e={id:i.id,seriesId:i.seriesId,layerIndex:i.layerIndex,label:i.label,data:t,color:i.color};return Object.freeze(e)}function cs(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Tn(i,t.cacheKey);if(n&&n.version===s&&n.time===t.time&&n.sort===e)return n.data;const r=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l);if(i.getSeriesLayers(l)!==null){const c=i.getLayerSnapshots(l,t.time);if(!c)continue;for(const u of c)r.push(Li({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const d=i.getDataAtTime(l,t.time);d&&r.push(Li({id:l,seriesId:l,label:h,data:d,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Ln(r,e));return Rn(i,t.cacheKey,{version:s,time:t.time,sort:e,data:o}),o}function In(i,t){const e=t.sort??"none",s=i.getOverlayVersion(),n=Tn(i,t.cacheKey);if(n&&n.version===s&&n.time===null&&n.sort===e)return n.data;const r=[];for(const l of i.getSeriesIds()){if(!i.isSeriesVisible(l))continue;const h=i.getSeriesLabel(l),d=i.getLayerLastSnapshots(l);if(d){for(const u of d)r.push(Li({id:`${l}_layer${u.layerIndex}`,seriesId:l,layerIndex:u.layerIndex,label:h,data:{time:u.time,value:u.value},color:u.color}));continue}const c=i.getLastData(l);c&&r.push(Li({id:l,seriesId:l,label:h,data:c,color:i.getSeriesColor(l)??"#888"}))}const o=Object.freeze(Ln(r,e));return Rn(i,t.cacheKey,{version:s,time:null,sort:e,data:o}),o}const jo={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:E("#26a69a"),wick:"#26a69a"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(120, 123, 134, 0.18)",line:{color:"#787b86",width:1,areaTopColor:"rgba(120, 123, 134, 0.22)",areaBottomColor:"rgba(120, 123, 134, 0)"},candlestick:{up:{body:E("#26a69a"),wick:"#26a69a"},down:{body:E("#ef5350"),wick:"#ef5350"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(255, 255, 255, 0.30)",width:6},mask:{fill:"rgba(19, 23, 34, 0.78)"}}},_o={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:E("#089981"),wick:"#089981"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(139, 148, 158, 0.22)",line:{color:"#8b949e",width:1,areaTopColor:"rgba(139, 148, 158, 0.18)",areaBottomColor:"rgba(139, 148, 158, 0)"},candlestick:{up:{body:E("#089981"),wick:"#089981"},down:{body:E("#f23645"),wick:"#f23645"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0, 0, 0, 0.30)",width:6},mask:{fill:"rgba(255, 255, 255, 0.82)"}}},Oo=J({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{up:{body:E("#96e072"),wick:"#96e072"},down:{body:E("#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:un},fontUrl:dn}),Ho=J({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{up:{body:E("#bae67e"),wick:"#bae67e"},down:{body:E("#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:Di},fontUrl:rs}),No=J({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{up:{body:E("#50fa7b"),wick:"#50fa7b"},down:{body:E("#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:os},fontUrl:as}),$o=J({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:E("#2da44e"),wick:"#2da44e"},down:{body:E("#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:ls},fontUrl:hs}),Xo=J({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{up:{body:E("#b8bb26"),wick:"#b8bb26"},down:{body:E("#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:Ai},fontUrl:Wi}),Uo={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:bo,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:po,fontSize:15},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#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)"},navigator:{height:48,background:"transparent",borderColor:"rgba(106,143,160,0.22)",line:{color:"#92806c",width:1,areaTopColor:"rgba(146,128,108,0.18)",areaBottomColor:"rgba(146,128,108,0)"},candlestick:{up:{body:E("#7a9a5e"),wick:"#7a9a5e"},down:{body:E("#b07060"),wick:"#b07060"}},window:{fill:"transparent",border:"transparent",borderWidth:0},handle:{color:"rgba(0,0,0,0.30)",width:6},mask:{fill:"rgba(253,245,230,0.78)"}}}},Go="'Silkscreen', cursive",Ko="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",qo=J({name:"Matrix",background:"#000000",candlestick:{up:{body:E("#00ff41"),wick:"#00ff41"},down:{body:E("#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:Go},fontUrl:Ko,chartGradient:["#010a01","#000000"]}),Jo=J({name:"Lavender Mist",background:"#f5f0f4",candlestick:{up:{body:E("#6b8e5e"),wick:"#6b8e5e"},down:{body:E("#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:ls},fontUrl:hs,chartGradient:["#f8f4f7","#f5f0f4"]}),Qo=J({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{up:{body:E("#6a9a6e"),wick:"#6a9a6e"},down:{body:E("#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:Di},fontUrl:rs}),Zo=J({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{up:{body:E("#c3e88d"),wick:"#c3e88d"},down:{body:E("#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:un},fontUrl:dn}),ta="'Silkscreen', cursive",ea="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",ia=J({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:E("#111111"),wick:"#111111"},down:{body:E("#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:ta},fontUrl:ea}),sa=J({name:"Mint Breeze",background:"#f6f5ee",candlestick:{up:{body:E("#2e9070"),wick:"#2e9070"},down:{body:E("#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:go},fontUrl:mo,chartGradient:["#f8f7f0","#f6f5ee"]}),na=J({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{up:{body:E("#8ab862"),wick:"#8ab862"},down:{body:E("#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:os},fontUrl:as}),ra=J({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{up:{body:E("#7ec699"),wick:"#7ec699"},down:{body:E("#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:"#4d5a6c"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Ai},fontUrl:Wi}),oa=J({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{up:{body:E("#98c379"),wick:"#98c379"},down:{body:E("#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:Ai},fontUrl:Wi}),aa=J({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{up:{body:E("#19f9d8"),wick:"#19f9d8"},down:{body:E("#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:os},fontUrl:as}),la=J({name:"Peach Cream",background:"#fef6f0",candlestick:{up:{body:E("#5a9a68"),wick:"#5a9a68"},down:{body:E("#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:ls},fontUrl:hs,chartGradient:["#fff8f2","#fef6f0"]}),ha=J({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",chartGradient:["#fdfdfd","#f5f5f5"],grid:{color:"rgba(200,200,200,0.5)"},candlestick:{up:{body:E("#448c27"),wick:"#448c27"},down:{body:E("#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:uo},fontUrl:fo}),ca=J({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{up:{body:E("#56949f"),wick:"#56949f"},down:{body:E("#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:fn},fontUrl:gn}),ua=J({name:"Sand Dune",background:"#f4f0e8",candlestick:{up:{body:E("#5a8a50"),wick:"#5a8a50"},down:{body:E("#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:fn},fontUrl:gn,chartGradient:["#f8f4ec","#f4f0e8"]}),da=J({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:E("#859900"),wick:"#859900"},down:{body:E("#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:Ai},fontUrl:Wi});function hi(i){const{x:t,y:e,chartWidth:s,chartHeight:n,tooltipWidth:r,tooltipHeight:o,offsetX:l=16,offsetY:h=16}=i,d=t+l+r>s?t-l-r:t+l,c=e+h+o>n?e-h-o:e+h,u=Math.max(0,s-r),f=Math.max(0,n-o);return{left:Math.max(0,Math.min(u,d)),top:Math.max(0,Math.min(f,c))}}const Le=A.createContext(null);function lt(){const i=A.useContext(Le);if(!i)throw new Error("useChartInstance must be used within <ChartContainer>");return i}const fa=20;function An({data:i,options:t,id:e}){var h;const s=lt(),n=A.useRef(null),r=A.useRef([]),o=A.useRef([]),l=A.useRef([]);return A.useLayoutEffect(()=>{const d=s.addBarSeries({...t,layers:i.length,id:e});return n.current=d,r.current=new Array(i.length).fill(0),o.current=new Array(i.length).fill(null),l.current=new Array(i.length).fill(null),()=>{s.removeSeries(d),n.current=null,r.current=[],o.current=[],l.current=[]}},[s,i.length,e]),A.useLayoutEffect(()=>{const d=n.current;d&&s.batch(()=>{for(let c=0;c<i.length;c++){const u=i[c],f=r.current[c]??0,m=o.current[c]??null;if(u.length===0){s.setSeriesData(d,[],c),r.current[c]=0,o.current[c]=null,l.current[c]=null;continue}const g=ct(u[0].time),p=ct(u[u.length-1].time),v=l.current[c]??null,w=m!==null&&m!==g,x=u.length-f;if(w&&x===0&&(v!==null&&v!==p))s.setSeriesData(d,u.slice(0,-1),c),s.appendData(d,u[u.length-1],c);else if(f===0||u.length<f||x>fa||w)s.setSeriesData(d,u,c);else if(u.length===f)s.updateData(d,u[u.length-1],c);else for(let M=f;M<u.length;M++)s.appendData(d,u[M],c);r.current[c]=u.length,o.current[c]=g,l.current[c]=p}})},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(h=t==null?void 0:t.colors)==null?void 0:h.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 ga=20;function ma({data:i,options:t,id:e}){var h,d,c,u,f,m;const s=lt(),n=A.useRef(null),r=A.useRef(0),o=A.useRef(null),l=A.useRef(null);return A.useLayoutEffect(()=>{const g=s.addCandlestickSeries({...t,id:e});return n.current=g,()=>{s.removeSeries(g),n.current=null,r.current=0,o.current=null,l.current=null}},[s,e]),A.useLayoutEffect(()=>{const g=n.current;if(!g)return;if(i.length===0){s.setSeriesData(g,[]),r.current=0,o.current=null,l.current=null;return}const p=r.current,v=o.current,w=l.current,x=ct(i[0].time),y=ct(i[i.length-1].time),M=v!==null&&v!==x,S=i.length-p;if(M&&S===0&&(w!==null&&w!==y))s.setSeriesData(g,i.slice(0,-1)),s.appendData(g,i[i.length-1]);else if(p===0||i.length<p||S>ga||M)s.setSeriesData(g,i);else if(i.length===p)s.updateData(g,i[i.length-1]);else for(let b=p;b<i.length;b++)s.appendData(g,i[b]);r.current=i.length,o.current=x,l.current=y},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,Array.isArray((h=t==null?void 0:t.up)==null?void 0:h.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 us=A.createContext(null),Ie=us.Provider;function ci(){const i=A.useContext(us);if(!i)throw new Error("useTheme must be used within <ThemeProvider>");return i}function pa(){return A.useContext(us)}function Fi(i,t,e){const s=Array.isArray(t)?t:[t];return{subscribe:n=>{const r=n;for(const o of s)i.on(o,r);return()=>{for(const o of s)i.off(o,r)}},getSnapshot:e}}function Wn(i){const t=A.useMemo(()=>Fi(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getVisibleRange()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Dn(i){const t=A.useMemo(()=>Fi(i,["viewportChange","dataUpdate","seriesChange"],()=>i.getYRange()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}function ba(i,t){const e=A.useMemo(()=>{let s=i.getLastValue(t),n=s?i.yScale.valueToY(s.value):null;const r=()=>s,o=()=>{const l=i.getLastValue(t),h=l?i.yScale.valueToY(l.value):null;return(s==null?void 0:s.value)===(l==null?void 0:l.value)&&(s==null?void 0:s.isLive)===(l==null?void 0:l.isLive)&&n===h?!1:(s=l,n=h,!0)};return{subscribe:l=>{o();const h=()=>{o()&&l()};return i.on("dataUpdate",h),i.on("viewportChange",h),()=>{i.off("dataUpdate",h),i.off("viewportChange",h)}},getSnapshot:r}},[i,t]);return A.useSyncExternalStore(e.subscribe,e.getSnapshot)}function va(i,t){const e=A.useMemo(()=>Fi(i,"dataUpdate",()=>i.getPreviousClose(t)),[i,t]);return A.useSyncExternalStore(e.subscribe,e.getSnapshot)}function ui(i){const t=A.useMemo(()=>Fi(i,"crosshairMove",()=>i.getCrosshairPosition()),[i]);return A.useSyncExternalStore(t.subscribe,t.getSnapshot)}const ya=(i,t)=>t==="volume"?ae(i):is(i);function Fn({sort:i="none",format:t=ya,children:e}){const s=lt(),n=ci(),r=ui(s),[,o]=A.useState(0);A.useLayoutEffect(()=>{const f=()=>o(m=>m+1);return s.on("overlayChange",f),s.getSeriesIds().length>0&&o(m=>m+1),()=>{s.off("overlayChange",f)}},[s]);const l=In(s,{sort:i,cacheKey:"infobar-last"});let h=l,d=l.length===0?0:Math.max(...l.map(f=>f.data.time)),c=!1;if(r!==null){const f=cs(s,{time:r.time,sort:i,cacheKey:"infobar-hover"});f.length>0&&(h=f,d=r.time,c=!0)}if(h.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:h,time:d,isHover:c})});const u=s.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:li(d,u)}),h.map(f=>{if("open"in f.data){const p=f.data,v=p.close>=p.open,w=pt(v?n.candlestick.up.body:n.candlestick.down.body);return C.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[C.jsx(Ye,{label:"O",display:t(p.open,"open"),color:w,dim:n.axis.textColor}),C.jsx(Ye,{label:"H",display:t(p.high,"high"),color:w,dim:n.axis.textColor}),C.jsx(Ye,{label:"L",display:t(p.low,"low"),color:w,dim:n.axis.textColor}),C.jsx(Ye,{label:"C",display:t(p.close,"close"),color:w,dim:n.axis.textColor}),p.volume!=null&&C.jsx(Ye,{label:"V",display:t(p.volume,"volume"),color:n.axis.textColor,dim:n.axis.textColor})]},f.id)}const g=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(g.value,"value")})]},f.id)})]})}function Ye({label:i,display:t,color:e,dim:s}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{color:s,opacity:.5,marginLeft:5},children:i}),C.jsx("span",{style:{color:e,fontWeight:500,marginLeft:2},children:t})]})}function xa({chart:i,isolatedIdRef:t,setIsolatedId:e}){const s=[],n=i.getSeriesIds();for(const r of n){const o=i.getSeriesLayers(r);if(o){const l=i.getSeriesLabel(r);for(let h=0;h<o.length;h++){const d=`${r}_layer${h}`,c=i.isSeriesVisible(r)&&i.isLayerVisible(r,h);s.push($s({id:d,seriesId:r,layerIndex:h,label:l?`${l} ${h+1}`:`Series ${h+1}`,color:o[h].color,isDisabled:!c,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}else{const l=i.getSeriesColor(r);if(!l)continue;const h=i.getSeriesLabel(r),d=i.isSeriesVisible(r);s.push($s({id:r,seriesId:r,layerIndex:void 0,label:h??"Series",color:l,isDisabled:!d,chart:i,isolatedIdRef:t,setIsolatedId:e}))}}return s}function $s(i){const{id:t,seriesId:e,layerIndex:s,label:n,color:r,isDisabled:o,chart:l,isolatedIdRef:h,setIsolatedId:d}=i;return{id:t,seriesId:e,layerIndex:s,label:n,color:r,isDisabled:o,toggle:()=>{s!==void 0?l.setLayerVisible(e,s,!l.isLayerVisible(e,s)):l.setSeriesVisible(e,!l.isSeriesVisible(e))},isolate:()=>{if(h.current===t){l.batch(()=>{for(const f of l.getSeriesIds()){l.setSeriesVisible(f,!0);const m=l.getSeriesLayers(f);if(m)for(let g=0;g<m.length;g++)l.setLayerVisible(f,g,!0)}}),h.current=null,d(null);return}l.batch(()=>{for(const f of l.getSeriesIds()){const m=l.getSeriesLayers(f);if(m){l.setSeriesVisible(f,f===e);for(let g=0;g<m.length;g++)l.setLayerVisible(f,g,f===e&&g===s)}else l.setSeriesVisible(f,f===t)}}),h.current=t,d(t)}}}function Pn({items:i,position:t="bottom",mode:e="toggle",children:s}){const n=lt(),r=ci(),[o,l]=A.useState(null),[h,d]=A.useState(0),c=A.useRef(o);c.current=o,A.useLayoutEffect(()=>{const p=()=>d(w=>w+1),v=()=>l(null);return n.on("overlayChange",p),n.on("seriesChange",v),n.getSeriesIds().length>0&&d(w=>w+1),()=>{n.off("overlayChange",p),n.off("seriesChange",v)}},[n]);const u=A.useMemo(()=>xa({chart:n,isolatedIdRef:c,setIsolatedId:l}),[n,o,h]),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(s)return u.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:s({items:u})});if(i)return i.length===0?null:C.jsx("div",{"data-legend":t,style:m,children:i.map((p,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:p.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:p.label})]},v))});if(u.length===0)return null;const g=p=>{e==="isolate"||e==="solo"?p.isolate():p.toggle()};return C.jsx("div",{"data-legend":t,style:m,children:u.map(p=>C.jsxs("div",{onClick:()=>g(p),style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",opacity:p.isDisabled?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:p.color,flexShrink:0}}),C.jsx("span",{style:{whiteSpace:"nowrap"},children:p.label})]},p.id))})}function Bn({data:i,height:t,style:e,className:s}){const n=lt(),r=ci(),o=A.useRef(null),l=A.useRef(null);A.useLayoutEffect(()=>{if(!o.current)return;const d=new kn({container:o.current,chart:n,data:i,options:t!==void 0?{height:t}:void 0});return l.current=d,()=>{d.destroy(),l.current=null}},[n]),A.useEffect(()=>{var d;(d=l.current)==null||d.setData(i)},[i]),A.useEffect(()=>{var d;(d=l.current)==null||d.setOptions(t!==void 0?{height:t}:{})},[t]);const h=t??r.navigator.height;return C.jsx("div",{ref:o,className:s,"data-chart-navigator":"",style:{position:"relative",width:"100%",height:h,flexShrink:0,...e}})}function wa(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}function zn({seriesId:i,mode:t,format:e,position:s,children:n}){const r=t??"both",o=s??"bottom",l=e??ae,h=lt(),d=h.getTheme(),[,c]=A.useState(0);A.useLayoutEffect(()=>{const g=()=>c(p=>p+1);return h.on("overlayChange",g),h.getSeriesIds().length>0&&g(),()=>{h.off("overlayChange",g)}},[h]);const u=wa(h,i),f=u!==null?h.getSliceInfo(u):null;if(!f||f.length===0)return null;if(n)return C.jsx(C.Fragment,{children:n({slices:f,mode:r,format:l})});const m=o==="overlay";return C.jsx("div",{"data-chart-pie-legend":"","data-chart-pie-legend-position":o,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((g,p)=>C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:g.color,flexShrink:0}}),C.jsx("span",{style:{flex:1,opacity:.8},children:g.label}),(r==="value"||r==="both")&&C.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums",minWidth:r==="value"?40:void 0,textAlign:"right"},children:l(g.value)}),(r==="percent"||r==="both")&&C.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:[g.percent.toFixed(1),"%"]})]},p))})}function En({children:i,sub:t,style:e}){const s=ci();return C.jsxs("div",{"data-chart-title":"",style:{display:"flex",alignItems:"baseline",gap:6,padding:"6px 8px 4px",flexShrink:0,fontFamily:s.typography.fontFamily,fontSize:s.typography.fontSize,fontWeight:600,color:s.tooltip.textColor,pointerEvents:"none",...e},children:[i!=null&&i!==!1&&C.jsx("span",{children:i}),t!=null&&t!==!1&&C.jsx("span",{style:{fontWeight:400,color:s.axis.textColor,fontSize:s.axis.fontSize},children:t})]})}function Sa(i){let t=null,e=null,s=null,n=null,r=null;const o=[],l=h=>{if(A.isValidElement(h)&&h.type===A.Fragment){A.Children.forEach(h.props.children,l);return}if(A.isValidElement(h)){if(h.type===En){t=h;return}if(h.type===Pn){e=h;return}if(h.type===zn){const d=h;d.props.position==="overlay"?o.push(h):s=d;return}if(h.type===Fn){n=h;return}if(h.type===Bn){r=h;return}}o.push(h)};return A.Children.forEach(i,l),{titleEl:t,legendEl:e,pieLegendEl:s,tooltipLegendEl:n,navigatorEl:r,overlay:o}}function Vn({children:i,theme:t,axis:e,padding:s,gradient:n=!0,interactive:r,grid:o,headerLayout:l="overlay",perf:h,animations:d,style:c,className:u}){var Pt,Mt,Gt,Be,di,fi;const f=A.useRef(h),m=pa(),g=t??m??void 0,p=A.useRef(null),v=A.useRef(null),[w,x]=A.useState(0);A.useLayoutEffect(()=>{if(!p.current||v.current)return;const st={};return e&&(st.axis=e),g&&(st.theme=g),s&&(st.padding=s),r!==void 0&&(st.interactive=r),o!==void 0&&(st.grid=o),f.current!==void 0&&(st.perf=f.current),d!==void 0&&(st.animations=d),v.current=new vn(p.current,st),x(ft=>ft+1),()=>{var ft;(ft=v.current)==null||ft.destroy(),v.current=null}},[]),A.useEffect(()=>{v.current&&g&&v.current.setTheme(g)},[g]),A.useEffect(()=>{v.current&&e&&v.current.setAxis(e)},[(Pt=e==null?void 0:e.y)==null?void 0:Pt.width,(Mt=e==null?void 0:e.y)==null?void 0:Mt.min,(Gt=e==null?void 0:e.y)==null?void 0:Gt.max,(Be=e==null?void 0:e.y)==null?void 0:Be.visible,(di=e==null?void 0:e.x)==null?void 0:di.height,(fi=e==null?void 0:e.x)==null?void 0:fi.visible]),A.useEffect(()=>{v.current&&d!==void 0&&v.current.setAnimations(d)},[JSON.stringify(d)]);const y=A.useRef(null),[M,S]=A.useState(0),P=l==="overlay"?M:0;A.useEffect(()=>{const st=v.current;if(!st)return;const Kt={top:((s==null?void 0:s.top)??20)+P,...(s==null?void 0:s.bottom)!==void 0?{bottom:s.bottom}:{},...(s==null?void 0:s.right)!==void 0?{right:s.right}:{},...(s==null?void 0:s.left)!==void 0?{left:s.left}:{}};st.setPadding(Kt)},[s==null?void 0:s.top,s==null?void 0:s.bottom,typeof(s==null?void 0:s.right)=="object"?s.right.intervals:s==null?void 0:s.right,typeof(s==null?void 0:s.left)=="object"?s.left.intervals:s==null?void 0:s.left,P]),A.useEffect(()=>{v.current&&o!==void 0&&v.current.setGrid(o)},[o==null?void 0:o.visible]);const b=v.current,{titleEl:L,legendEl:I,pieLegendEl:T,tooltipLegendEl:D,navigatorEl:F,overlay:V}=Sa(i),z=(I==null?void 0:I.props.position)??"bottom",_=(T==null?void 0:T.props.position)??"bottom",$=z==="right"||_==="right",H=g??(b==null?void 0:b.getTheme()),[it,U]=(H==null?void 0:H.chartGradient)??["transparent","transparent"],bt=(H==null?void 0:H.background)??"transparent",vt=n?`linear-gradient(to bottom, ${it} 0%, ${bt} 70%, ${U} 100%)`:bt;A.useLayoutEffect(()=>{if(l!=="overlay"){S(0);return}const st=y.current;if(!st){S(0);return}const ft=()=>S(st.getBoundingClientRect().height);ft();const Kt=new ResizeObserver(ft);return Kt.observe(st),()=>Kt.disconnect()},[L!==null,D!==null,l,b!==null]);const St=(L||D)&&C.jsxs("div",{"data-chart-header":"","data-chart-top-overlay":l==="overlay"?"":void 0,ref:y,style:l==="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:[L,D]}),Q=C.jsx("div",{ref:p,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:b&&C.jsx(Le.Provider,{value:b,children:C.jsxs(Ie,{value:g??b.getTheme(),children:[l==="overlay"&&St,C.jsx("div",{"data-chart-series-overlay":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3},children:V})]})})}),Ut=l==="inline"?C.jsxs("div",{"data-chart-canvas-block":"",style:{display:"flex",flexDirection:"column",flex:1,minWidth:0,minHeight:0},children:[b&&St&&C.jsx(Le.Provider,{value:b,children:C.jsx(Ie,{value:g??b.getTheme(),children:St})}),Q]}):Q,yt=b&&I&&C.jsx(Le.Provider,{value:b,children:C.jsx(Ie,{value:g??b.getTheme(),children:I})}),ut=b&&T&&C.jsx(Le.Provider,{value:b,children:C.jsx(Ie,{value:g??b.getTheme(),children:T})}),dt=b&&F&&C.jsx(Le.Provider,{value:b,children:C.jsx(Ie,{value:g??b.getTheme(),children:F})});return C.jsxs("div",{className:u,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",background:vt,...c},children:[C.jsxs("div",{style:{display:"flex",flexDirection:$?"row":"column",flex:1,minHeight:0,minWidth:0},children:[Ut,yt,ut]}),dt]})}const Ma=20;function Yn({data:i,options:t,id:e}){var h,d;const s=lt(),n=A.useRef(null),r=A.useRef([]),o=A.useRef([]),l=A.useRef([]);return A.useLayoutEffect(()=>{const c=s.addLineSeries({...t,layers:i.length,id:e});return n.current=c,r.current=new Array(i.length).fill(0),o.current=new Array(i.length).fill(null),l.current=new Array(i.length).fill(null),()=>{s.removeSeries(c),n.current=null,r.current=[],o.current=[],l.current=[]}},[s,i.length,e]),A.useLayoutEffect(()=>{const c=n.current;c&&s.batch(()=>{for(let u=0;u<i.length;u++){const f=i[u],m=r.current[u]??0,g=o.current[u]??null;if(f.length===0){s.setSeriesData(c,[],u),r.current[u]=0,o.current[u]=null,l.current[u]=null;continue}const p=ct(f[0].time),v=ct(f[f.length-1].time),w=l.current[u]??null,x=g!==null&&g!==p,y=f.length-m;if(x&&y===0&&(w!==null&&w!==v))s.setSeriesData(c,f.slice(0,-1),u),s.appendData(c,f[f.length-1],u);else if(m===0||f.length<m||y>Ma||x)s.setSeriesData(c,f,u);else if(f.length===m)s.updateData(c,f[f.length-1],u);else for(let S=m;S<f.length;S++)s.appendData(c,f[S],u);r.current[u]=f.length,o.current[u]=p,l.current[u]=v}})},[s,i]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,(h=t==null?void 0:t.colors)==null?void 0:h.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 ka({data:i,options:t,id:e}){var r,o,l,h,d,c,u,f,m,g;const s=lt(),n=A.useRef(null);return A.useLayoutEffect(()=>{const p=s.addPieSeries({...t,id:e});return n.current=p,()=>{s.removeSeries(p),n.current=null}},[s,e]),A.useEffect(()=>{n.current&&t&&s.updateSeriesOptions(n.current,t)},[s,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,(o=t==null?void 0:t.sliceLabels)==null?void 0:o.content,(l=t==null?void 0:t.sliceLabels)==null?void 0:l.fontSize,(h=t==null?void 0:t.sliceLabels)==null?void 0:h.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,(g=t==null?void 0:t.sliceLabels)==null?void 0:g.balanceSides]),A.useLayoutEffect(()=>{n.current&&s.setSeriesData(n.current,i)},[s,i]),null}function Ca(){const i=lt(),t=ui(i);if(!t)return null;const e=i.getTheme(),s=i.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 C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...n},children:i.yScale.formatY(t.y)}),C.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...n},children:li(t.time,s)})]})}const Ta=["0","1","2","3","4","5","6","7","8","9"];function Ra(i){const t=[];for(const e of i)e>="0"&&e<="9"?t.push({type:"digit",value:e}):t.push({type:"symbol",value:e});return t}function jn({value:i,format:t,locale:e="en-US",spinDuration:s=350,className:n,style:r}){const l=A.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])(i),h=Ra(l);return C.jsx("span",{className:n,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...r},children:h.map((d,c)=>d.type==="digit"?C.jsx(La,{digit:parseInt(d.value,10),duration:s},`d${c}`):C.jsx("span",{style:{display:"inline-block"},children:d.value},`s${c}`))})}function La({digit:i,duration:t}){const e=A.useRef(!1);return A.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(${-i*1.2}em)`,transition:e.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:Ta.map(s=>C.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:s},s))})})}function Ia(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("pie",{visibleOnly:!0});return e.length>0?e[0]:null}const Aa=160,Wa=70;function Da({seriesId:i,format:t=ae,children:e}){const s=lt(),n=ui(s),[,r]=A.useState(0);A.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return s.on("overlayChange",f),()=>{s.off("overlayChange",f)}},[s]);const o=Ia(s,i),l=o!==null?s.getHoverInfo(o):null;if(!l||!n)return null;const h=s.getTheme(),d=s.getMediaSize();if(e)return C.jsx(Fa,{x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,children:e({info:l,format:t})});const{left:c,top:u}=hi({x:n.mediaX,y:n.mediaY,chartWidth:d.width,chartHeight:d.height,tooltipWidth:Aa,tooltipHeight:Wa,offsetX:16,offsetY:16});return C.jsxs("div",{style:{position:"absolute",left:c,top:u,pointerEvents:"none",zIndex:10,background:h.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${h.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:h.typography.fontSize,fontFamily:h.typography.fontFamily,color:h.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:l.color,flexShrink:0}}),C.jsx("span",{style:{fontWeight:600},children:l.label})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[C.jsx("span",{style:{opacity:.6},children:t(l.value)}),C.jsxs("span",{style:{fontWeight:600},children:[l.percent.toFixed(1),"%"]})]})]})}function Fa({x:i,y:t,chartWidth:e,chartHeight:s,children:n}){const r=A.useRef(null),[o,l]=A.useState(null);A.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&&l(g=>g&&g.width===f.width&&g.height===f.height?g:{width:f.width,height:f.height})});return c.observe(d),()=>c.disconnect()},[]);const h=o?hi({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:o.width,tooltipHeight:o.height,offsetX:16,offsetY:16}):{left:0,top:0};return C.jsx("div",{ref:r,"data-measured":o?"true":"false",style:{position:"absolute",left:h.left,top:h.top,pointerEvents:"none",zIndex:10,width:"max-content",maxWidth:e,boxSizing:"border-box",visibility:o?"visible":"hidden"},children:n})}function Pa(i,t){if(i.startsWith("rgba")||!i.startsWith("#"))return i;const e=parseInt(i.slice(1,3),16),s=parseInt(i.slice(3,5),16),n=parseInt(i.slice(5,7),16);return`rgba(${e}, ${s}, ${n}, ${t})`}function Ba(i){if(i.length<2)return{value:0,pct:0,positive:!0};const t=i[0].value,s=i[i.length-1].value-t,n=t!==0?s/t*100:0;return{value:s,pct:n,positive:s>=0}}function za({data:i,theme:t,variant:e="line",valuePosition:s="right",formatValue:n=ae,label:r,sublabel:o,color:l,negativeColor:h,area:d,areaFill:c,width:u=140,height:f=48,strokeWidth:m=1.5,gradient:g=!0,style:p}){const v=(d==null?void 0:d.visible)??c??!0,w=i.length>0?i[i.length-1].value:0,x=A.useMemo(()=>Ba(i),[i]),y=l??t.seriesColors[0],M=h??pt(t.candlestick.down.body),S=pt(x.positive?t.candlestick.up.body:t.candlestick.down.body),P=s!=="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.axis.fontSize,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(w)}),o!==void 0?C.jsx("div",{style:{fontSize:t.axis.fontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:o}):C.jsxs("div",{style:{fontSize:t.axis.fontSize-1,fontWeight:500,color:S,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[x.positive?"+":"",x.pct.toFixed(1),"%"]})]}),b=C.jsx("div",{style:{width:u,height:f,flexShrink:0,borderRadius:4,overflow:"hidden"},children:C.jsx(Vn,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:g,interactive:!1,grid:{visible:!1},children:e==="line"?C.jsx(Yn,{data:[i],options:{colors:[y],strokeWidth:m,area:{visible:v},pulse:!1,stacking:"off"}}):C.jsx(An,{data:[i],options:{colors:[y,M],barWidthRatio:.7,stacking:"off"}})})});return C.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:Pa(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...p},children:[s==="left"&&P,b,s==="right"&&P]})}const _n=250,On=`opacity ${_n/1e3}s ease`,Hn=_n*2;function Nn({labelCount:i,minLabelSpacing:t}={}){const e=lt();Wn(e),A.useLayoutEffect(()=>(e.setTimeAxisLabelDensity({labelCount:i??null,minLabelSpacing:t??null}),()=>{e.setTimeAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[e,i,t]);const s=e.getTheme(),n=e.getDataInterval(),{ticks:r,tickInterval:o}=e.timeScale.niceTickValues(n),l=new Set(r),d=A.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)l.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>Hn&&d.delete(f);const u=Array.from(d.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:u.map(([f,m])=>{const g=e.timeScale.timeToX(f);return C.jsx("span",{style:{position:"absolute",left:g,transform:"translateX(-50%)",color:ns(s,"x"),fontSize:ss(s,"x"),fontFamily:s.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:m.opacity,transition:On,willChange:"opacity"},children:li(f,o)},f)})})}const Ea=(i,t)=>t==="volume"?ae(i):is(i);function Va({sort:i="none",format:t=Ea,children:e}){const s=lt(),n=ui(s),[,r]=A.useState(0);if(A.useLayoutEffect(()=>{const f=()=>r(m=>m+1);return s.on("overlayChange",f),s.getSeriesIds().length>0&&r(m=>m+1),()=>{s.off("overlayChange",f)}},[s]),!n)return null;const o=cs(s,{time:n.time,sort:i,cacheKey:"tooltip"});if(o.length===0)return null;const l=s.getTheme(),h=s.getDataInterval(),d=s.getMediaSize(),c=d.width-s.yAxisWidth,u=d.height-s.xAxisHeight;return e?C.jsx(Ya,{x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,children:e({snapshots:o,time:n.time})}):C.jsx(ja,{snapshots:o,displayTime:n.time,x:n.mediaX,y:n.mediaY,chartWidth:c,chartHeight:u,theme:l,dataInterval:h,format:t})}function Ya({x:i,y:t,chartWidth:e,chartHeight:s,theme:n,children:r}){const o=A.useRef(null),[l,h]=A.useState(null);A.useEffect(()=>{const c=o.current;if(!c||typeof ResizeObserver>"u")return;const u=new ResizeObserver(f=>{var g;const m=(g=f[0])==null?void 0:g.contentRect;m&&h(p=>p&&p.width===m.width&&p.height===m.height?p:{width:m.width,height:m.height})});return u.observe(c),()=>u.disconnect()},[]);const d=l?hi({x:i,y:t,chartWidth:e,chartHeight:s,tooltipWidth:l.width,tooltipHeight:l.height}):{left:0,top:0};return C.jsx("div",{ref:o,"data-measured":l?"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:l?"visible":"hidden"},children:r})}function ja({snapshots:i,displayTime:t,x:e,y:s,chartWidth:n,chartHeight:r,theme:o,dataInterval:l,format:h}){const d=i.some(x=>"open"in x.data),c=i.filter(x=>!("open"in x.data)).length,u=160,f=d?140:40+c*22,{left:m,top:g}=hi({x:e,y:s,chartWidth:n,chartHeight:r,tooltipWidth:u,tooltipHeight:f}),p=o.tooltip.background,v=o.tooltip.borderColor;return C.jsxs("div",{style:{position:"absolute",left:m,top:g,pointerEvents:"none",background:p,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:o.tooltip.fontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,width:u,boxSizing:"border-box",zIndex:10,transition:"opacity 0.15s ease"},children:[C.jsxs("div",{style:{fontSize:o.axis.fontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${v}`,letterSpacing:"0.02em"},children:[Zs(t)," ",li(t,l)]}),i.map(x=>{if("open"in x.data){const S=x.data,P=S.close>=S.open,b=pt(P?o.candlestick.up.body:o.candlestick.down.body);return C.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[C.jsx(je,{label:"Open",color:b,display:h(S.open,"open")}),C.jsx(je,{label:"High",color:b,display:h(S.high,"high")}),C.jsx(je,{label:"Low",color:b,display:h(S.low,"low")}),C.jsx(je,{label:"Close",color:b,display:h(S.close,"close")}),S.volume!=null&&C.jsx(je,{label:"Volume",color:o.tooltip.textColor,display:h(S.volume,"volume")})]},x.id)}const M=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:h(M.value,"value")})]},x.id)})]})}function je({label:i,color:t,display:e}){return C.jsxs(C.Fragment,{children:[C.jsx("span",{style:{opacity:.5},children:i}),C.jsx("span",{style:{fontWeight:600,color:t,textAlign:"right"},children:e})]})}function _a({format:i,labelCount:t,minLabelSpacing:e}={}){const s=lt();Dn(s),A.useLayoutEffect(()=>(s.yScale.setFormat(i??null),()=>s.yScale.setFormat(null)),[s,i]),A.useLayoutEffect(()=>(s.setYAxisLabelDensity({labelCount:t??null,minLabelSpacing:e??null}),()=>{s.setYAxisLabelDensity({labelCount:null,minLabelSpacing:null})}),[s,t,e]);const n=s.getTheme(),r=s.yScale.niceTickValues(),o=new Set(r),h=A.useRef(new Map).current,d=performance.now();for(const u of r)h.has(u)?h.get(u).opacity=1:h.set(u,{opacity:1,addedAt:d});for(const[u,f]of h)o.has(u)||f.opacity!==0&&(f.opacity=0,f.fadedAt=d);for(const[u,f]of h)f.opacity===0&&f.fadedAt!==void 0&&d-f.fadedAt>Hn&&h.delete(u);const c=Array.from(h.entries());return C.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:s.xAxisHeight,width:s.yAxisWidth,pointerEvents:"none"},children:c.map(([u,f])=>{const m=s.yScale.valueToY(u);return C.jsx("span",{style:{position:"absolute",right:8,top:m,transform:"translateY(-50%)",color:ns(n,"y"),fontSize:ss(n,"y"),fontFamily:n.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:f.opacity,transition:On,willChange:"opacity"},children:s.yScale.formatY(u)},u)})})}function Oa(i,t){if(t!==void 0)return t;const e=i.getSeriesIdsByType("time",{visibleOnly:!0,singleLayerOnly:!0});if(e.length>0)return e[0];const s=i.getSeriesIdsByType("time",{visibleOnly:!0});return s.length>0?s[0]:null}function Ha({seriesId:i,color:t,format:e,children:s}){const n=lt();A.useEffect(()=>(n.setYLabel(!0),()=>n.setYLabel(!1)),[n]);const[,r]=A.useState(0);A.useLayoutEffect(()=>{const y=()=>r(M=>M+1);return n.on("overlayChange",y),n.on("viewportChange",y),n.getSeriesIds().length>0&&r(M=>M+1),()=>{n.off("overlayChange",y),n.off("viewportChange",y)}},[n]);const o=Oa(n,i),l=o!==null?n.getStackedLastValue(o):null,h=o!==null?n.getPreviousClose(o):null,d=n.yScale.getRange(),c=d.max-d.min,u=c<.1?6:c<10?4:c<1e3?2:0,f=A.useMemo(()=>{if(e)return e;const y=new Intl.NumberFormat("en-US",{minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!1});return M=>y.format(M)},[e,u]);if(!l||o===null)return null;const{value:m,isLive:g}=l,p=n.getTheme(),v=n.yScale.valueToY(m),w=h===null?"neutral":m>h?"up":m<h?"down":"neutral";let x;return g?t?x=t:x=w==="up"?p.yLabel.upBackground:w==="down"?p.yLabel.downBackground:p.yLabel.neutralBackground:x=p.axis.textColor,s?C.jsx(C.Fragment,{children:s({value:m,y:v,bgColor:x,isLive:g,direction:w,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:p.yLabel.textColor,fontSize:p.yLabel.fontSize,fontFamily:p.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:C.jsx(jn,{value:m,format:f,spinDuration:350})})]})}exports.BarSeries=An;exports.CandlestickSeries=ma;exports.ChartContainer=Vn;exports.ChartInstance=vn;exports.Crosshair=Ca;exports.InfoBar=Fn;exports.Legend=Pn;exports.LineSeries=Yn;exports.Navigator=Bn;exports.NavigatorController=kn;exports.NumberFlow=jn;exports.PieLegend=zn;exports.PieSeries=ka;exports.PieTooltip=Da;exports.Sparkline=za;exports.ThemeProvider=Ie;exports.TimeAxis=Nn;exports.Title=En;exports.Tooltip=Va;exports.XAxis=Nn;exports.YAxis=_a;exports.YLabel=Ha;exports.andromeda=Oo;exports.autoGradient=E;exports.ayuMirage=Ho;exports.buildHoverSnapshots=cs;exports.buildLastSnapshots=In;exports.catppuccin=mn;exports.computeTooltipPosition=hi;exports.createTheme=J;exports.darkTheme=jo;exports.detectInterval=Qs;exports.dracula=No;exports.formatCompact=ae;exports.formatDate=Zs;exports.formatPriceAdaptive=is;exports.formatTime=li;exports.githubLight=$o;exports.gruvbox=Xo;exports.handwritten=Uo;exports.highContrast=qo;exports.lavenderMist=Jo;exports.lightPink=Qo;exports.lightTheme=_o;exports.materialPalenight=Zo;exports.minimalLight=ia;exports.mintBreeze=sa;exports.monokaiPro=na;exports.nightOwl=ra;exports.normalizeTime=ct;exports.oneDarkPro=oa;exports.panda=aa;exports.peachCream=la;exports.quietLight=ha;exports.resolveAxisFontSize=ss;exports.resolveAxisTextColor=ns;exports.resolveCandlestickBodyColor=pt;exports.rosePineDawn=ca;exports.sandDune=ua;exports.solarizedLight=da;exports.useChartInstance=lt;exports.useCrosshairPosition=ui;exports.useLastYValue=ba;exports.usePreviousClose=va;exports.useTheme=ci;exports.useVisibleRange=Wn;exports.useYRange=Dn;
|