@wick-charts/react 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),x=require("react/jsx-runtime");var ui=Object.defineProperty,de=r=>{throw TypeError(r)},fi=(r,t,i)=>t in r?ui(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,S=(r,t,i)=>fi(r,typeof t!="symbol"?t+"":t,i),Ot=(r,t,i)=>t.has(r)||de("Cannot "+i),c=(r,t,i)=>(Ot(r,t,"read from private field"),i?i.call(r):t.get(r)),F=(r,t,i)=>t.has(r)?de("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,i),T=(r,t,i,e)=>(Ot(r,t,"write to private field"),t.set(r,i),i),Mt=(r,t,i)=>(Ot(r,t,"access private method"),i),ie=(r,t,i,e)=>({set _(a){T(r,t,a)},get _(){return c(r,t,e)}});class wt{constructor(){S(this,"listeners",new Map)}on(t,i){let e=this.listeners.get(t);e||(e=new Set,this.listeners.set(t,e)),e.add(i)}off(t,i){var e;(e=this.listeners.get(t))==null||e.delete(i)}emit(t,...i){var e;(e=this.listeners.get(t))==null||e.forEach(a=>a(...i))}removeAllListeners(){this.listeners.clear()}}function oe(r,t,i){const e=document.createElement("canvas");return e.style.position="absolute",e.style.inset="0",e.style.width="100%",e.style.height="100%",e.style.display="block",e.style.zIndex=String(t),r.appendChild(e),e}class gi extends wt{constructor(t){super(),S(this,"mainCanvas"),S(this,"mainCtx"),S(this,"overlayCanvas"),S(this,"overlayCtx"),S(this,"resizeObserver"),S(this,"_size"),S(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=oe(t,0),this.overlayCanvas=oe(t,1),this.mainCtx=this.mainCanvas.getContext("2d",{alpha:!0}),this.overlayCtx=this.overlayCanvas.getContext("2d",{alpha:!0});const i=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:i,verticalPixelRatio:i},this.resizeObserver=new ResizeObserver(a=>{this.handleResize(a[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){const a=window.devicePixelRatio||1,o=a,s=Math.round(e.width*a),n=Math.round(e.height*o);this.mainCanvas.width=s,this.mainCanvas.height=n,this.overlayCanvas.width=s,this.overlayCanvas.height=n,this._size={media:{width:e.width,height:e.height},bitmap:{width:s,height:n},horizontalPixelRatio:s/e.width,verticalPixelRatio:n/e.height}}}handleResize(t){var i,e;let a,o,s,n;if(this.supportsDevicePixelContentBox&&(i=t.devicePixelContentBoxSize)!=null&&i[0]){const d=t.devicePixelContentBoxSize[0];a=d.inlineSize,o=d.blockSize;const g=t.contentBoxSize[0];s=g.inlineSize,n=g.blockSize}else{const d=(e=t.contentBoxSize)==null?void 0:e[0];if(d)s=d.inlineSize,n=d.blockSize;else{const f=t.contentRect;s=f.width,n=f.height}const g=window.devicePixelRatio||1;a=Math.round(s*g),o=Math.round(n*g)}if(a===0||o===0)return;this.mainCanvas.width=a,this.mainCanvas.height=o,this.overlayCanvas.width=a,this.overlayCanvas.height=o;const l=a/s,h=o/n;this._size={media:{width:s,height:n},bitmap:{width:a,height:o},horizontalPixelRatio:l,verticalPixelRatio:h},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:i,height:e}=this._size.bitmap;this.overlayCtx.clearRect(0,0,i,e),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 pi(r,t,i,e){const{context:a,bitmapSize:o,horizontalPixelRatio:s}=r;a.strokeStyle=e.crosshair.color,a.lineWidth=1,a.setLineDash([4*s,4*s]);const n=Math.round(t)+.5,l=Math.round(i)+.5;a.beginPath(),a.moveTo(n,0),a.lineTo(n,o.height),a.moveTo(0,l),a.lineTo(o.width,l),a.stroke(),a.setLineDash([])}function mi(r,t,i,e,a){const{context:o,bitmapSize:s,horizontalPixelRatio:n,verticalPixelRatio:l}=r;o.strokeStyle=e.grid.color,o.lineWidth=1,e.grid.style==="dashed"?o.setLineDash([4*n,4*n]):e.grid.style==="dotted"&&o.setLineDash([1*n,3*n]);const h=i.niceTickValues();o.beginPath();for(const g of h){const f=Math.round(i.valueToBitmapY(g))+.5;o.moveTo(0,f),o.lineTo(s.width,f)}o.stroke();const{ticks:d}=t.niceTickValues(a);o.beginPath();for(const g of d){const f=Math.round(t.timeToBitmapX(g))+.5;o.moveTo(f,0),o.lineTo(f,s.height)}o.stroke(),o.setLineDash([])}function re(r,t,i){return r+(t-r)*i}function At(r,t,i){let e=0,a=r.length-1;for(;e<=a;){const o=e+a>>>1,s=i(r[o]);if(s<t)e=o+1;else if(s>t)a=o-1;else return o}return e}class $t extends wt{constructor(){super(...arguments),S(this,"data",[]),S(this,"_visible",!0),S(this,"cachedRange",null),S(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let i=!0;for(let e=1;e<t.length;e++)if(t[e].time<t[e-1].time){i=!1;break}this.data=i?t.slice():[...t].sort((e,a)=>e.time-a.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,i){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===i)return this.cachedResult;const e=Math.max(0,At(this.data,t,o=>o.time)-1),a=Math.min(this.data.length,At(this.data,i,o=>o.time)+1);return this.cachedResult=this.data.slice(e,a),this.cachedRange={from:t,to:i},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,i){if(this.data.length===0)return null;const e=At(this.data,t,s=>s.time);let a=null,o=i;for(let s=Math.max(0,e-1);s<=Math.min(this.data.length-1,e+1);s++){const n=Math.abs(this.data[s].time-t);n<=o&&(o=n,a=this.data[s])}return a}}class bi{constructor(t,i,e){S(this,"dragging",!1),S(this,"lastX",0),this.viewport=t,this.timeScale=i,this.canvas=e}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const i=t.clientX-this.lastX;this.lastX=t.clientX;const e=this.timeScale.pixelDeltaToTimeDelta(-i);this.viewport.pan(e)}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair")}isDragging(){return this.dragging}}class yi{constructor(t,i){this.viewport=t,this.timeScale=i}handleWheel(t){t.preventDefault();const i=vi(t.deltaY,t.deltaMode),e=Math.exp(i*.005),a=this.timeScale.getMediaWidth(),o=Math.min(t.offsetX,a),s=this.timeScale.xToTime(o);this.viewport.zoomAt(s,e)}}function vi(r,t){return t===WheelEvent.DOM_DELTA_LINE?r*8:t===WheelEvent.DOM_DELTA_PAGE?r*24:r}class xi extends wt{constructor(t,i,e,a){super(),S(this,"zoom"),S(this,"pan"),S(this,"canvas"),S(this,"timeScale"),S(this,"yScale"),S(this,"viewport"),S(this,"onWheel",o=>{this.zoom.handleWheel(o)}),S(this,"onMouseDown",o=>{this.pan.handleMouseDown(o)}),S(this,"onMouseMove",o=>{this.pan.isDragging()&&this.pan.handleMouseMove(o),this.emitCrosshair(o.offsetX,o.offsetY)}),S(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),S(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),S(this,"onDblClick",()=>{}),S(this,"lastTouchDist",0),S(this,"lastTouchCenter",0),S(this,"touchCount",0),S(this,"onTouchStart",o=>{o.preventDefault(),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)}),S(this,"onTouchMove",o=>{if(o.preventDefault(),o.touches.length===1&&this.touchCount===1){this.pan.handleMouseMove({clientX:o.touches[0].clientX});const s=this.canvas.getBoundingClientRect();this.emitCrosshair(o.touches[0].clientX-s.left,o.touches[0].clientY-s.top)}else if(o.touches.length===2){const s=Math.abs(o.touches[0].clientX-o.touches[1].clientX),n=(o.touches[0].clientX+o.touches[1].clientX)/2,l=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const h=this.lastTouchDist/s,d=this.timeScale.xToTime(n-l.left);this.viewport.zoomAt(d,h)}this.lastTouchDist=s,this.lastTouchCenter=n}}),S(this,"onTouchEnd",o=>{o.touches.length===0&&(this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0)}),this.canvas=t,this.viewport=i,this.timeScale=e,this.yScale=a,this.zoom=new yi(i,e),this.pan=new bi(i,e,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd)}emitCrosshair(t,i){const e=this.timeScale.xToTime(t),a=this.yScale.yToValue(i);this.emit("crosshairMove",{mediaX:t,mediaY:i,time:e,y:a})}destroy(){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()}}class ae{constructor(t){S(this,"dirty",!1),S(this,"rafId",null),S(this,"callback"),S(this,"render",i=>{this.dirty=!1,this.rafId=null,this.callback(i)}),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 lt=6e4,st=36e5,ot=864e5;function jt(r){return r instanceof Date?r.getTime():r}function Ci(r){return r.length===0||typeof r[0].time=="number"?r:r.map(t=>({...t,time:t.time.getTime()}))}function wi(r){return r.length===0||typeof r[0].time=="number"?r:r.map(t=>({...t,time:t.time.getTime()}))}function ue(r){if(r.length<2)return ot;const t=[];for(let i=1;i<Math.min(r.length,20);i++)t.push(r[i]-r[i-1]);return t.sort((i,e)=>i-e),t[Math.floor(t.length/2)]}function St(r,t){const i=new Date(r);return t>=ot?i.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=st?i.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):i.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function fe(r){return new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Si(r){const t=[1e3,5e3,1e4,15e3,3e4],i=[lt,5*lt,10*lt,15*lt,30*lt],e=[st,2*st,4*st,6*st,12*st],a=[ot,7*ot,30*ot,90*ot,365*ot];return r<lt?[...t,...i,...e,...a]:r<st?[...i,...e,...a]:r<ot?[...e,...a]:a}class ki{constructor(){S(this,"from",0),S(this,"to",0),S(this,"width",1),S(this,"pixelRatio",1)}update(t,i,e){this.from=t.from,this.to=t.to,this.width=i,this.pixelRatio=e}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};const i=Si(t),e=(this.to-this.from)/this.width*80;let a=i[i.length-1];for(const n of i)if(n>=e){a=n;break}const o=[],s=Math.ceil(this.from/a)*a;for(let n=s;n<=this.to;n+=a)o.push(n);return{ticks:o,tickInterval:a}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}}const It=[1e-4,2e-4,5e-4,.001,.002,.005,.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4];class Mi{constructor(){S(this,"min",0),S(this,"max",0),S(this,"height",1),S(this,"pixelRatio",1)}update(t,i,e){this.min=t.min,this.max=t.max,this.height=i,this.pixelRatio=e}valueToY(t){return(1-(t-this.min)/(this.max-this.min))*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){return this.max-t/this.height*(this.max-this.min)}niceTickValues(){if(this.max<=this.min)return[];const t=(this.max-this.min)/this.height*50;let i=It[It.length-1];for(const o of It)if(o>=t){i=o;break}const e=[],a=Math.ceil(this.min/i)*i;for(let o=a;o<=this.max;o+=i)e.push(o);return e}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){const i=this.max-this.min;return i<.01?t.toFixed(6):i<.1?t.toFixed(4):i<10?t.toFixed(2):i<1e3?t.toFixed(1):t.toFixed(0)}}const Ri={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};class Q{constructor(t,i){S(this,"stores"),S(this,"options"),this.stores=Array.from({length:t},()=>new $t),this.options={...Ri,...i}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}getValueRange(t,i){if(this.options.stacking==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const e=this.stores.map(n=>n.isVisible()?n.getVisibleData(t,i):[]);if(this.options.stacking==="off"){let n=1/0,l=-1/0;for(const h of e)for(const d of h)d.value<n&&(n=d.value),d.value>l&&(l=d.value);return n<1/0?{min:n,max:l}:null}const a=new Map;for(let n=0;n<e.length;n++)for(const l of e[n])a.has(l.time)||a.set(l.time,new Array(e.length).fill(0)),a.get(l.time)[n]=l.value;let o=0,s=0;for(const n of a.values()){let l=0,h=0;for(const d of n)d>0?l+=d:h+=d;l>s&&(s=l),h<o&&(o=h)}return s>o?{min:o,max:s}:null}render(t){switch(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:i,timeScale:e,yScale:a,dataInterval:o}=t,{context:s}=i,n=e.getRange(),l=e.barWidthBitmap(o),h=Math.max(1,Math.round(l*this.options.barWidthRatio)-2),d=Math.floor(h/2),g=a.getRange().min<0,f=g?a.valueToBitmapY(0):i.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const p=this.options.colors[0],m=this.options.colors.length>1?this.options.colors[1]:p,b=this.stores[0].getVisibleData(n.from,n.to);for(const u of b){const y=e.timeToBitmapX(u.time);if(u.value>=0){const v=a.valueToBitmapY(u.value),C=Math.max(1,f-v);this.fillBar(s,y-d,v,h,C,p)}else{const v=a.valueToBitmapY(u.value),C=Math.max(1,v-f);this.fillBar(s,y-d,f,h,C,m)}}}else{const p=this.stores.map(b=>b.isVisible()?b.getVisibleData(n.from,n.to):[]),m=new Map;for(let b=0;b<p.length;b++)for(const u of p[b]){let y=m.get(u.time);y||(y=[],m.set(u.time,y)),y.push({layer:b,value:u.value})}for(const[b,u]of m){u.sort((v,C)=>Math.abs(C.value)-Math.abs(v.value));const y=e.timeToBitmapX(b);for(const{layer:v,value:C}of u){const w=this.options.colors[v%this.options.colors.length];if(C>=0){const D=a.valueToBitmapY(C),M=Math.max(1,f-D);this.fillBar(s,y-d,D,h,M,w)}else{const D=a.valueToBitmapY(C),M=Math.max(1,D-f);this.fillBar(s,y-d,f,h,M,w)}}}}if(g){s.strokeStyle=t.theme.grid.color,s.lineWidth=1;const p=Math.round(f)+.5;s.beginPath(),s.moveTo(0,p),s.lineTo(i.bitmapSize.width,p),s.stroke()}}renderStacked(t,i){const{scope:e,timeScale:a,yScale:o,dataInterval:s}=t,{context:n}=e,l=a.getRange(),h=a.barWidthBitmap(s),d=Math.max(1,Math.round(h*this.options.barWidthRatio)-2),g=Math.floor(d/2),f=this.stores.map(m=>m.isVisible()?m.getVisibleData(l.from,l.to):[]);if(f.every(m=>m.length===0))return;const p=new Map;for(let m=0;m<f.length;m++)for(const b of f[m])p.has(b.time)||p.set(b.time,new Array(f.length).fill(0)),p.get(b.time)[m]=this.stores[m].isVisible()?b.value:0;for(let m=0;m<f.length;m++){const b=this.options.colors[m%this.options.colors.length];for(const[u,y]of p){const v=y[m];if(v===0)continue;const C=a.timeToBitmapX(u);let w=0,D=0;for(let M=0;M<m;M++){const B=y[M];B>0?w+=B:D+=B}if(i){let M=0,B=0;for(const L of y)L>0?M+=L:B+=L;if(v>0&&M>0){const L=w/M*100,V=(w+v)/M*100,P=o.valueToBitmapY(V),$=o.valueToBitmapY(L),X=Math.max(1,$-P);this.fillBar(n,C-g,P,d,X,b)}else if(v<0&&B<0){const L=D/B*-100,V=(D+v)/B*-100,P=o.valueToBitmapY(L),$=o.valueToBitmapY(V),X=Math.max(1,$-P);n.fillStyle=b,n.fillRect(C-g,P,d,X)}}else if(v>0){const M=o.valueToBitmapY(w+v),B=o.valueToBitmapY(w),L=Math.max(1,B-M);this.fillBar(n,C-g,M,d,L,b)}else{const M=o.valueToBitmapY(D),B=o.valueToBitmapY(D+v),L=Math.max(1,B-M);n.fillStyle=b,n.fillRect(C-g,M,d,L)}}}}fillBar(t,i,e,a,o,s){t.fillStyle=s,t.fillRect(i,e,a,o)}}function se(r,t){return r.length<=t?r:Di(r,t,i=>i.time,i=>i.value)}function Ti(r,t){if(r.length<=t)return r;const i=Math.ceil(r.length/t),e=[];for(let a=0;a<r.length;a+=i){const o=Math.min(a+i,r.length);let s=-1/0,n=1/0,l=0;for(let h=a;h<o;h++)r[h].high>s&&(s=r[h].high),r[h].low<n&&(n=r[h].low),l+=r[h].volume??0;e.push({time:r[a].time,open:r[a].open,high:s,low:n,close:r[o-1].close,volume:l})}return e}function Di(r,t,i,e){if(t>=r.length||t<3)return r;const a=[r[0]],o=(r.length-2)/(t-2);let s=0;for(let n=0;n<t-2;n++){const l=Math.floor((n+1)*o)+1,h=Math.min(Math.floor((n+2)*o)+1,r.length-1);let d=0,g=0;const f=h,p=Math.min(Math.floor((n+3)*o)+1,r.length),m=p-f;if(m>0){for(let C=f;C<p;C++)d+=i(r[C]),g+=e(r[C]);d/=m,g/=m}let b=-1,u=l;const y=i(r[s]),v=e(r[s]);for(let C=l;C<h;C++){const w=Math.abs((y-d)*(e(r[C])-v)-(y-i(r[C]))*(g-v));w>b&&(b=w,u=C)}a.push(r[u]),s=u}return a.push(r[r.length-1]),a}const ne=new Map,le=new Map,ce=new Map;function Xt(r){return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)]}function ge(r,t,i){return`#${r.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function ft(r,t){if(r.startsWith("rgba"))return r.replace(/[\d.]+\)\s*$/,`${t})`);if(r.startsWith("rgb("))return r.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const i=r+t;let e=ne.get(i);if(e)return e;const[a,o,s]=Xt(r);return e=`rgba(${a}, ${o}, ${s}, ${t})`,ne.set(i,e),e}function Bi(r,t){const i=r+t;let e=le.get(i);if(e)return e;const[a,o,s]=Xt(r);return e=ge(Math.min(255,Math.round(a+(255-a)*t)),Math.min(255,Math.round(o+(255-o)*t)),Math.min(255,Math.round(s+(255-s)*t))),le.set(i,e),e}function zi(r,t){const i=r+t;let e=ce.get(i);if(e)return e;const[a,o,s]=Xt(r);return e=ge(Math.max(0,Math.round(a*(1-t))),Math.max(0,Math.round(o*(1-t))),Math.max(0,Math.round(s*(1-t)))),ce.set(i,e),e}const Li={upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350",bodyWidthRatio:.6};class Et{constructor(t,i){S(this,"store"),S(this,"options"),this.store=t,this.options={...Li,...i}}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.upColor}render(t){const{scope:i,timeScale:e,yScale:a,dataInterval:o}=t,{context:s,horizontalPixelRatio:n}=i,l=e.getRange();let h=this.store.getVisibleData(l.from,l.to);const d=i.mediaSize.width;if(h.length>d*2&&(h=Ti(h,Math.round(d*1.5))),h.length===0)return;const g=e.barWidthBitmap(o),f=Math.max(1,Math.round(g*this.options.bodyWidthRatio)-2),p=Math.floor(f/2),m=Math.max(1,Math.round(n)),b=Math.round(a.getMediaHeight()*i.verticalPixelRatio);this.drawVolume(s,h,e,b,g,o);const u=[],y=[];for(const v of h)v.close>=v.open?u.push(v):y.push(v);this.drawCandles(s,u,e,a,p,f,m,this.options.upColor,this.options.wickUpColor),this.drawCandles(s,y,e,a,p,f,m,this.options.downColor,this.options.wickDownColor)}drawVolume(t,i,e,a,o,s){let n=0;for(const p of i)p.volume!==void 0&&p.volume>n&&(n=p.volume);if(n===0)return;const l=a*.2,h=Math.max(1,o-2),d=Math.floor(h/2),g=ft(this.options.upColor,.2),f=ft(this.options.downColor,.2);for(const p of i){if(p.volume===void 0||p.volume===0)continue;const m=e.timeToBitmapX(p.time),b=Math.max(1,p.volume/n*l),u=p.close>=p.open;t.fillStyle=u?g:f,t.fillRect(m-d,a-b,h,b)}}drawCandles(t,i,e,a,o,s,n,l,h){if(i.length===0)return;t.fillStyle=h;for(const p of i){const m=e.timeToBitmapX(p.time),b=a.valueToBitmapY(p.high),u=a.valueToBitmapY(p.low),y=m-Math.floor(n/2);t.fillRect(y,b,n,u-b)}const d=this.options.candleGradient!==!1,g=d?Bi(l,.2):l,f=d?zi(l,.15):l;d||(t.fillStyle=l);for(const p of i){const m=e.timeToBitmapX(p.time),b=a.valueToBitmapY(p.open),u=a.valueToBitmapY(p.close),y=Math.min(b,u),v=Math.max(1,Math.abs(u-b));if(d&&v>2){const C=t.createLinearGradient(0,y,0,y+v);C.addColorStop(0,g),C.addColorStop(.5,l),C.addColorStop(1,f),t.fillStyle=C}t.fillRect(m-o,y,s,v)}}}const Pi={colors:["#2962FF"],lineWidth:1,areaFill:!0,pulse:!0,stacking:"off"};class H{constructor(t,i){S(this,"stores"),S(this,"options"),S(this,"areaGradientCache",new Map),this.stores=Array.from({length:t},()=>new $t),this.options={...Pi,...i}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}getStacking(){return this.options.stacking}get needsAnimation(){return!1}get hasPulse(){return this.options.pulse&&this.stores.some(t=>t.isVisible()&&t.length>0)}getValueRange(t,i){if(this.options.stacking==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const e=this.stores.map(n=>n.isVisible()?n.getVisibleData(t,i):[]);if(this.options.stacking==="off"){let n=1/0,l=-1/0;for(const h of e)for(const d of h)d.value<n&&(n=d.value),d.value>l&&(l=d.value);return n<1/0?{min:n,max:l}:null}const a=new Map;for(let n=0;n<e.length;n++)for(const l of e[n])a.has(l.time)||a.set(l.time,new Array(e.length).fill(0)),a.get(l.time)[n]=l.value;let o=0,s=0;for(const n of a.values()){let l=0,h=0;for(const d of n)d>0?l+=d:h+=d;l>s&&(s=l),h<o&&(o=h)}return s>o?{min:o,max:s}:null}render(t){this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}renderOff(t){const{scope:i,timeScale:e,yScale:a}=t,{context:o}=i,s=e.getRange(),{verticalPixelRatio:n,horizontalPixelRatio:l}=i,h=Math.max(1,Math.round(this.options.lineWidth*n));for(let d=0;d<this.stores.length;d++){if(!this.stores[d].isVisible())continue;let g=this.stores[d].getVisibleData(s.from,s.to);const f=i.mediaSize.width;if(g.length>f*2&&(g=se(g,Math.round(f*1.5))),g.length<2)continue;const p=this.options.colors[d%this.options.colors.length];o.beginPath(),o.moveTo(e.timeToBitmapX(g[0].time),a.valueToBitmapY(g[0].value));for(let m=1;m<g.length;m++)o.lineTo(e.timeToBitmapX(g[m].time),a.valueToBitmapY(g[m].value));if(o.strokeStyle=p,o.lineWidth=h,o.lineJoin="round",o.lineCap="round",o.stroke(),this.options.areaFill){const m=e.timeToBitmapX(g[0].time),b=e.timeToBitmapX(g[g.length-1].time),u=i.bitmapSize.height;o.lineTo(b,u),o.lineTo(m,u),o.closePath();const y=String(d),v=this.areaGradientCache.get(y);let C;v&&v.bottomY===u&&v.color===p?C=v.gradient:(C=o.createLinearGradient(0,0,0,u),C.addColorStop(0,ft(p,.12)),C.addColorStop(1,ft(p,.01)),this.areaGradientCache.set(y,{gradient:C,bottomY:u,color:p})),o.fillStyle=C,o.fill()}}}renderStacked(t,i){const{scope:e,timeScale:a,yScale:o}=t,{context:s}=e,n=a.getRange(),{verticalPixelRatio:l}=e,h=Math.max(1,Math.round(this.options.lineWidth*l)),d=e.mediaSize.width,g=this.stores.map(u=>{let y=u.getVisibleData(n.from,n.to);return y.length>d*2&&(y=se(y,Math.round(d*1.5))),y}),f=new Set;for(const u of g)for(const y of u)f.add(y.time);const p=Array.from(f).sort((u,y)=>u-y);if(p.length<2)return;const m=g.map(u=>{const y=new Map;for(const v of u)y.set(v.time,v.value);return y}),b=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let u=0;u<p.length;u++){const y=p[u];let v=0;if(i)for(let w=0;w<this.stores.length;w++)this.stores[w].isVisible()&&(v+=m[w].get(y)??0);let C=0;for(let w=0;w<this.stores.length;w++){const D=this.stores[w].isVisible()?m[w].get(y)??0:0;C+=i&&v>0?D/v*100:D,b[w][u]=C}}for(let u=this.stores.length-1;u>=0;u--){if(!this.stores[u].isVisible())continue;const y=this.options.colors[u%this.options.colors.length],v=[];for(let w=0;w<p.length;w++)v.push([a.timeToBitmapX(p[w]),o.valueToBitmapY(b[u][w])]);const C=[];for(let w=0;w<p.length;w++){const D=u>0?b[u-1][w]:0;C.push([a.timeToBitmapX(p[w]),o.valueToBitmapY(D)])}if(this.options.areaFill){s.beginPath(),s.moveTo(v[0][0],v[0][1]);for(let w=1;w<v.length;w++)s.lineTo(v[w][0],v[w][1]);for(let w=C.length-1;w>=0;w--)s.lineTo(C[w][0],C[w][1]);s.closePath(),s.fillStyle=ft(y,.25),s.fill()}s.beginPath(),s.moveTo(v[0][0],v[0][1]);for(let w=1;w<v.length;w++)s.lineTo(v[w][0],v[w][1]);s.strokeStyle=y,s.lineWidth=h,s.lineJoin="round",s.lineCap="round",s.stroke()}}drawPulseOverlay(t,i,e,a){if(this.options.pulse)for(let o=0;o<this.stores.length;o++){if(!this.stores[o].isVisible())continue;const s=this.stores[o].last();if(!s)continue;const n=this.options.colors[o%this.options.colors.length];this.drawPulse(t,i.timeToBitmapX(s.time),e.valueToBitmapY(s.value),n,a)}}drawPulse(t,i,e,a,o){const s=3*o,n=.4+.6*Math.abs(Math.sin(performance.now()/600)),l=s+4*o*n;t.beginPath(),t.arc(i,e,l,0,Math.PI*2),t.fillStyle=ft(a,n*.3),t.fill(),t.beginPath(),t.arc(i,e,s,0,Math.PI*2),t.fillStyle=a,t.fill()}}const Fi={innerRadiusRatio:0,padAngle:.02,strokeColor:"transparent",strokeWidth:0},Rt=Math.PI*2;function Wi(r){if(!r.startsWith("#"))return!1;const t=parseInt(r.slice(1,3),16),i=parseInt(r.slice(3,5),16),e=parseInt(r.slice(5,7),16);return t*.299+i*.587+e*.114>150}function Ai(r,t){if(!r.startsWith("#"))return r;const i=Math.min(255,parseInt(r.slice(1,3),16)+Math.round(255*t)),e=Math.min(255,parseInt(r.slice(3,5),16)+Math.round(255*t)),a=Math.min(255,parseInt(r.slice(5,7),16)+Math.round(255*t));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function Ii(r,t,i){return r+(t-r)*Math.min(1,i)}class at{constructor(t){S(this,"data",[]),S(this,"options"),S(this,"hoverIndex",-1),S(this,"sliceOffsets",[]),S(this,"lastRenderTime",0),this.options={...Fi,...t}}getData(){return this.data}setData(t){this.data=t,this.sliceOffsets=new Array(t.length).fill(0)}updateOptions(t){this.options={...this.options,...t}}getColor(){var t,i;return((t=this.data[0])==null?void 0:t.color)??((i=this.options.colors)==null?void 0:i[0])??"#888"}hitTest(t,i,e,a){if(this.data.length===0)return-1;const o=this.data.reduce((b,u)=>b+u.value,0);if(o<=0)return-1;const s=e/2,n=a/2,l=Math.min(e,a)/2*.85,h=l*this.options.innerRadiusRatio,d=t-s,g=i-n,f=Math.sqrt(d*d+g*g);if(f>l||f<h)return-1;let p=Math.atan2(g,d)+Math.PI/2;p<0&&(p+=Rt);let m=0;for(let b=0;b<this.data.length;b++){const u=this.data[b].value/o*Rt;if(p>=m&&p<m+u)return b;m+=u}return-1}get needsAnimation(){for(let t=0;t<this.sliceOffsets.length;t++){const i=t===this.hoverIndex?1:0;if(Math.abs(this.sliceOffsets[t]-i)>.01)return!0}return!1}render(t){if(this.data.length===0)return;const{scope:i,theme:e}=t,{context:a,bitmapSize:o,horizontalPixelRatio:s}=i,n=performance.now(),l=this.lastRenderTime?(n-this.lastRenderTime)/1e3:0;this.lastRenderTime=n;const h=this.data.reduce((M,B)=>M+B.value,0);if(h<=0)return;const d=10;for(;this.sliceOffsets.length<this.data.length;)this.sliceOffsets.push(0);for(let M=0;M<this.data.length;M++){const B=M===this.hoverIndex?1:0;this.sliceOffsets[M]=Ii(this.sliceOffsets[M],B,d*l)}const g=this.options.colors??e.seriesColors,f=o.width/2,p=o.height/2,m=Math.min(o.width,o.height)/2*.85,b=m*this.options.innerRadiusRatio,u=this.options.padAngle,{strokeColor:y,strokeWidth:v}=this.options,C=8*s;let w=-Math.PI/2;for(let M=0;M<this.data.length;M++){const B=this.data[M],L=B.value/h*Rt,V=w+u/2,P=w+L-u/2,$=w+L/2,X=B.color??g[M%g.length],K=this.sliceOffsets[M]*C,Y=Math.cos($)*K,rt=Math.sin($)*K,_=f+Y,U=p+rt;a.beginPath(),a.arc(_,U,m,V,P),b>0?a.arc(_,U,b,P,V,!0):a.lineTo(_,U),a.closePath();const I=a.createRadialGradient(_,U,b||0,_,U,m);I.addColorStop(0,Ai(X,.15)),I.addColorStop(1,X),a.fillStyle=I,this.sliceOffsets[M]>.01&&(a.shadowColor="rgba(0,0,0,0.25)",a.shadowBlur=12*s*this.sliceOffsets[M],a.shadowOffsetX=Y*.3,a.shadowOffsetY=rt*.3),a.fill(),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0,v>0&&y!=="transparent"&&(a.strokeStyle=y,a.lineWidth=v,a.stroke()),w+=L}w=-Math.PI/2;const D=b>0?(m+b)/2:m*.65;a.textAlign="center",a.textBaseline="middle",a.font=`${11*s}px ${e.typography.fontFamily}`;for(let M=0;M<this.data.length;M++){const B=this.data[M],L=B.value/h*Rt;if(L>.3){const V=w+L/2,P=this.sliceOffsets[M]*C,$=f+Math.cos(V)*(D+P),X=p+Math.sin(V)*(D+P),K=B.color??g[M%g.length];a.fillStyle=Wi(K)?"#000000":"#ffffff",a.fillText(B.label,$,X)}w+=L}}}const pe={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"}},et={top:20,bottom:20,right:{intervals:3},left:{intervals:0}};class Ei extends wt{constructor({padding:t}={}){super(),S(this,"_visibleRange",{from:0,to:0}),S(this,"_yRange",{min:0,max:0}),S(this,"_autoScroll",!0),S(this,"padding"),S(this,"dataInterval",6e4),S(this,"_dataStart",null),S(this,"_dataEnd",null),S(this,"_animating",!1),S(this,"animStartTime",0),S(this,"animDuration",0),S(this,"animFrom",{from:0,to:0}),S(this,"animTo",{from:0,to:0}),this.padding={top:(t==null?void 0:t.top)??et.top,bottom:(t==null?void 0:t.bottom)??et.bottom,right:(t==null?void 0:t.right)??et.right,left:(t==null?void 0:t.left)??et.left}}resolveHPad(t,i,e){return typeof t=="object"?t.intervals*this.dataInterval:e<=0?0:t/e*i}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??et.top,bottom:(t==null?void 0:t.bottom)??et.bottom,right:(t==null?void 0:t.right)??et.right,left:(t==null?void 0:t.left)??et.left}}setDataStart(t){this._dataStart=t}setDataEnd(t){this._dataEnd=t}cancelAnimation(){this._animating=!1}applyRange(t,i,e=!1){if(i<=t)return;const a=i-t;if(!(a/this.dataInterval<2)){if(e&&this._dataStart!==null&&this._dataEnd!==null){const o=this._dataEnd-this._dataStart+this.dataInterval*5;if(a>o&&o>0)return}this._visibleRange={from:t,to:i},this.emit("change")}}animateTo(t,i,e=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:i},this.animDuration=e,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const i=t-this.animStartTime,e=Math.min(1,i/this.animDuration),a=1-(1-e)**3,o=re(this.animFrom.from,this.animTo.from,a),s=re(this.animFrom.to,this.animTo.to,a);return s>o&&this.applyRange(o,s),e>=1&&(this._animating=!1),this._animating}setYRange(t,i,e,a=!1,o=!1){const s=i-t,n=e>0?this.padding.top/e*s:0,l=e>0?this.padding.bottom/e*s:0;this._yRange={min:a?t:t-l,max:o?i:i+n}}zoomAt(t,i){this.cancelAnimation();const{from:e,to:a}=this._visibleRange,o=a-e,s=o*i,n=(t-e)/o,l=t-n*s,h=l+s;if(!(s/this.dataInterval<10)){if(i>1&&this._dataStart!==null&&this._dataEnd!==null&&l<=this._dataStart&&h>=this._dataEnd){this._autoScroll=!0,this.applyRange(l,h,!0);return}this._autoScroll=!1,this.applyRange(l,h,!0)}}pan(t){this.cancelAnimation();const{from:i,to:e}=this._visibleRange,a=i+t,o=e+t;this._autoScroll=!1,this.applyRange(a,o)}fitToData(t,i,e=0,a=!1){this._autoScroll=!0;const o=400*this.dataInterval,s=i-t,n=s>0?s:this.dataInterval*10,l=this.resolveHPad(this.padding.right,n,e),h=this.resolveHPad(this.padding.left,n,e);let d=i+l,g=t-h;d-g>o&&(d=i+l,g=d-o),a&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(g,d,450):this.applyRange(g,d)}scrollToEnd(t,i=0){const e=this._visibleRange.to-this._visibleRange.from,a=this.resolveHPad(this.padding.right,e,i),o=t+a,s=o-e;this._autoScroll=!0,this._animating?(this.animFrom={...this._visibleRange},this.animTo={from:s,to:o},this.animDuration=150,this.animStartTime=performance.now()):this.animateTo(s,o,150)}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}let ji=0;var j,z,E,ct,yt,R,W,vt,N,tt,O,Z,Vt,ht,it,xt,nt,dt,Ct,Dt,J,q,ut;class me extends wt{constructor(t,i){var e,a,o;super(),F(this,dt),F(this,j),F(this,z),F(this,E),F(this,ct),S(this,"timeScale"),S(this,"yScale"),F(this,yt),F(this,R,[]),F(this,W),F(this,vt),F(this,N,6e4),F(this,tt,null),F(this,O,{}),F(this,Z,null),F(this,Vt,!1),F(this,ht,{}),F(this,it,0),F(this,xt,!1),F(this,nt,!1),F(this,Dt,0),F(this,J,0),F(this,q,0),F(this,ut,!1),i!=null&&i.axis&&(T(this,ht,i.axis),T(this,O,{min:(e=i.axis.y)==null?void 0:e.min,max:(a=i.axis.y)==null?void 0:a.max})),T(this,W,(i==null?void 0:i.theme)??pe),T(this,vt,(i==null?void 0:i.grid)!==!1),T(this,j,new gi(t)),T(this,z,new Ei({padding:i==null?void 0:i.padding})),this.timeScale=new ki,this.yScale=new Mi,T(this,E,new ae(()=>this.renderMain())),T(this,ct,new ae(()=>this.renderOverlay()));const s=(i==null?void 0:i.interactive)!==!1;T(this,yt,s?new xi(c(this,j).canvas,c(this,z),this.timeScale,this.yScale):null),c(this,z).on("change",()=>{this.syncScales(),c(this,E).markDirty(),this.emit("viewportChange")}),c(this,j).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(o=c(this,yt))==null||o.on("crosshairMove",n=>{T(this,tt,n),c(this,ct).markDirty(),this.emit("crosshairMove",n),this.updatePieHover(n)})}get yAxisWidth(){const t=c(this,ht).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=c(this,ht).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}addCandlestickSeries(t){const i=new $t,e=new Et(i,{upColor:c(this,W).candlestick.upColor,downColor:c(this,W).candlestick.downColor,wickUpColor:c(this,W).candlestick.wickUpColor,wickDownColor:c(this,W).candlestick.wickDownColor,bodyWidthRatio:.6,...t}),a=Mt(this,dt,Ct).call(this,t==null?void 0:t.id);return i.on("update",()=>{this.onDataChanged()}),c(this,R).push({id:a,renderer:e,store:i,visible:!0}),T(this,Z,null),this.updateViewportPadding(),this.emit("seriesChange"),a}addLineSeries(t,i){let e,a;if(typeof t=="number")e=t,a=i;else{const{layers:n,...l}=t??{};e=n??1,a=l}const o=new H(e,{colors:e===1?[c(this,W).line.color]:c(this,W).seriesColors.slice(0,e),lineWidth:c(this,W).line.width,areaFill:!0,...a}),s=Mt(this,dt,Ct).call(this,a==null?void 0:a.id);for(const n of o.stores)n.on("update",()=>this.onDataChanged());return c(this,R).push({id:s,label:a==null?void 0:a.label,renderer:o,store:o.stores[0],visible:!0}),T(this,Z,null),this.updateViewportPadding(),this.emit("seriesChange"),s}setLineLayerData(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a||!(a.renderer instanceof H))return;const o=a.renderer.stores[i];o&&o.setData(e)}addBarSeries(t,i){let e,a;if(typeof t=="number")e=t,a=i;else{const{layers:n,...l}=t??{};e=n??1,a=l}const o=new Q(e,{colors:c(this,W).seriesColors.slice(0,e),barWidthRatio:.6,...a}),s=Mt(this,dt,Ct).call(this,a==null?void 0:a.id);for(const n of o.stores)n.on("update",()=>this.onDataChanged());return c(this,R).push({id:s,label:a==null?void 0:a.label,renderer:o,store:o.stores[0],visible:!0}),T(this,Z,null),this.updateViewportPadding(),this.emit("seriesChange"),s}setBarLayerData(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a||!(a.renderer instanceof Q))return;const o=a.renderer.stores[i];o&&o.setData(e)}addPieSeries(t){const i=new at(t),e=Mt(this,dt,Ct).call(this,t==null?void 0:t.id);return c(this,R).push({id:e,label:t==null?void 0:t.label,renderer:i,store:null,visible:!0}),T(this,Z,null),this.updateViewportPadding(),this.emit("seriesChange"),e}setPieData(t,i){const e=c(this,R).find(a=>a.id===t);!e||!(e.renderer instanceof at)||(e.renderer.setData(i),c(this,E).markDirty(),this.emit("dataUpdate"))}removeSeries(t){const i=c(this,R).findIndex(e=>e.id===t);if(i>=0){const{renderer:e,store:a}=c(this,R)[i];if(e instanceof H||e instanceof Q)for(const o of e.stores)o.removeAllListeners();else a==null||a.removeAllListeners();c(this,R).splice(i,1),T(this,Z,null),this.updateViewportPadding(),c(this,E).markDirty(),this.emit("seriesChange")}}setSeriesData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a=i.length>0&&"open"in i[0]?Ci(i):wi(i);e.store.setData(a)}appendData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a={...i,time:jt(i.time)};e.store.append(a)}updateData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a={...i,time:jt(i.time)};e.store.updateLast(a)}updateSeriesOptions(t,i){const e=c(this,R).find(a=>a.id===t);e&&((e.renderer instanceof Et||e.renderer instanceof H||e.renderer instanceof Q||e.renderer instanceof at)&&e.renderer.updateOptions(i),"label"in i&&typeof i.label=="string"&&(e.label=i.label),c(this,E).markDirty())}batch(t){this.beginUpdate();try{t()}finally{this.endUpdate()}}beginUpdate(){ie(this,it)._++}endUpdate(){--ie(this,it)._<=0&&(T(this,it,0),c(this,xt)?(T(this,xt,!1),T(this,nt,!1),this.onDataChanged()):c(this,nt)&&(T(this,nt,!1),this.updateYRange(!0),c(this,E).markDirty()))}setSeriesVisible(t,i){const e=c(this,R).find(a=>a.id===t);if(!(!e||e.visible===i)){if(e.visible=i,c(this,it)>0){T(this,nt,!0);return}this.updateYRange(!0),c(this,E).markDirty()}}isSeriesVisible(t){var i;return((i=c(this,R).find(e=>e.id===t))==null?void 0:i.visible)??!0}setLayerVisible(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a)return;const o=a.renderer;if(o instanceof Q||o instanceof H){const s=o.stores[i];if(s){if(s.isVisible()===e)return;if(s.setVisible(e),c(this,it)>0){T(this,nt,!0);return}this.updateYRange(!0),c(this,E).markDirty()}}}isLayerVisible(t,i){var e;const a=c(this,R).find(s=>s.id===t);if(!a)return!0;const o=a.renderer;return o instanceof Q||o instanceof H?((e=o.stores[i])==null?void 0:e.isVisible())??!0:!0}fitContent(){const{first:t,last:i}=this.getDataBounds();if(t===void 0||i===void 0)return;const e=c(this,j).size.media.width-this.yAxisWidth;c(this,z).fitToData(t,i,e,!0)}getVisibleRange(){return c(this,z).visibleRange}getYRange(){return c(this,z).yRange}getCrosshairPosition(){return c(this,tt)}getLastValue(t){const i=c(this,R).find(l=>l.id===t);if(!(i!=null&&i.store))return null;const e=i.store.last();if(!e)return null;const a=l=>"close"in l?l.close:l.value,{from:o,to:s}=c(this,z).visibleRange;if(e.time>=o&&e.time<=s)return{value:a(e),isLive:!0};const n=i.store.getVisibleData(o,s);return n.length===0?null:{value:a(n[n.length-1]),isLive:!1}}getPreviousClose(t){const i=c(this,R).find(o=>o.id===t);if(!(i!=null&&i.store))return null;const e=i.store.getAll();if(e.length<2)return null;const a=e[e.length-2];return"close"in a?a.close:a.value}getLastData(t){const i=c(this,R).find(e=>e.id===t);return i!=null&&i.store?i.store.last()??null:null}getDataAtTime(t,i){const e=c(this,R).find(n=>n.id===t);if(!(e!=null&&e.store))return null;const a=e.store.getVisibleData(i-c(this,N),i+c(this,N));if(a.length===0)return null;let o=a[0],s=Math.abs(a[0].time-i);for(let n=1;n<a.length;n++){const l=Math.abs(a[n].time-i);l<s&&(s=l,o=a[n])}return o}getLayerSnapshots(t,i){const e=c(this,R).find(n=>n.id===t);if(!e||!e.visible)return null;const a=e.renderer;if(!(a instanceof Q)&&!(a instanceof H)||a.stores.length<=1)return null;const o=a.getColors(),s=[];for(let n=0;n<a.stores.length;n++){if(!a.stores[n].isVisible())continue;const l=a.stores[n].getVisibleData(i-c(this,N),i+c(this,N));if(l.length===0)continue;let h=l[0],d=Math.abs(l[0].time-i);for(let g=1;g<l.length;g++){const f=Math.abs(l[g].time-i);f<d&&(d=f,h=l[g])}s.push({value:h.value,color:(o==null?void 0:o[n%((o==null?void 0:o.length)??1)])??c(this,W).seriesColors[n%c(this,W).seriesColors.length]})}return s.length>0?s:null}getSeriesIds(){return c(this,Z)||T(this,Z,c(this,R).map(t=>t.id)),c(this,Z).slice()}getSeriesColor(t){const i=c(this,R).find(e=>e.id===t);return i?"getColor"in i.renderer&&typeof i.renderer.getColor=="function"?i.renderer.getColor():c(this,W).line.color:null}getSeriesLabel(t){var i;return(i=c(this,R).find(e=>e.id===t))==null?void 0:i.label}getSeriesLayers(t){const i=c(this,R).find(o=>o.id===t);if(!i)return null;const e=i.renderer;if(!(e instanceof Q)&&!(e instanceof H))return null;const a=e.getColors();return e.stores.map((o,s)=>({color:a[s%a.length]}))}getPieSlices(t){const i=c(this,R).find(s=>s.id===t);if(!i||!(i.renderer instanceof at))return null;const e=i.renderer.getData();if(e.length===0)return null;const a=e.reduce((s,n)=>s+n.value,0),o=c(this,W).seriesColors;return e.map((s,n)=>({label:s.label,value:s.value,percent:a>0?s.value/a*100:0,color:s.color??o[n%o.length]}))}getPieHoverInfo(t){const i=c(this,R).find(l=>l.id===t);if(!i||!(i.renderer instanceof at))return null;const e=i.renderer;if(e.hoverIndex<0)return null;const a=e.getData(),o=a[e.hoverIndex];if(!o)return null;const s=a.reduce((l,h)=>l+h.value,0),n=c(this,W).seriesColors;return{label:o.label,value:o.value,percent:s>0?o.value/s*100:0,color:o.color??n[e.hoverIndex%n.length]}}setTheme(t){const i=c(this,W).line.color;T(this,W,t);for(const e of c(this,R))e.renderer instanceof Et?e.renderer.updateOptions({upColor:t.candlestick.upColor,downColor:t.candlestick.downColor,wickUpColor:t.candlestick.wickUpColor,wickDownColor:t.candlestick.wickDownColor}):e.renderer instanceof Q?e.renderer.updateOptions({colors:t.seriesColors.slice(0,e.renderer.stores.length)}):e.renderer instanceof H&&(e.renderer.stores.length===1?e.renderer.getColor()===i&&e.renderer.updateOptions({colors:[t.line.color]}):e.renderer.updateOptions({colors:t.seriesColors.slice(0,e.renderer.stores.length)}));c(this,E).markDirty()}getTheme(){return c(this,W)}setAxis(t){var i,e;const a=this.yAxisWidth,o=this.xAxisHeight;T(this,ht,t);const s={min:(i=t.y)==null?void 0:i.min,max:(e=t.y)==null?void 0:e.max};T(this,O,s),T(this,ut,!1),this.updateYRange(!0),(this.yAxisWidth!==a||this.xAxisHeight!==o)&&this.updateScales(!0),c(this,E).markDirty()}getMediaSize(){return c(this,j).size.media}getLayout(){const t=c(this,j).size.media,i=this.yAxisWidth,e=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-i,height:t.height-e},yAxisWidth:i,xAxisHeight:e}}getDataInterval(){return c(this,N)}setPadding(t){c(this,z).setPadding(t);const{first:i,last:e}=this.getDataBounds();if(i!==void 0&&e!==void 0){const a=c(this,j).size.media.width-this.yAxisWidth;c(this,z).fitToData(i,e,a,!1)}this.syncScales(),c(this,E).markDirty()}setGrid(t){T(this,vt,t),c(this,E).markDirty()}setYLabel(t){T(this,Vt,t),this.updateViewportPadding()}updatePieHover(t){const i=c(this,j).size;for(const e of c(this,R))if(e.renderer instanceof at){const a=e.renderer.hoverIndex;if(t){const o=t.mediaX*i.horizontalPixelRatio,s=t.mediaY*i.verticalPixelRatio;e.renderer.hoverIndex=e.renderer.hitTest(o,s,i.bitmap.width,i.bitmap.height)}else e.renderer.hoverIndex=-1;e.renderer.hoverIndex!==a&&c(this,E).markDirty()}}updateViewportPadding(){}destroy(){var t;c(this,z).destroy(),c(this,E).destroy(),c(this,ct).destroy(),(t=c(this,yt))==null||t.destroy(),c(this,j).destroy(),this.removeAllListeners()}getDataBounds(){let t,i;for(const e of c(this,R)){if(!e.visible||!e.store)continue;const a=e.store.first(),o=e.store.last();a&&(t===void 0||a.time<t)&&(t=a.time),o&&(i===void 0||o.time>i)&&(i=o.time)}return{first:t,last:i}}onDataChanged(){if(c(this,it)>0){T(this,xt,!0);return}this.updateDataInterval();const{first:t,last:i}=this.getDataBounds();t!==void 0&&c(this,z).setDataStart(t),i!==void 0&&c(this,z).setDataEnd(i);let e=0;for(const o of c(this,R))if(o.renderer instanceof H||o.renderer instanceof Q)for(const s of o.renderer.stores)e+=s.length;else o.store&&(e+=o.store.length);const a=e-c(this,Dt)>5;if(T(this,Dt,e),t!==void 0&&i!==void 0){const{from:o,to:s}=c(this,z).visibleRange,n=o===0&&s===0,l=c(this,j).size.media.width-this.yAxisWidth;n?c(this,z).fitToData(t,i,l,!1):a&&c(this,z).autoScroll?c(this,z).fitToData(t,i,l,!0):!a&&this.isLastPointVisible()&&c(this,z).scrollToEnd(i,l)}this.updateYRange(a),this.syncScales(),c(this,E).markDirty(),this.emit("dataUpdate")}isLastPointVisible(){const{from:t,to:i}=c(this,z).visibleRange;for(const e of c(this,R)){if(!e.visible||!e.store)continue;const a=e.store.last();if(a&&a.time>=t&&a.time<=i)return!0}return!1}updateDataInterval(){for(const t of c(this,R)){if(!t.store)continue;const i=t.store.getAll();if(i.length>=2){const e=i.slice(0,20).map(a=>a.time);T(this,N,ue(e)),c(this,z).setDataInterval(c(this,N));break}}}updateYRange(t=!1){let i=1/0,e=-1/0;const a=c(this,z).visibleRange;let o=c(this,O).min!==void 0&&c(this,O).min!=="auto"&&typeof c(this,O).min!="number"||c(this,O).max!==void 0&&c(this,O).max!=="auto"&&typeof c(this,O).max!="number"?[]:null;for(const h of c(this,R)){if(!h.visible)continue;if(h.renderer.getValueRange){const g=h.renderer.getValueRange(a.from,a.to);if(g){g.max>e&&(e=g.max),g.min<i&&(i=g.min),o==null||o.push(g.min,g.max);continue}}if(!h.store)continue;const d=h.store.getVisibleData(a.from,a.to);for(const g of d)if("high"in g){const f=g;f.high>e&&(e=f.high),f.low<i&&(i=f.low),o==null||o.push(f.high,f.low)}else{const f=g;f.value>e&&(e=f.value),f.value<i&&(i=f.value),o==null||o.push(f.value)}}if(i===1/0||e===-1/0){T(this,ut,!1);return}if(i=this.resolveBound(c(this,O).min,i,e,o??[],"min"),e=this.resolveBound(c(this,O).max,e,i,o??[],"max"),!c(this,ut)||t)T(this,J,i),T(this,q,e),T(this,ut,!0);else{T(this,J,c(this,J)+(i-c(this,J))*.2),T(this,q,c(this,q)+(e-c(this,q))*.2),i<c(this,J)&&T(this,J,i),e>c(this,q)&&T(this,q,e);const h=Math.max(Math.abs(c(this,q)-c(this,J))*1e-4,.001);(Math.abs(c(this,J)-i)>h||Math.abs(c(this,q)-e)>h)&&c(this,E).markDirty()}const s=c(this,O).min!==void 0&&c(this,O).min!=="auto",n=c(this,O).max!==void 0&&c(this,O).max!=="auto",l=c(this,j).size.media.height-this.xAxisHeight;c(this,z).setYRange(c(this,J),c(this,q),l,s,n)}resolveBound(t,i,e,a,o){if(t===void 0||t==="auto")return i;if(typeof t=="number")return t;if(typeof t=="function")return t(a);const s=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(s){const n=s[1]==="-"?-1:1,l=parseFloat(s[2])/100,h=Math.abs(e-i)||Math.abs(i)||1;return i+n*l*h*(o==="max"?1:-1)}return i}syncScales(){const t=c(this,j).size;if(t.media.width===0||t.media.height===0)return;const i=t.media.width-this.yAxisWidth,e=t.media.height-this.xAxisHeight;this.timeScale.update(c(this,z).visibleRange,i,t.horizontalPixelRatio),this.yScale.update(c(this,z).yRange,e,t.verticalPixelRatio)}updateScales(t=!1){const i=c(this,j).size;if(i.media.width===0||i.media.height===0)return;const e=i.media.width-this.yAxisWidth,a=i.media.height-this.xAxisHeight;this.timeScale.update(c(this,z).visibleRange,e,i.horizontalPixelRatio),this.yScale.update(c(this,z).yRange,a,i.verticalPixelRatio),this.updateYRange(t),this.yScale.update(c(this,z).yRange,a,i.verticalPixelRatio)}renderMain(){const t=c(this,j).size;if(!(t.media.width===0||t.media.height===0)){c(this,z).tick(performance.now())&&c(this,E).markDirty(),this.updateScales(),c(this,j).useMainLayer(i=>{const{context:e,bitmapSize:a}=i,o=(t.media.width-this.yAxisWidth)*t.horizontalPixelRatio,s=(t.media.height-this.xAxisHeight)*t.verticalPixelRatio;e.clearRect(0,0,a.width,a.height),e.save(),e.beginPath(),e.rect(0,0,o,s),e.clip(),c(this,vt)&&mi(i,this.timeScale,this.yScale,c(this,W),c(this,N));for(const n of c(this,R))n.visible&&n.renderer.render({scope:i,timeScale:this.timeScale,yScale:this.yScale,theme:c(this,W),dataInterval:c(this,N)});e.restore()});for(const i of c(this,R))if(i.renderer instanceof at&&i.renderer.needsAnimation){c(this,E).markDirty();break}this.renderOverlay()}}renderOverlay(){const t=c(this,j).size;if(t.media.width===0||t.media.height===0)return;let i=!1;for(const e of c(this,R))if(e.visible&&e.renderer instanceof H&&e.renderer.hasPulse){i=!0;break}if(c(this,j).useOverlayLayer(e=>{if(!c(this,tt)&&!i)return;const a=(t.media.width-this.yAxisWidth)*t.horizontalPixelRatio,o=(t.media.height-this.xAxisHeight)*t.verticalPixelRatio;if(e.context.save(),e.context.beginPath(),e.context.rect(0,0,a,o),e.context.clip(),c(this,tt)){const s=c(this,tt).mediaX*t.horizontalPixelRatio,n=c(this,tt).mediaY*t.verticalPixelRatio;pi(e,s,n,c(this,W));for(const l of c(this,R))if(l.visible&&l.renderer instanceof H){const h=l.renderer,d=h.getColors(),g=h.getStacking(),f=4*t.horizontalPixelRatio,p=[],m=[];for(let u=0;u<h.stores.length;u++){const y=h.stores[u].findNearest(c(this,tt).time,c(this,N));y?(p.push(y.value),m.push(y.time)):(p.push(0),m.push(0))}const b=[];if(g==="off")for(const u of p)b.push(u);else{let u=0;if(g==="percent")for(const v of p)u+=v;let y=0;for(const v of p)y+=g==="percent"&&u>0?v/u*100:v,b.push(y)}for(let u=0;u<h.stores.length;u++){if(m[u]===0||!h.stores[u].isVisible())continue;const y=d[u%d.length],v=this.timeScale.timeToBitmapX(m[u]),C=this.yScale.valueToBitmapY(b[u]);e.context.beginPath(),e.context.arc(v,C,f+3*t.horizontalPixelRatio,0,Math.PI*2);const w=y.startsWith("#")?y+"40":/^rgb\(/i.test(y)?y.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):y.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=w,e.context.fill(),e.context.beginPath(),e.context.arc(v,C,f,0,Math.PI*2),e.context.fillStyle=y,e.context.fill()}}}for(const s of c(this,R))s.visible&&s.renderer instanceof H&&s.renderer.hasPulse&&s.renderer.drawPulseOverlay(e.context,this.timeScale,this.yScale,t.horizontalPixelRatio);e.context.restore()}),i){const{from:e,to:a}=this.timeScale.getRange();let o=!1;for(const s of c(this,R))if(!(!s.visible||!(s.renderer instanceof H)||!s.renderer.hasPulse)){for(const n of s.renderer.stores){const l=n.last();if(l&&l.time>=e&&l.time<=a){o=!0;break}}if(o)break}o&&c(this,ct).markDirty()}}}j=new WeakMap,z=new WeakMap,E=new WeakMap,ct=new WeakMap,yt=new WeakMap,R=new WeakMap,W=new WeakMap,vt=new WeakMap,N=new WeakMap,tt=new WeakMap,O=new WeakMap,Z=new WeakMap,Vt=new WeakMap,ht=new WeakMap,it=new WeakMap,xt=new WeakMap,nt=new WeakMap,dt=new WeakSet,Ct=function(r){if(r&&!c(this,R).some(i=>i.id===r))return r;let t;do t=`series_${++ji}`;while(c(this,R).some(i=>i.id===t));return t},Dt=new WeakMap,J=new WeakMap,q=new WeakMap,ut=new WeakMap;const Vi={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{upColor:"#089981",downColor:"#f23645",wickUpColor:"#089981",wickDownColor:"#f23645"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"}};function Yi(r){return parseInt(r.slice(1,3),16)*.299+parseInt(r.slice(3,5),16)*.587+parseInt(r.slice(5,7),16)*.114<128}function A(r){var t,i,e,a,o,s,n,l,h,d,g,f,p,m,b,u,y,v,C,w,D,M,B,L,V,P,$,X,K;const{background:Y,name:rt="Custom",description:_,fontUrl:U=null}=r,I=Yi(Y),ei=I?"#d1d4dc":"#24292f",ii=I?"#787b86":"#8b949e",Qt=I?"#26a69a":"#2da44e",Zt=I?"#ef5350":"#cf222e",oi=I?"#2962ff":"#0969da",ri=I?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",ai=I?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",te=I?Tt(Y,.1):he(Y,.05),si=I?pt(Y,.92):pt(Y,.95),ni=I?pt(Tt(Y,.15),.6):"rgba(200,200,200,0.5)",li=Lt,Wt=((t=r.candlestick)==null?void 0:t.upColor)??Qt,kt=((i=r.candlestick)==null?void 0:i.downColor)??Zt,gt=((e=r.line)==null?void 0:e.color)??oi,ee=((a=r.tooltip)==null?void 0:a.textColor)??ei,ci=((o=r.axis)==null?void 0:o.textColor)??ii,hi=((s=r.typography)==null?void 0:s.fontFamily)??li,di={background:Y,chartGradient:r.chartGradient??(I?[Tt(Y,.04),he(Y,.06)]:[Tt(Y,.06),Y]),typography:{fontFamily:hi,fontSize:((n=r.typography)==null?void 0:n.fontSize)??12,axisFontSize:((l=r.typography)==null?void 0:l.axisFontSize)??10,yFontSize:((h=r.typography)==null?void 0:h.yFontSize)??11,tooltipFontSize:((d=r.typography)==null?void 0:d.tooltipFontSize)??((g=r.typography)==null?void 0:g.fontSize)??12},grid:{color:((f=r.grid)==null?void 0:f.color)??ri,style:((p=r.grid)==null?void 0:p.style)??"dashed"},candlestick:{upColor:Wt,downColor:kt,wickUpColor:((m=r.candlestick)==null?void 0:m.wickUpColor)??Wt,wickDownColor:((b=r.candlestick)==null?void 0:b.wickDownColor)??kt},line:{color:gt,width:((u=r.line)==null?void 0:u.width)??1,areaTopColor:((y=r.line)==null?void 0:y.areaTopColor)??pt(gt,.08),areaBottomColor:((v=r.line)==null?void 0:v.areaBottomColor)??pt(gt,.01)},seriesColors:r.seriesColors??[gt,Qt,Zt],bands:{upper:((C=r.bands)==null?void 0:C.upper)??gt,lower:((w=r.bands)==null?void 0:w.lower)??kt},crosshair:{color:((D=r.crosshair)==null?void 0:D.color)??ai,labelBackground:((M=r.crosshair)==null?void 0:M.labelBackground)??te,labelTextColor:((B=r.crosshair)==null?void 0:B.labelTextColor)??ee},axis:{textColor:ci},yLabel:{upBackground:((L=r.yLabel)==null?void 0:L.upBackground)??Wt,downBackground:((V=r.yLabel)==null?void 0:V.downBackground)??kt,neutralBackground:((P=r.yLabel)==null?void 0:P.neutralBackground)??te,textColor:(($=r.yLabel)==null?void 0:$.textColor)??"#ffffff"},tooltip:{background:((X=r.tooltip)==null?void 0:X.background)??si,textColor:ee,borderColor:((K=r.tooltip)==null?void 0:K.borderColor)??ni}};return{name:rt,description:_,fontUrl:U,dark:I,theme:di}}function pt(r,t){const i=parseInt(r.slice(1,3),16),e=parseInt(r.slice(3,5),16),a=parseInt(r.slice(5,7),16);return`rgba(${i}, ${e}, ${a}, ${t})`}function Tt(r,t){if(!r.startsWith("#"))return r;const i=Math.min(255,Math.round(parseInt(r.slice(1,3),16)+255*t)),e=Math.min(255,Math.round(parseInt(r.slice(3,5),16)+255*t)),a=Math.min(255,Math.round(parseInt(r.slice(5,7),16)+255*t));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function he(r,t){if(!r.startsWith("#"))return r;const i=Math.max(0,Math.round(parseInt(r.slice(1,3),16)*(1-t))),e=Math.max(0,Math.round(parseInt(r.slice(3,5),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.slice(5,7),16)*(1-t)));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}const Bt="'JetBrains Mono', 'Fira Code', monospace",zt="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Lt="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Ht="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",be="'Roboto Mono', monospace",ye="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",_i="'IBM Plex Mono', monospace",Ui="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Gt="'Fira Code', monospace",Nt="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",ve="'Source Code Pro', monospace",xe="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",Oi="'Space Mono', monospace",$i="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",Jt="'Plus Jakarta Sans', sans-serif",qt="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",Xi="'Caveat', 'Comic Sans MS', cursive",Hi="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",Ce=A({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{upColor:"#96e072",downColor:"#ee5d43"},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:be},fontUrl:ye}),we=A({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{upColor:"#bae67e",downColor:"#f27983"},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:Lt},fontUrl:Ht}),Se=A({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{upColor:"#a6e3a1",downColor:"#f38ba8"},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:Lt},fontUrl:Ht}),ke=A({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{upColor:"#45c868",downColor:"#d04848"},line:{color:"#a080d8"},seriesColors:["#a080d8","#d49858","#45c868","#d068a0","#d04848","#c8d070","#70c0d8","#d04848","#6272a4","#d068a0"],bands:{upper:"#70c0d8",lower:"#d068a0"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#6272a4"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Gt},fontUrl:Nt}),Me=A({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{upColor:"#2da44e",downColor:"#cf222e"},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:_i},fontUrl:Ui}),Re=A({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{upColor:"#b8bb26",downColor:"#fb4934"},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:Bt},fontUrl:zt}),Te={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Hi,dark:!1,theme:{background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:Xi,fontSize:18,axisFontSize:13,yFontSize:15,tooltipFontSize:14},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{upColor:"#7a9a5e",downColor:"#b07060",wickUpColor:"#7a9a5e",wickDownColor:"#b07060"},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{textColor:"#a09880"},yLabel:{upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"}}},Gi="'Silkscreen', cursive",Ni="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",De=A({name:"Matrix",background:"#000000",candlestick:{upColor:"#00ff41",downColor:"#00802a"},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Gi},fontUrl:Ni,chartGradient:["#010a01","#000000"]}),Be=A({name:"Lavender Mist",background:"#f5f0f4",candlestick:{upColor:"#6b8e5e",downColor:"#b85468"},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:Jt},fontUrl:qt,chartGradient:["#f8f4f7","#f5f0f4"]}),ze=A({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{upColor:"#6a9a6e",downColor:"#c45070"},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:Lt},fontUrl:Ht}),Le=A({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{upColor:"#c3e88d",downColor:"#f07178"},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:be},fontUrl:ye}),Ji="'Silkscreen', cursive",qi="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Pe=A({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{upColor:"#111111",downColor:"#bbbbbb"},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:Ji,tooltipFontSize:9},fontUrl:qi}),Fe=A({name:"Mint Breeze",background:"#f6f5ee",candlestick:{upColor:"#2e9070",downColor:"#d04848"},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:Oi},fontUrl:$i,chartGradient:["#f8f7f0","#f6f5ee"]}),We=A({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{upColor:"#8ab862",downColor:"#d05470"},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Gt},fontUrl:Nt}),Ae=A({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{upColor:"#7ec699",downColor:"#e06c75"},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#495a5a"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:Bt},fontUrl:zt}),Ie=A({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{upColor:"#98c379",downColor:"#e06c75"},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:Bt},fontUrl:zt}),Ee=A({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{upColor:"#19f9d8",downColor:"#ff75b5"},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Gt},fontUrl:Nt}),je=A({name:"Peach Cream",background:"#fef6f0",candlestick:{upColor:"#5a9a68",downColor:"#d06848"},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:Jt},fontUrl:qt,chartGradient:["#fff8f2","#fef6f0"]}),Ve=A({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",grid:{color:"rgba(200,200,200,0.5)"},candlestick:{upColor:"#448c27",downColor:"#aa3731"},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:Jt},fontUrl:qt}),Ye=A({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{upColor:"#56949f",downColor:"#b4637a"},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:ve},fontUrl:xe}),_e=A({name:"Sand Dune",background:"#f4f0e8",candlestick:{upColor:"#5a8a50",downColor:"#b85040"},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:ve},fontUrl:xe,chartGradient:["#f8f4ec","#f4f0e8"]}),Ue=A({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{upColor:"#859900",downColor:"#dc322f"},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:Bt},fontUrl:zt}),Yt={Dracula:ke,"One Dark Pro":Ie,"Monokai Pro":We,"Night Owl":Ae,"Material Palenight":Le,Gruvbox:Re,Catppuccin:Se,"Ayu Mirage":we,Panda:Ee,Andromeda:Ce,Matrix:De,Handwritten:Te,"GitHub Light":Me,"Solarized Light":Ue,"Rosé Pine Dawn":Ye,"Quiet Light":Ve,"Lavender Mist":Be,"Mint Breeze":Fe,"Sand Dune":_e,"Peach Cream":je,Monochrome:Pe,Love:ze};function Ki(r){return(Yt[r]??Yt["One Dark Pro"]).theme}const _t=k.createContext(null);function G(){const r=k.useContext(_t);if(!r)throw new Error("useChartInstance must be used within <ChartContainer>");return r}function Oe({data:r,options:t,label:i,id:e,onSeriesId:a}){var n;const o=G(),s=k.useRef(null);return k.useLayoutEffect(()=>{const l=o.addBarSeries({...t,label:i??(t==null?void 0:t.label),layers:r.length,id:e});return s.current=l,a==null||a(l),()=>{o.removeSeries(l),s.current=null}},[o,r.length,e]),k.useLayoutEffect(()=>{const l=s.current;l&&o.batch(()=>{for(let h=0;h<r.length;h++)o.setBarLayerData(l,h,r[h])})},[o,r]),k.useEffect(()=>{s.current&&t&&o.updateSeriesOptions(s.current,t)},[o,(n=t==null?void 0:t.colors)==null?void 0:n.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking]),null}function Qi({data:r,options:t,id:i,onSeriesId:e}){const a=G(),o=k.useRef(null),s=k.useRef(0);return k.useLayoutEffect(()=>{const n=a.addCandlestickSeries({...t,id:i});return o.current=n,e==null||e(n),()=>{a.removeSeries(n),o.current=null,s.current=0}},[a,i]),k.useLayoutEffect(()=>{const n=o.current;if(!n)return;if(r.length===0){a.setSeriesData(n,[]),s.current=0;return}const l=s.current;if(l===0||r.length<l||r.length-l>5)a.setSeriesData(n,r);else if(r.length===l)a.updateData(n,r[r.length-1]);else for(let h=l;h<r.length;h++)a.appendData(n,r[h]);s.current=r.length},[a,r]),k.useEffect(()=>{o.current&&t&&a.updateSeriesOptions(o.current,t)},[a,t==null?void 0:t.upColor,t==null?void 0:t.downColor,t==null?void 0:t.wickUpColor,t==null?void 0:t.wickDownColor,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.candleGradient]),null}const Kt=k.createContext(null),Ut=Kt.Provider;function $e(){const r=k.useContext(Kt);if(!r)throw new Error("useTheme must be used within <ThemeProvider>");return r}function Zi(){return k.useContext(Kt)}function Xe({items:r,position:t="bottom",mode:i="toggle"}){const e=G(),a=$e(),[o,s]=k.useState(new Set),[,n]=k.useState(0);k.useLayoutEffect(()=>{const f=()=>{n(m=>m+1),s(new Set)},p=()=>n(m=>m+1);return e.on("seriesChange",f),e.on("dataUpdate",p),e.getSeriesIds().length>0&&n(m=>m+1),()=>{e.off("seriesChange",f),e.off("dataUpdate",p)}},[e]);const l=(r==null?void 0:r.map((f,p)=>({...f,seriesId:"",layerIndex:p,isLayer:!1})))??(()=>{const f=[];for(const p of e.getSeriesIds()){const m=e.getSeriesLayers(p);if(m){const b=e.getSeriesLabel(p);for(let u=0;u<m.length;u++)f.push({label:b?`${b} ${u+1}`:`Series ${u+1}`,color:m[u].color,seriesId:p,layerIndex:u,isLayer:!0})}else{const b=e.getSeriesColor(p),u=e.getSeriesLabel(p);b&&f.push({label:u??"Series",color:b,seriesId:p,layerIndex:0,isLayer:!1})}}return f})();if(l.length===0)return null;const h=f=>{s(f),e.beginUpdate();for(let p=0;p<l.length;p++){const m=l[p];m.seriesId&&(m.isLayer?e.setLayerVisible(m.seriesId,m.layerIndex,!f.has(p)):e.setSeriesVisible(m.seriesId,!f.has(p)))}e.endUpdate()},d=f=>{if(i==="solo")if(l.every((m,b)=>b===f||o.has(b)))h(new Set);else{const m=new Set(l.map((b,u)=>u));m.delete(f),h(m)}else{const p=new Set(o);p.has(f)?p.delete(f):p.add(f),h(p)}},g=t==="right";return x.jsx("div",{"data-legend":t,style:{display:"flex",flexDirection:g?"column":"row",flexWrap:"wrap",gap:g?6:14,padding:g?"8px 6px":"6px 8px",alignItems:g?"flex-start":"center",justifyContent:g?"flex-start":"center",fontFamily:a.typography.fontFamily,fontSize:a.typography.axisFontSize,color:a.axis.textColor,pointerEvents:"auto",flexShrink:0},children:l.map((f,p)=>{const m=o.has(p),b=!!f.seriesId;return x.jsxs("div",{onClick:b?()=>d(p):void 0,style:{display:"flex",alignItems:"center",gap:4,cursor:b?"pointer":"default",opacity:m?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[x.jsx("span",{style:{width:8,height:8,borderRadius:2,background:f.color,flexShrink:0}}),x.jsx("span",{style:{whiteSpace:"nowrap"},children:f.label})]},p)})})}function He({children:r,theme:t,axis:i,padding:e,gradient:a=!0,interactive:o,grid:s,style:n,className:l}){var V,P,$,X,K,Y,rt;const h=Zi(),d=t??h??void 0,g=k.useRef(null),f=k.useRef(null),[p,m]=k.useState(0);k.useLayoutEffect(()=>{if(!g.current||f.current)return;const _={};return i&&(_.axis=i),d&&(_.theme=d),e&&(_.padding=e),o!==void 0&&(_.interactive=o),s!==void 0&&(_.grid=s),f.current=new me(g.current,_),m(U=>U+1),()=>{const U=f.current;f.current=null,setTimeout(()=>{f.current||U==null||U.destroy()},0)}},[]),k.useEffect(()=>{f.current&&d&&f.current.setTheme(d)},[d]),k.useEffect(()=>{f.current&&i&&f.current.setAxis(i)},[(V=i==null?void 0:i.y)==null?void 0:V.width,(P=i==null?void 0:i.y)==null?void 0:P.min,($=i==null?void 0:i.y)==null?void 0:$.max,(X=i==null?void 0:i.y)==null?void 0:X.visible,(K=i==null?void 0:i.x)==null?void 0:K.height,(Y=i==null?void 0:i.x)==null?void 0:Y.visible]),k.useEffect(()=>{f.current&&e&&f.current.setPadding(e)},[e==null?void 0:e.top,e==null?void 0:e.bottom,typeof(e==null?void 0:e.right)=="object"?e.right.intervals:e==null?void 0:e.right,typeof(e==null?void 0:e.left)=="object"?e.left.intervals:e==null?void 0:e.left]),k.useEffect(()=>{f.current&&s!==void 0&&f.current.setGrid(s)},[s]);const b=f.current,{legendEl:u,overlay:y}=(()=>{let _=null;const U=[];return k.Children.forEach(r,I=>{k.isValidElement(I)&&I.type===Xe?_=I:U.push(I)}),{legendEl:_,overlay:U}})(),C=(((rt=u==null?void 0:u.props)==null?void 0:rt.position)??"bottom")==="right",w=d??(b==null?void 0:b.getTheme()),[D,M]=(w==null?void 0:w.chartGradient)??["transparent","transparent"],B=(w==null?void 0:w.background)??"transparent",L=a?`linear-gradient(to bottom, ${D} 0%, ${B} 70%, ${M} 100%)`:B;return x.jsxs("div",{className:l,style:{display:"flex",flexDirection:C?"row":"column",width:"100%",height:"100%",overflow:"hidden",background:L,...n},children:[x.jsx("div",{ref:g,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:b&&x.jsx(_t.Provider,{value:b,children:x.jsx(Ut,{value:d??b.getTheme(),children:x.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:2},children:y})})})}),b&&u&&x.jsx(_t.Provider,{value:b,children:x.jsx(Ut,{value:d??b.getTheme(),children:u})})]})}function Ge({data:r,options:t,label:i,id:e,onSeriesId:a}){var n;const o=G(),s=k.useRef(null);return k.useLayoutEffect(()=>{const l=o.addLineSeries({...t,label:i??(t==null?void 0:t.label),layers:r.length,id:e});return s.current=l,a==null||a(l),()=>{o.removeSeries(l),s.current=null}},[o,r.length,e]),k.useLayoutEffect(()=>{const l=s.current;l&&o.batch(()=>{for(let h=0;h<r.length;h++)o.setLineLayerData(l,h,r[h])})},[o,r]),k.useEffect(()=>{s.current&&t&&o.updateSeriesOptions(s.current,t)},[o,(n=t==null?void 0:t.colors)==null?void 0:n.join(","),t==null?void 0:t.lineWidth,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking]),null}function to({data:r,options:t,id:i,onSeriesId:e}){const a=G(),o=k.useRef(null);return k.useLayoutEffect(()=>{const s=a.addPieSeries({...t,id:i});return o.current=s,e==null||e(s),()=>{a.removeSeries(s),o.current=null}},[a,i]),k.useEffect(()=>{o.current&&t&&a.updateSeriesOptions(o.current,t)},[a,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.strokeColor,t==null?void 0:t.strokeWidth,t==null?void 0:t.colors]),k.useLayoutEffect(()=>{o.current&&a.setPieData(o.current,r)},[a,r]),null}function Pt(r,t,i){const e=Array.isArray(t)?t:[t];return{subscribe:a=>{for(const o of e)r.on(o,a);return()=>{for(const o of e)r.off(o,a)}},getSnapshot:i}}function Ne(r){const t=k.useMemo(()=>Pt(r,["viewportChange","dataUpdate","seriesChange"],()=>r.getVisibleRange()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Je(r){const t=k.useMemo(()=>Pt(r,["viewportChange","dataUpdate","seriesChange"],()=>r.getYRange()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function qe(r,t){const i=k.useMemo(()=>{let e=r.getLastValue(t);return{subscribe:o=>{const s=()=>{const l=r.getLastValue(t);(e==null?void 0:e.value)===(l==null?void 0:l.value)&&(e==null?void 0:e.isLive)===(l==null?void 0:l.isLive)||(e=l,o())},n=()=>{const l=r.getLastValue(t),h=l?r.yScale.valueToY(l.value):null,d=e?r.yScale.valueToY(e.value):null;h===d&&(e==null?void 0:e.value)===(l==null?void 0:l.value)&&(e==null?void 0:e.isLive)===(l==null?void 0:l.isLive)||(e=l,o())};return r.on("dataUpdate",s),r.on("viewportChange",n),()=>{r.off("dataUpdate",s),r.off("viewportChange",n)}},getSnapshot:()=>e}},[r,t]);return k.useSyncExternalStore(i.subscribe,i.getSnapshot)}function Ke(r,t){const i=k.useMemo(()=>Pt(r,"dataUpdate",()=>r.getPreviousClose(t)),[r,t]);return k.useSyncExternalStore(i.subscribe,i.getSnapshot)}function Ft(r){const t=k.useMemo(()=>Pt(r,"crosshairMove",()=>r.getCrosshairPosition()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function eo(){const r=G(),t=Ft(r);if(!t)return null;const i=r.getTheme(),e=r.getDataInterval(),a={background:i.crosshair.labelBackground,color:i.crosshair.labelTextColor,fontSize:i.typography.axisFontSize,fontFamily:i.typography.fontFamily,padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none"};return x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...a},children:r.yScale.formatY(t.y)}),x.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...a},children:St(t.time,e)})]})}const io=["0","1","2","3","4","5","6","7","8","9"];function oo(r){const t=[];for(const i of r)i>="0"&&i<="9"?t.push({type:"digit",value:i}):t.push({type:"symbol",value:i});return t}function Qe({value:r,format:t,locale:i="en-US",spinDuration:e=350,className:a,style:o}){const n=k.useMemo(()=>new Intl.NumberFormat(i,t),[i,t]).format(r),l=oo(n);return x.jsx("span",{className:a,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...o},children:l.map((h,d)=>h.type==="digit"?x.jsx(ro,{digit:parseInt(h.value),duration:e},`d${d}`):x.jsx("span",{style:{display:"inline-block"},children:h.value},`s${d}`))})}function ro({digit:r,duration:t}){const i=k.useRef(!1);return k.useEffect(()=>{i.current=!0},[]),x.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:x.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-r*1.2}em)`,transition:i.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:io.map(e=>x.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:e},e))})})}function ao(r){return r>=1e9?(r/1e9).toFixed(1)+"B":r>=1e6?(r/1e6).toFixed(1)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toLocaleString()}function so({seriesId:r,format:t="value"}){const i=G(),e=i.getTheme(),[,a]=k.useState(0);k.useEffect(()=>{const s=()=>a(n=>n+1);return i.on("dataUpdate",s),()=>{i.off("dataUpdate",s)}},[i]);const o=i.getPieSlices(r);return!o||o.length===0?null:x.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 12px",fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize,color:e.tooltip.textColor,pointerEvents:"auto"},children:o.map((s,n)=>x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[x.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:s.color,flexShrink:0}}),x.jsx("span",{style:{flex:1,opacity:.8},children:s.label}),t==="value"&&x.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums"},children:ao(s.value)}),x.jsxs("span",{style:{opacity:t==="percent"?1:.5,fontWeight:t==="percent"?600:400,fontSize:t==="percent"?e.typography.fontSize:e.typography.axisFontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[s.percent.toFixed(1),"%"]})]},n))})}function no({seriesId:r}){const t=G(),i=Ft(t),e=t.getPieHoverInfo(r);if(!e||!i)return null;const a=t.getTheme(),o=t.getMediaSize(),s=160,n=70,l=16,h=16,d=i.mediaX+l+s>o.width?i.mediaX-l-s:i.mediaX+l,g=i.mediaY+h+n>o.height?i.mediaY-h-n:i.mediaY+h;return x.jsxs("div",{style:{position:"absolute",left:d,top:g,pointerEvents:"none",background:a.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${a.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:a.typography.fontSize,fontFamily:a.typography.fontFamily,color:a.tooltip.textColor,zIndex:10,display:"flex",flexDirection:"column",gap:6},children:[x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:e.color,flexShrink:0}}),x.jsx("span",{style:{fontWeight:600},children:e.label})]}),x.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[x.jsx("span",{style:{opacity:.6},children:e.value.toLocaleString()}),x.jsxs("span",{style:{fontWeight:600},children:[e.percent.toFixed(1),"%"]})]})]})}function lo(r,t){if(r.startsWith("rgba")||!r.startsWith("#"))return r;const i=parseInt(r.slice(1,3),16),e=parseInt(r.slice(3,5),16),a=parseInt(r.slice(5,7),16);return`rgba(${i}, ${e}, ${a}, ${t})`}function co(r){return Math.abs(r)>=1e6?`${(r/1e6).toFixed(1)}M`:Math.abs(r)>=1e4?`${(r/1e3).toFixed(1)}K`:Math.abs(r)>=1e3?`${(r/1e3).toFixed(2)}K`:Math.abs(r)<1?r.toFixed(4):Math.abs(r)<10?r.toFixed(2):r.toFixed(1)}function ho(r){if(r.length<2)return{value:0,pct:0,positive:!0};const t=r[0].value,e=r[r.length-1].value-t,a=t!==0?e/t*100:0;return{value:e,pct:a,positive:e>=0}}function uo({data:r,theme:t,variant:i="line",valuePosition:e="right",formatValue:a=co,label:o,sublabel:s,color:n,negativeColor:l,areaFill:h=!0,width:d=140,height:g=48,lineWidth:f=1.5,gradient:p=!0,style:m}){const b=r.length>0?r[r.length-1].value:0,u=k.useMemo(()=>ho(r),[r]),y=n??t.seriesColors[0],v=l??t.candlestick.downColor,C=u.positive?t.candlestick.upColor:t.candlestick.downColor,w=e!=="none"&&x.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[o&&x.jsx("div",{style:{fontSize:t.typography.axisFontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),x.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:a(b)}),s!==void 0?x.jsx("div",{style:{fontSize:t.typography.axisFontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:s}):x.jsxs("div",{style:{fontSize:t.typography.axisFontSize-1,fontWeight:500,color:C,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[u.positive?"+":"",u.pct.toFixed(1),"%"]})]}),D=x.jsx("div",{style:{width:d,height:g,flexShrink:0,borderRadius:4,overflow:"hidden"},children:x.jsx(He,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:!1,children:i==="line"?x.jsx(Ge,{data:[r],options:{colors:[y],lineWidth:f,areaFill:h,pulse:!1,stacking:"off"}}):x.jsx(Oe,{data:[r],options:{colors:[y,v],barWidthRatio:.7,stacking:"off"}})})});return x.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:lo(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...m},children:[e==="left"&&w,D,e==="right"&&w]})}function Ze(){const r=G();Ne(r);const t=r.getTheme(),i=r.getDataInterval(),{ticks:e,tickInterval:a}=r.timeScale.niceTickValues(i),o=new Set(e),n=k.useRef(new Map).current,l=performance.now();for(const d of e)n.has(d)?n.get(d).opacity=1:n.set(d,{opacity:1,addedAt:l});for(const[d,g]of n)o.has(d)||g.opacity!==0&&(g.opacity=0,g.fadedAt=l);for(const[d,g]of n)g.opacity===0&&g.fadedAt!==void 0&&l-g.fadedAt>600&&n.delete(d);const h=Array.from(n.entries());return x.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:r.yAxisWidth,height:r.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:h.map(([d,g])=>{const f=r.timeScale.timeToX(d);return x.jsx("span",{style:{position:"absolute",left:f,transform:"translateX(-50%)",color:t.axis.textColor,fontSize:t.typography.axisFontSize,fontFamily:t.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:g.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:St(d,a)},d)})})}function fo(r,t){return t==="none"||r.length<=1?r:[...r].sort((i,e)=>{const a="value"in i.data?i.data.value:i.data.close,o="value"in e.data?e.data.value:e.data.close;return t==="asc"?a-o:o-a})}function go({seriesId:r,sort:t="none",showLegend:i,legend:e}){const a=i??e??!0,o=G(),s=Ft(o),n=r?[r]:o.getSeriesIds(),[,l]=k.useState(0);k.useEffect(()=>{const u=()=>l(y=>y+1);return o.on("dataUpdate",u),()=>o.off("dataUpdate",u)},[o]);const h=[];if(s)for(const u of n){const y=o.getLayerSnapshots(u,s.time);if(y)for(let v=0;v<y.length;v++)h.push({id:`${u}_layer${v}`,label:o.getSeriesLabel(u),data:{time:s.time,value:y[v].value},color:y[v].color});else{const v=o.getDataAtTime(u,s.time);v&&h.push({id:u,label:o.getSeriesLabel(u),data:v,color:o.getSeriesColor(u)??"#888"})}}let d;if(h.length>0)d=h;else{const u=[];for(const y of n){const v=o.getLastData(y);if(!v)continue;const C=o.getLayerSnapshots(y,v.time);if(C)for(let w=0;w<C.length;w++)u.push({id:`${y}_layer${w}`,label:o.getSeriesLabel(y),data:{time:v.time,value:C[w].value},color:C[w].color});else u.push({id:y,label:o.getSeriesLabel(y),data:v,color:o.getSeriesColor(y)??"#888"})}d=u}const g=fo(d,t),f=o.getTheme();if(g.length===0)return null;const p=o.getDataInterval(),m=o.getMediaSize(),b=g[0].data.time;return x.jsxs(x.Fragment,{children:[a&&x.jsxs("div",{style:{position:"absolute",top:24,left:8,pointerEvents:"none",display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",maxWidth:"70%",fontSize:f.typography.fontSize,fontFamily:f.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:s?1:.6,transition:"opacity 0.2s ease"},children:[x.jsx("span",{style:{color:f.axis.textColor,marginRight:2},children:St(b,p)}),g.map(u=>{if("open"in u.data){const C=u.data,D=C.close>=C.open?f.candlestick.upColor:f.candlestick.downColor;return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[x.jsx(mt,{label:"O",value:C.open,color:D,dim:f.axis.textColor}),x.jsx(mt,{label:"H",value:C.high,color:D,dim:f.axis.textColor}),x.jsx(mt,{label:"L",value:C.low,color:D,dim:f.axis.textColor}),x.jsx(mt,{label:"C",value:C.close,color:D,dim:f.axis.textColor}),C.volume!=null&&x.jsx(mt,{label:"V",value:C.volume,color:f.axis.textColor,dim:f.axis.textColor,volume:!0})]},u.id)}const v=u.data;return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[x.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u.color,flexShrink:0}}),x.jsx("span",{style:{color:u.color,fontWeight:500},children:v.value.toFixed(2)})]},u.id)})]}),s&&h.length>0&&x.jsx(po,{snapshots:g,x:s.mediaX,y:s.mediaY,chartWidth:m.width-o.yAxisWidth,chartHeight:m.height-o.xAxisHeight,theme:f,dataInterval:p})]})}function mt({label:r,value:t,color:i,dim:e,volume:a}){return x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:e,opacity:.5,marginLeft:5},children:r}),x.jsx("span",{style:{color:i,fontWeight:500,marginLeft:2},children:a?ti(t):t.toFixed(2)})]})}function po({snapshots:r,x:t,y:i,chartWidth:e,chartHeight:a,theme:o,dataInterval:s}){const n=r.some(C=>"open"in C.data),l=r.filter(C=>!("open"in C.data)).length,h=160,d=n?140:40+l*22,g=16,f=16,p=t+g+h>e?t-g-h:t+g,m=i+f+d>a?i-f-d:i+f,b=o.tooltip.background,u=o.tooltip.borderColor,y="0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",v=r[0].data.time;return x.jsxs("div",{style:{position:"absolute",left:p,top:m,pointerEvents:"none",background:b,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${u}`,borderRadius:8,padding:"10px 14px",boxShadow:y,fontSize:o.typography.tooltipFontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,minWidth:140,zIndex:10,transition:"opacity 0.15s ease"},children:[x.jsxs("div",{style:{fontSize:o.typography.axisFontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${u}`,letterSpacing:"0.02em"},children:[fe(v)," ",St(v,s)]}),r.map(C=>{if("open"in C.data){const M=C.data,B=M.close>=M.open,L=o.candlestick.upColor,V=o.candlestick.downColor,P=B?L:V;return x.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[x.jsx(bt,{label:"Open",value:M.open,color:P}),x.jsx(bt,{label:"High",value:M.high,color:P}),x.jsx(bt,{label:"Low",value:M.low,color:P}),x.jsx(bt,{label:"Close",value:M.close,color:P}),M.volume!=null&&x.jsx(bt,{label:"Volume",value:M.volume,color:o.tooltip.textColor,volume:!0})]},C.id)}const D=C.data;return x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[x.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:C.color,flexShrink:0}}),x.jsx("span",{style:{opacity:.6,flex:1},children:C.label??"Value"}),x.jsx("span",{style:{fontWeight:600,color:C.color},children:D.value.toFixed(2)})]},C.id)})]})}function bt({label:r,value:t,color:i,volume:e}){return x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{opacity:.5},children:r}),x.jsx("span",{style:{fontWeight:600,color:i,textAlign:"right"},children:e?ti(t):t.toFixed(2)})]})}function ti(r){return r>=1e9?(r/1e9).toFixed(2)+"B":r>=1e6?(r/1e6).toFixed(2)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toFixed(0)}function mo(){const r=G();Je(r);const t=r.getTheme(),i=r.yScale.niceTickValues(),e=new Set(i),o=k.useRef(new Map).current,s=performance.now();for(const l of i)o.has(l)?o.get(l).opacity=1:o.set(l,{opacity:1,addedAt:s});for(const[l,h]of o)e.has(l)||h.opacity!==0&&(h.opacity=0,h.fadedAt=s);for(const[l,h]of o)h.opacity===0&&h.fadedAt!==void 0&&s-h.fadedAt>600&&o.delete(l);const n=Array.from(o.entries());return x.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:r.xAxisHeight,width:r.yAxisWidth,pointerEvents:"none"},children:n.map(([l,h])=>{const d=r.yScale.valueToY(l);return x.jsx("span",{style:{position:"absolute",right:8,top:d,transform:"translateY(-50%)",color:t.axis.textColor,fontSize:t.typography.axisFontSize,fontFamily:t.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:h.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:r.yScale.formatY(l)},l)})})}function bo({seriesId:r,color:t}){const i=G();k.useEffect(()=>(i.setYLabel(!0),()=>i.setYLabel(!1)),[i]);const e=qe(i,r),a=Ke(i,r);if(!e)return null;const{value:o,isLive:s}=e,n=i.getTheme(),l=i.yScale.valueToY(o);let h;if(!s)h=n.axis.textColor;else if(t)h=t;else{const p=a===null?"neutral":o>a?"up":o<a?"down":"neutral";h=p==="up"?n.yLabel.upBackground:p==="down"?n.yLabel.downBackground:n.yLabel.neutralBackground}const d=i.yScale.getRange(),g=d.max-d.min,f=g<.1?6:g<10?4:g<1e3?2:0;return x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"absolute",left:0,right:i.yAxisWidth,top:l,height:0,borderTop:`1px dashed ${h}`,opacity:.5,pointerEvents:"none",zIndex:2}}),x.jsx("div",{style:{position:"absolute",right:4,top:l,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:h,color:n.yLabel.textColor,fontSize:n.typography.yFontSize,fontFamily:n.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:x.jsx(Qe,{value:o,format:{minimumFractionDigits:f,maximumFractionDigits:f,useGrouping:!1},spinDuration:350})})]})}exports.BarSeries=Oe;exports.CandlestickSeries=Qi;exports.ChartContainer=He;exports.ChartInstance=me;exports.Crosshair=eo;exports.Legend=Xe;exports.LineSeries=Ge;exports.NumberFlow=Qe;exports.PieLegend=so;exports.PieSeries=to;exports.PieTooltip=no;exports.Sparkline=uo;exports.ThemeProvider=Ut;exports.TimeAxis=Ze;exports.Tooltip=go;exports.XAxis=Ze;exports.YAxis=mo;exports.YLabel=bo;exports.andromeda=Ce;exports.ayuMirage=we;exports.buildTheme=Ki;exports.catppuccin=Se;exports.createTheme=A;exports.darkTheme=pe;exports.detectInterval=ue;exports.dracula=ke;exports.formatDate=fe;exports.formatTime=St;exports.githubLight=Me;exports.gruvbox=Re;exports.handwritten=Te;exports.highContrast=De;exports.lavenderMist=Be;exports.lightPink=ze;exports.lightTheme=Vi;exports.materialPalenight=Le;exports.minimalLight=Pe;exports.mintBreeze=Fe;exports.monokaiPro=We;exports.nightOwl=Ae;exports.normalizeTime=jt;exports.oneDarkPro=Ie;exports.panda=Ee;exports.peachCream=je;exports.quietLight=Ve;exports.rosePineDawn=Ye;exports.sandDune=_e;exports.solarizedLight=Ue;exports.themes=Yt;exports.useChartInstance=G;exports.useCrosshairPosition=Ft;exports.useLastYValue=qe;exports.usePreviousClose=Ke;exports.useTheme=$e;exports.useVisibleRange=Ne;exports.useYRange=Je;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),x=require("react/jsx-runtime");var fi=Object.defineProperty,ue=r=>{throw TypeError(r)},gi=(r,t,i)=>t in r?fi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,S=(r,t,i)=>gi(r,typeof t!="symbol"?t+"":t,i),$t=(r,t,i)=>t.has(r)||ue("Cannot "+i),c=(r,t,i)=>($t(r,t,"read from private field"),i?i.call(r):t.get(r)),F=(r,t,i)=>t.has(r)?ue("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,i),T=(r,t,i,e)=>($t(r,t,"write to private field"),t.set(r,i),i),Rt=(r,t,i)=>($t(r,t,"access private method"),i),oe=(r,t,i,e)=>({set _(a){T(r,t,a)},get _(){return c(r,t,e)}});class St{constructor(){S(this,"listeners",new Map)}on(t,i){let e=this.listeners.get(t);e||(e=new Set,this.listeners.set(t,e)),e.add(i)}off(t,i){var e;(e=this.listeners.get(t))==null||e.delete(i)}emit(t,...i){var e;(e=this.listeners.get(t))==null||e.forEach(a=>a(...i))}removeAllListeners(){this.listeners.clear()}}function re(r,t,i){const e=document.createElement("canvas");return e.style.position="absolute",e.style.inset="0",e.style.width="100%",e.style.height="100%",e.style.display="block",e.style.zIndex=String(t),r.appendChild(e),e}class pi extends St{constructor(t){super(),S(this,"mainCanvas"),S(this,"mainCtx"),S(this,"overlayCanvas"),S(this,"overlayCtx"),S(this,"resizeObserver"),S(this,"_size"),S(this,"supportsDevicePixelContentBox",!1),this.mainCanvas=re(t,0),this.overlayCanvas=re(t,1),this.mainCtx=this.mainCanvas.getContext("2d",{alpha:!0}),this.overlayCtx=this.overlayCanvas.getContext("2d",{alpha:!0});const i=window.devicePixelRatio||1;this._size={media:{width:0,height:0},bitmap:{width:0,height:0},horizontalPixelRatio:i,verticalPixelRatio:i},this.resizeObserver=new ResizeObserver(a=>{this.handleResize(a[0])});try{this.resizeObserver.observe(t,{box:"device-pixel-content-box"}),this.supportsDevicePixelContentBox=!0}catch{this.resizeObserver.observe(t,{box:"content-box"})}const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){const a=window.devicePixelRatio||1,o=a,s=Math.round(e.width*a),n=Math.round(e.height*o);this.mainCanvas.width=s,this.mainCanvas.height=n,this.overlayCanvas.width=s,this.overlayCanvas.height=n,this._size={media:{width:e.width,height:e.height},bitmap:{width:s,height:n},horizontalPixelRatio:s/e.width,verticalPixelRatio:n/e.height}}}handleResize(t){var i,e;let a,o,s,n;if(this.supportsDevicePixelContentBox&&(i=t.devicePixelContentBoxSize)!=null&&i[0]){const d=t.devicePixelContentBoxSize[0];a=d.inlineSize,o=d.blockSize;const g=t.contentBoxSize[0];s=g.inlineSize,n=g.blockSize}else{const d=(e=t.contentBoxSize)==null?void 0:e[0];if(d)s=d.inlineSize,n=d.blockSize;else{const f=t.contentRect;s=f.width,n=f.height}const g=window.devicePixelRatio||1;a=Math.round(s*g),o=Math.round(n*g)}if(a===0||o===0)return;this.mainCanvas.width=a,this.mainCanvas.height=o,this.overlayCanvas.width=a,this.overlayCanvas.height=o;const l=a/s,h=o/n;this._size={media:{width:s,height:n},bitmap:{width:a,height:o},horizontalPixelRatio:l,verticalPixelRatio:h},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:i,height:e}=this._size.bitmap;this.overlayCtx.clearRect(0,0,i,e),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 mi(r,t,i,e){const{context:a,bitmapSize:o,horizontalPixelRatio:s}=r;a.strokeStyle=e.crosshair.color,a.lineWidth=1,a.setLineDash([4*s,4*s]);const n=Math.round(t)+.5,l=Math.round(i)+.5;a.beginPath(),a.moveTo(n,0),a.lineTo(n,o.height),a.moveTo(0,l),a.lineTo(o.width,l),a.stroke(),a.setLineDash([])}function bi(r,t,i,e,a){const{context:o,bitmapSize:s,horizontalPixelRatio:n,verticalPixelRatio:l}=r;o.strokeStyle=e.grid.color,o.lineWidth=1,e.grid.style==="dashed"?o.setLineDash([4*n,4*n]):e.grid.style==="dotted"&&o.setLineDash([1*n,3*n]);const h=i.niceTickValues();o.beginPath();for(const g of h){const f=Math.round(i.valueToBitmapY(g))+.5;o.moveTo(0,f),o.lineTo(s.width,f)}o.stroke();const{ticks:d}=t.niceTickValues(a);o.beginPath();for(const g of d){const f=Math.round(t.timeToBitmapX(g))+.5;o.moveTo(f,0),o.lineTo(f,s.height)}o.stroke(),o.setLineDash([])}function ae(r,t,i){return r+(t-r)*i}function At(r,t,i){let e=0,a=r.length-1;for(;e<=a;){const o=e+a>>>1,s=i(r[o]);if(s<t)e=o+1;else if(s>t)a=o-1;else return o}return e}class Xt extends St{constructor(){super(...arguments),S(this,"data",[]),S(this,"_visible",!0),S(this,"cachedRange",null),S(this,"cachedResult",[])}setVisible(t){this._visible=t}isVisible(){return this._visible}setData(t){let i=!0;for(let e=1;e<t.length;e++)if(t[e].time<t[e-1].time){i=!1;break}this.data=i?t.slice():[...t].sort((e,a)=>e.time-a.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,i){if(this.data.length===0)return[];if(this.cachedRange&&this.cachedRange.from===t&&this.cachedRange.to===i)return this.cachedResult;const e=Math.max(0,At(this.data,t,o=>o.time)-1),a=Math.min(this.data.length,At(this.data,i,o=>o.time)+1);return this.cachedResult=this.data.slice(e,a),this.cachedRange={from:t,to:i},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,i){if(this.data.length===0)return null;const e=At(this.data,t,s=>s.time);let a=null,o=i;for(let s=Math.max(0,e-1);s<=Math.min(this.data.length-1,e+1);s++){const n=Math.abs(this.data[s].time-t);n<=o&&(o=n,a=this.data[s])}return a}}class yi{constructor(t,i,e){S(this,"dragging",!1),S(this,"lastX",0),this.viewport=t,this.timeScale=i,this.canvas=e}handleMouseDown(t){t.button===0&&(this.dragging=!0,this.lastX=t.clientX,this.canvas.style.cursor="grabbing")}handleMouseMove(t){if(!this.dragging)return;const i=t.clientX-this.lastX;this.lastX=t.clientX;const e=this.timeScale.pixelDeltaToTimeDelta(-i);this.viewport.pan(e)}handleMouseUp(){this.dragging&&(this.dragging=!1,this.canvas.style.cursor="crosshair")}isDragging(){return this.dragging}}class vi{constructor(t,i){this.viewport=t,this.timeScale=i}handleWheel(t){t.preventDefault();const i=xi(t.deltaY,t.deltaMode),e=Math.exp(i*.005),a=this.timeScale.getMediaWidth(),o=Math.min(t.offsetX,a),s=this.timeScale.xToTime(o);this.viewport.zoomAt(s,e)}}function xi(r,t){return t===WheelEvent.DOM_DELTA_LINE?r*8:t===WheelEvent.DOM_DELTA_PAGE?r*24:r}class Ci extends St{constructor(t,i,e,a){super(),S(this,"zoom"),S(this,"pan"),S(this,"canvas"),S(this,"timeScale"),S(this,"yScale"),S(this,"viewport"),S(this,"onWheel",o=>{this.zoom.handleWheel(o)}),S(this,"onMouseDown",o=>{this.pan.handleMouseDown(o)}),S(this,"onMouseMove",o=>{this.pan.isDragging()&&this.pan.handleMouseMove(o),this.emitCrosshair(o.offsetX,o.offsetY)}),S(this,"onMouseUp",()=>{this.pan.handleMouseUp()}),S(this,"onMouseLeave",()=>{this.pan.handleMouseUp(),this.emit("crosshairMove",null)}),S(this,"onDblClick",()=>{}),S(this,"lastTouchDist",0),S(this,"lastTouchCenter",0),S(this,"touchCount",0),S(this,"onTouchStart",o=>{o.preventDefault(),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)}),S(this,"onTouchMove",o=>{if(o.preventDefault(),o.touches.length===1&&this.touchCount===1){this.pan.handleMouseMove({clientX:o.touches[0].clientX});const s=this.canvas.getBoundingClientRect();this.emitCrosshair(o.touches[0].clientX-s.left,o.touches[0].clientY-s.top)}else if(o.touches.length===2){const s=Math.abs(o.touches[0].clientX-o.touches[1].clientX),n=(o.touches[0].clientX+o.touches[1].clientX)/2,l=this.canvas.getBoundingClientRect();if(this.lastTouchDist>0){const h=this.lastTouchDist/s,d=this.timeScale.xToTime(n-l.left);this.viewport.zoomAt(d,h)}this.lastTouchDist=s,this.lastTouchCenter=n}}),S(this,"onTouchEnd",o=>{o.touches.length===0&&(this.pan.handleMouseUp(),this.touchCount=0,this.lastTouchDist=0)}),this.canvas=t,this.viewport=i,this.timeScale=e,this.yScale=a,this.zoom=new vi(i,e),this.pan=new yi(i,e,t),t.style.cursor="crosshair",t.style.touchAction="none",t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("mousedown",this.onMouseDown),t.addEventListener("mousemove",this.onMouseMove),t.addEventListener("mouseup",this.onMouseUp),t.addEventListener("mouseleave",this.onMouseLeave),t.addEventListener("dblclick",this.onDblClick),t.addEventListener("touchstart",this.onTouchStart,{passive:!1}),t.addEventListener("touchmove",this.onTouchMove,{passive:!1}),t.addEventListener("touchend",this.onTouchEnd)}emitCrosshair(t,i){const e=this.timeScale.xToTime(t),a=this.yScale.yToValue(i);this.emit("crosshairMove",{mediaX:t,mediaY:i,time:e,y:a})}destroy(){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()}}class se{constructor(t){S(this,"dirty",!1),S(this,"rafId",null),S(this,"callback"),S(this,"render",i=>{this.dirty=!1,this.rafId=null,this.callback(i)}),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 ct=6e4,nt=36e5,rt=864e5;function Vt(r){return r instanceof Date?r.getTime():r}function wi(r){return r.length===0||typeof r[0].time=="number"?r:r.map(t=>({...t,time:t.time.getTime()}))}function Si(r){return r.length===0||typeof r[0].time=="number"?r:r.map(t=>({...t,time:t.time.getTime()}))}function fe(r){if(r.length<2)return rt;const t=[];for(let i=1;i<Math.min(r.length,20);i++)t.push(r[i]-r[i-1]);return t.sort((i,e)=>i-e),t[Math.floor(t.length/2)]}function kt(r,t){const i=new Date(r);return t>=rt?i.toLocaleDateString("en-US",{month:"short",day:"numeric"}):t>=nt?i.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):i.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ge(r){return new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function ki(r){const t=[1e3,5e3,1e4,15e3,3e4],i=[ct,5*ct,10*ct,15*ct,30*ct],e=[nt,2*nt,4*nt,6*nt,12*nt],a=[rt,7*rt,30*rt,90*rt,365*rt];return r<ct?[...t,...i,...e,...a]:r<nt?[...i,...e,...a]:r<rt?[...e,...a]:a}class Mi{constructor(){S(this,"from",0),S(this,"to",0),S(this,"width",1),S(this,"pixelRatio",1)}update(t,i,e){this.from=t.from,this.to=t.to,this.width=i,this.pixelRatio=e}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};const i=ki(t),e=(this.to-this.from)/this.width*80;let a=i[i.length-1];for(const n of i)if(n>=e){a=n;break}const o=[],s=Math.ceil(this.from/a)*a;for(let n=s;n<=this.to;n+=a)o.push(n);return{ticks:o,tickInterval:a}}getRange(){return{from:this.from,to:this.to}}getMediaWidth(){return this.width}}const jt=[1e-4,2e-4,5e-4,.001,.002,.005,.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100,200,500,1e3,2e3,5e3,1e4,2e4,5e4];class Ri{constructor(){S(this,"min",0),S(this,"max",0),S(this,"height",1),S(this,"pixelRatio",1)}update(t,i,e){this.min=t.min,this.max=t.max,this.height=i,this.pixelRatio=e}valueToY(t){return(1-(t-this.min)/(this.max-this.min))*this.height}valueToBitmapY(t){return Math.round(this.valueToY(t)*this.pixelRatio)}yToValue(t){return this.max-t/this.height*(this.max-this.min)}niceTickValues(){if(this.max<=this.min)return[];const t=(this.max-this.min)/this.height*50;let i=jt[jt.length-1];for(const o of jt)if(o>=t){i=o;break}const e=[],a=Math.ceil(this.min/i)*i;for(let o=a;o<=this.max;o+=i)e.push(o);return e}getRange(){return{min:this.min,max:this.max}}getMediaHeight(){return this.height}formatY(t){const i=this.max-this.min;return i<.01?t.toFixed(6):i<.1?t.toFixed(4):i<10?t.toFixed(2):i<1e3?t.toFixed(1):t.toFixed(0)}}const Ti={colors:["#26a69a","#ef5350"],barWidthRatio:.6,stacking:"off"};class Z{constructor(t,i){S(this,"stores"),S(this,"options"),this.stores=Array.from({length:t},()=>new Xt),this.options={...Ti,...i}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}getValueRange(t,i){if(this.options.stacking==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const e=this.stores.map(n=>n.isVisible()?n.getVisibleData(t,i):[]);if(this.options.stacking==="off"){let n=1/0,l=-1/0;for(const h of e)for(const d of h)d.value<n&&(n=d.value),d.value>l&&(l=d.value);return n<1/0?{min:n,max:l}:null}const a=new Map;for(let n=0;n<e.length;n++)for(const l of e[n])a.has(l.time)||a.set(l.time,new Array(e.length).fill(0)),a.get(l.time)[n]=l.value;let o=0,s=0;for(const n of a.values()){let l=0,h=0;for(const d of n)d>0?l+=d:h+=d;l>s&&(s=l),h<o&&(o=h)}return s>o?{min:o,max:s}:null}render(t){switch(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:i,timeScale:e,yScale:a,dataInterval:o}=t,{context:s}=i,n=e.getRange(),l=e.barWidthBitmap(o),h=Math.max(1,Math.round(l*this.options.barWidthRatio)-2),d=Math.floor(h/2),g=a.getRange().min<0,f=g?a.valueToBitmapY(0):i.bitmapSize.height;if(this.stores.length===1){if(!this.stores[0].isVisible())return;const p=this.options.colors[0],m=this.options.colors.length>1?this.options.colors[1]:p,b=this.stores[0].getVisibleData(n.from,n.to);for(const u of b){const y=e.timeToBitmapX(u.time);if(u.value>=0){const v=a.valueToBitmapY(u.value),C=Math.max(1,f-v);this.fillBar(s,y-d,v,h,C,p)}else{const v=a.valueToBitmapY(u.value),C=Math.max(1,v-f);this.fillBar(s,y-d,f,h,C,m)}}}else{const p=this.stores.map(b=>b.isVisible()?b.getVisibleData(n.from,n.to):[]),m=new Map;for(let b=0;b<p.length;b++)for(const u of p[b]){let y=m.get(u.time);y||(y=[],m.set(u.time,y)),y.push({layer:b,value:u.value})}for(const[b,u]of m){u.sort((v,C)=>Math.abs(C.value)-Math.abs(v.value));const y=e.timeToBitmapX(b);for(const{layer:v,value:C}of u){const w=this.options.colors[v%this.options.colors.length];if(C>=0){const D=a.valueToBitmapY(C),M=Math.max(1,f-D);this.fillBar(s,y-d,D,h,M,w)}else{const D=a.valueToBitmapY(C),M=Math.max(1,D-f);this.fillBar(s,y-d,f,h,M,w)}}}}if(g){s.strokeStyle=t.theme.grid.color,s.lineWidth=1;const p=Math.round(f)+.5;s.beginPath(),s.moveTo(0,p),s.lineTo(i.bitmapSize.width,p),s.stroke()}}renderStacked(t,i){const{scope:e,timeScale:a,yScale:o,dataInterval:s}=t,{context:n}=e,l=a.getRange(),h=a.barWidthBitmap(s),d=Math.max(1,Math.round(h*this.options.barWidthRatio)-2),g=Math.floor(d/2),f=this.stores.map(m=>m.isVisible()?m.getVisibleData(l.from,l.to):[]);if(f.every(m=>m.length===0))return;const p=new Map;for(let m=0;m<f.length;m++)for(const b of f[m])p.has(b.time)||p.set(b.time,new Array(f.length).fill(0)),p.get(b.time)[m]=this.stores[m].isVisible()?b.value:0;for(let m=0;m<f.length;m++){const b=this.options.colors[m%this.options.colors.length];for(const[u,y]of p){const v=y[m];if(v===0)continue;const C=a.timeToBitmapX(u);let w=0,D=0;for(let M=0;M<m;M++){const B=y[M];B>0?w+=B:D+=B}if(i){let M=0,B=0;for(const L of y)L>0?M+=L:B+=L;if(v>0&&M>0){const L=w/M*100,E=(w+v)/M*100,P=o.valueToBitmapY(E),O=o.valueToBitmapY(L),$=Math.max(1,O-P);this.fillBar(n,C-g,P,d,$,b)}else if(v<0&&B<0){const L=D/B*-100,E=(D+v)/B*-100,P=o.valueToBitmapY(L),O=o.valueToBitmapY(E),$=Math.max(1,O-P);n.fillStyle=b,n.fillRect(C-g,P,d,$)}}else if(v>0){const M=o.valueToBitmapY(w+v),B=o.valueToBitmapY(w),L=Math.max(1,B-M);this.fillBar(n,C-g,M,d,L,b)}else{const M=o.valueToBitmapY(D),B=o.valueToBitmapY(D+v),L=Math.max(1,B-M);n.fillStyle=b,n.fillRect(C-g,M,d,L)}}}}fillBar(t,i,e,a,o,s){t.fillStyle=s,t.fillRect(i,e,a,o)}}function ne(r,t){return r.length<=t?r:Bi(r,t,i=>i.time,i=>i.value)}function Di(r,t){if(r.length<=t)return r;const i=Math.ceil(r.length/t),e=[];for(let a=0;a<r.length;a+=i){const o=Math.min(a+i,r.length);let s=-1/0,n=1/0,l=0;for(let h=a;h<o;h++)r[h].high>s&&(s=r[h].high),r[h].low<n&&(n=r[h].low),l+=r[h].volume??0;e.push({time:r[a].time,open:r[a].open,high:s,low:n,close:r[o-1].close,volume:l})}return e}function Bi(r,t,i,e){if(t>=r.length||t<3)return r;const a=[r[0]],o=(r.length-2)/(t-2);let s=0;for(let n=0;n<t-2;n++){const l=Math.floor((n+1)*o)+1,h=Math.min(Math.floor((n+2)*o)+1,r.length-1);let d=0,g=0;const f=h,p=Math.min(Math.floor((n+3)*o)+1,r.length),m=p-f;if(m>0){for(let C=f;C<p;C++)d+=i(r[C]),g+=e(r[C]);d/=m,g/=m}let b=-1,u=l;const y=i(r[s]),v=e(r[s]);for(let C=l;C<h;C++){const w=Math.abs((y-d)*(e(r[C])-v)-(y-i(r[C]))*(g-v));w>b&&(b=w,u=C)}a.push(r[u]),s=u}return a.push(r[r.length-1]),a}const le=new Map,ce=new Map,he=new Map;function Ht(r){return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)]}function pe(r,t,i){return`#${r.toString(16).padStart(2,"0")}${t.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function gt(r,t){if(r.startsWith("rgba"))return r.replace(/[\d.]+\)\s*$/,`${t})`);if(r.startsWith("rgb("))return r.replace(/^rgb\((.*)\)$/i,`rgba($1, ${t})`);const i=r+t;let e=le.get(i);if(e)return e;const[a,o,s]=Ht(r);return e=`rgba(${a}, ${o}, ${s}, ${t})`,le.set(i,e),e}function zi(r,t){const i=r+t;let e=ce.get(i);if(e)return e;const[a,o,s]=Ht(r);return e=pe(Math.min(255,Math.round(a+(255-a)*t)),Math.min(255,Math.round(o+(255-o)*t)),Math.min(255,Math.round(s+(255-s)*t))),ce.set(i,e),e}function Li(r,t){const i=r+t;let e=he.get(i);if(e)return e;const[a,o,s]=Ht(r);return e=pe(Math.max(0,Math.round(a*(1-t))),Math.max(0,Math.round(o*(1-t))),Math.max(0,Math.round(s*(1-t)))),he.set(i,e),e}const Pi={upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350",bodyWidthRatio:.6};class Et{constructor(t,i){S(this,"store"),S(this,"options"),this.store=t,this.options={...Pi,...i}}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.upColor}render(t){const{scope:i,timeScale:e,yScale:a,dataInterval:o}=t,{context:s,horizontalPixelRatio:n}=i,l=e.getRange();let h=this.store.getVisibleData(l.from,l.to);const d=i.mediaSize.width;if(h.length>d*2&&(h=Di(h,Math.round(d*1.5))),h.length===0)return;const g=e.barWidthBitmap(o),f=Math.max(1,Math.round(g*this.options.bodyWidthRatio)-2),p=Math.floor(f/2),m=Math.max(1,Math.round(n)),b=Math.round(a.getMediaHeight()*i.verticalPixelRatio);this.drawVolume(s,h,e,b,g,o);const u=[],y=[];for(const v of h)v.close>=v.open?u.push(v):y.push(v);this.drawCandles(s,u,e,a,p,f,m,this.options.upColor,this.options.wickUpColor),this.drawCandles(s,y,e,a,p,f,m,this.options.downColor,this.options.wickDownColor)}drawVolume(t,i,e,a,o,s){let n=0;for(const p of i)p.volume!==void 0&&p.volume>n&&(n=p.volume);if(n===0)return;const l=a*.2,h=Math.max(1,o-2),d=Math.floor(h/2),g=gt(this.options.upColor,.2),f=gt(this.options.downColor,.2);for(const p of i){if(p.volume===void 0||p.volume===0)continue;const m=e.timeToBitmapX(p.time),b=Math.max(1,p.volume/n*l),u=p.close>=p.open;t.fillStyle=u?g:f,t.fillRect(m-d,a-b,h,b)}}drawCandles(t,i,e,a,o,s,n,l,h){if(i.length===0)return;t.fillStyle=h;for(const p of i){const m=e.timeToBitmapX(p.time),b=a.valueToBitmapY(p.high),u=a.valueToBitmapY(p.low),y=m-Math.floor(n/2);t.fillRect(y,b,n,u-b)}const d=this.options.candleGradient!==!1,g=d?zi(l,.2):l,f=d?Li(l,.15):l;d||(t.fillStyle=l);for(const p of i){const m=e.timeToBitmapX(p.time),b=a.valueToBitmapY(p.open),u=a.valueToBitmapY(p.close),y=Math.min(b,u),v=Math.max(1,Math.abs(u-b));if(d&&v>2){const C=t.createLinearGradient(0,y,0,y+v);C.addColorStop(0,g),C.addColorStop(.5,l),C.addColorStop(1,f),t.fillStyle=C}t.fillRect(m-o,y,s,v)}}}const Fi={colors:["#2962FF"],lineWidth:1,areaFill:!0,pulse:!0,stacking:"off"};class X{constructor(t,i){S(this,"stores"),S(this,"options"),S(this,"areaGradientCache",new Map),this.stores=Array.from({length:t},()=>new Xt),this.options={...Fi,...i}}get store(){return this.stores[0]}updateOptions(t){this.options={...this.options,...t}}getColor(){return this.options.colors[0]}getColors(){return this.options.colors}getStacking(){return this.options.stacking}get needsAnimation(){return!1}get hasPulse(){return this.options.pulse&&this.stores.some(t=>t.isVisible()&&t.length>0)}getValueRange(t,i){if(this.options.stacking==="percent")return{min:0,max:100};if(this.stores.length<=1)return null;const e=this.stores.map(n=>n.isVisible()?n.getVisibleData(t,i):[]);if(this.options.stacking==="off"){let n=1/0,l=-1/0;for(const h of e)for(const d of h)d.value<n&&(n=d.value),d.value>l&&(l=d.value);return n<1/0?{min:n,max:l}:null}const a=new Map;for(let n=0;n<e.length;n++)for(const l of e[n])a.has(l.time)||a.set(l.time,new Array(e.length).fill(0)),a.get(l.time)[n]=l.value;let o=0,s=0;for(const n of a.values()){let l=0,h=0;for(const d of n)d>0?l+=d:h+=d;l>s&&(s=l),h<o&&(o=h)}return s>o?{min:o,max:s}:null}render(t){this.options.stacking==="off"?this.renderOff(t):this.renderStacked(t,this.options.stacking==="percent")}renderOff(t){const{scope:i,timeScale:e,yScale:a}=t,{context:o}=i,s=e.getRange(),{verticalPixelRatio:n,horizontalPixelRatio:l}=i,h=Math.max(1,Math.round(this.options.lineWidth*n));for(let d=0;d<this.stores.length;d++){if(!this.stores[d].isVisible())continue;let g=this.stores[d].getVisibleData(s.from,s.to);const f=i.mediaSize.width;if(g.length>f*2&&(g=ne(g,Math.round(f*1.5))),g.length<2)continue;const p=this.options.colors[d%this.options.colors.length];o.beginPath(),o.moveTo(e.timeToBitmapX(g[0].time),a.valueToBitmapY(g[0].value));for(let m=1;m<g.length;m++)o.lineTo(e.timeToBitmapX(g[m].time),a.valueToBitmapY(g[m].value));if(o.strokeStyle=p,o.lineWidth=h,o.lineJoin="round",o.lineCap="round",o.stroke(),this.options.areaFill){const m=e.timeToBitmapX(g[0].time),b=e.timeToBitmapX(g[g.length-1].time),u=i.bitmapSize.height;o.lineTo(b,u),o.lineTo(m,u),o.closePath();const y=String(d),v=this.areaGradientCache.get(y);let C;v&&v.bottomY===u&&v.color===p?C=v.gradient:(C=o.createLinearGradient(0,0,0,u),C.addColorStop(0,gt(p,.12)),C.addColorStop(1,gt(p,.01)),this.areaGradientCache.set(y,{gradient:C,bottomY:u,color:p})),o.fillStyle=C,o.fill()}}}renderStacked(t,i){const{scope:e,timeScale:a,yScale:o}=t,{context:s}=e,n=a.getRange(),{verticalPixelRatio:l}=e,h=Math.max(1,Math.round(this.options.lineWidth*l)),d=e.mediaSize.width,g=this.stores.map(u=>{let y=u.getVisibleData(n.from,n.to);return y.length>d*2&&(y=ne(y,Math.round(d*1.5))),y}),f=new Set;for(const u of g)for(const y of u)f.add(y.time);const p=Array.from(f).sort((u,y)=>u-y);if(p.length<2)return;const m=g.map(u=>{const y=new Map;for(const v of u)y.set(v.time,v.value);return y}),b=Array.from({length:this.stores.length},()=>new Array(p.length).fill(0));for(let u=0;u<p.length;u++){const y=p[u];let v=0;if(i)for(let w=0;w<this.stores.length;w++)this.stores[w].isVisible()&&(v+=m[w].get(y)??0);let C=0;for(let w=0;w<this.stores.length;w++){const D=this.stores[w].isVisible()?m[w].get(y)??0:0;C+=i&&v>0?D/v*100:D,b[w][u]=C}}for(let u=this.stores.length-1;u>=0;u--){if(!this.stores[u].isVisible())continue;const y=this.options.colors[u%this.options.colors.length],v=[];for(let w=0;w<p.length;w++)v.push([a.timeToBitmapX(p[w]),o.valueToBitmapY(b[u][w])]);const C=[];for(let w=0;w<p.length;w++){const D=u>0?b[u-1][w]:0;C.push([a.timeToBitmapX(p[w]),o.valueToBitmapY(D)])}if(this.options.areaFill){s.beginPath(),s.moveTo(v[0][0],v[0][1]);for(let w=1;w<v.length;w++)s.lineTo(v[w][0],v[w][1]);for(let w=C.length-1;w>=0;w--)s.lineTo(C[w][0],C[w][1]);s.closePath(),s.fillStyle=gt(y,.25),s.fill()}s.beginPath(),s.moveTo(v[0][0],v[0][1]);for(let w=1;w<v.length;w++)s.lineTo(v[w][0],v[w][1]);s.strokeStyle=y,s.lineWidth=h,s.lineJoin="round",s.lineCap="round",s.stroke()}}drawPulseOverlay(t,i,e,a){if(this.options.pulse)for(let o=0;o<this.stores.length;o++){if(!this.stores[o].isVisible())continue;const s=this.stores[o].last();if(!s)continue;const n=this.options.colors[o%this.options.colors.length];this.drawPulse(t,i.timeToBitmapX(s.time),e.valueToBitmapY(s.value),n,a)}}drawPulse(t,i,e,a,o){const s=3*o,n=.4+.6*Math.abs(Math.sin(performance.now()/600)),l=s+4*o*n;t.beginPath(),t.arc(i,e,l,0,Math.PI*2),t.fillStyle=gt(a,n*.3),t.fill(),t.beginPath(),t.arc(i,e,s,0,Math.PI*2),t.fillStyle=a,t.fill()}}const Wi={innerRadiusRatio:0,padAngle:.02,strokeColor:"transparent",strokeWidth:0},Tt=Math.PI*2;function Ii(r){if(!r.startsWith("#"))return!1;const t=parseInt(r.slice(1,3),16),i=parseInt(r.slice(3,5),16),e=parseInt(r.slice(5,7),16);return t*.299+i*.587+e*.114>150}function Ai(r,t){if(!r.startsWith("#"))return r;const i=Math.min(255,parseInt(r.slice(1,3),16)+Math.round(255*t)),e=Math.min(255,parseInt(r.slice(3,5),16)+Math.round(255*t)),a=Math.min(255,parseInt(r.slice(5,7),16)+Math.round(255*t));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function ji(r,t,i){return r+(t-r)*Math.min(1,i)}class st{constructor(t){S(this,"data",[]),S(this,"options"),S(this,"hoverIndex",-1),S(this,"sliceOffsets",[]),S(this,"lastRenderTime",0),this.options={...Wi,...t}}getData(){return this.data}setData(t){this.data=t,this.sliceOffsets=new Array(t.length).fill(0)}updateOptions(t){this.options={...this.options,...t}}getColor(){var t,i;return((t=this.data[0])==null?void 0:t.color)??((i=this.options.colors)==null?void 0:i[0])??"#888"}hitTest(t,i,e,a){if(this.data.length===0)return-1;const o=this.data.reduce((b,u)=>b+u.value,0);if(o<=0)return-1;const s=e/2,n=a/2,l=Math.min(e,a)/2*.85,h=l*this.options.innerRadiusRatio,d=t-s,g=i-n,f=Math.sqrt(d*d+g*g);if(f>l||f<h)return-1;let p=Math.atan2(g,d)+Math.PI/2;p<0&&(p+=Tt);let m=0;for(let b=0;b<this.data.length;b++){const u=this.data[b].value/o*Tt;if(p>=m&&p<m+u)return b;m+=u}return-1}get needsAnimation(){for(let t=0;t<this.sliceOffsets.length;t++){const i=t===this.hoverIndex?1:0;if(Math.abs(this.sliceOffsets[t]-i)>.01)return!0}return!1}render(t){if(this.data.length===0)return;const{scope:i,theme:e}=t,{context:a,bitmapSize:o,horizontalPixelRatio:s}=i,n=performance.now(),l=this.lastRenderTime?(n-this.lastRenderTime)/1e3:0;this.lastRenderTime=n;const h=this.data.reduce((M,B)=>M+B.value,0);if(h<=0)return;const d=10;for(;this.sliceOffsets.length<this.data.length;)this.sliceOffsets.push(0);for(let M=0;M<this.data.length;M++){const B=M===this.hoverIndex?1:0;this.sliceOffsets[M]=ji(this.sliceOffsets[M],B,d*l)}const g=this.options.colors??e.seriesColors,f=o.width/2,p=o.height/2,m=Math.min(o.width,o.height)/2*.85,b=m*this.options.innerRadiusRatio,u=this.options.padAngle,{strokeColor:y,strokeWidth:v}=this.options,C=8*s;let w=-Math.PI/2;for(let M=0;M<this.data.length;M++){const B=this.data[M],L=B.value/h*Tt,E=w+u/2,P=w+L-u/2,O=w+L/2,$=B.color??g[M%g.length],K=this.sliceOffsets[M]*C,V=Math.cos(O)*K,at=Math.sin(O)*K,Y=f+V,_=p+at;a.beginPath(),a.arc(Y,_,m,E,P),b>0?a.arc(Y,_,b,P,E,!0):a.lineTo(Y,_),a.closePath();const Q=a.createRadialGradient(Y,_,b||0,Y,_,m);Q.addColorStop(0,Ai($,.15)),Q.addColorStop(1,$),a.fillStyle=Q,this.sliceOffsets[M]>.01&&(a.shadowColor="rgba(0,0,0,0.25)",a.shadowBlur=12*s*this.sliceOffsets[M],a.shadowOffsetX=V*.3,a.shadowOffsetY=at*.3),a.fill(),a.shadowColor="transparent",a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0,v>0&&y!=="transparent"&&(a.strokeStyle=y,a.lineWidth=v,a.stroke()),w+=L}w=-Math.PI/2;const D=b>0?(m+b)/2:m*.65;a.textAlign="center",a.textBaseline="middle",a.font=`${11*s}px ${e.typography.fontFamily}`;for(let M=0;M<this.data.length;M++){const B=this.data[M],L=B.value/h*Tt;if(L>.3){const E=w+L/2,P=this.sliceOffsets[M]*C,O=f+Math.cos(E)*(D+P),$=p+Math.sin(E)*(D+P),K=B.color??g[M%g.length];a.fillStyle=Ii(K)?"#000000":"#ffffff",a.fillText(B.label,O,$)}w+=L}}}const me={background:"#131722",chartGradient:["#1a1f2e","#101318"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(42, 46, 57, 0.6)",style:"dashed"},candlestick:{upColor:"#26a69a",downColor:"#ef5350",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#26a69a","#AB47BC","#ef5350","#FFCA28","#66BB6A","#EC407A","#42A5F5","#B388FF"],bands:{upper:"#42A5F5",lower:"#EC407A"},crosshair:{color:"rgba(150, 150, 150, 0.5)",labelBackground:"#363a45",labelTextColor:"#d1d4dc"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#26a69a",downBackground:"#ef5350",neutralBackground:"#363a45",textColor:"#ffffff"},tooltip:{background:"rgba(19, 23, 34, 0.9)",textColor:"#d1d4dc",borderColor:"rgba(42, 46, 57, 0.8)"}},it={top:20,bottom:20,right:{intervals:3},left:{intervals:0}};class Ei extends St{constructor({padding:t}={}){super(),S(this,"_visibleRange",{from:0,to:0}),S(this,"_yRange",{min:0,max:0}),S(this,"_autoScroll",!0),S(this,"padding"),S(this,"dataInterval",6e4),S(this,"_dataStart",null),S(this,"_dataEnd",null),S(this,"_animating",!1),S(this,"animStartTime",0),S(this,"animDuration",0),S(this,"animFrom",{from:0,to:0}),S(this,"animTo",{from:0,to:0}),this.padding={top:(t==null?void 0:t.top)??it.top,bottom:(t==null?void 0:t.bottom)??it.bottom,right:(t==null?void 0:t.right)??it.right,left:(t==null?void 0:t.left)??it.left}}resolveHPad(t,i,e){return typeof t=="object"?t.intervals*this.dataInterval:e<=0?0:t/e*i}get visibleRange(){return this._visibleRange}get yRange(){return this._yRange}get autoScroll(){return this._autoScroll}get animating(){return this._animating}setDataInterval(t){this.dataInterval=t}setPadding(t){this.padding={top:(t==null?void 0:t.top)??it.top,bottom:(t==null?void 0:t.bottom)??it.bottom,right:(t==null?void 0:t.right)??it.right,left:(t==null?void 0:t.left)??it.left}}setDataStart(t){this._dataStart=t}setDataEnd(t){this._dataEnd=t}cancelAnimation(){this._animating=!1}applyRange(t,i,e=!1){if(i<=t)return;const a=i-t;if(!(a/this.dataInterval<2)){if(e&&this._dataStart!==null&&this._dataEnd!==null){const o=this._dataEnd-this._dataStart+this.dataInterval*5;if(a>o&&o>0)return}this._visibleRange={from:t,to:i},this.emit("change")}}animateTo(t,i,e=400){this.animFrom={...this._visibleRange},this.animTo={from:t,to:i},this.animDuration=e,this.animStartTime=performance.now(),this._animating=!0}tick(t){if(!this._animating)return!1;const i=t-this.animStartTime,e=Math.min(1,i/this.animDuration),a=1-(1-e)**3,o=ae(this.animFrom.from,this.animTo.from,a),s=ae(this.animFrom.to,this.animTo.to,a);return s>o&&this.applyRange(o,s),e>=1&&(this._animating=!1),this._animating}setYRange(t,i,e,a=!1,o=!1){const s=i-t,n=e>0?this.padding.top/e*s:0,l=e>0?this.padding.bottom/e*s:0;this._yRange={min:a?t:t-l,max:o?i:i+n}}zoomAt(t,i){this.cancelAnimation();const{from:e,to:a}=this._visibleRange,o=a-e,s=o*i,n=(t-e)/o,l=t-n*s,h=l+s;if(!(s/this.dataInterval<10)){if(i>1&&this._dataStart!==null&&this._dataEnd!==null&&l<=this._dataStart&&h>=this._dataEnd){this._autoScroll=!0,this.applyRange(l,h,!0);return}this._autoScroll=!1,this.applyRange(l,h,!0)}}pan(t){this.cancelAnimation();const{from:i,to:e}=this._visibleRange,a=i+t,o=e+t;this._autoScroll=!1,this.applyRange(a,o)}fitToData(t,i,e=0,a=!1){this._autoScroll=!0;const o=400*this.dataInterval,s=i-t,n=s>0?s:this.dataInterval*10,l=this.resolveHPad(this.padding.right,n,e),h=this.resolveHPad(this.padding.left,n,e);let d=i+l,g=t-h;d-g>o&&(d=i+l,g=d-o),a&&this._visibleRange.from!==0&&this._visibleRange.to!==0?this.animateTo(g,d,450):this.applyRange(g,d)}scrollToEnd(t,i=0){const e=this._visibleRange.to-this._visibleRange.from,a=this.resolveHPad(this.padding.right,e,i),o=t+a,s=o-e;this._autoScroll=!0,this._animating?(this.animFrom={...this._visibleRange},this.animTo={from:s,to:o},this.animDuration=150,this.animStartTime=performance.now()):this.animateTo(s,o,150)}getVisibleBarsCount(){return(this._visibleRange.to-this._visibleRange.from)/this.dataInterval}destroy(){this.cancelAnimation(),this.removeAllListeners()}}let Vi=0;var j,z,A,ht,vt,R,W,xt,N,et,U,tt,Yt,dt,ot,Ct,lt,ut,wt,Bt,J,q,ft;class be extends St{constructor(t,i){var e,a,o;super(),F(this,ut),F(this,j),F(this,z),F(this,A),F(this,ht),S(this,"timeScale"),S(this,"yScale"),F(this,vt),F(this,R,[]),F(this,W),F(this,xt),F(this,N,6e4),F(this,et,null),F(this,U,{}),F(this,tt,null),F(this,Yt,!1),F(this,dt,{}),F(this,ot,0),F(this,Ct,!1),F(this,lt,!1),F(this,Bt,0),F(this,J,0),F(this,q,0),F(this,ft,!1),i!=null&&i.axis&&(T(this,dt,i.axis),T(this,U,{min:(e=i.axis.y)==null?void 0:e.min,max:(a=i.axis.y)==null?void 0:a.max})),T(this,W,(i==null?void 0:i.theme)??me),T(this,xt,(i==null?void 0:i.grid)!==!1),T(this,j,new pi(t)),T(this,z,new Ei({padding:i==null?void 0:i.padding})),this.timeScale=new Mi,this.yScale=new Ri,T(this,A,new se(()=>this.renderMain())),T(this,ht,new se(()=>this.renderOverlay()));const s=(i==null?void 0:i.interactive)!==!1;T(this,vt,s?new Ci(c(this,j).canvas,c(this,z),this.timeScale,this.yScale):null),c(this,z).on("change",()=>{this.syncScales(),c(this,A).markDirty(),this.emit("viewportChange")}),c(this,j).on("resize",()=>{this.updateScales(!0),this.renderMain(),this.emit("viewportChange")}),(o=c(this,vt))==null||o.on("crosshairMove",n=>{T(this,et,n),c(this,ht).markDirty(),this.emit("crosshairMove",n),this.updatePieHover(n)})}get yAxisWidth(){const t=c(this,dt).y;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.width)??55}get xAxisHeight(){const t=c(this,dt).x;return(t==null?void 0:t.visible)===!1?0:(t==null?void 0:t.height)??30}addCandlestickSeries(t){const i=new Xt,e=new Et(i,{upColor:c(this,W).candlestick.upColor,downColor:c(this,W).candlestick.downColor,wickUpColor:c(this,W).candlestick.wickUpColor,wickDownColor:c(this,W).candlestick.wickDownColor,bodyWidthRatio:.6,...t}),a=Rt(this,ut,wt).call(this,t==null?void 0:t.id);return i.on("update",()=>{this.onDataChanged()}),c(this,R).push({id:a,renderer:e,store:i,visible:!0}),T(this,tt,null),this.updateViewportPadding(),this.emit("seriesChange"),a}addLineSeries(t,i){let e,a;if(typeof t=="number")e=t,a=i;else{const{layers:n,...l}=t??{};e=n??1,a=l}const o=new X(e,{colors:e===1?[c(this,W).line.color]:c(this,W).seriesColors.slice(0,e),lineWidth:c(this,W).line.width,areaFill:!0,...a}),s=Rt(this,ut,wt).call(this,a==null?void 0:a.id);for(const n of o.stores)n.on("update",()=>this.onDataChanged());return c(this,R).push({id:s,label:a==null?void 0:a.label,renderer:o,store:o.stores[0],visible:!0}),T(this,tt,null),this.updateViewportPadding(),this.emit("seriesChange"),s}setLineLayerData(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a||!(a.renderer instanceof X))return;const o=a.renderer.stores[i];o&&o.setData(e)}addBarSeries(t,i){let e,a;if(typeof t=="number")e=t,a=i;else{const{layers:n,...l}=t??{};e=n??1,a=l}const o=new Z(e,{colors:c(this,W).seriesColors.slice(0,e),barWidthRatio:.6,...a}),s=Rt(this,ut,wt).call(this,a==null?void 0:a.id);for(const n of o.stores)n.on("update",()=>this.onDataChanged());return c(this,R).push({id:s,label:a==null?void 0:a.label,renderer:o,store:o.stores[0],visible:!0}),T(this,tt,null),this.updateViewportPadding(),this.emit("seriesChange"),s}setBarLayerData(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a||!(a.renderer instanceof Z))return;const o=a.renderer.stores[i];o&&o.setData(e)}addPieSeries(t){const i=new st(t),e=Rt(this,ut,wt).call(this,t==null?void 0:t.id);return c(this,R).push({id:e,label:t==null?void 0:t.label,renderer:i,store:null,visible:!0}),T(this,tt,null),this.updateViewportPadding(),this.emit("seriesChange"),e}setPieData(t,i){const e=c(this,R).find(a=>a.id===t);!e||!(e.renderer instanceof st)||(e.renderer.setData(i),c(this,A).markDirty(),this.emit("dataUpdate"))}removeSeries(t){const i=c(this,R).findIndex(e=>e.id===t);if(i>=0){const{renderer:e,store:a}=c(this,R)[i];if(e instanceof X||e instanceof Z)for(const o of e.stores)o.removeAllListeners();else a==null||a.removeAllListeners();c(this,R).splice(i,1),T(this,tt,null),this.updateViewportPadding(),c(this,A).markDirty(),this.emit("seriesChange")}}setSeriesData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a=i.length>0&&"open"in i[0]?wi(i):Si(i);e.store.setData(a)}appendData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a={...i,time:Vt(i.time)};e.store.append(a)}updateData(t,i){const e=c(this,R).find(o=>o.id===t);if(!(e!=null&&e.store))return;const a={...i,time:Vt(i.time)};e.store.updateLast(a)}updateSeriesOptions(t,i){const e=c(this,R).find(a=>a.id===t);e&&((e.renderer instanceof Et||e.renderer instanceof X||e.renderer instanceof Z||e.renderer instanceof st)&&e.renderer.updateOptions(i),"label"in i&&typeof i.label=="string"&&(e.label=i.label),c(this,A).markDirty())}batch(t){this.beginUpdate();try{t()}finally{this.endUpdate()}}beginUpdate(){oe(this,ot)._++}endUpdate(){--oe(this,ot)._<=0&&(T(this,ot,0),c(this,Ct)?(T(this,Ct,!1),T(this,lt,!1),this.onDataChanged()):c(this,lt)&&(T(this,lt,!1),this.updateYRange(!0),c(this,A).markDirty()))}setSeriesVisible(t,i){const e=c(this,R).find(a=>a.id===t);if(!(!e||e.visible===i)){if(e.visible=i,c(this,ot)>0){T(this,lt,!0);return}this.updateYRange(!0),c(this,A).markDirty()}}isSeriesVisible(t){var i;return((i=c(this,R).find(e=>e.id===t))==null?void 0:i.visible)??!0}setLayerVisible(t,i,e){const a=c(this,R).find(s=>s.id===t);if(!a)return;const o=a.renderer;if(o instanceof Z||o instanceof X){const s=o.stores[i];if(s){if(s.isVisible()===e)return;if(s.setVisible(e),c(this,ot)>0){T(this,lt,!0);return}this.updateYRange(!0),c(this,A).markDirty()}}}isLayerVisible(t,i){var e;const a=c(this,R).find(s=>s.id===t);if(!a)return!0;const o=a.renderer;return o instanceof Z||o instanceof X?((e=o.stores[i])==null?void 0:e.isVisible())??!0:!0}fitContent(){const{first:t,last:i}=this.getDataBounds();if(t===void 0||i===void 0)return;const e=c(this,j).size.media.width-this.yAxisWidth;c(this,z).fitToData(t,i,e,!0)}getVisibleRange(){return c(this,z).visibleRange}getYRange(){return c(this,z).yRange}getCrosshairPosition(){return c(this,et)}getLastValue(t){const i=c(this,R).find(l=>l.id===t);if(!(i!=null&&i.store))return null;const e=i.store.last();if(!e)return null;const a=l=>"close"in l?l.close:l.value,{from:o,to:s}=c(this,z).visibleRange;if(e.time>=o&&e.time<=s)return{value:a(e),isLive:!0};const n=i.store.getVisibleData(o,s);return n.length===0?null:{value:a(n[n.length-1]),isLive:!1}}getPreviousClose(t){const i=c(this,R).find(o=>o.id===t);if(!(i!=null&&i.store))return null;const e=i.store.getAll();if(e.length<2)return null;const a=e[e.length-2];return"close"in a?a.close:a.value}getLastData(t){const i=c(this,R).find(e=>e.id===t);return i!=null&&i.store?i.store.last()??null:null}getDataAtTime(t,i){const e=c(this,R).find(n=>n.id===t);if(!(e!=null&&e.store))return null;const a=e.store.getVisibleData(i-c(this,N),i+c(this,N));if(a.length===0)return null;let o=a[0],s=Math.abs(a[0].time-i);for(let n=1;n<a.length;n++){const l=Math.abs(a[n].time-i);l<s&&(s=l,o=a[n])}return o}getLayerSnapshots(t,i){const e=c(this,R).find(n=>n.id===t);if(!e||!e.visible)return null;const a=e.renderer;if(!(a instanceof Z)&&!(a instanceof X)||a.stores.length<=1)return null;const o=a.getColors(),s=[];for(let n=0;n<a.stores.length;n++){if(!a.stores[n].isVisible())continue;const l=a.stores[n].getVisibleData(i-c(this,N),i+c(this,N));if(l.length===0)continue;let h=l[0],d=Math.abs(l[0].time-i);for(let g=1;g<l.length;g++){const f=Math.abs(l[g].time-i);f<d&&(d=f,h=l[g])}s.push({value:h.value,color:(o==null?void 0:o[n%((o==null?void 0:o.length)??1)])??c(this,W).seriesColors[n%c(this,W).seriesColors.length]})}return s.length>0?s:null}getSeriesIds(){return c(this,tt)||T(this,tt,c(this,R).map(t=>t.id)),c(this,tt).slice()}getSeriesColor(t){const i=c(this,R).find(e=>e.id===t);return i?"getColor"in i.renderer&&typeof i.renderer.getColor=="function"?i.renderer.getColor():c(this,W).line.color:null}getSeriesLabel(t){var i;return(i=c(this,R).find(e=>e.id===t))==null?void 0:i.label}getSeriesLayers(t){const i=c(this,R).find(o=>o.id===t);if(!i)return null;const e=i.renderer;if(!(e instanceof Z)&&!(e instanceof X))return null;const a=e.getColors();return e.stores.map((o,s)=>({color:a[s%a.length]}))}getPieSlices(t){const i=c(this,R).find(s=>s.id===t);if(!i||!(i.renderer instanceof st))return null;const e=i.renderer.getData();if(e.length===0)return null;const a=e.reduce((s,n)=>s+n.value,0),o=c(this,W).seriesColors;return e.map((s,n)=>({label:s.label,value:s.value,percent:a>0?s.value/a*100:0,color:s.color??o[n%o.length]}))}getPieHoverInfo(t){const i=c(this,R).find(l=>l.id===t);if(!i||!(i.renderer instanceof st))return null;const e=i.renderer;if(e.hoverIndex<0)return null;const a=e.getData(),o=a[e.hoverIndex];if(!o)return null;const s=a.reduce((l,h)=>l+h.value,0),n=c(this,W).seriesColors;return{label:o.label,value:o.value,percent:s>0?o.value/s*100:0,color:o.color??n[e.hoverIndex%n.length]}}setTheme(t){const i=c(this,W).line.color;T(this,W,t);for(const e of c(this,R))e.renderer instanceof Et?e.renderer.updateOptions({upColor:t.candlestick.upColor,downColor:t.candlestick.downColor,wickUpColor:t.candlestick.wickUpColor,wickDownColor:t.candlestick.wickDownColor}):e.renderer instanceof Z?e.renderer.updateOptions({colors:t.seriesColors.slice(0,e.renderer.stores.length)}):e.renderer instanceof X&&(e.renderer.stores.length===1?e.renderer.getColor()===i&&e.renderer.updateOptions({colors:[t.line.color]}):e.renderer.updateOptions({colors:t.seriesColors.slice(0,e.renderer.stores.length)}));c(this,A).markDirty()}getTheme(){return c(this,W)}setAxis(t){var i,e;const a=this.yAxisWidth,o=this.xAxisHeight;T(this,dt,t);const s={min:(i=t.y)==null?void 0:i.min,max:(e=t.y)==null?void 0:e.max};T(this,U,s),T(this,ft,!1),this.updateYRange(!0),(this.yAxisWidth!==a||this.xAxisHeight!==o)&&this.updateScales(!0),c(this,A).markDirty()}getMediaSize(){return c(this,j).size.media}getLayout(){const t=c(this,j).size.media,i=this.yAxisWidth,e=this.xAxisHeight;return{chartArea:{x:0,y:0,width:t.width-i,height:t.height-e},yAxisWidth:i,xAxisHeight:e}}getDataInterval(){return c(this,N)}setPadding(t){c(this,z).setPadding(t);const{first:i,last:e}=this.getDataBounds();if(i!==void 0&&e!==void 0){const a=c(this,j).size.media.width-this.yAxisWidth;c(this,z).fitToData(i,e,a,!1)}this.syncScales(),c(this,A).markDirty()}setGrid(t){T(this,xt,t),c(this,A).markDirty()}setYLabel(t){T(this,Yt,t),this.updateViewportPadding()}updatePieHover(t){const i=c(this,j).size;for(const e of c(this,R))if(e.renderer instanceof st){const a=e.renderer.hoverIndex;if(t){const o=t.mediaX*i.horizontalPixelRatio,s=t.mediaY*i.verticalPixelRatio;e.renderer.hoverIndex=e.renderer.hitTest(o,s,i.bitmap.width,i.bitmap.height)}else e.renderer.hoverIndex=-1;e.renderer.hoverIndex!==a&&c(this,A).markDirty()}}updateViewportPadding(){}destroy(){var t;c(this,z).destroy(),c(this,A).destroy(),c(this,ht).destroy(),(t=c(this,vt))==null||t.destroy(),c(this,j).destroy(),this.removeAllListeners()}getDataBounds(){let t,i;for(const e of c(this,R)){if(!e.visible||!e.store)continue;const a=e.store.first(),o=e.store.last();a&&(t===void 0||a.time<t)&&(t=a.time),o&&(i===void 0||o.time>i)&&(i=o.time)}return{first:t,last:i}}onDataChanged(){if(c(this,ot)>0){T(this,Ct,!0);return}this.updateDataInterval();const{first:t,last:i}=this.getDataBounds();t!==void 0&&c(this,z).setDataStart(t),i!==void 0&&c(this,z).setDataEnd(i);let e=0;for(const o of c(this,R))if(o.renderer instanceof X||o.renderer instanceof Z)for(const s of o.renderer.stores)e+=s.length;else o.store&&(e+=o.store.length);const a=e-c(this,Bt)>5;if(T(this,Bt,e),t!==void 0&&i!==void 0){const{from:o,to:s}=c(this,z).visibleRange,n=o===0&&s===0,l=c(this,j).size.media.width-this.yAxisWidth;n?c(this,z).fitToData(t,i,l,!1):a&&c(this,z).autoScroll?c(this,z).fitToData(t,i,l,!0):!a&&this.isLastPointVisible()&&c(this,z).scrollToEnd(i,l)}this.updateYRange(a),this.syncScales(),c(this,A).markDirty(),this.emit("dataUpdate")}isLastPointVisible(){const{from:t,to:i}=c(this,z).visibleRange;for(const e of c(this,R)){if(!e.visible||!e.store)continue;const a=e.store.last();if(a&&a.time>=t&&a.time<=i)return!0}return!1}updateDataInterval(){for(const t of c(this,R)){if(!t.store)continue;const i=t.store.getAll();if(i.length>=2){const e=i.slice(0,20).map(a=>a.time);T(this,N,fe(e)),c(this,z).setDataInterval(c(this,N));break}}}updateYRange(t=!1){let i=1/0,e=-1/0;const a=c(this,z).visibleRange;let o=c(this,U).min!==void 0&&c(this,U).min!=="auto"&&typeof c(this,U).min!="number"||c(this,U).max!==void 0&&c(this,U).max!=="auto"&&typeof c(this,U).max!="number"?[]:null;for(const h of c(this,R)){if(!h.visible)continue;if(h.renderer.getValueRange){const g=h.renderer.getValueRange(a.from,a.to);if(g){g.max>e&&(e=g.max),g.min<i&&(i=g.min),o==null||o.push(g.min,g.max);continue}}if(!h.store)continue;const d=h.store.getVisibleData(a.from,a.to);for(const g of d)if("high"in g){const f=g;f.high>e&&(e=f.high),f.low<i&&(i=f.low),o==null||o.push(f.high,f.low)}else{const f=g;f.value>e&&(e=f.value),f.value<i&&(i=f.value),o==null||o.push(f.value)}}if(i===1/0||e===-1/0){T(this,ft,!1);return}if(i=this.resolveBound(c(this,U).min,i,e,o??[],"min"),e=this.resolveBound(c(this,U).max,e,i,o??[],"max"),!c(this,ft)||t)T(this,J,i),T(this,q,e),T(this,ft,!0);else{T(this,J,c(this,J)+(i-c(this,J))*.2),T(this,q,c(this,q)+(e-c(this,q))*.2),i<c(this,J)&&T(this,J,i),e>c(this,q)&&T(this,q,e);const h=Math.max(Math.abs(c(this,q)-c(this,J))*1e-4,.001);(Math.abs(c(this,J)-i)>h||Math.abs(c(this,q)-e)>h)&&c(this,A).markDirty()}const s=c(this,U).min!==void 0&&c(this,U).min!=="auto",n=c(this,U).max!==void 0&&c(this,U).max!=="auto",l=c(this,j).size.media.height-this.xAxisHeight;c(this,z).setYRange(c(this,J),c(this,q),l,s,n)}resolveBound(t,i,e,a,o){if(t===void 0||t==="auto")return i;if(typeof t=="number")return t;if(typeof t=="function")return t(a);const s=String(t).match(/^([+-]?)\s*(\d+(?:\.\d+)?)\s*%$/);if(s){const n=s[1]==="-"?-1:1,l=parseFloat(s[2])/100,h=Math.abs(e-i)||Math.abs(i)||1;return i+n*l*h*(o==="max"?1:-1)}return i}syncScales(){const t=c(this,j).size;if(t.media.width===0||t.media.height===0)return;const i=t.media.width-this.yAxisWidth,e=t.media.height-this.xAxisHeight;this.timeScale.update(c(this,z).visibleRange,i,t.horizontalPixelRatio),this.yScale.update(c(this,z).yRange,e,t.verticalPixelRatio)}updateScales(t=!1){const i=c(this,j).size;if(i.media.width===0||i.media.height===0)return;const e=i.media.width-this.yAxisWidth,a=i.media.height-this.xAxisHeight;this.timeScale.update(c(this,z).visibleRange,e,i.horizontalPixelRatio),this.yScale.update(c(this,z).yRange,a,i.verticalPixelRatio),this.updateYRange(t),this.yScale.update(c(this,z).yRange,a,i.verticalPixelRatio)}renderMain(){const t=c(this,j).size;if(!(t.media.width===0||t.media.height===0)){c(this,z).tick(performance.now())&&c(this,A).markDirty(),this.updateScales(),c(this,j).useMainLayer(i=>{const{context:e,bitmapSize:a}=i,o=(t.media.width-this.yAxisWidth)*t.horizontalPixelRatio,s=(t.media.height-this.xAxisHeight)*t.verticalPixelRatio;e.clearRect(0,0,a.width,a.height),e.save(),e.beginPath(),e.rect(0,0,o,s),e.clip(),c(this,xt)&&bi(i,this.timeScale,this.yScale,c(this,W),c(this,N));for(const n of c(this,R))n.visible&&n.renderer.render({scope:i,timeScale:this.timeScale,yScale:this.yScale,theme:c(this,W),dataInterval:c(this,N)});e.restore()});for(const i of c(this,R))if(i.renderer instanceof st&&i.renderer.needsAnimation){c(this,A).markDirty();break}this.renderOverlay()}}renderOverlay(){const t=c(this,j).size;if(t.media.width===0||t.media.height===0)return;let i=!1;for(const e of c(this,R))if(e.visible&&e.renderer instanceof X&&e.renderer.hasPulse){i=!0;break}if(c(this,j).useOverlayLayer(e=>{if(!c(this,et)&&!i)return;const a=(t.media.width-this.yAxisWidth)*t.horizontalPixelRatio,o=(t.media.height-this.xAxisHeight)*t.verticalPixelRatio;if(e.context.save(),e.context.beginPath(),e.context.rect(0,0,a,o),e.context.clip(),c(this,et)){const s=c(this,et).mediaX*t.horizontalPixelRatio,n=c(this,et).mediaY*t.verticalPixelRatio;mi(e,s,n,c(this,W));for(const l of c(this,R))if(l.visible&&l.renderer instanceof X){const h=l.renderer,d=h.getColors(),g=h.getStacking(),f=4*t.horizontalPixelRatio,p=[],m=[];for(let u=0;u<h.stores.length;u++){const y=h.stores[u].findNearest(c(this,et).time,c(this,N));y?(p.push(y.value),m.push(y.time)):(p.push(0),m.push(0))}const b=[];if(g==="off")for(const u of p)b.push(u);else{let u=0;if(g==="percent")for(const v of p)u+=v;let y=0;for(const v of p)y+=g==="percent"&&u>0?v/u*100:v,b.push(y)}for(let u=0;u<h.stores.length;u++){if(m[u]===0||!h.stores[u].isVisible())continue;const y=d[u%d.length],v=this.timeScale.timeToBitmapX(m[u]),C=this.yScale.valueToBitmapY(b[u]);e.context.beginPath(),e.context.arc(v,C,f+3*t.horizontalPixelRatio,0,Math.PI*2);const w=y.startsWith("#")?y+"40":/^rgb\(/i.test(y)?y.replace(/^rgb\((.*)\)$/i,"rgba($1, 0.25)"):y.replace(/[\d.]+\)\s*$/,"0.25)");e.context.fillStyle=w,e.context.fill(),e.context.beginPath(),e.context.arc(v,C,f,0,Math.PI*2),e.context.fillStyle=y,e.context.fill()}}}for(const s of c(this,R))s.visible&&s.renderer instanceof X&&s.renderer.hasPulse&&s.renderer.drawPulseOverlay(e.context,this.timeScale,this.yScale,t.horizontalPixelRatio);e.context.restore()}),i){const{from:e,to:a}=this.timeScale.getRange();let o=!1;for(const s of c(this,R))if(!(!s.visible||!(s.renderer instanceof X)||!s.renderer.hasPulse)){for(const n of s.renderer.stores){const l=n.last();if(l&&l.time>=e&&l.time<=a){o=!0;break}}if(o)break}o&&c(this,ht).markDirty()}}}j=new WeakMap,z=new WeakMap,A=new WeakMap,ht=new WeakMap,vt=new WeakMap,R=new WeakMap,W=new WeakMap,xt=new WeakMap,N=new WeakMap,et=new WeakMap,U=new WeakMap,tt=new WeakMap,Yt=new WeakMap,dt=new WeakMap,ot=new WeakMap,Ct=new WeakMap,lt=new WeakMap,ut=new WeakSet,wt=function(r){if(r&&!c(this,R).some(i=>i.id===r))return r;let t;do t=`series_${++Vi}`;while(c(this,R).some(i=>i.id===t));return t},Bt=new WeakMap,J=new WeakMap,q=new WeakMap,ft=new WeakMap;const Yi={background:"#ffffff",chartGradient:["#ffffff","#f5f6f8"],typography:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:12,axisFontSize:10,yFontSize:11,tooltipFontSize:12},grid:{color:"rgba(0, 0, 0, 0.06)",style:"solid"},candlestick:{upColor:"#089981",downColor:"#f23645",wickUpColor:"#089981",wickDownColor:"#f23645"},line:{color:"#2962FF",width:1,areaTopColor:"rgba(41, 98, 255, 0.08)",areaBottomColor:"rgba(41, 98, 255, 0.01)"},seriesColors:["#2962FF","#FF6D00","#089981","#AB47BC","#f23645","#E6A700","#43A047","#D81B60","#1E88E5","#7E57C2"],bands:{upper:"#1E88E5",lower:"#D81B60"},crosshair:{color:"rgba(0, 0, 0, 0.2)",labelBackground:"#4c525e",labelTextColor:"#ffffff"},axis:{textColor:"#787b86"},yLabel:{upBackground:"#089981",downBackground:"#f23645",neutralBackground:"#4c525e",textColor:"#ffffff"},tooltip:{background:"rgba(255, 255, 255, 0.95)",textColor:"#131722",borderColor:"rgba(0, 0, 0, 0.1)"}};function _i(r){return parseInt(r.slice(1,3),16)*.299+parseInt(r.slice(3,5),16)*.587+parseInt(r.slice(5,7),16)*.114<128}function I(r){var t,i,e,a,o,s,n,l,h,d,g,f,p,m,b,u,y,v,C,w,D,M,B,L,E,P,O,$,K;const{background:V,name:at="Custom",description:Y,fontUrl:_=null,backgroundImage:Q,backgroundSize:ii}=r,G=_i(V),oi=G?"#d1d4dc":"#24292f",ri=G?"#787b86":"#8b949e",Zt=G?"#26a69a":"#2da44e",te=G?"#ef5350":"#cf222e",ai=G?"#2962ff":"#0969da",si=G?"rgba(42,46,57,0.6)":"rgba(200,200,200,0.5)",ni=G?"rgba(150,150,150,0.5)":"rgba(170,170,170,0.3)",ee=G?Dt(V,.1):de(V,.05),li=G?mt(V,.92):mt(V,.95),ci=G?mt(Dt(V,.15),.6):"rgba(200,200,200,0.5)",hi=Pt,It=((t=r.candlestick)==null?void 0:t.upColor)??Zt,Mt=((i=r.candlestick)==null?void 0:i.downColor)??te,pt=((e=r.line)==null?void 0:e.color)??ai,ie=((a=r.tooltip)==null?void 0:a.textColor)??oi,di=((o=r.axis)==null?void 0:o.textColor)??ri,ui=((s=r.typography)==null?void 0:s.fontFamily)??hi;return{name:at,description:Y,dark:G,fontUrl:_,backgroundImage:Q,backgroundSize:ii,background:V,chartGradient:r.chartGradient??(G?[Dt(V,.04),de(V,.06)]:[Dt(V,.06),V]),typography:{fontFamily:ui,fontSize:((n=r.typography)==null?void 0:n.fontSize)??12,axisFontSize:((l=r.typography)==null?void 0:l.axisFontSize)??10,yFontSize:((h=r.typography)==null?void 0:h.yFontSize)??11,tooltipFontSize:((d=r.typography)==null?void 0:d.tooltipFontSize)??((g=r.typography)==null?void 0:g.fontSize)??12},grid:{color:((f=r.grid)==null?void 0:f.color)??si,style:((p=r.grid)==null?void 0:p.style)??"dashed"},candlestick:{upColor:It,downColor:Mt,wickUpColor:((m=r.candlestick)==null?void 0:m.wickUpColor)??It,wickDownColor:((b=r.candlestick)==null?void 0:b.wickDownColor)??Mt},line:{color:pt,width:((u=r.line)==null?void 0:u.width)??1,areaTopColor:((y=r.line)==null?void 0:y.areaTopColor)??mt(pt,.08),areaBottomColor:((v=r.line)==null?void 0:v.areaBottomColor)??mt(pt,.01)},seriesColors:r.seriesColors??[pt,Zt,te],bands:{upper:((C=r.bands)==null?void 0:C.upper)??pt,lower:((w=r.bands)==null?void 0:w.lower)??Mt},crosshair:{color:((D=r.crosshair)==null?void 0:D.color)??ni,labelBackground:((M=r.crosshair)==null?void 0:M.labelBackground)??ee,labelTextColor:((B=r.crosshair)==null?void 0:B.labelTextColor)??ie},axis:{textColor:di},yLabel:{upBackground:((L=r.yLabel)==null?void 0:L.upBackground)??It,downBackground:((E=r.yLabel)==null?void 0:E.downBackground)??Mt,neutralBackground:((P=r.yLabel)==null?void 0:P.neutralBackground)??ee,textColor:((O=r.yLabel)==null?void 0:O.textColor)??"#ffffff"},tooltip:{background:(($=r.tooltip)==null?void 0:$.background)??li,textColor:ie,borderColor:((K=r.tooltip)==null?void 0:K.borderColor)??ci}}}function mt(r,t){const i=parseInt(r.slice(1,3),16),e=parseInt(r.slice(3,5),16),a=parseInt(r.slice(5,7),16);return`rgba(${i}, ${e}, ${a}, ${t})`}function Dt(r,t){if(!r.startsWith("#"))return r;const i=Math.min(255,Math.round(parseInt(r.slice(1,3),16)+255*t)),e=Math.min(255,Math.round(parseInt(r.slice(3,5),16)+255*t)),a=Math.min(255,Math.round(parseInt(r.slice(5,7),16)+255*t));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function de(r,t){if(!r.startsWith("#"))return r;const i=Math.max(0,Math.round(parseInt(r.slice(1,3),16)*(1-t))),e=Math.max(0,Math.round(parseInt(r.slice(3,5),16)*(1-t))),a=Math.max(0,Math.round(parseInt(r.slice(5,7),16)*(1-t)));return`#${i.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}const zt="'JetBrains Mono', 'Fira Code', monospace",Lt="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap",Pt="'Outfit', -apple-system, BlinkMacSystemFont, sans-serif",Gt="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap",ye="'Roboto Mono', monospace",ve="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600&display=swap",Ui="'IBM Plex Mono', monospace",Oi="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap",Nt="'Fira Code', monospace",Jt="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap",xe="'Source Code Pro', monospace",Ce="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;500;600&display=swap",$i="'Space Mono', monospace",Xi="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap",qt="'Plus Jakarta Sans', sans-serif",Kt="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap",Hi="'Caveat', 'Comic Sans MS', cursive",Gi="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&display=swap",we=I({name:"Andromeda",description:"Deep space purples and cosmic blues",background:"#23262e",grid:{color:"rgba(50,48,56,0.8)"},candlestick:{upColor:"#96e072",downColor:"#ee5d43"},line:{color:"#00e8c6"},seriesColors:["#00e8c6","#f39c12","#96e072","#c74ded","#ee5d43","#ffe66d","#00e8c6","#ee5d43","#7cb7ff","#c74ded"],bands:{upper:"#7cb7ff",lower:"#c74ded"},crosshair:{color:"rgba(102,94,110,0.4)",labelBackground:"#2e3038"},axis:{textColor:"#665e6e"},tooltip:{background:"rgba(35,38,46,0.92)",textColor:"#d5ced9",borderColor:"rgba(50,48,56,0.6)"},typography:{fontFamily:ye},fontUrl:ve}),Se=I({name:"Ayu Mirage",description:"Warm dark with amber accents",background:"#1f2430",grid:{color:"rgba(42,48,60,0.8)"},candlestick:{upColor:"#bae67e",downColor:"#f27983"},line:{color:"#73d0ff"},seriesColors:["#73d0ff","#ffad66","#bae67e","#d4bfff","#f27983","#ffd580","#95e6cb","#f28779","#5ccfe6","#d4bfff"],bands:{upper:"#5ccfe6",lower:"#f28779"},crosshair:{color:"rgba(92,103,115,0.4)",labelBackground:"#2a3040"},axis:{textColor:"#5c6773"},tooltip:{background:"rgba(31,36,48,0.92)",textColor:"#cbccc6",borderColor:"rgba(42,48,60,0.6)"},typography:{fontFamily:Pt},fontUrl:Gt}),ke=I({name:"Catppuccin",description:"Pastel tones on a mocha base",background:"#1e1e2e",grid:{color:"rgba(49,50,68,0.8)"},candlestick:{upColor:"#a6e3a1",downColor:"#f38ba8"},line:{color:"#89b4fa"},seriesColors:["#89b4fa","#fab387","#a6e3a1","#cba6f7","#f38ba8","#f9e2af","#94e2d5","#eba0ac","#74c7ec","#cba6f7"],bands:{upper:"#74c7ec",lower:"#f38ba8"},crosshair:{color:"rgba(108,112,134,0.4)",labelBackground:"#313244"},axis:{textColor:"#6c7086"},tooltip:{background:"rgba(30,30,46,0.92)",textColor:"#cdd6f4",borderColor:"rgba(49,50,68,0.6)"},typography:{fontFamily:Pt},fontUrl:Gt}),Me=I({name:"Dracula",description:"Classic dark with vibrant highlights",background:"#282a36",grid:{color:"rgba(68,71,90,0.8)"},candlestick:{upColor:"#45c868",downColor:"#d04848"},line:{color:"#a080d8"},seriesColors:["#a080d8","#d49858","#45c868","#d068a0","#d04848","#c8d070","#70c0d8","#d04848","#6272a4","#d068a0"],bands:{upper:"#70c0d8",lower:"#d068a0"},crosshair:{color:"rgba(98,114,164,0.4)",labelBackground:"#44475a"},axis:{textColor:"#6272a4"},tooltip:{background:"rgba(40,42,54,0.92)",textColor:"#f8f8f2",borderColor:"rgba(68,71,90,0.6)"},typography:{fontFamily:Nt},fontUrl:Jt}),Re=I({name:"GitHub Light",description:"Clean and familiar, GitHub-inspired",background:"#fafbfc",chartGradient:["#ffffff","#fafbfc"],grid:{color:"rgba(208,215,222,0.4)"},candlestick:{upColor:"#2da44e",downColor:"#cf222e"},line:{color:"#0969da",areaTopColor:"rgba(9,105,218,0.05)",areaBottomColor:"rgba(9,105,218,0.005)"},seriesColors:["#0969da","#c4820e","#2da44e","#8250df","#cf222e","#c4820e","#0550ae","#cf222e","#2da44e","#8250df"],bands:{upper:"#0550ae",lower:"#cf222e"},crosshair:{color:"rgba(208,215,222,0.3)",labelBackground:"#f0f3f6"},axis:{textColor:"#8b949e"},tooltip:{background:"rgba(250,251,252,0.95)",textColor:"#24292f",borderColor:"rgba(216,222,228,0.5)"},typography:{fontFamily:Ui},fontUrl:Oi}),Te=I({name:"Gruvbox",description:"Retro warm with earthy tones",background:"#282828",grid:{color:"rgba(60,56,54,0.8)"},candlestick:{upColor:"#b8bb26",downColor:"#fb4934"},line:{color:"#83a598"},seriesColors:["#83a598","#fe8019","#b8bb26","#d3869b","#fb4934","#fabd2f","#8ec07c","#fb4934","#458588","#d3869b"],bands:{upper:"#83a598",lower:"#d3869b"},crosshair:{color:"rgba(146,131,116,0.4)",labelBackground:"#3c3836"},axis:{textColor:"#928374"},tooltip:{background:"rgba(40,40,40,0.92)",textColor:"#ebdbb2",borderColor:"rgba(60,56,54,0.6)"},typography:{fontFamily:zt},fontUrl:Lt}),De={name:"Handwritten",description:"Sketch-style with a personal touch",fontUrl:Gi,dark:!1,background:"#fdf5e6",chartGradient:["#fef6e3","#fdf5e6"],typography:{fontFamily:Hi,fontSize:18,axisFontSize:13,yFontSize:15,tooltipFontSize:14},grid:{color:"rgba(180,170,150,0.3)",style:"dashed"},candlestick:{upColor:"#7a9a5e",downColor:"#b07060",wickUpColor:"#7a9a5e",wickDownColor:"#b07060"},line:{color:"#6a8fa0",width:1,areaTopColor:"rgba(106,143,160,0.08)",areaBottomColor:"rgba(106,143,160,0.01)"},seriesColors:["#6a8fa0","#c09050","#7a9a5e","#8a7098","#b07060","#a09030","#508878","#a06878","#6888a0","#8870a0"],bands:{upper:"#6888a0",lower:"#a06878"},crosshair:{color:"rgba(160,152,128,0.3)",labelBackground:"#f5edd8",labelTextColor:"#5c5040"},axis:{textColor:"#a09880"},yLabel:{upBackground:"#7a9a5e",downBackground:"#b07060",neutralBackground:"#e8dcc8",textColor:"#fdf5e6"},tooltip:{background:"rgba(253,245,230,0.95)",textColor:"#5c5040",borderColor:"rgba(180,170,150,0.4)"}},Ni="'Silkscreen', cursive",Ji="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Be=I({name:"Matrix",background:"#000000",candlestick:{upColor:"#00ff41",downColor:"#00802a"},line:{color:"#00ff41"},seriesColors:["#00ff41","#00cc33","#00992a","#33ff66","#66ff88","#00e639","#00b830","#4dff78","#00ff41","#00cc33"],bands:{upper:"#33ff66",lower:"#00802a"},grid:{color:"rgba(0,255,65,0.06)"},axis:{textColor:"#00cc33"},crosshair:{color:"rgba(0,255,65,0.3)",labelBackground:"#0a1a0a"},tooltip:{background:"rgba(0,10,0,0.95)",textColor:"#00ff41",borderColor:"rgba(0,255,65,0.2)"},typography:{fontFamily:Ni},fontUrl:Ji,chartGradient:["#010a01","#000000"]}),ze=I({name:"Lavender Mist",background:"#f5f0f4",candlestick:{upColor:"#6b8e5e",downColor:"#b85468"},line:{color:"#7c6bc4"},seriesColors:["#7c6bc4","#d4885a","#6b8e5e","#c46b8e","#b85468","#8e7a4e","#4e8e8a","#b85468","#7c6bc4","#c46b8e"],bands:{upper:"#4e8e8a",lower:"#b85468"},grid:{color:"rgba(150,130,155,0.12)"},axis:{textColor:"#9a88a0"},crosshair:{color:"rgba(150,130,155,0.2)",labelBackground:"#ebe4e8"},tooltip:{background:"rgba(245,240,244,0.95)",textColor:"#3a3050",borderColor:"rgba(150,130,155,0.25)"},typography:{fontFamily:qt},fontUrl:Kt,chartGradient:["#f8f4f7","#f5f0f4"]}),Le=I({name:"Love",description:"Soft romantic pinks and roses",background:"#fef7f8",chartGradient:["#fffafb","#fef7f8"],grid:{color:"rgba(200,160,175,0.25)"},candlestick:{upColor:"#6a9a6e",downColor:"#c45070"},line:{color:"#a05080"},seriesColors:["#a05080","#d08850","#6a9a6e","#7868a8","#c45070","#c89040","#508890","#c45070","#a05080","#7868a8"],bands:{upper:"#508890",lower:"#c45070"},crosshair:{color:"rgba(180,140,155,0.3)",labelBackground:"#f0dce2"},axis:{textColor:"#b08898"},tooltip:{background:"rgba(253,242,244,0.95)",textColor:"#4a3040",borderColor:"rgba(200,160,175,0.35)"},typography:{fontFamily:Pt},fontUrl:Gt}),Pe=I({name:"Material Palenight",description:"Material Design in moonlit hues",background:"#292d3e",grid:{color:"rgba(55,59,75,0.8)"},candlestick:{upColor:"#c3e88d",downColor:"#f07178"},line:{color:"#82aaff"},seriesColors:["#82aaff","#f78c6c","#c3e88d","#c792ea","#f07178","#ffcb6b","#89ddff","#ff5370","#82aaff","#c792ea"],bands:{upper:"#89ddff",lower:"#f07178"},crosshair:{color:"rgba(103,110,149,0.4)",labelBackground:"#34324a"},axis:{textColor:"#676e95"},tooltip:{background:"rgba(41,45,62,0.92)",textColor:"#a6accd",borderColor:"rgba(55,59,75,0.6)"},typography:{fontFamily:ye},fontUrl:ve}),qi="'Silkscreen', cursive",Ki="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap",Fe=I({name:"Monochrome",description:"Pure black and white, pixel font",background:"#ffffff",chartGradient:["#ffffff","#fafafa"],grid:{color:"rgba(0,0,0,0.06)",style:"solid"},candlestick:{upColor:"#111111",downColor:"#bbbbbb"},line:{color:"#111111"},seriesColors:["#111111","#888888","#bbbbbb","#555555","#999999","#333333","#aaaaaa","#666666","#cccccc","#444444"],bands:{upper:"#555555",lower:"#bbbbbb"},crosshair:{color:"rgba(0,0,0,0.08)",labelBackground:"#f0f0f0"},axis:{textColor:"#b0b0b0"},tooltip:{background:"rgba(255,255,255,0.97)",textColor:"#222222",borderColor:"rgba(0,0,0,0.08)"},typography:{fontFamily:qi,tooltipFontSize:9},fontUrl:Ki}),We=I({name:"Mint Breeze",background:"#f6f5ee",candlestick:{upColor:"#2e9070",downColor:"#d04848"},line:{color:"#2a8a80"},seriesColors:["#2a8a80","#d0884a","#2e9070","#7a68b0","#d04848","#a09040","#3a7a9a","#d04848","#2a8a80","#7a68b0"],bands:{upper:"#3a7a9a",lower:"#d04848"},grid:{color:"rgba(100,150,140,0.1)"},axis:{textColor:"#80a098"},crosshair:{color:"rgba(120,140,120,0.18)",labelBackground:"#ece8de"},tooltip:{background:"rgba(246,245,238,0.95)",textColor:"#2a3530",borderColor:"rgba(130,140,115,0.2)"},typography:{fontFamily:$i},fontUrl:Xi,chartGradient:["#f8f7f0","#f6f5ee"]}),Ie=I({name:"Monokai Pro",description:"Bold syntax colors on dark gray",background:"#2d2a2e",grid:{color:"rgba(64,60,62,0.8)"},candlestick:{upColor:"#8ab862",downColor:"#d05470"},line:{color:"#62b8c8"},seriesColors:["#62b8c8","#d08050","#8ab862","#9080c8","#d05470","#d0b850","#62b8c8","#d05470","#8ab862","#9080c8"],bands:{upper:"#62b8c8",lower:"#d05470"},crosshair:{color:"rgba(114,112,114,0.4)",labelBackground:"#403e42"},axis:{textColor:"#727072"},tooltip:{background:"rgba(45,42,46,0.92)",textColor:"#fcfcfa",borderColor:"rgba(64,60,62,0.6)"},typography:{fontFamily:Nt},fontUrl:Jt}),Ae=I({name:"Night Owl",description:"Crafted for late-night coding",background:"#011627",grid:{color:"rgba(31,52,72,0.8)"},candlestick:{upColor:"#7ec699",downColor:"#e06c75"},line:{color:"#82aaff"},seriesColors:["#82aaff","#d49a6a","#7ec699","#b48ead","#e06c75","#d4b568","#5fb3a1","#d47084","#6bc5e0","#b48ead"],bands:{upper:"#6bc5e0",lower:"#d47084"},crosshair:{color:"rgba(99,119,119,0.4)",labelBackground:"#1d3b53"},axis:{textColor:"#495a5a"},tooltip:{background:"rgba(1,22,39,0.92)",textColor:"#d6deeb",borderColor:"rgba(31,52,72,0.6)"},typography:{fontFamily:zt},fontUrl:Lt}),je=I({name:"One Dark Pro",description:"Atom editor's iconic dark palette",background:"#282c34",grid:{color:"rgba(59,64,72,0.8)"},candlestick:{upColor:"#98c379",downColor:"#e06c75"},line:{color:"#61afef"},seriesColors:["#61afef","#e5c07b","#98c379","#c678dd","#e06c75","#56b6c2","#d19a66","#be5046","#61afef","#c678dd"],bands:{upper:"#56b6c2",lower:"#c678dd"},crosshair:{color:"rgba(99,110,123,0.4)",labelBackground:"#3e4451"},axis:{textColor:"#5c6370"},tooltip:{background:"rgba(40,44,52,0.92)",textColor:"#abb2bf",borderColor:"rgba(59,64,72,0.6)"},typography:{fontFamily:zt},fontUrl:Lt}),Ee=I({name:"Panda",description:"Playful neons on charcoal",background:"#292a2b",grid:{color:"rgba(58,58,60,0.8)"},candlestick:{upColor:"#19f9d8",downColor:"#ff75b5"},line:{color:"#6fc1ff"},seriesColors:["#6fc1ff","#ffb86c","#19f9d8","#b084eb","#ff75b5","#ffcc95","#19f9d8","#ff4b82","#45a9f9","#b084eb"],bands:{upper:"#45a9f9",lower:"#ff75b5"},crosshair:{color:"rgba(117,117,117,0.4)",labelBackground:"#3a3a3c"},axis:{textColor:"#757575"},tooltip:{background:"rgba(41,42,43,0.92)",textColor:"#e6e6e6",borderColor:"rgba(58,58,60,0.6)"},typography:{fontFamily:Nt},fontUrl:Jt}),Ve=I({name:"Peach Cream",background:"#fef6f0",candlestick:{upColor:"#5a9a68",downColor:"#d06848"},line:{color:"#d07040"},seriesColors:["#d07040","#5a9a68","#8a6aaa","#c0884a","#d06848","#4a8a9a","#9a7a4a","#d06848","#d07040","#8a6aaa"],bands:{upper:"#4a8a9a",lower:"#d06848"},grid:{color:"rgba(180,140,120,0.12)"},axis:{textColor:"#b09080"},crosshair:{color:"rgba(180,140,120,0.2)",labelBackground:"#f0e4d8"},tooltip:{background:"rgba(254,246,240,0.95)",textColor:"#4a3028",borderColor:"rgba(180,140,120,0.25)"},typography:{fontFamily:qt},fontUrl:Kt,chartGradient:["#fff8f2","#fef6f0"]}),Ye=I({name:"Quiet Light",description:"Subdued and easy on the eyes",background:"#f5f5f5",grid:{color:"rgba(200,200,200,0.5)"},candlestick:{upColor:"#448c27",downColor:"#aa3731"},line:{color:"#4b69c6"},seriesColors:["#4b69c6","#c47820","#448c27","#7a3e9d","#aa3731","#c47820","#2d8fa1","#aa3731","#448c27","#7a3e9d"],bands:{upper:"#2d8fa1",lower:"#aa3731"},crosshair:{color:"rgba(170,170,170,0.3)",labelBackground:"#e8e8e8"},axis:{textColor:"#aaaaaa"},tooltip:{background:"rgba(245,245,245,0.95)",textColor:"#333333",borderColor:"rgba(200,200,200,0.5)"},typography:{fontFamily:qt},fontUrl:Kt}),_e=I({name:"Rosé Pine Dawn",description:"Dawn-inspired warm neutrals",background:"#faf4ed",grid:{color:"rgba(152,147,165,0.2)"},candlestick:{upColor:"#56949f",downColor:"#b4637a"},line:{color:"#907aa9"},seriesColors:["#907aa9","#ea9d34","#56949f","#d7827e","#b4637a","#ea9d34","#286983","#b4637a","#907aa9","#d7827e"],bands:{upper:"#286983",lower:"#b4637a"},crosshair:{color:"rgba(152,147,165,0.3)",labelBackground:"#f2e9e1"},axis:{textColor:"#9893a5"},tooltip:{background:"rgba(250,244,237,0.95)",textColor:"#575279",borderColor:"rgba(152,147,165,0.3)"},typography:{fontFamily:xe},fontUrl:Ce}),Ue=I({name:"Sand Dune",background:"#f4f0e8",candlestick:{upColor:"#5a8a50",downColor:"#b85040"},line:{color:"#8a6a3a"},seriesColors:["#8a6a3a","#b87a40","#5a8a50","#7a5a70","#b85040","#a09030","#4a7a7a","#b85040","#8a6a3a","#7a5a70"],bands:{upper:"#4a7a7a",lower:"#b85040"},grid:{color:"rgba(150,130,100,0.15)"},axis:{textColor:"#9a8a70"},crosshair:{color:"rgba(150,130,100,0.2)",labelBackground:"#e8e0d0"},tooltip:{background:"rgba(244,240,232,0.95)",textColor:"#3a3020",borderColor:"rgba(150,130,100,0.3)"},typography:{fontFamily:xe},fontUrl:Ce,chartGradient:["#f8f4ec","#f4f0e8"]}),Oe=I({name:"Solarized Light",description:"Ethan Schoonover's precision palette",background:"#fdf6e3",chartGradient:["#fef8e8","#fdf6e3"],grid:{color:"rgba(238,232,213,0.8)"},candlestick:{upColor:"#859900",downColor:"#dc322f"},line:{color:"#268bd2"},seriesColors:["#268bd2","#cb4b16","#859900","#6c71c4","#dc322f","#b58900","#2aa198","#d33682","#268bd2","#6c71c4"],bands:{upper:"#2aa198",lower:"#d33682"},crosshair:{color:"rgba(147,161,161,0.3)",labelBackground:"#eee8d5"},axis:{textColor:"#93a1a1"},tooltip:{background:"rgba(253,246,227,0.95)",textColor:"#586e75",borderColor:"rgba(238,232,213,0.6)"},typography:{fontFamily:zt},fontUrl:Lt}),_t={Dracula:Me,"One Dark Pro":je,"Monokai Pro":Ie,"Night Owl":Ae,"Material Palenight":Pe,Gruvbox:Te,Catppuccin:ke,"Ayu Mirage":Se,Panda:Ee,Andromeda:we,Matrix:Be,Handwritten:De,"GitHub Light":Re,"Solarized Light":Oe,"Rosé Pine Dawn":_e,"Quiet Light":Ye,"Lavender Mist":ze,"Mint Breeze":We,"Sand Dune":Ue,"Peach Cream":Ve,Monochrome:Fe,Love:Le};function Qi(r){return _t[r]??_t["One Dark Pro"]}const Ut=k.createContext(null);function H(){const r=k.useContext(Ut);if(!r)throw new Error("useChartInstance must be used within <ChartContainer>");return r}function $e({data:r,options:t,label:i,id:e,onSeriesId:a}){var n;const o=H(),s=k.useRef(null);return k.useLayoutEffect(()=>{const l=o.addBarSeries({...t,label:i??(t==null?void 0:t.label),layers:r.length,id:e});return s.current=l,a==null||a(l),()=>{o.removeSeries(l),s.current=null}},[o,r.length,e]),k.useLayoutEffect(()=>{const l=s.current;l&&o.batch(()=>{for(let h=0;h<r.length;h++)o.setBarLayerData(l,h,r[h])})},[o,r]),k.useEffect(()=>{s.current&&t&&o.updateSeriesOptions(s.current,t)},[o,(n=t==null?void 0:t.colors)==null?void 0:n.join(","),t==null?void 0:t.barWidthRatio,t==null?void 0:t.stacking]),null}function Zi({data:r,options:t,id:i,onSeriesId:e}){const a=H(),o=k.useRef(null),s=k.useRef(0);return k.useLayoutEffect(()=>{const n=a.addCandlestickSeries({...t,id:i});return o.current=n,e==null||e(n),()=>{a.removeSeries(n),o.current=null,s.current=0}},[a,i]),k.useLayoutEffect(()=>{const n=o.current;if(!n)return;if(r.length===0){a.setSeriesData(n,[]),s.current=0;return}const l=s.current;if(l===0||r.length<l||r.length-l>5)a.setSeriesData(n,r);else if(r.length===l)a.updateData(n,r[r.length-1]);else for(let h=l;h<r.length;h++)a.appendData(n,r[h]);s.current=r.length},[a,r]),k.useEffect(()=>{o.current&&t&&a.updateSeriesOptions(o.current,t)},[a,t==null?void 0:t.upColor,t==null?void 0:t.downColor,t==null?void 0:t.wickUpColor,t==null?void 0:t.wickDownColor,t==null?void 0:t.bodyWidthRatio,t==null?void 0:t.candleGradient]),null}const Qt=k.createContext(null),Ot=Qt.Provider;function Xe(){const r=k.useContext(Qt);if(!r)throw new Error("useTheme must be used within <ThemeProvider>");return r}function to(){return k.useContext(Qt)}function He({items:r,position:t="bottom",mode:i="toggle"}){const e=H(),a=Xe(),[o,s]=k.useState(new Set),[,n]=k.useState(0);k.useLayoutEffect(()=>{const f=()=>{n(m=>m+1),s(new Set)},p=()=>n(m=>m+1);return e.on("seriesChange",f),e.on("dataUpdate",p),e.getSeriesIds().length>0&&n(m=>m+1),()=>{e.off("seriesChange",f),e.off("dataUpdate",p)}},[e]);const l=(r==null?void 0:r.map((f,p)=>({...f,seriesId:"",layerIndex:p,isLayer:!1})))??(()=>{const f=[];for(const p of e.getSeriesIds()){const m=e.getSeriesLayers(p);if(m){const b=e.getSeriesLabel(p);for(let u=0;u<m.length;u++)f.push({label:b?`${b} ${u+1}`:`Series ${u+1}`,color:m[u].color,seriesId:p,layerIndex:u,isLayer:!0})}else{const b=e.getSeriesColor(p),u=e.getSeriesLabel(p);b&&f.push({label:u??"Series",color:b,seriesId:p,layerIndex:0,isLayer:!1})}}return f})();if(l.length===0)return null;const h=f=>{s(f),e.beginUpdate();for(let p=0;p<l.length;p++){const m=l[p];m.seriesId&&(m.isLayer?e.setLayerVisible(m.seriesId,m.layerIndex,!f.has(p)):e.setSeriesVisible(m.seriesId,!f.has(p)))}e.endUpdate()},d=f=>{if(i==="solo")if(l.every((m,b)=>b===f||o.has(b)))h(new Set);else{const m=new Set(l.map((b,u)=>u));m.delete(f),h(m)}else{const p=new Set(o);p.has(f)?p.delete(f):p.add(f),h(p)}},g=t==="right";return x.jsx("div",{"data-legend":t,style:{display:"flex",flexDirection:g?"column":"row",flexWrap:"wrap",gap:g?6:14,padding:g?"8px 6px":"6px 8px",alignItems:g?"flex-start":"center",justifyContent:g?"flex-start":"center",fontFamily:a.typography.fontFamily,fontSize:a.typography.axisFontSize,color:a.axis.textColor,pointerEvents:"auto",flexShrink:0},children:l.map((f,p)=>{const m=o.has(p),b=!!f.seriesId;return x.jsxs("div",{onClick:b?()=>d(p):void 0,style:{display:"flex",alignItems:"center",gap:4,cursor:b?"pointer":"default",opacity:m?.35:1,transition:"opacity 0.15s ease",userSelect:"none"},children:[x.jsx("span",{style:{width:8,height:8,borderRadius:2,background:f.color,flexShrink:0}}),x.jsx("span",{style:{whiteSpace:"nowrap"},children:f.label})]},p)})})}function Ge({children:r,theme:t,axis:i,padding:e,gradient:a=!0,interactive:o,grid:s,style:n,className:l}){var E,P,O,$,K,V,at;const h=to(),d=t??h??void 0,g=k.useRef(null),f=k.useRef(null),[p,m]=k.useState(0);k.useLayoutEffect(()=>{if(!g.current||f.current)return;const Y={};return i&&(Y.axis=i),d&&(Y.theme=d),e&&(Y.padding=e),o!==void 0&&(Y.interactive=o),s!==void 0&&(Y.grid=s),f.current=new be(g.current,Y),m(_=>_+1),()=>{const _=f.current;f.current=null,setTimeout(()=>{f.current||_==null||_.destroy()},0)}},[]),k.useEffect(()=>{f.current&&d&&f.current.setTheme(d)},[d]),k.useEffect(()=>{f.current&&i&&f.current.setAxis(i)},[(E=i==null?void 0:i.y)==null?void 0:E.width,(P=i==null?void 0:i.y)==null?void 0:P.min,(O=i==null?void 0:i.y)==null?void 0:O.max,($=i==null?void 0:i.y)==null?void 0:$.visible,(K=i==null?void 0:i.x)==null?void 0:K.height,(V=i==null?void 0:i.x)==null?void 0:V.visible]),k.useEffect(()=>{f.current&&e&&f.current.setPadding(e)},[e==null?void 0:e.top,e==null?void 0:e.bottom,typeof(e==null?void 0:e.right)=="object"?e.right.intervals:e==null?void 0:e.right,typeof(e==null?void 0:e.left)=="object"?e.left.intervals:e==null?void 0:e.left]),k.useEffect(()=>{f.current&&s!==void 0&&f.current.setGrid(s)},[s]);const b=f.current,{legendEl:u,overlay:y}=(()=>{let Y=null;const _=[];return k.Children.forEach(r,Q=>{k.isValidElement(Q)&&Q.type===He?Y=Q:_.push(Q)}),{legendEl:Y,overlay:_}})(),C=(((at=u==null?void 0:u.props)==null?void 0:at.position)??"bottom")==="right",w=d??(b==null?void 0:b.getTheme()),[D,M]=(w==null?void 0:w.chartGradient)??["transparent","transparent"],B=(w==null?void 0:w.background)??"transparent",L=a?`linear-gradient(to bottom, ${D} 0%, ${B} 70%, ${M} 100%)`:B;return x.jsxs("div",{className:l,style:{display:"flex",flexDirection:C?"row":"column",width:"100%",height:"100%",overflow:"hidden",background:L,...n},children:[x.jsx("div",{ref:g,style:{position:"relative",flex:1,minWidth:0,minHeight:0,overflow:"hidden"},children:b&&x.jsx(Ut.Provider,{value:b,children:x.jsx(Ot,{value:d??b.getTheme(),children:x.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:2},children:y})})})}),b&&u&&x.jsx(Ut.Provider,{value:b,children:x.jsx(Ot,{value:d??b.getTheme(),children:u})})]})}function Ne({data:r,options:t,label:i,id:e,onSeriesId:a}){var n;const o=H(),s=k.useRef(null);return k.useLayoutEffect(()=>{const l=o.addLineSeries({...t,label:i??(t==null?void 0:t.label),layers:r.length,id:e});return s.current=l,a==null||a(l),()=>{o.removeSeries(l),s.current=null}},[o,r.length,e]),k.useLayoutEffect(()=>{const l=s.current;l&&o.batch(()=>{for(let h=0;h<r.length;h++)o.setLineLayerData(l,h,r[h])})},[o,r]),k.useEffect(()=>{s.current&&t&&o.updateSeriesOptions(s.current,t)},[o,(n=t==null?void 0:t.colors)==null?void 0:n.join(","),t==null?void 0:t.lineWidth,t==null?void 0:t.areaFill,t==null?void 0:t.pulse,t==null?void 0:t.stacking]),null}function eo({data:r,options:t,id:i,onSeriesId:e}){const a=H(),o=k.useRef(null);return k.useLayoutEffect(()=>{const s=a.addPieSeries({...t,id:i});return o.current=s,e==null||e(s),()=>{a.removeSeries(s),o.current=null}},[a,i]),k.useEffect(()=>{o.current&&t&&a.updateSeriesOptions(o.current,t)},[a,t==null?void 0:t.innerRadiusRatio,t==null?void 0:t.padAngle,t==null?void 0:t.strokeColor,t==null?void 0:t.strokeWidth,t==null?void 0:t.colors]),k.useLayoutEffect(()=>{o.current&&a.setPieData(o.current,r)},[a,r]),null}function Ft(r,t,i){const e=Array.isArray(t)?t:[t];return{subscribe:a=>{for(const o of e)r.on(o,a);return()=>{for(const o of e)r.off(o,a)}},getSnapshot:i}}function Je(r){const t=k.useMemo(()=>Ft(r,["viewportChange","dataUpdate","seriesChange"],()=>r.getVisibleRange()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function qe(r){const t=k.useMemo(()=>Ft(r,["viewportChange","dataUpdate","seriesChange"],()=>r.getYRange()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function Ke(r,t){const i=k.useMemo(()=>{let e=r.getLastValue(t);return{subscribe:o=>{const s=()=>{const l=r.getLastValue(t);(e==null?void 0:e.value)===(l==null?void 0:l.value)&&(e==null?void 0:e.isLive)===(l==null?void 0:l.isLive)||(e=l,o())},n=()=>{const l=r.getLastValue(t),h=l?r.yScale.valueToY(l.value):null,d=e?r.yScale.valueToY(e.value):null;h===d&&(e==null?void 0:e.value)===(l==null?void 0:l.value)&&(e==null?void 0:e.isLive)===(l==null?void 0:l.isLive)||(e=l,o())};return r.on("dataUpdate",s),r.on("viewportChange",n),()=>{r.off("dataUpdate",s),r.off("viewportChange",n)}},getSnapshot:()=>e}},[r,t]);return k.useSyncExternalStore(i.subscribe,i.getSnapshot)}function Qe(r,t){const i=k.useMemo(()=>Ft(r,"dataUpdate",()=>r.getPreviousClose(t)),[r,t]);return k.useSyncExternalStore(i.subscribe,i.getSnapshot)}function Wt(r){const t=k.useMemo(()=>Ft(r,"crosshairMove",()=>r.getCrosshairPosition()),[r]);return k.useSyncExternalStore(t.subscribe,t.getSnapshot)}function io(){const r=H(),t=Wt(r);if(!t)return null;const i=r.getTheme(),e=r.getDataInterval(),a={background:i.crosshair.labelBackground,color:i.crosshair.labelTextColor,fontSize:i.typography.axisFontSize,fontFamily:i.typography.fontFamily,padding:"2px 6px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none"};return x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"absolute",right:0,top:t.mediaY,transform:"translateY(-50%)",...a},children:r.yScale.formatY(t.y)}),x.jsx("div",{style:{position:"absolute",bottom:0,left:t.mediaX,transform:"translateX(-50%)",...a},children:kt(t.time,e)})]})}const oo=["0","1","2","3","4","5","6","7","8","9"];function ro(r){const t=[];for(const i of r)i>="0"&&i<="9"?t.push({type:"digit",value:i}):t.push({type:"symbol",value:i});return t}function Ze({value:r,format:t,locale:i="en-US",spinDuration:e=350,className:a,style:o}){const n=k.useMemo(()=>new Intl.NumberFormat(i,t),[i,t]).format(r),l=ro(n);return x.jsx("span",{className:a,style:{display:"inline-flex",fontVariantNumeric:"tabular-nums",lineHeight:1.2,...o},children:l.map((h,d)=>h.type==="digit"?x.jsx(ao,{digit:parseInt(h.value),duration:e},`d${d}`):x.jsx("span",{style:{display:"inline-block"},children:h.value},`s${d}`))})}function ao({digit:r,duration:t}){const i=k.useRef(!1);return k.useEffect(()=>{i.current=!0},[]),x.jsx("span",{style:{display:"inline-block",height:"1.2em",overflow:"hidden",position:"relative"},children:x.jsx("span",{style:{display:"flex",flexDirection:"column",transform:`translateY(${-r*1.2}em)`,transition:i.current?`transform ${t}ms cubic-bezier(0.16, 1, 0.3, 1)`:"none"},children:oo.map(e=>x.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"1.2em"},children:e},e))})})}function so(r){return r>=1e9?(r/1e9).toFixed(1)+"B":r>=1e6?(r/1e6).toFixed(1)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toLocaleString()}function no({seriesId:r,format:t="value"}){const i=H(),e=i.getTheme(),[,a]=k.useState(0);k.useEffect(()=>{const s=()=>a(n=>n+1);return i.on("dataUpdate",s),()=>{i.off("dataUpdate",s)}},[i]);const o=i.getPieSlices(r);return!o||o.length===0?null:x.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 12px",fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize,color:e.tooltip.textColor,pointerEvents:"auto"},children:o.map((s,n)=>x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[x.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:s.color,flexShrink:0}}),x.jsx("span",{style:{flex:1,opacity:.8},children:s.label}),t==="value"&&x.jsx("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums"},children:so(s.value)}),x.jsxs("span",{style:{opacity:t==="percent"?1:.5,fontWeight:t==="percent"?600:400,fontSize:t==="percent"?e.typography.fontSize:e.typography.axisFontSize,fontVariantNumeric:"tabular-nums",minWidth:40,textAlign:"right"},children:[s.percent.toFixed(1),"%"]})]},n))})}function lo({seriesId:r}){const t=H(),i=Wt(t),e=t.getPieHoverInfo(r);if(!e||!i)return null;const a=t.getTheme(),o=t.getMediaSize(),s=160,n=70,l=16,h=16,d=i.mediaX+l+s>o.width?i.mediaX-l-s:i.mediaX+l,g=i.mediaY+h+n>o.height?i.mediaY-h-n:i.mediaY+h;return x.jsxs("div",{style:{position:"absolute",left:d,top:g,pointerEvents:"none",background:a.tooltip.background,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${a.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:a.typography.fontSize,fontFamily:a.typography.fontFamily,color:a.tooltip.textColor,zIndex:10,display:"flex",flexDirection:"column",gap:6},children:[x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:e.color,flexShrink:0}}),x.jsx("span",{style:{fontWeight:600},children:e.label})]}),x.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:16},children:[x.jsx("span",{style:{opacity:.6},children:e.value.toLocaleString()}),x.jsxs("span",{style:{fontWeight:600},children:[e.percent.toFixed(1),"%"]})]})]})}function co(r,t){if(r.startsWith("rgba")||!r.startsWith("#"))return r;const i=parseInt(r.slice(1,3),16),e=parseInt(r.slice(3,5),16),a=parseInt(r.slice(5,7),16);return`rgba(${i}, ${e}, ${a}, ${t})`}function ho(r){return Math.abs(r)>=1e6?`${(r/1e6).toFixed(1)}M`:Math.abs(r)>=1e4?`${(r/1e3).toFixed(1)}K`:Math.abs(r)>=1e3?`${(r/1e3).toFixed(2)}K`:Math.abs(r)<1?r.toFixed(4):Math.abs(r)<10?r.toFixed(2):r.toFixed(1)}function uo(r){if(r.length<2)return{value:0,pct:0,positive:!0};const t=r[0].value,e=r[r.length-1].value-t,a=t!==0?e/t*100:0;return{value:e,pct:a,positive:e>=0}}function fo({data:r,theme:t,variant:i="line",valuePosition:e="right",formatValue:a=ho,label:o,sublabel:s,color:n,negativeColor:l,areaFill:h=!0,width:d=140,height:g=48,lineWidth:f=1.5,gradient:p=!0,style:m}){const b=r.length>0?r[r.length-1].value:0,u=k.useMemo(()=>uo(r),[r]),y=n??t.seriesColors[0],v=l??t.candlestick.downColor,C=u.positive?t.candlestick.upColor:t.candlestick.downColor,w=e!=="none"&&x.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:1,minWidth:0,flexShrink:0},children:[o&&x.jsx("div",{style:{fontSize:t.typography.axisFontSize,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o}),x.jsx("div",{style:{fontSize:t.typography.fontSize+3,fontWeight:700,color:t.tooltip.textColor,lineHeight:1.1,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:a(b)}),s!==void 0?x.jsx("div",{style:{fontSize:t.typography.axisFontSize-1,color:t.axis.textColor,lineHeight:1.2,whiteSpace:"nowrap"},children:s}):x.jsxs("div",{style:{fontSize:t.typography.axisFontSize-1,fontWeight:500,color:C,lineHeight:1.2,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[u.positive?"+":"",u.pct.toFixed(1),"%"]})]}),D=x.jsx("div",{style:{width:d,height:g,flexShrink:0,borderRadius:4,overflow:"hidden"},children:x.jsx(Ge,{theme:t,axis:{y:{visible:!1,width:0},x:{visible:!1,height:0}},padding:{top:5,right:0,bottom:0,left:0},gradient:p,interactive:!1,grid:!1,children:i==="line"?x.jsx(Ne,{data:[r],options:{colors:[y],lineWidth:f,areaFill:h,pulse:!1,stacking:"off"}}):x.jsx($e,{data:[r],options:{colors:[y,v],barWidthRatio:.7,stacking:"off"}})})});return x.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:12,padding:"8px 12px",borderRadius:8,background:co(t.tooltip.background,.7),border:`1px solid ${t.tooltip.borderColor}`,fontFamily:t.typography.fontFamily,...m},children:[e==="left"&&w,D,e==="right"&&w]})}function ti(){const r=H();Je(r);const t=r.getTheme(),i=r.getDataInterval(),{ticks:e,tickInterval:a}=r.timeScale.niceTickValues(i),o=new Set(e),n=k.useRef(new Map).current,l=performance.now();for(const d of e)n.has(d)?n.get(d).opacity=1:n.set(d,{opacity:1,addedAt:l});for(const[d,g]of n)o.has(d)||g.opacity!==0&&(g.opacity=0,g.fadedAt=l);for(const[d,g]of n)g.opacity===0&&g.fadedAt!==void 0&&l-g.fadedAt>600&&n.delete(d);const h=Array.from(n.entries());return x.jsx("div",{style:{position:"absolute",left:0,bottom:0,right:r.yAxisWidth,height:r.xAxisHeight,pointerEvents:"none",display:"flex",alignItems:"center"},children:h.map(([d,g])=>{const f=r.timeScale.timeToX(d);return x.jsx("span",{style:{position:"absolute",left:f,transform:"translateX(-50%)",color:t.axis.textColor,fontSize:t.typography.axisFontSize,fontFamily:t.typography.fontFamily,userSelect:"none",whiteSpace:"nowrap",opacity:g.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:kt(d,a)},d)})})}function go(r,t){return t==="none"||r.length<=1?r:[...r].sort((i,e)=>{const a="value"in i.data?i.data.value:i.data.close,o="value"in e.data?e.data.value:e.data.close;return t==="asc"?a-o:o-a})}function po({seriesId:r,sort:t="none",showLegend:i,legend:e}){const a=i??e??!0,o=H(),s=Wt(o),n=r?[r]:o.getSeriesIds(),[,l]=k.useState(0);k.useEffect(()=>{const u=()=>l(y=>y+1);return o.on("dataUpdate",u),()=>o.off("dataUpdate",u)},[o]);const h=[];if(s)for(const u of n){const y=o.getLayerSnapshots(u,s.time);if(y)for(let v=0;v<y.length;v++)h.push({id:`${u}_layer${v}`,label:o.getSeriesLabel(u),data:{time:s.time,value:y[v].value},color:y[v].color});else{const v=o.getDataAtTime(u,s.time);v&&h.push({id:u,label:o.getSeriesLabel(u),data:v,color:o.getSeriesColor(u)??"#888"})}}let d;if(h.length>0)d=h;else{const u=[];for(const y of n){const v=o.getLastData(y);if(!v)continue;const C=o.getLayerSnapshots(y,v.time);if(C)for(let w=0;w<C.length;w++)u.push({id:`${y}_layer${w}`,label:o.getSeriesLabel(y),data:{time:v.time,value:C[w].value},color:C[w].color});else u.push({id:y,label:o.getSeriesLabel(y),data:v,color:o.getSeriesColor(y)??"#888"})}d=u}const g=go(d,t),f=o.getTheme();if(g.length===0)return null;const p=o.getDataInterval(),m=o.getMediaSize(),b=g[0].data.time;return x.jsxs(x.Fragment,{children:[a&&x.jsxs("div",{style:{position:"absolute",top:24,left:8,pointerEvents:"none",display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",maxWidth:"70%",fontSize:f.typography.fontSize,fontFamily:f.typography.fontFamily,fontVariantNumeric:"tabular-nums",opacity:s?1:.6,transition:"opacity 0.2s ease"},children:[x.jsx("span",{style:{color:f.axis.textColor,marginRight:2},children:kt(b,p)}),g.map(u=>{if("open"in u.data){const C=u.data,D=C.close>=C.open?f.candlestick.upColor:f.candlestick.downColor;return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[x.jsx(bt,{label:"O",value:C.open,color:D,dim:f.axis.textColor}),x.jsx(bt,{label:"H",value:C.high,color:D,dim:f.axis.textColor}),x.jsx(bt,{label:"L",value:C.low,color:D,dim:f.axis.textColor}),x.jsx(bt,{label:"C",value:C.close,color:D,dim:f.axis.textColor}),C.volume!=null&&x.jsx(bt,{label:"V",value:C.volume,color:f.axis.textColor,dim:f.axis.textColor,volume:!0})]},u.id)}const v=u.data;return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[x.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u.color,flexShrink:0}}),x.jsx("span",{style:{color:u.color,fontWeight:500},children:v.value.toFixed(2)})]},u.id)})]}),s&&h.length>0&&x.jsx(mo,{snapshots:g,x:s.mediaX,y:s.mediaY,chartWidth:m.width-o.yAxisWidth,chartHeight:m.height-o.xAxisHeight,theme:f,dataInterval:p})]})}function bt({label:r,value:t,color:i,dim:e,volume:a}){return x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:e,opacity:.5,marginLeft:5},children:r}),x.jsx("span",{style:{color:i,fontWeight:500,marginLeft:2},children:a?ei(t):t.toFixed(2)})]})}function mo({snapshots:r,x:t,y:i,chartWidth:e,chartHeight:a,theme:o,dataInterval:s}){const n=r.some(C=>"open"in C.data),l=r.filter(C=>!("open"in C.data)).length,h=160,d=n?140:40+l*22,g=16,f=16,p=t+g+h>e?t-g-h:t+g,m=i+f+d>a?i-f-d:i+f,b=o.tooltip.background,u=o.tooltip.borderColor,y="0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06)",v=r[0].data.time;return x.jsxs("div",{style:{position:"absolute",left:p,top:m,pointerEvents:"none",background:b,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:`1px solid ${u}`,borderRadius:8,padding:"10px 14px",boxShadow:y,fontSize:o.typography.tooltipFontSize,fontFamily:o.typography.fontFamily,fontVariantNumeric:"tabular-nums",color:o.tooltip.textColor,minWidth:140,zIndex:10,transition:"opacity 0.15s ease"},children:[x.jsxs("div",{style:{fontSize:o.typography.axisFontSize,color:o.axis.textColor,marginBottom:8,paddingBottom:6,borderBottom:`1px solid ${u}`,letterSpacing:"0.02em"},children:[ge(v)," ",kt(v,s)]}),r.map(C=>{if("open"in C.data){const M=C.data,B=M.close>=M.open,L=o.candlestick.upColor,E=o.candlestick.downColor,P=B?L:E;return x.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px"},children:[x.jsx(yt,{label:"Open",value:M.open,color:P}),x.jsx(yt,{label:"High",value:M.high,color:P}),x.jsx(yt,{label:"Low",value:M.low,color:P}),x.jsx(yt,{label:"Close",value:M.close,color:P}),M.volume!=null&&x.jsx(yt,{label:"Volume",value:M.volume,color:o.tooltip.textColor,volume:!0})]},C.id)}const D=C.data;return x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"2px 0"},children:[x.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:C.color,flexShrink:0}}),x.jsx("span",{style:{opacity:.6,flex:1},children:C.label??"Value"}),x.jsx("span",{style:{fontWeight:600,color:C.color},children:D.value.toFixed(2)})]},C.id)})]})}function yt({label:r,value:t,color:i,volume:e}){return x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{opacity:.5},children:r}),x.jsx("span",{style:{fontWeight:600,color:i,textAlign:"right"},children:e?ei(t):t.toFixed(2)})]})}function ei(r){return r>=1e9?(r/1e9).toFixed(2)+"B":r>=1e6?(r/1e6).toFixed(2)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toFixed(0)}function bo(){const r=H();qe(r);const t=r.getTheme(),i=r.yScale.niceTickValues(),e=new Set(i),o=k.useRef(new Map).current,s=performance.now();for(const l of i)o.has(l)?o.get(l).opacity=1:o.set(l,{opacity:1,addedAt:s});for(const[l,h]of o)e.has(l)||h.opacity!==0&&(h.opacity=0,h.fadedAt=s);for(const[l,h]of o)h.opacity===0&&h.fadedAt!==void 0&&s-h.fadedAt>600&&o.delete(l);const n=Array.from(o.entries());return x.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:r.xAxisHeight,width:r.yAxisWidth,pointerEvents:"none"},children:n.map(([l,h])=>{const d=r.yScale.valueToY(l);return x.jsx("span",{style:{position:"absolute",right:8,top:d,transform:"translateY(-50%)",color:t.axis.textColor,fontSize:t.typography.axisFontSize,fontFamily:t.typography.fontFamily,fontVariantNumeric:"tabular-nums",userSelect:"none",opacity:h.opacity,transition:"opacity 0.3s ease",willChange:"opacity"},children:r.yScale.formatY(l)},l)})})}function yo({seriesId:r,color:t}){const i=H();k.useEffect(()=>(i.setYLabel(!0),()=>i.setYLabel(!1)),[i]);const e=Ke(i,r),a=Qe(i,r);if(!e)return null;const{value:o,isLive:s}=e,n=i.getTheme(),l=i.yScale.valueToY(o);let h;if(!s)h=n.axis.textColor;else if(t)h=t;else{const p=a===null?"neutral":o>a?"up":o<a?"down":"neutral";h=p==="up"?n.yLabel.upBackground:p==="down"?n.yLabel.downBackground:n.yLabel.neutralBackground}const d=i.yScale.getRange(),g=d.max-d.min,f=g<.1?6:g<10?4:g<1e3?2:0;return x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"absolute",left:0,right:i.yAxisWidth,top:l,height:0,borderTop:`1px dashed ${h}`,opacity:.5,pointerEvents:"none",zIndex:2}}),x.jsx("div",{style:{position:"absolute",right:4,top:l,transform:"translateY(-50%)",pointerEvents:"auto",zIndex:3,background:h,color:n.yLabel.textColor,fontSize:n.typography.yFontSize,fontFamily:n.typography.fontFamily,padding:"3px 8px",borderRadius:3,whiteSpace:"nowrap",transition:"background-color 0.3s ease"},children:x.jsx(Ze,{value:o,format:{minimumFractionDigits:f,maximumFractionDigits:f,useGrouping:!1},spinDuration:350})})]})}exports.BarSeries=$e;exports.CandlestickSeries=Zi;exports.ChartContainer=Ge;exports.ChartInstance=be;exports.Crosshair=io;exports.Legend=He;exports.LineSeries=Ne;exports.NumberFlow=Ze;exports.PieLegend=no;exports.PieSeries=eo;exports.PieTooltip=lo;exports.Sparkline=fo;exports.ThemeProvider=Ot;exports.TimeAxis=ti;exports.Tooltip=po;exports.XAxis=ti;exports.YAxis=bo;exports.YLabel=yo;exports.andromeda=we;exports.ayuMirage=Se;exports.buildTheme=Qi;exports.catppuccin=ke;exports.createTheme=I;exports.darkTheme=me;exports.detectInterval=fe;exports.dracula=Me;exports.formatDate=ge;exports.formatTime=kt;exports.githubLight=Re;exports.gruvbox=Te;exports.handwritten=De;exports.highContrast=Be;exports.lavenderMist=ze;exports.lightPink=Le;exports.lightTheme=Yi;exports.materialPalenight=Pe;exports.minimalLight=Fe;exports.mintBreeze=We;exports.monokaiPro=Ie;exports.nightOwl=Ae;exports.normalizeTime=Vt;exports.oneDarkPro=je;exports.panda=Ee;exports.peachCream=Ve;exports.quietLight=Ye;exports.rosePineDawn=_e;exports.sandDune=Ue;exports.solarizedLight=Oe;exports.themes=_t;exports.useChartInstance=H;exports.useCrosshairPosition=Wt;exports.useLastYValue=Ke;exports.usePreviousClose=Qe;exports.useTheme=Xe;exports.useVisibleRange=Je;exports.useYRange=qe;
package/dist/index.d.ts CHANGED
@@ -51,7 +51,6 @@ import { SeriesType } from '@wick-charts/core';
51
51
  import { solarizedLight } from '@wick-charts/core';
52
52
  import { StackingMode } from '@wick-charts/core';
53
53
  import { ThemeConfig } from '@wick-charts/core';
54
- import { ThemePreset } from '@wick-charts/core';
55
54
  import { themes } from '@wick-charts/core';
56
55
  import { TimePoint } from '@wick-charts/core';
57
56
  import { TimePointInput } from '@wick-charts/core';
@@ -337,8 +336,6 @@ export { StackingMode }
337
336
 
338
337
  export { ThemeConfig }
339
338
 
340
- export { ThemePreset }
341
-
342
339
  export declare const ThemeProvider: Provider<ChartTheme | null>;
343
340
 
344
341
  export { themes }