@devexperts/dxcharts-lite 2.7.16 → 2.7.17

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.
Files changed (50) hide show
  1. package/dist/chart/animation/canvas-animation.d.ts +1 -0
  2. package/dist/chart/animation/canvas-animation.js +2 -1
  3. package/dist/chart/animation/viewport-model-animation.d.ts +4 -1
  4. package/dist/chart/animation/viewport-model-animation.js +21 -3
  5. package/dist/chart/bootstrap.js +17 -5
  6. package/dist/chart/chart.config.js +1 -1
  7. package/dist/chart/components/chart/chart-area-pan.handler.d.ts +16 -16
  8. package/dist/chart/components/chart/chart-area-pan.handler.js +8 -2
  9. package/dist/chart/components/chart/chart.component.js +2 -0
  10. package/dist/chart/components/chart/chart.model.d.ts +11 -0
  11. package/dist/chart/components/chart/chart.model.js +20 -0
  12. package/dist/chart/components/cross_tool/cross-tool.component.d.ts +3 -1
  13. package/dist/chart/components/cross_tool/cross-tool.component.js +3 -2
  14. package/dist/chart/components/cross_tool/cross-tool.model.d.ts +6 -3
  15. package/dist/chart/components/cross_tool/cross-tool.model.js +9 -5
  16. package/dist/chart/components/grid/grid.component.d.ts +1 -1
  17. package/dist/chart/components/grid/grid.component.js +2 -2
  18. package/dist/chart/components/grid/grid.drawer.d.ts +2 -1
  19. package/dist/chart/components/grid/grid.drawer.js +3 -2
  20. package/dist/chart/components/pan/chart-pan.component.js +17 -1
  21. package/dist/chart/components/pane/pane.component.js +3 -1
  22. package/dist/chart/drawers/data-series-drawers/trend-points.drawer.d.ts +12 -0
  23. package/dist/chart/drawers/data-series-drawers/trend-points.drawer.js +70 -0
  24. package/dist/chart/drawers/drawing-manager.js +0 -1
  25. package/dist/chart/inputhandlers/chart-resize.handler.d.ts +5 -0
  26. package/dist/chart/inputhandlers/chart-resize.handler.js +9 -1
  27. package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +28 -0
  28. package/dist/chart/inputlisteners/canvas-input-listener.component.js +104 -7
  29. package/dist/chart/model/data-series.config.d.ts +1 -1
  30. package/dist/chart/model/hit-test-canvas.model.d.ts +15 -13
  31. package/dist/chart/model/hit-test-canvas.model.js +2 -2
  32. package/dist/chart/model/scale.model.d.ts +5 -0
  33. package/dist/chart/model/scale.model.js +72 -6
  34. package/dist/chart/utils/device/touchpad.utils.d.ts +1 -0
  35. package/dist/chart/utils/device/touchpad.utils.js +1 -1
  36. package/dist/chart/utils/math.utils.js +1 -1
  37. package/dist/chart/utils/performance/queue-microtask.utils.d.ts +5 -0
  38. package/dist/chart/utils/performance/queue-microtask.utils.js +12 -0
  39. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.d.ts +1 -0
  40. package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +3 -0
  41. package/dist/chart/utils/performance/safari/components/animations/safari-canvas-animation.d.ts +77 -0
  42. package/dist/chart/utils/performance/safari/components/animations/safari-canvas-animation.js +137 -0
  43. package/dist/chart/utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler.d.ts +54 -0
  44. package/dist/chart/utils/performance/safari/components/chart-area-pan.handler/safari-chart-area-pan.handler.js +180 -0
  45. package/dist/chart/utils/performance/safari/safari-performance.model.d.ts +32 -0
  46. package/dist/chart/utils/performance/safari/safari-performance.model.js +31 -0
  47. package/dist/chart/utils/performance/safari/safari-performance.utils.d.ts +18 -0
  48. package/dist/chart/utils/performance/safari/safari-performance.utils.js +34 -0
  49. package/dist/dxchart.min.js +4 -4
  50. package/package.json +2 -2
@@ -3,10 +3,10 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
4
  * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
  */
6
- (()=>{var it=Math.pow;(()=>{var $o={156:k=>{"use strict";k.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},195:k=>{k.exports=function(N){return!N||typeof N=="string"?!1:N instanceof Array||Array.isArray(N)||N.length>=0&&(N.splice instanceof Function||Object.getOwnPropertyDescriptor(N,N.length-1)&&N.constructor.name!=="String")}},507:(k,nt,N)=>{const q=N(659);function z(){const y={},C=Object.keys(q);for(let w=C.length,g=0;g<w;g++)y[C[g]]={distance:-1,parent:null};return y}function L(y){const C=z(),w=[y];for(C[y].distance=0;w.length;){const g=w.pop(),S=Object.keys(q[g]);for(let _=S.length,A=0;A<_;A++){const m=S[A],T=C[m];T.distance===-1&&(T.distance=C[g].distance+1,T.parent=g,w.unshift(m))}}return C}function ht(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=q[C[y].parent][y],S=C[y].parent;for(;C[S].parent;)w.unshift(C[S].parent),g=ht(q[C[S].parent][S],g),S=C[S].parent;return g.conversion=w,g}k.exports=function(y){const C=L(y),w={},g=Object.keys(C);for(let S=g.length,_=0;_<S;_++){const A=g[_];C[A].parent!==null&&(w[A]=b(A,C))}return w}},520:(k,nt,N)=>{const q=N(854),z=N(734),L=["keyword","gray","hex"],ht={};for(const m of Object.keys(z))ht[[...z[m].labels].sort().join("")]=m;const b={};function y(m,T){if(!(this instanceof y))return new y(m,T);if(T&&T in L&&(T=null),T&&!(T in z))throw new Error("Unknown model: "+T);let E,D;if(m==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(m instanceof y)this.model=m.model,this.color=[...m.color],this.valpha=m.valpha;else if(typeof m=="string"){const F=q.get(m);if(F===null)throw new Error("Unable to parse color from string: "+m);this.model=F.model,D=z[this.model].channels,this.color=F.value.slice(0,D),this.valpha=typeof F.value[D]=="number"?F.value[D]:1}else if(m.length>0){this.model=T||"rgb",D=z[this.model].channels;const F=Array.prototype.slice.call(m,0,D);this.color=A(F,D),this.valpha=typeof m[D]=="number"?m[D]:1}else if(typeof m=="number")this.model="rgb",this.color=[m>>16&255,m>>8&255,m&255],this.valpha=1;else{this.valpha=1;const F=Object.keys(m);"alpha"in m&&(F.splice(F.indexOf("alpha"),1),this.valpha=typeof m.alpha=="number"?m.alpha:0);const lt=F.sort().join("");if(!(lt in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(m));this.model=ht[lt];const{labels:Dt}=z[this.model],Ft=[];for(E=0;E<Dt.length;E++)Ft.push(m[Dt[E]]);this.color=A(Ft)}if(b[this.model])for(D=z[this.model].channels,E=0;E<D;E++){const F=b[this.model][E];F&&(this.color[E]=F(this.color[E]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}y.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(m){let T=this.model in q.to?this:this.rgb();T=T.round(typeof m=="number"?m:1);const E=T.valpha===1?T.color:[...T.color,this.valpha];return q.to[T.model](E)},percentString(m){const T=this.rgb().round(typeof m=="number"?m:1),E=T.valpha===1?T.color:[...T.color,this.valpha];return q.to.rgb.percent(E)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const m={},{channels:T}=z[this.model],{labels:E}=z[this.model];for(let D=0;D<T;D++)m[E[D]]=this.color[D];return this.valpha!==1&&(m.alpha=this.valpha),m},unitArray(){const m=this.rgb().color;return m[0]/=255,m[1]/=255,m[2]/=255,this.valpha!==1&&m.push(this.valpha),m},unitObject(){const m=this.rgb().object();return m.r/=255,m.g/=255,m.b/=255,this.valpha!==1&&(m.alpha=this.valpha),m},round(m){return m=Math.max(m||0,0),new y([...this.color.map(w(m)),this.valpha],this.model)},alpha(m){return m!==void 0?new y([...this.color,Math.max(0,Math.min(1,m))],this.model):this.valpha},red:g("rgb",0,S(255)),green:g("rgb",1,S(255)),blue:g("rgb",2,S(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,m=>(m%360+360)%360),saturationl:g("hsl",1,S(100)),lightness:g("hsl",2,S(100)),saturationv:g("hsv",1,S(100)),value:g("hsv",2,S(100)),chroma:g("hcg",1,S(100)),gray:g("hcg",2,S(100)),white:g("hwb",1,S(100)),wblack:g("hwb",2,S(100)),cyan:g("cmyk",0,S(100)),magenta:g("cmyk",1,S(100)),yellow:g("cmyk",2,S(100)),black:g("cmyk",3,S(100)),x:g("xyz",0,S(95.047)),y:g("xyz",1,S(100)),z:g("xyz",2,S(108.833)),l:g("lab",0,S(100)),a:g("lab",1),b:g("lab",2),keyword(m){return m!==void 0?new y(m):z[this.model].keyword(this.color)},hex(m){return m!==void 0?new y(m):q.to.hex(this.rgb().round().color)},hexa(m){if(m!==void 0)return new y(m);const T=this.rgb().round().color;let E=Math.round(this.valpha*255).toString(16).toUpperCase();return E.length===1&&(E="0"+E),q.to.hex(T)+E},rgbNumber(){const m=this.rgb().color;return(m[0]&255)<<16|(m[1]&255)<<8|m[2]&255},luminosity(){const m=this.rgb().color,T=[];for(const[E,D]of m.entries()){const F=D/255;T[E]=F<=.04045?F/12.92:it((F+.055)/1.055,2.4)}return .2126*T[0]+.7152*T[1]+.0722*T[2]},contrast(m){const T=this.luminosity(),E=m.luminosity();return T>E?(T+.05)/(E+.05):(E+.05)/(T+.05)},level(m){const T=this.contrast(m);return T>=7?"AAA":T>=4.5?"AA":""},isDark(){const m=this.rgb().color;return(m[0]*2126+m[1]*7152+m[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const m=this.rgb();for(let T=0;T<3;T++)m.color[T]=255-m.color[T];return m},lighten(m){const T=this.hsl();return T.color[2]+=T.color[2]*m,T},darken(m){const T=this.hsl();return T.color[2]-=T.color[2]*m,T},saturate(m){const T=this.hsl();return T.color[1]+=T.color[1]*m,T},desaturate(m){const T=this.hsl();return T.color[1]-=T.color[1]*m,T},whiten(m){const T=this.hwb();return T.color[1]+=T.color[1]*m,T},blacken(m){const T=this.hwb();return T.color[2]+=T.color[2]*m,T},grayscale(){const m=this.rgb().color,T=m[0]*.3+m[1]*.59+m[2]*.11;return y.rgb(T,T,T)},fade(m){return this.alpha(this.valpha-this.valpha*m)},opaquer(m){return this.alpha(this.valpha+this.valpha*m)},rotate(m){const T=this.hsl();let E=T.color[0];return E=(E+m)%360,E=E<0?360+E:E,T.color[0]=E,T},mix(m,T){if(!m||!m.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof m);const E=m.rgb(),D=this.rgb(),F=T===void 0?.5:T,lt=2*F-1,Dt=E.alpha()-D.alpha(),Ft=((lt*Dt===-1?lt:(lt+Dt)/(1+lt*Dt))+1)/2,Fe=1-Ft;return y.rgb(Ft*E.red()+Fe*D.red(),Ft*E.green()+Fe*D.green(),Ft*E.blue()+Fe*D.blue(),E.alpha()*F+D.alpha()*(1-F))}};for(const m of Object.keys(z)){if(L.includes(m))continue;const{channels:T}=z[m];y.prototype[m]=function(...E){return this.model===m?new y(this):E.length>0?new y(E,m):new y([..._(z[this.model][m].raw(this.color)),this.valpha],m)},y[m]=function(...E){let D=E[0];return typeof D=="number"&&(D=A(E,T)),new y(D,m)}}function C(m,T){return Number(m.toFixed(T))}function w(m){return function(T){return C(T,m)}}function g(m,T,E){m=Array.isArray(m)?m:[m];for(const D of m)(b[D]||(b[D]=[]))[T]=E;return m=m[0],function(D){let F;return D!==void 0?(E&&(D=E(D)),F=this[m](),F.color[T]=D,F):(F=this[m]().color[T],E&&(F=E(F)),F)}}function S(m){return function(T){return Math.max(0,Math.min(m,T))}}function _(m){return Array.isArray(m)?m:[m]}function A(m,T){for(let E=0;E<T;E++)typeof m[E]!="number"&&(m[E]=0);return m}k.exports=y},659:(k,nt,N)=>{const q=N(156),z={};for(const b of Object.keys(q))z[q[b]]=b;const L={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};k.exports=L;for(const b of Object.keys(L)){if(!("channels"in L[b]))throw new Error("missing channels property: "+b);if(!("labels"in L[b]))throw new Error("missing channel labels property: "+b);if(L[b].labels.length!==L[b].channels)throw new Error("channel and label counts mismatch: "+b);const{channels:y,labels:C}=L[b];delete L[b].channels,delete L[b].labels,Object.defineProperty(L[b],"channels",{value:y}),Object.defineProperty(L[b],"labels",{value:C})}L.rgb.hsl=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(y,C,w),S=Math.max(y,C,w),_=S-g;let A,m;S===g?A=0:y===S?A=(C-w)/_:C===S?A=2+(w-y)/_:w===S&&(A=4+(y-C)/_),A=Math.min(A*60,360),A<0&&(A+=360);const T=(g+S)/2;return S===g?m=0:T<=.5?m=_/(S+g):m=_/(2-S-g),[A,m*100,T*100]},L.rgb.hsv=function(b){let y,C,w,g,S;const _=b[0]/255,A=b[1]/255,m=b[2]/255,T=Math.max(_,A,m),E=T-Math.min(_,A,m),D=function(F){return(T-F)/6/E+1/2};return E===0?(g=0,S=0):(S=E/T,y=D(_),C=D(A),w=D(m),_===T?g=w-C:A===T?g=.3333333333333333+y-w:m===T&&(g=.6666666666666666+C-y),g<0?g+=1:g>1&&(g-=1)),[g*360,S*100,T*100]},L.rgb.hwb=function(b){const y=b[0],C=b[1];let w=b[2];const g=L.rgb.hsl(b)[0],S=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,S*100,w*100]},L.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),S=(1-y-g)/(1-g)||0,_=(1-C-g)/(1-g)||0,A=(1-w-g)/(1-g)||0;return[S*100,_*100,A*100,g*100]};function ht(b,y){return it(b[0]-y[0],2)+it(b[1]-y[1],2)+it(b[2]-y[2],2)}L.rgb.keyword=function(b){const y=z[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(q)){const S=q[g],_=ht(b,S);_<C&&(C=_,w=g)}return w},L.keyword.rgb=function(b){return q[b]},L.rgb.xyz=function(b){let y=b[0]/255,C=b[1]/255,w=b[2]/255;y=y>.04045?it((y+.055)/1.055,2.4):y/12.92,C=C>.04045?it((C+.055)/1.055,2.4):C/12.92,w=w>.04045?it((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,S=y*.2126+C*.7152+w*.0722,_=y*.0193+C*.1192+w*.9505;return[g*100,S*100,_*100]},L.rgb.lab=function(b){const y=L.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?it(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?it(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?it(g,.3333333333333333):7.787*g+.13793103448275862;const S=116*w-16,_=500*(C-w),A=200*(w-g);return[S,_,A]},L.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,S,_;if(C===0)return _=w*255,[_,_,_];w<.5?g=w*(1+C):g=w+C-w*C;const A=2*w-g,m=[0,0,0];for(let T=0;T<3;T++)S=y+.3333333333333333*-(T-1),S<0&&S++,S>1&&S--,6*S<1?_=A+(g-A)*6*S:2*S<1?_=g:3*S<2?_=A+(g-A)*(.6666666666666666-S)*6:_=A,m[T]=_*255;return m},L.hsl.hsv=function(b){const y=b[0];let C=b[1]/100,w=b[2]/100,g=C;const S=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=S<=1?S:2-S;const _=(w+C)/2,A=w===0?2*g/(S+g):2*C/(w+C);return[y,A*100,_*100]},L.hsv.rgb=function(b){const y=b[0]/60,C=b[1]/100;let w=b[2]/100;const g=Math.floor(y)%6,S=y-Math.floor(y),_=255*w*(1-C),A=255*w*(1-C*S),m=255*w*(1-C*(1-S));switch(w*=255,g){case 0:return[w,m,_];case 1:return[A,w,_];case 2:return[_,w,m];case 3:return[_,A,w];case 4:return[m,_,w];case 5:return[w,_,A]}},L.hsv.hsl=function(b){const y=b[0],C=b[1]/100,w=b[2]/100,g=Math.max(w,.01);let S,_;_=(2-C)*w;const A=(2-C)*g;return S=C*g,S/=A<=1?A:2-A,S=S||0,_/=2,[y,S*100,_*100]},L.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let S;g>1&&(C/=g,w/=g);const _=Math.floor(6*y),A=1-w;S=6*y-_,_&1&&(S=1-S);const m=C+S*(A-C);let T,E,D;switch(_){default:case 6:case 0:T=A,E=m,D=C;break;case 1:T=m,E=A,D=C;break;case 2:T=C,E=A,D=m;break;case 3:T=C,E=m,D=A;break;case 4:T=m,E=C,D=A;break;case 5:T=A,E=C,D=m;break}return[T*255,E*255,D*255]},L.cmyk.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100,g=b[3]/100,S=1-Math.min(1,y*(1-g)+g),_=1-Math.min(1,C*(1-g)+g),A=1-Math.min(1,w*(1-g)+g);return[S*255,_*255,A*255]},L.xyz.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100;let g,S,_;return g=y*3.2406+C*-1.5372+w*-.4986,S=y*-.9689+C*1.8758+w*.0415,_=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*it(g,.4166666666666667)-.055:g*12.92,S=S>.0031308?1.055*it(S,.4166666666666667)-.055:S*12.92,_=_>.0031308?1.055*it(_,.4166666666666667)-.055:_*12.92,g=Math.min(Math.max(0,g),1),S=Math.min(Math.max(0,S),1),_=Math.min(Math.max(0,_),1),[g*255,S*255,_*255]},L.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?it(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?it(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?it(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,S=500*(y-C),_=200*(C-w);return[g,S,_]},L.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,S,_;S=(y+16)/116,g=C/500+S,_=S-w/200;const A=it(S,3),m=it(g,3),T=it(_,3);return S=A>.008856?A:(S-.13793103448275862)/7.787,g=m>.008856?m:(g-.13793103448275862)/7.787,_=T>.008856?T:(_-.13793103448275862)/7.787,g*=95.047,S*=100,_*=108.883,[g,S,_]},L.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const _=Math.sqrt(C*C+w*w);return[y,_,g]},L.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,S=C*Math.cos(g),_=C*Math.sin(g);return[y,S,_]},L.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let S=y===null?L.rgb.hsv(b)[2]:y;if(S=Math.round(S/50),S===0)return 30;let _=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return S===2&&(_+=60),_},L.hsv.ansi16=function(b){return L.rgb.ansi16(L.hsv.rgb(b),b[2])},L.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},L.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,S=(y>>2&1)*C*255;return[w,g,S]},L.ansi256.rgb=function(b){if(b>=232){const S=(b-232)*10+8;return[S,S,S]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},L.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},L.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(A=>A+A).join(""));const w=parseInt(C,16),g=w>>16&255,S=w>>8&255,_=w&255;return[g,S,_]},L.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),S=Math.min(Math.min(y,C),w),_=g-S;let A,m;return _<1?A=S/(1-_):A=0,_<=0?m=0:g===y?m=(C-w)/_%6:g===C?m=2+(w-y)/_:m=4+(y-C)/_,m/=6,m%=1,[m*360,_*100,A*100]},L.hsl.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=C<.5?2*y*C:2*y*(1-C);let g=0;return w<1&&(g=(C-.5*w)/(1-w)),[b[0],w*100,g*100]},L.hsv.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=y*C;let g=0;return w<1&&(g=(C-w)/(1-w)),[b[0],w*100,g*100]},L.hcg.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;if(C===0)return[w*255,w*255,w*255];const g=[0,0,0],S=y%1*6,_=S%1,A=1-_;let m=0;switch(Math.floor(S)){case 0:g[0]=1,g[1]=_,g[2]=0;break;case 1:g[0]=A,g[1]=1,g[2]=0;break;case 2:g[0]=0,g[1]=1,g[2]=_;break;case 3:g[0]=0,g[1]=A,g[2]=1;break;case 4:g[0]=_,g[1]=0,g[2]=1;break;default:g[0]=1,g[1]=0,g[2]=A}return m=(1-C)*w,[(C*g[0]+m)*255,(C*g[1]+m)*255,(C*g[2]+m)*255]},L.hcg.hsv=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);let g=0;return w>0&&(g=y/w),[b[0],g*100,w*100]},L.hcg.hsl=function(b){const y=b[1]/100,w=b[2]/100*(1-y)+.5*y;let g=0;return w>0&&w<.5?g=y/(2*w):w>=.5&&w<1&&(g=y/(2*(1-w))),[b[0],g*100,w*100]},L.hcg.hwb=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);return[b[0],(w-y)*100,(1-w)*100]},L.hwb.hcg=function(b){const y=b[1]/100,w=1-b[2]/100,g=w-y;let S=0;return g<1&&(S=(w-g)/(1-g)),[b[0],g*100,S*100]},L.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},L.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},L.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},L.gray.hsl=function(b){return[0,0,b[0]]},L.gray.hsv=L.gray.hsl,L.gray.hwb=function(b){return[0,100,b[0]]},L.gray.cmyk=function(b){return[0,0,0,b[0]]},L.gray.lab=function(b){return[b[0],0,0]},L.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},L.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}},734:(k,nt,N)=>{const q=N(659),z=N(507),L={},ht=Object.keys(q);function b(C){const w=function(...g){const S=g[0];return S==null?S:(S.length>1&&(g=S),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const S=g[0];if(S==null)return S;S.length>1&&(g=S);const _=C(g);if(typeof _=="object")for(let A=_.length,m=0;m<A;m++)_[m]=Math.round(_[m]);return _};return"conversion"in C&&(w.conversion=C.conversion),w}ht.forEach(C=>{L[C]={},Object.defineProperty(L[C],"channels",{value:q[C].channels}),Object.defineProperty(L[C],"labels",{value:q[C].labels});const w=z(C);Object.keys(w).forEach(S=>{const _=w[S];L[C][S]=y(_),L[C][S].raw=b(_)})}),k.exports=L},854:(k,nt,N)=>{var q=N(156),z=N(872),L=Object.hasOwnProperty,ht=Object.create(null);for(var b in q)L.call(q,b)&&(ht[q[b]]=b);var y=k.exports={to:{},get:{}};y.get=function(g){var S=g.substring(0,3).toLowerCase(),_,A;switch(S){case"hsl":_=y.get.hsl(g),A="hsl";break;case"hwb":_=y.get.hwb(g),A="hwb";break;default:_=y.get.rgb(g),A="rgb";break}return _?{model:A,value:_}:null},y.get.rgb=function(g){if(!g)return null;var S=/^#([a-f0-9]{3,4})$/i,_=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,A=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,m=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,T=/^(\w+)$/,E=[0,0,0,1],D,F,lt;if(D=g.match(_)){for(lt=D[2],D=D[1],F=0;F<3;F++){var Dt=F*2;E[F]=parseInt(D.slice(Dt,Dt+2),16)}lt&&(E[3]=parseInt(lt,16)/255)}else if(D=g.match(S)){for(D=D[1],lt=D[3],F=0;F<3;F++)E[F]=parseInt(D[F]+D[F],16);lt&&(E[3]=parseInt(lt+lt,16)/255)}else if(D=g.match(A)){for(F=0;F<3;F++)E[F]=parseInt(D[F+1],0);D[4]&&(D[5]?E[3]=parseFloat(D[4])*.01:E[3]=parseFloat(D[4]))}else if(D=g.match(m)){for(F=0;F<3;F++)E[F]=Math.round(parseFloat(D[F+1])*2.55);D[4]&&(D[5]?E[3]=parseFloat(D[4])*.01:E[3]=parseFloat(D[4]))}else return(D=g.match(T))?D[1]==="transparent"?[0,0,0,0]:L.call(q,D[1])?(E=q[D[1]],E[3]=1,E):null:null;for(F=0;F<3;F++)E[F]=C(E[F],0,255);return E[3]=C(E[3],0,1),E},y.get.hsl=function(g){if(!g)return null;var S=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,_=g.match(S);if(_){var A=parseFloat(_[4]),m=(parseFloat(_[1])%360+360)%360,T=C(parseFloat(_[2]),0,100),E=C(parseFloat(_[3]),0,100),D=C(isNaN(A)?1:A,0,1);return[m,T,E,D]}return null},y.get.hwb=function(g){if(!g)return null;var S=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,_=g.match(S);if(_){var A=parseFloat(_[4]),m=(parseFloat(_[1])%360+360)%360,T=C(parseFloat(_[2]),0,100),E=C(parseFloat(_[3]),0,100),D=C(isNaN(A)?1:A,0,1);return[m,T,E,D]}return null},y.to.hex=function(){var g=z(arguments);return"#"+w(g[0])+w(g[1])+w(g[2])+(g[3]<1?w(Math.round(g[3]*255)):"")},y.to.rgb=function(){var g=z(arguments);return g.length<4||g[3]===1?"rgb("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+")":"rgba("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+", "+g[3]+")"},y.to.rgb.percent=function(){var g=z(arguments),S=Math.round(g[0]/255*100),_=Math.round(g[1]/255*100),A=Math.round(g[2]/255*100);return g.length<4||g[3]===1?"rgb("+S+"%, "+_+"%, "+A+"%)":"rgba("+S+"%, "+_+"%, "+A+"%, "+g[3]+")"},y.to.hsl=function(){var g=z(arguments);return g.length<4||g[3]===1?"hsl("+g[0]+", "+g[1]+"%, "+g[2]+"%)":"hsla("+g[0]+", "+g[1]+"%, "+g[2]+"%, "+g[3]+")"},y.to.hwb=function(){var g=z(arguments),S="";return g.length>=4&&g[3]!==1&&(S=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+S+")"},y.to.keyword=function(g){return ht[g.slice(0,3)]};function C(g,S,_){return Math.min(Math.max(S,g),_)}function w(g){var S=Math.round(g).toString(16).toUpperCase();return S.length<2?"0"+S:S}},872:(k,nt,N)=>{"use strict";var q=N(195),z=Array.prototype.concat,L=Array.prototype.slice,ht=k.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var S=y[w];q(S)?C=z.call(C,L.call(S)):C.push(S)}return C};ht.wrap=function(b){return function(){return b(ht(arguments))}}}},mn={};function _t(k){var nt=mn[k];if(nt!==void 0)return nt.exports;var N=mn[k]={exports:{}};return $o[k](N,N.exports,_t),N.exports}_t.n=k=>{var nt=k&&k.__esModule?()=>k.default:()=>k;return _t.d(nt,{a:nt}),nt},_t.d=(k,nt)=>{for(var N in nt)_t.o(nt,N)&&!_t.o(k,N)&&Object.defineProperty(k,N,{enumerable:!0,get:nt[N]})},_t.o=(k,nt)=>Object.prototype.hasOwnProperty.call(k,nt),_t.r=k=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(k,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(k,"__esModule",{value:!0})};var ps={};(()=>{"use strict";_t.r(ps),_t.d(ps,{Chart:()=>Wo,createChart:()=>mp,generateCandlesData:()=>pp});function k(n){return typeof n=="function"}function nt(n){return k(n==null?void 0:n.lift)}function N(n){return function(t){if(nt(t))return t.lift(function(e){try{return n(e,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}var q=function(n,t){return q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])},q(n,t)};function z(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");q(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var L=function(){return L=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++){e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},L.apply(this,arguments)};function ht(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function w(n,t,e,s){function i(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(d){o(d)}}function l(h){try{c(s.throw(h))}catch(d){o(d)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,t||[])).next())})}function g(n,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,i,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(s=1,i&&(r=c[0]&2?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,i=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){e.label=c[1];break}if(c[0]===6&&e.label<r[1]){e.label=r[1],r=c;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(c);break}r[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],i=0}finally{s=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var S=Object.create?function(n,t,e,s){s===void 0&&(s=e);var i=Object.getOwnPropertyDescriptor(t,e);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,s,i)}:function(n,t,e,s){s===void 0&&(s=e),n[s]=t[e]};function _(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&S(t,n,e)}function A(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],s=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&s>=n.length&&(n=void 0),{value:n&&n[s++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var s=e.call(n),i,r=[],o;try{for(;(t===void 0||t-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return r}function T(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(m(arguments[t]));return n}function E(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var s=Array(n),i=0,t=0;t<e;t++)for(var r=arguments[t],o=0,a=r.length;o<a;o++,i++)s[i]=r[o];return s}function D(n,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,r;s<i;s++)(r||!(s in t))&&(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return n.concat(r||Array.prototype.slice.call(t))}function F(n){return this instanceof F?(this.v=n,this):new F(n)}function lt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=e.apply(n,t||[]),i,r=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(u){s[u]&&(i[u]=function(f){return new Promise(function(p,v){r.push([u,f,p,v])>1||a(u,f)})})}function a(u,f){try{l(s[u](f))}catch(p){d(r[0][3],p)}}function l(u){u.value instanceof F?Promise.resolve(u.value.v).then(c,h):d(r[0][2],u)}function c(u){a("next",u)}function h(u){a("throw",u)}function d(u,f){u(f),r.shift(),r.length&&a(r[0][0],r[0][1])}}function Dt(n){var t,e;return t={},s("next"),s("throw",function(i){throw i}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(i,r){t[i]=n[i]?function(o){return(e=!e)?{value:F(n[i](o)),done:i==="return"}:r?r(o):o}:r}}function Ft(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof A=="function"?A(n):n[Symbol.iterator](),e={},s("next"),s("throw"),s("return"),e[Symbol.asyncIterator]=function(){return this},e);function s(r){e[r]=n[r]&&function(o){return new Promise(function(a,l){o=n[r](o),i(a,l,o.done,o.value)})}}function i(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}function Fe(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var Ko=Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t};function vp(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.prototype.hasOwnProperty.call(n,e)&&S(t,n,e);return Ko(t,n),t}function bp(n){return n&&n.__esModule?n:{default:n}}function Cp(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)}function yp(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e}function wp(n,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?t===n:n.has(t)}function vn(n){var t=function(s){Error.call(s),s.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var ms=vn(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
6
+ (()=>{var rt=Math.pow;(()=>{var aa={156:(j=>{"use strict";j.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}),195:(j=>{j.exports=function(N){return!N||typeof N=="string"?!1:N instanceof Array||Array.isArray(N)||N.length>=0&&(N.splice instanceof Function||Object.getOwnPropertyDescriptor(N,N.length-1)&&N.constructor.name!=="String")}}),507:((j,it,N)=>{const K=N(659);function z(){const y={},C=Object.keys(K);for(let w=C.length,g=0;g<w;g++)y[C[g]]={distance:-1,parent:null};return y}function O(y){const C=z(),w=[y];for(C[y].distance=0;w.length;){const g=w.pop(),S=Object.keys(K[g]);for(let P=S.length,E=0;E<P;E++){const m=S[E],M=C[m];M.distance===-1&&(M.distance=C[g].distance+1,M.parent=g,w.unshift(m))}}return C}function ht(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=K[C[y].parent][y],S=C[y].parent;for(;C[S].parent;)w.unshift(C[S].parent),g=ht(K[C[S].parent][S],g),S=C[S].parent;return g.conversion=w,g}j.exports=function(y){const C=O(y),w={},g=Object.keys(C);for(let S=g.length,P=0;P<S;P++){const E=g[P];C[E].parent!==null&&(w[E]=b(E,C))}return w}}),520:((j,it,N)=>{const K=N(854),z=N(734),O=["keyword","gray","hex"],ht={};for(const m of Object.keys(z))ht[[...z[m].labels].sort().join("")]=m;const b={};function y(m,M){if(!(this instanceof y))return new y(m,M);if(M&&M in O&&(M=null),M&&!(M in z))throw new Error("Unknown model: "+M);let I,D;if(m==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(m instanceof y)this.model=m.model,this.color=[...m.color],this.valpha=m.valpha;else if(typeof m=="string"){const H=K.get(m);if(H===null)throw new Error("Unable to parse color from string: "+m);this.model=H.model,D=z[this.model].channels,this.color=H.value.slice(0,D),this.valpha=typeof H.value[D]=="number"?H.value[D]:1}else if(m.length>0){this.model=M||"rgb",D=z[this.model].channels;const H=Array.prototype.slice.call(m,0,D);this.color=E(H,D),this.valpha=typeof m[D]=="number"?m[D]:1}else if(typeof m=="number")this.model="rgb",this.color=[m>>16&255,m>>8&255,m&255],this.valpha=1;else{this.valpha=1;const H=Object.keys(m);"alpha"in m&&(H.splice(H.indexOf("alpha"),1),this.valpha=typeof m.alpha=="number"?m.alpha:0);const lt=H.sort().join("");if(!(lt in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(m));this.model=ht[lt];const{labels:Dt}=z[this.model],Ht=[];for(I=0;I<Dt.length;I++)Ht.push(m[Dt[I]]);this.color=E(Ht)}if(b[this.model])for(D=z[this.model].channels,I=0;I<D;I++){const H=b[this.model][I];H&&(this.color[I]=H(this.color[I]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}y.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(m){let M=this.model in K.to?this:this.rgb();M=M.round(typeof m=="number"?m:1);const I=M.valpha===1?M.color:[...M.color,this.valpha];return K.to[M.model](I)},percentString(m){const M=this.rgb().round(typeof m=="number"?m:1),I=M.valpha===1?M.color:[...M.color,this.valpha];return K.to.rgb.percent(I)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const m={},{channels:M}=z[this.model],{labels:I}=z[this.model];for(let D=0;D<M;D++)m[I[D]]=this.color[D];return this.valpha!==1&&(m.alpha=this.valpha),m},unitArray(){const m=this.rgb().color;return m[0]/=255,m[1]/=255,m[2]/=255,this.valpha!==1&&m.push(this.valpha),m},unitObject(){const m=this.rgb().object();return m.r/=255,m.g/=255,m.b/=255,this.valpha!==1&&(m.alpha=this.valpha),m},round(m){return m=Math.max(m||0,0),new y([...this.color.map(w(m)),this.valpha],this.model)},alpha(m){return m!==void 0?new y([...this.color,Math.max(0,Math.min(1,m))],this.model):this.valpha},red:g("rgb",0,S(255)),green:g("rgb",1,S(255)),blue:g("rgb",2,S(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,m=>(m%360+360)%360),saturationl:g("hsl",1,S(100)),lightness:g("hsl",2,S(100)),saturationv:g("hsv",1,S(100)),value:g("hsv",2,S(100)),chroma:g("hcg",1,S(100)),gray:g("hcg",2,S(100)),white:g("hwb",1,S(100)),wblack:g("hwb",2,S(100)),cyan:g("cmyk",0,S(100)),magenta:g("cmyk",1,S(100)),yellow:g("cmyk",2,S(100)),black:g("cmyk",3,S(100)),x:g("xyz",0,S(95.047)),y:g("xyz",1,S(100)),z:g("xyz",2,S(108.833)),l:g("lab",0,S(100)),a:g("lab",1),b:g("lab",2),keyword(m){return m!==void 0?new y(m):z[this.model].keyword(this.color)},hex(m){return m!==void 0?new y(m):K.to.hex(this.rgb().round().color)},hexa(m){if(m!==void 0)return new y(m);const M=this.rgb().round().color;let I=Math.round(this.valpha*255).toString(16).toUpperCase();return I.length===1&&(I="0"+I),K.to.hex(M)+I},rgbNumber(){const m=this.rgb().color;return(m[0]&255)<<16|(m[1]&255)<<8|m[2]&255},luminosity(){const m=this.rgb().color,M=[];for(const[I,D]of m.entries()){const H=D/255;M[I]=H<=.04045?H/12.92:rt((H+.055)/1.055,2.4)}return .2126*M[0]+.7152*M[1]+.0722*M[2]},contrast(m){const M=this.luminosity(),I=m.luminosity();return M>I?(M+.05)/(I+.05):(I+.05)/(M+.05)},level(m){const M=this.contrast(m);return M>=7?"AAA":M>=4.5?"AA":""},isDark(){const m=this.rgb().color;return(m[0]*2126+m[1]*7152+m[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const m=this.rgb();for(let M=0;M<3;M++)m.color[M]=255-m.color[M];return m},lighten(m){const M=this.hsl();return M.color[2]+=M.color[2]*m,M},darken(m){const M=this.hsl();return M.color[2]-=M.color[2]*m,M},saturate(m){const M=this.hsl();return M.color[1]+=M.color[1]*m,M},desaturate(m){const M=this.hsl();return M.color[1]-=M.color[1]*m,M},whiten(m){const M=this.hwb();return M.color[1]+=M.color[1]*m,M},blacken(m){const M=this.hwb();return M.color[2]+=M.color[2]*m,M},grayscale(){const m=this.rgb().color,M=m[0]*.3+m[1]*.59+m[2]*.11;return y.rgb(M,M,M)},fade(m){return this.alpha(this.valpha-this.valpha*m)},opaquer(m){return this.alpha(this.valpha+this.valpha*m)},rotate(m){const M=this.hsl();let I=M.color[0];return I=(I+m)%360,I=I<0?360+I:I,M.color[0]=I,M},mix(m,M){if(!m||!m.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof m);const I=m.rgb(),D=this.rgb(),H=M===void 0?.5:M,lt=2*H-1,Dt=I.alpha()-D.alpha(),Ht=((lt*Dt===-1?lt:(lt+Dt)/(1+lt*Dt))+1)/2,Xe=1-Ht;return y.rgb(Ht*I.red()+Xe*D.red(),Ht*I.green()+Xe*D.green(),Ht*I.blue()+Xe*D.blue(),I.alpha()*H+D.alpha()*(1-H))}};for(const m of Object.keys(z)){if(O.includes(m))continue;const{channels:M}=z[m];y.prototype[m]=function(...I){return this.model===m?new y(this):I.length>0?new y(I,m):new y([...P(z[this.model][m].raw(this.color)),this.valpha],m)},y[m]=function(...I){let D=I[0];return typeof D=="number"&&(D=E(I,M)),new y(D,m)}}function C(m,M){return Number(m.toFixed(M))}function w(m){return function(M){return C(M,m)}}function g(m,M,I){m=Array.isArray(m)?m:[m];for(const D of m)(b[D]||(b[D]=[]))[M]=I;return m=m[0],function(D){let H;return D!==void 0?(I&&(D=I(D)),H=this[m](),H.color[M]=D,H):(H=this[m]().color[M],I&&(H=I(H)),H)}}function S(m){return function(M){return Math.max(0,Math.min(m,M))}}function P(m){return Array.isArray(m)?m:[m]}function E(m,M){for(let I=0;I<M;I++)typeof m[I]!="number"&&(m[I]=0);return m}j.exports=y}),659:((j,it,N)=>{const K=N(156),z={};for(const b of Object.keys(K))z[K[b]]=b;const O={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};j.exports=O;for(const b of Object.keys(O)){if(!("channels"in O[b]))throw new Error("missing channels property: "+b);if(!("labels"in O[b]))throw new Error("missing channel labels property: "+b);if(O[b].labels.length!==O[b].channels)throw new Error("channel and label counts mismatch: "+b);const{channels:y,labels:C}=O[b];delete O[b].channels,delete O[b].labels,Object.defineProperty(O[b],"channels",{value:y}),Object.defineProperty(O[b],"labels",{value:C})}O.rgb.hsl=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(y,C,w),S=Math.max(y,C,w),P=S-g;let E,m;S===g?E=0:y===S?E=(C-w)/P:C===S?E=2+(w-y)/P:w===S&&(E=4+(y-C)/P),E=Math.min(E*60,360),E<0&&(E+=360);const M=(g+S)/2;return S===g?m=0:M<=.5?m=P/(S+g):m=P/(2-S-g),[E,m*100,M*100]},O.rgb.hsv=function(b){let y,C,w,g,S;const P=b[0]/255,E=b[1]/255,m=b[2]/255,M=Math.max(P,E,m),I=M-Math.min(P,E,m),D=function(H){return(M-H)/6/I+1/2};return I===0?(g=0,S=0):(S=I/M,y=D(P),C=D(E),w=D(m),P===M?g=w-C:E===M?g=.3333333333333333+y-w:m===M&&(g=.6666666666666666+C-y),g<0?g+=1:g>1&&(g-=1)),[g*360,S*100,M*100]},O.rgb.hwb=function(b){const y=b[0],C=b[1];let w=b[2];const g=O.rgb.hsl(b)[0],S=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,S*100,w*100]},O.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),S=(1-y-g)/(1-g)||0,P=(1-C-g)/(1-g)||0,E=(1-w-g)/(1-g)||0;return[S*100,P*100,E*100,g*100]};function ht(b,y){return rt(b[0]-y[0],2)+rt(b[1]-y[1],2)+rt(b[2]-y[2],2)}O.rgb.keyword=function(b){const y=z[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(K)){const S=K[g],P=ht(b,S);P<C&&(C=P,w=g)}return w},O.keyword.rgb=function(b){return K[b]},O.rgb.xyz=function(b){let y=b[0]/255,C=b[1]/255,w=b[2]/255;y=y>.04045?rt((y+.055)/1.055,2.4):y/12.92,C=C>.04045?rt((C+.055)/1.055,2.4):C/12.92,w=w>.04045?rt((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,S=y*.2126+C*.7152+w*.0722,P=y*.0193+C*.1192+w*.9505;return[g*100,S*100,P*100]},O.rgb.lab=function(b){const y=O.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?rt(g,.3333333333333333):7.787*g+.13793103448275862;const S=116*w-16,P=500*(C-w),E=200*(w-g);return[S,P,E]},O.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,S,P;if(C===0)return P=w*255,[P,P,P];w<.5?g=w*(1+C):g=w+C-w*C;const E=2*w-g,m=[0,0,0];for(let M=0;M<3;M++)S=y+.3333333333333333*-(M-1),S<0&&S++,S>1&&S--,6*S<1?P=E+(g-E)*6*S:2*S<1?P=g:3*S<2?P=E+(g-E)*(.6666666666666666-S)*6:P=E,m[M]=P*255;return m},O.hsl.hsv=function(b){const y=b[0];let C=b[1]/100,w=b[2]/100,g=C;const S=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=S<=1?S:2-S;const P=(w+C)/2,E=w===0?2*g/(S+g):2*C/(w+C);return[y,E*100,P*100]},O.hsv.rgb=function(b){const y=b[0]/60,C=b[1]/100;let w=b[2]/100;const g=Math.floor(y)%6,S=y-Math.floor(y),P=255*w*(1-C),E=255*w*(1-C*S),m=255*w*(1-C*(1-S));switch(w*=255,g){case 0:return[w,m,P];case 1:return[E,w,P];case 2:return[P,w,m];case 3:return[P,E,w];case 4:return[m,P,w];case 5:return[w,P,E]}},O.hsv.hsl=function(b){const y=b[0],C=b[1]/100,w=b[2]/100,g=Math.max(w,.01);let S,P;P=(2-C)*w;const E=(2-C)*g;return S=C*g,S/=E<=1?E:2-E,S=S||0,P/=2,[y,S*100,P*100]},O.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let S;g>1&&(C/=g,w/=g);const P=Math.floor(6*y),E=1-w;S=6*y-P,(P&1)!==0&&(S=1-S);const m=C+S*(E-C);let M,I,D;switch(P){default:case 6:case 0:M=E,I=m,D=C;break;case 1:M=m,I=E,D=C;break;case 2:M=C,I=E,D=m;break;case 3:M=C,I=m,D=E;break;case 4:M=m,I=C,D=E;break;case 5:M=E,I=C,D=m;break}return[M*255,I*255,D*255]},O.cmyk.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100,g=b[3]/100,S=1-Math.min(1,y*(1-g)+g),P=1-Math.min(1,C*(1-g)+g),E=1-Math.min(1,w*(1-g)+g);return[S*255,P*255,E*255]},O.xyz.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100;let g,S,P;return g=y*3.2406+C*-1.5372+w*-.4986,S=y*-.9689+C*1.8758+w*.0415,P=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*rt(g,.4166666666666667)-.055:g*12.92,S=S>.0031308?1.055*rt(S,.4166666666666667)-.055:S*12.92,P=P>.0031308?1.055*rt(P,.4166666666666667)-.055:P*12.92,g=Math.min(Math.max(0,g),1),S=Math.min(Math.max(0,S),1),P=Math.min(Math.max(0,P),1),[g*255,S*255,P*255]},O.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?rt(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,S=500*(y-C),P=200*(C-w);return[g,S,P]},O.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,S,P;S=(y+16)/116,g=C/500+S,P=S-w/200;const E=rt(S,3),m=rt(g,3),M=rt(P,3);return S=E>.008856?E:(S-.13793103448275862)/7.787,g=m>.008856?m:(g-.13793103448275862)/7.787,P=M>.008856?M:(P-.13793103448275862)/7.787,g*=95.047,S*=100,P*=108.883,[g,S,P]},O.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const P=Math.sqrt(C*C+w*w);return[y,P,g]},O.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,S=C*Math.cos(g),P=C*Math.sin(g);return[y,S,P]},O.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let S=y===null?O.rgb.hsv(b)[2]:y;if(S=Math.round(S/50),S===0)return 30;let P=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return S===2&&(P+=60),P},O.hsv.ansi16=function(b){return O.rgb.ansi16(O.hsv.rgb(b),b[2])},O.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},O.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,S=(y>>2&1)*C*255;return[w,g,S]},O.ansi256.rgb=function(b){if(b>=232){const S=(b-232)*10+8;return[S,S,S]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},O.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},O.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(E=>E+E).join(""));const w=parseInt(C,16),g=w>>16&255,S=w>>8&255,P=w&255;return[g,S,P]},O.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),S=Math.min(Math.min(y,C),w),P=g-S;let E,m;return P<1?E=S/(1-P):E=0,P<=0?m=0:g===y?m=(C-w)/P%6:g===C?m=2+(w-y)/P:m=4+(y-C)/P,m/=6,m%=1,[m*360,P*100,E*100]},O.hsl.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=C<.5?2*y*C:2*y*(1-C);let g=0;return w<1&&(g=(C-.5*w)/(1-w)),[b[0],w*100,g*100]},O.hsv.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=y*C;let g=0;return w<1&&(g=(C-w)/(1-w)),[b[0],w*100,g*100]},O.hcg.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;if(C===0)return[w*255,w*255,w*255];const g=[0,0,0],S=y%1*6,P=S%1,E=1-P;let m=0;switch(Math.floor(S)){case 0:g[0]=1,g[1]=P,g[2]=0;break;case 1:g[0]=E,g[1]=1,g[2]=0;break;case 2:g[0]=0,g[1]=1,g[2]=P;break;case 3:g[0]=0,g[1]=E,g[2]=1;break;case 4:g[0]=P,g[1]=0,g[2]=1;break;default:g[0]=1,g[1]=0,g[2]=E}return m=(1-C)*w,[(C*g[0]+m)*255,(C*g[1]+m)*255,(C*g[2]+m)*255]},O.hcg.hsv=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);let g=0;return w>0&&(g=y/w),[b[0],g*100,w*100]},O.hcg.hsl=function(b){const y=b[1]/100,w=b[2]/100*(1-y)+.5*y;let g=0;return w>0&&w<.5?g=y/(2*w):w>=.5&&w<1&&(g=y/(2*(1-w))),[b[0],g*100,w*100]},O.hcg.hwb=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);return[b[0],(w-y)*100,(1-w)*100]},O.hwb.hcg=function(b){const y=b[1]/100,w=1-b[2]/100,g=w-y;let S=0;return g<1&&(S=(w-g)/(1-g)),[b[0],g*100,S*100]},O.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},O.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},O.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},O.gray.hsl=function(b){return[0,0,b[0]]},O.gray.hsv=O.gray.hsl,O.gray.hwb=function(b){return[0,100,b[0]]},O.gray.cmyk=function(b){return[0,0,0,b[0]]},O.gray.lab=function(b){return[b[0],0,0]},O.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},O.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}}),734:((j,it,N)=>{const K=N(659),z=N(507),O={},ht=Object.keys(K);function b(C){const w=function(...g){const S=g[0];return S==null?S:(S.length>1&&(g=S),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const S=g[0];if(S==null)return S;S.length>1&&(g=S);const P=C(g);if(typeof P=="object")for(let E=P.length,m=0;m<E;m++)P[m]=Math.round(P[m]);return P};return"conversion"in C&&(w.conversion=C.conversion),w}ht.forEach(C=>{O[C]={},Object.defineProperty(O[C],"channels",{value:K[C].channels}),Object.defineProperty(O[C],"labels",{value:K[C].labels});const w=z(C);Object.keys(w).forEach(S=>{const P=w[S];O[C][S]=y(P),O[C][S].raw=b(P)})}),j.exports=O}),854:((j,it,N)=>{var K=N(156),z=N(872),O=Object.hasOwnProperty,ht=Object.create(null);for(var b in K)O.call(K,b)&&(ht[K[b]]=b);var y=j.exports={to:{},get:{}};y.get=function(g){var S=g.substring(0,3).toLowerCase(),P,E;switch(S){case"hsl":P=y.get.hsl(g),E="hsl";break;case"hwb":P=y.get.hwb(g),E="hwb";break;default:P=y.get.rgb(g),E="rgb";break}return P?{model:E,value:P}:null},y.get.rgb=function(g){if(!g)return null;var S=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,E=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,m=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,M=/^(\w+)$/,I=[0,0,0,1],D,H,lt;if(D=g.match(P)){for(lt=D[2],D=D[1],H=0;H<3;H++){var Dt=H*2;I[H]=parseInt(D.slice(Dt,Dt+2),16)}lt&&(I[3]=parseInt(lt,16)/255)}else if(D=g.match(S)){for(D=D[1],lt=D[3],H=0;H<3;H++)I[H]=parseInt(D[H]+D[H],16);lt&&(I[3]=parseInt(lt+lt,16)/255)}else if(D=g.match(E)){for(H=0;H<3;H++)I[H]=parseInt(D[H+1],0);D[4]&&(D[5]?I[3]=parseFloat(D[4])*.01:I[3]=parseFloat(D[4]))}else if(D=g.match(m)){for(H=0;H<3;H++)I[H]=Math.round(parseFloat(D[H+1])*2.55);D[4]&&(D[5]?I[3]=parseFloat(D[4])*.01:I[3]=parseFloat(D[4]))}else return(D=g.match(M))?D[1]==="transparent"?[0,0,0,0]:O.call(K,D[1])?(I=K[D[1]],I[3]=1,I):null:null;for(H=0;H<3;H++)I[H]=C(I[H],0,255);return I[3]=C(I[3],0,1),I},y.get.hsl=function(g){if(!g)return null;var S=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var E=parseFloat(P[4]),m=(parseFloat(P[1])%360+360)%360,M=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),D=C(isNaN(E)?1:E,0,1);return[m,M,I,D]}return null},y.get.hwb=function(g){if(!g)return null;var S=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var E=parseFloat(P[4]),m=(parseFloat(P[1])%360+360)%360,M=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),D=C(isNaN(E)?1:E,0,1);return[m,M,I,D]}return null},y.to.hex=function(){var g=z(arguments);return"#"+w(g[0])+w(g[1])+w(g[2])+(g[3]<1?w(Math.round(g[3]*255)):"")},y.to.rgb=function(){var g=z(arguments);return g.length<4||g[3]===1?"rgb("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+")":"rgba("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+", "+g[3]+")"},y.to.rgb.percent=function(){var g=z(arguments),S=Math.round(g[0]/255*100),P=Math.round(g[1]/255*100),E=Math.round(g[2]/255*100);return g.length<4||g[3]===1?"rgb("+S+"%, "+P+"%, "+E+"%)":"rgba("+S+"%, "+P+"%, "+E+"%, "+g[3]+")"},y.to.hsl=function(){var g=z(arguments);return g.length<4||g[3]===1?"hsl("+g[0]+", "+g[1]+"%, "+g[2]+"%)":"hsla("+g[0]+", "+g[1]+"%, "+g[2]+"%, "+g[3]+")"},y.to.hwb=function(){var g=z(arguments),S="";return g.length>=4&&g[3]!==1&&(S=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+S+")"},y.to.keyword=function(g){return ht[g.slice(0,3)]};function C(g,S,P){return Math.min(Math.max(S,g),P)}function w(g){var S=Math.round(g).toString(16).toUpperCase();return S.length<2?"0"+S:S}}),872:((j,it,N)=>{"use strict";var K=N(195),z=Array.prototype.concat,O=Array.prototype.slice,ht=j.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var S=y[w];K(S)?C=z.call(C,O.call(S)):C.push(S)}return C};ht.wrap=function(b){return function(){return b(ht(arguments))}}})},wn={};function Pt(j){var it=wn[j];if(it!==void 0)return it.exports;var N=wn[j]={exports:{}};return aa[j](N,N.exports,Pt),N.exports}Pt.n=j=>{var it=j&&j.__esModule?()=>j.default:()=>j;return Pt.d(it,{a:it}),it},Pt.d=(j,it)=>{for(var N in it)Pt.o(it,N)&&!Pt.o(j,N)&&Object.defineProperty(j,N,{enumerable:!0,get:it[N]})},Pt.o=(j,it)=>Object.prototype.hasOwnProperty.call(j,it),Pt.r=j=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(j,"__esModule",{value:!0})};var _s={};(()=>{"use strict";Pt.r(_s),Pt.d(_s,{Chart:()=>ea,createChart:()=>Np,generateCandlesData:()=>Yp});function j(n){return typeof n=="function"}function it(n){return j(n==null?void 0:n.lift)}function N(n){return function(t){if(it(t))return t.lift(function(e){try{return n(e,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}var K=function(n,t){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])},K(n,t)};function z(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");K(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var O=function(){return O=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++){e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},O.apply(this,arguments)};function ht(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function w(n,t,e,s){function i(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(d){o(d)}}function l(h){try{c(s.throw(h))}catch(d){o(d)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,t||[])).next())})}function g(n,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,i,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(s=1,i&&(r=c[0]&2?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,i=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){e.label=c[1];break}if(c[0]===6&&e.label<r[1]){e.label=r[1],r=c;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(c);break}r[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],i=0}finally{s=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var S=Object.create?(function(n,t,e,s){s===void 0&&(s=e);var i=Object.getOwnPropertyDescriptor(t,e);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,s,i)}):(function(n,t,e,s){s===void 0&&(s=e),n[s]=t[e]});function P(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&S(t,n,e)}function E(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],s=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&s>=n.length&&(n=void 0),{value:n&&n[s++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var s=e.call(n),i,r=[],o;try{for(;(t===void 0||t-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return r}function M(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(m(arguments[t]));return n}function I(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var s=Array(n),i=0,t=0;t<e;t++)for(var r=arguments[t],o=0,a=r.length;o<a;o++,i++)s[i]=r[o];return s}function D(n,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,r;s<i;s++)(r||!(s in t))&&(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return n.concat(r||Array.prototype.slice.call(t))}function H(n){return this instanceof H?(this.v=n,this):new H(n)}function lt(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=e.apply(n,t||[]),i,r=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(u){s[u]&&(i[u]=function(f){return new Promise(function(p,v){r.push([u,f,p,v])>1||a(u,f)})})}function a(u,f){try{l(s[u](f))}catch(p){d(r[0][3],p)}}function l(u){u.value instanceof H?Promise.resolve(u.value.v).then(c,h):d(r[0][2],u)}function c(u){a("next",u)}function h(u){a("throw",u)}function d(u,f){u(f),r.shift(),r.length&&a(r[0][0],r[0][1])}}function Dt(n){var t,e;return t={},s("next"),s("throw",function(i){throw i}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(i,r){t[i]=n[i]?function(o){return(e=!e)?{value:H(n[i](o)),done:i==="return"}:r?r(o):o}:r}}function Ht(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof E=="function"?E(n):n[Symbol.iterator](),e={},s("next"),s("throw"),s("return"),e[Symbol.asyncIterator]=function(){return this},e);function s(r){e[r]=n[r]&&function(o){return new Promise(function(a,l){o=n[r](o),i(a,l,o.done,o.value)})}}function i(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}function Xe(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var la=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t};function Wp(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.prototype.hasOwnProperty.call(n,e)&&S(t,n,e);return la(t,n),t}function zp(n){return n&&n.__esModule?n:{default:n}}function Vp(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)}function Up(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e}function Gp(n,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?t===n:n.has(t)}function Sn(n){var t=function(s){Error.call(s),s.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Ps=Sn(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
7
7
  `+e.map(function(s,i){return i+1+") "+s.toString()}).join(`
8
- `):"",this.name="UnsubscriptionError",this.errors=e}});function He(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ae=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,s,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=A(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(v){t={error:v}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(k(h))try{h()}catch(v){r=v instanceof ms?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=A(d),f=u.next();!f.done;f=u.next()){var p=f.value;try{yn(p)}catch(v){r=r!=null?r:[],v instanceof ms?r=D(D([],m(r)),m(v.errors)):r.push(v)}}}catch(v){s={error:v}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}if(r)throw new ms(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)yn(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&He(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&He(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),bn=ae.EMPTY;function Cn(n){return n instanceof ae||n&&"closed"in n&&k(n.remove)&&k(n.add)&&k(n.unsubscribe)}function yn(n){k(n)?n():n.unsubscribe()}var qt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ke={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=ke.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,D([n,t],m(e))):setTimeout.apply(void 0,D([n,t],m(e)))},clearTimeout:function(n){var t=ke.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function wn(n){ke.setTimeout(function(){var t=qt.onUnhandledError;if(t)t(n);else throw n})}function Sn(){}var qo=function(){return vs("C",void 0,void 0)}();function Jo(n){return vs("E",void 0,n)}function Qo(n){return vs("N",n,void 0)}function vs(n,t,e){return{kind:n,value:t,error:e}}var Jt=null;function je(n){if(qt.useDeprecatedSynchronousErrorHandling){var t=!Jt;if(t&&(Jt={errorThrown:!1,error:null}),n(),t){var e=Jt,s=e.errorThrown,i=e.error;if(Jt=null,s)throw i}}else n()}function ta(n){qt.useDeprecatedSynchronousErrorHandling&&Jt&&(Jt.errorThrown=!0,Jt.error=n)}var bs=function(n){z(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,Cn(e)&&e.add(s)):s.destination=ia,s}return t.create=function(e,s,i){return new ye(e,s,i)},t.prototype.next=function(e){this.isStopped?ys(Qo(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?ys(Jo(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?ys(qo,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ae),ea=Function.prototype.bind;function Cs(n,t){return ea.call(n,t)}var sa=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(s){Ye(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Ye(s)}else Ye(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Ye(e)}},n}(),ye=function(n){z(t,n);function t(e,s,i){var r=n.call(this)||this,o;if(k(e)||!e)o={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:i!=null?i:void 0};else{var a;r&&qt.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&Cs(e.next,a),error:e.error&&Cs(e.error,a),complete:e.complete&&Cs(e.complete,a)}):o=e}return r.destination=new sa(o),r}return t}(bs);function Ye(n){qt.useDeprecatedSynchronousErrorHandling?ta(n):wn(n)}function na(n){throw n}function ys(n,t){var e=qt.onStoppedNotification;e&&ke.setTimeout(function(){return e(n,t)})}var ia={closed:!0,next:Sn,error:na,complete:Sn};function mt(n,t,e,s,i){return new ra(n,t,e,s,i)}var ra=function(n){z(t,n);function t(e,s,i,r,o,a){var l=n.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;n.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(bs);function dt(n,t){return N(function(e,s){var i=0;e.subscribe(mt(s,function(r){s.next(n.call(t,r,i++))}))})}var xn=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function Pn(n){return k(n==null?void 0:n.then)}var ws=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function le(n){return n}function Sp(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return _n(n)}function _n(n){return n.length===0?le:n.length===1?n[0]:function(e){return n.reduce(function(s,i){return i(s)},e)}}var vt=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,s){var i=this,r=aa(t)?t:new ye(t,e,s);return je(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var s=this;return e=Tn(e),new e(function(i,r){var o=new ye({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});s.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[ws]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _n(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Tn(t),new t(function(s,i){var r;e.subscribe(function(o){return r=o},function(o){return i(o)},function(){return s(r)})})},n.create=function(t){return new n(t)},n}();function Tn(n){var t;return(t=n!=null?n:qt.Promise)!==null&&t!==void 0?t:Promise}function oa(n){return n&&k(n.next)&&k(n.error)&&k(n.complete)}function aa(n){return n&&n instanceof bs||oa(n)&&Cn(n)}function Mn(n){return k(n[ws])}function An(n){return Symbol.asyncIterator&&k(n==null?void 0:n[Symbol.asyncIterator])}function En(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function la(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var In=la();function Dn(n){return k(n==null?void 0:n[In])}function Ln(n){return lt(this,arguments,function(){var e,s,i,r;return g(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,F(e.read())];case 3:return s=o.sent(),i=s.value,r=s.done,r?[4,F(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,F(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function On(n){return k(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof vt)return n;if(n!=null){if(Mn(n))return ca(n);if(xn(n))return ha(n);if(Pn(n))return da(n);if(An(n))return Bn(n);if(Dn(n))return ua(n);if(On(n))return fa(n)}throw En(n)}function ca(n){return new vt(function(t){var e=n[ws]();if(k(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ha(n){return new vt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function da(n){return new vt(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,wn)})}function ua(n){return new vt(function(t){var e,s;try{for(var i=A(n),r=i.next();!r.done;r=i.next()){var o=r.value;if(t.next(o),t.closed)return}}catch(a){e={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(e)throw e.error}}t.complete()})}function Bn(n){return new vt(function(t){ga(n,t).catch(function(e){return t.error(e)})})}function fa(n){return Bn(Ln(n))}function ga(n,t){var e,s,i,r;return w(this,void 0,void 0,function(){var o,a;return g(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=Ft(n),l.label=1;case 1:return[4,e.next()];case 2:if(s=l.sent(),!!s.done)return[3,4];if(o=s.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),s&&!s.done&&(r=e.return)?[4,r.call(e)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Ht(n,t,e,s,i){s===void 0&&(s=0),i===void 0&&(i=!1);var r=t.schedule(function(){e(),i?n.add(this.schedule(null,s)):this.unsubscribe()},s);if(n.add(r),!i)return r}function pa(n,t,e,s,i,r,o,a){var l=[],c=0,h=0,d=!1,u=function(){d&&!l.length&&!c&&t.complete()},f=function(v){return c<s?p(v):l.push(v)},p=function(v){r&&t.next(v),c++;var x=!1;Lt(e(v,h++)).subscribe(mt(t,function(P){i==null||i(P),r?f(P):t.next(P)},function(){x=!0},void 0,function(){if(x)try{c--;for(var P=function(){var I=l.shift();o?Ht(t,o,function(){return p(I)}):p(I)};l.length&&c<s;)P();u()}catch(I){t.error(I)}}))};return n.subscribe(mt(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Rn(n,t,e){return e===void 0&&(e=1/0),k(t)?Rn(function(s,i){return dt(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return pa(s,i,n,e)}))}function Fn(n){return n===void 0&&(n=1/0),Rn(le,n)}var Hn=new vt(function(n){return n.complete()});function xp(n){return n?ma(n):Hn}function ma(n){return new Observable(function(t){return n.schedule(function(){return t.complete()})})}function kn(n){return n&&k(n.schedule)}function Ss(n){return n[n.length-1]}function va(n){return k(Ss(n))?n.pop():void 0}function Ne(n){return kn(Ss(n))?n.pop():void 0}function ba(n,t){return typeof Ss(n)=="number"?n.pop():t}function jn(n,t){return t===void 0&&(t=0),N(function(e,s){e.subscribe(mt(s,function(i){return Ht(s,n,function(){return s.next(i)},t)},function(){return Ht(s,n,function(){return s.complete()},t)},function(i){return Ht(s,n,function(){return s.error(i)},t)}))})}function Yn(n,t){return t===void 0&&(t=0),N(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function Ca(n,t){return Lt(n).pipe(Yn(t),jn(t))}function ya(n,t){return Lt(n).pipe(Yn(t),jn(t))}function wa(n,t){return new vt(function(e){var s=0;return t.schedule(function(){s===n.length?e.complete():(e.next(n[s++]),e.closed||this.schedule())})})}function Sa(n,t){return new vt(function(e){var s;return Ht(e,t,function(){s=n[In](),Ht(e,t,function(){var i,r,o;try{i=s.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return k(s==null?void 0:s.return)&&s.return()}})}function Nn(n,t){if(!n)throw new Error("Iterable cannot be null");return new vt(function(e){Ht(e,t,function(){var s=n[Symbol.asyncIterator]();Ht(e,t,function(){s.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function xa(n,t){return Nn(Ln(n),t)}function Pa(n,t){if(n!=null){if(Mn(n))return Ca(n,t);if(xn(n))return wa(n,t);if(Pn(n))return ya(n,t);if(An(n))return Nn(n,t);if(Dn(n))return Sa(n,t);if(On(n))return xa(n,t)}throw En(n)}function Xe(n,t){return t?Pa(n,t):Lt(n)}function bt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ne(n),s=ba(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):Fn(s)(Xe(i,e)):Hn}var _a=vn(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),R=function(n){z(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var s=new Xn(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new _a},t.prototype.next=function(e){var s=this;je(function(){var i,r;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=A(s.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(e)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var s=this;je(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var i=s.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;je(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var s=e.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var s=this,i=this,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?bn:(this.currentObservers=null,a.push(e),new ae(function(){s.currentObservers=null,He(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,i=s.hasError,r=s.thrownError,o=s.isStopped;i?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new vt;return e.source=this,e},t.create=function(e,s){return new Xn(e,s)},t}(vt),Xn=function(n){z(t,n);function t(e,s){var i=n.call(this)||this;return i.destination=e,i.source=s,i}return t.prototype.next=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.next)===null||i===void 0||i.call(s,e)},t.prototype.error=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.error)===null||i===void 0||i.call(s,e)},t.prototype.complete=function(){var e,s;(s=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||s===void 0||s.call(e)},t.prototype._subscribe=function(e){var s,i;return(i=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&i!==void 0?i:bn},t}(R),ft=function(n){z(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t}(R);let xs=!1,Ps=0;const ze=new Map,_s=new Map,zn=()=>{xs||(xs=!0,Ps=requestAnimationFrame(()=>{_s.forEach((n,t)=>{n(),_s.delete(t)}),ze.forEach((n,t)=>{n(),ze.delete(t)}),xs=!1}))},Wn=(n,t)=>{ze.set(n,t),zn()},Ta=n=>{ze.delete(n)},we=(n,t)=>{_s.set(n,t),zn()};function yt(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}var Ma=Math.pow;const We=14,Ve=[];for(let n=0;n<We+1;n++)Ve.push(Ma(10,n));const Ts=5e-13;class ut{static roundToNearest(t,e){return isFinite(t)?ut.isZero(t)?0:(t>0?t+=Ts:t<0&&(t-=Ts),ut.roundDecimal(Math.round(ut.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return ut.roundDecimal(Math.ceil(t/e))*e}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const e=Math.sign(t),s=Math.abs(t),i=Math.min(We,We-1-Math.floor(Math.log10(s)));for(let r=i;r>=0;r--){const o=Math.floor(Ve[r]*s+.5);if(o<Ve[We])return e*o/Ve[r]}return Math.round(t)}static makeDecimal(t,e,s,i){if(!isFinite(t))return"";if(isFinite(t)){let r=t.toFixed(e);if(!i)return s?r.replace(".",s):r;if(s===i)throw new Error("Grouping symbol cannot be the same as decimal separator.");const o=r.split(".");let a=o[0];const l=o[1];return Math.abs(t)>=1e3&&(a=a.replace(RegExp("\\d(?=(\\d{3})+$)","g"),`$&${i}`)),l?(r=[a,l].join(s),r):a}return""}static compare(t,e,s){return t>e+s?1:t<e-s?-1:(isNaN(t)?1:0)-(isNaN(e)?1:0)}static isZero(t){return ut.compare(t,0,Ts)===0}static cutNumber(t,e,s=0){return{K:r=>r/1e3,M:r=>r/1e6}[e](t).toFixed(s)+e}static isExponential(t){return/\de(\-|\+)\d/.test(t.toString())}}function Aa(n,t,e){const s=n/t;return s>=e||s<=1/e}function Ms(n,t,e){return Math.max(t,Math.min(n,e))}function Ea(n){return 1-(Math.pow(2,-5*n)-.0009765625)*1.0009775171065494}function Se(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const rt=n=>~~n,Ia=n=>~~(n+1),xe=n=>~~(n+.5),Da=(n,t)=>n>>t;function Pp(n){if(!Number.isFinite(n))throw new Error("Input must be a finite number.");const t=n.toString();return t.includes(".")?t.split(".")[1].length:0}class As{constructor(t,e){this.animationTimeLeft=0,this.onTickFunction=e,this.animationTime=t.duration,this.animationStartTime=Date.now(),this.animationInProgress=!0}tick(){var t;Date.now()>this.animationStartTime+this.animationTime&&(this.animationInProgress=!1),(t=this.onTickFunction)==null||t.call(this)}getProgress(){return Math.min((Date.now()-this.animationStartTime)/this.animationTime,1)}finishAnimation(){this.animationInProgress=!1,this.animationStartTime=0}}var La=_t(520),Ot=_t.n(La);class Oa extends As{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Ot().rgb(i.color),i.initialAlpha=i.rgbColor.valpha,i.currentAnimationColor=i.rgbColor})}tick(){super.tick(),this.colorConfigs.forEach(t=>{if(t.initialAlpha===void 0||t.rgbColor===void 0)return;const e=t.initialAlpha*(t.type==="fading"?1-this.getProgress():this.getProgress());t.currentAnimationColor=t.rgbColor.alpha(e)})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){const t=Ms(Date.now()-this.animationStartTime,0,this.animationTime);this.animationStartTime=Date.now()-this.animationTime+t,this.colorConfigs.forEach(e=>{e.type=e.type==="fading"?"appearing":"fading"})}}class Ba extends As{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Ot().rgb(i.startColor),i.rgbEndColor=Ot().rgb(i.endColor),i.currentAnimationColor=i.type==="appearing"?i.rgbStartColor:i.rgbEndColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{const e=1-this.animationTimeLeft/this.animationTime;!t.rgbStartColor||!t.rgbEndColor||(t.type==="fading"?t.currentAnimationColor=this.calculateTransitionColor(t.rgbEndColor,t.rgbStartColor,e):t.type==="appearing"&&(t.currentAnimationColor=this.calculateTransitionColor(t.rgbStartColor,t.rgbEndColor,e)))})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){this.animationTimeLeft=Math.max(this.animationTime-this.animationTimeLeft,1),this.colorConfigs.forEach(t=>{t.type==="fading"?t.type="appearing":t.type="fading"})}moveToLastTick(){this.animationTimeLeft=1}calculateTransitionColor(t,e,s){const i=t.red()-(t.red()-e.red())*s,r=t.green()-(t.green()-e.green())*s,o=t.blue()-(t.blue()-e.blue())*s;return Ot().rgb(i,r,o)}}class Ra extends As{constructor(t,e,s){var i;super(e,s),this.viewportModel=t,this.animationConfig=e,this.id=yt(),this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.easingFn=(i=e.easingFn)!=null?i:Ea}tick(){if(super.tick(),this.animationInProgress){const t=this.easingFn(this.getProgress()),e=this.xStart+(this.animationConfig.targetXStart-this.xStart)*t,s=this.xEnd+(this.animationConfig.targetXEnd-this.xEnd)*t,i=this.yStart+(this.animationConfig.targetYStart-this.yStart)*t,r=this.yEnd+(this.animationConfig.targetYEnd-this.yEnd)*t,o=this.zoomX+(this.animationConfig.targetZoomX-this.zoomX)*t,a=this.zoomY+(this.animationConfig.targetZoomY-this.zoomY)*t;this.viewportModel.apply({xStart:e,xEnd:s,yStart:i,yEnd:r,zoomX:o,zoomY:a,inverseY:this.viewportModel.inverseY})}}finishAnimation(){super.finishAnimation(),this.viewportModel.apply({xStart:this.animationConfig.targetXStart,xEnd:this.animationConfig.targetXEnd,yStart:this.animationConfig.targetYStart,yEnd:this.animationConfig.targetYEnd,zoomX:this.animationConfig.targetZoomX,zoomY:this.animationConfig.targetZoomY,inverseY:this.viewportModel.inverseY})}}var Fa=Object.defineProperty,Ha=Object.defineProperties,ka=Object.getOwnPropertyDescriptors,Vn=Object.getOwnPropertySymbols,ja=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable,Un=(n,t,e)=>t in n?Fa(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Na=(n,t)=>{for(var e in t||(t={}))ja.call(t,e)&&Un(n,e,t[e]);if(Vn)for(var e of Vn(t))Ya.call(t,e)&&Un(n,e,t[e]);return n},Xa=(n,t)=>Ha(n,ka(t));const Gn=400,Ue="VIEWPORT_ANIMATION";class za{constructor(t){this.animations={},this.animationInProgressSubject=new ft(!1),this.animFrameId=`canvas_animation_${yt()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=Ue,i){const r=new Ra(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new Oa(Xa(Na({},i),{duration:i&&i.duration||Gn}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Gn,i){const r=new Ba({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0)}processAnimation(){we(this.animFrameId,()=>this.tick())}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():queueMicrotask(()=>{this.processAnimation(),this.eventBus.fireDraw()})}stopInterval(){Ta(this.animFrameId)}}function Et(n,t){return t===void 0&&(t=le),n=n!=null?n:Wa,N(function(e,s){var i,r=!0;e.subscribe(mt(s,function(o){var a=t(o);(r||!n(i,a))&&(r=!1,i=a,s.next(o))}))})}function Wa(n,t){return n===t}function Va(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Es(n){return n}function Zn(n){return n!=null}const _p=()=>{};function Tp(n){return n!=null}function Ua(n,t,e=Ga,s=!0){const i=n.filter(r=>t.some(o=>e(r,o)));return s?i.filter((r,o,a)=>a.indexOf(r)===o):i}const $n=(n,t)=>{const e=t.slice().filter(s=>n.find(i=>i===s));return n.map(s=>{var i;return t.indexOf(s)>=0&&(i=e.shift())!=null?i:s})},Ga=(n,t)=>n===t,Mp=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),Za=(n,t)=>n===t,Kn=(n,t,e=Za)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function Ap(n,t,e){const s=n.slice(),i=s[t];return s.splice(t,1),s.splice(e,0,i),s}function Is(n,t,e){const s=n.length,i=Ms(t,0,s-1),r=Ms(e,0,s-1),o=n[i];return n.splice(i,1),n.splice(r,0,o),n}function Ep(n,t,e){const s=n.slice(),i=s.findIndex(t);return i!==-1&&(s.splice(i,1),s.splice(i,0,e)),s}const Ip=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},Dp=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),Lp=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),Op=n=>Array.isArray(n[0]),qn=n=>Array.isArray(n[0])?n:[n],$a=(n,t,e)=>{const s=[];let i=0;for(const r of n){const o=Math.max(t-i,0),a=Math.max(e-i,-1),l=r.slice(o,a+1);l.length>0&&s.push(l),i+=r.length}return s},Ka=(n,t)=>n>=0?t[n]:t[t.length+n],Ct=n=>Array.prototype.flat?n.flat():Pe(n,Es),Pe=(n,t)=>{if(Array.prototype.flatMap)return n.flatMap(t);const e=[];for(let s=0;s<n.length;s++){const i=n[s];e.push(...t(i,s,n))}return e};function Bt(n,t,e){const s=e!=null?e:Es;return!n.length||t!==t?{index:-1,exact:!0}:Ds(n,t,0,n.length,s)}function Ds(n,t,e,s,i){const r=Da(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Ds(n,t,e,r,i):Ds(n,t,r,s,i)}function wt(n){if(n&&n.length)return n[n.length-1]}function qa(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Ja(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ce(n){if(n)return n[0]}function Qa(n){function t(e,s){const i=n(s);return i==null||!isFinite(i)?e:[Math.max(e[0],i),Math.min(e[1],i)]}return function(e){const s=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,s):s}}function tl(n,t,e,s=()=>0){const i=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])<=a?l=h+1:c=h-1}return c},r=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])>=a?c=h-1:l=h+1}return l};return n.slice(r(n,t),i(n,e)+1)}let Ls;const kt=()=>(Ls||(Ls=!!navigator.userAgent.match(/Android|iPhone|Opera Mini/)||!1),Ls),el=1.33;function Jn(n,t){let e="";t.textStyle&&(t.textStyle.italic&&(e+="italic "),t.textStyle.bold&&(e+="bold ")),n.font=e+(t.textSize||12)+" "+(t.textFontFamily||"monospace"),n.fillStyle=t.textFill||"#FFFFFF",t.rtl?n.textAlign="right":n.textAlign="start"}function Ge(n,t=!0){const e=n.font.match(/(\d+.)?\d+(px|pt)/gi);let s="10px";return e&&e.length&&(e[0].includes("pt")?s=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":s=e[0]),t?parseInt(s,10)*el:parseInt(s,10)}function Qn(n,t,e){n.save(),Jn(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(o=>n.measureText(o).width))),i=Ge(n),r=i*t.length;return n.restore(),[s,r,i]}function ti(n){return(n||"").split(/\r\n|\r|\n/)}function sl(n,t,e,s,i){n.save();const[r,,o]=Qn(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=nl(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&il(n,a,f,s+o*l,(h=i.textFill)!=null?h:"",(d=i.textSize)!=null?d:""),n.fillText(a,f,s+o*l)}),n.restore()}function nl(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function il(n,t,e,s,i,r){n.save();const o=n.measureText(t).width,a=e,l=e+o,c=s+2,h=c;let d=parseInt(r,10)/15;d<1&&(d=1),n.beginPath(),n.strokeStyle=i,n.lineWidth=d,n.moveTo(a,c),n.lineTo(l,h),n.stroke(),n.restore()}function Bp(n){return`${n}px`}function Qt(n,t,e){const s=Ot().rgb(n).array(),i=s[0],r=s[1],o=s[2];return(i*299+r*587+o*114)/1e3<128?t:e}function rl(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=ei(t,i.dateFormat,e),a=ti(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=Qn(n,a,l);return[c+r.x*2,h+r.y*2]}function ei(n,t,e){return e(t)(n).split(" ").join(`
9
- `)}const si={};function jt(n,t){let e=si[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,si[n]=e,t.restore()),e}const ni=new Map;function Tt(n,t,e){const s=e+n;let i=ni.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,ni.set(s,i),t.restore()),i}function Mt(n,t,e=ii){function s(i,r){for(const o in r)o in i?typeof i[o]=="object"&&i[o]!==null&&!Array.isArray(i[o])?s(i[o],r[o]):e!=null&&e.overrideExisting&&(i[o]=r[o]):e!=null&&e.addIfMissing&&(i[o]=r[o]);return i}return s(n,t)}function Rp(n,t,e,s=!1){!n||!t||t.length===0||t.forEach(i=>{const r=e(i),o=n.findIndex(a=>e(a)===r);o===-1?n.push(i):s?Mt(n[o],i,{overrideExisting:!0,addIfMissing:!0}):n.splice(o,1,i)})}const ii={overrideExisting:!1,addIfMissing:!0};function ol(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){const s=n.charCodeAt(e);t=(t<<5)-t+s,t|=0}return t}const Os=1,al=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),ri=(n,t)=>`${n}_${ol(t.toString())}`;function Ze(n,t){return t===n?"none":t>n?"up":"down"}function ll(n,t){return t>n?"up":"down"}function cl(n,t,e=!1){const{id:s,expansion:i,impVolatility:r,vwap:o,typicalPrice:a,volume:l,timestamp:c}=n;let h=n.hi,d=n.lo,u=n.open;const f=n.close;e&&(h=f,d=f,u=f);let p=n.idx;return t!==void 0&&(p=t),{id:s,hi:h,lo:d,open:u,close:f,timestamp:c,volume:l,expansion:i,idx:p,impVolatility:r,vwap:o,typicalPrice:a}}var hl=Object.defineProperty,oi=Object.getOwnPropertySymbols,dl=Object.prototype.hasOwnProperty,ul=Object.prototype.propertyIsEnumerable,ai=(n,t,e)=>t in n?hl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fl=(n,t)=>{for(var e in t||(t={}))dl.call(t,e)&&ai(n,e,t[e]);if(oi)for(var e of oi(t))ul.call(t,e)&&ai(n,e,t[e]);return n};const li="Open Sans Semibold, sans-serif",gl=null,pl=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],Fp=n=>gl.find(t=>t===n)!==void 0,$e=()=>({devexpertsPromoLink:!0,useUTCTimeOverride:!1,shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rtl:!1,intlFormatter:{decimalSeparator:".",thousandsSeparator:""},scale:{keepZoomXOnYAxisChange:!0,auto:!0,zoomToCursor:!1,lockPriceToBarRatio:!1,autoScaleOnCandles:!0,autoScaleDisableOnDrag:{enabled:!0,edgeAngle:Math.PI/15,yDiff:80},inverse:!1,zoomSensitivity:{wheel:.25},defaultViewportItems:100,disableAnimations:!1},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,components:{chart:{type:"candle",showCandlesBorder:!0,showActiveCandlesBorder:!0,showWicks:!0,candleLineWidth:1,lineWidth:1,areaLineWidth:1,barLineWidth:1,minWidth:.5,minCandles:10,candlePaddingPercent:.25,highlightActiveCandle:!0,cursor:"default",selectedWidth:3,minCandlesOffset:2,defaultZoomCandleWidth:7,zoomStep:0,histogram:{barCapSize:1},maxYAxisScalesAmount:10,applyBackgroundToAxes:{x:!0,y:!0},sortCandles:al},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:li,cursor:"ns-resize",resizeDisabledCursor:"default",labelBoxMargin:{top:4,bottom:4,end:8,start:10},typeConfig:{badge:{rounded:!0,paddings:{top:4,bottom:4,end:4,start:4}},plain:{},rectangle:{rounded:!1,paddings:{top:4,bottom:4,end:4,start:4}}},labels:{descriptions:!1,settings:{lastPrice:{mode:"label",type:"badge"},countdownToBarClose:{mode:"none",type:"rectangle"}}},treasuryFormat:{enabled:!1}},xAxis:{visible:!0,formatsForLabelsConfig:{lessThanSecond:"HH:mm:ss",second_1:"HH:mm:ss",minute_1:"HH:mm",minute_5:"HH:mm",minute_30:"HH:mm",hour_1:"HH:mm",day_1:"dd.MM",month_1:"MMM",year_1:"YYYY"},fontSize:12,fontFamily:li,cursor:"ew-resize",padding:{top:8,bottom:16},fontStyle:""},events:{visible:!1,eventsVisibility:{"conference-calls":!0,dividends:!0,splits:!0,earnings:!0},height:20,cursor:"default",xAxisLabelFormat:[{format:"d MMM"}],icons:{earnings:{normal:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" stroke="#D92C40" stroke-width="1.5"/></svg>',hover:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" fill="#D92C40" stroke="#D92C40" stroke-width="1.5"/></svg>'}}},offsets:{visible:!0,right:10,top:10,bottom:20,left:0},waterMark:{visible:!1,fontFamily:"Open Sans, sans-serif",firstRowFontSize:80,firstRowBottomPadding:10,secondRowFontSize:40,secondRowBottomPadding:25,thirdRowFontSize:40,thirdRowBottomPadding:15,position:"center",offsetX:20,offsetY:20,logoWidth:20,logoHeight:20},highLow:{visible:!1,font:"12px sans-serif",prefix:{high:"H: ",low:"L: "}},highlights:{visible:!1,fontFamily:"Open Sans",fontSize:13,border:{width:1,dash:[8,4]}},crossTool:{type:"cross-and-labels",discrete:!1,magnetTarget:"none",lineDash:[4,6],xAxisLabelFormat:[{format:"dd.MM.YYYY",showWhen:{periodMoreThen:24*60*60*1e3}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:24*60*60*1e3,periodMoreThen:6*1e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6*1e3}}],xLabel:{padding:{top:4,bottom:4,right:8,left:8},margin:{top:4}},yLabel:{padding:{top:4,bottom:4,end:4,start:4},type:"badge"}},grid:{visible:!0,horizontal:!1,vertical:!0,width:1,dash:[0,0],color:"#FFFFFF"},volumes:{visible:!0,showSeparately:!1,valueLines:15,barCapSize:1,volumeBarSpace:0,volumeFillColor:"#FFFFFF"},navigationMap:{visible:!1,allCandlesHistory:!0,timeLabels:{visible:!1,dateFormat:"dd.MM.YYYY HH:mm",fontFamily:"Open Sans",fontSize:13,padding:{x:10,y:1}},minSliderWindowWidth:10,cursors:{chart:"default",buttonLeft:"pointer",buttonRight:"pointer",leftResizer:"ew-resize",rightResizer:"ew-resize",slider:"grab"},knots:{height:35,width:7,border:0,lineWidth:1}},baseline:{cursor:"ns-resize",dragZone:3,height:1},paneResizer:{cursor:"ns-resize",height:1,visible:!0,fixedMode:!1,dragZone:3}},colors:{candleTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(77,153,83,1)",downWickColor:"rgba(217,44,64,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:1},barTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},lineTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},chartAreaTheme:{backgroundMode:"regular",backgroundColor:"rgba(20,20,19,1)",backgroundGradientTopColor:"red",backgroundGradientBottomColor:"blue",gridColor:"rgba(37,37,36,1)"},scatterPlot:{mainColor:"rgba(255,255,255,1)"},areaTheme:{lineColor:"rgba(127,120,214,1)",startColor:"rgba(169,38,251,1)",stopColor:"rgba(169,38,251,0.8)"},baseLineTheme:{lowerSectionStrokeColor:"rgba(217,44,64,1)",upperSectionStrokeColor:"rgba(77,153,83,1)",lowerSectionFillColor:"rgba(217, 44, 64, 0.07)",upperSectionFillColor:"rgba(77, 153, 83, 0.07)",baselineColor:"rgba(55,55,54,1)"},histogram:{upCap:"rgba(77,153,83,1)",upBottom:"rgba(77,153,83,0.1)",upBright:"rgba(77,153,83,0.4)",downCap:"rgba(217,44,64,1)",downBottom:"rgba(217,44,64,0.1)",downBright:"rgba(217,44,64,0.4)",noneCap:"rgba(255,255,255,1)",noneBottom:"rgba(255,255,255,0.1)",noneBright:"rgba(255,255,255,0.4)"},crossTool:{lineColor:"rgba(107,96,86,1)",labelBoxColor:"rgba(107,96,86,1)",labelTextColor:"rgba(255,255,255,1)"},waterMarkTheme:{firstRowColor:"rgba(255,255,255,0.2)",secondRowColor:"rgba(255,255,255,0.2)",thirdRowColor:"rgba(255,255,255,0.2)"},highlights:{NO_TRADING:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"},AFTER_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(38, 251, 149, 0.05)",label:"transparent"},PRE_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(255, 170, 0, 0.05)",label:"transparent"},REGULAR:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"}},activeCandleTheme:{upColor:"rgba(98,201,93,1)",downColor:"rgba(255,47,47,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(98,201,93,1)",downWickColor:"rgba(255,47,47,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:.5},volume:{downBarColor:"rgba(99,30,37,1)",upBarColor:"rgba(42,72,44,1)",noneBarColor:"rgba(255,255,255,0.4)",upCapColor:"rgba(42,72,44,1)",downCapColor:"rgba(99,30,37,1)",noneCapColor:"rgba(255,255,255,0.4)"},highLowTheme:{highColor:"rgba(223,222,223,1)",lowColor:"rgba(223,222,223,1)"},instrumentInfo:{textColor:"#aeb1b3"},paneResizer:{lineColor:"rgba(61,61,61,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)",normal:"rgba(217,44,64,1)",hover:"rgba(217,44,64,1)",line:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)",normal:"rgba(169,38,251,1)",hover:"rgba(169,38,251,1)",line:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)",normal:"rgba(244,187,63,1)",hover:"rgba(244,187,63,1)",line:"rgba(244,187,63,1)"},"conference-calls":{color:"rgba(48,194,97,1)",normal:"rgba(48,194,97,1)",hover:"rgba(48,194,97,1)",line:"rgba(48,194,97,1)"}},secondaryChartTheme:[{lineTheme:{upColor:"rgba(226,61,25,1)",downColor:"rgba(226,61,25,1)",noneColor:"rgba(226,61,25,1)"},areaTheme:{lineColor:"rgba(226,61,25,1)",startColor:"rgba(226,61,25,0.8)",stopColor:"rgba(226,61,25,0)"}},{lineTheme:{upColor:"rgba(250,191,64,1)",downColor:"rgba(250,191,64,1)",noneColor:"rgba(250,191,64,1)"},areaTheme:{lineColor:"rgba(250,191,64,1)",startColor:"rgba(250,191,64,0.8)",stopColor:"rgba(250,191,64,0)"}},{lineTheme:{upColor:"rgba(169,38,251,1)",downColor:"rgba(169,38,251,1)",noneColor:"rgba(169,38,251,1)"},areaTheme:{lineColor:"rgba(169,38,251,1)",startColor:"rgba(169,38,251,0.8)",stopColor:"rgba(169,38,251,0)"}},{lineTheme:{upColor:"rgba(77,211,240,1)",downColor:"rgba(77,211,240,1)",noneColor:"rgba(77,211,240,1)"},areaTheme:{lineColor:"rgba(77,211,240,1)",startColor:"rgba(77,211,240,0.8)",stopColor:"rgba(77,211,240,0)"}},{lineTheme:{upColor:"rgba(59,203,91,1)",downColor:"rgba(59,203,91,1)",noneColor:"rgba(59,203,91,1)"},areaTheme:{lineColor:"rgba(59,203,91,1)",startColor:"rgba(59,203,91,0.8)",stopColor:"rgba(59,203,91,0)"}}],yAxis:{backgroundColor:"rgba(20,20,19,1)",labelBoxColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)",labelInvertedTextColor:"rgba(20,20,19,1)",rectLabelTextColor:"rgba(255,255,255,1)",rectLabelInvertedTextColor:"rgba(20,20,19,1)",zeroPercentLine:"rgba(55,55,54,1)"},labels:{lastPrice:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(0,0,0,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},countdownToBarClose:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(255,255,255,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},highLow:{high:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"High"},low:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Low"}},bidAsk:{bid:{boxColor:"rgba(77,153,83,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Bid"},ask:{boxColor:"rgba(217,44,64,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Ask"}},prePostMarket:{post:{boxColor:"rgba(38,251,149,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Post"},pre:{boxColor:"rgba(255,170,0,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Pre"}},prevDayClose:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)"}},xAxis:{backgroundColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)"},navigationMap:{backgroundColor:"transparent",buttonColor:"rgba(255,255,255,0.1)",buttonArrowColor:"rgba(212,212,211,1)",knotColor:"rgba(255,255,255,0.1)",knotLineColor:"rgba(212,212,211,1)",sliderColor:"rgba(255,255,255,0.08)",knotBorderColor:"#0b0d1a",timeLabelsTextColor:"rgba(128,128,128,1)",mapColor:"rgba(255,255,255,0.1)",mapFillColor:"rgba(255,255,255,0.1)",mapGradientTopColor:"rgba(255,255,255,0.1)",mapGradientBottomColor:"rgba(255,255,255,0.1)"}},animation:{moveDuration:1e3,candleDuration:200,paneResizer:{bgMode:!0,enabled:!0,duration:40},yAxis:{background:{enabled:!1,duration:40}}},drawingOrder:["OVER_SERIES_CLEAR","MAIN_CLEAR","SERIES_CLEAR","GRID","X_AXIS","Y_AXIS","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function ml(n,t=$e()){return Mt(n,t,ii),n}function Hp(n,t=$e()){const e=fl({},n);return merge(e,t,DEFAULT_MERGE_OPTIONS),e}function kp(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function ci(n){return typeof n=="object"&&n!==null}function hi(n,t){return[...n].map(s=>Bs(s,t))}const vl=n=>Array.isArray(n);function Bs(n,t){if(!ci(n))return n;if(vl(n))return hi(n,t);{const e=di({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function di(n,t,e){if(!ci(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return hi(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=Bs(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=di(n[i],t[i],e):e.addIfMissing&&(s[i]=Bs(t[i],e))}),s}const te=n=>`${n.fontSize}px ${n.fontFamily}`;class bl{constructor(t,e){this.config=t,this.mainCanvasModel=e,this.extentsOrder=new Map,this.yAxisWidthContributors=[]}registerYAxisWidthContributor(t){this.yAxisWidthContributors.push(t)}removeYAxisWidthContributor(t){this.yAxisWidthContributors=this.yAxisWidthContributors.filter(e=>e!==t)}getTextWidth(t){const e=te(this.config.components.yAxis);return Tt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(s=>{var i,r,o;const a=s.getYAxisState();if(!a.visible)return;const l=a.labelBoxMargin.start+a.labelBoxMargin.end,c=this.getTextWidth(s.getLargestLabel())+l,h=s.getYAxisIndex(),d=s.getPaneUUID(),u=(i=this.extentsOrder.get(d))!=null?i:{left:[],right:[]};if(a.align==="left"){const f=u.left.length;t[f]=Math.max((r=t[f])!=null?r:0,c),u.left.push(h)}else{const f=u.right.length;e[f]=Math.max((o=e[f])!=null?o:0,c),u.right.push(h)}this.extentsOrder.set(d,u)}),{left:t,right:e}}}var Cl=Object.defineProperty,yl=Object.defineProperties,wl=Object.getOwnPropertyDescriptors,ui=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,xl=Object.prototype.propertyIsEnumerable,fi=(n,t,e)=>t in n?Cl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Yt=(n,t)=>{for(var e in t||(t={}))Sl.call(t,e)&&fi(n,e,t[e]);if(ui)for(var e of ui(t))xl.call(t,e)&&fi(n,e,t[e]);return n},gi=(n,t)=>yl(n,wl(t));const Z="CHART",st=class{};st.CANVAS="CANVAS",st.N_MAP="N_MAP",st.X_AXIS="X_AXIS",st.N_MAP_KNOT_L="N_MAP_KNOT_L",st.N_MAP_KNOT_R="N_MAP_KNOT_R",st.N_MAP_BTN_L="N_MAP_BTN_L",st.N_MAP_BTN_R="N_MAP_BTN_R",st.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",st.N_MAP_CHART="N_MAP_CHART",st.N_MAP_LABEL_R="N_MAP_LABEL_R",st.N_MAP_LABEL_L="N_MAP_LABEL_L",st.PANE_UUID=n=>"PANE_"+n,st.PANE_UUID_Y_AXIS=(n,t=0)=>"PANE_"+n+"_Y_AXIS_"+t,st.PANE_UUID_RESIZER=n=>"PANE_"+n+"_RESIZER",st.ALL_PANES="ALL_PANES",st.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",st.EVENTS="EVENTS",st.CHART=st.PANE_UUID(Z),st.Y_AXIS=st.PANE_UUID_Y_AXIS(Z);let M=st;const pi={x:0,y:0,pageX:0,pageY:0,width:0,height:0},mi=20,vi=35,Rs=15,bi=1.5,Ci=kt()?8*bi:8,_e=kt()?5:0,Pl=1e-6;class Fs{constructor(t,e,s,i,r){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new R,this.paneMovedSubject=new R,this.paneVisibilityChangedSubject=new R,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new R,this.barResizerChangedSubject=new R,this._graphsHeightRatio={[Z]:1},this.graphsHeightRatioChangedSubject=new R,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new bl(this.config,this.canvasModel)}get graphsHeightRatio(){return this._graphsHeightRatio}updateYAxisWidths(){const t=this.yAxisBoundsContainer.getYAxisWidths();this.setYAxisWidths(t)}addPaneBounds(t,e){if(this.panesOrder.indexOf(t)===-1){if(this.panesOrder.push(t),e!==void 0){const s=this.panesOrder.indexOf(t);Is(this.panesOrder,s,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=Yt(Yt({},this.graphsHeightRatio),t),s=Object.values(e).reduce((i,r)=>i+r,0);Math.abs(s-1)<Pl?(this._graphsHeightRatio=e,this.recalculateBounds()):console.error(`Result ratio should be equal 1, but equal ${s}`)}movePaneUp(t){const e=this.panesOrder.indexOf(t);e!==-1&&(Is(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(Is(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}reorderPanes(t){this.panesOrder=$n(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}hidePaneBounds(t){this.graphsHeightRatio[t]=0,this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}showPaneBounds(t){if(t===Z){const[e]=yi(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){Ja(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[M.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[M.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[M.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,s=this.config.components.paneResizer.height,i=this.getBounds(M.CANVAS);i.x=0,i.y=0,i.width=t,i.height=e;const r=this.yAxisWidths,o=this.getNavMapBounds(i),a=this.getXAxisBounds(o,i),l=e-a.height-o.height,c=r.left.reduce((H,B)=>H+B,0),h=r.right.reduce((H,B)=>H+B,0),d=0,u=i.width-h,f=d+c,p=0,v=i.width-c-h;let x=p;const P=this.panesOrder.findIndex(H=>this.graphsHeightRatio[H]>0);this.panesOrder.forEach((H,B)=>{var Y;const W=this.graphsHeightRatio[this.panesOrder[B]],G=M.PANE_UUID_RESIZER(H),V=M.PANE_UUID(H),U=this.config.components.paneResizer.visible&&B>P&&W>0;U?he(this.bounds,G,0,x,i.width,s,this.canvasOnPageLocation):he(this.bounds,G,0,0,0,0,this.canvasOnPageLocation);const $=x+(U?s:0),K=he(this.bounds,V,f,$,v,l*W-(U?s:0),this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const et=this.yAxisBoundsContainer.extentsOrder.get(H);if(et===void 0)return;const tt=l*W-(U?s:0);let Q=f-((Y=r.left[0])!=null?Y:0),ot=u;et.left.forEach((ct,at)=>{var Pt;he(this.bounds,M.PANE_UUID_Y_AXIS(H,ct),Q,$,r.left[at],tt,this.canvasOnPageLocation),Q-=(Pt=r.left[at+1])!=null?Pt:0}),et.right.forEach((ct,at)=>{he(this.bounds,M.PANE_UUID_Y_AXIS(H,ct),ot,$,r.right[at],tt,this.canvasOnPageLocation),ot+=r.right[at]})}else he(this.bounds,M.PANE_UUID_Y_AXIS(H),0,0,0,0,this.canvasOnPageLocation);x=K.y+K.height});const I=this.getBounds(M.ALL_PANES);I.x=f,I.y=p,I.width=v,I.height=x;const O=this.getBounds(M.CHART_WITH_Y_AXIS),j=this.getBounds(M.CHART);this.getEventsBounds(j),this.copyBounds(j,O),O.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=gi(Yt({},this.canvasOnPageLocation),{x:t.x,y:t.y,width:t.width,height:t.height})}updateAllBoundsPageCoordinates(){for(const t of Object.keys(this.bounds)){const e=this.bounds[t];e.pageX=e.x+this.canvasOnPageLocation.x,e.pageY=e.y+this.canvasOnPageLocation.y}}getEventsBounds(t){const e=this.getBounds(M.EVENTS);return this.config.components.events.visible?(e.x=0,e.y=t.y+t.height-this.config.components.events.height,e.width=t.width,e.height=this.config.components.events.height):this.applyDefaultBounds(e),e}getNavMapBounds(t){const e=this.getBounds(M.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-vi,e.width=t.width,e.height=vi):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const s=this.getBounds(M.X_AXIS),i=this.yAxisWidths.left.length+this.yAxisWidths.right.length===1,r=i?0:this.yAxisWidths.left.reduce((a,l)=>a+=l,0),o=i?0:this.yAxisWidths.right.reduce((a,l)=>a+=l,0);if(this.config.components.xAxis.visible){const a=this.getXAxisHeight();s.x=r,s.y=e.height-a-t.height,s.width=e.width-o,s.height=a}else this.applyDefaultBounds(s);return s}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const s=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,i=jt(s,this.canvasModel.ctx);this.xAxisHeight=i+((t=this.config.components.xAxis.padding.top)!=null?t:0)+((e=this.config.components.xAxis.padding.bottom)!=null?e:0)+_e}return this.xAxisHeight}setYAxisWidths(t){(!Kn(this.yAxisWidths.left,t.left)||!Kn(this.yAxisWidths.right,t.right))&&(this.yAxisWidths=t,this.recalculateBounds())}setXAxisHeight(t){t!==this.xAxisHeight&&(this.xAxisHeight=t,this.recalculateBounds())}setPanesOrder(t){this.panesOrder=t,this.recalculateBounds()}recalculatePanesHeightRatios(){this.calculateGraphsHeightRatios(),this.recalculateBounds()}calculateGraphsHeightRatios(){let t=this.graphsHeightRatio[Z];const e=[];e.push(...this.panesOrder.filter(p=>p!==Z));const s=e.map(p=>this.graphsHeightRatio[p]===void 0?void 0:this.graphsHeightRatio[p]),i=s.filter(p=>p!==0),r=i.length,o=i.filter(p=>p!==void 0).length,a=s.filter(p=>p===void 0).length,l=a>0;let c=0,h=0,d=1,u=0;if(l&&([d,u]=yi(r)),(!this.graphsHeightRatio[Z]||this.graphsHeightRatio[Z]===0)&&(t=0),this.graphsHeightRatio[Z]&&this.graphsHeightRatio[Z]!==0)if(l)t=1*d;else{const p=Object.values(this.graphsHeightRatio).reduce((v,x)=>x+=v);p<1&&this.graphsHeightRatio[Z]!==0&&(t+=1-p)}o===0&&(t=1-u*a),h=1-t-u*a,i.forEach(p=>{p&&(h-=p*d)}),c=h/(r||1);const f=s.map(p=>p===0?p:p?p*d+c:u+c);this._graphsHeightRatio={},this.graphsHeightRatio[Z]=t,f.forEach((p,v)=>{const x=e[v];this.graphsHeightRatio[x]=p})}recalculateNavigationMapElementBounds(){var t,e,s,i;if(!this.config.components.navigationMap.visible)return;const r=this.getBounds(M.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=kt()?a*bi:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=tt=>rl(this.canvasModel.ctx,tt,this.formatterFactory,this.config)[0],f=Ct((i=(s=this.mainCandleSeries)==null?void 0:s.getSeriesInViewport())!=null?i:[]),p=d&&f.length?u(f[0].candle.timestamp):0,v=d&&f.length?u(f[f.length-1].candle.timestamp):0,x=Math.max(p,v);if(d){const tt=this.getBounds(M.N_MAP_LABEL_L);tt.x=r.x,tt.y=r.y,tt.width=x,tt.height=r.height;const Q=this.getBounds(M.N_MAP_LABEL_R);Q.x=r.x+r.width-x,Q.y=r.y,Q.width=x,Q.height=r.height}const P=this.getBounds(M.N_MAP_BTN_L);P.x=r.x+x,P.y=r.y,P.width=Rs,P.height=r.height;const I=this.getBounds(M.N_MAP_BTN_R);I.x=r.x+r.width-Rs-x,I.y=r.y,I.width=Rs,I.height=r.height;const O=P.x+P.width,j=I.x-O,H=O+j,B=this.config.components.navigationMap.minSliderWindowWidth,Y=c!=null?c:Ci,W=l!=null?l:r.height,G=Y+B,V=this.getBounds(M.N_MAP_KNOT_L);V.x=O+j*this.leftRatio,V.x=Math.min(V.x,H-G),V.y=h,V.width=Y,V.height=W;const U=this.getBounds(M.N_MAP_KNOT_R);U.x=O+j*this.rightRatio-Ci,U.x=Math.max(U.x,O+G),U.y=h,U.width=Y,U.height=W;const $=G-(U.x-V.x);$>0&&(V.x-=$);const K=this.getBounds(M.N_MAP_SLIDER_WINDOW);K.x=V.x+V.width,K.y=r.y,K.width=U.x-K.x,K.height=r.height;const et=this.getBounds(M.N_MAP_CHART);et.x=O,et.y=r.y,et.width=j,et.height=r.height}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){let e=this.bounds[t];return e===void 0&&(e=this.copyOf(pi),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>gi(Yt({},t),{[e]:this.bounds[M.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=Ke){const{extensionX:s,extensionY:i,wholePage:r}=Yt(Yt({},Ke),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-s&&o<l.pageX+l.width+s&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-s&&o<l.x+l.width+s&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=Ke){const{extensionX:s,extensionY:i,wholePage:r}=Yt(Yt({},Ke),e);return r?(o,a)=>o>t.pageX-s&&o<t.pageX+t.width+s&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-s&&o<t.x+t.width+s&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(M.CANVAS);return t.width>0&&t.height>0}isAllBoundsAvailable(){return Object.values(this.bounds).every(t=>t.width>=0&&t.height>=0)}resizePaneVertically(t,e){const s=this.panesOrder.indexOf(t),i=this.getBounds(M.PANE_UUID_RESIZER(t));this.doResizePaneVertically(s,i.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){let s=t-1;const i=this.panesOrder[s];if(this._graphsHeightRatio[i]<=0)for(let d=0;d<t;d++)this._graphsHeightRatio[this.panesOrder[d]]>0&&(s=d);const r=this.getBounds(M.ALL_PANES).height,o=mi,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ft(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(dt(s=>this.copyOf(s)),Et((s,i)=>this.sameBounds(s,i)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return Yt({},t)}copyBounds(t,e){e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height}sameBounds(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}applyDefaultBounds(t){this.copyBounds(pi,t)}setMainCandleSeries(t){this.mainCandleSeries=t}getEffectiveYAxisWidth(){return this.getBounds(M.PANE_UUID_Y_AXIS(Z)).width}getEffectiveChartWidth(){return this.getBounds(M.PANE_UUID(Z)).width}getEffectiveChartHeight(){return this.getBounds(M.PANE_UUID(Z)).height}}const _l={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},yi=n=>{var t;const e=(t=_l[n])!=null?t:.4,s=(1-e)/n;return[e,s]},jp=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,Tl=(n,t)=>n>t.y&&n<t.y+t.height,he=(n,t,e,s,i,r,o)=>{const a=n[t];if(a)return a.x=e,a.y=s,a.pageX=e+o.x,a.pageY=s+o.y,a.width=i,a.height=r,a;const l={x:e,y:s,pageX:e+o.x,pageY:s+o.y,width:i,height:r};return n[t]=l,l},wi=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),Ke={extensionX:0,extensionY:0,wholePage:!1},Si=(n,t)=>n.width===t.width&&n.height===t.height;var Ml=function(n){z(t,n);function t(e,s){return n.call(this)||this}return t.prototype.schedule=function(e,s){return s===void 0&&(s=0),this},t}(ae),qe={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=qe.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,D([n,t],m(e))):setInterval.apply(void 0,D([n,t],m(e)))},clearInterval:function(n){var t=qe.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},xi=function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i.pending=!1,i}return t.prototype.schedule=function(e,s){var i;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,s)),this.pending=!0,this.delay=s,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,s),this},t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),qe.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,s,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return s;s!=null&&qe.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,s);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var i=!1,r;try{this.work(e)}catch(o){i=!0,r=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,He(r,this),s!=null&&(this.id=this.recycleAsyncId(i,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Ml),Te={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=Te.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new ae(function(){return e==null?void 0:e(i)})},requestAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Te.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,D([],m(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Te.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,D([],m(n)))},delegate:void 0},Al=function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i}return t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),i!==null&&i>0?n.prototype.requestAsyncId.call(this,e,s,i):(e.actions.push(this),e._scheduled||(e._scheduled=Te.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,s,i){var r;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return n.prototype.recycleAsyncId.call(this,e,s,i);var o=e.actions;s!=null&&s===e._scheduled&&((r=o[o.length-1])===null||r===void 0?void 0:r.id)!==s&&(Te.cancelAnimationFrame(s),e._scheduled=void 0)},t}(xi),Hs={now:function(){return(Hs.delegate||Date).now()},delegate:void 0},Pi=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,s){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(s,e)},n.now=Hs.now,n}(),_i=function(n){z(t,n);function t(e,s){s===void 0&&(s=Pi.now);var i=n.call(this,e,s)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var s=this.actions;if(this._active){s.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=s.shift());if(this._active=!1,i){for(;e=s.shift();)e.unsubscribe();throw i}},t}(Pi),El=function(n){z(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var s;e?s=e.id:(s=this._scheduled,this._scheduled=void 0);var i=this.actions,r;e=e||i.shift();do if(r=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===s&&i.shift());if(this._active=!1,r){for(;(e=i[0])&&e.id===s&&i.shift();)e.unsubscribe();throw r}},t}(_i),de=new El(Al),Yp=null,ks=new _i(xi),Il=ks;function Dl(n,t){return N(function(e,s){var i=t!=null?t:{},r=i.leading,o=r===void 0?!0:r,a=i.trailing,l=a===void 0?!1:a,c=!1,h=null,d=null,u=!1,f=function(){d==null||d.unsubscribe(),d=null,l&&(x(),u&&s.complete())},p=function(){d=null,u&&s.complete()},v=function(P){return d=Lt(n(P)).subscribe(mt(s,f,p))},x=function(){if(c){c=!1;var P=h;h=null,s.next(P),!u&&v(P)}};e.subscribe(mt(s,function(P){c=!0,h=P,!(d&&!d.closed)&&(o?x():v(P))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function Ll(n){return n instanceof Date&&!isNaN(n)}function Ol(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Il);var s=-1;return t!=null&&(kn(t)?e=t:s=t),new vt(function(i){var r=Ll(n)?+n-e.now():n;r<0&&(r=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=s?this.schedule(void 0,s):i.complete())},r)})}function ue(n,t,e){t===void 0&&(t=ks);var s=Ol(n,t);return Dl(function(){return s},e)}class X{constructor(){this.subscriptions=[],this._state="initial",this.entities=[]}doActivate(){}doDeactivate(){this.subscriptions.forEach(t=>t()),this.subscriptions=[]}enable(){this._state!=="active"&&(this._state="deactivated",this.activate())}disable(){this._state!=="disabled"&&(this.deactivate(),this._state="disabled")}activate(){this._state!=="disabled"&&(this._state!=="active"&&(this.doActivate(),this._state="active"),this.entities.forEach(t=>t.activate()))}deactivate(){this._state!=="disabled"&&(this._state!=="deactivated"&&(this.doDeactivate(),this._state="deactivated"),this.entities.forEach(t=>t.deactivate()))}getState(){return this._state}addSubscription(t){this.subscriptions.push(t)}addRxSubscription(t){t&&this.subscriptions.push(t.unsubscribe.bind(t))}addChildEntity(t){this.entities.push(t),this._state==="active"&&t.activate()}removeChildEntity(t){this.entities=this.entities.filter(e=>e!==t)}}class Bl extends X{constructor(t,e,s,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new R}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(ue(100,de,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(t,e,s,i=0){const r=Fs.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:s,hitTest:r}):this.normalLayer.set(t,{cursor:s,hitTest:r})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(Et())}observeCursorType(t,e,s){const i=s?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(t);s?this.extensionLayer.set(t,{cursor:e,hitTest:i}):this.normalLayer.set(t,{cursor:e,hitTest:i})}updateCursor(t){this.element.style.cursor!==t&&(this.element.style.cursor=t,this.cursorChangedSubject.next(t))}}const Rl=n=>{const t=n.canvasArea!==null,e=n.snapshotCanvas!==null,s=n.backgroundCanvas!==null,i=n.mainCanvas!==null,r=n.yAxisLabelsCanvas!==null,o=n.crossToolCanvas!==null,a=n.hitTestCanvas!==null,l=n.chartResizer!==null,c=n.chartContainer!==null,h=n.dynamicObjectsCanvas!==null;return t&&e&&s&&i&&r&&o&&a&&l&&c&&h},Fl=n=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
8
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function We(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var he=(function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,s,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=E(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(v){t={error:v}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(j(h))try{h()}catch(v){r=v instanceof Ps?v.errors:[v]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=E(d),f=u.next();!f.done;f=u.next()){var p=f.value;try{Pn(p)}catch(v){r=r!=null?r:[],v instanceof Ps?r=D(D([],m(r)),m(v.errors)):r.push(v)}}}catch(v){s={error:v}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}if(r)throw new Ps(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Pn(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&We(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&We(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),xn=he.EMPTY;function _n(n){return n instanceof he||n&&"closed"in n&&j(n.remove)&&j(n.add)&&j(n.unsubscribe)}function Pn(n){j(n)?n():n.unsubscribe()}var Qt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ze={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=ze.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,D([n,t],m(e))):setTimeout.apply(void 0,D([n,t],m(e)))},clearTimeout:function(n){var t=ze.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Tn(n){ze.setTimeout(function(){var t=Qt.onUnhandledError;if(t)t(n);else throw n})}function Mn(){}var ca=(function(){return Ts("C",void 0,void 0)})();function ha(n){return Ts("E",void 0,n)}function da(n){return Ts("N",n,void 0)}function Ts(n,t,e){return{kind:n,value:t,error:e}}var te=null;function Ve(n){if(Qt.useDeprecatedSynchronousErrorHandling){var t=!te;if(t&&(te={errorThrown:!1,error:null}),n(),t){var e=te,s=e.errorThrown,i=e.error;if(te=null,s)throw i}}else n()}function ua(n){Qt.useDeprecatedSynchronousErrorHandling&&te&&(te.errorThrown=!0,te.error=n)}var Ms=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,_n(e)&&e.add(s)):s.destination=ma,s}return t.create=function(e,s,i){return new _e(e,s,i)},t.prototype.next=function(e){this.isStopped?Es(da(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Es(ha(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Es(ca,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(he),fa=Function.prototype.bind;function As(n,t){return fa.call(n,t)}var ga=(function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(s){Ue(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Ue(s)}else Ue(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Ue(e)}},n})(),_e=(function(n){z(t,n);function t(e,s,i){var r=n.call(this)||this,o;if(j(e)||!e)o={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:i!=null?i:void 0};else{var a;r&&Qt.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&As(e.next,a),error:e.error&&As(e.error,a),complete:e.complete&&As(e.complete,a)}):o=e}return r.destination=new ga(o),r}return t})(Ms);function Ue(n){Qt.useDeprecatedSynchronousErrorHandling?ua(n):Tn(n)}function pa(n){throw n}function Es(n,t){var e=Qt.onStoppedNotification;e&&ze.setTimeout(function(){return e(n,t)})}var ma={closed:!0,next:Mn,error:pa,complete:Mn};function vt(n,t,e,s,i){return new va(n,t,e,s,i)}var va=(function(n){z(t,n);function t(e,s,i,r,o,a){var l=n.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;n.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(Ms);function dt(n,t){return N(function(e,s){var i=0;e.subscribe(vt(s,function(r){s.next(n.call(t,r,i++))}))})}var An=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function En(n){return j(n==null?void 0:n.then)}var Is=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function de(n){return n}function Zp(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return In(n)}function In(n){return n.length===0?de:n.length===1?n[0]:function(e){return n.reduce(function(s,i){return i(s)},e)}}var bt=(function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,s){var i=this,r=Ca(t)?t:new _e(t,e,s);return Ve(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var s=this;return e=Dn(e),new e(function(i,r){var o=new _e({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});s.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Is]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return In(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Dn(t),new t(function(s,i){var r;e.subscribe(function(o){return r=o},function(o){return i(o)},function(){return s(r)})})},n.create=function(t){return new n(t)},n})();function Dn(n){var t;return(t=n!=null?n:Qt.Promise)!==null&&t!==void 0?t:Promise}function ba(n){return n&&j(n.next)&&j(n.error)&&j(n.complete)}function Ca(n){return n&&n instanceof Ms||ba(n)&&_n(n)}function Ln(n){return j(n[Is])}function On(n){return Symbol.asyncIterator&&j(n==null?void 0:n[Symbol.asyncIterator])}function Bn(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ya(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Rn=ya();function Fn(n){return j(n==null?void 0:n[Rn])}function Hn(n){return lt(this,arguments,function(){var e,s,i,r;return g(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,H(e.read())];case 3:return s=o.sent(),i=s.value,r=s.done,r?[4,H(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,H(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function kn(n){return j(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof bt)return n;if(n!=null){if(Ln(n))return wa(n);if(An(n))return Sa(n);if(En(n))return xa(n);if(On(n))return jn(n);if(Fn(n))return _a(n);if(kn(n))return Pa(n)}throw Bn(n)}function wa(n){return new bt(function(t){var e=n[Is]();if(j(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Sa(n){return new bt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function xa(n){return new bt(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Tn)})}function _a(n){return new bt(function(t){var e,s;try{for(var i=E(n),r=i.next();!r.done;r=i.next()){var o=r.value;if(t.next(o),t.closed)return}}catch(a){e={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(e)throw e.error}}t.complete()})}function jn(n){return new bt(function(t){Ta(n,t).catch(function(e){return t.error(e)})})}function Pa(n){return jn(Hn(n))}function Ta(n,t){var e,s,i,r;return w(this,void 0,void 0,function(){var o,a;return g(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=Ht(n),l.label=1;case 1:return[4,e.next()];case 2:if(s=l.sent(),!!s.done)return[3,4];if(o=s.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),s&&!s.done&&(r=e.return)?[4,r.call(e)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function kt(n,t,e,s,i){s===void 0&&(s=0),i===void 0&&(i=!1);var r=t.schedule(function(){e(),i?n.add(this.schedule(null,s)):this.unsubscribe()},s);if(n.add(r),!i)return r}function Ma(n,t,e,s,i,r,o,a){var l=[],c=0,h=0,d=!1,u=function(){d&&!l.length&&!c&&t.complete()},f=function(v){return c<s?p(v):l.push(v)},p=function(v){r&&t.next(v),c++;var x=!1;Lt(e(v,h++)).subscribe(vt(t,function(_){i==null||i(_),r?f(_):t.next(_)},function(){x=!0},void 0,function(){if(x)try{c--;for(var _=function(){var A=l.shift();o?kt(t,o,function(){return p(A)}):p(A)};l.length&&c<s;)_();u()}catch(A){t.error(A)}}))};return n.subscribe(vt(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Yn(n,t,e){return e===void 0&&(e=1/0),j(t)?Yn(function(s,i){return dt(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return Ma(s,i,n,e)}))}function Nn(n){return n===void 0&&(n=1/0),Yn(de,n)}var Xn=new bt(function(n){return n.complete()});function $p(n){return n?Aa(n):Xn}function Aa(n){return new Observable(function(t){return n.schedule(function(){return t.complete()})})}function Wn(n){return n&&j(n.schedule)}function Ds(n){return n[n.length-1]}function Ea(n){return j(Ds(n))?n.pop():void 0}function Ge(n){return Wn(Ds(n))?n.pop():void 0}function Ia(n,t){return typeof Ds(n)=="number"?n.pop():t}function zn(n,t){return t===void 0&&(t=0),N(function(e,s){e.subscribe(vt(s,function(i){return kt(s,n,function(){return s.next(i)},t)},function(){return kt(s,n,function(){return s.complete()},t)},function(i){return kt(s,n,function(){return s.error(i)},t)}))})}function Vn(n,t){return t===void 0&&(t=0),N(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function Da(n,t){return Lt(n).pipe(Vn(t),zn(t))}function La(n,t){return Lt(n).pipe(Vn(t),zn(t))}function Oa(n,t){return new bt(function(e){var s=0;return t.schedule(function(){s===n.length?e.complete():(e.next(n[s++]),e.closed||this.schedule())})})}function Ba(n,t){return new bt(function(e){var s;return kt(e,t,function(){s=n[Rn](),kt(e,t,function(){var i,r,o;try{i=s.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return j(s==null?void 0:s.return)&&s.return()}})}function Un(n,t){if(!n)throw new Error("Iterable cannot be null");return new bt(function(e){kt(e,t,function(){var s=n[Symbol.asyncIterator]();kt(e,t,function(){s.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function Ra(n,t){return Un(Hn(n),t)}function Fa(n,t){if(n!=null){if(Ln(n))return Da(n,t);if(An(n))return Oa(n,t);if(En(n))return La(n,t);if(On(n))return Un(n,t);if(Fn(n))return Ba(n,t);if(kn(n))return Ra(n,t)}throw Bn(n)}function Ze(n,t){return t?Fa(n,t):Lt(n)}function Ct(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=Ia(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):Nn(s)(Ze(i,e)):Xn}var Ha=Sn(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=(function(n){z(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var s=new Gn(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ha},t.prototype.next=function(e){var s=this;Ve(function(){var i,r;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=E(s.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(e)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var s=this;Ve(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var i=s.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ve(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var s=e.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var s=this,i=this,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?xn:(this.currentObservers=null,a.push(e),new he(function(){s.currentObservers=null,We(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,i=s.hasError,r=s.thrownError,o=s.isStopped;i?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new bt;return e.source=this,e},t.create=function(e,s){return new Gn(e,s)},t})(bt),Gn=(function(n){z(t,n);function t(e,s){var i=n.call(this)||this;return i.destination=e,i.source=s,i}return t.prototype.next=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.next)===null||i===void 0||i.call(s,e)},t.prototype.error=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.error)===null||i===void 0||i.call(s,e)},t.prototype.complete=function(){var e,s;(s=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||s===void 0||s.call(e)},t.prototype._subscribe=function(e){var s,i;return(i=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&i!==void 0?i:xn},t})(B),ut=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(B);let Ls=!1,Os=0;const $e=new Map,Ke=new Map,Zn=()=>{Ls||(Ls=!0,Os=requestAnimationFrame(()=>{Ke.forEach((n,t)=>{n(),Ke.delete(t)}),$e.forEach((n,t)=>{n(),$e.delete(t)}),Ls=!1}))},$n=(n,t)=>{$e.set(n,t),Zn()},ka=n=>{$e.delete(n)},ja=n=>{Ke.delete(n)},Pe=(n,t)=>{Ke.set(n,t),Zn()};function yt(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}var Ya=Math.pow;const qe=14,Je=[];for(let n=0;n<qe+1;n++)Je.push(Ya(10,n));const Bs=5e-13;class ft{static roundToNearest(t,e){return isFinite(t)?ft.isZero(t)?0:(t>0?t+=Bs:t<0&&(t-=Bs),ft.roundDecimal(Math.round(ft.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return ft.roundDecimal(Math.ceil(t/e))*e}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const e=Math.sign(t),s=Math.abs(t),i=Math.min(qe,qe-1-Math.floor(Math.log10(s)));for(let r=i;r>=0;r--){const o=Math.floor(Je[r]*s+.5);if(o<Je[qe])return e*o/Je[r]}return Math.round(t)}static makeDecimal(t,e,s,i){if(!isFinite(t))return"";if(isFinite(t)){let r=t.toFixed(e);if(!i)return s?r.replace(".",s):r;if(s===i)throw new Error("Grouping symbol cannot be the same as decimal separator.");const o=r.split(".");let a=o[0];const l=o[1];return Math.abs(t)>=1e3&&(a=a.replace(RegExp("\\d(?=(\\d{3})+$)","g"),`$&${i}`)),l?(r=[a,l].join(s),r):a}return""}static compare(t,e,s){return t>e+s?1:t<e-s?-1:(isNaN(t)?1:0)-(isNaN(e)?1:0)}static isZero(t){return ft.compare(t,0,Bs)===0}static cutNumber(t,e,s=0){return{K:r=>r/1e3,M:r=>r/1e6}[e](t).toFixed(s)+e}static isExponential(t){return/\de(\-|\+)\d/.test(t.toString())}}function Na(n,t,e){const s=n/t;return s>=e||s<=1/e}function Rs(n,t,e){return Math.max(t,Math.min(n,e))}function Xa(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Te(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const ot=n=>~~n,Wa=n=>~~(n+1),Me=n=>~~(n+.5),za=(n,t)=>n>>t;function Kp(n){if(!Number.isFinite(n))throw new Error("Input must be a finite number.");const t=n.toString();return t.includes(".")?t.split(".")[1].length:0}class Fs{constructor(t,e){this.animationTimeLeft=0,this.onTickFunction=e,this.animationTime=t.duration,this.animationStartTime=Date.now(),this.animationInProgress=!0}tick(){var t;Date.now()>this.animationStartTime+this.animationTime&&(this.animationInProgress=!1),(t=this.onTickFunction)==null||t.call(this)}getProgress(){return Math.min((Date.now()-this.animationStartTime)/this.animationTime,1)}finishAnimation(){this.animationInProgress=!1,this.animationStartTime=0}}var Va=Pt(520),Ot=Pt.n(Va);class Kn extends Fs{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Ot().rgb(i.color),i.initialAlpha=i.rgbColor.valpha,i.currentAnimationColor=i.rgbColor})}tick(){super.tick(),this.colorConfigs.forEach(t=>{if(t.initialAlpha===void 0||t.rgbColor===void 0)return;const e=t.initialAlpha*(t.type==="fading"?1-this.getProgress():this.getProgress());t.currentAnimationColor=t.rgbColor.alpha(e)})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){const t=Rs(Date.now()-this.animationStartTime,0,this.animationTime);this.animationStartTime=Date.now()-this.animationTime+t,this.colorConfigs.forEach(e=>{e.type=e.type==="fading"?"appearing":"fading"})}}class qn extends Fs{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Ot().rgb(i.startColor),i.rgbEndColor=Ot().rgb(i.endColor),i.currentAnimationColor=i.type==="appearing"?i.rgbStartColor:i.rgbEndColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{const e=1-this.animationTimeLeft/this.animationTime;!t.rgbStartColor||!t.rgbEndColor||(t.type==="fading"?t.currentAnimationColor=this.calculateTransitionColor(t.rgbEndColor,t.rgbStartColor,e):t.type==="appearing"&&(t.currentAnimationColor=this.calculateTransitionColor(t.rgbStartColor,t.rgbEndColor,e)))})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){this.animationTimeLeft=Math.max(this.animationTime-this.animationTimeLeft,1),this.colorConfigs.forEach(t=>{t.type==="fading"?t.type="appearing":t.type="fading"})}moveToLastTick(){this.animationTimeLeft=1}calculateTransitionColor(t,e,s){const i=t.red()-(t.red()-e.red())*s,r=t.green()-(t.green()-e.green())*s,o=t.blue()-(t.blue()-e.blue())*s;return Ot().rgb(i,r,o)}}class Jn extends Fs{constructor(t,e,s){var i;super(e,s),this.viewportModel=t,this.animationConfig=e,this.id=yt(),this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.easingFn=(i=e.easingFn)!=null?i:Xa}tick(){if(super.tick(),this.animationInProgress){const t=this.easingFn(this.getProgress()),e=this.xStart+(this.animationConfig.targetXStart-this.xStart)*t,s=this.xEnd+(this.animationConfig.targetXEnd-this.xEnd)*t,i=this.yStart+(this.animationConfig.targetYStart-this.yStart)*t,r=this.yEnd+(this.animationConfig.targetYEnd-this.yEnd)*t,o=this.zoomX+(this.animationConfig.targetZoomX-this.zoomX)*t,a=this.zoomY+(this.animationConfig.targetZoomY-this.zoomY)*t;this.viewportModel.apply({xStart:e,xEnd:s,yStart:i,yEnd:r,zoomX:o,zoomY:a,inverseY:this.viewportModel.inverseY})}}finishAnimation(){super.finishAnimation(),this.viewportModel.apply({xStart:this.animationConfig.targetXStart,xEnd:this.animationConfig.targetXEnd,yStart:this.animationConfig.targetYStart,yEnd:this.animationConfig.targetYEnd,zoomX:this.animationConfig.targetZoomX,zoomY:this.animationConfig.targetZoomY,inverseY:this.viewportModel.inverseY})}}const ue=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Ua=!!window.chrome,Qn=typeof InstallTrigger!="undefined",Ga=navigator.platform.indexOf("Win")>-1,qp=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(ue)i=e===n.deltaY*-3||Math.abs(e+Math.sign(e))===Math.abs(Math.round(n.deltaY)*3)||Math.abs(e-Math.sign(e))===Math.abs(Math.round(n.deltaY)*3);else if(Ua){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,Ga){const r=Math.round(n.deltaY)===e||Math.abs(Math.round(n.deltaY)+Math.sign(n.deltaY))===Math.abs(e)||Math.abs(Math.round(n.deltaY)-Math.sign(n.deltaY))===Math.abs(e);i=Math.abs(e)===Math.abs(n.deltaY)||r}}else Qn?Math.abs(n.deltaY)>Math.abs(n.deltaX)?i=!1:i=s===n.deltaX*-3:i=e===n.deltaY*-3;i&&(t=!0)}else n.deltaMode===0&&(t=!0);return Qn&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Za=(n,t)=>n==="percent"?t/4:t;var $a=Object.defineProperty,Ka=Object.defineProperties,qa=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,Ja=Object.prototype.hasOwnProperty,Qa=Object.prototype.propertyIsEnumerable,ei=(n,t,e)=>t in n?$a(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,tl=(n,t)=>{for(var e in t||(t={}))Ja.call(t,e)&&ei(n,e,t[e]);if(ti)for(var e of ti(t))Qa.call(t,e)&&ei(n,e,t[e]);return n},el=(n,t)=>Ka(n,qa(t));const Ae=ue?150:400,fe="VIEWPORT_ANIMATION";class si{constructor(t){this.animations={},this.animationInProgressSubject=new ut(!1),this.animFrameId=`canvas_animation_${yt()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=fe,i){const r=new Jn(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new Kn(el(tl({},i),{duration:i&&i.duration||Ae}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ae,i){const r=new qn({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0)}processAnimation(){Pe(this.animFrameId,()=>this.tick())}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():queueMicrotask(()=>{this.processAnimation(),this.eventBus.fireDraw()})}stopInterval(){ka(this.animFrameId)}}function Et(n,t){return t===void 0&&(t=de),n=n!=null?n:sl,N(function(e,s){var i,r=!0;e.subscribe(vt(s,function(o){var a=t(o);(r||!n(i,a))&&(r=!1,i=a,s.next(o))}))})}function sl(n,t){return n===t}function nl(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Hs(n){return n}function ni(n){return n!=null}const Jp=()=>{};function Qp(n){return n!=null}function il(n,t,e=rl,s=!0){const i=n.filter(r=>t.some(o=>e(r,o)));return s?i.filter((r,o,a)=>a.indexOf(r)===o):i}const ii=(n,t)=>{const e=t.slice().filter(s=>n.find(i=>i===s));return n.map(s=>{var i;return t.indexOf(s)>=0&&(i=e.shift())!=null?i:s})},rl=(n,t)=>n===t,tm=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),ol=(n,t)=>n===t,ri=(n,t,e=ol)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function em(n,t,e){const s=n.slice(),i=s[t];return s.splice(t,1),s.splice(e,0,i),s}function ks(n,t,e){const s=n.length,i=Rs(t,0,s-1),r=Rs(e,0,s-1),o=n[i];return n.splice(i,1),n.splice(r,0,o),n}function sm(n,t,e){const s=n.slice(),i=s.findIndex(t);return i!==-1&&(s.splice(i,1),s.splice(i,0,e)),s}const nm=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},im=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),rm=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),om=n=>Array.isArray(n[0]),oi=n=>Array.isArray(n[0])?n:[n],al=(n,t,e)=>{const s=[];let i=0;for(const r of n){const o=Math.max(t-i,0),a=Math.max(e-i,-1),l=r.slice(o,a+1);l.length>0&&s.push(l),i+=r.length}return s},ll=(n,t)=>n>=0?t[n]:t[t.length+n],gt=n=>Array.prototype.flat?n.flat():Ee(n,Hs),Ee=(n,t)=>{if(Array.prototype.flatMap)return n.flatMap(t);const e=[];for(let s=0;s<n.length;s++){const i=n[s];e.push(...t(i,s,n))}return e};function Bt(n,t,e){const s=e!=null?e:Hs;return!n.length||t!==t?{index:-1,exact:!0}:js(n,t,0,n.length,s)}function js(n,t,e,s,i){const r=za(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?js(n,t,e,r,i):js(n,t,r,s,i)}function wt(n){if(n&&n.length)return n[n.length-1]}function cl(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function hl(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ge(n){if(n)return n[0]}function dl(n){function t(e,s){const i=n(s);return i==null||!isFinite(i)?e:[Math.max(e[0],i),Math.min(e[1],i)]}return function(e){const s=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,s):s}}function ul(n,t,e,s=()=>0){const i=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])<=a?l=h+1:c=h-1}return c},r=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])>=a?c=h-1:l=h+1}return l};return n.slice(r(n,t),i(n,e)+1)}let Ys;const jt=()=>(Ys||(Ys=!!navigator.userAgent.match(/Android|iPhone|Opera Mini/)||!1),Ys),fl=1.33;function ai(n,t){let e="";t.textStyle&&(t.textStyle.italic&&(e+="italic "),t.textStyle.bold&&(e+="bold ")),n.font=e+(t.textSize||12)+" "+(t.textFontFamily||"monospace"),n.fillStyle=t.textFill||"#FFFFFF",t.rtl?n.textAlign="right":n.textAlign="start"}function Qe(n,t=!0){const e=n.font.match(/(\d+.)?\d+(px|pt)/gi);let s="10px";return e&&e.length&&(e[0].includes("pt")?s=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":s=e[0]),t?parseInt(s,10)*fl:parseInt(s,10)}function li(n,t,e){n.save(),ai(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(o=>n.measureText(o).width))),i=Qe(n),r=i*t.length;return n.restore(),[s,r,i]}function ci(n){return(n||"").split(/\r\n|\r|\n/)}function gl(n,t,e,s,i){n.save();const[r,,o]=li(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=pl(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&ml(n,a,f,s+o*l,(h=i.textFill)!=null?h:"",(d=i.textSize)!=null?d:""),n.fillText(a,f,s+o*l)}),n.restore()}function pl(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function ml(n,t,e,s,i,r){n.save();const o=n.measureText(t).width,a=e,l=e+o,c=s+2,h=c;let d=parseInt(r,10)/15;d<1&&(d=1),n.beginPath(),n.strokeStyle=i,n.lineWidth=d,n.moveTo(a,c),n.lineTo(l,h),n.stroke(),n.restore()}function am(n){return`${n}px`}function ee(n,t,e){const s=Ot().rgb(n).array(),i=s[0],r=s[1],o=s[2];return(i*299+r*587+o*114)/1e3<128?t:e}function vl(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=hi(t,i.dateFormat,e),a=ci(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=li(n,a,l);return[c+r.x*2,h+r.y*2]}function hi(n,t,e){return e(t)(n).split(" ").join(`
9
+ `)}const di={};function Yt(n,t){let e=di[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,di[n]=e,t.restore()),e}const ui=new Map;function Tt(n,t,e){const s=e+n;let i=ui.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,ui.set(s,i),t.restore()),i}function Mt(n,t,e=fi){function s(i,r){for(const o in r)o in i?typeof i[o]=="object"&&i[o]!==null&&!Array.isArray(i[o])?s(i[o],r[o]):e!=null&&e.overrideExisting&&(i[o]=r[o]):e!=null&&e.addIfMissing&&(i[o]=r[o]);return i}return s(n,t)}function lm(n,t,e,s=!1){!n||!t||t.length===0||t.forEach(i=>{const r=e(i),o=n.findIndex(a=>e(a)===r);o===-1?n.push(i):s?Mt(n[o],i,{overrideExisting:!0,addIfMissing:!0}):n.splice(o,1,i)})}const fi={overrideExisting:!1,addIfMissing:!0};function bl(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){const s=n.charCodeAt(e);t=(t<<5)-t+s,t|=0}return t}const Ns=1,Cl=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),gi=(n,t)=>`${n}_${bl(t.toString())}`;function ts(n,t){return t===n?"none":t>n?"up":"down"}function yl(n,t){return t>n?"up":"down"}function wl(n,t,e=!1){const{id:s,expansion:i,impVolatility:r,vwap:o,typicalPrice:a,volume:l,timestamp:c}=n;let h=n.hi,d=n.lo,u=n.open;const f=n.close;e&&(h=f,d=f,u=f);let p=n.idx;return t!==void 0&&(p=t),{id:s,hi:h,lo:d,open:u,close:f,timestamp:c,volume:l,expansion:i,idx:p,impVolatility:r,vwap:o,typicalPrice:a}}var Sl=Object.defineProperty,pi=Object.getOwnPropertySymbols,xl=Object.prototype.hasOwnProperty,_l=Object.prototype.propertyIsEnumerable,mi=(n,t,e)=>t in n?Sl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Pl=(n,t)=>{for(var e in t||(t={}))xl.call(t,e)&&mi(n,e,t[e]);if(pi)for(var e of pi(t))_l.call(t,e)&&mi(n,e,t[e]);return n};const vi="Open Sans Semibold, sans-serif",Tl=null,Ml=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],cm=n=>Tl.find(t=>t===n)!==void 0,es=()=>({devexpertsPromoLink:!0,useUTCTimeOverride:!1,shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rtl:!1,intlFormatter:{decimalSeparator:".",thousandsSeparator:""},scale:{keepZoomXOnYAxisChange:!0,auto:!0,zoomToCursor:!1,lockPriceToBarRatio:!1,autoScaleOnCandles:!0,autoScaleDisableOnDrag:{enabled:!0,edgeAngle:Math.PI/15,yDiff:80},inverse:!1,zoomSensitivity:{wheel:.25},defaultViewportItems:100,disableAnimations:!1},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,components:{chart:{type:"candle",showCandlesBorder:!0,showActiveCandlesBorder:!0,showWicks:!0,candleLineWidth:1,lineWidth:1,areaLineWidth:1,barLineWidth:1,minWidth:.5,minCandles:10,candlePaddingPercent:.25,highlightActiveCandle:!0,cursor:"default",selectedWidth:3,minCandlesOffset:2,defaultZoomCandleWidth:7,zoomStep:0,histogram:{barCapSize:1},maxYAxisScalesAmount:10,applyBackgroundToAxes:{x:!0,y:!0},sortCandles:Cl},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:vi,cursor:"ns-resize",resizeDisabledCursor:"default",labelBoxMargin:{top:4,bottom:4,end:8,start:10},typeConfig:{badge:{rounded:!0,paddings:{top:4,bottom:4,end:4,start:4}},plain:{},rectangle:{rounded:!1,paddings:{top:4,bottom:4,end:4,start:4}}},labels:{descriptions:!1,settings:{lastPrice:{mode:"label",type:"badge"},countdownToBarClose:{mode:"none",type:"rectangle"}}},treasuryFormat:{enabled:!1}},xAxis:{visible:!0,formatsForLabelsConfig:{lessThanSecond:"HH:mm:ss",second_1:"HH:mm:ss",minute_1:"HH:mm",minute_5:"HH:mm",minute_30:"HH:mm",hour_1:"HH:mm",day_1:"dd.MM",month_1:"MMM",year_1:"YYYY"},fontSize:12,fontFamily:vi,cursor:"ew-resize",padding:{top:8,bottom:16},fontStyle:""},events:{visible:!1,eventsVisibility:{"conference-calls":!0,dividends:!0,splits:!0,earnings:!0},height:20,cursor:"default",xAxisLabelFormat:[{format:"d MMM"}],icons:{earnings:{normal:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" stroke="#D92C40" stroke-width="1.5"/></svg>',hover:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" fill="#D92C40" stroke="#D92C40" stroke-width="1.5"/></svg>'}}},offsets:{visible:!0,right:10,top:10,bottom:20,left:0},waterMark:{visible:!1,fontFamily:"Open Sans, sans-serif",firstRowFontSize:80,firstRowBottomPadding:10,secondRowFontSize:40,secondRowBottomPadding:25,thirdRowFontSize:40,thirdRowBottomPadding:15,position:"center",offsetX:20,offsetY:20,logoWidth:20,logoHeight:20},highLow:{visible:!1,font:"12px sans-serif",prefix:{high:"H: ",low:"L: "}},highlights:{visible:!1,fontFamily:"Open Sans",fontSize:13,border:{width:1,dash:[8,4]}},crossTool:{type:"cross-and-labels",discrete:!0,magnetTarget:"none",lineDash:[4,6],xAxisLabelFormat:[{format:"dd.MM.YYYY",showWhen:{periodMoreThen:1440*60*1e3}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:1440*60*1e3,periodMoreThen:6*1e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6*1e3}}],xLabel:{padding:{top:4,bottom:4,right:8,left:8},margin:{top:4}},yLabel:{padding:{top:4,bottom:4,end:4,start:4},type:"badge"}},grid:{visible:!0,horizontal:!1,vertical:!0,width:1,dash:[0,0],color:"#FFFFFF"},volumes:{visible:!0,showSeparately:!1,valueLines:15,barCapSize:1,volumeBarSpace:0,volumeFillColor:"#FFFFFF"},navigationMap:{visible:!1,allCandlesHistory:!0,timeLabels:{visible:!1,dateFormat:"dd.MM.YYYY HH:mm",fontFamily:"Open Sans",fontSize:13,padding:{x:10,y:1}},minSliderWindowWidth:10,cursors:{chart:"default",buttonLeft:"pointer",buttonRight:"pointer",leftResizer:"ew-resize",rightResizer:"ew-resize",slider:"grab"},knots:{height:35,width:7,border:0,lineWidth:1}},baseline:{cursor:"ns-resize",dragZone:3,height:1},paneResizer:{cursor:"ns-resize",height:1,visible:!0,fixedMode:!1,dragZone:3}},colors:{candleTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(77,153,83,1)",downWickColor:"rgba(217,44,64,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:1},barTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},lineTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},chartAreaTheme:{backgroundMode:"regular",backgroundColor:"rgba(20,20,19,1)",backgroundGradientTopColor:"red",backgroundGradientBottomColor:"blue",gridColor:"rgba(37,37,36,1)"},scatterPlot:{mainColor:"rgba(255,255,255,1)"},areaTheme:{lineColor:"rgba(127,120,214,1)",startColor:"rgba(169,38,251,1)",stopColor:"rgba(169,38,251,0.8)"},baseLineTheme:{lowerSectionStrokeColor:"rgba(217,44,64,1)",upperSectionStrokeColor:"rgba(77,153,83,1)",lowerSectionFillColor:"rgba(217, 44, 64, 0.07)",upperSectionFillColor:"rgba(77, 153, 83, 0.07)",baselineColor:"rgba(55,55,54,1)"},histogram:{upCap:"rgba(77,153,83,1)",upBottom:"rgba(77,153,83,0.1)",upBright:"rgba(77,153,83,0.4)",downCap:"rgba(217,44,64,1)",downBottom:"rgba(217,44,64,0.1)",downBright:"rgba(217,44,64,0.4)",noneCap:"rgba(255,255,255,1)",noneBottom:"rgba(255,255,255,0.1)",noneBright:"rgba(255,255,255,0.4)"},crossTool:{lineColor:"rgba(107,96,86,1)",labelBoxColor:"rgba(107,96,86,1)",labelTextColor:"rgba(255,255,255,1)"},waterMarkTheme:{firstRowColor:"rgba(255,255,255,0.2)",secondRowColor:"rgba(255,255,255,0.2)",thirdRowColor:"rgba(255,255,255,0.2)"},highlights:{NO_TRADING:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"},AFTER_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(38, 251, 149, 0.05)",label:"transparent"},PRE_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(255, 170, 0, 0.05)",label:"transparent"},REGULAR:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"}},activeCandleTheme:{upColor:"rgba(98,201,93,1)",downColor:"rgba(255,47,47,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(98,201,93,1)",downWickColor:"rgba(255,47,47,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:.5},volume:{downBarColor:"rgba(99,30,37,1)",upBarColor:"rgba(42,72,44,1)",noneBarColor:"rgba(255,255,255,0.4)",upCapColor:"rgba(42,72,44,1)",downCapColor:"rgba(99,30,37,1)",noneCapColor:"rgba(255,255,255,0.4)"},highLowTheme:{highColor:"rgba(223,222,223,1)",lowColor:"rgba(223,222,223,1)"},instrumentInfo:{textColor:"#aeb1b3"},paneResizer:{lineColor:"rgba(61,61,61,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)",normal:"rgba(217,44,64,1)",hover:"rgba(217,44,64,1)",line:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)",normal:"rgba(169,38,251,1)",hover:"rgba(169,38,251,1)",line:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)",normal:"rgba(244,187,63,1)",hover:"rgba(244,187,63,1)",line:"rgba(244,187,63,1)"},"conference-calls":{color:"rgba(48,194,97,1)",normal:"rgba(48,194,97,1)",hover:"rgba(48,194,97,1)",line:"rgba(48,194,97,1)"}},secondaryChartTheme:[{lineTheme:{upColor:"rgba(226,61,25,1)",downColor:"rgba(226,61,25,1)",noneColor:"rgba(226,61,25,1)"},areaTheme:{lineColor:"rgba(226,61,25,1)",startColor:"rgba(226,61,25,0.8)",stopColor:"rgba(226,61,25,0)"}},{lineTheme:{upColor:"rgba(250,191,64,1)",downColor:"rgba(250,191,64,1)",noneColor:"rgba(250,191,64,1)"},areaTheme:{lineColor:"rgba(250,191,64,1)",startColor:"rgba(250,191,64,0.8)",stopColor:"rgba(250,191,64,0)"}},{lineTheme:{upColor:"rgba(169,38,251,1)",downColor:"rgba(169,38,251,1)",noneColor:"rgba(169,38,251,1)"},areaTheme:{lineColor:"rgba(169,38,251,1)",startColor:"rgba(169,38,251,0.8)",stopColor:"rgba(169,38,251,0)"}},{lineTheme:{upColor:"rgba(77,211,240,1)",downColor:"rgba(77,211,240,1)",noneColor:"rgba(77,211,240,1)"},areaTheme:{lineColor:"rgba(77,211,240,1)",startColor:"rgba(77,211,240,0.8)",stopColor:"rgba(77,211,240,0)"}},{lineTheme:{upColor:"rgba(59,203,91,1)",downColor:"rgba(59,203,91,1)",noneColor:"rgba(59,203,91,1)"},areaTheme:{lineColor:"rgba(59,203,91,1)",startColor:"rgba(59,203,91,0.8)",stopColor:"rgba(59,203,91,0)"}}],yAxis:{backgroundColor:"rgba(20,20,19,1)",labelBoxColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)",labelInvertedTextColor:"rgba(20,20,19,1)",rectLabelTextColor:"rgba(255,255,255,1)",rectLabelInvertedTextColor:"rgba(20,20,19,1)",zeroPercentLine:"rgba(55,55,54,1)"},labels:{lastPrice:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(0,0,0,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},countdownToBarClose:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(255,255,255,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},highLow:{high:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"High"},low:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Low"}},bidAsk:{bid:{boxColor:"rgba(77,153,83,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Bid"},ask:{boxColor:"rgba(217,44,64,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Ask"}},prePostMarket:{post:{boxColor:"rgba(38,251,149,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Post"},pre:{boxColor:"rgba(255,170,0,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Pre"}},prevDayClose:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)"}},xAxis:{backgroundColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)"},navigationMap:{backgroundColor:"transparent",buttonColor:"rgba(255,255,255,0.1)",buttonArrowColor:"rgba(212,212,211,1)",knotColor:"rgba(255,255,255,0.1)",knotLineColor:"rgba(212,212,211,1)",sliderColor:"rgba(255,255,255,0.08)",knotBorderColor:"#0b0d1a",timeLabelsTextColor:"rgba(128,128,128,1)",mapColor:"rgba(255,255,255,0.1)",mapFillColor:"rgba(255,255,255,0.1)",mapGradientTopColor:"rgba(255,255,255,0.1)",mapGradientBottomColor:"rgba(255,255,255,0.1)"}},animation:{moveDuration:1e3,candleDuration:200,paneResizer:{bgMode:!0,enabled:!0,duration:40},yAxis:{background:{enabled:!1,duration:40}}},drawingOrder:["OVER_SERIES_CLEAR","MAIN_CLEAR","SERIES_CLEAR","GRID","X_AXIS","Y_AXIS","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function Al(n,t=es()){return Mt(n,t,fi),n}function hm(n,t=es()){const e=Pl({},n);return merge(e,t,DEFAULT_MERGE_OPTIONS),e}function dm(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function bi(n){return typeof n=="object"&&n!==null}function Ci(n,t){return[...n].map(s=>Xs(s,t))}const El=n=>Array.isArray(n);function Xs(n,t){if(!bi(n))return n;if(El(n))return Ci(n,t);{const e=yi({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function yi(n,t,e){if(!bi(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return Ci(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=Xs(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=yi(n[i],t[i],e):e.addIfMissing&&(s[i]=Xs(t[i],e))}),s}const se=n=>`${n.fontSize}px ${n.fontFamily}`;class Il{constructor(t,e){this.config=t,this.mainCanvasModel=e,this.extentsOrder=new Map,this.yAxisWidthContributors=[]}registerYAxisWidthContributor(t){this.yAxisWidthContributors.push(t)}removeYAxisWidthContributor(t){this.yAxisWidthContributors=this.yAxisWidthContributors.filter(e=>e!==t)}getTextWidth(t){const e=se(this.config.components.yAxis);return Tt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(s=>{var i,r,o;const a=s.getYAxisState();if(!a.visible)return;const l=a.labelBoxMargin.start+a.labelBoxMargin.end,c=this.getTextWidth(s.getLargestLabel())+l,h=s.getYAxisIndex(),d=s.getPaneUUID(),u=(i=this.extentsOrder.get(d))!=null?i:{left:[],right:[]};if(a.align==="left"){const f=u.left.length;t[f]=Math.max((r=t[f])!=null?r:0,c),u.left.push(h)}else{const f=u.right.length;e[f]=Math.max((o=e[f])!=null?o:0,c),u.right.push(h)}this.extentsOrder.set(d,u)}),{left:t,right:e}}}var Dl=Object.defineProperty,Ll=Object.defineProperties,Ol=Object.getOwnPropertyDescriptors,wi=Object.getOwnPropertySymbols,Bl=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable,Si=(n,t,e)=>t in n?Dl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Nt=(n,t)=>{for(var e in t||(t={}))Bl.call(t,e)&&Si(n,e,t[e]);if(wi)for(var e of wi(t))Rl.call(t,e)&&Si(n,e,t[e]);return n},xi=(n,t)=>Ll(n,Ol(t));const $="CHART",nt=class{};nt.CANVAS="CANVAS",nt.N_MAP="N_MAP",nt.X_AXIS="X_AXIS",nt.N_MAP_KNOT_L="N_MAP_KNOT_L",nt.N_MAP_KNOT_R="N_MAP_KNOT_R",nt.N_MAP_BTN_L="N_MAP_BTN_L",nt.N_MAP_BTN_R="N_MAP_BTN_R",nt.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",nt.N_MAP_CHART="N_MAP_CHART",nt.N_MAP_LABEL_R="N_MAP_LABEL_R",nt.N_MAP_LABEL_L="N_MAP_LABEL_L",nt.PANE_UUID=n=>"PANE_"+n,nt.PANE_UUID_Y_AXIS=(n,t=0)=>"PANE_"+n+"_Y_AXIS_"+t,nt.PANE_UUID_RESIZER=n=>"PANE_"+n+"_RESIZER",nt.ALL_PANES="ALL_PANES",nt.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",nt.EVENTS="EVENTS",nt.CHART=nt.PANE_UUID($),nt.Y_AXIS=nt.PANE_UUID_Y_AXIS($);let T=nt;const _i={x:0,y:0,pageX:0,pageY:0,width:0,height:0},Pi=20,Ti=35,Ws=15,Mi=1.5,Ai=jt()?8*Mi:8,Ie=jt()?5:0,Fl=1e-6;class zs{constructor(t,e,s,i,r){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new B,this.paneMovedSubject=new B,this.paneVisibilityChangedSubject=new B,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new B,this.barResizerChangedSubject=new B,this._graphsHeightRatio={[$]:1},this.graphsHeightRatioChangedSubject=new B,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new Il(this.config,this.canvasModel)}get graphsHeightRatio(){return this._graphsHeightRatio}updateYAxisWidths(){const t=this.yAxisBoundsContainer.getYAxisWidths();this.setYAxisWidths(t)}addPaneBounds(t,e){if(this.panesOrder.indexOf(t)===-1){if(this.panesOrder.push(t),e!==void 0){const s=this.panesOrder.indexOf(t);ks(this.panesOrder,s,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=Nt(Nt({},this.graphsHeightRatio),t),s=Object.values(e).reduce((i,r)=>i+r,0);Math.abs(s-1)<Fl?(this._graphsHeightRatio=e,this.recalculateBounds()):console.error(`Result ratio should be equal 1, but equal ${s}`)}movePaneUp(t){const e=this.panesOrder.indexOf(t);e!==-1&&(ks(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(ks(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}reorderPanes(t){this.panesOrder=ii(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}hidePaneBounds(t){this.graphsHeightRatio[t]=0,this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}showPaneBounds(t){if(t===$){const[e]=Ei(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){hl(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[T.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[T.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[T.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,s=this.config.components.paneResizer.height,i=this.getBounds(T.CANVAS);i.x=0,i.y=0,i.width=t,i.height=e;const r=this.yAxisWidths,o=this.getNavMapBounds(i),a=this.getXAxisBounds(o,i),l=e-a.height-o.height,c=r.left.reduce((F,R)=>F+R,0),h=r.right.reduce((F,R)=>F+R,0),d=0,u=i.width-h,f=d+c,p=0,v=i.width-c-h;let x=p;const _=this.panesOrder.findIndex(F=>this.graphsHeightRatio[F]>0);this.panesOrder.forEach((F,R)=>{var k;const q=this.graphsHeightRatio[this.panesOrder[R]],W=T.PANE_UUID_RESIZER(F),U=T.PANE_UUID(F),G=this.config.components.paneResizer.visible&&R>_&&q>0;G?pe(this.bounds,W,0,x,i.width,s,this.canvasOnPageLocation):pe(this.bounds,W,0,0,0,0,this.canvasOnPageLocation);const V=x+(G?s:0),Q=pe(this.bounds,U,f,V,v,l*q-(G?s:0),this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const J=this.yAxisBoundsContainer.extentsOrder.get(F);if(J===void 0)return;const et=l*q-(G?s:0);let tt=f-((k=r.left[0])!=null?k:0),st=u;J.left.forEach((ct,at)=>{var _t;pe(this.bounds,T.PANE_UUID_Y_AXIS(F,ct),tt,V,r.left[at],et,this.canvasOnPageLocation),tt-=(_t=r.left[at+1])!=null?_t:0}),J.right.forEach((ct,at)=>{pe(this.bounds,T.PANE_UUID_Y_AXIS(F,ct),st,V,r.right[at],et,this.canvasOnPageLocation),st+=r.right[at]})}else pe(this.bounds,T.PANE_UUID_Y_AXIS(F),0,0,0,0,this.canvasOnPageLocation);x=Q.y+Q.height});const A=this.getBounds(T.ALL_PANES);A.x=f,A.y=p,A.width=v,A.height=x;const L=this.getBounds(T.CHART_WITH_Y_AXIS),Y=this.getBounds(T.CHART);this.getEventsBounds(Y),this.copyBounds(Y,L),L.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=xi(Nt({},this.canvasOnPageLocation),{x:t.x,y:t.y,width:t.width,height:t.height})}updateAllBoundsPageCoordinates(){for(const t of Object.keys(this.bounds)){const e=this.bounds[t];e.pageX=e.x+this.canvasOnPageLocation.x,e.pageY=e.y+this.canvasOnPageLocation.y}}getEventsBounds(t){const e=this.getBounds(T.EVENTS);return this.config.components.events.visible?(e.x=0,e.y=t.y+t.height-this.config.components.events.height,e.width=t.width,e.height=this.config.components.events.height):this.applyDefaultBounds(e),e}getNavMapBounds(t){const e=this.getBounds(T.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-Ti,e.width=t.width,e.height=Ti):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const s=this.getBounds(T.X_AXIS),i=this.yAxisWidths.left.length+this.yAxisWidths.right.length===1,r=i?0:this.yAxisWidths.left.reduce((a,l)=>a+=l,0),o=i?0:this.yAxisWidths.right.reduce((a,l)=>a+=l,0);if(this.config.components.xAxis.visible){const a=this.getXAxisHeight();s.x=r,s.y=e.height-a-t.height,s.width=e.width-o,s.height=a}else this.applyDefaultBounds(s);return s}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const s=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,i=Yt(s,this.canvasModel.ctx);this.xAxisHeight=i+((t=this.config.components.xAxis.padding.top)!=null?t:0)+((e=this.config.components.xAxis.padding.bottom)!=null?e:0)+Ie}return this.xAxisHeight}setYAxisWidths(t){(!ri(this.yAxisWidths.left,t.left)||!ri(this.yAxisWidths.right,t.right))&&(this.yAxisWidths=t,this.recalculateBounds())}setXAxisHeight(t){t!==this.xAxisHeight&&(this.xAxisHeight=t,this.recalculateBounds())}setPanesOrder(t){this.panesOrder=t,this.recalculateBounds()}recalculatePanesHeightRatios(){this.calculateGraphsHeightRatios(),this.recalculateBounds()}calculateGraphsHeightRatios(){let t=this.graphsHeightRatio[$];const e=[];e.push(...this.panesOrder.filter(p=>p!==$));const s=e.map(p=>this.graphsHeightRatio[p]===void 0?void 0:this.graphsHeightRatio[p]),i=s.filter(p=>p!==0),r=i.length,o=i.filter(p=>p!==void 0).length,a=s.filter(p=>p===void 0).length,l=a>0;let c=0,h=0,d=1,u=0;if(l&&([d,u]=Ei(r)),(!this.graphsHeightRatio[$]||this.graphsHeightRatio[$]===0)&&(t=0),this.graphsHeightRatio[$]&&this.graphsHeightRatio[$]!==0)if(l)t=1*d;else{const p=Object.values(this.graphsHeightRatio).reduce((v,x)=>x+=v);p<1&&this.graphsHeightRatio[$]!==0&&(t+=1-p)}o===0&&(t=1-u*a),h=1-t-u*a,i.forEach(p=>{p&&(h-=p*d)}),c=h/(r||1);const f=s.map(p=>p===0?p:p?p*d+c:u+c);this._graphsHeightRatio={},this.graphsHeightRatio[$]=t,f.forEach((p,v)=>{const x=e[v];this.graphsHeightRatio[x]=p})}recalculateNavigationMapElementBounds(){var t,e,s,i;if(!this.config.components.navigationMap.visible)return;const r=this.getBounds(T.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=jt()?a*Mi:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=et=>vl(this.canvasModel.ctx,et,this.formatterFactory,this.config)[0],f=gt((i=(s=this.mainCandleSeries)==null?void 0:s.getSeriesInViewport())!=null?i:[]),p=d&&f.length?u(f[0].candle.timestamp):0,v=d&&f.length?u(f[f.length-1].candle.timestamp):0,x=Math.max(p,v);if(d){const et=this.getBounds(T.N_MAP_LABEL_L);et.x=r.x,et.y=r.y,et.width=x,et.height=r.height;const tt=this.getBounds(T.N_MAP_LABEL_R);tt.x=r.x+r.width-x,tt.y=r.y,tt.width=x,tt.height=r.height}const _=this.getBounds(T.N_MAP_BTN_L);_.x=r.x+x,_.y=r.y,_.width=Ws,_.height=r.height;const A=this.getBounds(T.N_MAP_BTN_R);A.x=r.x+r.width-Ws-x,A.y=r.y,A.width=Ws,A.height=r.height;const L=_.x+_.width,Y=A.x-L,F=L+Y,R=this.config.components.navigationMap.minSliderWindowWidth,k=c!=null?c:Ai,q=l!=null?l:r.height,W=k+R,U=this.getBounds(T.N_MAP_KNOT_L);U.x=L+Y*this.leftRatio,U.x=Math.min(U.x,F-W),U.y=h,U.width=k,U.height=q;const G=this.getBounds(T.N_MAP_KNOT_R);G.x=L+Y*this.rightRatio-Ai,G.x=Math.max(G.x,L+W),G.y=h,G.width=k,G.height=q;const V=W-(G.x-U.x);V>0&&(U.x-=V);const Q=this.getBounds(T.N_MAP_SLIDER_WINDOW);Q.x=U.x+U.width,Q.y=r.y,Q.width=G.x-Q.x,Q.height=r.height;const J=this.getBounds(T.N_MAP_CHART);J.x=L,J.y=r.y,J.width=Y,J.height=r.height}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){let e=this.bounds[t];return e===void 0&&(e=this.copyOf(_i),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>xi(Nt({},t),{[e]:this.bounds[T.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=ss){const{extensionX:s,extensionY:i,wholePage:r}=Nt(Nt({},ss),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-s&&o<l.pageX+l.width+s&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-s&&o<l.x+l.width+s&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=ss){const{extensionX:s,extensionY:i,wholePage:r}=Nt(Nt({},ss),e);return r?(o,a)=>o>t.pageX-s&&o<t.pageX+t.width+s&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-s&&o<t.x+t.width+s&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(T.CANVAS);return t.width>0&&t.height>0}isAllBoundsAvailable(){return Object.values(this.bounds).every(t=>t.width>=0&&t.height>=0)}resizePaneVertically(t,e){const s=this.panesOrder.indexOf(t),i=this.getBounds(T.PANE_UUID_RESIZER(t));this.doResizePaneVertically(s,i.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){let s=t-1;const i=this.panesOrder[s];if(this._graphsHeightRatio[i]<=0)for(let d=0;d<t;d++)this._graphsHeightRatio[this.panesOrder[d]]>0&&(s=d);const r=this.getBounds(T.ALL_PANES).height,o=Pi,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ut(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(dt(s=>this.copyOf(s)),Et((s,i)=>this.sameBounds(s,i)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return Nt({},t)}copyBounds(t,e){e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height}sameBounds(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}applyDefaultBounds(t){this.copyBounds(_i,t)}setMainCandleSeries(t){this.mainCandleSeries=t}getEffectiveYAxisWidth(){return this.getBounds(T.PANE_UUID_Y_AXIS($)).width}getEffectiveChartWidth(){return this.getBounds(T.PANE_UUID($)).width}getEffectiveChartHeight(){return this.getBounds(T.PANE_UUID($)).height}}const Hl={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},Ei=n=>{var t;const e=(t=Hl[n])!=null?t:.4,s=(1-e)/n;return[e,s]},um=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,kl=(n,t)=>n>t.y&&n<t.y+t.height,pe=(n,t,e,s,i,r,o)=>{const a=n[t];if(a)return a.x=e,a.y=s,a.pageX=e+o.x,a.pageY=s+o.y,a.width=i,a.height=r,a;const l={x:e,y:s,pageX:e+o.x,pageY:s+o.y,width:i,height:r};return n[t]=l,l},Ii=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),ss={extensionX:0,extensionY:0,wholePage:!1},Di=(n,t)=>n.width===t.width&&n.height===t.height;var jl=(function(n){z(t,n);function t(e,s){return n.call(this)||this}return t.prototype.schedule=function(e,s){return s===void 0&&(s=0),this},t})(he),ns={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=ns.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,D([n,t],m(e))):setInterval.apply(void 0,D([n,t],m(e)))},clearInterval:function(n){var t=ns.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Li=(function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i.pending=!1,i}return t.prototype.schedule=function(e,s){var i;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,s)),this.pending=!0,this.delay=s,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,s),this},t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),ns.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,s,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return s;s!=null&&ns.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,s);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var i=!1,r;try{this.work(e)}catch(o){i=!0,r=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,We(r,this),s!=null&&(this.id=this.recycleAsyncId(i,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(jl),De={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=De.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new he(function(){return e==null?void 0:e(i)})},requestAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=De.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,D([],m(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=De.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,D([],m(n)))},delegate:void 0},Yl=(function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i}return t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),i!==null&&i>0?n.prototype.requestAsyncId.call(this,e,s,i):(e.actions.push(this),e._scheduled||(e._scheduled=De.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,s,i){var r;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return n.prototype.recycleAsyncId.call(this,e,s,i);var o=e.actions;s!=null&&s===e._scheduled&&((r=o[o.length-1])===null||r===void 0?void 0:r.id)!==s&&(De.cancelAnimationFrame(s),e._scheduled=void 0)},t})(Li),Vs={now:function(){return(Vs.delegate||Date).now()},delegate:void 0},Oi=(function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,s){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(s,e)},n.now=Vs.now,n})(),Bi=(function(n){z(t,n);function t(e,s){s===void 0&&(s=Oi.now);var i=n.call(this,e,s)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var s=this.actions;if(this._active){s.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=s.shift());if(this._active=!1,i){for(;e=s.shift();)e.unsubscribe();throw i}},t})(Oi),Nl=(function(n){z(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var s;e?s=e.id:(s=this._scheduled,this._scheduled=void 0);var i=this.actions,r;e=e||i.shift();do if(r=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===s&&i.shift());if(this._active=!1,r){for(;(e=i[0])&&e.id===s&&i.shift();)e.unsubscribe();throw r}},t})(Bi),Xt=new Nl(Yl),fm=null,Us=new Bi(Li),Xl=Us;function Wl(n,t){return N(function(e,s){var i=t!=null?t:{},r=i.leading,o=r===void 0?!0:r,a=i.trailing,l=a===void 0?!1:a,c=!1,h=null,d=null,u=!1,f=function(){d==null||d.unsubscribe(),d=null,l&&(x(),u&&s.complete())},p=function(){d=null,u&&s.complete()},v=function(_){return d=Lt(n(_)).subscribe(vt(s,f,p))},x=function(){if(c){c=!1;var _=h;h=null,s.next(_),!u&&v(_)}};e.subscribe(vt(s,function(_){c=!0,h=_,!(d&&!d.closed)&&(o?x():v(_))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function zl(n){return n instanceof Date&&!isNaN(n)}function Vl(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Xl);var s=-1;return t!=null&&(Wn(t)?e=t:s=t),new bt(function(i){var r=zl(n)?+n-e.now():n;r<0&&(r=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=s?this.schedule(void 0,s):i.complete())},r)})}function Wt(n,t,e){t===void 0&&(t=Us);var s=Vl(n,t);return Wl(function(){return s},e)}class X{constructor(){this.subscriptions=[],this._state="initial",this.entities=[]}doActivate(){}doDeactivate(){this.subscriptions.forEach(t=>t()),this.subscriptions=[]}enable(){this._state!=="active"&&(this._state="deactivated",this.activate())}disable(){this._state!=="disabled"&&(this.deactivate(),this._state="disabled")}activate(){this._state!=="disabled"&&(this._state!=="active"&&(this.doActivate(),this._state="active"),this.entities.forEach(t=>t.activate()))}deactivate(){this._state!=="disabled"&&(this._state!=="deactivated"&&(this.doDeactivate(),this._state="deactivated"),this.entities.forEach(t=>t.deactivate()))}getState(){return this._state}addSubscription(t){this.subscriptions.push(t)}addRxSubscription(t){t&&this.subscriptions.push(t.unsubscribe.bind(t))}addChildEntity(t){this.entities.push(t),this._state==="active"&&t.activate()}removeChildEntity(t){this.entities=this.entities.filter(e=>e!==t)}}class Ul extends X{constructor(t,e,s,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new B}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(Wt(100,Xt,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(t,e,s,i=0){const r=zs.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:s,hitTest:r}):this.normalLayer.set(t,{cursor:s,hitTest:r})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(Et())}observeCursorType(t,e,s){const i=s?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(t);s?this.extensionLayer.set(t,{cursor:e,hitTest:i}):this.normalLayer.set(t,{cursor:e,hitTest:i})}updateCursor(t){this.element.style.cursor!==t&&(this.element.style.cursor=t,this.cursorChangedSubject.next(t))}}const Gl=n=>{const t=n.canvasArea!==null,e=n.snapshotCanvas!==null,s=n.backgroundCanvas!==null,i=n.mainCanvas!==null,r=n.yAxisLabelsCanvas!==null,o=n.crossToolCanvas!==null,a=n.hitTestCanvas!==null,l=n.chartResizer!==null,c=n.chartContainer!==null,h=n.dynamicObjectsCanvas!==null;return t&&e&&s&&i&&r&&o&&a&&l&&c&&h},Zl=(n=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
10
10
  <div data-element="chartContainer" style="position: absolute; height: 100%; width: 100%;" class="chart chartArea--graph">
11
11
  <div data-element="canvasArea" style="position: relative; height: 100%; width: 100%; touch-action: manipulation;">
12
12
  <canvas data-element="snapshotCanvas"></canvas>
@@ -21,4 +21,4 @@ ${n?` <p style="position: absolute; visibility: hidden;">If you have any sugge
21
21
  `:""} </div>
22
22
  </div>
23
23
  </div>
24
- `;function Hl(n){const t=document.createElement("template");return t.innerHTML=Fl(n.devexpertsPromoLink),t}function kl(n){const t={},e=Array.from(n.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(s=>{var i;t[(i=s.getAttribute("data-element"))!=null?i:""]=s}),Rl(t))return t;throw new Error("Some chart elements are missing")}function jl(n){if(n.length>1){const t=n.reduce((i,r,o)=>{if(o!==n.length-1){const a=n[o+1].timestamp-r.timestamp;i[a]?i[a]++:i[a]=1}return i},{});let e=0,s;for(const i of Object.keys(t)){const r=parseInt(i,10),o=t[r];o>e&&r>0&&(e=o,s=r)}if(s)return s}}const Yl=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Me=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Yl(!!c),u=d(n),f=d((r=(i=ce(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=wt(e))==null?void 0:o.timestamp)!=null?a:0);return u>p?h?{index:e.length-1+Math.ceil((u-p)/s),exact:!0}:{index:e.length-1,exact:!0}:u<f?h?{index:rt((u-f)/s),exact:!0}:{index:-1,exact:!0}:Bt(e,u,v=>d(v.timestamp))},Ti={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Mi={paintConfig:[Ti],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var Nl=Object.defineProperty,Ai=Object.getOwnPropertySymbols,Xl=Object.prototype.hasOwnProperty,zl=Object.prototype.propertyIsEnumerable,Ei=(n,t,e)=>t in n?Nl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wl=(n,t)=>{for(var e in t||(t={}))Xl.call(t,e)&&Ei(n,e,t[e]);if(Ai)for(var e of Ai(t))zl.call(t,e)&&Ei(n,e,t[e]);return n};class Vl{constructor(t,e,s,i){this.series=t,this.config=e,this.yAxisBoundsProvider=s,this.axisState=i}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,s=this.yAxisBoundsProvider(),i=this.config.labelMode,r=this.config.labelAppearanceType,o=e();if(o===void 0)return[];const a=this.series.view.toY(o.close);if(!isFinite(a))return[];const l=this.series.valueFormatter(o.close),c=this.getLabelDrawConfig();return[{labels:[Wl({y:a,description:this.series.name,mode:i,labelType:r,labelText:l},c)],axisState:this.axisState,bounds:s}]}getLabelDrawConfig(){var t;const e=this.series.config,i=((t=e.paintConfig[0])!=null?t:Ti).color;return{textColor:Qt(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function Ul(n,t){if(n.filter(a=>a!==null).length<=1)return n.map(a=>a.y);const e=t-2,s=n.map((a,l)=>Gl(a,l,e)).filter(Zn).sort(Zl),i=new Array(s.length),r=s.reduce((a,l)=>Math.min(a,l.labelWeight),Number.POSITIVE_INFINITY),o=s.findIndex(a=>a.labelWeight===r);for(let a=o;a>=0;a--){const l=s[a],c=s[a-1];if(l){if(c&&c.bottom>l.top){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.bottom=l.top-h,c.top=c.bottom-t}i[l.actualIndex]=(l.top+l.bottom)/2}}for(let a=o;a<s.length;a++){const l=s[a],c=s[a+1];if(!l)break;if(c&&c.top<l.bottom){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.top=l.bottom+h,c.bottom=c.top+t}i[l.actualIndex]=(l.top+l.bottom)/2}return i}const Gl=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,Zl=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var $l=Object.defineProperty,Kl=Object.defineProperties,ql=Object.getOwnPropertyDescriptors,Ii=Object.getOwnPropertySymbols,Jl=Object.prototype.hasOwnProperty,Ql=Object.prototype.propertyIsEnumerable,Di=(n,t,e)=>t in n?$l(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Li=(n,t)=>{for(var e in t||(t={}))Jl.call(t,e)&&Di(n,e,t[e]);if(Ii)for(var e of Ii(t))Ql.call(t,e)&&Di(n,e,t[e]);return n},Oi=(n,t)=>Kl(n,ql(t));const ee={MAIN:"MAIN"};class tc extends X{constructor(t,e,s,i,r,o,a,l){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.chartResizeHandler=l,this.orderedLabels=[],this.customLabels={},this._labelsProviders={},this.labelsPositionRecalculatedSubject=new R,this.animFrameId=`anim_cache_${yt()}`,this.initModel()}get labelsProviders(){return this._labelsProviders}doActivate(){super.doActivate(),this.addRxSubscription(bt(this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed,bt(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.paneUUID)),this.chartResizeHandler.canvasResized).pipe(ue(50,de,{trailing:!0,leading:!0}))).subscribe(()=>{this.updateLabels()}))}initModel(){this.initLabelsGroups(),this.recalculateLabels(),this.canvasModel.fireDraw()}initLabelsGroups(){for(const t of Object.keys(this.labelsProviders))this.createGroup(t),Object.entries(this.labelsProviders[t]).forEach(([e,s])=>{this.addToGroup(s,t,e)})}updateLabels(t=!1){this.recalculateLabels(),we(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const s=this.state.fontSize+((t=this.state.labelBoxMargin.top)!=null?t:0)+((e=this.state.labelBoxMargin.bottom)!=null?e:0);for(const i of Object.values(this.labelsProviders)){const r=Ct(Object.values(i).map(l=>l.getUnorderedLabels())),o=Ct(r.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),a=Ul(o,s);r.forEach(l=>{const c=a.splice(0,l.labels.length);this.orderedLabels.push(this.updateLabelsCoordinates(l,c))})}this.orderedLabels=this.orderedLabels.reverse()}createGroup(t){!this.labelsProviders[t]&&(this.labelsProviders[t]={})}addToGroup(t,e,s){this.labelsProviders[e]&&(Object.values(this.labelsProviders[e]).includes(t)||(this.labelsProviders[e][s]=t))}updateLabelsCoordinates(t,e){return Oi(Li({},t),{labels:t.labels.map((s,i)=>Oi(Li({},s),{lineY:s.y,y:e[i]}))})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[s]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const i=(s=this.labelsProviders[t])!=null?s:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}let Rt=window.devicePixelRatio,Je=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const js=()=>{Je.removeEventListener("change",js),Rt=window.devicePixelRatio,Je=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),Je.addEventListener("change",js)};Je.addEventListener("change",js);const ec=()=>Rt,Np=n=>round(Rt*n)/Rt,At=n=>rt(Rt*n)/Rt,Ys=n=>Ia(Rt*n)/Rt,se=n=>JSON.parse(JSON.stringify(n));function Ns(n){return Object.entries(n)}const Bi=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function Ri(n){return Object.keys(n)}function Fi(n,t){if(Object.is(n,t))return!0;if(typeof n!="object"||n===null||typeof t!="object"||t===null)return!1;const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(let i=0,r=e.length;i<r;i++)if(!hasOwnProperty.call(t,e[i])||!Fi(n[e[i]],t[e[i]]))return!1;return!0}const sc=n=>Object.keys(n).length===0&&n.constructor===Object;function Hi(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new R}:t,s=n.resetOnError,i=s===void 0?!0:s,r=n.resetOnComplete,o=r===void 0?!0:r,a=n.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var h,d,u,f=0,p=!1,v=!1,x=function(){d==null||d.unsubscribe(),d=void 0},P=function(){x(),h=u=void 0,p=v=!1},I=function(){var O=h;P(),O==null||O.unsubscribe()};return N(function(O,j){f++,!v&&!p&&x();var H=u=u!=null?u:e();j.add(function(){f--,f===0&&!v&&!p&&(d=Xs(I,l))}),H.subscribe(j),!h&&f>0&&(h=new ye({next:function(B){return H.next(B)},error:function(B){v=!0,x(),d=Xs(P,i,B),H.error(B)},complete:function(){p=!0,x(),d=Xs(P,o),H.complete()}}),Lt(O).subscribe(h))})(c)}}function Xs(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t===!0){n();return}if(t!==!1){var i=new ye({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,D([],m(e)))).subscribe(i)}}const Qe=(n,t)=>n/t,gt=(n,t)=>n/t,Nt=(n,t)=>n*t,ki=(n,t)=>(n-t)*100/t,ji=(n,t)=>n*t/100+t,Yi=n=>Math.log2(n),zs=n=>Math.pow(2,n);class nc extends X{constructor(){super(...arguments),this._xStart=0,this._xEnd=0,this._yStart=0,this._yEnd=0,this._zoomX=1,this._zoomY=1,this._inverseY=!1,this.changed=new R,this.xChanged=this.changed.pipe(dt(()=>({start:this.xStart,end:this.xEnd})),Et((t,e)=>t.start===e.start&&t.end===e.end),Hi()),this.yChanged=this.changed.pipe(dt(()=>({start:this.yStart,end:this.yEnd})),Et((t,e)=>t.start===e.start&&t.end===e.end),Hi()),this.initialViewportValidSubject=new ft(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+gt(t-this.xStart,this.zoomX)}xPixels(t){return gt(t,this.zoomX)}toY(t){const e=this.getBounds();return this.inverseY?e.y+gt(t-this.yStart,this.zoomY):e.y+e.height-gt(t-this.yStart,this.zoomY)}yPixels(t){return gt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return Nt(e+gt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),s=t-e.y;return this.inverseY?Nt(s+gt(this.yStart,this.zoomY),this.zoomY):Nt(e.height-s+gt(this.yStart,this.zoomY),this.zoomY)}recalculateZoomX(){this.zoomX=this.calculateZoomX(this.xStart,this.xEnd)}recalculateZoomY(){this.zoomY=this.calculateZoomY(this.yStart,this.yEnd)}calculateZoomX(t,e){return Qe(e-t,this.getBounds().width)}calculateZoomY(t,e){return Qe(e-t,this.getBounds().height)}recalculateZoom(t=!0){this.recalculateZoomX(),this.recalculateZoomY(),t&&this.fireChanged()}setXScale(t,e,s=!0){this.xStart=t,this.xEnd=e,this.recalculateZoomX(),s&&this.fireChanged()}setYScale(t,e,s=!0){this.yStart=t,this.yEnd=e,this.recalculateZoomY(),s&&this.fireChanged()}export(){return{xStart:this.xStart,xEnd:this.xEnd,yStart:this.yStart,yEnd:this.yEnd,zoomX:this.zoomX,zoomY:this.zoomY,inverseY:this.inverseY}}apply(t){this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.inverseY=t.inverseY,this.fireChanged()}fireChanged(){this.changed.next()}get xStart(){return this._xStart}set xStart(t){this._xStart=t}get xEnd(){return this._xEnd}set xEnd(t){this._xEnd=t}get yStart(){return this._yStart}set yStart(t){this._yStart=t}get yEnd(){return this._yEnd}set yEnd(t){this._yEnd=t}get zoomX(){return this._zoomX}set zoomX(t){this._zoomX=t}get zoomY(){return this._zoomY}set zoomY(t){this._zoomY=t}get inverseY(){return this._inverseY}set inverseY(t){this._inverseY=t}isViewportValid(t=!0){const e=t===!1||this.zoomX>0&&this.zoomY>0;return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)&&e}}const ic=(n,t)=>!Ri(n).some(e=>n[e]!==t[e]);class rc{constructor(t,e){this.scale=t,this.dataSeries=e,this.prevAnimationId=""}getBaselineForPercent(t){const e=this.scale.currentAnimation;let s;if(e!=null&&e.animationInProgress){e.id!==this.prevAnimationId&&(this.initialBaseline=void 0,this.targetBaseline=void 0,this.prevAnimationId=e.id);const i=e.easingFn(e.getProgress());this.initialBaseline===void 0&&(this.initialBaseline=t(Bt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(Bt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else s=t();return s}}class Ni{constructor(t,e,s,i){this.dataSeries=t,this.scale=e,this.getAxisType=s,this.getBaseline=i,this.toY=r=>this.scale.toY(this.toAxisUnits(r)),this.toX=r=>this.scale.toX(r),this.xPixels=r=>this.scale.xPixels(r),this.yPixels=r=>this.scale.yPixels(r),this.percentAnimationHandler=new rc(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return ki(t,s);case"logarithmic":return t<=0?t:Yi(t);case"regular":return t}}priceFromY(t){const e=this.scale.fromY(t);return this.fromAxisUnits(e)}fromAxisUnits(t){switch(this.getAxisType()){case"percent":return ji(t,this.getBaseline());case"logarithmic":return zs(t);case"regular":return t}}}var oc=Object.defineProperty,ac=Object.defineProperties,lc=Object.getOwnPropertyDescriptors,Xi=Object.getOwnPropertySymbols,cc=Object.prototype.hasOwnProperty,hc=Object.prototype.propertyIsEnumerable,zi=(n,t,e)=>t in n?oc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wi=(n,t)=>{for(var e in t||(t={}))cc.call(t,e)&&zi(n,e,t[e]);if(Xi)for(var e of Xi(t))hc.call(t,e)&&zi(n,e,t[e]);return n},dc=(n,t)=>ac(n,lc(t));class Ae{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return At(t.toY(this.close))}x(t){return t.toX(this.centerUnit)}clone(){return new Ae(this.centerUnit,this.close)}}class Vi extends X{constructor(t,e,s,i,r){var o;super(),this.extentComponent=t,this.id=e,this.htId=s,this.parentId=i,this.name="",this.highlighted=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=l=>{var c;return(c=this.config.paintConfig[l])!=null?c:this.config.paintConfig[0]},this.getBaseline=(l=this.dataIdxStart)=>{var c,h,d;return(c=this.visualPoints[l])!=null&&c.close&&((h=this.visualPoints[l])==null?void 0:h.close)>=0?(d=this.visualPoints[l])==null?void 0:d.close:1},this.getTextForPoint=l=>`${l.close}`,this.getLastVisualSeriesPoint=()=>{const l=this.visualPoints,c=Bt(l,this.scale.xEnd,h=>h.centerUnit).index;return l[c]},this.getLastDataSeriesPoint=()=>{const l=this.visualPoints;return wt(l)};const a=r!=null?r:se(Mi);this.config=Mt(a,Mi),this.scale=t.scale,this.view=new Ni(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Vl(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=fc(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=qn(t),this._dataPointsFlat=this._dataPoints.flat(),this.visualPoints=this._toVisualPoints(this._dataPoints)}get visualPoints(){return this._visualPointsFlat}get visualPoints2D(){return this._visualPoints}set visualPoints(t){this._visualPoints=qn(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.recalculateDataViewportIndexes())),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>{this.recalculateVisualPoints(),this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;const s=Wi({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new Ni(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider.yAxisBoundsProvider=t.getYAxisBounds,this.yAxisLabelProvider.axisState=(e=t.yAxis)==null?void 0:e.state;const i=s.yAxis.model.fancyLabelsModel.labelsProviders[ee.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[ee.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(ee.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(ee.MAIN,r))}this.deactivate(),this.activate(),t.addDataSeries(this)}toVisualPoints(t){return t.map((e,s)=>({centerUnit:s,close:e.close}))}setType(t){this.config.type=t,this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}recalculateVisualPoints(){this.visualPoints=this._toVisualPoints(this.dataPoints2D)}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i}calculateDataViewportIndexes(t,e){const s=Bt(this.visualPoints,t,r=>r.centerUnit).index,i=Bt(this.visualPoints,e,r=>r.centerUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}valueFormatter(t){return this.extentComponent.formatters.regular(t)}getSeriesInViewport(t,e){let s=this.dataIdxStart,i=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const r=this.calculateDataViewportIndexes(t,e);s=r.dataIdxStart,i=r.dataIdxEnd}return $a(this.visualPoints2D,s,i)}}const uc=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.close>t.high&&(t.high=s.close,t.highIdx=e),s.close<t.low&&(t.low=s.close,t.lowIdx=e)}return t},fc=n=>({isHighLowActive:()=>n.config.highLowActive,calculateHighLow:t=>{const e=uc(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return dc(Wi({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),gc=n=>{const e=r=>Math.ceil(Math.log(Math.abs(r))*Math.LOG10E),i=((r,o=5)=>Math.max(0,o-Math.max(0,e(r))))(n);return ut.makeDecimal(n,i)};class ts extends Ae{constructor(t,e,s,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.endUnit=t+e/2,this.width=e,this.open=s,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return Math.max(Math.abs(t.toY(this.open)-t.toY(this.close)),1)}candleHeight(t){return Math.abs(t.toY(this.high)-t.toY(this.low))}bodyAsVLine(t){if(this.width<2)return[this.centerUnit,this.yLineStart(t),this.width,this.candleHeight(t)]}bodyRect(t){return[this.startUnit,this.yBodyStart(t),this.width,this.bodyHeight(t)]}getCandle(){return this.candle}yBodyKeyPoints(t){const e=t.toY(this.high),s=t.toY(this.low),i=t.toY(this.open),r=t.toY(this.close),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>s?[s,e]:[e,s];return[l,o,a,c]}yLineEnd(t){return Math.max(t.toY(this.high),t.toY(this.low))}yLineStart(t){return Math.min(t.toY(this.high),t.toY(this.low))}yBodyStart(t){return Math.min(t.toY(this.open),t.toY(this.close))}yBodyEnd(t){return Math.max(t.toY(this.open),t.toY(this.close))}xCenter(t){return this.x(t)}xStart(t){return t.toX(this.startUnit)}}const fe=60,Ee=(n,t,e=fe)=>{const s=Ui(n,t,e);return{id:ri(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},pc=(n,t,e=fe)=>({close:NaN,timestamp:Ui(n,t,e)});function Ui(n,t,e=fe){var s,i;const r=xe(t);if(n.length===0)return 0;const o=wt(n);if(r>=n.length&&o)return Gi(o,n.length-1,r,e);const a=ce(n);return r<0&&a?Gi(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const Gi=(n,t,e,s=fe)=>n.timestamp+(e-(t!=null?t:0))*s,Ws=(n,t,e,s,i=fe)=>{const r=Ee(n,s,i);r.volume=e;let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new ts(o,e,r.open,r.close,r.lo,r.hi,Ze(r.open,r.close),r)},mc=(n,t,e,s,i=fe)=>{const r=pc(n,s,i);let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new Ae(o,r.close)};class vc{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new R,this.dataSetSubject=new R,this.dataRemovedSubject=new R,this.dataPrependSubject=new R,this.meanDataWidth=1,this.period=1}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=Me(t,e,s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=jl(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?Ws(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):mc(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var bc=Object.defineProperty,Zi=Object.getOwnPropertySymbols,Cc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable,$i=(n,t,e)=>t in n?bc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,wc=(n,t)=>{for(var e in t||(t={}))Cc.call(t,e)&&$i(n,e,t[e]);if(Zi)for(var e of Zi(t))yc.call(t,e)&&$i(n,e,t[e]);return n};class Sc{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!Fi(this.config.colors.chartAreaTheme,this.prevState)}draw(){if(this.drawPredicate()||this.isColorsChanged()){this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0+this.canvasModel.height/2,this.canvasModel.width,0+this.canvasModel.height/2);e.addColorStop(0,this.config.colors.chartAreaTheme.backgroundGradientTopColor),e.addColorStop(1,this.config.colors.chartAreaTheme.backgroundGradientBottomColor),t.fillStyle=e}else t.fillStyle=this.config.colors.chartAreaTheme.backgroundColor;t.fillRect(0,0,this.canvasModel.width,this.canvasModel.height)}this.prevState=wc({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const xc=(n,t,e,s,i,r,o)=>{const a=ec(),l=[e*a,s*a,i*a,r*a];let c=n.getImageData(...l);if(o!==void 0){const h=c.data[3]/255;if(h===1)for(let d=3;d<c.data.length;d+=4)c.data[d]=rt(c.data[d]*o);else for(let d=0;d<c.data.length;d++){const u=c.data[d];c.data[d]=d%4===3?rt(u*o):rt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},Ki=(n,{x:t,width:e,activeCandle:s})=>new ts(t,e,n.open,n.close,n.hi,n.lo,Ze(n.open,n.close),n,!0,Vs(n,s)),Pc=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new ts(t,e,n.open,n.close,n.hi,n.lo,ll((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,Vs(n,s),n.close>n.open)},qi=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new ts(t,e,n.open,n.close,n.hi,n.lo,Ze((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,Vs(n,s),n.close>n.open)},_c=qi,Vs=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},Ji=()=>Os,Ie=class re{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>rt(Math.log10((i^i>>31)-(i>>31)))+1;let s=e(t);return s===1&&t<1&&(s=e(t*1e9)-9),s}static getPriceIncrement(t,e=[]){if(!this.validatePriceIncrementsOrPrecisions(e))return this.DEFAULT_INCREMENT;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;const i=1e-6;for(;s<e.length&&t>e[s]+Math.min(e[s-1],e[s+1])*i;)s+=2;return s>=e.length||t<e[s]-Math.min(e[s-1],e[s+1])*i?e[s-1]:Math.min(e[s-1],e[s+1])}static getPricePrecision(t,e){if(!this.validatePriceIncrementsOrPrecisions(e))return 0;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;for(;s<e.length&&t>e[s];)s+=2;return Math.round(e[s-1])}static roundPriceToIncrement(t,e,s){const i=re.getPriceIncrement(s||t,e);return ut.roundToNearest(t,i)}static computePrecisions(t){const e=[...t];for(let s=0;s<t.length;s+=2)e[s]=re.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*re.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<re.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*re.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return re.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(t){return!(t.length===0||!Array.isArray(t)||t.findIndex(e=>e!==0)===-1)}};Ie.DEFAULT_INCREMENT=.01,Ie.DEFAULT_PRECISION=2,Ie.RELATIVE_EPS=1e-8,Ie.MAXIMUM_PRECISION=10;let ge=Ie;const Tc=(n,t)=>{var e;const s=(e=wt(t))!=null?e:1;return Math.pow(10,-s)};var Mc=Object.defineProperty,Ac=Object.defineProperties,Ec=Object.getOwnPropertyDescriptors,Qi=Object.getOwnPropertySymbols,Ic=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable,tr=(n,t,e)=>t in n?Mc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Lc=(n,t)=>{for(var e in t||(t={}))Ic.call(t,e)&&tr(n,e,t[e]);if(Qi)for(var e of Qi(t))Dc.call(t,e)&&tr(n,e,t[e]);return n},Oc=(n,t)=>Ac(n,Ec(t));const Bc=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:n.scale.xStart,s=t?t.xEnd:n.scale.xEnd,{dataIdxStart:i,dataIdxEnd:r}=n.calculateDataViewportIndexes(e,s),o=n.visualPoints.slice(i,r+1),a=er(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return Oc(Lc({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),er=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.high>t.high&&(t.high=s.high,t.highIdx=e),s.low<t.low&&(t.low=s.low,t.lowIdx=e)}return t},Rc=400,sr=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:Rc,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},Ue,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s};class Fc{constructor(t,e){this.delegate=t,this.highLowPostProcessor={},this.highLowProviders=e!=null?e:{}}setHighLowProvider(t,e){this.highLowProviders[t]=e}deleteHighLowProvider(t){delete this.highLowProviders[t]}setHighLowPostProcessor(t,e){this.highLowPostProcessor[t]=e}doAutoYScale(t){Hc(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Hc=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=nr(i),o=s.reduce((a,l)=>l(a),r);t.yStart=o.low,t.yEnd=o.high,t.zoomY=n.calculateZoomY(t.yStart,t.yEnd)};function nr(n){if(n.length===0)return kc();let t=n[0].high,e=n[0].low;return n.forEach(s=>{isFinite(s.high)&&s.high>=t&&(t=s.high),isFinite(s.low)&&s.low<=e&&(e=s.low)}),{low:e,high:t}}const kc=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),ir=(n,t)=>n/t,jc=(n,t)=>n/t,Yc=(n,t)=>n*t,rr=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=ir(e,s),r=n.yEnd-n.yStart;t.zoomY=jc(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Nc=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=ir(e,s),r=n.xEnd-n.xStart;t.zoomX=Yc(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Xc=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},zc=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},or=(n,t,e,s,i)=>{const r=(t.xEnd-t.xStart)*s,o=r*e,a=r*(1-e);return i?(t.xStart=t.xStart+o,t.xEnd=t.xEnd-a):(t.xStart=t.xStart-o,t.xEnd=t.xEnd+a),t.zoomX=n.calculateZoomX(t.xStart,t.xEnd),t},Wc=(n,t,e,s)=>or(n,t,1,e,s);var Vc=Object.defineProperty,Uc=Object.defineProperties,Gc=Object.getOwnPropertyDescriptors,ar=Object.getOwnPropertySymbols,Zc=Object.prototype.hasOwnProperty,$c=Object.prototype.propertyIsEnumerable,lr=(n,t,e)=>t in n?Vc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,es=(n,t)=>{for(var e in t||(t={}))Zc.call(t,e)&&lr(n,e,t[e]);if(ar)for(var e of ar(t))$c.call(t,e)&&lr(n,e,t[e]);return n},Kc=(n,t)=>Uc(n,Gc(t));const qc=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class cr extends nc{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new R,this.beforeStartAnimationSubject=new R,this.zoomReached={zoomIn:!1,zoomOut:!1},this.history=[],this.xConstraints=[],this.scalePostProcessor=(i,r)=>this.xConstraints.reduce((o,a)=>a(i,o),r),this.state=se(t.scale),this.autoScaleModel=new Fc(this),this.offsets=this.config.components.offsets}doActivate(){super.doActivate(),this.scaleInversedSubject=new R,this.beforeStartAnimationSubject=new R,this.zoomReached=this.calculateZoomReached(this.export().zoomX),this.addRxSubscription(this.scaleInversedSubject.subscribe(()=>{this.fireChanged()}))}doDeactivate(){super.doDeactivate(),this.scaleInversedSubject.complete(),this.beforeStartAnimationSubject.complete()}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=es(es({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,s=!1,i){const r=this.config.scale.disableAnimations||s;r&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const o=this.export();or(this,o,t,i,e),this.zoomXTo(o,e,r)}zoomXToEnd(t,e){this.config.scale.disableAnimations&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const s=this.export();Wc(this,s,e,t),this.zoomXTo(s,t,this.config.scale.disableAnimations)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.doAutoScale())}zoomXTo(t,e,s){var i;const r=this.export(),o=this.scalePostProcessor(r,t);this.zoomReached=this.calculateZoomReached(o.zoomX,e),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&rr(r,o),this.state.auto&&this.autoScaleModel.doAutoYScale(o),s?this.apply(o):((i=this.currentAnimation)==null||i.tick(),sr(this.canvasAnimation,this,o)))}calculateZoomReached(t,e=!0){const s=this.getBounds().width,i=.001;if(s>0){const r=Qe(this.config.components.chart.minCandles,s),a=t!==r&&t-r<=i&&e,l=Qe(s/this.config.components.chart.minWidth,s),h=t-l>=i&&!e;return{zoomIn:a,zoomOut:h}}return{zoomIn:!1,zoomOut:!1}}setXScale(t,e,s=!0){var i;const r=this.export(),o=this.calculateZoomX(t,e);if(r.xStart===t&&r.xEnd===e&&r.zoomX>0)return;const a=Kc(es({},r),{zoomX:o,xStart:t,xEnd:e}),l=this.scalePostProcessor(r,a),c=l.xEnd-l.xStart<r.xEnd-r.xStart;this.zoomReached=this.calculateZoomReached(o,c),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&rr(r,l),this.state.auto&&this.autoScaleModel.doAutoYScale(l),s||this.config.scale.disableAnimations?(this.haltAnimation(),this.apply(l)):((i=this.currentAnimation)==null||i.tick(),sr(this.canvasAnimation,this,l)))}setYScale(t,e,s=!1){const i=this.export();if(i.yStart===t&&i.yEnd===e&&i.zoomY>0)return;if(this.state.lockPriceToBarRatio){this.setLockedYScale(t,e,s,i);return}super.setYScale(t,e,s);const r=this.export(),o=this.scalePostProcessor(i,r);this.state.auto&&this.autoScaleModel.doAutoYScale(o),this.apply(o)}setLockedYScale(t,e,s=!1,i){const r=e<i.yEnd;if(this.zoomReached.zoomOut&&r===!1||this.zoomReached.zoomIn&&r===!0)return;super.setYScale(t,e,s);const o=this.export(),a=this.scalePostProcessor(i,o);Nc(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=es({},e);this.haltAnimation(),Xc(e,t);const i=this.scalePostProcessor(s,e);this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();zc(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),ic(e,this.export())||this.apply(e)}}isViewportAnimationInProgress(){const t=this.currentAnimation;return t==null?void 0:t.animationInProgress}pushToHistory(t){this.history.push(t)}popFromHistory(){return this.history.pop()}clearHistory(){this.history=[]}isDefaultXBounds(){return this.xStart===0&&this.xEnd===0}isDefaultYBounds(){return this.yStart===0&&this.yEnd===0}isScaleReady(){return!this.isDefaultXBounds()&&!this.isDefaultYBounds()}autoScale(t=!0){this.config.components.yAxis.type==="percent"?this.state.auto=!0:this.state.auto=t,t&&(this.clearHistory(),this.doAutoScale())}setLockPriceToBarRatio(t=!1){const{type:e}=this.config.components.yAxis;if(e==="percent"||e==="logarithmic"){this.state.lockPriceToBarRatio=!1;return}this.state.lockPriceToBarRatio=t}}class Jc extends cr{constructor(t,e,s,i){super(e,s,i),this.delegate=t,this.config=e,this.getBounds=s}doActivate(){this.addRxSubscription(this.delegate.xChanged.subscribe(()=>this.doAutoScale(this.state.auto)))}get xStart(){return this.delegate.xStart}set xStart(t){this.delegate.xStart=t}get xEnd(){return this.delegate.xEnd}set xEnd(t){this.delegate.xEnd=t}get zoomX(){return this.delegate.zoomX}set zoomX(t){this.delegate.zoomX=t}observeXChanged(){return this.delegate.xChanged}fireChanged(){this.delegate.changed.next(),this.changed.next()}}const Qc=$e().colors;class Ut extends Vi{constructor(t,e,s,i,r,o,a,l,c=Qc){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=qc(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new R,this.meanCandleWidth=Os,this._instrument=o,this.instrument=o,this.highLowProvider=Bc(this),this.scale=r,this.name=o.symbol}get dataPoints(){return super.dataPoints}set dataPoints(t){super.dataPoints=t,this.applyPriceMovement()}get instrument(){return this._instrument}set instrument(t){var e;this._instrument=t,this.pricePrecisions=ge.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i,this.recalculateZippedHighLow(),this.eventBus.fireDraw()}calculateDataViewportIndexes(t,e){const s=Bt(this.visualPoints,t,r=>r.startUnit).index,i=Bt(this.visualPoints,e,r=>r.startUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}applyPriceMovement(){const t=wt(this.dataPoints);t&&(this.lastPriceMovement=Ze(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=er(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd+1))}updateCurrentPrice(t){this.previousPrice=this.currentPrice||t,this.currentPrice=t,this.currentPrice!==this.previousPrice&&(this.lastPriceMovement=this.currentPrice>this.previousPrice?"up":"down")}updateCandleSeriesColors(t){this.colors=Mt(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var s,i;if(t.length===0)return[];const r=this.config.type,o=[];let a=e;const l=(s=this.candleWidthByChartType[r])!=null?s:Ji;for(let c=0;c<t.length;c++){const h=t[c],d=t[c-1],u=l(h),f=a+u/2,p=(i=this.candlesTransformersByChartType[r])!=null?i:Ki;o.push(p(h,{x:f,width:u,prevCandle:d,activeCandle:this.activeCandle},o[c-1])),a+=u}return o}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,s)=>e+s.width,0)/t.length:this.meanCandleWidth=Os}setActiveCandle(t){this.activeCandle=t,this.recalculateVisualPoints()}clearData(){this.dataPoints=[],this.clearVisualCandles(),this.clearPrices()}clearPrices(){this.previousPrice=void 0,this.currentPrice=void 0,this.lastPriceMovement="none"}clearVisualCandles(){this.visualPoints=[]}}function Xp(n){switch(n){case"line":case"area":return!0;default:return!1}}class th{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=!!i.color;if(s instanceof Ut){const a=Ct(e);if(a.length===0)return;i.color?t.strokeStyle=i.color:t.strokeStyle=s.colors.areaTheme.lineColor,o?t.lineWidth=(r=i.hoverWidth)!=null?r:this.config.selectedWidth*3:s.highlighted?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const l=s.extentComponent.getBounds(),c=a[0],h=s.view.toX(c.centerUnit);for(let d=0;d<a.length;d++){const u=a[d-1],f=a[d+1],p=a[d],v=s.view.toX(p.centerUnit),x=s.view.toY(p.close),P=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(rt(v),P),t.moveTo(rt(v),x);else if(f===void 0){t.lineTo(rt(v),x),t.stroke(),t.lineTo(rt(v),P),t.lineTo(rt(h),P),t.closePath();let I;i.color?t.fillStyle=i.color:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(I=t.createLinearGradient(0,0,0,l.height),I.addColorStop(0,s.colors.areaTheme.startColor),I.addColorStop(1,s.colors.areaTheme.stopColor),I):"",o||t.fill()}else t.lineTo(v,x)}}}}function hr(n,t,e,s,i,r=4,o=!0,a=!1){n.save(),n.beginPath(),n.moveTo(t+r,e),n.lineTo(t+s-r,e),n.quadraticCurveTo(t+s,e,t+s,e+r),n.lineTo(t+s,e+i-r),n.quadraticCurveTo(t+s,e+i,t+s-r,e+i),n.lineTo(t+r,e+i),n.quadraticCurveTo(t,e+i,t,e+i-r),n.lineTo(t,e+r),n.quadraticCurveTo(t,e,t+r,e),n.closePath(),o&&n.fill(),a&&n.stroke(),n.restore()}function eh(n,t,e,s,i,r,o,a,l,c,h=4,d=!0,u=!1){const f=c==="right"?a:-a,p=c==="right"?h:-h,v=h;n.save(),n.beginPath(),l?n.moveTo(r+p,o):n.moveTo(r,o),l?(n.lineTo(r+f-p,o),n.quadraticCurveTo(r+f,o,r+f,o-v),n.lineTo(r+f,e+v),n.quadraticCurveTo(r+f,e,r+f-p,e),n.lineTo(t+p,e)):(n.lineTo(r+f,o),n.lineTo(r+f,e),n.lineTo(t,e)),l?(n.quadraticCurveTo(t,e,t-p/3,e+v/3),n.lineTo(s+p/3,i-v/3),n.quadraticCurveTo(s,i,s+p/3,i+v/3),n.lineTo(r-p/3,o-v/3),n.quadraticCurveTo(r,o,r+p/3,o)):(n.lineTo(s,i),n.lineTo(r,o)),n.closePath(),d&&n.fill(),u&&n.stroke(),n.restore()}function sh(n,t,e,s,i,r=1){n.save(),n.lineWidth=r,n.beginPath(),n.moveTo(t,e),n.lineTo(s,i),n.stroke(),n.closePath(),n.restore()}function ne(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function dr(n,t,e){const s=Math.min(t.x,e.x)+.5,i=Math.min(t.y,e.y),r=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);n.fillRect(s,i,r,o)}const Gt=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},zp=n=>Array.isArray(n[0])?n:[n];class nh{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,s){const i=t.ctx,r=s&&this.paneManager.panes[s];e&&(i.save(),r&&Gt(i,r.getBounds()),this.drawSeries(i,e),i.restore())}drawSeries(t,e){const s=e.config.additionalVisibilityPredicatesMap;if(e.config.visible||s&&!sc(s)){const i=e.config.type,r=this.seriesDrawers[i];if(r){const o=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);o&&o.length>=1&&r.draw(t,o,e,{})}else console.error(`Data series drawer with type ${i} isn't registered!`)}}}const Zt=(n,t,e,s,i=t)=>{s.hoverWidth?n.lineWidth=s.hoverWidth:e.highlighted?n.lineWidth=t!==i?t+1:i:n.lineWidth=t};class ih{constructor(t){this.config=t}setFillStyle(t,e,s,i){if(e.color)t.strokeStyle=e.color;else{const r=s.colors.barTheme;r&&(t.strokeStyle=r[`${i.name}Color`])}}draw(t,e,s,i){if(s instanceof Ut){const r=Ct(e);Zt(t,this.config.barLineWidth,s,i),ne(t,()=>{for(const o of r){this.setFillStyle(t,i,s,o),t.beginPath();const a=s.view.toX(o.centerUnit),l=s.view.toX(o.startUnit),[c,h,d,u]=o.yBodyKeyPoints(s.view),f=At(s.view.xPixels(o.width)/2),p=s.view.toY(o.close),v=s.view.toY(o.open);this.config.showWicks?(t.moveTo(a,c),t.lineTo(a,u)):(t.moveTo(a,h),t.lineTo(a,d)),t.moveTo(a,p),t.lineTo(a+f,p),t.moveTo(l,v),t.lineTo(a,v),t.stroke()}})}}}class rh{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,s,i){if(i!==void 0&&s instanceof Ut){const r=Ct(e),o=this.baseLineModel.baselineYPercents,a=this.canvasBoundContainer.getBounds(M.CHART),l=a.y+a.height*(o/100),c=r[0];for(let h=0;h<r.length;h++){const d=r[h],u=r[h-1],f=r[h+1],p=s.view.toX(c.centerUnit),v=s.view.toX(d.centerUnit),x=s.view.toY(d.close),P=u?s.view.toY(u.close)<l:!1,I=x<l;if(u!==void 0&&P!==I){ur(t,s,i,P);const O=s.view.toX(u.centerUnit),j=s.view.toY(u.close),H=v-O,B=x-j,Y=H/B,W=x-l,G=Y*W,V=O+(H-G);t.lineTo(V,l),t.stroke(),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(V,l)}u===void 0?(t.beginPath(),t.moveTo(v,x)):f===void 0?(ur(t,s,i,I),t.lineTo(v,x),t.stroke(),t.lineTo(v,l),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(p,l),t.lineTo(v,l),t.strokeStyle=s.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(v,x)}}}}const ur=(n,t,e,s)=>{e.color?(n.fillStyle=e.color,n.strokeStyle=e.color):(n.fillStyle=s?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,n.strokeStyle=s?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class oh{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,s,i){if(s instanceof Ut){const r=Ct(e);Zt(t,this.config.candleLineWidth,s,i,this.config.candleLineWidth),ne(t,()=>{this.pixelLength=1/Rt,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const o of r){const{candleTheme:a,activeCandleTheme:l}=s.colors;a&&l&&this.drawCandle(t,i,s,o)}})}}drawCandle(t,e,s,i){const{candleTheme:r,activeCandleTheme:o}=s.colors,a=i.name,l=i.isActive?o:r,c=i.isHollow;e.color?t.fillStyle=e.color:c?t.fillStyle=l[`${a}WickColor`]:t.fillStyle=l[`${a}Color`];const h=s.view.toX(i.startUnit),d=s.view.xPixels(i.width),u=i.bodyHeight(s.view),[f,p,v,x]=i.yBodyKeyPoints(s.view),P=p===v?p+1:v,I=f===x?f+1:x,O=l[`${a}Color`],j=a==="none"?O:l[`${a}WickColor`];t.fillStyle=O,e.color?t.strokeStyle=e.color:t.strokeStyle=j;const H=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),B=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,B?f:p),t.lineTo(h,B?I:P),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,B?f:p),t.lineTo(h,B?I:P),t.moveTo(h+1,p),t.lineTo(h+1,P),t.stroke();else if(d===3){const Y=d/Rt;this.drawCandlesWicks(t,h+Y,f,I,p,P),c||(t.beginPath(),t.moveTo(h+Y,p),t.lineTo(h+Y,P),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,p+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const Y=i.x(s.view);this.drawCandlesWicks(t,Y,f,I,p,P);const W=this.config.candlePaddingPercent,G=Math.max(d*W/2,this.pixelLength),V=h+G,U=d-G*2;if(!c){e.color&&(t.fillStyle=e.color);const $=e.hoverWidth?d+G:U,K=e.hoverWidth?u+e.hoverWidth+G:u;t.fillRect(V,p,$,K)}H&&this.drawCandleBorder(t,e,l,i,V+this.halfLineWidthCU,p+this.halfLineWidthCU,U-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,s,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,s,i,r,o,a,l){if(e.color)t.strokeStyle=e.color;else{const c=i.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class ah{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof Ut){const r=e.flat(),o=s.scale.getBounds(),a=o.y+o.height;for(const l of r){t.beginPath();const c=l.name,h=this.config.barCapSize,d=s.colors.histogram;if(d===void 0)return;i.color?t.fillStyle=i.color:t.fillStyle=d[`${c}Bright`];const u=l.xStart(s.view),f=s.view.toY(l.close),p=At(s.view.xPixels(l.width));t.fillRect(u,f,p,h);const v=t.createLinearGradient(0,f+h,0,a);i.color?t.fillStyle=i.color:(v.addColorStop(0,d[`${c}Cap`]),v.addColorStop(1,d[`${c}Bottom`]),t.fillStyle=v),p===0?(t.beginPath(),t.strokeStyle=v,t.moveTo(u,f+h),t.lineTo(u,a),t.stroke(),t.closePath()):t.fillRect(u,f+h,p,a-f-h)}}}}class lh{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof Ut){const r=Ct(e);Zt(t,this.config.lineWidth,s,i,this.config.selectedWidth);const o=s.colors.lineTheme;t.lineCap="round",i.color&&(t.strokeStyle=i.color);for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a],h=c.name;i.color||(t.strokeStyle=o[`${h}Color`]);const d=s.view.toX(l.centerUnit),u=s.view.toY(l.close),f=s.view.toX(c.centerUnit),p=s.view.toY(c.close);t.beginPath(),t.moveTo(d,u),t.lineTo(f,p),t.stroke()}}}}const ch=1.5;class hh{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:ch;t.fillStyle=(r=i.color)!=null?r:this.config.mainColor;for(const a of Ct(e)){t.beginPath();const l=s.view.toX(a.centerUnit),c=s.view.toY(a.close);t.arc(l,c,o,0,Math.PI*2,!0),t.fill()}}}const dh=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class uh{constructor(t,e,s){this.drawer=t,this.config=e,this.chartBounds=s}draw(t,e,s,i){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,s,i),this.afterDraw(t,s))}beforeDraw(t){t.restore(),t.save(),Gt(t,this.chartBounds())}isChartTypeAllowed(){return dh.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Gt(t,e.scale.getBounds())}}class fh{constructor(t){this.chartModel=t}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=this.chartModel.getVisualCandle(rt(c.centerUnit)),d=c.close;if(h&&d===1){const u=this.chartModel.scale.zoomX,f=At(gt(h.width,u)),p=At(h.bodyHeight(this.chartModel.scale)),v=h.xCenter(this.chartModel.scale)-f/2,x=h.yBodyStart(this.chartModel.scale),P=this.chartModel.config.components.chart.candlePaddingPercent,I=At(f*P/2),O=v+I,j=f-I*2;t.fillRect(O,x,j,p)}})})}}const gh=(n,t,e,s)=>{const{centerUnit:i,close:r}=n,o=e.toX(i),a=e.toY(r);s===0?t.moveTo(o,a):t.lineTo(o,a)},fr=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{gh(s,t,e,i)})},ph=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,mh=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,vh=/^rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}\s*0*(?:\.\d+|1(?:\.0*)?)\s*[)]$/,bh=n=>ph.exec(n),Ch=n=>mh.exec(n),Wp=n=>vh.exec(n);function yh(n){const t=bh(n)||Ch(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const gr={};function wh(n,t){let e=gr[n+t];if(!e){const s=yh(n);e=s&&"rgba("+s.join(",")+","+t+")",gr[n+t]=e}return e}class Sh{constructor(){}draw(t,e,s,i){s.config.visible&&(e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);Zt(t,l.lineWidth,s,i,l.hoveredLineWidth);const c=(a=i.color)!=null?a:l.color;t.strokeStyle=c,this.drawLine(t,r,s.view)}),s.linkedDataSeriesModels.forEach((r,o)=>{if(pr(r.config.type)&&pr(s.config.type)&&r.config.visible){const a=[],l=s,c=l.getSeriesInViewport(l.scale.xStart-1,l.scale.xEnd+1),h=r.getSeriesInViewport(r.scale.xStart-1,r.scale.xEnd+1);c.forEach((d,u)=>{var f,p;const v=Math.min(d.length,(p=(f=h[u])==null?void 0:f.length)!=null?p:0);for(let I=0;I<v;I++){const O=[d[I].clone(),h[u][I].clone()];a.push({diffPoints:O})}const x=l.getPaintConfig(u).color,P=r.getPaintConfig(o).color;this.drawDifference(t,x,P,a,l,r,i)})}}))}drawLine(t,e,s){t.beginPath(),fr(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a){const[l,c]=[[],[]];i.forEach(u=>{const[f,p]=u.diffPoints;l.push(f),c.push(p)});const h=this.mapDataSeriesDiffPointsIntoPoints(l,r.view),d=this.mapDataSeriesDiffPointsIntoPoints(c,o.view);this.fillCloud(t,s,h,d,a),this.fillCloud(t,e,d,h,a)}fillCloud(t,e,s,i,r){var o,a,l,c;t.save(),t.beginPath();const h=(a=(o=ce(s))==null?void 0:o.x)!=null?a:0,d=(c=(l=wt(s))==null?void 0:l.x)!=null?c:0;t.lineTo(h,0),s.forEach(u=>{t.lineTo(u.x,u.y)}),t.lineTo(d,0),t.closePath(),t.clip(),t.beginPath(),s.forEach((u,f)=>{f===0?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y)}),i.slice().reverse().forEach(u=>{t.lineTo(u.x,u.y)}),t.closePath(),t.fillStyle=r.color?r.color:wh(e||"#383838",.3),t.fill(),t.restore()}mapDataSeriesDiffPointsIntoPoints(t,e){return t.map(s=>{const{centerUnit:i,close:r}=s,o=e.toX(i),a=e.toY(r);return{x:o,y:a}})}}const pr=n=>n==="DIFFERENCE";class xh{constructor(){}draw(t,e,s,i){const r=s.view.toY(0);e.forEach((o,a)=>{var l;const c=s.getPaintConfig(a);Zt(t,c.lineWidth,s,i,c.hoveredLineWidth),t.strokeStyle=(l=i.color)!=null?l:c.color,t.beginPath(),o.forEach(h=>{const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.moveTo(d,rt(r)),t.lineTo(d,rt(u))}),t.stroke()})}}class Ph{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);Zt(t,l.lineWidth,s,i,l.hoveredLineWidth),t.strokeStyle=(a=i.color)!=null?a:l.color,this.drawLinePath(t,r,s.view)})}drawLinePath(t,e,s){t.beginPath(),fr(e,t,s),t.stroke()}}class _h{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o),c=i.hoverWidth?i.hoverWidth/2:l.lineWidth;t.fillStyle=(a=i.color)!=null?a:l.color,t.lineWidth=1,r.forEach(h=>{t.beginPath();const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.arc(d,u,c,0,Math.PI*2),t.fill()})})}}class Th{constructor(t){this.config=t}draw(t,e,s,i){t.save(),e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,r.forEach(h=>{const d=s.getTextForPoint(h),u=Tt(d,t,c),f=jt(c,t),p=s.view.toX(h.centerUnit)-u/2,v=s.view.toY(h.close)+f;t.fillText(d,p,v)})}),t.restore()}}class Mh{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=s.view.toX(c.centerUnit),d=s.view.toY(c.close);this.drawCandleTriangle(t,h,d,l.lineWidth)})})}drawCandleTriangle(t,e,s,i){t.beginPath(),t.moveTo(e-i/2,s),t.lineTo(e,s-i),t.lineTo(e+i/2,s),t.fill()}}const Us="resized_local",ss="draw",Vp="draw_last_candle",pe={width:20,height:20};class mr{constructor(t,e,s,i,r,o={}){this.eventBus=t,this.canvas=e,this.drawingManager=s,this.resizer=r,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.type=Gs;var a;i.push(this),this.parent=Ih(e);const l=e.getContext("2d",o);if(l===null)throw new Error("Couldn't get 2d context????");this.context=l,this._canvasId=(a=e.getAttribute("data-element"))!=null?a:"",this.updateCanvasWidthHeight(e,this.getChartResizerElement().getBoundingClientRect())}updateDPR(t){const{width:e,height:s}=t,i=window.devicePixelRatio;this.canvas.style.height=s+"px",this.canvas.style.width=e+"px",this.canvas.width=e*i,this.canvas.height=s*i,this.width=e,this.height=s,this.ctx.scale(i,i)}get canvasId(){return this._canvasId}get ctx(){return this.context}clear(){this.context.clearRect(0,0,this.width,this.height)}isLinked(){var t,e;return(e=(t=this.type)==null?void 0:t.linked)!=null?e:!1}fireDraw(){this.eventBus.fireDraw([this.canvasId])}updateCanvasWidthHeight(t,e=this.getChartResizerElement().getBoundingClientRect()){t.clientWidth!==this.width&&(t.width=t.clientWidth,this.width=t.clientWidth);const s=e.height;s!==this.height&&(t.style.height=s+"px",this.height=s,t.height=s,this.prevHeight=s)}getChartResizerElement(){var t;return(t=this.resizer)!=null?t:this.parent}isReady(){return this.width>pe.width&&this.height>pe.height}}const Gs={name:"candle"},Ah={candle:Gs,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function Eh(n,t,e,s,i,r,o){var a;const l=ie(n,t,i,r,o,e);return l.type=(a=Ah[s])!=null?a:Gs,l}function ie(n,t,e,s,i,r,o){const a=new mr(n,t,s,i,r,o);return vr(a,e),a}function vr(n,t){const e=n.canvas;t.fixedSize&&(e.width=t.fixedSize.width,e.height=t.fixedSize.height,e.style.width=t.fixedSize.width+"px",e.style.height=t.fixedSize.height+"px",n.width=t.fixedSize.width,n.height=t.fixedSize.height),e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.direction="ltr"}function Ih(n){let t=n;for(;t;){if(t.nodeType===1&&t.hasAttribute("data-chart-container"))return t;if(t.parentElement!==null)t=t.parentElement;else break}return t}const ns="HIT_TEST_",$p=null;class Dh{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${yt()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(ns)!==-1&&this.drawersMap[s].draw()})},t.on(ss,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),Wn(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(ns)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(ns)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}Ua(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>pe.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>pe.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=yt()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(e);this.drawingOrder.splice(i,1);const r=this.drawingOrder.indexOf(s);this.drawingOrder.splice(r+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(s);if(i!==-1){const r=this.drawingOrder.indexOf(e);return this.drawingOrder.splice(r,1),this.drawingOrder.splice(i,0,e),this.reorderDrawers(this.drawingOrder),!0}return!1}getDrawerByName(t){return this.drawersMap[t]}getNameByDrawer(t){for(const e in this.drawersMap)if(this.drawersMap[e]===t)return e}removeDrawerByName(t){const e=this.drawersMap[t];this.removeDrawer(e)}removeDrawer(t){Object.keys(this.drawersMap).forEach(e=>{if(this.drawersMap[e]===t){delete this.drawersMap[e];const s=this.drawingOrder.indexOf(e);s!==-1&&this.drawingOrder.splice(s,1)}})}reorderDrawers(t){this.drawingOrder=$n(this.drawingOrder,t)}}class br{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Lh=7;class Oh{constructor(t,e,s,i=()=>!0){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=s,this.drawPredicate=i}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),Gt(t,e.getBounds()),e.dataSeries.forEach(s=>this.drawSeries(t,s)),t.restore()})}}drawSeries(t,e){if(e.config.visible){const s=e.config.type,i=this.seriesDrawers[s];if(i){const r={color:this.canvasModel.idToColor(e.htId),hoverWidth:Lh};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Cr={dragPredicate:()=>!0};class yr extends X{constructor(t,e,s,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragComponentOptions.dragPredicate()&&(this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o))},this.onDragTick=o=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels))}}}class is extends yr{constructor(t,e,s,i,r=Cr){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeYDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeYDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeYDragEnd().subscribe(this.onDragEnd))}}const Bh="BASELINE_RESIZER";class Rh extends X{constructor(t,e,s,i,r,o,a){super(),this.chartModel=t,this.chartPanComponent=e,this.canvasModel=s,this.canvasInputListener=i,this.config=r,this.canvasBoundContainer=o,this.cursorHandler=a,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.dragPredicate=new ft(!1),this.baselineYPercents=50,this.ht=Fs.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragStartCb=()=>{this.chartPanComponent.deactivatePanHandlers(),this.dragPredicate.next(!0)},this.dragEndCb=()=>{this.chartPanComponent.activateChartPanHandlers(),this.dragPredicate.next(!1)},this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(M.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&Tl(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new is(this.ht,{onDragTick:this.dragTickCb,onDragStart:this.dragStartCb,onDragEnd:this.dragEndCb},i,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(M.CHART).subscribe(()=>this.recalculateBounds())),this.chartModel.chartTypeChanged.subscribe(t=>{t==="baseline"?this.cursorHandler.setCursorForBounds("BASELINE_RESIZER",this.resizerBounds,this.config.components.baseline.cursor,this.config.components.baseline.dragZone):this.cursorHandler.removeCursorForCanvasEl("BASELINE_RESIZER")})}recalculateBounds(){const t=this.canvasBoundContainer.getBounds(M.CHART),e=this.canvasBoundContainer.getBounds(M.Y_AXIS);this.resizerBounds.x=t.x,this.resizerBounds.width=t.width+e.width,this.resizerBounds.height=this.config.components.baseline.height;const s=t.y+t.height*(this.baselineYPercents/100);this.resizerBounds.y=s,this.canvasBoundContainer.bounds[Bh]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(M.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const wr=16,Fh=n=>{var t;try{const e=Se(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Se(n.hi,Math.max(n.open,n.close),e),i=Se(n.lo,Math.min(n.open,n.close),e),r=Se(n.open,n.lo,e),o=Se(n.close,n.hi,e),a=Number.isNaN(n.vwap)?void 0:n.vwap;return{id:n.id,hi:s,lo:i,open:r,close:o,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility,vwap:a,typicalPrice:n.typicalPrice}}catch(e){console.warn(e);return}},De=(n,t=0)=>{for(let e=t;e<n.length;++e)n[e].idx=e},Sr=n=>{n.forEach(t=>{t.idx=void 0})},Hh=n=>n!==void 0;class kh{constructor(){}draw(t,e,s,i){const r=s.view.toY(0),o=Ct(e),a=s.getPaintConfig(0);Zt(t,a.lineWidth,s,i,a.hoveredLineWidth),o.forEach((l,c)=>{var h,d,u,f,p,v,x,P;const I=jh(o,c),O=I&&l.close<I;if(((h=a.multiplyColors)==null?void 0:h.length)===2){t.strokeStyle=(d=i.color)!=null?d:(O?a.multiplyColors[1]:a.multiplyColors[0])||a.color||"#FF00FF",t.beginPath();const B=s.view.toX(l.centerUnit),Y=s.view.toY(l.close);t.moveTo(B,r),t.lineTo(B,Y),t.stroke();return}if(((u=a.multiplyColors)==null?void 0:u.length)===4){O&&l.close<0&&(t.strokeStyle=(f=i.color)!=null?f:a.multiplyColors[0]||a.color||"#FF00FF"),!O&&l.close<0&&(t.strokeStyle=(p=i.color)!=null?p:a.multiplyColors[1]||a.color||"#FF00FF"),O&&l.close>0&&(t.strokeStyle=(v=i.color)!=null?v:a.multiplyColors[2]||a.color||"#FF00FF"),!O&&l.close>0&&(t.strokeStyle=(x=i.color)!=null?x:a.multiplyColors[3]||a.color||"#FF00FF"),t.beginPath();const B=s.view.toX(l.centerUnit),Y=s.view.toY(l.close);t.moveTo(B,r),t.lineTo(B,Y),t.stroke();return}t.strokeStyle=(P=i.color)!=null?P:a.color||"#FF00FF",t.beginPath();const j=s.view.toX(l.centerUnit),H=s.view.toY(l.close);t.moveTo(j,r),t.lineTo(j,H),t.stroke()})}}const jh=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},Yh=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class Nh{constructor(){}draw(t,e,s,i){const r=Ct(e),o=s.getPaintConfig(0);Zt(t,o.lineWidth,s,i,o.hoveredLineWidth),t.lineCap="round",r.forEach((a,l)=>{var c,h;const d=Xh(r,l)||r[0],u=d&&a.close<d.close;if(((c=o.multiplyColors)==null?void 0:c.length)===2){t.strokeStyle=(h=i.color)!=null?h:(u?o.multiplyColors[1]:o.multiplyColors[0])||o.color||"#FF00FF";const f=s.view.toX(a.centerUnit),p=s.view.toY(a.close),v=s.view.toX(d.centerUnit),x=s.view.toY(d.close);t.beginPath(),t.moveTo(v,x),t.lineTo(f,p),t.stroke();return}})}}const Xh=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0};var zh=Object.defineProperty,xr=Object.getOwnPropertySymbols,Wh=Object.prototype.hasOwnProperty,Vh=Object.prototype.propertyIsEnumerable,Pr=(n,t,e)=>t in n?zh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_r=(n,t)=>{for(var e in t||(t={}))Wh.call(t,e)&&Pr(n,e,t[e]);if(xr)for(var e of xr(t))Vh.call(t,e)&&Pr(n,e,t[e]);return n};class Uh{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class Gh extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=f,this.chartResizeHandler=p,this._dataSeriesDrawers={},this.backgroundDrawerPredicateSubject=new ft(!0),this.strToBarType=x=>{var P;return(P=this.barTypeValues.find(I=>I===x))!=null?P:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new Rh(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const v=new Oh(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(v,ns+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new Sc(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(M.PANE_UUID(Z),s.components.chart.cursor),this.dataSeriesDrawer=new nh(d,this.dataSeriesDrawers)}doActivate(){super.doActivate(),this.dynamicObjects.model.addObject({id:this.chartModel.mainCandleSeries.id,paneId:this.chartModel.mainCandleSeries.extentComponent.paneUUID,model:this.chartModel.mainCandleSeries,drawer:this.dataSeriesDrawer}),this.addRxSubscription(this.paneManager.dataSeriesAddedSubject.subscribe(t=>{this.dynamicObjects.model.addObject({id:t.id,paneId:t.extentComponent.paneUUID,parentId:t.parentId,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)})),this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(Yh(()=>{this.backgroundDrawerPredicateSubject.next(!1)},wr))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",Ki),this.registerCandlesTransformer("trend",qi),this.registerCandlesTransformer("hollow",Pc),this.registerCandlesTransformer("line",_c)}get barTypeValues(){return Ri(this._dataSeriesDrawers)}get dataSeriesDrawers(){return this._dataSeriesDrawers}registerCandlesTransformer(t,e){this.chartModel.registerCandlesTransformer(t,e)}registerLastCandleLabelHandler(t,e){this.chartModel.registerLastCandleLabelHandler(t,e)}registerCandlesWidthCalculator(t,e){this.chartModel.registerCandlesWidthCalculator(t,e)}registerDefaultDataSeriesDrawers(){const t=new oh(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new ih(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new lh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new hh(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new th(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new rh(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new ah(this.config.components.chart.histogram));const e=M.PANE_UUID(Z),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new Ph),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new Nh),this.registerDataSeriesTypeDrawer("HISTOGRAM",new xh),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new kh),this.registerDataSeriesTypeDrawer("POINTS",new _h),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new uh(new fh(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new Th(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new Mh),this.registerDataSeriesTypeDrawer("DIFFERENCE",new Sh)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(_r({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e,s=!0){return this.chartModel.setTimestampRange(t,e,s)}setXScale(t,e,s=!0){return this.scale.setXScale(t,e,s)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.fireDraw()}setApplyBackgroundToAxes(t){this.config.components.chart.applyBackgroundToAxes=_r({},t),this.chartModel.bus.fireDraw()}setMainSeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument;this.chartModel.mainCandleSeries.instrument=s,this.chartModel.setAllSeries({candles:t.candles,instrument:s},this.chartModel.getSecondarySeries().map(i=>{var r;const o=(r=i.instrument)!=null?r:this.chartModel.mainCandleSeries.instrument,a=i.dataPoints;return Sr(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),i)return i}setAllSeries(t,e=[]){var s;const i=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(i),e.forEach(r=>{var o;const a=(o=r.instrument)!=null?o:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(a)}),this.chartModel.setAllSeries(t,e)}toXFromCandleIndex(t){return this.chartModel.toX(t)}toXFromTimestamp(t){return this.chartModel.candleFromTimestamp(t).xCenter(this.chartModel.scale)}toY(t){return this.chartModel.toY(t)}updateAllSeries(t,e=[]){this.chartModel.updateAllSeries(t,e),this.canvasModel.fireDraw()}removeDataFrom(t){this.chartModel.removeDataFrom(t)}removeSecondarySeries(t){this.chartModel.removeSecondaryCandleSeries(t)}prependCandles(t,e){this.chartModel.prependCandles(t,e)}addLastCandle(t,e){this.chartModel.addLastCandle(t,e)}removeCandleByIdx(t,e){this.chartModel.removeCandleByIdx(t,e)}removeCandlesByIdsSequence(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIdsSequence(t,e)}removeCandlesByIds(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIds(t,e)}addCandlesById(t,e,s=this.chartModel.mainCandleSeries){this.chartModel.addCandlesById(t,e,s)}updateLastCandle(t,e){this.chartModel.updateLastCandle(t,e)}updateCandles(t,e){this.chartModel.updateCandles(t,e)}setOffsets(t){this.chartModel.setOffsets(t)}getDataSeriesDrawer(t){return this._dataSeriesDrawers[t]}registerDataSeriesTypeDrawer(t,e){this._dataSeriesDrawers[t]=e}updatePriceIncrementsIfNeeded(t){(!t.priceIncrements||!ge.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[ge.autoDetectIncrementOfValueRange(this.scale.yEnd-this.scale.yStart)])}observeOffsetsChanged(){return this.chartModel.offsetsChanged}observeChartTypeChanged(){return this.chartModel.chartTypeChanged}observeCandlesChanged(){return this.chartModel.observeCandlesChanged()}observeCandlesUpdated(){return this.chartModel.candlesUpdatedSubject}observeCandlesPrepended(){return this.chartModel.candlesPrependSubject}}function Zh(n,t){return t===void 0&&(t=ks),N(function(e,s){var i=null,r=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var c=r;r=null,s.next(c)}};function l(){var c=o+n,h=t.now();if(h<c){i=this.schedule(void 0,c-h),s.add(i);return}a()}e.subscribe(mt(s,function(c){r=c,o=t.now(),i||(i=t.schedule(l,n),s.add(i))},function(){a(),s.complete()},void 0,function(){r=i=null}))})}class Tr extends Ut{constructor(t,e,s,i,r,o,a,l,c,h){super(e,s,i,r,o,a,l,c,h),this.baseModel=t}set visualPoints(t){super.visualPoints=t,this.baseModel.mainVisualPoints=super.visualPoints}get visualPoints(){return super.visualPoints}set dataPoints(t){super.dataPoints=t,this.baseModel.mainDataPoints=super.dataPoints}get dataPoints(){return super.dataPoints}recalculateMeanCandleWidth(t){super.recalculateMeanCandleWidth(t),this.baseModel.meanDataWidth=this.meanCandleWidth}}var $h=Object.defineProperty,Mr=Object.getOwnPropertySymbols,Kh=Object.prototype.hasOwnProperty,qh=Object.prototype.propertyIsEnumerable,Ar=(n,t,e)=>t in n?$h(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Jh=(n,t)=>{for(var e in t||(t={}))Kh.call(t,e)&&Ar(n,e,t[e]);if(Mr)for(var e of Mr(t))qh.call(t,e)&&Ar(n,e,t[e]);return n};const Qh=(n,t,e,s)=>{var i,r,o,a;const l=Jh({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=Ka(-e,t))==null?void 0:o.startUnit)!=null?a:0;let d=n.xStart,u=n.xEnd;return l.xStart>=h&&(d=h,u=u-(l.xStart-h)),l.xEnd<c&&(d=c-Nt(s.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},td=n=>(t,e={xScale:!0,yScale:!0})=>{if(t.length!==0){if(e.xScale){const s=t.slice(Math.max(t.length-n.state.defaultViewportItems,0)),i=s[0],r=s[s.length-1];n.setXScale(i.startUnit,r.startUnit+r.width+n.offsets.right)}e.yScale&&n.doAutoScale(!0),n.fireChanged()}},ed=(n,t)=>(e,s=null)=>{const[i,r]=e,o=t.candleFromTimestamp(i).startUnit,a=t.candleFromTimestamp(r).startUnit,l=s===null?0:t.mainCandleSeries.meanCandleWidth*2,c=s?o-l:o+l,h=s?a+l:a-l;n.setXScale(c,h)};var sd=Object.defineProperty,nd=Object.defineProperties,id=Object.getOwnPropertyDescriptors,Er=Object.getOwnPropertySymbols,rd=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,Ir=(n,t,e)=>t in n?sd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Le=(n,t)=>{for(var e in t||(t={}))rd.call(t,e)&&Ir(n,e,t[e]);if(Er)for(var e of Er(t))od.call(t,e)&&Ir(n,e,t[e]);return n},Zs=(n,t)=>nd(n,id(t));class ad{constructor(t){this.config=t,this.usedChartColors={},this.symbolsToColorKeys={},this.secondaryChartColorsPool=this.createColorPool(this.config.colors.secondaryChartTheme),this.usedChartColors=Object.keys(this.secondaryChartColorsPool).reduce((e,s)=>Zs(Le({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=Zs(Le({},se(this.config.colors)),{lineTheme:Le({},s.lineTheme),areaTheme:Le({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,s=i);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[t]=s,this.secondaryChartColorsPool[s]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var s,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=Zs(Le({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var ld=Object.defineProperty,Dr=Object.getOwnPropertySymbols,cd=Object.prototype.hasOwnProperty,hd=Object.prototype.propertyIsEnumerable,Lr=(n,t,e)=>t in n?ld(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,rs=(n,t)=>{for(var e in t||(t={}))cd.call(t,e)&&Lr(n,e,t[e]);if(Dr)for(var e of Dr(t))hd.call(t,e)&&Lr(n,e,t[e]);return n};class dd extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=i,this.config=r,this.scale=o,this.formatterFactory=a,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.chartTypeChanged=new R,this.mainInstrumentChangedSubject=new R,this.offsetsChanged=new R,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.prepareCandles=u=>{const f=u.map(Fh).filter(Hh),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new ad(this.config);const d=new Tr(this.chartBaseModel,this.paneManager.panes[Z].mainExtent,yt(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new Uh,this.candlesTransformersByChartType,this.candleWidthByChartType,rs({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),this.config.components.chart.minCandlesOffset>0&&o.addXConstraint((u,f)=>Qh(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=td(o),this.timeFrameViewportTransformer=ed(o,this),this.pane=this.paneManager.panes[Z]}get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(t=>t!==this.mainCandleSeries)}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(Z)).pipe(Et(Si)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(Zh(wr)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>pe.width&&t.height>pe.height){const e=this.canvasBoundsContainer.getEffectiveChartWidth(),s=this.canvasBoundsContainer.getEffectiveYAxisWidth();if(this.prevChartWidth===0&&this.scale){this.scale.isViewportValid(!1)?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=Nt(s-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-r)}else this.scale.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=e;return}const i=Nt(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-i,this.scale.xEnd),this.scale.recalculateZoomY(),this.prevYWidth=s,this.prevChartWidth=e}}setMainCandleSeries(t,e){this.mainCandleSeries.instrument=e,this.setAllSeries({candles:t,instrument:e},this.getSecondarySeries().map(s=>{const i=s.dataPoints;return Sr(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const i=this.prepareCandles(t),r=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),o=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,r),l=this.secondaryCandleSeries.some(c=>c.instrument.symbol===e.symbol)?this.secondaryCandleSeries.find(c=>c.instrument.symbol===e.symbol):this.createSecondaryCandleSeriesModel(e);if(l)return l.dataPoints=o,s&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var s;this.mainCandleSeries.instrument=(s=t.instrument)!=null?s:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=this.prepareCandles(t.candles);this.mainCandleSeries.clearData(),De(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(r=>e.filter(o=>{var a;return((a=o.instrument)==null?void 0:a.symbol)===r.instrument.symbol}).length===0).forEach(r=>this.removeSecondaryCandleSeries(r)),e.map(r=>this.setSecondaryCandleSeries(r.candles,r.instrument,!1)),this.candleSeries.forEach(r=>{r.recalculateDataViewportIndexes(),r.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()}autoScaleOnCandles(){this.scale.state.autoScaleOnCandles&&(this.doBasicScale(),this.scale.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(t=null){this.timeFrameViewportTransformer(this.lastTimeFrame,t),this.scale.state.autoScaleOnCandles&&this.scale.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scale.toX(this.scale.xStart),!0).timestamp,this.candleFromX(this.scale.toX(this.scale.xEnd),!0).timestamp])}updateAllSeries(t,e=[]){t=rs({},t),t.instrument||(t.instrument=this.mainCandleSeries.instrument);const s=[t,...e];if(!this.candleSeries.every(l=>s.find(c=>{var h;return((h=c.instrument)==null?void 0:h.symbol)===l.instrument.symbol}))||e.length!==this.secondaryCandleSeries.length){console.error("All series update failed. Instruments for series are different.");return}const i=this.prepareCandles(t.candles),r=Br(this.mainCandleSeries.dataPoints,i),o=r.candles;De(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=Br((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints(),l.recalculateDataViewportIndexes()});const a=this.chartBaseModel.mainVisualPoints.slice(0,r.prepended.length).reduce((l,c)=>l+c.width,0);this.scale.moveXStart(this.scale.xStart+a),this.candlesPrependSubject.next({prependedCandlesWidth:a,prependedCandles:r.prepended}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(t){Object.values(this.paneManager.panes).forEach(e=>{e.dataSeries.forEach(s=>{const i=Bt(s.dataPoints,t,o=>o.timestamp),r=i.exact?i.index:i.index+1;s.dataPoints=s.dataPoints.slice(0,r)})}),this.candlesChangedRedraw()}createSecondaryCandleSeriesModel(t){const e=rs(rs({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new Ut(this.paneManager.panes[Z].mainExtent,yt(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,t,this.candlesTransformersByChartType,this.candleWidthByChartType,e);return s.config.type="line",this.candleSeries.push(s),s}removeSecondaryCandleSeries(t){return this.secondaryChartColors.addColorToPool(t.instrument.symbol),this.candleSeries=this.candleSeries.filter(e=>e!==t),t.deactivate(),this.paneManager.panes[Z].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(i=>{const r=this.candleIdxFromId(i.id),o=r>0?r:0,a=e[o];if(a)s.push(a);else{let l=Or(e,o,-1);if(l||(l=Or(e,o,1)),l){const c=cl(l,o,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const i=Mt(t,$e().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=s,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=s.length&&this.scale.setXScale(this.scale.xStart,this.candleFromIdx(e).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scale.getOffsets()}fromY(t){return this.scale.fromY(t)}priceFromY(t,e){return(e!=null?e:this.mainCandleSeries).view.priceFromY(t)}fromX(t){return this.scale.fromX(t)}toX(t){const e=this.candleFromIdx(t);return this.scale.toX(e.centerUnit)}candleFromX(t,e=!1,s=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var i,r;const o=Bt(s.visualPoints,t,d=>d.startUnit),a=s.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=xe((t-a[o.index].centerUnit)/this.mainCandleSeries.meanCandleWidth));const c=o.index,h=Math.max(Math.min(a.length-1,c),0);return(c<0||c>=a.length)&&e?Ee(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:Ee(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e={extrapolate:!0},s=this.mainCandleSeries){const i=s.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,i)}candleFromId(t,e=this.mainCandleSeries){return e.visualPoints.find(s=>s.candle.id===t)}candleIdxFromId(t,e=this.mainCandleSeries){return e.visualPoints.findIndex(s=>s.candle.id===t)}candleFromIdx(t){return this.chartBaseModel.dataFromIdx(t)}isReady(){return this.canvasModel.isReady()&&this.hasCandles()}registerCandlesTransformer(t,e){this.candlesTransformersByChartType[t]=e}registerCandlesWidthCalculator(t,e){this.candleWidthByChartType[t]=e}registerLastCandleLabelHandler(t,e){this.lastCandleLabelsByChartType[t]=e}hasCandles(){return this.mainCandleSeries.visualPoints.length!==0}getVisualCandle(t){var e,s,i;const r=t-((i=(s=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:s.idx)!=null?i:0);return this.mainCandleSeries.visualPoints[r]}getFirstIdx(){return this.mainCandleSeries.dataIdxStart}getLastIdx(){return this.mainCandleSeries.dataIdxEnd}getFirstTimestamp(t=!0){return t?this.candleFromIdx(this.getFirstIdx()).candle.timestamp:this.candleFromUnit(this.scale.xStart,!0).timestamp}getLastTimestamp(t=!0){return t?this.candleFromIdx(this.getLastIdx()).candle.timestamp:this.candleFromUnit(this.scale.xEnd,!0).timestamp}setTimestampRange(t,e,s=!0){const i=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),o=r.startUnit+r.width;return this.scale.setXScale(i,o,s)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return wt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return wt(t)}getMaxCandlesFitLength(){return rt(this.canvasBoundsContainer.getEffectiveChartWidth()/this.config.components.chart.minWidth)}getSecondarySeries(){return this.secondaryCandleSeries}isSeriesInstrument(t,e){return t.instrument.symbol===e}findSeriesBySymbol(t){return this.candleSeries.filter(e=>this.isSeriesInstrument(e,t))}findSecondarySeriesBySymbol(t){return this.secondaryCandleSeries.find(e=>this.isSeriesInstrument(e,t))}reindexCandlesBasedOnSeries(t,e){return e.reduce((s,i)=>{const r=i.timestamp,o=Me(r,{extrapolate:!1},t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=Me(h.timestamp,{extrapolate:!0},o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,v=c&&h.timestamp<c.timestamp;if(p&&!v&&(c=h),a&&c&&s&&l){const x=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:Ji;this.scale.moveXStart(this.scale.xStart+x(c))}}),c&&(r.updateCurrentPrice(c.close),this.paneManager.yExtents.forEach(h=>h.yAxis.updateOrderedLabels(!0))),l&&c&&t.length===1?this.canvasModel.fireDraw():r.recalculateVisualPoints()}),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return bt(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=0,e){let s=this.getCandles().slice();const i=this.getCandlesCount(),r=e!=null?e:i+this.FAKE_CANDLES_DEFAULT;s=s.slice(Math.max(0,t),Math.min(i,r));const o=[],a=[];for(let c=i;c<r;c++)o.push(Ee(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=t;c<l;c++)a.push(Ee(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...a,...s,...o]}getCandlesCount(){return this.mainCandleSeries.dataPoints.length}getCandlesCountWithRightOffset(){return this.getCandlesCount()+this.getOffsets().right}clearData(){this.candleSeries.forEach(t=>t.clearData())}prependCandles(t,e){const s=t.slice(),i=[];return e.forEach(r=>{const a=Me(r.timestamp,{extrapolate:!1},t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),De(i.dataPoints),i.recalculateVisualPoints()}),this.candlesChangedRedraw()}removeCandlesByIdsSequence(t,e){const s=this.candleIdxFromId(t[0],e),i=this.candleIdxFromId(t[t.length-1],e);if(s<0||i<0){console.warn("Candle is not found");return}e.dataPoints=e.dataPoints.slice(0,s).concat(e.dataPoints.slice(i+1)),De(e.dataPoints,i),e.recalculateVisualPoints(),this.candlesChangedRedraw()}removeCandlesByIds(t,e){t.forEach(s=>this.removeCandleByIdx(this.candleIdxFromId(s,e)))}addCandlesById(t,e,s){const i=this.candleIdxFromId(e);if(i<0){console.warn("Selected start candle is not found");return}const r=s.dataPoints.slice(0,i),o=s.dataPoints.slice(i);s.dataPoints=r.concat(t).concat(o),De(s.dataPoints),s.recalculateVisualPoints(),this.candlesChangedRedraw()}candlesChangedRedraw(){this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const Or=(n,t,e)=>{if(t>=n.length)return n[n.length-1];for(let s=t;s<n.length&&s>=0;s+=e){const i=n[s];if(i)return i}},Br=(n,t)=>{const e=n.slice(),s=[],i=[];return t.forEach(r=>{const a=Me(r.timestamp,{extrapolate:!0},n).index;a<0?s.push(r):a>=n.length?i.push(r):n[a].timestamp===r.timestamp?e[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:s,appended:i,candles:[...s,...e,...i]}};class me{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class $s{constructor(t){this.drawers=t!=null?t:new Map}draw(){this.drawers.forEach(t=>t.draw())}addDrawer(t,e){const s=e!=null?e:"drawer"+this.drawers.size;this.drawers.set(s,t)}drawLastBar(){this.drawers.forEach(t=>t.drawLastBar&&t.drawLastBar())}removeDrawer(t){const e=Bi(this.drawers,t);e?this.drawers.delete(e):console.warn("Couldn't find drawer type")}removeDrawerByName(t){this.drawers.delete(t)}getDrawer(t){return this.drawers.get(t)}moveTop(t){const e=Bi(this.drawers,t);e?this.moveTopByName(e):console.warn("Couldn't find drawer type")}moveTopByName(t){if(this.drawers.size===1)return;const e=this.drawers.get(t);this.drawers.delete(t),e&&this.drawers.set(t,e)}getSize(){return this.drawers.size}getAll(){return this.drawers}getCanvasIds(){const t=Ct(Array.from(this.drawers).map(([,s])=>s.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class ud{constructor(t,e,s,i){this.model=t,this.config=e,this.crossToolCanvasModel=s,this.crossToolTypeDrawers=i}draw(){const t=this.crossToolTypeDrawers[this.config.components.crossTool.type];t?this.model.currentHover&&t.draw(this.crossToolCanvasModel.ctx,this.model.currentHover):console.error(`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}var fd=Object.defineProperty,gd=Object.defineProperties,pd=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,md=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Fr=(n,t,e)=>t in n?fd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,bd=(n,t)=>{for(var e in t||(t={}))md.call(t,e)&&Fr(n,e,t[e]);if(Rr)for(var e of Rr(t))vd.call(t,e)&&Fr(n,e,t[e]);return n},Cd=(n,t)=>gd(n,pd(t));class yd extends X{constructor(t,e,s,i,r,o){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=i,this.canvasBoundsContainer=r,this.baselineModel=o,this.currentHoverSubject=new ft(null)}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.config.type=t}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?kt()?this.updateCrossToolMobile(t):this.updateCrossTool(t):this.currentHover=null,this.fireDraw()})),this.addRxSubscription(this.baselineModel.dragPredicate.subscribe(t=>{if(kt())if(t)this.hoverProducer.deactivate();else{const e=this.crossEventProducer.crossToolTouchInfo;e.isSet&&this.crossEventProducer.crossSubject.next([e.temp.x,e.temp.y,Z]),this.hoverProducer.activate()}}))}fireDraw(){this.config.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateCrossTool(t,e=this.config.magnetTarget){if(this.currentHover===null?this.currentHover={x:t.x,y:0,time:t.timeFormatted,paneId:t.paneId}:(this.currentHover.x=t.x,this.currentHover.time=t.timeFormatted),t.candleHover&&t.paneId===Z)switch(e){case"O":this.currentHover.y=t.candleHover.openY;break;case"C":this.currentHover.y=t.candleHover.closeY;break;case"H":this.currentHover.y=t.candleHover.highY;break;case"L":this.currentHover.y=t.candleHover.lowY;break;case"OHLC":this.currentHover.y=t.candleHover.closestOHLCY;break;case"none":this.currentHover.y=t.y;break}else this.currentHover.y=t.y;this.currentHover.paneId=t.paneId,this.currentHoverSubject.next(this.currentHover)}updateCrossToolMobile(t){var e;if(!this.hoverProducer.longTouchActivatedSubject.getValue())return;const{fixed:s,temp:i,isSet:r}=this.crossEventProducer.crossToolTouchInfo;if(!r){this.updateCrossTool(t);return}const o=this.canvasBoundsContainer.getBounds(M.PANE_UUID(t.paneId)),a=5,l=t.x-i.x,c=t.y-i.y,h=s.x+l,d=s.y+c,u=o.y+a,f=o.y+o.height-a,p=h<a?a:h>o.width-a?o.width-a:h,v=d<u?u:d>f?f:d,x=(e=this.hoverProducer.createHover(p,v,t.paneId))!=null?e:t,P=Cd(bd({},x),{x:p,y:v});this.crossEventProducer.crossToolHover=P,this.updateCrossTool(P)}}const It=4;function wd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p;const v=r.align,x=(l=i.textFont)!=null?l:te(r),P=i.bgColor,I=(c=i.textColor)!=null?c:Qt(P,o.labelTextColor,o.labelInvertedTextColor),O=(h=i.paddingTop)!=null?h:It,j=(d=i.paddingBottom)!=null?d:It,H=(u=i.paddingEnd)!=null?u:It,B=xe(jt(x,n)/2),Y=s-B-O,G=s+B+j-Y;if(a&&!os(s,t,G))return;n.save(),n.fillStyle=P,n.strokeStyle=P;const V=xe(t.width/6),U=v==="right"?t.x:t.x+t.width,$=v==="right"?U+V:U-V,K=r.labelBoxMargin.end,et=K-H,tt=t.width-V-et;eh(n,$,Y,U,Y+xe(G/2),$,Y+G,tt,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,v),n.fillStyle=I,n.font=x;const Q=v==="right"?t.x+t.width-Tt(e,n,x)-K:t.x+K;n.fillText(e,Q,s+B-1),n.restore()}function Sd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,v,x,P,I;const O=r.align,j=(l=i.textFont)!=null?l:te(r),H=i.bgColor,B=(c=i.textColor)!=null?c:Qt(H,o.labelTextColor,o.labelInvertedTextColor),Y=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,W=(u=(d=i.paddingTop)!=null?d:Y==null?void 0:Y.top)!=null?u:It,G=(p=(f=i.paddingBottom)!=null?f:Y==null?void 0:Y.bottom)!=null?p:It,V=(x=(v=i.paddingEnd)!=null?v:Y==null?void 0:Y.end)!=null?x:It,U=i.paddingStart,$=jt(j,n),K=s-$/2-W,tt=s+$/2+G-K,Q=(I=i.rounded)!=null?I:(P=r.typeConfig.rectangle)==null?void 0:P.rounded;if(a&&!os(s,t,tt))return;n.save(),n.fillStyle=H,n.strokeStyle=H;const ot=r.labelBoxMargin.end;n.font=j;const ct=Tt(e,n,j),at=ot-V,Pt=U!==void 0?ct+U+V:t.width-at,Vt=O==="right"?t.x+t.width-at-Pt:t.x+at,Ce=O==="right"?t.x+t.width-ct-ot:ot;Q?hr(n,Vt,K,Pt,tt,4,!0):n.fillRect(Vt,K,Pt,tt),n.fillStyle=B,n.fillText(e,Ce,s+$/2-1),n.restore()}function xd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,v,x;const P=r.align,I=(l=i.textFont)!=null?l:te(r),O=o.backgroundColor,j=(c=i.textColor)!=null?c:Qt(O,o.labelTextColor,o.labelInvertedTextColor),H=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,B=(u=(d=i.paddingTop)!=null?d:H==null?void 0:H.top)!=null?u:It,Y=(p=(f=i.paddingBottom)!=null?f:H==null?void 0:H.bottom)!=null?p:It,W=(x=(v=i.paddingEnd)!=null?v:H==null?void 0:H.end)!=null?x:It,G=i.paddingStart,V=jt(I,n),U=s-V/2-B,K=s+V/2+Y-U;if(a&&!os(s,t,K))return;n.save(),n.fillStyle=O,n.strokeStyle=O;const et=r.labelBoxMargin.end;n.font=I;const tt=Tt(e,n,I),Q=et-W,ot=G!==void 0?tt+G+W:t.width-Q,ct=P==="right"?t.x+t.width-Q-ot:t.x+Q,at=P==="right"?t.x+t.width-tt-et:et;n.fillStyle=O,n.strokeStyle=O,n.fillRect(ct,U,ot,K),n.fillStyle=j,n.fillText(e,at,s+V/2-1),n.restore()}function Pd(n,t,e=It){return jt(n,t)/2+e}function os(n,t,e){return!(n<t.y+e/2||n>t.y+t.height-e/2)}const _d="badge",Hr=4,kr={badge:wd,rectangle:Sd,plain:xd};function jr(n,t,e,s,i,r,o,a,l){var c,h,d,u,f;const p=r.y,v=r.labelText,x=(c=r.mode)!=null?c:"label",P=(h=r.labelType)!=null?h:_d,I=r.description,O=(d=r.textFont)!=null?d:te(a),j=r.bgColor,H=(u=r.lineColor)!=null?u:j,B=Tt(I!=null?I:"",n,O)+8,Y=rt(r.y),W=jt(O,n),G=p-W/2,U=p+W/2-G;n.save(),n.fillStyle=j,n.strokeStyle=H;const $=o.getBounds(M.PANE_UUID(Z)),K=kr[P],et=a.labels.descriptions,tt=Td(s,Y,U),Q=()=>et&&Md(e,t,s,i,r,a);let ot,ct;const at=2;a.align==="right"?(ot=$.x,ct=et?$.x+$.width-B:$.x+$.width+at):(ot=et?$.x+B:$.x-at,ct=$.x+$.width);const Pt=(f=r.lineY)!=null?f:r.y,Vt=()=>tt&&ne(n,()=>sh(n,ot,Pt,ct,Pt,1)),Ce=()=>K(n,s,v,p,r,a,l.yAxis,!1),pn={line:()=>{Vt(),Q()},"line-label":()=>{Vt(),Ce(),Q()},label:()=>{Q(),Ce()}};x!=="none"&&os(p,s,U)&&pn[x](),n.restore()}const Td=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Md(n,t,e,s,i,r){var o,a,l;const c=r.align||"right",h=i.description;if(!h||h.length===0)return;const d=i.y,u=te(r),f=Tt(h,t,u),p=jt(u,t),v=(o=i.paddingTop)!=null?o:Hr,x=(a=i.paddingBottom)!=null?a:Hr,P=d-p/2-v,O=d+p/2+x-P;t.save();const j=f+5,H=4,B=f+H*2,Y=s.x+s.width,W=c==="right"?Y-B:s.x+H;xc(n,t,W,P,j,O,.8),t.fillStyle=(l=i.descColor)!=null?l:i.bgColor,t.font=u;const G=c==="right"?Y-f-H*2:s.x+H*2;t.fillText(h,G,d+p/2-1),t.restore()}class Yr{constructor(t,e,s,i=()=>!0,r){this.config=t,this.canvasBoundsContainer=e,this.paneManager=s,this.crossDrawPredicate=i,this.noLines=r}draw(t,e){this.crossDrawPredicate()&&ne(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var s,i,r,o,a;const l=this.canvasBoundsContainer.getBounds(M.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES,{extensionY:1e-4}),h=(s=this.config.components.xAxis.padding.top)!=null?s:0,d=(r=this.config.components.yAxis.typeConfig[(i=this.config.components.crossTool.yLabel.type)!=null?i:"badge"])==null?void 0:r.paddings,u=(o=d==null?void 0:d.start)!=null?o:0,f=(a=this.paneManager.panes[e.paneId])==null?void 0:a.ht;if(c(e.x,l.y)){const p={start:[l.x,e.y],end:[l.x+l.width+u,e.y]},v={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},x=f==null?void 0:f(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),x&&(t.moveTo(...p.start),t.lineTo(...p.end)),t.moveTo(...v.start),t.lineTo(...v.end),t.stroke()),x&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,i,r,o,a;const l=this.config.components.crossTool.xLabel.padding,c=this.config.components.crossTool.xLabel.margin,h=this.config.colors.crossTool;if(this.config.components.xAxis.visible){t.font=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily;const d=e.x,u=e.time,f=t.measureText(u).width,p=this.config.components.xAxis.fontSize,v=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const x=(s=l==null?void 0:l.left)!=null?s:0,P=(i=l==null?void 0:l.right)!=null?i:0,I=(r=l==null?void 0:l.top)!=null?r:0,O=(o=l==null?void 0:l.bottom)!=null?o:0,j=(a=c==null?void 0:c.top)!=null?a:0,H=f+x+P,B=p+I+O,Y=Math.max(d-H/2,0),W=v.y+j+_e/2;hr(t,Y,W,H,B),t.fillStyle=h.labelTextColor;const G=Math.max(d-f/2,x),V=v.y+j+p+_e/2+I-1;t.fillText(u,G,V),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,i=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const r=this.paneManager.panes[e.paneId],o=e.y,a=this.config.components.crossTool.yLabel.type;if(!r)return;for(const l of r.yExtentComponents){const c=l.regularValueFromY(o),h=l.valueFormatter(c),d=this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=kr[a],f=a==="plain"?i.lineColor:i.labelTextColor;u(t,d,h,o,{textColor:f,bgColor:i.labelBoxColor,paddingBottom:s==null?void 0:s.bottom,paddingEnd:s==null?void 0:s.end,paddingTop:s==null?void 0:s.top},l.yAxis.state,this.config.colors.yAxis,!0)}}}}class Ad{draw(){}}class Ed extends X{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=i,this.paneManager=r,this.crossEventProducer=o,this.hoverProducer=a,this.baselineModel=l,this.crossToolTypeDrawers={},this.model=new yd(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel),this.addChildEntity(this.model);const c=new me(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const h=new ud(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),d=new $s;d.addDrawer(c,"CLEAR_CANVAS"),d.addDrawer(h,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(d,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new Yr(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new Yr(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Ad)}setVisible(t){this.model.setType(t?"cross-and-labels":"none")}setType(t){this.model.setType(t)}observeCrossToolChanged(){return this.model.currentHoverSubject}setMagnetTarget(t){this.config.components.crossTool.magnetTarget=t}registerCrossToolTypeDrawer(t,e){this.crossToolTypeDrawers[t]=e}}class Id{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,s])=>{for(const i of s){const{model:r,drawer:o}=i;o.draw(this.canvasModel,r,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class Xt{constructor(t){this.data=t,this.next=null}}class Dd{constructor(t){if(this._head=null,this._tail=null,this.length=0,this._head=t!=null?t:null,this.head!==null){let e=this.head;for(;e.next;)e=e.next;this._tail=e,this.length++}}insertAtEnd(t){const e=new Xt(t);if(this.head===null)this._head=e;else{let s=this.head;for(;s.next;)s=s.next;s.next=e}this._tail=e,this.length++}insertAt(t,e){if(!this.head||t<0||t>this.length)return null;const s=new Xt(e);if(t===0)s.next=this.head,this._head=s;else{let i=this.head,r=i,o=0;for(;i&&o<t;)o++,r=i,i=i.next;s.next=i,r.next=s,t===this.length-1&&(this._tail=s)}this.length++}removeAt(t){if(!this.head||t<0||t>=this.length)return null;let e=this.head,s=e,i=0;if(t===0)this._head=e.next;else{for(;e.next&&i<t;)i++,s=e,e=e.next;s.next=e.next,t===this.length-1&&(this._tail=s)}this.length--}getNodePosition(t){let e=0,s=this.head;for(;s;){if(s.data===t.data)return e;s=s.next,e++}return-1}size(){return this.length}get head(){return this._head}get tail(){return this._tail}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.data,t=t.next}}class Ld extends X{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this._objects=new ft({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new Xt(s);return i.getNodePosition(r)}addObject(t){var e,s;const i=t.paneId,r=this.objects,o=(e=r[i])!=null?e:new Dd;Object.keys(r).find(a=>a===i)||(r[i]=o),o.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.uniqueObjects[i]||(this.uniqueObjects[i]=new Set),this.uniqueObjects[i].add((s=t.parentId)!=null?s:t.id),this.setDynamicObjects(r)}removeObject(t){var e;const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new Xt(i),a=r.getNodePosition(o);r.removeAt(a),this.modelIdToObjectMap.delete(t),this.uniqueObjects[i.paneId]&&this.uniqueObjects[i.paneId].delete((e=i.parentId)!=null?e:i.id),r.size()===0&&delete this.objects[i.paneId],this.setDynamicObjects(this.objects)}updateObject(t){const e=this.getObjectInfoById(t.id);if(!e)return;const[s]=e;this.removeObject(s.id),this.addObject(t)}moveToPosition(t,e){const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new Xt(i),a=r.getNodePosition(o);a!==e&&(a<e?(r.insertAt(e,i),r.removeAt(a)):(r.removeAt(a),r.insertAt(e,i)),this.setDynamicObjects(this.objects))}bringToFront(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Xt(s),o=i.getNodePosition(r);o>=0&&o<i.size()&&(i.removeAt(o),i.insertAtEnd(s),this.setDynamicObjects(this.objects))}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Xt(s),o=i.getNodePosition(r);o>0&&o<=i.size()&&(i.removeAt(o),i.insertAt(0,s),this.setDynamicObjects(this.objects))}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Xt(s),o=i.getNodePosition(r);o>=0&&o+1<i.size()&&(i.removeAt(o),i.insertAt(o+1,s),this.setDynamicObjects(this.objects))}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Xt(s),o=i.getNodePosition(r);o>0&&o<i.size()&&(i.removeAt(o),i.insertAt(o-1,s),this.setDynamicObjects(this.objects))}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Od extends X{constructor(t,e){super();const s=new Ld(t);this.model=s,this.addChildEntity(s);const i=new Id(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Bd=()=>n=>n.toString(),Rd=(n,t)=>{var e;const s="date.get"+(t((e=n.timezone)!=null?e:"")?"":"UTC"),i={YYYY:r("FullYear"),YY:r("FullYear")+" % 100",MMM:o("shortMonths","Month"),MMMM:a(o("shortMonths","Month")),M:"1+"+r("Month"),d:r("Date"),H:r("Hours"),m:r("Minutes"),s:r("Seconds"),sss:r("Milliseconds"),EEE:o("shortDays","Day"),SSS:"this.addTwoZeros("+r("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(l){i[l+l]="this.addZero("+i[l]+")"});function r(l){return s+l+"()"}function o(l,c){return"this."+l+"["+r(c)+"]"}function a(l){return l+".toUpperCase()"}return function(l){var c;const h={shortDays:Fd(n),shortMonths:Hd(n),addZero(d){return d<10?"0"+d:d},addTwoZeros(d){return(d<100?"0":"")+(d<10?"0":"")+d},tzDate:t((c=n.timezone)!=null?c:"")||function(d){return new Date(+d)}};return d=>kd(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function Fd(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function Hd(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const Nr=(n,t,e)=>{if(n){if(typeof n=="string")return e(n);if(Array.isArray(n)){const s=n.filter(i=>{if(i.showWhen){const r=[];return i.showWhen.periodLessThen&&r.push(()=>{var o,a;return t<((a=(o=i.showWhen)==null?void 0:o.periodLessThen)!=null?a:0)}),i.showWhen.periodMoreThen&&r.push(()=>{var o,a;return t>=((a=(o=i.showWhen)==null?void 0:o.periodMoreThen)!=null?a:0)}),r.every(o=>o())}else return!0});if(s.length>0){const i=s[0];if(i.format)return e(i.format);if(i.customFormatter)return i.customFormatter}}}return Bd()},kd=(n,t,e,s)=>{t||(t="M/d/yyyy");const i=n.getDate(),r=n.getMonth(),o=n.getFullYear(),a=n.getHours(),l=n.getMinutes(),c=n.getSeconds(),h=n.getMilliseconds(),d=a%12,u=ve(d),f=ve(a),p=ve(l),v=ve(c),x=a<12?"AM":"PM",P=e[n.getDay()],I=P.substring(0,3),O=ve(i),j=r+1,H=ve(j),B=s[r],Y=B.substring(0,3),W=o+"",G=W.substring(2,4);return t=t.replace("hh",u+"").replace("h",d+"").replace("HH",f+"").replace("H",a+"").replace("mm",p+"").replace("m",l+"").replace("ss",v+"").replace("s",c+"").replace("S",h+"").replace("dd",O+"").replace("d",i+"").replace("EEEE",P).replace("EEE",I).replace("YYYY",W).replace("yyyy",W).replace("YY",G).replace("yy",G).replace("aaa",x),t.indexOf("MMM")>-1?t=t.replace("MMMM",B).replace("MMM",Y):t=t.replace("MM",H+"").replace("M",j+""),t},ve=n=>typeof n=="number"&&n<10?"0"+n:n,Oe=(n,t)=>`${n}_${t}`,jd=(n,t)=>{if(t){const e=Xr(t.normal),s=Xr(t.hover);return{type:n,normal:e,hover:s}}},Xr=n=>{var t;const s=new DOMParser().parseFromString(n,"text/html").querySelector("svg");let i=0;s&&(i=parseInt((t=s.getAttribute("height"))!=null?t:"",10));const a="data:image/svg+xml;base64,"+btoa(n),l=new Image;return l.src=a,{img:l,svgHeight:i}},Yd=(n,t,e,s,i)=>{if(i){const r=t[Oe(s,"hover")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}else{const r=t[Oe(s,"normal")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}},Nd={"rhombus-small":4,rhombus:6,"rhombus-large":8},Xd=["earnings","dividends","splits","conference-calls"];class zd{constructor(t,e,s,i,r,o){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.formatterProvider=o,this.customIcons={};const a=this.config.components.events.icons;a&&Xd.forEach(l=>{const c=jd(l,a[l]);c&&(this.customIcons[Oe(c.type,"normal")]=c.normal,this.customIcons[Oe(c.type,"hover")]=c.hover)})}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(M.EVENTS),e=this.canvasBoundsContainer.getBounds(M.ALL_PANES),s=this.canvasModel.ctx;s.save(),this.model.events.filter(i=>this.config.components.events.eventsVisibility[i.type]).forEach(i=>{var r,o,a,l;const c=this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale);if(c>e.x&&c<e.x+e.width){const h=this.config.colors.events[i.type];if(s.strokeStyle=(o=(r=h.line)!=null?r:h.normal)!=null?o:h.color,this.customIcons[Oe(i.type,"hover")]!==void 0){const d={x:c,y:t.y+t.height/2},u=this.model.hoveredEvent.getValue()===i;Yd(s,this.customIcons,d,i.type,u)}else this.drawDefaultEvent(s,c,t,i,h);if(this.model.hoveredEvent.getValue()===i){const d=this.config.components.events.line,u=d&&d[i.type]&&((a=d[i.type])==null?void 0:a.width),f=d&&d[i.type]&&((l=d[i.type])==null?void 0:l.dash);s.lineWidth=u!=null?u:1,s.beginPath(),s.setLineDash(f!=null?f:[]),s.moveTo(c,e.y),s.lineTo(c,t.y+t.height/2),s.stroke(),s.closePath(),this.config.components.xAxis.visible&&this.drawLabel(c,i)}}}),s.restore()}drawDefaultEvent(t,e,s,i,r){var o,a,l;const c=s.y+s.height/2;t.fillStyle=(o=r.normal)!=null?o:r.color,t.lineWidth=1.5;const h=Ks(i);t.beginPath(),t.moveTo(e-h,c),t.lineTo(e,c-h),t.lineTo(e+h,c),t.lineTo(e,c+h),t.closePath(),this.model.hoveredEvent.getValue()===i?(t.fillStyle=(a=r.hover)!=null?a:r.color,t.fill()):(t.strokeStyle=(l=r.normal)!=null?l:r.color,t.stroke())}drawLabel(t,e){var s;const i=this.canvasModel.ctx,r=this.canvasBoundsContainer.getBounds(M.X_AXIS),o=this.config.components.xAxis.fontFamily,a=this.config.components.xAxis.fontSize,l=(s=this.config.components.xAxis.padding.top)!=null?s:0,c=r.y+a-1+l;i.font=`${a}px ${o}`;const h=this.formatterProvider()(e.timestamp),d=i.measureText(h).width;i.fillStyle=this.config.colors.xAxis.backgroundColor,i.strokeStyle=this.config.colors.xAxis.backgroundColor,i.fillRect(t-d/2,r.y+1,d,r.height-1),i.fillStyle=this.config.colors.events[e.type].color,i.fillText(h,t-d/2,c)}getCanvasIds(){return[this.canvasModel.canvasId]}}function Ks(n){return Nd[n.style]}const as=5;class Wd{constructor(t,e,s,i,r,o=()=>!0){this.hitTestCanvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.drawPredicate=o}draw(){if(this.drawPredicate()){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(M.EVENTS);t.save(),this.model.events.forEach((s,i)=>{if(!this.config.components.events.eventsVisibility[s.type])return;const o=this.model.events[i-1],a=o&&this.chartModel.candleFromTimestamp(o.timestamp).xCenter(this.chartModel.scale),l=this.chartModel.candleFromTimestamp(s.timestamp).xCenter(this.chartModel.scale);if(l>e.x&&l<e.x+e.width){const c=this.config.colors.events[s.type].color;t.strokeStyle=c,t.fillStyle=c;const h=Ks(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+as)*2;if(a!==void 0){const u=Ks(o);if(this.config.components.events.eventsVisibility[o.type]&&a+u>l-d/2){const v=h*2+as;t.fillRect(a+u,e.y,v,e.height)}else t.fillRect(l-h-as,e.y,d,e.height)}else t.fillRect(l-h-as,e.y,d,e.height)}}),t.restore()}}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var Vd=Object.defineProperty,zr=Object.getOwnPropertySymbols,Ud=Object.prototype.hasOwnProperty,Gd=Object.prototype.propertyIsEnumerable,Wr=(n,t,e)=>t in n?Vd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Zd=(n,t)=>{for(var e in t||(t={}))Ud.call(t,e)&&Wr(n,e,t[e]);if(zr)for(var e of zr(t))Gd.call(t,e)&&Wr(n,e,t[e]);return n};const Vr=317,qs={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999]};class $d extends mr{constructor(t,e,s,i,r,o,a,l){super(t,e,r,a,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=s,this.canvasBoundsContainer=i,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new R,this.touchStartSubject=new R,this.dblClickSubject=new R,this.rightClickSubject=new R,this.hitTestDrawersPredicateSubject=new ft(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,vr(this,o),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(ue(100,de,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(dt(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=bt(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(dt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=bt(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(dt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mouseup")),o=this.canvasInputListener.observeDbClick(t).subscribe(c=>this.eventHandler(c,"dblclick")),a=this.canvasInputListener.observeContextMenu(t).pipe(dt(()=>Zd({},this.canvasInputListener.currentPoint))).subscribe(c=>{this.eventHandler(c,"contextmenu")}),l=this.canvasInputListener.observeWheel(t).subscribe(c=>setTimeout(()=>this.eventHandler(c,"zoom"),0));this.eventsSubscriptions.push(e,i,o,a,l,s,r)}}disableUserControls(){this.eventsSubscriptions.forEach(t=>t.unsubscribe()),this.eventsSubscriptions=[]}addSubscriber(t){this.hitTestSubscribers.push(t)}removeSubscriber(t){this.hitTestSubscribers=this.hitTestSubscribers.filter(e=>e===t)}idToColor(t){const e=(t*Vr).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/Vr}observeHoverOnElement(){return this.hoverSubject.asObservable()}observeTouchStartOnElement(){return this.touchStartSubject.asObservable()}observeDblClickOnElement(){return this.dblClickSubject.asObservable()}observeRightClickOnElement(){return this.rightClickSubject.asObservable()}getPixel(t,e){const s=window.devicePixelRatio;return this.prevAnimationFrameId!==Ps&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=Ps),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),s=this.colorToId(e[0]*65536+e[1]*256+e[2]),i=Number(s),[r]=Js(this.hitTestSubscribers,i);return r==null?void 0:r.lookup(s)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const s=this.getPixel(t.x,t.y),i=this.colorToId(s[0]*65536+s[1]*256+s[2]),r=Number(i),[o]=Js(this.hitTestSubscribers,r),a=o==null?void 0:o.lookup(i);return(e=o==null?void 0:o.resolveCursor)==null?void 0:e.call(o,t,a)}eventHandler(t,e){var s,i,r,o,a,l,c;const h=this.getPixel(t.x,t.y),d=this.colorToId(h[0]*65536+h[1]*256+h[2]),u=Number(d),[f,p]=Js(this.hitTestSubscribers,u),v=f==null?void 0:f.lookup(d),x={point:t,model:v};switch(e){case"mousedown":v&&((s=f==null?void 0:f.onMouseDown)==null||s.call(f,v,t)),p.forEach(P=>P.onMouseDown&&P.onMouseDown(null,t));break;case"mouseup":v&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,v,t)),p.forEach(P=>P.onMouseUp&&P.onMouseUp(null,t));break;case"hover":v&&((r=f==null?void 0:f.onHover)==null||r.call(f,v,t)),p.forEach(P=>P.onHover&&P.onHover(null,t)),this.hoverSubject.next(x);break;case"touchstart":v&&((o=f==null?void 0:f.onTouchStart)==null||o.call(f,v,t)),p.forEach(P=>P.onTouchStart&&P.onTouchStart(null,t)),this.touchStartSubject.next(x);break;case"dblclick":v&&((a=f==null?void 0:f.onDblClick)==null||a.call(f,v,t)),this.dblClickSubject.next(x);break;case"contextmenu":v&&((l=f==null?void 0:f.onRightClick)==null||l.call(f,v,t)),this.rightClickSubject.next(x);break;case"zoom":v&&((c=f==null?void 0:f.onZoom)==null||c.call(f,v,t)),p.forEach(P=>P.onZoom&&P.onZoom(null,t));break;default:break}}}const Js=(n,t)=>{let e;const s=[];return n.forEach(i=>{const[r,o]=i.getIdRange();t>=r&&t<=o?e=i:s.push(i)}),[e,s]};var Kd=Object.defineProperty,qd=Object.defineProperties,Jd=Object.getOwnPropertyDescriptors,Ur=Object.getOwnPropertySymbols,Qd=Object.prototype.hasOwnProperty,tu=Object.prototype.propertyIsEnumerable,Gr=(n,t,e)=>t in n?Kd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,eu=(n,t)=>{for(var e in t||(t={}))Qd.call(t,e)&&Gr(n,e,t[e]);if(Ur)for(var e of Ur(t))tu.call(t,e)&&Gr(n,e,t[e]);return n},su=(n,t)=>qd(n,Jd(t));class nu extends X{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ft(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>su(eu({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return qs.EVENTS}lookup(t){return this.events.filter(e=>e.id===t)[0]}onHover(t,e){this.hoveredEvent.getValue()!==t&&(t&&(t.point=e),this.hoveredEvent.next(t),this.canvasModel.fireDraw())}onTouchStart(t,e){this.onHover(t,e)}}class iu extends X{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>Nr(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new nu(e);this.eventsModel=c,this.addChildEntity(c),s.addSubscriber(c);const h=new zd(e,i,t,r,c,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(h,"EVENTS");const d=new Wd(s,i,t,r,c,()=>s.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(d,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(M.EVENTS,t.components.events.cursor)}setEvents(t){this.eventsModel.setEvents(t),this.canvasModel.fireDraw()}setVisible(t){this.config.components.events.visible=t,this.canvasBoundsContainer.recalculateBounds(),this.canvasModel.fireDraw()}setEventTypeVisible(t){Mt(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class ru{constructor(t,e,s,i,r,o,a,l,c=()=>!0,h,d){this.canvasModel=t,this.viewportModel=e,this.config=s,this.yAxisState=i,this.xBoundsProvider=r,this.yBoundsProvider=o,this.xLabelsProvider=a,this.yLabelsProvider=l,this.drawPredicate=c,this.extentIdx=h,this.getBaseline=d}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;ne(t,()=>this.drawVertical(t)),ne(t,()=>this.drawHorizontal(t)),ne(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.extentIdx===0&&this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const s=this.xBoundsProvider(),i=rt(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(s.x,i),t.lineTo(s.x+s.width,i),t.stroke(),t.closePath()}}drawVertical(t){const e=this.xLabelsProvider();if(e.length&&this.config.components.grid.vertical){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.xBoundsProvider(),i=s.x+s.width;for(const r of e){const o=At(this.viewportModel.toX(r.value));o>s.x&&o<i&&(t.beginPath(),t.moveTo(o,s.y),t.lineTo(o,s.y+s.height),t.stroke())}}}drawHorizontal(t){const e=this.yLabelsProvider();if(e.length&&this.config.components.grid.horizontal){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.yBoundsProvider();for(const i of e){const r=rt(this.viewportModel.toY(i.value)),o=Pd(i.text,t,It);r>s.y+o&&r<s.y+s.height-o&&(t.beginPath(),t.moveTo(s.x,r),t.lineTo(s.x+s.width,r),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Zr extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new ru(t,e,s,i,a,l,c,h,f,d,u)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class ou{constructor(t,e,s,i){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+s,a=r+i,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,o,t,"high"),this.drawMarkerLabel(l,a,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,i){const r=this.getMarkerY(t,s,i==="low"),o=Ge(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(s,i),c=this.getMarkerX(t,e,l);t.fillStyle=i==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(l,c,r);const h=this.canvasBoundsContainer.getBounds("PANE_CHART");Gt(t,h)}getMarkerText(t,e){const s=this.chartModel.pane.regularFormatter(t);return`${e==="high"?this.config.components.highLow.prefix.high:this.config.components.highLow.prefix.low} ${s}`}getMarkerY(t,e,s=!1){const i=this.chartModel.toY(e);if(s){const r=Ge(t,!1);return i+r}return i}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(M.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,s){let i=this.chartModel.toX(e);const r=this.canvasBoundsContainer.getBounds(M.CHART),o=4,a=t.measureText(s).width;return i+o+a>r.width&&(i=i-(o+a)),i+o}getCanvasIds(){return[this.canvasModel.canvasId]}}class au extends X{constructor(t,e,s,i,r){super();const o=new ou(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const lu=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],cu=24*60*60*1e3;class hu extends X{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new R}activate(){this.addRxSubscription(this.chartModel.scale.xChanged.subscribe(()=>this.highlights.length&&this.recalculateVisualHighlights()))}getHighlights(){return this.highlights}getVisualHighlights(){return this.visualHighlights}recalculateVisualHighlights(){this.visualHighlights={};const t=this.chartModel.getFirstTimestamp(),e=this.chartModel.getLastTimestamp()+cu;tl(this.highlights,t,e,du).forEach(i=>{var r;this.visualHighlights[i.type]||(this.visualHighlights[i.type]=[]),(r=this.visualHighlights[i.type])==null||r.push(i)})}setHighlights(t){this.highlights=t,this.highlights.sort((e,s)=>e.to-s.to),this.highlightsUpdatedSubject.next(this.highlights),this.highlights.length?this.recalculateVisualHighlights():this.visualHighlights={}}observeHighlightsUpdated(){return this.highlightsUpdatedSubject.asObservable()}}const du=n=>n.to,$t=[20,10];class uu{constructor(t,e,s,i,r){this.highlightsModel=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.config=r}draw(){var t,e,s,i;if(this.config.components.highlights.visible){const r=this.chartModel.getCandles(),o=this.canvasModel.ctx,a=this.highlightsModel.getVisualHighlights();if(this.highlightsModel.getHighlights().length&&r.length!==0&&this.chartModel.scale.isScaleReady()){const c=this.canvasBoundsContainer.getBounds(M.ALL_PANES);o.save(),Gt(o,c);const h=(t=this.config.components.highlights.border.width)!=null?t:1,d=(e=this.config.components.highlights.border.dash)!=null?e:[0,0],u=(s=this.config.components.highlights.fontSize)!=null?s:11,f=(i=this.config.components.highlights.fontFamily)!=null?i:"monospace",p=`${u}px ${f}, monospace`;o.font=p,o.lineWidth=h,o.setLineDash(d),lu.forEach(v=>{var x,P;const I=a[v];if(I){const O=this.config.colors.highlights[v],j=(x=O==null?void 0:O.border)!=null?x:"#ffffff",H=(P=O==null?void 0:O.background)!=null?P:"#ffffff";o.save(),o.beginPath(),o.fillStyle=H,o.strokeStyle=j,I.forEach(B=>{var Y,W,G;const V=this.chartModel.candleFromTimestamp(B.from),U=gt(V.width,this.chartModel.scale.zoomX),$=V.xStart(this.chartModel.scale),K=B.to-this.chartModel.chartBaseModel.period,et=this.chartModel.candleFromTimestamp(K),tt=gt(et.width,this.chartModel.scale.zoomX),Q=et.xStart(this.chartModel.scale)+tt;if(B.border&&this.drawBorders(B.border,o,$+U,Q-tt,c),o.fillRect($,c.y,Q-$,c.y+c.height),B.label){const ot=(Y=B.label.text)!=null?Y:"",ct=this.config.colors.highlights[B.type];o.save(),o.fillStyle=(W=ct==null?void 0:ct.label)!=null?W:"#ffffff";const at=Tt(ot,o,p),[Pt,Vt]=this.resolveHighlightLabelPosition((G=B.label.placement)!=null?G:"left-left",c,[$,Q],at);o.fillText(ot,Pt,Vt),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}resolveHighlightLabelPosition(t,e,s,i){const[r,o]=s;switch(t){case"right-left":return[o-$t[1]-i,e.y+$t[0]];case"left-left":return[r-$t[1]-i,e.y+$t[0]];case"right-right":return[o+$t[1],e.y+$t[0]];case"left-right":default:return[r+$t[1],e.y+$t[0]]}}drawBorders(t,e,s,i,r){const o=t.left,a=t.right;o&&(e.beginPath(),e.moveTo(s,r.y),e.lineTo(s,r.y+r.height),e.stroke(),e.closePath()),a&&(e.beginPath(),e.moveTo(i,r.y),e.lineTo(i,r.y+r.height),e.stroke(),e.closePath())}getCanvasIds(){return[this.canvasModel.canvasId]}}const fu="HIGHLIGHTS_PLUGIN";class gu extends X{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new hu(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new uu(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,fu)}getHighlights(){return this.highlightsModel.getHighlights()}setHighlights(t){this.highlightsModel.setHighlights(t)}setHighlightsVisible(t=!0){this.config.components.highlights.visible=t,this.eventBus.fireDraw(this.highLightsDrawer.getCanvasIds())}observeHighlightsUpdated(){return this.highlightsModel.observeHighlightsUpdated()}}function pu(){return N(function(n,t){var e,s=!1;n.subscribe(mt(t,function(i){var r=e;e=i,s&&t.next([r,i]),s=!0}))})}function J(n,t){return N(function(e,s){var i=0;e.subscribe(mt(s,function(r){return n.call(t,r,i++)&&s.next(r)}))})}var mu=Object.defineProperty,vu=Object.defineProperties,bu=Object.getOwnPropertyDescriptors,$r=Object.getOwnPropertySymbols,Cu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,Kr=(n,t,e)=>t in n?mu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,qr=(n,t)=>{for(var e in t||(t={}))Cu.call(t,e)&&Kr(n,e,t[e]);if($r)for(var e of $r(t))yu.call(t,e)&&Kr(n,e,t[e]);return n},Jr=(n,t)=>vu(n,bu(t));const zt=4;class wu{constructor(t,e,s,i,r,o){this.config=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.formatterFactory=r,this.visualCandlesProvider=o}draw(){if(this.config.components.navigationMap.visible){const t=this.visualCandlesProvider();if(t.length){const e=this.canvasBoundsContainer.getBounds(M.N_MAP),s=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_L),i=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_R),r=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_L),o=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_R),a=this.canvasBoundsContainer.getBounds(M.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),c=this.canvasModel.ctx;c.fillStyle=this.config.colors.navigationMap.backgroundColor,c.fillRect(e.x,e.y,e.width,e.height),c.strokeStyle=this.config.colors.paneResizer.lineColor,c.lineWidth=1,c.beginPath(),c.moveTo(e.x,e.y),c.lineTo(e.x+e.width,e.y),c.closePath(),c.stroke(),s.width!==0&&this.drawLeftArrowButton(c,s,this.config),i.width!==0&&this.drawRightArrowButton(c,i,this.config),c.fillStyle=this.config.colors.navigationMap.mapFillColor,c.beginPath(),c.moveTo(l.x,l.y+l.height);for(const h of t)c.lineTo(h[0],h[1]);if(c.lineTo(l.x+l.width,l.y+l.height),c.lineTo(l.x,l.y+l.height),c.closePath(),this.config.colors.navigationMap.mapGradientTopColor&&this.config.colors.navigationMap.mapGradientBottomColor){const h=c.createLinearGradient(l.x,l.y,l.x,l.y+l.height);h.addColorStop(0,this.config.colors.navigationMap.mapGradientTopColor),h.addColorStop(1,this.config.colors.navigationMap.mapGradientBottomColor),c.fillStyle=h}c.fill(),this.config.colors.navigationMap.mapColor&&(c.strokeStyle=this.config.colors.navigationMap.mapColor,c.stroke()),this.drawSlider(c,r,o,s,a),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,s,i){t.x<=s.x+s.width&&(t.x=s.x+s.width,i.x=t.x+t.width,e.x=i.x+i.width)}drawSlider(t,e,s,i,r){this.blockDrawSliderOnLeftArrow(e,s,i,r),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,s,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(r.x,r.y,r.width,r.height)}drawLeftArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-zt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r),t.lineTo(i+zt,r+zt),t.lineTo(i+zt,r-zt),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawRightArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-zt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r-zt),t.lineTo(i,r+zt),t.lineTo(i+zt,r),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,s,i){const r=s.components.navigationMap.knots.border;t.fillStyle=s.colors.navigationMap.knotColor;const o=i?e.x-r:e.x+r;t.fillRect(o,e.y,e.width,e.height),t.lineWidth=s.components.navigationMap.knots.lineWidth,r>0&&(t.beginPath(),t.moveTo(o,e.y),t.lineTo(o,e.y+e.height),t.lineTo(o+e.width,e.y+e.height),t.lineTo(o+e.width,e.y),t.lineTo(o,e.y),t.lineWidth=r,t.strokeStyle=s.colors.navigationMap.knotBorderColor,t.stroke()),t.beginPath(),t.moveTo(o+e.width/2,e.y+e.height/4),t.lineTo(o+e.width/2,e.y+3*e.height/4),t.strokeStyle=s.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=Ct(this.chartModel.mainCandleSeries.getSeriesInViewport()),s=this.config.components.navigationMap.timeLabels,i=s.visible;if(e.length&&i){const r=e[0].candle.timestamp,o=e[e.length-1].candle.timestamp,a=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:s.fontFamily,textSize:`${s.fontSize}px`},d={dateFormat:s.dateFormat,padding:s.padding,textProperties:Jr(qr({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:Jr(qr({},h),{textAlign:"right"})};this.drawTimeLabel(t,a,r,d),this.drawTimeLabel(t,l,o,u)}}drawTimeLabel(t,e,s,i){const r=i.padding,o=ei(s,i.dateFormat,this.formatterFactory);Jn(t,i.textProperties);const a=Ge(t),l=ti(o);sl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}class Be extends yr{constructor(t,e,s,i,r=Cr){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeXDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeXDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const Qr=4;class Su extends X{constructor(t,e,s,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.leftKnotDragStartXRelative=f.x-p.x-Qr},this.leftKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,P=(this.leftKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.leftRatio=P,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.rightKnotDragStartXRelative=f.x-p.x+Qr},this.rightKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,P=(this.rightKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.rightRatio=P,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=f=>{const{delta:p}=f,v=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),x=this.chartModel.mainCandleSeries.meanCandleWidth/(v.width/this.chartModel.mainCandleSeries.dataPoints.length),P=(this.lastMousePosition-p)*x;this.scale.moveXStart(this.scale.xStart-P),this.lastMousePosition=p};const a=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_R),c=new Be(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Be(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_SLIDER_WINDOW),u=new Be(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_L);this.addRxSubscription(this.canvasInputListeners.observeClick(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)}));const e=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_R);this.addRxSubscription(this.canvasInputListeners.observeClick(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>{const s=this.chartModel.mainCandleSeries;this.canvasBoundsContainer.leftRatio=s.dataIdxStart/(s.dataPoints.length-1),this.canvasBoundsContainer.rightRatio=s.dataIdxEnd/(s.dataPoints.length-1),this.canvasBoundsContainer.recalculateNavigationMapElementBounds(),this.bus.fireDraw()}))}}class xu extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new wu(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,M.N_MAP_CHART),this.navigationMapMoveHandler=new Su(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(M.N_MAP_CHART,i.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(M.N_MAP_BTN_L,i.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(M.N_MAP_BTN_R,i.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(M.N_MAP_KNOT_L,i.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(M.N_MAP_KNOT_R,i.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(M.N_MAP_SLIDER_WINDOW,i.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(bt(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(M.N_MAP),this.chartModel.scale.xChanged.pipe(pu(),J(([t,e])=>{const i=t.start<0||t.end>0,r=e.start<0||e.end>0;return i&&!r||r}))).subscribe(()=>{this.config.components.navigationMap.visible&&(this.visualCandles=this.makeVisualCandles(),this.canvasModel.fireDraw())}))}makeVisualCandles(){var t;const e=this.chartModel.getCandles();if(!e.length)return[];const s=this.chartModel.mainCandleSeries.dataIdxStart,i=this.chartModel.mainCandleSeries.dataIdxEnd,r=Math.round(Math.max(-s,0)),o=Math.max(this.chartModel.getCandlesCountWithRightOffset(),i)+r;let a=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),h=c.width,d=[];let u=0,f,p;for(f=0;f<h;f++)p=rt(f*o/h)-r,p in e?(d[f]=e[p].close,u=(t=d[f])!=null?t:0,a=Math.max(a,u),l=Math.min(l,u)):d[f]=0;return a-=l,d.map((v,x)=>[x+c.x,(a+l-v)*c.height/a+c.y])}setVisible(t=!0){var e;(e=this.config.components)!=null&&e.navigationMap&&(this.config.components.navigationMap.visible=t,this.eventBus.fire(Us),this.canvasModel.fireDraw())}}const to=()=>{const n=/Mac|iPod|iPhone|iPad/i.test(navigator.userAgent),e=[/Android/i,/webOS/i,/BlackBerry/i,/Windows Phone/i].some(s=>navigator.userAgent.match(s));return n?"apple":e?"mobile":"other"},Kp=(n,t)=>n==="apple"||n==="mobile"?3:t,Pu=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),_u=!!window.chrome,eo=typeof InstallTrigger!="undefined",Tu=navigator.platform.indexOf("Win")>-1,qp=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(Pu)i=e===n.deltaY*-3||Math.abs(e+Math.sign(e))===Math.abs(Math.round(n.deltaY)*3)||Math.abs(e-Math.sign(e))===Math.abs(Math.round(n.deltaY)*3);else if(_u){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,Tu){const r=Math.round(n.deltaY)===e||Math.abs(Math.round(n.deltaY)+Math.sign(n.deltaY))===Math.abs(e)||Math.abs(Math.round(n.deltaY)-Math.sign(n.deltaY))===Math.abs(e);i=Math.abs(e)===Math.abs(n.deltaY)||r}}else eo?Math.abs(n.deltaY)>Math.abs(n.deltaX)?i=!1:i=s===n.deltaX*-3:i=e===n.deltaY*-3;i&&(t=!0)}else n.deltaMode===0&&(t=!0);return eo&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Mu=(n,t)=>n==="percent"?t/4:t;var Qs=Math.pow;class Au extends X{constructor(t,e,s,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=15,this.chartPanningOptions={horizontal:!0,vertical:!0},this.zoomXHandler=(d,u)=>{const f=d.deltaY<0;if(this.config.scale.zoomToCursor){const v=this.canvasBoundsContainer.getBounds(M.CANVAS).width,P=d.offsetX/v;this.scale.zoomXToPercent(P,f,!1,u)}else this.scale.zoomXToEnd(f,u);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(Ue),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=d=>{const{delta:u}=d;this.currentPoint.x=u;const f=Nt(u,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-f),this.bus.fireDraw()},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)};const c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),h=new Be(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.horizontal});this.addChildEntity(h)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeWheel(t).pipe(J(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),ue(this.wheelThrottleTime,de,{trailing:!0,leading:!0})).subscribe(e=>{const s=to(),i=s==="apple"||s==="mobile"?-1:1,r=0+e.deltaX*i,o=0+e.deltaY*i;if(e.ctrlKey){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw();return}if(o!==0&&Math.abs(o)>Math.abs(r)){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw()}if(r!==0&&Math.abs(r)>Math.abs(o)){const a=Nt(r,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-a),this.bus.fireDraw();return}})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e}))}calculateDynamicSesitivity(t,e){const i=Math.max(Math.abs(t.deltaY),Math.abs(t.deltaX)),r=e*i/100;return Mu(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(Ue),this.currentPoint={x:0,y:0},s=t.yStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},r=l=>{const{delta:c}=l;if(this.currentPoint.y=c,t.state.auto)Eu(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const h=Nt(t.state.inverse?-c:c,t.zoomY);t.moveYStart(s+h)}},o=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},a=new is(e,{onDragTick:r,onDragStart:i,onDragEnd:o},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.vertical});return this.addChildEntity(a),a}}const Eu=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=Qs(Qs(Math.abs(n.x),2)+Qs(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},Iu=2;class Du extends X{constructor(t,e,s,i,r){super(),this.chartAreaPanHandler=t,this.scale=e,this.canvasInputListeners=s,this.mainCanvasParent=i,this.hitTest=r,this.touchedCandleIndexes=[0,0],this.canvasTouchInfo={touchStart:{x:0,y:0},isMoving:!1}}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart(this.hitTest).subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove(this.hitTest).subscribe(t=>this.handleTouchMoveEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(t=>this.handleTouchEndEvent(t)))}handleTouchStartEvent(t){const{clientX:e,clientY:s}=t.touches[0];t.touches.length===1&&(this.canvasTouchInfo.touchStart={x:e,y:s}),t.touches.length===2&&(this.chartAreaPanHandler.deactivate(),this.touchedCandleIndexes=this.getXPositions(t).map(i=>this.scale.fromX(i)))}handleTouchMoveEvent(t){const{clientX:e,clientY:s}=t.touches[0],{touchStart:i}=this.canvasTouchInfo;t.touches.length===1&&(this.canvasTouchInfo.isMoving=so(e,i.x,s,i.y)),t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}handleTouchEndEvent(t){this.canvasTouchInfo.isMoving=!1,t.touches.length===0&&this.chartAreaPanHandler.activate()}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),s=[0,0],i=document.body.scrollLeft||document.documentElement.scrollLeft;for(let r=0,o=t.touches.length;r<o;r++){const a=t.touches[r];s[r]=a.pageX-e.left-i}return s}pinchHandler(t,e){const s=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),i=s+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;s>=i||e[0]===e[1]||this.scale.setXScale(s,i)}}const so=(n,t,e,s,i=Iu)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i;class Lu extends X{constructor(t,e,s,i,r,o,a,l,c){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.hitTestCanvasModel=c,this.chartAreaPanHandler=new Au(this.eventBus,this.config,this.mainScale,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this,this.hitTestCanvasModel),this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new Du(this.chartAreaPanHandler,this.mainScale,this.canvasInputListener,this.mainCanvasParent,this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES)),this.addChildEntity(this.mainCanvasTouchHandler)}activateChartPanHandlers(){this.activate()}deactivatePanHandlers(){this.deactivate()}setChartPanningOptions(t,e){this.chartAreaPanHandler.chartPanningOptions={horizontal:t,vertical:e}}}const no=n=>t=>{const{top:e,bottom:s}=n(),i=t.high-t.low,r=i===0?1:i,o=r*e/100,a=r*s/100,l=t.low-a,c=t.high+o;return{low:l,high:c}},io=(n,t)=>{const e=no(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function Ou(){return Fn(1)}function ro(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Ou()(Xe(n,Ne(n)))}function Bu(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ne(n);return N(function(s,i){(e?ro(n,s,e):ro(n,s)).subscribe(i)})}function Ru(n){return J(function(t,e){return n<=e})}class Fu{constructor(t,e,s,i,r){this.config=t,this.boundsProvider=e,this.canvasModel=s,this.canvasAnimation=i,this.animationId=r}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),s=this.canvasModel.ctx,i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),r=this.config.components.paneResizer.dragZone;!t&&i&&(s.fillStyle=i.getColor(0),s.fillRect(e.x,e.y-r,e.width,e.height+2*r)),s.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?s.fillRect(e.x,e.y,e.width,e.height):s.fillRect(e.x,e.y-r,e.width,e.height+2*r)}}getCanvasIds(){return[this.canvasModel.canvasId]}}const oo=8;class tn extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=i,this.dragPredicate=r,this.chartPanComponent=o,this.canvasModel=a,this.drawingManager=l,this.canvasInputListener=c,this.canvasAnimation=h,this.config=d,this.canvasBoundsContainer=u,this.hitTestCanvasModel=f,this.initialY=0,this.resizeEvent$=new R,this.onYDragStartMobile=()=>{this.config.components.crossTool.type="none",this.onYDragStart()},this.onYDragStart=()=>{this.initialY=this.boundsProvider().y,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1),this.chartPanComponent.deactivatePanHandlers()},this.onYDragEndMobile=()=>{this.config.components.crossTool.type="cross-and-labels",this.onYDragEnd()},this.onYDragEnd=()=>{this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0),this.chartPanComponent.activateChartPanHandlers()},this.onYDragTick=p=>{const{delta:v,draggedPixels:x}=p;Math.abs(this.initialY-this.boundsProvider().y+x)>=0&&(this.dragTickCb(v),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new is(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:kt()?this.onYDragStartMobile:this.onYDragStart,onDragEnd:kt()?this.onYDragEndMobile:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:this.dragPredicate});this.addChildEntity(s),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(Bu(!1),J(this.dragPredicate),Et(),Ru(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Fu(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,br.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(br.paneResizer(this.id)))}doDeactivate(){super.doDeactivate(),this.resizeEvent$.complete()}handleHoverAnimation(t){let e;this.config.animation.paneResizer.bgMode?(e=this.canvasAnimation.getColorAlphaAnimation(this.animationId),(!e||!e.animationInProgress)&&this.canvasAnimation.startColorAlphaAnimation(this.animationId,[{color:this.config.colors.paneResizer.bgHoverColor,type:t}])):(e=this.canvasAnimation.getColorTransitionAnimation(this.animationId),(!e||!e.animationInProgress)&&this.canvasAnimation.startColorTransitionAnimation(this.animationId,[{startColor:this.config.colors.paneResizer.bgColor,endColor:this.config.colors.paneResizer.bgHoverColor,type:t}],this.config.animation.paneResizer.duration)),e&&e.animationInProgress&&e.revert()}}const en=1/32,Hu=n=>{const t=Math.floor(n),e=n-t,s=Math.round(e*64),r=Math.floor(s/2).toString().padStart(2,"0");return`${t}'${r}`},ao=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),Jp=n=>!!ao(n),Qp=n=>{const t=ao(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*en;return e+i}return Number(n)},ku=(n,t)=>e=>{let s;if(typeof e=="number")s=e;else if(typeof e=="string")s=Number(e);else return"\u2014";const i=t.treasuryFormat;if(i&&i.enabled)return Hu(s);const[r]=n.dataSeries;if(r!==void 0){const o=ge.getPricePrecision(s,r.pricePrecisions);return s.toFixed(o)}return`${s}`},ju=n=>(t,e)=>{const[s]=n.dataSeries;let i=t;const r=e!=null?e:s;r!==void 0&&(i=ki(t,r.getBaseline()));const o=i.toFixed(ge.DEFAULT_PRECISION).replace("-","\u2212")+" %";return o==="\u22120.00 %"?"0.00 %":o},Yu=(n,t)=>({percent:ju(n),regular:ku(n,t)});class Nu extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:gc}){super(),this.config=t,this.paneUUID=e,this.idx=s,this.paneComponent=i,this.chartBaseModel=r,this.canvasBoundsContainer=o,this.hitTestController=a,this.dynamicObjectsCanvasModel=l,this.scale=c,this.dragNDrop=d,this.dataSeries=u,this.formatters=f,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=p=>p.map(v=>new Ae(this.chartBaseModel.dataFromTimestamp(v.timestamp).centerUnit,v.close)),this.toY=p=>{var v,x;return(x=(v=this.mainDataSeries)==null?void 0:v.view.toY(p))!=null?x:1},this.valueFormatter=(p,v)=>{if(!this.formatters[this.yAxis.getAxisType()])return this.formatters.regular(p);const{regular:x,percent:P,logarithmic:I}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p);case"percent":return P?P(p,v):x(p);case"logarithmic":return I?I(p):x(p);default:return this.regularFormatter(p)}},this.addChildEntity(c),this.setValueFormatters(Yu(this,t)),this.yAxis=h(this.valueFormatter.bind(this),()=>this.mainDataSeries),this.addChildEntity(this.yAxis)}doDeactivate(){super.doDeactivate(),this.dataSeries.forEach(t=>{this.paneComponent.seriesRemovedSubject.next(t),t.deactivate()})}getBounds(){return this.scale.getBounds()}getBaseline(){var t,e;return(e=(t=this.mainDataSeries)==null?void 0:t.getBaseline())!=null?e:1}createDataSeries(){const t=new Vi(this,yt(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){if(this.dataSeries.add(t),this.dataSeries.size===1)this.mainDataSeries=t;else if(this.paneComponent.yExtentComponents.length>1&&this.paneUUID!==Z){this.mainDataSeries=t;const e=Array.from(this.paneComponent.mainExtent.dataSeries);this.paneComponent.mainExtent.mainDataSeries=e[e.length-1]}this.paneComponent.updateView(),this.paneComponent.seriesAddedSubject.next(t)}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView(),this.paneComponent.seriesRemovedSubject.next(t)}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var e,s;return(s=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?s:this.scale.fromY(t)}}const lo=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(n.dataSeries).filter(s=>s.highLowProvider.isHighLowActive()).map(s=>s.highLowProvider.calculateHighLow(t));return nr(e)}});class Xu{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=qs.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return qs.DATA_SERIES}get allDataSeries(){return Pe(Pe(Object.values(this.panes),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(s=>s.htId===t)}onHover(t){this.allDataSeries.forEach(e=>e.highlighted=e.htId===(t==null?void 0:t.htId)),this.canvasModel.fireDraw()}onMouseDown(t){t&&this.handleYExtentDragStart(t)}onMouseUp(){this.handleYExtentDragEnd()}handleYExtentDragStart(t){Object.values(this.panes).forEach(e=>e.yExtentComponents.forEach(s=>s.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.panes).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}const Wt="#FF00FF";function tm(n,t,e,s){const i=n.yAxis.backgroundColor,r=n.chartAreaTheme.backgroundColor,o=n.chartAreaTheme.backgroundGradientTopColor,a=n.chartAreaTheme.backgroundGradientBottomColor,l=s.align==="left"?o:a,c=n.chartAreaTheme.backgroundMode==="gradient"?l:r,h=i==="transparent"?c:i;return getLabelTextColorByBackgroundColor(h,t,e)}const zu=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,Wu=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Wt},Vu=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Wt},Uu=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Wt},Gu=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Wt},Zu=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Wt},$u=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Wt},Ku=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Wt},co=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Wt},qu=()=>(console.warn("Fallback for label default color"),Wt),ho=10;class uo extends X{constructor(t,e,s,i,r,o,a,l){if(super(),this.bus=t,this.config=e,this.scale=i,this.canvasInputListener=r,this.bounds=o,this.hitTest=a,this.hitTestCanvasModel=l,this.yAxisDragEndSubject=new R,this.lastYStart=0,this.lastYEnd=0,this.lastYHeight=0,this.lastYPxHeight=0,this.onYDragStart=()=>{this.scale.haltAnimation(),this.lastYStart=this.scale.yStart,this.lastYEnd=this.scale.yEnd,this.lastYHeight=this.scale.yEnd-this.scale.yStart,this.lastYPxHeight=Math.max(this.bounds.getBounds(M.Y_AXIS).height,mi),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onYDragTick=c=>{let{delta:h}=c;this.touches&&this.touches.length>1&&(h=Math.min(this.touches[0].clientY,this.touches[1].clientY)===this.touches[0].clientY?h:-h);let d;h<0?d=1/(1+-h/this.lastYPxHeight*(ho-1)):d=1+h/this.lastYPxHeight*(ho-1);const f=(this.lastYHeight*d-this.lastYHeight)/2,p=this.lastYStart-f,v=this.lastYEnd+f;(this.lastYStart!==p||this.lastYEnd!==v)&&(this.scale.setYScale(p,v),this.scale.state.auto=!1,this.bus.fireDraw())},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next(),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>i.autoScale(!0),this.dblTapCallback=()=>i.autoScale(!0),e.customScale){const c=new is(a,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},r,s,{dragPredicate:()=>s.chartAreaPanHandler.chartPanningOptions.vertical&&e.type!=="percent"});this.addChildEntity(c),this.dragNDropYComponent=c}}isDragging(){return this.dragNDropYComponent?Math.abs(this.dragNDropYComponent.draggedPixels)>0:!1}doActivate(){this.config.customScaleDblClick&&(this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>{this.dblClickCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})))}}class Ju{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${yt()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),Wn(this.animFrameId,()=>{this.calculatedInThisFrame=!1})),(t=this.cache)!=null?t:this.dataProvider()}forceCalculateOrGet(){return this.invalidate(),this.calculateOrGet()}getLastCachedValue(){return this.cache}updateCacheValue(t){this.cache=t}invalidate(){this.cache=void 0,this.calculatedInThisFrame=!1}}const Qu=0,tf=.01;class sn{constructor(t,e,s,i,r=!1,o,a,l=Es,c=23,h){this.increment=t,this.startEndProvider=e,this.lengthProvider=s,this.valueFormatter=i,this.withZero=r,this.axisTypeProvider=o,this.baseLineProvider=a,this.labelFilter=l,this.singleLabelHeightPixels=c,this.yAxisConfig=h,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new R,this.newGeneratedLabelsSubject=new R,this.lastStart=0,this.lastEnd=0,this.labelsCache=new Ju(()=>this.labelFilter(this.doGenerateLabels())),this.treasuryFormat=this.yAxisConfig&&this.yAxisConfig.treasuryFormat}generateRegularLabels(t,e,s){const i=[];this.withZero&&i.push({value:0,text:"0"});let r=ut.roundToNearest(t,s);for(;r<e;){const o=ut.roundToNearest(r,s),a=this.valueFormatter(o);i.push({value:o,text:a}),r=ut.roundDecimal(r+s)}return i}generatePercentLabels(t,e,s){const i=[],r=this.baseLineProvider();let o=ut.roundToNearest(t,s);for(;o<e;){const a=ut.roundToNearest(o,s),l=ji(a,r),c=this.valueFormatter(l);i.push({value:a,text:c}),o=ut.roundDecimal(o+s)}return i}generateLogarithmLabels(t,e,s){const i=[];let r=ut.roundToNearest(t,s);for(;r<e;){const o=zs(r),a=this.valueFormatter(o);i.push({value:r,text:a}),r=ut.roundDecimal(r+s)}return i}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[s,i]=this.calculateMinMax(),r=this.getAxisStep(s,i,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=r);let o;const a=this.axisTypeProvider();if(a==="logarithmic"?o=this.generateLogarithmLabels(s,i,r):a==="percent"?o=this.generatePercentLabels(s,i,r):o=this.generateRegularLabels(s,i,r),this.lastSingleLabelHeightValue!==r&&this.labelsCache.cache){const l=(t=this.labelsCache.getLastCachedValue())!=null?t:[];this.distanceBetweenLabelsChangeSubject.next([l,o]),this.lastSingleLabelHeightValue=r}return this.newGeneratedLabelsSubject.next(o),o}calculateMinMax(){const[t,e]=this.startEndProvider(),s=this.lengthProvider(),i=sn.getLabelBounds(t,e,s);return[i[0],i[1]]}getAxisStep(t,e,s){const i=e-t,r=s/this.singleLabelHeightPixels,o=this.calculateIncrement(i),a=i/r;return this.calculateAxisStep(a,o)}observeDistanceBetweenLabelsChanged(){return this.distanceBetweenLabelsChangeSubject.asObservable()}observeLabelsChanged(){return this.newGeneratedLabelsSubject.asObservable()}calculateIncrement(t){var e;if(this.increment)return this.increment;if(!isNaN(t)){const s=(e=this.treasuryFormat)!=null&&e.enabled?en:ge.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(tf)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=zs(e)+t;return Yi(i)-e;case"regular":return t}}generateNumericLabels(){const[t,e]=this.startEndProvider();return(t!==this.lastStart||e!==this.lastEnd)&&this.labelsCache.invalidate(),this.lastStart=t,this.lastEnd=e,this.labelsCache.calculateOrGet()}static getLabelBounds(t,e,s){const i=Math.abs((e-t)*(Qu/s));return[t-i,e+i]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let s=e,i=e,r=0;for(;s<t&&s>0;)r>=this.gridDistanceMultipliers.length&&(r=0,i*=10),s=i*this.gridDistanceMultipliers[r++];return s}}class ef extends sn{constructor(t,e,s,i,r=()=>"regular",o=23,a){super(t,()=>[s.yStart,s.yEnd],()=>s.getBounds().height,i,!1,r,()=>{var l,c;return(c=(l=e())==null?void 0:l.getBaseline())!=null?c:1},void 0,o,a),this.dataSeriesProvider=e}getLargestLabel(){var t;return((t=this.labelsCache.getLastCachedValue())!=null?t:[]).reduce((e,s)=>s.text.length>e.length?s.text:e,"")}updateTreasuryFormat(t){this.treasuryFormat=t}calculateIncrement(t){var e,s;const i=this.dataSeriesProvider();if(i){const r=wt(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=Tc(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?en:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function fo(n,t,e){var s=k(n)||t||e?{next:n,error:t,complete:e}:n;return s?N(function(i,r){var o;(o=s.subscribe)===null||o===void 0||o.call(s);var a=!0;i.subscribe(mt(r,function(l){var c;(c=s.next)===null||c===void 0||c.call(s,l),r.next(l)},function(){var l;a=!1,(l=s.complete)===null||l===void 0||l.call(s),r.complete()},function(l){var c;a=!1,(c=s.error)===null||c===void 0||c.call(s,l),r.error(l)},function(){var l,c;a&&((l=s.unsubscribe)===null||l===void 0||l.call(s)),(c=s.finalize)===null||c===void 0||c.call(s)}))}):le}class sf extends X{constructor(t,e,s,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${yt()}`}doActivate(){super.doActivate(),this.addRxSubscription(bt(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(dt(t=>t.height),J(t=>Aa(t,this.prevYAxisHeight,1.5)),fo(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,we(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){we(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class nf extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new ef(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new sf(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new tc(e,o,i,s,r,t,()=>this.canvasBoundsContainer.updateYAxisWidths(),h),this.addChildEntity(this.fancyLabelsModel)}doActivate(){const t={getLargestLabel:()=>{var e;return((e=this.labelsGenerator.labelsCache.getLastCachedValue())!=null?e:[]).map(s=>s.text).concat(this.fancyLabelsModel.orderedLabels.flatMap(s=>s.labels).map(s=>s.labelText)).reduce((s,i)=>i.length>s.length?i:s,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class rf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x){super(),this.eventBus=t,this.config=e,this.mainCanvasModel=s,this.canvasModel=i,this.scale=r,this.canvasInputListeners=o,this.canvasBoundsContainer=a,this.chartPanComponent=l,this.cursors=c,this.paneUUID=u,this.extentIdx=f,this.hitTestCanvasModel=p,this.chartResizeHandler=v,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new R,this.axisAlignSetSubject=new R,this.axisAlignMovedSubject=new R,this.setDblClickCallback=I=>this.yAxisScaleHandler.setDblClickCallback(I),this.setDblTapCallback=I=>this.yAxisScaleHandler.setDblTapCallback(I);const P=x?se(x):{};this.state=Mt(P,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new uo(t,this.state,l,r,o,a,a.getBoundsHitTest(M.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new nf(this.paneUUID,t,this.state,a,i,r,h,d,f,this.chartResizeHandler),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}setExtentIdx(t){this.extentIdx=t,this.model.extentIdx=t,this.yAxisScaleHandler.deactivate(),this.removeChildEntity(this.yAxisScaleHandler),this.yAxisScaleHandler=new uo(this.eventBus,this.state,this.chartPanComponent,this.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,t)),this.hitTestCanvasModel),this.addChildEntity(this.yAxisScaleHandler)}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",Uu),this.registerLabelColorResolver("bar",Wu),this.registerLabelColorResolver("line",Vu),this.registerLabelColorResolver("area",Gu),this.registerLabelColorResolver("scatterPlot",Zu),this.registerLabelColorResolver("histogram",$u),this.registerLabelColorResolver("baseline",Ku),this.registerLabelColorResolver("trend",co),this.registerLabelColorResolver("hollow",co)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.cursor)}updateOrderedLabels(t=!1){this.model.fancyLabelsModel.updateLabels(t)}registerLabelColorResolver(t,e){this.labelsColorByChartTypeMap[t]=e}getLabelsColorResolver(t){var e;return(e=this.labelsColorByChartTypeMap[t])!=null?e:qu}registerYAxisLabelsProvider(t,e=ee.MAIN,s=yt()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,s),s}addSimpleYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}updateCustomYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}deleteSimpleYAxisLabel(t){delete this.model.fancyLabelsModel.customLabels[t],this.canvasModel.fireDraw()}getAxisType(){return this.state.type}unregisterYAxisLabelsProvider(t=ee.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx))}registerYAxisWidthContributor(t){this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t)}setAxisType(t){t!==this.state.type&&(this.state.type=t,this.config.components.yAxis.type=t,this.axisTypeSetSubject.next(t),this.scale.autoScale(!0),this.model.fancyLabelsModel.updateLabels(!0),this.updateCursor(),this.mainCanvasModel.fireDraw())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.axisAlignSetSubject.next(t),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.activate():this.deactivate(),this.model.fancyLabelsModel.updateLabels(),this.model.baseLabelsModel.updateLabels()}isVisible(){return this.state.visible}setLockPriceToBarRatio(t=!1){this.scale.setLockPriceToBarRatio(t)}changeLabelMode(t,e){this.state.labels.settings[t].mode=e,this.model.fancyLabelsModel.updateLabels()}changeLabelAppearance(t,e){this.state.labels.settings[t].type=e,this.model.fancyLabelsModel.updateLabels()}togglePriceScaleInverse(t=!1){this.scale.state.inverse=t,this.scale.inverseY=t,this.model.fancyLabelsModel.updateLabels(),this.scale.scaleInversedSubject.next(t),this.canvasModel.fireDraw()}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}class of extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x,P,I,O,j){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=i,this.hitTestController=r,this.config=o,this.mainScale=a,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=d,this.cursorHandler=u,this.eventBus=f,this.canvasBoundsContainer=p,this.uuid=v,this.seriesAddedSubject=x,this.seriesRemovedSubject=P,this.hitTestCanvasModel=I,this.chartResizeHandler=O,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new R,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(B,Y)=>this.mainExtent.valueFormatter(B,Y);const H=this.createExtentComponent(j);this.mainExtent=H,this.ht=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(v),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get dataSeries(){return Pe(this.yExtentComponents,t=>Array.from(t.dataSeries))}get visible(){return this.canvasBoundsContainer.graphsHeightRatio[this.uuid]>0}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.uuid)).pipe(Et(Si)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()}))}toY(t){var e,s;return(s=(e=this.mainExtent.mainDataSeries)==null?void 0:e.view.toY(t))!=null?s:this.scale.toY(t)}createGridComponent(t,e,s,i,r,o){const a=M.PANE_UUID(t);return new Zr(this.mainCanvasModel,s,this.config,i,`PANE_${t}_${e}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(a),()=>this.canvasBoundsContainer.getBounds(a),()=>[],r,e,o,()=>this.config.components.grid.visible)}createYPanHandler(t,e){const s=M.PANE_UUID(t),i=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(s));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(i),i.disable()},i]}addCursors(t,e){const s=M.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(s,e.state.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(s)}createExtentComponent(t){var e,s;const i=this.yExtentComponents.length,r=M.PANE_UUID(this.uuid),o=()=>this.canvasBoundsContainer.getBounds(r),a=(e=t==null?void 0:t.scale)!=null?e:new Jc(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(v,x)=>new rf(this.eventBus,this.config,this.mainCanvasModel,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,v,x,this.uuid,i,this.hitTestCanvasModel,this.chartResizeHandler,l),u=new Nu(this.config.components.yAxis,this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,d,h);u.addSubscription(c),u.addSubscription(this.addCursors(i,u.yAxis)),t!=null&&t.paneFormatters&&u.setValueFormatters(t.paneFormatters),u.yAxis.togglePriceScaleInverse(t==null?void 0:t.inverse),u.scale.setLockPriceToBarRatio(t==null?void 0:t.lockToPriceRatio),((s=t==null?void 0:t.useDefaultHighLow)!=null?s:!0)&&a.autoScaleModel.setHighLowProvider("default",io(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),lo(u)));const p=this.createGridComponent(this.uuid,u.idx,a,u.yAxis.state,()=>u.yAxis.model.baseLabelsModel.labels,()=>u.toY(u.getBaseline()));return u.addChildEntity(p),u.activate(),this.yExtentComponents.push(u),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next(),u}removeExtentComponents(t){t.forEach(e=>e.disable()),this.yExtentComponents=this.yExtentComponents.filter(e=>!t.map(s=>s.idx).includes(e.idx)),this.yExtentComponents.forEach((e,s)=>{e.yAxis.setExtentIdx(s),e.idx=s,e.yAxis.updateCursor()}),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next()}moveDataSeriesToNewExtentComponent(t,e,s,i="right"){const r=se(s.yAxis.state),o=se(s.scale.state),a=Mt(r,this.config.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),l=this.createExtentComponent({initialYAxisState:a,inverse:o.inverse,lockToPriceRatio:o.lockPriceToBarRatio});l.yAxis.setYAxisAlign(i),t.forEach(c=>c.moveToExtent(l)),s.dataSeries.size===0&&e.removeExtentComponents([s])}moveDataSeriesToExistingExtentComponent(t,e,s,i,r){t.forEach(o=>o.moveToExtent(i)),!r&&s.dataSeries.size===0&&e.removeExtentComponents([s]),this.yExtentComponentsChangedSubject.next()}updateView(){this.yExtentComponents.forEach(t=>{t.scale.doAutoScale(),t.yAxis.model.labelsGenerator.generateNumericLabels()}),this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}mergeYExtents(){for(let t=1;t<this.yExtentComponents.length;t++){const e=this.yExtentComponents[t];e.dataSeries.forEach(s=>s.moveToExtent(this.mainExtent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainExtent]}getBounds(){return this.mainExtent.getBounds()}createDataSeries(){var t;return(t=this.mainExtent)==null?void 0:t.createDataSeries()}addDataSeries(t){this.mainExtent.addDataSeries(t),this.updateView()}removeDataSeries(t){this.mainExtent.removeDataSeries(t),this.updateView()}getAxisType(){return"regular"}moveUp(){this.canvasBoundsContainer.movePaneUp(this.uuid)}moveDown(){this.canvasBoundsContainer.movePaneDown(this.uuid)}canMoveUp(){const t=ce(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=wt(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}var af=Object.defineProperty,lf=Object.defineProperties,cf=Object.getOwnPropertyDescriptors,go=Object.getOwnPropertySymbols,hf=Object.prototype.hasOwnProperty,df=Object.prototype.propertyIsEnumerable,po=(n,t,e)=>t in n?af(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,uf=(n,t)=>{for(var e in t||(t={}))hf.call(t,e)&&po(n,e,t[e]);if(go)for(var e of go(t))df.call(t,e)&&po(n,e,t[e]);return n},ff=(n,t)=>lf(n,cf(t));class gf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x,P){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=v,this.hitTestCanvasModel=x,this.chartResizeHandler=P,this.panes={},this.paneRemovedSubject=new R,this.paneAddedSubject=new R,this.dataSeriesAddedSubject=new R,this.dataSeriesRemovedSubject=new R,this.hitTestController=new Xu(this.panes,this.dynamicObjectsCanvasModel);const I=this.createPane(Z,{useDefaultHighLow:!1,scale:this.mainScale});I.mainExtent.scale.autoScaleModel.setHighLowProvider("series",lo(I.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",no(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removePaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone+oo}),s=()=>this.chartBaseModel.mainVisualPoints.length!==0,i=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},r=M.PANE_UUID_RESIZER(t),o=new tn(r,()=>this.canvasBoundsContainer.getBounds(r),e,i,s,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer,this.hitTestCanvasModel);return this.userInputListenerComponents.push(o),o}get yExtents(){return Pe(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(s=>this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(s.uuid))(t.x,t.y))}createPane(t=yt(),e){if(this.panes[t]!==void 0)return this.panes[t];const s=new of(this.chartBaseModel,this.mainCanvasModel,this.yAxisLabelsCanvasModel,this.dynamicObjectsCanvasModel,this.hitTestController,this.config,this.mainScale,this.drawingManager,this.chartPanComponent,this.canvasInputListener,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,t,this.dataSeriesAddedSubject,this.dataSeriesRemovedSubject,this.hitTestCanvasModel,this.chartResizeHandler,e);return this.config.components.paneResizer.visible&&s.addChildEntity(this.addResizer(t)),s.addSubscription(this.addBounds(t,e==null?void 0:e.order)),s.addSubscription(this.addCursors(t)),s.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,s.ht)),this.panes[t]=s,s.activate(),this.recalculateState(),s.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),s}movePaneUp(t){this.canvasBoundsContainer.movePaneUp(t)}movePaneDown(t){this.canvasBoundsContainer.movePaneDown(t)}canMovePaneUp(t){var e,s;const i=ce(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}canMovePaneDown(t){var e,s;const i=wt(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}removePane(t){const e=this.panes[t];e!==void 0&&(this.paneRemovedSubject.next(e),e.disable(),e.yExtentComponents.forEach(s=>s.disable()),delete this.panes[t],this.recalculateState())}hidePane(t){const e=this.panes[t];if(e===void 0||!e.visible)return;const s=M.PANE_UUID_RESIZER(t),i=this.userInputListenerComponents.find(r=>r instanceof tn&&r.id===s);i==null||i.disable(),this.canvasBoundsContainer.hidePaneBounds(t),this.recalculateState()}showPane(t){const e=this.panes[t],s=M.PANE_UUID_RESIZER(t);if(e===void 0||e.visible)return;const i=this.userInputListenerComponents.find(r=>r instanceof tn&&r.id===s);i==null||i.enable(),this.canvasBoundsContainer.showPaneBounds(t),this.recalculateState()}moveDataSeriesToPane(t,e,s,i){const{paneUUID:r,extent:o,direction:a,align:l,extentIdx:c,isForceKeepPane:h,index:d=0}=i,u=r&&this.panes[r],f=l?ff(uf({},s.yAxis.state),{align:l}):void 0,p=c&&c>0;if(!u){const v=a&&a==="above"?d:d+1,x=this.createPane(r,{order:v,initialYAxisState:f,inverse:s.scale.state.inverse,lockToPriceRatio:s.scale.state.lockPriceToBarRatio});x.moveDataSeriesToExistingExtentComponent(t,e,s,x.mainExtent,h),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid);return}o&&!p?u.moveDataSeriesToExistingExtentComponent(t,e,s,o):u.moveDataSeriesToNewExtentComponent(t,e,s,l!=null?l:s.yAxis.state.align),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid)}addCursors(t,e=this.config.components.chart.cursor){const s=M.PANE_UUID(t),i=M.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone+oo),()=>{this.cursorHandler.removeCursorForCanvasEl(s),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(i)}}recalculateState(){Object.values(this.panes).forEach(t=>t.scale.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])}}class pf extends X{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,s=this.canvasModel.ctx;if(s){s.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,i,r),s.drawImage(this.elements.mainCanvas,0,0,i,r),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),s.drawImage(this.elements.crossToolCanvas,0,0,i,r),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(s),new Promise((o,a)=>this.elements.snapshotCanvas.toBlob(l=>l?o(l):a("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const mf=(n,t=1)=>{function e(i){let r;const o=Math.pow(10,t);return i=Math.round(i*o)/o,i>=1e-15&&i<1?r=i.toFixed(t).replace(/\.?0+$/,""):r=String(i),r.replace(/(\.[1-9]*)0+$/,(a,l)=>l)}function s(i){let r="";return i<0&&(r="-",i=-i),i<995?r+e(i):i<999995?r+e(i/1e3)+"K":i<999999995?(i=1e3*Math.round(i/1e3),r+e(i/1e6)+"M"):(i=1e6*Math.round(i/1e6),r+e(i/1e9)+"B")}return s(n)},mo=class gs extends X{constructor(t,e,s,i){super(),this.chartComponent=t,this.config=e,this.volumesModel=s,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var t,e;return!((t=this.pane)!=null&&t.scale.isViewportValid())&&((e=this.pane)==null?void 0:e.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var t;return(t=this.pane)==null?void 0:t.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[gs.UUID]===void 0){const e=this.paneManager.createPane(gs.UUID,{paneFormatters:{regular:r=>mf(r,1)},useDefaultHighLow:!1,increment:1});this.pane=e,e.mainExtent.yAxis.setAxisType("regular");const{scale:s}=e,i=io(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);s.autoScaleModel.setHighLowProvider("volumes",i),s.doAutoScale(!0)}}deactiveSeparateVolumes(){this.paneManager.removePane(gs.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};mo.UUID="volumes";let vf=mo;const ls=.3,bf=(n,t)=>{const e=t.barTheme[`${n}Color`];return Ot()(e).alpha(ls).toString()},Cf=(n,t)=>{const e=t.volume[`${n}BarColor`];return Ot()(e).alpha(ls).toString()},yf=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Ot()(e).alpha(ls).toString()},nn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Ot()(e).alpha(ls).toString()},wf=3;class Sf{constructor(t,e,s,i,r,o){this.config=t,this.volumesModel=e,this.chartModel=s,this.getViewportModel=i,this.volumesColorByChartTypeMap=r,this.drawPredicate=o,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const s=(e=this.volumesColorByChartTypeMap[t])!=null?e:Cf;this.volumeBarColors.down=s("down",this.config.colors),this.volumeBarColors.up=s("up",this.config.colors),this.volumeBarColors.none=s("none",this.config.colors)}draw(t){if(this.config.components.volumes.visible&&this.drawPredicate()){this.calculateColors(this.config.components.chart.type);const e=t.ctx;e.save();const s=this.getViewportModel().getBounds();Gt(e,s),this.drawVolumes(t),e.restore()}}drawLastBar(){this.config.components.volumes.visible}drawVolumes(t){const e=this.volumesModel.volumeMax.getValue();if(e===0)return;const s=Ct(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1)),i=this.getViewportModel();s.forEach((r,o)=>{if(r.candle.volume){const a=i.getBounds(),l=a.height,c=s[o+1]!==void 0?At(i.toX(s[o+1].startUnit)):void 0,h=At(i.toX(r.startUnit)),d=c!==void 0?c-h:At(gt(r.width,i.zoomX));if(this.config.components.volumes.showSeparately){const u=At(i.toY(r.candle.volume)),f=Ys(i.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=e/(l/wf),f=Math.max(Ys(gt(r.candle.volume,u)),2),p=At(a.y+l-f);this.drawVolume(t,r,h,p,d,f)}}})}drawVolume(t,e,s,i,r,o){const a=t.ctx,l=i,c=i+o,h=e.name;a.fillStyle=this.volumeBarColors[h],a.strokeStyle=this.volumeBarColors[h],r===0?(a.beginPath(),a.moveTo(s,l),a.lineTo(s,Ys(c)),a.stroke()):a.fillRect(s,i,r,o)}}const xf=Qa(n=>n.candle.volume),vo="volumes";class Pf extends X{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=vo,this.volumeMax=new ft(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(bt(this.chartComponent.chartModel.observeCandlesChanged(),this.scale.xChanged).subscribe(()=>this.updateVolumeMax())),this.addRxSubscription(this.chartComponent.chartModel.mainCandleSeries.observeLastVisualCandleChanged().subscribe(()=>this.recalculateLastVisualVolume()))}recalculateLastVisualVolume(){}updateVolumeMax(){var t;this.volumeMax.next((t=ce(xf(this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport().flat())))!=null?t:0)}}class _f extends X{constructor(t,e,s,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new ft(!1),this.volumeIsSeparateModeChangedSubject=new ft(!1);const c=new Pf(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new vf(e,o,c,a),this.volumesDrawer=new Sf(o,this.volumesModel,e.chartModel,()=>{var h,d;return this.config.components.volumes.showSeparately&&(d=(h=this.separateVolumes.pane)==null?void 0:h.scale)!=null?d:s},this.volumesColorByChartTypeMap,()=>!0),o.components.volumes.visible&&this.syncVolumesDynamicObject(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(o.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(o.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",nn),this.registerVolumeColorResolver("trend",nn),this.registerVolumeColorResolver("hollow",nn),this.registerVolumeColorResolver("line",yf),this.registerVolumeColorResolver("bar",bf)}setShowVolumesSeparatly(t){this.config.components.volumes.showSeparately!==t&&(this.config.components.volumes.showSeparately=t,t?this.separateVolumes.activateSeparateVolumes():this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(t),this.syncVolumesDynamicObject())}doDeactivate(){super.doDeactivate(),this.setVisible(!1)}registerVolumeColorResolver(t,e){this.volumesColorByChartTypeMap[t]=e}setVisible(t=!0){this.config.components.volumes.visible=t,this.volumeVisibilityChangedSubject.next(t),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.syncVolumesDynamicObject(),this.canvasModel.fireDraw()}syncVolumesDynamicObject(){if(!this.config.components.volumes.visible){this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);return}const e=this.config.components.volumes.showSeparately?vo:Z,s={id:this.volumesModel.id,paneId:e,drawer:this.volumesDrawer,model:this.volumesModel};if(this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1){this.dynamicObjectsComponent.model.addObject(s);return}this.dynamicObjectsComponent.model.updateObject(s)}}class Tf{constructor(t,e,s,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,f=this.canvasBoundsContainer.getBounds(M.PANE_UUID(Z)),{position:p,offsetY:v,offsetX:x}=this.config.components.waterMark;let P;switch(d?P=d:(u.font=cs(this.config,l),P=u.measureText(a).width,f.width-10<P&&(u.font=Mf(this.config,this.canvasBoundsContainer,l,P),P=u.measureText(a).width)),p){case"left-top":return{x:x+f.x,y:v+o+f.y,font:u.font,text:a,color:c};case"left-bottom":return{x:x+f.x,y:f.height-h-v+o+f.y,font:u.font,text:a,color:c};case"center":return{x:f.width/2-P/2+f.x,y:(f.height-h)/2+o+f.y,font:u.font,text:a,color:c}}}}draw(){var t,e,s,i,r,o,a;if((t=this.config.components.waterMark)!=null&&t.visible&&this.config.colors){const{firstRow:l,secondRow:c,thirdRow:h}=this.watermarkDataProvider(),d=this.waterMarkConfigProvider(),u=this.config.colors.waterMarkTheme,f=this.canvasModel.ctx;let p=0,v=0,x=0,P=0,I=0;if(f.save(),d.firstRowFontSize&&l){f.font=cs(this.config,d.firstRowFontSize);const B=f.measureText(l);p=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){f.font=cs(this.config,d.secondRowFontSize);const B=f.measureText(c);v=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent,x=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){f.font=cs(this.config,d.thirdRowFontSize);const B=f.measureText(h);P=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent,I=(s=d.secondRowBottomPadding)!=null?s:0}const O=(i=d.thirdRowBottomPadding)!=null?i:0,j=(r=d.logoHeight)!=null?r:0,H=p+v+x+P+I+O+j;if(l&&this.drawWaterMark(this.getConfig(p,l,d.firstRowFontSize,u.firstRowColor,H)),c&&this.drawWaterMark(this.getConfig(p+x+v,c,d.secondRowFontSize,u.secondRowColor,H)),h&&this.drawWaterMark(this.getConfig(p+x+v+I+P,h,d.thirdRowFontSize,u.thirdRowColor,H)),this.logoImage){const B=this.getConfig(p+x+v+I+P+O,"",d.thirdRowFontSize,u.thirdRowColor,H,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,B.x,B.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}f.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const s=this.canvasModel.ctx;s.font=t.font,s.fillStyle=t.color;const i=t.x,r=t.y;s.fillText(e,i,r)}reset(){}}const Mf=(n,t,e,s)=>{const r=((a,l)=>t.getBounds(M.CHART).width/l*a)(e,s);let o;return n.components&&n.components.waterMark&&(o=n.components.waterMark.fontFamily),r+"px "+o},cs=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var Af=Object.defineProperty,bo=Object.getOwnPropertySymbols,Ef=Object.prototype.hasOwnProperty,If=Object.prototype.propertyIsEnumerable,Co=(n,t,e)=>t in n?Af(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,yo=(n,t)=>{for(var e in t||(t={}))Ef.call(t,e)&&Co(n,e,t[e]);if(bo)for(var e of bo(t))If.call(t,e)&&Co(n,e,t[e]);return n};class Df extends X{constructor(t,e,s,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Tf(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(Mt(r.observeBoundsChanged(M.PANE_UUID(Z)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),a.addDrawerAfter(this.waterMarkDrawer,"WATERMARK","DYNAMIC_OBJECTS")}setWaterMarkVisible(t){this.config.components&&this.config.components.waterMark&&(this.config.components.waterMark.visible=t,this.canvasModel.fireDraw())}setWaterMarkData(t){this.waterMarkData=t,this.canvasModel.fireDraw()}getWaterMarkData(){return this.waterMarkData||{}}setWaterMarkConfig(t){if(!(!t||!this.config.components)){if(!this.config.components.waterMark)this.config.components.waterMark=JSON.parse(JSON.stringify(t));else{const e={};Mt(e,t),Mt(e,this.config.components.waterMark),this.config.components.waterMark=e}this.canvasModel.fireDraw()}}setLogoImage(t){this.waterMarkDrawer.setLogoImage(t)}recalculateTextSize(t,e){const r=d=>.15*Math.log(d)/Math.log(1.5)+1,o=r(t/1920),a=r(e/1080),l=Math.min(o,a),c=l>=0?l:0,h={firstRowFontSize:Math.round(this.config.components.waterMark.firstRowFontSize*c),secondRowFontSize:Math.round(this.config.components.waterMark.secondRowFontSize*c),thirdRowFontSize:Math.round(this.config.components.waterMark.thirdRowFontSize*c)};return yo(yo({},this.config.components.waterMark),h)}}const wo={x:4,y:4};function Lf(n,t,e,s){var i,r;const o=(i=s.alignType)!=null?i:"middle",{fontSize:a,fontFamily:l,padding:c}=e.components.xAxis,h=e.colors.xAxis,d=(r=c.top)!=null?r:0,u=t.getBounds(M.X_AXIS);n.save(),n.font=`bold ${a}px ${l}`;const p=n.measureText(s.text).width+wo.x*2;let v=0;const x=s.x;switch(o){case"start":v=x-p;break;case"end":v=x;break;case"middle":default:v=x-p/2;break}n.fillStyle=h.backgroundColor,n.strokeStyle=h.backgroundColor,n.fillRect(v,u.y,p,u.height),o!=="middle"&&(n.strokeStyle=s.color,n.beginPath(),n.moveTo(x,u.y),n.lineTo(x,u.y+u.height),n.stroke()),n.fillStyle=s.color;const P=v+wo.x,I=u.y+d+a+_e/2;n.fillText(s.text,P,I),n.restore()}class Of{constructor(t,e,s,i){this.config=t,this.canvasModel=e,this.canvasBoundsContainer=s,this.xAxisLabelsModel=i}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{Lf(t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},s=this.xAxisLabelsModel.labels.reduce((i,r)=>{if(r.subGroupId!==void 0){let o=i[r.subGroupId];o||(o=[],i[r.subGroupId]=o),o.push(r)}return i},e);Object.keys(s).forEach(i=>{const r=s[i];if(r.length===2){const o=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.fillStyle=Ot().rgb(r[0].color).alpha(.1).toString(),dr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const em="week-weekday",Bf=["second","minute","hour","day","month","year"],Rf=["lessThanSecond"],Ff=n=>Bf.some(t=>t===n),Hf=n=>n==="week-weekday",kf=n=>Rf.some(t=>t===n),So=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},rn=n=>parseInt(n,10),xo=n=>{const[t,...e]=n.split("_");if(Ff(t)){const[s]=e,i=So(s),r=rn(s);return{key:t,value:r,exact:i["!"]}}else if(Hf(t)){const[s,i]=e,r=So(s),o=rn(s),a=rn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return kf(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats in dxchart-lite documentation.`),null)};class hs{constructor(t,e,s,i,r,o=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=s,this.canvasBoundsContainer=i,this.labelsProvider=r,this.drawPredicate=o}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,s=this.config.colors.xAxis,i=this.config.components.xAxis.fontFamily,r=hs.getFontFromConfig(this.config),o=this.config.components.xAxis.fontSize,a=(t=this.config.components.xAxis.padding.top)!=null?t:0;e.save(),e.font=r,e.fillStyle=s.backgroundColor;const l=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.config.components.chart.applyBackgroundToAxes.x||e.fillRect(l.x,l.y,l.width,l.height);const c=this.config.colors.xAxis.labelTextColor,h=this.labelsProvider();this.drawLabels(e,h,l,c,o,i,a+_e/2),e.restore()}}drawLabels(t,e,s,i,r,o,a){const l=`${r}px ${o}`;t.fillStyle=i;for(const c of e){const h=this.viewportModel.toX(c.value)-Tt(c.text,t,l)/2;if(h<s.x||h>s.width)continue;const d=s.y+r-1+a,u=c.text;t.font=l,t.fillText(u,h,d)}}static getFontFromConfig(t){return`${t.components.xAxis.fontStyle} ${t.components.xAxis.fontSize}px ${t.components.xAxis.fontFamily}`}getCanvasIds(){return[this.canvasModel.canvasId]}}const on={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Po=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return on[n.key]+n.value;case"lessThanSecond":return on[n.key];case"week-weekday":return on[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},_o=n=>{const t={};for(const e of n){const s=t[e.weight];s===void 0?t[e.weight]=[e]:s.push(e)}return t},jf=(n,t)=>{const e=Object.keys(n).map(i=>parseInt(i,10)).sort((i,r)=>r-i);let s=[];for(const i of e){const r=n[i];if(!r)continue;const o=[...s];s=[];const a=o.length,l=r.length;let c=0,h=1/0,d=-1/0;for(let u=0;u<l;u++){const f=r[u],p=f.idx;for(;c<a;){const v=o[c],x=v.idx;if(p>x)c++,s.push(v),d=x,h=1/0;else{h=x;break}}h-p>=t&&p-d>=t&&(s.push(f),d=p)}for(;c<a;)s.push(o[c]),c++}return s},Yf=(n,t,e,s,i,r)=>{const o=hs.getFontFromConfig(t),a=Tt(e.text,n,o),l=Tt(s.text,n,o),c=i.toX(e.value)+a/2;return i.toX(s.value)-l/2-c<r};function an(n){"@babel/helpers - typeof";return an=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},an(n)}function St(n,t){if(t.length<n)throw new TypeError(n+" argument"+(n>1?"s":"")+" required, but only "+t.length+" present")}function xt(n){St(1,arguments);var t=Object.prototype.toString.call(n);return n instanceof Date||an(n)==="object"&&t==="[object Date]"?new Date(n.getTime()):typeof n=="number"||t==="[object Number]"?new Date(n):((typeof n=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function Nf(n){return St(1,arguments),xt(n).getDay()===1}function Xf(n){return St(1,arguments),xt(n).getDay()===2}function zf(n){return St(1,arguments),xt(n).getDay()===3}function Wf(n){return St(1,arguments),xt(n).getDay()===4}function Vf(n){return St(1,arguments),xt(n).getDay()===5}function Uf(n){return St(1,arguments),xt(n).getDay()===6}function Gf(n){return St(1,arguments),xt(n).getDay()===0}function Zf(n,t){var e;St(1,arguments);var s=n||{},i=xt(s.start),r=xt(s.end),o=r.getTime();if(!(i.getTime()<=o))throw new RangeError("Invalid interval");var a=[],l=i;l.setHours(0,0,0,0);var c=Number((e=t==null?void 0:t.step)!==null&&e!==void 0?e:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number greater than 1");for(;l.getTime()<=o;)a.push(xt(l)),l.setDate(l.getDate()+c),l.setHours(0,0,0,0);return a}function $f(n){St(1,arguments);var t=xt(n);return t.setDate(1),t.setHours(0,0,0,0),t}function Kf(n){St(1,arguments);var t=xt(n),e=t.getMonth();return t.setFullYear(t.getFullYear(),e+1,0),t.setHours(23,59,59,999),t}function To(n){St(1,arguments);var t=xt(n);return t.setHours(0,0,0,0),t}function Mo(n,t){St(2,arguments);var e=To(n),s=To(t);return e.getTime()===s.getTime()}const qf=n=>{switch(n.key){case"lessThanSecond":return eg(n);case"month":return sg(n);case"second":case"minute":case"hour":case"day":case"year":return ng(n);case"week-weekday":return ig(n);default:return()=>!1}},Kt=(n,t)=>{switch(t){case"lessThanSecond":return n.getMilliseconds();case"month":return n.getMonth();case"second":return n.getSeconds();case"minute":return n.getMinutes();case"hour":return n.getHours();case"day":return n.getDate();case"year":return n.getFullYear();case"week-weekday":return n.getDate()}},ln=n=>(t,e)=>{const s=Kt(t,n),i=Kt(e,n);return s!==i},Jf=n=>(t,e)=>{const s=Kt(t,n),i=Kt(e,n);return s>=i},Qf={1:Nf,2:Xf,3:zf,4:Wf,5:Vf,6:Uf,7:Gf},tg=(n,t,e)=>{var s;const i=Zf({start:$f(n),end:Kf(n)}),r=(s=Qf[e])!=null?s:()=>!1;if(t==="$"){for(const o of i.reverse())if(r(o))return Mo(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return Mo(n,a);o++}}return!1},Ao=(n,t)=>t===1?n===1:n/t===1,Eo=(n,t)=>t===1?!0:n%t===0,eg=n=>(t,e)=>Jf(n.key)(t,e),sg=n=>(t,e)=>{const s=ln(n.key)(t,e),i=n.exact?Ao(Kt(t,n.key)+1,n.value):Eo(Kt(t,n.key)+1,n.value);return s&&i},ng=n=>(t,e)=>{const s=ln(n.key)(t,e),i=n.exact?Ao(Kt(t,n.key),n.value):Eo(Kt(t,n.key),n.value);return s&&i},ig=n=>(t,e)=>{const s=ln(n.key)(t,e),i=tg(t,n.week,n.weekday);return s&&i},rg=n=>{switch(n.key){case"second":case"minute":return og(n.value);case"hour":return ag(n.value);case"day":return lg(n.value);case"month":return dg(n.value);case"year":return ug(n.value);case"week-weekday":const t=hg(n.week),e=cg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},og=n=>n>0&&n<=60,ag=n=>n>0&&n<=24,lg=n=>n>0&&n<=31,cg=n=>Io(n)?n>=1&&n<=7:!1,hg=n=>n==="$"?!0:Io(n)?n>=1&&n<=6:!1,dg=n=>n>0&&n<=12,ug=n=>n>0,Io=n=>!isNaN(n)&&isFinite(n),fg=(n,t,e)=>{var s,i;for(const[r,o]of e)if(o(n,t))return r;return(i=(s=e[e.length-1])==null?void 0:s[0])!=null?i:0};function cn(n,t,e){const s=new Array(n.length);let i=e(0);for(let r=0;r<n.length;r++){const o=n[r],a=e(o.candle.timestamp),l={weight:fg(a,i,t)};s[r]=l,i=a}return s}const Do=n=>{const t={},e={};return Ns(n).forEach(([s,i])=>{const r=xo(s),o=r===null?!1:rg(r);if(r&&o){const a=Po(r);t[a]=i,e[a]=qf(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class Lo{constructor(t,e,s,i,r,o,a){this.eventBus=t,this.config=e,this.chartModel=s,this.scale=i,this.timeZoneModel=r,this.canvasModel=o,this.canvasBoundsContainer=a,this.labelsGroupedByWeight={},this.levelsCache={},this.labelCache=new Map,this.weightToTimeFormatMatcherArray=[],this.weightToTimeFormatsDict={},this.extendedLabelsFilterConfig={minute_1:h=>h>=2},this.calculateCoverUpLevel=()=>{const h=this.scale.currentAnimation,d=this.chartModel.mainCandleSeries.meanCandleWidth;if(Object.getOwnPropertyNames(this.labelsGroupedByWeight).length===0)return-1;const u=h!=null&&h.animationInProgress?gt(d,h.animationConfig.targetZoomX):gt(d,this.scale.zoomX);if(!isFinite(u))return-1;const f=this.config.components.xAxis.fontSize,p=Object.values(this.formatsByWeightMap).reduce((x,P)=>Math.max(P.length,x),1),v=f*p;return Math.round(v/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=Do(this.formatsByWeightMap);this.weightToTimeFormatMatcherArray=Object.entries(c).map(([h,d])=>[parseInt(h,10),d]).sort(([h],[d])=>d-h),this.weightToTimeFormatsDict=l}get labels(){return this.filterLabelsInViewport(this.getLabelsFromChartType())}filterLabelsInViewport(t){const e=this.canvasBoundsContainer.getBounds(M.X_AXIS),s=[];for(const i of t){const r=this.scale.toX(i.value);r<0||r>e.width||s.push(i)}return s}getLabelsFromChartType(){var t,e;const s=(e=(t=this.weightedCache)==null?void 0:t.labels)!=null?e:[];return this.config.components.chart.type==="equivolume"?this.postProcessing(s):s}getVisualCandleAtIndex(t,e,s,i,r){return t>=0&&t<s.length?s[t]:Ws(e,s,i,t,r)}getVisualCandlesWithFake(t=[]){const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0)return[];const i=Array.from({length:750}).map((r,o)=>Ws(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,e.length+o,this.chartModel.getPeriod()));return[...t,...e,...i]}getViewportCandlesWithFake(){var t;const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0||this.scale.xEnd-this.scale.xStart<=1)return[];const s=this.chartModel.mainCandleSeries.meanCandleWidth,i=this.chartModel.getPeriod(),r=this.chartModel.mainCandleSeries.dataPoints,o=this.canvasBoundsContainer.getBounds(M.CHART),a=0,l=o.width,c=this.scale.fromX(a),h=this.scale.fromX(l);let d=0;if(e.length>0){const O=e[0];d=O.centerUnit-((t=O.candle.idx)!=null?t:0)*s}const u=500,f=500,p=Math.floor((c-d)/s)-u,v=Math.ceil((h-d)/s)+u,x=Math.floor(p/f)*f,P=Math.ceil(v/f)*f,I=[];for(let O=x;O<=P;O++)I.push(this.getVisualCandleAtIndex(O,r,e,s,i));return[...I]}getAllCandlesWithFake(t=[]){return this.config.components.chart.minCandlesOffset?this.getVisualCandlesWithFake(t):this.getViewportCandlesWithFake()}mapWeightedPointsToLabels(t,e){var s;const i=new Array(t.length);for(let r=0;r<t.length;++r){const o=t[r],a=e[r],l=this.weightToTimeFormatsDict[o.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(a.candle.timestamp);i[r]={weight:o.weight,idx:(s=a.candle.idx)!=null?s:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){this.clearLabelCache();const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=Do(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(s).map(([i,r])=>[parseInt(i,10),r]).sort(([i],[r])=>r-i),this.weightToTimeFormatsDict=e,this.generateLabels()}getLabelsFromCache(t){if(this.levelsCache[t])return this.levelsCache[t]}updateLastLabel(t){const e=this.chartModel.mainCandleSeries.visualPoints[this.chartModel.mainCandleSeries.visualPoints.length-2];if(e){const i=cn([e,t],this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),r=this.mapWeightedPointsToLabels([i[1]],[t]),[o]=r;this.labelsGroupedByWeight=Object.entries(this.labelsGroupedByWeight).reduce((a,[l,c])=>{const h=c.findIndex(u=>u.idx===o.idx);let d=c;if(h!==-1&&(d=c.filter(u=>u.idx!==o.idx)),parseInt(l,10)===o.weight){const u=d.findIndex(f=>f.idx>o.idx);u!==-1?d=[...d.slice(0,u),o,...d.slice(u)]:d.push(o)}return a[l]=d,a},{}),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}}updateHistoryLabels(t){const e=t.concat(this.chartModel.mainCandleSeries.visualPoints[t.length]),s=cn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=_o(i),o=se(r);for(const c in this.labelsGroupedByWeight)o[c]===void 0&&(o[c]=this.labelsGroupedByWeight[c]);const a=this.chartModel.mainCandleSeries.visualPoints[t.length-1],l=Object.entries(o).sort(([c],[h])=>parseInt(h,10)-parseInt(c,10)).reduce((c,[h,d])=>{const u=parseInt(h,10),f=this.labelsGroupedByWeight[u];if(u===this.weightToTimeFormatMatcherArray[0][0]&&f.shift(),f){const p=f.map(v=>(v.idx=v.idx+t.length,v.value=a.startUnit+a.width+v.value,v));r[u]?c[h]=d.concat(p):c[h]=p}else c[h]=d;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(t,e=!1){var s;const i=this.getAllCandlesWithFake(t),r=cn(i,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone));let o=[];if(e)for(let a=0;a<i.length;a++){const l=(s=i[a].candle.idx)!=null?s:a,c=i[a].candle.timestamp,h=`${l}_${c}`;let d=this.labelCache.get(h);d||(d=this.mapWeightedPointsToLabels([r[a]],[i[a]])[0],this.labelCache.set(h,d)),o.push(d)}else o=this.mapWeightedPointsToLabels(r,i);this.labelsGroupedByWeight=_o(o),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}recalculateLabels(){this.recalculateCachedLabels()}recalculateCachedLabels(){const t=this.calculateCoverUpLevel();if(!(t<0)&&(this.weightedCache===void 0||t!==this.weightedCache.coverUpLevel)){const e=this.getLabelsFromCache(t);if(e){this.weightedCache={labels:e,coverUpLevel:t};return}const s=jf(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,t),t);this.levelsCache[t]=s,this.weightedCache={labels:s,coverUpLevel:t},this.eventBus.fireDraw()}}postProcessing(t){var e,s;const i=[];let r=0,o=1;for(;o<=t.length-1;){const a=t[r],l=t[o];Yf(this.canvasModel.ctx,this.config,a,l,this.scale,30)?((e=l.weight)!=null?e:0)>((s=a.weight)!=null?s:0)&&(r=o):(i.push(a),r=o,o===t.length-1&&i.push(l)),o++}return i}filterLabelsByExtendedRules(t,e){const s=Ns(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=xo(o);if(l){const c=Po(l);i[c]=a}}return i},{});return Ns(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class gg extends X{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(ss,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}const Oo=3;class pg extends X{constructor(t,e,s,i,r,o,a){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=i,this.chartModel=r,this.hitTest=o,this.hitTestCanvasModel=a,this.lastXStart=0,this.lastXEnd=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXEnd=this.scale.xEnd,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const c=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.lastXPxWidth=c.width-this.canvasInputListener.currentPoint.x,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=c=>{let{delta:h}=c;if(!this.touches||this.touches.length===1){const d=this.lastXPxWidth-h;if(d<0)return;const u=this.lastXPxWidth/d,f=this.lastXWidth*u,p=this.lastXStart+(this.lastXWidth-f);this.scale.setXScale(p,this.scale.xEnd);return}if(this.touches.length>1){h=Math.min(this.touches[0].clientX,this.touches[1].clientX)===this.touches[0].clientX?h:-h;let u;h<0?u=1/(1+-h/this.lastXPxWidth*(Oo-1)):u=1+h/this.lastXPxWidth*(Oo-1);const p=(this.lastXWidth*u-this.lastXWidth)/2,v=this.lastXStart-p,x=this.lastXEnd+p;(this.lastXStart!==v||this.lastXEnd!==x)&&this.scale.setXScale(v,x)}},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>r.doBasicScale(),this.dblTapCallback=()=>r.doBasicScale();const l=new Be(o,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>i.chartAreaPanHandler.chartPanningOptions.horizontal});this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>this.dblClickCallback())),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class mg extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.chartComponent=i,this.scale=r,this.chartResizeHandler=l,this.timeZoneModel=h,this.setDblClickCallback=x=>this.xAxisScaleHandler.setDblClickCallback(x),this.setDblTapCallback=x=>this.xAxisScaleHandler.setDblTapCallback(x);const p=new Lo(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=p,this.xAxisLabelsModel=new gg(t,[]);const v=new $s;c.addDrawer(v,"X_AXIS"),this.xAxisDrawer=new hs(e,s,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),v.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Of(e,s,o,this.xAxisLabelsModel),v.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new pg(r,a,o,d,this.chartComponent.chartModel,o.getBoundsHitTest(M.X_AXIS),f),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(M.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(bt(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe(J(({prependedCandles:t})=>t.length!==0),dt(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;pl.includes(this.config.components.chart.type)&&((s=(e=this.xAxisLabelsGenerator).updateHistoryLabels)==null||s.call(e,t))})),this.config.components.chart.minCandlesOffset?this.addRxSubscription(bt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(ue(50,de,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.recalculateLabels())):this.addRxSubscription(bt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(ue(150,de,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.generateLabels(void 0,!0))),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(dt(()=>wt(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),Et((t,e)=>{var s,i;return((s=t==null?void 0:t.candle)==null?void 0:s.id)===((i=e==null?void 0:e.candle)==null?void 0:i.id)}),J(Zn)).subscribe(t=>{var e,s;return(s=(e=this.xAxisLabelsGenerator)==null?void 0:e.updateLastLabel)==null?void 0:s.call(e,t)}))}getDrawer(){return this.xAxisDrawer}registerXAxisLabelsProvider(t){this.xAxisLabelsModel.labelProviders.push(t)}setVisible(t){var e;(e=this.config.components)!=null&&e.xAxis&&(this.config.components.xAxis.visible=t,this.eventBus.fireDraw())}setFormatsForLabelsConfig(t){this.xAxisLabelsGenerator instanceof Lo?this.xAxisLabelsGenerator.setFormatsForLabelsConfig(t):console.error("Format config for x-axis is not available")}isVisible(){var t,e;return(e=(t=this.config.components)==null?void 0:t.xAxis.visible)!=null?e:!1}}var vg=Object.defineProperty,Bo=Object.getOwnPropertySymbols,bg=Object.prototype.hasOwnProperty,Cg=Object.prototype.propertyIsEnumerable,Ro=(n,t,e)=>t in n?vg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ds=(n,t)=>{for(var e in t||(t={}))bg.call(t,e)&&Ro(n,e,t[e]);if(Bo)for(var e of Bo(t))Cg.call(t,e)&&Ro(n,e,t[e]);return n};class yg{constructor(t,e,s,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=s&&ds(ds({},s),this.getLabelDrawConfig(this.chartModel.mainCandleSeries,!0));if(i){const r={labels:[i]},o=this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];o==null||o(r,this.chartModel.mainCandleSeries),t.push(r)}return this.chartModel.candleSeries.forEach((r,o)=>{if(o===0)return;const a=this.getYAxisVisualLabel(r),l=a&&ds(ds({},a),this.getLabelDrawConfig(r,!1));if(l){const c={labels:[l]},h=this.lastCandleLabelsByChartType[r.config.type];h==null||h(c,this.chartModel.mainCandleSeries),t.push(c)}}),t}getYAxisVisualLabel(t){const e=wt(t.dataPoints);if(e){const s=t.view.toY(e.close);if(isFinite(s)){const i=this.yAxisConfig.labels.settings.lastPrice.mode,r=this.yAxisConfig.labels.settings.lastPrice.type;return{y:s,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,t),mode:i,labelType:r,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const s=this.yAxisConfig.labels.settings.lastPrice.type,i=t.colors.labels,{rectLabelTextColor:r="white",rectLabelInvertedTextColor:o="black"}=this.chartConfig.colors.yAxis,a=this.resolveLabelColorFn(t.config.type);if(!i)return{bgColor:"#FFFFFF",textColor:Qt("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:zu(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):Qt(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):Qt(l,r,o),rounded:!0}}}class wg{constructor(t,e,s,i,r,o){this.yAxisLabelsCanvasModel=t,this.yAxisDescriptionsCanvasModel=e,this.backgroundCanvasModel=s,this.canvasBoundsContainer=i,this.fullConfig=r,this.paneManager=o}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx,s=this.yAxisDescriptionsCanvasModel.ctx;this.paneManager.yExtents.forEach(i=>{if(i.yAxis.state.visible){const r=i.getYAxisBounds(),o=this.canvasBoundsContainer.getBounds(M.ALL_PANES),a=i.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(l=>{var c;const h=(c=l.bounds)!=null?c:r;l.labels.forEach(d=>jr(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>jr(t,s,e,r,o,l,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=s[r.subGroupId])!=null?o:[];if(s[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(Z));e.save(),e.fillStyle=(l=c[0].highlightColor)!=null?l:c[0].bgColor;const[d,u]=c[0].y>c[1].y?[c[1].y,c[0].y]:[c[0].y,c[1].y];dr(e,{x:h.x,y:wi(d,h)},{x:h.x+h.width-6,y:wi(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Sg{constructor(t,e,s){this.fullConfig=t,this.canvasModel=e,this.paneManager=s}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const s=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;this.fullConfig.components.chart.applyBackgroundToAxes.y||(r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height));const o=te(e.state),a=jt(o,r),l=this.getLabelTextColor();r.save(),Gt(r,i),this.drawLabels(r,s,i,a,o,l,e),r.restore()}})}drawLabels(t,e,s,i,r,o,a){t.fillStyle=o,t.font=r;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=s.y+c,d=s.y+s.height-c;e.forEach(u=>{const f=a.scale.toY(u.value);f>h&&f<d&&xg(t,s,u.text,f,i,r,a.state.labelBoxMargin.end,a.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const xg=(n,t,e,s,i,r,o,a)=>{const l=a==="right"?t.x+t.width-Tt(e,n,r)-o:t.x+o;n.fillText(e,l,s+i/2-1)};class Pg{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&qa.call(s,e)},this.add=(t,e,s)=>(e in this.handlers?t.call(this.handlers[e],s):this.handlers[e]=[s],this.unsub.bind(this,e,s)),this.on=(t,e)=>this.add(this.UNKNOWN_ARR.push,t,e),this.observe=t=>{const e=new R,s=e.next.bind(e),i=e.unsubscribe.bind(e);return this.on(t,s),e.unsubscribe=()=>{this.unsub(t,s),i()},e.asObservable()},this.onPrior=(t,e)=>this.add(this.UNKNOWN_ARR.unshift,t,e),this.off=this.unsub,this.fire=(t,...e)=>{var s;if(!this.muted){const i=(s=this.handlers[t])!=null?s:[];let r;for(r=0,i.length;r<i.length;r++)i[r].apply(null,e)}},this.fireAsync=(t,e)=>{if(!this.muted)return window.setTimeout(this.fire.bind(this,t,e),0)},this.setMuted=t=>{this.muted=t},this.clear=()=>{this.handlers={}}}fireDraw(t){this.fire(ss,t)}}class _g extends X{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(dt(r=>i.components.chart.highlightActiveCandle?r:void 0),Et()).subscribe(r=>{r&&this.setCandleAsActive(r,t,e)})}setCandleAsActive(t,e,s){if(t.touches.length===1){const i=t.touches.item(0);if(i!==null){const r=this.getTouchXPosition(i,e),o=s.candleFromX(r);o&&s.mainCandleSeries.setActiveCandle(o)}}}getTouchXPosition(t,e){const s=e.getBoundingClientRect(),i=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-s.left-i}}class Tg{constructor(t,e,s,i,r){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${yt()}`,this.canvasResized=new R,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){we(this.animFrameId,()=>this.fireUpdates())}fireUpdates(){const t=this.resizerElement.getBoundingClientRect(),e={x:t.x,y:t.y,width:t.width,height:t.height};this.config||(this.frameElement.style.height=this.resizerElement.clientHeight+"px"),(this.previousBCR===void 0||this.isBCRDimensionsDiffer(this.previousBCR,e))&&(this.previousBCR=e,this.canvasModels.forEach(s=>this.previousBCR&&s.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(Us,e),this.bus.fire(ss))}isBCRDimensionsDiffer(t,e){return t.height!==e.height||t.width!==e.width}unsubscribeAnimationUpdate(){if(this.resizerElement)try{this.elementResizeDetector.unobserve(this.resizerElement)}catch(t){console.warn("ChartResizeHandler.ts, unsubscribeAnimationUpdate failed")}}wasResized(){return this.previousBCR!==void 0}}var Mg=Array.isArray,Ag=Object.getPrototypeOf,Eg=Object.prototype,Ig=Object.keys;function Dg(n){if(n.length===1){var t=n[0];if(Mg(t))return{args:t,keys:null};if(Lg(t)){var e=Ig(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function Lg(n){return n&&typeof n=="object"&&Ag(n)===Eg}var Og=Array.isArray;function Bg(n,t){return Og(t)?n.apply(void 0,D([],m(t))):n(t)}function Rg(n){return dt(function(t){return Bg(n,t)})}function Fg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function Hg(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ne(n),s=va(n),i=Dg(n),r=i.args,o=i.keys;if(r.length===0)return Xe([],e);var a=new vt(kg(r,e,o?function(l){return Fg(o,l)}:le));return s?a.pipe(Rg(s)):a}function kg(n,t,e){return e===void 0&&(e=le),function(s){Fo(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){Fo(t,function(){var d=Xe(n[h],t),u=!1;d.subscribe(mt(s,function(f){r[h]=f,u||(u=!0,a--),a||s.next(e(r.slice()))},function(){--o||s.complete()}))},s)},c=0;c<i;c++)l(c)},s)}}function Fo(n,t,e){n?Ht(e,n,t):t()}class jg extends X{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new ft(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=Hg([s,i]).pipe(J(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}!l&&!kt()&&(this.crossSubject.next(null),r=!0)});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}function Yg(n,t){return N(function(e,s){var i=null,r=0,o=!1,a=function(){return o&&!i&&s.complete()};e.subscribe(mt(s,function(l){i==null||i.unsubscribe();var c=0,h=r++;Lt(n(l,h)).subscribe(i=mt(s,function(d){return s.next(t?t(l,d,h,c++):d)},function(){i=null,a()}))},function(){o=!0,a()}))})}class Ng{constructor(t,e,s,i){this.visualCandle=t,this.price=e,this.priceFormatter=s,this.toY=i}get high(){return this.visualCandle.high}get low(){return this.visualCandle.low}get open(){return this.visualCandle.open}get close(){return this.visualCandle.close}get volume(){return this.visualCandle.candle.volume}get openY(){return this.toY(this.open)}get closeY(){return this.toY(this.close)}get highY(){return this.toY(this.high)}get lowY(){return this.toY(this.low)}get openFormatted(){return this.priceFormatter(this.open)}get closeFormatted(){return this.priceFormatter(this.close)}get highFormatted(){return this.priceFormatter(this.high)}get lowFormatted(){return this.priceFormatter(this.low)}get closestOHLCY(){return this.toY([this.close,this.open,this.high,this.low].sort((t,e)=>Math.abs(t-this.price)-Math.abs(e-this.price))[0])}}class Xg{constructor(t){this.chartModel=t}getData(t){const{x:e,y:s}=t,r=this.chartModel.candleFromX(e).idx||0,o=this.chartModel.getVisualCandle(r),a=this.chartModel.priceFromY(s);return o&&new Ng(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class zg{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof Tr)return;const{x:e}=t,i=this.chartModel.candleFromX(e).idx||0;return this.chartModel.candleSeries.map(o=>{const a=o.dataPoints[i],l=this.chartModel.pane.regularFormatter(a==null?void 0:a.close);return{instrument:o.instrument.symbol,price:l,id:o.id,htId:o.htId}})}}var Wg=Object.defineProperty,Vg=Object.defineProperties,Ug=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertySymbols,Gg=Object.prototype.hasOwnProperty,Zg=Object.prototype.propertyIsEnumerable,ko=(n,t,e)=>t in n?Wg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Re=(n,t)=>{for(var e in t||(t={}))Gg.call(t,e)&&ko(n,e,t[e]);if(Ho)for(var e of Ho(t))Zg.call(t,e)&&ko(n,e,t[e]);return n},hn=(n,t)=>Vg(n,Ug(t));class $g extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.mainCanvasTouchHandler=c,this.formatterFactory=h,this.hoverSubject=new ft(null),this.longTouchActivatedSubject=new ft(!1),this.xFormatter=()=>"";const d=new Xg(this.chartModel),u=new zg(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(Yg(()=>this.scale.initialViewportValidSubject.pipe(J(Boolean)))).subscribe(()=>{const e=this.chartModel.getLastVisualCandle();e&&this.createAndFireHoverFromCandle(e)})),this.addRxSubscription(this.chartModel.candlesUpdatedSubject.subscribe(()=>{const e=this.chartModel.getLastVisualCandle();this.hover!==null&&e!==void 0&&e.candle.timestamp<=this.hover.timestamp&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?this.hoverSubject.next(null):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(bt(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter())),this.addRxSubscription(this.canvasInputListener.observeTouchStart().subscribe(e=>{var s;this.crossEventProducer.crossToolTouchInfo.isCommonTap=!0;const{clientX:i,clientY:r}=e.touches[0];if(this.longTouchActivatedSubject.getValue())this.crossEventProducer.crossToolTouchInfo.temp={x:i-this.canvasBoundsContainer.canvasOnPageLocation.x,y:r-this.canvasBoundsContainer.canvasOnPageLocation.y};else{const o=((s=this.paneManager.getPaneIfHit({x:i,y:r}))==null?void 0:s.uuid)||"";this.createAndFireHover([i,r,o])}}));const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{var s;if(this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.mainCanvasTouchHandler.canvasTouchInfo.isMoving||this.chartModel.config.components.crossTool.type==="none"||e.touches.length>1)return;this.longTouchActivatedSubject.next(!0),this.crossEventProducer.crossToolTouchInfo.isSet=!1;const r=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,o=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.crossEventProducer.crossToolTouchInfo.fixed={x:r,y:o};const a=((s=this.paneManager.getPaneIfHit({x:r,y:o}))==null?void 0:s.uuid)||"";this.createAndFireHover([r,o,a]),this.crossEventProducer.crossSubject.next([r,o,a]),this.paneManager.chartPanComponent.setChartPanningOptions(!1,!1)})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(e=>{var s,i;const{clientX:r,clientY:o}=e.changedTouches[0],{fixed:a,temp:l}=this.crossEventProducer.crossToolTouchInfo,c=r-this.canvasBoundsContainer.canvasOnPageLocation.x,h=o-this.canvasBoundsContainer.canvasOnPageLocation.y;if(this.crossEventProducer.crossToolTouchInfo.isCommonTap&&!so(c,l.x,h,l.y)){this.paneManager.chartPanComponent.setChartPanningOptions(!0,!0),this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose(),this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isSet=!1;return}if(!this.crossEventProducer.crossToolTouchInfo.isSet)this.crossEventProducer.crossToolTouchInfo.isSet=!0,this.crossEventProducer.crossToolTouchInfo.temp={x:this.crossEventProducer.crossToolTouchInfo.fixed.x,y:this.crossEventProducer.crossToolTouchInfo.fixed.y},this.crossEventProducer.crossToolTouchInfo.fixed={x:c,y:h},this.crossEventProducer.crossToolTouchInfo.isSet=!0;else{const d=(i=(s=this.crossEventProducer.crossToolHover)==null?void 0:s.paneId)!=null?i:"CHART",u=this.canvasBoundsContainer.getBounds(M.PANE_UUID(d)),f=u.y+5,p=u.y+u.height-5,v=c-l.x,x=h-l.y,P=a.x<0?0:a.x>u.width?u.width:a.x+=v,I=a.y<f?f:a.y>p?p:a.y+=x;this.crossEventProducer.crossToolTouchInfo.fixed={x:P,y:I}}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=Nr(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),s=this.scale.toY(t.close);return this.createHover(e,s,Z)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const r=this.chartModel.candleFromX(t,!0).timestamp,o={x:t,y:e,timestamp:r,timeFormatted:this.xFormatter(r),paneId:s},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>hn(Re({},l),{[c[0]]:c[1].getData(o)}),{});return Re(Re({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){const e=this.createHoverFromCandle(t);if(this.hover&&e){const s=hn(Re({},e),{x:this.hover.x,y:this.hover.y});this.fireHover(s)}}createAndFireHover([t,e,s]){const i=this.createHover(t,e,s);this.fireHover(i)}fireHover(t){var e,s;if(t){if(kt()&&this.config.components.crossTool.type!=="none"){const i=this.crossEventProducer.crossToolHover,r=i?(e=i.candleHover)==null?void 0:e.visualCandle.candle:(s=t.candleHover)==null?void 0:s.visualCandle.candle;r&&this.chartModel.mainCandleSeries.setActiveCandle(r)}this.hoverSubject.next(t)}else this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}registerHoverProducerPart(t,e){this.hoverProducerParts=hn(Re({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const jo={left:0,middle:1,right:2};function pt(n,t,e,s){return n.addEventListener(e,t,s),function(){n.removeEventListener(e,t,s)}}function be(n){return t=>{t.button===jo.left&&n(t)}}var Kg=Object.defineProperty,Yo=Object.getOwnPropertySymbols,qg=Object.prototype.hasOwnProperty,Jg=Object.prototype.propertyIsEnumerable,No=(n,t,e)=>t in n?Kg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Qg=(n,t)=>{for(var e in t||(t={}))qg.call(t,e)&&No(n,e,t[e]);if(Yo)for(var e of Yo(t))Jg.call(t,e)&&No(n,e,t[e]);return n};const us=class oe extends X{constructor(t,e){super(),this.eventBus=t,this.element=e,this.xDragStartSubject=new R,this.xDragSubject=new R,this.xDragTickSubject=new R,this.xDragEndSubject=new R,this.yDragStartSubject=new R,this.yDragSubject=new R,this.yDragTickSubject=new R,this.yDragEndSubject=new R,this.mouseMoveSubject=new R,this.mouseMoveDocumentSubject=new R,this.clickSubject=new R,this.clickDocumentSubject=new R,this.dbClickSubject=new R,this.dbTapSubject=new R,this.mouseDownSubject=new R,this.mouseUpSubject=new R,this.mouseUpDocumentSubject=new R,this.wheelSubject=new R,this.touchStartSubject=new R,this.touchStartTimestamp=0,this.touchMoveSubject=new R,this.touchEndSubject=new R,this.touchCancelSubject=new R,this.longTouchStartSubject=new R,this.longTouchEndSubject=new R,this.contextMenuSubject=new R,this.fastTouchScroll=new R,this.mouseLeavesCanvasSubject=new R,this.dragStartPoint={x:0,y:0},this.prevDragPoint={x:0,y:0},this.currentPoint={x:0,y:0},this.currentPointDocument={x:0,y:0},this.dragging=!1,this.canvasBounds={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.documentDragListeners=[],this.dragProcessListener=()=>{this.xDragSubject.next(this.currentPoint.x-this.dragStartPoint.x),this.yDragSubject.next(this.currentPoint.y-this.dragStartPoint.y),this.xDragTickSubject.next(this.currentPoint.x-this.prevDragPoint.x),this.yDragTickSubject.next(this.currentPoint.y-this.prevDragPoint.y),this.prevDragPoint.x=this.currentPoint.x,this.prevDragPoint.y=this.currentPoint.y},this.dragStartListener=s=>{this.isDraggable(s)&&(this.updateCurrentPoints(s),this.dragging=!0,this.dragStartEvent=s,this.documentDragListeners.forEach(i=>i()),this.dragStartPoint=oe.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=Qg({},this.dragStartPoint),oe.DRAG_EVENTS.forEach(i=>{document.addEventListener(i,this.dragProcessListener,!0);const r=document.removeEventListener.bind(document,i,this.dragProcessListener,!0);this.documentDragListeners.push(r),this.addSubscription(r)}),this.dragProcessListener())},this.dragListener=()=>this.mouseMoveDocumentSubject.next(this.currentPoint),this.updateElementOffsetListener=()=>this.mouseMoveSubject.next(this.currentPoint),this.dragEndListener=()=>{this.dragging=!1,this.documentDragListeners.forEach(s=>s()),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=s=>{this.updateCurrentDocumentPoint(s),this.updateCurrentMousePoint(s)}}isDraggable(t){return t instanceof MouseEvent?t.button===jo.left:t instanceof TouchEvent}startDragging(t){this.updateCurrentPoints(t),this.dragStartListener(t)}movePointer(t){this.updateCurrentPoints(t),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const t=e=>(e.preventDefault(),!1);this.element.addEventListener("selectstart",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",t,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],oe.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),oe.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragListener)),this.element.addEventListener(s,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,s,this.updateElementOffsetListener))}),oe.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(pt(this.element,be(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(pt(document,be(s=>this.clickDocumentSubject.next(s)),"click"));const t=to();if(t==="apple"||t==="mobile"){let s=null;const i=a=>{a.preventDefault(),s?(this.dbTapSubject.next(this.currentPoint),clearTimeout(s),s=null):s=window.setTimeout(()=>{s=null},250)};this.addSubscription(pt(this.element,i,"touchend"));const r=(a,l=200)=>{a.preventDefault();let c=!1,h=null;h=setTimeout(()=>{c=!0,this.longTouchStartSubject.next(a)},l);const d=f=>{f.preventDefault(),f.touches.length>1&&h&&clearTimeout(h)},u=f=>{f.preventDefault(),h&&clearTimeout(h),c&&(c=!1,this.longTouchEndSubject.next(f)),this.element.removeEventListener("touchend",u),this.element.removeEventListener("touchmove",d)};this.element.addEventListener("touchmove",d),this.element.addEventListener("touchend",u)};this.addSubscription(pt(this.element,a=>r(a),"touchstart"));const o=a=>{if(a.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const h=this.touchStartTimestamp,u=Date.now()-h,p=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,v=u<=250;p&&v&&this.fastTouchScroll.next(a)}};this.addSubscription(pt(this.element,o,"touchend"))}this.addSubscription(pt(this.element,be(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(pt(this.element,s=>{this.touchStartSubject.next(s),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(pt(this.element,s=>this.touchMoveSubject.next(s),"touchmove",!0)),this.addSubscription(pt(this.element,s=>this.touchEndSubject.next(s),"touchend")),this.addSubscription(pt(this.element,s=>this.touchCancelSubject.next(s),"touchcancel")),this.addSubscription(pt(this.element,s=>{this.wheelSubject.next(s),s.preventDefault()},"wheel")),this.addSubscription(pt(this.element,s=>this.contextMenuSubject.next(s),"contextmenu")),this.addSubscription(pt(this.element,be(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(pt(this.element,be(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(pt(document,be(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(Us).subscribe(()=>{const s=this.element.getBoundingClientRect();this.canvasBounds.x=s.left,this.canvasBounds.y=s.top,this.canvasBounds.width=s.width,this.canvasBounds.height=s.height}));const e=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",e,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",e,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){oe.DRAG_EVENTS.forEach(t=>{document.addEventListener(t,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(t,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(t){"pageX"in t?this.currentPointDocument.x=t.pageX:t.touches!==void 0&&(this.currentPointDocument.x=t.touches[0].pageX),"pageY"in t?this.currentPointDocument.y=t.pageY:t.touches!==void 0&&(this.currentPointDocument.y=t.touches[0].pageY)}updateCurrentMousePoint(t){const e=this.element.getBoundingClientRect();"clientX"in t?this.currentPoint.x=t.clientX-e.left:t.touches!==void 0&&(this.currentPoint.x=t.touches[0].clientX-e.left),"clientY"in t?this.currentPoint.y=t.clientY-e.top:t.touches!==void 0&&(this.currentPoint.y=t.touches[0].clientY-e.top)}static copyPoint(t){return{x:t.x,y:t.y}}observeMouseMove(t=()=>!0){return this.mouseMoveSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe(J(()=>!this.dragging))}observeMouseMoveDocument(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(J(()=>t(this.currentPointDocument.x,this.currentPointDocument.y)),dt(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(t=()=>!0){return this.xDragStartSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(t=()=>!0){return this.xDragSubject.pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(t=()=>!0){return this.xDragEndSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(t=()=>!0){return this.yDragStartSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(t=()=>!0){return this.yDragSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(t=()=>!0){return this.yDragEndSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(t=()=>!0,e=!1){const s=this.mouseMoveSubject.asObservable().pipe(J(()=>!(e&&this.dragging)),dt(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(dt(()=>!1));return bt(s,i).pipe(Et())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(t=()=>!0){return this.clickSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(t=()=>!0){return this.dbClickSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(t=()=>!0){return this.dbTapSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeWheel(t=()=>!0){return this.wheelSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchStart(t=()=>!0){return this.touchStartSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(t=()=>!0){return this.touchMoveSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(t=()=>!0){return this.mouseDownSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(t=()=>!0){return this.mouseUpSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(t=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(t=()=>!0){return this.contextMenuSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)),fo(e=>e.preventDefault()))}observeLongTouchStart(t=()=>!0){return this.longTouchStartSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(t=()=>!0){return this.longTouchEndSubject.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(t=()=>!0){return this.fastTouchScroll.asObservable().pipe(J(()=>t(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};us.DRAG_START_EVENTS=["mousedown","touchstart"],us.DRAG_EVENTS=["mousemove","touchmove"],us.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];let tp=us;var ep=function(n){z(t,n);function t(e,s,i){e===void 0&&(e=1/0),s===void 0&&(s=1/0),i===void 0&&(i=Hs);var r=n.call(this)||this;return r._bufferSize=e,r._windowTime=s,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=s===1/0,r._bufferSize=Math.max(1,e),r._windowTime=Math.max(1,s),r}return t.prototype.next=function(e){var s=this,i=s.isStopped,r=s._buffer,o=s._infiniteTimeWindow,a=s._timestampProvider,l=s._windowTime;i||(r.push(e),!o&&r.push(a.now()+l)),this._trimBuffer(),n.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var s=this._innerSubscribe(e),i=this,r=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!e.closed;l+=r?1:2)e.next(a[l]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,i=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*s;if(s<1/0&&a<r.length&&r.splice(0,r.length-a),!o){for(var l=i.now(),c=0,h=1;h<r.length&&r[h]<=l;h+=2)c=h;c&&r.splice(0,c+1)}},t}(R);const dn={};function sp(n){return dn[n]||(dn[n]=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),dn[n]}const Xo=(n,t=Date.now())=>{const s=sp(n).format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(s);if(i){const r=Date.UTC(+i[3],+i[1]-1,+i[2],+i[4]%24,+i[5],+i[6]);let o=t;const a=o%1e3;return o-=a>=0?a:1e3+a,r-o}return 0},zo=60*1e3;class np{constructor(t){this.config=t,this.timeZoneChangedSubject=new ep,this.currentTzOffset=e=>Xo(this.config.timezone,e)+new Date(e).getTimezoneOffset()*zo,this.formatterCache={},this.dateTimeFormatterFactory=this.initFormatterFactory(this.config.dateFormatter)}setTimeZone(t){this.config.timezone=t,this.formatterCache={},this.timeZoneChangedSubject.next(t)}observeTimeZoneChanged(){return this.timeZoneChangedSubject.asObservable()}initFormatterFactory(t){let e;if(t&&typeof t=="function")e=t;else if(t&&t.createFormatterFunction&&typeof t.createFormatterFunction=="function"){const s=t.createFormatterFunction;e=i=>s(i).bind(t)}else e=Rd(this.config,this.tzOffset);return e}getFormatterFactory(){return this.dateTimeFormatterFactory}getDateTimeFormatter(t){return this.formatterCache[t]===void 0&&(this.formatterCache[t]=this.dateTimeFormatterFactory(t)),this.formatterCache[t]}tzOffset(t){return t?e=>new Date(e+Xo(t,e)+new Date(e).getTimezoneOffset()*zo):e=>new Date(e)}}class ip extends X{constructor(t,e,s){super(),this.hitTestCanvasModel=t,this.canvasAnimation=e,this.eventBus=s}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasAnimation.animationInProgressSubject.subscribe(()=>{const t=this.canvasAnimation.animationInProgressSubject.getValue();this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!t)})),this.addRxSubscription(this.hitTestCanvasModel.hitTestDrawersPredicateSubject.pipe(Et((t,e)=>t!==e&&t===!0&&e===!1)).subscribe(()=>this.eventBus.fireDraw([this.hitTestCanvasModel.canvasId])))}}class un{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;ml(r),this.config=r;const o=Hl(r);t.innerHTML="",t.appendChild(o.content),this.id=(s=t.getAttribute("data-id"))!=null?s:"",r.fixedSize&&(t.style.width=r.fixedSize.width+"px",t.style.height=r.fixedSize.height+"px");const a=new np(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=kl(t);this.elements=c;const h=new Pg;this.bus=h;const d=new Tg(t,(i=c.chartResizer)!=null?i:t,h,this.canvasModels,r);this.chartResizeHandler=d,d.subscribeResize(),this.components.push(d.unsubscribeAnimationUpdate.bind(d));const u=new Dh(h,d);this.drawingManager=u;const f=Eh(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=ie(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new me(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const v=ie(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),x=ie(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),P=new Fs(r,h,f,l,d);this.canvasBoundsContainer=P;const I=c.mainCanvas.parentElement;if(I===null)throw new Error("Couldn't get main canvas parent");const O=new tp(h,I);this.canvasInputListener=O,this.chartComponents.push(this.canvasInputListener);const j=new $d(h,c.hitTestCanvas,O,P,u,r,this.canvasModels,c.chartResizer);this.hitTestCanvasModel=j;const H=new me(j);u.addDrawer(H,"HIT_TEST_CLEAR");const B=new za(h);this.canvasAnimation=B;const Y=M.PANE_UUID(Z),W=new cr(r,()=>P.getBounds(Y),B);this.scaleModel=W;const G=ie(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=G,this.cursorHandler=new Bl(c.canvasArea,O,P,j),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new jg(O,P),this.chartComponents.push(this.crossEventProducer);const V=new vc("candle");this.chartBaseModel=V;const U=new Lu(h,W,P,r,B,O,I,V,j);this.chartPanComponent=U,this.chartComponents.push(U),this.userInputListenerComponents.push(U.chartAreaPanHandler);const $=new ip(j,B,h);this.hitTestComponent=$,this.chartComponents.push($);const K=new gf(V,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,W,P,r,B,O,u,this.cursorHandler,this.crossEventProducer,U,f,v,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=K;const et=this.paneManager.panes[Z];this.mainPane=et,this.chartComponents.push(K),this.dynamicObjects=new Od(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new dd(V,K,h,this.dynamicObjectsCanvasModel,r,W,l,I,P,d);const tt=new Gh(this.chartModel,this.dynamicObjectsCanvasModel,r,W,P,u,j,O,G,U,K,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(tt),this.chartComponent=tt;const Q=this.chartComponent.chartModel;this.chartModel=Q,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),j.addSubscriber(K.hitTestController),this.xAxisComponent=new mg(h,r,f,tt,W,P,O,d,this.drawingManager,a,U,this.cursorHandler,this.hitTestCanvasModel),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const ot=new me(f);u.addDrawer(ot,"MAIN_CLEAR");const ct=new _g(I,Q,O,r);this.chartComponents.push(ct),this.watermarkComponent=new Df(K,Q,h,r,P,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const at=ie(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new gu(h,r,Q,f,P,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(Q)),this.navigationMapComponent=new xu(h,Q,f,r,O,P,u,l,U,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Pt=new au(r,this.dynamicObjectsCanvasModel,Q,P,u);this.chartComponents.push(Pt),this.initYAxisDrawer(v,x),this.yAxisComponent=et.mainExtent.yAxis;const Vt=new yg(this.chartModel,this.config,et.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(Vt,ee.MAIN),this.volumesComponent=new _f(this.dynamicObjectsCanvasModel,tt,W,P,u,r,K,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const Ce=new Zr(f,W,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(M.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(Y),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>[],void 0,void 0,()=>r.components.grid.visible);this.chartComponents.push(Ce),this.hoverProducer=new $g(this.crossEventProducer,W,r,Q,O,this.canvasBoundsContainer,this.paneManager,a,U.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new Ed(r,at,P,u,K,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel),this.chartComponents.push(this.crossToolComponent);const Zo=ie(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),fn=new pf(this.elements,Zo);this.snapshotComponent=fn,this.chartComponents.push(fn);const gn=new iu(r,this.dynamicObjectsCanvasModel,j,Q,P,u,l,this.cursorHandler);this.eventsComponent=gn,this.chartComponents.push(gn),this.chartComponents.forEach(pn=>pn.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=Va(this.components)}initYAxisDrawer(t,e){const s=new $s,i=new me(t),r=new me(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new Sg(this.config,t,this.paneManager);s.addDrawer(o);const a=new wg(t,e,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);this.drawingManager.addDrawer(a,"Y_AXIS_PRICE_LABELS")}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:s=>e.test(s)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const s in e)s in t?typeof t[s]=="object"&&un.mergeConfig(t[s],e[s]):t[s]=e[s];return t}getConfig(){return this.config}disableUserControls(){this.userInputListenerComponents.forEach(t=>t.deactivate()),this.hitTestCanvasModel.disableUserControls()}enableUserControls(){this.userInputListenerComponents.forEach(t=>t.activate()),this.hitTestCanvasModel.enableUserControls()}setGridConfig(t){var e,s,i,r,o;const a=this.config.components.grid;a.visible=(e=t.visible)!=null?e:!1,a.dash=(s=t.dash)!=null?s:[0,0],a.width=(i=t.width)!=null?i:1,a.color=(r=t.color)!=null?r:"#FFFFFF",this.config.colors.chartAreaTheme.gridColor=(o=t.color)!=null?o:"#FFFFFF",this.redraw()}setGridVisible(t){this.config.components&&this.config.components.grid&&(this.config.components.grid.visible=t,this.redraw())}setGridVertical(t){this.config.components.grid.vertical=t,this.redraw()}setGridHorizontal(t){this.config.components.grid.horizontal=t,this.redraw()}redraw(){this.bus.fireDraw()}getOffsets(){return this.config.components&&this.config.components.offsets}setShowCandleBorders(t=!0){this.config.components&&this.config.components.chart&&(this.config.components.chart.showCandlesBorder=t,this.redraw())}setHighLowVisible(t=!0){this.config.components&&this.config.components.highLow&&(this.config.components.highLow.visible=t,this.redraw())}setCrossToolVisible(t="cross-and-labels"){this.config.components&&this.config.components.crossTool&&(this.config.components.crossTool.type=t,this.redraw())}setHighlightsVisible(t=!0){var e;(e=this.config.components)!=null&&e.highlights&&(this.config.components.highlights.visible=t,this.redraw())}setHighlightsData(t){this.highlightsComponent.setHighlights(t)}setColors(t){Mt(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseMove(s).subscribe(e);return()=>i.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,s=!1){const i=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseEnter(i,s).subscribe(e);return()=>r.unsubscribe()}addClickOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeClick(s).subscribe(e);return()=>i.unsubscribe()}addDragEventsListener(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=bt(this.canvasInputListener.observeYDrag(s),this.canvasInputListener.observeXDrag(s)).subscribe(e);return()=>i.unsubscribe()}registerComponent(t,e){const s=t(this);this.components.push(s),e&&e(s),s.activate()}}class Wo extends un{constructor(t,e={}){super(t,e),this.yAxis=this.yAxisComponent,this.xAxis=this.xAxisComponent,this.watermark=this.watermarkComponent,this.highlights=this.highlightsComponent,this.events=this.eventsComponent,this.snapshot=this.snapshotComponent,this.crosshair=this.crossToolComponent,this.navigationMap=this.navigationMapComponent,this.volumes=this.volumesComponent,this.cursors=this.cursorHandler,this.data=this.chartComponent,this.scale=this.scaleModel,this.panning=this.chartPanComponent,this.bounds=this.canvasBoundsContainer,this.hover=this.hoverProducer}registerPaneFormatters(t,e){var s;(s=this.paneManager.panes[t])==null||s.setPaneValueFormatters(e)}destroy(){this.bus.setMuted(!0),this.chartComponents.forEach(t=>t.disable()),this.parentElement.childNodes.forEach(t=>t.remove()),this.parentElement.style.width="",this.parentElement.style.height=""}showSeparateVolumes(t=!1){this.volumes&&(this.volumes.setShowVolumesSeparatly(t),this.bounds.updateYAxisWidths())}setData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.setAllSeries(e,s)}else this.chartComponent.setMainSeries(t)}updateData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.updateAllSeries(e,s)}else this.chartComponent.updateAllSeries(t)}setAutoScale(t=!0){this.scale.autoScale(t)}setRtl(t){this.config.rtl=t,this.bus.fireDraw()}setChartType(t){this.data.setChartType(t),this.yAxis.updateOrderedLabels()}setTreasuryFormat(t){this.config.components.yAxis.treasuryFormat=t,this.paneManager.yExtents.forEach(e=>{e.yAxis.model.labelsGenerator.updateTreasuryFormat(t),e.yAxis.model.labelsGenerator.doGenerateLabels(),e.yAxis.model.fancyLabelsModel.updateLabels(!0),e.yAxis.model.baseLabelsModel.updateLabels()})}createPane(){return this.paneManager.createPane()}}var rp=Object.defineProperty,op=Object.defineProperties,ap=Object.getOwnPropertyDescriptors,Vo=Object.getOwnPropertySymbols,lp=Object.prototype.hasOwnProperty,cp=Object.prototype.propertyIsEnumerable,Uo=(n,t,e)=>t in n?rp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hp=(n,t)=>{for(var e in t||(t={}))lp.call(t,e)&&Uo(n,e,t[e]);if(Vo)for(var e of Vo(t))cp.call(t,e)&&Uo(n,e,t[e]);return n},dp=(n,t)=>op(n,ap(t));function Go(n){n=n||{},n.quantity=n.quantity||200,n.startY=n.startY||50,n.avgCandleSize=n.avgCandleSize||2,n.avgTrendLength=n.avgTrendLength||{},n.avgTrendLength.sw=n.avgTrendLength.sw||10,n.avgTrendLength.down=n.avgTrendLength.down||10,n.avgTrendLength.up=n.avgTrendLength.up||10,n.withVolume=n.withVolume===!0||!1,n.period=n.period||3600;var t=[],e=n.quantity||200,s=10,i=10,r=10;n.avgTrendLength&&(s=n.avgTrendLength.sw||10,i=n.avgTrendLength.down||10,r=n.avgTrendLength.up||10);var o=n.startY||50,a=n.avgCandleSize||2,l=o-a,c=o+a,h=fs(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(gp(t[t.length-1],a,s)):d>3?t=t.concat(up(t[t.length-1],a,r)):t=t.concat(fp(t[t.length-1],a,i))}t=t.slice(0,n.quantity);let u=Math.round(new Date().getTime()/3e5)*3e5;u-=e*1e3*n.period;for(let f=0;f<t.length;f++){const p=t[f];Object.assign(p,{timestamp:u,isVisible:!0}),u+=1e3*n.period,n.withVolume&&(p.volume=Math.ceil(Math.random()*1e3+200))}return t}function fs(n,t,e,s){var i=Math.random()*(t-n)+n,r;if(s&&s==="bull"||!s&&Math.random()>.5){var o=i+e;r=o<t?o:t}else{var a=i-e;r=a>n?a:n}var l=Math.max(i,r)+Math.random()*e*.2,c=Math.min(i,r)-Math.random()*e*.2;return{id:ri(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function up(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.lo,o=n.hi+t*1.2,a=0;a<i;a++){var l=Math.random()>.9?"bear":"bull",c=fs(r,o,t,l);r=c.lo-t*(Math.random()*.1+.1),o=c.hi+t*(Math.random()*1.3+.1),Math.random()>.9&&(o=c.hi+t),s.push(c)}return s}function fp(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.hi-t*1.2,o=n.hi,a=0;a<i;a++){var l=Math.random()<.9?"bear":"bull",c=fs(r,o,t,l);r=c.lo-t*(Math.random()*.3+.1),o=c.hi-t*(Math.random()*.1+.1),Math.random()>.9&&(o=c.lo-t),s.push(c)}return s}function gp(n,t,e){var s=[],i=Math.random()*e+e/2;function r(u){var f,p;return Math.random()>.5?(f=u.lo-t*.2,p=u.hi+t*1.2):(f=u.lo-t*1.2,p=u.hi+t*.2),{from:f,to:p}}for(var o=r(n),a=o.from,l=o.to,c=0;c<i;c++){var h=Math.random()<.5?"bear":"bull",d=fs(a,l,t,h);o=r(d),a=o.from,l=o.to,Math.random()>.9&&(Math.random()>.5?a=d.lo-t:l=d.hi+t),s.push(d)}return s}window.DXChart=dp(hp({},window.DXChart),{generateCandlesData:Go});function pp(n){return Go(n)}const mp=(n,t={})=>new Wo(n,t)})(),window.DXChart=ps})();})();
24
+ `);function $l(n){const t=document.createElement("template");return t.innerHTML=Zl(n.devexpertsPromoLink),t}function Kl(n){const t={},e=Array.from(n.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(s=>{var i;t[(i=s.getAttribute("data-element"))!=null?i:""]=s}),Gl(t))return t;throw new Error("Some chart elements are missing")}function ql(n){if(n.length>1){const t=n.reduce((i,r,o)=>{if(o!==n.length-1){const a=n[o+1].timestamp-r.timestamp;i[a]?i[a]++:i[a]=1}return i},{});let e=0,s;for(const i of Object.keys(t)){const r=parseInt(i,10),o=t[r];o>e&&r>0&&(e=o,s=r)}if(s)return s}}const Jl=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Le=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Jl(!!c),u=d(n),f=d((r=(i=ge(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=wt(e))==null?void 0:o.timestamp)!=null?a:0);return u>p?h?{index:e.length-1+Math.ceil((u-p)/s),exact:!0}:{index:e.length-1,exact:!0}:u<f?h?{index:ot((u-f)/s),exact:!0}:{index:-1,exact:!0}:Bt(e,u,v=>d(v.timestamp))},Ri={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Fi={paintConfig:[Ri],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var Ql=Object.defineProperty,Hi=Object.getOwnPropertySymbols,tc=Object.prototype.hasOwnProperty,ec=Object.prototype.propertyIsEnumerable,ki=(n,t,e)=>t in n?Ql(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,sc=(n,t)=>{for(var e in t||(t={}))tc.call(t,e)&&ki(n,e,t[e]);if(Hi)for(var e of Hi(t))ec.call(t,e)&&ki(n,e,t[e]);return n};class nc{constructor(t,e,s,i){this.series=t,this.config=e,this.yAxisBoundsProvider=s,this.axisState=i}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,s=this.yAxisBoundsProvider(),i=this.config.labelMode,r=this.config.labelAppearanceType,o=e();if(o===void 0)return[];const a=this.series.view.toY(o.close);if(!isFinite(a))return[];const l=this.series.valueFormatter(o.close),c=this.getLabelDrawConfig();return[{labels:[sc({y:a,description:this.series.name,mode:i,labelType:r,labelText:l},c)],axisState:this.axisState,bounds:s}]}getLabelDrawConfig(){var t;const e=this.series.config,i=((t=e.paintConfig[0])!=null?t:Ri).color;return{textColor:ee(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function ic(n,t){if(n.filter(a=>a!==null).length<=1)return n.map(a=>a.y);const e=t-2,s=n.map((a,l)=>rc(a,l,e)).filter(ni).sort(oc),i=new Array(s.length),r=s.reduce((a,l)=>Math.min(a,l.labelWeight),Number.POSITIVE_INFINITY),o=s.findIndex(a=>a.labelWeight===r);for(let a=o;a>=0;a--){const l=s[a],c=s[a-1];if(l){if(c&&c.bottom>l.top){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.bottom=l.top-h,c.top=c.bottom-t}i[l.actualIndex]=(l.top+l.bottom)/2}}for(let a=o;a<s.length;a++){const l=s[a],c=s[a+1];if(!l)break;if(c&&c.top<l.bottom){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.top=l.bottom+h,c.bottom=c.top+t}i[l.actualIndex]=(l.top+l.bottom)/2}return i}const rc=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,oc=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var ac=Object.defineProperty,lc=Object.defineProperties,cc=Object.getOwnPropertyDescriptors,ji=Object.getOwnPropertySymbols,hc=Object.prototype.hasOwnProperty,dc=Object.prototype.propertyIsEnumerable,Yi=(n,t,e)=>t in n?ac(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ni=(n,t)=>{for(var e in t||(t={}))hc.call(t,e)&&Yi(n,e,t[e]);if(ji)for(var e of ji(t))dc.call(t,e)&&Yi(n,e,t[e]);return n},Xi=(n,t)=>lc(n,cc(t));const ne={MAIN:"MAIN"};class uc extends X{constructor(t,e,s,i,r,o,a,l){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.chartResizeHandler=l,this.orderedLabels=[],this.customLabels={},this._labelsProviders={},this.labelsPositionRecalculatedSubject=new B,this.animFrameId=`anim_cache_${yt()}`,this.initModel()}get labelsProviders(){return this._labelsProviders}doActivate(){super.doActivate(),this.addRxSubscription(Ct(this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed,Ct(this.canvasBoundsContainer.observeBoundsChanged(T.PANE_UUID(this.paneUUID)),this.chartResizeHandler.canvasResized).pipe(Wt(50,Xt,{trailing:!0,leading:!0}))).subscribe(()=>{this.updateLabels()}))}initModel(){this.initLabelsGroups(),this.recalculateLabels(),this.canvasModel.fireDraw()}initLabelsGroups(){for(const t of Object.keys(this.labelsProviders))this.createGroup(t),Object.entries(this.labelsProviders[t]).forEach(([e,s])=>{this.addToGroup(s,t,e)})}updateLabels(t=!1){this.recalculateLabels(),Pe(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const s=this.state.fontSize+((t=this.state.labelBoxMargin.top)!=null?t:0)+((e=this.state.labelBoxMargin.bottom)!=null?e:0);for(const i of Object.values(this.labelsProviders)){const r=gt(Object.values(i).map(l=>l.getUnorderedLabels())),o=gt(r.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),a=ic(o,s);r.forEach(l=>{const c=a.splice(0,l.labels.length);this.orderedLabels.push(this.updateLabelsCoordinates(l,c))})}this.orderedLabels=this.orderedLabels.reverse()}createGroup(t){!this.labelsProviders[t]&&(this.labelsProviders[t]={})}addToGroup(t,e,s){this.labelsProviders[e]&&(Object.values(this.labelsProviders[e]).includes(t)||(this.labelsProviders[e][s]=t))}updateLabelsCoordinates(t,e){return Xi(Ni({},t),{labels:t.labels.map((s,i)=>Xi(Ni({},s),{lineY:s.y,y:e[i]}))})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[s]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const i=(s=this.labelsProviders[t])!=null?s:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}let Rt=window.devicePixelRatio,is=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const Gs=()=>{is.removeEventListener("change",Gs),Rt=window.devicePixelRatio,is=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),is.addEventListener("change",Gs)};is.addEventListener("change",Gs);const fc=()=>Rt,gm=n=>round(Rt*n)/Rt,At=n=>ot(Rt*n)/Rt,Zs=n=>Wa(Rt*n)/Rt,ie=n=>JSON.parse(JSON.stringify(n));function $s(n){return Object.entries(n)}const Wi=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function zi(n){return Object.keys(n)}function Vi(n,t){if(Object.is(n,t))return!0;if(typeof n!="object"||n===null||typeof t!="object"||t===null)return!1;const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(let i=0,r=e.length;i<r;i++)if(!hasOwnProperty.call(t,e[i])||!Vi(n[e[i]],t[e[i]]))return!1;return!0}const gc=n=>Object.keys(n).length===0&&n.constructor===Object;function Ui(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new B}:t,s=n.resetOnError,i=s===void 0?!0:s,r=n.resetOnComplete,o=r===void 0?!0:r,a=n.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var h,d,u,f=0,p=!1,v=!1,x=function(){d==null||d.unsubscribe(),d=void 0},_=function(){x(),h=u=void 0,p=v=!1},A=function(){var L=h;_(),L==null||L.unsubscribe()};return N(function(L,Y){f++,!v&&!p&&x();var F=u=u!=null?u:e();Y.add(function(){f--,f===0&&!v&&!p&&(d=Ks(A,l))}),F.subscribe(Y),!h&&f>0&&(h=new _e({next:function(R){return F.next(R)},error:function(R){v=!0,x(),d=Ks(_,i,R),F.error(R)},complete:function(){p=!0,x(),d=Ks(_,o),F.complete()}}),Lt(L).subscribe(h))})(c)}}function Ks(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t===!0){n();return}if(t!==!1){var i=new _e({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,D([],m(e)))).subscribe(i)}}const rs=(n,t)=>n/t,pt=(n,t)=>n/t,Ft=(n,t)=>n*t,Gi=(n,t)=>(n-t)*100/t,Zi=(n,t)=>n*t/100+t,$i=n=>Math.log2(n),qs=n=>Math.pow(2,n);class pc extends X{constructor(){super(...arguments),this._xStart=0,this._xEnd=0,this._yStart=0,this._yEnd=0,this._zoomX=1,this._zoomY=1,this._inverseY=!1,this.changed=new B,this.xChanged=this.changed.pipe(dt(()=>({start:this.xStart,end:this.xEnd})),Et((t,e)=>t.start===e.start&&t.end===e.end),Ui()),this.yChanged=this.changed.pipe(dt(()=>({start:this.yStart,end:this.yEnd})),Et((t,e)=>t.start===e.start&&t.end===e.end),Ui()),this.initialViewportValidSubject=new ut(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+pt(t-this.xStart,this.zoomX)}xPixels(t){return pt(t,this.zoomX)}toY(t){const e=this.getBounds();return this.inverseY?e.y+pt(t-this.yStart,this.zoomY):e.y+e.height-pt(t-this.yStart,this.zoomY)}yPixels(t){return pt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return Ft(e+pt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),s=t-e.y;return this.inverseY?Ft(s+pt(this.yStart,this.zoomY),this.zoomY):Ft(e.height-s+pt(this.yStart,this.zoomY),this.zoomY)}recalculateZoomX(){this.zoomX=this.calculateZoomX(this.xStart,this.xEnd)}recalculateZoomY(){this.zoomY=this.calculateZoomY(this.yStart,this.yEnd)}calculateZoomX(t,e){return rs(e-t,this.getBounds().width)}calculateZoomY(t,e){return rs(e-t,this.getBounds().height)}recalculateZoom(t=!0){this.recalculateZoomX(),this.recalculateZoomY(),t&&this.fireChanged()}setXScale(t,e,s=!0){this.xStart=t,this.xEnd=e,this.recalculateZoomX(),s&&this.fireChanged()}setYScale(t,e,s=!0){this.yStart=t,this.yEnd=e,this.recalculateZoomY(),s&&this.fireChanged()}export(){return{xStart:this.xStart,xEnd:this.xEnd,yStart:this.yStart,yEnd:this.yEnd,zoomX:this.zoomX,zoomY:this.zoomY,inverseY:this.inverseY}}apply(t){this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.inverseY=t.inverseY,this.fireChanged()}fireChanged(){this.changed.next()}get xStart(){return this._xStart}set xStart(t){this._xStart=t}get xEnd(){return this._xEnd}set xEnd(t){this._xEnd=t}get yStart(){return this._yStart}set yStart(t){this._yStart=t}get yEnd(){return this._yEnd}set yEnd(t){this._yEnd=t}get zoomX(){return this._zoomX}set zoomX(t){this._zoomX=t}get zoomY(){return this._zoomY}set zoomY(t){this._zoomY=t}get inverseY(){return this._inverseY}set inverseY(t){this._inverseY=t}isViewportValid(t=!0){const e=t===!1||this.zoomX>0&&this.zoomY>0;return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)&&e}}const mc=(n,t)=>!zi(n).some(e=>n[e]!==t[e]);class vc{constructor(t,e){this.scale=t,this.dataSeries=e,this.prevAnimationId=""}getBaselineForPercent(t){const e=this.scale.currentAnimation;let s;if(e!=null&&e.animationInProgress){e.id!==this.prevAnimationId&&(this.initialBaseline=void 0,this.targetBaseline=void 0,this.prevAnimationId=e.id);const i=e.easingFn(e.getProgress());this.initialBaseline===void 0&&(this.initialBaseline=t(Bt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(Bt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else s=t();return s}}class Ki{constructor(t,e,s,i){this.dataSeries=t,this.scale=e,this.getAxisType=s,this.getBaseline=i,this.toY=r=>this.scale.toY(this.toAxisUnits(r)),this.toX=r=>this.scale.toX(r),this.xPixels=r=>this.scale.xPixels(r),this.yPixels=r=>this.scale.yPixels(r),this.percentAnimationHandler=new vc(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return Gi(t,s);case"logarithmic":return t<=0?t:$i(t);case"regular":return t}}priceFromY(t){const e=this.scale.fromY(t);return this.fromAxisUnits(e)}fromAxisUnits(t){switch(this.getAxisType()){case"percent":return Zi(t,this.getBaseline());case"logarithmic":return qs(t);case"regular":return t}}}var bc=Object.defineProperty,Cc=Object.defineProperties,yc=Object.getOwnPropertyDescriptors,qi=Object.getOwnPropertySymbols,wc=Object.prototype.hasOwnProperty,Sc=Object.prototype.propertyIsEnumerable,Ji=(n,t,e)=>t in n?bc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Qi=(n,t)=>{for(var e in t||(t={}))wc.call(t,e)&&Ji(n,e,t[e]);if(qi)for(var e of qi(t))Sc.call(t,e)&&Ji(n,e,t[e]);return n},xc=(n,t)=>Cc(n,yc(t));class Oe{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return At(t.toY(this.close))}x(t){return t.toX(this.centerUnit)}clone(){return new Oe(this.centerUnit,this.close)}}class tr extends X{constructor(t,e,s,i,r){var o;super(),this.extentComponent=t,this.id=e,this.htId=s,this.parentId=i,this.name="",this.highlighted=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=l=>{var c;return(c=this.config.paintConfig[l])!=null?c:this.config.paintConfig[0]},this.getBaseline=(l=this.dataIdxStart)=>{var c,h,d;return(c=this.visualPoints[l])!=null&&c.close&&((h=this.visualPoints[l])==null?void 0:h.close)>=0?(d=this.visualPoints[l])==null?void 0:d.close:1},this.getTextForPoint=l=>`${l.close}`,this.getLastVisualSeriesPoint=()=>{const l=this.visualPoints,c=Bt(l,this.scale.xEnd,h=>h.centerUnit).index;return l[c]},this.getLastDataSeriesPoint=()=>{const l=this.visualPoints;return wt(l)};const a=r!=null?r:ie(Fi);this.config=Mt(a,Fi),this.scale=t.scale,this.view=new Ki(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new nc(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=Pc(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=oi(t),this._dataPointsFlat=this._dataPoints.flat(),this.visualPoints=this._toVisualPoints(this._dataPoints)}get visualPoints(){return this._visualPointsFlat}get visualPoints2D(){return this._visualPoints}set visualPoints(t){this._visualPoints=oi(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.recalculateDataViewportIndexes())),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>{this.recalculateVisualPoints(),this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;const s=Qi({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new Ki(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider.yAxisBoundsProvider=t.getYAxisBounds,this.yAxisLabelProvider.axisState=(e=t.yAxis)==null?void 0:e.state;const i=s.yAxis.model.fancyLabelsModel.labelsProviders[ne.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[ne.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(ne.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(ne.MAIN,r))}this.deactivate(),this.activate(),t.addDataSeries(this)}toVisualPoints(t){return t.map((e,s)=>({centerUnit:s,close:e.close}))}setType(t){this.config.type=t,this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}recalculateVisualPoints(){this.visualPoints=this._toVisualPoints(this.dataPoints2D)}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i}calculateDataViewportIndexes(t,e){const s=Bt(this.visualPoints,t,r=>r.centerUnit).index,i=Bt(this.visualPoints,e,r=>r.centerUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}valueFormatter(t){return this.extentComponent.formatters.regular(t)}getSeriesInViewport(t,e){let s=this.dataIdxStart,i=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const r=this.calculateDataViewportIndexes(t,e);s=r.dataIdxStart,i=r.dataIdxEnd}return al(this.visualPoints2D,s,i)}}const _c=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.close>t.high&&(t.high=s.close,t.highIdx=e),s.close<t.low&&(t.low=s.close,t.lowIdx=e)}return t},Pc=n=>({isHighLowActive:()=>n.config.highLowActive,calculateHighLow:t=>{const e=_c(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return xc(Qi({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),Tc=n=>{const e=r=>Math.ceil(Math.log(Math.abs(r))*Math.LOG10E),i=((r,o=5)=>Math.max(0,o-Math.max(0,e(r))))(n);return ft.makeDecimal(n,i)};class os extends Oe{constructor(t,e,s,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.endUnit=t+e/2,this.width=e,this.open=s,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return Math.max(Math.abs(t.toY(this.open)-t.toY(this.close)),1)}candleHeight(t){return Math.abs(t.toY(this.high)-t.toY(this.low))}bodyAsVLine(t){if(this.width<2)return[this.centerUnit,this.yLineStart(t),this.width,this.candleHeight(t)]}bodyRect(t){return[this.startUnit,this.yBodyStart(t),this.width,this.bodyHeight(t)]}getCandle(){return this.candle}yBodyKeyPoints(t){const e=t.toY(this.high),s=t.toY(this.low),i=t.toY(this.open),r=t.toY(this.close),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>s?[s,e]:[e,s];return[l,o,a,c]}yLineEnd(t){return Math.max(t.toY(this.high),t.toY(this.low))}yLineStart(t){return Math.min(t.toY(this.high),t.toY(this.low))}yBodyStart(t){return Math.min(t.toY(this.open),t.toY(this.close))}yBodyEnd(t){return Math.max(t.toY(this.open),t.toY(this.close))}xCenter(t){return this.x(t)}xStart(t){return t.toX(this.startUnit)}}const me=60,Be=(n,t,e=me)=>{const s=er(n,t,e);return{id:gi(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},Mc=(n,t,e=me)=>({close:NaN,timestamp:er(n,t,e)});function er(n,t,e=me){var s,i;const r=Me(t);if(n.length===0)return 0;const o=wt(n);if(r>=n.length&&o)return sr(o,n.length-1,r,e);const a=ge(n);return r<0&&a?sr(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const sr=(n,t,e,s=me)=>n.timestamp+(e-(t!=null?t:0))*s,Js=(n,t,e,s,i=me)=>{const r=Be(n,s,i);r.volume=e;let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new os(o,e,r.open,r.close,r.lo,r.hi,ts(r.open,r.close),r)},Ac=(n,t,e,s,i=me)=>{const r=Mc(n,s,i);let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new Oe(o,r.close)};class Ec{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new B,this.dataSetSubject=new B,this.dataRemovedSubject=new B,this.dataPrependSubject=new B,this.meanDataWidth=1,this.period=1}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=Le(t,e,s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=ql(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?Js(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):Ac(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var Ic=Object.defineProperty,nr=Object.getOwnPropertySymbols,Dc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,ir=(n,t,e)=>t in n?Ic(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Oc=(n,t)=>{for(var e in t||(t={}))Dc.call(t,e)&&ir(n,e,t[e]);if(nr)for(var e of nr(t))Lc.call(t,e)&&ir(n,e,t[e]);return n};class Bc{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!Vi(this.config.colors.chartAreaTheme,this.prevState)}draw(){if(this.drawPredicate()||this.isColorsChanged()){this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0+this.canvasModel.height/2,this.canvasModel.width,0+this.canvasModel.height/2);e.addColorStop(0,this.config.colors.chartAreaTheme.backgroundGradientTopColor),e.addColorStop(1,this.config.colors.chartAreaTheme.backgroundGradientBottomColor),t.fillStyle=e}else t.fillStyle=this.config.colors.chartAreaTheme.backgroundColor;t.fillRect(0,0,this.canvasModel.width,this.canvasModel.height)}this.prevState=Oc({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const Rc=(n,t,e,s,i,r,o)=>{const a=fc(),l=[e*a,s*a,i*a,r*a];let c=n.getImageData(...l);if(o!==void 0){const h=c.data[3]/255;if(h===1)for(let d=3;d<c.data.length;d+=4)c.data[d]=ot(c.data[d]*o);else for(let d=0;d<c.data.length;d++){const u=c.data[d];c.data[d]=d%4===3?ot(u*o):ot(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},rr=(n,{x:t,width:e,activeCandle:s})=>new os(t,e,n.open,n.close,n.hi,n.lo,ts(n.open,n.close),n,!0,Qs(n,s)),Fc=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new os(t,e,n.open,n.close,n.hi,n.lo,yl((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,Qs(n,s),n.close>n.open)},or=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new os(t,e,n.open,n.close,n.hi,n.lo,ts((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,Qs(n,s),n.close>n.open)},Hc=or,Qs=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},ar=()=>Ns,Re=class le{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>ot(Math.log10((i^i>>31)-(i>>31)))+1;let s=e(t);return s===1&&t<1&&(s=e(t*1e9)-9),s}static getPriceIncrement(t,e=[]){if(!this.validatePriceIncrementsOrPrecisions(e))return this.DEFAULT_INCREMENT;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;const i=1e-6;for(;s<e.length&&t>e[s]+Math.min(e[s-1],e[s+1])*i;)s+=2;return s>=e.length||t<e[s]-Math.min(e[s-1],e[s+1])*i?e[s-1]:Math.min(e[s-1],e[s+1])}static getPricePrecision(t,e){if(!this.validatePriceIncrementsOrPrecisions(e))return 0;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;for(;s<e.length&&t>e[s];)s+=2;return Math.round(e[s-1])}static roundPriceToIncrement(t,e,s){const i=le.getPriceIncrement(s||t,e);return ft.roundToNearest(t,i)}static computePrecisions(t){const e=[...t];for(let s=0;s<t.length;s+=2)e[s]=le.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*le.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<le.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*le.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return le.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(t){return!(t.length===0||!Array.isArray(t)||t.findIndex(e=>e!==0)===-1)}};Re.DEFAULT_INCREMENT=.01,Re.DEFAULT_PRECISION=2,Re.RELATIVE_EPS=1e-8,Re.MAXIMUM_PRECISION=10;let ve=Re;const kc=(n,t)=>{var e;const s=(e=wt(t))!=null?e:1;return Math.pow(10,-s)};var jc=Object.defineProperty,Yc=Object.defineProperties,Nc=Object.getOwnPropertyDescriptors,lr=Object.getOwnPropertySymbols,Xc=Object.prototype.hasOwnProperty,Wc=Object.prototype.propertyIsEnumerable,cr=(n,t,e)=>t in n?jc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,zc=(n,t)=>{for(var e in t||(t={}))Xc.call(t,e)&&cr(n,e,t[e]);if(lr)for(var e of lr(t))Wc.call(t,e)&&cr(n,e,t[e]);return n},Vc=(n,t)=>Yc(n,Nc(t));const Uc=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:n.scale.xStart,s=t?t.xEnd:n.scale.xEnd,{dataIdxStart:i,dataIdxEnd:r}=n.calculateDataViewportIndexes(e,s),o=n.visualPoints.slice(i,r+1),a=hr(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return Vc(zc({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),hr=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.high>t.high&&(t.high=s.high,t.highIdx=e),s.low<t.low&&(t.low=s.low,t.lowIdx=e)}return t};class Gc{constructor(t,e){this.delegate=t,this.highLowPostProcessor={},this.highLowProviders=e!=null?e:{}}setHighLowProvider(t,e){this.highLowProviders[t]=e}deleteHighLowProvider(t){delete this.highLowProviders[t]}setHighLowPostProcessor(t,e){this.highLowPostProcessor[t]=e}doAutoYScale(t){Zc(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Zc=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=dr(i),o=s.reduce((a,l)=>l(a),r);t.yStart=o.low,t.yEnd=o.high,t.zoomY=n.calculateZoomY(t.yStart,t.yEnd)};function dr(n){if(n.length===0)return $c();let t=n[0].high,e=n[0].low;return n.forEach(s=>{isFinite(s.high)&&s.high>=t&&(t=s.high),isFinite(s.low)&&s.low<=e&&(e=s.low)}),{low:e,high:t}}const $c=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),ur=(n,t)=>n/t,Kc=(n,t)=>n/t,qc=(n,t)=>n*t,fr=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=ur(e,s),r=n.yEnd-n.yStart;t.zoomY=Kc(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Jc=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=ur(e,s),r=n.xEnd-n.xStart;t.zoomX=qc(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Qc=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},th=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},gr=(n,t,e,s,i)=>{const r=(t.xEnd-t.xStart)*s,o=r*e,a=r*(1-e);return i?(t.xStart=t.xStart+o,t.xEnd=t.xEnd-a):(t.xStart=t.xStart-o,t.xEnd=t.xEnd+a),t.zoomX=n.calculateZoomX(t.xStart,t.xEnd),t},eh=(n,t,e,s)=>gr(n,t,1,e,s),sh=Ae,nh=.9,pr=(n,t,e,s)=>{t.currentAnimation&&t.currentAnimation.animationInProgress&&t.currentAnimation.getProgress()>nh&&(t.currentAnimation.finishAnimation(),t.currentAnimation=void 0),s&&s.doAutoYScale(e),as(n,t,e)},as=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:sh,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},fe,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s},Fe=16;var ih=Object.defineProperty,rh=Object.defineProperties,oh=Object.getOwnPropertyDescriptors,mr=Object.getOwnPropertySymbols,ah=Object.prototype.hasOwnProperty,lh=Object.prototype.propertyIsEnumerable,vr=(n,t,e)=>t in n?ih(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,re=(n,t)=>{for(var e in t||(t={}))ah.call(t,e)&&vr(n,e,t[e]);if(mr)for(var e of mr(t))lh.call(t,e)&&vr(n,e,t[e]);return n},br=(n,t)=>rh(n,oh(t));const ch=new B,hh=new B,dh=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Cr extends pc{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new B,this.beforeStartAnimationSubject=new B,this.zoomReached={zoomIn:!1,zoomOut:!1},this.history=[],this.xConstraints=[],this.autoScaleZoomSubscription=null,this.autoScalePanSubscription=null,this.scalePostProcessor=(i,r)=>this.xConstraints.reduce((o,a)=>a(i,o),r),this.state=ie(t.scale),this.autoScaleModel=new Gc(this),this.offsets=this.config.components.offsets,this.initAutoScaleThrottling()}doActivate(){super.doActivate(),this.scaleInversedSubject=new B,this.beforeStartAnimationSubject=new B,this.zoomReached=this.calculateZoomReached(this.export().zoomX),this.addRxSubscription(this.scaleInversedSubject.subscribe(()=>{this.fireChanged()}))}doDeactivate(){this.autoScaleZoomSubscription&&(this.autoScaleZoomSubscription.unsubscribe(),this.autoScaleZoomSubscription=null),this.autoScalePanSubscription&&(this.autoScalePanSubscription.unsubscribe(),this.autoScalePanSubscription=null),super.doDeactivate(),this.scaleInversedSubject.complete(),this.beforeStartAnimationSubject.complete()}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=re(re({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,s=!1,i){const r=this.config.scale.disableAnimations||s;r&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const o=this.export();gr(this,o,t,i,e),this.zoomXTo(o,e,r)}zoomXToEnd(t,e){this.config.scale.disableAnimations&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const s=this.export();eh(this,s,e,t),this.zoomXTo(s,t,this.config.scale.disableAnimations)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.currentAnimation=void 0,this.canvasAnimation.forceStopAnimation(fe),this.doAutoScale())}zoomXTo(t,e,s){var i;const r=this.export(),o=this.scalePostProcessor(r,t);this.zoomReached=this.calculateZoomReached(o.zoomX,e),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&fr(r,o),this.state.auto&&this.autoScaleModel.doAutoYScale(o),s?this.apply(o):((i=this.currentAnimation)==null||i.tick(),as(this.canvasAnimation,this,o)))}calculateZoomReached(t,e=!0){const s=this.getBounds().width,i=.001;if(s>0){const r=rs(this.config.components.chart.minCandles,s),a=t!==r&&t-r<=i&&e,l=rs(s/this.config.components.chart.minWidth,s),h=t-l>=i&&!e;return{zoomIn:a,zoomOut:h}}return{zoomIn:!1,zoomOut:!1}}setXScale(t,e,s=!0){var i;const r=this.export(),o=this.calculateZoomX(t,e);if(r.xStart===t&&r.xEnd===e&&r.zoomX>0)return;const a=br(re({},r),{zoomX:o,xStart:t,xEnd:e}),l=this.scalePostProcessor(r,a),c=l.xEnd-l.xStart<r.xEnd-r.xStart;this.zoomReached=this.calculateZoomReached(o,c),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&fr(r,l),this.state.auto&&this.autoScaleModel.doAutoYScale(l),s||this.config.scale.disableAnimations?(this.haltAnimation(),this.apply(l)):((i=this.currentAnimation)==null||i.tick(),ue?pr(this.canvasAnimation,this,l,this.state.auto?this.autoScaleModel:void 0):as(this.canvasAnimation,this,l)))}setXScaleWithoutYScale(t){var e;const s=this.export(),i=t.slice(Math.max(t.length-this.state.defaultViewportItems,0)),r=i[i.length-1],o=r.startUnit+r.width+this.offsets.right,a=o-this.getBounds().width*this.zoomX,l=br(re({},s),{xStart:a,xEnd:o}),c=this.scalePostProcessor(s,l);this.state.auto&&this.autoScaleModel.doAutoYScale(c),(e=this.currentAnimation)==null||e.tick(),as(this.canvasAnimation,this,c)}setYScale(t,e,s=!1){const i=this.export();if(i.yStart===t&&i.yEnd===e&&i.zoomY>0)return;if(this.state.lockPriceToBarRatio){this.setLockedYScale(t,e,s,i);return}super.setYScale(t,e,s);const r=this.export(),o=this.scalePostProcessor(i,r);this.state.auto&&this.autoScaleModel.doAutoYScale(o),this.apply(o)}setLockedYScale(t,e,s=!1,i){const r=e<i.yEnd;if(this.zoomReached.zoomOut&&r===!1||this.zoomReached.zoomIn&&r===!0)return;super.setYScale(t,e,s);const o=this.export(),a=this.scalePostProcessor(i,o);Jc(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=re({},e);this.haltAnimation(),Qc(e,t);const i=this.scalePostProcessor(s,e);ue?pr(this.canvasAnimation,this,i,this.state.auto?this.autoScaleModel:void 0):(this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i))}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();th(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),mc(e,this.export())||this.apply(e)}}isViewportAnimationInProgress(){const t=this.currentAnimation;return t==null?void 0:t.animationInProgress}pushToHistory(t){this.history.push(t)}popFromHistory(){return this.history.pop()}clearHistory(){this.history=[]}isDefaultXBounds(){return this.xStart===0&&this.xEnd===0}isDefaultYBounds(){return this.yStart===0&&this.yEnd===0}isScaleReady(){return!this.isDefaultXBounds()&&!this.isDefaultYBounds()}autoScale(t=!0){this.config.components.yAxis.type==="percent"?this.state.auto=!0:this.state.auto=t,t&&(this.clearHistory(),this.doAutoScale())}setLockPriceToBarRatio(t=!1){const{type:e}=this.config.components.yAxis;if(e==="percent"||e==="logarithmic"){this.state.lockPriceToBarRatio=!1;return}this.state.lockPriceToBarRatio=t}initAutoScaleThrottling(){this.autoScaleZoomSubscription=ch.pipe(Wt(Fe,Xt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=re({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)}),this.autoScalePanSubscription=hh.pipe(Wt(Fe,Xt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=re({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)})}}class uh extends Cr{constructor(t,e,s,i){super(e,s,i),this.delegate=t,this.config=e,this.getBounds=s}doActivate(){this.addRxSubscription(this.delegate.xChanged.subscribe(()=>this.doAutoScale(this.state.auto)))}get xStart(){return this.delegate.xStart}set xStart(t){this.delegate.xStart=t}get xEnd(){return this.delegate.xEnd}set xEnd(t){this.delegate.xEnd=t}get zoomX(){return this.delegate.zoomX}set zoomX(t){this.delegate.zoomX=t}observeXChanged(){return this.delegate.xChanged}fireChanged(){this.delegate.changed.next(),this.changed.next()}}const fh=es().colors;class Zt extends tr{constructor(t,e,s,i,r,o,a,l,c=fh){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=dh(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new B,this.meanCandleWidth=Ns,this._instrument=o,this.instrument=o,this.highLowProvider=Uc(this),this.scale=r,this.name=o.symbol}get dataPoints(){return super.dataPoints}set dataPoints(t){super.dataPoints=t,this.applyPriceMovement()}get instrument(){return this._instrument}set instrument(t){var e;this._instrument=t,this.pricePrecisions=ve.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i,this.recalculateZippedHighLow(),this.eventBus.fireDraw()}calculateDataViewportIndexes(t,e){const s=Bt(this.visualPoints,t,r=>r.startUnit).index,i=Bt(this.visualPoints,e,r=>r.startUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}applyPriceMovement(){const t=wt(this.dataPoints);t&&(this.lastPriceMovement=ts(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=hr(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd+1))}updateCurrentPrice(t){this.previousPrice=this.currentPrice||t,this.currentPrice=t,this.currentPrice!==this.previousPrice&&(this.lastPriceMovement=this.currentPrice>this.previousPrice?"up":"down")}updateCandleSeriesColors(t){this.colors=Mt(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var s,i;if(t.length===0)return[];const r=this.config.type,o=[];let a=e;const l=(s=this.candleWidthByChartType[r])!=null?s:ar;for(let c=0;c<t.length;c++){const h=t[c],d=t[c-1],u=l(h),f=a+u/2,p=(i=this.candlesTransformersByChartType[r])!=null?i:rr;o.push(p(h,{x:f,width:u,prevCandle:d,activeCandle:this.activeCandle},o[c-1])),a+=u}return o}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,s)=>e+s.width,0)/t.length:this.meanCandleWidth=Ns}setActiveCandle(t){this.activeCandle=t,this.recalculateVisualPoints()}clearData(){this.dataPoints=[],this.clearVisualCandles(),this.clearPrices()}clearPrices(){this.previousPrice=void 0,this.currentPrice=void 0,this.lastPriceMovement="none"}clearVisualCandles(){this.visualPoints=[]}}function pm(n){switch(n){case"line":case"area":return!0;default:return!1}}class gh{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=!!i.color;if(s instanceof Zt){const a=gt(e);if(a.length===0)return;i.color?t.strokeStyle=i.color:t.strokeStyle=s.colors.areaTheme.lineColor,o?t.lineWidth=(r=i.hoverWidth)!=null?r:this.config.selectedWidth*3:s.highlighted?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const l=s.extentComponent.getBounds(),c=a[0],h=s.view.toX(c.centerUnit);for(let d=0;d<a.length;d++){const u=a[d-1],f=a[d+1],p=a[d],v=s.view.toX(p.centerUnit),x=s.view.toY(p.close),_=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(ot(v),_),t.moveTo(ot(v),x);else if(f===void 0){t.lineTo(ot(v),x),t.stroke(),t.lineTo(ot(v),_),t.lineTo(ot(h),_),t.closePath();let A;i.color?t.fillStyle=i.color:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(A=t.createLinearGradient(0,0,0,l.height),A.addColorStop(0,s.colors.areaTheme.startColor),A.addColorStop(1,s.colors.areaTheme.stopColor),A):"",o||t.fill()}else t.lineTo(v,x)}}}}function yr(n,t,e,s,i,r=4,o=!0,a=!1){n.save(),n.beginPath(),n.moveTo(t+r,e),n.lineTo(t+s-r,e),n.quadraticCurveTo(t+s,e,t+s,e+r),n.lineTo(t+s,e+i-r),n.quadraticCurveTo(t+s,e+i,t+s-r,e+i),n.lineTo(t+r,e+i),n.quadraticCurveTo(t,e+i,t,e+i-r),n.lineTo(t,e+r),n.quadraticCurveTo(t,e,t+r,e),n.closePath(),o&&n.fill(),a&&n.stroke(),n.restore()}function ph(n,t,e,s,i,r,o,a,l,c,h=4,d=!0,u=!1){const f=c==="right"?a:-a,p=c==="right"?h:-h,v=h;n.save(),n.beginPath(),l?n.moveTo(r+p,o):n.moveTo(r,o),l?(n.lineTo(r+f-p,o),n.quadraticCurveTo(r+f,o,r+f,o-v),n.lineTo(r+f,e+v),n.quadraticCurveTo(r+f,e,r+f-p,e),n.lineTo(t+p,e)):(n.lineTo(r+f,o),n.lineTo(r+f,e),n.lineTo(t,e)),l?(n.quadraticCurveTo(t,e,t-p/3,e+v/3),n.lineTo(s+p/3,i-v/3),n.quadraticCurveTo(s,i,s+p/3,i+v/3),n.lineTo(r-p/3,o-v/3),n.quadraticCurveTo(r,o,r+p/3,o)):(n.lineTo(s,i),n.lineTo(r,o)),n.closePath(),d&&n.fill(),u&&n.stroke(),n.restore()}function mh(n,t,e,s,i,r=1){n.save(),n.lineWidth=r,n.beginPath(),n.moveTo(t,e),n.lineTo(s,i),n.stroke(),n.closePath(),n.restore()}function oe(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function wr(n,t,e){const s=Math.min(t.x,e.x)+.5,i=Math.min(t.y,e.y),r=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);n.fillRect(s,i,r,o)}const $t=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},mm=n=>Array.isArray(n[0])?n:[n];class vh{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,s){const i=t.ctx,r=s&&this.paneManager.panes[s];e&&(i.save(),r&&$t(i,r.getBounds()),this.drawSeries(i,e),i.restore())}drawSeries(t,e){const s=e.config.additionalVisibilityPredicatesMap;if(e.config.visible||s&&!gc(s)){const i=e.config.type,r=this.seriesDrawers[i];if(r){const o=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);o&&o.length>=1&&r.draw(t,o,e,{})}else console.error(`Data series drawer with type ${i} isn't registered!`)}}}const Kt=(n,t,e,s,i=t)=>{s.hoverWidth?n.lineWidth=s.hoverWidth:e.highlighted?n.lineWidth=t!==i?t+1:i:n.lineWidth=t};class bh{constructor(t){this.config=t}setFillStyle(t,e,s,i){if(e.color)t.strokeStyle=e.color;else{const r=s.colors.barTheme;r&&(t.strokeStyle=r[`${i.name}Color`])}}draw(t,e,s,i){if(s instanceof Zt){const r=gt(e);Kt(t,this.config.barLineWidth,s,i),oe(t,()=>{for(const o of r){this.setFillStyle(t,i,s,o),t.beginPath();const a=s.view.toX(o.centerUnit),l=s.view.toX(o.startUnit),[c,h,d,u]=o.yBodyKeyPoints(s.view),f=At(s.view.xPixels(o.width)/2),p=s.view.toY(o.close),v=s.view.toY(o.open);this.config.showWicks?(t.moveTo(a,c),t.lineTo(a,u)):(t.moveTo(a,h),t.lineTo(a,d)),t.moveTo(a,p),t.lineTo(a+f,p),t.moveTo(l,v),t.lineTo(a,v),t.stroke()}})}}}class Ch{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,s,i){if(i!==void 0&&s instanceof Zt){const r=gt(e),o=this.baseLineModel.baselineYPercents,a=this.canvasBoundContainer.getBounds(T.CHART),l=a.y+a.height*(o/100),c=r[0];for(let h=0;h<r.length;h++){const d=r[h],u=r[h-1],f=r[h+1],p=s.view.toX(c.centerUnit),v=s.view.toX(d.centerUnit),x=s.view.toY(d.close),_=u?s.view.toY(u.close)<l:!1,A=x<l;if(u!==void 0&&_!==A){Sr(t,s,i,_);const L=s.view.toX(u.centerUnit),Y=s.view.toY(u.close),F=v-L,R=x-Y,k=F/R,q=x-l,W=k*q,U=L+(F-W);t.lineTo(U,l),t.stroke(),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(U,l)}u===void 0?(t.beginPath(),t.moveTo(v,x)):f===void 0?(Sr(t,s,i,A),t.lineTo(v,x),t.stroke(),t.lineTo(v,l),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(p,l),t.lineTo(v,l),t.strokeStyle=s.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(v,x)}}}}const Sr=(n,t,e,s)=>{e.color?(n.fillStyle=e.color,n.strokeStyle=e.color):(n.fillStyle=s?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,n.strokeStyle=s?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class yh{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,s,i){if(s instanceof Zt){const r=gt(e);Kt(t,this.config.candleLineWidth,s,i,this.config.candleLineWidth),oe(t,()=>{this.pixelLength=1/Rt,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const o of r){const{candleTheme:a,activeCandleTheme:l}=s.colors;a&&l&&this.drawCandle(t,i,s,o)}})}}drawCandle(t,e,s,i){const{candleTheme:r,activeCandleTheme:o}=s.colors,a=i.name,l=i.isActive?o:r,c=i.isHollow;e.color?t.fillStyle=e.color:c?t.fillStyle=l[`${a}WickColor`]:t.fillStyle=l[`${a}Color`];const h=s.view.toX(i.startUnit),d=s.view.xPixels(i.width),u=i.bodyHeight(s.view),[f,p,v,x]=i.yBodyKeyPoints(s.view),_=p===v?p+1:v,A=f===x?f+1:x,L=l[`${a}Color`],Y=a==="none"?L:l[`${a}WickColor`];t.fillStyle=L,e.color?t.strokeStyle=e.color:t.strokeStyle=Y;const F=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),R=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:_),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:_),t.moveTo(h+1,p),t.lineTo(h+1,_),t.stroke();else if(d===3){const k=d/Rt;this.drawCandlesWicks(t,h+k,f,A,p,_),c||(t.beginPath(),t.moveTo(h+k,p),t.lineTo(h+k,_),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,p+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const k=i.x(s.view);this.drawCandlesWicks(t,k,f,A,p,_);const q=this.config.candlePaddingPercent,W=Math.max(d*q/2,this.pixelLength),U=h+W,G=d-W*2;if(!c){e.color&&(t.fillStyle=e.color);const V=e.hoverWidth?d+W:G,Q=e.hoverWidth?u+e.hoverWidth+W:u;t.fillRect(U,p,V,Q)}F&&this.drawCandleBorder(t,e,l,i,U+this.halfLineWidthCU,p+this.halfLineWidthCU,G-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,s,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,s,i,r,o,a,l){if(e.color)t.strokeStyle=e.color;else{const c=i.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class wh{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof Zt){const r=e.flat(),o=s.scale.getBounds(),a=o.y+o.height;for(const l of r){t.beginPath();const c=l.name,h=this.config.barCapSize,d=s.colors.histogram;if(d===void 0)return;i.color?t.fillStyle=i.color:t.fillStyle=d[`${c}Bright`];const u=l.xStart(s.view),f=s.view.toY(l.close),p=At(s.view.xPixels(l.width));t.fillRect(u,f,p,h);const v=t.createLinearGradient(0,f+h,0,a);i.color?t.fillStyle=i.color:(v.addColorStop(0,d[`${c}Cap`]),v.addColorStop(1,d[`${c}Bottom`]),t.fillStyle=v),p===0?(t.beginPath(),t.strokeStyle=v,t.moveTo(u,f+h),t.lineTo(u,a),t.stroke(),t.closePath()):t.fillRect(u,f+h,p,a-f-h)}}}}class Sh{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof Zt){const r=gt(e);Kt(t,this.config.lineWidth,s,i,this.config.selectedWidth);const o=s.colors.lineTheme;t.lineCap="round",i.color&&(t.strokeStyle=i.color);for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a],h=c.name;i.color||(t.strokeStyle=o[`${h}Color`]);const d=s.view.toX(l.centerUnit),u=s.view.toY(l.close),f=s.view.toX(c.centerUnit),p=s.view.toY(c.close);t.beginPath(),t.moveTo(d,u),t.lineTo(f,p),t.stroke()}}}}const xh=1.5;class _h{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:xh;t.fillStyle=(r=i.color)!=null?r:this.config.mainColor;for(const a of gt(e)){t.beginPath();const l=s.view.toX(a.centerUnit),c=s.view.toY(a.close);t.arc(l,c,o,0,Math.PI*2,!0),t.fill()}}}const Ph=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class Th{constructor(t,e,s){this.drawer=t,this.config=e,this.chartBounds=s}draw(t,e,s,i){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,s,i),this.afterDraw(t,s))}beforeDraw(t){t.restore(),t.save(),$t(t,this.chartBounds())}isChartTypeAllowed(){return Ph.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),$t(t,e.scale.getBounds())}}class Mh{constructor(t){this.chartModel=t}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=this.chartModel.getVisualCandle(ot(c.centerUnit)),d=c.close;if(h&&d===1){const u=this.chartModel.scale.zoomX,f=At(pt(h.width,u)),p=At(h.bodyHeight(this.chartModel.scale)),v=h.xCenter(this.chartModel.scale)-f/2,x=h.yBodyStart(this.chartModel.scale),_=this.chartModel.config.components.chart.candlePaddingPercent,A=At(f*_/2),L=v+A,Y=f-A*2;t.fillRect(L,x,Y,p)}})})}}const Ah=(n,t,e,s)=>{const{centerUnit:i,close:r}=n,o=e.toX(i),a=e.toY(r);s===0?t.moveTo(o,a):t.lineTo(o,a)},xr=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{Ah(s,t,e,i)})},Eh=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,Ih=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,Dh=/^rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}\s*0*(?:\.\d+|1(?:\.0*)?)\s*[)]$/,Lh=n=>Eh.exec(n),Oh=n=>Ih.exec(n),vm=n=>Dh.exec(n);function Bh(n){const t=Lh(n)||Oh(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const _r={};function Rh(n,t){let e=_r[n+t];if(!e){const s=Bh(n);e=s&&"rgba("+s.join(",")+","+t+")",_r[n+t]=e}return e}class Fh{constructor(){}draw(t,e,s,i){s.config.visible&&(e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);Kt(t,l.lineWidth,s,i,l.hoveredLineWidth);const c=(a=i.color)!=null?a:l.color;t.strokeStyle=c,this.drawLine(t,r,s.view)}),s.linkedDataSeriesModels.forEach((r,o)=>{if(Pr(r.config.type)&&Pr(s.config.type)&&r.config.visible){const a=[],l=s,c=l.getSeriesInViewport(l.scale.xStart-1,l.scale.xEnd+1),h=r.getSeriesInViewport(r.scale.xStart-1,r.scale.xEnd+1);c.forEach((d,u)=>{var f,p;const v=Math.min(d.length,(p=(f=h[u])==null?void 0:f.length)!=null?p:0);for(let A=0;A<v;A++){const L=[d[A].clone(),h[u][A].clone()];a.push({diffPoints:L})}const x=l.getPaintConfig(u).color,_=r.getPaintConfig(o).color;this.drawDifference(t,x,_,a,l,r,i)})}}))}drawLine(t,e,s){t.beginPath(),xr(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a){const[l,c]=[[],[]];i.forEach(u=>{const[f,p]=u.diffPoints;l.push(f),c.push(p)});const h=this.mapDataSeriesDiffPointsIntoPoints(l,r.view),d=this.mapDataSeriesDiffPointsIntoPoints(c,o.view);this.fillCloud(t,s,h,d,a),this.fillCloud(t,e,d,h,a)}fillCloud(t,e,s,i,r){var o,a,l,c;t.save(),t.beginPath();const h=(a=(o=ge(s))==null?void 0:o.x)!=null?a:0,d=(c=(l=wt(s))==null?void 0:l.x)!=null?c:0;t.lineTo(h,0),s.forEach(u=>{t.lineTo(u.x,u.y)}),t.lineTo(d,0),t.closePath(),t.clip(),t.beginPath(),s.forEach((u,f)=>{f===0?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y)}),i.slice().reverse().forEach(u=>{t.lineTo(u.x,u.y)}),t.closePath(),t.fillStyle=r.color?r.color:Rh(e||"#383838",.3),t.fill(),t.restore()}mapDataSeriesDiffPointsIntoPoints(t,e){return t.map(s=>{const{centerUnit:i,close:r}=s,o=e.toX(i),a=e.toY(r);return{x:o,y:a}})}}const Pr=n=>n==="DIFFERENCE";class Hh{constructor(){}draw(t,e,s,i){const r=s.view.toY(0);e.forEach((o,a)=>{var l;const c=s.getPaintConfig(a);Kt(t,c.lineWidth,s,i,c.hoveredLineWidth),t.strokeStyle=(l=i.color)!=null?l:c.color,t.beginPath(),o.forEach(h=>{const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.moveTo(d,ot(r)),t.lineTo(d,ot(u))}),t.stroke()})}}class kh{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);Kt(t,l.lineWidth,s,i,l.hoveredLineWidth),t.strokeStyle=(a=i.color)!=null?a:l.color,this.drawLinePath(t,r,s.view)})}drawLinePath(t,e,s){t.beginPath(),xr(e,t,s),t.stroke()}}class jh{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o),c=i.hoverWidth?i.hoverWidth/2:l.lineWidth;t.fillStyle=(a=i.color)!=null?a:l.color,t.lineWidth=1,r.forEach(h=>{t.beginPath();const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.arc(d,u,c,0,Math.PI*2),t.fill()})})}}class Yh{constructor(t){this.config=t}draw(t,e,s,i){t.save(),e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,r.forEach(h=>{const d=s.getTextForPoint(h),u=Tt(d,t,c),f=Yt(c,t),p=s.view.toX(h.centerUnit)-u/2,v=s.view.toY(h.close)+f;t.fillText(d,p,v)})}),t.restore()}}class Nh{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=s.view.toX(c.centerUnit),d=s.view.toY(c.close);this.drawCandleTriangle(t,h,d,l.lineWidth)})})}drawCandleTriangle(t,e,s,i){t.beginPath(),t.moveTo(e-i/2,s),t.lineTo(e,s-i),t.lineTo(e+i/2,s),t.fill()}}const ls="resized_local",cs="draw",bm="draw_last_candle",be={width:20,height:20};class Tr{constructor(t,e,s,i,r,o={}){this.eventBus=t,this.canvas=e,this.drawingManager=s,this.resizer=r,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.type=tn;var a;i.push(this),this.parent=zh(e);const l=e.getContext("2d",o);if(l===null)throw new Error("Couldn't get 2d context????");this.context=l,this._canvasId=(a=e.getAttribute("data-element"))!=null?a:"",this.updateCanvasWidthHeight(e,this.getChartResizerElement().getBoundingClientRect())}updateDPR(t){const{width:e,height:s}=t,i=window.devicePixelRatio;this.canvas.style.height=s+"px",this.canvas.style.width=e+"px",this.canvas.width=e*i,this.canvas.height=s*i,this.width=e,this.height=s,this.ctx.scale(i,i)}get canvasId(){return this._canvasId}get ctx(){return this.context}clear(){this.context.clearRect(0,0,this.width,this.height)}isLinked(){var t,e;return(e=(t=this.type)==null?void 0:t.linked)!=null?e:!1}fireDraw(){this.eventBus.fireDraw([this.canvasId])}updateCanvasWidthHeight(t,e=this.getChartResizerElement().getBoundingClientRect()){t.clientWidth!==this.width&&(t.width=t.clientWidth,this.width=t.clientWidth);const s=e.height;s!==this.height&&(t.style.height=s+"px",this.height=s,t.height=s,this.prevHeight=s)}getChartResizerElement(){var t;return(t=this.resizer)!=null?t:this.parent}isReady(){return this.width>be.width&&this.height>be.height}}const tn={name:"candle"},Xh={candle:tn,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function Wh(n,t,e,s,i,r,o){var a;const l=ae(n,t,i,r,o,e);return l.type=(a=Xh[s])!=null?a:tn,l}function ae(n,t,e,s,i,r,o){const a=new Tr(n,t,s,i,r,o);return Mr(a,e),a}function Mr(n,t){const e=n.canvas;t.fixedSize&&(e.width=t.fixedSize.width,e.height=t.fixedSize.height,e.style.width=t.fixedSize.width+"px",e.style.height=t.fixedSize.height+"px",n.width=t.fixedSize.width,n.height=t.fixedSize.height),e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.direction="ltr"}function zh(n){let t=n;for(;t;){if(t.nodeType===1&&t.hasAttribute("data-chart-container"))return t;if(t.parentElement!==null)t=t.parentElement;else break}return t}const hs="HIT_TEST_",Sm=null;class Vh{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${yt()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(hs)!==-1&&this.drawersMap[s].draw()})},t.on(cs,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),$n(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(hs)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(hs)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}il(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>be.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>be.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=yt()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(e);this.drawingOrder.splice(i,1);const r=this.drawingOrder.indexOf(s);this.drawingOrder.splice(r+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(s);if(i!==-1){const r=this.drawingOrder.indexOf(e);return this.drawingOrder.splice(r,1),this.drawingOrder.splice(i,0,e),this.reorderDrawers(this.drawingOrder),!0}return!1}getDrawerByName(t){return this.drawersMap[t]}getNameByDrawer(t){for(const e in this.drawersMap)if(this.drawersMap[e]===t)return e}removeDrawerByName(t){const e=this.drawersMap[t];this.removeDrawer(e)}removeDrawer(t){Object.keys(this.drawersMap).forEach(e=>{if(this.drawersMap[e]===t){delete this.drawersMap[e];const s=this.drawingOrder.indexOf(e);s!==-1&&this.drawingOrder.splice(s,1)}})}reorderDrawers(t){this.drawingOrder=ii(this.drawingOrder,t)}}class Ar{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Uh=7;class Gh{constructor(t,e,s,i=()=>!0){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=s,this.drawPredicate=i}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),$t(t,e.getBounds()),e.dataSeries.forEach(s=>this.drawSeries(t,s)),t.restore()})}}drawSeries(t,e){if(e.config.visible){const s=e.config.type,i=this.seriesDrawers[s];if(i){const r={color:this.canvasModel.idToColor(e.htId),hoverWidth:Uh};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Er={dragPredicate:()=>!0};class Ir extends X{constructor(t,e,s,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragComponentOptions.dragPredicate()&&(this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o))},this.onDragTick=o=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels))}}}class ds extends Ir{constructor(t,e,s,i,r=Er){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeYDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeYDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeYDragEnd().subscribe(this.onDragEnd))}}const Zh="BASELINE_RESIZER";class $h extends X{constructor(t,e,s,i,r,o,a){super(),this.chartModel=t,this.chartPanComponent=e,this.canvasModel=s,this.canvasInputListener=i,this.config=r,this.canvasBoundContainer=o,this.cursorHandler=a,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.dragPredicate=new ut(!1),this.baselineYPercents=50,this.ht=zs.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragStartCb=()=>{this.chartPanComponent.deactivatePanHandlers(),this.dragPredicate.next(!0)},this.dragEndCb=()=>{this.chartPanComponent.activateChartPanHandlers(),this.dragPredicate.next(!1)},this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(T.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&kl(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new ds(this.ht,{onDragTick:this.dragTickCb,onDragStart:this.dragStartCb,onDragEnd:this.dragEndCb},i,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(T.CHART).subscribe(()=>this.recalculateBounds())),this.chartModel.chartTypeChanged.subscribe(t=>{t==="baseline"?this.cursorHandler.setCursorForBounds("BASELINE_RESIZER",this.resizerBounds,this.config.components.baseline.cursor,this.config.components.baseline.dragZone):this.cursorHandler.removeCursorForCanvasEl("BASELINE_RESIZER")})}recalculateBounds(){const t=this.canvasBoundContainer.getBounds(T.CHART),e=this.canvasBoundContainer.getBounds(T.Y_AXIS);this.resizerBounds.x=t.x,this.resizerBounds.width=t.width+e.width,this.resizerBounds.height=this.config.components.baseline.height;const s=t.y+t.height*(this.baselineYPercents/100);this.resizerBounds.y=s,this.canvasBoundContainer.bounds[Zh]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(T.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const Kh=n=>{var t;try{const e=Te(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Te(n.hi,Math.max(n.open,n.close),e),i=Te(n.lo,Math.min(n.open,n.close),e),r=Te(n.open,n.lo,e),o=Te(n.close,n.hi,e),a=Number.isNaN(n.vwap)?void 0:n.vwap;return{id:n.id,hi:s,lo:i,open:r,close:o,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility,vwap:a,typicalPrice:n.typicalPrice}}catch(e){console.warn(e);return}},He=(n,t=0)=>{for(let e=t;e<n.length;++e)n[e].idx=e},Dr=n=>{n.forEach(t=>{t.idx=void 0})},qh=n=>n!==void 0;class Jh{constructor(){}draw(t,e,s,i){const r=s.view.toY(0),o=gt(e),a=s.getPaintConfig(0);Kt(t,a.lineWidth,s,i,a.hoveredLineWidth),o.forEach((l,c)=>{var h,d,u,f,p,v,x,_;const A=Qh(o,c),L=A&&l.close<A;if(((h=a.multiplyColors)==null?void 0:h.length)===2){t.strokeStyle=(d=i.color)!=null?d:(L?a.multiplyColors[1]:a.multiplyColors[0])||a.color||"#FF00FF",t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}if(((u=a.multiplyColors)==null?void 0:u.length)===4){L&&l.close<0&&(t.strokeStyle=(f=i.color)!=null?f:a.multiplyColors[0]||a.color||"#FF00FF"),!L&&l.close<0&&(t.strokeStyle=(p=i.color)!=null?p:a.multiplyColors[1]||a.color||"#FF00FF"),L&&l.close>0&&(t.strokeStyle=(v=i.color)!=null?v:a.multiplyColors[2]||a.color||"#FF00FF"),!L&&l.close>0&&(t.strokeStyle=(x=i.color)!=null?x:a.multiplyColors[3]||a.color||"#FF00FF"),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}t.strokeStyle=(_=i.color)!=null?_:a.color||"#FF00FF",t.beginPath();const Y=s.view.toX(l.centerUnit),F=s.view.toY(l.close);t.moveTo(Y,r),t.lineTo(Y,F),t.stroke()})}}const Qh=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},td=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class ed{constructor(){}draw(t,e,s,i){const r=gt(e),o=s.getPaintConfig(0);Kt(t,o.lineWidth,s,i,o.hoveredLineWidth),t.lineCap="round",r.forEach((a,l)=>{var c,h;const d=sd(r,l)||r[0],u=d&&a.close<d.close;if(((c=o.multiplyColors)==null?void 0:c.length)===2){t.strokeStyle=(h=i.color)!=null?h:(u?o.multiplyColors[1]:o.multiplyColors[0])||o.color||"#FF00FF";const f=s.view.toX(a.centerUnit),p=s.view.toY(a.close),v=s.view.toX(d.centerUnit),x=s.view.toY(d.close);t.beginPath(),t.moveTo(v,x),t.lineTo(f,p),t.stroke();return}})}}const sd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0},Ce="#FF00FF";class nd{constructor(){}draw(t,e,s,i){const r=gt(e),o=s.getPaintConfig(0),a=i.hoverWidth?i.hoverWidth/2:o.lineWidth;r.forEach((l,c)=>{var h,d,u,f,p,v,x,_;const A=id(r,c),L=A&&l.close<A;if(((h=o.multiplyColors)==null?void 0:h.length)===2){t.fillStyle=(d=i.color)!=null?d:(L?o.multiplyColors[1]:o.multiplyColors[0])||o.color||Ce;const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}if(((u=o.multiplyColors)==null?void 0:u.length)===4){L&&l.close<0&&(t.fillStyle=(f=i.color)!=null?f:o.multiplyColors[0]||o.color||Ce),!L&&l.close<0&&(t.fillStyle=(p=i.color)!=null?p:o.multiplyColors[1]||o.color||Ce),L&&l.close>0&&(t.fillStyle=(v=i.color)!=null?v:o.multiplyColors[2]||o.color||Ce),!L&&l.close>0&&(t.fillStyle=(x=i.color)!=null?x:o.multiplyColors[3]||o.color||Ce),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}t.fillStyle=(_=i.color)!=null?_:o.color||Ce,t.beginPath();const Y=s.view.toX(l.centerUnit),F=s.view.toY(l.close);t.arc(Y,F,a,0,Math.PI*2),t.fill()})}}const id=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0};var rd=Object.defineProperty,Lr=Object.getOwnPropertySymbols,od=Object.prototype.hasOwnProperty,ad=Object.prototype.propertyIsEnumerable,Or=(n,t,e)=>t in n?rd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Br=(n,t)=>{for(var e in t||(t={}))od.call(t,e)&&Or(n,e,t[e]);if(Lr)for(var e of Lr(t))ad.call(t,e)&&Or(n,e,t[e]);return n};class ld{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class cd extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=f,this.chartResizeHandler=p,this._dataSeriesDrawers={},this.backgroundDrawerPredicateSubject=new ut(!0),this.strToBarType=x=>{var _;return(_=this.barTypeValues.find(A=>A===x))!=null?_:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new $h(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const v=new Gh(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(v,hs+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new Bc(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(T.PANE_UUID($),s.components.chart.cursor),this.dataSeriesDrawer=new vh(d,this.dataSeriesDrawers)}doActivate(){super.doActivate(),this.dynamicObjects.model.addObject({id:this.chartModel.mainCandleSeries.id,paneId:this.chartModel.mainCandleSeries.extentComponent.paneUUID,model:this.chartModel.mainCandleSeries,drawer:this.dataSeriesDrawer}),this.addRxSubscription(this.paneManager.dataSeriesAddedSubject.subscribe(t=>{this.dynamicObjects.model.addObject({id:t.id,paneId:t.extentComponent.paneUUID,parentId:t.parentId,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)})),this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(td(()=>{this.backgroundDrawerPredicateSubject.next(!1)},Fe))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",rr),this.registerCandlesTransformer("trend",or),this.registerCandlesTransformer("hollow",Fc),this.registerCandlesTransformer("line",Hc)}get barTypeValues(){return zi(this._dataSeriesDrawers)}get dataSeriesDrawers(){return this._dataSeriesDrawers}registerCandlesTransformer(t,e){this.chartModel.registerCandlesTransformer(t,e)}registerLastCandleLabelHandler(t,e){this.chartModel.registerLastCandleLabelHandler(t,e)}registerCandlesWidthCalculator(t,e){this.chartModel.registerCandlesWidthCalculator(t,e)}registerDefaultDataSeriesDrawers(){const t=new yh(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new bh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new Sh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new _h(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new gh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new Ch(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new wh(this.config.components.chart.histogram));const e=T.PANE_UUID($),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new kh),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new ed),this.registerDataSeriesTypeDrawer("HISTOGRAM",new Hh),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new Jh),this.registerDataSeriesTypeDrawer("POINTS",new jh),this.registerDataSeriesTypeDrawer("TREND_POINTS",new nd),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new Th(new Mh(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new Yh(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new Nh),this.registerDataSeriesTypeDrawer("DIFFERENCE",new Fh)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(Br({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e,s=!0){return this.chartModel.setTimestampRange(t,e,s)}setXScale(t,e,s=!0){return this.scale.setXScale(t,e,s)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.fireDraw()}setApplyBackgroundToAxes(t){this.config.components.chart.applyBackgroundToAxes=Br({},t),this.chartModel.bus.fireDraw()}setMainSeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument;this.chartModel.mainCandleSeries.instrument=s,this.chartModel.setAllSeries({candles:t.candles,instrument:s},this.chartModel.getSecondarySeries().map(i=>{var r;const o=(r=i.instrument)!=null?r:this.chartModel.mainCandleSeries.instrument,a=i.dataPoints;return Dr(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),i)return i}setAllSeries(t,e=[]){var s;const i=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(i),e.forEach(r=>{var o;const a=(o=r.instrument)!=null?o:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(a)}),this.chartModel.setAllSeries(t,e)}toXFromCandleIndex(t){return this.chartModel.toX(t)}toXFromTimestamp(t){return this.chartModel.candleFromTimestamp(t).xCenter(this.chartModel.scale)}toY(t){return this.chartModel.toY(t)}updateAllSeries(t,e=[]){this.chartModel.updateAllSeries(t,e),this.canvasModel.fireDraw()}removeDataFrom(t){this.chartModel.removeDataFrom(t)}removeSecondarySeries(t){this.chartModel.removeSecondaryCandleSeries(t)}prependCandles(t,e){this.chartModel.prependCandles(t,e)}addLastCandle(t,e){this.chartModel.addLastCandle(t,e)}removeCandleByIdx(t,e){this.chartModel.removeCandleByIdx(t,e)}removeCandlesByIdsSequence(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIdsSequence(t,e)}removeCandlesByIds(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIds(t,e)}addCandlesById(t,e,s=this.chartModel.mainCandleSeries){this.chartModel.addCandlesById(t,e,s)}updateLastCandle(t,e){this.chartModel.updateLastCandle(t,e)}updateCandles(t,e){this.chartModel.updateCandles(t,e)}setOffsets(t){this.chartModel.setOffsets(t)}getDataSeriesDrawer(t){return this._dataSeriesDrawers[t]}registerDataSeriesTypeDrawer(t,e){this._dataSeriesDrawers[t]=e}updatePriceIncrementsIfNeeded(t){(!t.priceIncrements||!ve.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[ve.autoDetectIncrementOfValueRange(this.scale.yEnd-this.scale.yStart)])}observeOffsetsChanged(){return this.chartModel.offsetsChanged}observeChartTypeChanged(){return this.chartModel.chartTypeChanged}observeCandlesChanged(){return this.chartModel.observeCandlesChanged()}observeCandlesUpdated(){return this.chartModel.candlesUpdatedSubject}observeCandlesPrepended(){return this.chartModel.candlesPrependSubject}}function Rr(n,t){return t===void 0&&(t=Us),N(function(e,s){var i=null,r=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var c=r;r=null,s.next(c)}};function l(){var c=o+n,h=t.now();if(h<c){i=this.schedule(void 0,c-h),s.add(i);return}a()}e.subscribe(vt(s,function(c){r=c,o=t.now(),i||(i=t.schedule(l,n),s.add(i))},function(){a(),s.complete()},void 0,function(){r=i=null}))})}class Fr extends Zt{constructor(t,e,s,i,r,o,a,l,c,h){super(e,s,i,r,o,a,l,c,h),this.baseModel=t}set visualPoints(t){super.visualPoints=t,this.baseModel.mainVisualPoints=super.visualPoints}get visualPoints(){return super.visualPoints}set dataPoints(t){super.dataPoints=t,this.baseModel.mainDataPoints=super.dataPoints}get dataPoints(){return super.dataPoints}recalculateMeanCandleWidth(t){super.recalculateMeanCandleWidth(t),this.baseModel.meanDataWidth=this.meanCandleWidth}}var hd=Object.defineProperty,Hr=Object.getOwnPropertySymbols,dd=Object.prototype.hasOwnProperty,ud=Object.prototype.propertyIsEnumerable,kr=(n,t,e)=>t in n?hd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fd=(n,t)=>{for(var e in t||(t={}))dd.call(t,e)&&kr(n,e,t[e]);if(Hr)for(var e of Hr(t))ud.call(t,e)&&kr(n,e,t[e]);return n};const gd=(n,t,e,s)=>{var i,r,o,a;const l=fd({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=ll(-e,t))==null?void 0:o.startUnit)!=null?a:0;let d=n.xStart,u=n.xEnd;return l.xStart>=h&&(d=h,u=u-(l.xStart-h)),l.xEnd<c&&(d=c-Ft(s.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},pd=n=>(t,e={xScale:!0,yScale:!0})=>{if(t.length!==0){if(e.xScale){const s=t.slice(Math.max(t.length-n.state.defaultViewportItems,0)),i=s[0],r=s[s.length-1];n.setXScale(i.startUnit,r.startUnit+r.width+n.offsets.right)}e.yScale&&n.doAutoScale(!0),n.fireChanged()}},md=(n,t)=>(e,s=null)=>{const[i,r]=e,o=t.candleFromTimestamp(i).startUnit,a=t.candleFromTimestamp(r).startUnit,l=s===null?0:t.mainCandleSeries.meanCandleWidth*2,c=s?o-l:o+l,h=s?a+l:a-l;n.setXScale(c,h)};var vd=Object.defineProperty,bd=Object.defineProperties,Cd=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertySymbols,yd=Object.prototype.hasOwnProperty,wd=Object.prototype.propertyIsEnumerable,Yr=(n,t,e)=>t in n?vd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ke=(n,t)=>{for(var e in t||(t={}))yd.call(t,e)&&Yr(n,e,t[e]);if(jr)for(var e of jr(t))wd.call(t,e)&&Yr(n,e,t[e]);return n},en=(n,t)=>bd(n,Cd(t));class Sd{constructor(t){this.config=t,this.usedChartColors={},this.symbolsToColorKeys={},this.secondaryChartColorsPool=this.createColorPool(this.config.colors.secondaryChartTheme),this.usedChartColors=Object.keys(this.secondaryChartColorsPool).reduce((e,s)=>en(ke({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=en(ke({},ie(this.config.colors)),{lineTheme:ke({},s.lineTheme),areaTheme:ke({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,s=i);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[t]=s,this.secondaryChartColorsPool[s]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var s,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=en(ke({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var xd=Object.defineProperty,Nr=Object.getOwnPropertySymbols,_d=Object.prototype.hasOwnProperty,Pd=Object.prototype.propertyIsEnumerable,Xr=(n,t,e)=>t in n?xd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,us=(n,t)=>{for(var e in t||(t={}))_d.call(t,e)&&Xr(n,e,t[e]);if(Nr)for(var e of Nr(t))Pd.call(t,e)&&Xr(n,e,t[e]);return n};class Td extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=i,this.config=r,this.scale=o,this.formatterFactory=a,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.chartTypeChanged=new B,this.mainInstrumentChangedSubject=new B,this.offsetsChanged=new B,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.prepareCandles=u=>{const f=u.map(Kh).filter(qh),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new Sd(this.config);const d=new Fr(this.chartBaseModel,this.paneManager.panes[$].mainExtent,yt(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new ld,this.candlesTransformersByChartType,this.candleWidthByChartType,us({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),this.config.components.chart.minCandlesOffset>0&&o.addXConstraint((u,f)=>gd(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=pd(o),this.timeFrameViewportTransformer=md(o,this),this.pane=this.paneManager.panes[$]}get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(t=>t!==this.mainCandleSeries)}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(T.PANE_UUID($)).pipe(Et(Di)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(Rr(Fe)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>be.width&&t.height>be.height){const e=this.canvasBoundsContainer.getEffectiveChartWidth(),s=this.canvasBoundsContainer.getEffectiveYAxisWidth();if(this.prevChartWidth===0&&this.scale){this.scale.isViewportValid(!1)?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=Ft(s-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-r)}else this.scale.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=e;return}const i=Ft(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-i,this.scale.xEnd),this.scale.recalculateZoomY(),this.prevYWidth=s,this.prevChartWidth=e}}setMainCandleSeries(t,e){this.mainCandleSeries.instrument=e,this.setAllSeries({candles:t,instrument:e},this.getSecondarySeries().map(s=>{const i=s.dataPoints;return Dr(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const i=this.prepareCandles(t),r=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),o=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,r),l=this.secondaryCandleSeries.some(c=>c.instrument.symbol===e.symbol)?this.secondaryCandleSeries.find(c=>c.instrument.symbol===e.symbol):this.createSecondaryCandleSeriesModel(e);if(l)return l.dataPoints=o,s&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var s;this.mainCandleSeries.instrument=(s=t.instrument)!=null?s:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=this.prepareCandles(t.candles);this.mainCandleSeries.clearData(),He(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(r=>e.filter(o=>{var a;return((a=o.instrument)==null?void 0:a.symbol)===r.instrument.symbol}).length===0).forEach(r=>this.removeSecondaryCandleSeries(r)),e.map(r=>this.setSecondaryCandleSeries(r.candles,r.instrument,!1)),this.candleSeries.forEach(r=>{r.recalculateDataViewportIndexes(),r.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()}autoScaleOnCandles(){this.scale.state.autoScaleOnCandles&&(this.doBasicScale(),this.scale.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doBasicXScale(){this.scale.setXScaleWithoutYScale(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(t=null){this.timeFrameViewportTransformer(this.lastTimeFrame,t),this.scale.state.autoScaleOnCandles&&this.scale.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scale.toX(this.scale.xStart),!0).timestamp,this.candleFromX(this.scale.toX(this.scale.xEnd),!0).timestamp])}updateAllSeries(t,e=[]){t=us({},t),t.instrument||(t.instrument=this.mainCandleSeries.instrument);const s=[t,...e];if(!this.candleSeries.every(l=>s.find(c=>{var h;return((h=c.instrument)==null?void 0:h.symbol)===l.instrument.symbol}))||e.length!==this.secondaryCandleSeries.length){console.error("All series update failed. Instruments for series are different.");return}const i=this.prepareCandles(t.candles),r=zr(this.mainCandleSeries.dataPoints,i),o=r.candles;He(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=zr((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints(),l.recalculateDataViewportIndexes()});const a=this.chartBaseModel.mainVisualPoints.slice(0,r.prepended.length).reduce((l,c)=>l+c.width,0);this.scale.moveXStart(this.scale.xStart+a),this.candlesPrependSubject.next({prependedCandlesWidth:a,prependedCandles:r.prepended}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(t){Object.values(this.paneManager.panes).forEach(e=>{e.dataSeries.forEach(s=>{const i=Bt(s.dataPoints,t,o=>o.timestamp),r=i.exact?i.index:i.index+1;s.dataPoints=s.dataPoints.slice(0,r)})}),this.candlesChangedRedraw()}createSecondaryCandleSeriesModel(t){const e=us(us({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new Zt(this.paneManager.panes[$].mainExtent,yt(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,t,this.candlesTransformersByChartType,this.candleWidthByChartType,e);return s.config.type="line",this.candleSeries.push(s),s}removeSecondaryCandleSeries(t){return this.secondaryChartColors.addColorToPool(t.instrument.symbol),this.candleSeries=this.candleSeries.filter(e=>e!==t),t.deactivate(),this.paneManager.panes[$].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(i=>{const r=this.candleIdxFromId(i.id),o=r>0?r:0,a=e[o];if(a)s.push(a);else{let l=Wr(e,o,-1);if(l||(l=Wr(e,o,1)),l){const c=wl(l,o,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const i=Mt(t,es().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=s,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=s.length&&this.scale.setXScale(this.scale.xStart,this.candleFromIdx(e).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scale.getOffsets()}fromY(t){return this.scale.fromY(t)}priceFromY(t,e){return(e!=null?e:this.mainCandleSeries).view.priceFromY(t)}fromX(t){return this.scale.fromX(t)}toX(t){const e=this.candleFromIdx(t);return this.scale.toX(e.centerUnit)}candleFromX(t,e=!1,s=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var i,r;const o=Bt(s.visualPoints,t,d=>d.startUnit),a=s.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=Me((t-a[o.index].centerUnit)/this.mainCandleSeries.meanCandleWidth));const c=o.index,h=Math.max(Math.min(a.length-1,c),0);return(c<0||c>=a.length)&&e?Be(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:Be(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e={extrapolate:!0},s=this.mainCandleSeries){const i=s.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,i)}candleFromId(t,e=this.mainCandleSeries){return e.visualPoints.find(s=>s.candle.id===t)}candleIdxFromId(t,e=this.mainCandleSeries){return e.visualPoints.findIndex(s=>s.candle.id===t)}candleFromIdx(t){return this.chartBaseModel.dataFromIdx(t)}isReady(){return this.canvasModel.isReady()&&this.hasCandles()}registerCandlesTransformer(t,e){this.candlesTransformersByChartType[t]=e}registerCandlesWidthCalculator(t,e){this.candleWidthByChartType[t]=e}registerLastCandleLabelHandler(t,e){this.lastCandleLabelsByChartType[t]=e}hasCandles(){return this.mainCandleSeries.visualPoints.length!==0}getVisualCandle(t){var e,s,i;const r=t-((i=(s=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:s.idx)!=null?i:0);return this.mainCandleSeries.visualPoints[r]}getFirstIdx(){return this.mainCandleSeries.dataIdxStart}getLastIdx(){return this.mainCandleSeries.dataIdxEnd}getFirstTimestamp(t=!0){return t?this.candleFromIdx(this.getFirstIdx()).candle.timestamp:this.candleFromUnit(this.scale.xStart,!0).timestamp}getLastTimestamp(t=!0){return t?this.candleFromIdx(this.getLastIdx()).candle.timestamp:this.candleFromUnit(this.scale.xEnd,!0).timestamp}setTimestampRange(t,e,s=!0){const i=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),o=r.startUnit+r.width;return this.scale.setXScale(i,o,s)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return wt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return wt(t)}getMaxCandlesFitLength(){return ot(this.canvasBoundsContainer.getEffectiveChartWidth()/this.config.components.chart.minWidth)}getSecondarySeries(){return this.secondaryCandleSeries}isSeriesInstrument(t,e){return t.instrument.symbol===e}findSeriesBySymbol(t){return this.candleSeries.filter(e=>this.isSeriesInstrument(e,t))}findSecondarySeriesBySymbol(t){return this.secondaryCandleSeries.find(e=>this.isSeriesInstrument(e,t))}reindexCandlesBasedOnSeries(t,e){return e.reduce((s,i)=>{const r=i.timestamp,o=Le(r,{extrapolate:!1},t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}isLastCandleInViewport(){const t=this.getLastCandle();return t&&t.idx?this.isCandleInViewport(t.idx):!1}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=Le(h.timestamp,{extrapolate:!0},o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,v=c&&h.timestamp<c.timestamp;if(p&&!v&&(c=h),a&&c&&s&&l){const x=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:ar;this.scale.moveXStart(this.scale.xStart+x(c))}}),c&&(r.updateCurrentPrice(c.close),this.paneManager.yExtents.forEach(h=>h.yAxis.updateOrderedLabels(!0))),l&&c&&t.length===1?this.canvasModel.fireDraw():r.recalculateVisualPoints()}),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return Ct(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=0,e){let s=this.getCandles().slice();const i=this.getCandlesCount(),r=e!=null?e:i+this.FAKE_CANDLES_DEFAULT;s=s.slice(Math.max(0,t),Math.min(i,r));const o=[],a=[];for(let c=i;c<r;c++)o.push(Be(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=t;c<l;c++)a.push(Be(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...a,...s,...o]}getCandlesCount(){return this.mainCandleSeries.dataPoints.length}getCandlesCountWithRightOffset(){return this.getCandlesCount()+this.getOffsets().right}clearData(){this.candleSeries.forEach(t=>t.clearData())}prependCandles(t,e){const s=t.slice(),i=[];return e.forEach(r=>{const a=Le(r.timestamp,{extrapolate:!1},t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),He(i.dataPoints),i.recalculateVisualPoints()}),this.candlesChangedRedraw()}removeCandlesByIdsSequence(t,e){const s=this.candleIdxFromId(t[0],e),i=this.candleIdxFromId(t[t.length-1],e);if(s<0||i<0){console.warn("Candle is not found");return}e.dataPoints=e.dataPoints.slice(0,s).concat(e.dataPoints.slice(i+1)),He(e.dataPoints,i),e.recalculateVisualPoints(),this.candlesChangedRedraw()}removeCandlesByIds(t,e){t.forEach(s=>this.removeCandleByIdx(this.candleIdxFromId(s,e)))}addCandlesById(t,e,s){const i=this.candleIdxFromId(e);if(i<0){console.warn("Selected start candle is not found");return}const r=s.dataPoints.slice(0,i),o=s.dataPoints.slice(i);s.dataPoints=r.concat(t).concat(o),He(s.dataPoints),s.recalculateVisualPoints(),this.candlesChangedRedraw()}candlesChangedRedraw(){this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const Wr=(n,t,e)=>{if(t>=n.length)return n[n.length-1];for(let s=t;s<n.length&&s>=0;s+=e){const i=n[s];if(i)return i}},zr=(n,t)=>{const e=n.slice(),s=[],i=[];return t.forEach(r=>{const a=Le(r.timestamp,{extrapolate:!0},n).index;a<0?s.push(r):a>=n.length?i.push(r):n[a].timestamp===r.timestamp?e[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:s,appended:i,candles:[...s,...e,...i]}};class ye{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class sn{constructor(t){this.drawers=t!=null?t:new Map}draw(){this.drawers.forEach(t=>t.draw())}addDrawer(t,e){const s=e!=null?e:"drawer"+this.drawers.size;this.drawers.set(s,t)}drawLastBar(){this.drawers.forEach(t=>t.drawLastBar&&t.drawLastBar())}removeDrawer(t){const e=Wi(this.drawers,t);e?this.drawers.delete(e):console.warn("Couldn't find drawer type")}removeDrawerByName(t){this.drawers.delete(t)}getDrawer(t){return this.drawers.get(t)}moveTop(t){const e=Wi(this.drawers,t);e?this.moveTopByName(e):console.warn("Couldn't find drawer type")}moveTopByName(t){if(this.drawers.size===1)return;const e=this.drawers.get(t);this.drawers.delete(t),e&&this.drawers.set(t,e)}getSize(){return this.drawers.size}getAll(){return this.drawers}getCanvasIds(){const t=gt(Array.from(this.drawers).map(([,s])=>s.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class Md{constructor(t,e,s,i){this.model=t,this.config=e,this.crossToolCanvasModel=s,this.crossToolTypeDrawers=i}draw(){const t=this.crossToolTypeDrawers[this.config.components.crossTool.type];t?this.model.currentHover&&t.draw(this.crossToolCanvasModel.ctx,this.model.currentHover):console.error(`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}var Ad=Object.defineProperty,Ed=Object.defineProperties,Id=Object.getOwnPropertyDescriptors,Vr=Object.getOwnPropertySymbols,Dd=Object.prototype.hasOwnProperty,Ld=Object.prototype.propertyIsEnumerable,Ur=(n,t,e)=>t in n?Ad(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Od=(n,t)=>{for(var e in t||(t={}))Dd.call(t,e)&&Ur(n,e,t[e]);if(Vr)for(var e of Vr(t))Ld.call(t,e)&&Ur(n,e,t[e]);return n},Bd=(n,t)=>Ed(n,Id(t));class Rd extends X{constructor(t,e,s,i,r,o,a){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=i,this.canvasBoundsContainer=r,this.baselineModel=o,this.chartModel=a,this.currentHoverSubject=new ut(null)}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.config.type=t}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?jt()?this.updateCrossToolMobile(t):this.updateCrossTool(t):this.currentHover=null,this.fireDraw()})),this.addRxSubscription(this.baselineModel.dragPredicate.subscribe(t=>{if(jt())if(t)this.hoverProducer.deactivate();else{const e=this.crossEventProducer.crossToolTouchInfo;e.isSet&&this.crossEventProducer.crossSubject.next([e.temp.x,e.temp.y,$]),this.hoverProducer.activate()}}))}fireDraw(){this.config.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateCrossTool(t,e=this.config.magnetTarget,s=this.config.discrete){var i;const r=s?this.chartModel.toX((i=this.chartModel.candleFromX(t.x,!0).idx)!=null?i:0):t.x;if(this.currentHover===null?this.currentHover={x:r,y:0,time:t.timeFormatted,paneId:t.paneId}:(this.currentHover.x=r,this.currentHover.time=t.timeFormatted),t.candleHover&&t.paneId===$)switch(e){case"O":this.currentHover.y=t.candleHover.openY;break;case"C":this.currentHover.y=t.candleHover.closeY;break;case"H":this.currentHover.y=t.candleHover.highY;break;case"L":this.currentHover.y=t.candleHover.lowY;break;case"OHLC":this.currentHover.y=t.candleHover.closestOHLCY;break;case"none":this.currentHover.y=t.y;break}else this.currentHover.y=t.y;this.currentHover.paneId=t.paneId,this.currentHoverSubject.next(this.currentHover)}updateCrossToolMobile(t){var e;if(!this.hoverProducer.longTouchActivatedSubject.getValue())return;const{fixed:s,temp:i,isSet:r}=this.crossEventProducer.crossToolTouchInfo;if(!r){this.updateCrossTool(t);return}const o=this.canvasBoundsContainer.getBounds(T.PANE_UUID(t.paneId)),a=5,l=t.x-i.x,c=t.y-i.y,h=s.x+l,d=s.y+c,u=o.y+a,f=o.y+o.height-a,p=h<a?a:h>o.width-a?o.width-a:h,v=d<u?u:d>f?f:d,x=(e=this.hoverProducer.createHover(p,v,t.paneId))!=null?e:t,_=Bd(Od({},x),{x:p,y:v});this.crossEventProducer.crossToolHover=_,this.updateCrossTool(_)}}const It=4;function Fd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p;const v=r.align,x=(l=i.textFont)!=null?l:se(r),_=i.bgColor,A=(c=i.textColor)!=null?c:ee(_,o.labelTextColor,o.labelInvertedTextColor),L=(h=i.paddingTop)!=null?h:It,Y=(d=i.paddingBottom)!=null?d:It,F=(u=i.paddingEnd)!=null?u:It,R=Me(Yt(x,n)/2),k=s-R-L,W=s+R+Y-k;if(a&&!fs(s,t,W))return;n.save(),n.fillStyle=_,n.strokeStyle=_;const U=Me(t.width/6),G=v==="right"?t.x:t.x+t.width,V=v==="right"?G+U:G-U,Q=r.labelBoxMargin.end,J=Q-F,et=t.width-U-J;ph(n,V,k,G,k+Me(W/2),V,k+W,et,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,v),n.fillStyle=A,n.font=x;const tt=v==="right"?t.x+t.width-Tt(e,n,x)-Q:t.x+Q;n.fillText(e,tt,s+R-1),n.restore()}function Hd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,v,x,_,A;const L=r.align,Y=(l=i.textFont)!=null?l:se(r),F=i.bgColor,R=(c=i.textColor)!=null?c:ee(F,o.labelTextColor,o.labelInvertedTextColor),k=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,q=(u=(d=i.paddingTop)!=null?d:k==null?void 0:k.top)!=null?u:It,W=(p=(f=i.paddingBottom)!=null?f:k==null?void 0:k.bottom)!=null?p:It,U=(x=(v=i.paddingEnd)!=null?v:k==null?void 0:k.end)!=null?x:It,G=i.paddingStart,V=Yt(Y,n),Q=s-V/2-q,et=s+V/2+W-Q,tt=(A=i.rounded)!=null?A:(_=r.typeConfig.rectangle)==null?void 0:_.rounded;if(a&&!fs(s,t,et))return;n.save(),n.fillStyle=F,n.strokeStyle=F;const st=r.labelBoxMargin.end;n.font=Y;const ct=Tt(e,n,Y),at=st-U,_t=G!==void 0?ct+G+U:t.width-at,Gt=L==="right"?t.x+t.width-at-_t:t.x+at,xe=L==="right"?t.x+t.width-ct-st:st;tt?yr(n,Gt,Q,_t,et,4,!0):n.fillRect(Gt,Q,_t,et),n.fillStyle=R,n.fillText(e,xe,s+V/2-1),n.restore()}function kd(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,v,x;const _=r.align,A=(l=i.textFont)!=null?l:se(r),L=o.backgroundColor,Y=(c=i.textColor)!=null?c:ee(L,o.labelTextColor,o.labelInvertedTextColor),F=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,R=(u=(d=i.paddingTop)!=null?d:F==null?void 0:F.top)!=null?u:It,k=(p=(f=i.paddingBottom)!=null?f:F==null?void 0:F.bottom)!=null?p:It,q=(x=(v=i.paddingEnd)!=null?v:F==null?void 0:F.end)!=null?x:It,W=i.paddingStart,U=Yt(A,n),G=s-U/2-R,Q=s+U/2+k-G;if(a&&!fs(s,t,Q))return;n.save(),n.fillStyle=L,n.strokeStyle=L;const J=r.labelBoxMargin.end;n.font=A;const et=Tt(e,n,A),tt=J-q,st=W!==void 0?et+W+q:t.width-tt,ct=_==="right"?t.x+t.width-tt-st:t.x+tt,at=_==="right"?t.x+t.width-et-J:J;n.fillStyle=L,n.strokeStyle=L,n.fillRect(ct,G,st,Q),n.fillStyle=Y,n.fillText(e,at,s+U/2-1),n.restore()}function jd(n,t,e=It){return Yt(n,t)/2+e}function fs(n,t,e){return!(n<t.y+e/2||n>t.y+t.height-e/2)}const Yd="badge",Gr=4,Zr={badge:Fd,rectangle:Hd,plain:kd};function $r(n,t,e,s,i,r,o,a,l){var c,h,d,u,f;const p=r.y,v=r.labelText,x=(c=r.mode)!=null?c:"label",_=(h=r.labelType)!=null?h:Yd,A=r.description,L=(d=r.textFont)!=null?d:se(a),Y=r.bgColor,F=(u=r.lineColor)!=null?u:Y,R=Tt(A!=null?A:"",n,L)+8,k=ot(r.y),q=Yt(L,n),W=p-q/2,G=p+q/2-W;n.save(),n.fillStyle=Y,n.strokeStyle=F;const V=o.getBounds(T.PANE_UUID($)),Q=Zr[_],J=a.labels.descriptions,et=Nd(s,k,G),tt=()=>J&&Xd(e,t,s,i,r,a);let st,ct;const at=2;a.align==="right"?(st=V.x,ct=J?V.x+V.width-R:V.x+V.width+at):(st=J?V.x+R:V.x-at,ct=V.x+V.width);const _t=(f=r.lineY)!=null?f:r.y,Gt=()=>et&&oe(n,()=>mh(n,st,_t,ct,_t,1)),xe=()=>Q(n,s,v,p,r,a,l.yAxis,!1),Ss={line:()=>{Gt(),tt()},"line-label":()=>{Gt(),xe(),tt()},label:()=>{tt(),xe()}};x!=="none"&&fs(p,s,G)&&Ss[x](),n.restore()}const Nd=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Xd(n,t,e,s,i,r){var o,a,l;const c=r.align||"right",h=i.description;if(!h||h.length===0)return;const d=i.y,u=se(r),f=Tt(h,t,u),p=Yt(u,t),v=(o=i.paddingTop)!=null?o:Gr,x=(a=i.paddingBottom)!=null?a:Gr,_=d-p/2-v,L=d+p/2+x-_;t.save();const Y=f+5,F=4,R=f+F*2,k=s.x+s.width,q=c==="right"?k-R:s.x+F;Rc(n,t,q,_,Y,L,.8),t.fillStyle=(l=i.descColor)!=null?l:i.bgColor,t.font=u;const W=c==="right"?k-f-F*2:s.x+F*2;t.fillText(h,W,d+p/2-1),t.restore()}class Kr{constructor(t,e,s,i=()=>!0,r){this.config=t,this.canvasBoundsContainer=e,this.paneManager=s,this.crossDrawPredicate=i,this.noLines=r}draw(t,e){this.crossDrawPredicate()&&oe(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var s,i,r,o,a;const l=this.canvasBoundsContainer.getBounds(T.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES,{extensionY:1e-4}),h=(s=this.config.components.xAxis.padding.top)!=null?s:0,d=(r=this.config.components.yAxis.typeConfig[(i=this.config.components.crossTool.yLabel.type)!=null?i:"badge"])==null?void 0:r.paddings,u=(o=d==null?void 0:d.start)!=null?o:0,f=(a=this.paneManager.panes[e.paneId])==null?void 0:a.ht;if(c(e.x,l.y)){const p={start:[l.x,e.y],end:[l.x+l.width+u,e.y]},v={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},x=f==null?void 0:f(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),x&&(t.moveTo(...p.start),t.lineTo(...p.end)),t.moveTo(...v.start),t.lineTo(...v.end),t.stroke()),x&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,i,r,o,a;const l=this.config.components.crossTool.xLabel.padding,c=this.config.components.crossTool.xLabel.margin,h=this.config.colors.crossTool;if(this.config.components.xAxis.visible){t.font=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily;const d=e.x,u=e.time,f=t.measureText(u).width,p=this.config.components.xAxis.fontSize,v=this.canvasBoundsContainer.getBounds(T.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const x=(s=l==null?void 0:l.left)!=null?s:0,_=(i=l==null?void 0:l.right)!=null?i:0,A=(r=l==null?void 0:l.top)!=null?r:0,L=(o=l==null?void 0:l.bottom)!=null?o:0,Y=(a=c==null?void 0:c.top)!=null?a:0,F=f+x+_,R=p+A+L,k=Math.max(d-F/2,0),q=v.y+Y+Ie/2;yr(t,k,q,F,R),t.fillStyle=h.labelTextColor;const W=Math.max(d-f/2,x),U=v.y+Y+p+Ie/2+A-1;t.fillText(u,W,U),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,i=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const r=this.paneManager.panes[e.paneId],o=e.y,a=this.config.components.crossTool.yLabel.type;if(!r)return;for(const l of r.yExtentComponents){const c=l.regularValueFromY(o),h=l.valueFormatter(c),d=this.canvasBoundsContainer.getBounds(T.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=Zr[a],f=a==="plain"?i.lineColor:i.labelTextColor;u(t,d,h,o,{textColor:f,bgColor:i.labelBoxColor,paddingBottom:s==null?void 0:s.bottom,paddingEnd:s==null?void 0:s.end,paddingTop:s==null?void 0:s.top},l.yAxis.state,this.config.colors.yAxis,!0)}}}}class Wd{draw(){}}class zd extends X{constructor(t,e,s,i,r,o,a,l,c){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=i,this.paneManager=r,this.crossEventProducer=o,this.hoverProducer=a,this.baselineModel=l,this.chartModel=c,this.crossToolTypeDrawers={},this.model=new Rd(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel,this.chartModel),this.addChildEntity(this.model);const h=new ye(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const d=new Md(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),u=new sn;u.addDrawer(h,"CLEAR_CANVAS"),u.addDrawer(d,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(u,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new Kr(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new Kr(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Wd)}setVisible(t){this.model.setType(t?"cross-and-labels":"none")}setType(t){this.model.setType(t)}observeCrossToolChanged(){return this.model.currentHoverSubject}setMagnetTarget(t){this.config.components.crossTool.magnetTarget=t}registerCrossToolTypeDrawer(t,e){this.crossToolTypeDrawers[t]=e}}class Vd{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,s])=>{for(const i of s){const{model:r,drawer:o}=i;o.draw(this.canvasModel,r,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class zt{constructor(t){this.data=t,this.next=null}}class Ud{constructor(t){if(this._head=null,this._tail=null,this.length=0,this._head=t!=null?t:null,this.head!==null){let e=this.head;for(;e.next;)e=e.next;this._tail=e,this.length++}}insertAtEnd(t){const e=new zt(t);if(this.head===null)this._head=e;else{let s=this.head;for(;s.next;)s=s.next;s.next=e}this._tail=e,this.length++}insertAt(t,e){if(!this.head||t<0||t>this.length)return null;const s=new zt(e);if(t===0)s.next=this.head,this._head=s;else{let i=this.head,r=i,o=0;for(;i&&o<t;)o++,r=i,i=i.next;s.next=i,r.next=s,t===this.length-1&&(this._tail=s)}this.length++}removeAt(t){if(!this.head||t<0||t>=this.length)return null;let e=this.head,s=e,i=0;if(t===0)this._head=e.next;else{for(;e.next&&i<t;)i++,s=e,e=e.next;s.next=e.next,t===this.length-1&&(this._tail=s)}this.length--}getNodePosition(t){let e=0,s=this.head;for(;s;){if(s.data===t.data)return e;s=s.next,e++}return-1}size(){return this.length}get head(){return this._head}get tail(){return this._tail}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.data,t=t.next}}class Gd extends X{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this._objects=new ut({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new zt(s);return i.getNodePosition(r)}addObject(t){var e,s;const i=t.paneId,r=this.objects,o=(e=r[i])!=null?e:new Ud;Object.keys(r).find(a=>a===i)||(r[i]=o),o.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.uniqueObjects[i]||(this.uniqueObjects[i]=new Set),this.uniqueObjects[i].add((s=t.parentId)!=null?s:t.id),this.setDynamicObjects(r)}removeObject(t){var e;const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new zt(i),a=r.getNodePosition(o);r.removeAt(a),this.modelIdToObjectMap.delete(t),this.uniqueObjects[i.paneId]&&this.uniqueObjects[i.paneId].delete((e=i.parentId)!=null?e:i.id),r.size()===0&&delete this.objects[i.paneId],this.setDynamicObjects(this.objects)}updateObject(t){const e=this.getObjectInfoById(t.id);if(!e)return;const[s]=e;this.removeObject(s.id),this.addObject(t)}moveToPosition(t,e){const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new zt(i),a=r.getNodePosition(o);a!==e&&(a<e?(r.insertAt(e,i),r.removeAt(a)):(r.removeAt(a),r.insertAt(e,i)),this.setDynamicObjects(this.objects))}bringToFront(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>=0&&o<i.size()&&(i.removeAt(o),i.insertAtEnd(s),this.setDynamicObjects(this.objects))}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>0&&o<=i.size()&&(i.removeAt(o),i.insertAt(0,s),this.setDynamicObjects(this.objects))}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>=0&&o+1<i.size()&&(i.removeAt(o),i.insertAt(o+1,s),this.setDynamicObjects(this.objects))}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>0&&o<i.size()&&(i.removeAt(o),i.insertAt(o-1,s),this.setDynamicObjects(this.objects))}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Zd extends X{constructor(t,e){super();const s=new Gd(t);this.model=s,this.addChildEntity(s);const i=new Vd(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const $d=()=>n=>n.toString(),Kd=(n,t)=>{var e;const s="date.get"+(t((e=n.timezone)!=null?e:"")?"":"UTC"),i={YYYY:r("FullYear"),YY:r("FullYear")+" % 100",MMM:o("shortMonths","Month"),MMMM:a(o("shortMonths","Month")),M:"1+"+r("Month"),d:r("Date"),H:r("Hours"),m:r("Minutes"),s:r("Seconds"),sss:r("Milliseconds"),EEE:o("shortDays","Day"),SSS:"this.addTwoZeros("+r("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(l){i[l+l]="this.addZero("+i[l]+")"});function r(l){return s+l+"()"}function o(l,c){return"this."+l+"["+r(c)+"]"}function a(l){return l+".toUpperCase()"}return function(l){var c;const h={shortDays:qd(n),shortMonths:Jd(n),addZero(d){return d<10?"0"+d:d},addTwoZeros(d){return(d<100?"0":"")+(d<10?"0":"")+d},tzDate:t((c=n.timezone)!=null?c:"")||function(d){return new Date(+d)}};return d=>Qd(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function qd(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function Jd(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const qr=(n,t,e)=>{if(n){if(typeof n=="string")return e(n);if(Array.isArray(n)){const s=n.filter(i=>{if(i.showWhen){const r=[];return i.showWhen.periodLessThen&&r.push(()=>{var o,a;return t<((a=(o=i.showWhen)==null?void 0:o.periodLessThen)!=null?a:0)}),i.showWhen.periodMoreThen&&r.push(()=>{var o,a;return t>=((a=(o=i.showWhen)==null?void 0:o.periodMoreThen)!=null?a:0)}),r.every(o=>o())}else return!0});if(s.length>0){const i=s[0];if(i.format)return e(i.format);if(i.customFormatter)return i.customFormatter}}}return $d()},Qd=(n,t,e,s)=>{t||(t="M/d/yyyy");const i=n.getDate(),r=n.getMonth(),o=n.getFullYear(),a=n.getHours(),l=n.getMinutes(),c=n.getSeconds(),h=n.getMilliseconds(),d=a%12,u=we(d),f=we(a),p=we(l),v=we(c),x=a<12?"AM":"PM",_=e[n.getDay()],A=_.substring(0,3),L=we(i),Y=r+1,F=we(Y),R=s[r],k=R.substring(0,3),q=o+"",W=q.substring(2,4);return t=t.replace("hh",u+"").replace("h",d+"").replace("HH",f+"").replace("H",a+"").replace("mm",p+"").replace("m",l+"").replace("ss",v+"").replace("s",c+"").replace("S",h+"").replace("dd",L+"").replace("d",i+"").replace("EEEE",_).replace("EEE",A).replace("YYYY",q).replace("yyyy",q).replace("YY",W).replace("yy",W).replace("aaa",x),t.indexOf("MMM")>-1?t=t.replace("MMMM",R).replace("MMM",k):t=t.replace("MM",F+"").replace("M",Y+""),t},we=n=>typeof n=="number"&&n<10?"0"+n:n,je=(n,t)=>`${n}_${t}`,tu=(n,t)=>{if(t){const e=Jr(t.normal),s=Jr(t.hover);return{type:n,normal:e,hover:s}}},Jr=n=>{var t;const s=new DOMParser().parseFromString(n,"text/html").querySelector("svg");let i=0;s&&(i=parseInt((t=s.getAttribute("height"))!=null?t:"",10));const a="data:image/svg+xml;base64,"+btoa(n),l=new Image;return l.src=a,{img:l,svgHeight:i}},eu=(n,t,e,s,i)=>{if(i){const r=t[je(s,"hover")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}else{const r=t[je(s,"normal")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}},su={"rhombus-small":4,rhombus:6,"rhombus-large":8},nu=["earnings","dividends","splits","conference-calls"];class iu{constructor(t,e,s,i,r,o){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.formatterProvider=o,this.customIcons={};const a=this.config.components.events.icons;a&&nu.forEach(l=>{const c=tu(l,a[l]);c&&(this.customIcons[je(c.type,"normal")]=c.normal,this.customIcons[je(c.type,"hover")]=c.hover)})}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(T.EVENTS),e=this.canvasBoundsContainer.getBounds(T.ALL_PANES),s=this.canvasModel.ctx;s.save(),this.model.events.filter(i=>this.config.components.events.eventsVisibility[i.type]).forEach(i=>{var r,o,a,l;const c=this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale);if(c>e.x&&c<e.x+e.width){const h=this.config.colors.events[i.type];if(s.strokeStyle=(o=(r=h.line)!=null?r:h.normal)!=null?o:h.color,this.customIcons[je(i.type,"hover")]!==void 0){const d={x:c,y:t.y+t.height/2},u=this.model.hoveredEvent.getValue()===i;eu(s,this.customIcons,d,i.type,u)}else this.drawDefaultEvent(s,c,t,i,h);if(this.model.hoveredEvent.getValue()===i){const d=this.config.components.events.line,u=d&&d[i.type]&&((a=d[i.type])==null?void 0:a.width),f=d&&d[i.type]&&((l=d[i.type])==null?void 0:l.dash);s.lineWidth=u!=null?u:1,s.beginPath(),s.setLineDash(f!=null?f:[]),s.moveTo(c,e.y),s.lineTo(c,t.y+t.height/2),s.stroke(),s.closePath(),this.config.components.xAxis.visible&&this.drawLabel(c,i)}}}),s.restore()}drawDefaultEvent(t,e,s,i,r){var o,a,l;const c=s.y+s.height/2;t.fillStyle=(o=r.normal)!=null?o:r.color,t.lineWidth=1.5;const h=nn(i);t.beginPath(),t.moveTo(e-h,c),t.lineTo(e,c-h),t.lineTo(e+h,c),t.lineTo(e,c+h),t.closePath(),this.model.hoveredEvent.getValue()===i?(t.fillStyle=(a=r.hover)!=null?a:r.color,t.fill()):(t.strokeStyle=(l=r.normal)!=null?l:r.color,t.stroke())}drawLabel(t,e){var s;const i=this.canvasModel.ctx,r=this.canvasBoundsContainer.getBounds(T.X_AXIS),o=this.config.components.xAxis.fontFamily,a=this.config.components.xAxis.fontSize,l=(s=this.config.components.xAxis.padding.top)!=null?s:0,c=r.y+a-1+l;i.font=`${a}px ${o}`;const h=this.formatterProvider()(e.timestamp),d=i.measureText(h).width;i.fillStyle=this.config.colors.xAxis.backgroundColor,i.strokeStyle=this.config.colors.xAxis.backgroundColor,i.fillRect(t-d/2,r.y+1,d,r.height-1),i.fillStyle=this.config.colors.events[e.type].color,i.fillText(h,t-d/2,c)}getCanvasIds(){return[this.canvasModel.canvasId]}}function nn(n){return su[n.style]}const gs=5;class ru{constructor(t,e,s,i,r,o=()=>!0){this.hitTestCanvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.drawPredicate=o}draw(){if(this.drawPredicate()){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(T.EVENTS);t.save(),this.model.events.forEach((s,i)=>{if(!this.config.components.events.eventsVisibility[s.type])return;const o=this.model.events[i-1],a=o&&this.chartModel.candleFromTimestamp(o.timestamp).xCenter(this.chartModel.scale),l=this.chartModel.candleFromTimestamp(s.timestamp).xCenter(this.chartModel.scale);if(l>e.x&&l<e.x+e.width){const c=this.config.colors.events[s.type].color;t.strokeStyle=c,t.fillStyle=c;const h=nn(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+gs)*2;if(a!==void 0){const u=nn(o);if(this.config.components.events.eventsVisibility[o.type]&&a+u>l-d/2){const v=h*2+gs;t.fillRect(a+u,e.y,v,e.height)}else t.fillRect(l-h-gs,e.y,d,e.height)}else t.fillRect(l-h-gs,e.y,d,e.height)}}),t.restore()}}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var ou=Object.defineProperty,Qr=Object.getOwnPropertySymbols,au=Object.prototype.hasOwnProperty,lu=Object.prototype.propertyIsEnumerable,to=(n,t,e)=>t in n?ou(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,cu=(n,t)=>{for(var e in t||(t={}))au.call(t,e)&&to(n,e,t[e]);if(Qr)for(var e of Qr(t))lu.call(t,e)&&to(n,e,t[e]);return n};const eo=317,rn={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999]};class hu extends Tr{constructor(t,e,s,i,r,o,a,l){super(t,e,r,a,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=s,this.canvasBoundsContainer=i,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new B,this.touchStartSubject=new B,this.dblClickSubject=new B,this.rightClickSubject=new B,this.hitTestDrawersPredicateSubject=new ut(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,Mr(this,o),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(Wt(100,Xt,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(dt(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=Ct(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(dt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=Ct(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(dt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mouseup")),o=this.canvasInputListener.observeDbClick(t).subscribe(c=>this.eventHandler(c,"dblclick")),a=this.canvasInputListener.observeContextMenu(t).pipe(dt(()=>cu({},this.canvasInputListener.currentPoint))).subscribe(c=>{this.eventHandler(c,"contextmenu")}),l=this.canvasInputListener.observeWheel(t).subscribe(c=>setTimeout(()=>this.eventHandler(c,"zoom"),0));this.eventsSubscriptions.push(e,i,o,a,l,s,r)}}disableUserControls(){this.eventsSubscriptions.forEach(t=>t.unsubscribe()),this.eventsSubscriptions=[]}addSubscriber(t){this.hitTestSubscribers.push(t)}removeSubscriber(t){this.hitTestSubscribers=this.hitTestSubscribers.filter(e=>e===t)}idToColor(t){const e=(t*eo).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/eo}observeHoverOnElement(){return this.hoverSubject.asObservable()}observeTouchStartOnElement(){return this.touchStartSubject.asObservable()}observeDblClickOnElement(){return this.dblClickSubject.asObservable()}observeRightClickOnElement(){return this.rightClickSubject.asObservable()}getPixel(t,e){const s=window.devicePixelRatio;return this.prevAnimationFrameId!==Os&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=Os),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),s=this.colorToId(e[0]*65536+e[1]*256+e[2]),i=Number(s),[r]=on(this.hitTestSubscribers,i);return r==null?void 0:r.lookup(s)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const s=this.getPixel(t.x,t.y),i=this.colorToId(s[0]*65536+s[1]*256+s[2]),r=Number(i),[o]=on(this.hitTestSubscribers,r),a=o==null?void 0:o.lookup(i);return(e=o==null?void 0:o.resolveCursor)==null?void 0:e.call(o,t,a)}eventHandler(t,e){var s,i,r,o,a,l,c;const h=this.getPixel(t.x,t.y),d=this.colorToId(h[0]*65536+h[1]*256+h[2]),u=Number(d),[f,p]=on(this.hitTestSubscribers,u),v=f==null?void 0:f.lookup(d),x={point:t,model:v};switch(e){case"mousedown":v&&((s=f==null?void 0:f.onMouseDown)==null||s.call(f,v,t)),p.forEach(_=>_.onMouseDown&&_.onMouseDown(null,t));break;case"mouseup":v&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,v,t)),p.forEach(_=>_.onMouseUp&&_.onMouseUp(null,t));break;case"hover":v&&((r=f==null?void 0:f.onHover)==null||r.call(f,v,t)),p.forEach(_=>_.onHover&&_.onHover(null,t)),this.hoverSubject.next(x);break;case"touchstart":v&&((o=f==null?void 0:f.onTouchStart)==null||o.call(f,v,t)),p.forEach(_=>_.onTouchStart&&_.onTouchStart(null,t)),this.touchStartSubject.next(x);break;case"dblclick":v&&((a=f==null?void 0:f.onDblClick)==null||a.call(f,v,t)),this.dblClickSubject.next(x);break;case"contextmenu":v&&((l=f==null?void 0:f.onRightClick)==null||l.call(f,v,t)),this.rightClickSubject.next(x);break;case"zoom":v&&((c=f==null?void 0:f.onZoom)==null||c.call(f,v,t)),p.forEach(_=>_.onZoom&&_.onZoom(null,t));break;default:break}}}const on=(n,t)=>{let e;const s=[];return n.forEach(i=>{const[r,o]=i.getIdRange();t>=r&&t<=o?e=i:s.push(i)}),[e,s]};var du=Object.defineProperty,uu=Object.defineProperties,fu=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,gu=Object.prototype.hasOwnProperty,pu=Object.prototype.propertyIsEnumerable,no=(n,t,e)=>t in n?du(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mu=(n,t)=>{for(var e in t||(t={}))gu.call(t,e)&&no(n,e,t[e]);if(so)for(var e of so(t))pu.call(t,e)&&no(n,e,t[e]);return n},vu=(n,t)=>uu(n,fu(t));class bu extends X{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ut(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>vu(mu({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return rn.EVENTS}lookup(t){return this.events.filter(e=>e.id===t)[0]}onHover(t,e){this.hoveredEvent.getValue()!==t&&(t&&(t.point=e),this.hoveredEvent.next(t),this.canvasModel.fireDraw())}onTouchStart(t,e){this.onHover(t,e)}}class Cu extends X{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>qr(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new bu(e);this.eventsModel=c,this.addChildEntity(c),s.addSubscriber(c);const h=new iu(e,i,t,r,c,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(h,"EVENTS");const d=new ru(s,i,t,r,c,()=>s.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(d,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(T.EVENTS,t.components.events.cursor)}setEvents(t){this.eventsModel.setEvents(t),this.canvasModel.fireDraw()}setVisible(t){this.config.components.events.visible=t,this.canvasBoundsContainer.recalculateBounds(),this.canvasModel.fireDraw()}setEventTypeVisible(t){Mt(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class yu{constructor(t,e,s,i,r,o,a,l,c=()=>!0,h,d,u){this.canvasModel=t,this.viewportModel=e,this.config=s,this.yAxisState=i,this.xBoundsProvider=r,this.yBoundsProvider=o,this.xLabelsProvider=a,this.yLabelsProvider=l,this.drawPredicate=c,this.extentIdx=h,this.getBaseline=d,this.mainExtentIdx=u}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;oe(t,()=>this.drawVertical(t)),oe(t,()=>this.drawHorizontal(t)),oe(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.extentIdx===0&&this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const s=this.xBoundsProvider(),i=ot(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(s.x,i),t.lineTo(s.x+s.width,i),t.stroke(),t.closePath()}}drawVertical(t){const e=this.xLabelsProvider();if(e.length&&this.config.components.grid.vertical){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.xBoundsProvider(),i=s.x+s.width;for(const r of e){const o=At(this.viewportModel.toX(r.value));o>s.x&&o<i&&(t.beginPath(),t.moveTo(o,s.y),t.lineTo(o,s.y+s.height),t.stroke())}}}drawHorizontal(t){const e=this.yLabelsProvider();if(e.length>0&&this.config.components.grid.horizontal&&this.extentIdx===this.mainExtentIdx){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.yBoundsProvider();for(const i of e){const r=ot(this.viewportModel.toY(i.value)),o=jd(i.text,t,It);r>s.y+o&&r<s.y+s.height-o&&(t.beginPath(),t.moveTo(s.x,r),t.lineTo(s.x+s.width,r),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class io extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new yu(t,e,s,i,a,l,c,h,f,d,u,p)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class wu{constructor(t,e,s,i){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+s,a=r+i,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,o,t,"high"),this.drawMarkerLabel(l,a,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,i){const r=this.getMarkerY(t,s,i==="low"),o=Qe(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(s,i),c=this.getMarkerX(t,e,l);t.fillStyle=i==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(l,c,r);const h=this.canvasBoundsContainer.getBounds("PANE_CHART");$t(t,h)}getMarkerText(t,e){const s=this.chartModel.pane.regularFormatter(t);return`${e==="high"?this.config.components.highLow.prefix.high:this.config.components.highLow.prefix.low} ${s}`}getMarkerY(t,e,s=!1){const i=this.chartModel.toY(e);if(s){const r=Qe(t,!1);return i+r}return i}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(T.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,s){let i=this.chartModel.toX(e);const r=this.canvasBoundsContainer.getBounds(T.CHART),o=4,a=t.measureText(s).width;return i+o+a>r.width&&(i=i-(o+a)),i+o}getCanvasIds(){return[this.canvasModel.canvasId]}}class Su extends X{constructor(t,e,s,i,r){super();const o=new wu(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const xu=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],_u=1440*60*1e3;class Pu extends X{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new B}activate(){this.addRxSubscription(this.chartModel.scale.xChanged.subscribe(()=>this.highlights.length&&this.recalculateVisualHighlights()))}getHighlights(){return this.highlights}getVisualHighlights(){return this.visualHighlights}recalculateVisualHighlights(){this.visualHighlights={};const t=this.chartModel.getFirstTimestamp(),e=this.chartModel.getLastTimestamp()+_u;ul(this.highlights,t,e,Tu).forEach(i=>{var r;this.visualHighlights[i.type]||(this.visualHighlights[i.type]=[]),(r=this.visualHighlights[i.type])==null||r.push(i)})}setHighlights(t){this.highlights=t,this.highlights.sort((e,s)=>e.to-s.to),this.highlightsUpdatedSubject.next(this.highlights),this.highlights.length?this.recalculateVisualHighlights():this.visualHighlights={}}observeHighlightsUpdated(){return this.highlightsUpdatedSubject.asObservable()}}const Tu=n=>n.to,qt=[20,10];class Mu{constructor(t,e,s,i,r){this.highlightsModel=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.config=r}draw(){var t,e,s,i;if(this.config.components.highlights.visible){const r=this.chartModel.getCandles(),o=this.canvasModel.ctx,a=this.highlightsModel.getVisualHighlights();if(this.highlightsModel.getHighlights().length&&r.length!==0&&this.chartModel.scale.isScaleReady()){const c=this.canvasBoundsContainer.getBounds(T.ALL_PANES);o.save(),$t(o,c);const h=(t=this.config.components.highlights.border.width)!=null?t:1,d=(e=this.config.components.highlights.border.dash)!=null?e:[0,0],u=(s=this.config.components.highlights.fontSize)!=null?s:11,f=(i=this.config.components.highlights.fontFamily)!=null?i:"monospace",p=`${u}px ${f}, monospace`;o.font=p,o.lineWidth=h,o.setLineDash(d),xu.forEach(v=>{var x,_;const A=a[v];if(A){const L=this.config.colors.highlights[v],Y=(x=L==null?void 0:L.border)!=null?x:"#ffffff",F=(_=L==null?void 0:L.background)!=null?_:"#ffffff";o.save(),o.beginPath(),o.fillStyle=F,o.strokeStyle=Y,A.forEach(R=>{var k,q,W;const U=this.chartModel.candleFromTimestamp(R.from),G=pt(U.width,this.chartModel.scale.zoomX),V=U.xStart(this.chartModel.scale),Q=R.to-this.chartModel.chartBaseModel.period,J=this.chartModel.candleFromTimestamp(Q),et=pt(J.width,this.chartModel.scale.zoomX),tt=J.xStart(this.chartModel.scale)+et;if(R.border&&this.drawBorders(R.border,o,V+G,tt-et,c),o.fillRect(V,c.y,tt-V,c.y+c.height),R.label){const st=(k=R.label.text)!=null?k:"",ct=this.config.colors.highlights[R.type];o.save(),o.fillStyle=(q=ct==null?void 0:ct.label)!=null?q:"#ffffff";const at=Tt(st,o,p),[_t,Gt]=this.resolveHighlightLabelPosition((W=R.label.placement)!=null?W:"left-left",c,[V,tt],at);o.fillText(st,_t,Gt),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}resolveHighlightLabelPosition(t,e,s,i){const[r,o]=s;switch(t){case"right-left":return[o-qt[1]-i,e.y+qt[0]];case"left-left":return[r-qt[1]-i,e.y+qt[0]];case"right-right":return[o+qt[1],e.y+qt[0]];case"left-right":default:return[r+qt[1],e.y+qt[0]]}}drawBorders(t,e,s,i,r){const o=t.left,a=t.right;o&&(e.beginPath(),e.moveTo(s,r.y),e.lineTo(s,r.y+r.height),e.stroke(),e.closePath()),a&&(e.beginPath(),e.moveTo(i,r.y),e.lineTo(i,r.y+r.height),e.stroke(),e.closePath())}getCanvasIds(){return[this.canvasModel.canvasId]}}const Au="HIGHLIGHTS_PLUGIN";class Eu extends X{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new Pu(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new Mu(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,Au)}getHighlights(){return this.highlightsModel.getHighlights()}setHighlights(t){this.highlightsModel.setHighlights(t)}setHighlightsVisible(t=!0){this.config.components.highlights.visible=t,this.eventBus.fireDraw(this.highLightsDrawer.getCanvasIds())}observeHighlightsUpdated(){return this.highlightsModel.observeHighlightsUpdated()}}function Iu(){return N(function(n,t){var e,s=!1;n.subscribe(vt(t,function(i){var r=e;e=i,s&&t.next([r,i]),s=!0}))})}function Z(n,t){return N(function(e,s){var i=0;e.subscribe(vt(s,function(r){return n.call(t,r,i++)&&s.next(r)}))})}var Du=Object.defineProperty,Lu=Object.defineProperties,Ou=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,Bu=Object.prototype.hasOwnProperty,Ru=Object.prototype.propertyIsEnumerable,oo=(n,t,e)=>t in n?Du(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ao=(n,t)=>{for(var e in t||(t={}))Bu.call(t,e)&&oo(n,e,t[e]);if(ro)for(var e of ro(t))Ru.call(t,e)&&oo(n,e,t[e]);return n},lo=(n,t)=>Lu(n,Ou(t));const Vt=4;class Fu{constructor(t,e,s,i,r,o){this.config=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.formatterFactory=r,this.visualCandlesProvider=o}draw(){if(this.config.components.navigationMap.visible){const t=this.visualCandlesProvider();if(t.length){const e=this.canvasBoundsContainer.getBounds(T.N_MAP),s=this.canvasBoundsContainer.getBounds(T.N_MAP_BTN_L),i=this.canvasBoundsContainer.getBounds(T.N_MAP_BTN_R),r=this.canvasBoundsContainer.getBounds(T.N_MAP_KNOT_L),o=this.canvasBoundsContainer.getBounds(T.N_MAP_KNOT_R),a=this.canvasBoundsContainer.getBounds(T.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART),c=this.canvasModel.ctx;c.fillStyle=this.config.colors.navigationMap.backgroundColor,c.fillRect(e.x,e.y,e.width,e.height),c.strokeStyle=this.config.colors.paneResizer.lineColor,c.lineWidth=1,c.beginPath(),c.moveTo(e.x,e.y),c.lineTo(e.x+e.width,e.y),c.closePath(),c.stroke(),s.width!==0&&this.drawLeftArrowButton(c,s,this.config),i.width!==0&&this.drawRightArrowButton(c,i,this.config),c.fillStyle=this.config.colors.navigationMap.mapFillColor,c.beginPath(),c.moveTo(l.x,l.y+l.height);for(const h of t)c.lineTo(h[0],h[1]);if(c.lineTo(l.x+l.width,l.y+l.height),c.lineTo(l.x,l.y+l.height),c.closePath(),this.config.colors.navigationMap.mapGradientTopColor&&this.config.colors.navigationMap.mapGradientBottomColor){const h=c.createLinearGradient(l.x,l.y,l.x,l.y+l.height);h.addColorStop(0,this.config.colors.navigationMap.mapGradientTopColor),h.addColorStop(1,this.config.colors.navigationMap.mapGradientBottomColor),c.fillStyle=h}c.fill(),this.config.colors.navigationMap.mapColor&&(c.strokeStyle=this.config.colors.navigationMap.mapColor,c.stroke()),this.drawSlider(c,r,o,s,a),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,s,i){t.x<=s.x+s.width&&(t.x=s.x+s.width,i.x=t.x+t.width,e.x=i.x+i.width)}drawSlider(t,e,s,i,r){this.blockDrawSliderOnLeftArrow(e,s,i,r),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,s,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(r.x,r.y,r.width,r.height)}drawLeftArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Vt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r),t.lineTo(i+Vt,r+Vt),t.lineTo(i+Vt,r-Vt),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawRightArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Vt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r-Vt),t.lineTo(i,r+Vt),t.lineTo(i+Vt,r),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,s,i){const r=s.components.navigationMap.knots.border;t.fillStyle=s.colors.navigationMap.knotColor;const o=i?e.x-r:e.x+r;t.fillRect(o,e.y,e.width,e.height),t.lineWidth=s.components.navigationMap.knots.lineWidth,r>0&&(t.beginPath(),t.moveTo(o,e.y),t.lineTo(o,e.y+e.height),t.lineTo(o+e.width,e.y+e.height),t.lineTo(o+e.width,e.y),t.lineTo(o,e.y),t.lineWidth=r,t.strokeStyle=s.colors.navigationMap.knotBorderColor,t.stroke()),t.beginPath(),t.moveTo(o+e.width/2,e.y+e.height/4),t.lineTo(o+e.width/2,e.y+3*e.height/4),t.strokeStyle=s.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=gt(this.chartModel.mainCandleSeries.getSeriesInViewport()),s=this.config.components.navigationMap.timeLabels,i=s.visible;if(e.length&&i){const r=e[0].candle.timestamp,o=e[e.length-1].candle.timestamp,a=this.canvasBoundsContainer.getBounds(T.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(T.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:s.fontFamily,textSize:`${s.fontSize}px`},d={dateFormat:s.dateFormat,padding:s.padding,textProperties:lo(ao({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:lo(ao({},h),{textAlign:"right"})};this.drawTimeLabel(t,a,r,d),this.drawTimeLabel(t,l,o,u)}}drawTimeLabel(t,e,s,i){const r=i.padding,o=hi(s,i.dateFormat,this.formatterFactory);ai(t,i.textProperties);const a=Qe(t),l=ci(o);gl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}class Ye extends Ir{constructor(t,e,s,i,r=Er){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeXDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeXDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const co=4;class Hu extends X{constructor(t,e,s,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART);this.leftKnotDragStartXRelative=f.x-p.x-co},this.leftKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART).width,_=(this.leftKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.leftRatio=_,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART);this.rightKnotDragStartXRelative=f.x-p.x+co},this.rightKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART).width,_=(this.rightKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.rightRatio=_,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=f=>{const{delta:p}=f,v=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART),x=this.chartModel.mainCandleSeries.meanCandleWidth/(v.width/this.chartModel.mainCandleSeries.dataPoints.length),_=(this.lastMousePosition-p)*x;this.scale.moveXStart(this.scale.xStart-_),this.lastMousePosition=p};const a=this.canvasBoundsContainer.getBoundsHitTest(T.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(T.N_MAP_KNOT_R),c=new Ye(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Ye(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(T.N_MAP_SLIDER_WINDOW),u=new Ye(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(T.N_MAP_BTN_L);this.addRxSubscription(this.canvasInputListeners.observeClick(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)}));const e=this.canvasBoundsContainer.getBoundsHitTest(T.N_MAP_BTN_R);this.addRxSubscription(this.canvasInputListeners.observeClick(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>{const s=this.chartModel.mainCandleSeries;this.canvasBoundsContainer.leftRatio=s.dataIdxStart/(s.dataPoints.length-1),this.canvasBoundsContainer.rightRatio=s.dataIdxEnd/(s.dataPoints.length-1),this.canvasBoundsContainer.recalculateNavigationMapElementBounds(),this.bus.fireDraw()}))}}class ku extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new Fu(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,T.N_MAP_CHART),this.navigationMapMoveHandler=new Hu(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(T.N_MAP_CHART,i.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(T.N_MAP_BTN_L,i.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(T.N_MAP_BTN_R,i.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(T.N_MAP_KNOT_L,i.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(T.N_MAP_KNOT_R,i.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(T.N_MAP_SLIDER_WINDOW,i.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(Ct(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(T.N_MAP),this.chartModel.scale.xChanged.pipe(Iu(),Z(([t,e])=>{const i=t.start<0||t.end>0,r=e.start<0||e.end>0;return i&&!r||r}))).subscribe(()=>{this.config.components.navigationMap.visible&&(this.visualCandles=this.makeVisualCandles(),this.canvasModel.fireDraw())}))}makeVisualCandles(){var t;const e=this.chartModel.getCandles();if(!e.length)return[];const s=this.chartModel.mainCandleSeries.dataIdxStart,i=this.chartModel.mainCandleSeries.dataIdxEnd,r=Math.round(Math.max(-s,0)),o=Math.max(this.chartModel.getCandlesCountWithRightOffset(),i)+r;let a=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(T.N_MAP_CHART),h=c.width,d=[];let u=0,f,p;for(f=0;f<h;f++)p=ot(f*o/h)-r,p in e?(d[f]=e[p].close,u=(t=d[f])!=null?t:0,a=Math.max(a,u),l=Math.min(l,u)):d[f]=0;return a-=l,d.map((v,x)=>[x+c.x,(a+l-v)*c.height/a+c.y])}setVisible(t=!0){var e;(e=this.config.components)!=null&&e.navigationMap&&(this.config.components.navigationMap.visible=t,this.eventBus.fire(ls),this.canvasModel.fireDraw())}}const ps=()=>{const n=/Mac|iPod|iPhone|iPad/i.test(navigator.userAgent),e=[/Android/i,/webOS/i,/BlackBerry/i,/Windows Phone/i].some(s=>navigator.userAgent.match(s));return n?"apple":e?"mobile":"other"},xm=(n,t)=>n==="apple"||n==="mobile"?3:t;var an=Math.pow;class ho extends X{constructor(t,e,s,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=15,this.chartPanningOptions={horizontal:!0,vertical:!0},this.zoomXHandler=(d,u)=>{const f=d.deltaY<0;if(this.config.scale.zoomToCursor){const v=this.canvasBoundsContainer.getBounds(T.CANVAS).width,_=d.offsetX/v;this.scale.zoomXToPercent(_,f,!1,u)}else this.scale.zoomXToEnd(f,u);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(fe),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=d=>{const{delta:u}=d;this.currentPoint.x=u;const f=Ft(u,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-f),this.bus.fireDraw()},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)};const c=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES),h=new Ye(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.horizontal});this.addChildEntity(h)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeWheel(t).pipe(Z(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),Wt(this.wheelThrottleTime,Xt,{trailing:!0,leading:!0})).subscribe(e=>{const s=ps(),i=s==="apple"||s==="mobile"?-1:1,r=0+e.deltaX*i,o=0+e.deltaY*i;if(e.ctrlKey){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw();return}if(o!==0&&Math.abs(o)>Math.abs(r)){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw()}if(r!==0&&Math.abs(r)>Math.abs(o)){const a=Ft(r,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-a),this.bus.fireDraw();return}})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e}))}calculateDynamicSesitivity(t,e){const i=Math.max(Math.abs(t.deltaY),Math.abs(t.deltaX)),r=e*i/100;return Za(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(fe),this.currentPoint={x:0,y:0},s=t.yStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},r=l=>{const{delta:c}=l;if(this.currentPoint.y=c,t.state.auto)ju(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const h=Ft(t.state.inverse?-c:c,t.zoomY);t.moveYStart(s+h)}},o=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},a=new ds(e,{onDragTick:r,onDragStart:i,onDragEnd:o},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.vertical});return this.addChildEntity(a),a}}const ju=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=an(an(Math.abs(n.x),2)+an(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},Yu=2;class Nu extends X{constructor(t,e,s,i,r){super(),this.chartAreaPanHandler=t,this.scale=e,this.canvasInputListeners=s,this.mainCanvasParent=i,this.hitTest=r,this.touchedCandleIndexes=[0,0],this.canvasTouchInfo={touchStart:{x:0,y:0},isMoving:!1}}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart(this.hitTest).subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove(this.hitTest).subscribe(t=>this.handleTouchMoveEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(t=>this.handleTouchEndEvent(t)))}handleTouchStartEvent(t){const{clientX:e,clientY:s}=t.touches[0];t.touches.length===1&&(this.canvasTouchInfo.touchStart={x:e,y:s}),t.touches.length===2&&(this.chartAreaPanHandler.deactivate(),this.touchedCandleIndexes=this.getXPositions(t).map(i=>this.scale.fromX(i)))}handleTouchMoveEvent(t){const{clientX:e,clientY:s}=t.touches[0],{touchStart:i}=this.canvasTouchInfo;t.touches.length===1&&(this.canvasTouchInfo.isMoving=uo(e,i.x,s,i.y)),t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}handleTouchEndEvent(t){this.canvasTouchInfo.isMoving=!1,t.touches.length===0&&this.chartAreaPanHandler.activate()}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),s=[0,0],i=document.body.scrollLeft||document.documentElement.scrollLeft;for(let r=0,o=t.touches.length;r<o;r++){const a=t.touches[r];s[r]=a.pageX-e.left-i}return s}pinchHandler(t,e){const s=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),i=s+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;s>=i||e[0]===e[1]||this.scale.setXScale(s,i)}}const uo=(n,t,e,s,i=Yu)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i,_m={MAX_DIMENSION:2048,MAX_TOTAL_PIXELS:18e5,ZOOM_OPTIMIZED_PIXELS:12e5},Xu=2e6,Wu=24,zu=20,Vu=16,Uu=10,Gu=1e3,Pm=5e4,Tm={MIN:60,LOW:80,MEDIUM:100,HIGH:120,MAX:150};class Zu extends ho{constructor(t,e,s,i,r,o,a,l){super(t,e,s,i,r,o,a,l),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=Fe,this.wheelSubscription=null,this.initFrameId=null,this.isActivated=!1,this.lastWheelTime=0,this.wheelCount=0,this.consecutiveLowWheelEvents=0,this.chartPanningOptions={horizontal:!0,vertical:!0}}doActivate(){this.isActivated||(this.isActivated=!0,super.doActivate(),this.canvasInputListener.initializeRectCache(),this.createWheelSubscription(),this.initFrameId=requestAnimationFrame(()=>{this.bus.fireDraw()}),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:t})=>{this.lastXStart+=t})),this.addRxSubscription(this.bus.observe(ls).pipe(Rr(100)).subscribe(()=>{this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation()})))}createWheelSubscription(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null);const t=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES),e=this.canvasBoundsContainer.getBounds(T.CANVAS),s=e.width*e.height;s>0?s>Xu?this.wheelThrottleTime=Wu:this.wheelThrottleTime=zu:this.wheelThrottleTime=Vu,this.wheelSubscription=this.canvasInputListener.observeWheel(t).pipe(Z(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),Z(i=>ps()==="apple"?Math.abs(i.deltaY)>1||Math.abs(i.deltaX)>1:!0),Wt(this.wheelThrottleTime,Xt,{trailing:!0,leading:!0})).subscribe(i=>{const r=performance.now();this.lastWheelTime||(this.lastWheelTime=r,this.wheelCount=0),this.wheelCount++,r-this.lastWheelTime>Gu&&(Math.round(this.wheelCount*1e3/(r-this.lastWheelTime))<Uu?(this.consecutiveLowWheelEvents++,this.consecutiveLowWheelEvents>=1&&(this.triggerPerformanceCleanup(),this.consecutiveLowWheelEvents=0)):this.consecutiveLowWheelEvents=0,this.lastWheelTime=r,this.wheelCount=0);const o=ps(),a=o==="apple"||o==="mobile"?-1:1,l=0+i.deltaX*a,c=0+i.deltaY*a;if(i.ctrlKey){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw();return}if(c!==0&&Math.abs(c)>Math.abs(l)){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw()}if(l!==0&&Math.abs(l)>Math.abs(c)){const h=Ft(l,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-h),this.bus.fireDraw();return}}),this.addRxSubscription(this.wheelSubscription)}triggerPerformanceCleanup(){window.dispatchEvent(new Event("resize")),window.gc&&window.gc(),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation(),this.consecutiveLowWheelEvents=0,this.wheelCount=0,this.lastWheelTime=0}doDeactivate(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.isActivated=!1,super.doDeactivate()}}class $u extends X{constructor(t,e,s,i,r,o,a,l,c){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.hitTestCanvasModel=c;const h=[this.eventBus,this.config,this.mainScale,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this,this.hitTestCanvasModel],d=ue?new Zu(...h):new ho(...h);this.chartAreaPanHandler=d,this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new Nu(this.chartAreaPanHandler,this.mainScale,this.canvasInputListener,this.mainCanvasParent,this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES)),this.addChildEntity(this.mainCanvasTouchHandler)}activateChartPanHandlers(){this.activate()}deactivatePanHandlers(){this.deactivate()}setChartPanningOptions(t,e){this.chartAreaPanHandler.chartPanningOptions={horizontal:t,vertical:e}}}const fo=n=>t=>{const{top:e,bottom:s}=n(),i=t.high-t.low,r=i===0?1:i,o=r*e/100,a=r*s/100,l=t.low-a,c=t.high+o;return{low:l,high:c}},go=(n,t)=>{const e=fo(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function Ku(){return Nn(1)}function po(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Ku()(Ze(n,Ge(n)))}function qu(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n);return N(function(s,i){(e?po(n,s,e):po(n,s)).subscribe(i)})}function Ju(n){return Z(function(t,e){return n<=e})}class Qu{constructor(t,e,s,i,r){this.config=t,this.boundsProvider=e,this.canvasModel=s,this.canvasAnimation=i,this.animationId=r}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),s=this.canvasModel.ctx,i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),r=this.config.components.paneResizer.dragZone;!t&&i&&(s.fillStyle=i.getColor(0),s.fillRect(e.x,e.y-r,e.width,e.height+2*r)),s.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?s.fillRect(e.x,e.y,e.width,e.height):s.fillRect(e.x,e.y-r,e.width,e.height+2*r)}}getCanvasIds(){return[this.canvasModel.canvasId]}}const mo=8;class ln extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=i,this.dragPredicate=r,this.chartPanComponent=o,this.canvasModel=a,this.drawingManager=l,this.canvasInputListener=c,this.canvasAnimation=h,this.config=d,this.canvasBoundsContainer=u,this.hitTestCanvasModel=f,this.initialY=0,this.resizeEvent$=new B,this.onYDragStartMobile=()=>{this.config.components.crossTool.type="none",this.onYDragStart()},this.onYDragStart=()=>{this.initialY=this.boundsProvider().y,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1),this.chartPanComponent.deactivatePanHandlers()},this.onYDragEndMobile=()=>{this.config.components.crossTool.type="cross-and-labels",this.onYDragEnd()},this.onYDragEnd=()=>{this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0),this.chartPanComponent.activateChartPanHandlers()},this.onYDragTick=p=>{const{delta:v,draggedPixels:x}=p;Math.abs(this.initialY-this.boundsProvider().y+x)>=0&&(this.dragTickCb(v),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new ds(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:jt()?this.onYDragStartMobile:this.onYDragStart,onDragEnd:jt()?this.onYDragEndMobile:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:this.dragPredicate});this.addChildEntity(s),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(qu(!1),Z(this.dragPredicate),Et(),Ju(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Qu(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,Ar.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(Ar.paneResizer(this.id)))}doDeactivate(){super.doDeactivate(),this.resizeEvent$.complete()}handleHoverAnimation(t){let e;this.config.animation.paneResizer.bgMode?(e=this.canvasAnimation.getColorAlphaAnimation(this.animationId),(!e||!e.animationInProgress)&&this.canvasAnimation.startColorAlphaAnimation(this.animationId,[{color:this.config.colors.paneResizer.bgHoverColor,type:t}])):(e=this.canvasAnimation.getColorTransitionAnimation(this.animationId),(!e||!e.animationInProgress)&&this.canvasAnimation.startColorTransitionAnimation(this.animationId,[{startColor:this.config.colors.paneResizer.bgColor,endColor:this.config.colors.paneResizer.bgHoverColor,type:t}],this.config.animation.paneResizer.duration)),e&&e.animationInProgress&&e.revert()}}const cn=1/32,tf=n=>{const t=Math.floor(n),e=n-t,s=Math.round(e*64),r=Math.floor(s/2).toString().padStart(2,"0");return`${t}'${r}`},vo=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),Mm=n=>!!vo(n),Am=n=>{const t=vo(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*cn;return e+i}return Number(n)},ef=(n,t)=>e=>{let s;if(typeof e=="number")s=e;else if(typeof e=="string")s=Number(e);else return"\u2014";const i=t.treasuryFormat;if(i&&i.enabled)return tf(s);const[r]=n.dataSeries;if(r!==void 0){const o=ve.getPricePrecision(s,r.pricePrecisions);return s.toFixed(o)}return`${s}`},sf=n=>(t,e)=>{const[s]=n.dataSeries;let i=t;const r=e!=null?e:s;r!==void 0&&(i=Gi(t,r.getBaseline()));const o=i.toFixed(ve.DEFAULT_PRECISION).replace("-","\u2212")+" %";return o==="\u22120.00 %"?"0.00 %":o},nf=(n,t)=>({percent:sf(n),regular:ef(n,t)});class rf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:Tc}){super(),this.config=t,this.paneUUID=e,this.idx=s,this.paneComponent=i,this.chartBaseModel=r,this.canvasBoundsContainer=o,this.hitTestController=a,this.dynamicObjectsCanvasModel=l,this.scale=c,this.dragNDrop=d,this.dataSeries=u,this.formatters=f,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(T.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(T.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=p=>p.map(v=>new Oe(this.chartBaseModel.dataFromTimestamp(v.timestamp).centerUnit,v.close)),this.toY=p=>{var v,x;return(x=(v=this.mainDataSeries)==null?void 0:v.view.toY(p))!=null?x:1},this.valueFormatter=(p,v)=>{if(!this.formatters[this.yAxis.getAxisType()])return this.formatters.regular(p);const{regular:x,percent:_,logarithmic:A}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p);case"percent":return _?_(p,v):x(p);case"logarithmic":return A?A(p):x(p);default:return this.regularFormatter(p)}},this.addChildEntity(c),this.setValueFormatters(nf(this,t)),this.yAxis=h(this.valueFormatter.bind(this),()=>this.mainDataSeries),this.addChildEntity(this.yAxis)}doDeactivate(){super.doDeactivate(),this.dataSeries.forEach(t=>{this.paneComponent.seriesRemovedSubject.next(t),t.deactivate()})}getBounds(){return this.scale.getBounds()}getBaseline(){var t,e;return(e=(t=this.mainDataSeries)==null?void 0:t.getBaseline())!=null?e:1}createDataSeries(){const t=new tr(this,yt(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){if(this.dataSeries.add(t),this.dataSeries.size===1)this.mainDataSeries=t;else if(this.paneComponent.yExtentComponents.length>1&&this.paneUUID!==$){this.mainDataSeries=t;const e=Array.from(this.paneComponent.mainExtent.dataSeries);this.paneComponent.mainExtent.mainDataSeries=e[e.length-1]}this.paneComponent.updateView(),this.paneComponent.seriesAddedSubject.next(t)}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView(),this.paneComponent.seriesRemovedSubject.next(t)}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var e,s;return(s=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?s:this.scale.fromY(t)}}const bo=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(n.dataSeries).filter(s=>s.highLowProvider.isHighLowActive()).map(s=>s.highLowProvider.calculateHighLow(t));return dr(e)}});class of{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=rn.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return rn.DATA_SERIES}get allDataSeries(){return Ee(Ee(Object.values(this.panes),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(s=>s.htId===t)}onHover(t){this.allDataSeries.forEach(e=>e.highlighted=e.htId===(t==null?void 0:t.htId)),this.canvasModel.fireDraw()}onMouseDown(t){t&&this.handleYExtentDragStart(t)}onMouseUp(){this.handleYExtentDragEnd()}handleYExtentDragStart(t){Object.values(this.panes).forEach(e=>e.yExtentComponents.forEach(s=>s.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.panes).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}const Ut="#FF00FF";function Em(n,t,e,s){const i=n.yAxis.backgroundColor,r=n.chartAreaTheme.backgroundColor,o=n.chartAreaTheme.backgroundGradientTopColor,a=n.chartAreaTheme.backgroundGradientBottomColor,l=s.align==="left"?o:a,c=n.chartAreaTheme.backgroundMode==="gradient"?l:r,h=i==="transparent"?c:i;return getLabelTextColorByBackgroundColor(h,t,e)}const af=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,lf=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Ut},cf=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Ut},hf=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Ut},df=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Ut},uf=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Ut},ff=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Ut},gf=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Ut},Co=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Ut},pf=()=>(console.warn("Fallback for label default color"),Ut),yo=10;class wo extends X{constructor(t,e,s,i,r,o,a,l){if(super(),this.bus=t,this.config=e,this.scale=i,this.canvasInputListener=r,this.bounds=o,this.hitTest=a,this.hitTestCanvasModel=l,this.yAxisDragEndSubject=new B,this.lastYStart=0,this.lastYEnd=0,this.lastYHeight=0,this.lastYPxHeight=0,this.onYDragStart=()=>{this.scale.haltAnimation(),this.lastYStart=this.scale.yStart,this.lastYEnd=this.scale.yEnd,this.lastYHeight=this.scale.yEnd-this.scale.yStart,this.lastYPxHeight=Math.max(this.bounds.getBounds(T.Y_AXIS).height,Pi),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onYDragTick=c=>{let{delta:h}=c;this.touches&&this.touches.length>1&&(h=Math.min(this.touches[0].clientY,this.touches[1].clientY)===this.touches[0].clientY?h:-h);let d;h<0?d=1/(1+-h/this.lastYPxHeight*(yo-1)):d=1+h/this.lastYPxHeight*(yo-1);const f=(this.lastYHeight*d-this.lastYHeight)/2,p=this.lastYStart-f,v=this.lastYEnd+f;(this.lastYStart!==p||this.lastYEnd!==v)&&(this.scale.setYScale(p,v),this.scale.state.auto=!1,this.bus.fireDraw())},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next(),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>i.autoScale(!0),this.dblTapCallback=()=>i.autoScale(!0),e.customScale){const c=new ds(a,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},r,s,{dragPredicate:()=>s.chartAreaPanHandler.chartPanningOptions.vertical&&e.type!=="percent"});this.addChildEntity(c),this.dragNDropYComponent=c}}isDragging(){return this.dragNDropYComponent?Math.abs(this.dragNDropYComponent.draggedPixels)>0:!1}doActivate(){this.config.customScaleDblClick&&(this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>{this.dblClickCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})))}}class mf{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${yt()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),$n(this.animFrameId,()=>{this.calculatedInThisFrame=!1})),(t=this.cache)!=null?t:this.dataProvider()}forceCalculateOrGet(){return this.invalidate(),this.calculateOrGet()}getLastCachedValue(){return this.cache}updateCacheValue(t){this.cache=t}invalidate(){this.cache=void 0,this.calculatedInThisFrame=!1}}const vf=0,bf=.01;class hn{constructor(t,e,s,i,r=!1,o,a,l=Hs,c=23,h){this.increment=t,this.startEndProvider=e,this.lengthProvider=s,this.valueFormatter=i,this.withZero=r,this.axisTypeProvider=o,this.baseLineProvider=a,this.labelFilter=l,this.singleLabelHeightPixels=c,this.yAxisConfig=h,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new B,this.newGeneratedLabelsSubject=new B,this.lastStart=0,this.lastEnd=0,this.labelsCache=new mf(()=>this.labelFilter(this.doGenerateLabels())),this.treasuryFormat=this.yAxisConfig&&this.yAxisConfig.treasuryFormat}generateRegularLabels(t,e,s){const i=[];this.withZero&&i.push({value:0,text:"0"});let r=ft.roundToNearest(t,s);for(;r<e;){const o=ft.roundToNearest(r,s),a=this.valueFormatter(o);i.push({value:o,text:a}),r=ft.roundDecimal(r+s)}return i}generatePercentLabels(t,e,s){const i=[],r=this.baseLineProvider();let o=ft.roundToNearest(t,s);for(;o<e;){const a=ft.roundToNearest(o,s),l=Zi(a,r),c=this.valueFormatter(l);i.push({value:a,text:c}),o=ft.roundDecimal(o+s)}return i}generateLogarithmLabels(t,e,s){const i=[];let r=ft.roundToNearest(t,s);for(;r<e;){const o=qs(r),a=this.valueFormatter(o);i.push({value:r,text:a}),r=ft.roundDecimal(r+s)}return i}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[s,i]=this.calculateMinMax(),r=this.getAxisStep(s,i,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=r);let o;const a=this.axisTypeProvider();if(a==="logarithmic"?o=this.generateLogarithmLabels(s,i,r):a==="percent"?o=this.generatePercentLabels(s,i,r):o=this.generateRegularLabels(s,i,r),this.lastSingleLabelHeightValue!==r&&this.labelsCache.cache){const l=(t=this.labelsCache.getLastCachedValue())!=null?t:[];this.distanceBetweenLabelsChangeSubject.next([l,o]),this.lastSingleLabelHeightValue=r}return this.newGeneratedLabelsSubject.next(o),o}calculateMinMax(){const[t,e]=this.startEndProvider(),s=this.lengthProvider(),i=hn.getLabelBounds(t,e,s);return[i[0],i[1]]}getAxisStep(t,e,s){const i=e-t,r=s/this.singleLabelHeightPixels,o=this.calculateIncrement(i),a=i/r;return this.calculateAxisStep(a,o)}observeDistanceBetweenLabelsChanged(){return this.distanceBetweenLabelsChangeSubject.asObservable()}observeLabelsChanged(){return this.newGeneratedLabelsSubject.asObservable()}calculateIncrement(t){var e;if(this.increment)return this.increment;if(!isNaN(t)){const s=(e=this.treasuryFormat)!=null&&e.enabled?cn:ve.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(bf)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=qs(e)+t;return $i(i)-e;case"regular":return t}}generateNumericLabels(){const[t,e]=this.startEndProvider();return(t!==this.lastStart||e!==this.lastEnd)&&this.labelsCache.invalidate(),this.lastStart=t,this.lastEnd=e,this.labelsCache.calculateOrGet()}static getLabelBounds(t,e,s){const i=Math.abs((e-t)*(vf/s));return[t-i,e+i]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let s=e,i=e,r=0;for(;s<t&&s>0;)r>=this.gridDistanceMultipliers.length&&(r=0,i*=10),s=i*this.gridDistanceMultipliers[r++];return s}}class Cf extends hn{constructor(t,e,s,i,r=()=>"regular",o=23,a){super(t,()=>[s.yStart,s.yEnd],()=>s.getBounds().height,i,!1,r,()=>{var l,c;return(c=(l=e())==null?void 0:l.getBaseline())!=null?c:1},void 0,o,a),this.dataSeriesProvider=e}getLargestLabel(){var t;return((t=this.labelsCache.getLastCachedValue())!=null?t:[]).reduce((e,s)=>s.text.length>e.length?s.text:e,"")}updateTreasuryFormat(t){this.treasuryFormat=t}calculateIncrement(t){var e,s;const i=this.dataSeriesProvider();if(i){const r=wt(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=kc(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?cn:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function So(n,t,e){var s=j(n)||t||e?{next:n,error:t,complete:e}:n;return s?N(function(i,r){var o;(o=s.subscribe)===null||o===void 0||o.call(s);var a=!0;i.subscribe(vt(r,function(l){var c;(c=s.next)===null||c===void 0||c.call(s,l),r.next(l)},function(){var l;a=!1,(l=s.complete)===null||l===void 0||l.call(s),r.complete()},function(l){var c;a=!1,(c=s.error)===null||c===void 0||c.call(s,l),r.error(l)},function(){var l,c;a&&((l=s.unsubscribe)===null||l===void 0||l.call(s)),(c=s.finalize)===null||c===void 0||c.call(s)}))}):de}class yf extends X{constructor(t,e,s,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${yt()}`}doActivate(){super.doActivate(),this.addRxSubscription(Ct(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(T.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(dt(t=>t.height),Z(t=>Na(t,this.prevYAxisHeight,1.5)),So(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,Pe(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){Pe(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class wf extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new Cf(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new yf(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new uc(e,o,i,s,r,t,()=>this.canvasBoundsContainer.updateYAxisWidths(),h),this.addChildEntity(this.fancyLabelsModel)}doActivate(){const t={getLargestLabel:()=>{var e;return((e=this.labelsGenerator.labelsCache.getLastCachedValue())!=null?e:[]).map(s=>s.text).concat(this.fancyLabelsModel.orderedLabels.flatMap(s=>s.labels).map(s=>s.labelText)).reduce((s,i)=>i.length>s.length?i:s,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class Sf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x){super(),this.eventBus=t,this.config=e,this.mainCanvasModel=s,this.canvasModel=i,this.scale=r,this.canvasInputListeners=o,this.canvasBoundsContainer=a,this.chartPanComponent=l,this.cursors=c,this.paneUUID=u,this.extentIdx=f,this.hitTestCanvasModel=p,this.chartResizeHandler=v,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new B,this.axisAlignSetSubject=new B,this.axisAlignMovedSubject=new B,this.setDblClickCallback=A=>this.yAxisScaleHandler.setDblClickCallback(A),this.setDblTapCallback=A=>this.yAxisScaleHandler.setDblTapCallback(A);const _=x?ie(x):{};this.state=Mt(_,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new wo(t,this.state,l,r,o,a,a.getBoundsHitTest(T.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new wf(this.paneUUID,t,this.state,a,i,r,h,d,f,this.chartResizeHandler),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}setExtentIdx(t){this.extentIdx=t,this.model.extentIdx=t,this.yAxisScaleHandler.deactivate(),this.removeChildEntity(this.yAxisScaleHandler),this.yAxisScaleHandler=new wo(this.eventBus,this.state,this.chartPanComponent,this.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.canvasBoundsContainer.getBoundsHitTest(T.PANE_UUID_Y_AXIS(this.paneUUID,t)),this.hitTestCanvasModel),this.addChildEntity(this.yAxisScaleHandler)}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",hf),this.registerLabelColorResolver("bar",lf),this.registerLabelColorResolver("line",cf),this.registerLabelColorResolver("area",df),this.registerLabelColorResolver("scatterPlot",uf),this.registerLabelColorResolver("histogram",ff),this.registerLabelColorResolver("baseline",gf),this.registerLabelColorResolver("trend",Co),this.registerLabelColorResolver("hollow",Co)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(T.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(T.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.cursor)}updateOrderedLabels(t=!1){this.model.fancyLabelsModel.updateLabels(t)}registerLabelColorResolver(t,e){this.labelsColorByChartTypeMap[t]=e}getLabelsColorResolver(t){var e;return(e=this.labelsColorByChartTypeMap[t])!=null?e:pf}registerYAxisLabelsProvider(t,e=ne.MAIN,s=yt()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,s),s}addSimpleYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}updateCustomYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}deleteSimpleYAxisLabel(t){delete this.model.fancyLabelsModel.customLabels[t],this.canvasModel.fireDraw()}getAxisType(){return this.state.type}unregisterYAxisLabelsProvider(t=ne.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(T.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx))}registerYAxisWidthContributor(t){this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t)}setAxisType(t){t!==this.state.type&&(this.state.type=t,this.config.components.yAxis.type=t,this.axisTypeSetSubject.next(t),this.scale.autoScale(!0),this.model.fancyLabelsModel.updateLabels(!0),this.updateCursor(),this.mainCanvasModel.fireDraw())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.axisAlignSetSubject.next(t),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.activate():this.deactivate(),this.model.fancyLabelsModel.updateLabels(),this.model.baseLabelsModel.updateLabels()}isVisible(){return this.state.visible}setLockPriceToBarRatio(t=!1){this.scale.setLockPriceToBarRatio(t)}changeLabelMode(t,e){this.state.labels.settings[t].mode=e,this.model.fancyLabelsModel.updateLabels()}changeLabelAppearance(t,e){this.state.labels.settings[t].type=e,this.model.fancyLabelsModel.updateLabels()}togglePriceScaleInverse(t=!1){this.scale.state.inverse=t,this.scale.inverseY=t,this.model.fancyLabelsModel.updateLabels(),this.scale.scaleInversedSubject.next(t),this.canvasModel.fireDraw()}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}class xf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x,_,A,L,Y){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=i,this.hitTestController=r,this.config=o,this.mainScale=a,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=d,this.cursorHandler=u,this.eventBus=f,this.canvasBoundsContainer=p,this.uuid=v,this.seriesAddedSubject=x,this.seriesRemovedSubject=_,this.hitTestCanvasModel=A,this.chartResizeHandler=L,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new B,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(T.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(R,k)=>this.mainExtent.valueFormatter(R,k);const F=this.createExtentComponent(Y);this.mainExtent=F,this.ht=this.canvasBoundsContainer.getBoundsHitTest(T.PANE_UUID(v),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get dataSeries(){return Ee(this.yExtentComponents,t=>Array.from(t.dataSeries))}get visible(){return this.canvasBoundsContainer.graphsHeightRatio[this.uuid]>0}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(T.PANE_UUID(this.uuid)).pipe(Et(Di)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()}))}toY(t){var e,s;return(s=(e=this.mainExtent.mainDataSeries)==null?void 0:e.view.toY(t))!=null?s:this.scale.toY(t)}createGridComponent(t,e,s,i,r,o){var a,l;const c=T.PANE_UUID(t),h=(l=(a=this.mainExtent)==null?void 0:a.idx)!=null?l:0;return new io(this.mainCanvasModel,s,this.config,i,`PANE_${t}_${e}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(c),()=>this.canvasBoundsContainer.getBounds(c),()=>[],r,e,o,()=>this.config.components.grid.visible,h)}createYPanHandler(t,e){const s=T.PANE_UUID(t),i=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(s));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(i),i.disable()},i]}addCursors(t,e){const s=T.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(s,e.state.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(s)}createExtentComponent(t){var e,s;const i=this.yExtentComponents.length,r=T.PANE_UUID(this.uuid),o=()=>this.canvasBoundsContainer.getBounds(r),a=(e=t==null?void 0:t.scale)!=null?e:new uh(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(v,x)=>new Sf(this.eventBus,this.config,this.mainCanvasModel,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,v,x,this.uuid,i,this.hitTestCanvasModel,this.chartResizeHandler,l),u=new rf(this.config.components.yAxis,this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,d,h);u.addSubscription(c),u.addSubscription(this.addCursors(i,u.yAxis)),t!=null&&t.paneFormatters&&u.setValueFormatters(t.paneFormatters),u.yAxis.togglePriceScaleInverse(t==null?void 0:t.inverse),u.scale.setLockPriceToBarRatio(t==null?void 0:t.lockToPriceRatio),((s=t==null?void 0:t.useDefaultHighLow)!=null?s:!0)&&a.autoScaleModel.setHighLowProvider("default",go(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),bo(u)));const p=this.createGridComponent(this.uuid,u.idx,a,u.yAxis.state,()=>u.yAxis.model.baseLabelsModel.labels,()=>u.toY(u.getBaseline()));return u.addChildEntity(p),u.activate(),this.yExtentComponents.push(u),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next(),u}removeExtentComponents(t){t.forEach(e=>e.disable()),this.yExtentComponents=this.yExtentComponents.filter(e=>!t.map(s=>s.idx).includes(e.idx)),this.yExtentComponents.forEach((e,s)=>{e.yAxis.setExtentIdx(s),e.idx=s,e.yAxis.updateCursor()}),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next()}moveDataSeriesToNewExtentComponent(t,e,s,i="right"){const r=ie(s.yAxis.state),o=ie(s.scale.state),a=Mt(r,this.config.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),l=this.createExtentComponent({initialYAxisState:a,inverse:o.inverse,lockToPriceRatio:o.lockPriceToBarRatio});l.yAxis.setYAxisAlign(i),t.forEach(c=>c.moveToExtent(l)),s.dataSeries.size===0&&e.removeExtentComponents([s])}moveDataSeriesToExistingExtentComponent(t,e,s,i,r){t.forEach(o=>o.moveToExtent(i)),!r&&s.dataSeries.size===0&&e.removeExtentComponents([s]),this.yExtentComponentsChangedSubject.next()}updateView(){this.yExtentComponents.forEach(t=>{t.scale.doAutoScale(),t.yAxis.model.labelsGenerator.generateNumericLabels()}),this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}mergeYExtents(){for(let t=1;t<this.yExtentComponents.length;t++){const e=this.yExtentComponents[t];e.dataSeries.forEach(s=>s.moveToExtent(this.mainExtent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainExtent]}getBounds(){return this.mainExtent.getBounds()}createDataSeries(){var t;return(t=this.mainExtent)==null?void 0:t.createDataSeries()}addDataSeries(t){this.mainExtent.addDataSeries(t),this.updateView()}removeDataSeries(t){this.mainExtent.removeDataSeries(t),this.updateView()}getAxisType(){return"regular"}moveUp(){this.canvasBoundsContainer.movePaneUp(this.uuid)}moveDown(){this.canvasBoundsContainer.movePaneDown(this.uuid)}canMoveUp(){const t=ge(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=wt(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}var _f=Object.defineProperty,Pf=Object.defineProperties,Tf=Object.getOwnPropertyDescriptors,xo=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Af=Object.prototype.propertyIsEnumerable,_o=(n,t,e)=>t in n?_f(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ef=(n,t)=>{for(var e in t||(t={}))Mf.call(t,e)&&_o(n,e,t[e]);if(xo)for(var e of xo(t))Af.call(t,e)&&_o(n,e,t[e]);return n},If=(n,t)=>Pf(n,Tf(t));class Df extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,v,x,_){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=v,this.hitTestCanvasModel=x,this.chartResizeHandler=_,this.panes={},this.paneRemovedSubject=new B,this.paneAddedSubject=new B,this.dataSeriesAddedSubject=new B,this.dataSeriesRemovedSubject=new B,this.hitTestController=new of(this.panes,this.dynamicObjectsCanvasModel);const A=this.createPane($,{useDefaultHighLow:!1,scale:this.mainScale});A.mainExtent.scale.autoScaleModel.setHighLowProvider("series",bo(A.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",fo(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removePaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(T.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone+mo}),s=()=>this.chartBaseModel.mainVisualPoints.length!==0,i=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},r=T.PANE_UUID_RESIZER(t),o=new ln(r,()=>this.canvasBoundsContainer.getBounds(r),e,i,s,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer,this.hitTestCanvasModel);return this.userInputListenerComponents.push(o),o}get yExtents(){return Ee(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(s=>this.canvasBoundsContainer.getBoundsHitTest(T.PANE_UUID(s.uuid))(t.x,t.y))}createPane(t=yt(),e){if(this.panes[t]!==void 0)return this.panes[t];const s=new xf(this.chartBaseModel,this.mainCanvasModel,this.yAxisLabelsCanvasModel,this.dynamicObjectsCanvasModel,this.hitTestController,this.config,this.mainScale,this.drawingManager,this.chartPanComponent,this.canvasInputListener,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,t,this.dataSeriesAddedSubject,this.dataSeriesRemovedSubject,this.hitTestCanvasModel,this.chartResizeHandler,e);return this.config.components.paneResizer.visible&&s.addChildEntity(this.addResizer(t)),s.addSubscription(this.addBounds(t,e==null?void 0:e.order)),s.addSubscription(this.addCursors(t)),s.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,s.ht)),this.panes[t]=s,s.activate(),this.recalculateState(),s.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),s}movePaneUp(t){this.canvasBoundsContainer.movePaneUp(t)}movePaneDown(t){this.canvasBoundsContainer.movePaneDown(t)}canMovePaneUp(t){var e,s;const i=ge(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}canMovePaneDown(t){var e,s;const i=wt(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}removePane(t){const e=this.panes[t];e!==void 0&&(this.paneRemovedSubject.next(e),e.disable(),e.yExtentComponents.forEach(s=>s.disable()),delete this.panes[t],this.recalculateState())}hidePane(t){const e=this.panes[t];if(e===void 0||!e.visible)return;const s=T.PANE_UUID_RESIZER(t),i=this.userInputListenerComponents.find(r=>r instanceof ln&&r.id===s);i==null||i.disable(),this.canvasBoundsContainer.hidePaneBounds(t),this.recalculateState()}showPane(t){const e=this.panes[t],s=T.PANE_UUID_RESIZER(t);if(e===void 0||e.visible)return;const i=this.userInputListenerComponents.find(r=>r instanceof ln&&r.id===s);i==null||i.enable(),this.canvasBoundsContainer.showPaneBounds(t),this.recalculateState()}moveDataSeriesToPane(t,e,s,i){const{paneUUID:r,extent:o,direction:a,align:l,extentIdx:c,isForceKeepPane:h,index:d=0}=i,u=r&&this.panes[r],f=l?If(Ef({},s.yAxis.state),{align:l}):void 0,p=c&&c>0;if(!u){const v=a&&a==="above"?d:d+1,x=this.createPane(r,{order:v,initialYAxisState:f,inverse:s.scale.state.inverse,lockToPriceRatio:s.scale.state.lockPriceToBarRatio});x.moveDataSeriesToExistingExtentComponent(t,e,s,x.mainExtent,h),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid);return}o&&!p?u.moveDataSeriesToExistingExtentComponent(t,e,s,o):u.moveDataSeriesToNewExtentComponent(t,e,s,l!=null?l:s.yAxis.state.align),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid)}addCursors(t,e=this.config.components.chart.cursor){const s=T.PANE_UUID(t),i=T.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone+mo),()=>{this.cursorHandler.removeCursorForCanvasEl(s),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(i)}}recalculateState(){Object.values(this.panes).forEach(t=>t.scale.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])}}class Lf extends X{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,s=this.canvasModel.ctx;if(s){s.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,i,r),s.drawImage(this.elements.mainCanvas,0,0,i,r),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),s.drawImage(this.elements.crossToolCanvas,0,0,i,r),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(s),new Promise((o,a)=>this.elements.snapshotCanvas.toBlob(l=>l?o(l):a("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const Of=(n,t=1)=>{function e(i){let r;const o=Math.pow(10,t);return i=Math.round(i*o)/o,i>=1e-15&&i<1?r=i.toFixed(t).replace(/\.?0+$/,""):r=String(i),r.replace(/(\.[1-9]*)0+$/,(a,l)=>l)}function s(i){let r="";return i<0&&(r="-",i=-i),i<995?r+e(i):i<999995?r+e(i/1e3)+"K":i<999999995?(i=1e3*Math.round(i/1e3),r+e(i/1e6)+"M"):(i=1e6*Math.round(i/1e6),r+e(i/1e9)+"B")}return s(n)},Po=class xs extends X{constructor(t,e,s,i){super(),this.chartComponent=t,this.config=e,this.volumesModel=s,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var t,e;return!((t=this.pane)!=null&&t.scale.isViewportValid())&&((e=this.pane)==null?void 0:e.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var t;return(t=this.pane)==null?void 0:t.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[xs.UUID]===void 0){const e=this.paneManager.createPane(xs.UUID,{paneFormatters:{regular:r=>Of(r,1)},useDefaultHighLow:!1,increment:1});this.pane=e,e.mainExtent.yAxis.setAxisType("regular");const{scale:s}=e,i=go(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);s.autoScaleModel.setHighLowProvider("volumes",i),s.doAutoScale(!0)}}deactiveSeparateVolumes(){this.paneManager.removePane(xs.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};Po.UUID="volumes";let Bf=Po;const ms=.3,Rf=(n,t)=>{const e=t.barTheme[`${n}Color`];return Ot()(e).alpha(ms).toString()},Ff=(n,t)=>{const e=t.volume[`${n}BarColor`];return Ot()(e).alpha(ms).toString()},Hf=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Ot()(e).alpha(ms).toString()},dn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Ot()(e).alpha(ms).toString()},kf=3;class jf{constructor(t,e,s,i,r,o){this.config=t,this.volumesModel=e,this.chartModel=s,this.getViewportModel=i,this.volumesColorByChartTypeMap=r,this.drawPredicate=o,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const s=(e=this.volumesColorByChartTypeMap[t])!=null?e:Ff;this.volumeBarColors.down=s("down",this.config.colors),this.volumeBarColors.up=s("up",this.config.colors),this.volumeBarColors.none=s("none",this.config.colors)}draw(t){if(this.config.components.volumes.visible&&this.drawPredicate()){this.calculateColors(this.config.components.chart.type);const e=t.ctx;e.save();const s=this.getViewportModel().getBounds();$t(e,s),this.drawVolumes(t),e.restore()}}drawLastBar(){this.config.components.volumes.visible}drawVolumes(t){const e=this.volumesModel.volumeMax.getValue();if(e===0)return;const s=gt(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1)),i=this.getViewportModel();s.forEach((r,o)=>{if(r.candle.volume){const a=i.getBounds(),l=a.height,c=s[o+1]!==void 0?At(i.toX(s[o+1].startUnit)):void 0,h=At(i.toX(r.startUnit)),d=c!==void 0?c-h:At(pt(r.width,i.zoomX));if(this.config.components.volumes.showSeparately){const u=At(i.toY(r.candle.volume)),f=Zs(i.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=e/(l/kf),f=Math.max(Zs(pt(r.candle.volume,u)),2),p=At(a.y+l-f);this.drawVolume(t,r,h,p,d,f)}}})}drawVolume(t,e,s,i,r,o){const a=t.ctx,l=i,c=i+o,h=e.name;a.fillStyle=this.volumeBarColors[h],a.strokeStyle=this.volumeBarColors[h],r===0?(a.beginPath(),a.moveTo(s,l),a.lineTo(s,Zs(c)),a.stroke()):a.fillRect(s,i,r,o)}}const Yf=dl(n=>n.candle.volume),To="volumes";class Nf extends X{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=To,this.volumeMax=new ut(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(Ct(this.chartComponent.chartModel.observeCandlesChanged(),this.scale.xChanged).subscribe(()=>this.updateVolumeMax())),this.addRxSubscription(this.chartComponent.chartModel.mainCandleSeries.observeLastVisualCandleChanged().subscribe(()=>this.recalculateLastVisualVolume()))}recalculateLastVisualVolume(){}updateVolumeMax(){var t;this.volumeMax.next((t=ge(Yf(this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport().flat())))!=null?t:0)}}class Xf extends X{constructor(t,e,s,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new ut(!1),this.volumeIsSeparateModeChangedSubject=new ut(!1);const c=new Nf(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new Bf(e,o,c,a),this.volumesDrawer=new jf(o,this.volumesModel,e.chartModel,()=>{var h,d;return this.config.components.volumes.showSeparately&&(d=(h=this.separateVolumes.pane)==null?void 0:h.scale)!=null?d:s},this.volumesColorByChartTypeMap,()=>!0),o.components.volumes.visible&&this.syncVolumesDynamicObject(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(o.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(o.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",dn),this.registerVolumeColorResolver("trend",dn),this.registerVolumeColorResolver("hollow",dn),this.registerVolumeColorResolver("line",Hf),this.registerVolumeColorResolver("bar",Rf)}setShowVolumesSeparatly(t){this.config.components.volumes.showSeparately!==t&&(this.config.components.volumes.showSeparately=t,t?this.separateVolumes.activateSeparateVolumes():this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(t),this.syncVolumesDynamicObject())}doDeactivate(){super.doDeactivate(),this.setVisible(!1)}registerVolumeColorResolver(t,e){this.volumesColorByChartTypeMap[t]=e}setVisible(t=!0){this.config.components.volumes.visible=t,this.volumeVisibilityChangedSubject.next(t),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.syncVolumesDynamicObject(),this.canvasModel.fireDraw()}syncVolumesDynamicObject(){if(!this.config.components.volumes.visible){this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);return}const e=this.config.components.volumes.showSeparately?To:$,s={id:this.volumesModel.id,paneId:e,drawer:this.volumesDrawer,model:this.volumesModel};if(this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1){this.dynamicObjectsComponent.model.addObject(s);return}this.dynamicObjectsComponent.model.updateObject(s)}}class Wf{constructor(t,e,s,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,f=this.canvasBoundsContainer.getBounds(T.PANE_UUID($)),{position:p,offsetY:v,offsetX:x}=this.config.components.waterMark;let _;switch(d?_=d:(u.font=vs(this.config,l),_=u.measureText(a).width,f.width-10<_&&(u.font=zf(this.config,this.canvasBoundsContainer,l,_),_=u.measureText(a).width)),p){case"left-top":return{x:x+f.x,y:v+o+f.y,font:u.font,text:a,color:c};case"left-bottom":return{x:x+f.x,y:f.height-h-v+o+f.y,font:u.font,text:a,color:c};case"center":return{x:f.width/2-_/2+f.x,y:(f.height-h)/2+o+f.y,font:u.font,text:a,color:c}}}}draw(){var t,e,s,i,r,o,a;if((t=this.config.components.waterMark)!=null&&t.visible&&this.config.colors){const{firstRow:l,secondRow:c,thirdRow:h}=this.watermarkDataProvider(),d=this.waterMarkConfigProvider(),u=this.config.colors.waterMarkTheme,f=this.canvasModel.ctx;let p=0,v=0,x=0,_=0,A=0;if(f.save(),d.firstRowFontSize&&l){f.font=vs(this.config,d.firstRowFontSize);const R=f.measureText(l);p=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){f.font=vs(this.config,d.secondRowFontSize);const R=f.measureText(c);v=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,x=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){f.font=vs(this.config,d.thirdRowFontSize);const R=f.measureText(h);_=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,A=(s=d.secondRowBottomPadding)!=null?s:0}const L=(i=d.thirdRowBottomPadding)!=null?i:0,Y=(r=d.logoHeight)!=null?r:0,F=p+v+x+_+A+L+Y;if(l&&this.drawWaterMark(this.getConfig(p,l,d.firstRowFontSize,u.firstRowColor,F)),c&&this.drawWaterMark(this.getConfig(p+x+v,c,d.secondRowFontSize,u.secondRowColor,F)),h&&this.drawWaterMark(this.getConfig(p+x+v+A+_,h,d.thirdRowFontSize,u.thirdRowColor,F)),this.logoImage){const R=this.getConfig(p+x+v+A+_+L,"",d.thirdRowFontSize,u.thirdRowColor,F,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,R.x,R.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}f.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const s=this.canvasModel.ctx;s.font=t.font,s.fillStyle=t.color;const i=t.x,r=t.y;s.fillText(e,i,r)}reset(){}}const zf=(n,t,e,s)=>{const r=((a,l)=>t.getBounds(T.CHART).width/l*a)(e,s);let o;return n.components&&n.components.waterMark&&(o=n.components.waterMark.fontFamily),r+"px "+o},vs=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var Vf=Object.defineProperty,Mo=Object.getOwnPropertySymbols,Uf=Object.prototype.hasOwnProperty,Gf=Object.prototype.propertyIsEnumerable,Ao=(n,t,e)=>t in n?Vf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Eo=(n,t)=>{for(var e in t||(t={}))Uf.call(t,e)&&Ao(n,e,t[e]);if(Mo)for(var e of Mo(t))Gf.call(t,e)&&Ao(n,e,t[e]);return n};class Zf extends X{constructor(t,e,s,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Wf(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(Mt(r.observeBoundsChanged(T.PANE_UUID($)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),a.addDrawerAfter(this.waterMarkDrawer,"WATERMARK","DYNAMIC_OBJECTS")}setWaterMarkVisible(t){this.config.components&&this.config.components.waterMark&&(this.config.components.waterMark.visible=t,this.canvasModel.fireDraw())}setWaterMarkData(t){this.waterMarkData=t,this.canvasModel.fireDraw()}getWaterMarkData(){return this.waterMarkData||{}}setWaterMarkConfig(t){if(!(!t||!this.config.components)){if(!this.config.components.waterMark)this.config.components.waterMark=JSON.parse(JSON.stringify(t));else{const e={};Mt(e,t),Mt(e,this.config.components.waterMark),this.config.components.waterMark=e}this.canvasModel.fireDraw()}}setLogoImage(t){this.waterMarkDrawer.setLogoImage(t)}recalculateTextSize(t,e){const r=d=>.15*Math.log(d)/Math.log(1.5)+1,o=r(t/1920),a=r(e/1080),l=Math.min(o,a),c=l>=0?l:0,h={firstRowFontSize:Math.round(this.config.components.waterMark.firstRowFontSize*c),secondRowFontSize:Math.round(this.config.components.waterMark.secondRowFontSize*c),thirdRowFontSize:Math.round(this.config.components.waterMark.thirdRowFontSize*c)};return Eo(Eo({},this.config.components.waterMark),h)}}const Io={x:4,y:4};function $f(n,t,e,s){var i,r;const o=(i=s.alignType)!=null?i:"middle",{fontSize:a,fontFamily:l,padding:c}=e.components.xAxis,h=e.colors.xAxis,d=(r=c.top)!=null?r:0,u=t.getBounds(T.X_AXIS);n.save(),n.font=`bold ${a}px ${l}`;const p=n.measureText(s.text).width+Io.x*2;let v=0;const x=s.x;switch(o){case"start":v=x-p;break;case"end":v=x;break;case"middle":default:v=x-p/2;break}n.fillStyle=h.backgroundColor,n.strokeStyle=h.backgroundColor,n.fillRect(v,u.y,p,u.height),o!=="middle"&&(n.strokeStyle=s.color,n.beginPath(),n.moveTo(x,u.y),n.lineTo(x,u.y+u.height),n.stroke()),n.fillStyle=s.color;const _=v+Io.x,A=u.y+d+a+Ie/2;n.fillText(s.text,_,A),n.restore()}class Kf{constructor(t,e,s,i){this.config=t,this.canvasModel=e,this.canvasBoundsContainer=s,this.xAxisLabelsModel=i}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{$f(t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},s=this.xAxisLabelsModel.labels.reduce((i,r)=>{if(r.subGroupId!==void 0){let o=i[r.subGroupId];o||(o=[],i[r.subGroupId]=o),o.push(r)}return i},e);Object.keys(s).forEach(i=>{const r=s[i];if(r.length===2){const o=this.canvasBoundsContainer.getBounds(T.X_AXIS);t.fillStyle=Ot().rgb(r[0].color).alpha(.1).toString(),wr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const Im="week-weekday",qf=["second","minute","hour","day","month","year"],Jf=["lessThanSecond"],Qf=n=>qf.some(t=>t===n),tg=n=>n==="week-weekday",eg=n=>Jf.some(t=>t===n),Do=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},un=n=>parseInt(n,10),Lo=n=>{const[t,...e]=n.split("_");if(Qf(t)){const[s]=e,i=Do(s),r=un(s);return{key:t,value:r,exact:i["!"]}}else if(tg(t)){const[s,i]=e,r=Do(s),o=un(s),a=un(i);return{key:t,week:r.$?"$":o,weekday:a}}else return eg(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats in dxchart-lite documentation.`),null)};class bs{constructor(t,e,s,i,r,o=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=s,this.canvasBoundsContainer=i,this.labelsProvider=r,this.drawPredicate=o}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,s=this.config.colors.xAxis,i=this.config.components.xAxis.fontFamily,r=bs.getFontFromConfig(this.config),o=this.config.components.xAxis.fontSize,a=(t=this.config.components.xAxis.padding.top)!=null?t:0;e.save(),e.font=r,e.fillStyle=s.backgroundColor;const l=this.canvasBoundsContainer.getBounds(T.X_AXIS);this.config.components.chart.applyBackgroundToAxes.x||e.fillRect(l.x,l.y,l.width,l.height);const c=this.config.colors.xAxis.labelTextColor,h=this.labelsProvider();this.drawLabels(e,h,l,c,o,i,a+Ie/2),e.restore()}}drawLabels(t,e,s,i,r,o,a){const l=`${r}px ${o}`;t.fillStyle=i;for(const c of e){const h=this.viewportModel.toX(c.value)-Tt(c.text,t,l)/2;if(h<s.x||h>s.width)continue;const d=s.y+r-1+a,u=c.text;t.font=l,t.fillText(u,h,d)}}static getFontFromConfig(t){return`${t.components.xAxis.fontStyle} ${t.components.xAxis.fontSize}px ${t.components.xAxis.fontFamily}`}getCanvasIds(){return[this.canvasModel.canvasId]}}const fn={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Oo=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return fn[n.key]+n.value;case"lessThanSecond":return fn[n.key];case"week-weekday":return fn[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},Bo=n=>{const t={};for(const e of n){const s=t[e.weight];s===void 0?t[e.weight]=[e]:s.push(e)}return t},sg=(n,t)=>{const e=Object.keys(n).map(i=>parseInt(i,10)).sort((i,r)=>r-i);let s=[];for(const i of e){const r=n[i];if(!r)continue;const o=[...s];s=[];const a=o.length,l=r.length;let c=0,h=1/0,d=-1/0;for(let u=0;u<l;u++){const f=r[u],p=f.idx;for(;c<a;){const v=o[c],x=v.idx;if(p>x)c++,s.push(v),d=x,h=1/0;else{h=x;break}}h-p>=t&&p-d>=t&&(s.push(f),d=p)}for(;c<a;)s.push(o[c]),c++}return s},ng=(n,t,e,s,i,r)=>{const o=bs.getFontFromConfig(t),a=Tt(e.text,n,o),l=Tt(s.text,n,o),c=i.toX(e.value)+a/2;return i.toX(s.value)-l/2-c<r};function gn(n){"@babel/helpers - typeof";return gn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gn(n)}function St(n,t){if(t.length<n)throw new TypeError(n+" argument"+(n>1?"s":"")+" required, but only "+t.length+" present")}function xt(n){St(1,arguments);var t=Object.prototype.toString.call(n);return n instanceof Date||gn(n)==="object"&&t==="[object Date]"?new Date(n.getTime()):typeof n=="number"||t==="[object Number]"?new Date(n):((typeof n=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function ig(n){return St(1,arguments),xt(n).getDay()===1}function rg(n){return St(1,arguments),xt(n).getDay()===2}function og(n){return St(1,arguments),xt(n).getDay()===3}function ag(n){return St(1,arguments),xt(n).getDay()===4}function lg(n){return St(1,arguments),xt(n).getDay()===5}function cg(n){return St(1,arguments),xt(n).getDay()===6}function hg(n){return St(1,arguments),xt(n).getDay()===0}function dg(n,t){var e;St(1,arguments);var s=n||{},i=xt(s.start),r=xt(s.end),o=r.getTime();if(!(i.getTime()<=o))throw new RangeError("Invalid interval");var a=[],l=i;l.setHours(0,0,0,0);var c=Number((e=t==null?void 0:t.step)!==null&&e!==void 0?e:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number greater than 1");for(;l.getTime()<=o;)a.push(xt(l)),l.setDate(l.getDate()+c),l.setHours(0,0,0,0);return a}function ug(n){St(1,arguments);var t=xt(n);return t.setDate(1),t.setHours(0,0,0,0),t}function fg(n){St(1,arguments);var t=xt(n),e=t.getMonth();return t.setFullYear(t.getFullYear(),e+1,0),t.setHours(23,59,59,999),t}function Ro(n){St(1,arguments);var t=xt(n);return t.setHours(0,0,0,0),t}function Fo(n,t){St(2,arguments);var e=Ro(n),s=Ro(t);return e.getTime()===s.getTime()}const gg=n=>{switch(n.key){case"lessThanSecond":return bg(n);case"month":return Cg(n);case"second":case"minute":case"hour":case"day":case"year":return yg(n);case"week-weekday":return wg(n);default:return()=>!1}},Jt=(n,t)=>{switch(t){case"lessThanSecond":return n.getMilliseconds();case"month":return n.getMonth();case"second":return n.getSeconds();case"minute":return n.getMinutes();case"hour":return n.getHours();case"day":return n.getDate();case"year":return n.getFullYear();case"week-weekday":return n.getDate()}},pn=n=>(t,e)=>{const s=Jt(t,n),i=Jt(e,n);return s!==i},pg=n=>(t,e)=>{const s=Jt(t,n),i=Jt(e,n);return s>=i},mg={1:ig,2:rg,3:og,4:ag,5:lg,6:cg,7:hg},vg=(n,t,e)=>{var s;const i=dg({start:ug(n),end:fg(n)}),r=(s=mg[e])!=null?s:(()=>!1);if(t==="$"){for(const o of i.reverse())if(r(o))return Fo(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return Fo(n,a);o++}}return!1},Ho=(n,t)=>t===1?n===1:n/t===1,ko=(n,t)=>t===1?!0:n%t===0,bg=n=>(t,e)=>pg(n.key)(t,e),Cg=n=>(t,e)=>{const s=pn(n.key)(t,e),i=n.exact?Ho(Jt(t,n.key)+1,n.value):ko(Jt(t,n.key)+1,n.value);return s&&i},yg=n=>(t,e)=>{const s=pn(n.key)(t,e),i=n.exact?Ho(Jt(t,n.key),n.value):ko(Jt(t,n.key),n.value);return s&&i},wg=n=>(t,e)=>{const s=pn(n.key)(t,e),i=vg(t,n.week,n.weekday);return s&&i},Sg=n=>{switch(n.key){case"second":case"minute":return xg(n.value);case"hour":return _g(n.value);case"day":return Pg(n.value);case"month":return Ag(n.value);case"year":return Eg(n.value);case"week-weekday":const t=Mg(n.week),e=Tg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},xg=n=>n>0&&n<=60,_g=n=>n>0&&n<=24,Pg=n=>n>0&&n<=31,Tg=n=>jo(n)?n>=1&&n<=7:!1,Mg=n=>n==="$"?!0:jo(n)?n>=1&&n<=6:!1,Ag=n=>n>0&&n<=12,Eg=n=>n>0,jo=n=>!isNaN(n)&&isFinite(n),Ig=(n,t,e)=>{var s,i;for(const[r,o]of e)if(o(n,t))return r;return(i=(s=e[e.length-1])==null?void 0:s[0])!=null?i:0};function mn(n,t,e){const s=new Array(n.length);let i=e(0);for(let r=0;r<n.length;r++){const o=n[r],a=e(o.candle.timestamp),l={weight:Ig(a,i,t)};s[r]=l,i=a}return s}const Yo=n=>{const t={},e={};return $s(n).forEach(([s,i])=>{const r=Lo(s),o=r===null?!1:Sg(r);if(r&&o){const a=Oo(r);t[a]=i,e[a]=gg(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class No{constructor(t,e,s,i,r,o,a){this.eventBus=t,this.config=e,this.chartModel=s,this.scale=i,this.timeZoneModel=r,this.canvasModel=o,this.canvasBoundsContainer=a,this.labelsGroupedByWeight={},this.levelsCache={},this.labelCache=new Map,this.weightToTimeFormatMatcherArray=[],this.weightToTimeFormatsDict={},this.extendedLabelsFilterConfig={minute_1:h=>h>=2},this.calculateCoverUpLevel=()=>{const h=this.scale.currentAnimation,d=this.chartModel.mainCandleSeries.meanCandleWidth;if(Object.getOwnPropertyNames(this.labelsGroupedByWeight).length===0)return-1;const u=h!=null&&h.animationInProgress?pt(d,h.animationConfig.targetZoomX):pt(d,this.scale.zoomX);if(!isFinite(u))return-1;const f=this.config.components.xAxis.fontSize,p=Object.values(this.formatsByWeightMap).reduce((x,_)=>Math.max(_.length,x),1),v=f*p;return Math.round(v/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=Yo(this.formatsByWeightMap);this.weightToTimeFormatMatcherArray=Object.entries(c).map(([h,d])=>[parseInt(h,10),d]).sort(([h],[d])=>d-h),this.weightToTimeFormatsDict=l}get labels(){return this.filterLabelsInViewport(this.getLabelsFromChartType())}filterLabelsInViewport(t){const e=this.canvasBoundsContainer.getBounds(T.X_AXIS),s=[];for(const i of t){const r=this.scale.toX(i.value);r<0||r>e.width||s.push(i)}return s}getLabelsFromChartType(){var t,e;const s=(e=(t=this.weightedCache)==null?void 0:t.labels)!=null?e:[];return this.config.components.chart.type==="equivolume"?this.postProcessing(s):s}getVisualCandleAtIndex(t,e,s,i,r){return t>=0&&t<s.length?s[t]:Js(e,s,i,t,r)}getVisualCandlesWithFake(t=[]){const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0)return[];const i=Array.from({length:750}).map((r,o)=>Js(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,e.length+o,this.chartModel.getPeriod()));return[...t,...e,...i]}getViewportCandlesWithFake(){var t;const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0||this.scale.xEnd-this.scale.xStart<=1)return[];const s=this.chartModel.mainCandleSeries.meanCandleWidth,i=this.chartModel.getPeriod(),r=this.chartModel.mainCandleSeries.dataPoints,o=this.canvasBoundsContainer.getBounds(T.CHART),a=0,l=o.width,c=this.scale.fromX(a),h=this.scale.fromX(l);let d=0;if(e.length>0){const L=e[0];d=L.centerUnit-((t=L.candle.idx)!=null?t:0)*s}const u=500,f=500,p=Math.floor((c-d)/s)-u,v=Math.ceil((h-d)/s)+u,x=Math.floor(p/f)*f,_=Math.ceil(v/f)*f,A=[];for(let L=x;L<=_;L++)A.push(this.getVisualCandleAtIndex(L,r,e,s,i));return[...A]}getAllCandlesWithFake(t=[]){return this.config.components.chart.minCandlesOffset?this.getVisualCandlesWithFake(t):this.getViewportCandlesWithFake()}mapWeightedPointsToLabels(t,e){var s;const i=new Array(t.length);for(let r=0;r<t.length;++r){const o=t[r],a=e[r],l=this.weightToTimeFormatsDict[o.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(a.candle.timestamp);i[r]={weight:o.weight,idx:(s=a.candle.idx)!=null?s:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){this.clearLabelCache();const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=Yo(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(s).map(([i,r])=>[parseInt(i,10),r]).sort(([i],[r])=>r-i),this.weightToTimeFormatsDict=e,this.generateLabels()}getLabelsFromCache(t){if(this.levelsCache[t])return this.levelsCache[t]}updateLastLabel(t){const e=this.chartModel.mainCandleSeries.visualPoints[this.chartModel.mainCandleSeries.visualPoints.length-2];if(e){const i=mn([e,t],this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),r=this.mapWeightedPointsToLabels([i[1]],[t]),[o]=r;this.labelsGroupedByWeight=Object.entries(this.labelsGroupedByWeight).reduce((a,[l,c])=>{const h=c.findIndex(u=>u.idx===o.idx);let d=c;if(h!==-1&&(d=c.filter(u=>u.idx!==o.idx)),parseInt(l,10)===o.weight){const u=d.findIndex(f=>f.idx>o.idx);u!==-1?d=[...d.slice(0,u),o,...d.slice(u)]:d.push(o)}return a[l]=d,a},{}),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}}updateHistoryLabels(t){const e=t.concat(this.chartModel.mainCandleSeries.visualPoints[t.length]),s=mn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=Bo(i),o=ie(r);for(const c in this.labelsGroupedByWeight)o[c]===void 0&&(o[c]=this.labelsGroupedByWeight[c]);const a=this.chartModel.mainCandleSeries.visualPoints[t.length-1],l=Object.entries(o).sort(([c],[h])=>parseInt(h,10)-parseInt(c,10)).reduce((c,[h,d])=>{const u=parseInt(h,10),f=this.labelsGroupedByWeight[u];if(u===this.weightToTimeFormatMatcherArray[0][0]&&f.shift(),f){const p=f.map(v=>(v.idx=v.idx+t.length,v.value=a.startUnit+a.width+v.value,v));r[u]?c[h]=d.concat(p):c[h]=p}else c[h]=d;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(t,e=!1){var s;const i=this.getAllCandlesWithFake(t),r=mn(i,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone));let o=[];if(e)for(let a=0;a<i.length;a++){const l=(s=i[a].candle.idx)!=null?s:a,c=i[a].candle.timestamp,h=`${l}_${c}`;let d=this.labelCache.get(h);d||(d=this.mapWeightedPointsToLabels([r[a]],[i[a]])[0],this.labelCache.set(h,d)),o.push(d)}else o=this.mapWeightedPointsToLabels(r,i);this.labelsGroupedByWeight=Bo(o),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}recalculateLabels(){this.recalculateCachedLabels()}recalculateCachedLabels(){const t=this.calculateCoverUpLevel();if(!(t<0)&&(this.weightedCache===void 0||t!==this.weightedCache.coverUpLevel)){const e=this.getLabelsFromCache(t);if(e){this.weightedCache={labels:e,coverUpLevel:t};return}const s=sg(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,t),t);this.levelsCache[t]=s,this.weightedCache={labels:s,coverUpLevel:t},this.eventBus.fireDraw()}}postProcessing(t){var e,s;const i=[];let r=0,o=1;for(;o<=t.length-1;){const a=t[r],l=t[o];ng(this.canvasModel.ctx,this.config,a,l,this.scale,30)?((e=l.weight)!=null?e:0)>((s=a.weight)!=null?s:0)&&(r=o):(i.push(a),r=o,o===t.length-1&&i.push(l)),o++}return i}filterLabelsByExtendedRules(t,e){const s=$s(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=Lo(o);if(l){const c=Oo(l);i[c]=a}}return i},{});return $s(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class Dg extends X{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(cs,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}const Xo=3;class Lg extends X{constructor(t,e,s,i,r,o,a){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=i,this.chartModel=r,this.hitTest=o,this.hitTestCanvasModel=a,this.lastXStart=0,this.lastXEnd=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXEnd=this.scale.xEnd,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const c=this.canvasBoundsContainer.getBounds(T.X_AXIS);this.lastXPxWidth=c.width-this.canvasInputListener.currentPoint.x,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=c=>{let{delta:h}=c;if(!this.touches||this.touches.length===1){const d=this.lastXPxWidth-h;if(d<0)return;const u=this.lastXPxWidth/d,f=this.lastXWidth*u,p=this.lastXStart+(this.lastXWidth-f);this.scale.setXScale(p,this.scale.xEnd);return}if(this.touches.length>1){h=Math.min(this.touches[0].clientX,this.touches[1].clientX)===this.touches[0].clientX?h:-h;let u;h<0?u=1/(1+-h/this.lastXPxWidth*(Xo-1)):u=1+h/this.lastXPxWidth*(Xo-1);const p=(this.lastXWidth*u-this.lastXWidth)/2,v=this.lastXStart-p,x=this.lastXEnd+p;(this.lastXStart!==v||this.lastXEnd!==x)&&this.scale.setXScale(v,x)}},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>r.doBasicScale(),this.dblTapCallback=()=>r.doBasicScale();const l=new Ye(o,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>i.chartAreaPanHandler.chartPanningOptions.horizontal});this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>this.dblClickCallback())),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class Og extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.chartComponent=i,this.scale=r,this.chartResizeHandler=l,this.timeZoneModel=h,this.setDblClickCallback=x=>this.xAxisScaleHandler.setDblClickCallback(x),this.setDblTapCallback=x=>this.xAxisScaleHandler.setDblTapCallback(x);const p=new No(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=p,this.xAxisLabelsModel=new Dg(t,[]);const v=new sn;c.addDrawer(v,"X_AXIS"),this.xAxisDrawer=new bs(e,s,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),v.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Kf(e,s,o,this.xAxisLabelsModel),v.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new Lg(r,a,o,d,this.chartComponent.chartModel,o.getBoundsHitTest(T.X_AXIS),f),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(T.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(Ct(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe(Z(({prependedCandles:t})=>t.length!==0),dt(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;Ml.includes(this.config.components.chart.type)&&((s=(e=this.xAxisLabelsGenerator).updateHistoryLabels)==null||s.call(e,t))})),this.config.components.chart.minCandlesOffset?this.addRxSubscription(Ct(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Wt(50,Xt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.recalculateLabels())):this.addRxSubscription(Ct(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Wt(150,Xt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.generateLabels(void 0,!0))),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(dt(()=>wt(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),Et((t,e)=>{var s,i;return((s=t==null?void 0:t.candle)==null?void 0:s.id)===((i=e==null?void 0:e.candle)==null?void 0:i.id)}),Z(ni)).subscribe(t=>{var e,s;return(s=(e=this.xAxisLabelsGenerator)==null?void 0:e.updateLastLabel)==null?void 0:s.call(e,t)}))}getDrawer(){return this.xAxisDrawer}registerXAxisLabelsProvider(t){this.xAxisLabelsModel.labelProviders.push(t)}setVisible(t){var e;(e=this.config.components)!=null&&e.xAxis&&(this.config.components.xAxis.visible=t,this.eventBus.fireDraw())}setFormatsForLabelsConfig(t){this.xAxisLabelsGenerator instanceof No?this.xAxisLabelsGenerator.setFormatsForLabelsConfig(t):console.error("Format config for x-axis is not available")}isVisible(){var t,e;return(e=(t=this.config.components)==null?void 0:t.xAxis.visible)!=null?e:!1}}var Bg=Object.defineProperty,Wo=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Fg=Object.prototype.propertyIsEnumerable,zo=(n,t,e)=>t in n?Bg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Cs=(n,t)=>{for(var e in t||(t={}))Rg.call(t,e)&&zo(n,e,t[e]);if(Wo)for(var e of Wo(t))Fg.call(t,e)&&zo(n,e,t[e]);return n};class Hg{constructor(t,e,s,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=s&&Cs(Cs({},s),this.getLabelDrawConfig(this.chartModel.mainCandleSeries,!0));if(i){const r={labels:[i]},o=this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];o==null||o(r,this.chartModel.mainCandleSeries),t.push(r)}return this.chartModel.candleSeries.forEach((r,o)=>{if(o===0)return;const a=this.getYAxisVisualLabel(r),l=a&&Cs(Cs({},a),this.getLabelDrawConfig(r,!1));if(l){const c={labels:[l]},h=this.lastCandleLabelsByChartType[r.config.type];h==null||h(c,this.chartModel.mainCandleSeries),t.push(c)}}),t}getYAxisVisualLabel(t){const e=wt(t.dataPoints);if(e){const s=t.view.toY(e.close);if(isFinite(s)){const i=this.yAxisConfig.labels.settings.lastPrice.mode,r=this.yAxisConfig.labels.settings.lastPrice.type;return{y:s,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,t),mode:i,labelType:r,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const s=this.yAxisConfig.labels.settings.lastPrice.type,i=t.colors.labels,{rectLabelTextColor:r="white",rectLabelInvertedTextColor:o="black"}=this.chartConfig.colors.yAxis,a=this.resolveLabelColorFn(t.config.type);if(!i)return{bgColor:"#FFFFFF",textColor:ee("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:af(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ee(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ee(l,r,o),rounded:!0}}}class kg{constructor(t,e,s,i,r,o){this.yAxisLabelsCanvasModel=t,this.yAxisDescriptionsCanvasModel=e,this.backgroundCanvasModel=s,this.canvasBoundsContainer=i,this.fullConfig=r,this.paneManager=o}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx,s=this.yAxisDescriptionsCanvasModel.ctx;this.paneManager.yExtents.forEach(i=>{if(i.yAxis.state.visible){const r=i.getYAxisBounds(),o=this.canvasBoundsContainer.getBounds(T.ALL_PANES),a=i.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(l=>{var c;const h=(c=l.bounds)!=null?c:r;l.labels.forEach(d=>$r(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>$r(t,s,e,r,o,l,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=s[r.subGroupId])!=null?o:[];if(s[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(T.PANE_UUID_Y_AXIS($));e.save(),e.fillStyle=(l=c[0].highlightColor)!=null?l:c[0].bgColor;const[d,u]=c[0].y>c[1].y?[c[1].y,c[0].y]:[c[0].y,c[1].y];wr(e,{x:h.x,y:Ii(d,h)},{x:h.x+h.width-6,y:Ii(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class jg{constructor(t,e,s){this.fullConfig=t,this.canvasModel=e,this.paneManager=s}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const s=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;this.fullConfig.components.chart.applyBackgroundToAxes.y||(r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height));const o=se(e.state),a=Yt(o,r),l=this.getLabelTextColor();r.save(),$t(r,i),this.drawLabels(r,s,i,a,o,l,e),r.restore()}})}drawLabels(t,e,s,i,r,o,a){t.fillStyle=o,t.font=r;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=s.y+c,d=s.y+s.height-c;e.forEach(u=>{const f=a.scale.toY(u.value);f>h&&f<d&&Yg(t,s,u.text,f,i,r,a.state.labelBoxMargin.end,a.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const Yg=(n,t,e,s,i,r,o,a)=>{const l=a==="right"?t.x+t.width-Tt(e,n,r)-o:t.x+o;n.fillText(e,l,s+i/2-1)};class Ng{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&cl.call(s,e)},this.add=(t,e,s)=>(e in this.handlers?t.call(this.handlers[e],s):this.handlers[e]=[s],this.unsub.bind(this,e,s)),this.on=(t,e)=>this.add(this.UNKNOWN_ARR.push,t,e),this.observe=t=>{const e=new B,s=e.next.bind(e),i=e.unsubscribe.bind(e);return this.on(t,s),e.unsubscribe=()=>{this.unsub(t,s),i()},e.asObservable()},this.onPrior=(t,e)=>this.add(this.UNKNOWN_ARR.unshift,t,e),this.off=this.unsub,this.fire=(t,...e)=>{var s;if(!this.muted){const i=(s=this.handlers[t])!=null?s:[];let r;for(r=0,i.length;r<i.length;r++)i[r].apply(null,e)}},this.fireAsync=(t,e)=>{if(!this.muted)return window.setTimeout(this.fire.bind(this,t,e),0)},this.setMuted=t=>{this.muted=t},this.clear=()=>{this.handlers={}}}fireDraw(t){this.fire(cs,t)}}class Xg extends X{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(dt(r=>i.components.chart.highlightActiveCandle?r:void 0),Et()).subscribe(r=>{r&&this.setCandleAsActive(r,t,e)})}setCandleAsActive(t,e,s){if(t.touches.length===1){const i=t.touches.item(0);if(i!==null){const r=this.getTouchXPosition(i,e),o=s.candleFromX(r);o&&s.mainCandleSeries.setActiveCandle(o)}}}getTouchXPosition(t,e){const s=e.getBoundingClientRect(),i=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-s.left-i}}class Wg{constructor(t,e,s,i,r){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${yt()}`,this.canvasResized=new B,this.recentlyResized=!1,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){Pe(this.animFrameId,()=>this.fireUpdates())}fireUpdates(){const t=this.resizerElement.getBoundingClientRect(),e={x:t.x,y:t.y,width:t.width,height:t.height};this.config||(this.frameElement.style.height=this.resizerElement.clientHeight+"px"),(this.previousBCR===void 0||this.isBCRDimensionsDiffer(this.previousBCR,e))&&(this.previousBCR=e,this.recentlyResized=!0,this.canvasModels.forEach(s=>this.previousBCR&&s.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(ls,e),this.bus.fire(cs))}clearResizedFlag(){this.recentlyResized=!1}isBCRDimensionsDiffer(t,e){return t.height!==e.height||t.width!==e.width}unsubscribeAnimationUpdate(){if(this.resizerElement)try{this.elementResizeDetector.unobserve(this.resizerElement)}catch(t){console.warn("ChartResizeHandler.ts, unsubscribeAnimationUpdate failed")}}wasResized(){return this.recentlyResized}}var zg=Array.isArray,Vg=Object.getPrototypeOf,Ug=Object.prototype,Gg=Object.keys;function Zg(n){if(n.length===1){var t=n[0];if(zg(t))return{args:t,keys:null};if($g(t)){var e=Gg(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function $g(n){return n&&typeof n=="object"&&Vg(n)===Ug}var Kg=Array.isArray;function qg(n,t){return Kg(t)?n.apply(void 0,D([],m(t))):n(t)}function Jg(n){return dt(function(t){return qg(n,t)})}function Qg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function tp(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=Ea(n),i=Zg(n),r=i.args,o=i.keys;if(r.length===0)return Ze([],e);var a=new bt(ep(r,e,o?function(l){return Qg(o,l)}:de));return s?a.pipe(Jg(s)):a}function ep(n,t,e){return e===void 0&&(e=de),function(s){Vo(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){Vo(t,function(){var d=Ze(n[h],t),u=!1;d.subscribe(vt(s,function(f){r[h]=f,u||(u=!0,a--),a||s.next(e(r.slice()))},function(){--o||s.complete()}))},s)},c=0;c<i;c++)l(c)},s)}}function Vo(n,t,e){n?kt(e,n,t):t()}class sp extends X{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new ut(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=tp([s,i]).pipe(Z(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}!l&&!jt()&&(this.crossSubject.next(null),r=!0)});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}function np(n,t){return N(function(e,s){var i=null,r=0,o=!1,a=function(){return o&&!i&&s.complete()};e.subscribe(vt(s,function(l){i==null||i.unsubscribe();var c=0,h=r++;Lt(n(l,h)).subscribe(i=vt(s,function(d){return s.next(t?t(l,d,h,c++):d)},function(){i=null,a()}))},function(){o=!0,a()}))})}class ip{constructor(t,e,s,i){this.visualCandle=t,this.price=e,this.priceFormatter=s,this.toY=i}get high(){return this.visualCandle.high}get low(){return this.visualCandle.low}get open(){return this.visualCandle.open}get close(){return this.visualCandle.close}get volume(){return this.visualCandle.candle.volume}get openY(){return this.toY(this.open)}get closeY(){return this.toY(this.close)}get highY(){return this.toY(this.high)}get lowY(){return this.toY(this.low)}get openFormatted(){return this.priceFormatter(this.open)}get closeFormatted(){return this.priceFormatter(this.close)}get highFormatted(){return this.priceFormatter(this.high)}get lowFormatted(){return this.priceFormatter(this.low)}get closestOHLCY(){return this.toY([this.close,this.open,this.high,this.low].sort((t,e)=>Math.abs(t-this.price)-Math.abs(e-this.price))[0])}}class rp{constructor(t){this.chartModel=t}getData(t){const{x:e,y:s}=t,r=this.chartModel.candleFromX(e).idx||0,o=this.chartModel.getVisualCandle(r),a=this.chartModel.priceFromY(s);return o&&new ip(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class op{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof Fr)return;const{x:e}=t,i=this.chartModel.candleFromX(e).idx||0;return this.chartModel.candleSeries.map(o=>{const a=o.dataPoints[i],l=this.chartModel.pane.regularFormatter(a==null?void 0:a.close);return{instrument:o.instrument.symbol,price:l,id:o.id,htId:o.htId}})}}var ap=Object.defineProperty,lp=Object.defineProperties,cp=Object.getOwnPropertyDescriptors,Uo=Object.getOwnPropertySymbols,hp=Object.prototype.hasOwnProperty,dp=Object.prototype.propertyIsEnumerable,Go=(n,t,e)=>t in n?ap(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ne=(n,t)=>{for(var e in t||(t={}))hp.call(t,e)&&Go(n,e,t[e]);if(Uo)for(var e of Uo(t))dp.call(t,e)&&Go(n,e,t[e]);return n},vn=(n,t)=>lp(n,cp(t));class up extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.mainCanvasTouchHandler=c,this.formatterFactory=h,this.hoverSubject=new ut(null),this.longTouchActivatedSubject=new ut(!1),this.xFormatter=()=>"";const d=new rp(this.chartModel),u=new op(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(np(()=>this.scale.initialViewportValidSubject.pipe(Z(Boolean)))).subscribe(()=>{const e=this.chartModel.getLastVisualCandle();e&&this.createAndFireHoverFromCandle(e)})),this.addRxSubscription(this.chartModel.candlesUpdatedSubject.subscribe(()=>{const e=this.chartModel.getLastVisualCandle();this.hover!==null&&e!==void 0&&e.candle.timestamp<=this.hover.timestamp&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?this.hoverSubject.next(null):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(Ct(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter())),this.addRxSubscription(this.canvasInputListener.observeTouchStart().subscribe(e=>{var s;this.crossEventProducer.crossToolTouchInfo.isCommonTap=!0;const{clientX:i,clientY:r}=e.touches[0];if(this.longTouchActivatedSubject.getValue())this.crossEventProducer.crossToolTouchInfo.temp={x:i-this.canvasBoundsContainer.canvasOnPageLocation.x,y:r-this.canvasBoundsContainer.canvasOnPageLocation.y};else{const o=((s=this.paneManager.getPaneIfHit({x:i,y:r}))==null?void 0:s.uuid)||"";this.createAndFireHover([i,r,o])}}));const t=this.canvasBoundsContainer.getBoundsHitTest(T.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{var s;if(this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.mainCanvasTouchHandler.canvasTouchInfo.isMoving||this.chartModel.config.components.crossTool.type==="none"||e.touches.length>1)return;this.longTouchActivatedSubject.next(!0),this.crossEventProducer.crossToolTouchInfo.isSet=!1;const r=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,o=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.crossEventProducer.crossToolTouchInfo.fixed={x:r,y:o};const a=((s=this.paneManager.getPaneIfHit({x:r,y:o}))==null?void 0:s.uuid)||"";this.createAndFireHover([r,o,a]),this.crossEventProducer.crossSubject.next([r,o,a]),this.paneManager.chartPanComponent.setChartPanningOptions(!1,!1)})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(e=>{var s,i;const{clientX:r,clientY:o}=e.changedTouches[0],{fixed:a,temp:l}=this.crossEventProducer.crossToolTouchInfo,c=r-this.canvasBoundsContainer.canvasOnPageLocation.x,h=o-this.canvasBoundsContainer.canvasOnPageLocation.y;if(this.crossEventProducer.crossToolTouchInfo.isCommonTap&&!uo(c,l.x,h,l.y)){this.paneManager.chartPanComponent.setChartPanningOptions(!0,!0),this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose(),this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isSet=!1;return}if(!this.crossEventProducer.crossToolTouchInfo.isSet)this.crossEventProducer.crossToolTouchInfo.isSet=!0,this.crossEventProducer.crossToolTouchInfo.temp={x:this.crossEventProducer.crossToolTouchInfo.fixed.x,y:this.crossEventProducer.crossToolTouchInfo.fixed.y},this.crossEventProducer.crossToolTouchInfo.fixed={x:c,y:h},this.crossEventProducer.crossToolTouchInfo.isSet=!0;else{const d=(i=(s=this.crossEventProducer.crossToolHover)==null?void 0:s.paneId)!=null?i:"CHART",u=this.canvasBoundsContainer.getBounds(T.PANE_UUID(d)),f=u.y+5,p=u.y+u.height-5,v=c-l.x,x=h-l.y,_=a.x<0?0:a.x>u.width?u.width:a.x+=v,A=a.y<f?f:a.y>p?p:a.y+=x;this.crossEventProducer.crossToolTouchInfo.fixed={x:_,y:A}}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=qr(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),s=this.scale.toY(t.close);return this.createHover(e,s,$)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const r=this.chartModel.candleFromX(t,!0).timestamp,o={x:t,y:e,timestamp:r,timeFormatted:this.xFormatter(r),paneId:s},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>vn(Ne({},l),{[c[0]]:c[1].getData(o)}),{});return Ne(Ne({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){const e=this.createHoverFromCandle(t);if(this.hover&&e){const s=vn(Ne({},e),{x:this.hover.x,y:this.hover.y});this.fireHover(s)}}createAndFireHover([t,e,s]){const i=this.createHover(t,e,s);this.fireHover(i)}fireHover(t){var e,s;if(t){if(jt()&&this.config.components.crossTool.type!=="none"){const i=this.crossEventProducer.crossToolHover,r=i?(e=i.candleHover)==null?void 0:e.visualCandle.candle:(s=t.candleHover)==null?void 0:s.visualCandle.candle;r&&this.chartModel.mainCandleSeries.setActiveCandle(r)}this.hoverSubject.next(t)}else this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}registerHoverProducerPart(t,e){this.hoverProducerParts=vn(Ne({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const Zo={left:0,middle:1,right:2};function mt(n,t,e,s){return n.addEventListener(e,t,s),function(){n.removeEventListener(e,t,s)}}function Se(n){return t=>{t.button===Zo.left&&n(t)}}var fp=Object.defineProperty,$o=Object.getOwnPropertySymbols,gp=Object.prototype.hasOwnProperty,pp=Object.prototype.propertyIsEnumerable,Ko=(n,t,e)=>t in n?fp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mp=(n,t)=>{for(var e in t||(t={}))gp.call(t,e)&&Ko(n,e,t[e]);if($o)for(var e of $o(t))pp.call(t,e)&&Ko(n,e,t[e]);return n};const ys=class ce extends X{constructor(t,e){super(),this.eventBus=t,this.element=e,this.xDragStartSubject=new B,this.xDragSubject=new B,this.xDragTickSubject=new B,this.xDragEndSubject=new B,this.yDragStartSubject=new B,this.yDragSubject=new B,this.yDragTickSubject=new B,this.yDragEndSubject=new B,this.mouseMoveSubject=new B,this.mouseMoveDocumentSubject=new B,this.clickSubject=new B,this.clickDocumentSubject=new B,this.dbClickSubject=new B,this.dbTapSubject=new B,this.mouseDownSubject=new B,this.mouseUpSubject=new B,this.mouseUpDocumentSubject=new B,this.wheelSubject=new B,this.touchStartSubject=new B,this.touchStartTimestamp=0,this.touchMoveSubject=new B,this.touchEndSubject=new B,this.touchCancelSubject=new B,this.longTouchStartSubject=new B,this.longTouchEndSubject=new B,this.contextMenuSubject=new B,this.fastTouchScroll=new B,this.mouseLeavesCanvasSubject=new B,this.dragStartPoint={x:0,y:0},this.prevDragPoint={x:0,y:0},this.currentPoint={x:0,y:0},this.currentPointDocument={x:0,y:0},this.dragging=!1,this.canvasBounds={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.cachedElementRect=null,this.rectCacheValid=!1,this.documentDragListeners=[],this.dragProcessListener=()=>{this.xDragSubject.next(this.currentPoint.x-this.dragStartPoint.x),this.yDragSubject.next(this.currentPoint.y-this.dragStartPoint.y),this.xDragTickSubject.next(this.currentPoint.x-this.prevDragPoint.x),this.yDragTickSubject.next(this.currentPoint.y-this.prevDragPoint.y),this.prevDragPoint.x=this.currentPoint.x,this.prevDragPoint.y=this.currentPoint.y},this.dragStartListener=s=>{this.isDraggable(s)&&(this.updateCurrentPoints(s),this.dragging=!0,this.dragStartEvent=s,this.cleanupDocumentDragListeners(),this.dragStartPoint=ce.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=mp({},this.dragStartPoint),ce.DRAG_EVENTS.forEach(i=>{document.addEventListener(i,this.dragProcessListener,!0);const r=document.removeEventListener.bind(document,i,this.dragProcessListener,!0);this.documentDragListeners.push(r),this.addSubscription(r)}),this.dragProcessListener())},this.dragListener=()=>this.mouseMoveDocumentSubject.next(this.currentPoint),this.updateElementOffsetListener=()=>this.mouseMoveSubject.next(this.currentPoint),this.dragEndListener=()=>{this.dragging=!1,this.cleanupDocumentDragListeners(),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=s=>{this.updateCurrentDocumentPoint(s),this.updateCurrentMousePoint(s)}}getElementRect(){if(this.rectCacheValid&&this.cachedElementRect)return this.cachedElementRect;try{if(!this.element||!this.element.isConnected)return this.createFallbackRect();const t=this.element.getBoundingClientRect();return this.cachedElementRect=t,this.rectCacheValid=!0,t}catch(t){return this.createFallbackRect()}}createFallbackRect(){return typeof DOMRect!="undefined"?new DOMRect(0,0,0,0):{x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>({})}}invalidateRectCache(){this.rectCacheValid=!1}initializeRectCache(){this.invalidateRectCache();const t=this.getElementRect();this.canvasBounds.x=t.left,this.canvasBounds.y=t.top,this.canvasBounds.width=t.width,this.canvasBounds.height=t.height}cleanupDocumentDragListeners(){if(!this.documentDragListeners||!Array.isArray(this.documentDragListeners)){this.documentDragListeners=[];return}this.documentDragListeners.forEach(t=>{try{t()}catch(e){console.warn("Error cleaning up drag listener:",e)}}),this.documentDragListeners=[]}doDeactivate(){this.invalidateRectCache(),this.cachedElementRect=null,this.cleanupDocumentDragListeners(),super.doDeactivate()}isDraggable(t){return t instanceof MouseEvent?t.button===Zo.left:t instanceof TouchEvent}startDragging(t){this.updateCurrentPoints(t),this.dragStartListener(t)}movePointer(t){this.updateCurrentPoints(t),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const t=e=>(e.preventDefault(),!1);this.element.addEventListener("selectstart",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",t,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],ce.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),ce.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragListener)),this.element.addEventListener(s,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,s,this.updateElementOffsetListener))}),ce.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(mt(this.element,Se(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(mt(document,Se(s=>this.clickDocumentSubject.next(s)),"click"));const t=ps();if(t==="apple"||t==="mobile"){let s=null;const i=a=>{a.preventDefault(),s?(this.dbTapSubject.next(this.currentPoint),clearTimeout(s),s=null):s=window.setTimeout(()=>{s=null},250)};this.addSubscription(mt(this.element,i,"touchend"));const r=(a,l=200)=>{a.preventDefault();let c=!1,h=null;h=setTimeout(()=>{c=!0,this.longTouchStartSubject.next(a)},l);const d=f=>{f.preventDefault(),f.touches.length>1&&h&&clearTimeout(h)},u=f=>{f.preventDefault(),h&&clearTimeout(h),c&&(c=!1,this.longTouchEndSubject.next(f)),this.element.removeEventListener("touchend",u),this.element.removeEventListener("touchmove",d)};this.element.addEventListener("touchmove",d),this.element.addEventListener("touchend",u)};this.addSubscription(mt(this.element,a=>r(a),"touchstart"));const o=a=>{if(a.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const h=this.touchStartTimestamp,u=Date.now()-h,p=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,v=u<=250;p&&v&&this.fastTouchScroll.next(a)}};this.addSubscription(mt(this.element,o,"touchend"))}this.addSubscription(mt(this.element,Se(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(mt(this.element,s=>{this.touchStartSubject.next(s),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(mt(this.element,s=>this.touchMoveSubject.next(s),"touchmove",!0)),this.addSubscription(mt(this.element,s=>this.touchEndSubject.next(s),"touchend")),this.addSubscription(mt(this.element,s=>this.touchCancelSubject.next(s),"touchcancel")),this.addSubscription(mt(this.element,s=>{this.updateCurrentPoints(s),this.wheelSubject.next(s),s.preventDefault()},"wheel")),this.addSubscription(mt(this.element,s=>this.contextMenuSubject.next(s),"contextmenu")),this.addSubscription(mt(this.element,Se(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(mt(this.element,Se(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(mt(document,Se(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(ls).subscribe(()=>{this.invalidateRectCache();const s=this.getElementRect();this.canvasBounds.x=s.left,this.canvasBounds.y=s.top,this.canvasBounds.width=s.width,this.canvasBounds.height=s.height}));const e=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",e,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",e,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){ce.DRAG_EVENTS.forEach(t=>{document.addEventListener(t,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(t,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(t){"pageX"in t?this.currentPointDocument.x=t.pageX:t.touches!==void 0&&(this.currentPointDocument.x=t.touches[0].pageX),"pageY"in t?this.currentPointDocument.y=t.pageY:t.touches!==void 0&&(this.currentPointDocument.y=t.touches[0].pageY)}updateCurrentMousePoint(t){const e=this.getElementRect();"clientX"in t?this.currentPoint.x=t.clientX-e.left:t.touches!==void 0&&(this.currentPoint.x=t.touches[0].clientX-e.left),"clientY"in t?this.currentPoint.y=t.clientY-e.top:t.touches!==void 0&&(this.currentPoint.y=t.touches[0].clientY-e.top)}static copyPoint(t){return{x:t.x,y:t.y}}observeMouseMove(t=()=>!0){return this.mouseMoveSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe(Z(()=>!this.dragging))}observeMouseMoveDocument(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(Z(()=>t(this.currentPointDocument.x,this.currentPointDocument.y)),dt(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(t=()=>!0){return this.xDragStartSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(t=()=>!0){return this.xDragSubject.pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(t=()=>!0){return this.xDragEndSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(t=()=>!0){return this.yDragStartSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(t=()=>!0){return this.yDragSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(t=()=>!0){return this.yDragEndSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(t=()=>!0,e=!1){const s=this.mouseMoveSubject.asObservable().pipe(Z(()=>!(e&&this.dragging)),dt(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(dt(()=>!1));return Ct(s,i).pipe(Et())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(t=()=>!0){return this.clickSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(t=()=>!0){return this.dbClickSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(t=()=>!0){return this.dbTapSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeWheel(t=()=>!0){return this.wheelSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchStart(t=()=>!0){return this.touchStartSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(t=()=>!0){return this.touchMoveSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(t=()=>!0){return this.mouseDownSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(t=()=>!0){return this.mouseUpSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(t=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(t=()=>!0){return this.contextMenuSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)),So(e=>e.preventDefault()))}observeLongTouchStart(t=()=>!0){return this.longTouchStartSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(t=()=>!0){return this.longTouchEndSubject.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(t=()=>!0){return this.fastTouchScroll.asObservable().pipe(Z(()=>t(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};ys.DRAG_START_EVENTS=["mousedown","touchstart"],ys.DRAG_EVENTS=["mousemove","touchmove"],ys.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];let vp=ys;var bp=(function(n){z(t,n);function t(e,s,i){e===void 0&&(e=1/0),s===void 0&&(s=1/0),i===void 0&&(i=Vs);var r=n.call(this)||this;return r._bufferSize=e,r._windowTime=s,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=s===1/0,r._bufferSize=Math.max(1,e),r._windowTime=Math.max(1,s),r}return t.prototype.next=function(e){var s=this,i=s.isStopped,r=s._buffer,o=s._infiniteTimeWindow,a=s._timestampProvider,l=s._windowTime;i||(r.push(e),!o&&r.push(a.now()+l)),this._trimBuffer(),n.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var s=this._innerSubscribe(e),i=this,r=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!e.closed;l+=r?1:2)e.next(a[l]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,i=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*s;if(s<1/0&&a<r.length&&r.splice(0,r.length-a),!o){for(var l=i.now(),c=0,h=1;h<r.length&&r[h]<=l;h+=2)c=h;c&&r.splice(0,c+1)}},t})(B);const bn={};function Cp(n){return bn[n]||(bn[n]=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),bn[n]}const qo=(n,t=Date.now())=>{const s=Cp(n).format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(s);if(i){const r=Date.UTC(+i[3],+i[1]-1,+i[2],+i[4]%24,+i[5],+i[6]);let o=t;const a=o%1e3;return o-=a>=0?a:1e3+a,r-o}return 0},Jo=60*1e3;class yp{constructor(t){this.config=t,this.timeZoneChangedSubject=new bp,this.currentTzOffset=e=>qo(this.config.timezone,e)+new Date(e).getTimezoneOffset()*Jo,this.formatterCache={},this.dateTimeFormatterFactory=this.initFormatterFactory(this.config.dateFormatter)}setTimeZone(t){this.config.timezone=t,this.formatterCache={},this.timeZoneChangedSubject.next(t)}observeTimeZoneChanged(){return this.timeZoneChangedSubject.asObservable()}initFormatterFactory(t){let e;if(t&&typeof t=="function")e=t;else if(t&&t.createFormatterFunction&&typeof t.createFormatterFunction=="function"){const s=t.createFormatterFunction;e=i=>s(i).bind(t)}else e=Kd(this.config,this.tzOffset);return e}getFormatterFactory(){return this.dateTimeFormatterFactory}getDateTimeFormatter(t){return this.formatterCache[t]===void 0&&(this.formatterCache[t]=this.dateTimeFormatterFactory(t)),this.formatterCache[t]}tzOffset(t){return t?e=>new Date(e+qo(t,e)+new Date(e).getTimezoneOffset()*Jo):e=>new Date(e)}}class wp extends X{constructor(t,e,s){super(),this.hitTestCanvasModel=t,this.canvasAnimation=e,this.eventBus=s}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasAnimation.animationInProgressSubject.subscribe(()=>{const t=this.canvasAnimation.animationInProgressSubject.getValue();this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!t)})),this.addRxSubscription(this.hitTestCanvasModel.hitTestDrawersPredicateSubject.pipe(Et((t,e)=>t!==e&&t===!0&&e===!1)).subscribe(()=>this.eventBus.fireDraw([this.hitTestCanvasModel.canvasId])))}}var Sp=Object.defineProperty,xp=Object.defineProperties,_p=Object.getOwnPropertyDescriptors,Qo=Object.getOwnPropertySymbols,Pp=Object.prototype.hasOwnProperty,Tp=Object.prototype.propertyIsEnumerable,ta=(n,t,e)=>t in n?Sp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mp=(n,t)=>{for(var e in t||(t={}))Pp.call(t,e)&&ta(n,e,t[e]);if(Qo)for(var e of Qo(t))Tp.call(t,e)&&ta(n,e,t[e]);return n},Ap=(n,t)=>xp(n,_p(t));class Ep extends si{constructor(t){super(t),this.animations={},this.animFrameId="animation",this.animationInProgressSubject=new ut(!1),this.microtaskQueued=!1}startViewportMovementAnimation(t,e,s=fe,i){const r=new Jn(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new Kn(Ap(Mp({},i),{duration:i&&i.duration||Ae}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ae,i){const r=new qn({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0,delete this.animations[t]),Object.keys(this.animations).length===0&&this.stopInterval()}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():this.microtaskQueued||(this.microtaskQueued=!0,queueMicrotask(()=>{this.microtaskQueued=!1,this.processAnimation(),this.eventBus.fireDraw()}))}stopInterval(){ja(this.animFrameId),this.microtaskQueued=!1}}class Cn{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;Al(r),this.config=r;const o=$l(r);t.innerHTML="",t.appendChild(o.content),this.id=(s=t.getAttribute("data-id"))!=null?s:"",r.fixedSize&&(t.style.width=r.fixedSize.width+"px",t.style.height=r.fixedSize.height+"px");const a=new yp(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=Kl(t);this.elements=c;const h=new Ng;this.bus=h;const d=new Wg(t,(i=c.chartResizer)!=null?i:t,h,this.canvasModels,r);this.chartResizeHandler=d,d.subscribeResize(),this.components.push(d.unsubscribeAnimationUpdate.bind(d));const u=new Vh(h,d);this.drawingManager=u;const f=Wh(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=ae(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new ye(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const v=ae(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),x=ae(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),_=new zs(r,h,f,l,d);this.canvasBoundsContainer=_;const A=c.mainCanvas.parentElement;if(A===null)throw new Error("Couldn't get main canvas parent");const L=new vp(h,A);this.canvasInputListener=L,this.chartComponents.push(this.canvasInputListener);const Y=[h,c.hitTestCanvas,L,_,u,r,this.canvasModels,c.chartResizer],F=new hu(...Y);this.hitTestCanvasModel=F;const R=new ye(F);u.addDrawer(R,"HIT_TEST_CLEAR");const k=ue?new Ep(h):new si(h);this.canvasAnimation=k;const q=T.PANE_UUID($),W=new Cr(r,()=>_.getBounds(q),k);this.scaleModel=W;const U=ae(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=U,this.cursorHandler=new Ul(c.canvasArea,L,_,F),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new sp(L,_),this.chartComponents.push(this.crossEventProducer);const G=new Ec("candle");this.chartBaseModel=G;const V=new $u(h,W,_,r,k,L,A,G,F);this.chartPanComponent=V,this.chartComponents.push(V),this.userInputListenerComponents.push(V.chartAreaPanHandler);const Q=new wp(F,k,h);this.hitTestComponent=Q,this.chartComponents.push(Q);const J=new Df(G,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,W,_,r,k,L,u,this.cursorHandler,this.crossEventProducer,V,f,v,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=J;const et=this.paneManager.panes[$];this.mainPane=et,this.chartComponents.push(J),this.dynamicObjects=new Zd(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new Td(G,J,h,this.dynamicObjectsCanvasModel,r,W,l,A,_,d);const tt=new cd(this.chartModel,this.dynamicObjectsCanvasModel,r,W,_,u,F,L,U,V,J,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(tt),this.chartComponent=tt;const st=this.chartComponent.chartModel;this.chartModel=st,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),F.addSubscriber(J.hitTestController),this.xAxisComponent=new Og(h,r,f,tt,W,_,L,d,this.drawingManager,a,V,this.cursorHandler,this.hitTestCanvasModel),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const ct=new ye(f);u.addDrawer(ct,"MAIN_CLEAR");const at=new Xg(A,st,L,r);this.chartComponents.push(at),this.watermarkComponent=new Zf(J,st,h,r,_,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const _t=ae(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new Eu(h,r,st,f,_,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(st)),this.navigationMapComponent=new ku(h,st,f,r,L,_,u,l,V,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Gt=new Su(r,this.dynamicObjectsCanvasModel,st,_,u);this.chartComponents.push(Gt),this.initYAxisDrawer(v,x),this.yAxisComponent=et.mainExtent.yAxis;const xe=new Hg(this.chartModel,this.config,et.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(xe,ne.MAIN),this.volumesComponent=new Xf(this.dynamicObjectsCanvasModel,tt,W,_,u,r,J,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const ra=new io(f,W,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(T.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(q),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>[],void 0,void 0,()=>r.components.grid.visible,this.mainPane.mainExtent.idx);this.chartComponents.push(ra),this.hoverProducer=new up(this.crossEventProducer,W,r,st,L,this.canvasBoundsContainer,this.paneManager,a,V.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new zd(r,_t,_,u,J,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel,this.chartModel),this.chartComponents.push(this.crossToolComponent);const oa=ae(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),yn=new Lf(this.elements,oa);this.snapshotComponent=yn,this.chartComponents.push(yn);const Ss=new Cu(r,this.dynamicObjectsCanvasModel,F,st,_,u,l,this.cursorHandler);this.eventsComponent=Ss,this.chartComponents.push(Ss),this.chartComponents.forEach(Xp=>Xp.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=nl(this.components)}initYAxisDrawer(t,e){const s=new sn,i=new ye(t),r=new ye(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new jg(this.config,t,this.paneManager);s.addDrawer(o);const a=new kg(t,e,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);this.drawingManager.addDrawer(a,"Y_AXIS_PRICE_LABELS")}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:s=>e.test(s)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const s in e)s in t?typeof t[s]=="object"&&Cn.mergeConfig(t[s],e[s]):t[s]=e[s];return t}getConfig(){return this.config}disableUserControls(){this.userInputListenerComponents.forEach(t=>t.deactivate()),this.hitTestCanvasModel.disableUserControls()}enableUserControls(){this.userInputListenerComponents.forEach(t=>t.activate()),this.hitTestCanvasModel.enableUserControls()}setGridConfig(t){var e,s,i,r,o;const a=this.config.components.grid;a.visible=(e=t.visible)!=null?e:!1,a.dash=(s=t.dash)!=null?s:[0,0],a.width=(i=t.width)!=null?i:1,a.color=(r=t.color)!=null?r:"#FFFFFF",this.config.colors.chartAreaTheme.gridColor=(o=t.color)!=null?o:"#FFFFFF",this.redraw()}setGridVisible(t){this.config.components&&this.config.components.grid&&(this.config.components.grid.visible=t,this.redraw())}setGridVertical(t){this.config.components.grid.vertical=t,this.redraw()}setGridHorizontal(t){this.config.components.grid.horizontal=t,this.redraw()}redraw(){this.bus.fireDraw()}getOffsets(){return this.config.components&&this.config.components.offsets}setShowCandleBorders(t=!0){this.config.components&&this.config.components.chart&&(this.config.components.chart.showCandlesBorder=t,this.redraw())}setHighLowVisible(t=!0){this.config.components&&this.config.components.highLow&&(this.config.components.highLow.visible=t,this.redraw())}setCrossToolVisible(t="cross-and-labels"){this.config.components&&this.config.components.crossTool&&(this.config.components.crossTool.type=t,this.redraw())}setHighlightsVisible(t=!0){var e;(e=this.config.components)!=null&&e.highlights&&(this.config.components.highlights.visible=t,this.redraw())}setHighlightsData(t){this.highlightsComponent.setHighlights(t)}setColors(t){Mt(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseMove(s).subscribe(e);return()=>i.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,s=!1){const i=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseEnter(i,s).subscribe(e);return()=>r.unsubscribe()}addClickOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeClick(s).subscribe(e);return()=>i.unsubscribe()}addDragEventsListener(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=Ct(this.canvasInputListener.observeYDrag(s),this.canvasInputListener.observeXDrag(s)).subscribe(e);return()=>i.unsubscribe()}registerComponent(t,e){const s=t(this);this.components.push(s),e&&e(s),s.activate()}}class ea extends Cn{constructor(t,e={}){super(t,e),this.yAxis=this.yAxisComponent,this.xAxis=this.xAxisComponent,this.watermark=this.watermarkComponent,this.highlights=this.highlightsComponent,this.events=this.eventsComponent,this.snapshot=this.snapshotComponent,this.crosshair=this.crossToolComponent,this.navigationMap=this.navigationMapComponent,this.volumes=this.volumesComponent,this.cursors=this.cursorHandler,this.data=this.chartComponent,this.scale=this.scaleModel,this.panning=this.chartPanComponent,this.bounds=this.canvasBoundsContainer,this.hover=this.hoverProducer}registerPaneFormatters(t,e){var s;(s=this.paneManager.panes[t])==null||s.setPaneValueFormatters(e)}destroy(){this.bus.setMuted(!0),this.chartComponents.forEach(t=>t.disable()),this.parentElement.childNodes.forEach(t=>t.remove()),this.parentElement.style.width="",this.parentElement.style.height=""}showSeparateVolumes(t=!1){this.volumes&&(this.volumes.setShowVolumesSeparatly(t),this.bounds.updateYAxisWidths())}setData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.setAllSeries(e,s)}else this.chartComponent.setMainSeries(t)}updateData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.updateAllSeries(e,s)}else this.chartComponent.updateAllSeries(t)}setAutoScale(t=!0){this.scale.autoScale(t)}setRtl(t){this.config.rtl=t,this.bus.fireDraw()}setChartType(t){this.data.setChartType(t),this.yAxis.updateOrderedLabels()}setTreasuryFormat(t){this.config.components.yAxis.treasuryFormat=t,this.paneManager.yExtents.forEach(e=>{e.yAxis.model.labelsGenerator.updateTreasuryFormat(t),e.yAxis.model.labelsGenerator.doGenerateLabels(),e.yAxis.model.fancyLabelsModel.updateLabels(!0),e.yAxis.model.baseLabelsModel.updateLabels()})}createPane(){return this.paneManager.createPane()}}var Ip=Object.defineProperty,Dp=Object.defineProperties,Lp=Object.getOwnPropertyDescriptors,sa=Object.getOwnPropertySymbols,Op=Object.prototype.hasOwnProperty,Bp=Object.prototype.propertyIsEnumerable,na=(n,t,e)=>t in n?Ip(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Rp=(n,t)=>{for(var e in t||(t={}))Op.call(t,e)&&na(n,e,t[e]);if(sa)for(var e of sa(t))Bp.call(t,e)&&na(n,e,t[e]);return n},Fp=(n,t)=>Dp(n,Lp(t));function ia(n){n=n||{},n.quantity=n.quantity||200,n.startY=n.startY||50,n.avgCandleSize=n.avgCandleSize||2,n.avgTrendLength=n.avgTrendLength||{},n.avgTrendLength.sw=n.avgTrendLength.sw||10,n.avgTrendLength.down=n.avgTrendLength.down||10,n.avgTrendLength.up=n.avgTrendLength.up||10,n.withVolume=n.withVolume===!0||!1,n.period=n.period||3600;var t=[],e=n.quantity||200,s=10,i=10,r=10;n.avgTrendLength&&(s=n.avgTrendLength.sw||10,i=n.avgTrendLength.down||10,r=n.avgTrendLength.up||10);var o=n.startY||50,a=n.avgCandleSize||2,l=o-a,c=o+a,h=ws(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(jp(t[t.length-1],a,s)):d>3?t=t.concat(Hp(t[t.length-1],a,r)):t=t.concat(kp(t[t.length-1],a,i))}t=t.slice(0,n.quantity);let u=Math.round(new Date().getTime()/3e5)*3e5;u-=e*1e3*n.period;for(let f=0;f<t.length;f++){const p=t[f];Object.assign(p,{timestamp:u,isVisible:!0}),u+=1e3*n.period,n.withVolume&&(p.volume=Math.ceil(Math.random()*1e3+200))}return t}function ws(n,t,e,s){var i=Math.random()*(t-n)+n,r;if(s&&s==="bull"||!s&&Math.random()>.5){var o=i+e;r=o<t?o:t}else{var a=i-e;r=a>n?a:n}var l=Math.max(i,r)+Math.random()*e*.2,c=Math.min(i,r)-Math.random()*e*.2;return{id:gi(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function Hp(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.lo,o=n.hi+t*1.2,a=0;a<i;a++){var l=Math.random()>.9?"bear":"bull",c=ws(r,o,t,l);r=c.lo-t*(Math.random()*.1+.1),o=c.hi+t*(Math.random()*1.3+.1),Math.random()>.9&&(o=c.hi+t),s.push(c)}return s}function kp(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.hi-t*1.2,o=n.hi,a=0;a<i;a++){var l=Math.random()<.9?"bear":"bull",c=ws(r,o,t,l);r=c.lo-t*(Math.random()*.3+.1),o=c.hi-t*(Math.random()*.1+.1),Math.random()>.9&&(o=c.lo-t),s.push(c)}return s}function jp(n,t,e){var s=[],i=Math.random()*e+e/2;function r(u){var f,p;return Math.random()>.5?(f=u.lo-t*.2,p=u.hi+t*1.2):(f=u.lo-t*1.2,p=u.hi+t*.2),{from:f,to:p}}for(var o=r(n),a=o.from,l=o.to,c=0;c<i;c++){var h=Math.random()<.5?"bear":"bull",d=ws(a,l,t,h);o=r(d),a=o.from,l=o.to,Math.random()>.9&&(Math.random()>.5?a=d.lo-t:l=d.hi+t),s.push(d)}return s}window.DXChart=Fp(Rp({},window.DXChart),{generateCandlesData:ia});function Yp(n){return ia(n)}const Np=((n,t={})=>new ea(n,t))})(),window.DXChart=_s})();})();