@pipsend/charts 0.0.9 → 0.0.11
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/pipsend-charts.development.mjs +2 -2
- package/dist/pipsend-charts.production.mjs +2 -2
- package/dist/pipsend-charts.standalone.development.js +2 -2
- package/dist/pipsend-charts.standalone.development.mjs +2 -2
- package/dist/pipsend-charts.standalone.production.js +2 -2
- package/dist/pipsend-charts.standalone.production.mjs +2 -2
- package/package.json +1 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @license
|
|
3
|
-
* Pipsend Charts v0.0.
|
|
3
|
+
* Pipsend Charts v0.0.11-dev+202510282325
|
|
4
4
|
* Copyright (c) 2025 Pipsend
|
|
5
5
|
* Licensed under MIT License
|
|
6
6
|
* Built on TradingView Lightweight Charts™ (Apache 2.0)
|
|
7
7
|
*/
|
|
8
|
-
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,s;function n(t,i){const s={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(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,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"}(s||(s={}));class o{constructor(){this.t=[]}i(t,i,s){const n={h:t,l:i,o:!0===s};this.t.push(n)}_(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,s){const n=[...this.t];this.t=this.t.filter(t=>!t.o),n.forEach(n=>n.h(t,i,s))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:_(t[i],s[i]));return t}function c(t){return"number"==typeof t&&isFinite(t)}function u(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 s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?p(e):e);return s}function v(t){return null!==t}function m(t){return null===t?void 0:t}const g="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function w(t,i,s){return void 0===i&&(i=g),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,P:NaN,T:"",R:"",D:"",B:"",V:0,A:0,I:0,L:0,O:0},this.F=t}W(){const t=this.M,i=this.N(),s=this.H();return t.P===i&&t.R===s||(t.P=i,t.R=s,t.T=w(i,s),t.L=2.5/12*i,t.V=t.L,t.A=i/12*t.C,t.I=i/12*t.C,t.O=0),t.D=this.U(),t.B=this.$(),this.M}U(){return this.F.W().layout.textColor}$(){return this.F.j()}N(){return this.F.W().layout.fontSize}H(){return this.F.W().layout.fontFamily}}function b(t){return t<0?0:t>255?255:Math.round(t)||0}function S(t){return.199*t[0]+.687*t[1]+.114*t[2]}class x{constructor(t,i){this.q=new Map,this.Y=t,i&&(this.q=i)}K(t,i){if("transparent"===t)return t;const s=this.X(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}G(t){const i=this.X(t);return{Z:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,J:S(i)>160?"black":"white"}}tt(t){return S(this.X(t))}it(t,i,s){const[n,e,r,h]=this.X(t),[a,l,o,_]=this.X(i),c=[b(n+s*(a-n)),b(e+s*(l-e)),b(r+s*(o-r)),(u=h+s*(_-h),u<=0||u>1?Math.min(Math.max(u,0),1):Math.round(1e4*u)/1e4)];var u;return`rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3]})`}X(t){const i=this.q.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),n=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.q.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.q.set(t,e),e}}class y{constructor(){this.st=[]}nt(t){this.st=t}et(t,i,s){this.st.forEach(n=>{n.et(t,i,s)})}}class C{et(t,i,s){t.useBitmapCoordinateSpace(t=>this.rt(t,i,s))}}class P extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.ht||null===this.ht.ot)return;const n=this.ht.ot,e=this.ht,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=n.to-1;a>=n.from;--a){const n=e._t[a],l=Math.round(n.ct*i)+r,o=n.ut*s,_=h*s+r;t.moveTo(l,o),t.arc(l,o,_,0,2*Math.PI)}t.fill()};e.dt>0&&(t.fillStyle=e.ft,h(e.vt+e.dt)),t.fillStyle=e.gt,h(e.vt)}}function k(){return{_t:[{ct:0,ut:0,wt:0,Mt:0}],gt:"",ft:"",vt:0,dt:0,ot:null}}const T={from:0,to:1};class R{constructor(t,i,s){this.bt=new y,this.St=[],this.xt=[],this.yt=!0,this.F=t,this.Ct=i,this.Pt=s,this.bt.nt(this.St)}kt(t){this.Tt(),this.yt=!0}Rt(){return this.yt&&(this.Dt(),this.yt=!1),this.bt}Tt(){const t=this.Pt.Et();t.length!==this.St.length&&(this.xt=t.map(k),this.St=this.xt.map(t=>{const i=new P;return i.lt(t),i}),this.bt.nt(this.St))}Dt(){const t=2===this.Ct.W().mode||!this.Ct.Bt(),i=this.Pt.Vt(),s=this.Ct.At(),n=this.F.It();this.Tt(),i.forEach((i,e)=>{const r=this.xt[e],h=i.zt(s),a=i.Lt();!t&&null!==h&&i.Bt()&&null!==a?(r.gt=h.Ot,r.vt=h.vt,r.dt=h.Ft,r._t[0].Mt=h.Mt,r._t[0].ut=i.Nt().Wt(h.Mt,a.Ht),r.ft=h.Ut??this.F.$t(r._t[0].ut/i.Nt().jt()),r._t[0].wt=s,r._t[0].ct=n.qt(s),r.ot=T):r.ot=null})}}class D extends C{constructor(t){super(),this.Yt=t}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;const h=this.Yt.Kt.Bt,a=this.Yt.Xt.Bt;if(!h&&!a)return;const l=Math.round(this.Yt.ct*s),o=Math.round(this.Yt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.Yt.Kt.dt*s),t.strokeStyle=this.Yt.Kt.D,t.fillStyle=this.Yt.Kt.D,n(t,this.Yt.Kt.Gt),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Xt.dt*r),t.strokeStyle=this.Yt.Xt.D,t.fillStyle=this.Yt.Xt.D,n(t,this.Yt.Xt.Gt),e(t,o,0,i.width))}}class E{constructor(t,i){this.yt=!0,this.Zt={Kt:{dt:1,Gt:0,D:"",Bt:!1},Xt:{dt:1,Gt:0,D:"",Bt:!1},ct:0,ut:0},this.Jt=new D(this.Zt),this.Qt=t,this.Pt=i}kt(){this.yt=!0}Rt(t){return this.yt&&(this.Dt(),this.yt=!1),this.Jt}Dt(){const t=this.Qt.Bt(),i=this.Pt.ti().W().crosshair,s=this.Zt;if(2===i.mode)return s.Xt.Bt=!1,void(s.Kt.Bt=!1);s.Xt.Bt=t&&this.Qt.ii(this.Pt),s.Kt.Bt=t&&this.Qt.si(),s.Xt.dt=i.horzLine.width,s.Xt.Gt=i.horzLine.style,s.Xt.D=i.horzLine.color,s.Kt.dt=i.vertLine.width,s.Kt.Gt=i.vertLine.style,s.Kt.D=i.vertLine.color,s.ct=this.Qt.ni(),s.ut=this.Qt.ei()}}function B(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function V(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function A(t,i,s,n,e,r){t.beginPath(),t.roundRect?t.roundRect(i,s,n,e,r):(t.lineTo(i+n-r[1],s),0!==r[1]&&t.arcTo(i+n,s,i+n,s+r[1],r[1]),t.lineTo(i+n,s+e-r[2]),0!==r[2]&&t.arcTo(i+n,s+e,i+n-r[2],s+e,r[2]),t.lineTo(i+r[3],s+e),0!==r[3]&&t.arcTo(i,s+e,i,s+e-r[3],r[3]),t.lineTo(i,s+r[0]),0!==r[0]&&t.arcTo(i,s,i+r[0],s,r[0]))}function I(t,i,s,n,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return A(t,i,s,n,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;A(t,i+o,s+o,n-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,s,n,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,s,n,e),t.restore()}class L{constructor(t,i){this.lt(t,i)}lt(t,i){this.Yt=t,this.ri=i}jt(t,i){return this.Yt.Bt?t.P+t.L+t.V:0}et(t,i,s,n){if(!this.Yt.Bt||0===this.Yt.hi.length)return;const e=this.Yt.D,r=this.ri.Z,h=t.useBitmapCoordinateSpace(t=>{const h=t.context;h.font=i.T;const a=this.ai(t,i,s,n),l=a.li;return a.oi?I(h,l._i,l.ci,l.ui,l.di,r,l.fi,[l.vt,0,0,l.vt],r):I(h,l.pi,l.ci,l.ui,l.di,r,l.fi,[0,l.vt,l.vt,0],r),this.Yt.mi&&(h.fillStyle=e,h.fillRect(l.pi,l.gi,l.wi-l.pi,l.Mi)),this.Yt.bi&&(h.fillStyle=i.B,h.fillRect(a.oi?l.Si-l.fi:0,l.ci,l.fi,l.xi-l.ci)),a});t.useMediaCoordinateSpace(({context:t})=>{const s=h.yi;t.font=i.T,t.textAlign=h.oi?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Yt.hi,s.Ci,(s.ci+s.xi)/2+s.Pi)})}ai(t,i,s,n){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.Yt.mi||!this.Yt.ki?i.C:0,_=this.Yt.Ti?i.S:0,c=i.L+this.ri.Ri,u=i.V+this.ri.Di,d=i.A,f=i.I,p=this.Yt.hi,v=i.P,m=s.Ei(e,p),g=Math.ceil(s.Bi(e,p)),w=v+c+u,M=i.S+d+f+g+o,b=Math.max(1,Math.floor(l));let S=Math.round(w*l);S%2!=b%2&&(S+=1);const x=_>0?Math.max(1,Math.floor(_*a)):0,y=Math.round(M*a),C=Math.round(o*a),P=this.ri.Vi??this.ri.Ai,k=Math.round(P*l)-Math.floor(.5*l),T=Math.floor(k+b/2-S/2),R=T+S,D="right"===n,E=D?h.width-_:_,B=D?r.width-x:x;let V,A,I;return D?(V=B-y,A=B-C,I=E-o-d-_):(V=B+y,A=B+C,I=E+o+d),{oi:D,li:{ci:T,gi:k,xi:R,ui:y,di:S,vt:2*a,fi:x,_i:V,pi:B,wi:A,Mi:b,Si:r.width},yi:{ci:T/l,xi:R/l,Ci:I,Pi:m}}}}class O{constructor(t){this.Ii={Ai:0,Z:"#000",Di:0,Ri:0},this.zi={hi:"",Bt:!1,mi:!0,ki:!1,Ut:"",D:"#FFF",bi:!1,Ti:!1},this.Li={hi:"",Bt:!1,mi:!1,ki:!0,Ut:"",D:"#FFF",bi:!0,Ti:!0},this.yt=!0,this.Oi=new(t||L)(this.zi,this.Ii),this.Fi=new(t||L)(this.Li,this.Ii)}hi(){return this.Wi(),this.zi.hi}Ai(){return this.Wi(),this.Ii.Ai}kt(){this.yt=!0}jt(t,i=!1){return Math.max(this.Oi.jt(t,i),this.Fi.jt(t,i))}Ni(){return this.Ii.Vi||0}Hi(t){this.Ii.Vi=t}Ui(){return this.Wi(),this.zi.Bt||this.Li.Bt}$i(){return this.Wi(),this.zi.Bt}Rt(t){return this.Wi(),this.zi.mi=this.zi.mi&&t.W().ticksVisible,this.Li.mi=this.Li.mi&&t.W().ticksVisible,this.Oi.lt(this.zi,this.Ii),this.Fi.lt(this.Li,this.Ii),this.Oi}ji(){return this.Wi(),this.Oi.lt(this.zi,this.Ii),this.Fi.lt(this.Li,this.Ii),this.Fi}Wi(){this.yt&&(this.zi.mi=!0,this.Li.mi=!1,this.qi(this.zi,this.Li,this.Ii))}}class F extends O{constructor(t,i,s){super(),this.Qt=t,this.Yi=i,this.Ki=s}qi(t,i,s){if(t.Bt=!1,2===this.Qt.W().mode)return;const n=this.Qt.W().horzLine;if(!n.labelVisible)return;const e=this.Yi.Lt();if(!this.Qt.Bt()||this.Yi.Xi()||null===e)return;const r=this.Yi.Gi().G(n.labelBackgroundColor);s.Z=r.Z,t.D=r.J;const h=2/12*this.Yi.P();s.Ri=h,s.Di=h;const a=this.Ki(this.Yi);s.Ai=a.Ai,t.hi=this.Yi.Zi(a.Mt,e),t.Bt=!0}}const W=/[1-9]/g;class N{constructor(){this.Yt=null}lt(t){this.Yt=t}et(t,i){if(null===this.Yt||!1===this.Yt.Bt||0===this.Yt.hi.length)return;const s=t.useMediaCoordinateSpace(({context:t})=>(t.font=i.T,Math.round(i.Ji.Bi(t,a(this.Yt).hi,W))));if(s<=0)return;const n=i.Qi,e=s+2*n,r=e/2,h=this.Yt.ts;let l=this.Yt.Ai,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,c=Math.ceil(0+i.S+i.C+i.L+i.P+i.V);t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=a(this.Yt);t.fillStyle=e.Z;const r=Math.round(o*s),h=Math.round(0*n),l=Math.round(_*s),u=Math.round(c*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,u-d),t.arcTo(r,u,r+d,u,d),t.lineTo(l-d,u),t.arcTo(l,u,l,u-d,d),t.lineTo(l,h),t.fill(),e.mi){const r=Math.round(e.Ai*s),a=h,l=Math.round((a+i.C)*n);t.fillStyle=e.D;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,a,o,l-a)}}),t.useMediaCoordinateSpace(({context:t})=>{const s=a(this.Yt),e=0+i.S+i.C+i.L+i.P/2;t.font=i.T,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.D;const r=i.Ji.Ei(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.hi,0,0)})}}class H{constructor(t,i,s){this.yt=!0,this.Jt=new N,this.Zt={Bt:!1,Z:"#4c525e",D:"white",hi:"",ts:0,Ai:NaN,mi:!0},this.Ct=t,this.ss=i,this.Ki=s}kt(){this.yt=!0}Rt(){return this.yt&&(this.Dt(),this.yt=!1),this.Jt.lt(this.Zt),this.Jt}Dt(){const t=this.Zt;if(t.Bt=!1,2===this.Ct.W().mode)return;const i=this.Ct.W().vertLine;if(!i.labelVisible)return;const s=this.ss.It();if(s.Xi())return;t.ts=s.ts();const n=this.Ki();if(null===n)return;t.Ai=n.Ai;const e=s.ns(this.Ct.At());t.hi=s.es(a(e)),t.Bt=!0;const r=this.ss.Gi().G(i.labelBackgroundColor);t.Z=r.Z,t.D=r.J,t.mi=s.W().ticksVisible}}class U{constructor(){this.rs=null,this.hs=0}ls(){return this.hs}_s(t){this.hs=t}Nt(){return this.rs}cs(t){this.rs=t}us(t){return[]}ds(){return[]}Bt(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}($||($={}));class j extends U{constructor(t,i){super(),this.Pt=null,this.fs=NaN,this.ps=0,this.vs=!1,this.gs=new Map,this.ws=!1,this.Ms=new WeakMap,this.bs=new WeakMap,this.Ss=NaN,this.xs=NaN,this.ys=NaN,this.Cs=NaN,this.ss=t,this.Ps=i;this.ks=((t,i)=>s=>{const n=i(),e=t();if(s===a(this.Pt).Ts())return{Mt:e,Ai:n};{const t=a(s.Lt());return{Mt:s.Rs(n,t),Ai:n}}})(()=>this.fs,()=>this.xs);const s=((t,i)=>()=>{const s=this.ss.It().Ds(t()),n=i();return s&&Number.isFinite(n)?{wt:s,Ai:n}:null})(()=>this.ps,()=>this.ni());this.Es=new H(this,t,s)}W(){return this.Ps}Bs(t,i){this.ys=t,this.Cs=i}Vs(){this.ys=NaN,this.Cs=NaN}As(){return this.ys}Is(){return this.Cs}zs(t,i,s){this.ws||(this.ws=!0),this.vs=!0,this.Ls(t,i,s)}At(){return this.ps}ni(){return this.Ss}ei(){return this.xs}Bt(){return this.vs}Os(){this.vs=!1,this.Fs(),this.fs=NaN,this.Ss=NaN,this.xs=NaN,this.Pt=null,this.Vs(),this.Ws()}Ns(t){let i=this.Ms.get(t);i||(i=new E(this,t),this.Ms.set(t,i));let s=this.bs.get(t);return s||(s=new R(this.ss,this,t),this.bs.set(t,s)),[i,s]}ii(t){return t===this.Pt&&this.Ps.horzLine.visible}si(){return this.Ps.vertLine.visible}Hs(t,i){this.vs&&this.Pt===t||this.gs.clear();const s=[];return this.Pt===t&&s.push(this.Us(this.gs,i,this.ks)),s}ds(){return this.vs?[this.Es]:[]}$s(){return this.Pt}Ws(){this.ss.js().forEach(t=>{this.Ms.get(t)?.kt(),this.bs.get(t)?.kt()}),this.gs.forEach(t=>t.kt()),this.Es.kt()}qs(t){return t&&!t.Ts().Xi()?t.Ts():null}Ls(t,i,s){this.Ys(t,i,s)&&this.Ws()}Ys(t,i,s){const n=this.Ss,e=this.xs,r=this.fs,h=this.ps,a=this.Pt,l=this.qs(s);this.ps=t,this.Ss=isNaN(t)?NaN:this.ss.It().qt(t),this.Pt=s;const o=null!==l?l.Lt():null;return null!==l&&null!==o?(this.fs=i,this.xs=l.Wt(i,o)):(this.fs=NaN,this.xs=NaN),n!==this.Ss||e!==this.xs||h!==this.ps||r!==this.fs||a!==this.Pt}Fs(){const t=this.ss.Ks().map(t=>t.Gs().Xs()).filter(v),i=0===t.length?null:Math.max(...t);this.ps=null!==i?i:NaN}Us(t,i,s){let n=t.get(i);return void 0===n&&(n=new F(this,i,s),t.set(i,n)),n}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.Zs=new Map,this.Js=[],this.Qs=t}tn(t,i){const s=function(t,i){return void 0===t?i:{sn:Math.max(t.sn,i.sn),nn:t.nn||i.nn}}(this.Zs.get(t),i);this.Zs.set(t,s)}en(){return this.Qs}rn(t){const i=this.Zs.get(t);return void 0===i?{sn:this.Qs}:{sn:Math.max(this.Qs,i.sn),nn:i.nn}}hn(){this.an(),this.Js=[{ln:0}]}_n(t){this.an(),this.Js=[{ln:1,Ht:t}]}cn(t){this.un(),this.Js.push({ln:5,Ht:t})}an(){this.un(),this.Js.push({ln:6})}dn(){this.an(),this.Js=[{ln:4}]}fn(t){this.an(),this.Js.push({ln:2,Ht:t})}pn(t){this.an(),this.Js.push({ln:3,Ht:t})}vn(){return this.Js}mn(t){for(const i of t.Js)this.gn(i);this.Qs=Math.max(this.Qs,t.Qs),t.Zs.forEach((t,i)=>{this.tn(i,t)})}static wn(){return new Y(2)}static Mn(){return new Y(3)}gn(t){switch(t.ln){case 0:this.hn();break;case 1:this._n(t.Ht);break;case 2:this.fn(t.Ht);break;case 3:this.pn(t.Ht);break;case 4:this.dn();break;case 5:this.cn(t.Ht);break;case 6:this.un()}}un(){const t=this.Js.findIndex(t=>5===t.ln);-1!==t&&this.Js.splice(t,1)}}class K{formatTickmarks(t){return t.map(t=>this.format(t))}}const X=".";function G(t,i){if(!c(t))return"n/a";if(!u(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 Z extends K{constructor(t,i){if(super(),i||(i=1),c(t)&&u(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.bn=i,this.Sn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.xn(t)}Sn(){if(this.yn=0,this.Yi>0&&this.bn>0){let t=this.Yi;for(;t>1;)t/=10,this.yn++}}xn(t){const i=this.Yi/this.bn;let s=Math.floor(t),n="";const e=void 0!==this.yn?this.yn:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.yn);r>=i&&(r-=i,s+=1),n=X+G(+r.toFixed(this.yn)*this.bn,e)}else s=Math.round(s*i)/i,e>0&&(n=X+G(0,e));return s.toFixed(0)+n}}class J extends Z{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Q extends K{constructor(t){super(),this.Cn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.Pn(t):t<999995?i+this.Pn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Pn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Pn(t/1e9)+"B")}Pn(t){let i;const s=Math.pow(10,this.Cn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Cn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,(t,i)=>i)}}const tt=/[2-9]/g;class it{constructor(t=50){this.kn=0,this.Tn=1,this.Rn=1,this.Dn={},this.En=new Map,this.Bn=t}Vn(){this.kn=0,this.En.clear(),this.Tn=1,this.Rn=1,this.Dn={}}Bi(t,i,s){return this.An(t,i,s).width}Ei(t,i,s){const n=this.An(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}An(t,i,s){const n=s||tt,e=String(i).replace(n,"0");if(this.En.has(e))return h(this.En.get(e)).In;if(this.kn===this.Bn){const t=this.Dn[this.Rn];delete this.Dn[this.Rn],this.En.delete(t),this.Rn++,this.kn--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.En.set(e,{In:r,zn:this.Tn}),this.Dn[this.Tn]=e,this.kn++,this.Tn++),r}}class st{constructor(t){this.Ln=null,this.M=null,this.On="right",this.Fn=t}Wn(t,i,s){this.Ln=t,this.M=i,this.On=s}et(t){null!==this.M&&null!==this.Ln&&this.Ln.et(t,this.M,this.Fn,this.On)}}class nt{constructor(t,i,s){this.Nn=t,this.Fn=new it(50),this.Hn=i,this.F=s,this.N=-1,this.Jt=new st(this.Fn)}Rt(){const t=this.F.Un(this.Hn);if(null===t)return null;const i=t.$n(this.Hn)?t.jn():this.Hn.Nt();if(null===i)return null;const s=t.qn(i);if("overlay"===s)return null;const n=this.F.Yn();return n.P!==this.N&&(this.N=n.P,this.Fn.Vn()),this.Jt.Wn(this.Nn.ji(),n,s),this.Jt}}class et extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}Kn(t,i){if(!this.Yt?.Bt)return null;const{ut:s,dt:n,Xn:e}=this.Yt;return i>=s-n-7&&i<=s+n+7?{Gn:this.Yt,Xn:e}:null}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;if(!1===this.Yt.Bt)return;const h=Math.round(this.Yt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.D,t.lineWidth=Math.floor(this.Yt.dt*s),n(t,this.Yt.Gt),e(t,h,0,i.width))}}class rt{constructor(t){this.Zn={ut:0,D:"rgba(0, 0, 0, 0)",dt:1,Gt:0,Bt:!1},this.Jn=new et,this.yt=!0,this.Qn=t,this.te=t.ti(),this.Jn.lt(this.Zn)}kt(){this.yt=!0}Rt(){return this.Qn.Bt()?(this.yt&&(this.ie(),this.yt=!1),this.Jn):null}}class ht extends rt{constructor(t){super(t)}ie(){this.Zn.Bt=!1;const t=this.Qn.Nt(),i=t.se().se;if(2!==i&&3!==i)return;const s=this.Qn.W();if(!s.baseLineVisible||!this.Qn.Bt())return;const n=this.Qn.Lt();null!==n&&(this.Zn.Bt=!0,this.Zn.ut=t.Wt(n.Ht,n.Ht),this.Zn.D=s.baseLineColor,this.Zn.dt=s.baseLineWidth,this.Zn.Gt=s.baseLineStyle)}}class at extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}ne(){return this.Yt}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Yt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.ee.x*i)+r,a=n.ee.y*s;t.fillStyle=n.re,t.beginPath();const l=Math.max(2,1.5*n.he)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.ae,t.beginPath(),t.arc(h,a,n.vt*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.le,t.beginPath(),t.arc(h,a,n.vt*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{oe:0,_e:.25,ce:4,ue:10,de:.25,fe:0,pe:.4,ve:.8},{oe:.25,_e:.525,ce:10,ue:14,de:0,fe:0,pe:.8,ve:0},{oe:.525,_e:1,ce:14,ue:14,de:0,fe:0,pe:0,ve:0}];class ot{constructor(t){this.Jt=new at,this.yt=!0,this.me=!0,this.ge=performance.now(),this.we=this.ge-1,this.Me=t}be(){this.we=this.ge-1,this.kt()}Se(){if(this.kt(),2===this.Me.W().lastPriceAnimation){const t=performance.now(),i=this.we-t;if(i>0)return void(i<650&&(this.we+=2600));this.ge=t,this.we=t+2600}}kt(){this.yt=!0}xe(){this.me=!0}Bt(){return 0!==this.Me.W().lastPriceAnimation}ye(){switch(this.Me.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.we}}Rt(){return this.yt?(this.Dt(),this.yt=!1,this.me=!1):this.me&&(this.Ce(),this.me=!1),this.Jt}Dt(){this.Jt.lt(null);const t=this.Me.ti().It(),i=t.Pe(),s=this.Me.Lt();if(null===i||null===s)return;const n=this.Me.ke(!0);if(n.Te||!i.Re(n.De))return;const e={x:t.qt(n.De),y:this.Me.Nt().Wt(n.Mt,s.Ht)},r=n.D,h=this.Me.W().lineWidth,a=this.Ee(this.Be(),r);this.Jt.lt({re:r,he:h,ae:a.ae,le:a.le,vt:a.vt,ee:e})}Ce(){const t=this.Jt.ne();if(null!==t){const i=this.Ee(this.Be(),t.re);t.ae=i.ae,t.le=i.le,t.vt=i.vt}}Be(){return this.ye()?performance.now()-this.ge:2599}Ve(t,i,s,n){const e=s+(n-s)*i;return this.Me.ti().Gi().K(t,e)}Ee(t,i){const s=t%2600/2600;let n;for(const t of lt)if(s>=t.oe&&s<=t._e){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.oe)/(n._e-n.oe);return{ae:this.Ve(i,e,n.de,n.fe),le:this.Ve(i,e,n.pe,n.ve),vt:(h=e,a=n.ce,l=n.ue,a+(l-a)*h)};var h,a,l}}class _t extends rt{constructor(t){super(t)}ie(){const t=this.Zn;t.Bt=!1;const i=this.Qn.W();if(!i.priceLineVisible||!this.Qn.Bt())return;const s=this.Qn.ke(0===i.priceLineSource);s.Te||(t.Bt=!0,t.ut=s.Ai,t.D=this.Qn.Ae(s.D),t.dt=i.priceLineWidth,t.Gt=i.priceLineStyle)}}class ct extends O{constructor(t){super(),this.Qt=t}qi(t,i,s){t.Bt=!1,i.Bt=!1;const n=this.Qt;if(!n.Bt())return;const e=n.W(),r=e.lastValueVisible,h=""!==n.Ie(),a=0===e.seriesLastValueMode,l=n.ke(!1);if(l.Te)return;r&&(t.hi=this.ze(l,r,a),t.Bt=0!==t.hi.length),(h||a)&&(i.hi=this.Le(l,r,h,a),i.Bt=i.hi.length>0);const o=n.Ae(l.D),_=this.Qt.ti().Gi().G(o);s.Z=_.Z,s.Ai=l.Ai,i.Ut=n.ti().$t(l.Ai/n.Nt().jt()),t.Ut=o,t.D=_.J,i.D=_.J}Le(t,i,s,n){let e="";const r=this.Qt.Ie();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.Qt.Nt().Oe()?t.Fe:t.We),e.trim()}ze(t,i,s){return i?s?this.Qt.Nt().Oe()?t.We:t.Fe:t.hi:""}}function ut(t,i,s,n){const e=Number.isFinite(i),r=Number.isFinite(s);return e&&r?t(i,s):e||r?e?i:s:n}class dt{constructor(t,i){this.Ne=t,this.He=i}Ue(t){return null!==t&&(this.Ne===t.Ne&&this.He===t.He)}$e(){return new dt(this.Ne,this.He)}je(){return this.Ne}qe(){return this.He}Ye(){return this.He-this.Ne}Xi(){return this.He===this.Ne||Number.isNaN(this.He)||Number.isNaN(this.Ne)}mn(t){return null===t?this:new dt(ut(Math.min,this.je(),t.je(),-1/0),ut(Math.max,this.qe(),t.qe(),1/0))}Ke(t){if(!c(t))return;if(0===this.He-this.Ne)return;const i=.5*(this.He+this.Ne);let s=this.He-i,n=this.Ne-i;s*=t,n*=t,this.He=i+s,this.Ne=i+n}Xe(t){c(t)&&(this.He+=t,this.Ne+=t)}Ge(){return{minValue:this.Ne,maxValue:this.He}}static Ze(t){return null===t?null:new dt(t.minValue,t.maxValue)}}class ft{constructor(t,i){this.Je=t,this.Qe=i||null}tr(){return this.Je}ir(){return this.Qe}Ge(){return{priceRange:null===this.Je?null:this.Je.Ge(),margins:this.Qe||void 0}}static Ze(t){return null===t?null:new ft(dt.Ze(t.priceRange),t.margins)}}class pt extends rt{constructor(t,i){super(t),this.sr=i}ie(){const t=this.Zn;t.Bt=!1;const i=this.sr.W();if(!this.Qn.Bt()||!i.lineVisible)return;const s=this.sr.nr();null!==s&&(t.Bt=!0,t.ut=s,t.D=i.color,t.dt=i.lineWidth,t.Gt=i.lineStyle,t.Xn=this.sr.W().id)}}class vt extends O{constructor(t,i){super(),this.Me=t,this.sr=i}qi(t,i,s){t.Bt=!1,i.Bt=!1;const n=this.sr.W(),e=n.axisLabelVisible,r=""!==n.title,h=this.Me;if(!e||!h.Bt())return;const a=this.sr.nr();if(null===a)return;r&&(i.hi=n.title,i.Bt=!0),i.Ut=h.ti().$t(a/h.Nt().jt()),t.hi=this.er(n.price),t.Bt=!0;const l=this.Me.ti().Gi().G(n.axisLabelColor||n.color);s.Z=l.Z;const o=n.axisLabelTextColor||l.J;t.D=o,i.D=o,s.Ai=a}er(t){const i=this.Me.Lt();return null===i?"":this.Me.Nt().Zi(t,i.Ht)}}class mt{constructor(t,i){this.Me=t,this.Ps=i,this.rr=new pt(t,this),this.Nn=new vt(t,this),this.hr=new nt(this.Nn,t,t.ti())}ar(t){_(this.Ps,t),this.kt(),this.Me.ti().lr()}W(){return this.Ps}_r(){return this.rr}cr(){return this.hr}ur(){return this.Nn}kt(){this.rr.kt(),this.Nn.kt()}nr(){const t=this.Me,i=t.Nt();if(t.ti().It().Xi()||i.Xi())return null;const s=t.Lt();return null===s?null:i.Wt(this.Ps.price,s.Ht)}}class gt extends U{constructor(t){super(),this.ss=t}ti(){return this.ss}}const wt={Bar:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=a(t(s,n)),o=l(h.Ht[0])<=l(h.Ht[3]);return{dr:h.D??(o?e:r)}},Candlestick:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,c=i.wickDownColor,u=a(t(s,n)),d=l(u.Ht[0])<=l(u.Ht[3]);return{dr:u.D??(d?e:r),pr:u.Ut??(d?h:o),vr:u.mr??(d?_:c)}},Custom:(t,i,s,n)=>({dr:a(t(s,n)).D??i.color}),Area:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.gt??i.lineColor,gt:e.gt??i.lineColor,gr:e.gr??i.topColor,wr:e.wr??i.bottomColor}},Baseline:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.Ht[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,Mr:e.Mr??i.topLineColor,br:e.br??i.bottomLineColor,Sr:e.Sr??i.topFillColor1,yr:e.yr??i.topFillColor2,Cr:e.Cr??i.bottomFillColor1,Pr:e.Pr??i.bottomFillColor2}},Line:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.D??i.color,gt:e.D??i.color}},Histogram:(t,i,s,n)=>({dr:a(t(s,n)).D??i.color})};class Mt{constructor(t){this.kr=(t,i)=>void 0!==i?i.Ht:this.Me.Gs().Tr(t),this.Me=t,this.Rr=wt[t.Dr()]}Er(t,i){return this.Rr(this.kr,this.Me.W(),t,i)}}function bt(t,i,s,n,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;n(i[a],s)===t?(e=a+1,h-=r+1):h=r}return e}const St=bt.bind(null,!0),xt=bt.bind(null,!1);var yt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(yt||(yt={}));const Ct=30;class Pt{constructor(){this.Br=[],this.Vr=new Map,this.Ar=new Map,this.Ir=[]}zr(){return this.Lr()>0?this.Br[this.Br.length-1]:null}Or(){return this.Lr()>0?this.Fr(0):null}Xs(){return this.Lr()>0?this.Fr(this.Br.length-1):null}Lr(){return this.Br.length}Xi(){return 0===this.Lr()}Re(t){return null!==this.Wr(t,0)}Tr(t){return this.Nr(t)}Nr(t,i=0){const s=this.Wr(t,i);return null===s?null:{...this.Hr(s),De:this.Fr(s)}}Ur(){return this.Br}$r(t,i,s){if(this.Xi())return null;let n=null;for(const e of s){n=kt(n,this.jr(t,i,e))}return n}lt(t){this.Ar.clear(),this.Vr.clear(),this.Br=t,this.Ir=t.map(t=>t.De)}qr(){return this.Ir}Fr(t){return this.Br[t].De}Hr(t){return this.Br[t]}Wr(t,i){const s=this.Yr(t);if(null===s&&0!==i)switch(i){case-1:return this.Kr(t);case 1:return this.Xr(t);default:throw new TypeError("Unknown search mode")}return s}Kr(t){let i=this.Gr(t);return i>0&&(i-=1),i!==this.Br.length&&this.Fr(i)<t?i:null}Xr(t){const i=this.Zr(t);return i!==this.Br.length&&t<this.Fr(i)?i:null}Yr(t){const i=this.Gr(t);return i===this.Br.length||t<this.Br[i].De?null:i}Gr(t){return St(this.Br,t,(t,i)=>t.De<i)}Zr(t){return xt(this.Br,t,(t,i)=>t.De>i)}Jr(t,i,s){let n=null;for(let e=t;e<i;e++){const t=this.Br[e].Ht[s];Number.isNaN(t)||(null===n?n={Qr:t,th:t}:(t<n.Qr&&(n.Qr=t),t>n.th&&(n.th=t)))}return n}jr(t,i,s){if(this.Xi())return null;let n=null;const e=a(this.Or()),r=a(this.Xs()),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.Gr(h),e=this.Zr(Math.min(l,o,i));n=kt(n,this.Jr(t,e,s))}let c=this.Vr.get(s);void 0===c&&(c=new Map,this.Vr.set(s,c));for(let t=Math.max(o+1,h);t<_;t+=Ct){const i=Math.floor(t/Ct);let e=c.get(i);if(void 0===e){const t=this.Gr(i*Ct),n=this.Zr((i+1)*Ct-1);e=this.Jr(t,n,s),c.set(i,e)}n=kt(n,e)}{const t=this.Gr(_),i=this.Zr(l);n=kt(n,this.Jr(t,i,s))}return n}}function kt(t,i){if(null===t)return i;if(null===i)return t;return{Qr:Math.min(t.Qr,i.Qr),th:Math.max(t.th,i.th)}}const Tt={setLineStyle:n};class Rt{constructor(t){this.ih=t}et(t,i,s){this.ih.draw(t,Tt)}sh(t,i,s){this.ih.drawBackground?.(t,Tt)}}class Dt{constructor(t){this.En=null,this.nh=t}Rt(){const t=this.nh.renderer();if(null===t)return null;if(this.En?.eh===t)return this.En.rh;const i=new Rt(t);return this.En={eh:t,rh:i},i}hh(){return this.nh.zOrder?.()??"normal"}}class Et{constructor(t){this.ah=null,this.oh=t}_h(){return this.oh}Ws(){this.oh.updateAllViews?.()}Ns(){const t=this.oh.paneViews?.()??[];if(this.ah?.eh===t)return this.ah.rh;const i=t.map(t=>new Dt(t));return this.ah={eh:t,rh:i},i}Kn(t,i){return this.oh.hitTest?.(t,i)??null}}let Bt=class extends Et{us(){return[]}};class Vt{constructor(t){this.ih=t}et(t,i,s){this.ih.draw(t,Tt)}sh(t,i,s){this.ih.drawBackground?.(t,Tt)}}class At{constructor(t){this.En=null,this.nh=t}Rt(){const t=this.nh.renderer();if(null===t)return null;if(this.En?.eh===t)return this.En.rh;const i=new Vt(t);return this.En={eh:t,rh:i},i}hh(){return this.nh.zOrder?.()??"normal"}}function It(t){return{hi:t.text(),Ai:t.coordinate(),Vi:t.fixedCoordinate?.(),D:t.textColor(),Z:t.backColor(),Bt:t.visible?.()??!0,mi:t.tickVisible?.()??!0}}class zt{constructor(t,i){this.Jt=new N,this.uh=t,this.dh=i}Rt(){return this.Jt.lt({ts:this.dh.ts(),...It(this.uh)}),this.Jt}}class Lt extends O{constructor(t,i){super(),this.uh=t,this.Yi=i}qi(t,i,s){const n=It(this.uh);s.Z=n.Z,t.D=n.D;const e=2/12*this.Yi.P();s.Ri=e,s.Di=e,s.Ai=n.Ai,s.Vi=n.Vi,t.hi=n.hi,t.Bt=n.Bt,t.mi=n.mi}}class Ot extends Et{constructor(t,i){super(t),this.fh=null,this.ph=null,this.mh=null,this.gh=null,this.Me=i}ds(){const t=this.oh.timeAxisViews?.()??[];if(this.fh?.eh===t)return this.fh.rh;const i=this.Me.ti().It(),s=t.map(t=>new zt(t,i));return this.fh={eh:t,rh:s},s}Hs(){const t=this.oh.priceAxisViews?.()??[];if(this.ph?.eh===t)return this.ph.rh;const i=this.Me.Nt(),s=t.map(t=>new Lt(t,i));return this.ph={eh:t,rh:s},s}wh(){const t=this.oh.priceAxisPaneViews?.()??[];if(this.mh?.eh===t)return this.mh.rh;const i=t.map(t=>new At(t));return this.mh={eh:t,rh:i},i}Mh(){const t=this.oh.timeAxisPaneViews?.()??[];if(this.gh?.eh===t)return this.gh.rh;const i=t.map(t=>new At(t));return this.gh={eh:t,rh:i},i}bh(t,i){return this.oh.autoscaleInfo?.(t,i)??null}}function Ft(t,i,s,n){t.forEach(t=>{i(t).forEach(t=>{t.hh()===s&&n.push(t)})})}function Wt(t){return t.Ns()}function Nt(t){return t.wh()}function Ht(t){return t.Mh()}const Ut=["Area","Line","Baseline"];class $t extends gt{constructor(t,i,s,n,e){super(t),this.Yt=new Pt,this.rr=new _t(this),this.Sh=[],this.xh=new ht(this),this.yh=null,this.Ch=null,this.Ph=null,this.kh=[],this.Ps=s,this.Th=i;const r=new ct(this);this.gs=[r],this.hr=new nt(r,this,t),Ut.includes(this.Th)&&(this.yh=new ot(this)),this.Rh(),this.nh=n(this,this.ti(),e)}m(){null!==this.Ph&&clearTimeout(this.Ph)}Ae(t){return this.Ps.priceLineColor||t}ke(t){const i={Te:!0},s=this.Nt();if(this.ti().It().Xi()||s.Xi()||this.Yt.Xi())return i;const n=this.ti().It().Pe(),e=this.Lt();if(null===n||null===e)return i;let r,h;if(t){const t=this.Yt.zr();if(null===t)return i;r=t,h=t.De}else{const t=this.Yt.Nr(n.Si(),-1);if(null===t)return i;if(r=this.Yt.Tr(t.De),null===r)return i;h=t.De}const a=r.Ht[3],l=this.Dh().Er(h,{Ht:r}),o=s.Wt(a,e.Ht);return{Te:!1,Mt:a,hi:s.Zi(a,e.Ht),Fe:s.Eh(a),We:s.Bh(a,e.Ht),D:l.dr,Ai:o,De:h}}Dh(){return null!==this.Ch||(this.Ch=new Mt(this)),this.Ch}W(){return this.Ps}ar(t){const i=t.priceScaleId;void 0!==i&&i!==this.Ps.priceScaleId&&this.ti().Vh(this,i),_(this.Ps,t),void 0!==t.priceFormat&&(this.Rh(),this.ti().Ah()),this.ti().Ih(this),this.ti().zh(),this.nh.kt("options")}lt(t,i){this.Yt.lt(t),this.nh.kt("data"),null!==this.yh&&(i&&i.Lh?this.yh.Se():0===t.length&&this.yh.be());const s=this.ti().Un(this);this.ti().Oh(s),this.ti().Ih(this),this.ti().zh(),this.ti().lr()}Fh(t){const i=new mt(this,t);return this.Sh.push(i),this.ti().Ih(this),i}Wh(t){const i=this.Sh.indexOf(t);-1!==i&&this.Sh.splice(i,1),this.ti().Ih(this)}Nh(){return this.Sh}Dr(){return this.Th}Lt(){const t=this.Hh();return null===t?null:{Ht:t.Ht[3],Uh:t.wt}}Hh(){const t=this.ti().It().Pe();if(null===t)return null;const i=t.$h();return this.Yt.Nr(i,1)}Gs(){return this.Yt}jh(t){const i=this.Yt.Tr(t);return null===i?null:"Bar"===this.Th||"Candlestick"===this.Th||"Custom"===this.Th?{qh:i.Ht[0],Yh:i.Ht[1],Kh:i.Ht[2],Xh:i.Ht[3]}:i.Ht[3]}Gh(t){const i=[];Ft(this.kh,Wt,"top",i);const s=this.yh;return null!==s&&s.Bt()?(null===this.Ph&&s.ye()&&(this.Ph=setTimeout(()=>{this.Ph=null,this.ti().Zh()},0)),s.xe(),i.unshift(s),i):i}Ns(){const t=[];this.Jh()||t.push(this.xh),t.push(this.nh,this.rr);const i=this.Sh.map(t=>t._r());return t.push(...i),Ft(this.kh,Wt,"normal",t),t}Qh(){return this.ta(Wt,"bottom")}ia(t){return this.ta(Nt,t)}sa(t){return this.ta(Ht,t)}na(t,i){return this.kh.map(s=>s.Kn(t,i)).filter(t=>null!==t)}us(){return[this.hr,...this.Sh.map(t=>t.cr())]}Hs(t,i){if(i!==this.rs&&!this.Jh())return[];const s=[...this.gs];for(const t of this.Sh)s.push(t.ur());return this.kh.forEach(t=>{s.push(...t.Hs())}),s}ds(){const t=[];return this.kh.forEach(i=>{t.push(...i.ds())}),t}bh(t,i){if(void 0!==this.Ps.autoscaleInfoProvider){const s=this.Ps.autoscaleInfoProvider(()=>{const s=this.ea(t,i);return null===s?null:s.Ge()});return ft.Ze(s)}return this.ea(t,i)}eh(){const t=this.Ps.priceFormat;return t.base??1/t.minMove}ra(){return this.ha}Ws(){this.nh.kt();for(const t of this.gs)t.kt();for(const t of this.Sh)t.kt();this.rr.kt(),this.xh.kt(),this.yh?.kt(),this.kh.forEach(t=>t.Ws())}Nt(){return a(super.Nt())}zt(t){if(!(("Line"===this.Th||"Area"===this.Th||"Baseline"===this.Th)&&this.Ps.crosshairMarkerVisible))return null;const i=this.Yt.Tr(t);if(null===i)return null;return{Mt:i.Ht[3],vt:this.aa(),Ut:this.la(),Ft:this.oa(),Ot:this._a(t)}}Ie(){return this.Ps.title}Bt(){return this.Ps.visible}ca(t){this.kh.push(new Ot(t,this))}ua(t){this.kh=this.kh.filter(i=>i._h()!==t)}da(){if("Custom"===this.Th)return t=>this.nh.fa(t)}pa(){if("Custom"===this.Th)return t=>this.nh.va(t)}ma(){return this.Yt.qr()}Jh(){return!q(this.Nt().ga())}ea(t,i){if(!u(t)||!u(i)||this.Yt.Xi())return null;const s="Line"===this.Th||"Area"===this.Th||"Baseline"===this.Th||"Histogram"===this.Th?[3]:[2,1],n=this.Yt.$r(t,i,s);let e=null!==n?new dt(n.Qr,n.th):null,r=null;if("Histogram"===this.Dr()){const t=this.Ps.base,i=new dt(t,t);e=null!==e?e.mn(i):i}return this.kh.forEach(s=>{const n=s.bh(t,i);if(n?.priceRange){const t=new dt(n.priceRange.minValue,n.priceRange.maxValue);e=null!==e?e.mn(t):t}n?.margins&&(r=n.margins)}),new ft(e,r)}aa(){switch(this.Th){case"Line":case"Area":case"Baseline":return this.Ps.crosshairMarkerRadius}return 0}la(){switch(this.Th){case"Line":case"Area":case"Baseline":{const t=this.Ps.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}oa(){switch(this.Th){case"Line":case"Area":case"Baseline":return this.Ps.crosshairMarkerBorderWidth}return 0}_a(t){switch(this.Th){case"Line":case"Area":case"Baseline":{const t=this.Ps.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Dh().Er(t).dr}Rh(){switch(this.Ps.priceFormat.type){case"custom":{const t=this.Ps.priceFormat.formatter;this.ha={format:t,formatTickmarks:this.Ps.priceFormat.tickmarksFormatter??(i=>i.map(t))};break}case"volume":this.ha=new Q(this.Ps.priceFormat.precision);break;case"percent":this.ha=new J(this.Ps.priceFormat.precision);break;default:{const t=Math.pow(10,this.Ps.priceFormat.precision);this.ha=new Z(t,this.Ps.priceFormat.minMove*t)}}null!==this.rs&&this.rs.wa()}ta(t,i){const s=[];return Ft(this.kh,t,i,s),s}}const jt=[3],qt=[0,1,2,3];class Yt{constructor(t){this.Ps=t}Ma(t,i,s){let n=t;if(0===this.Ps.mode)return n;const e=s.Ts(),r=e.Lt();if(null===r)return n;const h=e.Wt(t,r),a=s.ba().filter(t=>t instanceof $t).reduce((t,n)=>{if(s.$n(n)||!n.Bt())return t;const e=n.Nt(),r=n.Gs();if(e.Xi()||!r.Re(i))return t;const h=r.Tr(i);if(null===h)return t;const a=l(n.Lt()),o=3===this.Ps.mode?qt:jt;return t.concat(o.map(t=>e.Wt(h.Ht[t],a.Ht)))},[]);if(0===a.length)return n;a.sort((t,i)=>Math.abs(t-h)-Math.abs(i-h));const o=a[0];return n=e.Rs(o,r),n}}function Kt(t,i,s){return Math.min(Math.max(t,i),s)}function Xt(t,i,s){return i-t<=s}function Gt(t){const i=Math.ceil(t);return i%2==0?i-1:i}class Zt extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,()=>{const h=a(this.Yt);if(h.Sa){t.strokeStyle=h.xa,n(t,h.ya),t.beginPath();for(const n of h.Ca){const e=Math.round(n.Pa*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.ka){t.strokeStyle=h.Ta,n(t,h.Ra),t.beginPath();for(const s of h.Da){const n=Math.round(s.Pa*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}})}}class Jt{constructor(t){this.Jt=new Zt,this.yt=!0,this.Pt=t}kt(){this.yt=!0}Rt(){if(this.yt){const t=this.Pt.ti().W().grid,i={ka:t.horzLines.visible,Sa:t.vertLines.visible,Ta:t.horzLines.color,xa:t.vertLines.color,Ra:t.horzLines.style,ya:t.vertLines.style,Da:this.Pt.Ts().Ea(),Ca:(this.Pt.ti().It().Ea()||[]).map(t=>({Pa:t.coord}))};this.Jt.lt(i),this.yt=!1}return this.Jt}}class Qt{constructor(t){this.nh=new Jt(t)}_r(){return this.nh}}const ti={Ba:4,Va:1e-4};function ii(t,i){const s=100*(t-i)/i;return i<0?-s:s}function si(t,i){const s=ii(t.je(),i),n=ii(t.qe(),i);return new dt(s,n)}function ni(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function ei(t,i){const s=ni(t.je(),i),n=ni(t.qe(),i);return new dt(s,n)}function ri(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.log10(s+i.Va)+i.Ba;return t<0?-n:n}function hi(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.Ba)-i.Va;return t<0?-n:n}function ai(t,i){if(null===t)return null;const s=ri(t.je(),i),n=ri(t.qe(),i);return new dt(s,n)}function li(t,i){if(null===t)return null;const s=hi(t.je(),i),n=hi(t.qe(),i);return new dt(s,n)}function oi(t){if(null===t)return ti;const i=Math.abs(t.qe()-t.je());if(i>=1||i<1e-15)return ti;const s=Math.ceil(Math.abs(Math.log10(i))),n=ti.Ba+s;return{Ba:n,Va:1/Math.pow(10,n)}}class _i{constructor(t,i){if(this.Aa=t,this.Ia=i,function(t){if(t<0)return!1;if(t>1e18)return!0;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")}}}La(t,i,s){const n=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.Ia[0];for(;;){const t=Xt(e,n,1e-14)&&e>n+1e-14,i=Xt(e,s*h,1e-14),a=Xt(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.Ia[++r%this.Ia.length]}if(e<=n+1e-14&&(e=n),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];Xt(e,s*h,1e-14)&&e>n+1e-14;)e/=h,h=this.za[++r%this.za.length];var a,l,o;return e}}class ci{constructor(t,i,s,n){this.Oa=[],this.Yi=t,this.Aa=i,this.Fa=s,this.Wa=n}La(t,i){if(t<i)throw new Error("high < low");const s=this.Yi.jt(),n=(t-i)*this.Na()/s,e=new _i(this.Aa,[2,2.5,2]),r=new _i(this.Aa,[2,2,2.5]),h=new _i(this.Aa,[2.5,2,2]),a=[];return a.push(e.La(t,i,n),r.La(t,i,n),h.La(t,i,n)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let s=1;s<t.length;++s)t[s]<i&&(i=t[s]);return i}(a)}Ha(){const t=this.Yi,i=t.Lt();if(null===i)return void(this.Oa=[]);const s=t.jt(),n=this.Fa(s-1,i),e=this.Fa(0,i),r=this.Yi.W().entireTextOnly?this.Ua()/2:0,h=r,a=s-1-r,l=Math.max(n,e),o=Math.min(n,e);if(l===o)return void(this.Oa=[]);const _=this.La(l,o);if(this.$a(i,_,l,o,h,a),t.ja()&&this.qa(_,o,l)){const t=this.Yi.Ya();this.Ka(i,_,h,a,t,2*t)}const c=this.Oa.map(t=>t.Xa),u=this.Yi.Ga(c);for(let t=0;t<this.Oa.length;t++)this.Oa[t].Za=u[t]}Ea(){return this.Oa}Ua(){return this.Yi.P()}Na(){return Math.ceil(2.5*this.Ua())}$a(t,i,s,n,e,r){const h=this.Oa,a=this.Yi;let l=s%i;l+=l<0?i:0;const o=s>=n?1:-1;let _=null,c=0;for(let u=s-l;u>n;u-=i){const s=this.Wa(u,t,!0);null!==_&&Math.abs(s-_)<this.Na()||(s<e||s>r||(c<h.length?(h[c].Pa=s,h[c].Za=a.Ja(u),h[c].Xa=u):h.push({Pa:s,Za:a.Ja(u),Xa:u}),c++,_=s,a.Qa()&&(i=this.La(u*o,n))))}h.length=c}Ka(t,i,s,n,e,r){const h=this.Oa,a=this.tl(t,s,e,r),l=this.tl(t,n,-r,-e),o=this.Wa(0,t,!0)-this.Wa(i,t,!0);h.length>0&&h[0].Pa-a.Pa<o/2&&h.shift(),h.length>0&&l.Pa-h[h.length-1].Pa<o/2&&h.pop(),h.unshift(a),h.push(l)}tl(t,i,s,n){const e=(s+n)/2,r=this.Fa(i+s,t),h=this.Fa(i+n,t),a=Math.min(r,h),l=Math.max(r,h),o=Math.max(.1,this.La(l,a)),_=this.Fa(i+e,t),c=_-_%o,u=this.Wa(c,t,!0);return{Za:this.Yi.Ja(c),Pa:u,Xa:c}}qa(t,i,s){let n=l(this.Yi.tr());return this.Yi.Qa()&&(n=li(n,this.Yi.il())),n.je()-i<t&&s-n.qe()<t}}function ui(t){return t.slice().sort((t,i)=>a(t.ls())-a(i.ls()))}var di;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(di||(di={}));const fi=new J,pi=new Z(100,1);class vi{constructor(t,i,s,n,e){this.sl=0,this.nl=null,this.Je=null,this.el=null,this.rl={hl:!1,al:null},this.ll=!1,this.ol=0,this._l=0,this.cl=new o,this.ul=new o,this.dl=[],this.fl=null,this.pl=null,this.vl=null,this.ml=null,this.gl=null,this.ha=pi,this.wl=oi(null),this.Ml=t,this.Ps=i,this.bl=s,this.Sl=n,this.xl=e,this.yl=new ci(this,100,this.Cl.bind(this),this.Pl.bind(this))}ga(){return this.Ml}W(){return this.Ps}ar(t){if(_(this.Ps,t),this.wa(),void 0!==t.mode&&this.kl({se:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.Tl(),this.vl=null}}Rl(){return this.Ps.autoScale}Dl(){return this.ll}Qa(){return 1===this.Ps.mode}Oe(){return 2===this.Ps.mode}El(){return 3===this.Ps.mode}il(){return this.wl}se(){return{nn:this.Ps.autoScale,Bl:this.Ps.invertScale,se:this.Ps.mode}}kl(t){const i=this.se();let s=null;void 0!==t.nn&&(this.Ps.autoScale=t.nn),void 0!==t.se&&(this.Ps.mode=t.se,2!==t.se&&3!==t.se||(this.Ps.autoScale=!0),this.rl.hl=!1),1===i.se&&t.se!==i.se&&(!function(t,i){if(null===t)return!1;const s=hi(t.je(),i),n=hi(t.qe(),i);return isFinite(s)&&isFinite(n)}(this.Je,this.wl)?this.Ps.autoScale=!0:(s=li(this.Je,this.wl),null!==s&&this.Vl(s))),1===t.se&&t.se!==i.se&&(s=ai(this.Je,this.wl),null!==s&&this.Vl(s));const n=i.se!==this.Ps.mode;n&&(2===i.se||this.Oe())&&this.wa(),n&&(3===i.se||this.El())&&this.wa(),void 0!==t.Bl&&i.Bl!==t.Bl&&(this.Ps.invertScale=t.Bl,this.Al()),this.ul.p(i,this.se())}Il(){return this.ul}P(){return this.bl.fontSize}jt(){return this.sl}zl(t){this.sl!==t&&(this.sl=t,this.Tl(),this.vl=null)}Ll(){if(this.nl)return this.nl;const t=this.jt()-this.Ol()-this.Fl();return this.nl=t,t}tr(){return this.Wl(),this.Je}Vl(t,i){const s=this.Je;(i||null===s&&null!==t||null!==s&&!s.Ue(t))&&(this.vl=null,this.Je=t)}Nl(t){this.Vl(t),this.Hl(null!==t)}Xi(){return this.Wl(),0===this.sl||!this.Je||this.Je.Xi()}Ul(t){return this.Bl()?t:this.jt()-1-t}Wt(t,i){return this.Oe()?t=ii(t,i):this.El()&&(t=ni(t,i)),this.Pl(t,i)}$l(t,i,s){this.Wl();const n=this.Fl(),e=a(this.tr()),r=e.je(),h=e.qe(),l=this.Ll()-1,o=this.Bl(),_=l/(h-r),c=void 0===s?0:s.from,u=void 0===s?t.length:s.to,d=this.jl();for(let s=c;s<u;s++){const e=t[s],h=e.Mt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.Mt,i));const l=n+_*(a-r),c=o?l:this.sl-1-l;e.ut=c}}ql(t,i,s){this.Wl();const n=this.Fl(),e=a(this.tr()),r=e.je(),h=e.qe(),l=this.Ll()-1,o=this.Bl(),_=l/(h-r),c=void 0===s?0:s.from,u=void 0===s?t.length:s.to,d=this.jl();for(let s=c;s<u;s++){const e=t[s];let h=e.qh,a=e.Yh,l=e.Kh,c=e.Xh;null!==d&&(h=d(e.qh,i),a=d(e.Yh,i),l=d(e.Kh,i),c=d(e.Xh,i));let u=n+_*(h-r),f=o?u:this.sl-1-u;e.Yl=f,u=n+_*(a-r),f=o?u:this.sl-1-u,e.Kl=f,u=n+_*(l-r),f=o?u:this.sl-1-u,e.Xl=f,u=n+_*(c-r),f=o?u:this.sl-1-u,e.Gl=f}}Rs(t,i){const s=this.Cl(t,i);return this.Zl(s,i)}Zl(t,i){let s=t;return this.Oe()?s=function(t,i){return i<0&&(t=-t),t/100*i+i}(s,i):this.El()&&(s=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(s,i)),s}ba(){return this.dl}Et(){return this.pl||(this.pl=ui(this.dl)),this.pl}Jl(t){-1===this.dl.indexOf(t)&&(this.dl.push(t),this.wa(),this.Ql())}io(t){const i=this.dl.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.dl.splice(i,1),0===this.dl.length&&(this.kl({nn:!0}),this.Vl(null)),this.wa(),this.Ql()}Lt(){let t=null;for(const i of this.dl){const s=i.Lt();null!==s&&((null===t||s.Uh<t.Uh)&&(t=s))}return null===t?null:t.Ht}Bl(){return this.Ps.invertScale}Ea(){const t=null===this.Lt();if(null!==this.vl&&(t||this.vl.so===t))return this.vl.Ea;this.yl.Ha();const i=this.yl.Ea();return this.vl={Ea:i,so:t},this.cl.p(),i}no(){return this.cl}eo(t){this.Oe()||this.El()||null===this.ml&&null===this.el&&(this.Xi()||(this.ml=this.sl-t,this.el=a(this.tr()).$e()))}ro(t){if(this.Oe()||this.El())return;if(null===this.ml)return;this.kl({nn:!1}),(t=this.sl-t)<0&&(t=0);let i=(this.ml+.2*(this.sl-1))/(t+.2*(this.sl-1));const s=a(this.el).$e();i=Math.max(i,.1),s.Ke(i),this.Vl(s)}ho(){this.Oe()||this.El()||(this.ml=null,this.el=null)}ao(t){this.Rl()||null===this.gl&&null===this.el&&(this.Xi()||(this.gl=t,this.el=a(this.tr()).$e()))}lo(t){if(this.Rl())return;if(null===this.gl)return;const i=a(this.tr()).Ye()/(this.Ll()-1);let s=t-this.gl;this.Bl()&&(s*=-1);const n=s*i,e=a(this.el).$e();e.Xe(n),this.Vl(e,!0),this.vl=null}oo(){this.Rl()||null!==this.gl&&(this.gl=null,this.el=null)}ra(){return this.ha||this.wa(),this.ha}Zi(t,i){switch(this.Ps.mode){case 2:return this._o(ii(t,i));case 3:return this.ra().format(ni(t,i));default:return this.er(t)}}Ja(t){switch(this.Ps.mode){case 2:return this._o(t);case 3:return this.ra().format(t);default:return this.er(t)}}Ga(t){switch(this.Ps.mode){case 2:return this.co(t);case 3:return this.ra().formatTickmarks(t);default:return this.uo(t)}}Eh(t){return this.er(t,a(this.fl).ra())}Bh(t,i){return t=ii(t,i),this._o(t,fi)}do(){return this.dl}fo(t){this.rl={al:t,hl:!1}}Ws(){this.dl.forEach(t=>t.Ws())}ja(){return this.Ps.ensureEdgeTickMarksVisible&&this.Rl()}Ya(){return this.P()/2}wa(){this.vl=null;let t=1/0;this.fl=null;for(const i of this.dl)i.ls()<t&&(t=i.ls(),this.fl=i);let i=100;null!==this.fl&&(i=Math.round(this.fl.eh())),this.ha=pi,this.Oe()?(this.ha=fi,i=100):this.El()?(this.ha=new Z(100,1),i=100):null!==this.fl&&(this.ha=this.fl.ra()),this.yl=new ci(this,i,this.Cl.bind(this),this.Pl.bind(this)),this.yl.Ha()}Ql(){this.pl=null}po(){return null===this.fl||this.Oe()||this.El()?1:1/this.fl.eh()}Gi(){return this.xl}Hl(t){this.ll=t}Ol(){return this.Bl()?this.Ps.scaleMargins.bottom*this.jt()+this._l:this.Ps.scaleMargins.top*this.jt()+this.ol}Fl(){return this.Bl()?this.Ps.scaleMargins.top*this.jt()+this.ol:this.Ps.scaleMargins.bottom*this.jt()+this._l}Wl(){this.rl.hl||(this.rl.hl=!0,this.vo())}Tl(){this.nl=null}Pl(t,i){if(this.Wl(),this.Xi())return 0;t=this.Qa()&&t?ri(t,this.wl):t;const s=a(this.tr()),n=this.Fl()+(this.Ll()-1)*(t-s.je())/s.Ye();return this.Ul(n)}Cl(t,i){if(this.Wl(),this.Xi())return 0;const s=this.Ul(t),n=a(this.tr()),e=n.je()+n.Ye()*((s-this.Fl())/(this.Ll()-1));return this.Qa()?hi(e,this.wl):e}Al(){this.vl=null,this.yl.Ha()}vo(){if(this.Dl()&&!this.Rl())return;const t=this.rl.al;if(null===t)return;let i=null;const s=this.do();let n=0,e=0;for(const r of s){if(!r.Bt())continue;const s=r.Lt();if(null===s)continue;const h=r.bh(t.$h(),t.Si());let l=h&&h.tr();if(null!==l){switch(this.Ps.mode){case 1:l=ai(l,this.wl);break;case 2:l=si(l,s.Ht);break;case 3:l=ei(l,s.Ht)}if(i=null===i?l:i.mn(a(l)),null!==h){const t=h.ir();null!==t&&(n=Math.max(n,t.above),e=Math.max(e,t.below))}}}if(this.ja()&&(n=Math.max(n,this.Ya()),e=Math.max(e,this.Ya())),n===this.ol&&e===this._l||(this.ol=n,this._l=e,this.vl=null,this.Tl()),null!==i){if(i.je()===i.qe()){const t=5*this.po();this.Qa()&&(i=li(i,this.wl)),i=new dt(i.je()-t,i.qe()+t),this.Qa()&&(i=ai(i,this.wl))}if(this.Qa()){const t=li(i,this.wl),s=oi(t);if(r=s,h=this.wl,r.Ba!==h.Ba||r.Va!==h.Va){const n=null!==this.el?li(this.el,this.wl):null;this.wl=s,i=ai(t,s),null!==n&&(this.el=ai(n,s))}}this.Vl(i)}else null===this.Je&&(this.Vl(new dt(-.5,.5)),this.wl=oi(null));var r,h}jl(){return this.Oe()?ii:this.El()?ni:this.Qa()?t=>ri(t,this.wl):null}mo(t,i,s){return void 0===i?(void 0===s&&(s=this.ra()),s.format(t)):i(t)}wo(t,i,s){return void 0===i?(void 0===s&&(s=this.ra()),s.formatTickmarks(t)):i(t)}er(t,i){return this.mo(t,this.Sl.priceFormatter,i)}uo(t,i){const s=this.Sl.priceFormatter;return this.wo(t,this.Sl.tickmarksPriceFormatter??(s?t=>t.map(s):void 0),i)}_o(t,i){return this.mo(t,this.Sl.percentageFormatter,i)}co(t,i){const s=this.Sl.percentageFormatter;return this.wo(t,this.Sl.tickmarksPercentageFormatter??(s?t=>t.map(s):void 0),i)}}function mi(t){return t instanceof $t}class gi{constructor(t,i){this.dl=[],this.Mo=new Map,this.sl=0,this.bo=0,this.So=1,this.pl=null,this.xo=!1,this.yo=new o,this.kh=[],this.dh=t,this.ss=i,this.Co=new Qt(this);const s=i.W();this.Po=this.ko("left",s.leftPriceScale),this.To=this.ko("right",s.rightPriceScale),this.Po.Il().i(this.Ro.bind(this,this.Po),this),this.To.Il().i(this.Ro.bind(this,this.To),this),this.Do(s)}Do(t){if(t.leftPriceScale&&this.Po.ar(t.leftPriceScale),t.rightPriceScale&&this.To.ar(t.rightPriceScale),t.localization&&(this.Po.wa(),this.To.wa()),t.overlayPriceScales){const i=Array.from(this.Mo.values());for(const s of i){const i=a(s[0].Nt());i.ar(t.overlayPriceScales),t.localization&&i.wa()}}}Eo(t){switch(t){case"left":return this.Po;case"right":return this.To}return this.Mo.has(t)?h(this.Mo.get(t))[0].Nt():null}m(){this.ti().Bo().u(this),this.Po.Il().u(this),this.To.Il().u(this),this.dl.forEach(t=>{t.m&&t.m()}),this.kh=this.kh.filter(t=>{const i=t._h();return i.detached&&i.detached(),!1}),this.yo.p()}Vo(){return this.So}Ao(t){this.So=t}ti(){return this.ss}ts(){return this.bo}jt(){return this.sl}Io(t){this.bo=t,this.zo()}zl(t){this.sl=t,this.Po.zl(t),this.To.zl(t),this.dl.forEach(i=>{if(this.$n(i)){const s=i.Nt();null!==s&&s.zl(t)}}),this.zo()}Lo(t){this.xo=t}Oo(){return this.xo}Fo(){return this.dl.filter(mi)}ba(){return this.dl}$n(t){const i=t.Nt();return null===i||this.Po!==i&&this.To!==i}Jl(t,i,s){this.Wo(t,i,s?t.ls():this.dl.length)}io(t,i){const s=this.dl.indexOf(t);r(-1!==s,"removeDataSource: invalid data source"),this.dl.splice(s,1),i||this.dl.forEach((t,i)=>t._s(i));const n=a(t.Nt()).ga();if(this.Mo.has(n)){const i=h(this.Mo.get(n)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.Mo.delete(n))}const e=t.Nt();e&&e.ba().indexOf(t)>=0&&(e.io(t),this.No(e)),this.pl=null}qn(t){return t===this.Po?"left":t===this.To?"right":"overlay"}Ho(){return this.Po}Uo(){return this.To}$o(t,i){t.eo(i)}jo(t,i){t.ro(i),this.zo()}qo(t){t.ho()}Yo(t,i){t.ao(i)}Ko(t,i){t.lo(i),this.zo()}Xo(t){t.oo()}zo(){this.dl.forEach(t=>{t.Ws()})}Ts(){let t=null;return this.ss.W().rightPriceScale.visible&&0!==this.To.ba().length?t=this.To:this.ss.W().leftPriceScale.visible&&0!==this.Po.ba().length?t=this.Po:0!==this.dl.length&&(t=this.dl[0].Nt()),null===t&&(t=this.To),t}jn(){let t=null;return this.ss.W().rightPriceScale.visible?t=this.To:this.ss.W().leftPriceScale.visible&&(t=this.Po),t}No(t){null!==t&&t.Rl()&&this.Go(t)}Zo(t){const i=this.dh.Pe();t.kl({nn:!0}),null!==i&&t.fo(i),this.zo()}Jo(){this.Go(this.Po),this.Go(this.To)}Qo(){this.No(this.Po),this.No(this.To),this.dl.forEach(t=>{this.$n(t)&&this.No(t.Nt())}),this.zo(),this.ss.lr()}Et(){return null===this.pl&&(this.pl=ui(this.dl)),this.pl}t_(t,i){i=Kt(i,0,this.dl.length-1);const s=this.dl.indexOf(t);r(-1!==s,"setSeriesOrder: invalid data source"),this.dl.splice(s,1),this.dl.splice(i,0,t),this.dl.forEach((t,i)=>t._s(i)),this.pl=null;for(const t of[this.Po,this.To])t.Ql(),t.wa();this.ss.lr()}Vt(){return this.Et().filter(mi)}i_(){return this.yo}s_(){return this.Co}ca(t){this.kh.push(new Bt(t))}ua(t){this.kh=this.kh.filter(i=>i._h()!==t),t.detached&&t.detached(),this.ss.lr()}n_(){return this.kh}na(t,i){return this.kh.map(s=>s.Kn(t,i)).filter(t=>null!==t)}Go(t){const i=t.do();if(i&&i.length>0&&!this.dh.Xi()){const i=this.dh.Pe();null!==i&&t.fo(i)}t.Ws()}Wo(t,i,s){let n=this.Eo(i);if(null===n&&(n=this.ko(i,this.ss.W().overlayPriceScales)),this.dl.splice(s,0,t),!q(i)){const s=this.Mo.get(i)||[];s.push(t),this.Mo.set(i,s)}t._s(s),n.Jl(t),t.cs(n),this.No(n),this.pl=null}Ro(t,i,s){i.se!==s.se&&this.Go(t)}ko(t,i){const s={visible:!0,autoScale:!0,...p(i)},n=new vi(t,s,this.ss.W().layout,this.ss.W().localization,this.ss.Gi());return n.zl(this.jt()),n}}function wi(t,i){return!i||"top"===t&&"top"!==i||"normal"===t&&"bottom"===i}function Mi(t){return{e_:t.e_,r_:{Xn:t.h_.externalId},a_:t.h_.cursorStyle}}function bi(t,i,s,n){for(const e of t){const t=e.Rt(n);if(null!==t&&t.Kn){const n=t.Kn(i,s);if(null!==n)return{l_:e,r_:n}}}return null}function Si(t){return void 0!==t.Ns}function xi(t,i,s){const n=[t,...t.Et()],e=function(t,i,s){let n,e;for(const r of t){const t=r.na?.(i,s)??[];for(const i of t)wi(i.zOrder,n?.zOrder)&&(n=i,e=r)}return n&&e?{h_:n,e_:e}:null}(n,i,s);if("top"===e?.h_.zOrder)return Mi(e);for(const r of n){if(e&&e.e_===r&&"bottom"!==e.h_.zOrder&&!e.h_.isBackground)return Mi(e);if(Si(r)){const n=bi(r.Ns(t),i,s,t);if(null!==n)return{e_:r,l_:n.l_,r_:n.r_}}if(e&&e.e_===r&&"bottom"!==e.h_.zOrder&&e.h_.isBackground)return Mi(e)}return e?.h_?Mi(e):null}class yi{constructor(t,i,s=50){this.kn=0,this.Tn=1,this.Rn=1,this.En=new Map,this.Dn=new Map,this.o_=t,this.__=i,this.Bn=s}c_(t){const i=t.time,s=this.__.cacheKey(i),n=this.En.get(s);if(void 0!==n)return n.u_;if(this.kn===this.Bn){const t=this.Dn.get(this.Rn);this.Dn.delete(this.Rn),this.En.delete(h(t)),this.Rn++,this.kn--}const e=this.o_(t);return this.En.set(s,{u_:e,zn:this.Tn}),this.Dn.set(this.Tn,s),this.kn++,this.Tn++,e}}class Ci{constructor(t,i){r(t<=i,"right should be >= left"),this.d_=t,this.f_=i}$h(){return this.d_}Si(){return this.f_}p_(){return this.f_-this.d_+1}Re(t){return this.d_<=t&&t<=this.f_}Ue(t){return this.d_===t.$h()&&this.f_===t.Si()}}function Pi(t,i){return null===t||null===i?t===i:t.Ue(i)}class ki{constructor(){this.v_=new Map,this.En=null,this.m_=!1}g_(t){this.m_=t,this.En=null}w_(t,i){this.M_(i),this.En=null;for(let s=i;s<t.length;++s){const i=t[s];let n=this.v_.get(i.timeWeight);void 0===n&&(n=[],this.v_.set(i.timeWeight,n)),n.push({index:s,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}b_(t,i,s,n,e){const r=Math.ceil(i/t);return null!==this.En&&this.En.S_===r&&e===this.En.x_&&s===this.En.y_||(this.En={x_:e,y_:s,Ea:this.C_(r,s,n),S_:r}),this.En.Ea}M_(t){if(0===t)return void this.v_.clear();const i=[];this.v_.forEach((s,n)=>{t<=s[0].index?i.push(n):s.splice(St(s,t,i=>i.index<t),1/0)});for(const t of i)this.v_.delete(t)}C_(t,i,s){let n=[];const e=t=>!i||s.has(t.index);for(const i of Array.from(this.v_.keys()).sort((t,i)=>i-t)){if(!this.v_.get(i))continue;const s=n;n=[];const r=s.length;let a=0;const l=h(this.v_.get(i)),o=l.length;let _=1/0,c=-1/0;for(let i=0;i<o;i++){const h=l[i],o=h.index;for(;a<r;){const t=s[a],i=t.index;if(!(i<o&&e(t))){_=i;break}a++,n.push(t),c=i,_=1/0}if(_-o>=t&&o-c>=t&&e(h))n.push(h),c=o;else if(this.m_)return s}for(;a<r;a++)e(s[a])&&n.push(s[a])}return n}}class Ti{constructor(t){this.P_=t}k_(){return null===this.P_?null:new Ci(Math.floor(this.P_.$h()),Math.ceil(this.P_.Si()))}T_(){return this.P_}static R_(){return new Ti(null)}}function Ri(t,i){return t.weight>i.weight?t:i}class Di{constructor(t,i,s,n){this.bo=0,this.D_=null,this.E_=[],this.gl=null,this.ml=null,this.B_=new ki,this.V_=new Map,this.A_=Ti.R_(),this.I_=!0,this.z_=new o,this.L_=new o,this.O_=new o,this.F_=null,this.W_=null,this.N_=new Map,this.H_=-1,this.U_=[],this.Ps=i,this.Sl=s,this.j_=i.rightOffset,this.q_=i.barSpacing,this.ss=t,this.Y_(i),this.__=n,this.K_(),this.B_.g_(i.uniformDistribution),this.X_()}W(){return this.Ps}G_(t){_(this.Sl,t),this.Z_(),this.K_()}ar(t,i){_(this.Ps,t),this.Ps.fixLeftEdge&&this.J_(),this.Ps.fixRightEdge&&this.Q_(),void 0!==t.barSpacing&&this.ss.fn(t.barSpacing),void 0!==t.rightOffset&&this.ss.pn(t.rightOffset),this.Y_(t),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ss.fn(t.barSpacing??this.q_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.Ps.ignoreWhitespaceIndices&&this.X_(),this.Z_(),this.K_(),this.O_.p()}Ds(t){return this.E_[t]?.time??null}ns(t){return this.E_[t]??null}tc(t,i){if(this.E_.length<1)return null;if(this.__.key(t)>this.__.key(this.E_[this.E_.length-1].time))return i?this.E_.length-1:null;const s=St(this.E_,this.__.key(t),(t,i)=>this.__.key(t.time)<i);return this.__.key(t)<this.__.key(this.E_[s].time)?i?s:null:s}Xi(){return 0===this.bo||0===this.E_.length||null===this.D_}sc(){return this.E_.length>0}Pe(){return this.nc(),this.A_.k_()}ec(){return this.nc(),this.A_.T_()}rc(){const t=this.Pe();if(null===t)return null;const i={from:t.$h(),to:t.Si()};return this.hc(i)}hc(t){const i=Math.round(t.from),s=Math.round(t.to),n=a(this.ac()),e=a(this.lc());return{from:a(this.ns(Math.max(n,i))),to:a(this.ns(Math.min(e,s)))}}oc(t){return{from:a(this.tc(t.from,!0)),to:a(this.tc(t.to,!0))}}ts(){return this.bo}Io(t){if(!isFinite(t)||t<=0)return;if(this.bo===t)return;const i=this.ec(),s=this.bo;if(this.bo=t,this.I_=!0,this.Ps.lockVisibleTimeRangeOnResize&&0!==s){const i=this.q_*t/s;this.q_=i}if(this.Ps.fixLeftEdge&&null!==i&&i.$h()<=0){const i=s-t;this.j_-=Math.round(i/this.q_)+1,this.I_=!0}this._c(),this.cc()}qt(t){if(this.Xi()||!u(t))return 0;const i=this.uc()+this.j_-t;return this.bo-(i+.5)*this.q_-1}dc(t,i){const s=this.uc(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;i<e;i++){const n=t[i].wt,e=s+this.j_-n,r=this.bo-(e+.5)*this.q_-1;t[i].ct=r}}fc(t,i){const s=Math.ceil(this.vc(t));return i&&this.Ps.ignoreWhitespaceIndices&&!this.mc(s)?this.gc(s):s}pn(t){this.I_=!0,this.j_=t,this.cc(),this.ss.wc(),this.ss.lr()}Mc(){return this.q_}fn(t){const i=this.q_;if(this.bc(t),void 0!==this.Ps.rightOffsetPixels&&0!==i){const t=this.j_*i/this.q_;this.j_=t}this.cc(),this.ss.wc(),this.ss.lr()}Sc(){return this.j_}Ea(){if(this.Xi())return null;if(null!==this.W_)return this.W_;const t=this.q_,i=5*(this.ss.W().layout.fontSize+4)/8*(this.Ps.tickMarkMaxCharacterLength||8),s=Math.round(i/t),n=a(this.Pe()),e=Math.max(n.$h(),n.$h()-s),r=Math.max(n.Si(),n.Si()-s),h=this.B_.b_(t,i,this.Ps.ignoreWhitespaceIndices,this.N_,this.H_),l=this.ac()+s,o=this.lc()-s,_=this.xc(),c=this.Ps.fixLeftEdge||_,u=this.Ps.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.index&&t.index<=r))continue;let s;d<this.U_.length?(s=this.U_[d],s.coord=this.qt(t.index),s.label=this.yc(t),s.weight=t.weight):(s={needAlignCoordinate:!1,coord:this.qt(t.index),label:this.yc(t),weight:t.weight},this.U_.push(s)),this.q_>i/2&&!_?s.needAlignCoordinate=!1:s.needAlignCoordinate=c&&t.index<=l||u&&t.index>=o,d++}return this.U_.length=d,this.W_=this.U_,this.U_}Cc(){let t;this.I_=!0,this.fn(this.Ps.barSpacing),t=void 0!==this.Ps.rightOffsetPixels?this.Ps.rightOffsetPixels/this.Mc():this.Ps.rightOffset,this.pn(t)}Pc(t){this.I_=!0,this.D_=t,this.cc(),this.J_()}kc(t,i){const s=this.vc(t),n=this.Mc(),e=n+i*(n/10);this.fn(e),this.Ps.rightBarStaysOnScroll||this.pn(this.Sc()+(s-this.vc(t)))}eo(t){this.gl&&this.oo(),null===this.ml&&null===this.F_&&(this.Xi()||(this.ml=t,this.Tc()))}ro(t){if(null===this.F_)return;const i=Kt(this.bo-t,0,this.bo),s=Kt(this.bo-a(this.ml),0,this.bo);0!==i&&0!==s&&this.fn(this.F_.Mc*i/s)}ho(){null!==this.ml&&(this.ml=null,this.Rc())}ao(t){null===this.gl&&null===this.F_&&(this.Xi()||(this.gl=t,this.Tc()))}lo(t){if(null===this.gl)return;const i=(this.gl-t)/this.Mc();this.j_=a(this.F_).Sc+i,this.I_=!0,this.cc()}oo(){null!==this.gl&&(this.gl=null,this.Rc())}Dc(){this.Ec(this.Ps.rightOffset)}Ec(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.j_,n=performance.now();this.ss.cn({Bc:t=>(t-n)/i>=1,Vc:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}kt(t,i){this.I_=!0,this.E_=t,this.B_.w_(t,i),this.cc()}Ac(){return this.z_}Ic(){return this.L_}zc(){return this.O_}uc(){return this.D_||0}Lc(t,i){const s=t.p_(),n=i&&this.Ps.rightOffsetPixels||0;this.bc((this.bo-n)/s),this.j_=t.Si()-this.uc(),i&&(this.j_=n?n/this.Mc():this.Ps.rightOffset),this.cc(),this.I_=!0,this.ss.wc(),this.ss.lr()}Oc(){const t=this.ac(),i=this.lc();null!==t&&null!==i&&this.Lc(new Ci(t,i),!0)}Fc(t){const i=new Ci(t.from,t.to);this.Lc(i)}es(t){return void 0!==this.Sl.timeFormatter?this.Sl.timeFormatter(t.originalTime):this.__.formatHorzItem(t.time)}X_(){if(!this.Ps.ignoreWhitespaceIndices)return;this.N_.clear();const t=this.ss.Ks();for(const i of t)for(const t of i.ma())this.N_.set(t,!0);this.H_++}xc(){const t=this.ss.W().handleScroll,i=this.ss.W().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}ac(){return 0===this.E_.length?null:0}lc(){return 0===this.E_.length?null:this.E_.length-1}Wc(t){return(this.bo-1-t)/this.q_}vc(t){const i=this.Wc(t),s=this.uc()+this.j_-i;return Math.round(1e6*s)/1e6}bc(t){const i=this.q_;this.q_=t,this._c(),i!==this.q_&&(this.I_=!0,this.Nc())}nc(){if(!this.I_)return;if(this.I_=!1,this.Xi())return void this.Hc(Ti.R_());const t=this.uc(),i=this.bo/this.q_,s=this.j_+t,n=new Ci(s-i+1,s);this.Hc(new Ti(n))}_c(){const t=Kt(this.q_,this.Uc(),this.$c());this.q_!==t&&(this.q_=t,this.I_=!0)}$c(){return this.Ps.maxBarSpacing>0?this.Ps.maxBarSpacing:.5*this.bo}Uc(){return this.Ps.fixLeftEdge&&this.Ps.fixRightEdge&&0!==this.E_.length?this.bo/this.E_.length:this.Ps.minBarSpacing}cc(){const t=this.jc();null!==t&&this.j_<t&&(this.j_=t,this.I_=!0);const i=this.qc();this.j_>i&&(this.j_=i,this.I_=!0)}jc(){const t=this.ac(),i=this.D_;if(null===t||null===i)return null;return t-i-1+(this.Ps.fixLeftEdge?this.bo/this.q_:Math.min(2,this.E_.length))}qc(){return this.Ps.fixRightEdge?0:this.bo/this.q_-Math.min(2,this.E_.length)}Tc(){this.F_={Mc:this.Mc(),Sc:this.Sc()}}Rc(){this.F_=null}yc(t){let i=this.V_.get(t.weight);return void 0===i&&(i=new yi(t=>this.Yc(t),this.__),this.V_.set(t.weight,i)),i.c_(t)}Yc(t){return this.__.formatTickmark(t,this.Sl)}Hc(t){const i=this.A_;this.A_=t,Pi(i.k_(),this.A_.k_())||this.z_.p(),Pi(i.T_(),this.A_.T_())||this.L_.p(),this.Nc()}Nc(){this.W_=null}Z_(){this.Nc(),this.V_.clear()}K_(){this.__.updateFormatter(this.Sl)}J_(){if(!this.Ps.fixLeftEdge)return;const t=this.ac();if(null===t)return;const i=this.Pe();if(null===i)return;const s=i.$h()-t;if(s<0){const t=this.j_-s-1;this.pn(t)}this._c()}Q_(){this.cc(),this._c()}mc(t){return!this.Ps.ignoreWhitespaceIndices||(this.N_.get(t)||!1)}gc(t){const i=function*(t){const i=Math.round(t),s=i<t;let n=1;for(;;)s?(yield i+n,yield i-n):(yield i-n,yield i+n),n++}(t),s=this.lc();for(;s;){const t=i.next().value;if(this.N_.get(t))return t;if(t<0||t>s)break}return t}Y_(t){if(void 0!==t.rightOffsetPixels){const i=t.rightOffsetPixels/(t.barSpacing||this.q_);this.ss.pn(i)}}}var Ei,Bi,Vi,Ai,Ii;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ei||(Ei={}));class zi{constructor(t,i,s){this.Kc=[],this.Xc=[],this.bo=0,this.Gc=null,this.Zc=new o,this.Jc=new o,this.Qc=null,this.tu=t,this.Ps=i,this.__=s,this.xl=new x(this.Ps.layout.colorParsers),this.iu=new M(this),this.dh=new Di(this,i.timeScale,this.Ps.localization,s),this.Ct=new j(this,i.crosshair),this.su=new Yt(i.crosshair),i.addDefaultPane&&(this.nu(0),this.Kc[0].Ao(2)),this.eu=this.ru(0),this.hu=this.ru(1)}Ah(){this.au(Y.Mn())}lr(){this.au(Y.wn())}Zh(){this.au(new Y(1))}Ih(t){const i=this.lu(t);this.au(i)}ou(){return this.Gc}_u(t){if(this.Gc?.e_===t?.e_&&this.Gc?.r_?.Xn===t?.r_?.Xn)return;const i=this.Gc;this.Gc=t,null!==i&&this.Ih(i.e_),null!==t&&t.e_!==i?.e_&&this.Ih(t.e_)}W(){return this.Ps}ar(t){_(this.Ps,t),this.Kc.forEach(i=>i.Do(t)),void 0!==t.timeScale&&this.dh.ar(t.timeScale),void 0!==t.localization&&this.dh.G_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Zc.p(),this.eu=this.ru(0),this.hu=this.ru(1),this.Ah()}cu(t,i,s=0){const n=this.Kc[s];if(void 0===n)return;if("left"===t)return _(this.Ps,{leftPriceScale:i}),n.Do({leftPriceScale:i}),this.Zc.p(),void this.Ah();if("right"===t)return _(this.Ps,{rightPriceScale:i}),n.Do({rightPriceScale:i}),this.Zc.p(),void this.Ah();const e=this.uu(t,s);null!==e&&(e.Nt.ar(i),this.Zc.p())}uu(t,i){const s=this.Kc[i];if(void 0===s)return null;const n=s.Eo(t);return null!==n?{$s:s,Nt:n}:null}It(){return this.dh}js(){return this.Kc}du(){return this.Ct}fu(){return this.Jc}pu(t,i){t.zl(i),this.wc()}Io(t){this.bo=t,this.dh.Io(this.bo),this.Kc.forEach(i=>i.Io(t)),this.wc()}vu(t){1!==this.Kc.length&&(r(t>=0&&t<this.Kc.length,"Invalid pane index"),this.Kc.splice(t,1),this.Ah())}mu(t,i){if(this.Kc.length<2)return;r(t>=0&&t<this.Kc.length,"Invalid pane index");const s=this.Kc[t],n=this.Kc.reduce((t,i)=>t+i.Vo(),0),e=this.Kc.reduce((t,i)=>t+i.jt(),0),h=e-30*(this.Kc.length-1);i=Math.min(h,Math.max(30,i));const a=n/e,l=s.jt();s.Ao(i*a);let o=i-l,_=this.Kc.length-1;for(const t of this.Kc)if(t!==s){const i=Math.min(h,Math.max(30,t.jt()-o/_));o-=t.jt()-i,_-=1;const s=i*a;t.Ao(s)}this.Ah()}gu(t,i){r(t>=0&&t<this.Kc.length&&i>=0&&i<this.Kc.length,"Invalid pane index");const s=this.Kc[t],n=this.Kc[i];this.Kc[t]=n,this.Kc[i]=s,this.Ah()}wu(t,i){if(r(t>=0&&t<this.Kc.length&&i>=0&&i<this.Kc.length,"Invalid pane index"),t===i)return;const[s]=this.Kc.splice(t,1);this.Kc.splice(i,0,s),this.Ah()}$o(t,i,s){t.$o(i,s)}jo(t,i,s){t.jo(i,s),this.zh(),this.au(this.Mu(t,2))}qo(t,i){t.qo(i),this.au(this.Mu(t,2))}Yo(t,i,s){i.Rl()||t.Yo(i,s)}Ko(t,i,s){i.Rl()||(t.Ko(i,s),this.zh(),this.au(this.Mu(t,2)))}Xo(t,i){i.Rl()||(t.Xo(i),this.au(this.Mu(t,2)))}Zo(t,i){t.Zo(i),this.au(this.Mu(t,2))}bu(t){this.dh.eo(t)}Su(t,i){const s=this.It();if(s.Xi()||0===i)return;const n=s.ts();t=Math.max(1,Math.min(t,n)),s.kc(t,i),this.wc()}xu(t){this.yu(0),this.Cu(t),this.Pu()}ku(t){this.dh.ro(t),this.wc()}Tu(){this.dh.ho(),this.lr()}yu(t){this.dh.ao(t)}Cu(t){this.dh.lo(t),this.wc()}Pu(){this.dh.oo(),this.lr()}Ks(){return this.Xc}Ru(t,i,s,n,e){this.Ct.Bs(t,i);let r=NaN,h=this.dh.fc(t,!0);const a=this.dh.Pe();null!==a&&(h=Math.min(Math.max(a.$h(),h),a.Si()));const l=n.Ts(),o=l.Lt();if(null!==o&&(r=l.Rs(i,o)),r=this.su.Ma(r,h,n),this.Ct.zs(h,r,n),this.Zh(),!e){const e=xi(n,t,i);this._u(e&&{e_:e.e_,r_:e.r_,a_:e.a_||null}),this.Jc.p(this.Ct.At(),{x:t,y:i},s)}}Du(t,i,s){const n=s.Ts(),e=n.Lt(),r=n.Wt(t,a(e)),h=this.dh.tc(i,!0),l=this.dh.qt(a(h));this.Ru(l,r,null,s,!0)}Eu(t){this.du().Os(),this.Zh(),t||this.Jc.p(null,null,null)}zh(){const t=this.Ct.$s();if(null!==t){const i=this.Ct.As(),s=this.Ct.Is();this.Ru(i,s,null,t)}this.Ct.Ws()}Bu(t,i,s){const n=this.dh.Ds(0);void 0!==i&&void 0!==s&&this.dh.kt(i,s);const e=this.dh.Ds(0),r=this.dh.uc(),h=this.dh.Pe();if(null!==h&&null!==n&&null!==e){const i=h.Re(r),a=this.__.key(n)>this.__.key(e),l=null!==t&&t>r&&!a,o=this.dh.W().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===s)||o)&&this.dh.W().shiftVisibleRangeOnNewBar;if(l&&!_){const i=t-r;this.dh.pn(this.dh.Sc()-i)}}this.dh.Pc(t)}Oh(t){null!==t&&t.Qo()}Un(t){if(function(t){return t instanceof gi}(t))return t;const i=this.Kc.find(i=>i.Et().includes(t));return void 0===i?null:i}wc(){this.Kc.forEach(t=>t.Qo()),this.zh()}m(){this.Kc.forEach(t=>t.m()),this.Kc.length=0,this.Ps.localization.priceFormatter=void 0,this.Ps.localization.percentageFormatter=void 0,this.Ps.localization.timeFormatter=void 0}Vu(){return this.iu}Yn(){return this.iu.W()}Bo(){return this.Zc}Au(t,i){const s=this.nu(i);this.Iu(t,s),this.Xc.push(t),1===this.Xc.length?this.Ah():this.lr()}zu(t){const i=this.Un(t),s=this.Xc.indexOf(t);r(-1!==s,"Series not found");const n=a(i);this.Xc.splice(s,1),n.io(t),t.m&&t.m(),this.dh.X_();const e=this.Kc.length;this.Lu(n),this.Kc.length<e&&this.Ah()}Vh(t,i){const s=a(this.Un(t));s.io(t,!0),s.Jl(t,i,!0)}Oc(){const t=Y.wn();t.hn(),this.au(t)}Ou(t){const i=Y.wn();i._n(t),this.au(i)}dn(){const t=Y.wn();t.dn(),this.au(t)}fn(t){const i=Y.wn();i.fn(t),this.au(i)}pn(t){const i=Y.wn();i.pn(t),this.au(i)}cn(t){const i=Y.wn();i.cn(t),this.au(i)}an(){const t=Y.wn();t.an(),this.au(t)}Fu(){return this.Ps.rightPriceScale.visible?"right":"left"}Wu(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.Nu(t))return;const s=a(this.Un(t));s.io(t);const n=this.nu(i);this.Iu(t,n),0===s.ba().length&&this.Lu(s),this.Ah()}Hu(){return this.hu}j(){return this.eu}$t(t){const i=this.hu,s=this.eu;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Qc||this.Qc.gr!==s||this.Qc.wr!==i)this.Qc={gr:s,wr:i,Uu:new Map};else{const i=this.Qc.Uu.get(t);if(void 0!==i)return i}const n=this.xl.it(s,i,t/100);return this.Qc.Uu.set(t,n),n}$u(t){return this.Kc.indexOf(t)}Gi(){return this.xl}ju(){return this.qu()}qu(t){const i=new gi(this.dh,this);this.Kc.push(i);const s=t??this.Kc.length-1,n=Y.Mn();return n.tn(s,{sn:0,nn:!0}),this.au(n),i}nu(t){return r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.Kc.length,t))<this.Kc.length?this.Kc[t]:this.qu(t)}Nu(t){return this.Kc.findIndex(i=>i.Fo().includes(t))}Mu(t,i){const s=new Y(i);if(null!==t){const n=this.Kc.indexOf(t);s.tn(n,{sn:i})}return s}lu(t,i){return void 0===i&&(i=2),this.Mu(this.Un(t),i)}au(t){this.tu&&this.tu(t),this.Kc.forEach(t=>t.s_()._r().kt())}Iu(t,i){const s=t.W().priceScaleId,n=void 0!==s?s:this.Fu();i.Jl(t,n),q(n)||t.ar(t.W())}ru(t){const i=this.Ps.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}Lu(t){!t.Oo()&&0===t.ba().length&&this.Kc.length>1&&this.Kc.splice(this.$u(t),1)}}function Li(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}function Oi(t){return!c(t)&&!d(t)}function Fi(t){return c(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Bi||(Bi={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Vi||(Vi={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Ai||(Ai={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Ii||(Ii={}));const Wi=t=>t.getUTCFullYear();function Ni(t,i,s){return i.replace(/yyyy/g,(t=>G(Wi(t),4))(t)).replace(/yy/g,(t=>G(Wi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>G((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>G((t=>t.getUTCDate())(t),2))(t))}class Hi{constructor(t="yyyy-MM-dd",i="default"){this.Yu=t,this.Ku=i}c_(t){return Ni(t,this.Yu,this.Ku)}}class Ui{constructor(t){this.Xu=t||"%h:%m:%s"}c_(t){return this.Xu.replace("%h",G(t.getUTCHours(),2)).replace("%m",G(t.getUTCMinutes(),2)).replace("%s",G(t.getUTCSeconds(),2))}}const $i={Gu:"yyyy-MM-dd",Zu:"%h:%m:%s",Ju:" ",Qu:"default"};class ji{constructor(t={}){const i={...$i,...t};this.td=new Hi(i.Gu,i.Qu),this.sd=new Ui(i.Zu),this.nd=i.Ju}c_(t){return`${this.td.c_(t)}${this.nd}${this.sd.c_(t)}`}}function qi(t){return 60*t*60*1e3}function Yi(t){return 60*t*1e3}const Ki=[{ed:(Xi=1,1e3*Xi),rd:10},{ed:Yi(1),rd:20},{ed:Yi(5),rd:21},{ed:Yi(30),rd:22},{ed:qi(1),rd:30},{ed:qi(3),rd:31},{ed:qi(6),rd:32},{ed:qi(12),rd:33}];var Xi;function Gi(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=Ki.length-1;s>=0;--s)if(Math.floor(i.getTime()/Ki[s].ed)!==Math.floor(t.getTime()/Ki[s].ed))return Ki[s].rd;return 0}function Zi(t){return t}function Ji(t){let i=t;if(d(t)&&(i=ts(t)),!Oi(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{hd:Math.round(s.getTime()/1e3),ad:i}}function Qi(t){if(!Fi(t))throw new Error("time must be of type isUTCTimestamp");return{hd:t}}function ts(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function is(t){d(t.time)&&(t.time=ts(t.time))}class ss{options(){return this.Ps}setOptions(t){this.Ps=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(is)}(t):is(t)}createConverterToInternalObj(t){return a(function(t){return 0===t.length?null:Oi(t[0].time)||d(t[0].time)?Ji:Qi}(t))}key(t){return"object"==typeof t&&"hd"in t?t.hd:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.ad?new Date(1e3*i.hd).getTime():new Date(Date.UTC(i.ad.year,i.ad.month-1,i.ad.day)).getTime()}convertHorzItemToInternal(t){return Fi(i=t)?Qi(i):Oi(i)?Ji(i):Ji(ts(i));var i}updateFormatter(t){if(!this.Ps)return;const i=t.dateFormat;this.Ps.timeScale.timeVisible?this.ld=new ji({Gu:i,Zu:this.Ps.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Ju:" ",Qu:t.locale}):this.ld=new Hi(i,t.locale)}formatHorzItem(t){const i=t;return this.ld.c_(new Date(1e3*i.hd))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.Ps.timeScale.timeVisible,this.Ps.timeScale.secondsVisible),n=this.Ps.timeScale;if(void 0!==n.tickMarkFormatter){const e=n.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==e)return e}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.ad?new Date(1e3*t.hd):new Date(Date.UTC(t.ad.year,t.ad.month-1,t.ad.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Ri,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.hd,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*Zi(i.time).hd);null!==n&&(i.timeWeight=Gi(h,n)),e+=Zi(i.time).hd-(s||Zi(i.time).hd),s=Zi(i.time).hd,n=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0].time.hd-i));t[0].timeWeight=Gi(new Date(1e3*t[0].time.hd),s)}}(t,i)}static od(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function ns(t){var i=t.width,s=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(s<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:s}}function es(t,i){return t.width===i.width&&t.height===i.height}var rs=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){i._observers=i._observers.filter(function(t){return t!==s})}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(i){return i.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},t}();var hs=function(){function t(t,i,s){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=ns({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(n=null==s?void 0:s.allowResizeObserver)||void 0===n||n,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return ns({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=ns(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(i){return i!==t})},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(i){return i!==t})},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;es(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach(function(n){return n.call(s,t,i)})},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=ns(this._transformBitmapSize(t,this._canvasElementClientSize)),n=es(this.bitmapSize,s)?null:s;null===i&&null===n||null!==i&&null!==n&&es(i,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(i,n))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(n){return n.call(s,t,i)})},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise(function(t){var i=new ResizeObserver(function(s){t(s.every(function(t){return"devicePixelContentBoxSize"in t})),i.disconnect()});i.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1}).then(function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()}):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=as(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new rs(t)}(i),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=as(this._canvasElement);if(null!==s){var n=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return ns({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],n):ns({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver(function(i){var s=i.find(function(i){return i.target===t._canvasElement});if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var n=s.devicePixelContentBoxSize[0],e=ns({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(e)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function as(t){return t.ownerDocument.defaultView}var ls=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function os(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var n=t.bitmapSize;if(0===n.width||0===n.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new ls(e,s,n)}const _s="undefined"!=typeof window;function cs(){return!!_s&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function us(){return!!_s&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ds(t){return t+t%2}function fs(t){_s&&void 0!==window.chrome&&t.addEventListener("mousedown",t=>{if(1===t.button)return t.preventDefault(),!1})}class ps{constructor(t,i,s){this._d=0,this.ud=null,this.dd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.fd=0,this.pd=null,this.vd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.md=null,this.gd=!1,this.wd=null,this.Md=null,this.bd=!1,this.Sd=!1,this.xd=!1,this.yd=null,this.Cd=null,this.Pd=null,this.kd=null,this.Td=null,this.Rd=null,this.Dd=null,this.Ed=0,this.Bd=!1,this.Vd=!1,this.Ad=!1,this.Id=0,this.zd=null,this.Ld=!us(),this.Od=t=>{this.Fd(t)},this.Wd=t=>{if(this.Nd(t)){const i=this.Hd(t);if(++this.fd,this.pd&&this.fd>1){const{Ud:s}=this.$d(gs(t),this.vd);s<30&&!this.xd&&this.jd(i,this.Yd.qd),this.Kd()}}else{const i=this.Hd(t);if(++this._d,this.ud&&this._d>1){const{Ud:s}=this.$d(gs(t),this.dd);s<5&&!this.Sd&&this.Xd(i,this.Yd.Gd),this.Zd()}}},this.Jd=t,this.Yd=i,this.Ps=s,this.Qd()}m(){null!==this.yd&&(this.yd(),this.yd=null),null!==this.Cd&&(this.Cd(),this.Cd=null),null!==this.kd&&(this.kd(),this.kd=null),null!==this.Td&&(this.Td(),this.Td=null),null!==this.Rd&&(this.Rd(),this.Rd=null),null!==this.Pd&&(this.Pd(),this.Pd=null),this.tf(),this.Zd()}if(t){this.kd&&this.kd();const i=this.sf.bind(this);if(this.kd=()=>{this.Jd.removeEventListener("mousemove",i)},this.Jd.addEventListener("mousemove",i),this.Nd(t))return;const s=this.Hd(t);this.Xd(s,this.Yd.nf),this.Ld=!0}Zd(){null!==this.ud&&clearTimeout(this.ud),this._d=0,this.ud=null,this.dd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Kd(){null!==this.pd&&clearTimeout(this.pd),this.fd=0,this.pd=null,this.vd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}sf(t){if(this.Ad||null!==this.Md)return;if(this.Nd(t))return;const i=this.Hd(t);this.Xd(i,this.Yd.ef),this.Ld=!0}rf(t){const i=Ms(t.changedTouches,a(this.zd));if(null===i)return;if(this.Id=ws(t),null!==this.Dd)return;if(this.Vd)return;this.Bd=!0;const s=this.$d(gs(i),a(this.Md)),{hf:n,af:e,Ud:r}=s;if(this.bd||!(r<5)){if(!this.bd){const t=.5*n,i=e>=t&&!this.Ps.lf(),s=t>e&&!this.Ps._f();i||s||(this.Vd=!0),this.bd=!0,this.xd=!0,this.tf(),this.Kd()}if(!this.Vd){const s=this.Hd(t,i);this.jd(s,this.Yd.cf),ms(t)}}}uf(t){if(0!==t.button)return;const i=this.$d(gs(t),a(this.wd)),{Ud:s}=i;if(s>=5&&(this.Sd=!0,this.Zd()),this.Sd){const i=this.Hd(t);this.Xd(i,this.Yd.df)}}$d(t,i){const s=Math.abs(i.ct-t.ct),n=Math.abs(i.ut-t.ut);return{hf:s,af:n,Ud:s+n}}ff(t){let i=Ms(t.changedTouches,a(this.zd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.zd=null,this.Id=ws(t),this.tf(),this.Md=null,this.Rd&&(this.Rd(),this.Rd=null);const s=this.Hd(t,i);if(this.jd(s,this.Yd.pf),++this.fd,this.pd&&this.fd>1){const{Ud:t}=this.$d(gs(i),this.vd);t<30&&!this.xd&&this.jd(s,this.Yd.qd),this.Kd()}else this.xd||(this.jd(s,this.Yd.vf),this.Yd.vf&&ms(t));0===this.fd&&ms(t),0===t.touches.length&&this.gd&&(this.gd=!1,ms(t))}Fd(t){if(0!==t.button)return;const i=this.Hd(t);if(this.wd=null,this.Ad=!1,this.Td&&(this.Td(),this.Td=null),cs()){this.Jd.ownerDocument.documentElement.removeEventListener("mouseleave",this.Od)}if(!this.Nd(t))if(this.Xd(i,this.Yd.mf),++this._d,this.ud&&this._d>1){const{Ud:s}=this.$d(gs(t),this.dd);s<5&&!this.Sd&&this.Xd(i,this.Yd.Gd),this.Zd()}else this.Sd||this.Xd(i,this.Yd.gf)}tf(){null!==this.md&&(clearTimeout(this.md),this.md=null)}wf(t){if(null!==this.zd)return;const i=t.changedTouches[0];this.zd=i.identifier,this.Id=ws(t);const s=this.Jd.ownerDocument.documentElement;this.xd=!1,this.bd=!1,this.Vd=!1,this.Md=gs(i),this.Rd&&(this.Rd(),this.Rd=null);{const i=this.rf.bind(this),n=this.ff.bind(this);this.Rd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.tf(),this.md=setTimeout(this.Mf.bind(this,t),240)}const n=this.Hd(t,i);this.jd(n,this.Yd.bf),this.pd||(this.fd=0,this.pd=setTimeout(this.Kd.bind(this),500),this.vd=gs(i))}Sf(t){if(0!==t.button)return;const i=this.Jd.ownerDocument.documentElement;cs()&&i.addEventListener("mouseleave",this.Od),this.Sd=!1,this.wd=gs(t),this.Td&&(this.Td(),this.Td=null);{const t=this.uf.bind(this),s=this.Fd.bind(this);this.Td=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this.Ad=!0,this.Nd(t))return;const s=this.Hd(t);this.Xd(s,this.Yd.xf),this.ud||(this._d=0,this.ud=setTimeout(this.Zd.bind(this),500),this.dd=gs(t))}Qd(){this.Jd.addEventListener("mouseenter",this.if.bind(this)),this.Jd.addEventListener("touchcancel",this.tf.bind(this));{const t=this.Jd.ownerDocument,i=t=>{this.Yd.yf&&(t.composed&&this.Jd.contains(t.composedPath()[0])||t.target&&this.Jd.contains(t.target)||this.Yd.yf())};this.Cd=()=>{t.removeEventListener("touchstart",i)},this.yd=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}us()&&(this.Pd=()=>{this.Jd.removeEventListener("dblclick",this.Wd)},this.Jd.addEventListener("dblclick",this.Wd)),this.Jd.addEventListener("mouseleave",this.Cf.bind(this)),this.Jd.addEventListener("touchstart",this.wf.bind(this),{passive:!0}),fs(this.Jd),this.Jd.addEventListener("mousedown",this.Sf.bind(this)),this.Pf(),this.Jd.addEventListener("touchmove",()=>{},{passive:!1})}Pf(){void 0===this.Yd.kf&&void 0===this.Yd.Tf&&void 0===this.Yd.Rf||(this.Jd.addEventListener("touchstart",t=>this.Df(t.touches),{passive:!0}),this.Jd.addEventListener("touchmove",t=>{if(2===t.touches.length&&null!==this.Dd&&void 0!==this.Yd.Tf){const i=vs(t.touches[0],t.touches[1])/this.Ed;this.Yd.Tf(this.Dd,i),ms(t)}},{passive:!1}),this.Jd.addEventListener("touchend",t=>{this.Df(t.touches)}))}Df(t){1===t.length&&(this.Bd=!1),2!==t.length||this.Bd||this.gd?this.Ef():this.Bf(t)}Bf(t){const i=this.Jd.getBoundingClientRect()||{left:0,top:0};this.Dd={ct:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.Ed=vs(t[0],t[1]),void 0!==this.Yd.kf&&this.Yd.kf(),this.tf()}Ef(){null!==this.Dd&&(this.Dd=null,void 0!==this.Yd.Rf&&this.Yd.Rf())}Cf(t){if(this.kd&&this.kd(),this.Nd(t))return;if(!this.Ld)return;const i=this.Hd(t);this.Xd(i,this.Yd.Vf),this.Ld=!us()}Mf(t){const i=Ms(t.touches,a(this.zd));if(null===i)return;const s=this.Hd(t,i);this.jd(s,this.Yd.Af),this.xd=!0,this.gd=!0}Nd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:ws(t)<this.Id+500}jd(t,i){i&&i.call(this.Yd,t)}Xd(t,i){i&&i.call(this.Yd,t)}Hd(t,i){const s=i||t,n=this.Jd.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-n.left,localY:s.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,If:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,zf:t.type,Lf:s.target,l_:t.view,Of:()=>{"touchstart"!==t.type&&ms(t)}}}}function vs(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function ms(t){t.cancelable&&t.preventDefault()}function gs(t){return{ct:t.pageX,ut:t.pageY}}function ws(t){return t.timeStamp||performance.now()}function Ms(t,i){for(let s=0;s<t.length;++s)if(t[s].identifier===i)return t[s];return null}class bs{constructor(t,i,s){this.Ff=null,this.Wf=null,this.Nf=!0,this.Hf=null,this.Uf=t,this.$f=t.jf()[i],this.qf=t.jf()[s],this.Yf=document.createElement("tr"),this.Yf.style.height="1px",this.Kf=document.createElement("td"),this.Kf.style.position="relative",this.Kf.style.padding="0",this.Kf.style.margin="0",this.Kf.setAttribute("colspan","3"),this.Xf(),this.Yf.appendChild(this.Kf),this.Nf=this.Uf.W().layout.panes.enableResize,this.Nf?this.Gf():(this.Ff=null,this.Wf=null)}m(){null!==this.Wf&&this.Wf.m()}Zf(){return this.Yf}Jf(){return ns({width:this.$f.Jf().width,height:1})}Qf(){return ns({width:this.$f.Qf().width,height:1*window.devicePixelRatio})}tp(t,i,s){const n=this.Qf();t.fillStyle=this.Uf.W().layout.panes.separatorColor,t.fillRect(i,s,n.width,n.height)}kt(){this.Xf(),this.Uf.W().layout.panes.enableResize!==this.Nf&&(this.Nf=this.Uf.W().layout.panes.enableResize,this.Nf?this.Gf():(null!==this.Ff&&(this.Kf.removeChild(this.Ff.ip),this.Kf.removeChild(this.Ff.sp),this.Ff=null),null!==this.Wf&&(this.Wf.m(),this.Wf=null)))}Gf(){const t=document.createElement("div"),i=t.style;i.position="fixed",i.display="none",i.zIndex="49",i.top="0",i.left="0",i.width="100%",i.height="100%",i.cursor="row-resize",this.Kf.appendChild(t);const s=document.createElement("div"),n=s.style;n.position="absolute",n.zIndex="50",n.top="-4px",n.height="9px",n.width="100%",n.backgroundColor="",n.cursor="row-resize",this.Kf.appendChild(s);const e={nf:this.np.bind(this),Vf:this.ep.bind(this),xf:this.rp.bind(this),bf:this.rp.bind(this),df:this.hp.bind(this),cf:this.hp.bind(this),mf:this.ap.bind(this),pf:this.ap.bind(this)};this.Wf=new ps(s,e,{lf:()=>!1,_f:()=>!0}),this.Ff={sp:s,ip:t}}Xf(){this.Kf.style.background=this.Uf.W().layout.panes.separatorColor}np(t){null!==this.Ff&&(this.Ff.sp.style.backgroundColor=this.Uf.W().layout.panes.separatorHoverColor)}ep(t){null!==this.Ff&&null===this.Hf&&(this.Ff.sp.style.backgroundColor="")}rp(t){if(null===this.Ff)return;const i=this.$f.lp().Vo()+this.qf.lp().Vo(),s=i/(this.$f.Jf().height+this.qf.Jf().height),n=30*s;i<=2*n||(this.Hf={op:t.pageY,_p:this.$f.lp().Vo(),cp:i-n,up:i,dp:s,fp:n},this.Ff.ip.style.display="block")}hp(t){const i=this.Hf;if(null===i)return;const s=(t.pageY-i.op)*i.dp,n=Kt(i._p+s,i.fp,i.cp);this.$f.lp().Ao(n),this.qf.lp().Ao(i.up-n),this.Uf.ti().Ah()}ap(t){null!==this.Hf&&null!==this.Ff&&(this.Hf=null,this.Ff.ip.style.display="none")}}function Ss(t,i){return t.pp-i.pp}function xs(t,i,s){const n=(t.pp-i.pp)/(t.wt-i.wt);return Math.sign(n)*Math.min(Math.abs(n),s)}class ys{constructor(t,i,s,n){this.vp=null,this.mp=null,this.gp=null,this.wp=null,this.Mp=null,this.bp=0,this.Sp=0,this.xp=t,this.yp=i,this.Cp=s,this.bn=n}Pp(t,i){if(null!==this.vp){if(this.vp.wt===i)return void(this.vp.pp=t);if(Math.abs(this.vp.pp-t)<this.bn)return}this.wp=this.gp,this.gp=this.mp,this.mp=this.vp,this.vp={wt:i,pp:t}}oe(t,i){if(null===this.vp||null===this.mp)return;if(i-this.vp.wt>50)return;let s=0;const n=xs(this.vp,this.mp,this.yp),e=Ss(this.vp,this.mp),r=[n],h=[e];if(s+=e,null!==this.gp){const t=xs(this.mp,this.gp,this.yp);if(Math.sign(t)===Math.sign(n)){const i=Ss(this.mp,this.gp);if(r.push(t),h.push(i),s+=i,null!==this.wp){const t=xs(this.gp,this.wp,this.yp);if(Math.sign(t)===Math.sign(n)){const i=Ss(this.gp,this.wp);r.push(t),h.push(i),s+=i}}}}let a=0;for(let t=0;t<r.length;++t)a+=h[t]/s*r[t];Math.abs(a)<this.xp||(this.Mp={pp:t,wt:i},this.Sp=a,this.bp=function(t,i){const s=Math.log(i);return Math.log(1*s/-t)/s}(Math.abs(a),this.Cp))}Vc(t){const i=a(this.Mp),s=t-i.wt;return i.pp+this.Sp*(Math.pow(this.Cp,s)-1)/Math.log(this.Cp)}Bc(t){return null===this.Mp||this.kp(t)===this.bp}kp(t){const i=t-a(this.Mp).wt;return Math.min(i,this.bp)}}class Cs{constructor(t,i){this.Tp=void 0,this.Rp=void 0,this.Dp=void 0,this.vs=!1,this.Ep=t,this.Bp=i,this.Vp()}kt(){this.Vp()}Ap(){this.Tp&&this.Ep.removeChild(this.Tp),this.Rp&&this.Ep.removeChild(this.Rp),this.Tp=void 0,this.Rp=void 0}Ip(){return this.vs!==this.zp()||this.Dp!==this.Lp()}Lp(){return this.Bp.ti().Gi().tt(this.Bp.W().layout.textColor)>160?"dark":"light"}zp(){return this.Bp.W().layout.attributionLogo}Op(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Vp(){this.Ip()&&(this.Ap(),this.vs=this.zp(),this.vs&&(this.Dp=this.Lp(),this.Rp=document.createElement("style"),this.Rp.innerText="a#pipsend-attr-logo{--fill:#13d3c9;position:absolute;left:10px;bottom:10px;height:24px;width:46px;margin:0;padding:0;border:0;z-index:3;opacity:0.8;transition:opacity 0.3s;}a#pipsend-attr-logo:hover{opacity:1;}a#pipsend-attr-logo[data-dark]{--fill:#13d3c9;}",this.Tp=document.createElement("a"),this.Tp.href=`https://pipsend.com${this.Op()}`,this.Tp.title="Powered by Pipsend Charts",this.Tp.id="pipsend-attr-logo",this.Tp.target="_blank",this.Tp.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 155.89"><g><circle cx="220.68" cy="77.94" r="32.86" style="fill: var(--fill);"/><path d="M138.84,77.94c0,12.01-3.69,23.15-10,32.37h42.32v-.22c-6.21-9.17-9.84-20.24-9.84-32.15s3.63-22.97,9.84-32.15v-.22h-42.32c6.3,9.22,10,20.36,10,32.37Z" style="fill: var(--fill);"/><path d="M222.06,0H77.94C34.9,0,0,34.9,0,77.94h0c0,43.05,34.9,77.94,77.94,77.94h144.11c43.05,0,77.94-34.9,77.94-77.94h0C300,34.9,265.1,0,222.06,0ZM279.4,77.94c0,31.75-25.74,57.49-57.49,57.49H78.09c-31.75,0-57.49-25.74-57.49-57.49h0c0-31.75,25.74-57.49,57.49-57.49h143.82c31.75,0,57.49,25.74,57.49,57.49h0Z" style="fill: var(--fill);"/><circle cx="79.33" cy="77.94" r="32.86" style="fill: var(--fill);"/></g></svg>',this.Tp.toggleAttribute("data-dark","dark"===this.Dp),this.Ep.appendChild(this.Rp),this.Ep.appendChild(this.Tp)))}}function Ps(t,i){const s=a(t.ownerDocument).createElement("canvas");t.appendChild(s);const n=new hs(s,(e={options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})}).transform,e.options);var e;return n.resizeCanvasElement(i),n}function ks(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function Ts(t,i,s,n){t.sh&&t.sh(i,s,n)}function Rs(t,i,s,n){t.et(i,s,n)}function Ds(t,i,s,n){const e=t(s,n);for(const t of e){const s=t.Rt(n);null!==s&&i(s)}}function Es(t,i){return s=>{if(!function(t){return void 0!==t.Nt}(s))return[];return(s.Nt()?.ga()??"")!==i?[]:s.ia?.(t)??[]}}function Bs(t,i,s,n){if(!t.length)return;let e=0;const r=t[0].jt(n,!0);let h=1===i?s/2-(t[0].Ni()-r/2):t[0].Ni()-r/2-s/2;h=Math.max(0,h);for(let r=1;r<t.length;r++){const a=t[r],l=t[r-1],o=l.jt(n,!1),_=a.Ni(),c=l.Ni();if(1===i?_>c-o:_<c+o){const n=c-o*i;a.Hi(n);const r=n-i*o/2;if((1===i?r<0:r>s)&&h>0){const n=1===i?-1-r:r-s,a=Math.min(n,h);for(let s=e;s<t.length;s++)t[s].Hi(t[s].Ni()+i*a);h-=a}}else e=r,h=1===i?c-o-_:_-(c+o)}}class Vs{constructor(t,i,s,n){this.Yi=null,this.Fp=null,this.Wp=!1,this.Np=new it(200),this.Hp=null,this.Up=0,this.$p=!1,this.jp=()=>{this.$p||this.Pt.qp().ti().lr()},this.Yp=()=>{this.$p||this.Pt.qp().ti().lr()},this.Pt=t,this.Ps=i,this.bl=i.layout,this.iu=s,this.Kp="left"===n,this.Xp=Es("normal",n),this.Gp=Es("top",n),this.Zp=Es("bottom",n),this.Kf=document.createElement("div"),this.Kf.style.height="100%",this.Kf.style.overflow="hidden",this.Kf.style.width="25px",this.Kf.style.left="0",this.Kf.style.position="relative",this.Jp=Ps(this.Kf,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const e=this.Jp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.Qp=Ps(this.Kf,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const r=this.Qp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={xf:this.rp.bind(this),bf:this.rp.bind(this),df:this.hp.bind(this),cf:this.hp.bind(this),yf:this.tv.bind(this),mf:this.ap.bind(this),pf:this.ap.bind(this),Gd:this.iv.bind(this),qd:this.iv.bind(this),nf:this.sv.bind(this),Vf:this.ep.bind(this)};this.Wf=new ps(this.Qp.canvasElement,h,{lf:()=>!this.Ps.handleScroll.vertTouchDrag,_f:()=>!0})}m(){this.Wf.m(),this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose(),null!==this.Yi&&this.Yi.no().u(this),this.Yi=null}Zf(){return this.Kf}P(){return this.bl.fontSize}nv(){const t=this.iu.W();return this.Hp!==t.T&&(this.Np.Vn(),this.Hp=t.T),t}ev(){if(null===this.Yi)return 0;let t=0;const i=this.nv(),s=a(this.Jp.canvasElement.getContext("2d",{colorSpace:this.Pt.qp().W().layout.colorSpace}));s.save();const n=this.Yi.Ea();s.font=this.rv(),n.length>0&&(t=Math.max(this.Np.Bi(s,n[0].Za),this.Np.Bi(s,n[n.length-1].Za)));const e=this.hv();for(let i=e.length;i--;){const n=this.Np.Bi(s,e[i].hi());n>t&&(t=n)}const r=this.Yi.Lt();if(null!==r&&null!==this.Fp&&(2!==(h=this.Ps.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Yi.Rs(1,r),n=this.Yi.Rs(this.Fp.height-2,r);t=Math.max(t,this.Np.Bi(s,this.Yi.Zi(Math.floor(Math.min(i,n))+.11111111111111,r)),this.Np.Bi(s,this.Yi.Zi(Math.ceil(Math.max(i,n))-.11111111111111,r)))}var h;s.restore();const l=t||34;return ds(Math.ceil(i.S+i.C+i.A+i.I+5+l))}av(t){null!==this.Fp&&es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`)}lv(){return a(this.Fp).width}cs(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.no().u(this),this.Yi=t,t.no().i(this.cl.bind(this),this))}Nt(){return this.Yi}Vn(){const t=this.Pt.lp();this.Pt.qp().ti().Zo(t,a(this.Nt()))}ov(t){if(null===this.Fp)return;const i={colorSpace:this.Pt.qp().W().layout.colorSpace};if(1!==t){this._v(),this.Jp.applySuggestedBitmapSize();const t=os(this.Jp,i);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t)}),this.Pt.dv(t,this.Zp),this.fv(t),this.Pt.dv(t,this.Xp),this.pv(t))}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.vv(s),this.Pt.dv(s,this.Gp))}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;t.drawImage(n,i,s)}}kt(){this.Yi?.Ea()}rp(t){if(null===this.Yi||this.Yi.Xi()||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp();this.Wp=!0,i.$o(s,this.Yi,t.localY)}hp(t){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp(),n=this.Yi;i.jo(s,n,t.localY)}tv(){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const t=this.Pt.qp().ti(),i=this.Pt.lp(),s=this.Yi;this.Wp&&(this.Wp=!1,t.qo(i,s))}ap(t){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp();this.Wp=!1,i.qo(s,this.Yi)}iv(t){this.Ps.handleScale.axisDoubleClickReset.price&&this.Vn()}sv(t){if(null===this.Yi)return;!this.Pt.qp().ti().W().handleScale.axisPressedMouseMove.price||this.Yi.Oe()||this.Yi.El()||this.mv(1)}ep(t){this.mv(0)}hv(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let n=0;n<s.length;++n){const e=s[n].Hs(this.Pt.lp(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.Pt.lp().Et()),t}cv({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.Pt.lp().ti(),r=e.j(),h=e.Hu();r===h?V(t,0,0,s,n,r):z(t,0,0,s,n,r,h)}uv({context:t,bitmapSize:i,horizontalPixelRatio:s}){if(null===this.Fp||null===this.Yi||!this.Yi.W().borderVisible)return;t.fillStyle=this.Yi.W().borderColor;const n=Math.max(1,Math.floor(this.nv().S*s));let e;e=this.Kp?i.width-n:0,t.fillRect(e,0,n,i.height)}fv(t){if(null===this.Fp||null===this.Yi)return;const i=this.Yi.Ea(),s=this.Yi.W(),n=this.nv(),e=this.Kp?this.Fp.width-n.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=s.borderColor;const a=Math.max(1,Math.floor(h)),l=Math.floor(.5*h),o=Math.round(n.C*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.Pa*h)-l,o,a);t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{t.font=this.rv(),t.fillStyle=s.textColor??this.bl.textColor,t.textAlign=this.Kp?"right":"left",t.textBaseline="middle";const r=this.Kp?Math.round(e-n.A):Math.round(e+n.C+n.A),h=i.map(i=>this.Np.Ei(t,i.Za));for(let s=i.length;s--;){const n=i[s];t.fillText(n.Za,r,n.Pa+h[s])}})}_v(){if(null===this.Fp||null===this.Yi)return;let t=this.Fp.height/2;const i=[],s=this.Yi.Et().slice(),n=this.Pt.lp(),e=this.nv();this.Yi===n.jn()&&this.Pt.lp().Et().forEach(t=>{n.$n(t)&&s.push(t)});const r=this.Yi.ba()[0],h=this.Yi;s.forEach(s=>{const e=s.Hs(n,h);e.forEach(t=>{t.Hi(null),t.Ui()&&i.push(t)}),r===s&&e.length>0&&(t=e[0].Ai())}),i.forEach(t=>t.Hi(t.Ai()));this.Yi.W().alignLabels&&this.gv(i,e,t)}gv(t,i,s){if(null===this.Fp)return;const n=t.filter(t=>t.Ai()<=s),e=t.filter(t=>t.Ai()>s);n.sort((t,i)=>i.Ai()-t.Ai()),n.length&&e.length&&e.push(n[0]),e.sort((t,i)=>t.Ai()-i.Ai());for(const s of t){const t=Math.floor(s.jt(i)/2),n=s.Ai();n>-t&&n<t&&s.Hi(t),n>this.Fp.height-t&&n<this.Fp.height+t&&s.Hi(this.Fp.height-t)}Bs(n,1,this.Fp.height,i),Bs(e,-1,this.Fp.height,i)}pv(t){if(null===this.Fp)return;const i=this.hv(),s=this.nv(),n=this.Kp?"right":"left";i.forEach(i=>{if(i.$i()){i.Rt(a(this.Yi)).et(t,s,this.Np,n)}})}vv(t){if(null===this.Fp||null===this.Yi)return;const i=this.Pt.qp().ti(),s=[],n=this.Pt.lp(),e=i.du().Hs(n,this.Yi);e.length&&s.push(e);const r=this.nv(),h=this.Kp?"right":"left";s.forEach(i=>{i.forEach(i=>{i.Rt(a(this.Yi)).et(t,r,this.Np,h)})})}mv(t){this.Kf.style.cursor=1===t?"ns-resize":"default"}cl(){const t=this.ev();this.Up<t&&this.Pt.qp().ti().Ah(),this.Up=t}rv(){return w(this.bl.fontSize,this.bl.fontFamily)}}function As(t,i){return t.Qh?.(i)??[]}function Is(t,i){return t.Ns?.(i)??[]}function zs(t,i){return t.us?.(i)??[]}function Ls(t,i){return t.Gh?.(i)??[]}class Os{constructor(t,i){this.Fp=ns({width:0,height:0}),this.wv=null,this.Mv=null,this.bv=null,this.Sv=null,this.xv=!1,this.yv=new o,this.Cv=new o,this.Pv=0,this.kv=!1,this.Tv=null,this.Rv=!1,this.Dv=null,this.Ev=null,this.$p=!1,this.jp=()=>{this.$p||null===this.Bv||this.ss().lr()},this.Yp=()=>{this.$p||null===this.Bv||this.ss().lr()},this.Bp=t,this.Bv=i,this.Bv.i_().i(this.Vv.bind(this),this,!0),this.Av=document.createElement("td"),this.Av.style.padding="0",this.Av.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.Iv=document.createElement("td"),this.Iv.style.padding="0",this.zv=document.createElement("td"),this.zv.style.padding="0",this.Av.appendChild(s),this.Jp=Ps(s,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const n=this.Jp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Qp=Ps(s,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const e=this.Qp.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.Yf=document.createElement("tr"),this.Yf.appendChild(this.Iv),this.Yf.appendChild(this.Av),this.Yf.appendChild(this.zv),this.Lv(),this.Wf=new ps(this.Qp.canvasElement,this,{lf:()=>null===this.Tv&&!this.Bp.W().handleScroll.vertTouchDrag,_f:()=>null===this.Tv&&!this.Bp.W().handleScroll.horzTouchDrag})}m(){null!==this.wv&&this.wv.m(),null!==this.Mv&&this.Mv.m(),this.bv=null,this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose(),null!==this.Bv&&(this.Bv.i_().u(this),this.Bv.m()),this.Wf.m()}lp(){return a(this.Bv)}Ov(t){null!==this.Bv&&this.Bv.i_().u(this),this.Bv=t,null!==this.Bv&&this.Bv.i_().i(Os.prototype.Vv.bind(this),this,!0),this.Lv(),this.Bp.jf().indexOf(this)===this.Bp.jf().length-1?(this.bv=this.bv??new Cs(this.Av,this.Bp),this.bv.kt()):(this.bv?.Ap(),this.bv=null)}qp(){return this.Bp}Zf(){return this.Yf}Lv(){if(null!==this.Bv&&(this.Fv(),0!==this.ss().Ks().length)){if(null!==this.wv){const t=this.Bv.Ho();this.wv.cs(a(t))}if(null!==this.Mv){const t=this.Bv.Uo();this.Mv.cs(a(t))}}}Wv(){null!==this.wv&&this.wv.kt(),null!==this.Mv&&this.Mv.kt()}Vo(){return null!==this.Bv?this.Bv.Vo():0}Ao(t){this.Bv&&this.Bv.Ao(t)}nf(t){if(!this.Bv)return;this.Nv();const i=t.localX,s=t.localY;this.Hv(i,s,t)}xf(t){this.Nv(),this.Uv(),this.Hv(t.localX,t.localY,t)}ef(t){if(!this.Bv)return;this.Nv();const i=t.localX,s=t.localY;this.Hv(i,s,t)}gf(t){null!==this.Bv&&(this.Nv(),this.$v(t))}Gd(t){null!==this.Bv&&this.jv(this.Cv,t)}qd(t){this.Gd(t)}df(t){this.Nv(),this.qv(t),this.Hv(t.localX,t.localY,t)}mf(t){null!==this.Bv&&(this.Nv(),this.kv=!1,this.Yv(t))}vf(t){null!==this.Bv&&this.$v(t)}Af(t){if(this.kv=!0,null===this.Tv){const i={x:t.localX,y:t.localY};this.Kv(i,i,t)}}Vf(t){null!==this.Bv&&(this.Nv(),this.Bv.ti()._u(null),this.Xv())}Gv(){return this.yv}Zv(){return this.Cv}kf(){this.Pv=1,this.ss().an()}Tf(t,i){if(!this.Bp.W().handleScale.pinch)return;const s=5*(i-this.Pv);this.Pv=i,this.ss().Su(t.ct,s)}bf(t){this.kv=!1,this.Rv=null!==this.Tv,this.Uv();const i=this.ss().du();null!==this.Tv&&i.Bt()&&(this.Dv={x:i.ni(),y:i.ei()},this.Tv={x:t.localX,y:t.localY})}cf(t){if(null===this.Bv)return;const i=t.localX,s=t.localY;if(null!==this.Tv){this.Rv=!1;const n=a(this.Dv),e=n.x+(i-this.Tv.x),r=n.y+(s-this.Tv.y);return void this.Hv(e,r,t)}this.qv(t)}pf(t){0===this.qp().W().trackingMode.exitMode&&(this.Rv=!0),this.Jv(),this.Yv(t)}Kn(t,i){const s=this.Bv;return null===s?null:xi(s,t,i)}Qv(t,i){a("left"===i?this.wv:this.Mv).av(ns({width:t,height:this.Fp.height}))}Jf(){return this.Fp}av(t){es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Av.style.width=t.width+"px",this.Av.style.height=t.height+"px")}tm(){const t=a(this.Bv);t.No(t.Ho()),t.No(t.Uo());for(const i of t.ba())if(t.$n(i)){const s=i.Nt();null!==s&&t.No(s),i.Ws()}for(const i of t.n_())i.Ws()}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;null!==t&&t.drawImage(n,i,s)}}ov(t){if(0===t)return;if(null===this.Bv)return;t>1&&this.tm(),null!==this.wv&&this.wv.ov(t),null!==this.Mv&&this.Mv.ov(t);const i={colorSpace:this.Bp.W().layout.colorSpace};if(1!==t){this.Jp.applySuggestedBitmapSize();const t=os(this.Jp,i);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.cv(t)}),this.Bv&&(this.im(t,As),this.sm(t),this.im(t,Is),this.im(t,zs)))}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.nm(s),this.im(s,Ls),this.im(s,zs))}rm(){return this.wv}hm(){return this.Mv}dv(t,i){this.im(t,i)}Vv(){null!==this.Bv&&this.Bv.i_().u(this),this.Bv=null}$v(t){this.jv(this.yv,t)}jv(t,i){const s=i.localX,n=i.localY;t.v()&&t.p(this.ss().It().fc(s),{x:s,y:n},i)}cv({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ss(),r=e.j(),h=e.Hu();r===h?V(t,0,0,s,n,h):z(t,0,0,s,n,r,h)}sm(t){const i=a(this.Bv),s=i.s_()._r().Rt(i);null!==s&&s.et(t,!1)}nm(t){this.am(t,Is,Rs,this.ss().du())}im(t,i){const s=a(this.Bv),n=s.Et(),e=s.n_();for(const s of e)this.am(t,i,Ts,s);for(const s of n)this.am(t,i,Ts,s);for(const s of e)this.am(t,i,Rs,s);for(const s of n)this.am(t,i,Rs,s)}am(t,i,s,n){const e=a(this.Bv),r=e.ti().ou(),h=null!==r&&r.e_===n,l=null!==r&&h&&void 0!==r.r_?r.r_.Gn:void 0;Ds(i,i=>s(i,t,h,l),n,e)}Fv(){if(null===this.Bv)return;const t=this.Bp,i=this.Bv.Ho().W().visible,s=this.Bv.Uo().W().visible;i||null===this.wv||(this.Iv.removeChild(this.wv.Zf()),this.wv.m(),this.wv=null),s||null===this.Mv||(this.zv.removeChild(this.Mv.Zf()),this.Mv.m(),this.Mv=null);const n=t.ti().Vu();i&&null===this.wv&&(this.wv=new Vs(this,t.W(),n,"left"),this.Iv.appendChild(this.wv.Zf())),s&&null===this.Mv&&(this.Mv=new Vs(this,t.W(),n,"right"),this.zv.appendChild(this.Mv.Zf()))}lm(t){return t.If&&this.kv||null!==this.Tv}om(t){return Math.max(0,Math.min(t,this.Fp.width-1))}_m(t){return Math.max(0,Math.min(t,this.Fp.height-1))}Hv(t,i,s){this.ss().Ru(this.om(t),this._m(i),s,a(this.Bv))}Xv(){this.ss().Eu()}Jv(){this.Rv&&(this.Tv=null,this.Xv())}Kv(t,i,s){this.Tv=t,this.Rv=!1,this.Hv(i.x,i.y,s);const n=this.ss().du();this.Dv={x:n.ni(),y:n.ei()}}ss(){return this.Bp.ti()}Yv(t){if(!this.xv)return;const i=this.ss(),s=this.lp();if(i.Xo(s,s.Ts()),this.Sv=null,this.xv=!1,i.Pu(),null!==this.Ev){const t=performance.now(),s=i.It();this.Ev.oe(s.Sc(),t),this.Ev.Bc(t)||i.cn(this.Ev)}}Nv(){this.Tv=null}Uv(){if(!this.Bv)return;if(this.ss().an(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)a(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Bv.Ts().Xi()&&this.ss().It().Xi()}qv(t){if(null===this.Bv)return;const i=this.ss(),s=i.It();if(s.Xi())return;const n=this.Bp.W(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t.If)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.If))return;const h=this.Bv.Ts(),a=performance.now();if(null!==this.Sv||this.lm(t)||(this.Sv={x:t.clientX,y:t.clientY,hd:a,um:t.localX,dm:t.localY}),null!==this.Sv&&!this.xv&&(this.Sv.x!==t.clientX||this.Sv.y!==t.clientY)){if(t.If&&r.touch||!t.If&&r.mouse){const t=s.Mc();this.Ev=new ys(.2/t,7/t,.997,15/t),this.Ev.Pp(s.Sc(),this.Sv.hd)}else this.Ev=null;h.Xi()||i.Yo(this.Bv,h,t.localY),i.yu(t.localX),this.xv=!0}this.xv&&(h.Xi()||i.Ko(this.Bv,h,t.localY),i.Cu(t.localX),null!==this.Ev&&this.Ev.Pp(s.Sc(),a))}}class Fs{constructor(t,i,s,n,e){this.yt=!0,this.Fp=ns({width:0,height:0}),this.jp=()=>this.ov(3),this.Kp="left"===t,this.iu=s.Vu,this.Ps=i,this.fm=n,this.pm=e,this.Kf=document.createElement("div"),this.Kf.style.width="25px",this.Kf.style.height="100%",this.Kf.style.overflow="hidden",this.Jp=Ps(this.Kf,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp)}m(){this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose()}Zf(){return this.Kf}Jf(){return this.Fp}av(t){es(this.Fp,t)||(this.Fp=t,this.Jp.resizeCanvasElement(t),this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`,this.yt=!0)}ov(t){if(t<3&&!this.yt)return;if(0===this.Fp.width||0===this.Fp.height)return;this.yt=!1,this.Jp.applySuggestedBitmapSize();const i=os(this.Jp,{colorSpace:this.Ps.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t)})}Qf(){return this.Jp.bitmapSize}tp(t,i,s){const n=this.Qf();n.width>0&&n.height>0&&t.drawImage(this.Jp.canvasElement,i,s)}uv({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.fm())return;t.fillStyle=this.Ps.timeScale.borderColor;const e=Math.floor(this.iu.W().S*s),r=Math.floor(this.iu.W().S*n),h=this.Kp?i.width-e:0;t.fillRect(h,0,e,r)}cv({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.pm())}}function Ws(t){return i=>i.sa?.(t)??[]}const Ns=Ws("normal"),Hs=Ws("top"),Us=Ws("bottom");class $s{constructor(t,i){this.vm=null,this.gm=null,this.M=null,this.wm=!1,this.Fp=ns({width:0,height:0}),this.Mm=new o,this.Np=new it(5),this.$p=!1,this.jp=()=>{this.$p||this.Bp.ti().lr()},this.Yp=()=>{this.$p||this.Bp.ti().lr()},this.Bp=t,this.__=i,this.Ps=t.W().layout,this.Tp=document.createElement("tr"),this.bm=document.createElement("td"),this.bm.style.padding="0",this.Sm=document.createElement("td"),this.Sm.style.padding="0",this.Kf=document.createElement("td"),this.Kf.style.height="25px",this.Kf.style.padding="0",this.xm=document.createElement("div"),this.xm.style.width="100%",this.xm.style.height="100%",this.xm.style.position="relative",this.xm.style.overflow="hidden",this.Kf.appendChild(this.xm),this.Jp=Ps(this.xm,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const s=this.Jp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Qp=Ps(this.xm,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const n=this.Qp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.Tp.appendChild(this.bm),this.Tp.appendChild(this.Kf),this.Tp.appendChild(this.Sm),this.ym(),this.Bp.ti().Bo().i(this.ym.bind(this),this),this.Wf=new ps(this.Qp.canvasElement,this,{lf:()=>!0,_f:()=>!this.Bp.W().handleScroll.horzTouchDrag})}m(){this.Wf.m(),null!==this.vm&&this.vm.m(),null!==this.gm&&this.gm.m(),this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose()}Zf(){return this.Tp}Cm(){return this.vm}Pm(){return this.gm}xf(t){if(this.wm)return;this.wm=!0;const i=this.Bp.ti();!i.It().Xi()&&this.Bp.W().handleScale.axisPressedMouseMove.time&&i.bu(t.localX)}bf(t){this.xf(t)}yf(){const t=this.Bp.ti();!t.It().Xi()&&this.wm&&(this.wm=!1,this.Bp.W().handleScale.axisPressedMouseMove.time&&t.Tu())}df(t){const i=this.Bp.ti();!i.It().Xi()&&this.Bp.W().handleScale.axisPressedMouseMove.time&&i.ku(t.localX)}cf(t){this.df(t)}mf(){this.wm=!1;const t=this.Bp.ti();t.It().Xi()&&!this.Bp.W().handleScale.axisPressedMouseMove.time||t.Tu()}pf(){this.mf()}Gd(){this.Bp.W().handleScale.axisDoubleClickReset.time&&this.Bp.ti().dn()}qd(){this.Gd()}nf(){this.Bp.ti().W().handleScale.axisPressedMouseMove.time&&this.mv(1)}Vf(){this.mv(0)}Jf(){return this.Fp}km(){return this.Mm}Tm(t,i,s){es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`,this.Mm.p(t)),null!==this.vm&&this.vm.av(ns({width:i,height:t.height})),null!==this.gm&&this.gm.av(ns({width:s,height:t.height}))}Rm(){const t=this.Dm();return Math.ceil(t.S+t.C+t.P+t.L+t.V+t.Em)}kt(){this.Bp.ti().It().Ea()}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;t.drawImage(n,i,s)}}ov(t){if(0===t)return;const i={colorSpace:this.Ps.colorSpace};if(1!==t){this.Jp.applySuggestedBitmapSize();const s=os(this.Jp,i);null!==s&&(s.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t),this.Bm(s,Us)}),this.fv(s),this.Bm(s,Ns)),null!==this.vm&&this.vm.ov(t),null!==this.gm&&this.gm.ov(t)}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.Vm([...this.Bp.ti().Ks(),this.Bp.ti().du()],s),this.Bm(s,Hs))}Bm(t,i){const s=this.Bp.ti().Ks();for(const n of s)Ds(i,i=>Ts(i,t,!1,void 0),n,void 0);for(const n of s)Ds(i,i=>Rs(i,t,!1,void 0),n,void 0)}cv({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.Bp.ti().Hu())}uv({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.Bp.W().timeScale.borderVisible){t.fillStyle=this.Am();const n=Math.max(1,Math.floor(this.Dm().S*s));t.fillRect(0,0,i.width,n)}}fv(t){const i=this.Bp.ti().It(),s=i.Ea();if(!s||0===s.length)return;const n=this.__.maxTickMarkWeight(s),e=this.Dm(),r=i.W();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.Am(),t.fillStyle=this.Am();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const a=Math.round(e.C*n);for(let n=s.length;n--;){const e=Math.round(s[n].coord*i);t.rect(e-h,0,r,a)}t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{const i=e.S+e.C+e.L+e.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.U(),t.font=this.rv();for(const e of s)if(e.weight<n){const s=e.needAlignCoordinate?this.Im(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}this.Bp.W().timeScale.allowBoldLabels&&(t.font=this.zm());for(const e of s)if(e.weight>=n){const s=e.needAlignCoordinate?this.Im(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}})}Im(t,i,s){const n=this.Np.Bi(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.Fp.width&&(i-=Math.abs(this.Fp.width-(r+n))),i}Vm(t,i){const s=this.Dm();for(const n of t)for(const t of n.ds())t.Rt().et(i,s)}Am(){return this.Bp.W().timeScale.borderColor}U(){return this.Ps.textColor}N(){return this.Ps.fontSize}rv(){return w(this.N(),this.Ps.fontFamily)}zm(){return w(this.N(),this.Ps.fontFamily,"bold")}Dm(){null===this.M&&(this.M={S:1,O:NaN,L:NaN,V:NaN,Qi:NaN,C:5,P:NaN,T:"",Ji:new it,Em:0});const t=this.M,i=this.rv();if(t.T!==i){const s=this.N();t.P=s,t.T=i,t.L=3*s/12,t.V=3*s/12,t.Qi=9*s/12,t.O=0,t.Em=4*s/12,t.Ji.Vn()}return this.M}mv(t){this.Kf.style.cursor=1===t?"ew-resize":"default"}ym(){const t=this.Bp.ti(),i=t.W();i.leftPriceScale.visible||null===this.vm||(this.bm.removeChild(this.vm.Zf()),this.vm.m(),this.vm=null),i.rightPriceScale.visible||null===this.gm||(this.Sm.removeChild(this.gm.Zf()),this.gm.m(),this.gm=null);const s={Vu:this.Bp.ti().Vu()},n=()=>i.leftPriceScale.borderVisible&&t.It().W().borderVisible,e=()=>t.Hu();i.leftPriceScale.visible&&null===this.vm&&(this.vm=new Fs("left",i,s,n,e),this.bm.appendChild(this.vm.Zf())),i.rightPriceScale.visible&&null===this.gm&&(this.gm=new Fs("right",i,s,n,e),this.Sm.appendChild(this.gm.Zf()))}}const js=!!_s&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(t=>t.brand.includes("Chromium"))&&!!_s&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class qs{constructor(t,i,s){var n;this.Lm=[],this.Om=[],this.Fm=0,this.sl=0,this.bo=0,this.Wm=0,this.Nm=0,this.Hm=null,this.Um=!1,this.yv=new o,this.Cv=new o,this.Jc=new o,this.$m=null,this.jm=null,this.Ep=t,this.Ps=i,this.__=s,this.Tp=document.createElement("div"),this.Tp.classList.add("tv-lightweight-charts"),this.Tp.style.overflow="hidden",this.Tp.style.direction="ltr",this.Tp.style.width="100%",this.Tp.style.height="100%",(n=this.Tp).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.qm=document.createElement("table"),this.qm.setAttribute("cellspacing","0"),this.Tp.appendChild(this.qm),this.Ym=this.Km.bind(this),Ys(this.Ps)&&this.Xm(!0),this.ss=new zi(this.tu.bind(this),this.Ps,s),this.ti().fu().i(this.Gm.bind(this),this),this.Zm=new $s(this,this.__),this.qm.appendChild(this.Zm.Zf());const e=i.autoSize&&this.Jm();let r=this.Ps.width,h=this.Ps.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.Qm(r,h),this.tg(),t.appendChild(this.Tp),this.ig(),this.ss.It().zc().i(this.ss.Ah.bind(this.ss),this),this.ss.Bo().i(this.ss.Ah.bind(this.ss),this)}ti(){return this.ss}W(){return this.Ps}jf(){return this.Lm}sg(){return this.Zm}m(){this.Xm(!1),0!==this.Fm&&window.cancelAnimationFrame(this.Fm),this.ss.fu().u(this),this.ss.It().zc().u(this),this.ss.Bo().u(this),this.ss.m();for(const t of this.Lm)this.qm.removeChild(t.Zf()),t.Gv().u(this),t.Zv().u(this),t.m();this.Lm=[];for(const t of this.Om)this.ng(t);this.Om=[],a(this.Zm).m(),null!==this.Tp.parentElement&&this.Tp.parentElement.removeChild(this.Tp),this.Jc.m(),this.yv.m(),this.Cv.m(),this.eg()}Qm(t,i,s=!1){if(this.sl===i&&this.bo===t)return;const n=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return ns({width:i-i%2,height:s-s%2})}(ns({width:t,height:i}));this.sl=n.height,this.bo=n.width;const e=this.sl+"px",r=this.bo+"px";a(this.Tp).style.height=e,a(this.Tp).style.width=r,this.qm.style.height=e,this.qm.style.width=r,s?this.rg(Y.Mn(),performance.now()):this.ss.Ah()}ov(t){void 0===t&&(t=Y.Mn());for(let i=0;i<this.Lm.length;i++)this.Lm[i].ov(t.rn(i).sn);this.Ps.timeScale.visible&&this.Zm.ov(t.en())}ar(t){const i=Ys(this.Ps);this.ss.ar(t);const s=Ys(this.Ps);s!==i&&this.Xm(s),t.layout?.panes&&this.hg(),this.ig(),this.ag(t)}Gv(){return this.yv}Zv(){return this.Cv}fu(){return this.Jc}lg(t=!1){null!==this.Hm&&(this.rg(this.Hm,performance.now()),this.Hm=null);const i=this.og(null),s=document.createElement("canvas");s.width=i.width,s.height=i.height;const n=a(s.getContext("2d"));return this.og(n,t),s}_g(t){if("left"===t&&!this.cg())return 0;if("right"===t&&!this.ug())return 0;if(0===this.Lm.length)return 0;return a("left"===t?this.Lm[0].rm():this.Lm[0].hm()).lv()}dg(){return this.Ps.autoSize&&null!==this.$m}sp(){return this.Tp}fg(t){this.jm=t,this.jm?this.sp().style.setProperty("cursor",t):this.sp().style.removeProperty("cursor")}pg(){return this.jm}vg(t){return h(this.Lm[t]).Jf()}hg(){this.Om.forEach(t=>{t.kt()})}ag(t){(void 0!==t.autoSize||!this.$m||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.$m&&this.Jm(),!1===t.autoSize&&null!==this.$m&&this.eg(),t.autoSize||void 0===t.width&&void 0===t.height||this.Qm(t.width||this.bo,t.height||this.sl))}og(t,i){let s=0,n=0;const e=this.Lm[0],r=(s,n)=>{let e=0;for(let r=0;r<this.Lm.length;r++){const h=this.Lm[r],l=a("left"===s?h.rm():h.hm()),o=l.Qf();if(null!==t&&l.tp(t,n,e,i),e+=o.height,r<this.Lm.length-1){const i=this.Om[r],s=i.Qf();null!==t&&i.tp(t,n,e),e+=s.height}}};if(this.cg()){r("left",0);s+=a(e.rm()).Qf().width}for(let e=0;e<this.Lm.length;e++){const r=this.Lm[e],h=r.Qf();if(null!==t&&r.tp(t,s,n,i),n+=h.height,e<this.Lm.length-1){const i=this.Om[e],r=i.Qf();null!==t&&i.tp(t,s,n),n+=r.height}}if(s+=e.Qf().width,this.ug()){r("right",s);s+=a(e.hm()).Qf().width}const h=(i,s,n)=>{a("left"===i?this.Zm.Cm():this.Zm.Pm()).tp(a(t),s,n)};if(this.Ps.timeScale.visible){const s=this.Zm.Qf();if(null!==t){let r=0;this.cg()&&(h("left",r,n),r=a(e.rm()).Qf().width),this.Zm.tp(t,r,n,i),r+=s.width,this.ug()&&h("right",r,n)}n+=s.height}return ns({width:s,height:n})}mg(){let t=0,i=0,s=0;for(const n of this.Lm)this.cg()&&(i=Math.max(i,a(n.rm()).ev(),this.Ps.leftPriceScale.minimumWidth)),this.ug()&&(s=Math.max(s,a(n.hm()).ev(),this.Ps.rightPriceScale.minimumWidth)),t+=n.Vo();i=ds(i),s=ds(s);const n=this.bo,e=this.sl,r=Math.max(n-i-s,0),h=1*this.Om.length,l=this.Ps.timeScale.visible;let o=l?Math.max(this.Zm.Rm(),this.Ps.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const c=h+o,u=e<c?0:e-c,d=u/t;let f=0;const p=window.devicePixelRatio||1;for(let t=0;t<this.Lm.length;++t){const n=this.Lm[t];n.Ov(this.ss.js()[t]);let e=0,h=0;h=t===this.Lm.length-1?Math.ceil((u-f)*p)/p:Math.round(n.Vo()*d*p)/p,e=Math.max(h,2),f+=e,n.av(ns({width:r,height:e})),this.cg()&&n.Qv(i,"left"),this.ug()&&n.Qv(s,"right"),n.lp()&&this.ss.pu(n.lp(),e)}this.Zm.Tm(ns({width:l?r:0,height:o}),l?i:0,l?s:0),this.ss.Io(r),this.Wm!==i&&(this.Wm=i),this.Nm!==s&&(this.Nm=s)}Xm(t){t?this.Tp.addEventListener("wheel",this.Ym,{passive:!1}):this.Tp.removeEventListener("wheel",this.Ym)}gg(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return js?1/window.devicePixelRatio:1}Km(t){if(!(0!==t.deltaX&&this.Ps.handleScroll.mouseWheel||0!==t.deltaY&&this.Ps.handleScale.mouseWheel))return;const i=this.gg(t),s=i*t.deltaX/100,n=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==n&&this.Ps.handleScale.mouseWheel){const i=Math.sign(n)*Math.min(1,Math.abs(n)),s=t.clientX-this.Tp.getBoundingClientRect().left;this.ti().Su(s,i)}0!==s&&this.Ps.handleScroll.mouseWheel&&this.ti().xu(-80*s)}rg(t,i){const s=t.en();3===s&&this.wg(),3!==s&&2!==s||(this.Mg(t),this.bg(t,i),this.Zm.kt(),this.Lm.forEach(t=>{t.Wv()}),3===this.Hm?.en()&&(this.Hm.mn(t),this.wg(),this.Mg(this.Hm),this.bg(this.Hm,i),t=this.Hm,this.Hm=null)),this.ov(t)}bg(t,i){for(const s of t.vn())this.gn(s,i)}Mg(t){const i=this.ss.js();for(let s=0;s<i.length;s++)t.rn(s).nn&&i[s].Jo()}gn(t,i){const s=this.ss.It();switch(t.ln){case 0:s.Oc();break;case 1:s.Fc(t.Ht);break;case 2:s.fn(t.Ht);break;case 3:s.pn(t.Ht);break;case 4:s.Cc();break;case 5:t.Ht.Bc(i)||s.pn(t.Ht.Vc(i))}}tu(t){null!==this.Hm?this.Hm.mn(t):this.Hm=t,this.Um||(this.Um=!0,this.Fm=window.requestAnimationFrame(t=>{if(this.Um=!1,this.Fm=0,null!==this.Hm){const i=this.Hm;this.Hm=null,this.rg(i,t);for(const s of i.vn())if(5===s.ln&&!s.Ht.Bc(t)){this.ti().cn(s.Ht);break}}}))}wg(){this.tg()}ng(t){this.qm.removeChild(t.Zf()),t.m()}tg(){const t=this.ss.js(),i=t.length,s=this.Lm.length;for(let t=i;t<s;t++){const t=h(this.Lm.pop());this.qm.removeChild(t.Zf()),t.Gv().u(this),t.Zv().u(this),t.m();const i=this.Om.pop();void 0!==i&&this.ng(i)}for(let n=s;n<i;n++){const i=new Os(this,t[n]);if(i.Gv().i(this.Sg.bind(this,i),this),i.Zv().i(this.xg.bind(this,i),this),this.Lm.push(i),n>0){const t=new bs(this,n-1,n);this.Om.push(t),this.qm.insertBefore(t.Zf(),this.Zm.Zf())}this.qm.insertBefore(i.Zf(),this.Zm.Zf())}for(let s=0;s<i;s++){const i=t[s],n=this.Lm[s];n.lp()!==i?n.Ov(i):n.Lv()}this.ig(),this.mg()}yg(t,i,s,n){const e=new Map;if(null!==t){this.ss.Ks().forEach(i=>{const s=i.Gs().Nr(t);null!==s&&e.set(i,s)})}let r;if(null!==t){const i=this.ss.It().ns(t)?.originalTime;void 0!==i&&(r=i)}const h=this.ti().ou(),a=null!==h&&h.e_ instanceof $t?h.e_:void 0,l=null!==h&&void 0!==h.r_?h.r_.Xn:void 0,o=this.Cg(n);return{Pg:r,De:t??void 0,kg:i??void 0,Tg:-1!==o?o:void 0,Rg:a,Dg:e,Eg:l,Bg:s??void 0}}Cg(t){let i=-1;if(t)i=this.Lm.indexOf(t);else{const t=this.ti().du().$s();null!==t&&(i=this.ti().js().indexOf(t))}return i}Sg(t,i,s,n){this.yv.p(()=>this.yg(i,s,n,t))}xg(t,i,s,n){this.Cv.p(()=>this.yg(i,s,n,t))}Gm(t,i,s){this.fg(this.ti().ou()?.a_??null),this.Jc.p(()=>this.yg(t,i,s))}ig(){const t=this.Ps.timeScale.visible?"":"none";this.Zm.Zf().style.display=t}cg(){return this.Lm[0].lp().Ho().W().visible}ug(){return this.Lm[0].lp().Uo().W().visible}Jm(){return"ResizeObserver"in window&&(this.$m=new ResizeObserver(t=>{const i=t[t.length-1];i&&this.Qm(i.contentRect.width,i.contentRect.height)}),this.$m.observe(this.Ep,{box:"border-box"}),!0)}eg(){null!==this.$m&&this.$m.disconnect(),this.$m=null}}function Ys(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Ks(t){return void 0===t.open&&void 0===t.value}function Xs(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function Gs(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.color&&(r.D=s.color),r}function Zs(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.lineColor&&(r.gt=s.lineColor),void 0!==s.topColor&&(r.gr=s.topColor),void 0!==s.bottomColor&&(r.wr=s.bottomColor),r}function Js(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.topLineColor&&(r.Mr=s.topLineColor),void 0!==s.bottomLineColor&&(r.br=s.bottomLineColor),void 0!==s.topFillColor1&&(r.Sr=s.topFillColor1),void 0!==s.topFillColor2&&(r.yr=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.Cr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.Pr=s.bottomFillColor2),r}function Qs(t,i,s,n){const e={De:i,wt:t,Ht:[s.open,s.high,s.low,s.close],Pg:n};return void 0!==s.color&&(e.D=s.color),e}function tn(t,i,s,n){const e={De:i,wt:t,Ht:[s.open,s.high,s.low,s.close],Pg:n};return void 0!==s.color&&(e.D=s.color),void 0!==s.borderColor&&(e.Ut=s.borderColor),void 0!==s.wickColor&&(e.mr=s.wickColor),e}function sn(t,i,s,n,e){const r=h(e)(s),a=Math.max(...r),l=Math.min(...r),o=r[r.length-1],_=[o,a,l,o],{time:c,color:u,...d}=s;return{De:i,wt:t,Ht:_,Pg:n,ne:d,D:u}}function nn(t){return void 0!==t.Ht}function en(t,i){return void 0!==i.customValues&&(t.Vg=i.customValues),t}function rn(t){return(i,s,n,e,r,h)=>function(t,i){return i?i(t):Ks(t)}(n,h)?en({wt:i,De:s,Pg:e},n):en(t(i,s,n,e,r),n)}function hn(t){return{Candlestick:rn(tn),Bar:rn(Qs),Area:rn(Zs),Baseline:rn(Js),Histogram:rn(Gs),Line:rn(Gs),Custom:rn(sn)}[t]}function an(t){return{De:0,Ag:new Map,Uh:t}}function ln(t,i){if(void 0!==t&&0!==t.length)return{Ig:i.key(t[0].wt),zg:i.key(t[t.length-1].wt)}}function on(t){let i;return t.forEach(t=>{void 0===i&&(i=t.Pg)}),h(i)}class _n{constructor(t){this.Lg=new Map,this.Og=new Map,this.Fg=new Map,this.Wg=[],this.__=t}m(){this.Lg.clear(),this.Og.clear(),this.Fg.clear(),this.Wg=[]}Ng(t,i){let s=0!==this.Lg.size,n=!1;const e=this.Og.get(t);if(void 0!==e)if(1===this.Og.size)s=!1,n=!0,this.Lg.clear();else for(const i of this.Wg)i.pointData.Ag.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i.map(t=>t.time),e=this.__.createConverterToInternalObj(i),h=hn(t.Dr()),a=t.da(),l=t.pa();r=i.map((i,r)=>{const o=e(i.time),_=this.__.key(o);let c=this.Lg.get(_);void 0===c&&(c=an(o),this.Lg.set(_,c),n=!0);const u=h(o,c.De,i,s[r],a,l);return c.Ag.set(t,u),u})}s&&this.Hg(),this.Ug(t,r);let h=-1;if(n){const t=[];this.Lg.forEach(i=>{t.push({timeWeight:0,time:i.Uh,pointData:i,originalTime:on(i.Ag)})}),t.sort((t,i)=>this.__.key(t.time)-this.__.key(i.time)),h=this.$g(t)}return this.jg(t,h,function(t,i,s){const n=ln(t,s),e=ln(i,s);if(void 0!==n&&void 0!==e)return{qg:!1,Lh:n.zg>=e.zg&&n.Ig>=e.Ig}}(this.Og.get(t),e,this.__))}zu(t){return this.Ng(t,[])}Yg(t,i,s){const n=i;!function(t){void 0===t.Pg&&(t.Pg=t.time)}(n),this.__.preprocessData(i);const e=this.__.createConverterToInternalObj([i])(i.time),r=this.Fg.get(t);if(!s&&void 0!==r&&this.__.key(e)<this.__.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${e}`);let h=this.Lg.get(this.__.key(e));if(s&&void 0===h)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const a=void 0===h;void 0===h&&(h=an(e),this.Lg.set(this.__.key(e),h));const l=hn(t.Dr()),o=t.da(),_=t.pa(),c=l(e,h.De,i,n.Pg,o,_);h.Ag.set(t,c),s?this.Kg(t,c,h.De):this.Xg(t,c);const u={Lh:nn(c),qg:s};if(!a)return this.jg(t,-1,u);const d={timeWeight:0,time:h.Uh,pointData:h,originalTime:on(h.Ag)},f=St(this.Wg,this.__.key(d.time),(t,i)=>this.__.key(t.time)<i);this.Wg.splice(f,0,d);for(let t=f;t<this.Wg.length;++t)cn(this.Wg[t].pointData,t);return this.__.fillWeightsForPoints(this.Wg,f),this.jg(t,f,u)}Gg(t,i){const s=this.Og.get(t);if(void 0===s||i<=0)return[[],this.Zg()];i=Math.min(i,s.length);const n=s.splice(-i).reverse();0===s.length?this.Fg.delete(t):this.Fg.set(t,s[s.length-1].wt);for(const i of n){const s=this.Lg.get(this.__.key(i.wt));if(s&&(s.Ag.delete(t),0===s.Ag.size)){this.Lg.delete(this.__.key(s.Uh)),this.Wg.splice(s.De,1);for(let t=s.De;t<this.Wg.length;++t)cn(this.Wg[t].pointData,t)}}return[n,this.jg(t,this.Wg.length-1,{qg:!1,Lh:!1})]}Xg(t,i){let s=this.Og.get(t);void 0===s&&(s=[],this.Og.set(t,s));const n=0!==s.length?s[s.length-1]:null;null===n||this.__.key(i.wt)>this.__.key(n.wt)?nn(i)&&s.push(i):nn(i)?s[s.length-1]=i:s.splice(-1,1),this.Fg.set(t,i.wt)}Kg(t,i,s){const n=this.Og.get(t);if(void 0===n)return;const e=St(n,s,(t,i)=>t.De<i);nn(i)?n[e]=i:n.splice(e,1)}Ug(t,i){0!==i.length?(this.Og.set(t,i.filter(nn)),this.Fg.set(t,i[i.length-1].wt)):(this.Og.delete(t),this.Fg.delete(t))}Hg(){for(const t of this.Wg)0===t.pointData.Ag.size&&this.Lg.delete(this.__.key(t.time))}$g(t){let i=-1;for(let s=0;s<this.Wg.length&&s<t.length;++s){const n=this.Wg[s],e=t[s];if(this.__.key(n.time)!==this.__.key(e.time)){i=s;break}e.timeWeight=n.timeWeight,cn(e.pointData,s)}if(-1===i&&this.Wg.length!==t.length&&(i=Math.min(this.Wg.length,t.length)),-1===i)return-1;for(let s=i;s<t.length;++s)cn(t[s].pointData,s);return this.__.fillWeightsForPoints(t,i),this.Wg=t,i}Jg(){if(0===this.Og.size)return null;let t=0;return this.Og.forEach(i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].De))}),t}jg(t,i,s){const n=this.Zg();if(-1!==i)this.Og.forEach((i,e)=>{n.Fo.set(e,{ne:i,Qg:e===t?s:void 0})}),this.Og.has(t)||n.Fo.set(t,{ne:[],Qg:s}),n.It.tw=this.Wg,n.It.iw=i;else{const i=this.Og.get(t);n.Fo.set(t,{ne:i||[],Qg:s})}return n}Zg(){return{Fo:new Map,It:{uc:this.Jg()}}}}function cn(t,i){t.De=i,t.Ag.forEach(t=>{t.De=i})}function un(t,i){return t.wt<i}function dn(t,i){return i<t.wt}function fn(t,i,s){const n=i.$h(),e=i.Si(),r=St(t,n,un),h=xt(t,e,dn);if(!s)return{from:r,to:h};let a=r,l=h;return r>0&&r<t.length&&t[r].wt>=n&&(a=r-1),h>0&&h<t.length&&t[h-1].wt<=e&&(l=h+1),{from:a,to:l}}class pn{constructor(t,i,s){this.sw=!0,this.nw=!0,this.ew=!0,this.rw=[],this.hw=null,this.Qn=t,this.te=i,this.aw=s}kt(t){this.sw=!0,"data"===t&&(this.nw=!0),"options"===t&&(this.ew=!0)}Rt(){return this.Qn.Bt()?(this.lw(),null===this.hw?null:this.ow):null}_w(){this.rw=this.rw.map(t=>({...t,...this.Qn.Dh().Er(t.wt)}))}cw(){this.hw=null}lw(){this.nw&&(this.uw(),this.nw=!1),this.ew&&(this._w(),this.ew=!1),this.sw&&(this.dw(),this.sw=!1)}dw(){const t=this.Qn.Nt(),i=this.te.It();if(this.cw(),i.Xi()||t.Xi())return;const s=i.Pe();if(null===s)return;if(0===this.Qn.Gs().Lr())return;const n=this.Qn.Lt();null!==n&&(this.hw=fn(this.rw,s,this.aw),this.fw(t,i,n.Ht),this.pw())}}class vn{constructor(t,i){this.mw=t,this.Yi=i}et(t,i,s){this.mw.draw(t,this.Yi,i,s)}}class mn extends pn{constructor(t,i,s){super(t,i,!1),this.nh=s,this.ow=new vn(this.nh.renderer(),i=>{const s=t.Lt();return null===s?null:t.Nt().Wt(i,s.Ht)})}fa(t){return this.nh.priceValueBuilder(t)}va(t){return this.nh.isWhitespace(t)}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>({wt:i.De,ct:NaN,...t.Er(i.De),gw:i.ne}))}fw(t,i){i.dc(this.rw,m(this.hw))}pw(){this.nh.update({bars:this.rw.map(gn),barSpacing:this.te.It().Mc(),visibleRange:this.hw},this.Qn.W())}}function gn(t){return{x:t.ct,time:t.wt,originalData:t.gw,barColor:t.dr}}const wn={color:"#2196f3"},Mn=(t,i,s)=>{const n=l(s);return new mn(t,i,n)};function bn(t){const i={value:t.Ht[3],time:t.Pg};return void 0!==t.Vg&&(i.customValues=t.Vg),i}function Sn(t){const i=bn(t);return void 0!==t.D&&(i.color=t.D),i}function xn(t){const i=bn(t);return void 0!==t.gt&&(i.lineColor=t.gt),void 0!==t.gr&&(i.topColor=t.gr),void 0!==t.wr&&(i.bottomColor=t.wr),i}function yn(t){const i=bn(t);return void 0!==t.Mr&&(i.topLineColor=t.Mr),void 0!==t.br&&(i.bottomLineColor=t.br),void 0!==t.Sr&&(i.topFillColor1=t.Sr),void 0!==t.yr&&(i.topFillColor2=t.yr),void 0!==t.Cr&&(i.bottomFillColor1=t.Cr),void 0!==t.Pr&&(i.bottomFillColor2=t.Pr),i}function Cn(t){const i={open:t.Ht[0],high:t.Ht[1],low:t.Ht[2],close:t.Ht[3],time:t.Pg};return void 0!==t.Vg&&(i.customValues=t.Vg),i}function Pn(t){const i=Cn(t);return void 0!==t.D&&(i.color=t.D),i}function kn(t){const i=Cn(t),{D:s,Ut:n,mr:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}function Tn(t){return{Area:xn,Line:Sn,Baseline:yn,Histogram:Sn,Bar:Pn,Candlestick:kn,Custom:Rn}[t]}function Rn(t){const i=t.Pg;return{...t.ne,time:i}}const Dn={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},En={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Bn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:g,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Vn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1},An={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function In(){return{addDefaultPane:!0,width:0,height:0,autoSize:!1,layout:Bn,crosshair:Dn,grid:En,overlayPriceScales:{...Vn},leftPriceScale:{...Vn,visible:!1},rightPriceScale:{...Vn,visible:!0},timeScale:An,localization:{locale:_s?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class zn{constructor(t,i,s){this.Uf=t,this.ww=i,this.Mw=s??0}applyOptions(t){this.Uf.ti().cu(this.ww,t,this.Mw)}options(){return this.Yi().W()}width(){return q(this.ww)?this.Uf._g(this.ww):0}setVisibleRange(t){this.setAutoScale(!1),this.Yi().Nl(new dt(t.from,t.to))}getVisibleRange(){let t,i,s=this.Yi().tr();if(null===s)return null;if(this.Yi().Qa()){const n=this.Yi().po(),e=Li(n);s=li(s,this.Yi().il()),t=Number((Math.round(s.je()/n)*n).toFixed(e)),i=Number((Math.round(s.qe()/n)*n).toFixed(e))}else t=s.je(),i=s.qe();return{from:t,to:i}}setAutoScale(t){this.applyOptions({autoScale:t})}Yi(){return a(this.Uf.ti().uu(this.ww,this.Mw)).Nt}}class Ln{constructor(t,i,s,n){this.Uf=t,this.Pt=s,this.bw=i,this.Sw=n}getHeight(){return this.Pt.jt()}setHeight(t){const i=this.Uf.ti(),s=i.$u(this.Pt);i.mu(s,t)}getStretchFactor(){return this.Pt.Vo()}setStretchFactor(t){this.Pt.Ao(t),this.Uf.ti().Ah()}paneIndex(){return this.Uf.ti().$u(this.Pt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&t<this.Uf.jf().length,"Invalid pane index"),this.Uf.ti().wu(i,t))}getSeries(){return this.Pt.Fo().map(t=>this.bw(t))??[]}getHTMLElement(){const t=this.Uf.jf();return t&&0!==t.length&&t[this.paneIndex()]?t[this.paneIndex()].Zf():null}attachPrimitive(t){this.Pt.ca(t),t.attached&&t.attached({chart:this.Sw,requestUpdate:()=>this.Pt.ti().Ah()})}detachPrimitive(t){this.Pt.ua(t)}priceScale(t){if(null===this.Pt.Eo(t))throw new Error(`Cannot find price scale with id: ${t}`);return new zn(this.Uf,t,this.paneIndex())}setPreserveEmptyPane(t){this.Pt.Lo(t)}preserveEmptyPane(){return this.Pt.Oo()}addCustomSeries(t,i={},s=0){return this.Sw.addCustomSeries(t,i,s)}addSeries(t,i={}){return this.Sw.addSeries(t,i,this.paneIndex())}}const On={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Fn{constructor(t){this.sr=t}applyOptions(t){this.sr.ar(t)}options(){return this.sr.W()}xw(){return this.sr}}class Wn{constructor(t,i,s,n,e,r){this.yw=new o,this.Qn=t,this.Cw=i,this.Pw=s,this.__=e,this.Sw=n,this.kw=r}m(){this.yw.m()}priceFormatter(){return this.Qn.ra()}priceToCoordinate(t){const i=this.Qn.Lt();return null===i?null:this.Qn.Nt().Wt(t,i.Ht)}coordinateToPrice(t){const i=this.Qn.Lt();return null===i?null:this.Qn.Nt().Rs(t,i.Ht)}barsInLogicalRange(t){if(null===t)return null;const i=new Ti(new Ci(t.from,t.to)).k_(),s=this.Qn.Gs();if(s.Xi())return null;const n=s.Nr(i.$h(),1),e=s.Nr(i.Si(),-1),r=a(s.Or()),h=a(s.Xs());if(null!==n&&null!==e&&n.De>e.De)return{barsBefore:t.from-r,barsAfter:h-t.to};const l={barsBefore:null===n||n.De===r?t.from-r:n.De-r,barsAfter:null===e||e.De===h?h-t.to:h-e.De};return null!==n&&null!==e&&(l.from=n.Pg,l.to=e.Pg),l}setData(t){this.__,this.Qn.Dr(),this.Cw.Tw(this.Qn,t),this.Rw("full")}update(t,i=!1){this.Qn.Dr(),this.Cw.Dw(this.Qn,t,i),this.Rw("update")}pop(t=1){const i=this.Cw.Ew(this.Qn,t);0!==i.length&&this.Rw("update");const s=Tn(this.seriesType());return i.map(t=>s(t))}dataByIndex(t,i){const s=this.Qn.Gs().Nr(t,i);if(null===s)return null;return Tn(this.seriesType())(s)}data(){const t=Tn(this.seriesType());return this.Qn.Gs().Ur().map(i=>t(i))}subscribeDataChanged(t){this.yw.i(t)}unsubscribeDataChanged(t){this.yw._(t)}applyOptions(t){this.Qn.ar(t)}options(){return p(this.Qn.W())}priceScale(){return this.Pw.priceScale(this.Qn.Nt().ga(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(On),t),s=this.Qn.Fh(i);return new Fn(s)}removePriceLine(t){this.Qn.Wh(t.xw())}priceLines(){return this.Qn.Nh().map(t=>new Fn(t))}seriesType(){return this.Qn.Dr()}lastValueData(t){const i=this.Qn.ke(t);return i.Te?{noData:!0}:{noData:!1,price:i.Mt,color:i.D}}attachPrimitive(t){this.Qn.ca(t),t.attached&&t.attached({chart:this.Sw,series:this,requestUpdate:()=>this.Qn.ti().Ah(),horzScaleBehavior:this.__})}detachPrimitive(t){this.Qn.ua(t),t.detached&&t.detached(),this.Qn.ti().Ah()}getPane(){const t=this.Qn,i=a(this.Qn.ti().Un(t));return this.kw(i)}moveToPane(t){this.Qn.ti().Wu(this.Qn,t)}seriesOrder(){const t=this.Qn.ti().Un(this.Qn);return null===t?-1:t.Fo().indexOf(this.Qn)}setSeriesOrder(t){const i=this.Qn.ti().Un(this.Qn);null!==i&&i.t_(this.Qn,t)}Rw(t){this.yw.v()&&this.yw.p(t)}}class Nn{constructor(t,i,s){this.Bw=new o,this.L_=new o,this.Mm=new o,this.ss=t,this.dh=t.It(),this.Zm=i,this.dh.Ac().i(this.Vw.bind(this)),this.dh.Ic().i(this.Aw.bind(this)),this.Zm.km().i(this.Iw.bind(this)),this.__=s}m(){this.dh.Ac().u(this),this.dh.Ic().u(this),this.Zm.km().u(this),this.Bw.m(),this.L_.m(),this.Mm.m()}scrollPosition(){return this.dh.Sc()}scrollToPosition(t,i){i?this.dh.Ec(t,1e3):this.ss.pn(t)}scrollToRealTime(){this.dh.Dc()}getVisibleRange(){const t=this.dh.rc();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.__.convertHorzItemToInternal(t.from),to:this.__.convertHorzItemToInternal(t.to)},s=this.dh.oc(i);this.ss.Ou(s)}getVisibleLogicalRange(){const t=this.dh.ec();return null===t?null:{from:t.$h(),to:t.Si()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.ss.Ou(t)}resetTimeScale(){this.ss.dn()}fitContent(){this.ss.Oc()}logicalToCoordinate(t){const i=this.ss.It();return i.Xi()?null:i.qt(t)}coordinateToLogical(t){return this.dh.Xi()?null:this.dh.fc(t)}timeToIndex(t,i){const s=this.__.convertHorzItemToInternal(t);return this.dh.tc(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.dh.qt(i)}coordinateToTime(t){const i=this.ss.It(),s=i.fc(t),n=i.ns(s);return null===n?null:n.originalTime}width(){return this.Zm.Jf().width}height(){return this.Zm.Jf().height}subscribeVisibleTimeRangeChange(t){this.Bw.i(t)}unsubscribeVisibleTimeRangeChange(t){this.Bw._(t)}subscribeVisibleLogicalRangeChange(t){this.L_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.L_._(t)}subscribeSizeChange(t){this.Mm.i(t)}unsubscribeSizeChange(t){this.Mm._(t)}applyOptions(t){this.dh.ar(t)}options(){return{...p(this.dh.W()),barSpacing:this.dh.Mc()}}Vw(){this.Bw.v()&&this.Bw.p(this.getVisibleRange())}Aw(){this.L_.v()&&this.L_.p(this.getVisibleLogicalRange())}Iw(t){this.Mm.p(t.width,t.height)}}function Hn(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Un{constructor(t,i,s){this.zw=new Map,this.Lw=new Map,this.Ow=new o,this.Fw=new o,this.Ww=new o,this.Kc=new WeakMap,this.Nw=new _n(i);const n=void 0===s?p(In()):_(p(In()),Hn(s));this.Hw=i,this.Uf=new qs(t,n,i),this.Uf.Gv().i(t=>{this.Ow.v()&&this.Ow.p(this.Uw(t()))},this),this.Uf.Zv().i(t=>{this.Fw.v()&&this.Fw.p(this.Uw(t()))},this),this.Uf.fu().i(t=>{this.Ww.v()&&this.Ww.p(this.Uw(t()))},this);const e=this.Uf.ti();this.$w=new Nn(e,this.Uf.sg(),this.Hw)}remove(){this.Uf.Gv().u(this),this.Uf.Zv().u(this),this.Uf.fu().u(this),this.$w.m(),this.Uf.m(),this.zw.clear(),this.Lw.clear(),this.Ow.m(),this.Fw.m(),this.Ww.m(),this.Nw.m()}resize(t,i,s){this.autoSizeActive()||this.Uf.Qm(t,i,s)}addCustomSeries(t,i={},s=0){const n=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...wn,...t.defaultOptions()},jw:Mn,qw:t}))(l(t));return this.Yw(n,i,s)}addSeries(t,i={},s=0){return this.Yw(t,i,s)}removeSeries(t){const i=h(this.zw.get(t)),s=this.Nw.zu(i);this.Uf.ti().zu(i),this.Kw(s),this.zw.delete(t),this.Lw.delete(i)}Tw(t,i){this.Kw(this.Nw.Ng(t,i))}Dw(t,i,s){this.Kw(this.Nw.Yg(t,i,s))}Ew(t,i){const[s,n]=this.Nw.Gg(t,i);return 0!==s.length&&this.Kw(n),s}subscribeClick(t){this.Ow.i(t)}unsubscribeClick(t){this.Ow._(t)}subscribeCrosshairMove(t){this.Ww.i(t)}unsubscribeCrosshairMove(t){this.Ww._(t)}subscribeDblClick(t){this.Fw.i(t)}unsubscribeDblClick(t){this.Fw._(t)}priceScale(t,i=0){return new zn(this.Uf,t,i)}timeScale(){return this.$w}applyOptions(t){this.Uf.ar(Hn(t))}options(){return this.Uf.W()}takeScreenshot(t=!1,i=!1){let s,n;try{i||(s=this.Uf.ti().W().crosshair.mode,this.Uf.ar({crosshair:{mode:2}})),n=this.Uf.lg(t)}finally{i||void 0===s||this.Uf.ti().ar({crosshair:{mode:s}})}return n}addPane(t=!1){const i=this.Uf.ti().ju();return i.Lo(t),this.Xw(i)}removePane(t){this.Uf.ti().vu(t)}swapPanes(t,i){this.Uf.ti().gu(t,i)}autoSizeActive(){return this.Uf.dg()}chartElement(){return this.Uf.sp()}panes(){return this.Uf.ti().js().map(t=>this.Xw(t))}paneSize(t=0){const i=this.Uf.vg(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const n=this.zw.get(s);if(void 0===n)return;const e=this.Uf.ti().Un(n);null!==e&&this.Uf.ti().Du(t,i,e)}clearCrosshairPosition(){this.Uf.ti().Eu(!0)}horzBehaviour(){return this.Hw}Yw(i,s={},n=0){r(void 0!==i.jw),function(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=Li(i.minMove))}(s.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(s);const e=_(p(t),p(i.defaultOptions),s),h=i.jw,a=new $t(this.Uf.ti(),i.type,e,h,i.qw);this.Uf.ti().Au(a,n);const l=new Wn(a,this,this,this,this.Hw,t=>this.Xw(t));return this.zw.set(l,a),this.Lw.set(a,l),l}Kw(t){const i=this.Uf.ti();i.Bu(t.It.uc,t.It.tw,t.It.iw),t.Fo.forEach((t,i)=>i.lt(t.ne,t.Qg)),i.It().X_(),i.wc()}Gw(t){return h(this.Lw.get(t))}Uw(t){const i=new Map;t.Dg.forEach((t,s)=>{const n=s.Dr(),e=Tn(n)(t);if("Custom"!==n)r(Xs(e));else{const t=s.pa();r(!t||!1===t(e))}i.set(this.Gw(s),e)});const s=void 0!==t.Rg&&this.Lw.has(t.Rg)?this.Gw(t.Rg):void 0;return{time:t.Pg,logical:t.De,point:t.kg,paneIndex:t.Tg,hoveredSeries:s,hoveredObjectId:t.Eg,seriesData:i,sourceEvent:t.Bg}}Xw(t){let i=this.Kc.get(t);return i||(i=new Ln(this.Uf,t=>this.Gw(t),t,this),this.Kc.set(t,i)),i}}function $n(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function jn(t,i,s){const n=$n(t),e=new Un(n,i,s);return i.setOptions(e.options()),e}function qn(t,i){return jn(t,new ss,ss.od(i))}function Yn(){return ss}class Kn extends pn{constructor(t,i){super(t,i,!0)}fw(t,i,s){i.dc(this.rw,m(this.hw)),t.$l(this.rw,s,m(this.hw))}Zw(t,i){return{wt:t,Mt:i,ct:NaN,ut:NaN}}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>{const s=i.Ht[3];return this.Jw(i.De,s,t)})}}function Xn(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:o}=t,_=i[n.from];let c=r(t,_),u=_;if(n.to-n.from<2){const i=e/2;a.beginPath();const s={ct:_.ct-i,ut:_.ut},n={ct:_.ct+i,ut:_.ut};a.moveTo(s.ct*l,s.ut*o),a.lineTo(n.ct*l,n.ut*o),h(t,c,s,n)}else{const e=(i,s)=>{h(t,c,u,s),a.beginPath(),c=i,u=s};let d=u;a.beginPath(),a.moveTo(_.ct*l,_.ut*o);for(let h=n.from+1;h<n.to;++h){d=i[h];const n=r(t,d);switch(s){case 0:a.lineTo(d.ct*l,d.ut*o);break;case 1:a.lineTo(d.ct*l,i[h-1].ut*o),n!==c&&(e(n,d),a.lineTo(d.ct*l,i[h-1].ut*o)),a.lineTo(d.ct*l,d.ut*o);break;case 2:{const[t,s]=Qn(i,h-1,h);a.bezierCurveTo(t.ct*l,t.ut*o,s.ct*l,s.ut*o,d.ct*l,d.ut*o);break}}1!==s&&n!==c&&(e(n,d),a.moveTo(d.ct*l,d.ut*o))}(u!==d||u===d&&1===s)&&h(t,c,u,d)}}const Gn=6;function Zn(t,i){return{ct:t.ct-i.ct,ut:t.ut-i.ut}}function Jn(t,i){return{ct:t.ct/i,ut:t.ut/i}}function Qn(t,i,s){const n=Math.max(0,i-1),e=Math.min(t.length-1,s+1);var r,h;return[(r=t[i],h=Jn(Zn(t[s],t[n]),Gn),{ct:r.ct+h.ct,ut:r.ut+h.ut}),Zn(t[s],Jn(Zn(t[e],t[i]),Gn))]}function te(t,i){const s=t.context;s.strokeStyle=i,s.stroke()}class ie extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt(t){if(null===this.ht)return;const{_t:i,ot:s,Qw:e,tM:r,dt:h,Gt:a,iM:l}=this.ht;if(null===s)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,n(o,a),o.lineJoin="round";const _=this.sM.bind(this);void 0!==r&&Xn(t,i,r,s,e,_,te),l&&function(t,i,s,n,e){if(n.to-n.from<=0)return;const{horizontalPixelRatio:r,verticalPixelRatio:h,context:a}=t;let l=null;const o=Math.max(1,Math.floor(r))%2/2,_=s*h+o;for(let s=n.to-1;s>=n.from;--s){const n=i[s];if(n){const i=e(t,n);i!==l&&(a.beginPath(),null!==l&&a.fill(),a.fillStyle=i,l=i);const s=Math.round(n.ct*r)+o,c=n.ut*h;a.moveTo(s,c),a.arc(s,c,_,0,2*Math.PI)}}a.fill()}(t,i,l,s,_)}}class se extends ie{sM(t,i){return i.gt}}class ne extends Kn{constructor(){super(...arguments),this.ow=new se}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.W(),i={_t:this.rw,Gt:t.lineStyle,tM:t.lineVisible?t.lineType:void 0,dt:t.lineWidth,iM:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,ot:this.hw,Qw:this.te.It().Mc()};this.ow.lt(i)}}const ee={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new ne(t,i)};function re(t,i){return t.weight>i.weight?t:i}function he(t){return t}class ae{constructor(){this.nM=new o,this.eM=function(t){let i=!1;return function(...s){i||(i=!0,queueMicrotask(()=>{t(...s),i=!1}))}}(()=>this.nM.p(this.rM)),this.rM=0}hM(){return this.nM}m(){this.nM.m()}options(){return this.Ps}setOptions(t){this.Ps=t}preprocessData(t){}updateFormatter(t){this.Ps&&(this.Ps.localization=t)}createConverterToInternalObj(t){return this.eM(),t=>(t>this.rM&&(this.rM=t),t)}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return this.aM(t)}formatTickmark(t){return this.aM(t.time)}maxTickMarkWeight(t){return t.reduce(re,t[0]).weight}fillWeightsForPoints(t,i){const s=t=>t%120==0?10:t%60==0?9:t%36==0?8:t%12==0?7:t%6==0?6:t%3==0?5:t%1==0?4:0;for(let n=i;n<t.length;++n)t[n].timeWeight=s(he(t[n].time));this.rM=t[t.length-1].time,this.eM()}aM(t){if(this.Ps.localization?.timeFormatter)return this.Ps.localization.timeFormatter(t);if(t<12)return`${t}M`;const i=Math.floor(t/12),s=t%12;return 0===s?`${i}Y`:`${i}Y${s}M`}}const le={yieldCurve:{baseResolution:1,minimumTimeRange:120,startTimeRange:0},timeScale:{ignoreWhitespaceIndices:!0},leftPriceScale:{visible:!0},rightPriceScale:{visible:!1},localization:{priceFormatter:t=>t.toFixed(3)+"%"}},oe={lastValueVisible:!1,priceLineVisible:!1};class _e extends Un{constructor(t,i){const s=_(le,i||{}),n=new ae;super(t,n,s),n.setOptions(this.options()),this._initWhitespaceSeries()}addSeries(t,i={},s=0){if(t.isBuiltIn&&!1===["Area","Line"].includes(t.type))throw new Error("Yield curve only support Area and Line series");const n={...oe,...i};return super.addSeries(t,n,s)}_initWhitespaceSeries(){const t=this.horzBehaviour(),i=this.addSeries(ee);let s;function n(n){const e=function(t,i){return{oe:Math.max(0,t.startTimeRange),_e:Math.max(0,t.minimumTimeRange,i||0),lM:Math.max(1,t.baseResolution)}}(t.options().yieldCurve,n),r=(({oe:t,_e:i,lM:s})=>`${t}~${i}~${s}`)(e);r!==s&&(s=r,i.setData(function({oe:t,_e:i,lM:s}){return Array.from({length:Math.floor((i-t)/s)+1},(i,n)=>({time:t+n*s}))}(e)))}n(0),t.hM().i(n)}}function ce(t,i){const s=$n(t);return new _e(s,i)}function ue(t,i){return t.weight>i.weight?t:i}class de{options(){return this.Ps}setOptions(t){this.Ps=t}preprocessData(t){}updateFormatter(t){this.Ps&&(this.Ps.localization=t)}createConverterToInternalObj(t){return t=>t}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return t.toFixed(this.Cn())}formatTickmark(t,i){return t.time.toFixed(this.Cn())}maxTickMarkWeight(t){return t.reduce(ue,t[0]).weight}fillWeightsForPoints(t,i){const s=t=>t===100*Math.ceil(t/100)?8:t===50*Math.ceil(t/50)?7:t===25*Math.ceil(t/25)?6:t===10*Math.ceil(t/10)?5:t===5*Math.ceil(t/5)?4:t===Math.ceil(t)?3:2*t===Math.ceil(2*t)?1:0;for(let n=i;n<t.length;++n)t[n].timeWeight=s(t[n].time)}Cn(){return this.Ps.localization.precision}}function fe(t,i){return jn(t,new de,i)}function pe(t,i,s,n,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:a}=i;r.lineTo(e.ct*h,t*a),r.lineTo(n.ct*h,t*a),r.closePath(),r.fillStyle=s,r.fill()}class ve extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt(t){if(null===this.ht)return;const{_t:i,ot:s,Qw:e,dt:r,Gt:h,tM:a}=this.ht,l=this.ht.oM??(this.ht._M?0:t.mediaSize.height);if(null===s)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,n(o,h),o.lineWidth=1,Xn(t,i,a,s,e,this.cM.bind(this),pe.bind(null,l))}}class me{uM(t,i){const s=this.dM,{fM:n,pM:e,vM:r,mM:h,oM:a,gM:l,wM:o}=i;if(void 0===this.MM||void 0===s||s.fM!==n||s.pM!==e||s.vM!==r||s.mM!==h||s.oM!==a||s.gM!==l||s.wM!==o){const{verticalPixelRatio:s}=t,_=a||l>0?s:1,c=l*_,u=o===t.bitmapSize.height?o:o*_,d=(a??0)*_,f=t.context.createLinearGradient(0,c,0,u);if(f.addColorStop(0,n),null!=a){const t=Kt((d-c)/(u-c),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.MM=f,this.dM=i}return this.MM}}class ge extends ve{constructor(){super(...arguments),this.bM=new me}cM(t,i){const s=this.ht;return this.bM.uM(t,{fM:i.Sr,pM:i.yr,vM:i.Cr,mM:i.Pr,oM:s.oM,gM:s.gM??0,wM:s.wM??t.bitmapSize.height})}}class we extends ie{constructor(){super(...arguments),this.SM=new me}sM(t,i){const s=this.ht;return this.SM.uM(t,{fM:i.Mr,pM:i.Mr,vM:i.br,mM:i.br,oM:s.oM,gM:s.gM??0,wM:s.wM??t.bitmapSize.height})}}class Me extends Kn{constructor(t,i){super(t,i),this.ow=new y,this.xM=new ge,this.yM=new we,this.ow.nt([this.xM,this.yM])}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.Lt();if(null===t)return;const i=this.Qn.W(),s=this.Qn.Nt().Wt(i.baseValue.price,t.Ht),n=this.te.It().Mc();if(null===this.hw||0===this.rw.length)return;let e,r;if(i.relativeGradient){e=this.rw[this.hw.from].ut,r=this.rw[this.hw.from].ut;for(let t=this.hw.from;t<this.hw.to;t++){const i=this.rw[t];i.ut<e&&(e=i.ut),i.ut>r&&(r=i.ut)}}this.xM.lt({_t:this.rw,dt:i.lineWidth,Gt:i.lineStyle,tM:i.lineType,oM:s,gM:e,wM:r,_M:!1,ot:this.hw,Qw:n}),this.yM.lt({_t:this.rw,dt:i.lineWidth,Gt:i.lineStyle,tM:i.lineVisible?i.lineType:void 0,iM:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,oM:s,gM:e,wM:r,ot:this.hw,Qw:n})}}const be={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new Me(t,i)};class Se extends ve{constructor(){super(...arguments),this.bM=new me}cM(t,i){return this.bM.uM(t,{fM:i.gr,pM:"",vM:"",mM:i.wr,gM:this.ht?.gM??0,wM:t.bitmapSize.height})}}class xe extends Kn{constructor(t,i){super(t,i),this.ow=new y,this.CM=new Se,this.PM=new se,this.ow.nt([this.CM,this.PM])}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.W();if(null===this.hw||0===this.rw.length)return;let i;if(t.relativeGradient){i=this.rw[this.hw.from].ut;for(let t=this.hw.from;t<this.hw.to;t++){const s=this.rw[t];s.ut<i&&(i=s.ut)}}this.CM.lt({tM:t.lineType,_t:this.rw,Gt:t.lineStyle,dt:t.lineWidth,oM:null,gM:i,_M:t.invertFilledArea,ot:this.hw,Qw:this.te.It().Mc()}),this.PM.lt({tM:t.lineVisible?t.lineType:void 0,_t:this.rw,Gt:t.lineStyle,dt:t.lineWidth,ot:this.hw,Qw:this.te.It().Mc(),iM:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}const ye={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new xe(t,i)};class Ce extends C{constructor(){super(...arguments),this.Yt=null,this.kM=0,this.TM=0}lt(t){this.Yt=t}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt.Gs.length||null===this.Yt.ot)return;if(this.kM=this.RM(i),this.kM>=2){Math.max(1,Math.floor(i))%2!=this.kM%2&&this.kM--}this.TM=this.Yt.DM?Math.min(this.kM,Math.floor(i)):this.kM;let n=null;const e=this.TM<=this.kM&&this.Yt.Mc>=Math.floor(1.5*i);for(let r=this.Yt.ot.from;r<this.Yt.ot.to;++r){const h=this.Yt.Gs[r];n!==h.dr&&(t.fillStyle=h.dr,n=h.dr);const a=Math.floor(.5*this.TM),l=Math.round(h.ct*i),o=l-a,_=this.TM,c=o+_-1,u=Math.min(h.Kl,h.Xl),d=Math.max(h.Kl,h.Xl),f=Math.round(u*s)-a,p=Math.round(d*s)+a,v=Math.max(p-f,this.TM);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.kM);if(e){if(this.Yt.EM){const i=l-m;let n=Math.max(f,Math.round(h.Yl*s)-a),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(i,n,o-i,e-n+1)}const i=l+m;let n=Math.max(f,Math.round(h.Gl*s)-a),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(c+1,n,i-c,e-n+1)}}}RM(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(a(this.Yt).Mc,t)))}}class Pe extends pn{constructor(t,i){super(t,i,!1)}fw(t,i,s){i.dc(this.rw,m(this.hw)),t.ql(this.rw,s,m(this.hw))}BM(t,i,s){return{wt:t,qh:i.Ht[0],Yh:i.Ht[1],Kh:i.Ht[2],Xh:i.Ht[3],ct:NaN,Yl:NaN,Kl:NaN,Xl:NaN,Gl:NaN}}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>this.Jw(i.De,i,t))}}class ke extends Pe{constructor(){super(...arguments),this.ow=new Ce}Jw(t,i,s){return{...this.BM(t,i,s),...s.Er(t)}}pw(){const t=this.Qn.W();this.ow.lt({Gs:this.rw,Mc:this.te.It().Mc(),EM:t.openVisible,DM:t.thinBars,ot:this.hw})}}const Te={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},jw:(t,i)=>new ke(t,i)};class Re extends C{constructor(){super(...arguments),this.Yt=null,this.kM=0}lt(t){this.Yt=t}rt(t){if(null===this.Yt||0===this.Yt.Gs.length||null===this.Yt.ot)return;const{horizontalPixelRatio:i}=t;if(this.kM=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Yt.Mc,i),this.kM>=2){Math.floor(i)%2!=this.kM%2&&this.kM--}const s=this.Yt.Gs;this.Yt.VM&&this.AM(t,s,this.Yt.ot),this.Yt.bi&&this.uv(t,s,this.Yt.ot);const n=this.IM(i);(!this.Yt.bi||this.kM>2*n)&&this.zM(t,s,this.Yt.ot)}AM(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",a=Math.min(Math.floor(e),Math.floor(this.Yt.Mc*e));a=Math.max(Math.floor(e),Math.min(a,this.kM));const l=Math.floor(.5*a);let o=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.vr!==h&&(n.fillStyle=s.vr,h=s.vr);const _=Math.round(Math.min(s.Yl,s.Gl)*r),c=Math.round(Math.max(s.Yl,s.Gl)*r),u=Math.round(s.Kl*r),d=Math.round(s.Xl*r);let f=Math.round(e*s.ct)-l;const p=f+a-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;n.fillRect(f,u,v,_-u),n.fillRect(f,c+1,v,d-c),o=p}}IM(t){let i=Math.floor(1*t);this.kM<=2*i&&(i=Math.floor(.5*(this.kM-1)));const s=Math.max(Math.floor(t),i);return this.kM<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}uv(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.IM(e);let l=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.pr!==h&&(n.fillStyle=s.pr,h=s.pr);let o=Math.round(s.ct*e)-Math.floor(.5*this.kM);const _=o+this.kM-1,c=Math.round(Math.min(s.Yl,s.Gl)*r),u=Math.round(Math.max(s.Yl,s.Gl)*r);if(null!==l&&(o=Math.max(l+1,o),o=Math.min(o,_)),this.Yt.Mc*e>2*a)B(n,o,c,_-o+1,u-c+1,a);else{const t=_-o+1;n.fillRect(o,c,t,u-c+1)}l=_}}zM(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.IM(e);for(let t=s.from;t<s.to;t++){const s=i[t];let l=Math.round(Math.min(s.Yl,s.Gl)*r),o=Math.round(Math.max(s.Yl,s.Gl)*r),_=Math.round(s.ct*e)-Math.floor(.5*this.kM),c=_+this.kM-1;if(s.dr!==h){const t=s.dr;n.fillStyle=t,h=t}this.Yt.bi&&(_+=a,l+=a,c-=a,o-=a),l>o||n.fillRect(_,l,c-_+1,o-l+1)}}}class De extends Pe{constructor(){super(...arguments),this.ow=new Re}Jw(t,i,s){return{...this.BM(t,i,s),...s.Er(t)}}pw(){const t=this.Qn.W();this.ow.lt({Gs:this.rw,Mc:this.te.It().Mc(),VM:t.wickVisible,bi:t.borderVisible,ot:this.hw})}}const Ee={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},jw:(t,i)=>new De(t,i)};class Be extends C{constructor(){super(...arguments),this.Yt=null,this.LM=[]}lt(t){this.Yt=t,this.LM=[]}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt._t.length||null===this.Yt.ot)return;this.LM.length||this.OM(i);const n=Math.max(1,Math.floor(s)),e=Math.round(this.Yt.FM*s)-Math.floor(n/2),r=e+n;for(let i=this.Yt.ot.from;i<this.Yt.ot.to;i++){const h=this.Yt._t[i],a=this.LM[i-this.Yt.ot.from],l=Math.round(h.ut*s);let o,_;t.fillStyle=h.dr,l<=e?(o=l,_=r):(o=e,_=l-Math.floor(n/2)+n),t.fillRect(a.$h,o,a.Si-a.$h+1,_-o)}}OM(t){if(null===this.Yt||0===this.Yt._t.length||null===this.Yt.ot)return void(this.LM=[]);const i=Math.ceil(this.Yt.Mc*t)<=1?0:Math.max(1,Math.floor(t)),s=Math.round(this.Yt.Mc*t)-i;this.LM=new Array(this.Yt.ot.to-this.Yt.ot.from);for(let i=this.Yt.ot.from;i<this.Yt.ot.to;i++){const n=this.Yt._t[i],e=Math.round(n.ct*t);let r,h;if(s%2){const t=(s-1)/2;r=e-t,h=e+t}else{const t=s/2;r=e-t,h=e+t-1}this.LM[i-this.Yt.ot.from]={$h:r,Si:h,WM:e,ee:n.ct*t,wt:n.wt}}for(let t=this.Yt.ot.from+1;t<this.Yt.ot.to;t++){const s=this.LM[t-this.Yt.ot.from],n=this.LM[t-this.Yt.ot.from-1];s.wt===n.wt+1&&(s.$h-n.Si!==i+1&&(n.WM>n.ee?n.Si=s.$h-i-1:s.$h=n.Si+i+1))}let n=Math.ceil(this.Yt.Mc*t);for(let t=this.Yt.ot.from;t<this.Yt.ot.to;t++){const i=this.LM[t-this.Yt.ot.from];i.Si<i.$h&&(i.Si=i.$h);const s=i.Si-i.$h+1;n=Math.min(s,n)}if(i>0&&n<4)for(let t=this.Yt.ot.from;t<this.Yt.ot.to;t++){const i=this.LM[t-this.Yt.ot.from];i.Si-i.$h+1>n&&(i.WM>i.ee?i.Si-=1:i.$h+=1)}}}class Ve extends Kn{constructor(){super(...arguments),this.ow=new Be}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t={_t:this.rw,Mc:this.te.It().Mc(),ot:this.hw,FM:this.Qn.Nt().Wt(this.Qn.W().base,a(this.Qn.Lt()).Ht)};this.ow.lt(t)}}const Ae={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},jw:(t,i)=>new Ve(t,i)};class Ie{constructor(t,i){this.Pt=t,this.NM=i,this.HM()}detach(){this.Pt.detachPrimitive(this.NM)}getPane(){return this.Pt}applyOptions(t){this.NM.ar?.(t)}HM(){this.Pt.attachPrimitive(this.NM)}}const ze={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},Le={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:g,fontStyle:"",text:""};class Oe{constructor(t){this.UM=new Map,this.Yt=t}draw(t){t.useMediaCoordinateSpace(t=>{if(!this.Yt.visible)return;const{context:i,mediaSize:s}=t;let n=0;for(const t of this.Yt.lines){if(0===t.text.length)continue;i.font=t.T;const e=this.$M(i,t.text);e>s.width?t.kc=s.width/e:t.kc=1,n+=t.lineHeight*t.kc}let e=0;switch(this.Yt.vertAlign){case"top":e=0;break;case"center":e=Math.max((s.height-n)/2,0);break;case"bottom":e=Math.max(s.height-n,0)}for(const t of this.Yt.lines){i.save(),i.fillStyle=t.color;let n=0;switch(this.Yt.horzAlign){case"left":i.textAlign="left",n=t.lineHeight/2;break;case"center":i.textAlign="center",n=s.width/2;break;case"right":i.textAlign="right",n=s.width-1-t.lineHeight/2}i.translate(n,e),i.textBaseline="top",i.font=t.T,i.scale(t.kc,t.kc),i.fillText(t.text,0,t.jM),i.restore(),e+=t.lineHeight*t.kc}})}$M(t,i){const s=this.qM(t.font);let n=s.get(i);return void 0===n&&(n=t.measureText(i).width,s.set(i,n)),n}qM(t){let i=this.UM.get(t);return void 0===i&&(i=new Map,this.UM.set(t,i)),i}}class Fe{constructor(t){this.Ps=Ne(t)}kt(t){this.Ps=Ne(t)}renderer(){return new Oe(this.Ps)}}function We(t){return{...t,T:w(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,jM:0,kc:0}}function Ne(t){return{...t,lines:t.lines.map(We)}}function He(t){return{...Le,...t}}function Ue(t){return{...ze,...t,lines:t.lines?.map(He)??[]}}class $e{constructor(t){this.Ps=Ue(t),this.YM=[new Fe(this.Ps)]}updateAllViews(){this.YM.forEach(t=>t.kt(this.Ps))}paneViews(){return this.YM}attached({requestUpdate:t}){this.KM=t}detached(){this.KM=void 0}ar(t){this.Ps=Ue({...this.Ps,...t}),this.KM&&this.KM()}}function je(t,i){return new Ie(t,new $e(i))}const qe={alpha:1,padding:0};class Ye{constructor(t){this.Yt=t}draw(t){t.useMediaCoordinateSpace(t=>{const i=t.context,s=this.XM(this.Yt,t.mediaSize);s&&this.Yt.GM&&(i.globalAlpha=this.Yt.alpha??1,i.drawImage(this.Yt.GM,s.ct,s.ut,s.ts,s.jt))})}XM(t,i){const{maxHeight:s,maxWidth:n,ZM:e,JM:r,padding:h}=t,a=Math.round(i.width/2),l=Math.round(i.height/2),o=h??0;let _=i.width-2*o,c=i.height-2*o;s&&(c=Math.min(c,s)),n&&(_=Math.min(_,n));const u=_/r,d=c/e,f=Math.min(u,d),p=r*f,v=e*f;return{ct:a-.5*p,ut:l-.5*v,jt:v,ts:p}}}class Ke{constructor(t){this.QM=null,this.tb=0,this.ib=0,this.Ps=t,this.M=Xe(this.Ps,this.QM,this.tb,this.ib)}sb(t){void 0!==t.nb&&(this.tb=t.nb),void 0!==t.eb&&(this.ib=t.eb),void 0!==t.rb&&(this.QM=t.rb),this.kt()}hb(t){this.Ps=t,this.kt()}zOrder(){return"bottom"}kt(){this.M=Xe(this.Ps,this.QM,this.tb,this.ib)}renderer(){return new Ye(this.M)}}function Xe(t,i,s,n){return{...t,GM:i,JM:s,ZM:n}}function Ge(t){return{...qe,...t}}class Ze{constructor(t,i){this.ab=null,this.lb=t,this.Ps=Ge(i),this.YM=[new Ke(this.Ps)]}updateAllViews(){this.YM.forEach(t=>t.kt())}paneViews(){return this.YM}attached(t){const{requestUpdate:i}=t;this.ob=i,this.ab=new Image,this.ab.onload=()=>{const t=this.ab?.naturalHeight??1,i=this.ab?.naturalWidth??1;this.YM.forEach(s=>s.sb({eb:t,nb:i,rb:this.ab})),this.ob&&this.ob()},this.ab.src=this.lb}detached(){this.ob=void 0,this.ab=null}ar(t){this.Ps=Ge({...this.Ps,...t}),this._b(),this.KM&&this.KM()}KM(){this.ob&&this.ob()}_b(){this.YM.forEach(t=>t.hb(this.Ps))}}function Je(t,i,s){return new Ie(t,new Ze(i,s))}class Qe{constructor(t,i){this.Qn=t,this.oh=i,this.HM()}detach(){this.Qn.detachPrimitive(this.oh)}getSeries(){return this.Qn}applyOptions(t){this.oh&&this.oh.ar&&this.oh.ar(t)}HM(){this.Qn.attachPrimitive(this.oh)}}const tr={autoScale:!0,zOrder:"normal"};function ir(t,i){return Gt(Math.min(Math.max(t,12),30)*i)}function sr(t,i){switch(t){case"arrowDown":case"arrowUp":return ir(i,1);case"circle":return ir(i,.8);case"square":return ir(i,.7)}}function nr(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(ir(t,1))}function er(t){return Math.max(ir(t,.1),3)}function rr(t,i,s){return i?t:s?Math.ceil(t/2):0}function hr(t,i,s,n){const e=(sr("arrowUp",n)-1)/2*s.cb,r=(Gt(n/2)-1)/2*s.cb;i.beginPath(),t?(i.moveTo(s.ct-e,s.ut),i.lineTo(s.ct,s.ut-e),i.lineTo(s.ct+e,s.ut),i.lineTo(s.ct+r,s.ut),i.lineTo(s.ct+r,s.ut+e),i.lineTo(s.ct-r,s.ut+e),i.lineTo(s.ct-r,s.ut)):(i.moveTo(s.ct-e,s.ut),i.lineTo(s.ct,s.ut+e),i.lineTo(s.ct+e,s.ut),i.lineTo(s.ct+r,s.ut),i.lineTo(s.ct+r,s.ut-e),i.lineTo(s.ct-r,s.ut-e),i.lineTo(s.ct-r,s.ut)),i.fill()}function ar(t,i,s,n,e,r){const h=(sr("arrowUp",n)-1)/2,a=(Gt(n/2)-1)/2;if(e>=i-a-2&&e<=i+a+2&&r>=(t?s:s-h)-2&&r<=(t?s+h:s)+2)return!0;return(()=>{if(e<i-h-3||e>i+h+3||r<(t?s-h-3:s)||r>(t?s:s+h+3))return!1;const n=Math.abs(e-i);return Math.abs(r-s)+3>=n/2})()}class lr{constructor(){this.Yt=null,this.Fn=new it,this.N=-1,this.H="",this.Hp="",this.ub="normal"}lt(t){this.Yt=t}Wn(t,i,s){this.N===t&&this.H===i||(this.N=t,this.H=i,this.Hp=w(t,i),this.Fn.Vn()),this.ub=s}Kn(t,i){if(null===this.Yt||null===this.Yt.ot)return null;for(let s=this.Yt.ot.from;s<this.Yt.ot.to;s++){const n=this.Yt._t[s];if(n&&_r(n,t,i))return{zOrder:"normal",externalId:n.Xn??""}}return null}draw(t){"aboveSeries"!==this.ub&&t.useBitmapCoordinateSpace(t=>{this.rt(t)})}drawBackground(t){"aboveSeries"===this.ub&&t.useBitmapCoordinateSpace(t=>{this.rt(t)})}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null!==this.Yt&&null!==this.Yt.ot){t.textBaseline="middle",t.font=this.Hp;for(let n=this.Yt.ot.from;n<this.Yt.ot.to;n++){const e=this.Yt._t[n];void 0!==e.hi&&(e.hi.ts=this.Fn.Bi(t,e.hi.fb),e.hi.jt=this.N,e.hi.ct=e.ct-e.hi.ts/2),or(e,t,i,s)}}}}function or(t,i,s,n){i.fillStyle=t.D,void 0!==t.hi&&function(t,i,s,n,e,r){t.save(),t.scale(e,r),t.fillText(i,s,n),t.restore()}(i,t.hi.fb,t.hi.ct,t.hi.ut,s,n),function(t,i,s){if(0===t.Lr)return;switch(t.pb){case"arrowDown":return void hr(!1,i,s,t.Lr);case"arrowUp":return void hr(!0,i,s,t.Lr);case"circle":return void function(t,i,s){const n=(sr("circle",s)-1)/2;t.beginPath(),t.arc(i.ct,i.ut,n*i.cb,0,2*Math.PI,!1),t.fill()}(i,s,t.Lr);case"square":return void function(t,i,s){const n=sr("square",s),e=(n-1)*i.cb/2,r=i.ct-e,h=i.ut-e;t.fillRect(r,h,n*i.cb,n*i.cb)}(i,s,t.Lr)}t.pb}(t,i,function(t,i,s){const n=Math.max(1,Math.floor(i))%2/2;return{ct:Math.round(t.ct*i)+n,ut:t.ut*s,cb:i}}(t,s,n))}function _r(t,i,s){return!(void 0===t.hi||!function(t,i,s,n,e,r){const h=n/2;return e>=t&&e<=t+s&&r>=i-h&&r<=i+h}(t.hi.ct,t.hi.ut,t.hi.ts,t.hi.jt,i,s))||function(t,i,s){if(0===t.Lr)return!1;switch(t.pb){case"arrowDown":return ar(!0,t.ct,t.ut,t.Lr,i,s);case"arrowUp":return ar(!1,t.ct,t.ut,t.Lr,i,s);case"circle":return function(t,i,s,n,e){const r=2+sr("circle",s)/2,h=t-n,a=i-e;return Math.sqrt(h*h+a*a)<=r}(t.ct,t.ut,t.Lr,i,s);case"square":return function(t,i,s,n,e){const r=sr("square",s),h=(r-1)/2,a=t-h,l=i-h;return n>=a&&n<=a+r&&e>=l&&e<=l+r}(t.ct,t.ut,t.Lr,i,s)}}(t,i,s)}function cr(t){return"atPriceTop"===t||"atPriceBottom"===t||"atPriceMiddle"===t}function ur(t,i,s,n,e,r,h,l){const o=function(t,i,s){if(cr(i.position)&&void 0!==i.price)return i.price;if("value"in(n=t)&&"number"==typeof n.value)return t.value;var n;if(function(t){return"open"in t&&"high"in t&&"low"in t&&"close"in t}(t)){if("inBar"===i.position)return t.close;if("aboveBar"===i.position)return s?t.low:t.high;if("belowBar"===i.position)return s?t.high:t.low}}(s,i,h.priceScale().options().invertScale);if(void 0===o)return;const _=cr(i.position),u=l.timeScale(),d=c(i.size)?Math.max(i.size,0):1,f=nr(u.options().barSpacing)*d,p=f/2;t.Lr=f;switch(i.position){case"inBar":case"atPriceMiddle":return t.ut=a(h.priceToCoordinate(o)),void(void 0!==t.hi&&(t.hi.ut=t.ut+p+r+.6*e));case"aboveBar":case"atPriceTop":{const i=_?0:n.mb;return t.ut=a(h.priceToCoordinate(o))-p-i,void 0!==t.hi&&(t.hi.ut=t.ut-p-.6*e,n.mb+=1.2*e),void(_||(n.mb+=f+r))}case"belowBar":case"atPriceBottom":{const i=_?0:n.gb;return t.ut=a(h.priceToCoordinate(o))+p+i,void 0!==t.hi&&(t.hi.ut=t.ut+p+r+.6*e,n.gb+=1.2*e),void(_||(n.gb+=f+r))}}}class dr{constructor(t,i,s){this.wb=[],this.yt=!0,this.Mb=!0,this.Jt=new lr,this.Me=t,this.Bp=i,this.Yt={_t:[],ot:null},this.Ps=s}renderer(){if(!this.Me.options().visible)return null;this.yt&&this.bb();const t=this.Bp.options().layout;return this.Jt.Wn(t.fontSize,t.fontFamily,this.Ps.zOrder),this.Jt.lt(this.Yt),this.Jt}Sb(t){this.wb=t,this.kt("data")}kt(t){this.yt=!0,"data"===t&&(this.Mb=!0)}xb(t){this.yt=!0,this.Ps=t}zOrder(){return"aboveSeries"===this.Ps.zOrder?"top":this.Ps.zOrder}bb(){const t=this.Bp.timeScale(),i=this.wb;this.Mb&&(this.Yt._t=i.map(t=>({wt:t.time,ct:0,ut:0,Lr:0,pb:t.shape,D:t.color,Xn:t.id,yb:t.yb,hi:void 0})),this.Mb=!1);const s=this.Bp.options().layout;this.Yt.ot=null;const n=t.getVisibleLogicalRange();if(null===n)return;const e=new Ci(Math.floor(n.from),Math.ceil(n.to));if(null===this.Me.data()[0])return;if(0===this.Yt._t.length)return;let r=NaN;const h=er(t.options().barSpacing),l={mb:h,gb:h};this.Yt.ot=fn(this.Yt._t,e,!0);for(let n=this.Yt.ot.from;n<this.Yt.ot.to;n++){const e=i[n];e.time!==r&&(l.mb=h,l.gb=h,r=e.time);const o=this.Yt._t[n];o.ct=a(t.logicalToCoordinate(e.time)),void 0!==e.text&&e.text.length>0&&(o.hi={fb:e.text,ct:0,ut:0,ts:0,jt:0});const _=this.Me.dataByIndex(e.time,0);null!==_&&ur(o,e,_,l,s.fontSize,h,this.Me,this.Bp)}this.yt=!1}}function fr(t){return{...tr,...t}}class pr{constructor(t){this.nh=null,this.wb=[],this.Cb=[],this.Pb=null,this.Me=null,this.Bp=null,this.kb=!0,this.Tb=null,this.Rb=null,this.Db=null,this.Eb=!0,this.Ps=fr(t)}attached(t){this.Bb(),this.Bp=t.chart,this.Me=t.series,this.nh=new dr(this.Me,a(this.Bp),this.Ps),this.ob=t.requestUpdate,this.Me.subscribeDataChanged(t=>this.Rw(t)),this.Eb=!0,this.KM()}KM(){this.ob&&this.ob()}detached(){this.Me&&this.Pb&&this.Me.unsubscribeDataChanged(this.Pb),this.Bp=null,this.Me=null,this.nh=null,this.Pb=null}Sb(t){this.Eb=!0,this.wb=t,this.Bb(),this.kb=!0,this.Rb=null,this.KM()}Vb(){return this.wb}paneViews(){return this.nh?[this.nh]:[]}updateAllViews(){this.Ab()}hitTest(t,i){return this.nh?this.nh.renderer()?.Kn(t,i)??null:null}autoscaleInfo(t,i){if(this.Ps.autoScale&&this.nh){const t=this.Ib();if(t)return{priceRange:null,margins:t}}return null}ar(t){this.Ps=fr({...this.Ps,...t}),this.KM&&this.KM()}Ib(){const t=a(this.Bp).timeScale().options().barSpacing;if(this.kb||t!==this.Db){if(this.Db=t,this.wb.length>0){const i=er(t),s=1.5*nr(t)+2*i,n=this.zb();this.Tb={above:rr(s,n.aboveBar,n.inBar),below:rr(s,n.belowBar,n.inBar)}}else this.Tb=null;this.kb=!1}return this.Tb}zb(){return null===this.Rb&&(this.Rb=this.wb.reduce((t,i)=>(t[i.position]||(t[i.position]=!0),t),{inBar:!1,aboveBar:!1,belowBar:!1,atPriceTop:!1,atPriceBottom:!1,atPriceMiddle:!1})),this.Rb}Bb(){if(!this.Eb||!this.Bp||!this.Me)return;const t=this.Bp.timeScale(),i=this.Me?.data();if(null==t.getVisibleLogicalRange()||!this.Me||0===i.length)return void(this.Cb=[]);const s=t.timeToIndex(a(i[0].time),!0);this.Cb=this.wb.map((i,n)=>{const e=t.timeToIndex(i.time,!0),r=e<s?1:-1,h=a(this.Me).dataByIndex(e,r),l={time:t.timeToIndex(a(h).time,!1),position:i.position,shape:i.shape,color:i.color,id:i.id,yb:n,text:i.text,size:i.size,price:i.price,Pg:i.time};if("atPriceTop"===i.position||"atPriceBottom"===i.position||"atPriceMiddle"===i.position){if(void 0===i.price)throw new Error(`Price is required for position ${i.position}`);return{...l,position:i.position,price:i.price}}return{...l,position:i.position,price:i.price}}),this.Eb=!1}Ab(t){this.nh&&(this.Bb(),this.nh.Sb(this.Cb),this.nh.xb(this.Ps),this.nh.kt(t))}Rw(t){this.Eb=!0,this.KM()}}class vr extends Qe{constructor(t,i,s){super(t,i),s&&this.setMarkers(s)}setMarkers(t){this.oh.Sb(t)}markers(){return this.oh.Vb()}}function mr(t,i,s){const n=new vr(t,new pr(s??{}));return i&&n.setMarkers(i),n}class gr{constructor(t){this.wb=new Map,this.Lb=t}Ob(t,i,s){if(this.Fb(i),void 0!==s){const n=window.setTimeout(()=>{this.wb.delete(i),this.Wb()},s),e={...t,Nb:n,Hb:Date.now()+s};this.wb.set(i,e)}else this.wb.set(i,{...t,Nb:void 0,Hb:void 0});this.Wb()}Fb(t){const i=this.wb.get(t);i&&void 0!==i.Nb&&window.clearTimeout(i.Nb),this.wb.delete(t),this.Wb()}Ub(){for(const[t]of this.wb)this.Fb(t)}$b(){const t=Date.now(),i=[];for(const[s,n]of this.wb)!n.Hb||n.Hb>t?i.push({time:n.time,sign:n.sign,value:n.value}):this.Fb(s);return i}jb(t){this.Lb=t}Wb(){this.Lb&&this.Lb()}}const wr={positiveColor:"#22AB94",negativeColor:"#F7525F",updateVisibilityDuration:5e3};class Mr{constructor(t,i,s,n){this.Yt=t,this.qb=i,this.Yb=s,this.Kb=n}draw(t){t.useBitmapCoordinateSpace(t=>{const i=t.context,s=Math.max(1,Math.floor(t.horizontalPixelRatio))%2/2,n=4*t.verticalPixelRatio+s;this.Yt.forEach(e=>{const r=Math.round(e.ct*t.horizontalPixelRatio)+s;i.beginPath();const h=this.Xb(e.Gb);i.fillStyle=h,i.arc(r,e.ut*t.verticalPixelRatio,n,0,2*Math.PI,!1),i.fill(),e.Gb&&(i.strokeStyle=h,i.lineWidth=Math.floor(2*t.horizontalPixelRatio),i.beginPath(),i.moveTo((e.ct-4.7)*t.horizontalPixelRatio+s,(e.ut-7*e.Gb)*t.verticalPixelRatio),i.lineTo(e.ct*t.horizontalPixelRatio+s,(e.ut-7*e.Gb-7*e.Gb*.5)*t.verticalPixelRatio),i.lineTo((e.ct+4.7)*t.horizontalPixelRatio+s,(e.ut-7*e.Gb)*t.verticalPixelRatio),i.stroke())})})}Xb(t){return 0===t?this.qb:t>0?this.Kb:this.Yb}}class br{constructor(t,i,s){this.Yt=[],this.Me=t,this.dh=i,this.Ps=s}kt(t){this.Yt=t.map(t=>{const i=this.Me.priceToCoordinate(t.value);if(null===i)return null;return{ct:a(this.dh.timeToCoordinate(t.time)),ut:i,Gb:t.sign}}).filter(v)}renderer(){const t=function(t,i){return function(t,i){return"Area"===i}(0,i)?t.lineColor:t.color}(this.Me.options(),this.Me.seriesType());return new Mr(this.Yt,t,this.Ps.negativeColor,this.Ps.positiveColor)}}function Sr(t,i){return"Line"===i||"Area"===i}class xr{constructor(t){this.Bp=void 0,this.Me=void 0,this.YM=[],this.__=null,this.Zb=new Map,this.Jb=new gr(()=>this.KM()),this.Ps={...wr,...t}}ar(t){this.Ps={...this.Ps,...t},this.KM()}Sb(t){this.Jb.Ub();const i=this.__;i&&t.forEach(t=>{this.Jb.Ob(t,i.key(t.time))})}Vb(){return this.Jb.$b()}KM(){this.ob?.()}attached(t){const{chart:i,series:s,requestUpdate:n,horzScaleBehavior:e}=t;this.Bp=i,this.Me=s,this.__=e;const r=this.Me.seriesType();if("Area"!==r&&"Line"!==r)throw new Error("UpDownMarkersPrimitive is only supported for Area and Line series types");this.YM=[new br(this.Me,this.Bp.timeScale(),this.Ps)],this.ob=n,this.KM()}detached(){this.Bp=void 0,this.Me=void 0,this.ob=void 0}qp(){return h(this.Bp)}Fo(){return h(this.Me)}updateAllViews(){this.YM.forEach(t=>t.kt(this.Vb()))}paneViews(){return this.YM}lt(t){if(!this.Me)throw new Error("Primitive not attached to series");const i=this.Me.seriesType();this.Zb.clear();const s=this.__;s&&t.forEach(t=>{Xs(t)&&Sr(0,i)&&this.Zb.set(s.key(t.time),t.value)}),h(this.Me).setData(t)}kt(t,i){if(!this.Me||!this.__)throw new Error("Primitive not attached to series");const s=this.Me.seriesType(),n=this.__.key(t.time);if(Ks(t)&&this.Zb.delete(n),Xs(t)&&Sr(0,s)){const i=this.Zb.get(n);i&&this.Jb.Ob({time:t.time,value:t.value,sign:yr(t.value,i)},n,this.Ps.updateVisibilityDuration)}h(this.Me).update(t,i)}Qb(){this.Jb.Ub()}}function yr(t,i){return t===i?0:t-i>0?1:-1}class Cr extends Qe{setData(t){return this.oh.lt(t)}update(t,i){return this.oh.kt(t,i)}markers(){return this.oh.Vb()}setMarkers(t){return this.oh.Sb(t)}clearMarkers(){return this.oh.Qb()}}function Pr(t,i={}){return new Cr(t,new xr(i))}function kr(t,i,s={}){const n=s.period??20,e=s.color??"#2196F3",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[];for(let e=n-1;e<i.length;e++){let r=0;for(let t=0;t<n;t++)r+=i[e-t];const h=r/n;t[e]&&t[e].time&&s.push({time:t[e].time,value:h})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating SMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Tr(t,i,s={}){const n=s.period??12,e=s.color??"#FF9800",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=2/(n+1);let r=0;for(let t=0;t<n;t++)r+=i[t];r/=n,t[n-1]&&t[n-1].time&&s.push({time:t[n-1].time,value:r});for(let h=n;h<i.length;h++)r=(i[h]-r)*e+r,t[h]&&t[h].time&&s.push({time:t[h].time,value:r});return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating EMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Rr(t,i,s={}){const n=s.period??20,e=s.color??"#4CAF50",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=n*(n+1)/2;for(let r=n-1;r<i.length;r++){let h=0;for(let t=0;t<n;t++){const s=t+1;h+=i[r-n+1+t]*s}const a=h/e;t[r]&&t[r].time&&s.push({time:t[r].time,value:a})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating WMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Dr(t,i,s={}){const n=s.period??20,e=s.stdDev??2,r=i.addSeries(ee,{color:s.colorUpper??"#3F51B5",lineWidth:1},0),h=i.addSeries(ee,{color:s.colorMiddle??"#2196F3",lineWidth:2},0),a=i.addSeries(ee,{color:s.colorLower??"#3F51B5",lineWidth:1},0),l=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return{tS:[],iS:[],sS:[]};const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],r=[],h=[];for(let a=n-1;a<i.length;a++){let l=0;for(let t=0;t<n;t++)l+=i[a-t];const o=l/n;let _=0;for(let t=0;t<n;t++)_+=Math.pow(i[a-t]-o,2);const c=Math.sqrt(_/n),u=o+c*e,d=o-c*e;if(t[a]&&t[a].time){const i=t[a].time;s.push({time:i,value:u}),r.push({time:i,value:o}),h.push({time:i,value:d})}}return{tS:s,iS:r,sS:h}})([...i]);s.tS.length>0&&(r.setData(s.tS),h.setData(s.iS),a.setData(s.sS))}catch(t){console.error("Error calculating Bollinger Bands:",t)}};return t.subscribeDataChanged(l),l(),{upper:r,middle:h,lower:a}}function Er(t,i,s={}){const n=s.period??14,e=s.color??"#9C27B0",r=i.addSeries(ee,{color:e,priceFormat:{type:"price",precision:2,minMove:.01}},1);r.priceScale().applyOptions({scaleMargins:{top:.1,bottom:.1},borderVisible:!1,autoScale:!1});const h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n+1)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=[];for(let t=1;t<i.length;t++)e.push(i[t]-i[t-1]);let r=0,h=0;for(let t=0;t<n;t++)e[t]>0?r+=e[t]:h+=Math.abs(e[t]);r/=n,h/=n;let a=0===h?100:r/h,l=100-100/(1+a);t[n]&&t[n].time&&s.push({time:t[n].time,value:l});for(let i=n;i<e.length;i++){const o=e[i],_=o>0?o:0,c=o<0?Math.abs(o):0;r=(r*(n-1)+_)/n,h=(h*(n-1)+c)/n,a=0===h?100:r/h,l=100-100/(1+a),t[i+1]&&t[i+1].time&&s.push({time:t[i+1].time,value:l})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating RSI:",t)}};return t.subscribeDataChanged(h),h(),r}function Br(t,i,s={}){const n=s.fastPeriod??12,e=s.slowPeriod??26,r=s.signalPeriod??9,h=i.addSeries(ee,{color:s.colorMACD??"#2196F3",lineWidth:2},2),a=i.addSeries(ee,{color:s.colorSignal??"#FF6D00",lineWidth:2},2),l=i.addSeries(Ae,{color:s.colorHistogram??"#26a69a"},2),o=(t,i)=>{const s=[],n=2/(i+1);let e=0;for(let s=0;s<i;s++)e+=t[s];s.push(e/i);for(let e=i;e<t.length;e++)s.push((t[e]-s[s.length-1])*n+s[s.length-1]);return s},_=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<e+r)return{nS:[],eS:[],rS:[]};const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=o(i,n),h=o(i,e),a=[],l=e-n;for(let t=0;t<h.length;t++)a.push(s[t+l]-h[t]);const _=o(a,r),c=[],u=[],d=[],f=e-1;for(let i=r-1;i<_.length;i++){const s=f+i;if(t[s]&&t[s].time){const n=t[s].time,e=a[i],r=_[i],h=e-r;c.push({time:n,value:e}),u.push({time:n,value:r}),d.push({time:n,value:h,color:h>=0?"#26a69a":"#ef5350"})}}return{nS:c,eS:u,rS:d}})([...i]);s.nS.length>0&&(h.setData(s.nS),a.setData(s.eS),l.setData(s.rS))}catch(t){console.error("Error calculating MACD:",t)}};return t.subscribeDataChanged(_),_(),{macd:h,signal:a,histogram:l}}function Vr(t,i,s={}){const n=s.kPeriod??14,e=s.dPeriod??3,r=i.addSeries(ee,{color:s.colorK??"#2196F3",lineWidth:2},4),h=i.addSeries(ee,{color:s.colorD??"#FF6D00",lineWidth:2},4);r.priceScale().applyOptions({scaleMargins:{top:.1,bottom:.1}});const a=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return{hS:[],aS:[]};const i=[];for(let s=n-1;s<t.length;s++){let e=-1/0,r=1/0;for(let i=0;i<n;i++){const n=t[s-i];"high"in n&&"low"in n&&(e=Math.max(e,n.high),r=Math.min(r,n.low))}const h=t[s];if("close"in h){const t=(h.close-r)/(e-r)*100;i.push(t)}}const s=[];for(let e=0;e<i.length;e++){const r=n-1+e;t[r]&&t[r].time&&s.push({time:t[r].time,value:i[e]})}const r=[];if(i.length>=e)for(let s=e-1;s<i.length;s++){let h=0;for(let t=0;t<e;t++)h+=i[s-t];const a=h/e,l=n-1+s;t[l]&&t[l].time&&r.push({time:t[l].time,value:a})}return{hS:s,aS:r}})([...i]);s.hS.length>0&&(r.setData(s.hS),h.setData(s.aS))}catch(t){console.error("Error calculating Stochastic:",t)}};return t.subscribeDataChanged(a),a(),{k:r,d:h}}function Ar(t,i,s={}){const n=s.period??14,e=s.color??"#FF9800",r=i.addSeries(ee,{color:e,lineWidth:2},6),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n+1)return[];const i=[];for(let s=1;s<t.length;s++){const n=t[s],e=t[s-1];if("high"in n&&"low"in n&&"close"in e){const t=n.high-n.low,s=Math.abs(n.high-e.close),r=Math.abs(n.low-e.close),h=Math.max(t,s,r);i.push(h)}}if(i.length<n)return[];const s=[];let e=0;for(let t=0;t<n;t++)e+=i[t];e/=n,t[n]&&t[n].time&&s.push({time:t[n].time,value:e});for(let r=n;r<i.length;r++)e=(e*(n-1)+i[r])/n,t[r+1]&&t[r+1].time&&s.push({time:t[r+1].time,value:e});return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating ATR:",t)}};return t.subscribeDataChanged(h),h(),r}const Ir=new Map;function zr(t,i,s={}){const n=s.colorUp??"#26a69a",e=s.colorDown??"#ef5350";Ir.has(t)||Ir.set(t,new Map);const r=i.addSeries(Ae,{color:n,priceFormat:{type:"volume"},priceScaleId:""},3);r.priceScale().applyOptions({scaleMargins:{top:.8,bottom:0}});const h=()=>{try{const i=(()=>{const i=t.data(),s=Ir.get(t);if(!i||0===i.length)return[];if(!s||0===s.size)return[];const r=[];for(const t of i){const i="string"==typeof t.time?t.time:String(t.time),h=s.get(i);h&&"close"in t&&"open"in t&&r.push({time:t.time,value:h,color:t.close>=t.open?n:e})}return r})();i.length>0&&r.setData(i)}catch(t){console.error("Error calculating Volume:",t)}};return t.subscribeDataChanged(h),h(),r}function Lr(t,i){Ir.has(t)||Ir.set(t,new Map);const s=Ir.get(t);s.clear();for(const t of i)if("time"in t&&"volume"in t){const i="string"==typeof t.time?t.time:String(t.time);s.set(i,t.volume)}}const Or=new Map;function Fr(t,i,s={}){const n=s.color??"#2196F3";Or.has(t)||Or.set(t,new Map);const e=i.addSeries(ee,{color:n,lineWidth:2},5),r=()=>{try{const i=(()=>{const i=t.data(),s=Or.get(t);if(!i||i.length<2)return[];if(!s||0===s.size)return[];const n=[];let e=0;n.push({time:i[0].time,value:e});for(let t=1;t<i.length;t++){const r=i[t],h=i[t-1],a="string"==typeof r.time?r.time:String(r.time),l=s.get(a);l&&"close"in r&&"close"in h&&(r.close>h.close?e+=l:r.close<h.close&&(e-=l),n.push({time:r.time,value:e}))}return n})();i.length>0&&e.setData(i)}catch(t){console.error("Error calculating OBV:",t)}};return t.subscribeDataChanged(r),r(),e}function Wr(t,i){Or.has(t)||Or.set(t,new Map);const s=Or.get(t);s.clear();for(const t of i)if("time"in t&&"volume"in t){const i="string"==typeof t.time?t.time:String(t.time);s.set(i,t.volume)}}class Nr{constructor(t,i,s){this.sr=null,this.lS=!1,this.Ep=null,this.oS=[],this._S=!1,this.cS="",this.Bp=t,this.Me=i,this.Ps={lineWidth:2,lineStyle:0,axisLabelVisible:!0,draggable:!0,...s},this.uS(),this.Ps.draggable&&this.dS()}uS(){this.cS=this.Ps.color,this.sr=this.Me.createPriceLine({price:this.Ps.price,color:this.Ps.color,lineWidth:this.Ps.lineWidth,lineStyle:this.Ps.lineStyle,axisLabelVisible:this.Ps.axisLabelVisible,title:this.Ps.title||""})}dS(){const t=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!t)return;this.Ep=t;const i=t=>{if(!this.fS(t))return;const i=this.pS(t.clientY);this.vS(t,i)&&(this.lS=!0,this.Ep.style.cursor="ns-resize",this.Ps.onDragStart&&this.Ps.onDragStart(this.Ps.price),t.preventDefault(),t.stopPropagation())},s=t=>{if(this.lS){const i=this.pS(t.clientY);this.mS(i),this.Ps.onDragMove&&this.Ps.onDragMove(i),t.preventDefault(),t.stopPropagation()}else{if(!this.fS(t))return void this.gS(!1);const i=this.pS(t.clientY);this.vS(t,i)?(this.Ep.style.cursor="ns-resize",this.gS(!0)):(this.Ep.style.cursor="default",this.gS(!1))}},n=t=>{this.lS&&(this.lS=!1,this.Ep.style.cursor="default",this.gS(!1),this.Ps.onDragEnd&&this.Ps.onDragEnd(this.Ps.price))},e=t=>{this.lS?(this.lS=!1,this.gS(!1),this.Ps.onDragEnd&&this.Ps.onDragEnd(this.Ps.price)):this.gS(!1)};this.Ep.addEventListener("mousedown",i),this.Ep.addEventListener("mousemove",s),this.Ep.addEventListener("mouseup",n),this.Ep.addEventListener("mouseleave",e),this.oS.push(()=>{this.Ep?.removeEventListener("mousedown",i),this.Ep?.removeEventListener("mousemove",s),this.Ep?.removeEventListener("mouseup",n),this.Ep?.removeEventListener("mouseleave",e)})}pS(t){try{const i=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!i)return this.Ps.price;const s=t-i.getBoundingClientRect().top,n=this.Me.coordinateToPrice(s);return null===n?this.Ps.price:n}catch(t){return console.error("Error getting price from Y:",t),this.Ps.price}}vS(t,i){const s=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!s)return!1;const n=this.Me.priceToCoordinate(this.Ps.price);if(null===n)return!1;const e=s.getBoundingClientRect(),r=t.clientY-e.top;return Math.abs(r-n)<=5}fS(t){if(!this.Ep)return!1;const i=this.Ep.getBoundingClientRect();return t.clientX-i.left<i.width-80}gS(t){this._S!==t&&this.sr&&(this._S=t,t?this.sr.applyOptions({color:"#000000"}):this.sr.applyOptions({color:this.cS}))}mS(t){this.Ps.price=t,this.sr&&this.sr.applyOptions({price:t})}applyOptions(t){this.Ps={...this.Ps,...t},t.color&&(this.cS=t.color),this.sr&&void 0!==t.price&&this.sr.applyOptions({price:t.price,color:t.color,lineWidth:t.lineWidth,lineStyle:t.lineStyle,title:t.title})}getPrice(){return this.Ps.price}setPrice(t){this.mS(t)}remove(){this.oS.forEach(t=>t()),this.oS=[],this.gS(!1),this.sr&&(this.Me.removePriceLine(this.sr),this.sr=null),this.Ep&&(this.Ep.style.cursor="default")}getPriceLine(){return this.sr}}function Hr(t,i,s){const n={"stop-loss":{color:"#ef5350",lineStyle:2,title:"Stop Loss",draggable:!0},"take-profit":{color:"#26a69a",lineStyle:2,title:"Take Profit",draggable:!0},entry:{color:"#2196F3",lineStyle:0,title:"Entry",draggable:!0},target:{color:"#FF9800",lineStyle:2,title:"Target",draggable:!0},resistance:{color:"#f44336",lineStyle:0,title:"Resistance",draggable:!0},support:{color:"#4CAF50",lineStyle:0,title:"Support",draggable:!0},custom:{color:"#9E9E9E",lineStyle:0,title:"",draggable:!0}},e=s.type?n[s.type]:n.custom,r={price:s.price,color:s.color??e.color??"#9E9E9E",lineWidth:s.lineWidth??2,lineStyle:s.lineStyle??e.lineStyle??0,title:s.title??e.title??"",axisLabelVisible:s.axisLabelVisible??!0,draggable:s.draggable??e.draggable??!0,onDragStart:s.onDragStart,onDragMove:s.onDragMove,onDragEnd:s.onDragEnd};return new Nr(i,t,r)}class Ur{constructor(t,i){this.Ep=null,this.wS=null,this.MS=null,this.bS={},this.Bp=t,this.Me=i,this.SS()}SS(){const t=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");t&&(this.Ep=t)}xS(t){try{if(!this.Ep)return 0;const i=this.Ep.getBoundingClientRect(),s=t.clientY-i.top,n=this.Me.coordinateToPrice(s);return null===n?0:n}catch(t){return console.error("Error getting price from mouse event:",t),0}}enableClickToCreate(t,i){return this.Ep?(this.wS=t,this.bS=i||{},new Promise(t=>{this.Ep.style.cursor="crosshair",this.MS=i=>{const s=this.xS(i),n=this.yS(s);this.disableClickToCreate(),t(n)},this.Ep.addEventListener("click",this.MS)})):Promise.resolve(null)}disableClickToCreate(){this.Ep&&this.MS&&(this.Ep.removeEventListener("click",this.MS),this.Ep.style.cursor="default"),this.wS=null,this.MS=null,this.bS={}}yS(t){if(!this.wS)return null;let i;switch(this.wS){case"stop-loss":i={price:t,color:"#ef5350",lineWidth:2,title:"Stop Loss",draggable:!0,...this.bS};break;case"take-profit":i={price:t,color:"#26a69a",lineWidth:2,title:"Take Profit",draggable:!0,...this.bS};break;case"entry":i={price:t,color:"#2196F3",lineWidth:2,title:"Entry",draggable:!0,...this.bS};break;case"target":i={price:t,color:"#FF9800",lineWidth:2,title:"Target",draggable:!0,...this.bS};break;case"resistance":i={price:t,color:"#f44336",lineWidth:2,title:"Resistance",draggable:!0,...this.bS};break;case"support":i={price:t,color:"#4CAF50",lineWidth:2,title:"Support",draggable:!0,...this.bS};break;case"custom":i={price:t,color:"#9E9E9E",lineWidth:2,title:"Custom",draggable:!0,...this.bS};break;default:return null}return new Nr(this.Bp,this.Me,i)}getCreationMode(){return this.wS}isCreating(){return null!==this.wS}}function $r(t,i){return new Ur(t,i)}const jr={...t,color:"#2196f3"};function qr(){return"0.0.9-dev+202510282317"}export{ye as AreaSeries,Te as BarSeries,be as BaselineSeries,Ee as CandlestickSeries,Ai as ColorType,$ as CrosshairMode,Nr as DraggablePriceLine,Ae as HistogramSeries,Ur as InteractiveLineManager,Bi as LastPriceAnimationMode,ee as LineSeries,s as LineStyle,i as LineType,yt as MismatchDirection,Vi as PriceLineSource,di as PriceScaleMode,Ii as TickMarkType,Ei as TrackingModeExitMode,Ar as applyATR,Dr as applyBollingerBands,Tr as applyEMA,Br as applyMACD,Fr as applyOBV,Er as applyRSI,kr as applySMA,Vr as applyStochastic,zr as applyVolume,Rr as applyWMA,qn as createChart,jn as createChartEx,Je as createImageWatermark,$r as createInteractiveLineManager,fe as createOptionsChart,mr as createSeriesMarkers,je as createTextWatermark,Hr as createTradingLine,Pr as createUpDownMarkers,ce as createYieldCurveChart,jr as customSeriesDefaultOptions,Yn as defaultHorzScaleBehavior,Oi as isBusinessDay,Fi as isUTCTimestamp,Wr as setOBVVolumeData,Lr as setVolumeData,qr as version};
|
|
8
|
+
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,s;function n(t,i){const s={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(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,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"}(s||(s={}));class o{constructor(){this.t=[]}i(t,i,s){const n={h:t,l:i,o:!0===s};this.t.push(n)}_(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,s){const n=[...this.t];this.t=this.t.filter(t=>!t.o),n.forEach(n=>n.h(t,i,s))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:_(t[i],s[i]));return t}function c(t){return"number"==typeof t&&isFinite(t)}function u(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 s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?p(e):e);return s}function v(t){return null!==t}function m(t){return null===t?void 0:t}const g="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function w(t,i,s){return void 0===i&&(i=g),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,P:NaN,T:"",R:"",D:"",B:"",V:0,A:0,I:0,L:0,O:0},this.F=t}W(){const t=this.M,i=this.N(),s=this.H();return t.P===i&&t.R===s||(t.P=i,t.R=s,t.T=w(i,s),t.L=2.5/12*i,t.V=t.L,t.A=i/12*t.C,t.I=i/12*t.C,t.O=0),t.D=this.U(),t.B=this.$(),this.M}U(){return this.F.W().layout.textColor}$(){return this.F.j()}N(){return this.F.W().layout.fontSize}H(){return this.F.W().layout.fontFamily}}function b(t){return t<0?0:t>255?255:Math.round(t)||0}function S(t){return.199*t[0]+.687*t[1]+.114*t[2]}class x{constructor(t,i){this.q=new Map,this.Y=t,i&&(this.q=i)}K(t,i){if("transparent"===t)return t;const s=this.X(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}G(t){const i=this.X(t);return{Z:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,J:S(i)>160?"black":"white"}}tt(t){return S(this.X(t))}it(t,i,s){const[n,e,r,h]=this.X(t),[a,l,o,_]=this.X(i),c=[b(n+s*(a-n)),b(e+s*(l-e)),b(r+s*(o-r)),(u=h+s*(_-h),u<=0||u>1?Math.min(Math.max(u,0),1):Math.round(1e4*u)/1e4)];var u;return`rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3]})`}X(t){const i=this.q.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),n=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.q.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.q.set(t,e),e}}class y{constructor(){this.st=[]}nt(t){this.st=t}et(t,i,s){this.st.forEach(n=>{n.et(t,i,s)})}}class C{et(t,i,s){t.useBitmapCoordinateSpace(t=>this.rt(t,i,s))}}class P extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.ht||null===this.ht.ot)return;const n=this.ht.ot,e=this.ht,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=n.to-1;a>=n.from;--a){const n=e._t[a],l=Math.round(n.ct*i)+r,o=n.ut*s,_=h*s+r;t.moveTo(l,o),t.arc(l,o,_,0,2*Math.PI)}t.fill()};e.dt>0&&(t.fillStyle=e.ft,h(e.vt+e.dt)),t.fillStyle=e.gt,h(e.vt)}}function k(){return{_t:[{ct:0,ut:0,wt:0,Mt:0}],gt:"",ft:"",vt:0,dt:0,ot:null}}const T={from:0,to:1};class R{constructor(t,i,s){this.bt=new y,this.St=[],this.xt=[],this.yt=!0,this.F=t,this.Ct=i,this.Pt=s,this.bt.nt(this.St)}kt(t){this.Tt(),this.yt=!0}Rt(){return this.yt&&(this.Dt(),this.yt=!1),this.bt}Tt(){const t=this.Pt.Et();t.length!==this.St.length&&(this.xt=t.map(k),this.St=this.xt.map(t=>{const i=new P;return i.lt(t),i}),this.bt.nt(this.St))}Dt(){const t=2===this.Ct.W().mode||!this.Ct.Bt(),i=this.Pt.Vt(),s=this.Ct.At(),n=this.F.It();this.Tt(),i.forEach((i,e)=>{const r=this.xt[e],h=i.zt(s),a=i.Lt();!t&&null!==h&&i.Bt()&&null!==a?(r.gt=h.Ot,r.vt=h.vt,r.dt=h.Ft,r._t[0].Mt=h.Mt,r._t[0].ut=i.Nt().Wt(h.Mt,a.Ht),r.ft=h.Ut??this.F.$t(r._t[0].ut/i.Nt().jt()),r._t[0].wt=s,r._t[0].ct=n.qt(s),r.ot=T):r.ot=null})}}class D extends C{constructor(t){super(),this.Yt=t}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;const h=this.Yt.Kt.Bt,a=this.Yt.Xt.Bt;if(!h&&!a)return;const l=Math.round(this.Yt.ct*s),o=Math.round(this.Yt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.Yt.Kt.dt*s),t.strokeStyle=this.Yt.Kt.D,t.fillStyle=this.Yt.Kt.D,n(t,this.Yt.Kt.Gt),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Xt.dt*r),t.strokeStyle=this.Yt.Xt.D,t.fillStyle=this.Yt.Xt.D,n(t,this.Yt.Xt.Gt),e(t,o,0,i.width))}}class E{constructor(t,i){this.yt=!0,this.Zt={Kt:{dt:1,Gt:0,D:"",Bt:!1},Xt:{dt:1,Gt:0,D:"",Bt:!1},ct:0,ut:0},this.Jt=new D(this.Zt),this.Qt=t,this.Pt=i}kt(){this.yt=!0}Rt(t){return this.yt&&(this.Dt(),this.yt=!1),this.Jt}Dt(){const t=this.Qt.Bt(),i=this.Pt.ti().W().crosshair,s=this.Zt;if(2===i.mode)return s.Xt.Bt=!1,void(s.Kt.Bt=!1);s.Xt.Bt=t&&this.Qt.ii(this.Pt),s.Kt.Bt=t&&this.Qt.si(),s.Xt.dt=i.horzLine.width,s.Xt.Gt=i.horzLine.style,s.Xt.D=i.horzLine.color,s.Kt.dt=i.vertLine.width,s.Kt.Gt=i.vertLine.style,s.Kt.D=i.vertLine.color,s.ct=this.Qt.ni(),s.ut=this.Qt.ei()}}function B(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function V(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function A(t,i,s,n,e,r){t.beginPath(),t.roundRect?t.roundRect(i,s,n,e,r):(t.lineTo(i+n-r[1],s),0!==r[1]&&t.arcTo(i+n,s,i+n,s+r[1],r[1]),t.lineTo(i+n,s+e-r[2]),0!==r[2]&&t.arcTo(i+n,s+e,i+n-r[2],s+e,r[2]),t.lineTo(i+r[3],s+e),0!==r[3]&&t.arcTo(i,s+e,i,s+e-r[3],r[3]),t.lineTo(i,s+r[0]),0!==r[0]&&t.arcTo(i,s,i+r[0],s,r[0]))}function I(t,i,s,n,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return A(t,i,s,n,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;A(t,i+o,s+o,n-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,s,n,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,s,n,e),t.restore()}class L{constructor(t,i){this.lt(t,i)}lt(t,i){this.Yt=t,this.ri=i}jt(t,i){return this.Yt.Bt?t.P+t.L+t.V:0}et(t,i,s,n){if(!this.Yt.Bt||0===this.Yt.hi.length)return;const e=this.Yt.D,r=this.ri.Z,h=t.useBitmapCoordinateSpace(t=>{const h=t.context;h.font=i.T;const a=this.ai(t,i,s,n),l=a.li;return a.oi?I(h,l._i,l.ci,l.ui,l.di,r,l.fi,[l.vt,0,0,l.vt],r):I(h,l.pi,l.ci,l.ui,l.di,r,l.fi,[0,l.vt,l.vt,0],r),this.Yt.mi&&(h.fillStyle=e,h.fillRect(l.pi,l.gi,l.wi-l.pi,l.Mi)),this.Yt.bi&&(h.fillStyle=i.B,h.fillRect(a.oi?l.Si-l.fi:0,l.ci,l.fi,l.xi-l.ci)),a});t.useMediaCoordinateSpace(({context:t})=>{const s=h.yi;t.font=i.T,t.textAlign=h.oi?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Yt.hi,s.Ci,(s.ci+s.xi)/2+s.Pi)})}ai(t,i,s,n){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.Yt.mi||!this.Yt.ki?i.C:0,_=this.Yt.Ti?i.S:0,c=i.L+this.ri.Ri,u=i.V+this.ri.Di,d=i.A,f=i.I,p=this.Yt.hi,v=i.P,m=s.Ei(e,p),g=Math.ceil(s.Bi(e,p)),w=v+c+u,M=i.S+d+f+g+o,b=Math.max(1,Math.floor(l));let S=Math.round(w*l);S%2!=b%2&&(S+=1);const x=_>0?Math.max(1,Math.floor(_*a)):0,y=Math.round(M*a),C=Math.round(o*a),P=this.ri.Vi??this.ri.Ai,k=Math.round(P*l)-Math.floor(.5*l),T=Math.floor(k+b/2-S/2),R=T+S,D="right"===n,E=D?h.width-_:_,B=D?r.width-x:x;let V,A,I;return D?(V=B-y,A=B-C,I=E-o-d-_):(V=B+y,A=B+C,I=E+o+d),{oi:D,li:{ci:T,gi:k,xi:R,ui:y,di:S,vt:2*a,fi:x,_i:V,pi:B,wi:A,Mi:b,Si:r.width},yi:{ci:T/l,xi:R/l,Ci:I,Pi:m}}}}class O{constructor(t){this.Ii={Ai:0,Z:"#000",Di:0,Ri:0},this.zi={hi:"",Bt:!1,mi:!0,ki:!1,Ut:"",D:"#FFF",bi:!1,Ti:!1},this.Li={hi:"",Bt:!1,mi:!1,ki:!0,Ut:"",D:"#FFF",bi:!0,Ti:!0},this.yt=!0,this.Oi=new(t||L)(this.zi,this.Ii),this.Fi=new(t||L)(this.Li,this.Ii)}hi(){return this.Wi(),this.zi.hi}Ai(){return this.Wi(),this.Ii.Ai}kt(){this.yt=!0}jt(t,i=!1){return Math.max(this.Oi.jt(t,i),this.Fi.jt(t,i))}Ni(){return this.Ii.Vi||0}Hi(t){this.Ii.Vi=t}Ui(){return this.Wi(),this.zi.Bt||this.Li.Bt}$i(){return this.Wi(),this.zi.Bt}Rt(t){return this.Wi(),this.zi.mi=this.zi.mi&&t.W().ticksVisible,this.Li.mi=this.Li.mi&&t.W().ticksVisible,this.Oi.lt(this.zi,this.Ii),this.Fi.lt(this.Li,this.Ii),this.Oi}ji(){return this.Wi(),this.Oi.lt(this.zi,this.Ii),this.Fi.lt(this.Li,this.Ii),this.Fi}Wi(){this.yt&&(this.zi.mi=!0,this.Li.mi=!1,this.qi(this.zi,this.Li,this.Ii))}}class F extends O{constructor(t,i,s){super(),this.Qt=t,this.Yi=i,this.Ki=s}qi(t,i,s){if(t.Bt=!1,2===this.Qt.W().mode)return;const n=this.Qt.W().horzLine;if(!n.labelVisible)return;const e=this.Yi.Lt();if(!this.Qt.Bt()||this.Yi.Xi()||null===e)return;const r=this.Yi.Gi().G(n.labelBackgroundColor);s.Z=r.Z,t.D=r.J;const h=2/12*this.Yi.P();s.Ri=h,s.Di=h;const a=this.Ki(this.Yi);s.Ai=a.Ai,t.hi=this.Yi.Zi(a.Mt,e),t.Bt=!0}}const W=/[1-9]/g;class N{constructor(){this.Yt=null}lt(t){this.Yt=t}et(t,i){if(null===this.Yt||!1===this.Yt.Bt||0===this.Yt.hi.length)return;const s=t.useMediaCoordinateSpace(({context:t})=>(t.font=i.T,Math.round(i.Ji.Bi(t,a(this.Yt).hi,W))));if(s<=0)return;const n=i.Qi,e=s+2*n,r=e/2,h=this.Yt.ts;let l=this.Yt.Ai,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,c=Math.ceil(0+i.S+i.C+i.L+i.P+i.V);t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=a(this.Yt);t.fillStyle=e.Z;const r=Math.round(o*s),h=Math.round(0*n),l=Math.round(_*s),u=Math.round(c*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,u-d),t.arcTo(r,u,r+d,u,d),t.lineTo(l-d,u),t.arcTo(l,u,l,u-d,d),t.lineTo(l,h),t.fill(),e.mi){const r=Math.round(e.Ai*s),a=h,l=Math.round((a+i.C)*n);t.fillStyle=e.D;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,a,o,l-a)}}),t.useMediaCoordinateSpace(({context:t})=>{const s=a(this.Yt),e=0+i.S+i.C+i.L+i.P/2;t.font=i.T,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.D;const r=i.Ji.Ei(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.hi,0,0)})}}class H{constructor(t,i,s){this.yt=!0,this.Jt=new N,this.Zt={Bt:!1,Z:"#4c525e",D:"white",hi:"",ts:0,Ai:NaN,mi:!0},this.Ct=t,this.ss=i,this.Ki=s}kt(){this.yt=!0}Rt(){return this.yt&&(this.Dt(),this.yt=!1),this.Jt.lt(this.Zt),this.Jt}Dt(){const t=this.Zt;if(t.Bt=!1,2===this.Ct.W().mode)return;const i=this.Ct.W().vertLine;if(!i.labelVisible)return;const s=this.ss.It();if(s.Xi())return;t.ts=s.ts();const n=this.Ki();if(null===n)return;t.Ai=n.Ai;const e=s.ns(this.Ct.At());t.hi=s.es(a(e)),t.Bt=!0;const r=this.ss.Gi().G(i.labelBackgroundColor);t.Z=r.Z,t.D=r.J,t.mi=s.W().ticksVisible}}class U{constructor(){this.rs=null,this.hs=0}ls(){return this.hs}_s(t){this.hs=t}Nt(){return this.rs}cs(t){this.rs=t}us(t){return[]}ds(){return[]}Bt(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}($||($={}));class j extends U{constructor(t,i){super(),this.Pt=null,this.fs=NaN,this.ps=0,this.vs=!1,this.gs=new Map,this.ws=!1,this.Ms=new WeakMap,this.bs=new WeakMap,this.Ss=NaN,this.xs=NaN,this.ys=NaN,this.Cs=NaN,this.ss=t,this.Ps=i;this.ks=((t,i)=>s=>{const n=i(),e=t();if(s===a(this.Pt).Ts())return{Mt:e,Ai:n};{const t=a(s.Lt());return{Mt:s.Rs(n,t),Ai:n}}})(()=>this.fs,()=>this.xs);const s=((t,i)=>()=>{const s=this.ss.It().Ds(t()),n=i();return s&&Number.isFinite(n)?{wt:s,Ai:n}:null})(()=>this.ps,()=>this.ni());this.Es=new H(this,t,s)}W(){return this.Ps}Bs(t,i){this.ys=t,this.Cs=i}Vs(){this.ys=NaN,this.Cs=NaN}As(){return this.ys}Is(){return this.Cs}zs(t,i,s){this.ws||(this.ws=!0),this.vs=!0,this.Ls(t,i,s)}At(){return this.ps}ni(){return this.Ss}ei(){return this.xs}Bt(){return this.vs}Os(){this.vs=!1,this.Fs(),this.fs=NaN,this.Ss=NaN,this.xs=NaN,this.Pt=null,this.Vs(),this.Ws()}Ns(t){let i=this.Ms.get(t);i||(i=new E(this,t),this.Ms.set(t,i));let s=this.bs.get(t);return s||(s=new R(this.ss,this,t),this.bs.set(t,s)),[i,s]}ii(t){return t===this.Pt&&this.Ps.horzLine.visible}si(){return this.Ps.vertLine.visible}Hs(t,i){this.vs&&this.Pt===t||this.gs.clear();const s=[];return this.Pt===t&&s.push(this.Us(this.gs,i,this.ks)),s}ds(){return this.vs?[this.Es]:[]}$s(){return this.Pt}Ws(){this.ss.js().forEach(t=>{this.Ms.get(t)?.kt(),this.bs.get(t)?.kt()}),this.gs.forEach(t=>t.kt()),this.Es.kt()}qs(t){return t&&!t.Ts().Xi()?t.Ts():null}Ls(t,i,s){this.Ys(t,i,s)&&this.Ws()}Ys(t,i,s){const n=this.Ss,e=this.xs,r=this.fs,h=this.ps,a=this.Pt,l=this.qs(s);this.ps=t,this.Ss=isNaN(t)?NaN:this.ss.It().qt(t),this.Pt=s;const o=null!==l?l.Lt():null;return null!==l&&null!==o?(this.fs=i,this.xs=l.Wt(i,o)):(this.fs=NaN,this.xs=NaN),n!==this.Ss||e!==this.xs||h!==this.ps||r!==this.fs||a!==this.Pt}Fs(){const t=this.ss.Ks().map(t=>t.Gs().Xs()).filter(v),i=0===t.length?null:Math.max(...t);this.ps=null!==i?i:NaN}Us(t,i,s){let n=t.get(i);return void 0===n&&(n=new F(this,i,s),t.set(i,n)),n}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.Zs=new Map,this.Js=[],this.Qs=t}tn(t,i){const s=function(t,i){return void 0===t?i:{sn:Math.max(t.sn,i.sn),nn:t.nn||i.nn}}(this.Zs.get(t),i);this.Zs.set(t,s)}en(){return this.Qs}rn(t){const i=this.Zs.get(t);return void 0===i?{sn:this.Qs}:{sn:Math.max(this.Qs,i.sn),nn:i.nn}}hn(){this.an(),this.Js=[{ln:0}]}_n(t){this.an(),this.Js=[{ln:1,Ht:t}]}cn(t){this.un(),this.Js.push({ln:5,Ht:t})}an(){this.un(),this.Js.push({ln:6})}dn(){this.an(),this.Js=[{ln:4}]}fn(t){this.an(),this.Js.push({ln:2,Ht:t})}pn(t){this.an(),this.Js.push({ln:3,Ht:t})}vn(){return this.Js}mn(t){for(const i of t.Js)this.gn(i);this.Qs=Math.max(this.Qs,t.Qs),t.Zs.forEach((t,i)=>{this.tn(i,t)})}static wn(){return new Y(2)}static Mn(){return new Y(3)}gn(t){switch(t.ln){case 0:this.hn();break;case 1:this._n(t.Ht);break;case 2:this.fn(t.Ht);break;case 3:this.pn(t.Ht);break;case 4:this.dn();break;case 5:this.cn(t.Ht);break;case 6:this.un()}}un(){const t=this.Js.findIndex(t=>5===t.ln);-1!==t&&this.Js.splice(t,1)}}class K{formatTickmarks(t){return t.map(t=>this.format(t))}}const X=".";function G(t,i){if(!c(t))return"n/a";if(!u(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 Z extends K{constructor(t,i){if(super(),i||(i=1),c(t)&&u(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.bn=i,this.Sn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.xn(t)}Sn(){if(this.yn=0,this.Yi>0&&this.bn>0){let t=this.Yi;for(;t>1;)t/=10,this.yn++}}xn(t){const i=this.Yi/this.bn;let s=Math.floor(t),n="";const e=void 0!==this.yn?this.yn:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.yn);r>=i&&(r-=i,s+=1),n=X+G(+r.toFixed(this.yn)*this.bn,e)}else s=Math.round(s*i)/i,e>0&&(n=X+G(0,e));return s.toFixed(0)+n}}class J extends Z{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Q extends K{constructor(t){super(),this.Cn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.Pn(t):t<999995?i+this.Pn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Pn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Pn(t/1e9)+"B")}Pn(t){let i;const s=Math.pow(10,this.Cn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Cn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,(t,i)=>i)}}const tt=/[2-9]/g;class it{constructor(t=50){this.kn=0,this.Tn=1,this.Rn=1,this.Dn={},this.En=new Map,this.Bn=t}Vn(){this.kn=0,this.En.clear(),this.Tn=1,this.Rn=1,this.Dn={}}Bi(t,i,s){return this.An(t,i,s).width}Ei(t,i,s){const n=this.An(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}An(t,i,s){const n=s||tt,e=String(i).replace(n,"0");if(this.En.has(e))return h(this.En.get(e)).In;if(this.kn===this.Bn){const t=this.Dn[this.Rn];delete this.Dn[this.Rn],this.En.delete(t),this.Rn++,this.kn--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.En.set(e,{In:r,zn:this.Tn}),this.Dn[this.Tn]=e,this.kn++,this.Tn++),r}}class st{constructor(t){this.Ln=null,this.M=null,this.On="right",this.Fn=t}Wn(t,i,s){this.Ln=t,this.M=i,this.On=s}et(t){null!==this.M&&null!==this.Ln&&this.Ln.et(t,this.M,this.Fn,this.On)}}class nt{constructor(t,i,s){this.Nn=t,this.Fn=new it(50),this.Hn=i,this.F=s,this.N=-1,this.Jt=new st(this.Fn)}Rt(){const t=this.F.Un(this.Hn);if(null===t)return null;const i=t.$n(this.Hn)?t.jn():this.Hn.Nt();if(null===i)return null;const s=t.qn(i);if("overlay"===s)return null;const n=this.F.Yn();return n.P!==this.N&&(this.N=n.P,this.Fn.Vn()),this.Jt.Wn(this.Nn.ji(),n,s),this.Jt}}class et extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}Kn(t,i){if(!this.Yt?.Bt)return null;const{ut:s,dt:n,Xn:e}=this.Yt;return i>=s-n-7&&i<=s+n+7?{Gn:this.Yt,Xn:e}:null}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;if(!1===this.Yt.Bt)return;const h=Math.round(this.Yt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.D,t.lineWidth=Math.floor(this.Yt.dt*s),n(t,this.Yt.Gt),e(t,h,0,i.width))}}class rt{constructor(t){this.Zn={ut:0,D:"rgba(0, 0, 0, 0)",dt:1,Gt:0,Bt:!1},this.Jn=new et,this.yt=!0,this.Qn=t,this.te=t.ti(),this.Jn.lt(this.Zn)}kt(){this.yt=!0}Rt(){return this.Qn.Bt()?(this.yt&&(this.ie(),this.yt=!1),this.Jn):null}}class ht extends rt{constructor(t){super(t)}ie(){this.Zn.Bt=!1;const t=this.Qn.Nt(),i=t.se().se;if(2!==i&&3!==i)return;const s=this.Qn.W();if(!s.baseLineVisible||!this.Qn.Bt())return;const n=this.Qn.Lt();null!==n&&(this.Zn.Bt=!0,this.Zn.ut=t.Wt(n.Ht,n.Ht),this.Zn.D=s.baseLineColor,this.Zn.dt=s.baseLineWidth,this.Zn.Gt=s.baseLineStyle)}}class at extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}ne(){return this.Yt}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Yt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.ee.x*i)+r,a=n.ee.y*s;t.fillStyle=n.re,t.beginPath();const l=Math.max(2,1.5*n.he)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.ae,t.beginPath(),t.arc(h,a,n.vt*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.le,t.beginPath(),t.arc(h,a,n.vt*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{oe:0,_e:.25,ce:4,ue:10,de:.25,fe:0,pe:.4,ve:.8},{oe:.25,_e:.525,ce:10,ue:14,de:0,fe:0,pe:.8,ve:0},{oe:.525,_e:1,ce:14,ue:14,de:0,fe:0,pe:0,ve:0}];class ot{constructor(t){this.Jt=new at,this.yt=!0,this.me=!0,this.ge=performance.now(),this.we=this.ge-1,this.Me=t}be(){this.we=this.ge-1,this.kt()}Se(){if(this.kt(),2===this.Me.W().lastPriceAnimation){const t=performance.now(),i=this.we-t;if(i>0)return void(i<650&&(this.we+=2600));this.ge=t,this.we=t+2600}}kt(){this.yt=!0}xe(){this.me=!0}Bt(){return 0!==this.Me.W().lastPriceAnimation}ye(){switch(this.Me.W().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.we}}Rt(){return this.yt?(this.Dt(),this.yt=!1,this.me=!1):this.me&&(this.Ce(),this.me=!1),this.Jt}Dt(){this.Jt.lt(null);const t=this.Me.ti().It(),i=t.Pe(),s=this.Me.Lt();if(null===i||null===s)return;const n=this.Me.ke(!0);if(n.Te||!i.Re(n.De))return;const e={x:t.qt(n.De),y:this.Me.Nt().Wt(n.Mt,s.Ht)},r=n.D,h=this.Me.W().lineWidth,a=this.Ee(this.Be(),r);this.Jt.lt({re:r,he:h,ae:a.ae,le:a.le,vt:a.vt,ee:e})}Ce(){const t=this.Jt.ne();if(null!==t){const i=this.Ee(this.Be(),t.re);t.ae=i.ae,t.le=i.le,t.vt=i.vt}}Be(){return this.ye()?performance.now()-this.ge:2599}Ve(t,i,s,n){const e=s+(n-s)*i;return this.Me.ti().Gi().K(t,e)}Ee(t,i){const s=t%2600/2600;let n;for(const t of lt)if(s>=t.oe&&s<=t._e){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.oe)/(n._e-n.oe);return{ae:this.Ve(i,e,n.de,n.fe),le:this.Ve(i,e,n.pe,n.ve),vt:(h=e,a=n.ce,l=n.ue,a+(l-a)*h)};var h,a,l}}class _t extends rt{constructor(t){super(t)}ie(){const t=this.Zn;t.Bt=!1;const i=this.Qn.W();if(!i.priceLineVisible||!this.Qn.Bt())return;const s=this.Qn.ke(0===i.priceLineSource);s.Te||(t.Bt=!0,t.ut=s.Ai,t.D=this.Qn.Ae(s.D),t.dt=i.priceLineWidth,t.Gt=i.priceLineStyle)}}class ct extends O{constructor(t){super(),this.Qt=t}qi(t,i,s){t.Bt=!1,i.Bt=!1;const n=this.Qt;if(!n.Bt())return;const e=n.W(),r=e.lastValueVisible,h=""!==n.Ie(),a=0===e.seriesLastValueMode,l=n.ke(!1);if(l.Te)return;r&&(t.hi=this.ze(l,r,a),t.Bt=0!==t.hi.length),(h||a)&&(i.hi=this.Le(l,r,h,a),i.Bt=i.hi.length>0);const o=n.Ae(l.D),_=this.Qt.ti().Gi().G(o);s.Z=_.Z,s.Ai=l.Ai,i.Ut=n.ti().$t(l.Ai/n.Nt().jt()),t.Ut=o,t.D=_.J,i.D=_.J}Le(t,i,s,n){let e="";const r=this.Qt.Ie();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.Qt.Nt().Oe()?t.Fe:t.We),e.trim()}ze(t,i,s){return i?s?this.Qt.Nt().Oe()?t.We:t.Fe:t.hi:""}}function ut(t,i,s,n){const e=Number.isFinite(i),r=Number.isFinite(s);return e&&r?t(i,s):e||r?e?i:s:n}class dt{constructor(t,i){this.Ne=t,this.He=i}Ue(t){return null!==t&&(this.Ne===t.Ne&&this.He===t.He)}$e(){return new dt(this.Ne,this.He)}je(){return this.Ne}qe(){return this.He}Ye(){return this.He-this.Ne}Xi(){return this.He===this.Ne||Number.isNaN(this.He)||Number.isNaN(this.Ne)}mn(t){return null===t?this:new dt(ut(Math.min,this.je(),t.je(),-1/0),ut(Math.max,this.qe(),t.qe(),1/0))}Ke(t){if(!c(t))return;if(0===this.He-this.Ne)return;const i=.5*(this.He+this.Ne);let s=this.He-i,n=this.Ne-i;s*=t,n*=t,this.He=i+s,this.Ne=i+n}Xe(t){c(t)&&(this.He+=t,this.Ne+=t)}Ge(){return{minValue:this.Ne,maxValue:this.He}}static Ze(t){return null===t?null:new dt(t.minValue,t.maxValue)}}class ft{constructor(t,i){this.Je=t,this.Qe=i||null}tr(){return this.Je}ir(){return this.Qe}Ge(){return{priceRange:null===this.Je?null:this.Je.Ge(),margins:this.Qe||void 0}}static Ze(t){return null===t?null:new ft(dt.Ze(t.priceRange),t.margins)}}class pt extends rt{constructor(t,i){super(t),this.sr=i}ie(){const t=this.Zn;t.Bt=!1;const i=this.sr.W();if(!this.Qn.Bt()||!i.lineVisible)return;const s=this.sr.nr();null!==s&&(t.Bt=!0,t.ut=s,t.D=i.color,t.dt=i.lineWidth,t.Gt=i.lineStyle,t.Xn=this.sr.W().id)}}class vt extends O{constructor(t,i){super(),this.Me=t,this.sr=i}qi(t,i,s){t.Bt=!1,i.Bt=!1;const n=this.sr.W(),e=n.axisLabelVisible,r=""!==n.title,h=this.Me;if(!e||!h.Bt())return;const a=this.sr.nr();if(null===a)return;r&&(i.hi=n.title,i.Bt=!0),i.Ut=h.ti().$t(a/h.Nt().jt()),t.hi=this.er(n.price),t.Bt=!0;const l=this.Me.ti().Gi().G(n.axisLabelColor||n.color);s.Z=l.Z;const o=n.axisLabelTextColor||l.J;t.D=o,i.D=o,s.Ai=a}er(t){const i=this.Me.Lt();return null===i?"":this.Me.Nt().Zi(t,i.Ht)}}class mt{constructor(t,i){this.Me=t,this.Ps=i,this.rr=new pt(t,this),this.Nn=new vt(t,this),this.hr=new nt(this.Nn,t,t.ti())}ar(t){_(this.Ps,t),this.kt(),this.Me.ti().lr()}W(){return this.Ps}_r(){return this.rr}cr(){return this.hr}ur(){return this.Nn}kt(){this.rr.kt(),this.Nn.kt()}nr(){const t=this.Me,i=t.Nt();if(t.ti().It().Xi()||i.Xi())return null;const s=t.Lt();return null===s?null:i.Wt(this.Ps.price,s.Ht)}}class gt extends U{constructor(t){super(),this.ss=t}ti(){return this.ss}}const wt={Bar:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=a(t(s,n)),o=l(h.Ht[0])<=l(h.Ht[3]);return{dr:h.D??(o?e:r)}},Candlestick:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,c=i.wickDownColor,u=a(t(s,n)),d=l(u.Ht[0])<=l(u.Ht[3]);return{dr:u.D??(d?e:r),pr:u.Ut??(d?h:o),vr:u.mr??(d?_:c)}},Custom:(t,i,s,n)=>({dr:a(t(s,n)).D??i.color}),Area:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.gt??i.lineColor,gt:e.gt??i.lineColor,gr:e.gr??i.topColor,wr:e.wr??i.bottomColor}},Baseline:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.Ht[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,Mr:e.Mr??i.topLineColor,br:e.br??i.bottomLineColor,Sr:e.Sr??i.topFillColor1,yr:e.yr??i.topFillColor2,Cr:e.Cr??i.bottomFillColor1,Pr:e.Pr??i.bottomFillColor2}},Line:(t,i,s,n)=>{const e=a(t(s,n));return{dr:e.D??i.color,gt:e.D??i.color}},Histogram:(t,i,s,n)=>({dr:a(t(s,n)).D??i.color})};class Mt{constructor(t){this.kr=(t,i)=>void 0!==i?i.Ht:this.Me.Gs().Tr(t),this.Me=t,this.Rr=wt[t.Dr()]}Er(t,i){return this.Rr(this.kr,this.Me.W(),t,i)}}function bt(t,i,s,n,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;n(i[a],s)===t?(e=a+1,h-=r+1):h=r}return e}const St=bt.bind(null,!0),xt=bt.bind(null,!1);var yt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(yt||(yt={}));const Ct=30;class Pt{constructor(){this.Br=[],this.Vr=new Map,this.Ar=new Map,this.Ir=[]}zr(){return this.Lr()>0?this.Br[this.Br.length-1]:null}Or(){return this.Lr()>0?this.Fr(0):null}Xs(){return this.Lr()>0?this.Fr(this.Br.length-1):null}Lr(){return this.Br.length}Xi(){return 0===this.Lr()}Re(t){return null!==this.Wr(t,0)}Tr(t){return this.Nr(t)}Nr(t,i=0){const s=this.Wr(t,i);return null===s?null:{...this.Hr(s),De:this.Fr(s)}}Ur(){return this.Br}$r(t,i,s){if(this.Xi())return null;let n=null;for(const e of s){n=kt(n,this.jr(t,i,e))}return n}lt(t){this.Ar.clear(),this.Vr.clear(),this.Br=t,this.Ir=t.map(t=>t.De)}qr(){return this.Ir}Fr(t){return this.Br[t].De}Hr(t){return this.Br[t]}Wr(t,i){const s=this.Yr(t);if(null===s&&0!==i)switch(i){case-1:return this.Kr(t);case 1:return this.Xr(t);default:throw new TypeError("Unknown search mode")}return s}Kr(t){let i=this.Gr(t);return i>0&&(i-=1),i!==this.Br.length&&this.Fr(i)<t?i:null}Xr(t){const i=this.Zr(t);return i!==this.Br.length&&t<this.Fr(i)?i:null}Yr(t){const i=this.Gr(t);return i===this.Br.length||t<this.Br[i].De?null:i}Gr(t){return St(this.Br,t,(t,i)=>t.De<i)}Zr(t){return xt(this.Br,t,(t,i)=>t.De>i)}Jr(t,i,s){let n=null;for(let e=t;e<i;e++){const t=this.Br[e].Ht[s];Number.isNaN(t)||(null===n?n={Qr:t,th:t}:(t<n.Qr&&(n.Qr=t),t>n.th&&(n.th=t)))}return n}jr(t,i,s){if(this.Xi())return null;let n=null;const e=a(this.Or()),r=a(this.Xs()),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.Gr(h),e=this.Zr(Math.min(l,o,i));n=kt(n,this.Jr(t,e,s))}let c=this.Vr.get(s);void 0===c&&(c=new Map,this.Vr.set(s,c));for(let t=Math.max(o+1,h);t<_;t+=Ct){const i=Math.floor(t/Ct);let e=c.get(i);if(void 0===e){const t=this.Gr(i*Ct),n=this.Zr((i+1)*Ct-1);e=this.Jr(t,n,s),c.set(i,e)}n=kt(n,e)}{const t=this.Gr(_),i=this.Zr(l);n=kt(n,this.Jr(t,i,s))}return n}}function kt(t,i){if(null===t)return i;if(null===i)return t;return{Qr:Math.min(t.Qr,i.Qr),th:Math.max(t.th,i.th)}}const Tt={setLineStyle:n};class Rt{constructor(t){this.ih=t}et(t,i,s){this.ih.draw(t,Tt)}sh(t,i,s){this.ih.drawBackground?.(t,Tt)}}class Dt{constructor(t){this.En=null,this.nh=t}Rt(){const t=this.nh.renderer();if(null===t)return null;if(this.En?.eh===t)return this.En.rh;const i=new Rt(t);return this.En={eh:t,rh:i},i}hh(){return this.nh.zOrder?.()??"normal"}}class Et{constructor(t){this.ah=null,this.oh=t}_h(){return this.oh}Ws(){this.oh.updateAllViews?.()}Ns(){const t=this.oh.paneViews?.()??[];if(this.ah?.eh===t)return this.ah.rh;const i=t.map(t=>new Dt(t));return this.ah={eh:t,rh:i},i}Kn(t,i){return this.oh.hitTest?.(t,i)??null}}let Bt=class extends Et{us(){return[]}};class Vt{constructor(t){this.ih=t}et(t,i,s){this.ih.draw(t,Tt)}sh(t,i,s){this.ih.drawBackground?.(t,Tt)}}class At{constructor(t){this.En=null,this.nh=t}Rt(){const t=this.nh.renderer();if(null===t)return null;if(this.En?.eh===t)return this.En.rh;const i=new Vt(t);return this.En={eh:t,rh:i},i}hh(){return this.nh.zOrder?.()??"normal"}}function It(t){return{hi:t.text(),Ai:t.coordinate(),Vi:t.fixedCoordinate?.(),D:t.textColor(),Z:t.backColor(),Bt:t.visible?.()??!0,mi:t.tickVisible?.()??!0}}class zt{constructor(t,i){this.Jt=new N,this.uh=t,this.dh=i}Rt(){return this.Jt.lt({ts:this.dh.ts(),...It(this.uh)}),this.Jt}}class Lt extends O{constructor(t,i){super(),this.uh=t,this.Yi=i}qi(t,i,s){const n=It(this.uh);s.Z=n.Z,t.D=n.D;const e=2/12*this.Yi.P();s.Ri=e,s.Di=e,s.Ai=n.Ai,s.Vi=n.Vi,t.hi=n.hi,t.Bt=n.Bt,t.mi=n.mi}}class Ot extends Et{constructor(t,i){super(t),this.fh=null,this.ph=null,this.mh=null,this.gh=null,this.Me=i}ds(){const t=this.oh.timeAxisViews?.()??[];if(this.fh?.eh===t)return this.fh.rh;const i=this.Me.ti().It(),s=t.map(t=>new zt(t,i));return this.fh={eh:t,rh:s},s}Hs(){const t=this.oh.priceAxisViews?.()??[];if(this.ph?.eh===t)return this.ph.rh;const i=this.Me.Nt(),s=t.map(t=>new Lt(t,i));return this.ph={eh:t,rh:s},s}wh(){const t=this.oh.priceAxisPaneViews?.()??[];if(this.mh?.eh===t)return this.mh.rh;const i=t.map(t=>new At(t));return this.mh={eh:t,rh:i},i}Mh(){const t=this.oh.timeAxisPaneViews?.()??[];if(this.gh?.eh===t)return this.gh.rh;const i=t.map(t=>new At(t));return this.gh={eh:t,rh:i},i}bh(t,i){return this.oh.autoscaleInfo?.(t,i)??null}}function Ft(t,i,s,n){t.forEach(t=>{i(t).forEach(t=>{t.hh()===s&&n.push(t)})})}function Wt(t){return t.Ns()}function Nt(t){return t.wh()}function Ht(t){return t.Mh()}const Ut=["Area","Line","Baseline"];class $t extends gt{constructor(t,i,s,n,e){super(t),this.Yt=new Pt,this.rr=new _t(this),this.Sh=[],this.xh=new ht(this),this.yh=null,this.Ch=null,this.Ph=null,this.kh=[],this.Ps=s,this.Th=i;const r=new ct(this);this.gs=[r],this.hr=new nt(r,this,t),Ut.includes(this.Th)&&(this.yh=new ot(this)),this.Rh(),this.nh=n(this,this.ti(),e)}m(){null!==this.Ph&&clearTimeout(this.Ph)}Ae(t){return this.Ps.priceLineColor||t}ke(t){const i={Te:!0},s=this.Nt();if(this.ti().It().Xi()||s.Xi()||this.Yt.Xi())return i;const n=this.ti().It().Pe(),e=this.Lt();if(null===n||null===e)return i;let r,h;if(t){const t=this.Yt.zr();if(null===t)return i;r=t,h=t.De}else{const t=this.Yt.Nr(n.Si(),-1);if(null===t)return i;if(r=this.Yt.Tr(t.De),null===r)return i;h=t.De}const a=r.Ht[3],l=this.Dh().Er(h,{Ht:r}),o=s.Wt(a,e.Ht);return{Te:!1,Mt:a,hi:s.Zi(a,e.Ht),Fe:s.Eh(a),We:s.Bh(a,e.Ht),D:l.dr,Ai:o,De:h}}Dh(){return null!==this.Ch||(this.Ch=new Mt(this)),this.Ch}W(){return this.Ps}ar(t){const i=t.priceScaleId;void 0!==i&&i!==this.Ps.priceScaleId&&this.ti().Vh(this,i),_(this.Ps,t),void 0!==t.priceFormat&&(this.Rh(),this.ti().Ah()),this.ti().Ih(this),this.ti().zh(),this.nh.kt("options")}lt(t,i){this.Yt.lt(t),this.nh.kt("data"),null!==this.yh&&(i&&i.Lh?this.yh.Se():0===t.length&&this.yh.be());const s=this.ti().Un(this);this.ti().Oh(s),this.ti().Ih(this),this.ti().zh(),this.ti().lr()}Fh(t){const i=new mt(this,t);return this.Sh.push(i),this.ti().Ih(this),i}Wh(t){const i=this.Sh.indexOf(t);-1!==i&&this.Sh.splice(i,1),this.ti().Ih(this)}Nh(){return this.Sh}Dr(){return this.Th}Lt(){const t=this.Hh();return null===t?null:{Ht:t.Ht[3],Uh:t.wt}}Hh(){const t=this.ti().It().Pe();if(null===t)return null;const i=t.$h();return this.Yt.Nr(i,1)}Gs(){return this.Yt}jh(t){const i=this.Yt.Tr(t);return null===i?null:"Bar"===this.Th||"Candlestick"===this.Th||"Custom"===this.Th?{qh:i.Ht[0],Yh:i.Ht[1],Kh:i.Ht[2],Xh:i.Ht[3]}:i.Ht[3]}Gh(t){const i=[];Ft(this.kh,Wt,"top",i);const s=this.yh;return null!==s&&s.Bt()?(null===this.Ph&&s.ye()&&(this.Ph=setTimeout(()=>{this.Ph=null,this.ti().Zh()},0)),s.xe(),i.unshift(s),i):i}Ns(){const t=[];this.Jh()||t.push(this.xh),t.push(this.nh,this.rr);const i=this.Sh.map(t=>t._r());return t.push(...i),Ft(this.kh,Wt,"normal",t),t}Qh(){return this.ta(Wt,"bottom")}ia(t){return this.ta(Nt,t)}sa(t){return this.ta(Ht,t)}na(t,i){return this.kh.map(s=>s.Kn(t,i)).filter(t=>null!==t)}us(){return[this.hr,...this.Sh.map(t=>t.cr())]}Hs(t,i){if(i!==this.rs&&!this.Jh())return[];const s=[...this.gs];for(const t of this.Sh)s.push(t.ur());return this.kh.forEach(t=>{s.push(...t.Hs())}),s}ds(){const t=[];return this.kh.forEach(i=>{t.push(...i.ds())}),t}bh(t,i){if(void 0!==this.Ps.autoscaleInfoProvider){const s=this.Ps.autoscaleInfoProvider(()=>{const s=this.ea(t,i);return null===s?null:s.Ge()});return ft.Ze(s)}return this.ea(t,i)}eh(){const t=this.Ps.priceFormat;return t.base??1/t.minMove}ra(){return this.ha}Ws(){this.nh.kt();for(const t of this.gs)t.kt();for(const t of this.Sh)t.kt();this.rr.kt(),this.xh.kt(),this.yh?.kt(),this.kh.forEach(t=>t.Ws())}Nt(){return a(super.Nt())}zt(t){if(!(("Line"===this.Th||"Area"===this.Th||"Baseline"===this.Th)&&this.Ps.crosshairMarkerVisible))return null;const i=this.Yt.Tr(t);if(null===i)return null;return{Mt:i.Ht[3],vt:this.aa(),Ut:this.la(),Ft:this.oa(),Ot:this._a(t)}}Ie(){return this.Ps.title}Bt(){return this.Ps.visible}ca(t){this.kh.push(new Ot(t,this))}ua(t){this.kh=this.kh.filter(i=>i._h()!==t)}da(){if("Custom"===this.Th)return t=>this.nh.fa(t)}pa(){if("Custom"===this.Th)return t=>this.nh.va(t)}ma(){return this.Yt.qr()}Jh(){return!q(this.Nt().ga())}ea(t,i){if(!u(t)||!u(i)||this.Yt.Xi())return null;const s="Line"===this.Th||"Area"===this.Th||"Baseline"===this.Th||"Histogram"===this.Th?[3]:[2,1],n=this.Yt.$r(t,i,s);let e=null!==n?new dt(n.Qr,n.th):null,r=null;if("Histogram"===this.Dr()){const t=this.Ps.base,i=new dt(t,t);e=null!==e?e.mn(i):i}return this.kh.forEach(s=>{const n=s.bh(t,i);if(n?.priceRange){const t=new dt(n.priceRange.minValue,n.priceRange.maxValue);e=null!==e?e.mn(t):t}n?.margins&&(r=n.margins)}),new ft(e,r)}aa(){switch(this.Th){case"Line":case"Area":case"Baseline":return this.Ps.crosshairMarkerRadius}return 0}la(){switch(this.Th){case"Line":case"Area":case"Baseline":{const t=this.Ps.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}oa(){switch(this.Th){case"Line":case"Area":case"Baseline":return this.Ps.crosshairMarkerBorderWidth}return 0}_a(t){switch(this.Th){case"Line":case"Area":case"Baseline":{const t=this.Ps.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Dh().Er(t).dr}Rh(){switch(this.Ps.priceFormat.type){case"custom":{const t=this.Ps.priceFormat.formatter;this.ha={format:t,formatTickmarks:this.Ps.priceFormat.tickmarksFormatter??(i=>i.map(t))};break}case"volume":this.ha=new Q(this.Ps.priceFormat.precision);break;case"percent":this.ha=new J(this.Ps.priceFormat.precision);break;default:{const t=Math.pow(10,this.Ps.priceFormat.precision);this.ha=new Z(t,this.Ps.priceFormat.minMove*t)}}null!==this.rs&&this.rs.wa()}ta(t,i){const s=[];return Ft(this.kh,t,i,s),s}}const jt=[3],qt=[0,1,2,3];class Yt{constructor(t){this.Ps=t}Ma(t,i,s){let n=t;if(0===this.Ps.mode)return n;const e=s.Ts(),r=e.Lt();if(null===r)return n;const h=e.Wt(t,r),a=s.ba().filter(t=>t instanceof $t).reduce((t,n)=>{if(s.$n(n)||!n.Bt())return t;const e=n.Nt(),r=n.Gs();if(e.Xi()||!r.Re(i))return t;const h=r.Tr(i);if(null===h)return t;const a=l(n.Lt()),o=3===this.Ps.mode?qt:jt;return t.concat(o.map(t=>e.Wt(h.Ht[t],a.Ht)))},[]);if(0===a.length)return n;a.sort((t,i)=>Math.abs(t-h)-Math.abs(i-h));const o=a[0];return n=e.Rs(o,r),n}}function Kt(t,i,s){return Math.min(Math.max(t,i),s)}function Xt(t,i,s){return i-t<=s}function Gt(t){const i=Math.ceil(t);return i%2==0?i-1:i}class Zt extends C{constructor(){super(...arguments),this.Yt=null}lt(t){this.Yt=t}rt({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,()=>{const h=a(this.Yt);if(h.Sa){t.strokeStyle=h.xa,n(t,h.ya),t.beginPath();for(const n of h.Ca){const e=Math.round(n.Pa*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.ka){t.strokeStyle=h.Ta,n(t,h.Ra),t.beginPath();for(const s of h.Da){const n=Math.round(s.Pa*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}})}}class Jt{constructor(t){this.Jt=new Zt,this.yt=!0,this.Pt=t}kt(){this.yt=!0}Rt(){if(this.yt){const t=this.Pt.ti().W().grid,i={ka:t.horzLines.visible,Sa:t.vertLines.visible,Ta:t.horzLines.color,xa:t.vertLines.color,Ra:t.horzLines.style,ya:t.vertLines.style,Da:this.Pt.Ts().Ea(),Ca:(this.Pt.ti().It().Ea()||[]).map(t=>({Pa:t.coord}))};this.Jt.lt(i),this.yt=!1}return this.Jt}}class Qt{constructor(t){this.nh=new Jt(t)}_r(){return this.nh}}const ti={Ba:4,Va:1e-4};function ii(t,i){const s=100*(t-i)/i;return i<0?-s:s}function si(t,i){const s=ii(t.je(),i),n=ii(t.qe(),i);return new dt(s,n)}function ni(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function ei(t,i){const s=ni(t.je(),i),n=ni(t.qe(),i);return new dt(s,n)}function ri(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.log10(s+i.Va)+i.Ba;return t<0?-n:n}function hi(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.Ba)-i.Va;return t<0?-n:n}function ai(t,i){if(null===t)return null;const s=ri(t.je(),i),n=ri(t.qe(),i);return new dt(s,n)}function li(t,i){if(null===t)return null;const s=hi(t.je(),i),n=hi(t.qe(),i);return new dt(s,n)}function oi(t){if(null===t)return ti;const i=Math.abs(t.qe()-t.je());if(i>=1||i<1e-15)return ti;const s=Math.ceil(Math.abs(Math.log10(i))),n=ti.Ba+s;return{Ba:n,Va:1/Math.pow(10,n)}}class _i{constructor(t,i){if(this.Aa=t,this.Ia=i,function(t){if(t<0)return!1;if(t>1e18)return!0;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")}}}La(t,i,s){const n=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.Ia[0];for(;;){const t=Xt(e,n,1e-14)&&e>n+1e-14,i=Xt(e,s*h,1e-14),a=Xt(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.Ia[++r%this.Ia.length]}if(e<=n+1e-14&&(e=n),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];Xt(e,s*h,1e-14)&&e>n+1e-14;)e/=h,h=this.za[++r%this.za.length];var a,l,o;return e}}class ci{constructor(t,i,s,n){this.Oa=[],this.Yi=t,this.Aa=i,this.Fa=s,this.Wa=n}La(t,i){if(t<i)throw new Error("high < low");const s=this.Yi.jt(),n=(t-i)*this.Na()/s,e=new _i(this.Aa,[2,2.5,2]),r=new _i(this.Aa,[2,2,2.5]),h=new _i(this.Aa,[2.5,2,2]),a=[];return a.push(e.La(t,i,n),r.La(t,i,n),h.La(t,i,n)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let s=1;s<t.length;++s)t[s]<i&&(i=t[s]);return i}(a)}Ha(){const t=this.Yi,i=t.Lt();if(null===i)return void(this.Oa=[]);const s=t.jt(),n=this.Fa(s-1,i),e=this.Fa(0,i),r=this.Yi.W().entireTextOnly?this.Ua()/2:0,h=r,a=s-1-r,l=Math.max(n,e),o=Math.min(n,e);if(l===o)return void(this.Oa=[]);const _=this.La(l,o);if(this.$a(i,_,l,o,h,a),t.ja()&&this.qa(_,o,l)){const t=this.Yi.Ya();this.Ka(i,_,h,a,t,2*t)}const c=this.Oa.map(t=>t.Xa),u=this.Yi.Ga(c);for(let t=0;t<this.Oa.length;t++)this.Oa[t].Za=u[t]}Ea(){return this.Oa}Ua(){return this.Yi.P()}Na(){return Math.ceil(2.5*this.Ua())}$a(t,i,s,n,e,r){const h=this.Oa,a=this.Yi;let l=s%i;l+=l<0?i:0;const o=s>=n?1:-1;let _=null,c=0;for(let u=s-l;u>n;u-=i){const s=this.Wa(u,t,!0);null!==_&&Math.abs(s-_)<this.Na()||(s<e||s>r||(c<h.length?(h[c].Pa=s,h[c].Za=a.Ja(u),h[c].Xa=u):h.push({Pa:s,Za:a.Ja(u),Xa:u}),c++,_=s,a.Qa()&&(i=this.La(u*o,n))))}h.length=c}Ka(t,i,s,n,e,r){const h=this.Oa,a=this.tl(t,s,e,r),l=this.tl(t,n,-r,-e),o=this.Wa(0,t,!0)-this.Wa(i,t,!0);h.length>0&&h[0].Pa-a.Pa<o/2&&h.shift(),h.length>0&&l.Pa-h[h.length-1].Pa<o/2&&h.pop(),h.unshift(a),h.push(l)}tl(t,i,s,n){const e=(s+n)/2,r=this.Fa(i+s,t),h=this.Fa(i+n,t),a=Math.min(r,h),l=Math.max(r,h),o=Math.max(.1,this.La(l,a)),_=this.Fa(i+e,t),c=_-_%o,u=this.Wa(c,t,!0);return{Za:this.Yi.Ja(c),Pa:u,Xa:c}}qa(t,i,s){let n=l(this.Yi.tr());return this.Yi.Qa()&&(n=li(n,this.Yi.il())),n.je()-i<t&&s-n.qe()<t}}function ui(t){return t.slice().sort((t,i)=>a(t.ls())-a(i.ls()))}var di;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(di||(di={}));const fi=new J,pi=new Z(100,1);class vi{constructor(t,i,s,n,e){this.sl=0,this.nl=null,this.Je=null,this.el=null,this.rl={hl:!1,al:null},this.ll=!1,this.ol=0,this._l=0,this.cl=new o,this.ul=new o,this.dl=[],this.fl=null,this.pl=null,this.vl=null,this.ml=null,this.gl=null,this.ha=pi,this.wl=oi(null),this.Ml=t,this.Ps=i,this.bl=s,this.Sl=n,this.xl=e,this.yl=new ci(this,100,this.Cl.bind(this),this.Pl.bind(this))}ga(){return this.Ml}W(){return this.Ps}ar(t){if(_(this.Ps,t),this.wa(),void 0!==t.mode&&this.kl({se:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.Tl(),this.vl=null}}Rl(){return this.Ps.autoScale}Dl(){return this.ll}Qa(){return 1===this.Ps.mode}Oe(){return 2===this.Ps.mode}El(){return 3===this.Ps.mode}il(){return this.wl}se(){return{nn:this.Ps.autoScale,Bl:this.Ps.invertScale,se:this.Ps.mode}}kl(t){const i=this.se();let s=null;void 0!==t.nn&&(this.Ps.autoScale=t.nn),void 0!==t.se&&(this.Ps.mode=t.se,2!==t.se&&3!==t.se||(this.Ps.autoScale=!0),this.rl.hl=!1),1===i.se&&t.se!==i.se&&(!function(t,i){if(null===t)return!1;const s=hi(t.je(),i),n=hi(t.qe(),i);return isFinite(s)&&isFinite(n)}(this.Je,this.wl)?this.Ps.autoScale=!0:(s=li(this.Je,this.wl),null!==s&&this.Vl(s))),1===t.se&&t.se!==i.se&&(s=ai(this.Je,this.wl),null!==s&&this.Vl(s));const n=i.se!==this.Ps.mode;n&&(2===i.se||this.Oe())&&this.wa(),n&&(3===i.se||this.El())&&this.wa(),void 0!==t.Bl&&i.Bl!==t.Bl&&(this.Ps.invertScale=t.Bl,this.Al()),this.ul.p(i,this.se())}Il(){return this.ul}P(){return this.bl.fontSize}jt(){return this.sl}zl(t){this.sl!==t&&(this.sl=t,this.Tl(),this.vl=null)}Ll(){if(this.nl)return this.nl;const t=this.jt()-this.Ol()-this.Fl();return this.nl=t,t}tr(){return this.Wl(),this.Je}Vl(t,i){const s=this.Je;(i||null===s&&null!==t||null!==s&&!s.Ue(t))&&(this.vl=null,this.Je=t)}Nl(t){this.Vl(t),this.Hl(null!==t)}Xi(){return this.Wl(),0===this.sl||!this.Je||this.Je.Xi()}Ul(t){return this.Bl()?t:this.jt()-1-t}Wt(t,i){return this.Oe()?t=ii(t,i):this.El()&&(t=ni(t,i)),this.Pl(t,i)}$l(t,i,s){this.Wl();const n=this.Fl(),e=a(this.tr()),r=e.je(),h=e.qe(),l=this.Ll()-1,o=this.Bl(),_=l/(h-r),c=void 0===s?0:s.from,u=void 0===s?t.length:s.to,d=this.jl();for(let s=c;s<u;s++){const e=t[s],h=e.Mt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.Mt,i));const l=n+_*(a-r),c=o?l:this.sl-1-l;e.ut=c}}ql(t,i,s){this.Wl();const n=this.Fl(),e=a(this.tr()),r=e.je(),h=e.qe(),l=this.Ll()-1,o=this.Bl(),_=l/(h-r),c=void 0===s?0:s.from,u=void 0===s?t.length:s.to,d=this.jl();for(let s=c;s<u;s++){const e=t[s];let h=e.qh,a=e.Yh,l=e.Kh,c=e.Xh;null!==d&&(h=d(e.qh,i),a=d(e.Yh,i),l=d(e.Kh,i),c=d(e.Xh,i));let u=n+_*(h-r),f=o?u:this.sl-1-u;e.Yl=f,u=n+_*(a-r),f=o?u:this.sl-1-u,e.Kl=f,u=n+_*(l-r),f=o?u:this.sl-1-u,e.Xl=f,u=n+_*(c-r),f=o?u:this.sl-1-u,e.Gl=f}}Rs(t,i){const s=this.Cl(t,i);return this.Zl(s,i)}Zl(t,i){let s=t;return this.Oe()?s=function(t,i){return i<0&&(t=-t),t/100*i+i}(s,i):this.El()&&(s=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(s,i)),s}ba(){return this.dl}Et(){return this.pl||(this.pl=ui(this.dl)),this.pl}Jl(t){-1===this.dl.indexOf(t)&&(this.dl.push(t),this.wa(),this.Ql())}io(t){const i=this.dl.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.dl.splice(i,1),0===this.dl.length&&(this.kl({nn:!0}),this.Vl(null)),this.wa(),this.Ql()}Lt(){let t=null;for(const i of this.dl){const s=i.Lt();null!==s&&((null===t||s.Uh<t.Uh)&&(t=s))}return null===t?null:t.Ht}Bl(){return this.Ps.invertScale}Ea(){const t=null===this.Lt();if(null!==this.vl&&(t||this.vl.so===t))return this.vl.Ea;this.yl.Ha();const i=this.yl.Ea();return this.vl={Ea:i,so:t},this.cl.p(),i}no(){return this.cl}eo(t){this.Oe()||this.El()||null===this.ml&&null===this.el&&(this.Xi()||(this.ml=this.sl-t,this.el=a(this.tr()).$e()))}ro(t){if(this.Oe()||this.El())return;if(null===this.ml)return;this.kl({nn:!1}),(t=this.sl-t)<0&&(t=0);let i=(this.ml+.2*(this.sl-1))/(t+.2*(this.sl-1));const s=a(this.el).$e();i=Math.max(i,.1),s.Ke(i),this.Vl(s)}ho(){this.Oe()||this.El()||(this.ml=null,this.el=null)}ao(t){this.Rl()||null===this.gl&&null===this.el&&(this.Xi()||(this.gl=t,this.el=a(this.tr()).$e()))}lo(t){if(this.Rl())return;if(null===this.gl)return;const i=a(this.tr()).Ye()/(this.Ll()-1);let s=t-this.gl;this.Bl()&&(s*=-1);const n=s*i,e=a(this.el).$e();e.Xe(n),this.Vl(e,!0),this.vl=null}oo(){this.Rl()||null!==this.gl&&(this.gl=null,this.el=null)}ra(){return this.ha||this.wa(),this.ha}Zi(t,i){switch(this.Ps.mode){case 2:return this._o(ii(t,i));case 3:return this.ra().format(ni(t,i));default:return this.er(t)}}Ja(t){switch(this.Ps.mode){case 2:return this._o(t);case 3:return this.ra().format(t);default:return this.er(t)}}Ga(t){switch(this.Ps.mode){case 2:return this.co(t);case 3:return this.ra().formatTickmarks(t);default:return this.uo(t)}}Eh(t){return this.er(t,a(this.fl).ra())}Bh(t,i){return t=ii(t,i),this._o(t,fi)}do(){return this.dl}fo(t){this.rl={al:t,hl:!1}}Ws(){this.dl.forEach(t=>t.Ws())}ja(){return this.Ps.ensureEdgeTickMarksVisible&&this.Rl()}Ya(){return this.P()/2}wa(){this.vl=null;let t=1/0;this.fl=null;for(const i of this.dl)i.ls()<t&&(t=i.ls(),this.fl=i);let i=100;null!==this.fl&&(i=Math.round(this.fl.eh())),this.ha=pi,this.Oe()?(this.ha=fi,i=100):this.El()?(this.ha=new Z(100,1),i=100):null!==this.fl&&(this.ha=this.fl.ra()),this.yl=new ci(this,i,this.Cl.bind(this),this.Pl.bind(this)),this.yl.Ha()}Ql(){this.pl=null}po(){return null===this.fl||this.Oe()||this.El()?1:1/this.fl.eh()}Gi(){return this.xl}Hl(t){this.ll=t}Ol(){return this.Bl()?this.Ps.scaleMargins.bottom*this.jt()+this._l:this.Ps.scaleMargins.top*this.jt()+this.ol}Fl(){return this.Bl()?this.Ps.scaleMargins.top*this.jt()+this.ol:this.Ps.scaleMargins.bottom*this.jt()+this._l}Wl(){this.rl.hl||(this.rl.hl=!0,this.vo())}Tl(){this.nl=null}Pl(t,i){if(this.Wl(),this.Xi())return 0;t=this.Qa()&&t?ri(t,this.wl):t;const s=a(this.tr()),n=this.Fl()+(this.Ll()-1)*(t-s.je())/s.Ye();return this.Ul(n)}Cl(t,i){if(this.Wl(),this.Xi())return 0;const s=this.Ul(t),n=a(this.tr()),e=n.je()+n.Ye()*((s-this.Fl())/(this.Ll()-1));return this.Qa()?hi(e,this.wl):e}Al(){this.vl=null,this.yl.Ha()}vo(){if(this.Dl()&&!this.Rl())return;const t=this.rl.al;if(null===t)return;let i=null;const s=this.do();let n=0,e=0;for(const r of s){if(!r.Bt())continue;const s=r.Lt();if(null===s)continue;const h=r.bh(t.$h(),t.Si());let l=h&&h.tr();if(null!==l){switch(this.Ps.mode){case 1:l=ai(l,this.wl);break;case 2:l=si(l,s.Ht);break;case 3:l=ei(l,s.Ht)}if(i=null===i?l:i.mn(a(l)),null!==h){const t=h.ir();null!==t&&(n=Math.max(n,t.above),e=Math.max(e,t.below))}}}if(this.ja()&&(n=Math.max(n,this.Ya()),e=Math.max(e,this.Ya())),n===this.ol&&e===this._l||(this.ol=n,this._l=e,this.vl=null,this.Tl()),null!==i){if(i.je()===i.qe()){const t=5*this.po();this.Qa()&&(i=li(i,this.wl)),i=new dt(i.je()-t,i.qe()+t),this.Qa()&&(i=ai(i,this.wl))}if(this.Qa()){const t=li(i,this.wl),s=oi(t);if(r=s,h=this.wl,r.Ba!==h.Ba||r.Va!==h.Va){const n=null!==this.el?li(this.el,this.wl):null;this.wl=s,i=ai(t,s),null!==n&&(this.el=ai(n,s))}}this.Vl(i)}else null===this.Je&&(this.Vl(new dt(-.5,.5)),this.wl=oi(null));var r,h}jl(){return this.Oe()?ii:this.El()?ni:this.Qa()?t=>ri(t,this.wl):null}mo(t,i,s){return void 0===i?(void 0===s&&(s=this.ra()),s.format(t)):i(t)}wo(t,i,s){return void 0===i?(void 0===s&&(s=this.ra()),s.formatTickmarks(t)):i(t)}er(t,i){return this.mo(t,this.Sl.priceFormatter,i)}uo(t,i){const s=this.Sl.priceFormatter;return this.wo(t,this.Sl.tickmarksPriceFormatter??(s?t=>t.map(s):void 0),i)}_o(t,i){return this.mo(t,this.Sl.percentageFormatter,i)}co(t,i){const s=this.Sl.percentageFormatter;return this.wo(t,this.Sl.tickmarksPercentageFormatter??(s?t=>t.map(s):void 0),i)}}function mi(t){return t instanceof $t}class gi{constructor(t,i){this.dl=[],this.Mo=new Map,this.sl=0,this.bo=0,this.So=1,this.pl=null,this.xo=!1,this.yo=new o,this.kh=[],this.dh=t,this.ss=i,this.Co=new Qt(this);const s=i.W();this.Po=this.ko("left",s.leftPriceScale),this.To=this.ko("right",s.rightPriceScale),this.Po.Il().i(this.Ro.bind(this,this.Po),this),this.To.Il().i(this.Ro.bind(this,this.To),this),this.Do(s)}Do(t){if(t.leftPriceScale&&this.Po.ar(t.leftPriceScale),t.rightPriceScale&&this.To.ar(t.rightPriceScale),t.localization&&(this.Po.wa(),this.To.wa()),t.overlayPriceScales){const i=Array.from(this.Mo.values());for(const s of i){const i=a(s[0].Nt());i.ar(t.overlayPriceScales),t.localization&&i.wa()}}}Eo(t){switch(t){case"left":return this.Po;case"right":return this.To}return this.Mo.has(t)?h(this.Mo.get(t))[0].Nt():null}m(){this.ti().Bo().u(this),this.Po.Il().u(this),this.To.Il().u(this),this.dl.forEach(t=>{t.m&&t.m()}),this.kh=this.kh.filter(t=>{const i=t._h();return i.detached&&i.detached(),!1}),this.yo.p()}Vo(){return this.So}Ao(t){this.So=t}ti(){return this.ss}ts(){return this.bo}jt(){return this.sl}Io(t){this.bo=t,this.zo()}zl(t){this.sl=t,this.Po.zl(t),this.To.zl(t),this.dl.forEach(i=>{if(this.$n(i)){const s=i.Nt();null!==s&&s.zl(t)}}),this.zo()}Lo(t){this.xo=t}Oo(){return this.xo}Fo(){return this.dl.filter(mi)}ba(){return this.dl}$n(t){const i=t.Nt();return null===i||this.Po!==i&&this.To!==i}Jl(t,i,s){this.Wo(t,i,s?t.ls():this.dl.length)}io(t,i){const s=this.dl.indexOf(t);r(-1!==s,"removeDataSource: invalid data source"),this.dl.splice(s,1),i||this.dl.forEach((t,i)=>t._s(i));const n=a(t.Nt()).ga();if(this.Mo.has(n)){const i=h(this.Mo.get(n)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.Mo.delete(n))}const e=t.Nt();e&&e.ba().indexOf(t)>=0&&(e.io(t),this.No(e)),this.pl=null}qn(t){return t===this.Po?"left":t===this.To?"right":"overlay"}Ho(){return this.Po}Uo(){return this.To}$o(t,i){t.eo(i)}jo(t,i){t.ro(i),this.zo()}qo(t){t.ho()}Yo(t,i){t.ao(i)}Ko(t,i){t.lo(i),this.zo()}Xo(t){t.oo()}zo(){this.dl.forEach(t=>{t.Ws()})}Ts(){let t=null;return this.ss.W().rightPriceScale.visible&&0!==this.To.ba().length?t=this.To:this.ss.W().leftPriceScale.visible&&0!==this.Po.ba().length?t=this.Po:0!==this.dl.length&&(t=this.dl[0].Nt()),null===t&&(t=this.To),t}jn(){let t=null;return this.ss.W().rightPriceScale.visible?t=this.To:this.ss.W().leftPriceScale.visible&&(t=this.Po),t}No(t){null!==t&&t.Rl()&&this.Go(t)}Zo(t){const i=this.dh.Pe();t.kl({nn:!0}),null!==i&&t.fo(i),this.zo()}Jo(){this.Go(this.Po),this.Go(this.To)}Qo(){this.No(this.Po),this.No(this.To),this.dl.forEach(t=>{this.$n(t)&&this.No(t.Nt())}),this.zo(),this.ss.lr()}Et(){return null===this.pl&&(this.pl=ui(this.dl)),this.pl}t_(t,i){i=Kt(i,0,this.dl.length-1);const s=this.dl.indexOf(t);r(-1!==s,"setSeriesOrder: invalid data source"),this.dl.splice(s,1),this.dl.splice(i,0,t),this.dl.forEach((t,i)=>t._s(i)),this.pl=null;for(const t of[this.Po,this.To])t.Ql(),t.wa();this.ss.lr()}Vt(){return this.Et().filter(mi)}i_(){return this.yo}s_(){return this.Co}ca(t){this.kh.push(new Bt(t))}ua(t){this.kh=this.kh.filter(i=>i._h()!==t),t.detached&&t.detached(),this.ss.lr()}n_(){return this.kh}na(t,i){return this.kh.map(s=>s.Kn(t,i)).filter(t=>null!==t)}Go(t){const i=t.do();if(i&&i.length>0&&!this.dh.Xi()){const i=this.dh.Pe();null!==i&&t.fo(i)}t.Ws()}Wo(t,i,s){let n=this.Eo(i);if(null===n&&(n=this.ko(i,this.ss.W().overlayPriceScales)),this.dl.splice(s,0,t),!q(i)){const s=this.Mo.get(i)||[];s.push(t),this.Mo.set(i,s)}t._s(s),n.Jl(t),t.cs(n),this.No(n),this.pl=null}Ro(t,i,s){i.se!==s.se&&this.Go(t)}ko(t,i){const s={visible:!0,autoScale:!0,...p(i)},n=new vi(t,s,this.ss.W().layout,this.ss.W().localization,this.ss.Gi());return n.zl(this.jt()),n}}function wi(t,i){return!i||"top"===t&&"top"!==i||"normal"===t&&"bottom"===i}function Mi(t){return{e_:t.e_,r_:{Xn:t.h_.externalId},a_:t.h_.cursorStyle}}function bi(t,i,s,n){for(const e of t){const t=e.Rt(n);if(null!==t&&t.Kn){const n=t.Kn(i,s);if(null!==n)return{l_:e,r_:n}}}return null}function Si(t){return void 0!==t.Ns}function xi(t,i,s){const n=[t,...t.Et()],e=function(t,i,s){let n,e;for(const r of t){const t=r.na?.(i,s)??[];for(const i of t)wi(i.zOrder,n?.zOrder)&&(n=i,e=r)}return n&&e?{h_:n,e_:e}:null}(n,i,s);if("top"===e?.h_.zOrder)return Mi(e);for(const r of n){if(e&&e.e_===r&&"bottom"!==e.h_.zOrder&&!e.h_.isBackground)return Mi(e);if(Si(r)){const n=bi(r.Ns(t),i,s,t);if(null!==n)return{e_:r,l_:n.l_,r_:n.r_}}if(e&&e.e_===r&&"bottom"!==e.h_.zOrder&&e.h_.isBackground)return Mi(e)}return e?.h_?Mi(e):null}class yi{constructor(t,i,s=50){this.kn=0,this.Tn=1,this.Rn=1,this.En=new Map,this.Dn=new Map,this.o_=t,this.__=i,this.Bn=s}c_(t){const i=t.time,s=this.__.cacheKey(i),n=this.En.get(s);if(void 0!==n)return n.u_;if(this.kn===this.Bn){const t=this.Dn.get(this.Rn);this.Dn.delete(this.Rn),this.En.delete(h(t)),this.Rn++,this.kn--}const e=this.o_(t);return this.En.set(s,{u_:e,zn:this.Tn}),this.Dn.set(this.Tn,s),this.kn++,this.Tn++,e}}class Ci{constructor(t,i){r(t<=i,"right should be >= left"),this.d_=t,this.f_=i}$h(){return this.d_}Si(){return this.f_}p_(){return this.f_-this.d_+1}Re(t){return this.d_<=t&&t<=this.f_}Ue(t){return this.d_===t.$h()&&this.f_===t.Si()}}function Pi(t,i){return null===t||null===i?t===i:t.Ue(i)}class ki{constructor(){this.v_=new Map,this.En=null,this.m_=!1}g_(t){this.m_=t,this.En=null}w_(t,i){this.M_(i),this.En=null;for(let s=i;s<t.length;++s){const i=t[s];let n=this.v_.get(i.timeWeight);void 0===n&&(n=[],this.v_.set(i.timeWeight,n)),n.push({index:s,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}b_(t,i,s,n,e){const r=Math.ceil(i/t);return null!==this.En&&this.En.S_===r&&e===this.En.x_&&s===this.En.y_||(this.En={x_:e,y_:s,Ea:this.C_(r,s,n),S_:r}),this.En.Ea}M_(t){if(0===t)return void this.v_.clear();const i=[];this.v_.forEach((s,n)=>{t<=s[0].index?i.push(n):s.splice(St(s,t,i=>i.index<t),1/0)});for(const t of i)this.v_.delete(t)}C_(t,i,s){let n=[];const e=t=>!i||s.has(t.index);for(const i of Array.from(this.v_.keys()).sort((t,i)=>i-t)){if(!this.v_.get(i))continue;const s=n;n=[];const r=s.length;let a=0;const l=h(this.v_.get(i)),o=l.length;let _=1/0,c=-1/0;for(let i=0;i<o;i++){const h=l[i],o=h.index;for(;a<r;){const t=s[a],i=t.index;if(!(i<o&&e(t))){_=i;break}a++,n.push(t),c=i,_=1/0}if(_-o>=t&&o-c>=t&&e(h))n.push(h),c=o;else if(this.m_)return s}for(;a<r;a++)e(s[a])&&n.push(s[a])}return n}}class Ti{constructor(t){this.P_=t}k_(){return null===this.P_?null:new Ci(Math.floor(this.P_.$h()),Math.ceil(this.P_.Si()))}T_(){return this.P_}static R_(){return new Ti(null)}}function Ri(t,i){return t.weight>i.weight?t:i}class Di{constructor(t,i,s,n){this.bo=0,this.D_=null,this.E_=[],this.gl=null,this.ml=null,this.B_=new ki,this.V_=new Map,this.A_=Ti.R_(),this.I_=!0,this.z_=new o,this.L_=new o,this.O_=new o,this.F_=null,this.W_=null,this.N_=new Map,this.H_=-1,this.U_=[],this.Ps=i,this.Sl=s,this.j_=i.rightOffset,this.q_=i.barSpacing,this.ss=t,this.Y_(i),this.__=n,this.K_(),this.B_.g_(i.uniformDistribution),this.X_()}W(){return this.Ps}G_(t){_(this.Sl,t),this.Z_(),this.K_()}ar(t,i){_(this.Ps,t),this.Ps.fixLeftEdge&&this.J_(),this.Ps.fixRightEdge&&this.Q_(),void 0!==t.barSpacing&&this.ss.fn(t.barSpacing),void 0!==t.rightOffset&&this.ss.pn(t.rightOffset),this.Y_(t),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ss.fn(t.barSpacing??this.q_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.Ps.ignoreWhitespaceIndices&&this.X_(),this.Z_(),this.K_(),this.O_.p()}Ds(t){return this.E_[t]?.time??null}ns(t){return this.E_[t]??null}tc(t,i){if(this.E_.length<1)return null;if(this.__.key(t)>this.__.key(this.E_[this.E_.length-1].time))return i?this.E_.length-1:null;const s=St(this.E_,this.__.key(t),(t,i)=>this.__.key(t.time)<i);return this.__.key(t)<this.__.key(this.E_[s].time)?i?s:null:s}Xi(){return 0===this.bo||0===this.E_.length||null===this.D_}sc(){return this.E_.length>0}Pe(){return this.nc(),this.A_.k_()}ec(){return this.nc(),this.A_.T_()}rc(){const t=this.Pe();if(null===t)return null;const i={from:t.$h(),to:t.Si()};return this.hc(i)}hc(t){const i=Math.round(t.from),s=Math.round(t.to),n=a(this.ac()),e=a(this.lc());return{from:a(this.ns(Math.max(n,i))),to:a(this.ns(Math.min(e,s)))}}oc(t){return{from:a(this.tc(t.from,!0)),to:a(this.tc(t.to,!0))}}ts(){return this.bo}Io(t){if(!isFinite(t)||t<=0)return;if(this.bo===t)return;const i=this.ec(),s=this.bo;if(this.bo=t,this.I_=!0,this.Ps.lockVisibleTimeRangeOnResize&&0!==s){const i=this.q_*t/s;this.q_=i}if(this.Ps.fixLeftEdge&&null!==i&&i.$h()<=0){const i=s-t;this.j_-=Math.round(i/this.q_)+1,this.I_=!0}this._c(),this.cc()}qt(t){if(this.Xi()||!u(t))return 0;const i=this.uc()+this.j_-t;return this.bo-(i+.5)*this.q_-1}dc(t,i){const s=this.uc(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;i<e;i++){const n=t[i].wt,e=s+this.j_-n,r=this.bo-(e+.5)*this.q_-1;t[i].ct=r}}fc(t,i){const s=Math.ceil(this.vc(t));return i&&this.Ps.ignoreWhitespaceIndices&&!this.mc(s)?this.gc(s):s}pn(t){this.I_=!0,this.j_=t,this.cc(),this.ss.wc(),this.ss.lr()}Mc(){return this.q_}fn(t){const i=this.q_;if(this.bc(t),void 0!==this.Ps.rightOffsetPixels&&0!==i){const t=this.j_*i/this.q_;this.j_=t}this.cc(),this.ss.wc(),this.ss.lr()}Sc(){return this.j_}Ea(){if(this.Xi())return null;if(null!==this.W_)return this.W_;const t=this.q_,i=5*(this.ss.W().layout.fontSize+4)/8*(this.Ps.tickMarkMaxCharacterLength||8),s=Math.round(i/t),n=a(this.Pe()),e=Math.max(n.$h(),n.$h()-s),r=Math.max(n.Si(),n.Si()-s),h=this.B_.b_(t,i,this.Ps.ignoreWhitespaceIndices,this.N_,this.H_),l=this.ac()+s,o=this.lc()-s,_=this.xc(),c=this.Ps.fixLeftEdge||_,u=this.Ps.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.index&&t.index<=r))continue;let s;d<this.U_.length?(s=this.U_[d],s.coord=this.qt(t.index),s.label=this.yc(t),s.weight=t.weight):(s={needAlignCoordinate:!1,coord:this.qt(t.index),label:this.yc(t),weight:t.weight},this.U_.push(s)),this.q_>i/2&&!_?s.needAlignCoordinate=!1:s.needAlignCoordinate=c&&t.index<=l||u&&t.index>=o,d++}return this.U_.length=d,this.W_=this.U_,this.U_}Cc(){let t;this.I_=!0,this.fn(this.Ps.barSpacing),t=void 0!==this.Ps.rightOffsetPixels?this.Ps.rightOffsetPixels/this.Mc():this.Ps.rightOffset,this.pn(t)}Pc(t){this.I_=!0,this.D_=t,this.cc(),this.J_()}kc(t,i){const s=this.vc(t),n=this.Mc(),e=n+i*(n/10);this.fn(e),this.Ps.rightBarStaysOnScroll||this.pn(this.Sc()+(s-this.vc(t)))}eo(t){this.gl&&this.oo(),null===this.ml&&null===this.F_&&(this.Xi()||(this.ml=t,this.Tc()))}ro(t){if(null===this.F_)return;const i=Kt(this.bo-t,0,this.bo),s=Kt(this.bo-a(this.ml),0,this.bo);0!==i&&0!==s&&this.fn(this.F_.Mc*i/s)}ho(){null!==this.ml&&(this.ml=null,this.Rc())}ao(t){null===this.gl&&null===this.F_&&(this.Xi()||(this.gl=t,this.Tc()))}lo(t){if(null===this.gl)return;const i=(this.gl-t)/this.Mc();this.j_=a(this.F_).Sc+i,this.I_=!0,this.cc()}oo(){null!==this.gl&&(this.gl=null,this.Rc())}Dc(){this.Ec(this.Ps.rightOffset)}Ec(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.j_,n=performance.now();this.ss.cn({Bc:t=>(t-n)/i>=1,Vc:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}kt(t,i){this.I_=!0,this.E_=t,this.B_.w_(t,i),this.cc()}Ac(){return this.z_}Ic(){return this.L_}zc(){return this.O_}uc(){return this.D_||0}Lc(t,i){const s=t.p_(),n=i&&this.Ps.rightOffsetPixels||0;this.bc((this.bo-n)/s),this.j_=t.Si()-this.uc(),i&&(this.j_=n?n/this.Mc():this.Ps.rightOffset),this.cc(),this.I_=!0,this.ss.wc(),this.ss.lr()}Oc(){const t=this.ac(),i=this.lc();null!==t&&null!==i&&this.Lc(new Ci(t,i),!0)}Fc(t){const i=new Ci(t.from,t.to);this.Lc(i)}es(t){return void 0!==this.Sl.timeFormatter?this.Sl.timeFormatter(t.originalTime):this.__.formatHorzItem(t.time)}X_(){if(!this.Ps.ignoreWhitespaceIndices)return;this.N_.clear();const t=this.ss.Ks();for(const i of t)for(const t of i.ma())this.N_.set(t,!0);this.H_++}xc(){const t=this.ss.W().handleScroll,i=this.ss.W().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}ac(){return 0===this.E_.length?null:0}lc(){return 0===this.E_.length?null:this.E_.length-1}Wc(t){return(this.bo-1-t)/this.q_}vc(t){const i=this.Wc(t),s=this.uc()+this.j_-i;return Math.round(1e6*s)/1e6}bc(t){const i=this.q_;this.q_=t,this._c(),i!==this.q_&&(this.I_=!0,this.Nc())}nc(){if(!this.I_)return;if(this.I_=!1,this.Xi())return void this.Hc(Ti.R_());const t=this.uc(),i=this.bo/this.q_,s=this.j_+t,n=new Ci(s-i+1,s);this.Hc(new Ti(n))}_c(){const t=Kt(this.q_,this.Uc(),this.$c());this.q_!==t&&(this.q_=t,this.I_=!0)}$c(){return this.Ps.maxBarSpacing>0?this.Ps.maxBarSpacing:.5*this.bo}Uc(){return this.Ps.fixLeftEdge&&this.Ps.fixRightEdge&&0!==this.E_.length?this.bo/this.E_.length:this.Ps.minBarSpacing}cc(){const t=this.jc();null!==t&&this.j_<t&&(this.j_=t,this.I_=!0);const i=this.qc();this.j_>i&&(this.j_=i,this.I_=!0)}jc(){const t=this.ac(),i=this.D_;if(null===t||null===i)return null;return t-i-1+(this.Ps.fixLeftEdge?this.bo/this.q_:Math.min(2,this.E_.length))}qc(){return this.Ps.fixRightEdge?0:this.bo/this.q_-Math.min(2,this.E_.length)}Tc(){this.F_={Mc:this.Mc(),Sc:this.Sc()}}Rc(){this.F_=null}yc(t){let i=this.V_.get(t.weight);return void 0===i&&(i=new yi(t=>this.Yc(t),this.__),this.V_.set(t.weight,i)),i.c_(t)}Yc(t){return this.__.formatTickmark(t,this.Sl)}Hc(t){const i=this.A_;this.A_=t,Pi(i.k_(),this.A_.k_())||this.z_.p(),Pi(i.T_(),this.A_.T_())||this.L_.p(),this.Nc()}Nc(){this.W_=null}Z_(){this.Nc(),this.V_.clear()}K_(){this.__.updateFormatter(this.Sl)}J_(){if(!this.Ps.fixLeftEdge)return;const t=this.ac();if(null===t)return;const i=this.Pe();if(null===i)return;const s=i.$h()-t;if(s<0){const t=this.j_-s-1;this.pn(t)}this._c()}Q_(){this.cc(),this._c()}mc(t){return!this.Ps.ignoreWhitespaceIndices||(this.N_.get(t)||!1)}gc(t){const i=function*(t){const i=Math.round(t),s=i<t;let n=1;for(;;)s?(yield i+n,yield i-n):(yield i-n,yield i+n),n++}(t),s=this.lc();for(;s;){const t=i.next().value;if(this.N_.get(t))return t;if(t<0||t>s)break}return t}Y_(t){if(void 0!==t.rightOffsetPixels){const i=t.rightOffsetPixels/(t.barSpacing||this.q_);this.ss.pn(i)}}}var Ei,Bi,Vi,Ai,Ii;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ei||(Ei={}));class zi{constructor(t,i,s){this.Kc=[],this.Xc=[],this.bo=0,this.Gc=null,this.Zc=new o,this.Jc=new o,this.Qc=null,this.tu=t,this.Ps=i,this.__=s,this.xl=new x(this.Ps.layout.colorParsers),this.iu=new M(this),this.dh=new Di(this,i.timeScale,this.Ps.localization,s),this.Ct=new j(this,i.crosshair),this.su=new Yt(i.crosshair),i.addDefaultPane&&(this.nu(0),this.Kc[0].Ao(2)),this.eu=this.ru(0),this.hu=this.ru(1)}Ah(){this.au(Y.Mn())}lr(){this.au(Y.wn())}Zh(){this.au(new Y(1))}Ih(t){const i=this.lu(t);this.au(i)}ou(){return this.Gc}_u(t){if(this.Gc?.e_===t?.e_&&this.Gc?.r_?.Xn===t?.r_?.Xn)return;const i=this.Gc;this.Gc=t,null!==i&&this.Ih(i.e_),null!==t&&t.e_!==i?.e_&&this.Ih(t.e_)}W(){return this.Ps}ar(t){_(this.Ps,t),this.Kc.forEach(i=>i.Do(t)),void 0!==t.timeScale&&this.dh.ar(t.timeScale),void 0!==t.localization&&this.dh.G_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Zc.p(),this.eu=this.ru(0),this.hu=this.ru(1),this.Ah()}cu(t,i,s=0){const n=this.Kc[s];if(void 0===n)return;if("left"===t)return _(this.Ps,{leftPriceScale:i}),n.Do({leftPriceScale:i}),this.Zc.p(),void this.Ah();if("right"===t)return _(this.Ps,{rightPriceScale:i}),n.Do({rightPriceScale:i}),this.Zc.p(),void this.Ah();const e=this.uu(t,s);null!==e&&(e.Nt.ar(i),this.Zc.p())}uu(t,i){const s=this.Kc[i];if(void 0===s)return null;const n=s.Eo(t);return null!==n?{$s:s,Nt:n}:null}It(){return this.dh}js(){return this.Kc}du(){return this.Ct}fu(){return this.Jc}pu(t,i){t.zl(i),this.wc()}Io(t){this.bo=t,this.dh.Io(this.bo),this.Kc.forEach(i=>i.Io(t)),this.wc()}vu(t){1!==this.Kc.length&&(r(t>=0&&t<this.Kc.length,"Invalid pane index"),this.Kc.splice(t,1),this.Ah())}mu(t,i){if(this.Kc.length<2)return;r(t>=0&&t<this.Kc.length,"Invalid pane index");const s=this.Kc[t],n=this.Kc.reduce((t,i)=>t+i.Vo(),0),e=this.Kc.reduce((t,i)=>t+i.jt(),0),h=e-30*(this.Kc.length-1);i=Math.min(h,Math.max(30,i));const a=n/e,l=s.jt();s.Ao(i*a);let o=i-l,_=this.Kc.length-1;for(const t of this.Kc)if(t!==s){const i=Math.min(h,Math.max(30,t.jt()-o/_));o-=t.jt()-i,_-=1;const s=i*a;t.Ao(s)}this.Ah()}gu(t,i){r(t>=0&&t<this.Kc.length&&i>=0&&i<this.Kc.length,"Invalid pane index");const s=this.Kc[t],n=this.Kc[i];this.Kc[t]=n,this.Kc[i]=s,this.Ah()}wu(t,i){if(r(t>=0&&t<this.Kc.length&&i>=0&&i<this.Kc.length,"Invalid pane index"),t===i)return;const[s]=this.Kc.splice(t,1);this.Kc.splice(i,0,s),this.Ah()}$o(t,i,s){t.$o(i,s)}jo(t,i,s){t.jo(i,s),this.zh(),this.au(this.Mu(t,2))}qo(t,i){t.qo(i),this.au(this.Mu(t,2))}Yo(t,i,s){i.Rl()||t.Yo(i,s)}Ko(t,i,s){i.Rl()||(t.Ko(i,s),this.zh(),this.au(this.Mu(t,2)))}Xo(t,i){i.Rl()||(t.Xo(i),this.au(this.Mu(t,2)))}Zo(t,i){t.Zo(i),this.au(this.Mu(t,2))}bu(t){this.dh.eo(t)}Su(t,i){const s=this.It();if(s.Xi()||0===i)return;const n=s.ts();t=Math.max(1,Math.min(t,n)),s.kc(t,i),this.wc()}xu(t){this.yu(0),this.Cu(t),this.Pu()}ku(t){this.dh.ro(t),this.wc()}Tu(){this.dh.ho(),this.lr()}yu(t){this.dh.ao(t)}Cu(t){this.dh.lo(t),this.wc()}Pu(){this.dh.oo(),this.lr()}Ks(){return this.Xc}Ru(t,i,s,n,e){this.Ct.Bs(t,i);let r=NaN,h=this.dh.fc(t,!0);const a=this.dh.Pe();null!==a&&(h=Math.min(Math.max(a.$h(),h),a.Si()));const l=n.Ts(),o=l.Lt();if(null!==o&&(r=l.Rs(i,o)),r=this.su.Ma(r,h,n),this.Ct.zs(h,r,n),this.Zh(),!e){const e=xi(n,t,i);this._u(e&&{e_:e.e_,r_:e.r_,a_:e.a_||null}),this.Jc.p(this.Ct.At(),{x:t,y:i},s)}}Du(t,i,s){const n=s.Ts(),e=n.Lt(),r=n.Wt(t,a(e)),h=this.dh.tc(i,!0),l=this.dh.qt(a(h));this.Ru(l,r,null,s,!0)}Eu(t){this.du().Os(),this.Zh(),t||this.Jc.p(null,null,null)}zh(){const t=this.Ct.$s();if(null!==t){const i=this.Ct.As(),s=this.Ct.Is();this.Ru(i,s,null,t)}this.Ct.Ws()}Bu(t,i,s){const n=this.dh.Ds(0);void 0!==i&&void 0!==s&&this.dh.kt(i,s);const e=this.dh.Ds(0),r=this.dh.uc(),h=this.dh.Pe();if(null!==h&&null!==n&&null!==e){const i=h.Re(r),a=this.__.key(n)>this.__.key(e),l=null!==t&&t>r&&!a,o=this.dh.W().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===s)||o)&&this.dh.W().shiftVisibleRangeOnNewBar;if(l&&!_){const i=t-r;this.dh.pn(this.dh.Sc()-i)}}this.dh.Pc(t)}Oh(t){null!==t&&t.Qo()}Un(t){if(function(t){return t instanceof gi}(t))return t;const i=this.Kc.find(i=>i.Et().includes(t));return void 0===i?null:i}wc(){this.Kc.forEach(t=>t.Qo()),this.zh()}m(){this.Kc.forEach(t=>t.m()),this.Kc.length=0,this.Ps.localization.priceFormatter=void 0,this.Ps.localization.percentageFormatter=void 0,this.Ps.localization.timeFormatter=void 0}Vu(){return this.iu}Yn(){return this.iu.W()}Bo(){return this.Zc}Au(t,i){const s=this.nu(i);this.Iu(t,s),this.Xc.push(t),1===this.Xc.length?this.Ah():this.lr()}zu(t){const i=this.Un(t),s=this.Xc.indexOf(t);r(-1!==s,"Series not found");const n=a(i);this.Xc.splice(s,1),n.io(t),t.m&&t.m(),this.dh.X_();const e=this.Kc.length;this.Lu(n),this.Kc.length<e&&this.Ah()}Vh(t,i){const s=a(this.Un(t));s.io(t,!0),s.Jl(t,i,!0)}Oc(){const t=Y.wn();t.hn(),this.au(t)}Ou(t){const i=Y.wn();i._n(t),this.au(i)}dn(){const t=Y.wn();t.dn(),this.au(t)}fn(t){const i=Y.wn();i.fn(t),this.au(i)}pn(t){const i=Y.wn();i.pn(t),this.au(i)}cn(t){const i=Y.wn();i.cn(t),this.au(i)}an(){const t=Y.wn();t.an(),this.au(t)}Fu(){return this.Ps.rightPriceScale.visible?"right":"left"}Wu(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.Nu(t))return;const s=a(this.Un(t));s.io(t);const n=this.nu(i);this.Iu(t,n),0===s.ba().length&&this.Lu(s),this.Ah()}Hu(){return this.hu}j(){return this.eu}$t(t){const i=this.hu,s=this.eu;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Qc||this.Qc.gr!==s||this.Qc.wr!==i)this.Qc={gr:s,wr:i,Uu:new Map};else{const i=this.Qc.Uu.get(t);if(void 0!==i)return i}const n=this.xl.it(s,i,t/100);return this.Qc.Uu.set(t,n),n}$u(t){return this.Kc.indexOf(t)}Gi(){return this.xl}ju(){return this.qu()}qu(t){const i=new gi(this.dh,this);this.Kc.push(i);const s=t??this.Kc.length-1,n=Y.Mn();return n.tn(s,{sn:0,nn:!0}),this.au(n),i}nu(t){return r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.Kc.length,t))<this.Kc.length?this.Kc[t]:this.qu(t)}Nu(t){return this.Kc.findIndex(i=>i.Fo().includes(t))}Mu(t,i){const s=new Y(i);if(null!==t){const n=this.Kc.indexOf(t);s.tn(n,{sn:i})}return s}lu(t,i){return void 0===i&&(i=2),this.Mu(this.Un(t),i)}au(t){this.tu&&this.tu(t),this.Kc.forEach(t=>t.s_()._r().kt())}Iu(t,i){const s=t.W().priceScaleId,n=void 0!==s?s:this.Fu();i.Jl(t,n),q(n)||t.ar(t.W())}ru(t){const i=this.Ps.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}Lu(t){!t.Oo()&&0===t.ba().length&&this.Kc.length>1&&this.Kc.splice(this.$u(t),1)}}function Li(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}function Oi(t){return!c(t)&&!d(t)}function Fi(t){return c(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Bi||(Bi={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Vi||(Vi={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Ai||(Ai={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Ii||(Ii={}));const Wi=t=>t.getUTCFullYear();function Ni(t,i,s){return i.replace(/yyyy/g,(t=>G(Wi(t),4))(t)).replace(/yy/g,(t=>G(Wi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>G((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>G((t=>t.getUTCDate())(t),2))(t))}class Hi{constructor(t="yyyy-MM-dd",i="default"){this.Yu=t,this.Ku=i}c_(t){return Ni(t,this.Yu,this.Ku)}}class Ui{constructor(t){this.Xu=t||"%h:%m:%s"}c_(t){return this.Xu.replace("%h",G(t.getUTCHours(),2)).replace("%m",G(t.getUTCMinutes(),2)).replace("%s",G(t.getUTCSeconds(),2))}}const $i={Gu:"yyyy-MM-dd",Zu:"%h:%m:%s",Ju:" ",Qu:"default"};class ji{constructor(t={}){const i={...$i,...t};this.td=new Hi(i.Gu,i.Qu),this.sd=new Ui(i.Zu),this.nd=i.Ju}c_(t){return`${this.td.c_(t)}${this.nd}${this.sd.c_(t)}`}}function qi(t){return 60*t*60*1e3}function Yi(t){return 60*t*1e3}const Ki=[{ed:(Xi=1,1e3*Xi),rd:10},{ed:Yi(1),rd:20},{ed:Yi(5),rd:21},{ed:Yi(30),rd:22},{ed:qi(1),rd:30},{ed:qi(3),rd:31},{ed:qi(6),rd:32},{ed:qi(12),rd:33}];var Xi;function Gi(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=Ki.length-1;s>=0;--s)if(Math.floor(i.getTime()/Ki[s].ed)!==Math.floor(t.getTime()/Ki[s].ed))return Ki[s].rd;return 0}function Zi(t){return t}function Ji(t){let i=t;if(d(t)&&(i=ts(t)),!Oi(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{hd:Math.round(s.getTime()/1e3),ad:i}}function Qi(t){if(!Fi(t))throw new Error("time must be of type isUTCTimestamp");return{hd:t}}function ts(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function is(t){d(t.time)&&(t.time=ts(t.time))}class ss{options(){return this.Ps}setOptions(t){this.Ps=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(is)}(t):is(t)}createConverterToInternalObj(t){return a(function(t){return 0===t.length?null:Oi(t[0].time)||d(t[0].time)?Ji:Qi}(t))}key(t){return"object"==typeof t&&"hd"in t?t.hd:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.ad?new Date(1e3*i.hd).getTime():new Date(Date.UTC(i.ad.year,i.ad.month-1,i.ad.day)).getTime()}convertHorzItemToInternal(t){return Fi(i=t)?Qi(i):Oi(i)?Ji(i):Ji(ts(i));var i}updateFormatter(t){if(!this.Ps)return;const i=t.dateFormat;this.Ps.timeScale.timeVisible?this.ld=new ji({Gu:i,Zu:this.Ps.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Ju:" ",Qu:t.locale}):this.ld=new Hi(i,t.locale)}formatHorzItem(t){const i=t;return this.ld.c_(new Date(1e3*i.hd))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.Ps.timeScale.timeVisible,this.Ps.timeScale.secondsVisible),n=this.Ps.timeScale;if(void 0!==n.tickMarkFormatter){const e=n.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==e)return e}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.ad?new Date(1e3*t.hd):new Date(Date.UTC(t.ad.year,t.ad.month-1,t.ad.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Ri,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.hd,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*Zi(i.time).hd);null!==n&&(i.timeWeight=Gi(h,n)),e+=Zi(i.time).hd-(s||Zi(i.time).hd),s=Zi(i.time).hd,n=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0].time.hd-i));t[0].timeWeight=Gi(new Date(1e3*t[0].time.hd),s)}}(t,i)}static od(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function ns(t){var i=t.width,s=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(s<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:s}}function es(t,i){return t.width===i.width&&t.height===i.height}var rs=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){i._observers=i._observers.filter(function(t){return t!==s})}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(i){return i.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},t}();var hs=function(){function t(t,i,s){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=ns({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(n=null==s?void 0:s.allowResizeObserver)||void 0===n||n,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return ns({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=ns(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(i){return i!==t})},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(i){return i!==t})},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;es(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach(function(n){return n.call(s,t,i)})},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=ns(this._transformBitmapSize(t,this._canvasElementClientSize)),n=es(this.bitmapSize,s)?null:s;null===i&&null===n||null!==i&&null!==n&&es(i,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(i,n))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(n){return n.call(s,t,i)})},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise(function(t){var i=new ResizeObserver(function(s){t(s.every(function(t){return"devicePixelContentBoxSize"in t})),i.disconnect()});i.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1}).then(function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()}):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=as(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new rs(t)}(i),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=as(this._canvasElement);if(null!==s){var n=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return ns({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],n):ns({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver(function(i){var s=i.find(function(i){return i.target===t._canvasElement});if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var n=s.devicePixelContentBoxSize[0],e=ns({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(e)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function as(t){return t.ownerDocument.defaultView}var ls=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function os(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var n=t.bitmapSize;if(0===n.width||0===n.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new ls(e,s,n)}const _s="undefined"!=typeof window;function cs(){return!!_s&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function us(){return!!_s&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ds(t){return t+t%2}function fs(t){_s&&void 0!==window.chrome&&t.addEventListener("mousedown",t=>{if(1===t.button)return t.preventDefault(),!1})}class ps{constructor(t,i,s){this._d=0,this.ud=null,this.dd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.fd=0,this.pd=null,this.vd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.md=null,this.gd=!1,this.wd=null,this.Md=null,this.bd=!1,this.Sd=!1,this.xd=!1,this.yd=null,this.Cd=null,this.Pd=null,this.kd=null,this.Td=null,this.Rd=null,this.Dd=null,this.Ed=0,this.Bd=!1,this.Vd=!1,this.Ad=!1,this.Id=0,this.zd=null,this.Ld=!us(),this.Od=t=>{this.Fd(t)},this.Wd=t=>{if(this.Nd(t)){const i=this.Hd(t);if(++this.fd,this.pd&&this.fd>1){const{Ud:s}=this.$d(gs(t),this.vd);s<30&&!this.xd&&this.jd(i,this.Yd.qd),this.Kd()}}else{const i=this.Hd(t);if(++this._d,this.ud&&this._d>1){const{Ud:s}=this.$d(gs(t),this.dd);s<5&&!this.Sd&&this.Xd(i,this.Yd.Gd),this.Zd()}}},this.Jd=t,this.Yd=i,this.Ps=s,this.Qd()}m(){null!==this.yd&&(this.yd(),this.yd=null),null!==this.Cd&&(this.Cd(),this.Cd=null),null!==this.kd&&(this.kd(),this.kd=null),null!==this.Td&&(this.Td(),this.Td=null),null!==this.Rd&&(this.Rd(),this.Rd=null),null!==this.Pd&&(this.Pd(),this.Pd=null),this.tf(),this.Zd()}if(t){this.kd&&this.kd();const i=this.sf.bind(this);if(this.kd=()=>{this.Jd.removeEventListener("mousemove",i)},this.Jd.addEventListener("mousemove",i),this.Nd(t))return;const s=this.Hd(t);this.Xd(s,this.Yd.nf),this.Ld=!0}Zd(){null!==this.ud&&clearTimeout(this.ud),this._d=0,this.ud=null,this.dd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Kd(){null!==this.pd&&clearTimeout(this.pd),this.fd=0,this.pd=null,this.vd={ct:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}sf(t){if(this.Ad||null!==this.Md)return;if(this.Nd(t))return;const i=this.Hd(t);this.Xd(i,this.Yd.ef),this.Ld=!0}rf(t){const i=Ms(t.changedTouches,a(this.zd));if(null===i)return;if(this.Id=ws(t),null!==this.Dd)return;if(this.Vd)return;this.Bd=!0;const s=this.$d(gs(i),a(this.Md)),{hf:n,af:e,Ud:r}=s;if(this.bd||!(r<5)){if(!this.bd){const t=.5*n,i=e>=t&&!this.Ps.lf(),s=t>e&&!this.Ps._f();i||s||(this.Vd=!0),this.bd=!0,this.xd=!0,this.tf(),this.Kd()}if(!this.Vd){const s=this.Hd(t,i);this.jd(s,this.Yd.cf),ms(t)}}}uf(t){if(0!==t.button)return;const i=this.$d(gs(t),a(this.wd)),{Ud:s}=i;if(s>=5&&(this.Sd=!0,this.Zd()),this.Sd){const i=this.Hd(t);this.Xd(i,this.Yd.df)}}$d(t,i){const s=Math.abs(i.ct-t.ct),n=Math.abs(i.ut-t.ut);return{hf:s,af:n,Ud:s+n}}ff(t){let i=Ms(t.changedTouches,a(this.zd));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.zd=null,this.Id=ws(t),this.tf(),this.Md=null,this.Rd&&(this.Rd(),this.Rd=null);const s=this.Hd(t,i);if(this.jd(s,this.Yd.pf),++this.fd,this.pd&&this.fd>1){const{Ud:t}=this.$d(gs(i),this.vd);t<30&&!this.xd&&this.jd(s,this.Yd.qd),this.Kd()}else this.xd||(this.jd(s,this.Yd.vf),this.Yd.vf&&ms(t));0===this.fd&&ms(t),0===t.touches.length&&this.gd&&(this.gd=!1,ms(t))}Fd(t){if(0!==t.button)return;const i=this.Hd(t);if(this.wd=null,this.Ad=!1,this.Td&&(this.Td(),this.Td=null),cs()){this.Jd.ownerDocument.documentElement.removeEventListener("mouseleave",this.Od)}if(!this.Nd(t))if(this.Xd(i,this.Yd.mf),++this._d,this.ud&&this._d>1){const{Ud:s}=this.$d(gs(t),this.dd);s<5&&!this.Sd&&this.Xd(i,this.Yd.Gd),this.Zd()}else this.Sd||this.Xd(i,this.Yd.gf)}tf(){null!==this.md&&(clearTimeout(this.md),this.md=null)}wf(t){if(null!==this.zd)return;const i=t.changedTouches[0];this.zd=i.identifier,this.Id=ws(t);const s=this.Jd.ownerDocument.documentElement;this.xd=!1,this.bd=!1,this.Vd=!1,this.Md=gs(i),this.Rd&&(this.Rd(),this.Rd=null);{const i=this.rf.bind(this),n=this.ff.bind(this);this.Rd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.tf(),this.md=setTimeout(this.Mf.bind(this,t),240)}const n=this.Hd(t,i);this.jd(n,this.Yd.bf),this.pd||(this.fd=0,this.pd=setTimeout(this.Kd.bind(this),500),this.vd=gs(i))}Sf(t){if(0!==t.button)return;const i=this.Jd.ownerDocument.documentElement;cs()&&i.addEventListener("mouseleave",this.Od),this.Sd=!1,this.wd=gs(t),this.Td&&(this.Td(),this.Td=null);{const t=this.uf.bind(this),s=this.Fd.bind(this);this.Td=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this.Ad=!0,this.Nd(t))return;const s=this.Hd(t);this.Xd(s,this.Yd.xf),this.ud||(this._d=0,this.ud=setTimeout(this.Zd.bind(this),500),this.dd=gs(t))}Qd(){this.Jd.addEventListener("mouseenter",this.if.bind(this)),this.Jd.addEventListener("touchcancel",this.tf.bind(this));{const t=this.Jd.ownerDocument,i=t=>{this.Yd.yf&&(t.composed&&this.Jd.contains(t.composedPath()[0])||t.target&&this.Jd.contains(t.target)||this.Yd.yf())};this.Cd=()=>{t.removeEventListener("touchstart",i)},this.yd=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}us()&&(this.Pd=()=>{this.Jd.removeEventListener("dblclick",this.Wd)},this.Jd.addEventListener("dblclick",this.Wd)),this.Jd.addEventListener("mouseleave",this.Cf.bind(this)),this.Jd.addEventListener("touchstart",this.wf.bind(this),{passive:!0}),fs(this.Jd),this.Jd.addEventListener("mousedown",this.Sf.bind(this)),this.Pf(),this.Jd.addEventListener("touchmove",()=>{},{passive:!1})}Pf(){void 0===this.Yd.kf&&void 0===this.Yd.Tf&&void 0===this.Yd.Rf||(this.Jd.addEventListener("touchstart",t=>this.Df(t.touches),{passive:!0}),this.Jd.addEventListener("touchmove",t=>{if(2===t.touches.length&&null!==this.Dd&&void 0!==this.Yd.Tf){const i=vs(t.touches[0],t.touches[1])/this.Ed;this.Yd.Tf(this.Dd,i),ms(t)}},{passive:!1}),this.Jd.addEventListener("touchend",t=>{this.Df(t.touches)}))}Df(t){1===t.length&&(this.Bd=!1),2!==t.length||this.Bd||this.gd?this.Ef():this.Bf(t)}Bf(t){const i=this.Jd.getBoundingClientRect()||{left:0,top:0};this.Dd={ct:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.Ed=vs(t[0],t[1]),void 0!==this.Yd.kf&&this.Yd.kf(),this.tf()}Ef(){null!==this.Dd&&(this.Dd=null,void 0!==this.Yd.Rf&&this.Yd.Rf())}Cf(t){if(this.kd&&this.kd(),this.Nd(t))return;if(!this.Ld)return;const i=this.Hd(t);this.Xd(i,this.Yd.Vf),this.Ld=!us()}Mf(t){const i=Ms(t.touches,a(this.zd));if(null===i)return;const s=this.Hd(t,i);this.jd(s,this.Yd.Af),this.xd=!0,this.gd=!0}Nd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:ws(t)<this.Id+500}jd(t,i){i&&i.call(this.Yd,t)}Xd(t,i){i&&i.call(this.Yd,t)}Hd(t,i){const s=i||t,n=this.Jd.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-n.left,localY:s.clientY-n.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,If:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,zf:t.type,Lf:s.target,l_:t.view,Of:()=>{"touchstart"!==t.type&&ms(t)}}}}function vs(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function ms(t){t.cancelable&&t.preventDefault()}function gs(t){return{ct:t.pageX,ut:t.pageY}}function ws(t){return t.timeStamp||performance.now()}function Ms(t,i){for(let s=0;s<t.length;++s)if(t[s].identifier===i)return t[s];return null}class bs{constructor(t,i,s){this.Ff=null,this.Wf=null,this.Nf=!0,this.Hf=null,this.Uf=t,this.$f=t.jf()[i],this.qf=t.jf()[s],this.Yf=document.createElement("tr"),this.Yf.style.height="1px",this.Kf=document.createElement("td"),this.Kf.style.position="relative",this.Kf.style.padding="0",this.Kf.style.margin="0",this.Kf.setAttribute("colspan","3"),this.Xf(),this.Yf.appendChild(this.Kf),this.Nf=this.Uf.W().layout.panes.enableResize,this.Nf?this.Gf():(this.Ff=null,this.Wf=null)}m(){null!==this.Wf&&this.Wf.m()}Zf(){return this.Yf}Jf(){return ns({width:this.$f.Jf().width,height:1})}Qf(){return ns({width:this.$f.Qf().width,height:1*window.devicePixelRatio})}tp(t,i,s){const n=this.Qf();t.fillStyle=this.Uf.W().layout.panes.separatorColor,t.fillRect(i,s,n.width,n.height)}kt(){this.Xf(),this.Uf.W().layout.panes.enableResize!==this.Nf&&(this.Nf=this.Uf.W().layout.panes.enableResize,this.Nf?this.Gf():(null!==this.Ff&&(this.Kf.removeChild(this.Ff.ip),this.Kf.removeChild(this.Ff.sp),this.Ff=null),null!==this.Wf&&(this.Wf.m(),this.Wf=null)))}Gf(){const t=document.createElement("div"),i=t.style;i.position="fixed",i.display="none",i.zIndex="49",i.top="0",i.left="0",i.width="100%",i.height="100%",i.cursor="row-resize",this.Kf.appendChild(t);const s=document.createElement("div"),n=s.style;n.position="absolute",n.zIndex="50",n.top="-4px",n.height="9px",n.width="100%",n.backgroundColor="",n.cursor="row-resize",this.Kf.appendChild(s);const e={nf:this.np.bind(this),Vf:this.ep.bind(this),xf:this.rp.bind(this),bf:this.rp.bind(this),df:this.hp.bind(this),cf:this.hp.bind(this),mf:this.ap.bind(this),pf:this.ap.bind(this)};this.Wf=new ps(s,e,{lf:()=>!1,_f:()=>!0}),this.Ff={sp:s,ip:t}}Xf(){this.Kf.style.background=this.Uf.W().layout.panes.separatorColor}np(t){null!==this.Ff&&(this.Ff.sp.style.backgroundColor=this.Uf.W().layout.panes.separatorHoverColor)}ep(t){null!==this.Ff&&null===this.Hf&&(this.Ff.sp.style.backgroundColor="")}rp(t){if(null===this.Ff)return;const i=this.$f.lp().Vo()+this.qf.lp().Vo(),s=i/(this.$f.Jf().height+this.qf.Jf().height),n=30*s;i<=2*n||(this.Hf={op:t.pageY,_p:this.$f.lp().Vo(),cp:i-n,up:i,dp:s,fp:n},this.Ff.ip.style.display="block")}hp(t){const i=this.Hf;if(null===i)return;const s=(t.pageY-i.op)*i.dp,n=Kt(i._p+s,i.fp,i.cp);this.$f.lp().Ao(n),this.qf.lp().Ao(i.up-n),this.Uf.ti().Ah()}ap(t){null!==this.Hf&&null!==this.Ff&&(this.Hf=null,this.Ff.ip.style.display="none")}}function Ss(t,i){return t.pp-i.pp}function xs(t,i,s){const n=(t.pp-i.pp)/(t.wt-i.wt);return Math.sign(n)*Math.min(Math.abs(n),s)}class ys{constructor(t,i,s,n){this.vp=null,this.mp=null,this.gp=null,this.wp=null,this.Mp=null,this.bp=0,this.Sp=0,this.xp=t,this.yp=i,this.Cp=s,this.bn=n}Pp(t,i){if(null!==this.vp){if(this.vp.wt===i)return void(this.vp.pp=t);if(Math.abs(this.vp.pp-t)<this.bn)return}this.wp=this.gp,this.gp=this.mp,this.mp=this.vp,this.vp={wt:i,pp:t}}oe(t,i){if(null===this.vp||null===this.mp)return;if(i-this.vp.wt>50)return;let s=0;const n=xs(this.vp,this.mp,this.yp),e=Ss(this.vp,this.mp),r=[n],h=[e];if(s+=e,null!==this.gp){const t=xs(this.mp,this.gp,this.yp);if(Math.sign(t)===Math.sign(n)){const i=Ss(this.mp,this.gp);if(r.push(t),h.push(i),s+=i,null!==this.wp){const t=xs(this.gp,this.wp,this.yp);if(Math.sign(t)===Math.sign(n)){const i=Ss(this.gp,this.wp);r.push(t),h.push(i),s+=i}}}}let a=0;for(let t=0;t<r.length;++t)a+=h[t]/s*r[t];Math.abs(a)<this.xp||(this.Mp={pp:t,wt:i},this.Sp=a,this.bp=function(t,i){const s=Math.log(i);return Math.log(1*s/-t)/s}(Math.abs(a),this.Cp))}Vc(t){const i=a(this.Mp),s=t-i.wt;return i.pp+this.Sp*(Math.pow(this.Cp,s)-1)/Math.log(this.Cp)}Bc(t){return null===this.Mp||this.kp(t)===this.bp}kp(t){const i=t-a(this.Mp).wt;return Math.min(i,this.bp)}}class Cs{constructor(t,i){this.Tp=void 0,this.Rp=void 0,this.Dp=void 0,this.vs=!1,this.Ep=t,this.Bp=i,this.Vp()}kt(){this.Vp()}Ap(){this.Tp&&this.Ep.removeChild(this.Tp),this.Rp&&this.Ep.removeChild(this.Rp),this.Tp=void 0,this.Rp=void 0}Ip(){return this.vs!==this.zp()||this.Dp!==this.Lp()}Lp(){return this.Bp.ti().Gi().tt(this.Bp.W().layout.textColor)>160?"dark":"light"}zp(){return this.Bp.W().layout.attributionLogo}Op(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Vp(){this.Ip()&&(this.Ap(),this.vs=this.zp(),this.vs&&(this.Dp=this.Lp(),this.Rp=document.createElement("style"),this.Rp.innerText="a#pipsend-attr-logo{--fill:#13d3c9;position:absolute;left:10px;bottom:10px;height:24px;width:46px;margin:0;padding:0;border:0;z-index:3;opacity:0.8;transition:opacity 0.3s;}a#pipsend-attr-logo:hover{opacity:1;}a#pipsend-attr-logo[data-dark]{--fill:#13d3c9;}",this.Tp=document.createElement("a"),this.Tp.href=`https://pipsend.com${this.Op()}`,this.Tp.title="Powered by Pipsend Charts",this.Tp.id="pipsend-attr-logo",this.Tp.target="_blank",this.Tp.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 155.89"><g><circle cx="220.68" cy="77.94" r="32.86" style="fill: var(--fill);"/><path d="M138.84,77.94c0,12.01-3.69,23.15-10,32.37h42.32v-.22c-6.21-9.17-9.84-20.24-9.84-32.15s3.63-22.97,9.84-32.15v-.22h-42.32c6.3,9.22,10,20.36,10,32.37Z" style="fill: var(--fill);"/><path d="M222.06,0H77.94C34.9,0,0,34.9,0,77.94h0c0,43.05,34.9,77.94,77.94,77.94h144.11c43.05,0,77.94-34.9,77.94-77.94h0C300,34.9,265.1,0,222.06,0ZM279.4,77.94c0,31.75-25.74,57.49-57.49,57.49H78.09c-31.75,0-57.49-25.74-57.49-57.49h0c0-31.75,25.74-57.49,57.49-57.49h143.82c31.75,0,57.49,25.74,57.49,57.49h0Z" style="fill: var(--fill);"/><circle cx="79.33" cy="77.94" r="32.86" style="fill: var(--fill);"/></g></svg>',this.Tp.toggleAttribute("data-dark","dark"===this.Dp),this.Ep.appendChild(this.Rp),this.Ep.appendChild(this.Tp)))}}function Ps(t,i){const s=a(t.ownerDocument).createElement("canvas");t.appendChild(s);const n=new hs(s,(e={options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})}).transform,e.options);var e;return n.resizeCanvasElement(i),n}function ks(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function Ts(t,i,s,n){t.sh&&t.sh(i,s,n)}function Rs(t,i,s,n){t.et(i,s,n)}function Ds(t,i,s,n){const e=t(s,n);for(const t of e){const s=t.Rt(n);null!==s&&i(s)}}function Es(t,i){return s=>{if(!function(t){return void 0!==t.Nt}(s))return[];return(s.Nt()?.ga()??"")!==i?[]:s.ia?.(t)??[]}}function Bs(t,i,s,n){if(!t.length)return;let e=0;const r=t[0].jt(n,!0);let h=1===i?s/2-(t[0].Ni()-r/2):t[0].Ni()-r/2-s/2;h=Math.max(0,h);for(let r=1;r<t.length;r++){const a=t[r],l=t[r-1],o=l.jt(n,!1),_=a.Ni(),c=l.Ni();if(1===i?_>c-o:_<c+o){const n=c-o*i;a.Hi(n);const r=n-i*o/2;if((1===i?r<0:r>s)&&h>0){const n=1===i?-1-r:r-s,a=Math.min(n,h);for(let s=e;s<t.length;s++)t[s].Hi(t[s].Ni()+i*a);h-=a}}else e=r,h=1===i?c-o-_:_-(c+o)}}class Vs{constructor(t,i,s,n){this.Yi=null,this.Fp=null,this.Wp=!1,this.Np=new it(200),this.Hp=null,this.Up=0,this.$p=!1,this.jp=()=>{this.$p||this.Pt.qp().ti().lr()},this.Yp=()=>{this.$p||this.Pt.qp().ti().lr()},this.Pt=t,this.Ps=i,this.bl=i.layout,this.iu=s,this.Kp="left"===n,this.Xp=Es("normal",n),this.Gp=Es("top",n),this.Zp=Es("bottom",n),this.Kf=document.createElement("div"),this.Kf.style.height="100%",this.Kf.style.overflow="hidden",this.Kf.style.width="25px",this.Kf.style.left="0",this.Kf.style.position="relative",this.Jp=Ps(this.Kf,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const e=this.Jp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.Qp=Ps(this.Kf,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const r=this.Qp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={xf:this.rp.bind(this),bf:this.rp.bind(this),df:this.hp.bind(this),cf:this.hp.bind(this),yf:this.tv.bind(this),mf:this.ap.bind(this),pf:this.ap.bind(this),Gd:this.iv.bind(this),qd:this.iv.bind(this),nf:this.sv.bind(this),Vf:this.ep.bind(this)};this.Wf=new ps(this.Qp.canvasElement,h,{lf:()=>!this.Ps.handleScroll.vertTouchDrag,_f:()=>!0})}m(){this.Wf.m(),this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose(),null!==this.Yi&&this.Yi.no().u(this),this.Yi=null}Zf(){return this.Kf}P(){return this.bl.fontSize}nv(){const t=this.iu.W();return this.Hp!==t.T&&(this.Np.Vn(),this.Hp=t.T),t}ev(){if(null===this.Yi)return 0;let t=0;const i=this.nv(),s=a(this.Jp.canvasElement.getContext("2d",{colorSpace:this.Pt.qp().W().layout.colorSpace}));s.save();const n=this.Yi.Ea();s.font=this.rv(),n.length>0&&(t=Math.max(this.Np.Bi(s,n[0].Za),this.Np.Bi(s,n[n.length-1].Za)));const e=this.hv();for(let i=e.length;i--;){const n=this.Np.Bi(s,e[i].hi());n>t&&(t=n)}const r=this.Yi.Lt();if(null!==r&&null!==this.Fp&&(2!==(h=this.Ps.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Yi.Rs(1,r),n=this.Yi.Rs(this.Fp.height-2,r);t=Math.max(t,this.Np.Bi(s,this.Yi.Zi(Math.floor(Math.min(i,n))+.11111111111111,r)),this.Np.Bi(s,this.Yi.Zi(Math.ceil(Math.max(i,n))-.11111111111111,r)))}var h;s.restore();const l=t||34;return ds(Math.ceil(i.S+i.C+i.A+i.I+5+l))}av(t){null!==this.Fp&&es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`)}lv(){return a(this.Fp).width}cs(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.no().u(this),this.Yi=t,t.no().i(this.cl.bind(this),this))}Nt(){return this.Yi}Vn(){const t=this.Pt.lp();this.Pt.qp().ti().Zo(t,a(this.Nt()))}ov(t){if(null===this.Fp)return;const i={colorSpace:this.Pt.qp().W().layout.colorSpace};if(1!==t){this._v(),this.Jp.applySuggestedBitmapSize();const t=os(this.Jp,i);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t)}),this.Pt.dv(t,this.Zp),this.fv(t),this.Pt.dv(t,this.Xp),this.pv(t))}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.vv(s),this.Pt.dv(s,this.Gp))}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;t.drawImage(n,i,s)}}kt(){this.Yi?.Ea()}rp(t){if(null===this.Yi||this.Yi.Xi()||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp();this.Wp=!0,i.$o(s,this.Yi,t.localY)}hp(t){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp(),n=this.Yi;i.jo(s,n,t.localY)}tv(){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const t=this.Pt.qp().ti(),i=this.Pt.lp(),s=this.Yi;this.Wp&&(this.Wp=!1,t.qo(i,s))}ap(t){if(null===this.Yi||!this.Ps.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.qp().ti(),s=this.Pt.lp();this.Wp=!1,i.qo(s,this.Yi)}iv(t){this.Ps.handleScale.axisDoubleClickReset.price&&this.Vn()}sv(t){if(null===this.Yi)return;!this.Pt.qp().ti().W().handleScale.axisPressedMouseMove.price||this.Yi.Oe()||this.Yi.El()||this.mv(1)}ep(t){this.mv(0)}hv(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let n=0;n<s.length;++n){const e=s[n].Hs(this.Pt.lp(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.Pt.lp().Et()),t}cv({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.Pt.lp().ti(),r=e.j(),h=e.Hu();r===h?V(t,0,0,s,n,r):z(t,0,0,s,n,r,h)}uv({context:t,bitmapSize:i,horizontalPixelRatio:s}){if(null===this.Fp||null===this.Yi||!this.Yi.W().borderVisible)return;t.fillStyle=this.Yi.W().borderColor;const n=Math.max(1,Math.floor(this.nv().S*s));let e;e=this.Kp?i.width-n:0,t.fillRect(e,0,n,i.height)}fv(t){if(null===this.Fp||null===this.Yi)return;const i=this.Yi.Ea(),s=this.Yi.W(),n=this.nv(),e=this.Kp?this.Fp.width-n.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=s.borderColor;const a=Math.max(1,Math.floor(h)),l=Math.floor(.5*h),o=Math.round(n.C*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.Pa*h)-l,o,a);t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{t.font=this.rv(),t.fillStyle=s.textColor??this.bl.textColor,t.textAlign=this.Kp?"right":"left",t.textBaseline="middle";const r=this.Kp?Math.round(e-n.A):Math.round(e+n.C+n.A),h=i.map(i=>this.Np.Ei(t,i.Za));for(let s=i.length;s--;){const n=i[s];t.fillText(n.Za,r,n.Pa+h[s])}})}_v(){if(null===this.Fp||null===this.Yi)return;let t=this.Fp.height/2;const i=[],s=this.Yi.Et().slice(),n=this.Pt.lp(),e=this.nv();this.Yi===n.jn()&&this.Pt.lp().Et().forEach(t=>{n.$n(t)&&s.push(t)});const r=this.Yi.ba()[0],h=this.Yi;s.forEach(s=>{const e=s.Hs(n,h);e.forEach(t=>{t.Hi(null),t.Ui()&&i.push(t)}),r===s&&e.length>0&&(t=e[0].Ai())}),i.forEach(t=>t.Hi(t.Ai()));this.Yi.W().alignLabels&&this.gv(i,e,t)}gv(t,i,s){if(null===this.Fp)return;const n=t.filter(t=>t.Ai()<=s),e=t.filter(t=>t.Ai()>s);n.sort((t,i)=>i.Ai()-t.Ai()),n.length&&e.length&&e.push(n[0]),e.sort((t,i)=>t.Ai()-i.Ai());for(const s of t){const t=Math.floor(s.jt(i)/2),n=s.Ai();n>-t&&n<t&&s.Hi(t),n>this.Fp.height-t&&n<this.Fp.height+t&&s.Hi(this.Fp.height-t)}Bs(n,1,this.Fp.height,i),Bs(e,-1,this.Fp.height,i)}pv(t){if(null===this.Fp)return;const i=this.hv(),s=this.nv(),n=this.Kp?"right":"left";i.forEach(i=>{if(i.$i()){i.Rt(a(this.Yi)).et(t,s,this.Np,n)}})}vv(t){if(null===this.Fp||null===this.Yi)return;const i=this.Pt.qp().ti(),s=[],n=this.Pt.lp(),e=i.du().Hs(n,this.Yi);e.length&&s.push(e);const r=this.nv(),h=this.Kp?"right":"left";s.forEach(i=>{i.forEach(i=>{i.Rt(a(this.Yi)).et(t,r,this.Np,h)})})}mv(t){this.Kf.style.cursor=1===t?"ns-resize":"default"}cl(){const t=this.ev();this.Up<t&&this.Pt.qp().ti().Ah(),this.Up=t}rv(){return w(this.bl.fontSize,this.bl.fontFamily)}}function As(t,i){return t.Qh?.(i)??[]}function Is(t,i){return t.Ns?.(i)??[]}function zs(t,i){return t.us?.(i)??[]}function Ls(t,i){return t.Gh?.(i)??[]}class Os{constructor(t,i){this.Fp=ns({width:0,height:0}),this.wv=null,this.Mv=null,this.bv=null,this.Sv=null,this.xv=!1,this.yv=new o,this.Cv=new o,this.Pv=0,this.kv=!1,this.Tv=null,this.Rv=!1,this.Dv=null,this.Ev=null,this.$p=!1,this.jp=()=>{this.$p||null===this.Bv||this.ss().lr()},this.Yp=()=>{this.$p||null===this.Bv||this.ss().lr()},this.Bp=t,this.Bv=i,this.Bv.i_().i(this.Vv.bind(this),this,!0),this.Av=document.createElement("td"),this.Av.style.padding="0",this.Av.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.Iv=document.createElement("td"),this.Iv.style.padding="0",this.zv=document.createElement("td"),this.zv.style.padding="0",this.Av.appendChild(s),this.Jp=Ps(s,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const n=this.Jp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.Qp=Ps(s,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const e=this.Qp.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.Yf=document.createElement("tr"),this.Yf.appendChild(this.Iv),this.Yf.appendChild(this.Av),this.Yf.appendChild(this.zv),this.Lv(),this.Wf=new ps(this.Qp.canvasElement,this,{lf:()=>null===this.Tv&&!this.Bp.W().handleScroll.vertTouchDrag,_f:()=>null===this.Tv&&!this.Bp.W().handleScroll.horzTouchDrag})}m(){null!==this.wv&&this.wv.m(),null!==this.Mv&&this.Mv.m(),this.bv=null,this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose(),null!==this.Bv&&(this.Bv.i_().u(this),this.Bv.m()),this.Wf.m()}lp(){return a(this.Bv)}Ov(t){null!==this.Bv&&this.Bv.i_().u(this),this.Bv=t,null!==this.Bv&&this.Bv.i_().i(Os.prototype.Vv.bind(this),this,!0),this.Lv(),this.Bp.jf().indexOf(this)===this.Bp.jf().length-1?(this.bv=this.bv??new Cs(this.Av,this.Bp),this.bv.kt()):(this.bv?.Ap(),this.bv=null)}qp(){return this.Bp}Zf(){return this.Yf}Lv(){if(null!==this.Bv&&(this.Fv(),0!==this.ss().Ks().length)){if(null!==this.wv){const t=this.Bv.Ho();this.wv.cs(a(t))}if(null!==this.Mv){const t=this.Bv.Uo();this.Mv.cs(a(t))}}}Wv(){null!==this.wv&&this.wv.kt(),null!==this.Mv&&this.Mv.kt()}Vo(){return null!==this.Bv?this.Bv.Vo():0}Ao(t){this.Bv&&this.Bv.Ao(t)}nf(t){if(!this.Bv)return;this.Nv();const i=t.localX,s=t.localY;this.Hv(i,s,t)}xf(t){this.Nv(),this.Uv(),this.Hv(t.localX,t.localY,t)}ef(t){if(!this.Bv)return;this.Nv();const i=t.localX,s=t.localY;this.Hv(i,s,t)}gf(t){null!==this.Bv&&(this.Nv(),this.$v(t))}Gd(t){null!==this.Bv&&this.jv(this.Cv,t)}qd(t){this.Gd(t)}df(t){this.Nv(),this.qv(t),this.Hv(t.localX,t.localY,t)}mf(t){null!==this.Bv&&(this.Nv(),this.kv=!1,this.Yv(t))}vf(t){null!==this.Bv&&this.$v(t)}Af(t){if(this.kv=!0,null===this.Tv){const i={x:t.localX,y:t.localY};this.Kv(i,i,t)}}Vf(t){null!==this.Bv&&(this.Nv(),this.Bv.ti()._u(null),this.Xv())}Gv(){return this.yv}Zv(){return this.Cv}kf(){this.Pv=1,this.ss().an()}Tf(t,i){if(!this.Bp.W().handleScale.pinch)return;const s=5*(i-this.Pv);this.Pv=i,this.ss().Su(t.ct,s)}bf(t){this.kv=!1,this.Rv=null!==this.Tv,this.Uv();const i=this.ss().du();null!==this.Tv&&i.Bt()&&(this.Dv={x:i.ni(),y:i.ei()},this.Tv={x:t.localX,y:t.localY})}cf(t){if(null===this.Bv)return;const i=t.localX,s=t.localY;if(null!==this.Tv){this.Rv=!1;const n=a(this.Dv),e=n.x+(i-this.Tv.x),r=n.y+(s-this.Tv.y);return void this.Hv(e,r,t)}this.qv(t)}pf(t){0===this.qp().W().trackingMode.exitMode&&(this.Rv=!0),this.Jv(),this.Yv(t)}Kn(t,i){const s=this.Bv;return null===s?null:xi(s,t,i)}Qv(t,i){a("left"===i?this.wv:this.Mv).av(ns({width:t,height:this.Fp.height}))}Jf(){return this.Fp}av(t){es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Av.style.width=t.width+"px",this.Av.style.height=t.height+"px")}tm(){const t=a(this.Bv);t.No(t.Ho()),t.No(t.Uo());for(const i of t.ba())if(t.$n(i)){const s=i.Nt();null!==s&&t.No(s),i.Ws()}for(const i of t.n_())i.Ws()}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;null!==t&&t.drawImage(n,i,s)}}ov(t){if(0===t)return;if(null===this.Bv)return;t>1&&this.tm(),null!==this.wv&&this.wv.ov(t),null!==this.Mv&&this.Mv.ov(t);const i={colorSpace:this.Bp.W().layout.colorSpace};if(1!==t){this.Jp.applySuggestedBitmapSize();const t=os(this.Jp,i);null!==t&&(t.useBitmapCoordinateSpace(t=>{this.cv(t)}),this.Bv&&(this.im(t,As),this.sm(t),this.im(t,Is),this.im(t,zs)))}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.nm(s),this.im(s,Ls),this.im(s,zs))}rm(){return this.wv}hm(){return this.Mv}dv(t,i){this.im(t,i)}Vv(){null!==this.Bv&&this.Bv.i_().u(this),this.Bv=null}$v(t){this.jv(this.yv,t)}jv(t,i){const s=i.localX,n=i.localY;t.v()&&t.p(this.ss().It().fc(s),{x:s,y:n},i)}cv({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ss(),r=e.j(),h=e.Hu();r===h?V(t,0,0,s,n,h):z(t,0,0,s,n,r,h)}sm(t){const i=a(this.Bv),s=i.s_()._r().Rt(i);null!==s&&s.et(t,!1)}nm(t){this.am(t,Is,Rs,this.ss().du())}im(t,i){const s=a(this.Bv),n=s.Et(),e=s.n_();for(const s of e)this.am(t,i,Ts,s);for(const s of n)this.am(t,i,Ts,s);for(const s of e)this.am(t,i,Rs,s);for(const s of n)this.am(t,i,Rs,s)}am(t,i,s,n){const e=a(this.Bv),r=e.ti().ou(),h=null!==r&&r.e_===n,l=null!==r&&h&&void 0!==r.r_?r.r_.Gn:void 0;Ds(i,i=>s(i,t,h,l),n,e)}Fv(){if(null===this.Bv)return;const t=this.Bp,i=this.Bv.Ho().W().visible,s=this.Bv.Uo().W().visible;i||null===this.wv||(this.Iv.removeChild(this.wv.Zf()),this.wv.m(),this.wv=null),s||null===this.Mv||(this.zv.removeChild(this.Mv.Zf()),this.Mv.m(),this.Mv=null);const n=t.ti().Vu();i&&null===this.wv&&(this.wv=new Vs(this,t.W(),n,"left"),this.Iv.appendChild(this.wv.Zf())),s&&null===this.Mv&&(this.Mv=new Vs(this,t.W(),n,"right"),this.zv.appendChild(this.Mv.Zf()))}lm(t){return t.If&&this.kv||null!==this.Tv}om(t){return Math.max(0,Math.min(t,this.Fp.width-1))}_m(t){return Math.max(0,Math.min(t,this.Fp.height-1))}Hv(t,i,s){this.ss().Ru(this.om(t),this._m(i),s,a(this.Bv))}Xv(){this.ss().Eu()}Jv(){this.Rv&&(this.Tv=null,this.Xv())}Kv(t,i,s){this.Tv=t,this.Rv=!1,this.Hv(i.x,i.y,s);const n=this.ss().du();this.Dv={x:n.ni(),y:n.ei()}}ss(){return this.Bp.ti()}Yv(t){if(!this.xv)return;const i=this.ss(),s=this.lp();if(i.Xo(s,s.Ts()),this.Sv=null,this.xv=!1,i.Pu(),null!==this.Ev){const t=performance.now(),s=i.It();this.Ev.oe(s.Sc(),t),this.Ev.Bc(t)||i.cn(this.Ev)}}Nv(){this.Tv=null}Uv(){if(!this.Bv)return;if(this.ss().an(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)a(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Bv.Ts().Xi()&&this.ss().It().Xi()}qv(t){if(null===this.Bv)return;const i=this.ss(),s=i.It();if(s.Xi())return;const n=this.Bp.W(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t.If)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.If))return;const h=this.Bv.Ts(),a=performance.now();if(null!==this.Sv||this.lm(t)||(this.Sv={x:t.clientX,y:t.clientY,hd:a,um:t.localX,dm:t.localY}),null!==this.Sv&&!this.xv&&(this.Sv.x!==t.clientX||this.Sv.y!==t.clientY)){if(t.If&&r.touch||!t.If&&r.mouse){const t=s.Mc();this.Ev=new ys(.2/t,7/t,.997,15/t),this.Ev.Pp(s.Sc(),this.Sv.hd)}else this.Ev=null;h.Xi()||i.Yo(this.Bv,h,t.localY),i.yu(t.localX),this.xv=!0}this.xv&&(h.Xi()||i.Ko(this.Bv,h,t.localY),i.Cu(t.localX),null!==this.Ev&&this.Ev.Pp(s.Sc(),a))}}class Fs{constructor(t,i,s,n,e){this.yt=!0,this.Fp=ns({width:0,height:0}),this.jp=()=>this.ov(3),this.Kp="left"===t,this.iu=s.Vu,this.Ps=i,this.fm=n,this.pm=e,this.Kf=document.createElement("div"),this.Kf.style.width="25px",this.Kf.style.height="100%",this.Kf.style.overflow="hidden",this.Jp=Ps(this.Kf,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp)}m(){this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose()}Zf(){return this.Kf}Jf(){return this.Fp}av(t){es(this.Fp,t)||(this.Fp=t,this.Jp.resizeCanvasElement(t),this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`,this.yt=!0)}ov(t){if(t<3&&!this.yt)return;if(0===this.Fp.width||0===this.Fp.height)return;this.yt=!1,this.Jp.applySuggestedBitmapSize();const i=os(this.Jp,{colorSpace:this.Ps.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t)})}Qf(){return this.Jp.bitmapSize}tp(t,i,s){const n=this.Qf();n.width>0&&n.height>0&&t.drawImage(this.Jp.canvasElement,i,s)}uv({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.fm())return;t.fillStyle=this.Ps.timeScale.borderColor;const e=Math.floor(this.iu.W().S*s),r=Math.floor(this.iu.W().S*n),h=this.Kp?i.width-e:0;t.fillRect(h,0,e,r)}cv({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.pm())}}function Ws(t){return i=>i.sa?.(t)??[]}const Ns=Ws("normal"),Hs=Ws("top"),Us=Ws("bottom");class $s{constructor(t,i){this.vm=null,this.gm=null,this.M=null,this.wm=!1,this.Fp=ns({width:0,height:0}),this.Mm=new o,this.Np=new it(5),this.$p=!1,this.jp=()=>{this.$p||this.Bp.ti().lr()},this.Yp=()=>{this.$p||this.Bp.ti().lr()},this.Bp=t,this.__=i,this.Ps=t.W().layout,this.Tp=document.createElement("tr"),this.bm=document.createElement("td"),this.bm.style.padding="0",this.Sm=document.createElement("td"),this.Sm.style.padding="0",this.Kf=document.createElement("td"),this.Kf.style.height="25px",this.Kf.style.padding="0",this.xm=document.createElement("div"),this.xm.style.width="100%",this.xm.style.height="100%",this.xm.style.position="relative",this.xm.style.overflow="hidden",this.Kf.appendChild(this.xm),this.Jp=Ps(this.xm,ns({width:16,height:16})),this.Jp.subscribeSuggestedBitmapSizeChanged(this.jp);const s=this.Jp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Qp=Ps(this.xm,ns({width:16,height:16})),this.Qp.subscribeSuggestedBitmapSizeChanged(this.Yp);const n=this.Qp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.Tp.appendChild(this.bm),this.Tp.appendChild(this.Kf),this.Tp.appendChild(this.Sm),this.ym(),this.Bp.ti().Bo().i(this.ym.bind(this),this),this.Wf=new ps(this.Qp.canvasElement,this,{lf:()=>!0,_f:()=>!this.Bp.W().handleScroll.horzTouchDrag})}m(){this.Wf.m(),null!==this.vm&&this.vm.m(),null!==this.gm&&this.gm.m(),this.Qp.unsubscribeSuggestedBitmapSizeChanged(this.Yp),ks(this.Qp.canvasElement),this.Qp.dispose(),this.Jp.unsubscribeSuggestedBitmapSizeChanged(this.jp),ks(this.Jp.canvasElement),this.Jp.dispose()}Zf(){return this.Tp}Cm(){return this.vm}Pm(){return this.gm}xf(t){if(this.wm)return;this.wm=!0;const i=this.Bp.ti();!i.It().Xi()&&this.Bp.W().handleScale.axisPressedMouseMove.time&&i.bu(t.localX)}bf(t){this.xf(t)}yf(){const t=this.Bp.ti();!t.It().Xi()&&this.wm&&(this.wm=!1,this.Bp.W().handleScale.axisPressedMouseMove.time&&t.Tu())}df(t){const i=this.Bp.ti();!i.It().Xi()&&this.Bp.W().handleScale.axisPressedMouseMove.time&&i.ku(t.localX)}cf(t){this.df(t)}mf(){this.wm=!1;const t=this.Bp.ti();t.It().Xi()&&!this.Bp.W().handleScale.axisPressedMouseMove.time||t.Tu()}pf(){this.mf()}Gd(){this.Bp.W().handleScale.axisDoubleClickReset.time&&this.Bp.ti().dn()}qd(){this.Gd()}nf(){this.Bp.ti().W().handleScale.axisPressedMouseMove.time&&this.mv(1)}Vf(){this.mv(0)}Jf(){return this.Fp}km(){return this.Mm}Tm(t,i,s){es(this.Fp,t)||(this.Fp=t,this.$p=!0,this.Jp.resizeCanvasElement(t),this.Qp.resizeCanvasElement(t),this.$p=!1,this.Kf.style.width=`${t.width}px`,this.Kf.style.height=`${t.height}px`,this.Mm.p(t)),null!==this.vm&&this.vm.av(ns({width:i,height:t.height})),null!==this.gm&&this.gm.av(ns({width:s,height:t.height}))}Rm(){const t=this.Dm();return Math.ceil(t.S+t.C+t.P+t.L+t.V+t.Em)}kt(){this.Bp.ti().It().Ea()}Qf(){return this.Jp.bitmapSize}tp(t,i,s,n){const e=this.Qf();if(e.width>0&&e.height>0&&(t.drawImage(this.Jp.canvasElement,i,s),n)){const n=this.Qp.canvasElement;t.drawImage(n,i,s)}}ov(t){if(0===t)return;const i={colorSpace:this.Ps.colorSpace};if(1!==t){this.Jp.applySuggestedBitmapSize();const s=os(this.Jp,i);null!==s&&(s.useBitmapCoordinateSpace(t=>{this.cv(t),this.uv(t),this.Bm(s,Us)}),this.fv(s),this.Bm(s,Ns)),null!==this.vm&&this.vm.ov(t),null!==this.gm&&this.gm.ov(t)}this.Qp.applySuggestedBitmapSize();const s=os(this.Qp,i);null!==s&&(s.useBitmapCoordinateSpace(({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)}),this.Vm([...this.Bp.ti().Ks(),this.Bp.ti().du()],s),this.Bm(s,Hs))}Bm(t,i){const s=this.Bp.ti().Ks();for(const n of s)Ds(i,i=>Ts(i,t,!1,void 0),n,void 0);for(const n of s)Ds(i,i=>Rs(i,t,!1,void 0),n,void 0)}cv({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.Bp.ti().Hu())}uv({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.Bp.W().timeScale.borderVisible){t.fillStyle=this.Am();const n=Math.max(1,Math.floor(this.Dm().S*s));t.fillRect(0,0,i.width,n)}}fv(t){const i=this.Bp.ti().It(),s=i.Ea();if(!s||0===s.length)return;const n=this.__.maxTickMarkWeight(s),e=this.Dm(),r=i.W();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace(({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.Am(),t.fillStyle=this.Am();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const a=Math.round(e.C*n);for(let n=s.length;n--;){const e=Math.round(s[n].coord*i);t.rect(e-h,0,r,a)}t.fill()}),t.useMediaCoordinateSpace(({context:t})=>{const i=e.S+e.C+e.L+e.P/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.U(),t.font=this.rv();for(const e of s)if(e.weight<n){const s=e.needAlignCoordinate?this.Im(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}this.Bp.W().timeScale.allowBoldLabels&&(t.font=this.zm());for(const e of s)if(e.weight>=n){const s=e.needAlignCoordinate?this.Im(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}})}Im(t,i,s){const n=this.Np.Bi(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.Fp.width&&(i-=Math.abs(this.Fp.width-(r+n))),i}Vm(t,i){const s=this.Dm();for(const n of t)for(const t of n.ds())t.Rt().et(i,s)}Am(){return this.Bp.W().timeScale.borderColor}U(){return this.Ps.textColor}N(){return this.Ps.fontSize}rv(){return w(this.N(),this.Ps.fontFamily)}zm(){return w(this.N(),this.Ps.fontFamily,"bold")}Dm(){null===this.M&&(this.M={S:1,O:NaN,L:NaN,V:NaN,Qi:NaN,C:5,P:NaN,T:"",Ji:new it,Em:0});const t=this.M,i=this.rv();if(t.T!==i){const s=this.N();t.P=s,t.T=i,t.L=3*s/12,t.V=3*s/12,t.Qi=9*s/12,t.O=0,t.Em=4*s/12,t.Ji.Vn()}return this.M}mv(t){this.Kf.style.cursor=1===t?"ew-resize":"default"}ym(){const t=this.Bp.ti(),i=t.W();i.leftPriceScale.visible||null===this.vm||(this.bm.removeChild(this.vm.Zf()),this.vm.m(),this.vm=null),i.rightPriceScale.visible||null===this.gm||(this.Sm.removeChild(this.gm.Zf()),this.gm.m(),this.gm=null);const s={Vu:this.Bp.ti().Vu()},n=()=>i.leftPriceScale.borderVisible&&t.It().W().borderVisible,e=()=>t.Hu();i.leftPriceScale.visible&&null===this.vm&&(this.vm=new Fs("left",i,s,n,e),this.bm.appendChild(this.vm.Zf())),i.rightPriceScale.visible&&null===this.gm&&(this.gm=new Fs("right",i,s,n,e),this.Sm.appendChild(this.gm.Zf()))}}const js=!!_s&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(t=>t.brand.includes("Chromium"))&&!!_s&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class qs{constructor(t,i,s){var n;this.Lm=[],this.Om=[],this.Fm=0,this.sl=0,this.bo=0,this.Wm=0,this.Nm=0,this.Hm=null,this.Um=!1,this.yv=new o,this.Cv=new o,this.Jc=new o,this.$m=null,this.jm=null,this.Ep=t,this.Ps=i,this.__=s,this.Tp=document.createElement("div"),this.Tp.classList.add("tv-lightweight-charts"),this.Tp.style.overflow="hidden",this.Tp.style.direction="ltr",this.Tp.style.width="100%",this.Tp.style.height="100%",(n=this.Tp).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.qm=document.createElement("table"),this.qm.setAttribute("cellspacing","0"),this.Tp.appendChild(this.qm),this.Ym=this.Km.bind(this),Ys(this.Ps)&&this.Xm(!0),this.ss=new zi(this.tu.bind(this),this.Ps,s),this.ti().fu().i(this.Gm.bind(this),this),this.Zm=new $s(this,this.__),this.qm.appendChild(this.Zm.Zf());const e=i.autoSize&&this.Jm();let r=this.Ps.width,h=this.Ps.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.Qm(r,h),this.tg(),t.appendChild(this.Tp),this.ig(),this.ss.It().zc().i(this.ss.Ah.bind(this.ss),this),this.ss.Bo().i(this.ss.Ah.bind(this.ss),this)}ti(){return this.ss}W(){return this.Ps}jf(){return this.Lm}sg(){return this.Zm}m(){this.Xm(!1),0!==this.Fm&&window.cancelAnimationFrame(this.Fm),this.ss.fu().u(this),this.ss.It().zc().u(this),this.ss.Bo().u(this),this.ss.m();for(const t of this.Lm)this.qm.removeChild(t.Zf()),t.Gv().u(this),t.Zv().u(this),t.m();this.Lm=[];for(const t of this.Om)this.ng(t);this.Om=[],a(this.Zm).m(),null!==this.Tp.parentElement&&this.Tp.parentElement.removeChild(this.Tp),this.Jc.m(),this.yv.m(),this.Cv.m(),this.eg()}Qm(t,i,s=!1){if(this.sl===i&&this.bo===t)return;const n=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return ns({width:i-i%2,height:s-s%2})}(ns({width:t,height:i}));this.sl=n.height,this.bo=n.width;const e=this.sl+"px",r=this.bo+"px";a(this.Tp).style.height=e,a(this.Tp).style.width=r,this.qm.style.height=e,this.qm.style.width=r,s?this.rg(Y.Mn(),performance.now()):this.ss.Ah()}ov(t){void 0===t&&(t=Y.Mn());for(let i=0;i<this.Lm.length;i++)this.Lm[i].ov(t.rn(i).sn);this.Ps.timeScale.visible&&this.Zm.ov(t.en())}ar(t){const i=Ys(this.Ps);this.ss.ar(t);const s=Ys(this.Ps);s!==i&&this.Xm(s),t.layout?.panes&&this.hg(),this.ig(),this.ag(t)}Gv(){return this.yv}Zv(){return this.Cv}fu(){return this.Jc}lg(t=!1){null!==this.Hm&&(this.rg(this.Hm,performance.now()),this.Hm=null);const i=this.og(null),s=document.createElement("canvas");s.width=i.width,s.height=i.height;const n=a(s.getContext("2d"));return this.og(n,t),s}_g(t){if("left"===t&&!this.cg())return 0;if("right"===t&&!this.ug())return 0;if(0===this.Lm.length)return 0;return a("left"===t?this.Lm[0].rm():this.Lm[0].hm()).lv()}dg(){return this.Ps.autoSize&&null!==this.$m}sp(){return this.Tp}fg(t){this.jm=t,this.jm?this.sp().style.setProperty("cursor",t):this.sp().style.removeProperty("cursor")}pg(){return this.jm}vg(t){return h(this.Lm[t]).Jf()}hg(){this.Om.forEach(t=>{t.kt()})}ag(t){(void 0!==t.autoSize||!this.$m||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.$m&&this.Jm(),!1===t.autoSize&&null!==this.$m&&this.eg(),t.autoSize||void 0===t.width&&void 0===t.height||this.Qm(t.width||this.bo,t.height||this.sl))}og(t,i){let s=0,n=0;const e=this.Lm[0],r=(s,n)=>{let e=0;for(let r=0;r<this.Lm.length;r++){const h=this.Lm[r],l=a("left"===s?h.rm():h.hm()),o=l.Qf();if(null!==t&&l.tp(t,n,e,i),e+=o.height,r<this.Lm.length-1){const i=this.Om[r],s=i.Qf();null!==t&&i.tp(t,n,e),e+=s.height}}};if(this.cg()){r("left",0);s+=a(e.rm()).Qf().width}for(let e=0;e<this.Lm.length;e++){const r=this.Lm[e],h=r.Qf();if(null!==t&&r.tp(t,s,n,i),n+=h.height,e<this.Lm.length-1){const i=this.Om[e],r=i.Qf();null!==t&&i.tp(t,s,n),n+=r.height}}if(s+=e.Qf().width,this.ug()){r("right",s);s+=a(e.hm()).Qf().width}const h=(i,s,n)=>{a("left"===i?this.Zm.Cm():this.Zm.Pm()).tp(a(t),s,n)};if(this.Ps.timeScale.visible){const s=this.Zm.Qf();if(null!==t){let r=0;this.cg()&&(h("left",r,n),r=a(e.rm()).Qf().width),this.Zm.tp(t,r,n,i),r+=s.width,this.ug()&&h("right",r,n)}n+=s.height}return ns({width:s,height:n})}mg(){let t=0,i=0,s=0;for(const n of this.Lm)this.cg()&&(i=Math.max(i,a(n.rm()).ev(),this.Ps.leftPriceScale.minimumWidth)),this.ug()&&(s=Math.max(s,a(n.hm()).ev(),this.Ps.rightPriceScale.minimumWidth)),t+=n.Vo();i=ds(i),s=ds(s);const n=this.bo,e=this.sl,r=Math.max(n-i-s,0),h=1*this.Om.length,l=this.Ps.timeScale.visible;let o=l?Math.max(this.Zm.Rm(),this.Ps.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const c=h+o,u=e<c?0:e-c,d=u/t;let f=0;const p=window.devicePixelRatio||1;for(let t=0;t<this.Lm.length;++t){const n=this.Lm[t];n.Ov(this.ss.js()[t]);let e=0,h=0;h=t===this.Lm.length-1?Math.ceil((u-f)*p)/p:Math.round(n.Vo()*d*p)/p,e=Math.max(h,2),f+=e,n.av(ns({width:r,height:e})),this.cg()&&n.Qv(i,"left"),this.ug()&&n.Qv(s,"right"),n.lp()&&this.ss.pu(n.lp(),e)}this.Zm.Tm(ns({width:l?r:0,height:o}),l?i:0,l?s:0),this.ss.Io(r),this.Wm!==i&&(this.Wm=i),this.Nm!==s&&(this.Nm=s)}Xm(t){t?this.Tp.addEventListener("wheel",this.Ym,{passive:!1}):this.Tp.removeEventListener("wheel",this.Ym)}gg(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return js?1/window.devicePixelRatio:1}Km(t){if(!(0!==t.deltaX&&this.Ps.handleScroll.mouseWheel||0!==t.deltaY&&this.Ps.handleScale.mouseWheel))return;const i=this.gg(t),s=i*t.deltaX/100,n=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==n&&this.Ps.handleScale.mouseWheel){const i=Math.sign(n)*Math.min(1,Math.abs(n)),s=t.clientX-this.Tp.getBoundingClientRect().left;this.ti().Su(s,i)}0!==s&&this.Ps.handleScroll.mouseWheel&&this.ti().xu(-80*s)}rg(t,i){const s=t.en();3===s&&this.wg(),3!==s&&2!==s||(this.Mg(t),this.bg(t,i),this.Zm.kt(),this.Lm.forEach(t=>{t.Wv()}),3===this.Hm?.en()&&(this.Hm.mn(t),this.wg(),this.Mg(this.Hm),this.bg(this.Hm,i),t=this.Hm,this.Hm=null)),this.ov(t)}bg(t,i){for(const s of t.vn())this.gn(s,i)}Mg(t){const i=this.ss.js();for(let s=0;s<i.length;s++)t.rn(s).nn&&i[s].Jo()}gn(t,i){const s=this.ss.It();switch(t.ln){case 0:s.Oc();break;case 1:s.Fc(t.Ht);break;case 2:s.fn(t.Ht);break;case 3:s.pn(t.Ht);break;case 4:s.Cc();break;case 5:t.Ht.Bc(i)||s.pn(t.Ht.Vc(i))}}tu(t){null!==this.Hm?this.Hm.mn(t):this.Hm=t,this.Um||(this.Um=!0,this.Fm=window.requestAnimationFrame(t=>{if(this.Um=!1,this.Fm=0,null!==this.Hm){const i=this.Hm;this.Hm=null,this.rg(i,t);for(const s of i.vn())if(5===s.ln&&!s.Ht.Bc(t)){this.ti().cn(s.Ht);break}}}))}wg(){this.tg()}ng(t){this.qm.removeChild(t.Zf()),t.m()}tg(){const t=this.ss.js(),i=t.length,s=this.Lm.length;for(let t=i;t<s;t++){const t=h(this.Lm.pop());this.qm.removeChild(t.Zf()),t.Gv().u(this),t.Zv().u(this),t.m();const i=this.Om.pop();void 0!==i&&this.ng(i)}for(let n=s;n<i;n++){const i=new Os(this,t[n]);if(i.Gv().i(this.Sg.bind(this,i),this),i.Zv().i(this.xg.bind(this,i),this),this.Lm.push(i),n>0){const t=new bs(this,n-1,n);this.Om.push(t),this.qm.insertBefore(t.Zf(),this.Zm.Zf())}this.qm.insertBefore(i.Zf(),this.Zm.Zf())}for(let s=0;s<i;s++){const i=t[s],n=this.Lm[s];n.lp()!==i?n.Ov(i):n.Lv()}this.ig(),this.mg()}yg(t,i,s,n){const e=new Map;if(null!==t){this.ss.Ks().forEach(i=>{const s=i.Gs().Nr(t);null!==s&&e.set(i,s)})}let r;if(null!==t){const i=this.ss.It().ns(t)?.originalTime;void 0!==i&&(r=i)}const h=this.ti().ou(),a=null!==h&&h.e_ instanceof $t?h.e_:void 0,l=null!==h&&void 0!==h.r_?h.r_.Xn:void 0,o=this.Cg(n);return{Pg:r,De:t??void 0,kg:i??void 0,Tg:-1!==o?o:void 0,Rg:a,Dg:e,Eg:l,Bg:s??void 0}}Cg(t){let i=-1;if(t)i=this.Lm.indexOf(t);else{const t=this.ti().du().$s();null!==t&&(i=this.ti().js().indexOf(t))}return i}Sg(t,i,s,n){this.yv.p(()=>this.yg(i,s,n,t))}xg(t,i,s,n){this.Cv.p(()=>this.yg(i,s,n,t))}Gm(t,i,s){this.fg(this.ti().ou()?.a_??null),this.Jc.p(()=>this.yg(t,i,s))}ig(){const t=this.Ps.timeScale.visible?"":"none";this.Zm.Zf().style.display=t}cg(){return this.Lm[0].lp().Ho().W().visible}ug(){return this.Lm[0].lp().Uo().W().visible}Jm(){return"ResizeObserver"in window&&(this.$m=new ResizeObserver(t=>{const i=t[t.length-1];i&&this.Qm(i.contentRect.width,i.contentRect.height)}),this.$m.observe(this.Ep,{box:"border-box"}),!0)}eg(){null!==this.$m&&this.$m.disconnect(),this.$m=null}}function Ys(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Ks(t){return void 0===t.open&&void 0===t.value}function Xs(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function Gs(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.color&&(r.D=s.color),r}function Zs(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.lineColor&&(r.gt=s.lineColor),void 0!==s.topColor&&(r.gr=s.topColor),void 0!==s.bottomColor&&(r.wr=s.bottomColor),r}function Js(t,i,s,n){const e=s.value,r={De:i,wt:t,Ht:[e,e,e,e],Pg:n};return void 0!==s.topLineColor&&(r.Mr=s.topLineColor),void 0!==s.bottomLineColor&&(r.br=s.bottomLineColor),void 0!==s.topFillColor1&&(r.Sr=s.topFillColor1),void 0!==s.topFillColor2&&(r.yr=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.Cr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.Pr=s.bottomFillColor2),r}function Qs(t,i,s,n){const e={De:i,wt:t,Ht:[s.open,s.high,s.low,s.close],Pg:n};return void 0!==s.color&&(e.D=s.color),e}function tn(t,i,s,n){const e={De:i,wt:t,Ht:[s.open,s.high,s.low,s.close],Pg:n};return void 0!==s.color&&(e.D=s.color),void 0!==s.borderColor&&(e.Ut=s.borderColor),void 0!==s.wickColor&&(e.mr=s.wickColor),e}function sn(t,i,s,n,e){const r=h(e)(s),a=Math.max(...r),l=Math.min(...r),o=r[r.length-1],_=[o,a,l,o],{time:c,color:u,...d}=s;return{De:i,wt:t,Ht:_,Pg:n,ne:d,D:u}}function nn(t){return void 0!==t.Ht}function en(t,i){return void 0!==i.customValues&&(t.Vg=i.customValues),t}function rn(t){return(i,s,n,e,r,h)=>function(t,i){return i?i(t):Ks(t)}(n,h)?en({wt:i,De:s,Pg:e},n):en(t(i,s,n,e,r),n)}function hn(t){return{Candlestick:rn(tn),Bar:rn(Qs),Area:rn(Zs),Baseline:rn(Js),Histogram:rn(Gs),Line:rn(Gs),Custom:rn(sn)}[t]}function an(t){return{De:0,Ag:new Map,Uh:t}}function ln(t,i){if(void 0!==t&&0!==t.length)return{Ig:i.key(t[0].wt),zg:i.key(t[t.length-1].wt)}}function on(t){let i;return t.forEach(t=>{void 0===i&&(i=t.Pg)}),h(i)}class _n{constructor(t){this.Lg=new Map,this.Og=new Map,this.Fg=new Map,this.Wg=[],this.__=t}m(){this.Lg.clear(),this.Og.clear(),this.Fg.clear(),this.Wg=[]}Ng(t,i){let s=0!==this.Lg.size,n=!1;const e=this.Og.get(t);if(void 0!==e)if(1===this.Og.size)s=!1,n=!0,this.Lg.clear();else for(const i of this.Wg)i.pointData.Ag.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i.map(t=>t.time),e=this.__.createConverterToInternalObj(i),h=hn(t.Dr()),a=t.da(),l=t.pa();r=i.map((i,r)=>{const o=e(i.time),_=this.__.key(o);let c=this.Lg.get(_);void 0===c&&(c=an(o),this.Lg.set(_,c),n=!0);const u=h(o,c.De,i,s[r],a,l);return c.Ag.set(t,u),u})}s&&this.Hg(),this.Ug(t,r);let h=-1;if(n){const t=[];this.Lg.forEach(i=>{t.push({timeWeight:0,time:i.Uh,pointData:i,originalTime:on(i.Ag)})}),t.sort((t,i)=>this.__.key(t.time)-this.__.key(i.time)),h=this.$g(t)}return this.jg(t,h,function(t,i,s){const n=ln(t,s),e=ln(i,s);if(void 0!==n&&void 0!==e)return{qg:!1,Lh:n.zg>=e.zg&&n.Ig>=e.Ig}}(this.Og.get(t),e,this.__))}zu(t){return this.Ng(t,[])}Yg(t,i,s){const n=i;!function(t){void 0===t.Pg&&(t.Pg=t.time)}(n),this.__.preprocessData(i);const e=this.__.createConverterToInternalObj([i])(i.time),r=this.Fg.get(t);if(!s&&void 0!==r&&this.__.key(e)<this.__.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${e}`);let h=this.Lg.get(this.__.key(e));if(s&&void 0===h)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const a=void 0===h;void 0===h&&(h=an(e),this.Lg.set(this.__.key(e),h));const l=hn(t.Dr()),o=t.da(),_=t.pa(),c=l(e,h.De,i,n.Pg,o,_);h.Ag.set(t,c),s?this.Kg(t,c,h.De):this.Xg(t,c);const u={Lh:nn(c),qg:s};if(!a)return this.jg(t,-1,u);const d={timeWeight:0,time:h.Uh,pointData:h,originalTime:on(h.Ag)},f=St(this.Wg,this.__.key(d.time),(t,i)=>this.__.key(t.time)<i);this.Wg.splice(f,0,d);for(let t=f;t<this.Wg.length;++t)cn(this.Wg[t].pointData,t);return this.__.fillWeightsForPoints(this.Wg,f),this.jg(t,f,u)}Gg(t,i){const s=this.Og.get(t);if(void 0===s||i<=0)return[[],this.Zg()];i=Math.min(i,s.length);const n=s.splice(-i).reverse();0===s.length?this.Fg.delete(t):this.Fg.set(t,s[s.length-1].wt);for(const i of n){const s=this.Lg.get(this.__.key(i.wt));if(s&&(s.Ag.delete(t),0===s.Ag.size)){this.Lg.delete(this.__.key(s.Uh)),this.Wg.splice(s.De,1);for(let t=s.De;t<this.Wg.length;++t)cn(this.Wg[t].pointData,t)}}return[n,this.jg(t,this.Wg.length-1,{qg:!1,Lh:!1})]}Xg(t,i){let s=this.Og.get(t);void 0===s&&(s=[],this.Og.set(t,s));const n=0!==s.length?s[s.length-1]:null;null===n||this.__.key(i.wt)>this.__.key(n.wt)?nn(i)&&s.push(i):nn(i)?s[s.length-1]=i:s.splice(-1,1),this.Fg.set(t,i.wt)}Kg(t,i,s){const n=this.Og.get(t);if(void 0===n)return;const e=St(n,s,(t,i)=>t.De<i);nn(i)?n[e]=i:n.splice(e,1)}Ug(t,i){0!==i.length?(this.Og.set(t,i.filter(nn)),this.Fg.set(t,i[i.length-1].wt)):(this.Og.delete(t),this.Fg.delete(t))}Hg(){for(const t of this.Wg)0===t.pointData.Ag.size&&this.Lg.delete(this.__.key(t.time))}$g(t){let i=-1;for(let s=0;s<this.Wg.length&&s<t.length;++s){const n=this.Wg[s],e=t[s];if(this.__.key(n.time)!==this.__.key(e.time)){i=s;break}e.timeWeight=n.timeWeight,cn(e.pointData,s)}if(-1===i&&this.Wg.length!==t.length&&(i=Math.min(this.Wg.length,t.length)),-1===i)return-1;for(let s=i;s<t.length;++s)cn(t[s].pointData,s);return this.__.fillWeightsForPoints(t,i),this.Wg=t,i}Jg(){if(0===this.Og.size)return null;let t=0;return this.Og.forEach(i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].De))}),t}jg(t,i,s){const n=this.Zg();if(-1!==i)this.Og.forEach((i,e)=>{n.Fo.set(e,{ne:i,Qg:e===t?s:void 0})}),this.Og.has(t)||n.Fo.set(t,{ne:[],Qg:s}),n.It.tw=this.Wg,n.It.iw=i;else{const i=this.Og.get(t);n.Fo.set(t,{ne:i||[],Qg:s})}return n}Zg(){return{Fo:new Map,It:{uc:this.Jg()}}}}function cn(t,i){t.De=i,t.Ag.forEach(t=>{t.De=i})}function un(t,i){return t.wt<i}function dn(t,i){return i<t.wt}function fn(t,i,s){const n=i.$h(),e=i.Si(),r=St(t,n,un),h=xt(t,e,dn);if(!s)return{from:r,to:h};let a=r,l=h;return r>0&&r<t.length&&t[r].wt>=n&&(a=r-1),h>0&&h<t.length&&t[h-1].wt<=e&&(l=h+1),{from:a,to:l}}class pn{constructor(t,i,s){this.sw=!0,this.nw=!0,this.ew=!0,this.rw=[],this.hw=null,this.Qn=t,this.te=i,this.aw=s}kt(t){this.sw=!0,"data"===t&&(this.nw=!0),"options"===t&&(this.ew=!0)}Rt(){return this.Qn.Bt()?(this.lw(),null===this.hw?null:this.ow):null}_w(){this.rw=this.rw.map(t=>({...t,...this.Qn.Dh().Er(t.wt)}))}cw(){this.hw=null}lw(){this.nw&&(this.uw(),this.nw=!1),this.ew&&(this._w(),this.ew=!1),this.sw&&(this.dw(),this.sw=!1)}dw(){const t=this.Qn.Nt(),i=this.te.It();if(this.cw(),i.Xi()||t.Xi())return;const s=i.Pe();if(null===s)return;if(0===this.Qn.Gs().Lr())return;const n=this.Qn.Lt();null!==n&&(this.hw=fn(this.rw,s,this.aw),this.fw(t,i,n.Ht),this.pw())}}class vn{constructor(t,i){this.mw=t,this.Yi=i}et(t,i,s){this.mw.draw(t,this.Yi,i,s)}}class mn extends pn{constructor(t,i,s){super(t,i,!1),this.nh=s,this.ow=new vn(this.nh.renderer(),i=>{const s=t.Lt();return null===s?null:t.Nt().Wt(i,s.Ht)})}fa(t){return this.nh.priceValueBuilder(t)}va(t){return this.nh.isWhitespace(t)}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>({wt:i.De,ct:NaN,...t.Er(i.De),gw:i.ne}))}fw(t,i){i.dc(this.rw,m(this.hw))}pw(){this.nh.update({bars:this.rw.map(gn),barSpacing:this.te.It().Mc(),visibleRange:this.hw},this.Qn.W())}}function gn(t){return{x:t.ct,time:t.wt,originalData:t.gw,barColor:t.dr}}const wn={color:"#2196f3"},Mn=(t,i,s)=>{const n=l(s);return new mn(t,i,n)};function bn(t){const i={value:t.Ht[3],time:t.Pg};return void 0!==t.Vg&&(i.customValues=t.Vg),i}function Sn(t){const i=bn(t);return void 0!==t.D&&(i.color=t.D),i}function xn(t){const i=bn(t);return void 0!==t.gt&&(i.lineColor=t.gt),void 0!==t.gr&&(i.topColor=t.gr),void 0!==t.wr&&(i.bottomColor=t.wr),i}function yn(t){const i=bn(t);return void 0!==t.Mr&&(i.topLineColor=t.Mr),void 0!==t.br&&(i.bottomLineColor=t.br),void 0!==t.Sr&&(i.topFillColor1=t.Sr),void 0!==t.yr&&(i.topFillColor2=t.yr),void 0!==t.Cr&&(i.bottomFillColor1=t.Cr),void 0!==t.Pr&&(i.bottomFillColor2=t.Pr),i}function Cn(t){const i={open:t.Ht[0],high:t.Ht[1],low:t.Ht[2],close:t.Ht[3],time:t.Pg};return void 0!==t.Vg&&(i.customValues=t.Vg),i}function Pn(t){const i=Cn(t);return void 0!==t.D&&(i.color=t.D),i}function kn(t){const i=Cn(t),{D:s,Ut:n,mr:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}function Tn(t){return{Area:xn,Line:Sn,Baseline:yn,Histogram:Sn,Bar:Pn,Candlestick:kn,Custom:Rn}[t]}function Rn(t){const i=t.Pg;return{...t.ne,time:i}}const Dn={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},En={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Bn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:g,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Vn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1},An={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function In(){return{addDefaultPane:!0,width:0,height:0,autoSize:!1,layout:Bn,crosshair:Dn,grid:En,overlayPriceScales:{...Vn},leftPriceScale:{...Vn,visible:!1},rightPriceScale:{...Vn,visible:!0},timeScale:An,localization:{locale:_s?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class zn{constructor(t,i,s){this.Uf=t,this.ww=i,this.Mw=s??0}applyOptions(t){this.Uf.ti().cu(this.ww,t,this.Mw)}options(){return this.Yi().W()}width(){return q(this.ww)?this.Uf._g(this.ww):0}setVisibleRange(t){this.setAutoScale(!1),this.Yi().Nl(new dt(t.from,t.to))}getVisibleRange(){let t,i,s=this.Yi().tr();if(null===s)return null;if(this.Yi().Qa()){const n=this.Yi().po(),e=Li(n);s=li(s,this.Yi().il()),t=Number((Math.round(s.je()/n)*n).toFixed(e)),i=Number((Math.round(s.qe()/n)*n).toFixed(e))}else t=s.je(),i=s.qe();return{from:t,to:i}}setAutoScale(t){this.applyOptions({autoScale:t})}Yi(){return a(this.Uf.ti().uu(this.ww,this.Mw)).Nt}}class Ln{constructor(t,i,s,n){this.Uf=t,this.Pt=s,this.bw=i,this.Sw=n}getHeight(){return this.Pt.jt()}setHeight(t){const i=this.Uf.ti(),s=i.$u(this.Pt);i.mu(s,t)}getStretchFactor(){return this.Pt.Vo()}setStretchFactor(t){this.Pt.Ao(t),this.Uf.ti().Ah()}paneIndex(){return this.Uf.ti().$u(this.Pt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&t<this.Uf.jf().length,"Invalid pane index"),this.Uf.ti().wu(i,t))}getSeries(){return this.Pt.Fo().map(t=>this.bw(t))??[]}getHTMLElement(){const t=this.Uf.jf();return t&&0!==t.length&&t[this.paneIndex()]?t[this.paneIndex()].Zf():null}attachPrimitive(t){this.Pt.ca(t),t.attached&&t.attached({chart:this.Sw,requestUpdate:()=>this.Pt.ti().Ah()})}detachPrimitive(t){this.Pt.ua(t)}priceScale(t){if(null===this.Pt.Eo(t))throw new Error(`Cannot find price scale with id: ${t}`);return new zn(this.Uf,t,this.paneIndex())}setPreserveEmptyPane(t){this.Pt.Lo(t)}preserveEmptyPane(){return this.Pt.Oo()}addCustomSeries(t,i={},s=0){return this.Sw.addCustomSeries(t,i,s)}addSeries(t,i={}){return this.Sw.addSeries(t,i,this.paneIndex())}}const On={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Fn{constructor(t){this.sr=t}applyOptions(t){this.sr.ar(t)}options(){return this.sr.W()}xw(){return this.sr}}class Wn{constructor(t,i,s,n,e,r){this.yw=new o,this.Qn=t,this.Cw=i,this.Pw=s,this.__=e,this.Sw=n,this.kw=r}m(){this.yw.m()}priceFormatter(){return this.Qn.ra()}priceToCoordinate(t){const i=this.Qn.Lt();return null===i?null:this.Qn.Nt().Wt(t,i.Ht)}coordinateToPrice(t){const i=this.Qn.Lt();return null===i?null:this.Qn.Nt().Rs(t,i.Ht)}barsInLogicalRange(t){if(null===t)return null;const i=new Ti(new Ci(t.from,t.to)).k_(),s=this.Qn.Gs();if(s.Xi())return null;const n=s.Nr(i.$h(),1),e=s.Nr(i.Si(),-1),r=a(s.Or()),h=a(s.Xs());if(null!==n&&null!==e&&n.De>e.De)return{barsBefore:t.from-r,barsAfter:h-t.to};const l={barsBefore:null===n||n.De===r?t.from-r:n.De-r,barsAfter:null===e||e.De===h?h-t.to:h-e.De};return null!==n&&null!==e&&(l.from=n.Pg,l.to=e.Pg),l}setData(t){this.__,this.Qn.Dr(),this.Cw.Tw(this.Qn,t),this.Rw("full")}update(t,i=!1){this.Qn.Dr(),this.Cw.Dw(this.Qn,t,i),this.Rw("update")}pop(t=1){const i=this.Cw.Ew(this.Qn,t);0!==i.length&&this.Rw("update");const s=Tn(this.seriesType());return i.map(t=>s(t))}dataByIndex(t,i){const s=this.Qn.Gs().Nr(t,i);if(null===s)return null;return Tn(this.seriesType())(s)}data(){const t=Tn(this.seriesType());return this.Qn.Gs().Ur().map(i=>t(i))}subscribeDataChanged(t){this.yw.i(t)}unsubscribeDataChanged(t){this.yw._(t)}applyOptions(t){this.Qn.ar(t)}options(){return p(this.Qn.W())}priceScale(){return this.Pw.priceScale(this.Qn.Nt().ga(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(On),t),s=this.Qn.Fh(i);return new Fn(s)}removePriceLine(t){this.Qn.Wh(t.xw())}priceLines(){return this.Qn.Nh().map(t=>new Fn(t))}seriesType(){return this.Qn.Dr()}lastValueData(t){const i=this.Qn.ke(t);return i.Te?{noData:!0}:{noData:!1,price:i.Mt,color:i.D}}attachPrimitive(t){this.Qn.ca(t),t.attached&&t.attached({chart:this.Sw,series:this,requestUpdate:()=>this.Qn.ti().Ah(),horzScaleBehavior:this.__})}detachPrimitive(t){this.Qn.ua(t),t.detached&&t.detached(),this.Qn.ti().Ah()}getPane(){const t=this.Qn,i=a(this.Qn.ti().Un(t));return this.kw(i)}moveToPane(t){this.Qn.ti().Wu(this.Qn,t)}seriesOrder(){const t=this.Qn.ti().Un(this.Qn);return null===t?-1:t.Fo().indexOf(this.Qn)}setSeriesOrder(t){const i=this.Qn.ti().Un(this.Qn);null!==i&&i.t_(this.Qn,t)}Rw(t){this.yw.v()&&this.yw.p(t)}}class Nn{constructor(t,i,s){this.Bw=new o,this.L_=new o,this.Mm=new o,this.ss=t,this.dh=t.It(),this.Zm=i,this.dh.Ac().i(this.Vw.bind(this)),this.dh.Ic().i(this.Aw.bind(this)),this.Zm.km().i(this.Iw.bind(this)),this.__=s}m(){this.dh.Ac().u(this),this.dh.Ic().u(this),this.Zm.km().u(this),this.Bw.m(),this.L_.m(),this.Mm.m()}scrollPosition(){return this.dh.Sc()}scrollToPosition(t,i){i?this.dh.Ec(t,1e3):this.ss.pn(t)}scrollToRealTime(){this.dh.Dc()}getVisibleRange(){const t=this.dh.rc();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.__.convertHorzItemToInternal(t.from),to:this.__.convertHorzItemToInternal(t.to)},s=this.dh.oc(i);this.ss.Ou(s)}getVisibleLogicalRange(){const t=this.dh.ec();return null===t?null:{from:t.$h(),to:t.Si()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.ss.Ou(t)}resetTimeScale(){this.ss.dn()}fitContent(){this.ss.Oc()}logicalToCoordinate(t){const i=this.ss.It();return i.Xi()?null:i.qt(t)}coordinateToLogical(t){return this.dh.Xi()?null:this.dh.fc(t)}timeToIndex(t,i){const s=this.__.convertHorzItemToInternal(t);return this.dh.tc(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.dh.qt(i)}coordinateToTime(t){const i=this.ss.It(),s=i.fc(t),n=i.ns(s);return null===n?null:n.originalTime}width(){return this.Zm.Jf().width}height(){return this.Zm.Jf().height}subscribeVisibleTimeRangeChange(t){this.Bw.i(t)}unsubscribeVisibleTimeRangeChange(t){this.Bw._(t)}subscribeVisibleLogicalRangeChange(t){this.L_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.L_._(t)}subscribeSizeChange(t){this.Mm.i(t)}unsubscribeSizeChange(t){this.Mm._(t)}applyOptions(t){this.dh.ar(t)}options(){return{...p(this.dh.W()),barSpacing:this.dh.Mc()}}Vw(){this.Bw.v()&&this.Bw.p(this.getVisibleRange())}Aw(){this.L_.v()&&this.L_.p(this.getVisibleLogicalRange())}Iw(t){this.Mm.p(t.width,t.height)}}function Hn(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Un{constructor(t,i,s){this.zw=new Map,this.Lw=new Map,this.Ow=new o,this.Fw=new o,this.Ww=new o,this.Kc=new WeakMap,this.Nw=new _n(i);const n=void 0===s?p(In()):_(p(In()),Hn(s));this.Hw=i,this.Uf=new qs(t,n,i),this.Uf.Gv().i(t=>{this.Ow.v()&&this.Ow.p(this.Uw(t()))},this),this.Uf.Zv().i(t=>{this.Fw.v()&&this.Fw.p(this.Uw(t()))},this),this.Uf.fu().i(t=>{this.Ww.v()&&this.Ww.p(this.Uw(t()))},this);const e=this.Uf.ti();this.$w=new Nn(e,this.Uf.sg(),this.Hw)}remove(){this.Uf.Gv().u(this),this.Uf.Zv().u(this),this.Uf.fu().u(this),this.$w.m(),this.Uf.m(),this.zw.clear(),this.Lw.clear(),this.Ow.m(),this.Fw.m(),this.Ww.m(),this.Nw.m()}resize(t,i,s){this.autoSizeActive()||this.Uf.Qm(t,i,s)}addCustomSeries(t,i={},s=0){const n=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...wn,...t.defaultOptions()},jw:Mn,qw:t}))(l(t));return this.Yw(n,i,s)}addSeries(t,i={},s=0){return this.Yw(t,i,s)}removeSeries(t){const i=h(this.zw.get(t)),s=this.Nw.zu(i);this.Uf.ti().zu(i),this.Kw(s),this.zw.delete(t),this.Lw.delete(i)}Tw(t,i){this.Kw(this.Nw.Ng(t,i))}Dw(t,i,s){this.Kw(this.Nw.Yg(t,i,s))}Ew(t,i){const[s,n]=this.Nw.Gg(t,i);return 0!==s.length&&this.Kw(n),s}subscribeClick(t){this.Ow.i(t)}unsubscribeClick(t){this.Ow._(t)}subscribeCrosshairMove(t){this.Ww.i(t)}unsubscribeCrosshairMove(t){this.Ww._(t)}subscribeDblClick(t){this.Fw.i(t)}unsubscribeDblClick(t){this.Fw._(t)}priceScale(t,i=0){return new zn(this.Uf,t,i)}timeScale(){return this.$w}applyOptions(t){this.Uf.ar(Hn(t))}options(){return this.Uf.W()}takeScreenshot(t=!1,i=!1){let s,n;try{i||(s=this.Uf.ti().W().crosshair.mode,this.Uf.ar({crosshair:{mode:2}})),n=this.Uf.lg(t)}finally{i||void 0===s||this.Uf.ti().ar({crosshair:{mode:s}})}return n}addPane(t=!1){const i=this.Uf.ti().ju();return i.Lo(t),this.Xw(i)}removePane(t){this.Uf.ti().vu(t)}swapPanes(t,i){this.Uf.ti().gu(t,i)}autoSizeActive(){return this.Uf.dg()}chartElement(){return this.Uf.sp()}panes(){return this.Uf.ti().js().map(t=>this.Xw(t))}paneSize(t=0){const i=this.Uf.vg(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const n=this.zw.get(s);if(void 0===n)return;const e=this.Uf.ti().Un(n);null!==e&&this.Uf.ti().Du(t,i,e)}clearCrosshairPosition(){this.Uf.ti().Eu(!0)}horzBehaviour(){return this.Hw}Yw(i,s={},n=0){r(void 0!==i.jw),function(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=Li(i.minMove))}(s.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(s);const e=_(p(t),p(i.defaultOptions),s),h=i.jw,a=new $t(this.Uf.ti(),i.type,e,h,i.qw);this.Uf.ti().Au(a,n);const l=new Wn(a,this,this,this,this.Hw,t=>this.Xw(t));return this.zw.set(l,a),this.Lw.set(a,l),l}Kw(t){const i=this.Uf.ti();i.Bu(t.It.uc,t.It.tw,t.It.iw),t.Fo.forEach((t,i)=>i.lt(t.ne,t.Qg)),i.It().X_(),i.wc()}Gw(t){return h(this.Lw.get(t))}Uw(t){const i=new Map;t.Dg.forEach((t,s)=>{const n=s.Dr(),e=Tn(n)(t);if("Custom"!==n)r(Xs(e));else{const t=s.pa();r(!t||!1===t(e))}i.set(this.Gw(s),e)});const s=void 0!==t.Rg&&this.Lw.has(t.Rg)?this.Gw(t.Rg):void 0;return{time:t.Pg,logical:t.De,point:t.kg,paneIndex:t.Tg,hoveredSeries:s,hoveredObjectId:t.Eg,seriesData:i,sourceEvent:t.Bg}}Xw(t){let i=this.Kc.get(t);return i||(i=new Ln(this.Uf,t=>this.Gw(t),t,this),this.Kc.set(t,i)),i}}function $n(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function jn(t,i,s){const n=$n(t),e=new Un(n,i,s);return i.setOptions(e.options()),e}function qn(t,i){return jn(t,new ss,ss.od(i))}function Yn(){return ss}class Kn extends pn{constructor(t,i){super(t,i,!0)}fw(t,i,s){i.dc(this.rw,m(this.hw)),t.$l(this.rw,s,m(this.hw))}Zw(t,i){return{wt:t,Mt:i,ct:NaN,ut:NaN}}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>{const s=i.Ht[3];return this.Jw(i.De,s,t)})}}function Xn(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:o}=t,_=i[n.from];let c=r(t,_),u=_;if(n.to-n.from<2){const i=e/2;a.beginPath();const s={ct:_.ct-i,ut:_.ut},n={ct:_.ct+i,ut:_.ut};a.moveTo(s.ct*l,s.ut*o),a.lineTo(n.ct*l,n.ut*o),h(t,c,s,n)}else{const e=(i,s)=>{h(t,c,u,s),a.beginPath(),c=i,u=s};let d=u;a.beginPath(),a.moveTo(_.ct*l,_.ut*o);for(let h=n.from+1;h<n.to;++h){d=i[h];const n=r(t,d);switch(s){case 0:a.lineTo(d.ct*l,d.ut*o);break;case 1:a.lineTo(d.ct*l,i[h-1].ut*o),n!==c&&(e(n,d),a.lineTo(d.ct*l,i[h-1].ut*o)),a.lineTo(d.ct*l,d.ut*o);break;case 2:{const[t,s]=Qn(i,h-1,h);a.bezierCurveTo(t.ct*l,t.ut*o,s.ct*l,s.ut*o,d.ct*l,d.ut*o);break}}1!==s&&n!==c&&(e(n,d),a.moveTo(d.ct*l,d.ut*o))}(u!==d||u===d&&1===s)&&h(t,c,u,d)}}const Gn=6;function Zn(t,i){return{ct:t.ct-i.ct,ut:t.ut-i.ut}}function Jn(t,i){return{ct:t.ct/i,ut:t.ut/i}}function Qn(t,i,s){const n=Math.max(0,i-1),e=Math.min(t.length-1,s+1);var r,h;return[(r=t[i],h=Jn(Zn(t[s],t[n]),Gn),{ct:r.ct+h.ct,ut:r.ut+h.ut}),Zn(t[s],Jn(Zn(t[e],t[i]),Gn))]}function te(t,i){const s=t.context;s.strokeStyle=i,s.stroke()}class ie extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt(t){if(null===this.ht)return;const{_t:i,ot:s,Qw:e,tM:r,dt:h,Gt:a,iM:l}=this.ht;if(null===s)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,n(o,a),o.lineJoin="round";const _=this.sM.bind(this);void 0!==r&&Xn(t,i,r,s,e,_,te),l&&function(t,i,s,n,e){if(n.to-n.from<=0)return;const{horizontalPixelRatio:r,verticalPixelRatio:h,context:a}=t;let l=null;const o=Math.max(1,Math.floor(r))%2/2,_=s*h+o;for(let s=n.to-1;s>=n.from;--s){const n=i[s];if(n){const i=e(t,n);i!==l&&(a.beginPath(),null!==l&&a.fill(),a.fillStyle=i,l=i);const s=Math.round(n.ct*r)+o,c=n.ut*h;a.moveTo(s,c),a.arc(s,c,_,0,2*Math.PI)}}a.fill()}(t,i,l,s,_)}}class se extends ie{sM(t,i){return i.gt}}class ne extends Kn{constructor(){super(...arguments),this.ow=new se}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.W(),i={_t:this.rw,Gt:t.lineStyle,tM:t.lineVisible?t.lineType:void 0,dt:t.lineWidth,iM:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,ot:this.hw,Qw:this.te.It().Mc()};this.ow.lt(i)}}const ee={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new ne(t,i)};function re(t,i){return t.weight>i.weight?t:i}function he(t){return t}class ae{constructor(){this.nM=new o,this.eM=function(t){let i=!1;return function(...s){i||(i=!0,queueMicrotask(()=>{t(...s),i=!1}))}}(()=>this.nM.p(this.rM)),this.rM=0}hM(){return this.nM}m(){this.nM.m()}options(){return this.Ps}setOptions(t){this.Ps=t}preprocessData(t){}updateFormatter(t){this.Ps&&(this.Ps.localization=t)}createConverterToInternalObj(t){return this.eM(),t=>(t>this.rM&&(this.rM=t),t)}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return this.aM(t)}formatTickmark(t){return this.aM(t.time)}maxTickMarkWeight(t){return t.reduce(re,t[0]).weight}fillWeightsForPoints(t,i){const s=t=>t%120==0?10:t%60==0?9:t%36==0?8:t%12==0?7:t%6==0?6:t%3==0?5:t%1==0?4:0;for(let n=i;n<t.length;++n)t[n].timeWeight=s(he(t[n].time));this.rM=t[t.length-1].time,this.eM()}aM(t){if(this.Ps.localization?.timeFormatter)return this.Ps.localization.timeFormatter(t);if(t<12)return`${t}M`;const i=Math.floor(t/12),s=t%12;return 0===s?`${i}Y`:`${i}Y${s}M`}}const le={yieldCurve:{baseResolution:1,minimumTimeRange:120,startTimeRange:0},timeScale:{ignoreWhitespaceIndices:!0},leftPriceScale:{visible:!0},rightPriceScale:{visible:!1},localization:{priceFormatter:t=>t.toFixed(3)+"%"}},oe={lastValueVisible:!1,priceLineVisible:!1};class _e extends Un{constructor(t,i){const s=_(le,i||{}),n=new ae;super(t,n,s),n.setOptions(this.options()),this._initWhitespaceSeries()}addSeries(t,i={},s=0){if(t.isBuiltIn&&!1===["Area","Line"].includes(t.type))throw new Error("Yield curve only support Area and Line series");const n={...oe,...i};return super.addSeries(t,n,s)}_initWhitespaceSeries(){const t=this.horzBehaviour(),i=this.addSeries(ee);let s;function n(n){const e=function(t,i){return{oe:Math.max(0,t.startTimeRange),_e:Math.max(0,t.minimumTimeRange,i||0),lM:Math.max(1,t.baseResolution)}}(t.options().yieldCurve,n),r=(({oe:t,_e:i,lM:s})=>`${t}~${i}~${s}`)(e);r!==s&&(s=r,i.setData(function({oe:t,_e:i,lM:s}){return Array.from({length:Math.floor((i-t)/s)+1},(i,n)=>({time:t+n*s}))}(e)))}n(0),t.hM().i(n)}}function ce(t,i){const s=$n(t);return new _e(s,i)}function ue(t,i){return t.weight>i.weight?t:i}class de{options(){return this.Ps}setOptions(t){this.Ps=t}preprocessData(t){}updateFormatter(t){this.Ps&&(this.Ps.localization=t)}createConverterToInternalObj(t){return t=>t}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return t.toFixed(this.Cn())}formatTickmark(t,i){return t.time.toFixed(this.Cn())}maxTickMarkWeight(t){return t.reduce(ue,t[0]).weight}fillWeightsForPoints(t,i){const s=t=>t===100*Math.ceil(t/100)?8:t===50*Math.ceil(t/50)?7:t===25*Math.ceil(t/25)?6:t===10*Math.ceil(t/10)?5:t===5*Math.ceil(t/5)?4:t===Math.ceil(t)?3:2*t===Math.ceil(2*t)?1:0;for(let n=i;n<t.length;++n)t[n].timeWeight=s(t[n].time)}Cn(){return this.Ps.localization.precision}}function fe(t,i){return jn(t,new de,i)}function pe(t,i,s,n,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:a}=i;r.lineTo(e.ct*h,t*a),r.lineTo(n.ct*h,t*a),r.closePath(),r.fillStyle=s,r.fill()}class ve extends C{constructor(){super(...arguments),this.ht=null}lt(t){this.ht=t}rt(t){if(null===this.ht)return;const{_t:i,ot:s,Qw:e,dt:r,Gt:h,tM:a}=this.ht,l=this.ht.oM??(this.ht._M?0:t.mediaSize.height);if(null===s)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,n(o,h),o.lineWidth=1,Xn(t,i,a,s,e,this.cM.bind(this),pe.bind(null,l))}}class me{uM(t,i){const s=this.dM,{fM:n,pM:e,vM:r,mM:h,oM:a,gM:l,wM:o}=i;if(void 0===this.MM||void 0===s||s.fM!==n||s.pM!==e||s.vM!==r||s.mM!==h||s.oM!==a||s.gM!==l||s.wM!==o){const{verticalPixelRatio:s}=t,_=a||l>0?s:1,c=l*_,u=o===t.bitmapSize.height?o:o*_,d=(a??0)*_,f=t.context.createLinearGradient(0,c,0,u);if(f.addColorStop(0,n),null!=a){const t=Kt((d-c)/(u-c),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.MM=f,this.dM=i}return this.MM}}class ge extends ve{constructor(){super(...arguments),this.bM=new me}cM(t,i){const s=this.ht;return this.bM.uM(t,{fM:i.Sr,pM:i.yr,vM:i.Cr,mM:i.Pr,oM:s.oM,gM:s.gM??0,wM:s.wM??t.bitmapSize.height})}}class we extends ie{constructor(){super(...arguments),this.SM=new me}sM(t,i){const s=this.ht;return this.SM.uM(t,{fM:i.Mr,pM:i.Mr,vM:i.br,mM:i.br,oM:s.oM,gM:s.gM??0,wM:s.wM??t.bitmapSize.height})}}class Me extends Kn{constructor(t,i){super(t,i),this.ow=new y,this.xM=new ge,this.yM=new we,this.ow.nt([this.xM,this.yM])}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.Lt();if(null===t)return;const i=this.Qn.W(),s=this.Qn.Nt().Wt(i.baseValue.price,t.Ht),n=this.te.It().Mc();if(null===this.hw||0===this.rw.length)return;let e,r;if(i.relativeGradient){e=this.rw[this.hw.from].ut,r=this.rw[this.hw.from].ut;for(let t=this.hw.from;t<this.hw.to;t++){const i=this.rw[t];i.ut<e&&(e=i.ut),i.ut>r&&(r=i.ut)}}this.xM.lt({_t:this.rw,dt:i.lineWidth,Gt:i.lineStyle,tM:i.lineType,oM:s,gM:e,wM:r,_M:!1,ot:this.hw,Qw:n}),this.yM.lt({_t:this.rw,dt:i.lineWidth,Gt:i.lineStyle,tM:i.lineVisible?i.lineType:void 0,iM:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,oM:s,gM:e,wM:r,ot:this.hw,Qw:n})}}const be={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new Me(t,i)};class Se extends ve{constructor(){super(...arguments),this.bM=new me}cM(t,i){return this.bM.uM(t,{fM:i.gr,pM:"",vM:"",mM:i.wr,gM:this.ht?.gM??0,wM:t.bitmapSize.height})}}class xe extends Kn{constructor(t,i){super(t,i),this.ow=new y,this.CM=new Se,this.PM=new se,this.ow.nt([this.CM,this.PM])}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t=this.Qn.W();if(null===this.hw||0===this.rw.length)return;let i;if(t.relativeGradient){i=this.rw[this.hw.from].ut;for(let t=this.hw.from;t<this.hw.to;t++){const s=this.rw[t];s.ut<i&&(i=s.ut)}}this.CM.lt({tM:t.lineType,_t:this.rw,Gt:t.lineStyle,dt:t.lineWidth,oM:null,gM:i,_M:t.invertFilledArea,ot:this.hw,Qw:this.te.It().Mc()}),this.PM.lt({tM:t.lineVisible?t.lineType:void 0,_t:this.rw,Gt:t.lineStyle,dt:t.lineWidth,ot:this.hw,Qw:this.te.It().Mc(),iM:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}const ye={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},jw:(t,i)=>new xe(t,i)};class Ce extends C{constructor(){super(...arguments),this.Yt=null,this.kM=0,this.TM=0}lt(t){this.Yt=t}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt.Gs.length||null===this.Yt.ot)return;if(this.kM=this.RM(i),this.kM>=2){Math.max(1,Math.floor(i))%2!=this.kM%2&&this.kM--}this.TM=this.Yt.DM?Math.min(this.kM,Math.floor(i)):this.kM;let n=null;const e=this.TM<=this.kM&&this.Yt.Mc>=Math.floor(1.5*i);for(let r=this.Yt.ot.from;r<this.Yt.ot.to;++r){const h=this.Yt.Gs[r];n!==h.dr&&(t.fillStyle=h.dr,n=h.dr);const a=Math.floor(.5*this.TM),l=Math.round(h.ct*i),o=l-a,_=this.TM,c=o+_-1,u=Math.min(h.Kl,h.Xl),d=Math.max(h.Kl,h.Xl),f=Math.round(u*s)-a,p=Math.round(d*s)+a,v=Math.max(p-f,this.TM);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.kM);if(e){if(this.Yt.EM){const i=l-m;let n=Math.max(f,Math.round(h.Yl*s)-a),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(i,n,o-i,e-n+1)}const i=l+m;let n=Math.max(f,Math.round(h.Gl*s)-a),e=n+_-1;e>f+v-1&&(e=f+v-1,n=e-_+1),t.fillRect(c+1,n,i-c,e-n+1)}}}RM(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(a(this.Yt).Mc,t)))}}class Pe extends pn{constructor(t,i){super(t,i,!1)}fw(t,i,s){i.dc(this.rw,m(this.hw)),t.ql(this.rw,s,m(this.hw))}BM(t,i,s){return{wt:t,qh:i.Ht[0],Yh:i.Ht[1],Kh:i.Ht[2],Xh:i.Ht[3],ct:NaN,Yl:NaN,Kl:NaN,Xl:NaN,Gl:NaN}}uw(){const t=this.Qn.Dh();this.rw=this.Qn.Gs().Ur().map(i=>this.Jw(i.De,i,t))}}class ke extends Pe{constructor(){super(...arguments),this.ow=new Ce}Jw(t,i,s){return{...this.BM(t,i,s),...s.Er(t)}}pw(){const t=this.Qn.W();this.ow.lt({Gs:this.rw,Mc:this.te.It().Mc(),EM:t.openVisible,DM:t.thinBars,ot:this.hw})}}const Te={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},jw:(t,i)=>new ke(t,i)};class Re extends C{constructor(){super(...arguments),this.Yt=null,this.kM=0}lt(t){this.Yt=t}rt(t){if(null===this.Yt||0===this.Yt.Gs.length||null===this.Yt.ot)return;const{horizontalPixelRatio:i}=t;if(this.kM=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Yt.Mc,i),this.kM>=2){Math.floor(i)%2!=this.kM%2&&this.kM--}const s=this.Yt.Gs;this.Yt.VM&&this.AM(t,s,this.Yt.ot),this.Yt.bi&&this.uv(t,s,this.Yt.ot);const n=this.IM(i);(!this.Yt.bi||this.kM>2*n)&&this.zM(t,s,this.Yt.ot)}AM(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",a=Math.min(Math.floor(e),Math.floor(this.Yt.Mc*e));a=Math.max(Math.floor(e),Math.min(a,this.kM));const l=Math.floor(.5*a);let o=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.vr!==h&&(n.fillStyle=s.vr,h=s.vr);const _=Math.round(Math.min(s.Yl,s.Gl)*r),c=Math.round(Math.max(s.Yl,s.Gl)*r),u=Math.round(s.Kl*r),d=Math.round(s.Xl*r);let f=Math.round(e*s.ct)-l;const p=f+a-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;n.fillRect(f,u,v,_-u),n.fillRect(f,c+1,v,d-c),o=p}}IM(t){let i=Math.floor(1*t);this.kM<=2*i&&(i=Math.floor(.5*(this.kM-1)));const s=Math.max(Math.floor(t),i);return this.kM<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}uv(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.IM(e);let l=null;for(let t=s.from;t<s.to;t++){const s=i[t];s.pr!==h&&(n.fillStyle=s.pr,h=s.pr);let o=Math.round(s.ct*e)-Math.floor(.5*this.kM);const _=o+this.kM-1,c=Math.round(Math.min(s.Yl,s.Gl)*r),u=Math.round(Math.max(s.Yl,s.Gl)*r);if(null!==l&&(o=Math.max(l+1,o),o=Math.min(o,_)),this.Yt.Mc*e>2*a)B(n,o,c,_-o+1,u-c+1,a);else{const t=_-o+1;n.fillRect(o,c,t,u-c+1)}l=_}}zM(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.IM(e);for(let t=s.from;t<s.to;t++){const s=i[t];let l=Math.round(Math.min(s.Yl,s.Gl)*r),o=Math.round(Math.max(s.Yl,s.Gl)*r),_=Math.round(s.ct*e)-Math.floor(.5*this.kM),c=_+this.kM-1;if(s.dr!==h){const t=s.dr;n.fillStyle=t,h=t}this.Yt.bi&&(_+=a,l+=a,c-=a,o-=a),l>o||n.fillRect(_,l,c-_+1,o-l+1)}}}class De extends Pe{constructor(){super(...arguments),this.ow=new Re}Jw(t,i,s){return{...this.BM(t,i,s),...s.Er(t)}}pw(){const t=this.Qn.W();this.ow.lt({Gs:this.rw,Mc:this.te.It().Mc(),VM:t.wickVisible,bi:t.borderVisible,ot:this.hw})}}const Ee={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},jw:(t,i)=>new De(t,i)};class Be extends C{constructor(){super(...arguments),this.Yt=null,this.LM=[]}lt(t){this.Yt=t,this.LM=[]}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.Yt||0===this.Yt._t.length||null===this.Yt.ot)return;this.LM.length||this.OM(i);const n=Math.max(1,Math.floor(s)),e=Math.round(this.Yt.FM*s)-Math.floor(n/2),r=e+n;for(let i=this.Yt.ot.from;i<this.Yt.ot.to;i++){const h=this.Yt._t[i],a=this.LM[i-this.Yt.ot.from],l=Math.round(h.ut*s);let o,_;t.fillStyle=h.dr,l<=e?(o=l,_=r):(o=e,_=l-Math.floor(n/2)+n),t.fillRect(a.$h,o,a.Si-a.$h+1,_-o)}}OM(t){if(null===this.Yt||0===this.Yt._t.length||null===this.Yt.ot)return void(this.LM=[]);const i=Math.ceil(this.Yt.Mc*t)<=1?0:Math.max(1,Math.floor(t)),s=Math.round(this.Yt.Mc*t)-i;this.LM=new Array(this.Yt.ot.to-this.Yt.ot.from);for(let i=this.Yt.ot.from;i<this.Yt.ot.to;i++){const n=this.Yt._t[i],e=Math.round(n.ct*t);let r,h;if(s%2){const t=(s-1)/2;r=e-t,h=e+t}else{const t=s/2;r=e-t,h=e+t-1}this.LM[i-this.Yt.ot.from]={$h:r,Si:h,WM:e,ee:n.ct*t,wt:n.wt}}for(let t=this.Yt.ot.from+1;t<this.Yt.ot.to;t++){const s=this.LM[t-this.Yt.ot.from],n=this.LM[t-this.Yt.ot.from-1];s.wt===n.wt+1&&(s.$h-n.Si!==i+1&&(n.WM>n.ee?n.Si=s.$h-i-1:s.$h=n.Si+i+1))}let n=Math.ceil(this.Yt.Mc*t);for(let t=this.Yt.ot.from;t<this.Yt.ot.to;t++){const i=this.LM[t-this.Yt.ot.from];i.Si<i.$h&&(i.Si=i.$h);const s=i.Si-i.$h+1;n=Math.min(s,n)}if(i>0&&n<4)for(let t=this.Yt.ot.from;t<this.Yt.ot.to;t++){const i=this.LM[t-this.Yt.ot.from];i.Si-i.$h+1>n&&(i.WM>i.ee?i.Si-=1:i.$h+=1)}}}class Ve extends Kn{constructor(){super(...arguments),this.ow=new Be}Jw(t,i,s){return{...this.Zw(t,i),...s.Er(t)}}pw(){const t={_t:this.rw,Mc:this.te.It().Mc(),ot:this.hw,FM:this.Qn.Nt().Wt(this.Qn.W().base,a(this.Qn.Lt()).Ht)};this.ow.lt(t)}}const Ae={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},jw:(t,i)=>new Ve(t,i)};class Ie{constructor(t,i){this.Pt=t,this.NM=i,this.HM()}detach(){this.Pt.detachPrimitive(this.NM)}getPane(){return this.Pt}applyOptions(t){this.NM.ar?.(t)}HM(){this.Pt.attachPrimitive(this.NM)}}const ze={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},Le={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:g,fontStyle:"",text:""};class Oe{constructor(t){this.UM=new Map,this.Yt=t}draw(t){t.useMediaCoordinateSpace(t=>{if(!this.Yt.visible)return;const{context:i,mediaSize:s}=t;let n=0;for(const t of this.Yt.lines){if(0===t.text.length)continue;i.font=t.T;const e=this.$M(i,t.text);e>s.width?t.kc=s.width/e:t.kc=1,n+=t.lineHeight*t.kc}let e=0;switch(this.Yt.vertAlign){case"top":e=0;break;case"center":e=Math.max((s.height-n)/2,0);break;case"bottom":e=Math.max(s.height-n,0)}for(const t of this.Yt.lines){i.save(),i.fillStyle=t.color;let n=0;switch(this.Yt.horzAlign){case"left":i.textAlign="left",n=t.lineHeight/2;break;case"center":i.textAlign="center",n=s.width/2;break;case"right":i.textAlign="right",n=s.width-1-t.lineHeight/2}i.translate(n,e),i.textBaseline="top",i.font=t.T,i.scale(t.kc,t.kc),i.fillText(t.text,0,t.jM),i.restore(),e+=t.lineHeight*t.kc}})}$M(t,i){const s=this.qM(t.font);let n=s.get(i);return void 0===n&&(n=t.measureText(i).width,s.set(i,n)),n}qM(t){let i=this.UM.get(t);return void 0===i&&(i=new Map,this.UM.set(t,i)),i}}class Fe{constructor(t){this.Ps=Ne(t)}kt(t){this.Ps=Ne(t)}renderer(){return new Oe(this.Ps)}}function We(t){return{...t,T:w(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,jM:0,kc:0}}function Ne(t){return{...t,lines:t.lines.map(We)}}function He(t){return{...Le,...t}}function Ue(t){return{...ze,...t,lines:t.lines?.map(He)??[]}}class $e{constructor(t){this.Ps=Ue(t),this.YM=[new Fe(this.Ps)]}updateAllViews(){this.YM.forEach(t=>t.kt(this.Ps))}paneViews(){return this.YM}attached({requestUpdate:t}){this.KM=t}detached(){this.KM=void 0}ar(t){this.Ps=Ue({...this.Ps,...t}),this.KM&&this.KM()}}function je(t,i){return new Ie(t,new $e(i))}const qe={alpha:1,padding:0};class Ye{constructor(t){this.Yt=t}draw(t){t.useMediaCoordinateSpace(t=>{const i=t.context,s=this.XM(this.Yt,t.mediaSize);s&&this.Yt.GM&&(i.globalAlpha=this.Yt.alpha??1,i.drawImage(this.Yt.GM,s.ct,s.ut,s.ts,s.jt))})}XM(t,i){const{maxHeight:s,maxWidth:n,ZM:e,JM:r,padding:h}=t,a=Math.round(i.width/2),l=Math.round(i.height/2),o=h??0;let _=i.width-2*o,c=i.height-2*o;s&&(c=Math.min(c,s)),n&&(_=Math.min(_,n));const u=_/r,d=c/e,f=Math.min(u,d),p=r*f,v=e*f;return{ct:a-.5*p,ut:l-.5*v,jt:v,ts:p}}}class Ke{constructor(t){this.QM=null,this.tb=0,this.ib=0,this.Ps=t,this.M=Xe(this.Ps,this.QM,this.tb,this.ib)}sb(t){void 0!==t.nb&&(this.tb=t.nb),void 0!==t.eb&&(this.ib=t.eb),void 0!==t.rb&&(this.QM=t.rb),this.kt()}hb(t){this.Ps=t,this.kt()}zOrder(){return"bottom"}kt(){this.M=Xe(this.Ps,this.QM,this.tb,this.ib)}renderer(){return new Ye(this.M)}}function Xe(t,i,s,n){return{...t,GM:i,JM:s,ZM:n}}function Ge(t){return{...qe,...t}}class Ze{constructor(t,i){this.ab=null,this.lb=t,this.Ps=Ge(i),this.YM=[new Ke(this.Ps)]}updateAllViews(){this.YM.forEach(t=>t.kt())}paneViews(){return this.YM}attached(t){const{requestUpdate:i}=t;this.ob=i,this.ab=new Image,this.ab.onload=()=>{const t=this.ab?.naturalHeight??1,i=this.ab?.naturalWidth??1;this.YM.forEach(s=>s.sb({eb:t,nb:i,rb:this.ab})),this.ob&&this.ob()},this.ab.src=this.lb}detached(){this.ob=void 0,this.ab=null}ar(t){this.Ps=Ge({...this.Ps,...t}),this._b(),this.KM&&this.KM()}KM(){this.ob&&this.ob()}_b(){this.YM.forEach(t=>t.hb(this.Ps))}}function Je(t,i,s){return new Ie(t,new Ze(i,s))}class Qe{constructor(t,i){this.Qn=t,this.oh=i,this.HM()}detach(){this.Qn.detachPrimitive(this.oh)}getSeries(){return this.Qn}applyOptions(t){this.oh&&this.oh.ar&&this.oh.ar(t)}HM(){this.Qn.attachPrimitive(this.oh)}}const tr={autoScale:!0,zOrder:"normal"};function ir(t,i){return Gt(Math.min(Math.max(t,12),30)*i)}function sr(t,i){switch(t){case"arrowDown":case"arrowUp":return ir(i,1);case"circle":return ir(i,.8);case"square":return ir(i,.7)}}function nr(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(ir(t,1))}function er(t){return Math.max(ir(t,.1),3)}function rr(t,i,s){return i?t:s?Math.ceil(t/2):0}function hr(t,i,s,n){const e=(sr("arrowUp",n)-1)/2*s.cb,r=(Gt(n/2)-1)/2*s.cb;i.beginPath(),t?(i.moveTo(s.ct-e,s.ut),i.lineTo(s.ct,s.ut-e),i.lineTo(s.ct+e,s.ut),i.lineTo(s.ct+r,s.ut),i.lineTo(s.ct+r,s.ut+e),i.lineTo(s.ct-r,s.ut+e),i.lineTo(s.ct-r,s.ut)):(i.moveTo(s.ct-e,s.ut),i.lineTo(s.ct,s.ut+e),i.lineTo(s.ct+e,s.ut),i.lineTo(s.ct+r,s.ut),i.lineTo(s.ct+r,s.ut-e),i.lineTo(s.ct-r,s.ut-e),i.lineTo(s.ct-r,s.ut)),i.fill()}function ar(t,i,s,n,e,r){const h=(sr("arrowUp",n)-1)/2,a=(Gt(n/2)-1)/2;if(e>=i-a-2&&e<=i+a+2&&r>=(t?s:s-h)-2&&r<=(t?s+h:s)+2)return!0;return(()=>{if(e<i-h-3||e>i+h+3||r<(t?s-h-3:s)||r>(t?s:s+h+3))return!1;const n=Math.abs(e-i);return Math.abs(r-s)+3>=n/2})()}class lr{constructor(){this.Yt=null,this.Fn=new it,this.N=-1,this.H="",this.Hp="",this.ub="normal"}lt(t){this.Yt=t}Wn(t,i,s){this.N===t&&this.H===i||(this.N=t,this.H=i,this.Hp=w(t,i),this.Fn.Vn()),this.ub=s}Kn(t,i){if(null===this.Yt||null===this.Yt.ot)return null;for(let s=this.Yt.ot.from;s<this.Yt.ot.to;s++){const n=this.Yt._t[s];if(n&&_r(n,t,i))return{zOrder:"normal",externalId:n.Xn??""}}return null}draw(t){"aboveSeries"!==this.ub&&t.useBitmapCoordinateSpace(t=>{this.rt(t)})}drawBackground(t){"aboveSeries"===this.ub&&t.useBitmapCoordinateSpace(t=>{this.rt(t)})}rt({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null!==this.Yt&&null!==this.Yt.ot){t.textBaseline="middle",t.font=this.Hp;for(let n=this.Yt.ot.from;n<this.Yt.ot.to;n++){const e=this.Yt._t[n];void 0!==e.hi&&(e.hi.ts=this.Fn.Bi(t,e.hi.fb),e.hi.jt=this.N,e.hi.ct=e.ct-e.hi.ts/2),or(e,t,i,s)}}}}function or(t,i,s,n){i.fillStyle=t.D,void 0!==t.hi&&function(t,i,s,n,e,r){t.save(),t.scale(e,r),t.fillText(i,s,n),t.restore()}(i,t.hi.fb,t.hi.ct,t.hi.ut,s,n),function(t,i,s){if(0===t.Lr)return;switch(t.pb){case"arrowDown":return void hr(!1,i,s,t.Lr);case"arrowUp":return void hr(!0,i,s,t.Lr);case"circle":return void function(t,i,s){const n=(sr("circle",s)-1)/2;t.beginPath(),t.arc(i.ct,i.ut,n*i.cb,0,2*Math.PI,!1),t.fill()}(i,s,t.Lr);case"square":return void function(t,i,s){const n=sr("square",s),e=(n-1)*i.cb/2,r=i.ct-e,h=i.ut-e;t.fillRect(r,h,n*i.cb,n*i.cb)}(i,s,t.Lr)}t.pb}(t,i,function(t,i,s){const n=Math.max(1,Math.floor(i))%2/2;return{ct:Math.round(t.ct*i)+n,ut:t.ut*s,cb:i}}(t,s,n))}function _r(t,i,s){return!(void 0===t.hi||!function(t,i,s,n,e,r){const h=n/2;return e>=t&&e<=t+s&&r>=i-h&&r<=i+h}(t.hi.ct,t.hi.ut,t.hi.ts,t.hi.jt,i,s))||function(t,i,s){if(0===t.Lr)return!1;switch(t.pb){case"arrowDown":return ar(!0,t.ct,t.ut,t.Lr,i,s);case"arrowUp":return ar(!1,t.ct,t.ut,t.Lr,i,s);case"circle":return function(t,i,s,n,e){const r=2+sr("circle",s)/2,h=t-n,a=i-e;return Math.sqrt(h*h+a*a)<=r}(t.ct,t.ut,t.Lr,i,s);case"square":return function(t,i,s,n,e){const r=sr("square",s),h=(r-1)/2,a=t-h,l=i-h;return n>=a&&n<=a+r&&e>=l&&e<=l+r}(t.ct,t.ut,t.Lr,i,s)}}(t,i,s)}function cr(t){return"atPriceTop"===t||"atPriceBottom"===t||"atPriceMiddle"===t}function ur(t,i,s,n,e,r,h,l){const o=function(t,i,s){if(cr(i.position)&&void 0!==i.price)return i.price;if("value"in(n=t)&&"number"==typeof n.value)return t.value;var n;if(function(t){return"open"in t&&"high"in t&&"low"in t&&"close"in t}(t)){if("inBar"===i.position)return t.close;if("aboveBar"===i.position)return s?t.low:t.high;if("belowBar"===i.position)return s?t.high:t.low}}(s,i,h.priceScale().options().invertScale);if(void 0===o)return;const _=cr(i.position),u=l.timeScale(),d=c(i.size)?Math.max(i.size,0):1,f=nr(u.options().barSpacing)*d,p=f/2;t.Lr=f;switch(i.position){case"inBar":case"atPriceMiddle":return t.ut=a(h.priceToCoordinate(o)),void(void 0!==t.hi&&(t.hi.ut=t.ut+p+r+.6*e));case"aboveBar":case"atPriceTop":{const i=_?0:n.mb;return t.ut=a(h.priceToCoordinate(o))-p-i,void 0!==t.hi&&(t.hi.ut=t.ut-p-.6*e,n.mb+=1.2*e),void(_||(n.mb+=f+r))}case"belowBar":case"atPriceBottom":{const i=_?0:n.gb;return t.ut=a(h.priceToCoordinate(o))+p+i,void 0!==t.hi&&(t.hi.ut=t.ut+p+r+.6*e,n.gb+=1.2*e),void(_||(n.gb+=f+r))}}}class dr{constructor(t,i,s){this.wb=[],this.yt=!0,this.Mb=!0,this.Jt=new lr,this.Me=t,this.Bp=i,this.Yt={_t:[],ot:null},this.Ps=s}renderer(){if(!this.Me.options().visible)return null;this.yt&&this.bb();const t=this.Bp.options().layout;return this.Jt.Wn(t.fontSize,t.fontFamily,this.Ps.zOrder),this.Jt.lt(this.Yt),this.Jt}Sb(t){this.wb=t,this.kt("data")}kt(t){this.yt=!0,"data"===t&&(this.Mb=!0)}xb(t){this.yt=!0,this.Ps=t}zOrder(){return"aboveSeries"===this.Ps.zOrder?"top":this.Ps.zOrder}bb(){const t=this.Bp.timeScale(),i=this.wb;this.Mb&&(this.Yt._t=i.map(t=>({wt:t.time,ct:0,ut:0,Lr:0,pb:t.shape,D:t.color,Xn:t.id,yb:t.yb,hi:void 0})),this.Mb=!1);const s=this.Bp.options().layout;this.Yt.ot=null;const n=t.getVisibleLogicalRange();if(null===n)return;const e=new Ci(Math.floor(n.from),Math.ceil(n.to));if(null===this.Me.data()[0])return;if(0===this.Yt._t.length)return;let r=NaN;const h=er(t.options().barSpacing),l={mb:h,gb:h};this.Yt.ot=fn(this.Yt._t,e,!0);for(let n=this.Yt.ot.from;n<this.Yt.ot.to;n++){const e=i[n];e.time!==r&&(l.mb=h,l.gb=h,r=e.time);const o=this.Yt._t[n];o.ct=a(t.logicalToCoordinate(e.time)),void 0!==e.text&&e.text.length>0&&(o.hi={fb:e.text,ct:0,ut:0,ts:0,jt:0});const _=this.Me.dataByIndex(e.time,0);null!==_&&ur(o,e,_,l,s.fontSize,h,this.Me,this.Bp)}this.yt=!1}}function fr(t){return{...tr,...t}}class pr{constructor(t){this.nh=null,this.wb=[],this.Cb=[],this.Pb=null,this.Me=null,this.Bp=null,this.kb=!0,this.Tb=null,this.Rb=null,this.Db=null,this.Eb=!0,this.Ps=fr(t)}attached(t){this.Bb(),this.Bp=t.chart,this.Me=t.series,this.nh=new dr(this.Me,a(this.Bp),this.Ps),this.ob=t.requestUpdate,this.Me.subscribeDataChanged(t=>this.Rw(t)),this.Eb=!0,this.KM()}KM(){this.ob&&this.ob()}detached(){this.Me&&this.Pb&&this.Me.unsubscribeDataChanged(this.Pb),this.Bp=null,this.Me=null,this.nh=null,this.Pb=null}Sb(t){this.Eb=!0,this.wb=t,this.Bb(),this.kb=!0,this.Rb=null,this.KM()}Vb(){return this.wb}paneViews(){return this.nh?[this.nh]:[]}updateAllViews(){this.Ab()}hitTest(t,i){return this.nh?this.nh.renderer()?.Kn(t,i)??null:null}autoscaleInfo(t,i){if(this.Ps.autoScale&&this.nh){const t=this.Ib();if(t)return{priceRange:null,margins:t}}return null}ar(t){this.Ps=fr({...this.Ps,...t}),this.KM&&this.KM()}Ib(){const t=a(this.Bp).timeScale().options().barSpacing;if(this.kb||t!==this.Db){if(this.Db=t,this.wb.length>0){const i=er(t),s=1.5*nr(t)+2*i,n=this.zb();this.Tb={above:rr(s,n.aboveBar,n.inBar),below:rr(s,n.belowBar,n.inBar)}}else this.Tb=null;this.kb=!1}return this.Tb}zb(){return null===this.Rb&&(this.Rb=this.wb.reduce((t,i)=>(t[i.position]||(t[i.position]=!0),t),{inBar:!1,aboveBar:!1,belowBar:!1,atPriceTop:!1,atPriceBottom:!1,atPriceMiddle:!1})),this.Rb}Bb(){if(!this.Eb||!this.Bp||!this.Me)return;const t=this.Bp.timeScale(),i=this.Me?.data();if(null==t.getVisibleLogicalRange()||!this.Me||0===i.length)return void(this.Cb=[]);const s=t.timeToIndex(a(i[0].time),!0);this.Cb=this.wb.map((i,n)=>{const e=t.timeToIndex(i.time,!0),r=e<s?1:-1,h=a(this.Me).dataByIndex(e,r),l={time:t.timeToIndex(a(h).time,!1),position:i.position,shape:i.shape,color:i.color,id:i.id,yb:n,text:i.text,size:i.size,price:i.price,Pg:i.time};if("atPriceTop"===i.position||"atPriceBottom"===i.position||"atPriceMiddle"===i.position){if(void 0===i.price)throw new Error(`Price is required for position ${i.position}`);return{...l,position:i.position,price:i.price}}return{...l,position:i.position,price:i.price}}),this.Eb=!1}Ab(t){this.nh&&(this.Bb(),this.nh.Sb(this.Cb),this.nh.xb(this.Ps),this.nh.kt(t))}Rw(t){this.Eb=!0,this.KM()}}class vr extends Qe{constructor(t,i,s){super(t,i),s&&this.setMarkers(s)}setMarkers(t){this.oh.Sb(t)}markers(){return this.oh.Vb()}}function mr(t,i,s){const n=new vr(t,new pr(s??{}));return i&&n.setMarkers(i),n}class gr{constructor(t){this.wb=new Map,this.Lb=t}Ob(t,i,s){if(this.Fb(i),void 0!==s){const n=window.setTimeout(()=>{this.wb.delete(i),this.Wb()},s),e={...t,Nb:n,Hb:Date.now()+s};this.wb.set(i,e)}else this.wb.set(i,{...t,Nb:void 0,Hb:void 0});this.Wb()}Fb(t){const i=this.wb.get(t);i&&void 0!==i.Nb&&window.clearTimeout(i.Nb),this.wb.delete(t),this.Wb()}Ub(){for(const[t]of this.wb)this.Fb(t)}$b(){const t=Date.now(),i=[];for(const[s,n]of this.wb)!n.Hb||n.Hb>t?i.push({time:n.time,sign:n.sign,value:n.value}):this.Fb(s);return i}jb(t){this.Lb=t}Wb(){this.Lb&&this.Lb()}}const wr={positiveColor:"#22AB94",negativeColor:"#F7525F",updateVisibilityDuration:5e3};class Mr{constructor(t,i,s,n){this.Yt=t,this.qb=i,this.Yb=s,this.Kb=n}draw(t){t.useBitmapCoordinateSpace(t=>{const i=t.context,s=Math.max(1,Math.floor(t.horizontalPixelRatio))%2/2,n=4*t.verticalPixelRatio+s;this.Yt.forEach(e=>{const r=Math.round(e.ct*t.horizontalPixelRatio)+s;i.beginPath();const h=this.Xb(e.Gb);i.fillStyle=h,i.arc(r,e.ut*t.verticalPixelRatio,n,0,2*Math.PI,!1),i.fill(),e.Gb&&(i.strokeStyle=h,i.lineWidth=Math.floor(2*t.horizontalPixelRatio),i.beginPath(),i.moveTo((e.ct-4.7)*t.horizontalPixelRatio+s,(e.ut-7*e.Gb)*t.verticalPixelRatio),i.lineTo(e.ct*t.horizontalPixelRatio+s,(e.ut-7*e.Gb-7*e.Gb*.5)*t.verticalPixelRatio),i.lineTo((e.ct+4.7)*t.horizontalPixelRatio+s,(e.ut-7*e.Gb)*t.verticalPixelRatio),i.stroke())})})}Xb(t){return 0===t?this.qb:t>0?this.Kb:this.Yb}}class br{constructor(t,i,s){this.Yt=[],this.Me=t,this.dh=i,this.Ps=s}kt(t){this.Yt=t.map(t=>{const i=this.Me.priceToCoordinate(t.value);if(null===i)return null;return{ct:a(this.dh.timeToCoordinate(t.time)),ut:i,Gb:t.sign}}).filter(v)}renderer(){const t=function(t,i){return function(t,i){return"Area"===i}(0,i)?t.lineColor:t.color}(this.Me.options(),this.Me.seriesType());return new Mr(this.Yt,t,this.Ps.negativeColor,this.Ps.positiveColor)}}function Sr(t,i){return"Line"===i||"Area"===i}class xr{constructor(t){this.Bp=void 0,this.Me=void 0,this.YM=[],this.__=null,this.Zb=new Map,this.Jb=new gr(()=>this.KM()),this.Ps={...wr,...t}}ar(t){this.Ps={...this.Ps,...t},this.KM()}Sb(t){this.Jb.Ub();const i=this.__;i&&t.forEach(t=>{this.Jb.Ob(t,i.key(t.time))})}Vb(){return this.Jb.$b()}KM(){this.ob?.()}attached(t){const{chart:i,series:s,requestUpdate:n,horzScaleBehavior:e}=t;this.Bp=i,this.Me=s,this.__=e;const r=this.Me.seriesType();if("Area"!==r&&"Line"!==r)throw new Error("UpDownMarkersPrimitive is only supported for Area and Line series types");this.YM=[new br(this.Me,this.Bp.timeScale(),this.Ps)],this.ob=n,this.KM()}detached(){this.Bp=void 0,this.Me=void 0,this.ob=void 0}qp(){return h(this.Bp)}Fo(){return h(this.Me)}updateAllViews(){this.YM.forEach(t=>t.kt(this.Vb()))}paneViews(){return this.YM}lt(t){if(!this.Me)throw new Error("Primitive not attached to series");const i=this.Me.seriesType();this.Zb.clear();const s=this.__;s&&t.forEach(t=>{Xs(t)&&Sr(0,i)&&this.Zb.set(s.key(t.time),t.value)}),h(this.Me).setData(t)}kt(t,i){if(!this.Me||!this.__)throw new Error("Primitive not attached to series");const s=this.Me.seriesType(),n=this.__.key(t.time);if(Ks(t)&&this.Zb.delete(n),Xs(t)&&Sr(0,s)){const i=this.Zb.get(n);i&&this.Jb.Ob({time:t.time,value:t.value,sign:yr(t.value,i)},n,this.Ps.updateVisibilityDuration)}h(this.Me).update(t,i)}Qb(){this.Jb.Ub()}}function yr(t,i){return t===i?0:t-i>0?1:-1}class Cr extends Qe{setData(t){return this.oh.lt(t)}update(t,i){return this.oh.kt(t,i)}markers(){return this.oh.Vb()}setMarkers(t){return this.oh.Sb(t)}clearMarkers(){return this.oh.Qb()}}function Pr(t,i={}){return new Cr(t,new xr(i))}function kr(t,i,s={}){const n=s.period??20,e=s.color??"#2196F3",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[];for(let e=n-1;e<i.length;e++){let r=0;for(let t=0;t<n;t++)r+=i[e-t];const h=r/n;t[e]&&t[e].time&&s.push({time:t[e].time,value:h})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating SMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Tr(t,i,s={}){const n=s.period??12,e=s.color??"#FF9800",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=2/(n+1);let r=0;for(let t=0;t<n;t++)r+=i[t];r/=n,t[n-1]&&t[n-1].time&&s.push({time:t[n-1].time,value:r});for(let h=n;h<i.length;h++)r=(i[h]-r)*e+r,t[h]&&t[h].time&&s.push({time:t[h].time,value:r});return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating EMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Rr(t,i,s={}){const n=s.period??20,e=s.color??"#4CAF50",r=i.addSeries(ee,{color:e,lineWidth:2,priceFormat:{type:"price",precision:2,minMove:.01}},0),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=n*(n+1)/2;for(let r=n-1;r<i.length;r++){let h=0;for(let t=0;t<n;t++){const s=t+1;h+=i[r-n+1+t]*s}const a=h/e;t[r]&&t[r].time&&s.push({time:t[r].time,value:a})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating WMA:",t)}};return t.subscribeDataChanged(h),h(),r}function Dr(t,i,s={}){const n=s.period??20,e=s.stdDev??2,r=i.addSeries(ee,{color:s.colorUpper??"#3F51B5",lineWidth:1},0),h=i.addSeries(ee,{color:s.colorMiddle??"#2196F3",lineWidth:2},0),a=i.addSeries(ee,{color:s.colorLower??"#3F51B5",lineWidth:1},0),l=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return{tS:[],iS:[],sS:[]};const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],r=[],h=[];for(let a=n-1;a<i.length;a++){let l=0;for(let t=0;t<n;t++)l+=i[a-t];const o=l/n;let _=0;for(let t=0;t<n;t++)_+=Math.pow(i[a-t]-o,2);const c=Math.sqrt(_/n),u=o+c*e,d=o-c*e;if(t[a]&&t[a].time){const i=t[a].time;s.push({time:i,value:u}),r.push({time:i,value:o}),h.push({time:i,value:d})}}return{tS:s,iS:r,sS:h}})([...i]);s.tS.length>0&&(r.setData(s.tS),h.setData(s.iS),a.setData(s.sS))}catch(t){console.error("Error calculating Bollinger Bands:",t)}};return t.subscribeDataChanged(l),l(),{upper:r,middle:h,lower:a}}function Er(t,i,s={}){const n=s.period??14,e=s.color??"#9C27B0",r=i.addSeries(ee,{color:e,priceFormat:{type:"price",precision:2,minMove:.01}},1);r.priceScale().applyOptions({scaleMargins:{top:.1,bottom:.1},borderVisible:!1,autoScale:!1});const h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n+1)return[];const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=[],e=[];for(let t=1;t<i.length;t++)e.push(i[t]-i[t-1]);let r=0,h=0;for(let t=0;t<n;t++)e[t]>0?r+=e[t]:h+=Math.abs(e[t]);r/=n,h/=n;let a=0===h?100:r/h,l=100-100/(1+a);t[n]&&t[n].time&&s.push({time:t[n].time,value:l});for(let i=n;i<e.length;i++){const o=e[i],_=o>0?o:0,c=o<0?Math.abs(o):0;r=(r*(n-1)+_)/n,h=(h*(n-1)+c)/n,a=0===h?100:r/h,l=100-100/(1+a),t[i+1]&&t[i+1].time&&s.push({time:t[i+1].time,value:l})}return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating RSI:",t)}};return t.subscribeDataChanged(h),h(),r}function Br(t,i,s={}){const n=s.fastPeriod??12,e=s.slowPeriod??26,r=s.signalPeriod??9,h=i.addSeries(ee,{color:s.colorMACD??"#2196F3",lineWidth:2},2),a=i.addSeries(ee,{color:s.colorSignal??"#FF6D00",lineWidth:2},2),l=i.addSeries(Ae,{color:s.colorHistogram??"#26a69a"},2),o=(t,i)=>{const s=[],n=2/(i+1);let e=0;for(let s=0;s<i;s++)e+=t[s];s.push(e/i);for(let e=i;e<t.length;e++)s.push((t[e]-s[s.length-1])*n+s[s.length-1]);return s},_=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<e+r)return{nS:[],eS:[],rS:[]};const i=[];for(const s of t)"close"in s?i.push(s.close):"value"in s?i.push(s.value):i.push(0);const s=o(i,n),h=o(i,e),a=[],l=e-n;for(let t=0;t<h.length;t++)a.push(s[t+l]-h[t]);const _=o(a,r),c=[],u=[],d=[],f=e-1;for(let i=r-1;i<_.length;i++){const s=f+i;if(t[s]&&t[s].time){const n=t[s].time,e=a[i],r=_[i],h=e-r;c.push({time:n,value:e}),u.push({time:n,value:r}),d.push({time:n,value:h,color:h>=0?"#26a69a":"#ef5350"})}}return{nS:c,eS:u,rS:d}})([...i]);s.nS.length>0&&(h.setData(s.nS),a.setData(s.eS),l.setData(s.rS))}catch(t){console.error("Error calculating MACD:",t)}};return t.subscribeDataChanged(_),_(),{macd:h,signal:a,histogram:l}}function Vr(t,i,s={}){const n=s.kPeriod??14,e=s.dPeriod??3,r=i.addSeries(ee,{color:s.colorK??"#2196F3",lineWidth:2},4),h=i.addSeries(ee,{color:s.colorD??"#FF6D00",lineWidth:2},4);r.priceScale().applyOptions({scaleMargins:{top:.1,bottom:.1}});const a=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n)return{hS:[],aS:[]};const i=[];for(let s=n-1;s<t.length;s++){let e=-1/0,r=1/0;for(let i=0;i<n;i++){const n=t[s-i];"high"in n&&"low"in n&&(e=Math.max(e,n.high),r=Math.min(r,n.low))}const h=t[s];if("close"in h){const t=(h.close-r)/(e-r)*100;i.push(t)}}const s=[];for(let e=0;e<i.length;e++){const r=n-1+e;t[r]&&t[r].time&&s.push({time:t[r].time,value:i[e]})}const r=[];if(i.length>=e)for(let s=e-1;s<i.length;s++){let h=0;for(let t=0;t<e;t++)h+=i[s-t];const a=h/e,l=n-1+s;t[l]&&t[l].time&&r.push({time:t[l].time,value:a})}return{hS:s,aS:r}})([...i]);s.hS.length>0&&(r.setData(s.hS),h.setData(s.aS))}catch(t){console.error("Error calculating Stochastic:",t)}};return t.subscribeDataChanged(a),a(),{k:r,d:h}}function Ar(t,i,s={}){const n=s.period??14,e=s.color??"#FF9800",r=i.addSeries(ee,{color:e,lineWidth:2},6),h=()=>{try{const i=t.data();if(!i||0===i.length)return;const s=(t=>{if(!t||t.length<n+1)return[];const i=[];for(let s=1;s<t.length;s++){const n=t[s],e=t[s-1];if("high"in n&&"low"in n&&"close"in e){const t=n.high-n.low,s=Math.abs(n.high-e.close),r=Math.abs(n.low-e.close),h=Math.max(t,s,r);i.push(h)}}if(i.length<n)return[];const s=[];let e=0;for(let t=0;t<n;t++)e+=i[t];e/=n,t[n]&&t[n].time&&s.push({time:t[n].time,value:e});for(let r=n;r<i.length;r++)e=(e*(n-1)+i[r])/n,t[r+1]&&t[r+1].time&&s.push({time:t[r+1].time,value:e});return s})([...i]);s&&s.length>0&&r.setData(s)}catch(t){console.error("Error calculating ATR:",t)}};return t.subscribeDataChanged(h),h(),r}const Ir=new Map;function zr(t,i,s={}){const n=s.colorUp??"#26a69a",e=s.colorDown??"#ef5350";Ir.has(t)||Ir.set(t,new Map);const r=i.addSeries(Ae,{color:n,priceFormat:{type:"volume"},priceScaleId:""},3);r.priceScale().applyOptions({scaleMargins:{top:.8,bottom:0}});const h=()=>{try{const i=(()=>{const i=t.data(),s=Ir.get(t);if(!i||0===i.length)return[];if(!s||0===s.size)return[];const r=[];for(const t of i){const i="string"==typeof t.time?t.time:String(t.time),h=s.get(i);h&&"close"in t&&"open"in t&&r.push({time:t.time,value:h,color:t.close>=t.open?n:e})}return r})();i.length>0&&r.setData(i)}catch(t){console.error("Error calculating Volume:",t)}};return t.subscribeDataChanged(h),h(),r}function Lr(t,i){Ir.has(t)||Ir.set(t,new Map);const s=Ir.get(t);s.clear();for(const t of i)if("time"in t&&"volume"in t){const i="string"==typeof t.time?t.time:String(t.time);s.set(i,t.volume)}}const Or=new Map;function Fr(t,i,s={}){const n=s.color??"#2196F3";Or.has(t)||Or.set(t,new Map);const e=i.addSeries(ee,{color:n,lineWidth:2},5),r=()=>{try{const i=(()=>{const i=t.data(),s=Or.get(t);if(!i||i.length<2)return[];if(!s||0===s.size)return[];const n=[];let e=0;n.push({time:i[0].time,value:e});for(let t=1;t<i.length;t++){const r=i[t],h=i[t-1],a="string"==typeof r.time?r.time:String(r.time),l=s.get(a);l&&"close"in r&&"close"in h&&(r.close>h.close?e+=l:r.close<h.close&&(e-=l),n.push({time:r.time,value:e}))}return n})();i.length>0&&e.setData(i)}catch(t){console.error("Error calculating OBV:",t)}};return t.subscribeDataChanged(r),r(),e}function Wr(t,i){Or.has(t)||Or.set(t,new Map);const s=Or.get(t);s.clear();for(const t of i)if("time"in t&&"volume"in t){const i="string"==typeof t.time?t.time:String(t.time);s.set(i,t.volume)}}class Nr{constructor(t,i,s){this.sr=null,this.lS=!1,this.Ep=null,this.oS=[],this._S=!1,this.cS="",this.Bp=t,this.Me=i,this.Ps={lineWidth:2,lineStyle:0,axisLabelVisible:!0,draggable:!0,...s},this.uS(),this.Ps.draggable&&this.dS()}uS(){this.cS=this.Ps.color,this.sr=this.Me.createPriceLine({price:this.Ps.price,color:this.Ps.color,lineWidth:this.Ps.lineWidth,lineStyle:this.Ps.lineStyle,axisLabelVisible:this.Ps.axisLabelVisible,title:this.Ps.title||""})}dS(){const t=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!t)return;this.Ep=t;const i=t=>{if(!this.fS(t))return;const i=this.pS(t.clientY);this.vS(t,i)&&(this.lS=!0,this.Ep.style.cursor="ns-resize",this.Ps.onDragStart&&this.Ps.onDragStart(this.Ps.price),t.preventDefault(),t.stopPropagation())},s=t=>{if(this.lS){const i=this.pS(t.clientY);this.mS(i),this.Ps.onDragMove&&this.Ps.onDragMove(i),t.preventDefault(),t.stopPropagation()}else{if(!this.fS(t))return void this.gS(!1);const i=this.pS(t.clientY);this.vS(t,i)?(this.Ep.style.cursor="ns-resize",this.gS(!0)):(this.Ep.style.cursor="default",this.gS(!1))}},n=t=>{this.lS&&(this.lS=!1,this.Ep.style.cursor="default",this.gS(!1),this.Ps.onDragEnd&&this.Ps.onDragEnd(this.Ps.price))},e=t=>{this.lS?(this.lS=!1,this.gS(!1),this.Ps.onDragEnd&&this.Ps.onDragEnd(this.Ps.price)):this.gS(!1)};this.Ep.addEventListener("mousedown",i),this.Ep.addEventListener("mousemove",s),this.Ep.addEventListener("mouseup",n),this.Ep.addEventListener("mouseleave",e),this.oS.push(()=>{this.Ep?.removeEventListener("mousedown",i),this.Ep?.removeEventListener("mousemove",s),this.Ep?.removeEventListener("mouseup",n),this.Ep?.removeEventListener("mouseleave",e)})}pS(t){try{const i=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!i)return this.Ps.price;const s=t-i.getBoundingClientRect().top,n=this.Me.coordinateToPrice(s);return null===n?this.Ps.price:n}catch(t){return console.error("Error getting price from Y:",t),this.Ps.price}}vS(t,i){const s=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");if(!s)return!1;const n=this.Me.priceToCoordinate(this.Ps.price);if(null===n)return!1;const e=s.getBoundingClientRect(),r=t.clientY-e.top;return Math.abs(r-n)<=5}fS(t){if(!this.Ep)return!1;const i=this.Ep.getBoundingClientRect();return t.clientX-i.left<i.width-80}gS(t){this._S!==t&&this.sr&&(this._S=t,t?this.sr.applyOptions({color:"#000000"}):this.sr.applyOptions({color:this.cS}))}mS(t){this.Ps.price=t,this.sr&&this.sr.applyOptions({price:t})}applyOptions(t){this.Ps={...this.Ps,...t},t.color&&(this.cS=t.color),this.sr&&void 0!==t.price&&this.sr.applyOptions({price:t.price,color:t.color,lineWidth:t.lineWidth,lineStyle:t.lineStyle,title:t.title})}getPrice(){return this.Ps.price}setPrice(t){this.mS(t)}remove(){this.oS.forEach(t=>t()),this.oS=[],this.gS(!1),this.sr&&(this.Me.removePriceLine(this.sr),this.sr=null),this.Ep&&(this.Ep.style.cursor="default")}getPriceLine(){return this.sr}}function Hr(t,i,s){const n={"stop-loss":{color:"#ef5350",lineStyle:2,title:"Stop Loss",draggable:!0},"take-profit":{color:"#26a69a",lineStyle:2,title:"Take Profit",draggable:!0},entry:{color:"#2196F3",lineStyle:0,title:"Entry",draggable:!0},target:{color:"#FF9800",lineStyle:2,title:"Target",draggable:!0},resistance:{color:"#f44336",lineStyle:0,title:"Resistance",draggable:!0},support:{color:"#4CAF50",lineStyle:0,title:"Support",draggable:!0},custom:{color:"#9E9E9E",lineStyle:0,title:"",draggable:!0}},e=s.type?n[s.type]:n.custom,r={price:s.price,color:s.color??e.color??"#9E9E9E",lineWidth:s.lineWidth??2,lineStyle:s.lineStyle??e.lineStyle??0,title:s.title??e.title??"",axisLabelVisible:s.axisLabelVisible??!0,draggable:s.draggable??e.draggable??!0,onDragStart:s.onDragStart,onDragMove:s.onDragMove,onDragEnd:s.onDragEnd};return new Nr(i,t,r)}class Ur{constructor(t,i){this.Ep=null,this.wS=null,this.MS=null,this.bS={},this.Bp=t,this.Me=i,this.SS()}SS(){const t=this.Bp.chartElement?.()||document.querySelector(".tv-lightweight-charts");t&&(this.Ep=t)}xS(t){try{if(!this.Ep)return 0;const i=this.Ep.getBoundingClientRect(),s=t.clientY-i.top,n=this.Me.coordinateToPrice(s);return null===n?0:n}catch(t){return console.error("Error getting price from mouse event:",t),0}}enableClickToCreate(t,i){return this.Ep?(this.wS=t,this.bS=i||{},new Promise(t=>{this.Ep.style.cursor="crosshair",this.MS=i=>{const s=this.xS(i),n=this.yS(s);this.disableClickToCreate(),t(n)},this.Ep.addEventListener("click",this.MS)})):Promise.resolve(null)}disableClickToCreate(){this.Ep&&this.MS&&(this.Ep.removeEventListener("click",this.MS),this.Ep.style.cursor="default"),this.wS=null,this.MS=null,this.bS={}}yS(t){if(!this.wS)return null;let i;switch(this.wS){case"stop-loss":i={price:t,color:"#ef5350",lineWidth:2,title:"Stop Loss",draggable:!0,...this.bS};break;case"take-profit":i={price:t,color:"#26a69a",lineWidth:2,title:"Take Profit",draggable:!0,...this.bS};break;case"entry":i={price:t,color:"#2196F3",lineWidth:2,title:"Entry",draggable:!0,...this.bS};break;case"target":i={price:t,color:"#FF9800",lineWidth:2,title:"Target",draggable:!0,...this.bS};break;case"resistance":i={price:t,color:"#f44336",lineWidth:2,title:"Resistance",draggable:!0,...this.bS};break;case"support":i={price:t,color:"#4CAF50",lineWidth:2,title:"Support",draggable:!0,...this.bS};break;case"custom":i={price:t,color:"#9E9E9E",lineWidth:2,title:"Custom",draggable:!0,...this.bS};break;default:return null}return new Nr(this.Bp,this.Me,i)}getCreationMode(){return this.wS}isCreating(){return null!==this.wS}}function $r(t,i){return new Ur(t,i)}const jr={...t,color:"#2196f3"};function qr(){return"0.0.11-dev+202510282325"}export{ye as AreaSeries,Te as BarSeries,be as BaselineSeries,Ee as CandlestickSeries,Ai as ColorType,$ as CrosshairMode,Nr as DraggablePriceLine,Ae as HistogramSeries,Ur as InteractiveLineManager,Bi as LastPriceAnimationMode,ee as LineSeries,s as LineStyle,i as LineType,yt as MismatchDirection,Vi as PriceLineSource,di as PriceScaleMode,Ii as TickMarkType,Ei as TrackingModeExitMode,Ar as applyATR,Dr as applyBollingerBands,Tr as applyEMA,Br as applyMACD,Fr as applyOBV,Er as applyRSI,kr as applySMA,Vr as applyStochastic,zr as applyVolume,Rr as applyWMA,qn as createChart,jn as createChartEx,Je as createImageWatermark,$r as createInteractiveLineManager,fe as createOptionsChart,mr as createSeriesMarkers,je as createTextWatermark,Hr as createTradingLine,Pr as createUpDownMarkers,ce as createYieldCurveChart,jr as customSeriesDefaultOptions,Yn as defaultHorzScaleBehavior,Oi as isBusinessDay,Fi as isUTCTimestamp,Wr as setOBVVolumeData,Lr as setVolumeData,qr as version};
|