lightweight-charts
Version:
Performant financial charts built with HTML5 canvas
7 lines • 176 kB
JavaScript
/*!
* @license
* TradingView Lightweight Charts™ v5.0.2
* Copyright (c) 2025 TradingView, Inc.
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/
!function(){"use strict";const t={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var i,n;function s(t,i){const n={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(n)}function e(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(n,i+e),t.lineTo(s,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function a(t){if(null===t)throw new Error("Value is null");return t}function l(t){return a(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(n||(n={}));class o{constructor(){this.t=[]}i(t,i,n){const s={h:t,l:i,o:!0===n};this.t.push(s)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,n){const s=[...this.t];this.t=this.t.filter((t=>!t.o)),s.forEach((s=>s.h(t,i,n)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const n of i)for(const i in n)void 0!==n[i]&&Object.prototype.hasOwnProperty.call(n,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof n[i]||void 0===t[i]||Array.isArray(n[i])?t[i]=n[i]:_(t[i],n[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let n,s,e;for(s in n=Array.isArray(i)?[]:{},i)i.hasOwnProperty(s)&&(e=i[s],n[s]=e&&"object"==typeof e?p(e):e);return n}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,n){return void 0===i&&(i=w),`${n=void 0!==n?`${n} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,k:NaN,P:"",T:"",R:"",D:"",I:0,V:0,A:0,B:0,O:0},this.L=t}N(){const t=this.M,i=this.W(),n=this.F();return t.k===i&&t.T===n||(t.k=i,t.T=n,t.P=g(i,n),t.B=2.5/12*i,t.I=t.B,t.V=i/12*t.C,t.A=i/12*t.C,t.O=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.L.N().layout.textColor}U(){return this.L.$()}W(){return this.L.N().layout.fontSize}F(){return this.L.N().layout.fontFamily}}function b(t){return t<0?0:t>255?255:Math.round(t)||0}function x(t){return.199*t[0]+.687*t[1]+.114*t[2]}class S{constructor(t,i){this.j=new Map,this.q=t,i&&(this.j=i)}Y(t,i){if("transparent"===t)return t;const n=this.Z(t),s=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${i*s})`}K(t){const i=this.Z(t);return{X:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,G:x(i)>160?"black":"white"}}J(t){return x(this.Z(t))}tt(t,i,n){const[s,e,r,h]=this.Z(t),[a,l,o,_]=this.Z(i),u=[b(s+n*(a-s)),b(e+n*(l-e)),b(r+n*(o-r)),(c=h+n*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}Z(t){const i=this.j.get(t);if(i)return i;const n=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const n=window.getComputedStyle(i).color;return document.body.removeChild(i),n}(t),s=n.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!s){if(this.q.length)for(const i of this.q){const n=i(t);if(n)return this.j.set(t,n),n}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(s[1],10),parseInt(s[2],10),parseInt(s[3],10),s[4]?parseFloat(s[4]):1];return this.j.set(t,e),e}}class C{constructor(){this.it=[]}nt(t){this.it=t}st(t,i,n){this.it.forEach((s=>{s.st(t,i,n)}))}}class y{st(t,i,n){t.useBitmapCoordinateSpace((t=>this.et(t,i,n)))}}class k extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.rt||null===this.rt.lt)return;const s=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=s.to-1;a>=s.from;--a){const s=e.ot[a],l=Math.round(s._t*i)+r,o=s.ut*n,_=h*n+r;t.moveTo(l,o),t.arc(l,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function P(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const T={from:0,to:1};class R{constructor(t,i,n){this.Mt=new C,this.bt=[],this.xt=[],this.St=!0,this.L=t,this.Ct=i,this.yt=n,this.Mt.nt(this.bt)}kt(t){this.Pt(),this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Mt}Pt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.xt=t.map(P),this.bt=this.xt.map((t=>{const i=new k;return i.ht(t),i})),this.Mt.nt(this.bt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.It(),i=this.yt.Vt(),n=this.Ct.Et(),s=this.L.At();this.Pt(),i.forEach(((i,e)=>{const r=this.xt[e],h=i.Bt(n),a=i.zt();!t&&null!==h&&i.It()&&null!==a?(r.vt=h.Ot,r.ft=h.ft,r.ct=h.Lt,r.ot[0].gt=h.gt,r.ot[0].ut=i.Wt().Nt(h.gt,a.Ft),r.dt=h.Ht??this.L.Ut(r.ot[0].ut/i.Wt().$t()),r.ot[0].wt=n,r.ot[0]._t=s.jt(n),r.lt=T):r.lt=null}))}}class D extends y{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;const h=this.qt.Yt.It,a=this.qt.Zt.It;if(!h&&!a)return;const l=Math.round(this.qt._t*n),o=Math.round(this.qt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*n),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,s(t,this.qt.Yt.Kt),function(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,n),t.lineTo(i+e,s),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.qt.Zt.ct*r),t.strokeStyle=this.qt.Zt.R,t.fillStyle=this.qt.Zt.R,s(t,this.qt.Zt.Kt),e(t,o,0,i.width))}}class I{constructor(t,i){this.St=!0,this.Xt={Yt:{ct:1,Kt:0,R:"",It:!1},Zt:{ct:1,Kt:0,R:"",It:!1},_t:0,ut:0},this.Gt=new D(this.Xt),this.Jt=t,this.yt=i}kt(){this.St=!0}Tt(t){return this.St&&(this.Rt(),this.St=!1),this.Gt}Rt(){const t=this.Jt.It(),i=this.yt.Qt().N().crosshair,n=this.Xt;if(2===i.mode)return n.Zt.It=!1,void(n.Yt.It=!1);n.Zt.It=t&&this.Jt.ti(this.yt),n.Yt.It=t&&this.Jt.ii(),n.Zt.ct=i.horzLine.width,n.Zt.Kt=i.horzLine.style,n.Zt.R=i.horzLine.color,n.Yt.ct=i.vertLine.width,n.Yt.Kt=i.vertLine.style,n.Yt.R=i.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}}function V(t,i,n,s,e,r){t.fillRect(i+r,n,s-2*r,r),t.fillRect(i+r,n+e-r,s-2*r,r),t.fillRect(i,n,r,e),t.fillRect(i+s-r,n,r,e)}function E(t,i,n,s,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,s,e),t.restore()}function A(t,i,n,s,e,r){t.beginPath(),t.roundRect?t.roundRect(i,n,s,e,r):(t.lineTo(i+s-r[1],n),0!==r[1]&&t.arcTo(i+s,n,i+s,n+r[1],r[1]),t.lineTo(i+s,n+e-r[2]),0!==r[2]&&t.arcTo(i+s,n+e,i+s-r[2],n+e,r[2]),t.lineTo(i+r[3],n+e),0!==r[3]&&t.arcTo(i,n+e,i,n+e-r[3],r[3]),t.lineTo(i,n+r[0]),0!==r[0]&&t.arcTo(i,n,i+r[0],n,r[0]))}function B(t,i,n,s,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return A(t,i,n,s,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;A(t,i+o,n+o,s-h,e-h,(_=-o,a.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=h,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function z(t,i,n,s,e,r,h){t.save(),t.globalCompositeOperation="copy";const a=t.createLinearGradient(0,0,0,e);a.addColorStop(0,r),a.addColorStop(1,h),t.fillStyle=a,t.fillRect(i,n,s,e),t.restore()}class O{constructor(t,i){this.ht(t,i)}ht(t,i){this.qt=t,this.ei=i}$t(t,i){return this.qt.It?t.k+t.B+t.I:0}st(t,i,n,s){if(!this.qt.It||0===this.qt.ri.length)return;const e=this.qt.R,r=this.ei.X,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.P;const a=this.hi(t,i,n,s),l=a.ai;return a.li?B(h,l.oi,l._i,l.ui,l.ci,r,l.di,[l.ft,0,0,l.ft],r):B(h,l.fi,l._i,l.ui,l.ci,r,l.di,[0,l.ft,l.ft,0],r),this.qt.pi&&(h.fillStyle=e,h.fillRect(l.fi,l.mi,l.wi-l.fi,l.gi)),this.qt.Mi&&(h.fillStyle=i.D,h.fillRect(a.li?l.bi-l.di:0,l._i,l.di,l.xi-l._i)),a}));t.useMediaCoordinateSpace((({context:t})=>{const n=h.Si;t.font=i.P,t.textAlign=h.li?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.qt.ri,n.Ci,(n._i+n.xi)/2+n.yi)}))}hi(t,i,n,s){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.qt.pi||!this.qt.ki?i.C:0,_=this.qt.Pi?i.S:0,u=i.B+this.ei.Ti,c=i.I+this.ei.Ri,d=i.V,f=i.A,p=this.qt.ri,v=i.k,m=n.Di(e,p),w=Math.ceil(n.Ii(e,p)),g=v+u+c,M=i.S+d+f+w+o,b=Math.max(1,Math.floor(l));let x=Math.round(g*l);x%2!=b%2&&(x+=1);const S=_>0?Math.max(1,Math.floor(_*a)):0,C=Math.round(M*a),y=Math.round(o*a),k=this.ei.Vi??this.ei.Ei,P=Math.round(k*l)-Math.floor(.5*l),T=Math.floor(P+b/2-x/2),R=T+x,D="right"===s,I=D?h.width-_:_,V=D?r.width-S:S;let E,A,B;return D?(E=V-C,A=V-y,B=I-o-d-_):(E=V+C,A=V+y,B=I+o+d),{li:D,ai:{_i:T,mi:P,xi:R,ui:C,ci:x,ft:2*a,di:S,oi:E,fi:V,wi:A,gi:b,bi:r.width},Si:{_i:T/l,xi:R/l,Ci:B,yi:m}}}}class L{constructor(t){this.Ai={Ei:0,X:"#000",Ri:0,Ti:0},this.Bi={ri:"",It:!1,pi:!0,ki:!1,Ht:"",R:"#FFF",Mi:!1,Pi:!1},this.zi={ri:"",It:!1,pi:!1,ki:!0,Ht:"",R:"#FFF",Mi:!0,Pi:!0},this.St=!0,this.Oi=new(t||O)(this.Bi,this.Ai),this.Li=new(t||O)(this.zi,this.Ai)}ri(){return this.Ni(),this.Bi.ri}Ei(){return this.Ni(),this.Ai.Ei}kt(){this.St=!0}$t(t,i=!1){return Math.max(this.Oi.$t(t,i),this.Li.$t(t,i))}Wi(){return this.Ai.Vi||0}Fi(t){this.Ai.Vi=t}Hi(){return this.Ni(),this.Bi.It||this.zi.It}Ui(){return this.Ni(),this.Bi.It}Tt(t){return this.Ni(),this.Bi.pi=this.Bi.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Bi,this.Ai),this.Li.ht(this.zi,this.Ai),this.Oi}$i(){return this.Ni(),this.Oi.ht(this.Bi,this.Ai),this.Li.ht(this.zi,this.Ai),this.Li}Ni(){this.St&&(this.Bi.pi=!0,this.zi.pi=!1,this.ji(this.Bi,this.zi,this.Ai))}}class N extends L{constructor(t,i,n){super(),this.Jt=t,this.qi=i,this.Yi=n}ji(t,i,n){if(t.It=!1,2===this.Jt.N().mode)return;const s=this.Jt.N().horzLine;if(!s.labelVisible)return;const e=this.qi.zt();if(!this.Jt.It()||this.qi.Zi()||null===e)return;const r=this.qi.Ki().K(s.labelBackgroundColor);n.X=r.X,t.R=r.G;const h=2/12*this.qi.k();n.Ti=h,n.Ri=h;const a=this.Yi(this.qi);n.Ei=a.Ei,t.ri=this.qi.Xi(a.gt,e),t.It=!0}}const W=/[1-9]/g;class F{constructor(){this.qt=null}ht(t){this.qt=t}st(t,i){if(null===this.qt||!1===this.qt.It||0===this.qt.ri.length)return;const n=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.P,Math.round(i.Gi.Ii(t,a(this.qt).ri,W)))));if(n<=0)return;const s=i.Ji,e=n+2*s,r=e/2,h=this.qt.Qi;let l=this.qt.Ei,o=Math.floor(l-r)+.5;o<0?(l+=Math.abs(0-o),o=Math.floor(l-r)+.5):o+e>h&&(l-=Math.abs(h-(o+e)),o=Math.floor(l-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.C+i.B+i.k+i.I);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:n,verticalPixelRatio:s})=>{const e=a(this.qt);t.fillStyle=e.X;const r=Math.round(o*n),h=Math.round(0*s),l=Math.round(_*n),c=Math.round(u*s),d=Math.round(2*n);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(l-d,c),t.arcTo(l,c,l,c-d,d),t.lineTo(l,h),t.fill(),e.pi){const r=Math.round(e.Ei*n),a=h,l=Math.round((a+i.C)*s);t.fillStyle=e.R;const o=Math.max(1,Math.floor(n)),_=Math.floor(.5*n);t.fillRect(r-_,a,o,l-a)}})),t.useMediaCoordinateSpace((({context:t})=>{const n=a(this.qt),e=0+i.S+i.C+i.B+i.k/2;t.font=i.P,t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.R;const r=i.Gi.Di(t,"Apr0");t.translate(o+s,e+r),t.fillText(n.ri,0,0)}))}}class H{constructor(t,i,n){this.St=!0,this.Gt=new F,this.Xt={It:!1,X:"#4c525e",R:"white",ri:"",Qi:0,Ei:NaN,pi:!0},this.Ct=t,this.tn=i,this.Yi=n}kt(){this.St=!0}Tt(){return this.St&&(this.Rt(),this.St=!1),this.Gt.ht(this.Xt),this.Gt}Rt(){const t=this.Xt;if(t.It=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const n=this.tn.At();if(n.Zi())return;t.Qi=n.Qi();const s=this.Yi();if(null===s)return;t.Ei=s.Ei;const e=n.nn(this.Ct.Et());t.ri=n.sn(a(e)),t.It=!0;const r=this.tn.Ki().K(i.labelBackgroundColor);t.X=r.X,t.R=r.G,t.pi=n.N().ticksVisible}}class U{constructor(){this.en=null,this.rn=0}hn(){return this.rn}an(t){this.rn=t}Wt(){return this.en}ln(t){this.en=t}_n(t){return[]}un(){return[]}It(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden"}($||($={}));class j extends U{constructor(t,i){super(),this.yt=null,this.cn=NaN,this.dn=0,this.fn=!0,this.pn=new Map,this.vn=!1,this.mn=new WeakMap,this.wn=new WeakMap,this.gn=NaN,this.Mn=NaN,this.bn=NaN,this.xn=NaN,this.tn=t,this.Sn=i;this.Cn=((t,i)=>n=>{const s=i(),e=t();if(n===a(this.yt).yn())return{gt:e,Ei:s};{const t=a(n.zt());return{gt:n.kn(s,t),Ei:s}}})((()=>this.cn),(()=>this.Mn));const n=((t,i)=>()=>{const n=this.tn.At().Pn(t()),s=i();return n&&Number.isFinite(s)?{wt:n,Ei:s}:null})((()=>this.dn),(()=>this.ni()));this.Tn=new H(this,t,n)}N(){return this.Sn}Rn(t,i){this.bn=t,this.xn=i}Dn(){this.bn=NaN,this.xn=NaN}In(){return this.bn}Vn(){return this.xn}En(t,i,n){this.vn||(this.vn=!0),this.fn=!0,this.An(t,i,n)}Et(){return this.dn}ni(){return this.gn}si(){return this.Mn}It(){return this.fn}Bn(){this.fn=!1,this.zn(),this.cn=NaN,this.gn=NaN,this.Mn=NaN,this.yt=null,this.Dn(),this.On()}Ln(t){let i=this.mn.get(t);i||(i=new I(this,t),this.mn.set(t,i));let n=this.wn.get(t);return n||(n=new R(this.tn,this,t),this.wn.set(t,n)),[i,n]}ti(t){return t===this.yt&&this.Sn.horzLine.visible}ii(){return this.Sn.vertLine.visible}Nn(t,i){this.fn&&this.yt===t||this.pn.clear();const n=[];return this.yt===t&&n.push(this.Wn(this.pn,i,this.Cn)),n}un(){return this.fn?[this.Tn]:[]}Fn(){return this.yt}On(){this.tn.Hn().forEach((t=>{this.mn.get(t)?.kt(),this.wn.get(t)?.kt()})),this.pn.forEach((t=>t.kt())),this.Tn.kt()}Un(t){return t&&!t.yn().Zi()?t.yn():null}An(t,i,n){this.$n(t,i,n)&&this.On()}$n(t,i,n){const s=this.gn,e=this.Mn,r=this.cn,h=this.dn,a=this.yt,l=this.Un(n);this.dn=t,this.gn=isNaN(t)?NaN:this.tn.At().jt(t),this.yt=n;const o=null!==l?l.zt():null;return null!==l&&null!==o?(this.cn=i,this.Mn=l.Nt(i,o)):(this.cn=NaN,this.Mn=NaN),s!==this.gn||e!==this.Mn||h!==this.dn||r!==this.cn||a!==this.yt}zn(){const t=this.tn.jn().map((t=>t.Yn().qn())).filter(v),i=0===t.length?null:Math.max(...t);this.dn=null!==i?i:NaN}Wn(t,i,n){let s=t.get(i);return void 0===s&&(s=new N(this,i,n),t.set(i,s)),s}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.Zn=new Map,this.Kn=[],this.Xn=t}Gn(t,i){const n=function(t,i){return void 0===t?i:{Jn:Math.max(t.Jn,i.Jn),Qn:t.Qn||i.Qn}}(this.Zn.get(t),i);this.Zn.set(t,n)}ts(){return this.Xn}ns(t){const i=this.Zn.get(t);return void 0===i?{Jn:this.Xn}:{Jn:Math.max(this.Xn,i.Jn),Qn:i.Qn}}ss(){this.es(),this.Kn=[{rs:0}]}hs(t){this.es(),this.Kn=[{rs:1,Ft:t}]}ls(t){this._s(),this.Kn.push({rs:5,Ft:t})}es(){this._s(),this.Kn.push({rs:6})}us(){this.es(),this.Kn=[{rs:4}]}cs(t){this.es(),this.Kn.push({rs:2,Ft:t})}ds(t){this.es(),this.Kn.push({rs:3,Ft:t})}fs(){return this.Kn}ps(t){for(const i of t.Kn)this.vs(i);this.Xn=Math.max(this.Xn,t.Xn),t.Zn.forEach(((t,i)=>{this.Gn(i,t)}))}static ws(){return new Y(2)}static gs(){return new Y(3)}vs(t){switch(t.rs){case 0:this.ss();break;case 1:this.hs(t.Ft);break;case 2:this.cs(t.Ft);break;case 3:this.ds(t.Ft);break;case 4:this.us();break;case 5:this.ls(t.Ft);break;case 6:this._s()}}_s(){const t=this.Kn.findIndex((t=>5===t.rs));-1!==t&&this.Kn.splice(t,1)}}const Z=".";function K(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class X{constructor(t,i){if(i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.qi=t,this.Ms=i,this.bs()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.xs(t)}bs(){if(this.Ss=0,this.qi>0&&this.Ms>0){let t=this.qi;for(;t>1;)t/=10,this.Ss++}}xs(t){const i=this.qi/this.Ms;let n=Math.floor(t),s="";const e=void 0!==this.Ss?this.Ss:NaN;if(i>1){let r=+(Math.round(t*i)-n*i).toFixed(this.Ss);r>=i&&(r-=i,n+=1),s=Z+K(+r.toFixed(this.Ss)*this.Ms,e)}else n=Math.round(n*i)/i,e>0&&(s=Z+K(0,e));return n.toFixed(0)+s}}class G extends X{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class J{constructor(t){this.Cs=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.ys(t):t<999995?i+this.ys(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.ys(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.ys(t/1e9)+"B")}ys(t){let i;const n=Math.pow(10,this.Cs);return i=(t=Math.round(t*n)/n)>=1e-15&&t<1?t.toFixed(this.Cs).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const Q=/[2-9]/g;class tt{constructor(t=50){this.ks=0,this.Ps=1,this.Ts=1,this.Rs={},this.Ds=new Map,this.Is=t}Vs(){this.ks=0,this.Ds.clear(),this.Ps=1,this.Ts=1,this.Rs={}}Ii(t,i,n){return this.Es(t,i,n).width}Di(t,i,n){const s=this.Es(t,i,n);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}Es(t,i,n){const s=n||Q,e=String(i).replace(s,"0");if(this.Ds.has(e))return h(this.Ds.get(e)).As;if(this.ks===this.Is){const t=this.Rs[this.Ts];delete this.Rs[this.Ts],this.Ds.delete(t),this.Ts++,this.ks--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.Ds.set(e,{As:r,Bs:this.Ps}),this.Rs[this.Ps]=e,this.ks++,this.Ps++),r}}class it{constructor(t){this.zs=null,this.M=null,this.Os="right",this.Ls=t}Ns(t,i,n){this.zs=t,this.M=i,this.Os=n}st(t){null!==this.M&&null!==this.zs&&this.zs.st(t,this.M,this.Ls,this.Os)}}class nt{constructor(t,i,n){this.Ws=t,this.Ls=new tt(50),this.Fs=i,this.L=n,this.W=-1,this.Gt=new it(this.Ls)}Tt(){const t=this.L.Hs(this.Fs);if(null===t)return null;const i=t.Us(this.Fs)?t.$s():this.Fs.Wt();if(null===i)return null;const n=t.js(i);if("overlay"===n)return null;const s=this.L.qs();return s.k!==this.W&&(this.W=s.k,this.Ls.Vs()),this.Gt.Ns(this.Ws.$i(),s,n),this.Gt}}class st extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Ys(t,i){if(!this.qt?.It)return null;const{ut:n,ct:s,Zs:e}=this.qt;return i>=n-s-7&&i<=n+s+7?{Ks:this.qt,Zs:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;if(!1===this.qt.It)return;const h=Math.round(this.qt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*n),s(t,this.qt.Kt),e(t,h,0,i.width))}}class et{constructor(t){this.Xs={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Kt:0,It:!1},this.Gs=new st,this.St=!0,this.Js=t,this.Qs=t.Qt(),this.Gs.ht(this.Xs)}kt(){this.St=!0}Tt(){return this.Js.It()?(this.St&&(this.te(),this.St=!1),this.Gs):null}}class rt extends et{constructor(t){super(t)}te(){this.Xs.It=!1;const t=this.Js.Wt(),i=t.ie().ie;if(2!==i&&3!==i)return;const n=this.Js.N();if(!n.baseLineVisible||!this.Js.It())return;const s=this.Js.zt();null!==s&&(this.Xs.It=!0,this.Xs.ut=t.Nt(s.Ft,s.Ft),this.Xs.R=n.baseLineColor,this.Xs.ct=n.baseLineWidth,this.Xs.Kt=n.baseLineStyle)}}class ht extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ne(){return this.qt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){const s=this.qt;if(null===s)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(s.se.x*i)+r,a=s.se.y*n;t.fillStyle=s.ee,t.beginPath();const l=Math.max(2,1.5*s.re)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.he,t.beginPath(),t.arc(h,a,s.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=s.ae,t.beginPath(),t.arc(h,a,s.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const at=[{le:0,oe:.25,_e:4,ue:10,ce:.25,de:0,fe:.4,pe:.8},{le:.25,oe:.525,_e:10,ue:14,ce:0,de:0,fe:.8,pe:0},{le:.525,oe:1,_e:14,ue:14,ce:0,de:0,fe:0,pe:0}];class lt{constructor(t){this.Gt=new ht,this.St=!0,this.ve=!0,this.me=performance.now(),this.we=this.me-1,this.ge=t}Me(){this.we=this.me-1,this.kt()}be(){if(this.kt(),2===this.ge.N().lastPriceAnimation){const t=performance.now(),i=this.we-t;if(i>0)return void(i<650&&(this.we+=2600));this.me=t,this.we=t+2600}}kt(){this.St=!0}xe(){this.ve=!0}It(){return 0!==this.ge.N().lastPriceAnimation}Se(){switch(this.ge.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.we}}Tt(){return this.St?(this.Rt(),this.St=!1,this.ve=!1):this.ve&&(this.Ce(),this.ve=!1),this.Gt}Rt(){this.Gt.ht(null);const t=this.ge.Qt().At(),i=t.ye(),n=this.ge.zt();if(null===i||null===n)return;const s=this.ge.ke(!0);if(s.Pe||!i.Te(s.Re))return;const e={x:t.jt(s.Re),y:this.ge.Wt().Nt(s.gt,n.Ft)},r=s.R,h=this.ge.N().lineWidth,a=this.De(this.Ie(),r);this.Gt.ht({ee:r,re:h,he:a.he,ae:a.ae,ft:a.ft,se:e})}Ce(){const t=this.Gt.ne();if(null!==t){const i=this.De(this.Ie(),t.ee);t.he=i.he,t.ae=i.ae,t.ft=i.ft}}Ie(){return this.Se()?performance.now()-this.me:2599}Ve(t,i,n,s){const e=n+(s-n)*i;return this.ge.Qt().Ki().Y(t,e)}De(t,i){const n=t%2600/2600;let s;for(const t of at)if(n>=t.le&&n<=t.oe){s=t;break}r(void 0!==s,"Last price animation internal logic error");const e=(n-s.le)/(s.oe-s.le);return{he:this.Ve(i,e,s.ce,s.de),ae:this.Ve(i,e,s.fe,s.pe),ft:(h=e,a=s._e,l=s.ue,a+(l-a)*h)};var h,a,l}}class ot extends et{constructor(t){super(t)}te(){const t=this.Xs;t.It=!1;const i=this.Js.N();if(!i.priceLineVisible||!this.Js.It())return;const n=this.Js.ke(0===i.priceLineSource);n.Pe||(t.It=!0,t.ut=n.Ei,t.R=this.Js.Ee(n.R),t.ct=i.priceLineWidth,t.Kt=i.priceLineStyle)}}class _t extends L{constructor(t){super(),this.Jt=t}ji(t,i,n){t.It=!1,i.It=!1;const s=this.Jt;if(!s.It())return;const e=s.N(),r=e.lastValueVisible,h=""!==s.Ae(),a=0===e.seriesLastValueMode,l=s.ke(!1);if(l.Pe)return;r&&(t.ri=this.Be(l,r,a),t.It=0!==t.ri.length),(h||a)&&(i.ri=this.ze(l,r,h,a),i.It=i.ri.length>0);const o=s.Ee(l.R),_=this.Jt.Qt().Ki().K(o);n.X=_.X,n.Ei=l.Ei,i.Ht=s.Qt().Ut(l.Ei/s.Wt().$t()),t.Ht=o,t.R=_.G,i.R=_.G}ze(t,i,n,s){let e="";const r=this.Jt.Ae();return n&&0!==r.length&&(e+=`${r} `),i&&s&&(e+=this.Jt.Wt().Oe()?t.Le:t.Ne),e.trim()}Be(t,i,n){return i?n?this.Jt.Wt().Oe()?t.Ne:t.Le:t.ri:""}}function ut(t,i,n,s){const e=Number.isFinite(i),r=Number.isFinite(n);return e&&r?t(i,n):e||r?e?i:n:s}class ct{constructor(t,i){this.We=t,this.Fe=i}He(t){return null!==t&&(this.We===t.We&&this.Fe===t.Fe)}Ue(){return new ct(this.We,this.Fe)}$e(){return this.We}je(){return this.Fe}qe(){return this.Fe-this.We}Zi(){return this.Fe===this.We||Number.isNaN(this.Fe)||Number.isNaN(this.We)}ps(t){return null===t?this:new ct(ut(Math.min,this.$e(),t.$e(),-1/0),ut(Math.max,this.je(),t.je(),1/0))}Ye(t){if(!u(t))return;if(0===this.Fe-this.We)return;const i=.5*(this.Fe+this.We);let n=this.Fe-i,s=this.We-i;n*=t,s*=t,this.Fe=i+n,this.We=i+s}Ze(t){u(t)&&(this.Fe+=t,this.We+=t)}Ke(){return{minValue:this.We,maxValue:this.Fe}}static Xe(t){return null===t?null:new ct(t.minValue,t.maxValue)}}class dt{constructor(t,i){this.Ge=t,this.Je=i||null}Qe(){return this.Ge}tr(){return this.Je}Ke(){return{priceRange:null===this.Ge?null:this.Ge.Ke(),margins:this.Je||void 0}}static Xe(t){return null===t?null:new dt(ct.Xe(t.priceRange),t.margins)}}class ft extends et{constructor(t,i){super(t),this.ir=i}te(){const t=this.Xs;t.It=!1;const i=this.ir.N();if(!this.Js.It()||!i.lineVisible)return;const n=this.ir.nr();null!==n&&(t.It=!0,t.ut=n,t.R=i.color,t.ct=i.lineWidth,t.Kt=i.lineStyle,t.Zs=this.ir.N().id)}}class pt extends L{constructor(t,i){super(),this.ge=t,this.ir=i}ji(t,i,n){t.It=!1,i.It=!1;const s=this.ir.N(),e=s.axisLabelVisible,r=""!==s.title,h=this.ge;if(!e||!h.It())return;const a=this.ir.nr();if(null===a)return;r&&(i.ri=s.title,i.It=!0),i.Ht=h.Qt().Ut(a/h.Wt().$t()),t.ri=this.sr(s.price),t.It=!0;const l=this.ge.Qt().Ki().K(s.axisLabelColor||s.color);n.X=l.X;const o=s.axisLabelTextColor||l.G;t.R=o,i.R=o,n.Ei=a}sr(t){const i=this.ge.zt();return null===i?"":this.ge.Wt().Xi(t,i.Ft)}}class vt{constructor(t,i){this.ge=t,this.Sn=i,this.er=new ft(t,this),this.Ws=new pt(t,this),this.rr=new nt(this.Ws,t,t.Qt())}hr(t){_(this.Sn,t),this.kt(),this.ge.Qt().ar()}N(){return this.Sn}lr(){return this.er}_r(){return this.rr}ur(){return this.Ws}kt(){this.er.kt(),this.Ws.kt()}nr(){const t=this.ge,i=t.Wt();if(t.Qt().At().Zi()||i.Zi())return null;const n=t.zt();return null===n?null:i.Nt(this.Sn.price,n.Ft)}}class mt extends U{constructor(t){super(),this.tn=t}Qt(){return this.tn}}const wt={Bar:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=a(t(n,s)),o=l(h.Ft[0])<=l(h.Ft[3]);return{cr:h.R??(o?e:r)}},Candlestick:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=a(t(n,s)),d=l(c.Ft[0])<=l(c.Ft[3]);return{cr:c.R??(d?e:r),dr:c.Ht??(d?h:o),pr:c.vr??(d?_:u)}},Custom:(t,i,n,s)=>({cr:a(t(n,s)).R??i.color}),Area:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.vt??i.lineColor,vt:e.vt??i.lineColor,mr:e.mr??i.topColor,wr:e.wr??i.bottomColor}},Baseline:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.Ft[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,gr:e.gr??i.topLineColor,Mr:e.Mr??i.bottomLineColor,br:e.br??i.topFillColor1,Sr:e.Sr??i.topFillColor2,Cr:e.Cr??i.bottomFillColor1,yr:e.yr??i.bottomFillColor2}},Line:(t,i,n,s)=>{const e=a(t(n,s));return{cr:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,n,s)=>({cr:a(t(n,s)).R??i.color})};class gt{constructor(t){this.kr=(t,i)=>void 0!==i?i.Ft:this.ge.Yn().Pr(t),this.ge=t,this.Tr=wt[t.Rr()]}Dr(t,i){return this.Tr(this.kr,this.ge.N(),t,i)}}function Mt(t,i,n,s,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;s(i[a],n)===t?(e=a+1,h-=r+1):h=r}return e}const bt=Mt.bind(null,!0),xt=Mt.bind(null,!1);var St;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(St||(St={}));const Ct=30;class yt{constructor(){this.Ir=[],this.Vr=new Map,this.Er=new Map,this.Ar=[]}Br(){return this.zr()>0?this.Ir[this.Ir.length-1]:null}Or(){return this.zr()>0?this.Lr(0):null}qn(){return this.zr()>0?this.Lr(this.Ir.length-1):null}zr(){return this.Ir.length}Zi(){return 0===this.zr()}Te(t){return null!==this.Nr(t,0)}Pr(t){return this.Wr(t)}Wr(t,i=0){const n=this.Nr(t,i);return null===n?null:{...this.Fr(n),Re:this.Lr(n)}}Hr(){return this.Ir}Ur(t,i,n){if(this.Zi())return null;let s=null;for(const e of n){s=kt(s,this.$r(t,i,e))}return s}ht(t){this.Er.clear(),this.Vr.clear(),this.Ir=t,this.Ar=t.map((t=>t.Re))}jr(){return this.Ar}Lr(t){return this.Ir[t].Re}Fr(t){return this.Ir[t]}Nr(t,i){const n=this.qr(t);if(null===n&&0!==i)switch(i){case-1:return this.Yr(t);case 1:return this.Zr(t);default:throw new TypeError("Unknown search mode")}return n}Yr(t){let i=this.Kr(t);return i>0&&(i-=1),i!==this.Ir.length&&this.Lr(i)<t?i:null}Zr(t){const i=this.Xr(t);return i!==this.Ir.length&&t<this.Lr(i)?i:null}qr(t){const i=this.Kr(t);return i===this.Ir.length||t<this.Ir[i].Re?null:i}Kr(t){return bt(this.Ir,t,((t,i)=>t.Re<i))}Xr(t){return xt(this.Ir,t,((t,i)=>t.Re>i))}Gr(t,i,n){let s=null;for(let e=t;e<i;e++){const t=this.Ir[e].Ft[n];Number.isNaN(t)||(null===s?s={Jr:t,Qr:t}:(t<s.Jr&&(s.Jr=t),t>s.Qr&&(s.Qr=t)))}return s}$r(t,i,n){if(this.Zi())return null;let s=null;const e=a(this.Or()),r=a(this.qn()),h=Math.max(t,e),l=Math.min(i,r),o=Math.ceil(h/Ct)*Ct,_=Math.max(o,Math.floor(l/Ct)*Ct);{const t=this.Kr(h),e=this.Xr(Math.min(l,o,i));s=kt(s,this.Gr(t,e,n))}let u=this.Vr.get(n);void 0===u&&(u=new Map,this.Vr.set(n,u));for(let t=Math.max(o+1,h);t<_;t+=Ct){const i=Math.floor(t/Ct);let e=u.get(i);if(void 0===e){const t=this.Kr(i*Ct),s=this.Xr((i+1)*Ct-1);e=this.Gr(t,s,n),u.set(i,e)}s=kt(s,e)}{const t=this.Kr(_),i=this.Xr(l);s=kt(s,this.Gr(t,i,n))}return s}}function kt(t,i){if(null===t)return i;if(null===i)return t;return{Jr:Math.min(t.Jr,i.Jr),Qr:Math.max(t.Qr,i.Qr)}}class Pt{constructor(t){this.th=t}st(t,i,n){this.th.draw(t)}ih(t,i,n){this.th.drawBackground?.(t)}}class Tt{constructor(t){this.Ds=null,this.nh=t}Tt(){const t=this.nh.renderer();if(null===t)return null;if(this.Ds?.sh===t)return this.Ds.eh;const i=new Pt(t);return this.Ds={sh:t,eh:i},i}rh(){return this.nh.zOrder?.()??"normal"}}class Rt{constructor(t){this.hh=null,this.ah=t}oh(){return this.ah}On(){this.ah.updateAllViews?.()}Ln(){const t=this.ah.paneViews?.()??[];if(this.hh?.sh===t)return this.hh.eh;const i=t.map((t=>new Tt(t)));return this.hh={sh:t,eh:i},i}Ys(t,i){return this.ah.hitTest?.(t,i)??null}}let Dt=class extends Rt{_n(){return[]}};class It{constructor(t){this.th=t}st(t,i,n){this.th.draw(t)}ih(t,i,n){this.th.drawBackground?.(t)}}class Vt{constructor(t){this.Ds=null,this.nh=t}Tt(){const t=this.nh.renderer();if(null===t)return null;if(this.Ds?.sh===t)return this.Ds.eh;const i=new It(t);return this.Ds={sh:t,eh:i},i}rh(){return this.nh.zOrder?.()??"normal"}}function Et(t){return{ri:t.text(),Ei:t.coordinate(),Vi:t.fixedCoordinate?.(),R:t.textColor(),X:t.backColor(),It:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class At{constructor(t,i){this.Gt=new F,this._h=t,this.uh=i}Tt(){return this.Gt.ht({Qi:this.uh.Qi(),...Et(this._h)}),this.Gt}}class Bt extends L{constructor(t,i){super(),this._h=t,this.qi=i}ji(t,i,n){const s=Et(this._h);n.X=s.X,t.R=s.R;const e=2/12*this.qi.k();n.Ti=e,n.Ri=e,n.Ei=s.Ei,n.Vi=s.Vi,t.ri=s.ri,t.It=s.It,t.pi=s.pi}}class zt extends Rt{constructor(t,i){super(t),this.dh=null,this.fh=null,this.ph=null,this.mh=null,this.ge=i}un(){const t=this.ah.timeAxisViews?.()??[];if(this.dh?.sh===t)return this.dh.eh;const i=this.ge.Qt().At(),n=t.map((t=>new At(t,i)));return this.dh={sh:t,eh:n},n}Nn(){const t=this.ah.priceAxisViews?.()??[];if(this.fh?.sh===t)return this.fh.eh;const i=this.ge.Wt(),n=t.map((t=>new Bt(t,i)));return this.fh={sh:t,eh:n},n}wh(){const t=this.ah.priceAxisPaneViews?.()??[];if(this.ph?.sh===t)return this.ph.eh;const i=t.map((t=>new Vt(t)));return this.ph={sh:t,eh:i},i}gh(){const t=this.ah.timeAxisPaneViews?.()??[];if(this.mh?.sh===t)return this.mh.eh;const i=t.map((t=>new Vt(t)));return this.mh={sh:t,eh:i},i}Mh(t,i){return this.ah.autoscaleInfo?.(t,i)??null}}function Ot(t,i,n,s){t.forEach((t=>{i(t).forEach((t=>{t.rh()===n&&s.push(t)}))}))}function Lt(t){return t.Ln()}function Nt(t){return t.wh()}function Wt(t){return t.gh()}const Ft=["Area","Line","Baseline"];class Ht extends mt{constructor(t,i,n,s,e){super(t),this.qt=new yt,this.er=new ot(this),this.bh=[],this.xh=new rt(this),this.Sh=null,this.Ch=null,this.yh=null,this.kh=[],this.Sn=n,this.Ph=i;const r=new _t(this);this.pn=[r],this.rr=new nt(r,this,t),Ft.includes(this.Ph)&&(this.Sh=new lt(this)),this.Th(),this.nh=s(this,this.Qt(),e)}m(){null!==this.yh&&clearTimeout(this.yh)}Ee(t){return this.Sn.priceLineColor||t}ke(t){const i={Pe:!0},n=this.Wt();if(this.Qt().At().Zi()||n.Zi()||this.qt.Zi())return i;const s=this.Qt().At().ye(),e=this.zt();if(null===s||null===e)return i;let r,h;if(t){const t=this.qt.Br();if(null===t)return i;r=t,h=t.Re}else{const t=this.qt.Wr(s.bi(),-1);if(null===t)return i;if(r=this.qt.Pr(t.Re),null===r)return i;h=t.Re}const a=r.Ft[3],l=this.Rh().Dr(h,{Ft:r}),o=n.Nt(a,e.Ft);return{Pe:!1,gt:a,ri:n.Xi(a,e.Ft),Le:n.Dh(a),Ne:n.Ih(a,e.Ft),R:l.cr,Ei:o,Re:h}}Rh(){return null!==this.Ch||(this.Ch=new gt(this)),this.Ch}N(){return this.Sn}hr(t){const i=t.priceScaleId;void 0!==i&&i!==this.Sn.priceScaleId&&this.Qt().Vh(this,i),_(this.Sn,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().Eh()),this.Qt().Ah(this),this.Qt().Bh(),this.nh.kt("options")}ht(t,i){this.qt.ht(t),this.nh.kt("data"),null!==this.Sh&&(i&&i.zh?this.Sh.be():0===t.length&&this.Sh.Me());const n=this.Qt().Hs(this);this.Qt().Oh(n),this.Qt().Ah(this),this.Qt().Bh(),this.Qt().ar()}Lh(t){const i=new vt(this,t);return this.bh.push(i),this.Qt().Ah(this),i}Nh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().Ah(this)}Wh(){return this.bh}Rr(){return this.Ph}zt(){const t=this.Fh();return null===t?null:{Ft:t.Ft[3],Hh:t.wt}}Fh(){const t=this.Qt().At().ye();if(null===t)return null;const i=t.Uh();return this.qt.Wr(i,1)}Yn(){return this.qt}$h(t){const i=this.qt.Pr(t);return null===i?null:"Bar"===this.Ph||"Candlestick"===this.Ph||"Custom"===this.Ph?{jh:i.Ft[0],qh:i.Ft[1],Yh:i.Ft[2],Zh:i.Ft[3]}:i.Ft[3]}Kh(t){const i=[];Ot(this.kh,Lt,"top",i);const n=this.Sh;return null!==n&&n.It()?(null===this.yh&&n.Se()&&(this.yh=setTimeout((()=>{this.yh=null,this.Qt().Xh()}),0)),n.xe(),i.unshift(n),i):i}Ln(){const t=[];this.Gh()||t.push(this.xh),t.push(this.nh,this.er);const i=this.bh.map((t=>t.lr()));return t.push(...i),Ot(this.kh,Lt,"normal",t),t}Jh(){return this.Qh(Lt,"bottom")}ta(t){return this.Qh(Nt,t)}ia(t){return this.Qh(Wt,t)}na(t,i){return this.kh.map((n=>n.Ys(t,i))).filter((t=>null!==t))}_n(){return[this.rr,...this.bh.map((t=>t._r()))]}Nn(t,i){if(i!==this.en&&!this.Gh())return[];const n=[...this.pn];for(const t of this.bh)n.push(t.ur());return this.kh.forEach((t=>{n.push(...t.Nn())})),n}un(){const t=[];return this.kh.forEach((i=>{t.push(...i.un())})),t}Mh(t,i){if(void 0!==this.Sn.autoscaleInfoProvider){const n=this.Sn.autoscaleInfoProvider((()=>{const n=this.sa(t,i);return null===n?null:n.Ke()}));return dt.Xe(n)}return this.sa(t,i)}ea(){return this.Sn.priceFormat.minMove}ra(){return this.ha}On(){this.nh.kt();for(const t of this.pn)t.kt();for(const t of this.bh)t.kt();this.er.kt(),this.xh.kt(),this.Sh?.kt(),this.kh.forEach((t=>t.On()))}Wt(){return a(super.Wt())}Bt(t){if(!(("Line"===this.Ph||"Area"===this.Ph||"Baseline"===this.Ph)&&this.Sn.crosshairMarkerVisible))return null;const i=this.qt.Pr(t);if(null===i)return null;return{gt:i.Ft[3],ft:this.aa(),Ht:this.la(),Lt:this.oa(),Ot:this._a(t)}}Ae(){return this.Sn.title}It(){return this.Sn.visible}ua(t){this.kh.push(new zt(t,this))}ca(t){this.kh=this.kh.filter((i=>i.oh()!==t))}da(){if("Custom"===this.Ph)return t=>this.nh.fa(t)}pa(){if("Custom"===this.Ph)return t=>this.nh.va(t)}ma(){return this.qt.jr()}Gh(){return!q(this.Wt().wa())}sa(t,i){if(!c(t)||!c(i)||this.qt.Zi())return null;const n="Line"===this.Ph||"Area"===this.Ph||"Baseline"===this.Ph||"Histogram"===this.Ph?[3]:[2,1],s=this.qt.Ur(t,i,n);let e=null!==s?new ct(s.Jr,s.Qr):null,r=null;if("Histogram"===this.Rr()){const t=this.Sn.base,i=new ct(t,t);e=null!==e?e.ps(i):i}return this.kh.forEach((n=>{const s=n.Mh(t,i);if(s?.priceRange){const t=new ct(s.priceRange.minValue,s.priceRange.maxValue);e=null!==e?e.ps(t):t}s?.margins&&(r=s.margins)})),new dt(e,r)}aa(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.Sn.crosshairMarkerRadius}return 0}la(){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.Sn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}oa(){switch(this.Ph){case"Line":case"Area":case"Baseline":return this.Sn.crosshairMarkerBorderWidth}return 0}_a(t){switch(this.Ph){case"Line":case"Area":case"Baseline":{const t=this.Sn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Rh().Dr(t).cr}Th(){switch(this.Sn.priceFormat.type){case"custom":this.ha={format:this.Sn.priceFormat.formatter};break;case"volume":this.ha=new J(this.Sn.priceFormat.precision);break;case"percent":this.ha=new G(this.Sn.priceFormat.precision);break;default:{const t=Math.pow(10,this.Sn.priceFormat.precision);this.ha=new X(t,this.Sn.priceFormat.minMove*t)}}null!==this.en&&this.en.ga()}Qh(t,i){const n=[];return Ot(this.kh,t,i,n),n}}class Ut{constructor(t){this.Sn=t}Ma(t,i,n){let s=t;if(0===this.Sn.mode)return s;const e=n.yn(),r=e.zt();if(null===r)return s;const h=e.Nt(t,r),a=n.ba().filter((t=>t instanceof Ht)).reduce(((t,s)=>{if(n.Us(s)||!s.It())return t;const e=s.Wt(),r=s.Yn();if(e.Zi()||!r.Te(i))return t;const h=r.Pr(i);if(null===h)return t;const a=l(s.zt());return t.concat([e.Nt(h.Ft[3],a.Ft)])}),[]);if(0===a.length)return s;a.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=a[0];return s=e.kn(o,r),s}}class $t extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:e}){if(null===this.qt)return;const r=Math.max(1,Math.floor(n));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=a(this.qt);if(h.xa){t.strokeStyle=h.Sa,s(t,h.Ca),t.beginPath();for(const s of h.ya){const e=Math.round(s.ka*n);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Pa){t.strokeStyle=h.Ta,s(t,h.Ra),t.beginPath();for(const n of h.Da){const s=Math.round(n.ka*e);t.moveTo(-r,s),t.lineTo(i.width+r,s)}t.stroke()}}))}}class jt{constructor(t){this.Gt=new $t,this.St=!0,this.yt=t}kt(){this.St=!0}Tt(){if(this.St){const t=this.yt.Qt().N().grid,i={Pa:t.horzLines.visible,xa:t.vertLines.visible,Ta:t.horzLines.color,Sa:t.vertLines.color,Ra:t.horzLines.style,Ca:t.vertLines.style,Da:this.yt.yn().Ia(),ya:(this.yt.Qt().At().Ia()||[]).map((t=>({ka:t.coord})))};this.Gt.ht(i),this.St=!1}return this.Gt}}class qt{constructor(t){this.nh=new jt(t)}lr(){return this.nh}}const Yt={Va:4,Ea:1e-4};function Zt(t,i){const n=100*(t-i)/i;return i<0?-n:n}function Kt(t,i){const n=Zt(t.$e(),i),s=Zt(t.je(),i);return new ct(n,s)}function Xt(t,i){const n=100*(t-i)/i+100;return i<0?-n:n}function Gt(t,i){const n=Xt(t.$e(),i),s=Xt(t.je(),i);return new ct(n,s)}function Jt(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.log10(n+i.Ea)+i.Va;return t<0?-s:s}function Qt(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.pow(10,n-i.Va)-i.Ea;return t<0?-s:s}function ti(t,i){if(null===t)return null;const n=Jt(t.$e(),i),s=Jt(t.je(),i);return new ct(n,s)}function ii(t,i){if(null===t)return null;const n=Qt(t.$e(),i),s=Qt(t.je(),i);return new ct(n,s)}function ni(t){if(null===t)return Yt;const i=Math.abs(t.je()-t.$e());if(i>=1||i<1e-15)return Yt;const n=Math.ceil(Math.abs(Math.log10(i))),s=Yt.Va+n;return{Va:s,Ea:1/Math.pow(10,s)}}function si(t,i,n){return Math.min(Math.max(t,i),n)}function ei(t,i,n){return i-t<=n}function ri(t){const i=Math.ceil(t);return i%2==0?i-1:i}class hi{constructor(t,i){if(this.Aa=t,this.Ba=i,function(t){if(t<0)return!1;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Aa))this.za=[2,2.5,2];else{this.za=[];for(let t=this.Aa;1!==t;){if(t%2==0)this.za.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.za.push(2,2.5),t/=5}if(this.za.length>100)throw new Error("something wrong with base")}}}Oa(t,i,n){const s=0===this.Aa?0:1/this.Aa;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Ba[0];for(;;){const t=ei(e,s,1e-14)&&e>s+1e-14,i=ei(e,n*h,1e-14),a=ei(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.Ba[++r%this.Ba.length]}if(e<=s+1e-14&&(e=s),e=Math.max(1,e),this.za.length>0&&(a=e,l=1,o=1e-14,Math.abs(a-l)<o))for(r=0,h=this.za[0];ei(e,n*h,1e-14)&&e>s+1e-14;)e/=h,h=this.za[++r%this.za.length];var a,l,o;return e}}class ai{constructor(t,i,n,s){this.La=[],this.qi=t,this.Aa=i,this.Na=n,this.Wa=s}Oa(t,i){if(t<i)throw new Error("high < low");const n=this.qi.$t(),s=(t-i)*this.Fa()/n,e=new hi(this.Aa,[2,2.5,2]),r=new hi(this.Aa,[2,2,2.5]),h=new hi(this.Aa,[2.5,2,2]),a=[];return a.push(e.Oa(t,i,s),r.Oa(t,i,s),h.Oa(t,i,s)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(a)}Ha(){const t=this.qi,i=t.zt();if(null===i)return void(this.La=[]);const n=t.$t(),s=this.Na(n-1,i),e=this.Na(0,i),r=this.qi.N().entireTextOnly?this.Ua()/2:0,h=r,a=n-1-r,l=Math.max(s,e),o=Math.min(s,e);if(l===o)return void(this.La=[]);let _=this.Oa(l,o),u=l%_;u+=u<0?_:0;const c=l>=o?1:-1;let d=null,f=0;for(let n=l-u;n>o;n-=_){const s=this.Wa(n,i,!0);null!==d&&Math.abs(s-d)<this.Fa()||(s<h||s>a||(f<this.La.length?(this.La[f].ka=s,this.La[f].$a=t.ja(n)):this.La.push({ka:s,$a:t.ja(n)}),f++,d=s,t.qa()&&(_=this.Oa(n*c,o))))}this.La.length=f}Ia(){return this.La}Ua(){return this.qi.k()}Fa(){return Math.ceil(2.5*this.Ua())}}function li(t){return t.slice().sort(((t,i)=>a(t.hn())-a(i.hn())))}var oi;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(oi||(oi={}));const _i=new G,ui=new X(100,1);class ci{constructor(t,i,n,s,e){this.Ya=0,this.Za=null,this.Ge=null,this.Ka=null,this.Xa={Ga:!1,Ja:null},this.Qa=0,this.tl=0,this.il=new o,this.nl=new o,this.sl=[],this.el=null,this.rl=null,this.hl=null,this.al=null,this.ha=ui,this.ll=ni(null),this.ol=t,this.Sn=i,this._l=n,this.ul=s,this.cl=e,this.dl=new ai(this,100,this.fl.bind(this),this.pl.bind(this))}wa(){return this.ol}N(){return this.Sn}hr(t){if(_(this.Sn,t),this.ga(),void 0!==t.mode&&this.vl({ie:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),n=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(n<0||n>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(i+n>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+n}`);this.ml(),this.rl=null}}wl(){return this.Sn.autoScale}qa(){return 1===this.Sn.mode}Oe(){return 2===this.Sn.mode}gl(){return 3===this.Sn.mode}ie(){return{Qn:this.Sn.autoScale,Ml:this.Sn.invertScale,ie:this.Sn.mode}}vl(t){const i=this.ie();let n=null;void 0!==t.Qn&&(this.Sn.autoScale=t.Qn),void 0!==t.ie&&(this.Sn.mode=t.ie,2!==t.ie&&3!==t.ie||(this.Sn.autoScale=!0),this.Xa.Ga=!1),1===i.ie&&t.ie!==i.ie&&(!function(t,i){if(null===t)return!1;const n=Qt(t.$e(),i),s=Qt(t.je(),i);return isFinite(n)&&isFinite(s)}(this.Ge,this.ll)?this.Sn.autoScale=!0:(n=ii(this.Ge,this.ll),null!==n&&this.bl(n))),1===t.ie&&t.ie!==i.ie&&(n=ti(this.Ge,this.ll),null!==n&&this.bl(n));const s=i.ie!==this.Sn.mode;s&&(2===i.ie||this.Oe())&&this.ga(),s&&(3===i.ie||this.gl())&&this.ga(),void 0!==t.Ml&&i.Ml!==t.Ml&&(this.Sn.invertScale=t.Ml,this.xl()),this.nl.p(i,this.ie())}Sl(){return this.nl}k(){return this._l.fontSize}$t(){return this.Ya}Cl(t){this.Ya!==t&&(this.Ya=t,this.ml(),this.rl=null)}yl(){if(this.Za)return this.Za;const t=this.$t()-this.kl()-this.Pl();return this.Za=t,t}Qe(){return this.Tl(),this.Ge}bl(t,i){const n=this.Ge;(i||null===n&&null!==t||null!==n&&!n.He(t))&&(this.rl=null,this.Ge=t)}Zi(){return this.Tl(),0===this.Ya||!this.Ge||this.Ge.Zi()}Rl(t){return this.Ml()?t:this.$t()-1-t}Nt(t,i){return this.Oe()?t=Zt(t,i):this.gl()&&(t=Xt(t,i)),this.pl(t,i)}Dl(t,i,n){this.Tl();const s=this.Pl(),e=a(this.Qe()),r=e.$e(),h=e.je(),l=this.yl()-1,o=this.Ml(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Il();for(let n=u;n<c;n++){const e=t[n],h=e.gt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.gt,i));const l=s+_*(a-r),u=o?l:this.Ya-1-l;e.ut=u}}Vl(t,i,n){this.Tl();const s=this.Pl(),e=a(this.Qe()),r=e.$e(),h=e.je(),l=this.yl()-1,o=this.Ml(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Il();for(let n=u;n<c;n++){const e=t[n];let h=e.jh,a=e.qh,l=e.Yh,u=e.Zh;null!==d&&(h=d(e.jh,i),a=d(e.qh,i),l=d(e.Yh,i),u=d(e.Zh,i));let c=s+_*(h-r),f=o?c:this.Ya-1-c;e.El=f,c=s+_*(a-r),f=o?c:this.Ya-1-c,e.Al=f,c=s+_*(l-r),f=o?c:this.Ya-1-c,e.Bl=f,c=s+_*(u-r),f=o?c:this.Ya-1-c,e.zl=f}}kn(t,i){const n=this.fl(t,i);return this.Ol(n,i)}Ol(t,i){let n=t;return this.Oe()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this.gl()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n}ba(){return this.sl}Dt(){if(this.el)return this.el;let t=[];for(let i=0;i<this.sl.length;i++){const n=this.sl[i];null===n.hn()&&n.an(i+1),t.push(n)}return t=li(t),this.el=t,this.el}Ll(t){-1===this.sl.indexOf(t)&&(this.sl.push(t),this.ga(),this.Nl())}Wl(t){const i=this.sl.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.sl.splice(i,1),0===this.sl.length&&(this.vl({Qn:!0}),this.bl(null)),this.ga(),this.Nl()}zt(){let t=null;for(const i of this.sl){const n=i.zt();null!==n&&((null===t||n.Hh<t.Hh)&&(t=n))}return null===t?null:t.Ft}Ml(){return this.Sn.invertScale}Ia(){const t=null===this.zt();if(null!==this.rl&&(t||this.rl.Fl===t))return this.rl.Ia;this.dl.Ha();const i=this.dl.Ia();return this.rl={Ia:i,Fl:t},this.il.p(),i}Hl(){return this.il}Ul(t){this.Oe()||this.gl()||null===this.hl&&null===this.Ka&&(this.Zi()||(this.hl=this.Ya-t,this.Ka=a(this.Qe()).Ue()))}$l(t){if(this.Oe()||this.gl())return;if(null===this.hl)return;this.vl({Qn:!1}),(t=this.Ya-t)<0&&(t=0);let i=(this.hl+.2*(this.Ya-1))/(t+.2*(this.Ya-1));const n=a(this.Ka).Ue();i=Math.max(i,.1),n.Ye(i),this.bl(n)}jl(){this.Oe()||this.gl()||(this.hl=null,this.Ka=null)}ql(t){this.wl()||null===this.al&&null===this.Ka&&(this.Zi()||(this.al=t,this.Ka=a(this.Qe()).Ue()))}Yl(t){if(this.wl())return;if(null===this.al)return;const i=a(this.Qe()).qe()/(this.yl()-1);let n=t-this.al;this.Ml()&&(n*=-1);const s=n*i,e=a(this.Ka).Ue();e.Ze(s),this.bl(e,!0),this.rl=null}Zl(){this.wl()||null!==this.al&&(this.al=null,this.Ka=null)}ra(){return this.ha||this.ga(),this.ha}Xi(t,i){switch(this.Sn.mode){case 2:return this.Kl(Zt(t,i));case 3:return this.ra().format(Xt(t,i));default:return this.sr(t)}}ja(t){switch(this.Sn.mode){case 2:return this.Kl(t);case 3:return this.ra().format(t);default:return this.sr(t)}}Dh(t){return this.sr(t,a(this.Xl()).ra())}Ih(t,i){return t=Zt(t,i),this.Kl(t,_i)}Gl(){return this.sl}Jl(t){this.Xa={Ja:t,Ga:!1}}On(){this.sl.forEach((t=>t.On()))}ga(){this.rl=null;const t=this.Xl();let i=100;null!==t&&(i=Math.round(1/t.ea())),this.ha=ui,this.Oe()?(this.ha=_i,i=100):this.gl()?(this.ha=new X(100,1),i=100):null!==t&&(this.ha=t.ra()),this.dl=new ai(this,i,this.fl.bind(this),this.pl.bind(this)),this.dl.Ha()}Nl(){this.el=null}Ki(){return this.cl}Xl(){return this.sl[0]||null}kl(){return this.Ml()?this.Sn.scaleMargins.bottom*this.$t()+this.tl:this.Sn.scaleMargins.top*this.$t()+this.Qa}Pl(){return this.Ml()?this.Sn.scaleMargins.top*this.$t()+this.Qa:this.Sn.scaleMargins.bottom*this.$t()+this.tl}Tl(){this.Xa.Ga||(this.Xa.Ga=!0,this.Ql())}ml(){this.Za=null}pl(t,i){if(this.Tl(),this.Zi())return 0;t=this.qa()&&t?Jt(t,this.ll):t;const n=a(this.Qe()),s=this.Pl()+(this.yl()-1)*(t-n.$e())/n.qe();return this.Rl(s)}fl(t,i){if(this.Tl(),this.Zi())return 0;const n=this.Rl(t),s=a(this.Qe()),e=s.$e()+s.qe()*((n-this.Pl())/(this.yl()-1));return this.qa()?Qt(e,this.ll):e}xl(){this.rl=null,this.dl.Ha()}Ql(){const t=this.Xa.Ja;if(null===t)return;let i=null;const n=this.Gl();let s=0,e=0;for(const r of n){if(!r.It())continue;const n=r.zt();if(null===n)continue;const h=r.Mh(t.Uh(),t.bi());let l=h&&h.Qe();if(null!==l){switch(this.Sn.mode){case 1:l=ti(l,this.ll);break;case 2:l=Kt(l,n.Ft);break;case 3:l=Gt(l,n.Ft)}if(i=null===i?l:i.ps(a(l)),null!==h){const t=h.tr();null!==t&&(s=Math.max(s,t.above),e=Math.max(e,t.below))}}}if(s===this.Qa&&e===this.tl||(this.Qa=s,this.tl=e,this.rl=null,this.ml()),null!==i){if(i.$e()===i.je()){const t=this.Xl(),n=5*(null===t||this.Oe()||this.gl()?1:t.ea());this.qa()&&(i=ii(i,this.ll)),i=new ct(i.$e()-n,i.je()+n),this.qa()&&(i=ti(i,this.ll))}if(this.qa()){const t=ii(i,this.ll),n=ni(t);if(r=n,h=this.ll,r.Va!==h.Va||r.Ea!==h.Ea){const s=null!==this.Ka?ii(this.Ka,this.ll):null;this.ll=n,i=ti(t,n),null!==s&&(this.Ka=ti(s,n))}}this.bl(i)}else null===this.Ge&&(this.bl(new ct(-.5,.5)),this.ll=ni(null));var r,h;this.Xa.Ga=!0}Il(){return this.Oe()?Zt:this.gl()?Xt:this.qa()?t=>Jt(t,this.ll):null}io(t,i,n){return void 0===i?(void 0===n&&(n=this.ra()),n.format(t)):i(t)}sr(t,i){return this.io(t,this.ul.priceFormatter,i)}Kl(t,i){return this.io(t,this.ul.percentageFormatter,i)}}function di(t){return t instanceof Ht}class fi{constructor(t,i){this.sl=[],this.no=new Map,this.Ya=0,this.so=0,this.eo=1e3,this.el=null,this.ro=new o,this.kh=[],this.uh=t,this.tn=i,this.ho=new qt(this);const n=i.N();this.ao=this.lo("left",n.leftPriceScale),this.oo=this.lo("right",n.rightPriceScale),this.ao.Sl().i(this._o.bind(this,this.ao),this),this.oo.Sl().i(this._o.bind(this,this.oo),this),this.uo(n)}uo(t){if(t.leftPriceScale&&this.ao.hr(t.leftPriceScale),t.rightPriceScale&&this.oo.hr(t.rightPriceScale),t.localization&&(this.ao.ga(),this.oo.ga()),t.overlayPriceScales){const i=Array.from(this.no.values());for(const n of i){const i=a(n[0].Wt());i.hr(t.overlayPriceScales),t.localization&&i.ga()}}}co(t){switch(t){case"left":return this.ao;case"right":return this.oo}return this.no.has(t)?h(this.no.get(t))[0].Wt():null}m(){this.Qt().do().u(this),this.ao.Sl().u(this),this.oo.Sl().u(this),this.sl.forEach((t=>{t.m&&t.m()})),this.kh=this.kh.filter((t=>{const i=t.oh();return i.detached&&i.detached(),!1})),this.ro.p()}fo(){return this.eo}po(t){this.eo=t}Qt(){return this.tn}Qi(){return this.so}$t(){return this.Ya}vo(t){this.so=t,this.mo()}Cl(t){this.Ya=t,this.ao.Cl(t),this.oo.Cl(t),this.sl.forEach((i=>{if(this.Us(i)){const n=i.Wt();null!==n&&n.Cl(t)}})),this.mo()}wo(){return this.sl.filter(di)}ba(){return this.sl}Us(t){const i=t.Wt();return null===i||this.ao!==i&&this.oo!==i}Ll(t,i,n){const s=void 0!==n?n:this.bo().Mo+1;this.xo(t,i,s)}Wl(t){const i=this.sl.indexOf(t);r(-1!==i,"removeDataSource: invalid data source"),this.sl.splice(i,1);const n=a(t.Wt()).wa();if(this.no.has(n)){const i=h(this.no.get(n)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.no.delete(n))}const s=t.Wt();s&&s.ba().indexOf(t)>=0&&s.Wl(t),null!==s&&(s.Nl(),this.So(s)),this.el=null}js(t){return t===this.ao?"left":t===this.oo?"right":"overlay"}Co(){return this.ao}yo(){return this.oo}ko(t,i){t.Ul(i)}Po(t,i){t.$l(i),this.mo()}To(t){t.jl()}Ro(t,i){t.ql(i)}Do(t,i){t.Yl(i),this.mo()}Io(t){t.Zl()}mo(){this.sl.forEach((t=>{t.On()}))}yn(){let t=null;return this.tn.N().rightPriceScale.visible&&0!==this.oo.ba().length?t=this.oo:this.tn.N().leftPriceScale.visible&&0!==this.ao.ba().length?t=this.ao:0!==this.sl.length&&(t=this.sl[0].Wt()),null===t&&(t=this.oo),t}$s(){let t=null;return this.tn.N().rightPriceScale.visible?t=this.oo:this.tn.N().leftPriceScale.visible&&(t=this.ao),t}So(t){null!==t&&t.wl()&&this.Vo(t)}Eo(t){const i=this.uh.ye();t.vl({Qn:!0}),null!==i&&t.Jl(i),this.mo()}Ao(){this.Vo(this.ao),this.Vo(this.oo)}Bo(){this.So(this.ao),this.So(this.oo),this.sl.forEach((t=>{this.Us(t)&&this.So(t.Wt())})),this.mo(),this.tn.ar()}Dt(){return null===this.el&&(this.el=li(this.sl)),this.el}Vt(){return this.Dt().filter(di)}zo(){return this.ro}Oo(){return this.ho}ua(t){this.kh.push(new Dt(t))}ca(t){this.