@devexperts/dxcharts-lite 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart/bootstrap.js +4 -3
- package/dist/chart/canvas/canvas-bounds-container.js +5 -3
- package/dist/chart/canvas/cursor.handler.js +2 -2
- package/dist/chart/components/chart/chart-area-pan.handler.js +3 -3
- package/dist/chart/components/chart/chart.component.d.ts +6 -3
- package/dist/chart/components/chart/chart.component.js +18 -7
- package/dist/chart/components/chart/chart.model.d.ts +1 -2
- package/dist/chart/components/chart/chart.model.js +2 -3
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +4 -2
- package/dist/chart/components/high_low/high-low.drawer.js +9 -2
- package/dist/chart/components/highlights/highlights.drawer.js +1 -1
- package/dist/chart/components/pane/pane.component.js +6 -3
- package/dist/chart/components/volumes/volumes.drawer.js +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats.model.d.ts +1 -1
- package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +2 -2
- package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +6 -7
- package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +11 -3
- package/dist/chart/components/x_axis/x-axis-labels.generator.js +47 -19
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +0 -4
- package/dist/chart/components/x_axis/x-axis.component.js +7 -11
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +5 -5
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +21 -22
- package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +18 -6
- package/dist/chart/components/y_axis/y-axis-labels.drawer.js +23 -12
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +4 -0
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +13 -6
- package/dist/chart/components/y_axis/y-axis.drawer.js +1 -1
- package/dist/chart/drawers/chart-background.drawer.d.ts +2 -3
- package/dist/chart/drawers/chart-background.drawer.js +16 -22
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +1 -1
- package/dist/chart/drawers/data-series.drawer.d.ts +0 -2
- package/dist/chart/drawers/data-series.drawer.js +1 -6
- package/dist/chart/drawers/ht-data-series.drawer.js +1 -1
- package/dist/chart/inputhandlers/hover-producer.component.d.ts +1 -1
- package/dist/chart/model/compare-series-hover.d.ts +1 -1
- package/dist/chart/model/compare-series-hover.js +5 -0
- package/dist/chart/model/data-series.model.js +1 -1
- package/dist/chart/model/hit-test-canvas.model.js +2 -2
- package/dist/chart/model/scale.model.d.ts +3 -1
- package/dist/chart/model/scale.model.js +23 -4
- package/dist/chart/model/scaling/viewport.model.d.ts +2 -0
- package/dist/chart/model/scaling/viewport.model.js +13 -4
- package/dist/chart/model/time-zone.model.d.ts +0 -14
- package/dist/chart/model/time-zone.model.js +13 -33
- package/dist/chart/utils/canvas/canvas-drawing-functions.utils.d.ts +12 -1
- package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +16 -1
- package/dist/chart/utils/canvas/canvas-text-functions.utils.d.ts +3 -2
- package/dist/chart/utils/canvas/canvas-text-functions.utils.js +8 -3
- package/dist/chart/utils/math.utils.d.ts +1 -0
- package/dist/chart/utils/math.utils.js +3 -0
- package/dist/chart/utils/timezone.utils.d.ts +13 -0
- package/dist/chart/utils/timezone.utils.js +48 -0
- package/dist/dxchart.min.js +6 -6
- package/package.json +1 -2
package/dist/dxchart.min.js
CHANGED
|
@@ -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 mt=Math.pow;(()=>{var Ya={8168:(B,S,y)=>{const P=y(8874),L={};for(const v of Object.keys(P))L[P[v]]=v;const _={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"]}};B.exports=_;for(const v of Object.keys(_)){if(!("channels"in _[v]))throw new Error("missing channels property: "+v);if(!("labels"in _[v]))throw new Error("missing channel labels property: "+v);if(_[v].labels.length!==_[v].channels)throw new Error("channel and label counts mismatch: "+v);const{channels:f,labels:u}=_[v];delete _[v].channels,delete _[v].labels,Object.defineProperty(_[v],"channels",{value:f}),Object.defineProperty(_[v],"labels",{value:u})}_.rgb.hsl=function(v){const f=v[0]/255,u=v[1]/255,m=v[2]/255,d=Math.min(f,u,m),w=Math.max(f,u,m),A=w-d;let I,C;w===d?I=0:f===w?I=(u-m)/A:u===w?I=2+(m-f)/A:m===w&&(I=4+(f-u)/A),I=Math.min(I*60,360),I<0&&(I+=360);const M=(d+w)/2;return w===d?C=0:M<=.5?C=A/(w+d):C=A/(2-w-d),[I,C*100,M*100]},_.rgb.hsv=function(v){let f,u,m,d,w;const A=v[0]/255,I=v[1]/255,C=v[2]/255,M=Math.max(A,I,C),T=M-Math.min(A,I,C),x=function(D){return(M-D)/6/T+1/2};return T===0?(d=0,w=0):(w=T/M,f=x(A),u=x(I),m=x(C),A===M?d=m-u:I===M?d=.3333333333333333+f-m:C===M&&(d=.6666666666666666+u-f),d<0?d+=1:d>1&&(d-=1)),[d*360,w*100,M*100]},_.rgb.hwb=function(v){const f=v[0],u=v[1];let m=v[2];const d=_.rgb.hsl(v)[0],w=1/255*Math.min(f,Math.min(u,m));return m=1-.00392156862745098*Math.max(f,Math.max(u,m)),[d,w*100,m*100]},_.rgb.cmyk=function(v){const f=v[0]/255,u=v[1]/255,m=v[2]/255,d=Math.min(1-f,1-u,1-m),w=(1-f-d)/(1-d)||0,A=(1-u-d)/(1-d)||0,I=(1-m-d)/(1-d)||0;return[w*100,A*100,I*100,d*100]};function H(v,f){return mt(v[0]-f[0],2)+mt(v[1]-f[1],2)+mt(v[2]-f[2],2)}_.rgb.keyword=function(v){const f=L[v];if(f)return f;let u=1/0,m;for(const d of Object.keys(P)){const w=P[d],A=H(v,w);A<u&&(u=A,m=d)}return m},_.keyword.rgb=function(v){return P[v]},_.rgb.xyz=function(v){let f=v[0]/255,u=v[1]/255,m=v[2]/255;f=f>.04045?mt((f+.055)/1.055,2.4):f/12.92,u=u>.04045?mt((u+.055)/1.055,2.4):u/12.92,m=m>.04045?mt((m+.055)/1.055,2.4):m/12.92;const d=f*.4124+u*.3576+m*.1805,w=f*.2126+u*.7152+m*.0722,A=f*.0193+u*.1192+m*.9505;return[d*100,w*100,A*100]},_.rgb.lab=function(v){const f=_.rgb.xyz(v);let u=f[0],m=f[1],d=f[2];u/=95.047,m/=100,d/=108.883,u=u>.008856?mt(u,.3333333333333333):7.787*u+.13793103448275862,m=m>.008856?mt(m,.3333333333333333):7.787*m+.13793103448275862,d=d>.008856?mt(d,.3333333333333333):7.787*d+.13793103448275862;const w=116*m-16,A=500*(u-m),I=200*(m-d);return[w,A,I]},_.hsl.rgb=function(v){const f=v[0]/360,u=v[1]/100,m=v[2]/100;let d,w,A;if(u===0)return A=m*255,[A,A,A];m<.5?d=m*(1+u):d=m+u-m*u;const I=2*m-d,C=[0,0,0];for(let M=0;M<3;M++)w=f+.3333333333333333*-(M-1),w<0&&w++,w>1&&w--,6*w<1?A=I+(d-I)*6*w:2*w<1?A=d:3*w<2?A=I+(d-I)*(.6666666666666666-w)*6:A=I,C[M]=A*255;return C},_.hsl.hsv=function(v){const f=v[0];let u=v[1]/100,m=v[2]/100,d=u;const w=Math.max(m,.01);m*=2,u*=m<=1?m:2-m,d*=w<=1?w:2-w;const A=(m+u)/2,I=m===0?2*d/(w+d):2*u/(m+u);return[f,I*100,A*100]},_.hsv.rgb=function(v){const f=v[0]/60,u=v[1]/100;let m=v[2]/100;const d=Math.floor(f)%6,w=f-Math.floor(f),A=255*m*(1-u),I=255*m*(1-u*w),C=255*m*(1-u*(1-w));switch(m*=255,d){case 0:return[m,C,A];case 1:return[I,m,A];case 2:return[A,m,C];case 3:return[A,I,m];case 4:return[C,A,m];case 5:return[m,A,I]}},_.hsv.hsl=function(v){const f=v[0],u=v[1]/100,m=v[2]/100,d=Math.max(m,.01);let w,A;A=(2-u)*m;const I=(2-u)*d;return w=u*d,w/=I<=1?I:2-I,w=w||0,A/=2,[f,w*100,A*100]},_.hwb.rgb=function(v){const f=v[0]/360;let u=v[1]/100,m=v[2]/100;const d=u+m;let w;d>1&&(u/=d,m/=d);const A=Math.floor(6*f),I=1-m;w=6*f-A,A&1&&(w=1-w);const C=u+w*(I-u);let M,T,x;switch(A){default:case 6:case 0:M=I,T=C,x=u;break;case 1:M=C,T=I,x=u;break;case 2:M=u,T=I,x=C;break;case 3:M=u,T=C,x=I;break;case 4:M=C,T=u,x=I;break;case 5:M=I,T=u,x=C;break}return[M*255,T*255,x*255]},_.cmyk.rgb=function(v){const f=v[0]/100,u=v[1]/100,m=v[2]/100,d=v[3]/100,w=1-Math.min(1,f*(1-d)+d),A=1-Math.min(1,u*(1-d)+d),I=1-Math.min(1,m*(1-d)+d);return[w*255,A*255,I*255]},_.xyz.rgb=function(v){const f=v[0]/100,u=v[1]/100,m=v[2]/100;let d,w,A;return d=f*3.2406+u*-1.5372+m*-.4986,w=f*-.9689+u*1.8758+m*.0415,A=f*.0557+u*-.204+m*1.057,d=d>.0031308?1.055*mt(d,.4166666666666667)-.055:d*12.92,w=w>.0031308?1.055*mt(w,.4166666666666667)-.055:w*12.92,A=A>.0031308?1.055*mt(A,.4166666666666667)-.055:A*12.92,d=Math.min(Math.max(0,d),1),w=Math.min(Math.max(0,w),1),A=Math.min(Math.max(0,A),1),[d*255,w*255,A*255]},_.xyz.lab=function(v){let f=v[0],u=v[1],m=v[2];f/=95.047,u/=100,m/=108.883,f=f>.008856?mt(f,.3333333333333333):7.787*f+.13793103448275862,u=u>.008856?mt(u,.3333333333333333):7.787*u+.13793103448275862,m=m>.008856?mt(m,.3333333333333333):7.787*m+.13793103448275862;const d=116*u-16,w=500*(f-u),A=200*(u-m);return[d,w,A]},_.lab.xyz=function(v){const f=v[0],u=v[1],m=v[2];let d,w,A;w=(f+16)/116,d=u/500+w,A=w-m/200;const I=mt(w,3),C=mt(d,3),M=mt(A,3);return w=I>.008856?I:(w-.13793103448275862)/7.787,d=C>.008856?C:(d-.13793103448275862)/7.787,A=M>.008856?M:(A-.13793103448275862)/7.787,d*=95.047,w*=100,A*=108.883,[d,w,A]},_.lab.lch=function(v){const f=v[0],u=v[1],m=v[2];let d;d=Math.atan2(m,u)*360/2/Math.PI,d<0&&(d+=360);const A=Math.sqrt(u*u+m*m);return[f,A,d]},_.lch.lab=function(v){const f=v[0],u=v[1],d=v[2]/360*2*Math.PI,w=u*Math.cos(d),A=u*Math.sin(d);return[f,w,A]},_.rgb.ansi16=function(v,f=null){const[u,m,d]=v;let w=f===null?_.rgb.hsv(v)[2]:f;if(w=Math.round(w/50),w===0)return 30;let A=30+(Math.round(d/255)<<2|Math.round(m/255)<<1|Math.round(u/255));return w===2&&(A+=60),A},_.hsv.ansi16=function(v){return _.rgb.ansi16(_.hsv.rgb(v),v[2])},_.rgb.ansi256=function(v){const f=v[0],u=v[1],m=v[2];return f===u&&u===m?f<8?16:f>248?231:Math.round((f-8)/247*24)+232:16+36*Math.round(f/255*5)+6*Math.round(u/255*5)+Math.round(m/255*5)},_.ansi16.rgb=function(v){let f=v%10;if(f===0||f===7)return v>50&&(f+=3.5),f=f/10.5*255,[f,f,f];const u=(~~(v>50)+1)*.5,m=(f&1)*u*255,d=(f>>1&1)*u*255,w=(f>>2&1)*u*255;return[m,d,w]},_.ansi256.rgb=function(v){if(v>=232){const w=(v-232)*10+8;return[w,w,w]}v-=16;let f;const u=Math.floor(v/36)/5*255,m=Math.floor((f=v%36)/6)/5*255,d=f%6/5*255;return[u,m,d]},_.rgb.hex=function(v){const u=(((Math.round(v[0])&255)<<16)+((Math.round(v[1])&255)<<8)+(Math.round(v[2])&255)).toString(16).toUpperCase();return"000000".substring(u.length)+u},_.hex.rgb=function(v){const f=v.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!f)return[0,0,0];let u=f[0];f[0].length===3&&(u=u.split("").map(I=>I+I).join(""));const m=parseInt(u,16),d=m>>16&255,w=m>>8&255,A=m&255;return[d,w,A]},_.rgb.hcg=function(v){const f=v[0]/255,u=v[1]/255,m=v[2]/255,d=Math.max(Math.max(f,u),m),w=Math.min(Math.min(f,u),m),A=d-w;let I,C;return A<1?I=w/(1-A):I=0,A<=0?C=0:d===f?C=(u-m)/A%6:d===u?C=2+(m-f)/A:C=4+(f-u)/A,C/=6,C%=1,[C*360,A*100,I*100]},_.hsl.hcg=function(v){const f=v[1]/100,u=v[2]/100,m=u<.5?2*f*u:2*f*(1-u);let d=0;return m<1&&(d=(u-.5*m)/(1-m)),[v[0],m*100,d*100]},_.hsv.hcg=function(v){const f=v[1]/100,u=v[2]/100,m=f*u;let d=0;return m<1&&(d=(u-m)/(1-m)),[v[0],m*100,d*100]},_.hcg.rgb=function(v){const f=v[0]/360,u=v[1]/100,m=v[2]/100;if(u===0)return[m*255,m*255,m*255];const d=[0,0,0],w=f%1*6,A=w%1,I=1-A;let C=0;switch(Math.floor(w)){case 0:d[0]=1,d[1]=A,d[2]=0;break;case 1:d[0]=I,d[1]=1,d[2]=0;break;case 2:d[0]=0,d[1]=1,d[2]=A;break;case 3:d[0]=0,d[1]=I,d[2]=1;break;case 4:d[0]=A,d[1]=0,d[2]=1;break;default:d[0]=1,d[1]=0,d[2]=I}return C=(1-u)*m,[(u*d[0]+C)*255,(u*d[1]+C)*255,(u*d[2]+C)*255]},_.hcg.hsv=function(v){const f=v[1]/100,u=v[2]/100,m=f+u*(1-f);let d=0;return m>0&&(d=f/m),[v[0],d*100,m*100]},_.hcg.hsl=function(v){const f=v[1]/100,m=v[2]/100*(1-f)+.5*f;let d=0;return m>0&&m<.5?d=f/(2*m):m>=.5&&m<1&&(d=f/(2*(1-m))),[v[0],d*100,m*100]},_.hcg.hwb=function(v){const f=v[1]/100,u=v[2]/100,m=f+u*(1-f);return[v[0],(m-f)*100,(1-m)*100]},_.hwb.hcg=function(v){const f=v[1]/100,m=1-v[2]/100,d=m-f;let w=0;return d<1&&(w=(m-d)/(1-d)),[v[0],d*100,w*100]},_.apple.rgb=function(v){return[v[0]/65535*255,v[1]/65535*255,v[2]/65535*255]},_.rgb.apple=function(v){return[v[0]/255*65535,v[1]/255*65535,v[2]/255*65535]},_.gray.rgb=function(v){return[v[0]/100*255,v[0]/100*255,v[0]/100*255]},_.gray.hsl=function(v){return[0,0,v[0]]},_.gray.hsv=_.gray.hsl,_.gray.hwb=function(v){return[0,100,v[0]]},_.gray.cmyk=function(v){return[0,0,0,v[0]]},_.gray.lab=function(v){return[v[0],0,0]},_.gray.hex=function(v){const f=Math.round(v[0]/100*255)&255,m=((f<<16)+(f<<8)+f).toString(16).toUpperCase();return"000000".substring(m.length)+m},_.rgb.gray=function(v){return[(v[0]+v[1]+v[2])/3/255*100]}},2085:(B,S,y)=>{const P=y(8168),L=y(4111),_={},H=Object.keys(P);function v(u){const m=function(...d){const w=d[0];return w==null?w:(w.length>1&&(d=w),u(d))};return"conversion"in u&&(m.conversion=u.conversion),m}function f(u){const m=function(...d){const w=d[0];if(w==null)return w;w.length>1&&(d=w);const A=u(d);if(typeof A=="object")for(let I=A.length,C=0;C<I;C++)A[C]=Math.round(A[C]);return A};return"conversion"in u&&(m.conversion=u.conversion),m}H.forEach(u=>{_[u]={},Object.defineProperty(_[u],"channels",{value:P[u].channels}),Object.defineProperty(_[u],"labels",{value:P[u].labels});const m=L(u);Object.keys(m).forEach(w=>{const A=m[w];_[u][w]=f(A),_[u][w].raw=v(A)})}),B.exports=_},4111:(B,S,y)=>{const P=y(8168);function L(){const f={},u=Object.keys(P);for(let m=u.length,d=0;d<m;d++)f[u[d]]={distance:-1,parent:null};return f}function _(f){const u=L(),m=[f];for(u[f].distance=0;m.length;){const d=m.pop(),w=Object.keys(P[d]);for(let A=w.length,I=0;I<A;I++){const C=w[I],M=u[C];M.distance===-1&&(M.distance=u[d].distance+1,M.parent=d,m.unshift(C))}}return u}function H(f,u){return function(m){return u(f(m))}}function v(f,u){const m=[u[f].parent,f];let d=P[u[f].parent][f],w=u[f].parent;for(;u[w].parent;)m.unshift(u[w].parent),d=H(P[u[w].parent][w],d),w=u[w].parent;return d.conversion=m,d}B.exports=function(f){const u=_(f),m={},d=Object.keys(u);for(let w=d.length,A=0;A<w;A++){const I=d[A];u[I].parent!==null&&(m[I]=v(I,u))}return m}},8874:B=>{"use strict";B.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]}},9818:(B,S,y)=>{var P=y(8874),L=y(6851),_=Object.hasOwnProperty,H=Object.create(null);for(var v in P)_.call(P,v)&&(H[P[v]]=v);var f=B.exports={to:{},get:{}};f.get=function(d){var w=d.substring(0,3).toLowerCase(),A,I;switch(w){case"hsl":A=f.get.hsl(d),I="hsl";break;case"hwb":A=f.get.hwb(d),I="hwb";break;default:A=f.get.rgb(d),I="rgb";break}return A?{model:I,value:A}:null},f.get.rgb=function(d){if(!d)return null;var w=/^#([a-f0-9]{3,4})$/i,A=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,C=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,M=/^(\w+)$/,T=[0,0,0,1],x,D,R;if(x=d.match(A)){for(R=x[2],x=x[1],D=0;D<3;D++){var F=D*2;T[D]=parseInt(x.slice(F,F+2),16)}R&&(T[3]=parseInt(R,16)/255)}else if(x=d.match(w)){for(x=x[1],R=x[3],D=0;D<3;D++)T[D]=parseInt(x[D]+x[D],16);R&&(T[3]=parseInt(R+R,16)/255)}else if(x=d.match(I)){for(D=0;D<3;D++)T[D]=parseInt(x[D+1],0);x[4]&&(x[5]?T[3]=parseFloat(x[4])*.01:T[3]=parseFloat(x[4]))}else if(x=d.match(C)){for(D=0;D<3;D++)T[D]=Math.round(parseFloat(x[D+1])*2.55);x[4]&&(x[5]?T[3]=parseFloat(x[4])*.01:T[3]=parseFloat(x[4]))}else return(x=d.match(M))?x[1]==="transparent"?[0,0,0,0]:_.call(P,x[1])?(T=P[x[1]],T[3]=1,T):null:null;for(D=0;D<3;D++)T[D]=u(T[D],0,255);return T[3]=u(T[3],0,1),T},f.get.hsl=function(d){if(!d)return null;var w=/^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*)?\)$/,A=d.match(w);if(A){var I=parseFloat(A[4]),C=(parseFloat(A[1])%360+360)%360,M=u(parseFloat(A[2]),0,100),T=u(parseFloat(A[3]),0,100),x=u(isNaN(I)?1:I,0,1);return[C,M,T,x]}return null},f.get.hwb=function(d){if(!d)return null;var w=/^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*)?\)$/,A=d.match(w);if(A){var I=parseFloat(A[4]),C=(parseFloat(A[1])%360+360)%360,M=u(parseFloat(A[2]),0,100),T=u(parseFloat(A[3]),0,100),x=u(isNaN(I)?1:I,0,1);return[C,M,T,x]}return null},f.to.hex=function(){var d=L(arguments);return"#"+m(d[0])+m(d[1])+m(d[2])+(d[3]<1?m(Math.round(d[3]*255)):"")},f.to.rgb=function(){var d=L(arguments);return d.length<4||d[3]===1?"rgb("+Math.round(d[0])+", "+Math.round(d[1])+", "+Math.round(d[2])+")":"rgba("+Math.round(d[0])+", "+Math.round(d[1])+", "+Math.round(d[2])+", "+d[3]+")"},f.to.rgb.percent=function(){var d=L(arguments),w=Math.round(d[0]/255*100),A=Math.round(d[1]/255*100),I=Math.round(d[2]/255*100);return d.length<4||d[3]===1?"rgb("+w+"%, "+A+"%, "+I+"%)":"rgba("+w+"%, "+A+"%, "+I+"%, "+d[3]+")"},f.to.hsl=function(){var d=L(arguments);return d.length<4||d[3]===1?"hsl("+d[0]+", "+d[1]+"%, "+d[2]+"%)":"hsla("+d[0]+", "+d[1]+"%, "+d[2]+"%, "+d[3]+")"},f.to.hwb=function(){var d=L(arguments),w="";return d.length>=4&&d[3]!==1&&(w=", "+d[3]),"hwb("+d[0]+", "+d[1]+"%, "+d[2]+"%"+w+")"},f.to.keyword=function(d){return H[d.slice(0,3)]};function u(d,w,A){return Math.min(Math.max(w,d),A)}function m(d){var w=Math.round(d).toString(16).toUpperCase();return w.length<2?"0"+w:w}},6767:(B,S,y)=>{const P=y(9818),L=y(2085),_=["keyword","gray","hex"],H={};for(const C of Object.keys(L))H[[...L[C].labels].sort().join("")]=C;const v={};function f(C,M){if(!(this instanceof f))return new f(C,M);if(M&&M in _&&(M=null),M&&!(M in L))throw new Error("Unknown model: "+M);let T,x;if(C==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(C instanceof f)this.model=C.model,this.color=[...C.color],this.valpha=C.valpha;else if(typeof C=="string"){const D=P.get(C);if(D===null)throw new Error("Unable to parse color from string: "+C);this.model=D.model,x=L[this.model].channels,this.color=D.value.slice(0,x),this.valpha=typeof D.value[x]=="number"?D.value[x]:1}else if(C.length>0){this.model=M||"rgb",x=L[this.model].channels;const D=Array.prototype.slice.call(C,0,x);this.color=I(D,x),this.valpha=typeof C[x]=="number"?C[x]:1}else if(typeof C=="number")this.model="rgb",this.color=[C>>16&255,C>>8&255,C&255],this.valpha=1;else{this.valpha=1;const D=Object.keys(C);"alpha"in C&&(D.splice(D.indexOf("alpha"),1),this.valpha=typeof C.alpha=="number"?C.alpha:0);const R=D.sort().join("");if(!(R in H))throw new Error("Unable to parse color from object: "+JSON.stringify(C));this.model=H[R];const{labels:F}=L[this.model],j=[];for(T=0;T<F.length;T++)j.push(C[F[T]]);this.color=I(j)}if(v[this.model])for(x=L[this.model].channels,T=0;T<x;T++){const D=v[this.model][T];D&&(this.color[T]=D(this.color[T]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}f.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(C){let M=this.model in P.to?this:this.rgb();M=M.round(typeof C=="number"?C:1);const T=M.valpha===1?M.color:[...M.color,this.valpha];return P.to[M.model](T)},percentString(C){const M=this.rgb().round(typeof C=="number"?C:1),T=M.valpha===1?M.color:[...M.color,this.valpha];return P.to.rgb.percent(T)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const C={},{channels:M}=L[this.model],{labels:T}=L[this.model];for(let x=0;x<M;x++)C[T[x]]=this.color[x];return this.valpha!==1&&(C.alpha=this.valpha),C},unitArray(){const C=this.rgb().color;return C[0]/=255,C[1]/=255,C[2]/=255,this.valpha!==1&&C.push(this.valpha),C},unitObject(){const C=this.rgb().object();return C.r/=255,C.g/=255,C.b/=255,this.valpha!==1&&(C.alpha=this.valpha),C},round(C){return C=Math.max(C||0,0),new f([...this.color.map(m(C)),this.valpha],this.model)},alpha(C){return C!==void 0?new f([...this.color,Math.max(0,Math.min(1,C))],this.model):this.valpha},red:d("rgb",0,w(255)),green:d("rgb",1,w(255)),blue:d("rgb",2,w(255)),hue:d(["hsl","hsv","hsl","hwb","hcg"],0,C=>(C%360+360)%360),saturationl:d("hsl",1,w(100)),lightness:d("hsl",2,w(100)),saturationv:d("hsv",1,w(100)),value:d("hsv",2,w(100)),chroma:d("hcg",1,w(100)),gray:d("hcg",2,w(100)),white:d("hwb",1,w(100)),wblack:d("hwb",2,w(100)),cyan:d("cmyk",0,w(100)),magenta:d("cmyk",1,w(100)),yellow:d("cmyk",2,w(100)),black:d("cmyk",3,w(100)),x:d("xyz",0,w(95.047)),y:d("xyz",1,w(100)),z:d("xyz",2,w(108.833)),l:d("lab",0,w(100)),a:d("lab",1),b:d("lab",2),keyword(C){return C!==void 0?new f(C):L[this.model].keyword(this.color)},hex(C){return C!==void 0?new f(C):P.to.hex(this.rgb().round().color)},hexa(C){if(C!==void 0)return new f(C);const M=this.rgb().round().color;let T=Math.round(this.valpha*255).toString(16).toUpperCase();return T.length===1&&(T="0"+T),P.to.hex(M)+T},rgbNumber(){const C=this.rgb().color;return(C[0]&255)<<16|(C[1]&255)<<8|C[2]&255},luminosity(){const C=this.rgb().color,M=[];for(const[T,x]of C.entries()){const D=x/255;M[T]=D<=.04045?D/12.92:mt((D+.055)/1.055,2.4)}return .2126*M[0]+.7152*M[1]+.0722*M[2]},contrast(C){const M=this.luminosity(),T=C.luminosity();return M>T?(M+.05)/(T+.05):(T+.05)/(M+.05)},level(C){const M=this.contrast(C);return M>=7?"AAA":M>=4.5?"AA":""},isDark(){const C=this.rgb().color;return(C[0]*2126+C[1]*7152+C[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const C=this.rgb();for(let M=0;M<3;M++)C.color[M]=255-C.color[M];return C},lighten(C){const M=this.hsl();return M.color[2]+=M.color[2]*C,M},darken(C){const M=this.hsl();return M.color[2]-=M.color[2]*C,M},saturate(C){const M=this.hsl();return M.color[1]+=M.color[1]*C,M},desaturate(C){const M=this.hsl();return M.color[1]-=M.color[1]*C,M},whiten(C){const M=this.hwb();return M.color[1]+=M.color[1]*C,M},blacken(C){const M=this.hwb();return M.color[2]+=M.color[2]*C,M},grayscale(){const C=this.rgb().color,M=C[0]*.3+C[1]*.59+C[2]*.11;return f.rgb(M,M,M)},fade(C){return this.alpha(this.valpha-this.valpha*C)},opaquer(C){return this.alpha(this.valpha+this.valpha*C)},rotate(C){const M=this.hsl();let T=M.color[0];return T=(T+C)%360,T=T<0?360+T:T,M.color[0]=T,M},mix(C,M){if(!C||!C.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof C);const T=C.rgb(),x=this.rgb(),D=M===void 0?.5:M,R=2*D-1,F=T.alpha()-x.alpha(),j=((R*F===-1?R:(R+F)/(1+R*F))+1)/2,G=1-j;return f.rgb(j*T.red()+G*x.red(),j*T.green()+G*x.green(),j*T.blue()+G*x.blue(),T.alpha()*D+x.alpha()*(1-D))}};for(const C of Object.keys(L)){if(_.includes(C))continue;const{channels:M}=L[C];f.prototype[C]=function(...T){return this.model===C?new f(this):T.length>0?new f(T,C):new f([...A(L[this.model][C].raw(this.color)),this.valpha],C)},f[C]=function(...T){let x=T[0];return typeof x=="number"&&(x=I(T,M)),new f(x,C)}}function u(C,M){return Number(C.toFixed(M))}function m(C){return function(M){return u(M,C)}}function d(C,M,T){C=Array.isArray(C)?C:[C];for(const x of C)(v[x]||(v[x]=[]))[M]=T;return C=C[0],function(x){let D;return x!==void 0?(T&&(x=T(x)),D=this[C](),D.color[M]=x,D):(D=this[C]().color[M],T&&(D=T(D)),D)}}function w(C){return function(M){return Math.max(0,Math.min(C,M))}}function A(C){return Array.isArray(C)?C:[C]}function I(C,M){for(let T=0;T<M;T++)typeof C[T]!="number"&&(C[T]=0);return C}B.exports=f},7394:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P,L){for(var _=P<0?"-":"",H=Math.abs(P).toString();H.length<L;)H="0"+H;return _+H}B.exports=S.default},8609:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P,L){if(P==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var _ in L)Object.prototype.hasOwnProperty.call(L,_)&&(P[_]=L[_]);return P}B.exports=S.default},6420:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=_;var L=P(y(8609));function _(H){return(0,L.default)({},H)}B.exports=S.default},7561:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(2512)),_=L.default;S.default=_,B.exports=S.default},8729:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.getDefaultOptions=P,S.setDefaultOptions=L;var y={};function P(){return y}function L(_){y=_}},7100:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(1603)),_=P(y(1354)),H=P(y(1370)),v=P(y(623)),f=P(y(6226)),u=P(y(7394)),m=P(y(2699)),d={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},w={G:function(x,D,R){var F=x.getUTCFullYear()>0?1:0;switch(D){case"G":case"GG":case"GGG":return R.era(F,{width:"abbreviated"});case"GGGGG":return R.era(F,{width:"narrow"});case"GGGG":default:return R.era(F,{width:"wide"})}},y:function(x,D,R){if(D==="yo"){var F=x.getUTCFullYear(),j=F>0?F:1-F;return R.ordinalNumber(j,{unit:"year"})}return m.default.y(x,D)},Y:function(x,D,R,F){var j=(0,f.default)(x,F),G=j>0?j:1-j;if(D==="YY"){var et=G%100;return(0,u.default)(et,2)}return D==="Yo"?R.ordinalNumber(G,{unit:"year"}):(0,u.default)(G,D.length)},R:function(x,D){var R=(0,H.default)(x);return(0,u.default)(R,D.length)},u:function(x,D){var R=x.getUTCFullYear();return(0,u.default)(R,D.length)},Q:function(x,D,R){var F=Math.ceil((x.getUTCMonth()+1)/3);switch(D){case"Q":return String(F);case"QQ":return(0,u.default)(F,2);case"Qo":return R.ordinalNumber(F,{unit:"quarter"});case"QQQ":return R.quarter(F,{width:"abbreviated",context:"formatting"});case"QQQQQ":return R.quarter(F,{width:"narrow",context:"formatting"});case"QQQQ":default:return R.quarter(F,{width:"wide",context:"formatting"})}},q:function(x,D,R){var F=Math.ceil((x.getUTCMonth()+1)/3);switch(D){case"q":return String(F);case"qq":return(0,u.default)(F,2);case"qo":return R.ordinalNumber(F,{unit:"quarter"});case"qqq":return R.quarter(F,{width:"abbreviated",context:"standalone"});case"qqqqq":return R.quarter(F,{width:"narrow",context:"standalone"});case"qqqq":default:return R.quarter(F,{width:"wide",context:"standalone"})}},M:function(x,D,R){var F=x.getUTCMonth();switch(D){case"M":case"MM":return m.default.M(x,D);case"Mo":return R.ordinalNumber(F+1,{unit:"month"});case"MMM":return R.month(F,{width:"abbreviated",context:"formatting"});case"MMMMM":return R.month(F,{width:"narrow",context:"formatting"});case"MMMM":default:return R.month(F,{width:"wide",context:"formatting"})}},L:function(x,D,R){var F=x.getUTCMonth();switch(D){case"L":return String(F+1);case"LL":return(0,u.default)(F+1,2);case"Lo":return R.ordinalNumber(F+1,{unit:"month"});case"LLL":return R.month(F,{width:"abbreviated",context:"standalone"});case"LLLLL":return R.month(F,{width:"narrow",context:"standalone"});case"LLLL":default:return R.month(F,{width:"wide",context:"standalone"})}},w:function(x,D,R,F){var j=(0,v.default)(x,F);return D==="wo"?R.ordinalNumber(j,{unit:"week"}):(0,u.default)(j,D.length)},I:function(x,D,R){var F=(0,_.default)(x);return D==="Io"?R.ordinalNumber(F,{unit:"week"}):(0,u.default)(F,D.length)},d:function(x,D,R){return D==="do"?R.ordinalNumber(x.getUTCDate(),{unit:"date"}):m.default.d(x,D)},D:function(x,D,R){var F=(0,L.default)(x);return D==="Do"?R.ordinalNumber(F,{unit:"dayOfYear"}):(0,u.default)(F,D.length)},E:function(x,D,R){var F=x.getUTCDay();switch(D){case"E":case"EE":case"EEE":return R.day(F,{width:"abbreviated",context:"formatting"});case"EEEEE":return R.day(F,{width:"narrow",context:"formatting"});case"EEEEEE":return R.day(F,{width:"short",context:"formatting"});case"EEEE":default:return R.day(F,{width:"wide",context:"formatting"})}},e:function(x,D,R,F){var j=x.getUTCDay(),G=(j-F.weekStartsOn+8)%7||7;switch(D){case"e":return String(G);case"ee":return(0,u.default)(G,2);case"eo":return R.ordinalNumber(G,{unit:"day"});case"eee":return R.day(j,{width:"abbreviated",context:"formatting"});case"eeeee":return R.day(j,{width:"narrow",context:"formatting"});case"eeeeee":return R.day(j,{width:"short",context:"formatting"});case"eeee":default:return R.day(j,{width:"wide",context:"formatting"})}},c:function(x,D,R,F){var j=x.getUTCDay(),G=(j-F.weekStartsOn+8)%7||7;switch(D){case"c":return String(G);case"cc":return(0,u.default)(G,D.length);case"co":return R.ordinalNumber(G,{unit:"day"});case"ccc":return R.day(j,{width:"abbreviated",context:"standalone"});case"ccccc":return R.day(j,{width:"narrow",context:"standalone"});case"cccccc":return R.day(j,{width:"short",context:"standalone"});case"cccc":default:return R.day(j,{width:"wide",context:"standalone"})}},i:function(x,D,R){var F=x.getUTCDay(),j=F===0?7:F;switch(D){case"i":return String(j);case"ii":return(0,u.default)(j,D.length);case"io":return R.ordinalNumber(j,{unit:"day"});case"iii":return R.day(F,{width:"abbreviated",context:"formatting"});case"iiiii":return R.day(F,{width:"narrow",context:"formatting"});case"iiiiii":return R.day(F,{width:"short",context:"formatting"});case"iiii":default:return R.day(F,{width:"wide",context:"formatting"})}},a:function(x,D,R){var F=x.getUTCHours(),j=F/12>=1?"pm":"am";switch(D){case"a":case"aa":return R.dayPeriod(j,{width:"abbreviated",context:"formatting"});case"aaa":return R.dayPeriod(j,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return R.dayPeriod(j,{width:"narrow",context:"formatting"});case"aaaa":default:return R.dayPeriod(j,{width:"wide",context:"formatting"})}},b:function(x,D,R){var F=x.getUTCHours(),j;switch(F===12?j=d.noon:F===0?j=d.midnight:j=F/12>=1?"pm":"am",D){case"b":case"bb":return R.dayPeriod(j,{width:"abbreviated",context:"formatting"});case"bbb":return R.dayPeriod(j,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return R.dayPeriod(j,{width:"narrow",context:"formatting"});case"bbbb":default:return R.dayPeriod(j,{width:"wide",context:"formatting"})}},B:function(x,D,R){var F=x.getUTCHours(),j;switch(F>=17?j=d.evening:F>=12?j=d.afternoon:F>=4?j=d.morning:j=d.night,D){case"B":case"BB":case"BBB":return R.dayPeriod(j,{width:"abbreviated",context:"formatting"});case"BBBBB":return R.dayPeriod(j,{width:"narrow",context:"formatting"});case"BBBB":default:return R.dayPeriod(j,{width:"wide",context:"formatting"})}},h:function(x,D,R){if(D==="ho"){var F=x.getUTCHours()%12;return F===0&&(F=12),R.ordinalNumber(F,{unit:"hour"})}return m.default.h(x,D)},H:function(x,D,R){return D==="Ho"?R.ordinalNumber(x.getUTCHours(),{unit:"hour"}):m.default.H(x,D)},K:function(x,D,R){var F=x.getUTCHours()%12;return D==="Ko"?R.ordinalNumber(F,{unit:"hour"}):(0,u.default)(F,D.length)},k:function(x,D,R){var F=x.getUTCHours();return F===0&&(F=24),D==="ko"?R.ordinalNumber(F,{unit:"hour"}):(0,u.default)(F,D.length)},m:function(x,D,R){return D==="mo"?R.ordinalNumber(x.getUTCMinutes(),{unit:"minute"}):m.default.m(x,D)},s:function(x,D,R){return D==="so"?R.ordinalNumber(x.getUTCSeconds(),{unit:"second"}):m.default.s(x,D)},S:function(x,D){return m.default.S(x,D)},X:function(x,D,R,F){var j=F._originalDate||x,G=j.getTimezoneOffset();if(G===0)return"Z";switch(D){case"X":return I(G);case"XXXX":case"XX":return C(G);case"XXXXX":case"XXX":default:return C(G,":")}},x:function(x,D,R,F){var j=F._originalDate||x,G=j.getTimezoneOffset();switch(D){case"x":return I(G);case"xxxx":case"xx":return C(G);case"xxxxx":case"xxx":default:return C(G,":")}},O:function(x,D,R,F){var j=F._originalDate||x,G=j.getTimezoneOffset();switch(D){case"O":case"OO":case"OOO":return"GMT"+A(G,":");case"OOOO":default:return"GMT"+C(G,":")}},z:function(x,D,R,F){var j=F._originalDate||x,G=j.getTimezoneOffset();switch(D){case"z":case"zz":case"zzz":return"GMT"+A(G,":");case"zzzz":default:return"GMT"+C(G,":")}},t:function(x,D,R,F){var j=F._originalDate||x,G=Math.floor(j.getTime()/1e3);return(0,u.default)(G,D.length)},T:function(x,D,R,F){var j=F._originalDate||x,G=j.getTime();return(0,u.default)(G,D.length)}};function A(T,x){var D=T>0?"-":"+",R=Math.abs(T),F=Math.floor(R/60),j=R%60;if(j===0)return D+String(F);var G=x||"";return D+String(F)+G+(0,u.default)(j,2)}function I(T,x){if(T%60===0){var D=T>0?"-":"+";return D+(0,u.default)(Math.abs(T)/60,2)}return C(T,x)}function C(T,x){var D=x||"",R=T>0?"-":"+",F=Math.abs(T),j=(0,u.default)(Math.floor(F/60),2),G=(0,u.default)(F%60,2);return R+j+D+G}var M=w;S.default=M,B.exports=S.default},2699:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(7394)),_={y:function(f,u){var m=f.getUTCFullYear(),d=m>0?m:1-m;return(0,L.default)(u==="yy"?d%100:d,u.length)},M:function(f,u){var m=f.getUTCMonth();return u==="M"?String(m+1):(0,L.default)(m+1,2)},d:function(f,u){return(0,L.default)(f.getUTCDate(),u.length)},a:function(f,u){var m=f.getUTCHours()/12>=1?"pm":"am";switch(u){case"a":case"aa":return m.toUpperCase();case"aaa":return m;case"aaaaa":return m[0];case"aaaa":default:return m==="am"?"a.m.":"p.m."}},h:function(f,u){return(0,L.default)(f.getUTCHours()%12||12,u.length)},H:function(f,u){return(0,L.default)(f.getUTCHours(),u.length)},m:function(f,u){return(0,L.default)(f.getUTCMinutes(),u.length)},s:function(f,u){return(0,L.default)(f.getUTCSeconds(),u.length)},S:function(f,u){var m=u.length,d=f.getUTCMilliseconds(),w=Math.floor(d*Math.pow(10,m-3));return(0,L.default)(w,u.length)}},H=_;S.default=H,B.exports=S.default},5209:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var y=function(f,u){switch(f){case"P":return u.date({width:"short"});case"PP":return u.date({width:"medium"});case"PPP":return u.date({width:"long"});case"PPPP":default:return u.date({width:"full"})}},P=function(f,u){switch(f){case"p":return u.time({width:"short"});case"pp":return u.time({width:"medium"});case"ppp":return u.time({width:"long"});case"pppp":default:return u.time({width:"full"})}},L=function(f,u){var m=f.match(/(P+)(p+)?/)||[],d=m[1],w=m[2];if(!w)return y(f,u);var A;switch(d){case"P":A=u.dateTime({width:"short"});break;case"PP":A=u.dateTime({width:"medium"});break;case"PPP":A=u.dateTime({width:"long"});break;case"PPPP":default:A=u.dateTime({width:"full"});break}return A.replace("{{date}}",y(d,u)).replace("{{time}}",P(w,u))},_={p:P,P:L},H=_;S.default=H,B.exports=S.default},3561:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P){var L=new Date(Date.UTC(P.getFullYear(),P.getMonth(),P.getDate(),P.getHours(),P.getMinutes(),P.getSeconds(),P.getMilliseconds()));return L.setUTCFullYear(P.getFullYear()),P.getTime()-L.getTime()}B.exports=S.default},1603:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(1171)),_=P(y(8734)),H=864e5;function v(f){(0,_.default)(1,arguments);var u=(0,L.default)(f),m=u.getTime();u.setUTCMonth(0,1),u.setUTCHours(0,0,0,0);var d=u.getTime(),w=m-d;return Math.floor(w/H)+1}B.exports=S.default},1354:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var L=P(y(1171)),_=P(y(79)),H=P(y(4275)),v=P(y(8734)),f=6048e5;function u(m){(0,v.default)(1,arguments);var d=(0,L.default)(m),w=(0,_.default)(d).getTime()-(0,H.default)(d).getTime();return Math.round(w/f)+1}B.exports=S.default},1370:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(1171)),_=P(y(8734)),H=P(y(79));function v(f){(0,_.default)(1,arguments);var u=(0,L.default)(f),m=u.getUTCFullYear(),d=new Date(0);d.setUTCFullYear(m+1,0,4),d.setUTCHours(0,0,0,0);var w=(0,H.default)(d),A=new Date(0);A.setUTCFullYear(m,0,4),A.setUTCHours(0,0,0,0);var I=(0,H.default)(A);return u.getTime()>=w.getTime()?m+1:u.getTime()>=I.getTime()?m:m-1}B.exports=S.default},623:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var L=P(y(1171)),_=P(y(9209)),H=P(y(4118)),v=P(y(8734)),f=6048e5;function u(m,d){(0,v.default)(1,arguments);var w=(0,L.default)(m),A=(0,_.default)(w,d).getTime()-(0,H.default)(w,d).getTime();return Math.round(A/f)+1}B.exports=S.default},6226:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var L=P(y(1171)),_=P(y(8734)),H=P(y(9209)),v=P(y(2084)),f=y(8729);function u(m,d){var w,A,I,C,M,T,x,D;(0,_.default)(1,arguments);var R=(0,L.default)(m),F=R.getUTCFullYear(),j=(0,f.getDefaultOptions)(),G=(0,v.default)((w=(A=(I=(C=d==null?void 0:d.firstWeekContainsDate)!==null&&C!==void 0?C:d==null||(M=d.locale)===null||M===void 0||(T=M.options)===null||T===void 0?void 0:T.firstWeekContainsDate)!==null&&I!==void 0?I:j.firstWeekContainsDate)!==null&&A!==void 0?A:(x=j.locale)===null||x===void 0||(D=x.options)===null||D===void 0?void 0:D.firstWeekContainsDate)!==null&&w!==void 0?w:1);if(!(G>=1&&G<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var et=new Date(0);et.setUTCFullYear(F+1,0,G),et.setUTCHours(0,0,0,0);var $=(0,H.default)(et,d),z=new Date(0);z.setUTCFullYear(F,0,G),z.setUTCHours(0,0,0,0);var W=(0,H.default)(z,d);return R.getTime()>=$.getTime()?F+1:R.getTime()>=W.getTime()?F:F-1}B.exports=S.default},6736:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.isProtectedDayOfYearToken=L,S.isProtectedWeekYearToken=_,S.throwProtectedError=H;var y=["D","DD"],P=["YY","YYYY"];function L(v){return y.indexOf(v)!==-1}function _(v){return P.indexOf(v)!==-1}function H(v,f,u){if(v==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(f,"`) for formatting years to the input `").concat(u,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(v==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(f,"`) for formatting years to the input `").concat(u,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(v==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(f,"`) for formatting days of the month to the input `").concat(u,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(v==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(f,"`) for formatting days of the month to the input `").concat(u,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}},8734:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P,L){if(L.length<P)throw new TypeError(P+" argument"+(P>1?"s":"")+" required, but only "+L.length+" present")}B.exports=S.default},79:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=H;var L=P(y(1171)),_=P(y(8734));function H(v){(0,_.default)(1,arguments);var f=1,u=(0,L.default)(v),m=u.getUTCDay(),d=(m<f?7:0)+m-f;return u.setUTCDate(u.getUTCDate()-d),u.setUTCHours(0,0,0,0),u}B.exports=S.default},4275:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(1370)),_=P(y(79)),H=P(y(8734));function v(f){(0,H.default)(1,arguments);var u=(0,L.default)(f),m=new Date(0);m.setUTCFullYear(u,0,4),m.setUTCHours(0,0,0,0);var d=(0,_.default)(m);return d}B.exports=S.default},9209:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=f;var L=P(y(1171)),_=P(y(8734)),H=P(y(2084)),v=y(8729);function f(u,m){var d,w,A,I,C,M,T,x;(0,_.default)(1,arguments);var D=(0,v.getDefaultOptions)(),R=(0,H.default)((d=(w=(A=(I=m==null?void 0:m.weekStartsOn)!==null&&I!==void 0?I:m==null||(C=m.locale)===null||C===void 0||(M=C.options)===null||M===void 0?void 0:M.weekStartsOn)!==null&&A!==void 0?A:D.weekStartsOn)!==null&&w!==void 0?w:(T=D.locale)===null||T===void 0||(x=T.options)===null||x===void 0?void 0:x.weekStartsOn)!==null&&d!==void 0?d:0);if(!(R>=0&&R<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var F=(0,L.default)(u),j=F.getUTCDay(),G=(j<R?7:0)+j-R;return F.setUTCDate(F.getUTCDate()-G),F.setUTCHours(0,0,0,0),F}B.exports=S.default},4118:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var L=P(y(6226)),_=P(y(8734)),H=P(y(9209)),v=P(y(2084)),f=y(8729);function u(m,d){var w,A,I,C,M,T,x,D;(0,_.default)(1,arguments);var R=(0,f.getDefaultOptions)(),F=(0,v.default)((w=(A=(I=(C=d==null?void 0:d.firstWeekContainsDate)!==null&&C!==void 0?C:d==null||(M=d.locale)===null||M===void 0||(T=M.options)===null||T===void 0?void 0:T.firstWeekContainsDate)!==null&&I!==void 0?I:R.firstWeekContainsDate)!==null&&A!==void 0?A:(x=R.locale)===null||x===void 0||(D=x.options)===null||D===void 0?void 0:D.firstWeekContainsDate)!==null&&w!==void 0?w:1),j=(0,L.default)(m,d),G=new Date(0);G.setUTCFullYear(j,0,F),G.setUTCHours(0,0,0,0);var et=(0,H.default)(G,d);return et}B.exports=S.default},2084:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P){if(P===null||P===!0||P===!1)return NaN;var L=Number(P);return isNaN(L)?L:L<0?Math.ceil(L):Math.floor(L)}B.exports=S.default},5065:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(2084)),_=P(y(1171)),H=P(y(8734));function v(f,u){(0,H.default)(2,arguments);var m=(0,_.default)(f).getTime(),d=(0,L.default)(u);return new Date(m+d)}B.exports=S.default},5616:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=R;var L=P(y(9989)),_=P(y(3239)),H=P(y(1171)),v=P(y(7100)),f=P(y(5209)),u=P(y(3561)),m=y(6736),d=P(y(2084)),w=P(y(8734)),A=y(8729),I=P(y(7561)),C=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,M=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,T=/^'([^]*?)'?$/,x=/''/g,D=/[a-zA-Z]/;function R(j,G,et){var $,z,W,Q,it,ft,xt,Dt,Ct,Ut,At,Et,Wt,le,Te,Me,Be,Re;(0,w.default)(2,arguments);var Dn=String(G),Qt=(0,A.getDefaultOptions)(),It=($=(z=et==null?void 0:et.locale)!==null&&z!==void 0?z:Qt.locale)!==null&&$!==void 0?$:I.default,ce=(0,d.default)((W=(Q=(it=(ft=et==null?void 0:et.firstWeekContainsDate)!==null&&ft!==void 0?ft:et==null||(xt=et.locale)===null||xt===void 0||(Dt=xt.options)===null||Dt===void 0?void 0:Dt.firstWeekContainsDate)!==null&&it!==void 0?it:Qt.firstWeekContainsDate)!==null&&Q!==void 0?Q:(Ct=Qt.locale)===null||Ct===void 0||(Ut=Ct.options)===null||Ut===void 0?void 0:Ut.firstWeekContainsDate)!==null&&W!==void 0?W:1);if(!(ce>=1&&ce<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var Fe=(0,d.default)((At=(Et=(Wt=(le=et==null?void 0:et.weekStartsOn)!==null&&le!==void 0?le:et==null||(Te=et.locale)===null||Te===void 0||(Me=Te.options)===null||Me===void 0?void 0:Me.weekStartsOn)!==null&&Wt!==void 0?Wt:Qt.weekStartsOn)!==null&&Et!==void 0?Et:(Be=Qt.locale)===null||Be===void 0||(Re=Be.options)===null||Re===void 0?void 0:Re.weekStartsOn)!==null&&At!==void 0?At:0);if(!(Fe>=0&&Fe<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!It.localize)throw new RangeError("locale must contain localize property");if(!It.formatLong)throw new RangeError("locale must contain formatLong property");var he=(0,H.default)(j);if(!(0,L.default)(he))throw new RangeError("Invalid time value");var An=(0,u.default)(he),Ye=(0,_.default)(he,An),En={firstWeekContainsDate:ce,weekStartsOn:Fe,locale:It,_originalDate:he},be=Dn.match(M).map(function(bt){var Vt=bt[0];if(Vt==="p"||Vt==="P"){var de=f.default[Vt];return de(bt,It.formatLong)}return bt}).join("").match(C).map(function(bt){if(bt==="''")return"'";var Vt=bt[0];if(Vt==="'")return F(bt);var de=v.default[Vt];if(de)return!(et!=null&&et.useAdditionalWeekYearTokens)&&(0,m.isProtectedWeekYearToken)(bt)&&(0,m.throwProtectedError)(bt,G,String(j)),!(et!=null&&et.useAdditionalDayOfYearTokens)&&(0,m.isProtectedDayOfYearToken)(bt)&&(0,m.throwProtectedError)(bt,G,String(j)),de(Ye,bt,It.localize,En);if(Vt.match(D))throw new RangeError("Format string contains an unescaped latin alphabet character `"+Vt+"`");return bt}).join("");return be}function F(j){var G=j.match(T);return G?G[1].replace(x,"'"):j}B.exports=S.default},2382:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=H;var L=P(y(8698)),_=P(y(8734));function H(v){return(0,_.default)(1,arguments),v instanceof Date||(0,L.default)(v)==="object"&&Object.prototype.toString.call(v)==="[object Date]"}B.exports=S.default},9989:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(2382)),_=P(y(1171)),H=P(y(8734));function v(f){if((0,H.default)(1,arguments),!(0,L.default)(f)&&typeof f!="number")return!1;var u=(0,_.default)(f);return!isNaN(Number(u))}B.exports=S.default},289:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=L.width?String(L.width):P.defaultWidth,H=P.formats[_]||P.formats[P.defaultWidth];return H}}B.exports=S.default},6245:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P){return function(L,_){var H=_!=null&&_.context?String(_.context):"standalone",v;if(H==="formatting"&&P.formattingValues){var f=P.defaultFormattingWidth||P.defaultWidth,u=_!=null&&_.width?String(_.width):f;v=P.formattingValues[u]||P.formattingValues[f]}else{var m=P.defaultWidth,d=_!=null&&_.width?String(_.width):P.defaultWidth;v=P.values[d]||P.values[m]}var w=P.argumentCallback?P.argumentCallback(L):L;return v[w]}}B.exports=S.default},3421:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(_){return function(H){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=v.width,u=f&&_.matchPatterns[f]||_.matchPatterns[_.defaultMatchWidth],m=H.match(u);if(!m)return null;var d=m[0],w=f&&_.parsePatterns[f]||_.parsePatterns[_.defaultParseWidth],A=Array.isArray(w)?L(w,function(M){return M.test(d)}):P(w,function(M){return M.test(d)}),I;I=_.valueCallback?_.valueCallback(A):A,I=v.valueCallback?v.valueCallback(I):I;var C=H.slice(d.length);return{value:I,rest:C}}}function P(_,H){for(var v in _)if(_.hasOwnProperty(v)&&H(_[v]))return v}function L(_,H){for(var v=0;v<_.length;v++)if(H(_[v]))return v}B.exports=S.default},8926:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P){return function(L){var _=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=L.match(P.matchPattern);if(!H)return null;var v=H[0],f=L.match(P.parsePattern);if(!f)return null;var u=P.valueCallback?P.valueCallback(f[0]):f[0];u=_.valueCallback?_.valueCallback(u):u;var m=L.slice(v.length);return{value:u,rest:m}}}B.exports=S.default},1924:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var y={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},P=function(H,v,f){var u,m=y[H];return typeof m=="string"?u=m:v===1?u=m.one:u=m.other.replace("{{count}}",v.toString()),f!=null&&f.addSuffix?f.comparison&&f.comparison>0?"in "+u:u+" ago":u},L=P;S.default=L,B.exports=S.default},5062:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(289)),_={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},H={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},v={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},f={date:(0,L.default)({formats:_,defaultWidth:"full"}),time:(0,L.default)({formats:H,defaultWidth:"full"}),dateTime:(0,L.default)({formats:v,defaultWidth:"full"})},u=f;S.default=u,B.exports=S.default},5102:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var y={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},P=function(H,v,f,u){return y[H]},L=P;S.default=L,B.exports=S.default},7839:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(6245)),_={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},H={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},v={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},f={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},u={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},m={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},d=function(C,M){var T=Number(C),x=T%100;if(x>20||x<10)switch(x%10){case 1:return T+"st";case 2:return T+"nd";case 3:return T+"rd"}return T+"th"},w={ordinalNumber:d,era:(0,L.default)({values:_,defaultWidth:"wide"}),quarter:(0,L.default)({values:H,defaultWidth:"wide",argumentCallback:function(C){return C-1}}),month:(0,L.default)({values:v,defaultWidth:"wide"}),day:(0,L.default)({values:f,defaultWidth:"wide"}),dayPeriod:(0,L.default)({values:u,defaultWidth:"wide",formattingValues:m,defaultFormattingWidth:"wide"})},A=w;S.default=A,B.exports=S.default},9796:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(3421)),_=P(y(8926)),H=/^(\d+)(th|st|nd|rd)?/i,v=/\d+/i,f={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},u={any:[/^b/i,/^(a|c)/i]},m={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},d={any:[/1/i,/2/i,/3/i,/4/i]},w={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},A={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},I={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},C={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},M={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},T={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},x={ordinalNumber:(0,_.default)({matchPattern:H,parsePattern:v,valueCallback:function(F){return parseInt(F,10)}}),era:(0,L.default)({matchPatterns:f,defaultMatchWidth:"wide",parsePatterns:u,defaultParseWidth:"any"}),quarter:(0,L.default)({matchPatterns:m,defaultMatchWidth:"wide",parsePatterns:d,defaultParseWidth:"any",valueCallback:function(F){return F+1}}),month:(0,L.default)({matchPatterns:w,defaultMatchWidth:"wide",parsePatterns:A,defaultParseWidth:"any"}),day:(0,L.default)({matchPatterns:I,defaultMatchWidth:"wide",parsePatterns:C,defaultParseWidth:"any"}),dayPeriod:(0,L.default)({matchPatterns:M,defaultMatchWidth:"any",parsePatterns:T,defaultParseWidth:"any"})},D=x;S.default=D,B.exports=S.default},2512:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var L=P(y(1924)),_=P(y(5062)),H=P(y(5102)),v=P(y(7839)),f=P(y(9796)),u={code:"en-US",formatDistance:L.default,formatLong:_.default,formatRelative:H.default,localize:v.default,match:f.default,options:{weekStartsOn:0,firstWeekContainsDate:1}},m=u;S.default=m,B.exports=S.default},3239:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var L=P(y(5065)),_=P(y(8734)),H=P(y(2084));function v(f,u){(0,_.default)(2,arguments);var m=(0,H.default)(u);return(0,L.default)(f,-m)}B.exports=S.default},1171:(B,S,y)=>{"use strict";var P=y(4836).default;Object.defineProperty(S,"__esModule",{value:!0}),S.default=H;var L=P(y(8698)),_=P(y(8734));function H(v){(0,_.default)(1,arguments);var f=Object.prototype.toString.call(v);return v instanceof Date||(0,L.default)(v)==="object"&&f==="[object Date]"?new Date(v.getTime()):typeof v=="number"||f==="[object Number]"?new Date(v):((typeof v=="string"||f==="[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))}B.exports=S.default},5171:B=>{B.exports=function(y){return!y||typeof y=="string"?!1:y instanceof Array||Array.isArray(y)||y.length>=0&&(y.splice instanceof Function||Object.getOwnPropertyDescriptor(y,y.length-1)&&y.constructor.name!=="String")}},6851:(B,S,y)=>{"use strict";var P=y(5171),L=Array.prototype.concat,_=Array.prototype.slice,H=B.exports=function(f){for(var u=[],m=0,d=f.length;m<d;m++){var w=f[m];P(w)?u=L.call(u,_.call(w)):u.push(w)}return u};H.wrap=function(v){return function(){return v(H(arguments))}}},4836:B=>{function S(y){return y&&y.__esModule?y:{default:y}}B.exports=S,B.exports.__esModule=!0,B.exports.default=B.exports},8698:B=>{function S(y){"@babel/helpers - typeof";return B.exports=S=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(P){return typeof P}:function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},B.exports.__esModule=!0,B.exports.default=B.exports,S(y)}B.exports=S,B.exports.__esModule=!0,B.exports.default=B.exports},5721:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(P,L,_,H,v,f,u){var m=new Date(0);return m.setUTCFullYear(P,L,_),m.setUTCHours(H,v,f,u),m}B.exports=S.default},5855:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(H,v,f){var u=_(H,f.timeZone,f.locale);return u.formatToParts?P(u,v):L(u,v)}function P(H,v){for(var f=H.formatToParts(v),u=f.length-1;u>=0;--u)if(f[u].type==="timeZoneName")return f[u].value}function L(H,v){var f=H.format(v).replace(/\u200E/g,""),u=/ [\w-+ ]+$/.exec(f);return u?u[0].substr(1):""}function _(H,v,f){if(f&&!f.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(f?[f.code,"en-US"]:void 0,{timeZone:v,timeZoneName:H})}B.exports=S.default},2734:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var P=_(y(2712)),L=_(y(5721));function _(M){return M&&M.__esModule?M:{default:M}}var H=36e5,v=6e4,f={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function u(M,T,x){var D,R;if(!M||(D=f.timezoneZ.exec(M),D))return 0;var F;if(D=f.timezoneHH.exec(M),D)return F=parseInt(D[1],10),A(F)?-(F*H):NaN;if(D=f.timezoneHHMM.exec(M),D){F=parseInt(D[1],10);var j=parseInt(D[2],10);return A(F,j)?(R=Math.abs(F)*H+j*v,F>0?-R:R):NaN}if(C(M)){T=new Date(T||Date.now());var G=x?T:m(T),et=d(G,M),$=x?et:w(T,et,M);return-$}return NaN}function m(M){return(0,L.default)(M.getFullYear(),M.getMonth(),M.getDate(),M.getHours(),M.getMinutes(),M.getSeconds(),M.getMilliseconds())}function d(M,T){var x=(0,P.default)(M,T),D=(0,L.default)(x[0],x[1]-1,x[2],x[3]%24,x[4],x[5],0).getTime(),R=M.getTime(),F=R%1e3;return R-=F>=0?F:1e3+F,D-R}function w(M,T,x){var D=M.getTime(),R=D-T,F=d(new Date(R),x);if(T===F)return T;R-=F-T;var j=d(new Date(R),x);return F===j?F:Math.max(F,j)}function A(M,T){return-23<=M&&M<=23&&(T==null||0<=T&&T<=59)}var I={};function C(M){if(I[M])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:M}),I[M]=!0,!0}catch(T){return!1}}B.exports=S.default},7048:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var y=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,P=y;S.default=P,B.exports=S.default},2712:(B,S)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=y;function y(f,u){var m=v(u);return m.formatToParts?L(m,f):_(m,f)}var P={year:0,month:1,day:2,hour:3,minute:4,second:5};function L(f,u){try{for(var m=f.formatToParts(u),d=[],w=0;w<m.length;w++){var A=P[m[w].type];A>=0&&(d[A]=parseInt(m[w].value,10))}return d}catch(I){if(I instanceof RangeError)return[NaN];throw I}}function _(f,u){var m=f.format(u).replace(/\u200E/g,""),d=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(m);return[d[3],d[1],d[2],d[4],d[5],d[6]]}var H={};function v(f){if(!H[f]){var u=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),m=u==="06/25/2014, 00:00:00"||u==="\u200E06\u200E/\u200E25\u200E/\u200E2014\u200E \u200E00\u200E:\u200E00\u200E:\u200E00";H[f]=m?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:f,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:f,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return H[f]}B.exports=S.default},3826:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=void 0;var P=_(y(5855)),L=_(y(2734));function _(I){return I&&I.__esModule?I:{default:I}}var H=60*1e3,v={X:function(I,C,M,T){var x=f(T.timeZone,T._originalDate||I);if(x===0)return"Z";switch(C){case"X":return d(x);case"XXXX":case"XX":return m(x);case"XXXXX":case"XXX":default:return m(x,":")}},x:function(I,C,M,T){var x=f(T.timeZone,T._originalDate||I);switch(C){case"x":return d(x);case"xxxx":case"xx":return m(x);case"xxxxx":case"xxx":default:return m(x,":")}},O:function(I,C,M,T){var x=f(T.timeZone,T._originalDate||I);switch(C){case"O":case"OO":case"OOO":return"GMT"+w(x,":");case"OOOO":default:return"GMT"+m(x,":")}},z:function(I,C,M,T){var x=T._originalDate||I;switch(C){case"z":case"zz":case"zzz":return(0,P.default)("short",x,T);case"zzzz":default:return(0,P.default)("long",x,T)}}};function f(I,C){var M=I?(0,L.default)(I,C,!0)/H:C.getTimezoneOffset();if(Number.isNaN(M))throw new RangeError("Invalid time zone specified: "+I);return M}function u(I,C){for(var M=I<0?"-":"",T=Math.abs(I).toString();T.length<C;)T="0"+T;return M+T}function m(I,C){var M=C||"",T=I>0?"-":"+",x=Math.abs(I),D=u(Math.floor(x/60),2),R=u(Math.floor(x%60),2);return T+D+M+R}function d(I,C){if(I%60===0){var M=I>0?"-":"+";return M+u(Math.abs(I)/60,2)}return m(I,C)}function w(I,C){var M=I>0?"-":"+",T=Math.abs(I),x=Math.floor(T/60),D=T%60;if(D===0)return M+String(x);var R=C||"";return M+String(x)+R+u(D,2)}var A=v;S.default=A,B.exports=S.default},6558:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=f;var P=H(y(5616)),L=H(y(3826)),_=H(y(1476));function H(u){return u&&u.__esModule?u:{default:u}}var v=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function f(u,m,d){var w=String(m),A=d||{},I=w.match(v);if(I){var C=(0,_.default)(u,A);w=I.reduce(function(M,T){if(T[0]==="'")return M;var x=M.indexOf(T),D=M[x-1]==="'",R=M.replace(T,"'"+L.default[T[0]](C,T,null,A)+"'");return D?R.substring(0,x-1)+R.substring(x+1):R},w)}return(0,P.default)(u,w,A)}B.exports=S.default},6645:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=v;var P=H(y(6420)),L=H(y(6558)),_=H(y(1132));function H(f){return f&&f.__esModule?f:{default:f}}function v(f,u,m,d){var w=(0,P.default)(d);return w.timeZone=u,(0,L.default)((0,_.default)(f,u),m,w)}B.exports=S.default},4992:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=_;var P=L(y(2734));function L(H){return H&&H.__esModule?H:{default:H}}function _(H,v){return-(0,P.default)(H,v)}B.exports=S.default},722:(B,S,y)=>{"use strict";B.exports={format:y(6558),formatInTimeZone:y(6645),getTimezoneOffset:y(4992),toDate:y(1476),utcToZonedTime:y(1132),zonedTimeToUtc:y(8516)}},1476:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=w;var P=v(y(2084)),L=v(y(3561)),_=v(y(2734)),H=v(y(7048));function v($){return $&&$.__esModule?$:{default:$}}var f=36e5,u=6e4,m=2,d={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:H.default};function w($,z){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if($===null)return new Date(NaN);var W=z||{},Q=W.additionalDigits==null?m:(0,P.default)(W.additionalDigits);if(Q!==2&&Q!==1&&Q!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if($ instanceof Date||typeof $=="object"&&Object.prototype.toString.call($)==="[object Date]")return new Date($.getTime());if(typeof $=="number"||Object.prototype.toString.call($)==="[object Number]")return new Date($);if(!(typeof $=="string"||Object.prototype.toString.call($)==="[object String]"))return new Date(NaN);var it=A($),ft=I(it.date,Q),xt=ft.year,Dt=ft.restDateString,Ct=C(Dt,xt);if(isNaN(Ct))return new Date(NaN);if(Ct){var Ut=Ct.getTime(),At=0,Et;if(it.time&&(At=M(it.time),isNaN(At)))return new Date(NaN);if(it.timeZone||W.timeZone){if(Et=(0,_.default)(it.timeZone||W.timeZone,new Date(Ut+At)),isNaN(Et))return new Date(NaN)}else Et=(0,L.default)(new Date(Ut+At)),Et=(0,L.default)(new Date(Ut+At+Et));return new Date(Ut+At+Et)}else return new Date(NaN)}function A($){var z={},W=d.dateTimePattern.exec($),Q;if(W?(z.date=W[1],Q=W[3]):(W=d.datePattern.exec($),W?(z.date=W[1],Q=W[2]):(z.date=null,Q=$)),Q){var it=d.timeZone.exec(Q);it?(z.time=Q.replace(it[1],""),z.timeZone=it[1].trim()):z.time=Q}return z}function I($,z){var W=d.YYY[z],Q=d.YYYYY[z],it;if(it=d.YYYY.exec($)||Q.exec($),it){var ft=it[1];return{year:parseInt(ft,10),restDateString:$.slice(ft.length)}}if(it=d.YY.exec($)||W.exec($),it){var xt=it[1];return{year:parseInt(xt,10)*100,restDateString:$.slice(xt.length)}}return{year:null}}function C($,z){if(z===null)return null;var W,Q,it,ft;if($.length===0)return Q=new Date(0),Q.setUTCFullYear(z),Q;if(W=d.MM.exec($),W)return Q=new Date(0),it=parseInt(W[1],10)-1,F(z,it)?(Q.setUTCFullYear(z,it),Q):new Date(NaN);if(W=d.DDD.exec($),W){Q=new Date(0);var xt=parseInt(W[1],10);return j(z,xt)?(Q.setUTCFullYear(z,0,xt),Q):new Date(NaN)}if(W=d.MMDD.exec($),W){Q=new Date(0),it=parseInt(W[1],10)-1;var Dt=parseInt(W[2],10);return F(z,it,Dt)?(Q.setUTCFullYear(z,it,Dt),Q):new Date(NaN)}if(W=d.Www.exec($),W)return ft=parseInt(W[1],10)-1,G(z,ft)?T(z,ft):new Date(NaN);if(W=d.WwwD.exec($),W){ft=parseInt(W[1],10)-1;var Ct=parseInt(W[2],10)-1;return G(z,ft,Ct)?T(z,ft,Ct):new Date(NaN)}return null}function M($){var z,W,Q;if(z=d.HH.exec($),z)return W=parseFloat(z[1].replace(",",".")),et(W)?W%24*f:NaN;if(z=d.HHMM.exec($),z)return W=parseInt(z[1],10),Q=parseFloat(z[2].replace(",",".")),et(W,Q)?W%24*f+Q*u:NaN;if(z=d.HHMMSS.exec($),z){W=parseInt(z[1],10),Q=parseInt(z[2],10);var it=parseFloat(z[3].replace(",","."));return et(W,Q,it)?W%24*f+Q*u+it*1e3:NaN}return null}function T($,z,W){z=z||0,W=W||0;var Q=new Date(0);Q.setUTCFullYear($,0,4);var it=Q.getUTCDay()||7,ft=z*7+W+1-it;return Q.setUTCDate(Q.getUTCDate()+ft),Q}var x=[31,28,31,30,31,30,31,31,30,31,30,31],D=[31,29,31,30,31,30,31,31,30,31,30,31];function R($){return $%400===0||$%4===0&&$%100!==0}function F($,z,W){if(z<0||z>11)return!1;if(W!=null){if(W<1)return!1;var Q=R($);if(Q&&W>D[z]||!Q&&W>x[z])return!1}return!0}function j($,z){if(z<1)return!1;var W=R($);return!(W&&z>366||!W&&z>365)}function G($,z,W){return!(z<0||z>52||W!=null&&(W<0||W>6))}function et($,z,W){return!($!=null&&($<0||$>=25)||z!=null&&(z<0||z>=60)||W!=null&&(W<0||W>=60))}B.exports=S.default},1132:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=H;var P=_(y(2734)),L=_(y(1476));function _(v){return v&&v.__esModule?v:{default:v}}function H(v,f,u){var m=(0,L.default)(v,u),d=(0,P.default)(f,m,!0),w=new Date(m.getTime()-d),A=new Date(0);return A.setFullYear(w.getUTCFullYear(),w.getUTCMonth(),w.getUTCDate()),A.setHours(w.getUTCHours(),w.getUTCMinutes(),w.getUTCSeconds(),w.getUTCMilliseconds()),A}B.exports=S.default},8516:(B,S,y)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0}),S.default=u;var P=f(y(6420)),L=f(y(1476)),_=f(y(7048)),H=f(y(2734)),v=f(y(5721));function f(m){return m&&m.__esModule?m:{default:m}}function u(m,d,w){if(typeof m=="string"&&!m.match(_.default)){var A=(0,P.default)(w);return A.timeZone=d,(0,L.default)(m,A)}var I=(0,L.default)(m,w),C=(0,v.default)(I.getFullYear(),I.getMonth(),I.getDate(),I.getHours(),I.getMinutes(),I.getSeconds(),I.getMilliseconds()).getTime(),M=(0,H.default)(d,new Date(C));return new Date(C+M)}B.exports=S.default}},Ps={};function _t(B){var S=Ps[B];if(S!==void 0)return S.exports;var y=Ps[B]={exports:{}};return Ya[B](y,y.exports,_t),y.exports}_t.n=B=>{var S=B&&B.__esModule?()=>B.default:()=>B;return _t.d(S,{a:S}),S},_t.d=(B,S)=>{for(var y in S)_t.o(S,y)&&!_t.o(B,y)&&Object.defineProperty(B,y,{enumerable:!0,get:S[y]})},_t.o=(B,S)=>Object.prototype.hasOwnProperty.call(B,S),_t.r=B=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(B,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(B,"__esModule",{value:!0})};var _n={};(()=>{"use strict";_t.r(_n),_t.d(_n,{Chart:()=>La,createChart:()=>pg,generateCandlesData:()=>mg});function B(n){return typeof n=="function"}function S(n){return B(n==null?void 0:n.lift)}function y(n){return function(t){if(S(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 P=function(n,t){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])},P(n,t)};function L(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");P(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var _=function(){return _=Object.assign||function(t){for(var e,s=1,r=arguments.length;s<r;s++){e=arguments[s];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},_.apply(this,arguments)};function H(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 r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(e[s[r]]=n[s[r]]);return e}function v(n,t,e,s){var r=arguments.length,i=r<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,t,e,s);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(i=(r<3?a(i):r>3?a(t,e,i):a(t,e))||i);return r>3&&i&&Object.defineProperty(t,e,i),i}function f(n,t){return function(e,s){t(e,s,n)}}function u(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function m(n,t,e,s){function r(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function o(h){try{c(s.next(h))}catch(g){a(g)}}function l(h){try{c(s.throw(h))}catch(g){a(g)}}function c(h){h.done?i(h.value):r(h.value).then(o,l)}c((s=s.apply(n,t||[])).next())})}function d(n,t){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,r,i,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(c){return function(h){return l([c,h])}}function l(c){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(e=0)),e;)try{if(s=1,r&&(i=c[0]&2?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,r=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],r=0}finally{s=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var w=Object.create?function(n,t,e,s){s===void 0&&(s=e);var r=Object.getOwnPropertyDescriptor(t,e);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,s,r)}:function(n,t,e,s){s===void 0&&(s=e),n[s]=t[e]};function A(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&w(t,n,e)}function I(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 C(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var s=e.call(n),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(a)throw a.error}}return i}function M(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(C(arguments[t]));return n}function T(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var s=Array(n),r=0,t=0;t<e;t++)for(var i=arguments[t],a=0,o=i.length;a<o;a++,r++)s[r]=i[a];return s}function x(n,t,e){if(e||arguments.length===2)for(var s=0,r=t.length,i;s<r;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return n.concat(i||Array.prototype.slice.call(t))}function D(n){return this instanceof D?(this.v=n,this):new D(n)}function R(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=e.apply(n,t||[]),r,i=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(p){s[p]&&(r[p]=function(b){return new Promise(function(E,O){i.push([p,b,E,O])>1||o(p,b)})})}function o(p,b){try{l(s[p](b))}catch(E){g(i[0][3],E)}}function l(p){p.value instanceof D?Promise.resolve(p.value.v).then(c,h):g(i[0][2],p)}function c(p){o("next",p)}function h(p){o("throw",p)}function g(p,b){p(b),i.shift(),i.length&&o(i[0][0],i[0][1])}}function F(n){var t,e;return t={},s("next"),s("throw",function(r){throw r}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(r,i){t[r]=n[r]?function(a){return(e=!e)?{value:D(n[r](a)),done:r==="return"}:i?i(a):a}:i}}function j(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 I=="function"?I(n):n[Symbol.iterator](),e={},s("next"),s("throw"),s("return"),e[Symbol.asyncIterator]=function(){return this},e);function s(i){e[i]=n[i]&&function(a){return new Promise(function(o,l){a=n[i](a),r(o,l,a.done,a.value)})}}function r(i,a,o,l){Promise.resolve(l).then(function(c){i({value:c,done:o})},a)}}function G(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var et=Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t};function $(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)&&w(t,n,e);return et(t,n),t}function z(n){return n&&n.__esModule?n:{default:n}}function W(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 Q(n,t,e,s,r){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?r.call(n,e):r?r.value=e:t.set(n,e),e}function it(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 ft(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 xt=ft(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
7
|
-
`+e.map(function(
|
|
8
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Dt(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var Ct=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,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=I(a),l=o.next();!l.done;l=o.next()){var c=l.value;c.remove(this)}}catch(O){t={error:O}}finally{try{l&&!l.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else a.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(O){i=O instanceof xt?O.errors:[O]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var p=I(g),b=p.next();!b.done;b=p.next()){var E=b.value;try{Et(E)}catch(O){i=i!=null?i:[],O instanceof xt?i=x(x([],C(i)),C(O.errors)):i.push(O)}}}catch(O){s={error:O}}finally{try{b&&!b.done&&(r=p.return)&&r.call(p)}finally{if(s)throw s.error}}}if(i)throw new xt(i)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Et(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)&&Dt(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Dt(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),Ut=Ct.EMPTY;function At(n){return n instanceof Ct||n&&"closed"in n&&B(n.remove)&&B(n.add)&&B(n.unsubscribe)}function Et(n){B(n)?n():n.unsubscribe()}var Wt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},le={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var r=le.delegate;return r!=null&&r.setTimeout?r.setTimeout.apply(r,x([n,t],C(e))):setTimeout.apply(void 0,x([n,t],C(e)))},clearTimeout:function(n){var t=le.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Te(n){le.setTimeout(function(){var t=Wt.onUnhandledError;if(t)t(n);else throw n})}function Me(){}var Be=function(){return Qt("C",void 0,void 0)}();function Re(n){return Qt("E",void 0,n)}function Dn(n){return Qt("N",n,void 0)}function Qt(n,t,e){return{kind:n,value:t,error:e}}var It=null;function ce(n){if(Wt.useDeprecatedSynchronousErrorHandling){var t=!It;if(t&&(It={errorThrown:!1,error:null}),n(),t){var e=It,s=e.errorThrown,r=e.error;if(It=null,s)throw r}}else n()}function Fe(n){Wt.useDeprecatedSynchronousErrorHandling&&It&&(It.errorThrown=!0,It.error=n)}var he=function(n){L(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,At(e)&&e.add(s)):s.destination=Na,s}return t.create=function(e,s,r){return new be(e,s,r)},t.prototype.next=function(e){this.isStopped?de(Dn(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?de(Re(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?de(Be,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}(Ct),An=Function.prototype.bind;function Ye(n,t){return An.call(n,t)}var En=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){bt(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){bt(s)}else bt(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){bt(e)}},n}(),be=function(n){L(t,n);function t(e,s,r){var i=n.call(this)||this,a;if(B(e)||!e)a={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:r!=null?r:void 0};else{var o;i&&Wt.useDeprecatedNextContext?(o=Object.create(e),o.unsubscribe=function(){return i.unsubscribe()},a={next:e.next&&Ye(e.next,o),error:e.error&&Ye(e.error,o),complete:e.complete&&Ye(e.complete,o)}):a=e}return i.destination=new En(a),i}return t}(he);function bt(n){Wt.useDeprecatedSynchronousErrorHandling?Fe(n):Te(n)}function Vt(n){throw n}function de(n,t){var e=Wt.onStoppedNotification;e&&le.setTimeout(function(){return e(n,t)})}var Na={closed:!0,next:Me,error:Vt,complete:Me};function Xt(n,t,e,s,r){return new Ha(n,t,e,s,r)}var Ha=function(n){L(t,n);function t(e,s,r,i,a,o){var l=n.call(this,e)||this;return l.onFinalize=a,l.shouldUnsubscribe=o,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=i?function(c){try{i(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=r?function(){try{r()}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}(he);function yt(n,t){return y(function(e,s){var r=0;e.subscribe(Xt(s,function(i){s.next(n.call(t,i,r++))}))})}var Ts=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function Ms(n){return B(n==null?void 0:n.then)}var In=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function _e(n){return n}function Cg(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return _s(n)}function _s(n){return n.length===0?_e:n.length===1?n[0]:function(e){return n.reduce(function(s,r){return r(s)},e)}}var Tt=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 r=this,i=ja(t)?t:new be(t,e,s);return ce(function(){var a=r,o=a.operator,l=a.source;i.add(o?o.call(i,l):l?r._subscribe(i):r._trySubscribe(i))}),i},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=Ds(e),new e(function(r,i){var a=new be({next:function(o){try{t(o)}catch(l){i(l),a.unsubscribe()}},error:i,complete:r});s.subscribe(a)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[In]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _s(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Ds(t),new t(function(s,r){var i;e.subscribe(function(a){return i=a},function(a){return r(a)},function(){return s(i)})})},n.create=function(t){return new n(t)},n}();function Ds(n){var t;return(t=n!=null?n:Wt.Promise)!==null&&t!==void 0?t:Promise}function ka(n){return n&&B(n.next)&&B(n.error)&&B(n.complete)}function ja(n){return n&&n instanceof he||ka(n)&&At(n)}function As(n){return B(n[In])}function Es(n){return Symbol.asyncIterator&&B(n==null?void 0:n[Symbol.asyncIterator])}function Is(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 Ua(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Os=Ua();function Ls(n){return B(n==null?void 0:n[Os])}function Bs(n){return R(this,arguments,function(){var e,s,r,i;return d(this,function(a){switch(a.label){case 0:e=n.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,D(e.read())];case 3:return s=a.sent(),r=s.value,i=s.done,i?[4,D(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,D(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Rs(n){return B(n==null?void 0:n.getReader)}function te(n){if(n instanceof Tt)return n;if(n!=null){if(As(n))return Wa(n);if(Ts(n))return Xa(n);if(Ms(n))return za(n);if(Es(n))return Fs(n);if(Ls(n))return Va(n);if(Rs(n))return Ga(n)}throw Is(n)}function Wa(n){return new Tt(function(t){var e=n[In]();if(B(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Xa(n){return new Tt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function za(n){return new Tt(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Te)})}function Va(n){return new Tt(function(t){var e,s;try{for(var r=I(n),i=r.next();!i.done;i=r.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(o){e={error:o}}finally{try{i&&!i.done&&(s=r.return)&&s.call(r)}finally{if(e)throw e.error}}t.complete()})}function Fs(n){return new Tt(function(t){$a(n,t).catch(function(e){return t.error(e)})})}function Ga(n){return Fs(Bs(n))}function $a(n,t){var e,s,r,i;return m(this,void 0,void 0,function(){var a,o;return d(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=j(n),l.label=1;case 1:return[4,e.next()];case 2:if(s=l.sent(),!!s.done)return[3,4];if(a=s.value,t.next(a),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return o=l.sent(),r={error:o},[3,11];case 6:return l.trys.push([6,,9,10]),s&&!s.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ee(n,t,e,s,r){s===void 0&&(s=0),r===void 0&&(r=!1);var i=t.schedule(function(){e(),r?n.add(this.schedule(null,s)):this.unsubscribe()},s);if(n.add(i),!r)return i}function Za(n,t,e,s,r,i,a,o){var l=[],c=0,h=0,g=!1,p=function(){g&&!l.length&&!c&&t.complete()},b=function(O){return c<s?E(O):l.push(O)},E=function(O){i&&t.next(O),c++;var N=!1;te(e(O,h++)).subscribe(Xt(t,function(k){r==null||r(k),i?b(k):t.next(k)},function(){N=!0},void 0,function(){if(N)try{c--;for(var k=function(){var V=l.shift();a?ee(t,a,function(){return E(V)}):E(V)};l.length&&c<s;)k();p()}catch(V){t.error(V)}}))};return n.subscribe(Xt(t,b,function(){g=!0,p()})),function(){o==null||o()}}function Ys(n,t,e){return e===void 0&&(e=1/0),B(t)?Ys(function(s,r){return yt(function(i,a){return t(s,i,r,a)})(te(n(s,r)))},e):(typeof t=="number"&&(e=t),y(function(s,r){return Za(s,r,n,e)}))}function Ns(n){return n===void 0&&(n=1/0),Ys(_e,n)}var Hs=new Tt(function(n){return n.complete()});function yg(n){return n?Ka(n):Hs}function Ka(n){return new Observable(function(t){return n.schedule(function(){return t.complete()})})}function ks(n){return n&&B(n.schedule)}function On(n){return n[n.length-1]}function Ja(n){return B(On(n))?n.pop():void 0}function Je(n){return ks(On(n))?n.pop():void 0}function qa(n,t){return typeof On(n)=="number"?n.pop():t}function js(n,t){return t===void 0&&(t=0),y(function(e,s){e.subscribe(Xt(s,function(r){return ee(s,n,function(){return s.next(r)},t)},function(){return ee(s,n,function(){return s.complete()},t)},function(r){return ee(s,n,function(){return s.error(r)},t)}))})}function Us(n,t){return t===void 0&&(t=0),y(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function Qa(n,t){return te(n).pipe(Us(t),js(t))}function to(n,t){return te(n).pipe(Us(t),js(t))}function eo(n,t){return new Tt(function(e){var s=0;return t.schedule(function(){s===n.length?e.complete():(e.next(n[s++]),e.closed||this.schedule())})})}function no(n,t){return new Tt(function(e){var s;return ee(e,t,function(){s=n[Os](),ee(e,t,function(){var r,i,a;try{r=s.next(),i=r.value,a=r.done}catch(o){e.error(o);return}a?e.complete():e.next(i)},0,!0)}),function(){return B(s==null?void 0:s.return)&&s.return()}})}function Ws(n,t){if(!n)throw new Error("Iterable cannot be null");return new Tt(function(e){ee(e,t,function(){var s=n[Symbol.asyncIterator]();ee(e,t,function(){s.next().then(function(r){r.done?e.complete():e.next(r.value)})},0,!0)})})}function so(n,t){return Ws(Bs(n),t)}function ro(n,t){if(n!=null){if(As(n))return Qa(n,t);if(Ts(n))return eo(n,t);if(Ms(n))return to(n,t);if(Es(n))return Ws(n,t);if(Ls(n))return no(n,t);if(Rs(n))return so(n,t)}throw Is(n)}function qe(n,t){return t?ro(n,t):te(n)}function Ot(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Je(n),s=qa(n,1/0),r=n;return r.length?r.length===1?te(r[0]):Ns(s)(qe(r,e)):Hs}class Ln{constructor(t,e){this.onTickFunction=e,this.animationTimeLeft=0,this.animationInProgress=!1,this.animationTime=t.duration,this.animationTimeLeft=t.timeLeft===void 0?t.duration:t.timeLeft,this.animationInProgress=!0}tick(){this.animationTimeLeft<=0?this.animationInProgress=!1:this.animationTimeLeft--,this.onTickFunction&&this.onTickFunction()}getProgress(){return 1-this.animationTimeLeft/this.animationTime}finishAnimation(){this.animationInProgress=!1,this.animationTimeLeft=0}}var io=_t(6767),Gt=_t.n(io);class ao extends Ln{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(r=>{r.rgbColor=Gt().rgb(r.color),r.initialAlpha=r.rgbColor.valpha,r.currentAnimationColor=r.rgbColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{t.initialAlpha===void 0||t.rgbColor===void 0||(t.type==="fading"?t.currentAnimationColor=t.rgbColor.alpha(t.initialAlpha*this.animationTimeLeft/this.animationTime):t.type==="appearing"&&(t.currentAnimationColor=t.rgbColor.alpha(t.initialAlpha*(1-this.animationTimeLeft/this.animationTime))))})}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"})}}class oo extends Ln{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(r=>{r.rgbStartColor=Gt().rgb(r.startColor),r.rgbEndColor=Gt().rgb(r.endColor),r.currentAnimationColor=r.type==="appearing"?r.rgbStartColor:r.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 r=t.red()-(t.red()-e.red())*s,i=t.green()-(t.green()-e.green())*s,a=t.blue()-(t.blue()-e.blue())*s;return Gt().rgb(r,i,a)}}var lo=Math.pow;const Qe=14,tn=[];for(let n=0;n<Qe+1;n++)tn.push(lo(10,n));const Bn=5e-13;class wt{static roundToNearest(t,e){return isFinite(t)?wt.isZero(t)?0:(t>0?t+=Bn:t<0&&(t-=Bn),wt.roundDecimal(Math.round(wt.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return wt.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),r=Math.min(Qe,Qe-1-Math.floor(Math.log10(s)));for(let i=r;i>=0;i--){const a=Math.floor(tn[i]*s+.5);if(a<tn[Qe])return e*a/tn[i]}return Math.round(t)}static makeDecimal(t,e,s){if(isFinite(t)){const r=t.toFixed(e);return s?r.replace(".",s):r}else 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 wt.compare(t,0,Bn)===0}static cutNumber(t,e,s=0){return{K:i=>i/1e3,M:i=>i/1e6}[e](t).toFixed(s)+e}}function co(n,t,e){const s=n/t;return s>=e||s<=1/e}function Xs(n,t,e){return Math.max(t,Math.min(n,e))}function ho(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Ne(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const gt=n=>~~n,uo=n=>~~(n+1),Ce=n=>~~(n+.5),fo=(n,t)=>n>>t;function Ft(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}class go extends Ln{constructor(t,e,s){var r;super(e,s),this.viewportModel=t,this.animationConfig=e,this.id=Ft(),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=(r=e.easingFn)!=null?r:ho}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,r=this.yStart+(this.animationConfig.targetYStart-this.yStart)*t,i=this.yEnd+(this.animationConfig.targetYEnd-this.yEnd)*t,a=this.zoomX+(this.animationConfig.targetZoomX-this.zoomX)*t,o=this.zoomY+(this.animationConfig.targetZoomY-this.zoomY)*t;this.viewportModel.apply({xStart:e,xEnd:s,yStart:r,yEnd:i,zoomX:a,zoomY:o,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 vo=Object.defineProperty,mo=Object.defineProperties,po=Object.getOwnPropertyDescriptors,zs=Object.getOwnPropertySymbols,bo=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable,Vs=(n,t,e)=>t in n?vo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,yo=(n,t)=>{for(var e in t||(t={}))bo.call(t,e)&&Vs(n,e,t[e]);if(zs)for(var e of zs(t))Co.call(t,e)&&Vs(n,e,t[e]);return n},wo=(n,t)=>mo(n,po(t));const Gs=10,Rn="VIEWPORT_ANIMATION";class So{constructor(t){this.eventBus=t,this.animations={}}startViewportMovementAnimation(t,e,s=Rn,r){const i=new go(t,e,r);return this.animations[s]=i,this.ensureIntervalStarted(),i}startColorAlphaAnimation(t,e,s,r){const i=new ao(wo(yo({},r),{duration:r&&r.duration||Gs}),e,s);return this.animations[t]=i,this.ensureIntervalStarted(),i}startColorTransitionAnimation(t,e,s=Gs,r){const i=new oo({duration:s},e,r);return this.animations[t]=i,this.ensureIntervalStarted(),i}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.animationTimeLeft=-1,e.animationInProgress=!1)}ensureIntervalStarted(){this.animationIntervalId||(this.animationIntervalId=window.setInterval(()=>this.tick(),20))}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}t?this.stopInterval():this.eventBus.fireDraw()}stopInterval(){clearInterval(this.animationIntervalId),this.animationIntervalId=void 0}}var xo=ft(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),X=function(n){L(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 $s(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new xo},t.prototype.next=function(e){var s=this;ce(function(){var r,i;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var a=I(s.currentObservers),o=a.next();!o.done;o=a.next()){var l=o.value;l.next(e)}}catch(c){r={error:c}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var s=this;ce(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var r=s.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;ce(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,r=this,i=r.hasError,a=r.isStopped,o=r.observers;return i||a?Ut:(this.currentObservers=null,o.push(e),new Ct(function(){s.currentObservers=null,Dt(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,r=s.hasError,i=s.thrownError,a=s.isStopped;r?e.error(i):a&&e.complete()},t.prototype.asObservable=function(){var e=new Tt;return e.source=this,e},t.create=function(e,s){return new $s(e,s)},t}(Tt),$s=function(n){L(t,n);function t(e,s){var r=n.call(this)||this;return r.destination=e,r.source=s,r}return t.prototype.next=function(e){var s,r;(r=(s=this.destination)===null||s===void 0?void 0:s.next)===null||r===void 0||r.call(s,e)},t.prototype.error=function(e){var s,r;(r=(s=this.destination)===null||s===void 0?void 0:s.error)===null||r===void 0||r.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,r;return(r=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&r!==void 0?r:Ut},t}(X),$t=function(n){L(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,r=e.thrownError,i=e._value;if(s)throw r;return this._throwIfClosed(),i},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t}(X);function Zt(n,t){return t===void 0&&(t=_e),n=n!=null?n:Po,y(function(e,s){var r,i=!0;e.subscribe(Xt(s,function(a){var o=t(a);(i||!n(r,o))&&(i=!1,r=o,s.next(a))}))})}function Po(n,t){return n===t}function To(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Fn(n){return n}function Zs(n){return n!=null}const wg=()=>{};function Sg(n){return n!=null}function Mo(n,t,e=_o,s=!0){const r=n.filter(i=>t.some(a=>e(i,a)));return s?r.filter((i,a,o)=>o.indexOf(i)===a):r}const Ks=(n,t)=>{const e=t.slice().filter(s=>n.find(r=>r===s));return n.map(s=>{var r;return t.indexOf(s)>=0&&(r=e.shift())!=null?r:s})},_o=(n,t)=>n===t,xg=(n,t,e)=>n.filter(s=>t.filter(r=>e(s,r)).length===0),Do=(n,t)=>n===t,Js=(n,t,e=Do)=>n.length===t.length&&n.every((s,r)=>e(s,t[r]));function Pg(n,t,e){const s=n.slice(),r=s[t];return s.splice(t,1),s.splice(e,0,r),s}function Yn(n,t,e){const s=n.length,r=Xs(t,0,s-1),i=Xs(e,0,s-1),a=n[r];return n.splice(r,1),n.splice(i,0,a),n}function Tg(n,t,e){const s=n.slice(),r=s.findIndex(t);return r!==-1&&(s.splice(r,1),s.splice(r,0,e)),s}const Mg=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},_g=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),Dg=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),Ag=n=>Array.isArray(n[0]),qs=n=>Array.isArray(n[0])?n:[n],Ao=(n,t,e)=>{const s=[];let r=0;for(const i of n){const a=Math.max(t-r,0),o=Math.max(e-r,-1),l=i.slice(a,o+1);l.length>0&&s.push(l),r+=i.length}return s},Eo=(n,t)=>n>=0?t[n]:t[t.length+n],Lt=n=>Array.prototype.flat?n.flat():He(n,Fn),He=(n,t)=>{if(Array.prototype.flatMap)return n.flatMap(t);const e=[];for(let s=0;s<n.length;s++){const r=n[s];e.push(...t(r,s,n))}return e};function ue(n,t,e){const s=e!=null?e:Fn;return!n.length||t!==t?{index:-1,exact:!0}:Nn(n,t,0,n.length,s)}function Nn(n,t,e,s,r){const i=fo(e+s,1),a=r(n[i]);return t===a?{index:i,exact:!0}:e===i?{index:e,exact:!1}:t<a?Nn(n,t,e,i,r):Nn(n,t,i,s,r)}function Yt(n){if(n&&n.length)return n[n.length-1]}function Io(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Oo(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ke(n){if(n)return n[0]}function Lo(n){function t(e,s){const r=n(s);return r==null||!isFinite(r)?e:[Math.max(e[0],r),Math.min(e[1],r)]}return function(e){const s=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,s):s}}function Bo(n,t,e,s=()=>0){const r=(a,o)=>{let l=0,c=a.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(a[h])<=o?l=h+1:c=h-1}return c},i=(a,o)=>{let l=0,c=a.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(a[h])>=o?c=h-1:l=h+1}return l};return n.slice(i(n,t),r(n,e)+1)}let Hn;const kn=()=>(Hn||(Hn=!!navigator.userAgent.match(/Android|iPhone|Opera Mini/)||!1),Hn);function Qs(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 jn(n){const t=n.font.match(/(\d+.)?\d+(px|pt)/gi);let e="10px";return t&&t.length&&(t[0].includes("pt")?e=+t[0].slice(0,t[0].indexOf("pt"))*96/72+"px":e=t[0]),parseInt(e,10)*1.33}function tr(n,t,e){n.save(),Qs(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(a=>n.measureText(a).width))),r=jn(n),i=r*t.length;return n.restore(),[s,i,r]}function er(n){return(n||"").split(/\r\n|\r|\n/)}function Ro(n,t,e,s,r){n.save();const[i,,a]=tr(n,t,r);t.forEach((o,l)=>{var c,h,g;const p=n.measureText(o).width,b=Fo(e,i,p,(c=r.textAlign)!=null?c:"left");r.textStyle&&r.textStyle.underline&&Yo(n,o,b,s+a*l,(h=r.textFill)!=null?h:"",(g=r.textSize)!=null?g:""),n.fillText(o,b,s+a*l)}),n.restore()}function Fo(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function Yo(n,t,e,s,r,i){n.save();const a=n.measureText(t).width,o=e,l=e+a,c=s+2,h=c;let g=parseInt(i,10)/15;g<1&&(g=1),n.beginPath(),n.strokeStyle=r,n.lineWidth=g,n.moveTo(o,c),n.lineTo(l,h),n.stroke(),n.restore()}function Eg(n){return`${n}px`}function fe(n,t,e){const s=Gt().rgb(n).array(),r=s[0],i=s[1],a=s[2];return(r*299+i*587+a*114)/1e3<128?t:e}function No(n,t,e,s){const r=s.components.navigationMap.timeLabels,i=r.padding,a=nr(t,r.dateFormat,e),o=er(a),l={textFontFamily:r.fontFamily,textSize:`${r.fontSize}px`},[c,h]=tr(n,o,l);return[c+i.x*2,h+i.y*2]}function nr(n,t,e){return e(t)(n).split(" ").join(`
|
|
9
|
-
`)}const sr={};function ne(n,t){let e=sr[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,sr[n]=e,t.restore()),e}const rr=new Map;function Nt(n,t,e){const s=e+n;let r=rr.get(s);return r||(t.save(),t.font=e,r=t.measureText(n).width,rr.set(s,r),t.restore()),r}function Kt(n,t,e=ir){function s(r,i){for(const a in i)a in r?typeof r[a]=="object"&&r[a]!==null&&!Array.isArray(r[a])?s(r[a],i[a]):e!=null&&e.overrideExisting&&(r[a]=i[a]):e!=null&&e.addIfMissing&&(r[a]=i[a]);return r}return s(n,t)}function Ig(n,t,e,s=!1){!n||!t||t.length===0||t.forEach(r=>{const i=e(r),a=n.findIndex(o=>e(o)===i);a===-1?n.push(r):s?Kt(n[a],r,{overrideExisting:!0,addIfMissing:!0}):n.splice(a,1,r)})}const ir={overrideExisting:!1,addIfMissing:!0};var Ho=Object.defineProperty,ar=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,or=(n,t,e)=>t in n?Ho(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Uo=(n,t)=>{for(var e in t||(t={}))ko.call(t,e)&&or(n,e,t[e]);if(ar)for(var e of ar(t))jo.call(t,e)&&or(n,e,t[e]);return n};const lr="Open Sans Semibold, sans-serif",Wo=null,Xo=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],Og=n=>Wo.find(t=>t===n)!==void 0,en=()=>({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,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,pinch:.05,glide:.05},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}},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:lr,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"}}}},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:lr,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"},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:846e5}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:846e5,periodMoreThen:6e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6e3}}],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(55,55,54,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)"},"conference-calls":{color:"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:"transparent",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:"transparent",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","UNDERLAY_VOLUMES_AREA","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function zo(n,t=en()){return Kt(n,t,ir),n}function Lg(n,t=en()){const e=Uo({},n);return merge(e,t,DEFAULT_MERGE_OPTIONS),e}function Bg(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function cr(n){return typeof n=="object"&&n!==null}function hr(n,t){return[...n].map(s=>Un(s,t))}const Vo=n=>Array.isArray(n);function Un(n,t){if(!cr(n))return n;if(Vo(n))return hr(n,t);{const e=dr({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function dr(n,t,e){if(!cr(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const r=e.overrideExisting?t:n;return hr(r,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(r=>s[r]=Un(n[r],e)),Object.keys(t).forEach(r=>{r in n?s[r]=dr(n[r],t[r],e):e.addIfMissing&&(s[r]=Un(t[r],e))}),s}const ye=n=>`${n.fontSize}px ${n.fontFamily}`;class Go{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=ye(this.config.components.yAxis);return Nt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(s=>{var r,i,a;const o=s.getYAxisState(),l=o.labelBoxMargin.start+o.labelBoxMargin.end,c=this.getTextWidth(s.getLargestLabel())+l,h=s.getYAxisIndex(),g=s.getPaneUUID(),p=(r=this.extentsOrder.get(g))!=null?r:{left:[],right:[]};if(o.align==="left"){const b=p.left.length;t[b]=Math.max((i=t[b])!=null?i:0,c),p.left.push(h)}else{const b=p.right.length;e[b]=Math.max((a=e[b])!=null?a:0,c),p.right.push(h)}this.extentsOrder.set(g,p)}),{left:t,right:e}}}var $o=Object.defineProperty,Zo=Object.defineProperties,Ko=Object.getOwnPropertyDescriptors,ur=Object.getOwnPropertySymbols,Jo=Object.prototype.hasOwnProperty,qo=Object.prototype.propertyIsEnumerable,fr=(n,t,e)=>t in n?$o(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,se=(n,t)=>{for(var e in t||(t={}))Jo.call(t,e)&&fr(n,e,t[e]);if(ur)for(var e of ur(t))qo.call(t,e)&&fr(n,e,t[e]);return n},gr=(n,t)=>Zo(n,Ko(t));const ht="CHART",Wn=class{};let Y=Wn;Y.CANVAS="CANVAS",Y.N_MAP="N_MAP",Y.X_AXIS="X_AXIS",Y.N_MAP_KNOT_L="N_MAP_KNOT_L",Y.N_MAP_KNOT_R="N_MAP_KNOT_R",Y.N_MAP_BTN_L="N_MAP_BTN_L",Y.N_MAP_BTN_R="N_MAP_BTN_R",Y.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",Y.N_MAP_CHART="N_MAP_CHART",Y.N_MAP_LABEL_R="N_MAP_LABEL_R",Y.N_MAP_LABEL_L="N_MAP_LABEL_L",Y.PANE_UUID=n=>"PANE_"+n,Y.PANE_UUID_Y_AXIS=(n,t=0)=>"PANE_"+n+"_Y_AXIS_"+t,Y.PANE_UUID_RESIZER=n=>"PANE_"+n+"_RESIZER",Y.ALL_PANES="ALL_PANES",Y.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",Y.EVENTS="EVENTS",Y.CHART=Wn.PANE_UUID(ht),Y.Y_AXIS=Wn.PANE_UUID_Y_AXIS(ht);const vr={x:0,y:0,pageX:0,pageY:0,width:0,height:0},Qo=20,mr=35,Xn=15,pr=1.5,zn=kn()?8*pr:8,tl=1e-6;class Vn{constructor(t,e,s,r,i){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=r,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new X,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new X,this.barResizerChangedSubject=new X,this._graphsHeightRatio={chart:1},this.graphsHeightRatioChangedSubject=new X,this.boundsChangedSubscriptions={},i.canvasResized.subscribe(a=>{let o=a;o||(o=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(o),this.recalculateBounds()}),this.yAxisBoundsContainer=new Go(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);Yn(this.panesOrder,s,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=se(se({},this.graphsHeightRatio),t),s=Object.values(e).reduce((r,i)=>r+i,0);Math.abs(s-1)<tl?(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&&(Yn(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder))}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(Yn(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder))}reorderPanes(t){this.panesOrder=Ks(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}removedPaneBounds(t){Oo(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[Y.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[Y.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[Y.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,r=this.getBounds(Y.CANVAS);r.x=0,r.y=0,r.width=t,r.height=e;const i=this.yAxisWidths,a=this.getNavMapBounds(r),o=this.getXAxisBounds(a,r),l=e-o.height-a.height,c=i.left.reduce((J,K)=>J+K,0),h=i.right.reduce((J,K)=>J+K,0),g=0,p=r.width-h,b=g+c,E=0,O=r.width-c-h;let N=E;this.panesOrder.forEach((J,K)=>{var U;const q=this.graphsHeightRatio[this.panesOrder[K]],at=this.config.components.paneResizer.visible;at&&(K!==0?De(this.bounds,Y.PANE_UUID_RESIZER(J),0,N,r.width,s,this.canvasOnPageLocation):De(this.bounds,Y.PANE_UUID_RESIZER(J),0,0,0,0,this.canvasOnPageLocation));const ot=De(this.bounds,Y.PANE_UUID(J),b,at?N+s:N,O,at?l*q-this.config.components.paneResizer.height:l*q,this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const nt=this.yAxisBoundsContainer.extentsOrder.get(J);if(nt===void 0)return;const rt=at?N+s:N,dt=at?l*q-s:l*q;let ct=b-((U=i.left[0])!=null?U:0),St=p;nt.left.forEach((ut,vt)=>{var pt;De(this.bounds,Y.PANE_UUID_Y_AXIS(J,ut),ct,rt,i.left[vt],dt,this.canvasOnPageLocation),ct-=(pt=i.left[vt+1])!=null?pt:0}),nt.right.forEach((ut,vt)=>{De(this.bounds,Y.PANE_UUID_Y_AXIS(J,ut),St,rt,i.right[vt],dt,this.canvasOnPageLocation),St+=i.right[vt]})}else De(this.bounds,Y.PANE_UUID_Y_AXIS(J),0,0,0,0,this.canvasOnPageLocation);N=ot.y+ot.height});const k=this.getBounds(Y.ALL_PANES);k.x=b,k.y=E,k.width=O,k.height=N;const V=this.getBounds(Y.CHART_WITH_Y_AXIS),Z=this.getBounds(Y.PANE_UUID(ht));this.getEventsBounds(Z),this.copyBounds(Z,V),V.width=r.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=gr(se({},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(Y.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(Y.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-mr,e.width=t.width,e.height=mr):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const s=this.getBounds(Y.X_AXIS);return this.config.components.xAxis.visible?(s.x=0,s.y=e.height-this.getXAxisHeight()-t.height,s.width=e.width,s.height=this.getXAxisHeight()):this.applyDefaultBounds(s),s}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const s=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,r=ne(s,this.canvasModel.ctx);this.xAxisHeight=r+((t=this.config.components.xAxis.padding.top)!=null?t:0)+((e=this.config.components.xAxis.padding.bottom)!=null?e:0)}return this.xAxisHeight}setYAxisWidths(t){(!Js(this.yAxisWidths.left,t.left)||!Js(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[ht];const e=[];e.push(...this.panesOrder.filter(g=>g!==ht)),this.panesOrder.forEach(g=>{this.graphsHeightRatio[g]===0&&delete this.graphsHeightRatio[g]});const s=e.map(g=>this.graphsHeightRatio[g]===void 0?void 0:this.graphsHeightRatio[g]),r=s.filter(g=>g!==void 0).length,i=s.filter(g=>g===void 0).length;let a=0,o=0,l=1,c=0;i>0&&([l,c]=nl(e.length),t*=l),r===0&&(t=1-c*i),o=1-t-c*i,s.forEach(g=>{g&&(o-=g*l)}),a=o/(e.length+1);const h=s.map(g=>g?g*l+a:c+a);t+=a,this._graphsHeightRatio={},this.graphsHeightRatio[ht]=t,h.forEach((g,p)=>{const b=e[p];this.graphsHeightRatio[b]=g})}recalculateNavigationMapElementBounds(){var t,e,s,r;if(this.config.components.navigationMap.visible){const i=this.getBounds(Y.N_MAP),{height:a,width:o}=this.config.components.navigationMap.knots,l=a!=null?a:0,c=kn()?o*pr:o!=null?o:0,h=l?i.y+(i.height-l)/2:i.y,g=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,p=q=>No(this.canvasModel.ctx,q,this.formatterFactory,this.config)[0],b=Lt((r=(s=this.mainCandleSeries)==null?void 0:s.getSeriesInViewport())!=null?r:[]),E=g&&b.length?p(b[0].candle.timestamp):0,O=g&&b.length?p(b[b.length-1].candle.timestamp):0,N=Math.max(E,O);if(g){const q=this.getBounds(Y.N_MAP_LABEL_L);q.x=i.x,q.y=i.y,q.width=N,q.height=i.height;const at=this.getBounds(Y.N_MAP_LABEL_R);at.x=i.x+i.width-N,at.y=i.y,at.width=N,at.height=i.height}const k=this.getBounds(Y.N_MAP_BTN_L);k.x=i.x+N,k.y=i.y,k.width=Xn,k.height=i.height;const V=this.getBounds(Y.N_MAP_BTN_R);V.x=i.x+i.width-Xn-N,V.y=i.y,V.width=Xn,V.height=i.height;const Z=this.getBounds(Y.N_MAP_KNOT_L);Z.x=(V.x-k.x-k.width)*this.leftRatio+k.x+k.width,Z.y=h,Z.width=c!=null?c:zn,Z.height=l!=null?l:i.height;const J=this.getBounds(Y.N_MAP_KNOT_R);J.x=(V.x-k.x-k.width)*this.rightRatio+k.x+k.width-zn,J.y=h,J.width=c!=null?c:zn,J.height=l!=null?l:i.height;const K=this.getBounds(Y.N_MAP_SLIDER_WINDOW);K.x=Z.x+Z.width,K.y=i.y,K.width=J.x-K.x,K.height=i.height;const U=this.getBounds(Y.N_MAP_CHART);U.x=k.x+k.width,U.y=i.y,U.width=V.x-U.x,U.height=i.height}}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){return this.bounds[t]===void 0&&(this.bounds[t]=this.copyOf(vr)),this.bounds[t]}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>gr(se({},t),{[e]:this.bounds[Y.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=nn){const{extensionX:s,extensionY:r,wholePage:i}=se(se({},nn),e);return i?(a,o)=>{const l=this.getBounds(t);return a>l.pageX-s&&a<l.pageX+l.width+s&&o>l.pageY-r&&o<l.pageY+l.height+r}:(a,o)=>{const l=this.getBounds(t);return a>l.x-s&&a<l.x+l.width+s&&o>l.y-r&&o<l.y+l.height+r}}static hitTestOf(t,e=nn){const{extensionX:s,extensionY:r,wholePage:i}=se(se({},nn),e);return i?(a,o)=>a>t.pageX-s&&a<t.pageX+t.width+s&&o>t.pageY-r&&o<t.pageY+t.height+r:(a,o)=>a>t.x-s&&a<t.x+t.width+s&&o>t.y-r&&o<t.y+t.height+r}isChartBoundsAvailable(){const t=this.getBounds(Y.CANVAS);return t.width>0&&t.height>0}resizePaneVertically(t,e){const s=this.panesOrder.indexOf(t),r=this.getBounds(Y.PANE_UUID_RESIZER(t));this.doResizePaneVertically(s,r.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){const s=t-1,r=this.getBounds(Y.ALL_PANES).height,i=this.config.components.paneResizer.height+Qo,a=r*this.graphsHeightRatio[this.panesOrder[t]],o=r*this.graphsHeightRatio[this.panesOrder[s]],l=a+e>i,c=o-e>i;if(l&&c){const h=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=h,this.graphsHeightRatio[this.panesOrder[s]]-=h,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 $t(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(yt(s=>this.copyOf(s)),Zt((s,r)=>this.sameBounds(s,r)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return se({},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(vr,t)}setMainCandleSeries(t){this.mainCandleSeries=t}}const el={0:1,1:.8,2:.6,3:.5,4:.4,5:.2},nl=n=>{var t;const e=(t=el[n])!=null?t:.4,s=(1-e)/n;return[e,s]},Rg=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,sl=(n,t)=>n>t.y&&n<t.y+t.height,De=(n,t,e,s,r,i,a)=>{const o=n[t];if(o)return o.x=e,o.y=s,o.pageX=e+a.x,o.pageY=s+a.y,o.width=r,o.height=i,o;const l={x:e,y:s,pageX:e+a.x,pageY:s+a.y,width:r,height:i};return n[t]=l,l},br=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),nn={extensionX:0,extensionY:0,wholePage:!1},Cr=(n,t)=>n.width===t.width&&n.height===t.height;var rl=function(n){L(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}(Ct),sn={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var r=sn.delegate;return r!=null&&r.setInterval?r.setInterval.apply(r,x([n,t],C(e))):setInterval.apply(void 0,x([n,t],C(e)))},clearInterval:function(n){var t=sn.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},il=function(n){L(t,n);function t(e,s){var r=n.call(this,e,s)||this;return r.scheduler=e,r.work=s,r.pending=!1,r}return t.prototype.schedule=function(e,s){var r;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var i=this.id,a=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(a,i,s)),this.pending=!0,this.delay=s,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(a,this.id,s),this},t.prototype.requestAsyncId=function(e,s,r){return r===void 0&&(r=0),sn.setInterval(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,s,r){if(r===void 0&&(r=0),r!=null&&this.delay===r&&this.pending===!1)return s;s!=null&&sn.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,s);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var r=!1,i;try{this.work(e)}catch(a){r=!0,i=a||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,r=e.scheduler,i=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Dt(i,this),s!=null&&(this.id=this.recycleAsyncId(r,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(rl),Gn={now:function(){return(Gn.delegate||Date).now()},delegate:void 0},yr=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=Gn.now,n}(),al=function(n){L(t,n);function t(e,s){s===void 0&&(s=yr.now);var r=n.call(this,e,s)||this;return r.actions=[],r._active=!1,r}return t.prototype.flush=function(e){var s=this.actions;if(this._active){s.push(e);return}var r;this._active=!0;do if(r=e.execute(e.state,e.delay))break;while(e=s.shift());if(this._active=!1,r){for(;e=s.shift();)e.unsubscribe();throw r}},t}(yr),wr=new al(il),ol=wr;function ll(n,t){return y(function(e,s){var r=t!=null?t:{},i=r.leading,a=i===void 0?!0:i,o=r.trailing,l=o===void 0?!1:o,c=!1,h=null,g=null,p=!1,b=function(){g==null||g.unsubscribe(),g=null,l&&(N(),p&&s.complete())},E=function(){g=null,p&&s.complete()},O=function(k){return g=te(n(k)).subscribe(Xt(s,b,E))},N=function(){if(c){c=!1;var k=h;h=null,s.next(k),!p&&O(k)}};e.subscribe(Xt(s,function(k){c=!0,h=k,!(g&&!g.closed)&&(a?N():O(k))},function(){p=!0,!(l&&c&&g&&!g.closed)&&s.complete()}))})}function cl(n){return n instanceof Date&&!isNaN(n)}function hl(n,t,e){n===void 0&&(n=0),e===void 0&&(e=ol);var s=-1;return t!=null&&(ks(t)?e=t:s=t),new Tt(function(r){var i=cl(n)?+n-e.now():n;i<0&&(i=0);var a=0;return e.schedule(function(){r.closed||(r.next(a++),0<=s?this.schedule(void 0,s):r.complete())},i)})}function je(n,t,e){t===void 0&&(t=wr);var s=hl(n,t);return ll(function(){return s},e)}class tt{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 dl extends tt{constructor(t,e,s,r){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=r,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new X}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(je(100,void 0,{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,r=0){const i=Vn.hitTestOf(e,{extensionY:r});r?this.extensionLayer.set(t,{cursor:s,hitTest:i}):this.normalLayer.set(t,{cursor:s,hitTest:i})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(Zt())}observeCursorType(t,e,s){const r=s?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(t);s?this.extensionLayer.set(t,{cursor:e,hitTest:r}):this.normalLayer.set(t,{cursor:e,hitTest:r})}updateCursor(t){this.element.style.cursor!==t&&(this.element.style.cursor=t,this.cursorChangedSubject.next(t))}}const ul=n=>{const t=n.canvasArea!==null,e=n.snapshotCanvas!==null,s=n.backgroundCanvas!==null,r=n.mainCanvas!==null,i=n.yAxisLabelsCanvas!==null,a=n.crossToolCanvas!==null,o=n.hitTestCanvas!==null,l=n.chartResizer!==null,c=n.chartContainer!==null,h=n.dynamicObjectsCanvas!==null;return t&&e&&s&&r&&i&&a&&o&&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;">
|
|
6
|
+
(()=>{var rt=Math.pow;(()=>{var Oo={168:(k,st,N)=>{const G=N(874),z={};for(const m of Object.keys(G))z[G[m]]=m;const D={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=D;for(const m of Object.keys(D)){if(!("channels"in D[m]))throw new Error("missing channels property: "+m);if(!("labels"in D[m]))throw new Error("missing channel labels property: "+m);if(D[m].labels.length!==D[m].channels)throw new Error("channel and label counts mismatch: "+m);const{channels:b,labels:v}=D[m];delete D[m].channels,delete D[m].labels,Object.defineProperty(D[m],"channels",{value:b}),Object.defineProperty(D[m],"labels",{value:v})}D.rgb.hsl=function(m){const b=m[0]/255,v=m[1]/255,C=m[2]/255,f=Math.min(b,v,C),S=Math.max(b,v,C),P=S-f;let A,p;S===f?A=0:b===S?A=(v-C)/P:v===S?A=2+(C-b)/P:C===S&&(A=4+(b-v)/P),A=Math.min(A*60,360),A<0&&(A+=360);const T=(f+S)/2;return S===f?p=0:T<=.5?p=P/(S+f):p=P/(2-S-f),[A,p*100,T*100]},D.rgb.hsv=function(m){let b,v,C,f,S;const P=m[0]/255,A=m[1]/255,p=m[2]/255,T=Math.max(P,A,p),E=T-Math.min(P,A,p),L=function(O){return(T-O)/6/E+1/2};return E===0?(f=0,S=0):(S=E/T,b=L(P),v=L(A),C=L(p),P===T?f=C-v:A===T?f=.3333333333333333+b-C:p===T&&(f=.6666666666666666+v-b),f<0?f+=1:f>1&&(f-=1)),[f*360,S*100,T*100]},D.rgb.hwb=function(m){const b=m[0],v=m[1];let C=m[2];const f=D.rgb.hsl(m)[0],S=1/255*Math.min(b,Math.min(v,C));return C=1-.00392156862745098*Math.max(b,Math.max(v,C)),[f,S*100,C*100]},D.rgb.cmyk=function(m){const b=m[0]/255,v=m[1]/255,C=m[2]/255,f=Math.min(1-b,1-v,1-C),S=(1-b-f)/(1-f)||0,P=(1-v-f)/(1-f)||0,A=(1-C-f)/(1-f)||0;return[S*100,P*100,A*100,f*100]};function lt(m,b){return rt(m[0]-b[0],2)+rt(m[1]-b[1],2)+rt(m[2]-b[2],2)}D.rgb.keyword=function(m){const b=z[m];if(b)return b;let v=1/0,C;for(const f of Object.keys(G)){const S=G[f],P=lt(m,S);P<v&&(v=P,C=f)}return C},D.keyword.rgb=function(m){return G[m]},D.rgb.xyz=function(m){let b=m[0]/255,v=m[1]/255,C=m[2]/255;b=b>.04045?rt((b+.055)/1.055,2.4):b/12.92,v=v>.04045?rt((v+.055)/1.055,2.4):v/12.92,C=C>.04045?rt((C+.055)/1.055,2.4):C/12.92;const f=b*.4124+v*.3576+C*.1805,S=b*.2126+v*.7152+C*.0722,P=b*.0193+v*.1192+C*.9505;return[f*100,S*100,P*100]},D.rgb.lab=function(m){const b=D.rgb.xyz(m);let v=b[0],C=b[1],f=b[2];v/=95.047,C/=100,f/=108.883,v=v>.008856?rt(v,.3333333333333333):7.787*v+.13793103448275862,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,f=f>.008856?rt(f,.3333333333333333):7.787*f+.13793103448275862;const S=116*C-16,P=500*(v-C),A=200*(C-f);return[S,P,A]},D.hsl.rgb=function(m){const b=m[0]/360,v=m[1]/100,C=m[2]/100;let f,S,P;if(v===0)return P=C*255,[P,P,P];C<.5?f=C*(1+v):f=C+v-C*v;const A=2*C-f,p=[0,0,0];for(let T=0;T<3;T++)S=b+.3333333333333333*-(T-1),S<0&&S++,S>1&&S--,6*S<1?P=A+(f-A)*6*S:2*S<1?P=f:3*S<2?P=A+(f-A)*(.6666666666666666-S)*6:P=A,p[T]=P*255;return p},D.hsl.hsv=function(m){const b=m[0];let v=m[1]/100,C=m[2]/100,f=v;const S=Math.max(C,.01);C*=2,v*=C<=1?C:2-C,f*=S<=1?S:2-S;const P=(C+v)/2,A=C===0?2*f/(S+f):2*v/(C+v);return[b,A*100,P*100]},D.hsv.rgb=function(m){const b=m[0]/60,v=m[1]/100;let C=m[2]/100;const f=Math.floor(b)%6,S=b-Math.floor(b),P=255*C*(1-v),A=255*C*(1-v*S),p=255*C*(1-v*(1-S));switch(C*=255,f){case 0:return[C,p,P];case 1:return[A,C,P];case 2:return[P,C,p];case 3:return[P,A,C];case 4:return[p,P,C];case 5:return[C,P,A]}},D.hsv.hsl=function(m){const b=m[0],v=m[1]/100,C=m[2]/100,f=Math.max(C,.01);let S,P;P=(2-v)*C;const A=(2-v)*f;return S=v*f,S/=A<=1?A:2-A,S=S||0,P/=2,[b,S*100,P*100]},D.hwb.rgb=function(m){const b=m[0]/360;let v=m[1]/100,C=m[2]/100;const f=v+C;let S;f>1&&(v/=f,C/=f);const P=Math.floor(6*b),A=1-C;S=6*b-P,P&1&&(S=1-S);const p=v+S*(A-v);let T,E,L;switch(P){default:case 6:case 0:T=A,E=p,L=v;break;case 1:T=p,E=A,L=v;break;case 2:T=v,E=A,L=p;break;case 3:T=v,E=p,L=A;break;case 4:T=p,E=v,L=A;break;case 5:T=A,E=v,L=p;break}return[T*255,E*255,L*255]},D.cmyk.rgb=function(m){const b=m[0]/100,v=m[1]/100,C=m[2]/100,f=m[3]/100,S=1-Math.min(1,b*(1-f)+f),P=1-Math.min(1,v*(1-f)+f),A=1-Math.min(1,C*(1-f)+f);return[S*255,P*255,A*255]},D.xyz.rgb=function(m){const b=m[0]/100,v=m[1]/100,C=m[2]/100;let f,S,P;return f=b*3.2406+v*-1.5372+C*-.4986,S=b*-.9689+v*1.8758+C*.0415,P=b*.0557+v*-.204+C*1.057,f=f>.0031308?1.055*rt(f,.4166666666666667)-.055:f*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,f=Math.min(Math.max(0,f),1),S=Math.min(Math.max(0,S),1),P=Math.min(Math.max(0,P),1),[f*255,S*255,P*255]},D.xyz.lab=function(m){let b=m[0],v=m[1],C=m[2];b/=95.047,v/=100,C/=108.883,b=b>.008856?rt(b,.3333333333333333):7.787*b+.13793103448275862,v=v>.008856?rt(v,.3333333333333333):7.787*v+.13793103448275862,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862;const f=116*v-16,S=500*(b-v),P=200*(v-C);return[f,S,P]},D.lab.xyz=function(m){const b=m[0],v=m[1],C=m[2];let f,S,P;S=(b+16)/116,f=v/500+S,P=S-C/200;const A=rt(S,3),p=rt(f,3),T=rt(P,3);return S=A>.008856?A:(S-.13793103448275862)/7.787,f=p>.008856?p:(f-.13793103448275862)/7.787,P=T>.008856?T:(P-.13793103448275862)/7.787,f*=95.047,S*=100,P*=108.883,[f,S,P]},D.lab.lch=function(m){const b=m[0],v=m[1],C=m[2];let f;f=Math.atan2(C,v)*360/2/Math.PI,f<0&&(f+=360);const P=Math.sqrt(v*v+C*C);return[b,P,f]},D.lch.lab=function(m){const b=m[0],v=m[1],f=m[2]/360*2*Math.PI,S=v*Math.cos(f),P=v*Math.sin(f);return[b,S,P]},D.rgb.ansi16=function(m,b=null){const[v,C,f]=m;let S=b===null?D.rgb.hsv(m)[2]:b;if(S=Math.round(S/50),S===0)return 30;let P=30+(Math.round(f/255)<<2|Math.round(C/255)<<1|Math.round(v/255));return S===2&&(P+=60),P},D.hsv.ansi16=function(m){return D.rgb.ansi16(D.hsv.rgb(m),m[2])},D.rgb.ansi256=function(m){const b=m[0],v=m[1],C=m[2];return b===v&&v===C?b<8?16:b>248?231:Math.round((b-8)/247*24)+232:16+36*Math.round(b/255*5)+6*Math.round(v/255*5)+Math.round(C/255*5)},D.ansi16.rgb=function(m){let b=m%10;if(b===0||b===7)return m>50&&(b+=3.5),b=b/10.5*255,[b,b,b];const v=(~~(m>50)+1)*.5,C=(b&1)*v*255,f=(b>>1&1)*v*255,S=(b>>2&1)*v*255;return[C,f,S]},D.ansi256.rgb=function(m){if(m>=232){const S=(m-232)*10+8;return[S,S,S]}m-=16;let b;const v=Math.floor(m/36)/5*255,C=Math.floor((b=m%36)/6)/5*255,f=b%6/5*255;return[v,C,f]},D.rgb.hex=function(m){const v=(((Math.round(m[0])&255)<<16)+((Math.round(m[1])&255)<<8)+(Math.round(m[2])&255)).toString(16).toUpperCase();return"000000".substring(v.length)+v},D.hex.rgb=function(m){const b=m.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!b)return[0,0,0];let v=b[0];b[0].length===3&&(v=v.split("").map(A=>A+A).join(""));const C=parseInt(v,16),f=C>>16&255,S=C>>8&255,P=C&255;return[f,S,P]},D.rgb.hcg=function(m){const b=m[0]/255,v=m[1]/255,C=m[2]/255,f=Math.max(Math.max(b,v),C),S=Math.min(Math.min(b,v),C),P=f-S;let A,p;return P<1?A=S/(1-P):A=0,P<=0?p=0:f===b?p=(v-C)/P%6:f===v?p=2+(C-b)/P:p=4+(b-v)/P,p/=6,p%=1,[p*360,P*100,A*100]},D.hsl.hcg=function(m){const b=m[1]/100,v=m[2]/100,C=v<.5?2*b*v:2*b*(1-v);let f=0;return C<1&&(f=(v-.5*C)/(1-C)),[m[0],C*100,f*100]},D.hsv.hcg=function(m){const b=m[1]/100,v=m[2]/100,C=b*v;let f=0;return C<1&&(f=(v-C)/(1-C)),[m[0],C*100,f*100]},D.hcg.rgb=function(m){const b=m[0]/360,v=m[1]/100,C=m[2]/100;if(v===0)return[C*255,C*255,C*255];const f=[0,0,0],S=b%1*6,P=S%1,A=1-P;let p=0;switch(Math.floor(S)){case 0:f[0]=1,f[1]=P,f[2]=0;break;case 1:f[0]=A,f[1]=1,f[2]=0;break;case 2:f[0]=0,f[1]=1,f[2]=P;break;case 3:f[0]=0,f[1]=A,f[2]=1;break;case 4:f[0]=P,f[1]=0,f[2]=1;break;default:f[0]=1,f[1]=0,f[2]=A}return p=(1-v)*C,[(v*f[0]+p)*255,(v*f[1]+p)*255,(v*f[2]+p)*255]},D.hcg.hsv=function(m){const b=m[1]/100,v=m[2]/100,C=b+v*(1-b);let f=0;return C>0&&(f=b/C),[m[0],f*100,C*100]},D.hcg.hsl=function(m){const b=m[1]/100,C=m[2]/100*(1-b)+.5*b;let f=0;return C>0&&C<.5?f=b/(2*C):C>=.5&&C<1&&(f=b/(2*(1-C))),[m[0],f*100,C*100]},D.hcg.hwb=function(m){const b=m[1]/100,v=m[2]/100,C=b+v*(1-b);return[m[0],(C-b)*100,(1-C)*100]},D.hwb.hcg=function(m){const b=m[1]/100,C=1-m[2]/100,f=C-b;let S=0;return f<1&&(S=(C-f)/(1-f)),[m[0],f*100,S*100]},D.apple.rgb=function(m){return[m[0]/65535*255,m[1]/65535*255,m[2]/65535*255]},D.rgb.apple=function(m){return[m[0]/255*65535,m[1]/255*65535,m[2]/255*65535]},D.gray.rgb=function(m){return[m[0]/100*255,m[0]/100*255,m[0]/100*255]},D.gray.hsl=function(m){return[0,0,m[0]]},D.gray.hsv=D.gray.hsl,D.gray.hwb=function(m){return[0,100,m[0]]},D.gray.cmyk=function(m){return[0,0,0,m[0]]},D.gray.lab=function(m){return[m[0],0,0]},D.gray.hex=function(m){const b=Math.round(m[0]/100*255)&255,C=((b<<16)+(b<<8)+b).toString(16).toUpperCase();return"000000".substring(C.length)+C},D.rgb.gray=function(m){return[(m[0]+m[1]+m[2])/3/255*100]}},85:(k,st,N)=>{const G=N(168),z=N(111),D={},lt=Object.keys(G);function m(v){const C=function(...f){const S=f[0];return S==null?S:(S.length>1&&(f=S),v(f))};return"conversion"in v&&(C.conversion=v.conversion),C}function b(v){const C=function(...f){const S=f[0];if(S==null)return S;S.length>1&&(f=S);const P=v(f);if(typeof P=="object")for(let A=P.length,p=0;p<A;p++)P[p]=Math.round(P[p]);return P};return"conversion"in v&&(C.conversion=v.conversion),C}lt.forEach(v=>{D[v]={},Object.defineProperty(D[v],"channels",{value:G[v].channels}),Object.defineProperty(D[v],"labels",{value:G[v].labels});const C=z(v);Object.keys(C).forEach(S=>{const P=C[S];D[v][S]=b(P),D[v][S].raw=m(P)})}),k.exports=D},111:(k,st,N)=>{const G=N(168);function z(){const b={},v=Object.keys(G);for(let C=v.length,f=0;f<C;f++)b[v[f]]={distance:-1,parent:null};return b}function D(b){const v=z(),C=[b];for(v[b].distance=0;C.length;){const f=C.pop(),S=Object.keys(G[f]);for(let P=S.length,A=0;A<P;A++){const p=S[A],T=v[p];T.distance===-1&&(T.distance=v[f].distance+1,T.parent=f,C.unshift(p))}}return v}function lt(b,v){return function(C){return v(b(C))}}function m(b,v){const C=[v[b].parent,b];let f=G[v[b].parent][b],S=v[b].parent;for(;v[S].parent;)C.unshift(v[S].parent),f=lt(G[v[S].parent][S],f),S=v[S].parent;return f.conversion=C,f}k.exports=function(b){const v=D(b),C={},f=Object.keys(v);for(let S=f.length,P=0;P<S;P++){const A=f[P];v[A].parent!==null&&(C[A]=m(A,v))}return C}},874: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]}},818:(k,st,N)=>{var G=N(874),z=N(851),D=Object.hasOwnProperty,lt=Object.create(null);for(var m in G)D.call(G,m)&&(lt[G[m]]=m);var b=k.exports={to:{},get:{}};b.get=function(f){var S=f.substring(0,3).toLowerCase(),P,A;switch(S){case"hsl":P=b.get.hsl(f),A="hsl";break;case"hwb":P=b.get.hwb(f),A="hwb";break;default:P=b.get.rgb(f),A="rgb";break}return P?{model:A,value:P}:null},b.get.rgb=function(f){if(!f)return null;var S=/^#([a-f0-9]{3,4})$/i,P=/^#([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*)?\)$/,p=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,T=/^(\w+)$/,E=[0,0,0,1],L,O,at;if(L=f.match(P)){for(at=L[2],L=L[1],O=0;O<3;O++){var At=O*2;E[O]=parseInt(L.slice(At,At+2),16)}at&&(E[3]=parseInt(at,16)/255)}else if(L=f.match(S)){for(L=L[1],at=L[3],O=0;O<3;O++)E[O]=parseInt(L[O]+L[O],16);at&&(E[3]=parseInt(at+at,16)/255)}else if(L=f.match(A)){for(O=0;O<3;O++)E[O]=parseInt(L[O+1],0);L[4]&&(L[5]?E[3]=parseFloat(L[4])*.01:E[3]=parseFloat(L[4]))}else if(L=f.match(p)){for(O=0;O<3;O++)E[O]=Math.round(parseFloat(L[O+1])*2.55);L[4]&&(L[5]?E[3]=parseFloat(L[4])*.01:E[3]=parseFloat(L[4]))}else return(L=f.match(T))?L[1]==="transparent"?[0,0,0,0]:D.call(G,L[1])?(E=G[L[1]],E[3]=1,E):null:null;for(O=0;O<3;O++)E[O]=v(E[O],0,255);return E[3]=v(E[3],0,1),E},b.get.hsl=function(f){if(!f)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=f.match(S);if(P){var A=parseFloat(P[4]),p=(parseFloat(P[1])%360+360)%360,T=v(parseFloat(P[2]),0,100),E=v(parseFloat(P[3]),0,100),L=v(isNaN(A)?1:A,0,1);return[p,T,E,L]}return null},b.get.hwb=function(f){if(!f)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=f.match(S);if(P){var A=parseFloat(P[4]),p=(parseFloat(P[1])%360+360)%360,T=v(parseFloat(P[2]),0,100),E=v(parseFloat(P[3]),0,100),L=v(isNaN(A)?1:A,0,1);return[p,T,E,L]}return null},b.to.hex=function(){var f=z(arguments);return"#"+C(f[0])+C(f[1])+C(f[2])+(f[3]<1?C(Math.round(f[3]*255)):"")},b.to.rgb=function(){var f=z(arguments);return f.length<4||f[3]===1?"rgb("+Math.round(f[0])+", "+Math.round(f[1])+", "+Math.round(f[2])+")":"rgba("+Math.round(f[0])+", "+Math.round(f[1])+", "+Math.round(f[2])+", "+f[3]+")"},b.to.rgb.percent=function(){var f=z(arguments),S=Math.round(f[0]/255*100),P=Math.round(f[1]/255*100),A=Math.round(f[2]/255*100);return f.length<4||f[3]===1?"rgb("+S+"%, "+P+"%, "+A+"%)":"rgba("+S+"%, "+P+"%, "+A+"%, "+f[3]+")"},b.to.hsl=function(){var f=z(arguments);return f.length<4||f[3]===1?"hsl("+f[0]+", "+f[1]+"%, "+f[2]+"%)":"hsla("+f[0]+", "+f[1]+"%, "+f[2]+"%, "+f[3]+")"},b.to.hwb=function(){var f=z(arguments),S="";return f.length>=4&&f[3]!==1&&(S=", "+f[3]),"hwb("+f[0]+", "+f[1]+"%, "+f[2]+"%"+S+")"},b.to.keyword=function(f){return lt[f.slice(0,3)]};function v(f,S,P){return Math.min(Math.max(S,f),P)}function C(f){var S=Math.round(f).toString(16).toUpperCase();return S.length<2?"0"+S:S}},767:(k,st,N)=>{const G=N(818),z=N(85),D=["keyword","gray","hex"],lt={};for(const p of Object.keys(z))lt[[...z[p].labels].sort().join("")]=p;const m={};function b(p,T){if(!(this instanceof b))return new b(p,T);if(T&&T in D&&(T=null),T&&!(T in z))throw new Error("Unknown model: "+T);let E,L;if(p==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(p instanceof b)this.model=p.model,this.color=[...p.color],this.valpha=p.valpha;else if(typeof p=="string"){const O=G.get(p);if(O===null)throw new Error("Unable to parse color from string: "+p);this.model=O.model,L=z[this.model].channels,this.color=O.value.slice(0,L),this.valpha=typeof O.value[L]=="number"?O.value[L]:1}else if(p.length>0){this.model=T||"rgb",L=z[this.model].channels;const O=Array.prototype.slice.call(p,0,L);this.color=A(O,L),this.valpha=typeof p[L]=="number"?p[L]:1}else if(typeof p=="number")this.model="rgb",this.color=[p>>16&255,p>>8&255,p&255],this.valpha=1;else{this.valpha=1;const O=Object.keys(p);"alpha"in p&&(O.splice(O.indexOf("alpha"),1),this.valpha=typeof p.alpha=="number"?p.alpha:0);const at=O.sort().join("");if(!(at in lt))throw new Error("Unable to parse color from object: "+JSON.stringify(p));this.model=lt[at];const{labels:At}=z[this.model],Ot=[];for(E=0;E<At.length;E++)Ot.push(p[At[E]]);this.color=A(Ot)}if(m[this.model])for(L=z[this.model].channels,E=0;E<L;E++){const O=m[this.model][E];O&&(this.color[E]=O(this.color[E]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}b.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(p){let T=this.model in G.to?this:this.rgb();T=T.round(typeof p=="number"?p:1);const E=T.valpha===1?T.color:[...T.color,this.valpha];return G.to[T.model](E)},percentString(p){const T=this.rgb().round(typeof p=="number"?p:1),E=T.valpha===1?T.color:[...T.color,this.valpha];return G.to.rgb.percent(E)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const p={},{channels:T}=z[this.model],{labels:E}=z[this.model];for(let L=0;L<T;L++)p[E[L]]=this.color[L];return this.valpha!==1&&(p.alpha=this.valpha),p},unitArray(){const p=this.rgb().color;return p[0]/=255,p[1]/=255,p[2]/=255,this.valpha!==1&&p.push(this.valpha),p},unitObject(){const p=this.rgb().object();return p.r/=255,p.g/=255,p.b/=255,this.valpha!==1&&(p.alpha=this.valpha),p},round(p){return p=Math.max(p||0,0),new b([...this.color.map(C(p)),this.valpha],this.model)},alpha(p){return p!==void 0?new b([...this.color,Math.max(0,Math.min(1,p))],this.model):this.valpha},red:f("rgb",0,S(255)),green:f("rgb",1,S(255)),blue:f("rgb",2,S(255)),hue:f(["hsl","hsv","hsl","hwb","hcg"],0,p=>(p%360+360)%360),saturationl:f("hsl",1,S(100)),lightness:f("hsl",2,S(100)),saturationv:f("hsv",1,S(100)),value:f("hsv",2,S(100)),chroma:f("hcg",1,S(100)),gray:f("hcg",2,S(100)),white:f("hwb",1,S(100)),wblack:f("hwb",2,S(100)),cyan:f("cmyk",0,S(100)),magenta:f("cmyk",1,S(100)),yellow:f("cmyk",2,S(100)),black:f("cmyk",3,S(100)),x:f("xyz",0,S(95.047)),y:f("xyz",1,S(100)),z:f("xyz",2,S(108.833)),l:f("lab",0,S(100)),a:f("lab",1),b:f("lab",2),keyword(p){return p!==void 0?new b(p):z[this.model].keyword(this.color)},hex(p){return p!==void 0?new b(p):G.to.hex(this.rgb().round().color)},hexa(p){if(p!==void 0)return new b(p);const T=this.rgb().round().color;let E=Math.round(this.valpha*255).toString(16).toUpperCase();return E.length===1&&(E="0"+E),G.to.hex(T)+E},rgbNumber(){const p=this.rgb().color;return(p[0]&255)<<16|(p[1]&255)<<8|p[2]&255},luminosity(){const p=this.rgb().color,T=[];for(const[E,L]of p.entries()){const O=L/255;T[E]=O<=.04045?O/12.92:rt((O+.055)/1.055,2.4)}return .2126*T[0]+.7152*T[1]+.0722*T[2]},contrast(p){const T=this.luminosity(),E=p.luminosity();return T>E?(T+.05)/(E+.05):(E+.05)/(T+.05)},level(p){const T=this.contrast(p);return T>=7?"AAA":T>=4.5?"AA":""},isDark(){const p=this.rgb().color;return(p[0]*2126+p[1]*7152+p[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const p=this.rgb();for(let T=0;T<3;T++)p.color[T]=255-p.color[T];return p},lighten(p){const T=this.hsl();return T.color[2]+=T.color[2]*p,T},darken(p){const T=this.hsl();return T.color[2]-=T.color[2]*p,T},saturate(p){const T=this.hsl();return T.color[1]+=T.color[1]*p,T},desaturate(p){const T=this.hsl();return T.color[1]-=T.color[1]*p,T},whiten(p){const T=this.hwb();return T.color[1]+=T.color[1]*p,T},blacken(p){const T=this.hwb();return T.color[2]+=T.color[2]*p,T},grayscale(){const p=this.rgb().color,T=p[0]*.3+p[1]*.59+p[2]*.11;return b.rgb(T,T,T)},fade(p){return this.alpha(this.valpha-this.valpha*p)},opaquer(p){return this.alpha(this.valpha+this.valpha*p)},rotate(p){const T=this.hsl();let E=T.color[0];return E=(E+p)%360,E=E<0?360+E:E,T.color[0]=E,T},mix(p,T){if(!p||!p.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof p);const E=p.rgb(),L=this.rgb(),O=T===void 0?.5:T,at=2*O-1,At=E.alpha()-L.alpha(),Ot=((at*At===-1?at:(at+At)/(1+at*At))+1)/2,Ee=1-Ot;return b.rgb(Ot*E.red()+Ee*L.red(),Ot*E.green()+Ee*L.green(),Ot*E.blue()+Ee*L.blue(),E.alpha()*O+L.alpha()*(1-O))}};for(const p of Object.keys(z)){if(D.includes(p))continue;const{channels:T}=z[p];b.prototype[p]=function(...E){return this.model===p?new b(this):E.length>0?new b(E,p):new b([...P(z[this.model][p].raw(this.color)),this.valpha],p)},b[p]=function(...E){let L=E[0];return typeof L=="number"&&(L=A(E,T)),new b(L,p)}}function v(p,T){return Number(p.toFixed(T))}function C(p){return function(T){return v(T,p)}}function f(p,T,E){p=Array.isArray(p)?p:[p];for(const L of p)(m[L]||(m[L]=[]))[T]=E;return p=p[0],function(L){let O;return L!==void 0?(E&&(L=E(L)),O=this[p](),O.color[T]=L,O):(O=this[p]().color[T],E&&(O=E(O)),O)}}function S(p){return function(T){return Math.max(0,Math.min(p,T))}}function P(p){return Array.isArray(p)?p:[p]}function A(p,T){for(let E=0;E<T;E++)typeof p[E]!="number"&&(p[E]=0);return p}k.exports=b},171: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")}},851:(k,st,N)=>{"use strict";var G=N(171),z=Array.prototype.concat,D=Array.prototype.slice,lt=k.exports=function(b){for(var v=[],C=0,f=b.length;C<f;C++){var S=b[C];G(S)?v=z.call(v,D.call(S)):v.push(S)}return v};lt.wrap=function(m){return function(){return m(lt(arguments))}}}},hn={};function bt(k){var st=hn[k];if(st!==void 0)return st.exports;var N=hn[k]={exports:{}};return Oo[k](N,N.exports,bt),N.exports}bt.n=k=>{var st=k&&k.__esModule?()=>k.default:()=>k;return bt.d(st,{a:st}),st},bt.d=(k,st)=>{for(var N in st)bt.o(st,N)&&!bt.o(k,N)&&Object.defineProperty(k,N,{enumerable:!0,get:st[N]})},bt.o=(k,st)=>Object.prototype.hasOwnProperty.call(k,st),bt.r=k=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(k,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(k,"__esModule",{value:!0})};var cs={};(()=>{"use strict";bt.r(cs),bt.d(cs,{Chart:()=>Eo,createChart:()=>Cf,generateCandlesData:()=>bf});function k(s){return typeof s=="function"}function st(s){return k(s==null?void 0:s.lift)}function N(s){return function(t){if(st(t))return t.lift(function(e){try{return s(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}var G=function(s,t){return G=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},G(s,t)};function z(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");G(s,t);function e(){this.constructor=s}s.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var D=function(){return D=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},D.apply(this,arguments)};function lt(s,t){var e={};for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&t.indexOf(n)<0&&(e[n]=s[n]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(s);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(s,n[i])&&(e[n[i]]=s[n[i]]);return e}function m(s,t,e,n){var i=arguments.length,r=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,t,e,n);else for(var a=s.length-1;a>=0;a--)(o=s[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 b(s,t){return function(e,n){t(e,n,s)}}function v(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)}function C(s,t,e,n){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(n.next(h))}catch(d){o(d)}}function l(h){try{c(n.throw(h))}catch(d){o(d)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((n=n.apply(s,t||[])).next())})}function f(s,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,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(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(n=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(s,e)}catch(h){c=[6,h],i=0}finally{n=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var S=Object.create?function(s,t,e,n){n===void 0&&(n=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(s,n,i)}:function(s,t,e,n){n===void 0&&(n=e),s[n]=t[e]};function P(s,t){for(var e in s)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&S(t,s,e)}function A(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],n=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(s,t){var e=typeof Symbol=="function"&&s[Symbol.iterator];if(!e)return s;var n=e.call(s),i,r=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(o)throw o.error}}return r}function T(){for(var s=[],t=0;t<arguments.length;t++)s=s.concat(p(arguments[t]));return s}function E(){for(var s=0,t=0,e=arguments.length;t<e;t++)s+=arguments[t].length;for(var n=Array(s),i=0,t=0;t<e;t++)for(var r=arguments[t],o=0,a=r.length;o<a;o++,i++)n[i]=r[o];return n}function L(s,t,e){if(e||arguments.length===2)for(var n=0,i=t.length,r;n<i;n++)(r||!(n in t))&&(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return s.concat(r||Array.prototype.slice.call(t))}function O(s){return this instanceof O?(this.v=s,this):new O(s)}function at(s,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(s,t||[]),i,r=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(u){n[u]&&(i[u]=function(g){return new Promise(function(w,y){r.push([u,g,w,y])>1||a(u,g)})})}function a(u,g){try{l(n[u](g))}catch(w){d(r[0][3],w)}}function l(u){u.value instanceof O?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,g){u(g),r.shift(),r.length&&a(r[0][0],r[0][1])}}function At(s){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,r){t[i]=s[i]?function(o){return(e=!e)?{value:O(s[i](o)),done:i==="return"}:r?r(o):o}:r}}function Ot(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=s[Symbol.asyncIterator],e;return t?t.call(s):(s=typeof A=="function"?A(s):s[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=s[r]&&function(o){return new Promise(function(a,l){o=s[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 Ee(s,t){return Object.defineProperty?Object.defineProperty(s,"raw",{value:t}):s.raw=t,s}var Ro=Object.create?function(s,t){Object.defineProperty(s,"default",{enumerable:!0,value:t})}:function(s,t){s.default=t};function yf(s){if(s&&s.__esModule)return s;var t={};if(s!=null)for(var e in s)e!=="default"&&Object.prototype.hasOwnProperty.call(s,e)&&S(t,s,e);return Ro(t,s),t}function Sf(s){return s&&s.__esModule?s:{default:s}}function xf(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)}function _f(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e}function Pf(s,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof s=="function"?t===s:s.has(t)}function dn(s){var t=function(n){Error.call(n),n.stack=new Error().stack},e=s(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var hs=dn(function(s){return function(e){s(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
7
|
+
`+e.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
8
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function Le(s,t){if(s){var e=s.indexOf(t);0<=e&&s.splice(e,1)}}var ne=function(){function s(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var t,e,n,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(y){t={error:y}}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(y){r=y instanceof hs?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=A(d),g=u.next();!g.done;g=u.next()){var w=g.value;try{fn(w)}catch(y){r=r!=null?r:[],y instanceof hs?r=L(L([],p(r)),p(y.errors)):r.push(y)}}}catch(y){n={error:y}}finally{try{g&&!g.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(r)throw new hs(r)}},s.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)fn(t);else{if(t instanceof s){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},s.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},s.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},s.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Le(e,t)},s.prototype.remove=function(t){var e=this._finalizers;e&&Le(e,t),t instanceof s&&t._removeParent(this)},s.EMPTY=function(){var t=new s;return t.closed=!0,t}(),s}(),un=ne.EMPTY;function gn(s){return s instanceof ne||s&&"closed"in s&&k(s.remove)&&k(s.add)&&k(s.unsubscribe)}function fn(s){k(s)?s():s.unsubscribe()}var Zt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},De={setTimeout:function(s,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];var i=De.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,L([s,t],p(e))):setTimeout.apply(void 0,L([s,t],p(e)))},clearTimeout:function(s){var t=De.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(s)},delegate:void 0};function pn(s){De.setTimeout(function(){var t=Zt.onUnhandledError;if(t)t(s);else throw s})}function mn(){}var Fo=function(){return ds("C",void 0,void 0)}();function Ho(s){return ds("E",void 0,s)}function ko(s){return ds("N",s,void 0)}function ds(s,t,e){return{kind:s,value:t,error:e}}var $t=null;function Ie(s){if(Zt.useDeprecatedSynchronousErrorHandling){var t=!$t;if(t&&($t={errorThrown:!1,error:null}),s(),t){var e=$t,n=e.errorThrown,i=e.error;if($t=null,n)throw i}}else s()}function Yo(s){Zt.useDeprecatedSynchronousErrorHandling&&$t&&($t.errorThrown=!0,$t.error=s)}var us=function(s){z(t,s);function t(e){var n=s.call(this)||this;return n.isStopped=!1,e?(n.destination=e,gn(e)&&e.add(n)):n.destination=zo,n}return t.create=function(e,n,i){return new de(e,n,i)},t.prototype.next=function(e){this.isStopped?fs(ko(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?fs(Ho(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?fs(Fo,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,s.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}(ne),jo=Function.prototype.bind;function gs(s,t){return jo.call(s,t)}var No=function(){function s(t){this.partialObserver=t}return s.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(n){Be(n)}},s.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(n){Be(n)}else Be(t)},s.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Be(e)}},s}(),de=function(s){z(t,s);function t(e,n,i){var r=s.call(this)||this,o;if(k(e)||!e)o={next:e!=null?e:void 0,error:n!=null?n:void 0,complete:i!=null?i:void 0};else{var a;r&&Zt.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&gs(e.next,a),error:e.error&&gs(e.error,a),complete:e.complete&&gs(e.complete,a)}):o=e}return r.destination=new No(o),r}return t}(us);function Be(s){Zt.useDeprecatedSynchronousErrorHandling?Yo(s):pn(s)}function Xo(s){throw s}function fs(s,t){var e=Zt.onStoppedNotification;e&&De.setTimeout(function(){return e(s,t)})}var zo={closed:!0,next:mn,error:Xo,complete:mn};function Pt(s,t,e,n,i){return new Wo(s,t,e,n,i)}var Wo=function(s){z(t,s);function t(e,n,i,r,o,a){var l=s.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=n?function(c){try{n(c)}catch(h){e.error(h)}}:s.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:s.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:s.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;s.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(us);function ct(s,t){return N(function(e,n){var i=0;e.subscribe(Pt(n,function(r){n.next(s.call(t,r,i++))}))})}var vn=function(s){return s&&typeof s.length=="number"&&typeof s!="function"};function bn(s){return k(s==null?void 0:s.then)}var ps=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ie(s){return s}function Tf(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];return Cn(s)}function Cn(s){return s.length===0?ie:s.length===1?s[0]:function(e){return s.reduce(function(n,i){return i(n)},e)}}var gt=function(){function s(t){t&&(this._subscribe=t)}return s.prototype.lift=function(t){var e=new s;return e.source=this,e.operator=t,e},s.prototype.subscribe=function(t,e,n){var i=this,r=Vo(t)?t:new de(t,e,n);return Ie(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},s.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},s.prototype.forEach=function(t,e){var n=this;return e=wn(e),new e(function(i,r){var o=new de({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});n.subscribe(o)})},s.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},s.prototype[ps]=function(){return this},s.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Cn(t)(this)},s.prototype.toPromise=function(t){var e=this;return t=wn(t),new t(function(n,i){var r;e.subscribe(function(o){return r=o},function(o){return i(o)},function(){return n(r)})})},s.create=function(t){return new s(t)},s}();function wn(s){var t;return(t=s!=null?s:Zt.Promise)!==null&&t!==void 0?t:Promise}function Uo(s){return s&&k(s.next)&&k(s.error)&&k(s.complete)}function Vo(s){return s&&s instanceof us||Uo(s)&&gn(s)}function yn(s){return k(s[ps])}function Sn(s){return Symbol.asyncIterator&&k(s==null?void 0:s[Symbol.asyncIterator])}function xn(s){return new TypeError("You provided "+(s!==null&&typeof s=="object"?"an invalid object":"'"+s+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Go(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var _n=Go();function Pn(s){return k(s==null?void 0:s[_n])}function Tn(s){return at(this,arguments,function(){var e,n,i,r;return f(this,function(o){switch(o.label){case 0:e=s.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,O(e.read())];case 3:return n=o.sent(),i=n.value,r=n.done,r?[4,O(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,O(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 Mn(s){return k(s==null?void 0:s.getReader)}function Rt(s){if(s instanceof gt)return s;if(s!=null){if(yn(s))return Zo(s);if(vn(s))return $o(s);if(bn(s))return Ko(s);if(Sn(s))return An(s);if(Pn(s))return qo(s);if(Mn(s))return Jo(s)}throw xn(s)}function Zo(s){return new gt(function(t){var e=s[ps]();if(k(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function $o(s){return new gt(function(t){for(var e=0;e<s.length&&!t.closed;e++)t.next(s[e]);t.complete()})}function Ko(s){return new gt(function(t){s.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,pn)})}function qo(s){return new gt(function(t){var e,n;try{for(var i=A(s),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&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.complete()})}function An(s){return new gt(function(t){Qo(s,t).catch(function(e){return t.error(e)})})}function Jo(s){return An(Tn(s))}function Qo(s,t){var e,n,i,r;return C(this,void 0,void 0,function(){var o,a;return f(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=Ot(s),l.label=1;case 1:return[4,e.next()];case 2:if(n=l.sent(),!!n.done)return[3,4];if(o=n.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]),n&&!n.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 Ft(s,t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var r=t.schedule(function(){e(),i?s.add(this.schedule(null,n)):this.unsubscribe()},n);if(s.add(r),!i)return r}function ta(s,t,e,n,i,r,o,a){var l=[],c=0,h=0,d=!1,u=function(){d&&!l.length&&!c&&t.complete()},g=function(y){return c<n?w(y):l.push(y)},w=function(y){r&&t.next(y),c++;var _=!1;Rt(e(y,h++)).subscribe(Pt(t,function(M){i==null||i(M),r?g(M):t.next(M)},function(){_=!0},void 0,function(){if(_)try{c--;for(var M=function(){var B=l.shift();o?Ft(t,o,function(){return w(B)}):w(B)};l.length&&c<n;)M();u()}catch(B){t.error(B)}}))};return s.subscribe(Pt(t,g,function(){d=!0,u()})),function(){a==null||a()}}function En(s,t,e){return e===void 0&&(e=1/0),k(t)?En(function(n,i){return ct(function(r,o){return t(n,r,i,o)})(Rt(s(n,i)))},e):(typeof t=="number"&&(e=t),N(function(n,i){return ta(n,i,s,e)}))}function Ln(s){return s===void 0&&(s=1/0),En(ie,s)}var Dn=new gt(function(s){return s.complete()});function Mf(s){return s?ea(s):Dn}function ea(s){return new Observable(function(t){return s.schedule(function(){return t.complete()})})}function In(s){return s&&k(s.schedule)}function ms(s){return s[s.length-1]}function sa(s){return k(ms(s))?s.pop():void 0}function Oe(s){return In(ms(s))?s.pop():void 0}function na(s,t){return typeof ms(s)=="number"?s.pop():t}function Bn(s,t){return t===void 0&&(t=0),N(function(e,n){e.subscribe(Pt(n,function(i){return Ft(n,s,function(){return n.next(i)},t)},function(){return Ft(n,s,function(){return n.complete()},t)},function(i){return Ft(n,s,function(){return n.error(i)},t)}))})}function On(s,t){return t===void 0&&(t=0),N(function(e,n){n.add(s.schedule(function(){return e.subscribe(n)},t))})}function ia(s,t){return Rt(s).pipe(On(t),Bn(t))}function ra(s,t){return Rt(s).pipe(On(t),Bn(t))}function oa(s,t){return new gt(function(e){var n=0;return t.schedule(function(){n===s.length?e.complete():(e.next(s[n++]),e.closed||this.schedule())})})}function aa(s,t){return new gt(function(e){var n;return Ft(e,t,function(){n=s[_n](),Ft(e,t,function(){var i,r,o;try{i=n.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return k(n==null?void 0:n.return)&&n.return()}})}function Rn(s,t){if(!s)throw new Error("Iterable cannot be null");return new gt(function(e){Ft(e,t,function(){var n=s[Symbol.asyncIterator]();Ft(e,t,function(){n.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function la(s,t){return Rn(Tn(s),t)}function ca(s,t){if(s!=null){if(yn(s))return ia(s,t);if(vn(s))return oa(s,t);if(bn(s))return ra(s,t);if(Sn(s))return Rn(s,t);if(Pn(s))return aa(s,t);if(Mn(s))return la(s,t)}throw xn(s)}function Re(s,t){return t?ca(s,t):Rt(s)}function ft(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];var e=Oe(s),n=na(s,1/0),i=s;return i.length?i.length===1?Rt(i[0]):Ln(n)(Re(i,e)):Dn}class vs{constructor(t,e){this.onTickFunction=e,this.animationTimeLeft=0,this.animationInProgress=!1,this.animationTime=t.duration,this.animationTimeLeft=t.timeLeft===void 0?t.duration:t.timeLeft,this.animationInProgress=!0}tick(){this.animationTimeLeft<=0?this.animationInProgress=!1:this.animationTimeLeft--,this.onTickFunction&&this.onTickFunction()}getProgress(){return 1-this.animationTimeLeft/this.animationTime}finishAnimation(){this.animationInProgress=!1,this.animationTimeLeft=0}}var ha=bt(767),Et=bt.n(ha);class da extends vs{constructor(t,e,n=()=>{}){super(t,n),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Et().rgb(i.color),i.initialAlpha=i.rgbColor.valpha,i.currentAnimationColor=i.rgbColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{t.initialAlpha===void 0||t.rgbColor===void 0||(t.type==="fading"?t.currentAnimationColor=t.rgbColor.alpha(t.initialAlpha*this.animationTimeLeft/this.animationTime):t.type==="appearing"&&(t.currentAnimationColor=t.rgbColor.alpha(t.initialAlpha*(1-this.animationTimeLeft/this.animationTime))))})}getColor(t){var e,n;return(n=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?n:"#FFFFFF"}revert(){this.animationTimeLeft=Math.max(this.animationTime-this.animationTimeLeft,1),this.colorConfigs.forEach(t=>{t.type==="fading"?t.type="appearing":t.type="fading"})}}class ua extends vs{constructor(t,e,n=()=>{}){super(t,n),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Et().rgb(i.startColor),i.rgbEndColor=Et().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,n;return(n=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?n:"#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,n){const i=t.red()-(t.red()-e.red())*n,r=t.green()-(t.green()-e.green())*n,o=t.blue()-(t.blue()-e.blue())*n;return Et().rgb(i,r,o)}}var ga=Math.pow;const Fe=14,He=[];for(let s=0;s<Fe+1;s++)He.push(ga(10,s));const bs=5e-13;class ht{static roundToNearest(t,e){return isFinite(t)?ht.isZero(t)?0:(t>0?t+=bs:t<0&&(t-=bs),ht.roundDecimal(Math.round(ht.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return ht.roundDecimal(Math.ceil(t/e))*e}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const e=Math.sign(t),n=Math.abs(t),i=Math.min(Fe,Fe-1-Math.floor(Math.log10(n)));for(let r=i;r>=0;r--){const o=Math.floor(He[r]*n+.5);if(o<He[Fe])return e*o/He[r]}return Math.round(t)}static makeDecimal(t,e,n){if(isFinite(t)){const i=t.toFixed(e);return n?i.replace(".",n):i}else return""}static compare(t,e,n){return t>e+n?1:t<e-n?-1:(isNaN(t)?1:0)-(isNaN(e)?1:0)}static isZero(t){return ht.compare(t,0,bs)===0}static cutNumber(t,e,n=0){return{K:r=>r/1e3,M:r=>r/1e6}[e](t).toFixed(n)+e}static isExponential(t){return/\de(\-|\+)\d/.test(t.toString())}}function fa(s,t,e){const n=s/t;return n>=e||n<=1/e}function Fn(s,t,e){return Math.max(t,Math.min(s,e))}function pa(s){return 1-(Math.pow(2,-10*s)-.0009765625)*1.0009775171065494}function ue(...s){for(const t of s)if(t!==void 0&&isFinite(t))return t;return NaN}const nt=s=>~~s,ma=s=>~~(s+1),Kt=s=>~~(s+.5),va=(s,t)=>s>>t;function Ct(){const s=()=>Math.random().toString(16).slice(-4);return`${s()+s()}-${s()}-${s()}-${s()}-${s()+s()+s()}`}class ba extends vs{constructor(t,e,n){var i;super(e,n),this.viewportModel=t,this.animationConfig=e,this.id=Ct(),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:pa}tick(){if(super.tick(),this.animationInProgress){const t=this.easingFn(this.getProgress()),e=this.xStart+(this.animationConfig.targetXStart-this.xStart)*t,n=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:n,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 Ca=Object.defineProperty,wa=Object.defineProperties,ya=Object.getOwnPropertyDescriptors,Hn=Object.getOwnPropertySymbols,Sa=Object.prototype.hasOwnProperty,xa=Object.prototype.propertyIsEnumerable,kn=(s,t,e)=>t in s?Ca(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,_a=(s,t)=>{for(var e in t||(t={}))Sa.call(t,e)&&kn(s,e,t[e]);if(Hn)for(var e of Hn(t))xa.call(t,e)&&kn(s,e,t[e]);return s},Pa=(s,t)=>wa(s,ya(t));const Yn=10,Cs="VIEWPORT_ANIMATION";class Ta{constructor(t){this.eventBus=t,this.animations={}}startViewportMovementAnimation(t,e,n=Cs,i){const r=new ba(t,e,i);return this.animations[n]=r,this.ensureIntervalStarted(),r}startColorAlphaAnimation(t,e,n,i){const r=new da(Pa(_a({},i),{duration:i&&i.duration||Yn}),e,n);return this.animations[t]=r,this.ensureIntervalStarted(),r}startColorTransitionAnimation(t,e,n=Yn,i){const r=new ua({duration:n},e,i);return this.animations[t]=r,this.ensureIntervalStarted(),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.animationTimeLeft=-1,e.animationInProgress=!1)}ensureIntervalStarted(){this.animationIntervalId||(this.animationIntervalId=window.setInterval(()=>this.tick(),20))}tick(){let t=!0;for(const e of Object.keys(this.animations)){const n=this.animations[e];n.tick(),n.animationInProgress&&(t=!1)}t?this.stopInterval():this.eventBus.fireDraw()}stopInterval(){clearInterval(this.animationIntervalId),this.animationIntervalId=void 0}}var Ma=dn(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),I=function(s){z(t,s);function t(){var e=s.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 n=new jn(this,this);return n.operator=e,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ma},t.prototype.next=function(e){var n=this;Ie(function(){var i,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=A(n.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 n=this;Ie(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var i=n.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ie(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.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(),s.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 n=this,i=this,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?un:(this.currentObservers=null,a.push(e),new ne(function(){n.currentObservers=null,Le(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var n=this,i=n.hasError,r=n.thrownError,o=n.isStopped;i?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new gt;return e.source=this,e},t.create=function(e,n){return new jn(e,n)},t}(gt),jn=function(s){z(t,s);function t(e,n){var i=s.call(this)||this;return i.destination=e,i.source=n,i}return t.prototype.next=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,e)},t.prototype.error=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,e)},t.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},t.prototype._subscribe=function(e){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&i!==void 0?i:un},t}(I),Tt=function(s){z(t,s);function t(e){var n=s.call(this)||this;return n._value=e,n}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var n=s.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},t.prototype.getValue=function(){var e=this,n=e.hasError,i=e.thrownError,r=e._value;if(n)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){s.prototype.next.call(this,this._value=e)},t}(I);function Lt(s,t){return t===void 0&&(t=ie),s=s!=null?s:Aa,N(function(e,n){var i,r=!0;e.subscribe(Pt(n,function(o){var a=t(o);(r||!s(i,a))&&(r=!1,i=a,n.next(o))}))})}function Aa(s,t){return s===t}function Ea(s){return function(){s.forEach(e=>typeof e=="function"&&e()),s.length=0}}function ws(s){return s}function Nn(s){return s!=null}const Af=()=>{};function Ef(s){return s!=null}function La(s,t,e=Da,n=!0){const i=s.filter(r=>t.some(o=>e(r,o)));return n?i.filter((r,o,a)=>a.indexOf(r)===o):i}const Xn=(s,t)=>{const e=t.slice().filter(n=>s.find(i=>i===n));return s.map(n=>{var i;return t.indexOf(n)>=0&&(i=e.shift())!=null?i:n})},Da=(s,t)=>s===t,Lf=(s,t,e)=>s.filter(n=>t.filter(i=>e(n,i)).length===0),Ia=(s,t)=>s===t,zn=(s,t,e=Ia)=>s.length===t.length&&s.every((n,i)=>e(n,t[i]));function Df(s,t,e){const n=s.slice(),i=n[t];return n.splice(t,1),n.splice(e,0,i),n}function ys(s,t,e){const n=s.length,i=Fn(t,0,n-1),r=Fn(e,0,n-1),o=s[i];return s.splice(i,1),s.splice(r,0,o),s}function If(s,t,e){const n=s.slice(),i=n.findIndex(t);return i!==-1&&(n.splice(i,1),n.splice(i,0,e)),n}const Bf=s=>{const t={};return s.filter(e=>t[e]?!1:t[e]=!0)},Of=(s,t)=>s.reduce((e,n)=>((e[n[t]]=e[n[t]]||[]).push(n),e),{}),Rf=(s,t)=>[].concat(...s.map(e=>[e,t])).slice(0,-1),Ff=s=>Array.isArray(s[0]),Wn=s=>Array.isArray(s[0])?s:[s],Ba=(s,t,e)=>{const n=[];let i=0;for(const r of s){const o=Math.max(t-i,0),a=Math.max(e-i,-1),l=r.slice(o,a+1);l.length>0&&n.push(l),i+=r.length}return n},Oa=(s,t)=>s>=0?t[s]:t[t.length+s],pt=s=>Array.prototype.flat?s.flat():ge(s,ws),ge=(s,t)=>{if(Array.prototype.flatMap)return s.flatMap(t);const e=[];for(let n=0;n<s.length;n++){const i=s[n];e.push(...t(i,n,s))}return e};function zt(s,t,e){const n=e!=null?e:ws;return!s.length||t!==t?{index:-1,exact:!0}:Ss(s,t,0,s.length,n)}function Ss(s,t,e,n,i){const r=va(e+n,1),o=i(s[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Ss(s,t,e,r,i):Ss(s,t,r,n,i)}function wt(s){if(s&&s.length)return s[s.length-1]}function Ra(s){const t=this.indexOf(s);return t!==-1&&this.splice(t,1),this}function Fa(s,t){if(!s)return;const e=s.indexOf(t);e!==-1&&s.splice(e,1)}function fe(s){if(s)return s[0]}function Ha(s){function t(e,n){const i=s(n);return i==null||!isFinite(i)?e:[Math.max(e[0],i),Math.min(e[1],i)]}return function(e){const n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,n):n}}function ka(s,t,e,n=()=>0){const i=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);n(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);n(o[h])>=a?c=h-1:l=h+1}return l};return s.slice(r(s,t),i(s,e)+1)}let xs;const _s=()=>(xs||(xs=!!navigator.userAgent.match(/Android|iPhone|Opera Mini/)||!1),xs),Ya=1.33;function Un(s,t){let e="";t.textStyle&&(t.textStyle.italic&&(e+="italic "),t.textStyle.bold&&(e+="bold ")),s.font=e+(t.textSize||12)+" "+(t.textFontFamily||"monospace"),s.fillStyle=t.textFill||"#FFFFFF",t.rtl?s.textAlign="right":s.textAlign="start"}function ke(s,t=!0){const e=s.font.match(/(\d+.)?\d+(px|pt)/gi);let n="10px";return e&&e.length&&(e[0].includes("pt")?n=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":n=e[0]),t?parseInt(n,10)*Ya:parseInt(n,10)}function Vn(s,t,e){s.save(),Un(s,e);const n=Math.ceil(Math.max.apply(Math,t.map(o=>s.measureText(o).width))),i=ke(s),r=i*t.length;return s.restore(),[n,r,i]}function Gn(s){return(s||"").split(/\r\n|\r|\n/)}function ja(s,t,e,n,i){s.save();const[r,,o]=Vn(s,t,i);t.forEach((a,l)=>{var c,h,d;const u=s.measureText(a).width,g=Na(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&Xa(s,a,g,n+o*l,(h=i.textFill)!=null?h:"",(d=i.textSize)!=null?d:""),s.fillText(a,g,n+o*l)}),s.restore()}function Na(s,t,e,n){switch(n){case"left":return s;case"right":return s+t-e;default:return s}}function Xa(s,t,e,n,i,r){s.save();const o=s.measureText(t).width,a=e,l=e+o,c=n+2,h=c;let d=parseInt(r,10)/15;d<1&&(d=1),s.beginPath(),s.strokeStyle=i,s.lineWidth=d,s.moveTo(a,c),s.lineTo(l,h),s.stroke(),s.restore()}function Hf(s){return`${s}px`}function qt(s,t,e){const n=Et().rgb(s).array(),i=n[0],r=n[1],o=n[2];return(i*299+r*587+o*114)/1e3<128?t:e}function za(s,t,e,n){const i=n.components.navigationMap.timeLabels,r=i.padding,o=Zn(t,i.dateFormat,e),a=Gn(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=Vn(s,a,l);return[c+r.x*2,h+r.y*2]}function Zn(s,t,e){return e(t)(s).split(" ").join(`
|
|
9
|
+
`)}const $n={};function Ht(s,t){let e=$n[s];return e!==void 0||(t.save(),t.font=s,e=t.measureText("M").width,$n[s]=e,t.restore()),e}const Kn=new Map;function yt(s,t,e){const n=e+s;let i=Kn.get(n);return i||(t.save(),t.font=e,i=t.measureText(s).width,Kn.set(n,i),t.restore()),i}function Dt(s,t,e=qn){function n(i,r){for(const o in r)o in i?typeof i[o]=="object"&&i[o]!==null&&!Array.isArray(i[o])?n(i[o],r[o]):e!=null&&e.overrideExisting&&(i[o]=r[o]):e!=null&&e.addIfMissing&&(i[o]=r[o]);return i}return n(s,t)}function kf(s,t,e,n=!1){!s||!t||t.length===0||t.forEach(i=>{const r=e(i),o=s.findIndex(a=>e(a)===r);o===-1?s.push(i):n?Dt(s[o],i,{overrideExisting:!0,addIfMissing:!0}):s.splice(o,1,i)})}const qn={overrideExisting:!1,addIfMissing:!0};var Wa=Object.defineProperty,Jn=Object.getOwnPropertySymbols,Ua=Object.prototype.hasOwnProperty,Va=Object.prototype.propertyIsEnumerable,Qn=(s,t,e)=>t in s?Wa(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Ga=(s,t)=>{for(var e in t||(t={}))Ua.call(t,e)&&Qn(s,e,t[e]);if(Jn)for(var e of Jn(t))Va.call(t,e)&&Qn(s,e,t[e]);return s};const ti="Open Sans Semibold, sans-serif",Za=null,$a=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],Yf=s=>Za.find(t=>t===s)!==void 0,Ye=()=>({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,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,pinch:.05,glide:.05},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}},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:ti,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"}}}},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:ti,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"},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:846e5}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:846e5,periodMoreThen:6e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6e3}}],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(55,55,54,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)"},"conference-calls":{color:"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:"transparent",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:"transparent",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","UNDERLAY_VOLUMES_AREA","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function Ka(s,t=Ye()){return Dt(s,t,qn),s}function jf(s,t=Ye()){const e=Ga({},s);return merge(e,t,DEFAULT_MERGE_OPTIONS),e}function Nf(s,t){Object.keys(s).forEach(e=>delete s[e]),Object.keys(t).forEach(e=>s[e]=t[e])}function ei(s){return typeof s=="object"&&s!==null}function si(s,t){return[...s].map(n=>Ps(n,t))}const qa=s=>Array.isArray(s);function Ps(s,t){if(!ei(s))return s;if(qa(s))return si(s,t);{const e=ni({},s,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(s)),e}}function ni(s,t,e){if(!ei(s))return e.overrideExisting?t:s;if(Array.isArray(s)&&Array.isArray(t)){const i=e.overrideExisting?t:s;return si(i,e)}const n=Object.create(Object.getPrototypeOf(s));return Object.keys(s).forEach(i=>n[i]=Ps(s[i],e)),Object.keys(t).forEach(i=>{i in s?n[i]=ni(s[i],t[i],e):e.addIfMissing&&(n[i]=Ps(t[i],e))}),n}const Jt=s=>`${s.fontSize}px ${s.fontFamily}`;class Ja{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=Jt(this.config.components.yAxis);return yt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(n=>{var i,r,o;const a=n.getYAxisState(),l=a.labelBoxMargin.start+a.labelBoxMargin.end,c=this.getTextWidth(n.getLargestLabel())+l,h=n.getYAxisIndex(),d=n.getPaneUUID(),u=(i=this.extentsOrder.get(d))!=null?i:{left:[],right:[]};if(a.align==="left"){const g=u.left.length;t[g]=Math.max((r=t[g])!=null?r:0,c),u.left.push(h)}else{const g=u.right.length;e[g]=Math.max((o=e[g])!=null?o:0,c),u.right.push(h)}this.extentsOrder.set(d,u)}),{left:t,right:e}}}var Qa=Object.defineProperty,tl=Object.defineProperties,el=Object.getOwnPropertyDescriptors,ii=Object.getOwnPropertySymbols,sl=Object.prototype.hasOwnProperty,nl=Object.prototype.propertyIsEnumerable,ri=(s,t,e)=>t in s?Qa(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,kt=(s,t)=>{for(var e in t||(t={}))sl.call(t,e)&&ri(s,e,t[e]);if(ii)for(var e of ii(t))nl.call(t,e)&&ri(s,e,t[e]);return s},oi=(s,t)=>tl(s,el(t));const q="CHART",Ts=class{};let x=Ts;x.CANVAS="CANVAS",x.N_MAP="N_MAP",x.X_AXIS="X_AXIS",x.N_MAP_KNOT_L="N_MAP_KNOT_L",x.N_MAP_KNOT_R="N_MAP_KNOT_R",x.N_MAP_BTN_L="N_MAP_BTN_L",x.N_MAP_BTN_R="N_MAP_BTN_R",x.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",x.N_MAP_CHART="N_MAP_CHART",x.N_MAP_LABEL_R="N_MAP_LABEL_R",x.N_MAP_LABEL_L="N_MAP_LABEL_L",x.PANE_UUID=s=>"PANE_"+s,x.PANE_UUID_Y_AXIS=(s,t=0)=>"PANE_"+s+"_Y_AXIS_"+t,x.PANE_UUID_RESIZER=s=>"PANE_"+s+"_RESIZER",x.ALL_PANES="ALL_PANES",x.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",x.EVENTS="EVENTS",x.CHART=Ts.PANE_UUID(q),x.Y_AXIS=Ts.PANE_UUID_Y_AXIS(q);const ai={x:0,y:0,pageX:0,pageY:0,width:0,height:0},il=20,li=35,Ms=15,ci=1.5,As=_s()?8*ci:8,rl=1e-6;class Es{constructor(t,e,n,i,r){this.config=t,this.eventBus=e,this.canvasModel=n,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new I,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new I,this.barResizerChangedSubject=new I,this._graphsHeightRatio={chart:1},this.graphsHeightRatioChangedSubject=new I,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new Ja(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 n=this.panesOrder.indexOf(t);ys(this.panesOrder,n,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=kt(kt({},this.graphsHeightRatio),t),n=Object.values(e).reduce((i,r)=>i+r,0);Math.abs(n-1)<rl?(this._graphsHeightRatio=e,this.recalculateBounds()):console.error(`Result ratio should be equal 1, but equal ${n}`)}movePaneUp(t){const e=this.panesOrder.indexOf(t);e!==-1&&(ys(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder))}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(ys(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder))}reorderPanes(t){this.panesOrder=Xn(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}removedPaneBounds(t){Fa(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[x.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,n)=>delete this.bounds[x.PANE_UUID_Y_AXIS(t,n)]),delete this.bounds[x.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,n=this.config.components.paneResizer.height,i=this.getBounds(x.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((j,H)=>j+H,0),h=r.right.reduce((j,H)=>j+H,0),d=0,u=i.width-h,g=d+c,w=0,y=i.width-c-h;let _=w;this.panesOrder.forEach((j,H)=>{var R;const Y=this.graphsHeightRatio[this.panesOrder[H]],Z=this.config.components.paneResizer.visible;Z&&(H!==0?re(this.bounds,x.PANE_UUID_RESIZER(j),0,_,i.width,n,this.canvasOnPageLocation):re(this.bounds,x.PANE_UUID_RESIZER(j),0,0,0,0,this.canvasOnPageLocation));const K=re(this.bounds,x.PANE_UUID(j),g,Z?_+n:_,y,Z?l*Y-this.config.components.paneResizer.height:l*Y,this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const U=this.yAxisBoundsContainer.extentsOrder.get(j);if(U===void 0)return;const W=Z?_+n:_,J=Z?l*Y-n:l*Y;let Q=g-((R=r.left[0])!=null?R:0),tt=u;U.left.forEach((et,it)=>{var ot;re(this.bounds,x.PANE_UUID_Y_AXIS(j,et),Q,W,r.left[it],J,this.canvasOnPageLocation),Q-=(ot=r.left[it+1])!=null?ot:0}),U.right.forEach((et,it)=>{re(this.bounds,x.PANE_UUID_Y_AXIS(j,et),tt,W,r.right[it],J,this.canvasOnPageLocation),tt+=r.right[it]})}else re(this.bounds,x.PANE_UUID_Y_AXIS(j),0,0,0,0,this.canvasOnPageLocation);_=K.y+K.height});const M=this.getBounds(x.ALL_PANES);M.x=g,M.y=w,M.width=y,M.height=_;const B=this.getBounds(x.CHART_WITH_Y_AXIS),F=this.getBounds(x.PANE_UUID(q));this.getEventsBounds(F),this.copyBounds(F,B),B.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=oi(kt({},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(x.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(x.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-li,e.width=t.width,e.height=li):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const n=this.getBounds(x.X_AXIS);return this.config.components.xAxis.visible?(n.x=0,n.y=e.height-this.getXAxisHeight()-t.height,n.width=e.width,n.height=this.getXAxisHeight()):this.applyDefaultBounds(n),n}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const n=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,i=Ht(n,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)}return this.xAxisHeight}setYAxisWidths(t){(!zn(this.yAxisWidths.left,t.left)||!zn(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[q];const e=[];e.push(...this.panesOrder.filter(d=>d!==q)),this.panesOrder.forEach(d=>{this.graphsHeightRatio[d]===0&&delete this.graphsHeightRatio[d]});const n=e.map(d=>this.graphsHeightRatio[d]===void 0?void 0:this.graphsHeightRatio[d]),i=n.filter(d=>d!==void 0).length,r=n.filter(d=>d===void 0).length;let o=0,a=0,l=1,c=0;r>0&&([l,c]=al(e.length),t*=l),i===0&&(t=1-c*r),a=1-t-c*r,n.forEach(d=>{d&&(a-=d*l)}),o=a/(e.length+1);const h=n.map(d=>d?d*l+o:c+o);t+=o,this._graphsHeightRatio={},this.graphsHeightRatio[q]=t,h.forEach((d,u)=>{const g=e[u];this.graphsHeightRatio[g]=d})}recalculateNavigationMapElementBounds(){var t,e,n,i;if(this.config.components.navigationMap.visible){const r=this.getBounds(x.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=_s()?a*ci: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=Y=>za(this.canvasModel.ctx,Y,this.formatterFactory,this.config)[0],g=pt((i=(n=this.mainCandleSeries)==null?void 0:n.getSeriesInViewport())!=null?i:[]),w=d&&g.length?u(g[0].candle.timestamp):0,y=d&&g.length?u(g[g.length-1].candle.timestamp):0,_=Math.max(w,y);if(d){const Y=this.getBounds(x.N_MAP_LABEL_L);Y.x=r.x,Y.y=r.y,Y.width=_,Y.height=r.height;const Z=this.getBounds(x.N_MAP_LABEL_R);Z.x=r.x+r.width-_,Z.y=r.y,Z.width=_,Z.height=r.height}const M=this.getBounds(x.N_MAP_BTN_L);M.x=r.x+_,M.y=r.y,M.width=Ms,M.height=r.height;const B=this.getBounds(x.N_MAP_BTN_R);B.x=r.x+r.width-Ms-_,B.y=r.y,B.width=Ms,B.height=r.height;const F=this.getBounds(x.N_MAP_KNOT_L);F.x=(B.x-M.x-M.width)*this.leftRatio+M.x+M.width,F.y=h,F.width=c!=null?c:As,F.height=l!=null?l:r.height;const j=this.getBounds(x.N_MAP_KNOT_R);j.x=(B.x-M.x-M.width)*this.rightRatio+M.x+M.width-As,j.y=h,j.width=c!=null?c:As,j.height=l!=null?l:r.height;const H=this.getBounds(x.N_MAP_SLIDER_WINDOW);H.x=F.x+F.width,H.y=r.y,H.width=j.x-H.x,H.height=r.height;const R=this.getBounds(x.N_MAP_CHART);R.x=M.x+M.width,R.y=r.y,R.width=B.x-R.x,R.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(ai),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>oi(kt({},t),{[e]:this.bounds[x.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=je){const{extensionX:n,extensionY:i,wholePage:r}=kt(kt({},je),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-n&&o<l.pageX+l.width+n&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-n&&o<l.x+l.width+n&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=je){const{extensionX:n,extensionY:i,wholePage:r}=kt(kt({},je),e);return r?(o,a)=>o>t.pageX-n&&o<t.pageX+t.width+n&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-n&&o<t.x+t.width+n&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(x.CANVAS);return t.width>0&&t.height>0}resizePaneVertically(t,e){const n=this.panesOrder.indexOf(t),i=this.getBounds(x.PANE_UUID_RESIZER(t));this.doResizePaneVertically(n,i.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){const n=t-1,i=this.getBounds(x.ALL_PANES).height,r=this.config.components.paneResizer.height+il,o=i*this.graphsHeightRatio[this.panesOrder[t]],a=i*this.graphsHeightRatio[this.panesOrder[n]],l=o+e>r,c=a-e>r;if(l&&c){const h=e/i;this.graphsHeightRatio[this.panesOrder[t]]+=h,this.graphsHeightRatio[this.panesOrder[n]]-=h,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 Tt(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(ct(n=>this.copyOf(n)),Lt((n,i)=>this.sameBounds(n,i)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return kt({},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(ai,t)}setMainCandleSeries(t){this.mainCandleSeries=t}}const ol={0:1,1:.8,2:.6,3:.5,4:.4,5:.2},al=s=>{var t;const e=(t=ol[s])!=null?t:.4,n=(1-e)/s;return[e,n]},Xf=(s,t)=>s.x>t.x&&s.x<t.x+t.width&&s.y>t.y&&s.y<t.y+t.height,ll=(s,t)=>s>t.y&&s<t.y+t.height,re=(s,t,e,n,i,r,o)=>{const a=s[t];if(a)return a.x=e,a.y=n,a.pageX=e+o.x,a.pageY=n+o.y,a.width=i,a.height=r,a;const l={x:e,y:n,pageX:e+o.x,pageY:n+o.y,width:i,height:r};return s[t]=l,l},hi=(s,t)=>Math.min(Math.max(s,t.y),t.y+t.height),je={extensionX:0,extensionY:0,wholePage:!1},di=(s,t)=>s.width===t.width&&s.height===t.height;var cl=function(s){z(t,s);function t(e,n){return s.call(this)||this}return t.prototype.schedule=function(e,n){return n===void 0&&(n=0),this},t}(ne),Ne={setInterval:function(s,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];var i=Ne.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,L([s,t],p(e))):setInterval.apply(void 0,L([s,t],p(e)))},clearInterval:function(s){var t=Ne.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(s)},delegate:void 0},ui=function(s){z(t,s);function t(e,n){var i=s.call(this,e,n)||this;return i.scheduler=e,i.work=n,i.pending=!1,i}return t.prototype.schedule=function(e,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,n),this},t.prototype.requestAsyncId=function(e,n,i){return i===void 0&&(i=0),Ne.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&Ne.clearInterval(n)},t.prototype.execute=function(e,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,n){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,n=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Le(r,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,s.prototype.unsubscribe.call(this)}},t}(cl),pe={schedule:function(s){var t=requestAnimationFrame,e=cancelAnimationFrame,n=pe.delegate;n&&(t=n.requestAnimationFrame,e=n.cancelAnimationFrame);var i=t(function(r){e=void 0,s(r)});return new ne(function(){return e==null?void 0:e(i)})},requestAnimationFrame:function(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];var e=pe.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,L([],p(s)))},cancelAnimationFrame:function(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];var e=pe.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,L([],p(s)))},delegate:void 0},hl=function(s){z(t,s);function t(e,n){var i=s.call(this,e,n)||this;return i.scheduler=e,i.work=n,i}return t.prototype.requestAsyncId=function(e,n,i){return i===void 0&&(i=0),i!==null&&i>0?s.prototype.requestAsyncId.call(this,e,n,i):(e.actions.push(this),e._scheduled||(e._scheduled=pe.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,n,i){var r;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return s.prototype.recycleAsyncId.call(this,e,n,i);var o=e.actions;n!=null&&((r=o[o.length-1])===null||r===void 0?void 0:r.id)!==n&&(pe.cancelAnimationFrame(n),e._scheduled=void 0)},t}(ui),Ls={now:function(){return(Ls.delegate||Date).now()},delegate:void 0},gi=function(){function s(t,e){e===void 0&&(e=s.now),this.schedulerActionCtor=t,this.now=e}return s.prototype.schedule=function(t,e,n){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(n,e)},s.now=Ls.now,s}(),fi=function(s){z(t,s);function t(e,n){n===void 0&&(n=gi.now);var i=s.call(this,e,n)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var n=this.actions;if(this._active){n.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=n.shift());if(this._active=!1,i){for(;e=n.shift();)e.unsubscribe();throw i}},t}(gi),dl=function(s){z(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var n=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===n&&i.shift());if(this._active=!1,r){for(;(e=i[0])&&e.id===n&&i.shift();)e.unsubscribe();throw r}},t}(fi),me=new dl(hl),zf=null,pi=new fi(ui),ul=pi;function gl(s,t){return N(function(e,n){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,g=function(){d==null||d.unsubscribe(),d=null,l&&(_(),u&&n.complete())},w=function(){d=null,u&&n.complete()},y=function(M){return d=Rt(s(M)).subscribe(Pt(n,g,w))},_=function(){if(c){c=!1;var M=h;h=null,n.next(M),!u&&y(M)}};e.subscribe(Pt(n,function(M){c=!0,h=M,!(d&&!d.closed)&&(o?_():y(M))},function(){u=!0,!(l&&c&&d&&!d.closed)&&n.complete()}))})}function fl(s){return s instanceof Date&&!isNaN(s)}function pl(s,t,e){s===void 0&&(s=0),e===void 0&&(e=ul);var n=-1;return t!=null&&(In(t)?e=t:n=t),new gt(function(i){var r=fl(s)?+s-e.now():s;r<0&&(r=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=n?this.schedule(void 0,n):i.complete())},r)})}function ve(s,t,e){t===void 0&&(t=pi);var n=pl(s,t);return gl(function(){return n},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 ml extends X{constructor(t,e,n,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=n,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new I}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(ve(100,me,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(n=>{n.hitTest(t.x,t.y)&&this.updateCursor(n.cursor)}),this.extensionLayer.forEach(n=>{n.hitTest(t.x,t.y)&&this.updateCursor(n.cursor)}))})}setCursorForBounds(t,e,n,i=0){const r=Es.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:n,hitTest:r}):this.normalLayer.set(t,{cursor:n,hitTest:r})}setCursorForCanvasEl(t,e,n){this.observeCursorType(t,e,n)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(Lt())}observeCursorType(t,e,n){const i=n?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:n}):this.canvasBoundsContainer.getBoundsHitTest(t);n?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 vl=s=>{const t=s.canvasArea!==null,e=s.snapshotCanvas!==null,n=s.backgroundCanvas!==null,i=s.mainCanvas!==null,r=s.yAxisLabelsCanvas!==null,o=s.crossToolCanvas!==null,a=s.hitTestCanvas!==null,l=s.chartResizer!==null,c=s.chartContainer!==null,h=s.dynamicObjectsCanvas!==null;return t&&e&&n&&i&&r&&o&&a&&l&&c&&h},bl=s=>`<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" style="z-index: 0"></canvas>
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
<canvas data-element="yAxisLabelsCanvas" style="z-index: 4"></canvas>
|
|
17
17
|
<canvas data-element="crossToolCanvas" style="z-index: 5"></canvas>
|
|
18
18
|
<canvas data-element="hitTestCanvas" style="z-index: 6"></canvas>
|
|
19
|
-
${
|
|
19
|
+
${s?` <p style="position: absolute; visibility: hidden;">If you have any suggestions or are experiencing any issues, please feel free to contact us at <a href="https://devexperts.com/dxcharts/">devexperts.com</a></p>
|
|
20
20
|
`:""} </div>
|
|
21
21
|
</div>
|
|
22
22
|
</div>
|
|
23
|
-
`;function gl(n){const t=document.createElement("template");return t.innerHTML=fl(n.devexpertsPromoLink),t}function vl(n){const t={},e=Array.from(n.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(s=>{var r;t[(r=s.getAttribute("data-element"))!=null?r:""]=s}),ul(t))return t;throw new Error("Some chart elements are missing")}function ml(n){if(n.length>1){const t=n.reduce((r,i,a)=>{if(a!==n.length-1){const o=n[a+1].timestamp-i.timestamp;r[o]?r[o]++:r[o]=1}return r},{});let e=0,s;for(const r of Object.keys(t)){const i=parseInt(r,10),a=t[i];a>e&&i>0&&(e=a,s=i)}if(s)return s}}const Ue=(n,t,e,s=1e3)=>{var r,i,a,o;const l=(i=(r=ke(e))==null?void 0:r.timestamp)!=null?i:0,c=(o=(a=Yt(e))==null?void 0:a.timestamp)!=null?o:0;return n>c?t?{index:e.length-1+Math.ceil((n-c)/s),exact:!0}:{index:e.length-1,exact:!0}:n<l?t?{index:gt((n-l)/s),exact:!0}:{index:-1,exact:!0}:ue(e,n,h=>h.timestamp)},$n=1;function rn(n,t){return t===n?"none":t>n?"up":"down"}function pl(n,t){return t>n?"up":"down"}function bl(n,t,e=!1){const{expansion:s,impVolatility:r,vwap:i,volume:a,timestamp:o}=n;let l=n.hi,c=n.lo,h=n.open;const g=n.close;e&&(l=g,c=g,h=g);let p=n.idx;return t!==void 0&&(p=t),{hi:l,lo:c,open:h,close:g,timestamp:o,volume:a,expansion:s,idx:p,impVolatility:r,vwap:i}}const Sr={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2},xr={paintConfig:[Sr],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var Cl=Object.defineProperty,Pr=Object.getOwnPropertySymbols,yl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,Tr=(n,t,e)=>t in n?Cl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Sl=(n,t)=>{for(var e in t||(t={}))yl.call(t,e)&&Tr(n,e,t[e]);if(Pr)for(var e of Pr(t))wl.call(t,e)&&Tr(n,e,t[e]);return n};class xl{constructor(t,e,s,r){this.series=t,this.config=e,this.yAxisBoundsProvider=s,this.axisState=r}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,s=this.yAxisBoundsProvider(),r=this.config.labelMode,i=this.config.labelAppearanceType,a=e();if(a===void 0)return[];const o=this.series.view.toY(a.close);if(!isFinite(o))return[];const l=this.series.valueFormatter(a.close),c=this.getLabelDrawConfig();return[{labels:[Sl({y:o,description:this.series.name,mode:r,labelType:i,labelText:l},c)],axisState:this.axisState,bounds:s}]}getLabelDrawConfig(){var t;const e=this.series.config,r=((t=e.paintConfig[0])!=null?t:Sr).color;return{textColor:fe(r,"white","black"),bgColor:r,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}let Jt=window.devicePixelRatio,an=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const Zn=()=>{an.removeEventListener("change",Zn),Jt=window.devicePixelRatio,an=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),an.addEventListener("change",Zn)};an.addEventListener("change",Zn);const Pl=()=>Jt,Tl=n=>Ce(Jt*n)/Jt,st=n=>gt(Jt*n)/Jt,Mr=n=>uo(Jt*n)/Jt,We=n=>JSON.parse(JSON.stringify(n));function Kn(n){return Object.entries(n)}const _r=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function Dr(n){return Object.keys(n)}function Ar(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 r=0,i=e.length;r<i;r++)if(!hasOwnProperty.call(t,e[r])||!Ar(n[e[r]],t[e[r]]))return!1;return!0}function Er(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new X}:t,s=n.resetOnError,r=s===void 0?!0:s,i=n.resetOnComplete,a=i===void 0?!0:i,o=n.resetOnRefCountZero,l=o===void 0?!0:o;return function(c){var h,g,p,b=0,E=!1,O=!1,N=function(){g==null||g.unsubscribe(),g=void 0},k=function(){N(),h=p=void 0,E=O=!1},V=function(){var Z=h;k(),Z==null||Z.unsubscribe()};return y(function(Z,J){b++,!O&&!E&&N();var K=p=p!=null?p:e();J.add(function(){b--,b===0&&!O&&!E&&(g=Jn(V,l))}),K.subscribe(J),!h&&b>0&&(h=new be({next:function(U){return K.next(U)},error:function(U){O=!0,N(),g=Jn(k,r,U),K.error(U)},complete:function(){E=!0,N(),g=Jn(k,a),K.complete()}}),te(Z).subscribe(h))})(c)}}function Jn(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 r=new be({next:function(){r.unsubscribe(),n()}});return te(t.apply(void 0,x([],C(e)))).subscribe(r)}}const on=(n,t)=>n/t,Mt=(n,t)=>n/t,re=(n,t)=>n*t,Ir=(n,t)=>(n-t)*100/t,Or=(n,t)=>n*t/100+t,Lr=n=>Math.log2(n),qn=n=>Math.pow(2,n);class Ml extends tt{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 X,this.xChanged=this.changed.pipe(yt(()=>({start:this.xStart,end:this.xEnd})),Zt((t,e)=>t.start===e.start&&t.end===e.end),Er()),this.yChanged=this.changed.pipe(yt(()=>({start:this.yStart,end:this.yEnd})),Zt((t,e)=>t.start===e.start&&t.end===e.end),Er())}toX(t){return this.getBounds().x+Mt(t-this.xStart,this.zoomX)}xPixels(t){return Mt(t,this.zoomX)}toY(t){return this.inverseY?this.getBounds().y+Mt(t-this.yStart,this.zoomY):this.getBounds().y+this.getBounds().height-Mt(t-this.yStart,this.zoomY)}yPixels(t){return Mt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return re(e+Mt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=t-this.getBounds().y;return this.inverseY?re(e+Mt(this.yStart,this.zoomY),this.zoomY):re(this.getBounds().height-e+Mt(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 on(e-t,this.getBounds().width)}calculateZoomY(t,e){return on(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(){return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)}}const _l=(n,t)=>!Dr(n).some(e=>n[e]!==t[e]);class Dl{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 r=e.easingFn(e.getProgress());this.initialBaseline===void 0&&(this.initialBaseline=t(ue(this.dataSeries.visualPoints,e.xStart,i=>i.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(ue(this.dataSeries.visualPoints,e.animationConfig.targetXStart,i=>i.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*r}else s=t();return s}}class Br{constructor(t,e,s,r){this.dataSeries=t,this.scale=e,this.getAxisType=s,this.getBaseline=r,this.toY=i=>this.scale.toY(this.toAxisUnits(i)),this.toX=i=>this.scale.toX(i),this.xPixels=i=>this.scale.xPixels(i),this.yPixels=i=>this.scale.yPixels(i),this.percentAnimationHandler=new Dl(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return Ir(t,s);case"logarithmic":return Lr(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 Or(t,this.getBaseline());case"logarithmic":return qn(t);case"regular":return t}}}var Al=Object.defineProperty,El=Object.defineProperties,Il=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,Ol=Object.prototype.hasOwnProperty,Ll=Object.prototype.propertyIsEnumerable,Fr=(n,t,e)=>t in n?Al(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bl=(n,t)=>{for(var e in t||(t={}))Ol.call(t,e)&&Fr(n,e,t[e]);if(Rr)for(var e of Rr(t))Ll.call(t,e)&&Fr(n,e,t[e]);return n},Rl=(n,t)=>El(n,Il(t));class Xe{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return st(t.toY(this.close))}x(t){return st(t.toX(this.centerUnit))}clone(){return new Xe(this.centerUnit,this.close)}}class Yr extends tt{constructor(t,e,s,r=We(xr)){var i;super(),this.extentComponent=t,this.id=e,this.htId=s,this.name="",this.hovered=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=a=>{var o;return(o=this.config.paintConfig[a])!=null?o:this.config.paintConfig[0]},this.getBaseline=(a=this.dataIdxStart)=>{var o,l;return(l=(o=this.visualPoints[a])==null?void 0:o.close)!=null?l:1},this.getTextForPoint=a=>`${a.close}`,this.getLastVisualSeriesPoint=()=>{const a=this.visualPoints,o=ue(a,this.scale.xEnd,l=>l.centerUnit).index;return a[o]},this.getLastDataSeriesPoint=()=>{const a=this.visualPoints;return Yt(a)},this.config=Kt(r,xr),this.scale=t.scale,this.view=new Br(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new xl(this,this.config,t.getYAxisBounds,(i=t.yAxis)==null?void 0:i.state),this.highLowProvider=Yl(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=qs(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=qs(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.recalculateDataViewportIndexes())),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>this.recalculateVisualPoints()))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new Br(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,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:r}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=r}calculateDataViewportIndexes(t,e){const s=ue(this.visualPoints,t,i=>i.centerUnit).index,r=ue(this.visualPoints,e,i=>i.centerUnit).index;return{dataIdxStart:s,dataIdxEnd:r}}valueFormatter(t){return Nr(t)}getSeriesInViewport(t,e){let s=this.dataIdxStart,r=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const i=this.calculateDataViewportIndexes(t,e);s=i.dataIdxStart,r=i.dataIdxEnd}return Ao(this.visualPoints2D,s,r)}}const Fl=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},Yl=n=>({isHighLowActive:()=>n.config.highLowActive,calculateHighLow:t=>{const e=Fl(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return Rl(Bl({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),Nr=n=>{const e=i=>Math.ceil(Math.log(Math.abs(i))*Math.LOG10E),r=((i,a=5)=>Math.max(0,a-Math.max(0,e(i))))(n);return wt.makeDecimal(n,r)};class ln extends Xe{constructor(t,e,s,r,i,a,o,l,c=!1,h=!1,g=!1){super(t,r),this.startUnit=t-e/2,this.width=e,this.open=s,this.high=i,this.low=a,this.name=o,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=g}bodyHeight(t){return st(Math.abs(t.toY(this.open)-t.toY(this.close)))}candleHeight(t){return st(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=st(t.toY(this.high)),s=st(t.toY(this.low)),r=st(t.toY(this.open)),i=st(t.toY(this.close)),[a,o]=r>i?[i,r]:[r,i],[l,c]=e>s?[s,e]:[e,s];return[l,a,o,c]}yLineEnd(t){return st(Math.max(t.toY(this.high),t.toY(this.low)))}yLineStart(t){return st(Math.min(t.toY(this.high),t.toY(this.low)))}yBodyStart(t){return st(Math.min(t.toY(this.open),t.toY(this.close)))}yBodyEnd(t){return st(Math.max(t.toY(this.open),t.toY(this.close)))}xCenter(t){return this.x(t)}xStart(t){return Tl(t.toX(this.startUnit))}}const Ae=60,Hr=(n,t,e,s,r=Ae)=>{const i=ze(n,s,r);i.volume=e;let a;if(t.length===0)a=0;else if(s>=t.length){const o=t[t.length-1],c=(s-(t.length-1))*e;a=o.centerUnit+c}else{const o=t[0],c=-s*e;a=o.centerUnit-c}return new ln(a,e,i.open,i.close,i.lo,i.hi,rn(i.open,i.close),i)},Nl=(n,t,e,s,r=Ae)=>{const i=Hl(n,s,r);let a;if(t.length===0)a=0;else if(s>=t.length){const o=t[t.length-1],c=(s-(t.length-1))*e;a=o.centerUnit+c}else{const o=t[0],c=-s*e;a=o.centerUnit-c}return new Xe(a,i.close)},ze=(n,t,e=Ae)=>({hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:kr(n,t,e),volume:NaN,expansion:!0,idx:t}),Hl=(n,t,e=Ae)=>({close:NaN,timestamp:kr(n,t,e)});function kr(n,t,e=Ae){var s,r;const i=Ce(t);if(n.length===0)return 0;const a=Yt(n);if(i>=n.length&&a)return jr(a,n.length-1,i,e);const o=ke(n);return i<0&&o?jr(o,0,i,e):(r=(s=n[i])==null?void 0:s.timestamp)!=null?r:0}const jr=(n,t,e,s=Ae)=>n.timestamp+(e-(t!=null?t:0))*s;class kl{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new X,this.dataSetSubject=new X,this.dataRemovedSubject=new X,this.dataPrependSubject=new X,this.meanDataWidth=1,this.period=1}dataFromTimestamp(t,e=!0,s=this.mainDataPoints){const r=Ue(t,e,s,this.period);return this.dataFromIdx(r.index)}recalculatePeriod(){const t=ml(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?Hr(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):Nl(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var jl=Object.defineProperty,Ur=Object.getOwnPropertySymbols,Ul=Object.prototype.hasOwnProperty,Wl=Object.prototype.propertyIsEnumerable,Wr=(n,t,e)=>t in n?jl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Xl=(n,t)=>{for(var e in t||(t={}))Ul.call(t,e)&&Wr(n,e,t[e]);if(Ur)for(var e of Ur(t))Wl.call(t,e)&&Wr(n,e,t[e]);return n};class zl{constructor(t,e){this.canvasModel=t,this.config=e,this.prevState={},this.prevWidth=0,this.prevHeight=0}draw(){if(Ar(this.config.colors.chartAreaTheme,this.prevState)&&this.prevHeight===this.canvasModel.height&&this.prevWidth===this.canvasModel.width)return;this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0,this.canvasModel.width,this.canvasModel.height);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=Xl({},this.config.colors.chartAreaTheme),this.prevWidth=this.canvasModel.width,this.prevHeight=this.canvasModel.height}getCanvasIds(){return[this.canvasModel.canvasId]}}const cn=(n,t,e,s,r,i,a)=>{const o=Pl(),l=[e*o,s*o,r*o,i*o];let c=n.getImageData(...l);if(a!==void 0){const h=c.data[3]/255;if(h===1)for(let g=3;g<c.data.length;g+=4)c.data[g]=gt(c.data[g]*a);else for(let g=0;g<c.data.length;g++){const p=c.data[g];c.data[g]=g%4===3?gt(p*a):gt(h*p)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},Xr=(n,{x:t,width:e,activeCandle:s})=>new ln(t,e,n.open,n.close,n.hi,n.lo,rn(n.open,n.close),n,!0,Qn(n,s)),Vl=(n,{x:t,width:e,activeCandle:s,prevCandle:r})=>{var i;return new ln(t,e,n.open,n.close,n.hi,n.lo,pl((i=r==null?void 0:r.close)!=null?i:n.close,n.close),n,!0,Qn(n,s),n.close>n.open)},zr=(n,{x:t,width:e,activeCandle:s,prevCandle:r})=>{var i;return new ln(t,e,n.open,n.close,n.hi,n.lo,rn((i=r==null?void 0:r.close)!=null?i:n.close,n.close),n,!0,Qn(n,s),n.close>n.open)},Gl=zr,Qn=(n,t)=>{const e=t&&t.idx===n.idx;return e!=null?e:!1},Vr=()=>$n,we=class{static autoDetectIncrementOfValueRange(n){const t=this.getDigitsInNumber(n);return n===0?.01:Math.pow(10,t-3)}static getDigitsInNumber(n){const t=s=>gt(Math.log10((s^s>>31)-(s>>31)))+1;let e=t(n);return e===1&&n<1&&(e=t(n*1e9)-9),e}static getPriceIncrement(n,t=[]){if(!this.validatePriceIncrementsOrPrecisions(t))return this.DEFAULT_INCREMENT;if(isNaN(n))return Math.round(t[0]);n=Math.abs(n);let e=1;const s=1e-6;for(;e<t.length&&n>t[e]+Math.min(t[e-1],t[e+1])*s;)e+=2;return e>=t.length||n<t[e]-Math.min(t[e-1],t[e+1])*s?t[e-1]:Math.min(t[e-1],t[e+1])}static getPricePrecision(n,t){if(!this.validatePriceIncrementsOrPrecisions(t))return 0;if(isNaN(n))return Math.round(t[0]);n=Math.abs(n);let e=1;for(;e<t.length&&n>t[e];)e+=2;return Math.round(t[e-1])}static roundPriceToIncrement(n,t,e){const s=we.getPriceIncrement(e||n,t);return wt.roundToNearest(n,s)}static computePrecisions(n){const t=[...n];for(let e=0;e<n.length;e+=2)t[e]=we.calculatePrecision(n[e]);for(let e=1;e<n.length;e+=2)t[e]=n[e]+Math.min(n[e-1],n[e+1])*we.RELATIVE_EPS;return t}static calculatePrecision(n){let t=n>1?Math.abs(Math.floor(n)-n):n;for(let e=0;e<we.MAXIMUM_PRECISION;e++){const s=Math.floor(t+.5),r=Math.abs(t*we.RELATIVE_EPS);if(s>=t-r&&s<=t+r)return e;t*=10}return we.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(n){return!(n.length===0||!Array.isArray(n)||n.findIndex(t=>t!==0)===-1)}};let qt=we;qt.DEFAULT_INCREMENT=.01,qt.DEFAULT_PRECISION=2,qt.RELATIVE_EPS=1e-8,qt.MAXIMUM_PRECISION=10;const $l=(n,t)=>{var e;const s=(e=Yt(t))!=null?e:1;return Math.pow(10,-s)};var Zl=Object.defineProperty,Kl=Object.defineProperties,Jl=Object.getOwnPropertyDescriptors,Gr=Object.getOwnPropertySymbols,ql=Object.prototype.hasOwnProperty,Ql=Object.prototype.propertyIsEnumerable,$r=(n,t,e)=>t in n?Zl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,tc=(n,t)=>{for(var e in t||(t={}))ql.call(t,e)&&$r(n,e,t[e]);if(Gr)for(var e of Gr(t))Ql.call(t,e)&&$r(n,e,t[e]);return n},ec=(n,t)=>Kl(n,Jl(t));const nc=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:n.scale.xStart,s=t?t.xEnd:n.scale.xEnd,{dataIdxStart:r,dataIdxEnd:i}=n.calculateDataViewportIndexes(e,s),a=n.visualPoints.slice(r,i+1),o=Zr(a),l=()=>{var c,h;return(h=(c=n.visualPoints[r])==null?void 0:c.close)!=null?h:1};return ec(tc({},o),{low:n.view.toAxisUnits(o.low,l),high:n.view.toAxisUnits(o.high,l)})}}),Zr=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},sc=30,rc=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:sc,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY});t.currentAnimation=s};class ic{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){ac(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const ac=(n,t,e,s)=>{const r=e.filter(o=>o.isHighLowActive()).map(o=>o.calculateHighLow(t)),i=Kr(r),a=s.reduce((o,l)=>l(o),i);t.yStart=a.low,t.yEnd=a.high,t.zoomY=n.calculateZoomY(t.yStart,t.yEnd)};function Kr(n){if(n.length===0)return oc();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 oc=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER});var lc=Object.defineProperty,Jr=Object.getOwnPropertySymbols,cc=Object.prototype.hasOwnProperty,hc=Object.prototype.propertyIsEnumerable,qr=(n,t,e)=>t in n?lc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Qr=(n,t)=>{for(var e in t||(t={}))cc.call(t,e)&&qr(n,e,t[e]);if(Jr)for(var e of Jr(t))hc.call(t,e)&&qr(n,e,t[e]);return n};const dc=(n,t,e,s)=>{var r,i,a,o;const l=Qr({},n),c=(i=(r=t[e])==null?void 0:r.startUnit)!=null?i:0,h=(o=(a=Eo(-e,t))==null?void 0:a.startUnit)!=null?o:0;let g=n.xStart,p=n.xEnd;return l.xStart>=h&&(g=h,p=p-(l.xStart-h)),l.xEnd<c&&(g=c-re(s.width,l.zoomX),p=c),l.xStart=g,l.xEnd=p,l},uc=(n,t,e,s)=>{const r=Qr({},t),i=s(),a=r.xEnd-r.xStart,o=a<e.minCandles,l=i.width/e.minWidth,c=a>l;if(i.width>0){if(c)return r.xStart=r.xEnd-l,r.zoomX=on(r.xEnd-r.xStart,i.width),r;if(o)return r.xStart=r.xEnd-e.minCandles,r.zoomX=on(r.xEnd-r.xStart,i.width),r}return r},fc=(n,t)=>n/t,gc=(n,t)=>n/t,vc=(n,t)=>n*t,ti=(n,t)=>{const e=n.zoomY;n.zoomY=gc(n.zoomX,t);const s=n.zoomY/e,r=n.yEnd-n.yStart,a=r*s-r;n.yEnd=n.yEnd+a/2,n.yStart=n.yStart-a/2},mc=(n,t)=>{const e=n.zoomX;n.zoomX=vc(n.zoomY,t);const s=n.zoomX/e,r=n.xEnd-n.xStart,a=r*s-r;n.xStart=n.xStart-a},pc=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},bc=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},ei=(n,t,e,s,r)=>{const i=(t.xEnd-t.xStart)*s,a=i*e,o=i*(1-e);return r?(t.xStart=t.xStart+a,t.xEnd=t.xEnd-o):(t.xStart=t.xStart-a,t.xEnd=t.xEnd+o),t.zoomX=n.calculateZoomX(t.xStart,t.xEnd),t},Cc=(n,t,e,s)=>ei(n,t,1,e,s);var yc=Object.defineProperty,ni=Object.getOwnPropertySymbols,wc=Object.prototype.hasOwnProperty,Sc=Object.prototype.propertyIsEnumerable,si=(n,t,e)=>t in n?yc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hn=(n,t)=>{for(var e in t||(t={}))wc.call(t,e)&&si(n,e,t[e]);if(ni)for(var e of ni(t))Sc.call(t,e)&&si(n,e,t[e]);return n};const xc=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class ri extends Ml{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new X,this.beforeStartAnimationSubject=new X,this.history=[],this.zoomXYRatio=0,this.xConstraints=[],this.scalePostProcessor=(r,i)=>this.xConstraints.reduce((a,o)=>o(r,a),i),this.state=We(t.scale),this.autoScaleModel=new ic(this),this.offsets=this.config.components.offsets,this.addXConstraint((r,i)=>uc(r,i,this.config.components.chart,this.getBounds))}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=hn(hn({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,s=!1,r){const i=this.config.scale.disableAnimations||s;i&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const a=this.export();ei(this,a,t,r,e),this.zoomXTo(a,i)}zoomXToEnd(t,e){this.config.scale.disableAnimations&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const s=this.export();Cc(this,s,e,t),this.zoomXTo(s,this.config.scale.disableAnimations)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.doAutoScale())}zoomXTo(t,e){const s=hn({},t),r=this.scalePostProcessor(s,t);this.state.lockPriceToBarRatio&&ti(r,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.doAutoYScale(r),e?this.apply(r):rc(this.canvasAnimation,this,r)}setXScale(t,e){const s=this.export();super.setXScale(t,e,!1);const r=this.export(),i=this.scalePostProcessor(s,r);this.state.lockPriceToBarRatio&&ti(i,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i)}setYScale(t,e,s=!1){const r=this.export();super.setYScale(t,e,s);const i=this.export(),a=this.scalePostProcessor(r,i);if(this.state.lockPriceToBarRatio){mc(a,this.zoomXYRatio),this.setXScale(a.xStart,a.xEnd);return}else this.state.auto&&this.autoScaleModel.doAutoYScale(a),this.apply(a)}moveXStart(t){const e=this.export(),s=hn({},e);this.haltAnimation(),pc(e,t);const r=this.scalePostProcessor(s,e);this.state.auto&&this.autoScaleModel.doAutoYScale(r),this.apply(r)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();bc(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),_l(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}t&&this.recalculateZoomXYRatio(),this.state.lockPriceToBarRatio=t}recalculateZoomXYRatio(){this.zoomXYRatio=fc(this.zoomX,this.zoomY)}}class Pc extends ri{constructor(t,e,s,r){super(e,s,r),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 Tc=en().colors;class ge extends Yr{constructor(t,e,s,r,i,a,o,l,c=Tc){super(t,e,s),this.eventBus=r,this.candlesTransformersByChartType=o,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=xc(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new X,this.meanCandleWidth=$n,this._instrument=a,this.instrument=a,this.highLowProvider=nc(this),this.scale=i,this.name=a.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=qt.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){super.recalculateDataViewportIndexes(t,e),this.recalculateZippedHighLow(),this.eventBus.fireDraw()}applyPriceMovement(){const t=Yt(this.dataPoints);t&&(this.lastPriceMovement=rn(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=Zr(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd))}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=Kt(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var s,r;if(t.length===0)return[];const i=this.config.type,a=[];let o=e;const l=(s=this.candleWidthByChartType[i])!=null?s:Vr;for(let c=0;c<t.length;c++){const h=t[c],g=t[c-1],p=l(h),b=o+p/2,E=(r=this.candlesTransformersByChartType[i])!=null?r:Xr;a.push(E(h,{x:b,width:p,prevCandle:g,activeCandle:this.activeCandle})),o+=p}return a}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,s)=>e+s.width,0)/t.length:this.meanCandleWidth=$n}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 Fg(n){switch(n){case"line":case"area":return!0;default:return!1}}class Mc{constructor(t){this.config=t}draw(t,e,s,r){if(s instanceof ge){const i=Lt(e);if(i.length===0)return;r.singleColor?t.strokeStyle=r.singleColor:t.strokeStyle=s.colors.areaTheme.lineColor,s.hovered?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const a=s.extentComponent.getBounds(),o=i[0],l=s.view.toX(o.centerUnit);for(let c=0;c<i.length;c++){const h=i[c-1],g=i[c+1],p=i[c],b=s.view.toX(p.centerUnit),E=s.view.toY(p.close),O=a.y+a.height;if(h===void 0)t.beginPath(),t.lineTo(gt(b),O),t.moveTo(gt(b),E);else if(g===void 0){t.lineTo(gt(b),E),t.stroke(),t.lineTo(gt(b),O),t.lineTo(gt(l),O),t.closePath();let N;r.singleColor?t.fillStyle=r.singleColor:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(N=t.createLinearGradient(0,0,0,a.height),N.addColorStop(0,s.colors.areaTheme.startColor),N.addColorStop(1,s.colors.areaTheme.stopColor),N):"",t.fill()}else t.lineTo(gt(b),E)}}}}function ii(n,t,e,s,r,i=4,a=!0,o=!1){n.save(),n.beginPath(),n.moveTo(t+i,e),n.lineTo(t+s-i,e),n.quadraticCurveTo(t+s,e,t+s,e+i),n.lineTo(t+s,e+r-i),n.quadraticCurveTo(t+s,e+r,t+s-i,e+r),n.lineTo(t+i,e+r),n.quadraticCurveTo(t,e+r,t,e+r-i),n.lineTo(t,e+i),n.quadraticCurveTo(t,e,t+i,e),n.closePath(),a&&n.fill(),o&&n.stroke(),n.restore()}function _c(n,t,e,s,r,i,a,o,l,c,h=4,g=!0,p=!1){const b=c==="right"?o:-o,E=c==="right"?h:-h,O=h;n.save(),n.beginPath(),l?n.moveTo(i+E,a):n.moveTo(i,a),l?(n.lineTo(i+b-E,a),n.quadraticCurveTo(i+b,a,i+b,a-O),n.lineTo(i+b,e+O),n.quadraticCurveTo(i+b,e,i+b-E,e),n.lineTo(t+E,e)):(n.lineTo(i+b,a),n.lineTo(i+b,e),n.lineTo(t,e)),l?(n.quadraticCurveTo(t,e,t-E/3,e+O/3),n.lineTo(s+E/3,r-O/3),n.quadraticCurveTo(s,r,s+E/3,r+O/3),n.lineTo(i-E/3,a-O/3),n.quadraticCurveTo(i,a,i+E/3,a)):(n.lineTo(s,r),n.lineTo(i,a)),n.closePath(),g&&n.fill(),p&&n.stroke(),n.restore()}function Dc(n,t,e,s,r,i=1){n.save(),n.lineWidth=i,n.beginPath(),n.moveTo(t,e),n.lineTo(s,r),n.stroke(),n.closePath(),n.restore()}function Se(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function ai(n,t,e){const s=Math.min(t.x,e.x)+.5,r=Math.min(t.y,e.y),i=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);n.fillRect(s,r,i,a)}const Yg=n=>Array.isArray(n[0])?n:[n];class Ac{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,s){const r=t.ctx,i=s&&this.paneManager.panes[s];e&&(r.save(),i&&xe(r,i.getBounds()),this.drawSeries(r,e),r.restore())}drawSeries(t,e){if(e.config.visible){const s=e.config.type,r=this.seriesDrawers[s];if(r){const i=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);i&&i.length>=1&&r.draw(t,i,e,{})}else console.error(`Data series drawer with type ${s} isn't registered!`)}}}const xe=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},Ee=(n,t,e,s,r=t)=>{s.forceBold?n.lineWidth=s.forceBold:e.hovered?n.lineWidth=t!==r?t+1:r:n.lineWidth=t};class Ec{constructor(t){this.config=t}setFillStyle(t,e,s,r){if(e.singleColor)t.strokeStyle=e.singleColor;else{const i=s.colors.barTheme;i&&(t.strokeStyle=i[`${r.name}Color`])}}draw(t,e,s,r){if(s instanceof ge){const i=Lt(e);Ee(t,this.config.barLineWidth,s,r),Se(t,()=>{for(const a of i){this.setFillStyle(t,r,s,a),t.beginPath();const o=st(s.view.toX(a.centerUnit)),l=st(s.view.toX(a.startUnit)),[c,h,g,p]=a.yBodyKeyPoints(s.view),b=st(s.view.xPixels(a.width)/2),E=st(s.view.toY(a.close)),O=st(s.view.toY(a.open));this.config.showWicks?(t.moveTo(o,c),t.lineTo(o,p)):(t.moveTo(o,h),t.lineTo(o,g)),t.moveTo(o,E),t.lineTo(o+b,E),t.moveTo(l,O),t.lineTo(o,O),t.stroke()}})}}}class Ic{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,s,r){if(r!==void 0&&s instanceof ge){const i=Lt(e),a=this.baseLineModel.baselineYPercents,o=this.canvasBoundContainer.getBounds(Y.CHART),l=o.y+o.height*(a/100),c=i[0];for(let h=0;h<i.length;h++){const g=i[h],p=i[h-1],b=i[h+1],E=s.view.toX(c.centerUnit),O=s.view.toX(g.centerUnit),N=s.view.toY(g.close),k=p?s.view.toY(p.close)<l:!1,V=N<l;if(p!==void 0&&k!==V){oi(t,s,r,k);const Z=s.view.toX(p.centerUnit),J=s.view.toY(p.close),K=O-Z,U=N-J,q=K/U,at=N-l,ot=q*at,nt=Z+(K-ot);t.lineTo(nt,l),t.stroke(),t.lineTo(E,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(nt,l)}p===void 0?(t.beginPath(),t.moveTo(O,N)):b===void 0?(oi(t,s,r,V),t.lineTo(O,N),t.stroke(),t.lineTo(O,l),t.lineTo(E,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(E,l),t.lineTo(O,l),t.strokeStyle=s.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(O,N)}}}}const oi=(n,t,e,s)=>{e.singleColor?(n.fillStyle=e.singleColor,n.strokeStyle=e.singleColor):(n.fillStyle=s?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,n.strokeStyle=s?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class Oc{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,s,r){if(s instanceof ge){const i=Lt(e);Ee(t,this.config.candleLineWidth,s,r,this.config.candleLineWidth),Se(t,()=>{this.pixelLength=1/Jt,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const a of i){const{candleTheme:o,activeCandleTheme:l}=s.colors;o&&l&&this.drawCandle(t,r,s,a)}})}}drawCandle(t,e,s,r){const{candleTheme:i,activeCandleTheme:a}=s.colors,o=r.name,l=r.isActive?a:i,c=r.isHollow;e.singleColor?t.fillStyle=e.singleColor:c?t.fillStyle=l[`${o}WickColor`]:t.fillStyle=l[`${o}Color`];const h=st(s.view.toX(r.startUnit)),g=st(s.view.xPixels(r.width)),p=r.bodyHeight(s.view),[b,E,O,N]=r.yBodyKeyPoints(s.view),k=E===O?E+1:O,V=b===N?b+1:N,Z=l[`${o}Color`],J=o==="none"?Z:l[`${o}WickColor`];t.fillStyle=Z,e.singleColor?t.strokeStyle=e.singleColor:t.strokeStyle=J;const K=c||(r.hasBorder&&r.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),U=this.config.showWicks;if(g<2)t.beginPath(),t.moveTo(h,U?b:E),t.lineTo(h,U?V:k),t.stroke();else if(g<3)t.beginPath(),t.moveTo(h,U?b:E),t.lineTo(h,U?V:k),t.moveTo(h+1,E),t.lineTo(h+1,k),t.stroke();else if(g===3){const q=g/Jt;this.drawCandlesWicks(t,h+q,b,V,E,k),c||(t.beginPath(),t.moveTo(h+q,E),t.lineTo(h+q,k),t.stroke()),this.drawCandleBorder(t,e,l,r,h+this.halfLineWidthCU,E+this.halfLineWidthCU,g-this.lineWidthCU,p-this.lineWidthCU)}else{const q=r.x(s.view);this.drawCandlesWicks(t,q,b,V,E,k-1);const at=this.config.candlePaddingPercent,ot=Math.max(st(g*at/2),this.pixelLength),nt=h+ot,rt=g-ot*2;c||(e.singleColor&&(t.fillStyle=e.singleColor),t.fillRect(nt,E,rt,p)),K&&this.drawCandleBorder(t,e,l,r,nt+this.halfLineWidthCU,E+this.halfLineWidthCU,rt-this.lineWidthCU,p-this.lineWidthCU)}}drawCandlesWicks(t,e,s,r,i,a){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,i),t.moveTo(e,a),t.lineTo(e,r),t.stroke())}drawCandleBorder(t,e,s,r,i,a,o,l){if(e.singleColor)t.strokeStyle=e.singleColor;else{const c=r.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(i,a,o,l)}}class Lc{constructor(t){this.config=t}draw(t,e,s,r){if(s instanceof ge){const i=e.flat(),a=s.scale.getBounds(),o=a.y+a.height;for(const l of i){t.beginPath();const c=l.name,h=this.config.barCapSize,g=s.colors.histogram;if(g===void 0)return;r.singleColor?t.fillStyle=r.singleColor:t.fillStyle=g[`${c}Bright`];const p=l.xStart(s.view),b=st(s.view.toY(l.close)),E=st(s.view.xPixels(l.width));t.fillRect(p,b,E,h);const O=t.createLinearGradient(0,b+h,0,o);r.singleColor?t.fillStyle=r.singleColor:(O.addColorStop(0,g[`${c}Cap`]),O.addColorStop(1,g[`${c}Bottom`]),t.fillStyle=O),E===0?(t.beginPath(),t.strokeStyle=O,t.moveTo(p,b+h),t.lineTo(p,o),t.stroke(),t.closePath()):t.fillRect(p,b+h,E,o-b-h)}}}}class Bc{constructor(t){this.config=t}draw(t,e,s,r){if(s instanceof ge){const i=Lt(e);Ee(t,this.config.lineWidth,s,r,this.config.selectedWidth);const a=s.colors.lineTheme;t.lineCap="round",r.singleColor&&(t.strokeStyle=r.singleColor);for(let o=1;o<i.length;o++){const l=i[o-1],c=i[o],h=c.name;r.singleColor||(t.strokeStyle=a[`${h}Color`]);const g=s.view.toX(l.centerUnit),p=s.view.toY(l.close),b=s.view.toX(c.centerUnit),E=s.view.toY(c.close);t.beginPath(),t.moveTo(g,p),t.lineTo(b,E),t.stroke()}}}}const Rc=1.5;class Fc{constructor(t){this.config=t}draw(t,e,s,r){var i;t.fillStyle=(i=r.singleColor)!=null?i:this.config.mainColor;for(const a of Lt(e)){t.beginPath();const o=st(s.view.toX(a.centerUnit)),l=st(s.view.toY(a.close));t.arc(o,l,Rc,0,Math.PI*2,!0),t.fill()}}}const Yc=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class Nc{constructor(t,e,s){this.drawer=t,this.config=e,this.chartBounds=s}draw(t,e,s,r){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,s,r),this.afterDraw(t,s))}beforeDraw(t){t.restore(),t.save(),xe(t,this.chartBounds())}isChartTypeAllowed(){return Yc.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),xe(t,e.scale.getBounds())}}class Hc{constructor(t){this.chartModel=t}draw(t,e,s,r){e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a);t.fillStyle=(o=r.singleColor)!=null?o:l.color,i.forEach(c=>{const h=this.chartModel.getVisualCandle(Ce(c.centerUnit)),g=c.close;if(h&&g===1){const p=this.chartModel.scale.zoomX,b=st(Mt(h.width,p)),E=st(h.bodyHeight(this.chartModel.scale)),O=h.xCenter(this.chartModel.scale)-b/2,N=h.yBodyStart(this.chartModel.scale),k=this.chartModel.config.components.chart.candlePaddingPercent,V=st(b*k/2),Z=O+V,J=b-V*2;t.fillRect(Z,N,J,E)}})})}}const li=(n,t,e)=>{n.length!==0&&n.forEach((s,r)=>{const{centerUnit:i,close:a}=s,o=e.toX(i),l=e.toY(a);r===0?t.moveTo(o,l):t.lineTo(o,l)})},kc=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,jc=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i;function Uc(n){const t=kc.exec(n)||jc.exec(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const ci={};function Wc(n,t){let e=ci[n+t];if(!e){const s=Uc(n);e=s&&"rgba("+s.join(",")+","+t+")",ci[n+t]=e}return e}class Xc{constructor(){}draw(t,e,s,r){s.config.visible&&(e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a);Ee(t,l.lineWidth,s,r,l.hoveredLineWidth);const c=(o=r.singleColor)!=null?o:l.color;t.strokeStyle=c,this.drawLine(t,i,s.view)}),s.linkedDataSeriesModels.forEach((i,a)=>{if(di(i.config.type)&&di(s.config.type)&&i.config.visible){const o=[],l=s,c=l.getSeriesInViewport(l.scale.xStart-1,l.scale.xEnd+1),h=i.getSeriesInViewport(i.scale.xStart-1,i.scale.xEnd+1);c.forEach((g,p)=>{const b=Math.min(g.length,h[p].length);for(let N=0;N<b;N++){const k=[g[N].clone(),h[p][N].clone()];o.push({diffPoints:k})}const E=l.getPaintConfig(p).color,O=i.getPaintConfig(a).color;this.drawDifference(t,E,O,o,l,i,r)})}}))}drawLine(t,e,s){t.beginPath(),li(e,t,s),t.stroke()}drawDifference(t,e,s,r,i,a,o){const[l,c]=[[],[]];r.forEach(p=>{const[b,E]=p.diffPoints;l.push(b),c.push(E)});const h=hi(l,i.view),g=hi(c,a.view);this.fillCloud(t,s,h,g,o),this.fillCloud(t,e,g,h,o)}fillCloud(t,e,s,r,i){var a,o,l,c;t.save(),t.beginPath();const h=(o=(a=ke(s))==null?void 0:a.x)!=null?o:0,g=(c=(l=Yt(s))==null?void 0:l.x)!=null?c:0;t.lineTo(h,0),s.forEach(p=>{t.lineTo(p.x,p.y)}),t.lineTo(g,0),t.closePath(),t.clip(),t.beginPath(),s.forEach((p,b)=>{b===0?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y)}),r.slice().reverse().forEach(p=>{t.lineTo(p.x,p.y)}),t.closePath(),t.fillStyle=i.singleColor?i.singleColor:Wc(e||"#383838",.3),t.fill(),t.restore()}}const hi=(n,t)=>n.map(e=>{const{centerUnit:s,close:r}=e,i=t.toX(s),a=t.toY(r);return{x:i,y:a}}),di=n=>n==="DIFFERENCE";class zc{constructor(){}draw(t,e,s,r){const i=s.view.toY(0);e.forEach((a,o)=>{var l;const c=s.getPaintConfig(o);Ee(t,c.lineWidth,s,r,c.hoveredLineWidth),t.strokeStyle=(l=r.singleColor)!=null?l:c.color,t.beginPath(),a.forEach(h=>{const g=s.view.toX(h.centerUnit),p=s.view.toY(h.close);t.moveTo(g,gt(i)),t.lineTo(g,gt(p))}),t.stroke()})}}class Vc{constructor(){}draw(t,e,s,r){e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a);Ee(t,l.lineWidth,s,r,l.hoveredLineWidth),t.strokeStyle=(o=r.singleColor)!=null?o:l.color,this.drawLinePath(t,i,s.view)})}drawLinePath(t,e,s){t.beginPath(),li(e,t,s),t.stroke()}}class Gc{constructor(){}draw(t,e,s,r){e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a),c=l.lineWidth;t.fillStyle=(o=r.singleColor)!=null?o:l.color,t.lineWidth=1,i.forEach(h=>{t.beginPath();const g=s.view.toX(h.centerUnit),p=s.view.toY(h.close);t.arc(g,p,c,0,Math.PI*2),t.fill()})})}}class $c{constructor(t){this.config=t}draw(t,e,s,r){t.save(),e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a);t.fillStyle=(o=r.singleColor)!=null?o:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,i.forEach(h=>{const g=s.getTextForPoint(h),p=Nt(g,t,c),b=ne(c,t),E=s.view.toX(h.centerUnit)-p/2,O=s.view.toY(h.close)+b;t.fillText(g,E,O)})}),t.restore()}}class Zc{constructor(){}draw(t,e,s,r){e.forEach((i,a)=>{var o;const l=s.getPaintConfig(a);t.fillStyle=(o=r.singleColor)!=null?o:l.color,i.forEach(c=>{const h=s.view.toX(c.centerUnit),g=s.view.toY(c.close);this.drawCandleTriangle(t,h,g,l.lineWidth)})})}drawCandleTriangle(t,e,s,r){t.beginPath(),t.moveTo(e-r/2,s),t.lineTo(e,s-r),t.lineTo(e+r/2,s),t.fill()}}const ts="resized_local",dn="draw",Ng="draw_last_candle",Ie={width:20,height:20};class ui{constructor(t,e,s,r,i,a={}){this.eventBus=t,this.canvas=e,this.drawingManager=s,this.resizer=i,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.type=es;var o;r.push(this),this.parent=qc(e);const l=e.getContext("2d",a);if(l===null)throw new Error("Couldn't get 2d context????");this.context=l,this._canvasId=(o=e.getAttribute("data-element"))!=null?o:"",this.updateCanvasWidthHeight(e,this.getChartResizerElement().getBoundingClientRect())}updateDPR(t){const{width:e,height:s}=t,r=window.devicePixelRatio;this.canvas.style.height=s+"px",this.canvas.style.width=e+"px",this.canvas.width=e*r,this.canvas.height=s*r,this.width=e,this.height=s,this.ctx.scale(r,r)}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>Ie.width&&this.height>Ie.height}}const es={name:"candle"},Kc={candle:es,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function Jc(n,t,e,s,r,i,a){var o;const l=Oe(n,t,r,i,a,e);return l.type=(o=Kc[s])!=null?o:es,l}function Oe(n,t,e,s,r,i,a){const o=new ui(n,t,s,r,i,a);return fi(o,e),o}function fi(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 qc(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}let ns=!1,ss=0;const un=new Map,rs=new Map,gi=()=>{ns||(ns=!0,ss=requestAnimationFrame(()=>{rs.forEach((n,t)=>{n(),rs.delete(t)}),un.forEach((n,t)=>{n(),un.delete(t)}),ns=!1}))},vi=(n,t)=>{un.set(n,t),gi()},Ug=n=>{un.delete(n)},is=(n,t)=>{rs.set(n,t),gi()},fn="HIT_TEST_",Wg=null;class Qc{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${Ft()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(fn)!==-1&&this.drawersMap[s].draw()})},t.on(dn,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),vi(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(fn)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(fn)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}Mo(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,r;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>Ie.width&&((r=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?r:0)>Ie.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=Ft()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,s){this.addDrawer(t,e);const r=this.drawingOrder.indexOf(e);this.drawingOrder.splice(r,1);const i=this.drawingOrder.indexOf(s);this.drawingOrder.splice(i+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,s){this.addDrawer(t,e);const r=this.drawingOrder.indexOf(s);if(r!==-1){const i=this.drawingOrder.indexOf(e);return this.drawingOrder.splice(i,1),this.drawingOrder.splice(r,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=Ks(this.drawingOrder,t)}}class mi{static paneResizer(t){return`PANE_RESIZER_${t}`}}class th{constructor(t,e,s){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=s}draw(){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),xe(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,r=this.seriesDrawers[s];if(r){const i={singleColor:this.canvasModel.idToColor(e.htId),forceBold:7};r.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,i)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const pi={disableChartPanning:!0};class bi extends tt{constructor(t,e,s,r,i){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=r,this.dragComponentOptions=i,this.dragging=!1,this.draggedPixels=0,this.onDragStart=a=>{this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(a),this.dragComponentOptions.disableChartPanning&&this.chartPanComponent.deactivatePanHandlers()},this.onDragTick=a=>{this.dragging&&(this.draggedPixels+=a,this.dragCallbacks.onDragTick({delta:a,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels),this.dragComponentOptions.disableChartPanning&&this.chartPanComponent.activateChartPanHandlers())}}doActivate(){super.doActivate()}doDeactivate(){super.doDeactivate()}}class gn extends bi{constructor(t,e,s,r,i=pi){super(t,e,s,r,i)}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))}doDeactivate(){super.doDeactivate()}}const eh="BASELINE_RESIZER";class nh extends tt{constructor(t,e,s,r,i,a,o){super(),this.chartModel=t,this.canvasModel=s,this.canvasInputListener=r,this.config=i,this.canvasBoundContainer=a,this.cursorHandler=o,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.baselineYPercents=50,this.ht=Vn.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragTickCb=c=>{const{delta:h}=c,g=this.canvasBoundContainer.getBounds(Y.CHART),p=this.canvasInputListener.getCurrentPoint().y;h!==0&&sl(p,g)&&(this.moveBaseLine(p),this.canvasModel.fireDraw())};const l=new gn(this.ht,{onDragTick:this.dragTickCb},r,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(Y.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(Y.CHART),e=this.canvasBoundContainer.getBounds(Y.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[eh]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(Y.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const vn=n=>{var t;const e=Ne(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Ne(n.hi,Math.max(n.open,n.close),e),r=Ne(n.lo,Math.min(n.open,n.close),e),i=Ne(n.open,n.lo,e),a=Ne(n.close,n.hi,e);return{hi:s,lo:r,open:i,close:a,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility}},as=n=>{for(let t=0;t<n.length;++t)n[t].idx=t},Ci=n=>{n.forEach(t=>{t.idx=void 0})};class sh{constructor(){}draw(t,e,s){const r=s.view.toY(0),i=Lt(e),a=[[],[]];i.forEach((o,l,c)=>{a[o.close<this.previousValue(c,l)?1:0].push(o)}),a.forEach((o,l)=>{const c=s.getPaintConfig(l);t.strokeStyle=l===0?c.color:c.aditionalColor||"#FF00FF",t.lineWidth=c.lineWidth,t.beginPath(),o.forEach(h=>{const g=s.view.toX(h.centerUnit),p=s.view.toY(h.close);t.moveTo(g,gt(r)),t.lineTo(g,gt(p))}),t.stroke()})}previousValue(t,e){do e--;while(e>=0&&!isFinite(t[e]&&t[e].close));return t[e]?t[e].close:Number.NaN}}var rh=Object.defineProperty,yi=Object.getOwnPropertySymbols,ih=Object.prototype.hasOwnProperty,ah=Object.prototype.propertyIsEnumerable,wi=(n,t,e)=>t in n?rh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,oh=(n,t)=>{for(var e in t||(t={}))ih.call(t,e)&&wi(n,e,t[e]);if(yi)for(var e of yi(t))ah.call(t,e)&&wi(n,e,t[e]);return n};class lh{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class ch extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p,b){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=r,this.canvasBoundsContainer=i,this.drawingManager=a,this.hitTestCanvasModel=o,this.canvasInputListener=l,this.paneManager=g,this.dynamicObjects=b,this._dataSeriesDrawers={},this.strToBarType=O=>{var N;return(N=this.barTypeValues.find(k=>k===O))!=null?N:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new nh(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,p),this.addChildEntity(this.baselineModel);const E=new th(this._dataSeriesDrawers,this.hitTestCanvasModel,g);this.drawingManager.addDrawerBefore(E,fn+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new zl(c,this.config),a.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),p.setCursorForCanvasEl(Y.PANE_UUID(ht),s.components.chart.cursor),this.dataSeriesDrawer=new Ac(g,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,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",Xr),this.registerCandlesTransformer("trend",zr),this.registerCandlesTransformer("hollow",Vl),this.registerCandlesTransformer("line",Gl)}get barTypeValues(){return Dr(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 Oc(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new Ec(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new Bc(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new Fc(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new Mc(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new Ic(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new Lc(this.config.components.chart.histogram));const e=()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID(ht));this.registerDataSeriesTypeDrawer("LINEAR",new Vc),this.registerDataSeriesTypeDrawer("HISTOGRAM",new zc),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new sh),this.registerDataSeriesTypeDrawer("POINTS",new Gc),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new Nc(new Hc(this.chartModel),this.config,e)),this.registerDataSeriesTypeDrawer("TEXT",new $c(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new Zc),this.registerDataSeriesTypeDrawer("DIFFERENCE",new Xc)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(oh({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e){return this.chartModel.setTimestampRange(t,e)}setXScale(t,e){return this.scale.setXScale(t,e)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.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(r=>{var i;const a=(i=r.instrument)!=null?i:this.chartModel.mainCandleSeries.instrument,o=r.dataPoints;return Ci(o),{candles:o,instrument:a}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,r=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),r)return r}setAllSeries(t,e=[]){var s;const r=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(r),e.forEach(i=>{var a;const o=(a=i.instrument)!=null?a:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(o)}),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)}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||!qt.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[qt.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}}class hh extends ge{constructor(t,e,s,r,i,a,o,l,c,h){super(e,s,r,i,a,o,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}}const dh=n=>t=>{if(t.length!==0){const e=t.slice(Math.max(t.length-n.state.defaultViewportItems,0)),s=e[0],r=e[e.length-1];n.setXScale(s.startUnit,r.startUnit+r.width+n.offsets.right),n.doAutoScale(!0),n.recalculateZoomXYRatio(),n.fireChanged()}},uh=(n,t)=>(e,s=null)=>{const[r,i]=e,a=t.candleFromTimestamp(r).startUnit,o=t.candleFromTimestamp(i).startUnit,l=s===null?0:t.mainCandleSeries.meanCandleWidth*2,c=s?a-l:a+l,h=s?o+l:o-l;n.setXScale(c,h)};var fh=Object.defineProperty,gh=Object.defineProperties,vh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,mh=Object.prototype.hasOwnProperty,ph=Object.prototype.propertyIsEnumerable,xi=(n,t,e)=>t in n?fh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ve=(n,t)=>{for(var e in t||(t={}))mh.call(t,e)&&xi(n,e,t[e]);if(Si)for(var e of Si(t))ph.call(t,e)&&xi(n,e,t[e]);return n},os=(n,t)=>gh(n,vh(t));class bh{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)=>os(Ve({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,r)=>(e[`color${r}`]=os(Ve({},We(this.config.colors)),{lineTheme:Ve({},s.lineTheme),areaTheme:Ve({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[r,i]of Object.entries(this.usedChartColors))i<e&&(e=i,s=r);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,r;const i=this.secondaryChartColorsPool[this.usedChartColors[t]];if(i){const a=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=os(Ve({},e),{lineTheme:Object.assign(i.lineTheme,(s=a.lineTheme)!=null?s:{}),areaTheme:Object.assign(i.areaTheme,(r=a.areaTheme)!=null?r:{})})}}}var Ch=Object.defineProperty,Pi=Object.getOwnPropertySymbols,yh=Object.prototype.hasOwnProperty,wh=Object.prototype.propertyIsEnumerable,Ti=(n,t,e)=>t in n?Ch(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mn=(n,t)=>{for(var e in t||(t={}))yh.call(t,e)&&Ti(n,e,t[e]);if(Pi)for(var e of Pi(t))wh.call(t,e)&&Ti(n,e,t[e]);return n};class Sh extends tt{constructor(t,e,s,r,i,a,o,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=r,this.config=i,this.scale=a,this.formatterFactory=o,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.nextCandleTimeStampSubject=new X,this.chartTypeChanged=new X,this.mainInstrumentChangedSubject=new X,this.scaleInversedSubject=new X,this.offsetsChanged=new X,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=p=>this.mainCandleSeries.view.toY(p),this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new bh(this.config);const g=new hh(this.chartBaseModel,this.paneManager.panes[ht].mainExtent,Ft(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new lh,this.candlesTransformersByChartType,this.candleWidthByChartType,mn({},this.config.colors));g.config.type=this.config.components.chart.type,this.candleSeries.push(g),a.addXConstraint((p,b)=>dc(b,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,a.getBounds())),this.basicScaleViewportTransformer=dh(a),this.timeFrameViewportTransformer=uh(a,this),this.pane=this.paneManager.panes[ht]}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(Y.PANE_UUID(ht)).pipe(Zt(Cr)).subscribe(t=>{this.handleChartResize(t)}))}handleChartResize(t){if(t.width>Ie.width&&t.height>Ie.height){const e=this.getEffectiveChartWidth(),s=this.getEffectiveYAxisWidth();if(this.prevChartWidth===0){this.scale.isViewportValid()?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const i=re(s-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-i)}else this.scale.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=e;return}const r=re(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-r,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 r=s.dataPoints;return Ci(r),{candles:r,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const r=pn(t.map(vn)),i=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,r),a=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,i),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=a,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 r=pn(t.candles.map(vn));this.mainCandleSeries.clearData(),as(r),this.mainCandleSeries.dataPoints=r,this.secondaryCandleSeries.filter(i=>e.filter(a=>{var o;return((o=a.instrument)==null?void 0:o.symbol)===i.instrument.symbol}).length===0).forEach(i=>this.removeSecondaryCandleSeries(i)),e.map(i=>this.setSecondaryCandleSeries(i.candles,i.instrument,!1)),this.candleSeries.forEach(i=>{i.recalculateDataViewportIndexes(),i.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),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=mn({},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 r=pn(t.candles.map(vn)),i=_i(this.mainCandleSeries.dataPoints,r),a=i.candles;as(a),this.mainCandleSeries.dataPoints=a,e.map(l=>{var c,h,g,p;const b=pn(l.candles.map(vn)),E=_i((p=(g=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:g.dataPoints)!=null?p:[],b).candles;return this.setSecondaryCandleSeries(E,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints(),l.recalculateDataViewportIndexes()});const o=this.chartBaseModel.mainVisualPoints.slice(0,i.prepended.length).reduce((l,c)=>l+c.width,0);this.scale.moveXStart(this.scale.xStart+o),this.candlesPrependSubject.next({prependedCandlesWidth:o,prependedCandles:i.prepended}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(t){Object.values(this.paneManager.panes).forEach(e=>{e.dataSeries.forEach(s=>{const r=ue(s.dataPoints,t,a=>a.timestamp),i=r.exact?r.index:r.index+1;s.dataPoints=s.dataPoints.slice(0,i)})}),this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}createSecondaryCandleSeriesModel(t){const e=mn(mn({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new ge(this.paneManager.panes[ht].mainExtent,Ft(),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[ht].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(r=>{var i;const a=(i=r.idx)!=null?i:0,o=e[a];if(o)s.push(o);else{let l=Mi(e,a,-1);if(l||(l=Mi(e,a,1)),l){const c=bl(l,a,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const r=Kt(t,en().colors);this.secondaryChartColors.updateColorConfig(e,r);const i=this.findSecondarySeriesBySymbol(e);i&&(i.config.type=s,i.updateCandleSeriesColors(r)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}getEffectiveYAxisWidth(){return this.canvasBoundsContainer.getBounds(Y.PANE_UUID_Y_AXIS(ht)).width}getEffectiveChartWidth(){return this.canvasBoundsContainer.getBounds(Y.PANE_UUID(ht)).width}getEffectiveChartHeight(){return this.canvasBoundsContainer.getBounds(Y.PANE_UUID(ht)).height}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 r=this.scale.fromX(t);return this.candleFromUnit(r,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var r,i;const a=ue(s.visualPoints,t,g=>g.startUnit),o=s.visualPoints,l=this.getLastVisualCandle();o[a.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(a.index+=Ce((t-o[a.index].centerUnit)/this.mainCandleSeries.meanCandleWidth));const c=a.index,h=Math.max(Math.min(o.length-1,c),0);return(c<0||c>=o.length)&&e?ze(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(i=(r=o[h])==null?void 0:r.candle)!=null?i:ze(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e=!0,s=this.mainCandleSeries){const r=s.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,r)}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,r;const i=t-((r=(s=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:s.idx)!=null?r:0);return this.mainCandleSeries.visualPoints[i]}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){const s=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),i=r.startUnit+r.width;return this.scale.setXScale(s,i)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return Yt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return Yt(t)}getMaxCandlesFitLength(){return gt(this.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,r)=>{const i=r.timestamp,a=Ue(i,!1,t,this.chartBaseModel.period);return a.index>=0&&a.index<t.length&&(r.idx=a.index,s[a.index]=r),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,r=this.findSeriesBySymbol(e);if(r.length===0){console.warn("updateCandles failed. Can't find series",e);return}r.forEach(i=>{const a=i.dataPoints;let o=!1,l=!1,c;t.forEach(h=>{var g;if(!h)return;const p=Ue(h.timestamp,!0,a,this.getPeriod()),b=Math.min(p.index,a.length);o=o||b===a.length,a[b]=h,h.idx=b,i.dataPoints=a,i.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(b);const E=b>=a.length-1,O=c&&h.timestamp<c.timestamp;if(E&&!O&&(c=h),o&&c&&s&&l){const N=(g=this.candleWidthByChartType[this.config.components.chart.type])!=null?g:Vr;this.scale.moveXStart(this.scale.xStart+N(c))}}),c&&(i.updateCurrentPrice(c.close),this.paneManager.yExtents.forEach(h=>h.yAxis.updateOrderedLabels(!0))),l&&c&&t.length===1?this.canvasModel.fireDraw():i.recalculateVisualPoints()}),this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return Ot(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=0,e){let s=this.getCandles().slice();const r=this.getCandlesCount(),i=e!=null?e:r+this.FAKE_CANDLES_DEFAULT;s=s.slice(Math.max(0,t),Math.min(r,i));const a=[],o=[];for(let c=r;c<i;c++)a.push(ze(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,i);for(let c=t;c<l;c++)o.push(ze(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...o,...s,...a]}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(),r=[];return e.forEach(i=>{const o=Ue(i.timestamp,!1,t).index;o<0?r.push(i):t[o].timestamp===i.timestamp?s[o]=i:console.warn(`Couldn't update candle with timestamp ${i.timestamp}`)}),{prepended:r,candles:[...r,...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){const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(r=>{r.dataPoints=r.dataPoints.slice(0,t).concat(r.dataPoints.slice(t+1)),as(r.dataPoints),r.recalculateVisualPoints()}),this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const pn=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Mi=(n,t,e)=>{if(t>=n.length)return n[n.length-1];for(let s=t;s<n.length&&s>=0;s+=e){const r=n[s];if(r)return r}},_i=(n,t)=>{const e=n.slice(),s=[],r=[];return t.forEach(i=>{const o=Ue(i.timestamp,!0,n).index;o<0?s.push(i):o>=n.length?r.push(i):n[o].timestamp===i.timestamp?e[o]=i:console.warn(`Couldn't update candle with timestamp ${i.timestamp}`)}),{prepended:s,appended:r,candles:[...s,...e,...r]}};class Ge{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class ls{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=_r(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=_r(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=Lt(Array.from(this.drawers).map(([,s])=>s.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class xh{constructor(t,e,s){this.model=t,this.crossToolCanvasModel=e,this.crossToolTypeDrawers=s}draw(){const t=this.crossToolTypeDrawers[this.model.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.model.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}class Ph extends tt{constructor(t,e,s,r){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=r,this.currentHoverSubject=new $t(null),this.type="cross-and-labels",this.type=t.type}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.type=t}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?this.updateHover(t):this.currentHover=null,this.fireDraw()}))}fireDraw(){this.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateHover(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===ht)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)}}const zt=4;function Th(n,t,e,s,r,i,a,o=!1){var l,c,h,g,p,b,E;const O=i.align,N=(l=r.textFont)!=null?l:ye(i),k=r.bgColor,V=(c=r.textColor)!=null?c:fe(k,a.labelTextColor,a.labelInvertedTextColor),Z=(h=r.paddingTop)!=null?h:zt,J=(g=r.paddingBottom)!=null?g:zt,K=(p=r.paddingEnd)!=null?p:zt,U=Ce(ne(N,n)/2),q=s-U-Z,ot=s+U+J-q;if((s<t.y+ot/2||s>t.y+t.height-ot/2)&&!o)return;n.save(),n.fillStyle=k,n.strokeStyle=k;const nt=Ce(t.width/6),rt=O==="right"?t.x:t.x+t.width,dt=O==="right"?rt+nt:rt-nt,ct=i.labelBoxMargin.end,St=ct-K,ut=t.width-nt-St;_c(n,dt,q,rt,q+Ce(ot/2),dt,q+ot,ut,(E=(b=i.typeConfig.badge)==null?void 0:b.rounded)!=null?E:!1,O),n.fillStyle=V,n.font=N;const vt=O==="right"?t.x+t.width-Nt(e,n,N)-ct:t.x+ct;n.fillText(e,vt,s+U-1),n.restore()}function Mh(n,t,e,s,r,i,a,o=!1){var l,c,h,g,p,b,E,O,N,k,V;const Z=i.align,J=(l=r.textFont)!=null?l:ye(i),K=r.bgColor,U=(c=r.textColor)!=null?c:fe(K,a.labelTextColor,a.labelInvertedTextColor),q=(h=i.typeConfig.rectangle)==null?void 0:h.paddings,at=(p=(g=r.paddingTop)!=null?g:q==null?void 0:q.top)!=null?p:zt,ot=(E=(b=r.paddingBottom)!=null?b:q==null?void 0:q.bottom)!=null?E:zt,nt=(N=(O=r.paddingEnd)!=null?O:q==null?void 0:q.end)!=null?N:zt,rt=r.paddingStart,dt=ne(J,n),ct=s-dt/2-at,ut=s+dt/2+ot-ct,vt=(V=r.rounded)!=null?V:(k=i.typeConfig.rectangle)==null?void 0:k.rounded;if((s<t.y+ut/2||s>t.y+t.height-ut/2)&&!o)return;n.save(),n.fillStyle=K,n.strokeStyle=K;const pt=i.labelBoxMargin.end;n.font=J;const Ht=Nt(e,n,J),kt=pt-nt,jt=rt!==void 0?Ht+rt+nt:t.width-kt,pe=Z==="right"?t.x+t.width-kt-jt:t.x+kt,Mn=Z==="right"?t.x+t.width-Ht-pt:pt;vt?ii(n,pe,ct,jt,ut,4,!0):n.fillRect(pe,ct,jt,ut),n.fillStyle=U,n.fillText(e,Mn,s+dt/2-1),n.restore()}function _h(n,t,e,s,r,i,a,o=!1,l){var c,h,g,p,b,E,O,N,k;const V=i.align,Z=(c=r.textFont)!=null?c:ye(i),J=r.bgColor,K=(h=r.textColor)!=null?h:fe(J,a.labelTextColor,a.labelInvertedTextColor),U=(g=i.typeConfig.rectangle)==null?void 0:g.paddings,q=(b=(p=r.paddingTop)!=null?p:U==null?void 0:U.top)!=null?b:zt,at=(O=(E=r.paddingBottom)!=null?E:U==null?void 0:U.bottom)!=null?O:zt,ot=(k=(N=r.paddingEnd)!=null?N:U==null?void 0:U.end)!=null?k:zt,nt=r.paddingStart,rt=ne(Z,n),dt=s-rt/2-q,St=s+rt/2+at-dt;if((s<t.y+St/2||s>t.y+t.height-St/2)&&!o)return;n.save(),n.fillStyle=J,n.strokeStyle=J;const ut=i.labelBoxMargin.end;n.font=Z;const vt=Nt(e,n,Z),pt=ut-ot,Ht=nt!==void 0?vt+nt+ot:t.width-pt,kt=V==="right"?t.x+t.width-pt-Ht:t.x+pt,jt=V==="right"?t.x+t.width-vt-ut:ut;l&&cn(l,n,kt,dt,Ht,St),n.fillStyle=K,n.fillText(e,jt,s+rt/2-1),n.restore()}function Dh(n,t,e=zt){return ne(n,t)/2+e}const Ah="badge",Di=4,Ai={badge:Th,rectangle:Mh,plain:_h};function Ei(n,t,e,s,r,i,a,o){var l,c,h,g,p;const b=r.y,E=r.labelText,O=(l=r.mode)!=null?l:"label",N=(c=r.labelType)!=null?c:Ah,k=r.description,V=(h=r.textFont)!=null?h:ye(a),Z=r.bgColor,J=(g=r.lineColor)!=null?g:Z,K=Nt(k!=null?k:"",n,V)+8,U=gt(r.y),q=ne(V,n),at=b-q/2,nt=b+q/2-at;n.save(),n.fillStyle=Z,n.strokeStyle=J;const rt=i.getBounds(Y.PANE_UUID(ht)),dt=Ai[N],ct=a.labels.descriptions,St=Eh(e,U,nt),ut=()=>ct&&Ih(t,n,e,s,r,a.align,a);let vt,pt;const Ht=2;a.align==="right"?(vt=rt.x,pt=ct?rt.x+rt.width-K:rt.x+rt.width+Ht):(vt=ct?rt.x+K:rt.x-Ht,pt=rt.x+rt.width);const kt=(p=r.lineY)!=null?p:r.y,jt=()=>St&&Se(n,()=>Dc(n,vt,kt,pt,kt,1)),pe=()=>dt(n,e,E,b,r,a,o,!1,t);switch(O){case"line":jt(),ut();break;case"line-label":jt(),ut(),pe();break;case"label":ut(),pe();break;case"none":break}n.restore()}const Eh=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Ih(n,t,e,s,r,i="right",a){var o,l,c;const h=r.description;if(!h||h.length===0)return;const g=r.y,p=ye(a),b=Nt(h,t,p),E=ne(p,t),O=(o=r.paddingTop)!=null?o:Di,N=(l=r.paddingBottom)!=null?l:Di,k=g-E/2-O,Z=g+E/2+N-k;if(g<e.y+Z/2||g>e.y+e.height-Z/2)return;t.save();const J=b+5,K=4,U=b+K*2,q=s.x+s.width,at=i==="right"?q-U:s.x+K;cn(n,t,at,k,J,Z,.8),t.fillStyle=(c=r.descColor)!=null?c:r.bgColor,t.font=p;const ot=i==="right"?q-b-K*2:s.x+K*2;t.fillText(h,ot,g+E/2-1),t.restore()}class Ii{constructor(t,e,s,r,i=()=>!0,a){this.config=t,this.canvasBoundsContainer=e,this.paneManager=s,this.backgroundCanvasModel=r,this.crossDrawPredicate=i,this.noLines=a}draw(t,e){this.crossDrawPredicate()&&Se(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var s,r,i,a,o;const l=this.canvasBoundsContainer.getBounds(Y.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(Y.ALL_PANES,{extensionY:1e-4}),h=(s=this.config.components.xAxis.padding.top)!=null?s:0,g=(i=this.config.components.yAxis.typeConfig[(r=this.config.components.crossTool.yLabel.type)!=null?r:"badge"])==null?void 0:i.paddings,p=(a=g==null?void 0:g.start)!=null?a:0,b=(o=this.paneManager.panes[e.paneId])==null?void 0:o.ht;if(c(e.x,l.y)){const E={start:[l.x,e.y],end:[l.x+l.width+p,e.y]},O={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},N=b==null?void 0:b(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),N&&(t.moveTo(...E.start),t.lineTo(...E.end)),t.moveTo(...O.start),t.lineTo(...O.end),t.stroke()),N&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,r,i,a,o;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 g=e.x,p=e.time,b=t.measureText(p).width,E=this.config.components.xAxis.fontSize,O=this.canvasBoundsContainer.getBounds(Y.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const N=(s=l==null?void 0:l.left)!=null?s:0,k=(r=l==null?void 0:l.right)!=null?r:0,V=(i=l==null?void 0:l.top)!=null?i:0,Z=(a=l==null?void 0:l.bottom)!=null?a:0,J=(o=c==null?void 0:c.top)!=null?o:0,K=b+N+k,U=E+V+Z,q=Math.max(g-K/2,0),at=O.y+J;ii(t,q,at,K,U),t.fillStyle=h.labelTextColor;const ot=Math.max(g-b/2,N),nt=O.y+J+E+V-1;t.fillText(p,ot,nt),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,r=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const i=this.paneManager.panes[e.paneId],a=e.y;if(!i)return;for(const o of i.yExtentComponents){const l=o.regularValueFromY(a),c=o.valueFormatter(l),h=this.canvasBoundsContainer.getBounds(Y.PANE_UUID_Y_AXIS(i.uuid,o.idx)),g=Ai[this.config.components.crossTool.yLabel.type];g(t,h,c,a,{textColor:r.labelTextColor,bgColor:r.labelBoxColor,paddingBottom:s==null?void 0:s.bottom,paddingEnd:s==null?void 0:s.end,paddingTop:s==null?void 0:s.top},o.yAxis.state,this.config.colors.yAxis,!0,this.backgroundCanvasModel.ctx)}}}}class Oh{draw(){}}class Lh extends tt{constructor(t,e,s,r,i,a,o,l){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=r,this.paneManager=i,this.backgroundCanvasModel=l,this.crossToolTypeDrawers={},this.model=new Ph(t.components.crossTool,this.crossToolCanvasModel,a,o),this.addChildEntity(this.model);const c=new Ge(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const h=new xh(this.model,this.crossToolCanvasModel,this.crossToolTypeDrawers),g=new ls;g.addDrawer(c,"CLEAR_CANVAS"),g.addDrawer(h,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(g,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new Ii(this.config,this.canvasBoundsContainer,this.paneManager,this.backgroundCanvasModel,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new Ii(this.config,this.canvasBoundsContainer,this.paneManager,this.backgroundCanvasModel,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Oh)}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 Bh{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,s])=>{for(const r of s){const{model:i,drawer:a}=r;a.draw(this.canvasModel,i,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class ie{constructor(t){this.data=t,this.next=null}}class Rh{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 ie(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 ie(e);if(t===0)s.next=this.head,this._head=s;else{let r=this.head,i=r,a=0;for(;r&&a<t;)a++,i=r,r=r.next;s.next=r,i.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,r=0;if(t===0)this._head=e.next;else{for(;e.next&&r<t;)r++,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 Fh extends tt{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._objects=new $t({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,i=this.objects[s];if(i)return[e,i]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,r]=e,i=new ie(s);return r.getNodePosition(i)}addObject(t){var e;const s=t.paneId,r=this.objects,i=(e=r[s])!=null?e:new Rh;Object.keys(r).find(a=>a===s)||(r[s]=i),i.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.setDynamicObjects(r)}removeObject(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,r]=e,i=new ie(s),a=r.getNodePosition(i);r.removeAt(a),this.modelIdToObjectMap.delete(t),r.size()===0&&delete this.objects[s.paneId],this.setDynamicObjects(this.objects)}moveToPosition(t,e){const s=this.getObjectInfoById(t);if(!s)return;const[r,i]=s,a=new ie(r),o=i.getNodePosition(a);o!==e&&(o<e?(i.insertAt(e,r),i.removeAt(o)):(i.removeAt(o),i.insertAt(e,r)),this.setDynamicObjects(this.objects))}bringToFront(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,r]=e,i=new ie(s),a=r.getNodePosition(i);a>=0&&a<r.size()&&(r.removeAt(a),r.insertAtEnd(s),this.setDynamicObjects(this.objects))}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,r]=e,i=new ie(s),a=r.getNodePosition(i);a>0&&a<=r.size()&&(r.removeAt(a),r.insertAt(0,s),this.setDynamicObjects(this.objects))}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,r]=e,i=new ie(s),a=r.getNodePosition(i);a>=0&&a+1<r.size()&&(r.removeAt(a),r.insertAt(a+1,s),this.setDynamicObjects(this.objects))}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,r]=e,i=new ie(s),a=r.getNodePosition(i);a>0&&a<r.size()&&(r.removeAt(a),r.insertAt(a-1,s),this.setDynamicObjects(this.objects))}get objects(){return this._objects.getValue()}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Yh extends tt{constructor(t,e){super();const s=new Fh(t);this.model=s,this.addChildEntity(s);const r=new Bh(s,t);e.addDrawer(r,"DYNAMIC_OBJECTS")}}const Nh=()=>n=>n.toString(),Hh=(n,t)=>{var e;const s="date.get"+(t((e=n.timezone)!=null?e:"")?"":"UTC"),r={YYYY:a("FullYear"),YY:a("FullYear")+" % 100",MMM:o("shortMonths","Month"),MMMM:l(o("shortMonths","Month")),M:"1+"+a("Month"),d:a("Date"),H:a("Hours"),m:a("Minutes"),s:a("Seconds"),sss:a("Milliseconds"),EEE:o("shortDays","Day"),SSS:"this.addTwoZeros("+a("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(h){r[h+h]="this.addZero("+r[h]+")"});const i=new RegExp(Object.keys(r).sort().reverse().join("|"),"g");function a(h){return s+h+"()"}function o(h,g){return"this."+h+"["+a(g)+"]"}function l(h){return h+".toUpperCase()"}function c(h){return"' + ("+r[h]+") + '"}return function(h){var g;const p={shortDays:kh(n),shortMonths:jh(n),addZero(b){return b<10?"0"+b:b},addTwoZeros(b){return(b<100?"0":"")+(b<10?"0":"")+b},tzDate:t((g=n.timezone)!=null?g:"")||function(b){return b instanceof Date?b:new Date(+b)}};return new Function("date","date=this.tzDate(date); return '"+h.replace(i,c)+"'").bind(p)}};function kh(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function jh(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const Oi=(n,t,e)=>{if(n){if(typeof n=="string")return e(n);if(Array.isArray(n)){const s=n.filter(r=>{if(r.showWhen){const i=[];return r.showWhen.periodLessThen&&i.push(()=>{var a,o;return t<((o=(a=r.showWhen)==null?void 0:a.periodLessThen)!=null?o:0)}),r.showWhen.periodMoreThen&&i.push(()=>{var a,o;return t>=((o=(a=r.showWhen)==null?void 0:a.periodMoreThen)!=null?o:0)}),i.every(a=>a())}else return!0});if(s.length>0){const r=s[0];if(r.format)return e(r.format);if(r.customFormatter)return r.customFormatter}}}return Nh()},Uh={"rhombus-small":4,rhombus:6,"rhombus-large":8},$e=(n,t)=>`${n}_${t}`;class Wh{constructor(t,e,s,r,i,a,o){this.backgroundCanvas=t,this.canvasModel=e,this.chartModel=s,this.config=r,this.canvasBoundsContainer=i,this.model=a,this.formatterProvider=o,this.customIcons={};const l=this.config.components.events.icons;l&&(this.createCustomIcon("earnings",l.earnings),this.createCustomIcon("dividends",l.dividends),this.createCustomIcon("splits",l.splits),this.createCustomIcon("conference-calls",l.conferenceCalls))}createCustomIcon(t,e){if(e){const s=this.createIconImage(e.normal),r=this.createIconImage(e.hover);this.customIcons[$e(t,"normal")]=s,this.customIcons[$e(t,"hover")]=r}}createIconImage(t){var e;const r=new DOMParser().parseFromString(t,"text/html").querySelector("svg");let i=0;r&&(i=parseInt((e=r.getAttribute("height"))!=null?e:"",10));const l="data:image/svg+xml;base64,"+btoa(t),c=new Image;return c.src=l,{img:c,svgHeight:i}}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(Y.EVENTS),e=this.canvasBoundsContainer.getBounds(Y.ALL_PANES),s=this.canvasModel.ctx;s.save(),this.model.events.filter(r=>this.config.components.events.eventsVisibility[r.type]).forEach(r=>{const i=this.chartModel.candleFromTimestamp(r.timestamp).xCenter(this.chartModel.scale);if(i>e.x&&i<e.x+e.width){const a=this.config.colors.events[r.type].color;s.strokeStyle=a,this.customIcons[$e(r.type,"hover")]!==void 0?this.drawCustomSvgEvent(s,i,t,r):this.drawDefaultEvent(s,i,t,r,a),this.model.hoveredEvent.getValue()===r&&(s.beginPath(),s.moveTo(i,e.y),s.lineTo(i,t.y+t.height/2),s.stroke(),s.closePath(),this.config.components.xAxis.visible&&this.drawLabel(i,r))}}),s.restore()}drawCustomSvgEvent(t,e,s,r){const i=s.y+s.height/2,a=this.customIcons[$e(r.type,"normal")],o=this.customIcons[$e(r.type,"hover")];this.model.hoveredEvent.getValue()===r?t.drawImage(o.img,e-o.svgHeight/2,i-o.svgHeight/2):t.drawImage(a.img,e-a.svgHeight/2,i-a.svgHeight/2)}drawDefaultEvent(t,e,s,r,i){const a=s.y+s.height/2;t.fillStyle=i,t.lineWidth=1.5;const o=cs(r);t.beginPath(),t.moveTo(e-o,a),t.lineTo(e,a-o),t.lineTo(e+o,a),t.lineTo(e,a+o),t.closePath(),this.model.hoveredEvent.getValue()===r?t.fill():t.stroke()}drawLabel(t,e){var s;const r=this.canvasModel.ctx,i=this.canvasBoundsContainer.getBounds(Y.X_AXIS),a=this.config.components.xAxis.fontFamily,o=this.config.components.xAxis.fontSize,l=(s=this.config.components.xAxis.padding.top)!=null?s:0,c=i.y+o-1+l;r.font=`${o}px ${a}`;const h=this.formatterProvider()(e.timestamp),g=r.measureText(h).width;cn(this.backgroundCanvas.ctx,r,t-g/2,i.y+1,g,i.height-1),r.fillStyle=this.config.colors.events[e.type].color,r.fillText(h,t-g/2,c)}getCanvasIds(){return[this.canvasModel.canvasId]}}function cs(n){return Uh[n.style]}const bn=5;class Xh{constructor(t,e,s,r,i){this.hitTestCanvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=r,this.model=i}draw(){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(Y.EVENTS);t.save(),this.model.events.forEach((s,r)=>{const i=this.model.events[r-1],a=i&&this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale),o=this.chartModel.candleFromTimestamp(s.timestamp).xCenter(this.chartModel.scale);if(o>e.x&&o<e.x+e.width){const l=this.config.colors.events[s.type].color;t.strokeStyle=l,t.fillStyle=l;const c=cs(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const h=(c+bn)*2;if(a!==void 0){const g=cs(i);if(a+g>o-h/2){const b=c*2+bn;t.fillRect(a+g,e.y,b,e.height)}else t.fillRect(o-c-bn,e.y,h,e.height)}else t.fillRect(o-c-bn,e.y,h,e.height)}}),t.restore()}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var zh=Object.defineProperty,Li=Object.getOwnPropertySymbols,Vh=Object.prototype.hasOwnProperty,Gh=Object.prototype.propertyIsEnumerable,Bi=(n,t,e)=>t in n?zh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$h=(n,t)=>{for(var e in t||(t={}))Vh.call(t,e)&&Bi(n,e,t[e]);if(Li)for(var e of Li(t))Gh.call(t,e)&&Bi(n,e,t[e]);return n};const Ri=317,hs={DRAWINGS:[1,199],NEWS:[200,299],DATA_SERIES:[300,2999],EVENTS:[3e3,4e3],EXECUTED_ORDERS:[4001,5e3]};class Zh extends ui{constructor(t,e,s,r,i,a,o,l){super(t,e,i,o,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=s,this.canvasBoundsContainer=r,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new X,this.touchStartSubject=new X,this.dblClickSubject=new X,this.rightClickSubject=new X,this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,fi(this,a),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(Y.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(je(100,void 0,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(yt(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),r=Ot(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(yt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),i=Ot(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(yt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mouseup")),a=this.canvasInputListener.observeDbClick(t).subscribe(c=>this.eventHandler(c,"dblclick")),o=this.canvasInputListener.observeContextMenu(t).pipe(yt(()=>$h({},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,r,a,o,l,s,i)}}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*Ri).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/Ri}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!==ss&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=ss),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),s=this.colorToId(e[0]*65536+e[1]*256+e[2]),r=Number(s),[i]=ds(this.hitTestSubscribers,r);return i==null?void 0:i.lookup(s)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const s=this.getPixel(t.x,t.y),r=this.colorToId(s[0]*65536+s[1]*256+s[2]),i=Number(r),[a]=ds(this.hitTestSubscribers,i),o=a==null?void 0:a.lookup(r);return(e=a==null?void 0:a.resolveCursor)==null?void 0:e.call(a,t,o)}eventHandler(t,e){var s,r,i,a,o,l,c;const h=this.getPixel(t.x,t.y),g=this.colorToId(h[0]*65536+h[1]*256+h[2]),p=Number(g),[b,E]=ds(this.hitTestSubscribers,p),O=b==null?void 0:b.lookup(g),N={point:t,model:O};switch(e){case"mousedown":O&&((s=b==null?void 0:b.onMouseDown)==null||s.call(b,O,t)),E.forEach(k=>k.onMouseDown&&k.onMouseDown(null,t));break;case"mouseup":O&&((r=b==null?void 0:b.onMouseUp)==null||r.call(b,O,t)),E.forEach(k=>k.onMouseUp&&k.onMouseUp(null,t));break;case"hover":O&&((i=b==null?void 0:b.onHover)==null||i.call(b,O,t)),E.forEach(k=>k.onHover&&k.onHover(null,t)),this.hoverSubject.next(N);break;case"touchstart":O&&((a=b==null?void 0:b.onTouchStart)==null||a.call(b,O,t)),E.forEach(k=>k.onTouchStart&&k.onTouchStart(null,t)),this.touchStartSubject.next(N);break;case"dblclick":O&&((o=b==null?void 0:b.onDblClick)==null||o.call(b,O,t)),this.dblClickSubject.next(N);break;case"contextmenu":O&&((l=b==null?void 0:b.onRightClick)==null||l.call(b,O,t)),this.rightClickSubject.next(N);break;case"zoom":O&&((c=b==null?void 0:b.onZoom)==null||c.call(b,O,t)),E.forEach(k=>k.onZoom&&k.onZoom(null,t));break;default:break}}}const ds=(n,t)=>{let e;const s=[];return n.forEach(r=>{const[i,a]=r.getIdRange();t>=i&&t<=a?e=r:s.push(r)}),[e,s]};var Kh=Object.defineProperty,Jh=Object.defineProperties,qh=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,Qh=Object.prototype.hasOwnProperty,td=Object.prototype.propertyIsEnumerable,Yi=(n,t,e)=>t in n?Kh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ed=(n,t)=>{for(var e in t||(t={}))Qh.call(t,e)&&Yi(n,e,t[e]);if(Fi)for(var e of Fi(t))td.call(t,e)&&Yi(n,e,t[e]);return n},nd=(n,t)=>Jh(n,qh(t));class sd extends tt{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new $t(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,r)=>nd(ed({},s),{id:r+e})).sort((s,r)=>s.timestamp-r.timestamp)}getIdRange(){return hs.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 rd extends tt{constructor(t,e,s,r,i,a,o,l,c){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=i,this.drawingManager=a,this.formatterFactory=o,this.eventsXAxisLabelFormatterProvider=()=>Oi(this.config.components.events.xAxisLabelFormat,r.getPeriod(),this.formatterFactory);const h=new sd(e);this.eventsModel=h,this.addChildEntity(h),s.addSubscriber(h);const g=new Wh(c,e,r,t,i,h,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(g,"EVENTS");const p=new Xh(s,r,t,i,h);this.drawingManager.addDrawerBefore(p,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(Y.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){Kt(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class id{constructor(t,e,s,r,i,a,o,l,c=()=>!0,h){this.canvasModel=t,this.viewportModel=e,this.config=s,this.yAxisState=r,this.xBoundsProvider=i,this.yBoundsProvider=a,this.xLabelsProvider=o,this.yLabelsProvider=l,this.drawPredicate=c,this.getBaseline=h}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;Se(t,()=>this.drawVertical(t)),Se(t,()=>this.drawHorizontal(t)),Se(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const s=this.xBoundsProvider(),r=gt(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(s.x,r),t.lineTo(s.x+s.width,r),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(),r=s.x+s.width;for(const i of e){const a=st(this.viewportModel.toX(i.value));a>s.x&&a<r&&(t.beginPath(),t.moveTo(a,s.y),t.lineTo(a,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 r of e){const i=gt(this.viewportModel.toY(r.value)),a=Dh(r.text,t,zt);i>s.y+a&&i<s.y+s.height-a&&(t.beginPath(),t.moveTo(s.x,i),t.lineTo(s.x+s.width,i),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Ni extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p){super(),this.drawerName=i,this.drawingManager=a,this.drawer=new id(t,e,s,r,o,l,c,h,p,g)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class ad{constructor(t,e,s,r){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=r}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:r}=this.chartModel.mainCandleSeries.zippedHighLow,i=this.chartModel.mainCandleSeries.dataIdxStart,a=i+s,o=i+r,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,a,t,"high"),this.drawMarkerLabel(l,o,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,r){const i=this.getMarkerY(t,s,r==="low");if(!this.checkMarkerInBounds(i))return;const a=this.getMarkerText(s,r),o=this.getMarkerX(t,e,a);t.fillStyle=r==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(a,o,i)}getMarkerText(t,e){const s=this.chartModel.pane.regularFormatter(t);return`${e==="high"?"H:":"L:"} ${s}`}getMarkerY(t,e,s=!1){const r=this.chartModel.toY(e);if(s){const i=jn(t);return r+i}return r}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(Y.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,s){let r=this.chartModel.toX(e);const i=this.canvasBoundsContainer.getBounds(Y.CHART),a=4,o=t.measureText(s).width;return r+a+o>i.width&&(r=r-(a+o)),r+a}getCanvasIds(){return[this.canvasModel.canvasId]}}class od extends tt{constructor(t,e,s,r,i){super();const a=new ad(e,s,t,r);i.addDrawer(a,"HIGH_LOW")}}const ld=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],cd=24*60*60*1e3;class hd extends tt{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new X}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()+cd;Bo(this.highlights,t,e,dd).forEach(r=>{var i;this.visualHighlights[r.type]||(this.visualHighlights[r.type]=[]),(i=this.visualHighlights[r.type])==null||i.push(r)})}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 dd=n=>n.to,ve=[20,10];class ud{constructor(t,e,s,r,i){this.highlightsModel=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=r,this.config=i}draw(){var t,e,s,r;if(this.config.components.highlights.visible){const i=this.chartModel.getCandles(),a=this.canvasModel.ctx,o=this.highlightsModel.getVisualHighlights();if(this.highlightsModel.getHighlights().length&&i.length!==0&&this.chartModel.scale.isScaleReady()){const c=this.canvasBoundsContainer.getBounds(Y.ALL_PANES);a.save(),xe(a,c);const h=(t=this.config.components.highlights.border.width)!=null?t:1,g=(e=this.config.components.highlights.border.dash)!=null?e:[0,0],p=(s=this.config.components.highlights.fontSize)!=null?s:11,b=(r=this.config.components.highlights.fontFamily)!=null?r:"monospace",E=`${p}px ${b}, monospace`;a.font=E,a.lineWidth=h,a.setLineDash(g),ld.forEach(O=>{var N,k;const V=o[O];if(V){const Z=this.config.colors.highlights[O],J=(N=Z==null?void 0:Z.border)!=null?N:"#ffffff",K=(k=Z==null?void 0:Z.background)!=null?k:"#ffffff";a.save(),a.beginPath(),a.fillStyle=K,a.strokeStyle=J,V.forEach(U=>{var q,at,ot;const nt=this.chartModel.candleFromTimestamp(U.from),rt=Mt(nt.width,this.chartModel.scale.zoomX),dt=nt.xStart(this.chartModel.scale),ct=this.chartModel.candleFromTimestamp(U.to),St=Mt(ct.width,this.chartModel.scale.zoomX),ut=ct.xStart(this.chartModel.scale)+St;if(U.border&&this.drawBorders(U.border,a,dt+rt,ut-St,c),a.fillRect(dt,c.y,ut-dt,c.y+c.height),U.label){const vt=(q=U.label.text)!=null?q:"",pt=this.config.colors.highlights[U.type];a.save(),a.fillStyle=(at=pt==null?void 0:pt.label)!=null?at:"#ffffff";const Ht=Nt(vt,a,E),[kt,jt]=this.resolveHighlightLabelPosition((ot=U.label.placement)!=null?ot:"left-left",c,[dt,ut],Ht);a.fillText(vt,kt,jt),a.restore()}}),a.closePath(),a.restore()}}),a.restore()}}}resolveHighlightLabelPosition(t,e,s,r){const[i,a]=s;switch(t){case"right-left":return[a-ve[1]-r,e.y+ve[0]];case"left-left":return[i-ve[1]-r,e.y+ve[0]];case"right-right":return[a+ve[1],e.y+ve[0]];case"left-right":default:return[i+ve[1],e.y+ve[0]]}}drawBorders(t,e,s,r,i){const a=t.left,o=t.right;a&&(e.beginPath(),e.moveTo(s,i.y),e.lineTo(s,i.y+i.height),e.stroke(),e.closePath()),o&&(e.beginPath(),e.moveTo(r,i.y),e.lineTo(r,i.y+i.height),e.stroke(),e.closePath())}getCanvasIds(){return[this.canvasModel.canvasId]}}const fd="HIGHLIGHTS_PLUGIN";class gd extends tt{constructor(t,e,s,r,i,a){super(),this.eventBus=t,this.config=e,this.highlightsModel=new hd(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new ud(this.highlightsModel,s,r,i,e),a.addDrawer(this.highLightsDrawer,fd)}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 vd(){return y(function(n,t){var e,s=!1;n.subscribe(Xt(t,function(r){var i=e;e=r,s&&t.next([i,r]),s=!0}))})}function lt(n,t){return y(function(e,s){var r=0;e.subscribe(Xt(s,function(i){return n.call(t,i,r++)&&s.next(i)}))})}var md=Object.defineProperty,pd=Object.defineProperties,bd=Object.getOwnPropertyDescriptors,Hi=Object.getOwnPropertySymbols,Cd=Object.prototype.hasOwnProperty,yd=Object.prototype.propertyIsEnumerable,ki=(n,t,e)=>t in n?md(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ji=(n,t)=>{for(var e in t||(t={}))Cd.call(t,e)&&ki(n,e,t[e]);if(Hi)for(var e of Hi(t))yd.call(t,e)&&ki(n,e,t[e]);return n},Ui=(n,t)=>pd(n,bd(t));const ae=4;class wd{constructor(t,e,s,r,i,a){this.config=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=r,this.formatterFactory=i,this.visualCandlesProvider=a}draw(){if(this.config.components.navigationMap.visible){const t=this.visualCandlesProvider();if(t.length){const e=this.canvasBoundsContainer.getBounds(Y.N_MAP),s=this.canvasBoundsContainer.getBounds(Y.N_MAP_BTN_L),r=this.canvasBoundsContainer.getBounds(Y.N_MAP_BTN_R),i=this.canvasBoundsContainer.getBounds(Y.N_MAP_KNOT_L),a=this.canvasBoundsContainer.getBounds(Y.N_MAP_KNOT_R),o=this.canvasBoundsContainer.getBounds(Y.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(Y.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),r.width!==0&&this.drawRightArrowButton(c,r,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,i,a,s,o),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,s,r){t.x<=s.x+s.width&&(t.x=s.x+s.width,r.x=t.x+t.width,e.x=r.x+r.width)}drawSlider(t,e,s,r,i){this.blockDrawSliderOnLeftArrow(e,s,r,i),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,s,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(i.x,i.y,i.width,i.height)}drawLeftArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const r=Math.round(e.x+e.width/2-ae/2),i=Math.round(e.y+e.height/2);t.moveTo(r,i),t.lineTo(r+ae,i+ae),t.lineTo(r+ae,i-ae),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 r=Math.round(e.x+e.width/2-ae/2),i=Math.round(e.y+e.height/2);t.moveTo(r,i-ae),t.lineTo(r,i+ae),t.lineTo(r+ae,i),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,s,r){const i=s.components.navigationMap.knots.border;t.fillStyle=s.colors.navigationMap.knotColor;const a=r?e.x-i:e.x+i;t.fillRect(a,e.y,e.width,e.height),t.lineWidth=s.components.navigationMap.knots.lineWidth,i>0&&(t.beginPath(),t.moveTo(a,e.y),t.lineTo(a,e.y+e.height),t.lineTo(a+e.width,e.y+e.height),t.lineTo(a+e.width,e.y),t.lineTo(a,e.y),t.lineWidth=i,t.strokeStyle=s.colors.navigationMap.knotBorderColor,t.stroke()),t.beginPath(),t.moveTo(a+e.width/2,e.y+e.height/4),t.lineTo(a+e.width/2,e.y+3*e.height/4),t.strokeStyle=s.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=Lt(this.chartModel.mainCandleSeries.getSeriesInViewport()),s=this.config.components.navigationMap.timeLabels,r=s.visible;if(e.length&&r){const i=e[0].candle.timestamp,a=e[e.length-1].candle.timestamp,o=this.canvasBoundsContainer.getBounds(Y.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(Y.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:s.fontFamily,textSize:`${s.fontSize}px`},g={dateFormat:s.dateFormat,padding:s.padding,textProperties:Ui(ji({},h),{textAlign:"left"})},p={dateFormat:s.dateFormat,padding:s.padding,textProperties:Ui(ji({},h),{textAlign:"right"})};this.drawTimeLabel(t,o,i,g),this.drawTimeLabel(t,l,a,p)}}drawTimeLabel(t,e,s,r){const i=r.padding,a=nr(s,r.dateFormat,this.formatterFactory);Qs(t,r.textProperties);const o=jn(t),l=er(a);Ro(t,l,e.x+i.x,e.y+o+i.y,r.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}class Ze extends bi{constructor(t,e,s,r,i=pi){super(t,e,s,r,i)}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))}doDeactivate(){super.doDeactivate()}}const Wi=4;class Sd extends tt{constructor(t,e,s,r,i,a){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=r,this.canvasBoundsContainer=i,this.chartPanComponent=a,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=b=>{const E=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART);this.leftKnotDragStartXRelative=b.x-E.x-Wi},this.leftKnotDragTick=b=>{const{delta:E}=b,N=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART).width,k=(this.leftKnotDragStartXRelative+E)/N;this.canvasBoundsContainer.leftRatio=k,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=b=>{const E=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART);this.rightKnotDragStartXRelative=b.x-E.x+Wi},this.rightKnotDragTick=b=>{const{delta:E}=b,N=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART).width,k=(this.rightKnotDragStartXRelative+E)/N;this.canvasBoundsContainer.rightRatio=k,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=b=>{const{delta:E}=b,O=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART),N=this.chartModel.mainCandleSeries.meanCandleWidth/(O.width/this.chartModel.mainCandleSeries.dataPoints.length),k=(this.lastMousePosition-E)*N;this.scale.moveXStart(this.scale.xStart-k),this.lastMousePosition=E};const o=this.canvasBoundsContainer.getBoundsHitTest(Y.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(Y.N_MAP_KNOT_R),c=new Ze(o,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Ze(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const g=this.canvasBoundsContainer.getBoundsHitTest(Y.N_MAP_SLIDER_WINDOW),p=new Ze(g,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(p)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(Y.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(Y.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 xd extends tt{constructor(t,e,s,r,i,a,o,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=r,this.canvasInputListeners=i,this.canvasBoundsContainer=a,this.chartPanComponent=c,this.visualCandles=[];const g=new wd(r,e,s,a,l,()=>this.visualCandles);o.addDrawer(g,Y.N_MAP_CHART),this.navigationMapMoveHandler=new Sd(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(Y.N_MAP_CHART,r.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(Y.N_MAP_BTN_L,r.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(Y.N_MAP_BTN_R,r.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(Y.N_MAP_KNOT_L,r.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(Y.N_MAP_KNOT_R,r.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(Y.N_MAP_SLIDER_WINDOW,r.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(Ot(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(Y.N_MAP),this.chartModel.scale.xChanged.pipe(vd(),lt(([t,e])=>{const r=t.start<0||t.end>0,i=e.start<0||e.end>0;return r&&!i||i}))).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,r=this.chartModel.mainCandleSeries.dataIdxEnd,i=Math.round(Math.max(-s,0)),a=Math.max(this.chartModel.getCandlesCountWithRightOffset(),r)+i;let o=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(Y.N_MAP_CHART),h=c.width,g=[];let p=0,b,E;for(b=0;b<h;b++)E=gt(b*a/h)-i,E in e?(g[b]=e[E].close,p=(t=g[b])!=null?t:0,o=Math.max(o,p),l=Math.min(l,p)):g[b]=0;return o-=l,g.map((O,N)=>[N+c.x,(o+l-O)*c.height/o+c.y])}setVisible(t=!0){var e;(e=this.config.components)!=null&&e.navigationMap&&(this.config.components.navigationMap.visible=t,this.eventBus.fire(ts),this.canvasModel.fireDraw())}}class Pd extends tt{constructor(t,e,s){super(),this.scale=t,this.canvasInputListeners=e,this.mainCanvasParent=s,this.touchedCandleIndexes=[0,0]}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart().subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove().subscribe(t=>this.handleTouchMoveEvent(t)))}handleTouchStartEvent(t){t.touches.length===2&&(this.touchedCandleIndexes=this.getXPositions(t).map(e=>this.scale.fromX(e)))}handleTouchMoveEvent(t){t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),s=[0,0],r=document.body.scrollLeft||document.documentElement.scrollLeft;for(let i=0,a=t.touches.length;i<a;i++){const o=t.touches[i];s[i]=o.pageX-e.left-r}return s}pinchHandler(t,e){const s=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),r=s+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;this.scale.setXScale(s,r)}}const Xi=()=>{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"},Xg=(n,t)=>n==="apple"||n==="mobile"?3:t,Td=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Md=!!window.chrome,zi=typeof InstallTrigger!="undefined",_d=navigator.platform.indexOf("Win")>-1,Vi=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let r;if(Td)r=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(Md){if(r=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,_d){const i=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);r=Math.abs(e)===Math.abs(n.deltaY)||i}}else zi?Math.abs(n.deltaY)>Math.abs(n.deltaX)?r=!1:r=s===n.deltaX*-3:r=e===n.deltaY*-3;r&&(t=!0)}else n.deltaMode===0&&(t=!0);return zi&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Gi=(n,t)=>n==="percent"?t/4:t;var us=Math.pow;class Dd extends tt{constructor(t,e,s,r,i,a,o,l){super(),this.bus=t,this.config=e,this.scale=s,this.mainCanvasParent=r,this.canvasInputListener=i,this.canvasBoundsContainer=a,this.canvasAnimation=o,this.chartPanComponent=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelTrottleTime=15,this.zoomXHandler=(g,p)=>{const b=g.deltaY<0;if(this.config.scale.zoomToCursor){const O=this.canvasBoundsContainer.getBounds(Y.CANVAS).width,k=g.offsetX/O;this.scale.zoomXToPercent(k,b,!1,p)}else this.scale.zoomXToEnd(b,p);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(Rn),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart},this.onXDragTick=g=>{const{delta:p}=g;this.currentPoint.x=p;const b=re(p,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-b),this.bus.fireDraw()},this.touchHandler=new Pd(this.scale,this.canvasInputListener,this.mainCanvasParent);const c=this.canvasBoundsContainer.getBoundsHitTest(Y.ALL_PANES),h=new Ze(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});this.addChildEntity(h)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(Y.ALL_PANES);this.addRxSubscription(Ot(this.canvasInputListener.observeWheel(t),this.canvasInputListener.observePinch(t)).pipe(je(this.wheelTrottleTime,void 0,{trailing:!0,leading:!0})).subscribe(e=>{const r=Vi(e)?Gi(this.config.components.yAxis.type,this.config.scale.zoomSensitivity.pinch):this.config.scale.zoomSensitivity.wheel;this.zoomXHandler(e,r)})),this.addRxSubscription(this.canvasInputListener.observeScrollGesture().pipe(je(this.wheelTrottleTime,void 0,{trailing:!0,leading:!0})).subscribe(e=>{let s=-1;const r=Xi();(r==="apple"||r==="mobile")&&(s=1);let i=0,a=0;if(i+=e.deltaX*s,a+=e.deltaY*-s,i!==0&&Math.abs(i)>Math.abs(a)){const o=re(i,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-o)}else if(a!==0&&Math.abs(a)>Math.abs(i)){const o=Gi(this.config.components.yAxis.type,this.config.scale.zoomSensitivity.glide);this.zoomXHandler(e,o)}this.bus.fireDraw()})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e})),this.touchHandler.activate(),this.addSubscription(this.touchHandler.deactivate.bind(this.touchHandler))}registerChartYPanHandler(t,e){let s=t.yStart;const r=()=>{this.canvasAnimation.forceStopAnimation(Rn),this.currentPoint={x:0,y:0},s=t.yStart},i=o=>{const{delta:l}=o;if(this.currentPoint.y=l,t.state.auto)Ad(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const c=re(t.state.inverse?-l:l,t.zoomY);t.moveYStart(s+c)}},a=new gn(e,{onDragTick:i,onDragStart:r},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});return this.addChildEntity(a),a}}const Ad=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=us(us(Math.abs(n.x),2)+us(e,2),.5),r=Math.abs(Math.acos(e/s));return e>t.yDiff&&r<t.edgeAngle};class Ed extends tt{constructor(t,e,s,r,i,a,o,l){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=r,this.canvasAnimation=i,this.canvasInputListener=a,this.mainCanvasParent=o,this.chartBaseModel=l,this.chartPanComponents=[],this.chartAreaPanHandler=new Dd(this.eventBus,this.config,this.mainScale,this.mainCanvasParent,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this),this.chartPanComponents.push(this.chartAreaPanHandler)}doActivate(){this.activateChartPanHandlers()}doDeactivate(){this.deactivatePanHandlers()}activateChartPanHandlers(){this.chartPanComponents.forEach(t=>t.activate())}deactivatePanHandlers(){this.chartPanComponents.forEach(t=>t.deactivate())}}const $i=n=>t=>{const{top:e,bottom:s}=n(),r=t.high-t.low,i=r===0?1:r,a=i*e/100,o=i*s/100,l=t.low-o,c=t.high+a;return{low:l,high:c}},Zi=(n,t)=>{const e=$i(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const r=t.calculateHighLow(s);return e(r)}}};function Id(){return Ns(1)}function Ki(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Id()(qe(n,Je(n)))}function Od(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Je(n);return y(function(s,r){(e?Ki(n,s,e):Ki(n,s)).subscribe(r)})}function Ld(n){return lt(function(t,e){return n<=e})}class Bd{constructor(t,e,s,r,i){this.config=t,this.boundsProvider=e,this.canvasModel=s,this.canvasAnimation=r,this.animationId=i}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),s=this.canvasModel.ctx,r=this.canvasAnimation.getColorAlphaAnimation(this.animationId),i=this.config.components.paneResizer.dragZone;!t&&r&&(s.fillStyle=r.getColor(0),s.fillRect(e.x,e.y-i,e.width,e.height+2*i)),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-i,e.width,e.height+2*i)}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Rd extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=r,this.chartPanComponent=i,this.canvasModel=a,this.drawingManager=o,this.canvasInputListener=l,this.canvasAnimation=c,this.config=h,this.canvasBoundsContainer=g,this.initialY=0,this.resizeEvent$=new X,this.onYDragStart=()=>{this.config.components.crossTool.type="none",this.initialY=this.boundsProvider().y},this.onYDragEnd=()=>{this.config.components.crossTool.type="cross-and-labels",this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio)},this.onYDragTick=p=>{const{delta:b,draggedPixels:E}=p;Math.abs(this.initialY-this.boundsProvider().y+E)>=0&&(this.dragTickCb(b),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new gn(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent);this.addChildEntity(s),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(Od(!1),Zt(),Ld(1)).subscribe(r=>{r?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Bd(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,mi.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(mi.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 Fd=n=>t=>{let e;if(typeof t=="number")e=t;else if(typeof t=="string")e=Number(t);else return"\u2014";const[s]=n.dataSeries;if(s!==void 0){const r=qt.getPricePrecision(e,s.pricePrecisions);return e.toFixed(r)}return`${e}`},Yd=n=>(t,e)=>{const[s]=n.dataSeries;let r=t;const i=e!=null?e:s;i!==void 0&&(r=Ir(t,i.getBaseline()));const a=r.toFixed(qt.DEFAULT_PRECISION).replace("-","\u2212")+" %";return a==="\u22120.00 %"?"0.00 %":a},Nd=n=>({percent:Yd(n),regular:Fd(n)});class Hd extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g=new Set,p={regular:Nr}){super(),this.paneUUID=t,this.idx=e,this.paneComponent=s,this.chartBaseModel=r,this.canvasBoundsContainer=i,this.hitTestController=a,this.dynamicObjectsCanvasModel=o,this.scale=l,this.dragNDrop=h,this.dataSeries=g,this.formatters=p,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(Y.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=b=>b.map(E=>new Xe(this.chartBaseModel.dataFromTimestamp(E.timestamp).centerUnit,E.close)),this.toY=b=>{var E,O;return(O=(E=this.mainDataSeries)==null?void 0:E.view.toY(b))!=null?O:1},this.valueFormatter=(b,E)=>{var O;return((O=this.formatters[this.yAxis.getAxisType()])!=null?O:this.formatters.regular)(b,E)},this.addChildEntity(l),this.setValueFormatters(Nd(this)),this.yAxis=c(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 Yr(this,Ft(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){this.dataSeries.add(t),this.dataSeries.size===1&&(this.mainDataSeries=t),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 Ji=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(n.dataSeries).filter(s=>s.highLowProvider.isHighLowActive()).map(s=>s.highLowProvider.calculateHighLow(t));return Kr(e)}});class kd{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=hs.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return hs.DATA_SERIES}get allDataSeries(){return He(He(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.hovered=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 oe="#FF00FF";function qi(n,t,e,s){const r=n.yAxis.backgroundColor,i=n.chartAreaTheme.backgroundColor,a=n.chartAreaTheme.backgroundGradientTopColor,o=n.chartAreaTheme.backgroundGradientBottomColor,l=s.align==="left"?a:o,c=n.chartAreaTheme.backgroundMode==="gradient"?l:i;return fe(r==="transparent"?c:r,t,e)}const jd=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,Ud=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:oe},Wd=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:oe},Xd=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:oe},zd=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:oe},Vd=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:oe},Gd=(n,t)=>{const e=t.histogram[`${n}Cap`];return e!=null?e:oe},$d=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:oe},Qi=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:oe},Zd=()=>(console.warn("Fallback for label default color"),oe);function Kd(n,t){if(n.filter(o=>o!==null).length<=1)return n.map(o=>o.y);const e=t-2,s=n.map((o,l)=>Jd(o,l,e)).filter(Zs).sort(qd),r=new Array(s.length),i=s.reduce((o,l)=>Math.min(o,l.labelWeight),Number.POSITIVE_INFINITY),a=s.findIndex(o=>o.labelWeight===i);for(let o=a;o>=0;o--){const l=s[o],c=s[o-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}r[l.actualIndex]=(l.top+l.bottom)/2}}for(let o=a;o<s.length;o++){const l=s[o],c=s[o+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}r[l.actualIndex]=(l.top+l.bottom)/2}return r}const Jd=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,qd=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var Qd=Object.defineProperty,tu=Object.defineProperties,eu=Object.getOwnPropertyDescriptors,ta=Object.getOwnPropertySymbols,nu=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,ea=(n,t,e)=>t in n?Qd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,na=(n,t)=>{for(var e in t||(t={}))nu.call(t,e)&&ea(n,e,t[e]);if(ta)for(var e of ta(t))su.call(t,e)&&ea(n,e,t[e]);return n},sa=(n,t)=>tu(n,eu(t));const fs={MAIN:"MAIN"};class ru extends tt{constructor(t,e,s,r,i,a,o){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=r,this.canvasModel=i,this.paneUUID=a,this.updateYAxisWidth=o,this.orderedLabels=[],this.customLabels={},this.labelsProviders={},this.labelsPositionRecalculatedSubject=new X,this.animFrameId=`anim_cache_${Ft()}`,this.initModel()}doActivate(){super.doActivate(),this.addRxSubscription(Ot(this.canvasBoundsContainer.observeBoundsChanged(Y.PANE_UUID(this.paneUUID)),this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed).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(),is(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 r of Object.values(this.labelsProviders)){const i=Lt(Object.values(r).map(l=>l.getUnorderedLabels())),a=Lt(i.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),o=Kd(a,s);i.forEach(l=>{const c=o.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 sa(na({},t),{labels:t.labels.map((s,r)=>sa(na({},s),{lineY:s.y,y:e[r]}))})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var r;const i=(r=this.labelsProviders[t])!=null?r:{};i[s]=e,this.labelsProviders[t]=i,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const r=(s=this.labelsProviders[t])!=null?s:{};delete r[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}const ra=10;class iu extends tt{constructor(t,e,s,r,i,a,o,l){if(super(),this.bus=t,this.scale=r,this.bounds=a,this.autoScaleCallback=l,this.yAxisDragEndSubject=new X,this.lastYStart=0,this.lastYEnd=0,this.lastYHeight=0,this.lastYPxHeight=0,this.onYDragStart=()=>{this.lastYStart=this.scale.yStart,this.lastYEnd=this.scale.yEnd,this.lastYHeight=this.scale.yEnd-this.scale.yStart,this.lastYPxHeight=this.bounds.getBounds(Y.Y_AXIS).height},this.onYDragTick=c=>{const{delta:h}=c;let g;h<0?g=1/(1+-h/this.lastYPxHeight*(ra-1)):g=1+h/this.lastYPxHeight*(ra-1);const b=(this.lastYHeight*g-this.lastYHeight)/2,E=this.lastYStart-b,O=this.lastYEnd+b;this.autoScaleCallback(!1),this.scale.setYScale(E,O),this.bus.fireDraw()},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next()},e.customScale){const c=()=>e.type!=="percent"&&e.visible,h=new gn(o,{onDragTick:gs(this.onYDragTick,c),onDragStart:gs(this.onYDragStart,c),onDragEnd:gs(this.onYDragEnd,c)},i,s,{disableChartPanning:!1});this.addChildEntity(h),e.customScaleDblClick&&i.observeDbClick(o).subscribe(()=>{l(!0),this.bus.fireDraw()})}}}const gs=(n,t)=>(...e)=>t()&&n(...e);class au{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${Ft()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),vi(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 ou=0,lu=.01;class vs{constructor(t,e,s,r,i=!1,a,o,l=Fn,c=23){this.increment=t,this.startEndProvider=e,this.lengthProvider=s,this.valueFormatter=r,this.withZero=i,this.axisTypeProvider=a,this.baseLineProvider=o,this.labelFilter=l,this.singleLabelHeightPixels=c,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new X,this.newGeneratedLabelsSubject=new X,this.lastStart=0,this.lastEnd=0,this.labelsCache=new au(()=>this.labelFilter(this.doGenerateLabels()))}generateRegularLabels(t,e,s){const r=[];this.withZero&&r.push({value:0,text:"0"});let i=wt.roundToNearest(t,s);for(;i<e;){const a=wt.roundToNearest(i,s),o=this.valueFormatter(a);r.push({value:a,text:o}),i=wt.roundDecimal(i+s)}return r}generatePercentLabels(t,e,s){const r=[],i=this.baseLineProvider();let a=wt.roundToNearest(t,s);for(;a<e;){const o=wt.roundToNearest(a,s),l=Or(o,i),c=this.valueFormatter(l);r.push({value:o,text:c}),a=wt.roundDecimal(a+s)}return r}generateLogarithmLabels(t,e,s){const r=[];let i=wt.roundToNearest(t,s);for(;i<e;){const a=qn(i),o=this.valueFormatter(a);r.push({value:i,text:o}),i=wt.roundDecimal(i+s)}return r}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[s,r]=this.calculateMinMax(),i=this.getAxisStep(s,r,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=i);let a;const o=this.axisTypeProvider();if(o==="logarithmic"?a=this.generateLogarithmLabels(s,r,i):o==="percent"?a=this.generatePercentLabels(s,r,i):a=this.generateRegularLabels(s,r,i),this.lastSingleLabelHeightValue!==i&&this.labelsCache.cache){const l=(t=this.labelsCache.getLastCachedValue())!=null?t:[];this.distanceBetweenLabelsChangeSubject.next([l,a]),this.lastSingleLabelHeightValue=i}return this.newGeneratedLabelsSubject.next(a),a}calculateMinMax(){const[t,e]=this.startEndProvider(),s=this.lengthProvider(),r=vs.getLabelBounds(t,e,s);return[r[0],r[1]]}getAxisStep(t,e,s){const r=e-t,i=s/this.singleLabelHeightPixels,a=this.calculateIncrement(r),o=r/i;return this.calculateAxisStep(o,a)}observeDistanceBetweenLabelsChanged(){return this.distanceBetweenLabelsChangeSubject.asObservable()}observeLabelsChanged(){return this.newGeneratedLabelsSubject.asObservable()}calculateIncrement(t){if(this.increment)return this.increment;if(!isNaN(t)){const e=qt.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(e)}return this.adjustIncrementOnAxisType(lu)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),r=qn(e)+t;return Lr(r)-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 r=Math.abs((e-t)*(ou/s));return[t-r,e+r]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let s=e,r=e,i=0;for(;s<t&&s>0;)i>=this.gridDistanceMultipliers.length&&(i=0,r*=10),s=r*this.gridDistanceMultipliers[i++];return s}}class cu extends vs{constructor(t,e,s,r,i=()=>"regular",a=23){super(t,()=>[s.yStart,s.yEnd],()=>s.getBounds().height,r,!1,i,()=>{var o,l;return(l=(o=e())==null?void 0:o.getBaseline())!=null?l:1},void 0,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,"")}calculateIncrement(t){var e;const s=this.dataSeriesProvider();if(s){const r=Yt(s.dataPoints),i=(e=r==null?void 0:r.close)!=null?e:0,a=$l(i,s.pricePrecisions);return this.adjustIncrementOnAxisType(a)}return super.calculateIncrement(t)}}function ia(n,t,e){var s=B(n)||t||e?{next:n,error:t,complete:e}:n;return s?y(function(r,i){var a;(a=s.subscribe)===null||a===void 0||a.call(s);var o=!0;r.subscribe(Xt(i,function(l){var c;(c=s.next)===null||c===void 0||c.call(s,l),i.next(l)},function(){var l;o=!1,(l=s.complete)===null||l===void 0||l.call(s),i.complete()},function(l){var c;o=!1,(c=s.error)===null||c===void 0||c.call(s,l),i.error(l)},function(){var l,c;o&&((l=s.unsubscribe)===null||l===void 0||l.call(s)),(c=s.finalize)===null||c===void 0||c.call(s)}))}):_e}class hu extends tt{constructor(t,e,s,r,i){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=r,this.extentIdx=i,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${Ft()}`}doActivate(){super.doActivate(),this.addRxSubscription(Ot(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(Y.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(yt(t=>t.height),lt(t=>co(t,this.prevYAxisHeight,1.5)),ia(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}updateLabels(){this.labels=this.labelsGenerator.generateNumericLabels(),is(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}}class du extends tt{constructor(t,e,s,r,i,a,o,l,c){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=r,this.extentIdx=c,this.labelsGenerator=new cu(null,l,a,o,()=>this.state.type,s.labelHeight),this.baseLabelsModel=new hu(a,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new ru(e,a,r,s,i,t,()=>this.canvasBoundsContainer.updateYAxisWidths()),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,r)=>r.length>s.length?r:s,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class uu extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.scale=r,this.canvasBoundsContainer=a,this.cursors=l,this.paneUUID=g,this.extentIdx=p,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new X,this.state=We(e.components.yAxis),this.yAxisScaleHandler=new iu(t,this.state,o,r,i,a,a.getBoundsHitTest(Y.PANE_UUID_Y_AXIS(g,p)),b=>r.autoScale(b)),this.addChildEntity(this.yAxisScaleHandler),this.model=new du(this.paneUUID,t,this.state,a,s,r,c,h,p),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",Xd),this.registerLabelColorResolver("bar",Ud),this.registerLabelColorResolver("line",Wd),this.registerLabelColorResolver("area",zd),this.registerLabelColorResolver("scatterPlot",Vd),this.registerLabelColorResolver("histogram",Gd),this.registerLabelColorResolver("baseline",$d),this.registerLabelColorResolver("trend",Qi),this.registerLabelColorResolver("hollow",Qi)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(Y.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(Y.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:Zd}registerYAxisLabelsProvider(t,e=fs.MAIN,s=Ft()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,s),s}addSimpleYAxisLabel(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=fs.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(Y.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())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.enable():this.disable(),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){this.scale.state.inverse=t,this.scale.inverseY=t,this.scale.scaleInversedSubject.next(t)}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}class fu extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p,b,E,O,N,k,V){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=r,this.hitTestController=i,this.config=a,this.mainScale=o,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=g,this.cursorHandler=p,this.eventBus=b,this.canvasBoundsContainer=E,this.uuid=O,this.seriesAddedSubject=N,this.seriesRemovedSubject=k,this._paneOrder=0,this.yExtentComponents=[],this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(J,K)=>this.mainExtent.valueFormatter(J,K);const Z=this.createExtentComponent(V);this.mainExtent=Z,this.ht=this.canvasBoundsContainer.getBoundsHitTest(Y.PANE_UUID(O),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get dataSeries(){return He(this.yExtentComponents,t=>Array.from(t.dataSeries))}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(Y.PANE_UUID(this.uuid)).pipe(Zt(Cr)).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,r){return new Ni(this.mainCanvasModel,e,this.config,r,`PANE_${t}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID(t)),()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID(t)),()=>[],()=>s.generateNumericLabels())}createYPanHandler(t,e){const s=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(Y.PANE_UUID(t)));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(s),s.disable()},s]}addCursors(t,e){const s=Y.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 r=this.yExtentComponents.length,i=()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID(this.uuid)),a=(e=t==null?void 0:t.scale)!=null?e:new Pc(this.mainScale,this.config,i,this.canvasAnimation),[o,l]=this.createYPanHandler(this.uuid,a),c=(b,E)=>new uu(this.eventBus,this.config,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,b,E,this.uuid,r),h=new Hd(this.uuid,r,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,c,l);h.addSubscription(o),h.addSubscription(this.addCursors(r,h.yAxis)),t!=null&&t.paneFormatters&&h.setValueFormatters(t.paneFormatters),((s=t==null?void 0:t.useDefaultHighLow)!=null?s:!0)&&a.autoScaleModel.setHighLowProvider("default",Zi(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),Ji(h)));const p=this.createGridComponent(this.uuid,a,h.yAxis.model.labelsGenerator,h.yAxis.state);return h.addChildEntity(p),h.activate(),this.yExtentComponents.push(h),this.canvasBoundsContainer.updateYAxisWidths(),h}removeExtentComponent(t){t.disable(),this.yExtentComponents.splice(t.idx,1),this.yExtentComponents.forEach((e,s)=>e.idx=s),this.canvasBoundsContainer.updateYAxisWidths()}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()}hide(){this._paneOrder=this.canvasBoundsContainer.panesOrder.indexOf(this.uuid),this.canvasBoundsContainer.removedPaneBounds(this.uuid),this.eventBus.fireDraw()}show(){this.canvasBoundsContainer.addPaneBounds(this.uuid,this._paneOrder),this.eventBus.fireDraw()}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=ke(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}canMoveDown(){const t=Yt(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}class gu extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p,b,E,O){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=r,this.mainScale=i,this.canvasBoundsContainer=a,this.config=o,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=g,this.crossEventProducer=p,this.chartPanComponent=b,this.mainCanvasModel=E,this.yAxisLabelsCanvasModel=O,this.panes={},this.paneRemovedSubject=new X,this.paneAddedSubject=new X,this.dataSeriesAddedSubject=new X,this.dataSeriesRemovedSubject=new X,this.hitTestController=new kd(this.panes,this.dynamicObjectsCanvasModel);const N=this.createPane(ht,{useDefaultHighLow:!1,scale:this.mainScale});N.mainExtent.scale.autoScaleModel.setHighLowProvider("series",Ji(N.mainExtent)),i.autoScaleModel.setHighLowPostProcessor("offsets",$i(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removedPaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(Y.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone}),s=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},r=Y.PANE_UUID_RESIZER(t),i=new Rd(r,()=>this.canvasBoundsContainer.getBounds(r),e,s,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer);return this.userInputListenerComponents.push(i),i}get yExtents(){return He(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(s=>this.canvasBoundsContainer.getBoundsHitTest(Y.PANE_UUID(s.uuid))(t.x,t.y))}createPane(t=Ft(),e){if(this.panes[t]!==void 0)return this.panes[t];const s=new fu(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,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}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())}addCursors(t,e=this.config.components.chart.cursor){const s=Y.PANE_UUID(t),r=Y.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(r,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone),()=>{this.cursorHandler.removeCursorForCanvasEl(s),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(r)}}recalculateState(){Object.values(this.panes).forEach(t=>t.scale.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])}}class vu extends tt{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 r=e.width/window.devicePixelRatio,i=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,r,i),s.drawImage(this.elements.mainCanvas,0,0,r,i),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,r,i),s.drawImage(this.elements.crossToolCanvas,0,0,r,i),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,r,i),t&&t(s),new Promise((a,o)=>this.elements.snapshotCanvas.toBlob(l=>l?a(l):o("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const mu=(n,t=1)=>{function e(r){let i;const a=Math.pow(10,t);return r=Math.round(r*a)/a,r>=1e-15&&r<1?i=r.toFixed(t).replace(/\.?0+$/,""):i=String(r),i.replace(/(\.[1-9]*)0+$/,(o,l)=>l)}function s(r){let i="";return r<0&&(i="-",r=-r),r<995?i+e(r):r<999995?i+e(r/1e3)+"K":r<999999995?(r=1e3*Math.round(r/1e3),i+e(r/1e6)+"M"):(r=1e6*Math.round(r/1e6),i+e(r/1e9)+"B")}return s(n)},Cn=class extends tt{constructor(n,t,e,s,r){super(),this.chartComponent=n,this.drawingManager=t,this.config=e,this.volumesModel=s,this.paneManager=r,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var n,t;return!((n=this.pane)!=null&&n.scale.isViewportValid())&&((t=this.pane)==null?void 0:t.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var n;return(n=this.pane)==null?void 0:n.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[Cn.UUID]===void 0){const t=this.paneManager.createPane(Cn.UUID,{paneFormatters:{regular:r=>mu(r,1)},useDefaultHighLow:!1,increment:1});this.pane=t,t.mainExtent.yAxis.setAxisType("regular");const{scale:e}=t,s=Zi(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);e.autoScaleModel.setHighLowProvider("volumes",s),e.doAutoScale(!0)}}deactiveSeparateVolumes(){this.paneManager.removePane(Cn.UUID),delete this.pane,this.drawingManager.removeDrawerByName("UNDERLAY_VOLUMES_AREA")}fromY(n){var t,e;return(e=(t=this.pane)==null?void 0:t.scale.fromY(n))!=null?e:0}};let aa=Cn;aa.UUID="volumes";const yn=.3,pu=(n,t)=>{const e=t.barTheme[`${n}Color`];return Gt()(e).alpha(yn).toString()},bu=(n,t)=>{const e=t.volume[`${n}BarColor`];return Gt()(e).alpha(yn).toString()},Cu=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Gt()(e).alpha(yn).toString()},ms=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Gt()(e).alpha(yn).toString()},yu=3;class wu{constructor(t,e,s,r,i,a){this.config=t,this.volumesModel=e,this.chartModel=s,this.getViewportModel=r,this.volumesColorByChartTypeMap=i,this.drawPredicate=a,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const s=(e=this.volumesColorByChartTypeMap[t])!=null?e:bu;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();xe(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=Lt(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1)),r=this.getViewportModel();s.forEach((i,a)=>{if(i.candle.volume){const o=r.getBounds(),l=o.height,c=s[a+1]!==void 0?st(r.toX(s[a+1].startUnit)):void 0,h=st(r.toX(i.startUnit)),g=c!==void 0?c-h:st(Mt(i.width,r.zoomX));if(this.config.components.volumes.showSeparately){const p=st(r.toY(i.candle.volume)),b=st(r.toY(0))-p;this.drawVolume(t,i,h,p,g,b)}else{const p=e/(l/yu),b=Math.max(Mt(i.candle.volume,p),2),E=st(o.y+l-b);this.drawVolume(t,i,h,E,g,b)}}})}drawVolume(t,e,s,r,i,a){const o=t.ctx,l=r,c=r+a,h=e.name;o.fillStyle=this.volumeBarColors[h],o.strokeStyle=this.volumeBarColors[h],i===0?(o.beginPath(),o.moveTo(s,l),o.lineTo(s,Mr(c)),o.stroke()):o.fillRect(s,r,i,Mr(a))}}const Su=Lo(n=>n.candle.volume),oa="volumes";class xu extends tt{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=oa,this.volumeMax=new $t(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(Ot(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=ke(Su(this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport().flat())))!=null?t:0)}}class Pu extends tt{constructor(t,e,s,r,i,a,o,l){super(),this.canvasModel=t,this.canvasBoundsContainer=r,this.config=a,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new $t(!1),this.volumeIsSeparateModeChangedSubject=new $t(!1);const c=new xu(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new aa(e,i,a,c,o),this.volumesDrawer=new wu(a,this.volumesModel,e.chartModel,()=>{var h,g;return this.config.components.volumes.showSeparately&&(g=(h=this.separateVolumes.pane)==null?void 0:h.scale)!=null?g:s},this.volumesColorByChartTypeMap,()=>!0),a.components.volumes.visible&&this.addVolumesToDynamicObjects(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(a.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(a.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",ms),this.registerVolumeColorResolver("trend",ms),this.registerVolumeColorResolver("hollow",ms),this.registerVolumeColorResolver("line",Cu),this.registerVolumeColorResolver("bar",pu)}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))}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),t?this.addVolumesToDynamicObjects():this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.canvasModel.fireDraw()}addVolumesToDynamicObjects(){this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1&&this.dynamicObjectsComponent.model.addObject({id:this.volumesModel.id,paneId:this.config.components.volumes.showSeparately?oa:ht,drawer:this.volumesDrawer,model:this.volumesModel})}}class Tu{constructor(t,e,s,r,i){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=r,this.watermarkDataProvider=i,this.getConfig=(a=0,o,l,c,h,g)=>{const p=this.canvasModel.ctx,b=this.canvasBoundsContainer.getBounds(Y.PANE_UUID(ht)),{position:E,offsetY:O,offsetX:N}=this.config.components.waterMark;let k;switch(g?k=g:(p.font=wn(this.config,l),k=p.measureText(o).width,b.width-10<k&&(p.font=Mu(this.config,this.canvasBoundsContainer,l,k),k=p.measureText(o).width)),E){case"left-top":return{x:N+b.x,y:O+a+b.y,font:p.font,text:o,color:c};case"left-bottom":return{x:N+b.x,y:b.height-h-O+a+b.y,font:p.font,text:o,color:c};case"center":return{x:b.width/2-k/2+b.x,y:(b.height-h)/2+a+b.y,font:p.font,text:o,color:c}}}}draw(){var t,e,s,r,i,a,o;if((t=this.config.components.waterMark)!=null&&t.visible&&this.config.colors){const{firstRow:l,secondRow:c,thirdRow:h}=this.watermarkDataProvider(),g=this.waterMarkConfigProvider(),p=this.config.colors.waterMarkTheme,b=this.canvasModel.ctx;let E=0,O=0,N=0,k=0,V=0;if(b.save(),g.firstRowFontSize&&l){b.font=wn(this.config,g.firstRowFontSize);const U=b.measureText(l);E=U.actualBoundingBoxAscent+U.actualBoundingBoxDescent}if(g.secondRowFontSize&&c){b.font=wn(this.config,g.secondRowFontSize);const U=b.measureText(c);O=U.actualBoundingBoxAscent+U.actualBoundingBoxDescent,N=(e=g.firstRowBottomPadding)!=null?e:0}if(g.thirdRowFontSize&&h){b.font=wn(this.config,g.thirdRowFontSize);const U=b.measureText(h);k=U.actualBoundingBoxAscent+U.actualBoundingBoxDescent,V=(s=g.secondRowBottomPadding)!=null?s:0}const Z=(r=g.thirdRowBottomPadding)!=null?r:0,J=(i=g.logoHeight)!=null?i:0,K=E+O+N+k+V+Z+J;if(l&&this.drawWaterMark(this.getConfig(E,l,g.firstRowFontSize,p.firstRowColor,K)),c&&this.drawWaterMark(this.getConfig(E+N+O,c,g.secondRowFontSize,p.secondRowColor,K)),h&&this.drawWaterMark(this.getConfig(E+N+O+V+k,h,g.thirdRowFontSize,p.thirdRowColor,K)),this.logoImage){const U=this.getConfig(E+N+O+V+k+Z,"",g.thirdRowFontSize,p.thirdRowColor,K,g.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,U.x,U.y,(a=g.logoWidth)!=null?a:0,(o=g.logoHeight)!=null?o:0)}b.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 r=t.x,i=t.y;s.fillText(e,r,i)}reset(){}}const Mu=(n,t,e,s)=>{const i=((o,l)=>t.getBounds(Y.CHART).width/l*o)(e,s);let a;return n.components&&n.components.waterMark&&(a=n.components.waterMark.fontFamily),i+"px "+a},wn=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var _u=Object.defineProperty,la=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Au=Object.prototype.propertyIsEnumerable,ca=(n,t,e)=>t in n?_u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ha=(n,t)=>{for(var e in t||(t={}))Du.call(t,e)&&ca(n,e,t[e]);if(la)for(var e of la(t))Au.call(t,e)&&ca(n,e,t[e]);return n};class Eu extends tt{constructor(t,e,s,r,i,a,o){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=r,this.canvasModel=a,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Tu(this.config,i,a,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(Kt(i.observeBoundsChanged(Y.PANE_UUID(ht)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),o.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={};Kt(e,t),Kt(e,this.config.components.waterMark),this.config.components.waterMark=e}this.canvasModel.fireDraw()}}setLogoImage(t){this.waterMarkDrawer.setLogoImage(t)}recalculateTextSize(t,e){const i=g=>.15*Math.log(g)/Math.log(1.5)+1,a=i(t/1920),o=i(e/1080),l=Math.min(a,o),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 ha(ha({},this.config.components.waterMark),h)}}const da={x:4,y:4};function Iu(n,t,e,s,r){var i,a;const o=(i=r.alignType)!=null?i:"middle",{fontSize:l,fontFamily:c,padding:h}=s.components.xAxis,g=(a=h.top)!=null?a:0,p=e.getBounds(Y.X_AXIS);t.save(),t.font=`bold ${l}px ${c}`;const E=t.measureText(r.text).width+da.x*2;let O=0;const N=r.x;switch(o){case"start":O=N-E;break;case"end":O=N;break;case"middle":default:O=N-E/2;break}cn(n,t,O,p.y,E,p.height-1),o!=="middle"&&(t.strokeStyle=r.color,t.beginPath(),t.moveTo(N,p.y),t.lineTo(N,p.y+p.height),t.stroke()),t.fillStyle=r.color;const k=O+da.x,V=p.y+g+l;t.fillText(r.text,k,V),t.restore()}class Ou{constructor(t,e,s,r,i){this.backgroundCanvasModel=t,this.config=e,this.canvasModel=s,this.canvasBoundsContainer=r,this.xAxisLabelsModel=i}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{Iu(this.backgroundCanvasModel.ctx,t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},s=this.xAxisLabelsModel.labels.reduce((r,i)=>{if(i.subGroupId!==void 0){let a=r[i.subGroupId];a||(a=[],r[i.subGroupId]=a),a.push(i)}return r},e);Object.keys(s).forEach(r=>{const i=s[r];if(i.length===2){const a=this.canvasBoundsContainer.getBounds(Y.X_AXIS);t.fillStyle=Gt().rgb(i[0].color).alpha(.1).toString(),ai(t,{x:i[0].x,y:a.y},{x:i[1].x,y:a.y+a.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const zg="week-weekday",Lu=["second","minute","hour","day","month","year"],Bu=["lessThanSecond"],Ru=n=>Lu.some(t=>t===n),Fu=n=>n==="week-weekday",Yu=n=>Bu.some(t=>t===n),ua=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},ps=n=>parseInt(n,10),fa=n=>{const[t,...e]=n.split("_");if(Ru(t)){const[s]=e,r=ua(s),i=ps(s);return{key:t,value:i,exact:r["!"]}}else if(Fu(t)){const[s,r]=e,i=ua(s),a=ps(s),o=ps(r);return{key:t,week:i.$?"$":a,weekday:o}}else return Yu(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats https://webdev.prosp.devexperts.com:8095/docs/chart/x-axis`),null)};class Sn{constructor(t,e,s,r,i,a=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=s,this.canvasBoundsContainer=r,this.labelsProvider=i,this.drawPredicate=a}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,s=this.config.colors.xAxis,r=this.config.components.xAxis.fontFamily,i=Sn.getFontFromConfig(this.config),a=this.config.components.xAxis.fontSize,o=(t=this.config.components.xAxis.padding.top)!=null?t:0;e.save(),e.font=i,e.fillStyle=s.backgroundColor;const l=this.canvasBoundsContainer.getBounds(Y.X_AXIS);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,a,r,o),e.restore()}}drawLabels(t,e,s,r,i,a,o){const l=`${i}px ${a}`;t.fillStyle=r;for(const c of e){const h=this.viewportModel.toX(c.value)-Nt(c.text,t,l)/2;if(h<0||h>s.width)continue;const g=s.y+i-1+o,p=c.text;t.font=l,t.fillText(p,h,g)}}static getFontFromConfig(t){return`${t.components.xAxis.fontStyle} ${t.components.xAxis.fontSize}px ${t.components.xAxis.fontFamily}`}getCanvasIds(){return[this.canvasModel.canvasId]}}const bs={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},ga=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return bs[n.key]+n.value;case"lessThanSecond":return bs[n.key];case"week-weekday":return bs[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},va=n=>{const t={};return n.forEach(e=>{const s=t[e.weight];s===void 0?t[e.weight]=[e]:s.push(e)}),t},Nu=(n,t)=>{const e=Object.keys(n).map(r=>parseInt(r,10)).sort((r,i)=>i-r);let s=[];for(const r of e){const i=n[r];if(!i)continue;const a=[...s];s=[];const o=a.length,l=i.length;let c=0,h=1/0,g=-1/0;for(let p=0;p<l;p++){const b=i[p],E=b.idx;for(;c<o;){const O=a[c],N=O.idx;if(E>N)c++,s.push(O),g=N,h=1/0;else{h=N;break}}h-E>=t&&E-g>=t&&(s.push(b),g=E)}for(;c<o;)s.push(a[c]),c++}return s},Hu=(n,t,e,s,r,i)=>{const a=Sn.getFontFromConfig(t),o=Nt(e.text,n,a),l=Nt(s.text,n,a),c=r.toX(e.value)+o/2;return r.toX(s.value)-l/2-c<i};function Cs(n){"@babel/helpers - typeof";return Cs=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},Cs(n)}function Bt(n,t){if(t.length<n)throw new TypeError(n+" argument"+(n>1?"s":"")+" required, but only "+t.length+" present")}function Rt(n){Bt(1,arguments);var t=Object.prototype.toString.call(n);return n instanceof Date||Cs(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 ku(n){return Bt(1,arguments),Rt(n).getDay()===1}function ju(n){return Bt(1,arguments),Rt(n).getDay()===2}function Uu(n){return Bt(1,arguments),Rt(n).getDay()===3}function Wu(n){return Bt(1,arguments),Rt(n).getDay()===4}function Xu(n){return Bt(1,arguments),Rt(n).getDay()===5}function zu(n){return Bt(1,arguments),Rt(n).getDay()===6}function Vu(n){return Bt(1,arguments),Rt(n).getDay()===0}function Gu(n,t){var e;Bt(1,arguments);var s=n||{},r=Rt(s.start),i=Rt(s.end),a=i.getTime();if(!(r.getTime()<=a))throw new RangeError("Invalid interval");var o=[],l=r;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()<=a;)o.push(Rt(l)),l.setDate(l.getDate()+c),l.setHours(0,0,0,0);return o}function $u(n){Bt(1,arguments);var t=Rt(n);return t.setDate(1),t.setHours(0,0,0,0),t}function Zu(n){Bt(1,arguments);var t=Rt(n),e=t.getMonth();return t.setFullYear(t.getFullYear(),e+1,0),t.setHours(23,59,59,999),t}function ma(n){Bt(1,arguments);var t=Rt(n);return t.setHours(0,0,0,0),t}function pa(n,t){Bt(2,arguments);var e=ma(n),s=ma(t);return e.getTime()===s.getTime()}const Ku=n=>{switch(n.key){case"lessThanSecond":return tf(n);case"month":return ef(n);case"second":case"minute":case"hour":case"day":case"year":return nf(n);case"week-weekday":return sf(n);default:return()=>!1}},me=(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()}},ys=n=>(t,e)=>{const s=me(t,n),r=me(e,n);return s!==r},Ju=n=>(t,e)=>{const s=me(t,n),r=me(e,n);return s>=r},qu={1:ku,2:ju,3:Uu,4:Wu,5:Xu,6:zu,7:Vu},Qu=(n,t,e)=>{var s;const r=Gu({start:$u(n),end:Zu(n)}),i=(s=qu[e])!=null?s:()=>!1;if(t==="$"){for(const a of r.reverse())if(i(a))return pa(n,a)}else{let a=1;for(const o of r)if(i(o)){if(a===t)return pa(n,o);a++}}return!1},ba=(n,t)=>t===1?n===1:n/t===1,Ca=(n,t)=>t===1?!0:n%t===0,tf=n=>(t,e)=>Ju(n.key)(t,e),ef=n=>(t,e)=>{const s=ys(n.key)(t,e),r=n.exact?ba(me(t,n.key)+1,n.value):Ca(me(t,n.key)+1,n.value);return s&&r},nf=n=>(t,e)=>{const s=ys(n.key)(t,e),r=n.exact?ba(me(t,n.key),n.value):Ca(me(t,n.key),n.value);return s&&r},sf=n=>(t,e)=>{const s=ys(n.key)(t,e),r=Qu(t,n.week,n.weekday);return s&&r},rf=n=>{switch(n.key){case"second":case"minute":return af(n.value);case"hour":return of(n.value);case"day":return lf(n.value);case"month":return df(n.value);case"year":return uf(n.value);case"week-weekday":const t=hf(n.week),e=cf(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},af=n=>n>0&&n<=60,of=n=>n>0&&n<=24,lf=n=>n>0&&n<=31,cf=n=>ya(n)?n>=1&&n<=7:!1,hf=n=>n==="$"?!0:ya(n)?n>=1&&n<=6:!1,df=n=>n>0&&n<=12,uf=n=>n>0,ya=n=>!isNaN(n)&&isFinite(n),ff=(n,t,e,s)=>{var r,i;const a=s(n.getTime()),o=s(t.getTime());for(const[l,c]of e)if(c(a,o))return l;return(i=(r=e[e.length-1])==null?void 0:r[0])!=null?i:0};function ws(n,t,e){const s=new Array(n.length);let r=new Date(0);for(let i=0;i<n.length;i++){const a=n[i],o=new Date(a.candle.timestamp),l={weight:ff(o,r,t,e)};s[i]=l,r=o}return s}const wa=n=>{const t={},e={};return Kn(n).forEach(([s,r])=>{const i=fa(s),a=i===null?!1:rf(i);if(i&&a){const o=ga(i);t[o]=r,e[o]=Ku(i)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class Sa{constructor(t,e,s,r,i,a){this.eventBus=t,this.config=e,this.chartModel=s,this.scale=r,this.timeZoneModel=i,this.canvasModel=a,this.labelsGroupedByWeight={},this.levelsCache={},this.weightToTimeFormatMatcherArray=[],this.weightToTimeFormatsDict={},this.extendedLabelsFilterConfig={minute_1:c=>c>=2},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:o,weightToTimeFormatMatcherDict:l}=wa(this.formatsByWeightMap);this.weightToTimeFormatMatcherArray=Object.entries(l).map(([c,h])=>[parseInt(c,10),h]).sort(([c],[h])=>h-c),this.weightToTimeFormatsDict=o}get labels(){return this.getLabelsFromChartType()}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}getAllCandlesWithFake(){const t=this.chartModel.mainCandleSeries.visualPoints;if(t.length===0)return[];const s=Array.from({length:750}).map((r,i)=>Hr(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,t.length+i,this.chartModel.getPeriod()));return[...t,...s]}mapWeightedPointsToLabels(t,e){const s=new Array(t.length);return t.forEach((r,i)=>{var a;const o=e[i],l=this.weightToTimeFormatsDict[r.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(o.candle.timestamp);s[i]={weight:r.weight,idx:(a=o.candle.idx)!=null?a:0,value:o.centerUnit,time:o.candle.timestamp,text:c}}),s}setFormatsForLabelsConfig(t){const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=wa(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(s).map(([r,i])=>[parseInt(r,10),i]).sort(([r],[i])=>i-r),this.weightToTimeFormatsDict=e,this.generateWeightedLabels()}generateWeightedLabels(){const t=this.getAllCandlesWithFake(),e=ws(t,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),s=this.mapWeightedPointsToLabels(e,t);this.labelsGroupedByWeight=va(s),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}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 r=ws([e,t],this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels([r[1]],[t]),[a]=i;this.labelsGroupedByWeight=Object.entries(this.labelsGroupedByWeight).reduce((o,[l,c])=>{const h=c.findIndex(p=>p.idx===a.idx);let g=c;if(h!==-1&&(g=c.filter(p=>p.idx!==a.idx)),parseInt(l,10)===a.weight){const p=g.findIndex(b=>b.idx>a.idx);p!==-1?g=[...g.slice(0,p),a,...g.slice(p)]:g.push(a)}return o[l]=g,o},{}),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}}updateHistoryLabels(t){const e=t.concat(this.chartModel.mainCandleSeries.visualPoints[t.length]),s=ws(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),r=this.mapWeightedPointsToLabels(s,e),i=va(r),a=We(i);for(const c in this.labelsGroupedByWeight)a[c]===void 0&&(a[c]=this.labelsGroupedByWeight[c]);const o=this.chartModel.mainCandleSeries.visualPoints[t.length-1],l=Object.entries(a).sort(([c],[h])=>parseInt(h,10)-parseInt(c,10)).reduce((c,[h,g])=>{const p=parseInt(h,10),b=this.labelsGroupedByWeight[p];if(p===this.weightToTimeFormatMatcherArray[0][0]&&b.shift(),b){const E=b.map(O=>(O.idx=O.idx+t.length,O.value=o.startUnit+o.width+O.value,O));i[p]?c[h]=g.concat(E):c[h]=E}else c[h]=g;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(){this.generateWeightedLabels()}recalculateLabels(){this.recalculateCachedLabels()}recalculateCachedLabels(){if(Object.getOwnPropertyNames(this.labelsGroupedByWeight).length===0)return;const t=this.config.components.xAxis.fontSize,e=Object.values(this.formatsByWeightMap).reduce((a,o)=>Math.max(o.length,a),1),s=t*e,r=Mt(this.chartModel.mainCandleSeries.meanCandleWidth,this.scale.zoomX),i=Math.round(s/r);if(!(i<0&&!isFinite(r))&&(this.weightedCache===void 0||i!==this.weightedCache.coverUpLevel)){const a=this.getLabelsFromCache(i);if(a){this.weightedCache={labels:a,coverUpLevel:i};return}const o=Nu(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,i),i);this.levelsCache[i]=o,this.weightedCache={labels:o,coverUpLevel:i},this.eventBus.fireDraw()}}postProcessing(t){var e,s;const r=[];let i=0,a=1;for(;a<=t.length-1;){const o=t[i],l=t[a];Hu(this.canvasModel.ctx,this.config,o,l,this.scale,30)?((e=l.weight)!=null?e:0)>((s=o.weight)!=null?s:0)&&(i=a):(r.push(o),i=a,a===t.length-1&&r.push(l)),a++}return r}filterLabelsByExtendedRules(t,e){const s=Kn(this.extendedLabelsFilterConfig).reduce((r,i)=>{if(!i)return r;const[a,o]=i;if(o){const l=fa(a);if(l){const c=ga(l);r[c]=o}}return r},{});return Kn(t).reduce((r,[i,a])=>(s[i]&&s[i](e)||(r[i]=a),r),{})}}class gf extends tt{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(dn,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}class vf extends tt{constructor(t,e,s,r,i){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=r,this.chartModel=i,this.lastXStart=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const o=this.canvasBoundsContainer.getBounds(Y.X_AXIS);this.lastXPxWidth=o.width-this.canvasInputListener.currentPoint.x},this.onXDragTick=o=>{const{delta:l}=o,c=this.lastXPxWidth-l;if(c<0)return;const h=this.lastXPxWidth/c,g=this.lastXWidth*h,p=this.lastXStart+(this.lastXWidth-g);this.scale.setXScale(p,this.scale.xEnd)};const a=new Ze(this.canvasBoundsContainer.getBoundsHitTest(Y.X_AXIS),{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});this.addChildEntity(a)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.canvasBoundsContainer.getBoundsHitTest(Y.X_AXIS)).subscribe(()=>this.chartModel.doBasicScale())),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class mf extends tt{constructor(t,e,s,r,i,a,o,l,c,h,g,p,b){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.chartComponent=r,this.scale=i,this.chartResizeHandler=l,this.timeZoneModel=h;const E=new Sa(t,e,r.chartModel,i,h,this.canvasModel);this.xAxisLabelsGenerator=E,this.xAxisLabelsModel=new gf(t,[]);const O=new ls;c.addDrawer(O,"X_AXIS"),this.xAxisDrawer=new Sn(e,s,i,a,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),O.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Ou(b,e,s,a,this.xAxisLabelsModel),O.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new vf(i,o,a,g,this.chartComponent.chartModel),this.addChildEntity(this.xAxisScaleHandler),p.setCursorForCanvasEl(Y.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(Ot(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe(lt(({prependedCandles:t})=>t.length!==0),yt(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{Xo.includes(this.config.components.chart.type)&&this.xAxisLabelsGenerator.updateHistoryLabels&&this.xAxisLabelsGenerator.updateHistoryLabels(t)})),this.addRxSubscription(Ot(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(je(50,void 0,{trailing:!0,leading:!0})).subscribe(()=>{this.xAxisLabelsGenerator.recalculateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(yt(()=>Yt(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),Zt((t,e)=>{var s,r;return((s=t==null?void 0:t.candle)==null?void 0:s.timestamp)===((r=e==null?void 0:e.candle)==null?void 0:r.timestamp)}),lt(Zs)).subscribe(t=>{this.xAxisLabelsGenerator.updateLastLabel&&this.xAxisLabelsGenerator.updateLastLabel(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 Sa?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 pf=Object.defineProperty,xa=Object.getOwnPropertySymbols,bf=Object.prototype.hasOwnProperty,Cf=Object.prototype.propertyIsEnumerable,Pa=(n,t,e)=>t in n?pf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,xn=(n,t)=>{for(var e in t||(t={}))bf.call(t,e)&&Pa(n,e,t[e]);if(xa)for(var e of xa(t))Cf.call(t,e)&&Pa(n,e,t[e]);return n};class yf{constructor(t,e,s,r,i){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=r,this.resolveLabelColorFn=i}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),r=s&&xn(xn({},s),this.getLabelDrawConfig(this.chartModel.mainCandleSeries,!0));if(r){const i={labels:[r]},a=this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];a==null||a(i,this.chartModel.mainCandleSeries),t.push(i)}return this.chartModel.candleSeries.forEach((i,a)=>{if(a===0)return;const o=this.getYAxisVisualLabel(i),l=o&&xn(xn({},o),this.getLabelDrawConfig(i,!1));if(l){const c={labels:[l]},h=this.lastCandleLabelsByChartType[i.config.type];h==null||h(c,this.chartModel.mainCandleSeries),t.push(c)}}),t}getYAxisVisualLabel(t){const e=Yt(t.dataPoints);if(e){const s=t.view.toY(e.close);if(isFinite(s)){const r=this.yAxisConfig.labels.settings.lastPrice.mode,i=this.yAxisConfig.labels.settings.lastPrice.type;return{y:s,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,t),mode:r,labelType:i,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const s=this.yAxisConfig.labels.settings.lastPrice.type,r=t.colors.labels,{rectLabelTextColor:i="white",rectLabelInvertedTextColor:a="black"}=this.chartConfig.colors.yAxis,o=this.resolveLabelColorFn(t.config.type);if(!r)return{bgColor:"#FFFFFF",textColor:fe("#FFFFFF","#000000",a),rounded:!0};const l=o(t.lastPriceMovement,t.colors);if(e){const c=jd(t.lastPriceMovement,r);return{bgColor:l,textColor:s==="plain"?qi(this.chartConfig.colors,c,a,this.yAxisConfig):fe(l,c,a),rounded:!0}}return{bgColor:l,textColor:s==="plain"?qi(this.chartConfig.colors,i,a,this.yAxisConfig):fe(l,i,a),rounded:!0}}}class wf{constructor(t,e,s,r,i){this.yAxisLabelsCanvasModel=t,this.backgroundCanvasModel=e,this.canvasBoundsContainer=s,this.fullConfig=r,this.paneManager=i}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx;this.paneManager.yExtents.forEach(s=>{if(s.yAxis.state.visible){const r=s.getYAxisBounds(),i=this.canvasBoundsContainer.getBounds(Y.ALL_PANES),a=s.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(o=>{var l;const c=(l=o.bounds)!=null?l:r;o.labels.forEach(h=>Ei(t,e,c,i,h,this.canvasBoundsContainer,s.yAxis.state,this.fullConfig.colors.yAxis))}),Object.values(s.yAxis.model.fancyLabelsModel.customLabels).forEach(o=>Ei(t,e,r,i,o,this.canvasBoundsContainer,s.yAxis.state,this.fullConfig.colors.yAxis))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(r=>{r.labels.forEach(i=>{var a,o,l;if(i.subGroupId){const c=(a=s[i.subGroupId])!=null?a:[];if(s[i.subGroupId]=c,c.push(i),c.length===2){const h=(o=r.bounds)!=null?o:this.canvasBoundsContainer.getBounds(Y.PANE_UUID_Y_AXIS(ht));e.save(),e.fillStyle=(l=c[0].highlightColor)!=null?l:c[0].bgColor;const[g,p]=c[0].y>c[1].y?[c[1].y,c[0].y]:[c[0].y,c[1].y];ai(e,{x:h.x,y:br(g,h)},{x:h.x+h.width-6,y:br(p,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Sf{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,r=e.getBounds(),i=this.canvasModel.ctx;i.fillStyle=this.getBackgroundColor(),i.fillRect(r.x,r.y,r.width,r.height);const a=ye(e.state),o=ne(a,i),l=this.getLabelTextColor();i.save(),xe(i,r),this.drawLabels(i,s,r,o,a,l,e),i.restore()}})}drawLabels(t,e,s,r,i,a,o){t.fillStyle=a,t.font=i;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=s.y+c,g=s.y+s.height-c;e.forEach(p=>{const b=o.scale.toY(p.value);b>h&&b<g&&xf(t,s,p.text,b,r,i,o.state.labelBoxMargin.end,o.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const xf=(n,t,e,s,r,i,a,o)=>{const l=o==="right"?t.x+t.width-Nt(e,n,i)-a:t.x+a;n.fillText(e,l,s+r/2-1)};class Pf{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&Io.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 X,s=e.next.bind(e),r=e.unsubscribe.bind(e);return this.on(t,s),e.unsubscribe=()=>{this.unsub(t,s),r()},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 r=(s=this.handlers[t])!=null?s:[];let i;for(i=0,r.length;i<r.length;i++)r[i].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(dn,t)}}class Tf extends tt{constructor(t,e,s,r){super(),s.observeTouchStart().pipe(yt(i=>r.components.chart.highlightActiveCandle?i:void 0),Zt()).subscribe(i=>{i&&this.setCandleAsActive(i,t,e)})}setCandleAsActive(t,e,s){if(t.touches.length===1){const r=t.touches.item(0);if(r!==null){const i=this.getTouchXPosition(r,e),a=s.candleFromX(i);a&&s.mainCandleSeries.setActiveCandle(a)}}}getTouchXPosition(t,e){const s=e.getBoundingClientRect(),r=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-s.left-r}}class Mf{constructor(t,e,s,r,i){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=r,this.config=i,this.previousBCR=void 0,this.animFrameId=`resize_${Ft()}`,this.canvasResized=new X,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){is(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(ts,e),this.bus.fire(dn))}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 _f=Array.isArray,Df=Object.getPrototypeOf,Af=Object.prototype,Ef=Object.keys;function If(n){if(n.length===1){var t=n[0];if(_f(t))return{args:t,keys:null};if(Of(t)){var e=Ef(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function Of(n){return n&&typeof n=="object"&&Df(n)===Af}var Lf=Array.isArray;function Bf(n,t){return Lf(t)?n.apply(void 0,x([],C(t))):n(t)}function Rf(n){return yt(function(t){return Bf(n,t)})}function Ff(n,t){return n.reduce(function(e,s,r){return e[s]=t[r],e},{})}function Yf(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Je(n),s=Ja(n),r=If(n),i=r.args,a=r.keys;if(i.length===0)return qe([],e);var o=new Tt(Nf(i,e,a?function(l){return Ff(a,l)}:_e));return s?o.pipe(Rf(s)):o}function Nf(n,t,e){return e===void 0&&(e=_e),function(s){Ta(t,function(){for(var r=n.length,i=new Array(r),a=r,o=r,l=function(h){Ta(t,function(){var g=qe(n[h],t),p=!1;g.subscribe(Xt(s,function(b){i[h]=b,p||(p=!0,o--),o||s.next(e(i.slice()))},function(){--a||s.complete()}))},s)},c=0;c<r;c++)l(c)},s)}}function Ta(n,t,e){n?ee(e,n,t):t()}class Hf extends tt{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new $t(null)}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const r=e.map(a=>this.canvasBoundsContainer.getBoundsHitTest(a,s)),i=(a,o)=>r.some(l=>l(a,o));return this.subscribeMouseOverHT(t,i)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),r=this.canvasInputListener.observeMouseEnter(e);let i=!1;const a=Yf([s,r]).pipe(lt(([,o])=>!i||i&&o)).subscribe(([o,l])=>{if(l){const c=[o.x,o.y,t];this.crossSubject.next(c),i=!1}else this.crossSubject.next(null),i=!0});return this.panesSubscriptions[t]=a,()=>a.unsubscribe()}}class kf{constructor(t,e,s,r){this.visualCandle=t,this.price=e,this.priceFormatter=s,this.toY=r}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 jf{constructor(t){this.chartModel=t}getData(t){const{x:e,y:s}=t,i=this.chartModel.candleFromX(e).idx||0,a=this.chartModel.getVisualCandle(i),o=this.chartModel.priceFromY(s);return a&&new kf(a,o,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class Uf{constructor(t){this.chartModel=t}getData(t){const{x:e}=t,r=this.chartModel.candleFromX(e).idx||0;return this.chartModel.candleSeries.map(a=>{const o=a.dataPoints[r],l=this.chartModel.pane.regularFormatter(o==null?void 0:o.close);return{instrument:a.instrument.symbol,price:l,id:a.id,htId:a.htId}})}}var Wf=Object.defineProperty,Xf=Object.defineProperties,zf=Object.getOwnPropertyDescriptors,Ma=Object.getOwnPropertySymbols,Vf=Object.prototype.hasOwnProperty,Gf=Object.prototype.propertyIsEnumerable,_a=(n,t,e)=>t in n?Wf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ke=(n,t)=>{for(var e in t||(t={}))Vf.call(t,e)&&_a(n,e,t[e]);if(Ma)for(var e of Ma(t))Gf.call(t,e)&&_a(n,e,t[e]);return n},Ss=(n,t)=>Xf(n,zf(t));class $f extends tt{constructor(t,e,s,r,i,a,o,l,c){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=r,this.canvasInputListener=i,this.canvasBoundsContainer=a,this.paneManager=o,this.timeZoneModel=l,this.formatterFactory=c,this.hoverSubject=new $t(null),this.longTouchActivatedSubject=new $t(!1),this.xFormatter=()=>"";const h=new jf(this.chartModel),g=new Uf(this.chartModel);this.hoverProducerParts={candleHover:h,compareSeriesHover:g}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.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(this.canvasInputListener.observeTouchStart().subscribe(e=>{const s=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,r=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.chartModel.candleFromX(s,!0)&&this.createAndFireHover([s,r,""])}));const t=this.canvasBoundsContainer.getBoundsHitTest(Y.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{this.paneManager.chartPanComponent.deactivatePanHandlers(),this.longTouchActivatedSubject.next(!0);const s=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,r=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.createAndFireHover([s,r,""]),this.crossEventProducer.crossSubject.next([s,r,""])})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(()=>{this.paneManager.chartPanComponent.activateChartPanHandlers(),this.longTouchActivatedSubject.getValue()&&(this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose())})),this.addRxSubscription(Ot(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter()))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=Oi(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,ht)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const i=this.chartModel.candleFromX(t,!0).timestamp,a={x:t,y:e,timestamp:i,timeFormatted:this.xFormatter(i),paneId:s},o=Object.entries(this.hoverProducerParts).reduce((l,c)=>Ss(Ke({},l),{[c[0]]:c[1].getData(a)}),{});return Ke(Ke({},a),o)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){const e=this.createHoverFromCandle(t);if(this.hover&&e){const s=Ss(Ke({},e),{x:this.hover.x,y:this.hover.y});this.fireHover(s)}}createAndFireHover([t,e,s]){const r=this.createHover(t,e,s);this.fireHover(r)}fireHover(t){var e;if(t){if(kn()&&this.config.components.crossTool.type!=="none"){const s=(e=t.candleHover)==null?void 0:e.visualCandle.candle;s&&this.chartModel.mainCandleSeries.setActiveCandle(s)}this.hoverSubject.next(t)}else this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}registerHoverProducerPart(t,e){this.hoverProducerParts=Ss(Ke({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const Da={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 Le(n){return t=>{t.button===Da.left&&n(t)}}var Zf=Object.defineProperty,Aa=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,Jf=Object.prototype.propertyIsEnumerable,Ea=(n,t,e)=>t in n?Zf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,qf=(n,t)=>{for(var e in t||(t={}))Kf.call(t,e)&&Ea(n,e,t[e]);if(Aa)for(var e of Aa(t))Jf.call(t,e)&&Ea(n,e,t[e]);return n};const Pe=class extends tt{constructor(n,t){super(),this.eventBus=n,this.element=t,this.xDragStartSubject=new X,this.xDragSubject=new X,this.xDragTickSubject=new X,this.xDragEndSubject=new X,this.yDragStartSubject=new X,this.yDragSubject=new X,this.yDragTickSubject=new X,this.yDragEndSubject=new X,this.mouseMoveSubject=new X,this.mouseMoveDocumentSubject=new X,this.clickSubject=new X,this.clickDocumentSubject=new X,this.dbClickSubject=new X,this.dbTapSubject=new X,this.mouseDownSubject=new X,this.mouseUpSubject=new X,this.mouseUpDocumentSubject=new X,this.wheelSubject=new X,this.touchStartSubject=new X,this.touchStartTimestamp=0,this.touchMoveSubject=new X,this.touchEndSubject=new X,this.touchCancelSubject=new X,this.longTouchStartSubject=new X,this.longTouchEndSubject=new X,this.contextMenuSubject=new X,this.pinchSubject=new X,this.scrollGestureSubject=new X,this.fastTouchScroll=new X,this.mouseLeavesCanvasSubject=new X,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=e=>{this.isDraggable(e)&&(this.updateCurrentPoints(e),this.dragging=!0,this.dragStartEvent=e,this.documentDragListeners.forEach(s=>s()),this.dragStartPoint=Pe.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=qf({},this.dragStartPoint),Pe.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.dragProcessListener,!0);const r=document.removeEventListener.bind(document,s,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(e=>e()),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=e=>{this.updateCurrentDocumentPoint(e),this.updateCurrentMousePoint(e)}}isDraggable(n){return n instanceof MouseEvent?n.button===Da.left:n instanceof TouchEvent}startDragging(n){this.updateCurrentPoints(n),this.dragStartListener(n)}movePointer(n){this.updateCurrentPoints(n),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const n=t=>(t.preventDefault(),!1);this.element.addEventListener("selectstart",n,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",n,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],Pe.DRAG_START_EVENTS.forEach(e=>{this.element.addEventListener(e,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(e,this.dragStartListener))}),this.trackMousePosition(),Pe.DRAG_EVENTS.forEach(e=>{document.addEventListener(e,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,e,this.dragListener)),this.element.addEventListener(e,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,e,this.updateElementOffsetListener))}),Pe.DRAG_END_EVENTS.forEach(e=>{document.addEventListener(e,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,e,this.dragEndListener))}),this.addSubscription(Pt(this.element,Le(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(Pt(document,Le(e=>this.clickDocumentSubject.next(e)),"click"));const n=Xi();if(n==="apple"||n==="mobile"){let e=null;const s=a=>{a.preventDefault(),e?(this.dbTapSubject.next(this.currentPoint),clearTimeout(e),e=null):e=window.setTimeout(()=>{e=null},250)};this.addSubscription(Pt(this.element,s,"touchend"));const r=(a,o=700,l=3)=>{a.preventDefault();const c={x:a.touches[0].clientX,y:a.touches[0].clientY};let h={x:0,y:0},g=!1,p=null;p=setTimeout(()=>{g=!0,this.longTouchStartSubject.next(a)},o);const b=O=>{O.preventDefault(),h={x:O.touches[0].clientX,y:O.touches[0].clientY},(Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2))>l||O.touches.length>1)&&p&&clearTimeout(p)},E=O=>{O.preventDefault(),p&&clearTimeout(p),g&&(g=!1,this.longTouchEndSubject.next(O)),this.element.removeEventListener("touchend",E),this.element.removeEventListener("touchmove",b)};this.element.addEventListener("touchmove",b),this.element.addEventListener("touchend",E)};this.addSubscription(Pt(this.element,a=>r(a),"touchstart"));const i=a=>{if(a.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const c=this.touchStartTimestamp,g=Date.now()-c,b=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,E=g<=250;b&&E&&this.fastTouchScroll.next(a)}};this.addSubscription(Pt(this.element,i,"touchend"))}this.addSubscription(Pt(this.element,Le(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(Pt(this.element,e=>{this.touchStartSubject.next(e),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(Pt(this.element,e=>this.touchMoveSubject.next(e),"touchmove",!0)),this.addSubscription(Pt(this.element,e=>this.touchEndSubject.next(e),"touchend")),this.addSubscription(Pt(this.element,e=>this.touchCancelSubject.next(e),"touchcancel")),this.addSubscription(Pt(this.element,e=>{e.ctrlKey?this.pinchSubject.next(e):Vi(e)?this.scrollGestureSubject.next(e):this.wheelSubject.next(e),e.preventDefault()},"wheel")),this.addSubscription(Pt(this.element,e=>this.contextMenuSubject.next(e),"contextmenu")),this.addSubscription(Pt(this.element,Le(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(Pt(this.element,Le(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(Pt(document,Le(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(ts).subscribe(()=>{const e=this.element.getBoundingClientRect();this.canvasBounds.x=e.left,this.canvasBounds.y=e.top,this.canvasBounds.width=e.width,this.canvasBounds.height=e.height}));const t=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",t,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){Pe.DRAG_EVENTS.forEach(n=>{document.addEventListener(n,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(n,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(n){"pageX"in n?this.currentPointDocument.x=n.pageX:n.touches!==void 0&&(this.currentPointDocument.x=n.touches[0].pageX),"pageY"in n?this.currentPointDocument.y=n.pageY:n.touches!==void 0&&(this.currentPointDocument.y=n.touches[0].pageY)}updateCurrentMousePoint(n){const t=this.element.getBoundingClientRect();"clientX"in n?this.currentPoint.x=n.clientX-t.left:n.touches!==void 0&&(this.currentPoint.x=n.touches[0].clientX-t.left),"clientY"in n?this.currentPoint.y=n.clientY-t.top:n.touches!==void 0&&(this.currentPoint.y=n.touches[0].clientY-t.top)}static copyPoint(n){return{x:n.x,y:n.y}}observeMouseMove(n=()=>!0){return this.mouseMoveSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe(lt(()=>!this.dragging))}observeMouseMoveDocument(n=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(n=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(lt(()=>n(this.currentPointDocument.x,this.currentPointDocument.y)),yt(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(n=()=>!0){return this.xDragStartSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(n=()=>!0){return this.xDragSubject.pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(n=()=>!0){return this.xDragEndSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(n=()=>!0){return this.yDragStartSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(n=()=>!0){return this.yDragSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(n=()=>!0){return this.yDragEndSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(n=()=>!0,t=!1){const e=this.mouseMoveSubject.asObservable().pipe(lt(()=>!(t&&this.dragging)),yt(()=>n(this.currentPoint.x,this.currentPoint.y))),s=this.observeMouseLeavesCanvas().pipe(yt(()=>!1));return Ot(e,s).pipe(Zt())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(n=()=>!0){return this.clickSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(n=()=>!0){return this.dbClickSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(n=()=>!0){return this.dbTapSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeWheel(n=()=>!0){return this.wheelSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observePinch(n=()=>!0){return this.pinchSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeScrollGesture(){return this.scrollGestureSubject.asObservable()}observeTouchStart(n=()=>!0){return this.touchStartSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(n=()=>!0){return this.touchMoveSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(n=()=>!0){return this.mouseDownSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(n=()=>!0){return this.mouseUpSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(n=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(n=()=>!0){return this.contextMenuSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)),ia(t=>t.preventDefault()))}observeLongTouchStart(n=()=>!0){return this.longTouchStartSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(n=()=>!0){return this.longTouchEndSubject.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(n=()=>!0){return this.fastTouchScroll.asObservable().pipe(lt(()=>n(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};let Pn=Pe;Pn.DRAG_START_EVENTS=["mousedown","touchstart"],Pn.DRAG_EVENTS=["mousemove","touchmove"],Pn.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];var Qf=_t(722),tg=function(n){L(t,n);function t(e,s,r){e===void 0&&(e=1/0),s===void 0&&(s=1/0),r===void 0&&(r=Gn);var i=n.call(this)||this;return i._bufferSize=e,i._windowTime=s,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=s===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,s),i}return t.prototype.next=function(e){var s=this,r=s.isStopped,i=s._buffer,a=s._infiniteTimeWindow,o=s._timestampProvider,l=s._windowTime;r||(i.push(e),!a&&i.push(o.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),r=this,i=r._infiniteTimeWindow,a=r._buffer,o=a.slice(),l=0;l<o.length&&!e.closed;l+=i?1:2)e.next(o[l]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,r=e._timestampProvider,i=e._buffer,a=e._infiniteTimeWindow,o=(a?1:2)*s;if(s<1/0&&o<i.length&&i.splice(0,i.length-o),!a){for(var l=r.now(),c=0,h=1;h<i.length&&i[h]<=l;h+=2)c=h;c&&i.splice(0,c+1)}},t}(X);const eg=Symbol("MEMOIZE_CLEAR_FUNCTION");function ng(n){const t={},e=function(){const s=Array.prototype.slice.call(arguments),r=Ia(s);return typeof t[r]=="undefined"&&(t[r]=n.apply(this,s)),t[r]}.bind(this);return e[eg]=function(){const s=Array.prototype.slice.call(arguments),r=Ia(s);delete t[r]},e}const Vg=n=>t=>{let e=!1,s,r=[];const i=a=>{s=t(...a),e=!0,r=a};return(...a)=>{const o=a.length;if(e&&o===0)return s;if(!e||r.length!==o)return i(a),s;for(let l=0;l<o;l++)if(!n.equals(r[l],a[l]))return i(a),s;return s}};function Ia(n){if(!n.every(e=>typeof e=="number"||typeof e=="string"||typeof e=="boolean"))throw Error("Arguments to memoized function can only be strings or numbers");return JSON.stringify(n)}const Oa=ng(Qf.getTimezoneOffset),sg=(n,t)=>new Date(t).getTimezoneOffset()*60*1e3+Oa(n,t);class rg{constructor(t){this.config=t,this.timeZoneChangedSubject=new tg,this.currentTzOffset=e=>this.getOffset(this.config.timezone,e),this.formatterCache={},this.getOffset=(e,s)=>sg(e,s),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=r=>s(r).bind(t)}else e=Hh(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){const e=r=>-new Date(r).getTimezoneOffset()*ig;let s;return t?s=r=>Oa(t,r):s=e,r=>new Date(+r+s(r)-e(r))}}const ig=60*1e3;class xs{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,r;this.parentElement=t;const i=e;zo(i),this.config=i;const a=gl(i);t.innerHTML="",t.appendChild(a.content),this.id=(s=t.getAttribute("data-id"))!=null?s:"",i.fixedSize&&(t.style.width=i.fixedSize.width+"px",t.style.height=i.fixedSize.height+"px");const o=new rg(i);this.timeZoneModel=o;const l=this.timeZoneModel.getFormatterFactory(),c=vl(t);this.elements=c;const h=new Pf;this.bus=h;const g=new Mf(t,(r=c.chartResizer)!=null?r:t,h,this.canvasModels,i);this.chartResizeHandler=g,g.subscribeResize(),this.components.push(g.unsubscribeAnimationUpdate.bind(g));const p=new Qc(h,g);this.drawingManager=p;const b=Jc(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,p,this.canvasModels);this.mainCanvasModel=b,this.dynamicObjectsCanvasModel=Oe(h,c.dynamicObjectsCanvas,i,p,this.canvasModels,c.chartResizer);const E=new Ge(this.dynamicObjectsCanvasModel);p.addDrawer(E,"SERIES_CLEAR");const O=Oe(h,c.yAxisLabelsCanvas,i,p,this.canvasModels,c.chartResizer),N=new Vn(i,h,b,l,g);this.canvasBoundsContainer=N;const k=c.mainCanvas.parentElement;if(k===null)throw new Error("Couldn't get main canvas parent");const V=new Pn(h,k);this.canvasInputListener=V,this.chartComponents.push(this.canvasInputListener);const Z=new Zh(h,c.hitTestCanvas,V,N,p,i,this.canvasModels,c.chartResizer);this.hitTestCanvasModel=Z;const J=new Ge(Z);p.addDrawer(J,"HIT_TEST_CLEAR");const K=new So(h);this.canvasAnimation=K;const U=new ri(i,()=>N.getBounds(Y.PANE_UUID(ht)),K);this.scaleModel=U;const q=Oe(h,c.backgroundCanvas,i,p,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=q,this.cursorHandler=new dl(c.canvasArea,V,N,Z),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new Hf(V,N),this.chartComponents.push(this.crossEventProducer);const at=new kl("candle");this.chartBaseModel=at;const ot=new Ed(h,U,N,i,K,V,k,at);this.chartPanComponent=ot,this.chartComponents.push(ot),this.userInputListenerComponents.push(ot.chartAreaPanHandler);const nt=new gu(at,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,U,N,i,K,V,p,this.cursorHandler,this.crossEventProducer,ot,b,O);this.paneManager=nt;const rt=this.paneManager.panes[ht];this.mainPane=rt,this.chartComponents.push(nt),this.dynamicObjects=new Yh(this.dynamicObjectsCanvasModel,p),this.chartComponents.push(this.dynamicObjects),this.chartModel=new Sh(at,nt,h,this.dynamicObjectsCanvasModel,i,U,l,k,N,g);const dt=new ch(this.chartModel,this.dynamicObjectsCanvasModel,i,U,N,p,Z,V,q,ot,nt,this.cursorHandler,this.dynamicObjects);this.chartComponents.push(dt),this.chartComponent=dt;const ct=this.chartComponent.chartModel;this.chartModel=ct,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),Z.addSubscriber(nt.hitTestController),this.xAxisComponent=new mf(h,i,b,dt,U,N,V,g,this.drawingManager,o,ot,this.cursorHandler,q),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const St=new Ge(b);p.addDrawer(St,"MAIN_CLEAR");const ut=new Tf(k,ct,V,i);this.chartComponents.push(ut),this.watermarkComponent=new Eu(nt,ct,h,i,N,this.dynamicObjectsCanvasModel,p),this.chartComponents.push(this.watermarkComponent);const vt=Oe(h,c.crossToolCanvas,i,p,this.canvasModels,c.chartResizer);this.highlightsComponent=new gd(h,i,ct,b,N,p),this.chartComponents.push(this.highlightsComponent),i.useUTCTimeOverride&&i.dateFormatter&&!i.dateFormatter.utcTimeOverride&&(i.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(ct)),this.navigationMapComponent=new xd(h,ct,b,i,V,N,p,l,ot,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const pt=new od(i,this.dynamicObjectsCanvasModel,ct,N,p);this.chartComponents.push(pt),this.initYAxisDrawer(O),this.yAxisComponent=rt.mainExtent.yAxis;const Ht=new yf(this.chartModel,this.config,rt.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(Ht,fs.MAIN),this.volumesComponent=new Pu(this.dynamicObjectsCanvasModel,dt,U,N,p,i,nt,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const kt=new Ni(b,U,i,this.yAxisComponent.state,"GRID",p,()=>this.canvasBoundsContainer.getBounds(Y.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(Y.PANE_UUID(ht)),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>this.yAxisComponent.model.baseLabelsModel.labels,()=>rt.mainExtent.toY(rt.mainExtent.getBaseline()),()=>i.components.grid.visible);this.chartComponents.push(kt),this.hoverProducer=new $f(this.crossEventProducer,U,i,ct,V,this.canvasBoundsContainer,this.paneManager,o,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new Lh(i,vt,N,p,nt,this.crossEventProducer,this.hoverProducer,this.backgroundCanvasModel),this.chartComponents.push(this.crossToolComponent);const jt=Oe(h,c.snapshotCanvas,i,p,this.canvasModels,c.chartResizer),pe=new vu(this.elements,jt);this.snapshotComponent=pe,this.chartComponents.push(pe);const Mn=new rd(i,this.dynamicObjectsCanvasModel,Z,ct,N,p,l,this.cursorHandler,q);this.eventsComponent=Mn,this.chartComponents.push(Mn),this.chartComponents.forEach(bg=>bg.activate()),this.enableUserControls(),p.reorderDrawers(i.drawingOrder),this.clearer=To(this.components)}initYAxisDrawer(t){const e=new ls,s=new Ge(t);e.addDrawer(s,"YAXIS_CLEAR"),this.drawingManager.addDrawer(e,"Y_AXIS");const r=new Sf(this.config,t,this.paneManager);e.addDrawer(r);const i=new wf(t,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);e.addDrawer(i)}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"&&xs.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,r,i,a;const o=this.config.components.grid;o.visible=(e=t.visible)!=null?e:!1,o.dash=(s=t.dash)!=null?s:[0,0],o.width=(r=t.width)!=null?r:1,o.color=(i=t.color)!=null?i:"#FFFFFF",this.config.colors.chartAreaTheme.gridColor=(a=t.color)!=null?a:"#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){Kt(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseMove(s).subscribe(e);return()=>r.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,s=!1){const r=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseEnter(r,s).subscribe(e);return()=>i.unsubscribe()}addClickOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeClick(s).subscribe(e);return()=>r.unsubscribe()}addDragEventsListener(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),r=Ot(this.canvasInputListener.observeYDrag(s),this.canvasInputListener.observeXDrag(s)).subscribe(e);return()=>r.unsubscribe()}registerComponent(t,e){const s=t(this);this.components.push(s),e&&e(s),s.activate()}}class La extends xs{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.chartComponent.setChartType(t)}createPane(){return this.paneManager.createPane()}}var ag=Object.defineProperty,og=Object.defineProperties,lg=Object.getOwnPropertyDescriptors,Ba=Object.getOwnPropertySymbols,cg=Object.prototype.hasOwnProperty,hg=Object.prototype.propertyIsEnumerable,Ra=(n,t,e)=>t in n?ag(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dg=(n,t)=>{for(var e in t||(t={}))cg.call(t,e)&&Ra(n,e,t[e]);if(Ba)for(var e of Ba(t))hg.call(t,e)&&Ra(n,e,t[e]);return n},ug=(n,t)=>og(n,lg(t));function Fa(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,r=10,i=10;n.avgTrendLength&&(s=n.avgTrendLength.sw||10,r=n.avgTrendLength.down||10,i=n.avgTrendLength.up||10);var a=n.startY||50,o=n.avgCandleSize||2,l=a-o,c=a+o,h=Tn(l,c,o);for(t.push(h);t.length<e;){var g=Math.random()*10;g>6?t=t.concat(vg(t[t.length-1],o,s)):g>3?t=t.concat(fg(t[t.length-1],o,i)):t=t.concat(gg(t[t.length-1],o,r))}t=t.slice(0,n.quantity);let p=Math.round(new Date().getTime()/3e5)*3e5;p-=e*1e3*n.period;for(let b=0;b<t.length;b++){const E=t[b];Object.assign(E,{timestamp:p,isVisible:!0}),p+=1e3*n.period,n.withVolume&&(E.volume=Math.ceil(Math.random()*1e3+200))}return t}function Tn(n,t,e,s){var r=Math.random()*(t-n)+n,i;if(s&&s==="bull"||!s&&Math.random()>.5){var a=r+e;i=a<t?a:t}else{var o=r-e;i=o>n?o:n}var l=Math.max(r,i)+Math.random()*e*.2,c=Math.min(r,i)-Math.random()*e*.2;return{hi:l,lo:c,open:r,close:i,timestamp:0,volume:0}}function fg(n,t,e){for(var s=[],r=Math.random()*e+e/2,i=n.lo,a=n.hi+t*1.2,o=0;o<r;o++){var l=Math.random()>.9?"bear":"bull",c=Tn(i,a,t,l);i=c.lo-t*(Math.random()*.1+.1),a=c.hi+t*(Math.random()*1.3+.1),Math.random()>.9&&(a=c.hi+t),s.push(c)}return s}function gg(n,t,e){for(var s=[],r=Math.random()*e+e/2,i=n.hi-t*1.2,a=n.hi,o=0;o<r;o++){var l=Math.random()<.9?"bear":"bull",c=Tn(i,a,t,l);i=c.lo-t*(Math.random()*.3+.1),a=c.hi-t*(Math.random()*.1+.1),Math.random()>.9&&(a=c.lo-t),s.push(c)}return s}function vg(n,t,e){var s=[],r=Math.random()*e+e/2;function i(p){var b,E;return Math.random()>.5?(b=p.lo-t*.2,E=p.hi+t*1.2):(b=p.lo-t*1.2,E=p.hi+t*.2),{from:b,to:E}}for(var a=i(n),o=a.from,l=a.to,c=0;c<r;c++){var h=Math.random()<.5?"bear":"bull",g=Tn(o,l,t,h);a=i(g),o=a.from,l=a.to,Math.random()>.9&&(Math.random()>.5?o=g.lo-t:l=g.hi+t),s.push(g)}return s}window.DXChart=ug(dg({},window.DXChart),{generateCandlesData:Fa});function mg(n){return Fa(n)}const pg=(n,t={})=>new La(n,t)})(),window.DXChart=_n})();})();
|
|
23
|
+
`;function Cl(s){const t=document.createElement("template");return t.innerHTML=bl(s.devexpertsPromoLink),t}function wl(s){const t={},e=Array.from(s.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(n=>{var i;t[(i=n.getAttribute("data-element"))!=null?i:""]=n}),vl(t))return t;throw new Error("Some chart elements are missing")}function yl(s){if(s.length>1){const t=s.reduce((i,r,o)=>{if(o!==s.length-1){const a=s[o+1].timestamp-r.timestamp;i[a]?i[a]++:i[a]=1}return i},{});let e=0,n;for(const i of Object.keys(t)){const r=parseInt(i,10),o=t[r];o>e&&r>0&&(e=o,n=r)}if(n)return n}}const be=(s,t,e,n=1e3)=>{var i,r,o,a;const l=(r=(i=fe(e))==null?void 0:i.timestamp)!=null?r:0,c=(a=(o=wt(e))==null?void 0:o.timestamp)!=null?a:0;return s>c?t?{index:e.length-1+Math.ceil((s-c)/n),exact:!0}:{index:e.length-1,exact:!0}:s<l?t?{index:nt((s-l)/n),exact:!0}:{index:-1,exact:!0}:zt(e,s,h=>h.timestamp)},Ds=1;function Xe(s,t){return t===s?"none":t>s?"up":"down"}function Sl(s,t){return t>s?"up":"down"}function xl(s,t,e=!1){const{expansion:n,impVolatility:i,vwap:r,volume:o,timestamp:a}=s;let l=s.hi,c=s.lo,h=s.open;const d=s.close;e&&(l=d,c=d,h=d);let u=s.idx;return t!==void 0&&(u=t),{hi:l,lo:c,open:h,close:d,timestamp:a,volume:o,expansion:n,idx:u,impVolatility:i,vwap:r}}const mi={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2},vi={paintConfig:[mi],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var _l=Object.defineProperty,bi=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Tl=Object.prototype.propertyIsEnumerable,Ci=(s,t,e)=>t in s?_l(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Ml=(s,t)=>{for(var e in t||(t={}))Pl.call(t,e)&&Ci(s,e,t[e]);if(bi)for(var e of bi(t))Tl.call(t,e)&&Ci(s,e,t[e]);return s};class Al{constructor(t,e,n,i){this.series=t,this.config=e,this.yAxisBoundsProvider=n,this.axisState=i}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,n=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:[Ml({y:a,description:this.series.name,mode:i,labelType:r,labelText:l},c)],axisState:this.axisState,bounds:n}]}getLabelDrawConfig(){var t;const e=this.series.config,i=((t=e.paintConfig[0])!=null?t:mi).color;return{textColor:qt(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}let It=window.devicePixelRatio,ze=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const Is=()=>{ze.removeEventListener("change",Is),It=window.devicePixelRatio,ze=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),ze.addEventListener("change",Is)};ze.addEventListener("change",Is);const El=()=>It,Ll=s=>Kt(It*s)/It,V=s=>nt(It*s)/It,wi=s=>ma(It*s)/It,Ce=s=>JSON.parse(JSON.stringify(s));function Bs(s){return Object.entries(s)}const yi=(s,t)=>{for(const[e,n]of Array.from(s.entries()))if(n===t)return e};function Si(s){return Object.keys(s)}function xi(s,t){if(Object.is(s,t))return!0;if(typeof s!="object"||s===null||typeof t!="object"||t===null)return!1;const e=Object.keys(s),n=Object.keys(t);if(e.length!==n.length)return!1;for(let i=0,r=e.length;i<r;i++)if(!hasOwnProperty.call(t,e[i])||!xi(s[e[i]],t[e[i]]))return!1;return!0}function _i(s){s===void 0&&(s={});var t=s.connector,e=t===void 0?function(){return new I}:t,n=s.resetOnError,i=n===void 0?!0:n,r=s.resetOnComplete,o=r===void 0?!0:r,a=s.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var h,d,u,g=0,w=!1,y=!1,_=function(){d==null||d.unsubscribe(),d=void 0},M=function(){_(),h=u=void 0,w=y=!1},B=function(){var F=h;M(),F==null||F.unsubscribe()};return N(function(F,j){g++,!y&&!w&&_();var H=u=u!=null?u:e();j.add(function(){g--,g===0&&!y&&!w&&(d=Os(B,l))}),H.subscribe(j),!h&&g>0&&(h=new de({next:function(R){return H.next(R)},error:function(R){y=!0,_(),d=Os(M,i,R),H.error(R)},complete:function(){w=!0,_(),d=Os(M,o),H.complete()}}),Rt(F).subscribe(h))})(c)}}function Os(s,t){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];if(t===!0){s();return}if(t!==!1){var i=new de({next:function(){i.unsubscribe(),s()}});return Rt(t.apply(void 0,L([],p(e)))).subscribe(i)}}const We=(s,t)=>s/t,dt=(s,t)=>s/t,Yt=(s,t)=>s*t,Pi=(s,t)=>(s-t)*100/t,Ti=(s,t)=>s*t/100+t,Mi=s=>Math.log2(s),Rs=s=>Math.pow(2,s);class Dl 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 I,this.xChanged=this.changed.pipe(ct(()=>({start:this.xStart,end:this.xEnd})),Lt((t,e)=>t.start===e.start&&t.end===e.end),_i()),this.yChanged=this.changed.pipe(ct(()=>({start:this.yStart,end:this.yEnd})),Lt((t,e)=>t.start===e.start&&t.end===e.end),_i())}doActivate(){super.doActivate()}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+dt(t-this.xStart,this.zoomX)}xPixels(t){return dt(t,this.zoomX)}toY(t){const e=this.getBounds();return this.inverseY?e.y+dt(t-this.yStart,this.zoomY):e.y+e.height-dt(t-this.yStart,this.zoomY)}yPixels(t){return dt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return Yt(e+dt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),n=t-e.y;return this.inverseY?Yt(n+dt(this.yStart,this.zoomY),this.zoomY):Yt(e.height-n+dt(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 We(e-t,this.getBounds().width)}calculateZoomY(t,e){return We(e-t,this.getBounds().height)}recalculateZoom(t=!0){this.recalculateZoomX(),this.recalculateZoomY(),t&&this.fireChanged()}setXScale(t,e,n=!0){this.xStart=t,this.xEnd=e,this.recalculateZoomX(),n&&this.fireChanged()}setYScale(t,e,n=!0){this.yStart=t,this.yEnd=e,this.recalculateZoomY(),n&&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(){return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)}}const Il=(s,t)=>!Si(s).some(e=>s[e]!==t[e]);class Bl{constructor(t,e){this.scale=t,this.dataSeries=e,this.prevAnimationId=""}getBaselineForPercent(t){const e=this.scale.currentAnimation;let n;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(zt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(zt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),n=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else n=t();return n}}class Ai{constructor(t,e,n,i){this.dataSeries=t,this.scale=e,this.getAxisType=n,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 Bl(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const n=this.percentAnimationHandler.getBaselineForPercent(e);return Pi(t,n);case"logarithmic":return Mi(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 Ti(t,this.getBaseline());case"logarithmic":return Rs(t);case"regular":return t}}}var Ol=Object.defineProperty,Rl=Object.defineProperties,Fl=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Hl=Object.prototype.hasOwnProperty,kl=Object.prototype.propertyIsEnumerable,Li=(s,t,e)=>t in s?Ol(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Yl=(s,t)=>{for(var e in t||(t={}))Hl.call(t,e)&&Li(s,e,t[e]);if(Ei)for(var e of Ei(t))kl.call(t,e)&&Li(s,e,t[e]);return s},jl=(s,t)=>Rl(s,Fl(t));class we{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return V(t.toY(this.close))}x(t){return V(t.toX(this.centerUnit))}clone(){return new we(this.centerUnit,this.close)}}class Di extends X{constructor(t,e,n,i=Ce(vi)){var r;super(),this.extentComponent=t,this.id=e,this.htId=n,this.name="",this.hovered=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=o=>{var a;return(a=this.config.paintConfig[o])!=null?a:this.config.paintConfig[0]},this.getBaseline=(o=this.dataIdxStart)=>{var a,l;return(l=(a=this.visualPoints[o])==null?void 0:a.close)!=null?l:1},this.getTextForPoint=o=>`${o.close}`,this.getLastVisualSeriesPoint=()=>{const o=this.visualPoints,a=zt(o,this.scale.xEnd,l=>l.centerUnit).index;return o[a]},this.getLastDataSeriesPoint=()=>{const o=this.visualPoints;return wt(o)},this.config=Dt(i,vi),this.scale=t.scale,this.view=new Ai(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Al(this,this.config,t.getYAxisBounds,(r=t.yAxis)==null?void 0:r.state),this.highLowProvider=Xl(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=Wn(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=Wn(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.recalculateDataViewportIndexes())),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>{this.recalculateVisualPoints()}))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new Ai(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,this.deactivate(),this.activate(),t.addDataSeries(this)}toVisualPoints(t){return t.map((e,n)=>({centerUnit:n,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:n,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=n,this.dataIdxEnd=i}calculateDataViewportIndexes(t,e){const n=zt(this.visualPoints,t,r=>r.centerUnit).index,i=zt(this.visualPoints,e,r=>r.centerUnit).index;return{dataIdxStart:n,dataIdxEnd:i}}valueFormatter(t){return Ii(t)}getSeriesInViewport(t,e){let n=this.dataIdxStart,i=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const r=this.calculateDataViewportIndexes(t,e);n=r.dataIdxStart,i=r.dataIdxEnd}return Ba(this.visualPoints2D,n,i)}}const Nl=s=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<s.length;e++){const n=s[e];n.close>t.high&&(t.high=n.close,t.highIdx=e),n.close<t.low&&(t.low=n.close,t.lowIdx=e)}return t},Xl=s=>({isHighLowActive:()=>s.config.highLowActive,calculateHighLow:t=>{const e=Nl(s.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return jl(Yl({},e),{high:s.view.toAxisUnits(e.high),low:s.view.toAxisUnits(e.low)})}}),Ii=s=>{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))))(s);return ht.makeDecimal(s,i)};class Ue extends we{constructor(t,e,n,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.width=e,this.open=n,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return V(Math.abs(t.toY(this.open)-t.toY(this.close)))}candleHeight(t){return V(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=V(t.toY(this.high)),n=V(t.toY(this.low)),i=V(t.toY(this.open)),r=V(t.toY(this.close)),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>n?[n,e]:[e,n];return[l,o,a,c]}yLineEnd(t){return V(Math.max(t.toY(this.high),t.toY(this.low)))}yLineStart(t){return V(Math.min(t.toY(this.high),t.toY(this.low)))}yBodyStart(t){return V(Math.min(t.toY(this.open),t.toY(this.close)))}yBodyEnd(t){return V(Math.max(t.toY(this.open),t.toY(this.close)))}xCenter(t){return this.x(t)}xStart(t){return Ll(t.toX(this.startUnit))}}const oe=60,Bi=(s,t,e,n,i=oe)=>{const r=ye(s,n,i);r.volume=e;let o;if(t.length===0)o=0;else if(n>=t.length){const a=t[t.length-1],c=(n-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-n*e;o=a.centerUnit-c}return new Ue(o,e,r.open,r.close,r.lo,r.hi,Xe(r.open,r.close),r)},zl=(s,t,e,n,i=oe)=>{const r=Wl(s,n,i);let o;if(t.length===0)o=0;else if(n>=t.length){const a=t[t.length-1],c=(n-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-n*e;o=a.centerUnit-c}return new we(o,r.close)},ye=(s,t,e=oe)=>({hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:Oi(s,t,e),volume:NaN,expansion:!0,idx:t}),Wl=(s,t,e=oe)=>({close:NaN,timestamp:Oi(s,t,e)});function Oi(s,t,e=oe){var n,i;const r=Kt(t);if(s.length===0)return 0;const o=wt(s);if(r>=s.length&&o)return Ri(o,s.length-1,r,e);const a=fe(s);return r<0&&a?Ri(a,0,r,e):(i=(n=s[r])==null?void 0:n.timestamp)!=null?i:0}const Ri=(s,t,e,n=oe)=>s.timestamp+(e-(t!=null?t:0))*n;class Ul{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new I,this.dataSetSubject=new I,this.dataRemovedSubject=new I,this.dataPrependSubject=new I,this.meanDataWidth=1,this.period=1}dataFromTimestamp(t,e=!0,n=this.mainDataPoints){const i=be(t,e,n,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=yl(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?Bi(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):zl(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var Vl=Object.defineProperty,Fi=Object.getOwnPropertySymbols,Gl=Object.prototype.hasOwnProperty,Zl=Object.prototype.propertyIsEnumerable,Hi=(s,t,e)=>t in s?Vl(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,$l=(s,t)=>{for(var e in t||(t={}))Gl.call(t,e)&&Hi(s,e,t[e]);if(Fi)for(var e of Fi(t))Zl.call(t,e)&&Hi(s,e,t[e]);return s};class Kl{constructor(t,e,n=()=>!0){this.canvasModel=t,this.config=e,this.backgroundDrawPredicate=n,this.prevState={}}draw(){if(this.backgroundDrawPredicate()||!xi(this.config.colors.chartAreaTheme,this.prevState)){this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0,this.canvasModel.width,this.canvasModel.height);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=$l({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const Ve=(s,t,e,n,i,r,o)=>{const a=El(),l=[e*a,n*a,i*a,r*a];let c=s.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]=nt(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?nt(u*o):nt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},ki=(s,{x:t,width:e,activeCandle:n})=>new Ue(t,e,s.open,s.close,s.hi,s.lo,Xe(s.open,s.close),s,!0,Fs(s,n)),ql=(s,{x:t,width:e,activeCandle:n,prevCandle:i})=>{var r;return new Ue(t,e,s.open,s.close,s.hi,s.lo,Sl((r=i==null?void 0:i.close)!=null?r:s.close,s.close),s,!0,Fs(s,n),s.close>s.open)},Yi=(s,{x:t,width:e,activeCandle:n,prevCandle:i})=>{var r;return new Ue(t,e,s.open,s.close,s.hi,s.lo,Xe((r=i==null?void 0:i.close)!=null?r:s.close,s.close),s,!0,Fs(s,n),s.close>s.open)},Jl=Yi,Fs=(s,t)=>{const e=t&&t.idx===s.idx;return e!=null?e:!1},ji=()=>Ds,Qt=class{static autoDetectIncrementOfValueRange(s){const t=this.getDigitsInNumber(s);return s===0?.01:Math.pow(10,t-3)}static getDigitsInNumber(s){const t=n=>nt(Math.log10((n^n>>31)-(n>>31)))+1;let e=t(s);return e===1&&s<1&&(e=t(s*1e9)-9),e}static getPriceIncrement(s,t=[]){if(!this.validatePriceIncrementsOrPrecisions(t))return this.DEFAULT_INCREMENT;if(isNaN(s))return Math.round(t[0]);s=Math.abs(s);let e=1;const n=1e-6;for(;e<t.length&&s>t[e]+Math.min(t[e-1],t[e+1])*n;)e+=2;return e>=t.length||s<t[e]-Math.min(t[e-1],t[e+1])*n?t[e-1]:Math.min(t[e-1],t[e+1])}static getPricePrecision(s,t){if(!this.validatePriceIncrementsOrPrecisions(t))return 0;if(isNaN(s))return Math.round(t[0]);s=Math.abs(s);let e=1;for(;e<t.length&&s>t[e];)e+=2;return Math.round(t[e-1])}static roundPriceToIncrement(s,t,e){const n=Qt.getPriceIncrement(e||s,t);return ht.roundToNearest(s,n)}static computePrecisions(s){const t=[...s];for(let e=0;e<s.length;e+=2)t[e]=Qt.calculatePrecision(s[e]);for(let e=1;e<s.length;e+=2)t[e]=s[e]+Math.min(s[e-1],s[e+1])*Qt.RELATIVE_EPS;return t}static calculatePrecision(s){let t=s>1?Math.abs(Math.floor(s)-s):s;for(let e=0;e<Qt.MAXIMUM_PRECISION;e++){const n=Math.floor(t+.5),i=Math.abs(t*Qt.RELATIVE_EPS);if(n>=t-i&&n<=t+i)return e;t*=10}return Qt.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(s){return!(s.length===0||!Array.isArray(s)||s.findIndex(t=>t!==0)===-1)}};let Bt=Qt;Bt.DEFAULT_INCREMENT=.01,Bt.DEFAULT_PRECISION=2,Bt.RELATIVE_EPS=1e-8,Bt.MAXIMUM_PRECISION=10;const Ql=(s,t)=>{var e;const n=(e=wt(t))!=null?e:1;return Math.pow(10,-n)};var tc=Object.defineProperty,ec=Object.defineProperties,sc=Object.getOwnPropertyDescriptors,Ni=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,ic=Object.prototype.propertyIsEnumerable,Xi=(s,t,e)=>t in s?tc(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,rc=(s,t)=>{for(var e in t||(t={}))nc.call(t,e)&&Xi(s,e,t[e]);if(Ni)for(var e of Ni(t))ic.call(t,e)&&Xi(s,e,t[e]);return s},oc=(s,t)=>ec(s,sc(t));const ac=s=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:s.scale.xStart,n=t?t.xEnd:s.scale.xEnd,{dataIdxStart:i,dataIdxEnd:r}=s.calculateDataViewportIndexes(e,n),o=s.visualPoints.slice(i,r+1),a=zi(o),l=()=>{var c,h;return(h=(c=s.visualPoints[i])==null?void 0:c.close)!=null?h:1};return oc(rc({},a),{low:s.view.toAxisUnits(a.low,l),high:s.view.toAxisUnits(a.high,l)})}}),zi=s=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<s.length;e++){const n=s[e];n.high>t.high&&(t.high=n.high,t.highIdx=e),n.low<t.low&&(t.low=n.low,t.lowIdx=e)}return t},lc=30,Wi=(s,t,e)=>{const n=s.startViewportMovementAnimation(t,{duration:lc,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY});t.currentAnimation=n};class cc{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=(s,t,e,n)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=Ui(i),o=n.reduce((a,l)=>l(a),r);t.yStart=o.low,t.yEnd=o.high,t.zoomY=s.calculateZoomY(t.yStart,t.yEnd)};function Ui(s){if(s.length===0)return dc();let t=s[0].high,e=s[0].low;return s.forEach(n=>{isFinite(n.high)&&n.high>=t&&(t=n.high),isFinite(n.low)&&n.low<=e&&(e=n.low)}),{low:e,high:t}}const dc=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER});var uc=Object.defineProperty,Vi=Object.getOwnPropertySymbols,gc=Object.prototype.hasOwnProperty,fc=Object.prototype.propertyIsEnumerable,Gi=(s,t,e)=>t in s?uc(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Zi=(s,t)=>{for(var e in t||(t={}))gc.call(t,e)&&Gi(s,e,t[e]);if(Vi)for(var e of Vi(t))fc.call(t,e)&&Gi(s,e,t[e]);return s};const pc=(s,t,e,n)=>{var i,r,o,a;const l=Zi({},s),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=Oa(-e,t))==null?void 0:o.startUnit)!=null?a:0;let d=s.xStart,u=s.xEnd;return l.xStart>=h&&(d=h,u=u-(l.xStart-h)),l.xEnd<c&&(d=c-Yt(n.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},mc=(s,t,e,n)=>{const i=Zi({},t),r=n(),o=i.xEnd-i.xStart,a=o<e.minCandles,l=r.width/e.minWidth,c=o>l;if(r.width>0){if(c)return i.xStart=i.xEnd-l,i.zoomX=We(i.xEnd-i.xStart,r.width),i;if(a)return i.xStart=i.xEnd-e.minCandles,i.zoomX=We(i.xEnd-i.xStart,r.width),i}return i},vc=(s,t)=>s/t,bc=(s,t)=>s/t,Cc=(s,t)=>s*t,$i=(s,t)=>{const e=s.zoomY;s.zoomY=bc(s.zoomX,t);const n=s.zoomY/e,i=s.yEnd-s.yStart,o=i*n-i;s.yEnd=s.yEnd+o/2,s.yStart=s.yStart-o/2},wc=(s,t)=>{const e=s.zoomX;s.zoomX=Cc(s.zoomY,t);const n=s.zoomX/e,i=s.xEnd-s.xStart,o=i*n-i;s.xStart=s.xStart-o},yc=(s,t)=>{const e=s.xStart;s.xStart=t,s.xEnd=s.xEnd+(t-e)},Sc=(s,t)=>{const e=s.yStart;s.yStart=t,s.yEnd=s.yEnd+(t-e)},Ki=(s,t,e,n,i)=>{const r=(t.xEnd-t.xStart)*n,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=s.calculateZoomX(t.xStart,t.xEnd),t},xc=(s,t,e,n)=>Ki(s,t,1,e,n);var _c=Object.defineProperty,Pc=Object.defineProperties,Tc=Object.getOwnPropertyDescriptors,qi=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Ac=Object.prototype.propertyIsEnumerable,Ji=(s,t,e)=>t in s?_c(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Se=(s,t)=>{for(var e in t||(t={}))Mc.call(t,e)&&Ji(s,e,t[e]);if(qi)for(var e of qi(t))Ac.call(t,e)&&Ji(s,e,t[e]);return s},Ec=(s,t)=>Pc(s,Tc(t));const Lc=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Qi extends Dl{constructor(t,e,n){super(),this.config=t,this.getBounds=e,this.canvasAnimation=n,this.scaleInversedSubject=new I,this.beforeStartAnimationSubject=new I,this.history=[],this.zoomXYRatio=0,this.xConstraints=[],this.scalePostProcessor=(i,r)=>this.xConstraints.reduce((o,a)=>a(i,o),r),this.state=Ce(t.scale),this.autoScaleModel=new cc(this),this.offsets=this.config.components.offsets,this.addXConstraint((i,r)=>mc(i,r,this.config.components.chart,this.getBounds))}doActivate(){super.doActivate(),this.scaleInversedSubject=new I,this.beforeStartAnimationSubject=new I,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=Se(Se({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,n=!1,i){const r=this.config.scale.disableAnimations||n;r&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const o=this.export();Ki(this,o,t,i,e),this.zoomXTo(o,r)}zoomXToEnd(t,e){this.config.scale.disableAnimations&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const n=this.export();xc(this,n,e,t),this.zoomXTo(n,this.config.scale.disableAnimations)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.doAutoScale())}zoomXTo(t,e){const n=Se({},t),i=this.scalePostProcessor(n,t);this.state.lockPriceToBarRatio&&$i(i,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.doAutoYScale(i),e?this.apply(i):Wi(this.canvasAnimation,this,i)}setXScale(t,e,n=!0){const i=this.export(),r=this.calculateZoomX(t,e),o=Ec(Se({},i),{zoomX:r,xStart:t,xEnd:e}),a=this.scalePostProcessor(i,o);this.state.lockPriceToBarRatio&&$i(a,this.zoomXYRatio),this.state.auto&&this.autoScaleModel.doAutoYScale(a),n||this.config.scale.disableAnimations?(this.haltAnimation(),this.apply(a)):Wi(this.canvasAnimation,this,a)}setYScale(t,e,n=!1){const i=this.export();super.setYScale(t,e,n);const r=this.export(),o=this.scalePostProcessor(i,r);if(this.state.lockPriceToBarRatio){wc(o,this.zoomXYRatio),this.setXScale(o.xStart,o.xEnd);return}else this.state.auto&&this.autoScaleModel.doAutoYScale(o),this.apply(o)}moveXStart(t){const e=this.export(),n=Se({},e);this.haltAnimation(),yc(e,t);const i=this.scalePostProcessor(n,e);this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();Sc(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),Il(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}t&&this.recalculateZoomXYRatio(),this.state.lockPriceToBarRatio=t}recalculateZoomXYRatio(){this.zoomXYRatio=vc(this.zoomX,this.zoomY)}}class Dc extends Qi{constructor(t,e,n,i){super(e,n,i),this.delegate=t,this.config=e,this.getBounds=n}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 Ic=Ye().colors;class Wt extends Di{constructor(t,e,n,i,r,o,a,l,c=Ic){super(t,e,n),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=Lc(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new I,this.meanCandleWidth=Ds,this._instrument=o,this.instrument=o,this.highLowProvider=ac(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=Bt.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){super.recalculateDataViewportIndexes(t,e),this.recalculateZippedHighLow(),this.eventBus.fireDraw()}applyPriceMovement(){const t=wt(this.dataPoints);t&&(this.lastPriceMovement=Xe(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=zi(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd))}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=Dt(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var n,i;if(t.length===0)return[];const r=this.config.type,o=[];let a=e;const l=(n=this.candleWidthByChartType[r])!=null?n:ji;for(let c=0;c<t.length;c++){const h=t[c],d=t[c-1],u=l(h),g=a+u/2,w=(i=this.candlesTransformersByChartType[r])!=null?i:ki;o.push(w(h,{x:g,width:u,prevCandle:d,activeCandle:this.activeCandle})),a+=u}return o}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,n)=>e+n.width,0)/t.length:this.meanCandleWidth=Ds}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 Wf(s){switch(s){case"line":case"area":return!0;default:return!1}}class Bc{constructor(t){this.config=t}draw(t,e,n,i){if(n instanceof Wt){const r=pt(e);if(r.length===0)return;i.singleColor?t.strokeStyle=i.singleColor:t.strokeStyle=n.colors.areaTheme.lineColor,n.hovered?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const o=n.extentComponent.getBounds(),a=r[0],l=n.view.toX(a.centerUnit);for(let c=0;c<r.length;c++){const h=r[c-1],d=r[c+1],u=r[c],g=n.view.toX(u.centerUnit),w=n.view.toY(u.close),y=o.y+o.height;if(h===void 0)t.beginPath(),t.lineTo(nt(g),y),t.moveTo(nt(g),w);else if(d===void 0){t.lineTo(nt(g),w),t.stroke(),t.lineTo(nt(g),y),t.lineTo(nt(l),y),t.closePath();let _;i.singleColor?t.fillStyle=i.singleColor:t.fillStyle=n.colors.areaTheme.startColor&&n.colors.areaTheme.stopColor?(_=t.createLinearGradient(0,0,0,o.height),_.addColorStop(0,n.colors.areaTheme.startColor),_.addColorStop(1,n.colors.areaTheme.stopColor),_):"",t.fill()}else t.lineTo(nt(g),w)}}}}function tr(s,t,e,n,i,r=4,o=!0,a=!1){s.save(),s.beginPath(),s.moveTo(t+r,e),s.lineTo(t+n-r,e),s.quadraticCurveTo(t+n,e,t+n,e+r),s.lineTo(t+n,e+i-r),s.quadraticCurveTo(t+n,e+i,t+n-r,e+i),s.lineTo(t+r,e+i),s.quadraticCurveTo(t,e+i,t,e+i-r),s.lineTo(t,e+r),s.quadraticCurveTo(t,e,t+r,e),s.closePath(),o&&s.fill(),a&&s.stroke(),s.restore()}function Oc(s,t,e,n,i,r,o,a,l,c,h=4,d=!0,u=!1){const g=c==="right"?a:-a,w=c==="right"?h:-h,y=h;s.save(),s.beginPath(),l?s.moveTo(r+w,o):s.moveTo(r,o),l?(s.lineTo(r+g-w,o),s.quadraticCurveTo(r+g,o,r+g,o-y),s.lineTo(r+g,e+y),s.quadraticCurveTo(r+g,e,r+g-w,e),s.lineTo(t+w,e)):(s.lineTo(r+g,o),s.lineTo(r+g,e),s.lineTo(t,e)),l?(s.quadraticCurveTo(t,e,t-w/3,e+y/3),s.lineTo(n+w/3,i-y/3),s.quadraticCurveTo(n,i,n+w/3,i+y/3),s.lineTo(r-w/3,o-y/3),s.quadraticCurveTo(r,o,r+w/3,o)):(s.lineTo(n,i),s.lineTo(r,o)),s.closePath(),d&&s.fill(),u&&s.stroke(),s.restore()}function Rc(s,t,e,n,i,r=1){s.save(),s.lineWidth=r,s.beginPath(),s.moveTo(t,e),s.lineTo(n,i),s.stroke(),s.closePath(),s.restore()}function te(s,t){s.save(),s.lineWidth%2&&s.translate(.5,.5),t(),s.restore()}function er(s,t,e){const n=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);s.fillRect(n,i,r,o)}const Ut=(s,t)=>{s.beginPath(),s.rect(t.x,t.y,t.width,t.height),s.clip(),s.closePath()},Uf=s=>Array.isArray(s[0])?s:[s];class Fc{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,n){const i=t.ctx,r=n&&this.paneManager.panes[n];e&&(i.save(),r&&Ut(i,r.getBounds()),this.drawSeries(i,e),i.restore())}drawSeries(t,e){if(e.config.visible){const n=e.config.type,i=this.seriesDrawers[n];if(i){const r=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);r&&r.length>=1&&i.draw(t,r,e,{})}else console.error(`Data series drawer with type ${n} isn't registered!`)}}}const ae=(s,t,e,n,i=t)=>{n.forceBold?s.lineWidth=n.forceBold:e.hovered?s.lineWidth=t!==i?t+1:i:s.lineWidth=t};class Hc{constructor(t){this.config=t}setFillStyle(t,e,n,i){if(e.singleColor)t.strokeStyle=e.singleColor;else{const r=n.colors.barTheme;r&&(t.strokeStyle=r[`${i.name}Color`])}}draw(t,e,n,i){if(n instanceof Wt){const r=pt(e);ae(t,this.config.barLineWidth,n,i),te(t,()=>{for(const o of r){this.setFillStyle(t,i,n,o),t.beginPath();const a=V(n.view.toX(o.centerUnit)),l=V(n.view.toX(o.startUnit)),[c,h,d,u]=o.yBodyKeyPoints(n.view),g=V(n.view.xPixels(o.width)/2),w=V(n.view.toY(o.close)),y=V(n.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,w),t.lineTo(a+g,w),t.moveTo(l,y),t.lineTo(a,y),t.stroke()}})}}}class kc{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,n,i){if(i!==void 0&&n instanceof Wt){const r=pt(e),o=this.baseLineModel.baselineYPercents,a=this.canvasBoundContainer.getBounds(x.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],g=r[h+1],w=n.view.toX(c.centerUnit),y=n.view.toX(d.centerUnit),_=n.view.toY(d.close),M=u?n.view.toY(u.close)<l:!1,B=_<l;if(u!==void 0&&M!==B){sr(t,n,i,M);const F=n.view.toX(u.centerUnit),j=n.view.toY(u.close),H=y-F,R=_-j,Y=H/R,Z=_-l,K=Y*Z,U=F+(H-K);t.lineTo(U,l),t.stroke(),t.lineTo(w,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(U,l)}u===void 0?(t.beginPath(),t.moveTo(y,_)):g===void 0?(sr(t,n,i,B),t.lineTo(y,_),t.stroke(),t.lineTo(y,l),t.lineTo(w,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(w,l),t.lineTo(y,l),t.strokeStyle=n.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(y,_)}}}}const sr=(s,t,e,n)=>{e.singleColor?(s.fillStyle=e.singleColor,s.strokeStyle=e.singleColor):(s.fillStyle=n?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,s.strokeStyle=n?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class Yc{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,n,i){if(n instanceof Wt){const r=pt(e);ae(t,this.config.candleLineWidth,n,i,this.config.candleLineWidth),te(t,()=>{this.pixelLength=1/It,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const o of r){const{candleTheme:a,activeCandleTheme:l}=n.colors;a&&l&&this.drawCandle(t,i,n,o)}})}}drawCandle(t,e,n,i){const{candleTheme:r,activeCandleTheme:o}=n.colors,a=i.name,l=i.isActive?o:r,c=i.isHollow;e.singleColor?t.fillStyle=e.singleColor:c?t.fillStyle=l[`${a}WickColor`]:t.fillStyle=l[`${a}Color`];const h=V(n.view.toX(i.startUnit)),d=V(n.view.xPixels(i.width)),u=i.bodyHeight(n.view),[g,w,y,_]=i.yBodyKeyPoints(n.view),M=w===y?w+1:y,B=g===_?g+1:_,F=l[`${a}Color`],j=a==="none"?F:l[`${a}WickColor`];t.fillStyle=F,e.singleColor?t.strokeStyle=e.singleColor:t.strokeStyle=j;const H=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),R=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,R?g:w),t.lineTo(h,R?B:M),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,R?g:w),t.lineTo(h,R?B:M),t.moveTo(h+1,w),t.lineTo(h+1,M),t.stroke();else if(d===3){const Y=d/It;this.drawCandlesWicks(t,h+Y,g,B,w,M),c||(t.beginPath(),t.moveTo(h+Y,w),t.lineTo(h+Y,M),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,w+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const Y=i.x(n.view);this.drawCandlesWicks(t,Y,g,B,w,M-1);const Z=this.config.candlePaddingPercent,K=Math.max(V(d*Z/2),this.pixelLength),U=h+K,W=d-K*2;c||(e.singleColor&&(t.fillStyle=e.singleColor),t.fillRect(U,w,W,u)),H&&this.drawCandleBorder(t,e,l,i,U+this.halfLineWidthCU,w+this.halfLineWidthCU,W-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,n,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,n,i,r,o,a,l){if(e.singleColor)t.strokeStyle=e.singleColor;else{const c=i.name;t.strokeStyle=c==="none"?n[`${c}Color`]:n[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class jc{constructor(t){this.config=t}draw(t,e,n,i){if(n instanceof Wt){const r=e.flat(),o=n.scale.getBounds(),a=o.y+o.height;for(const l of r){t.beginPath();const c=l.name,h=this.config.barCapSize,d=n.colors.histogram;if(d===void 0)return;i.singleColor?t.fillStyle=i.singleColor:t.fillStyle=d[`${c}Bright`];const u=l.xStart(n.view),g=V(n.view.toY(l.close)),w=V(n.view.xPixels(l.width));t.fillRect(u,g,w,h);const y=t.createLinearGradient(0,g+h,0,a);i.singleColor?t.fillStyle=i.singleColor:(y.addColorStop(0,d[`${c}Cap`]),y.addColorStop(1,d[`${c}Bottom`]),t.fillStyle=y),w===0?(t.beginPath(),t.strokeStyle=y,t.moveTo(u,g+h),t.lineTo(u,a),t.stroke(),t.closePath()):t.fillRect(u,g+h,w,a-g-h)}}}}class Nc{constructor(t){this.config=t}draw(t,e,n,i){if(n instanceof Wt){const r=pt(e);ae(t,this.config.lineWidth,n,i,this.config.selectedWidth);const o=n.colors.lineTheme;t.lineCap="round",i.singleColor&&(t.strokeStyle=i.singleColor);for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a],h=c.name;i.singleColor||(t.strokeStyle=o[`${h}Color`]);const d=n.view.toX(l.centerUnit),u=n.view.toY(l.close),g=n.view.toX(c.centerUnit),w=n.view.toY(c.close);t.beginPath(),t.moveTo(d,u),t.lineTo(g,w),t.stroke()}}}}const Xc=1.5;class zc{constructor(t){this.config=t}draw(t,e,n,i){var r;t.fillStyle=(r=i.singleColor)!=null?r:this.config.mainColor;for(const o of pt(e)){t.beginPath();const a=V(n.view.toX(o.centerUnit)),l=V(n.view.toY(o.close));t.arc(a,l,Xc,0,Math.PI*2,!0),t.fill()}}}const Wc=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class Uc{constructor(t,e,n){this.drawer=t,this.config=e,this.chartBounds=n}draw(t,e,n,i){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,n,i),this.afterDraw(t,n))}beforeDraw(t){t.restore(),t.save(),Ut(t,this.chartBounds())}isChartTypeAllowed(){return Wc.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Ut(t,e.scale.getBounds())}}class Vc{constructor(t){this.chartModel=t}draw(t,e,n,i){e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o);t.fillStyle=(a=i.singleColor)!=null?a:l.color,r.forEach(c=>{const h=this.chartModel.getVisualCandle(Kt(c.centerUnit)),d=c.close;if(h&&d===1){const u=this.chartModel.scale.zoomX,g=V(dt(h.width,u)),w=V(h.bodyHeight(this.chartModel.scale)),y=h.xCenter(this.chartModel.scale)-g/2,_=h.yBodyStart(this.chartModel.scale),M=this.chartModel.config.components.chart.candlePaddingPercent,B=V(g*M/2),F=y+B,j=g-B*2;t.fillRect(F,_,j,w)}})})}}const nr=(s,t,e)=>{s.length!==0&&s.forEach((n,i)=>{const{centerUnit:r,close:o}=n,a=e.toX(r),l=e.toY(o);i===0?t.moveTo(a,l):t.lineTo(a,l)})},Gc=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,Zc=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i;function $c(s){const t=Gc.exec(s)||Zc.exec(s);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(n){return parseInt(n,16)}):e}const ir={};function Kc(s,t){let e=ir[s+t];if(!e){const n=$c(s);e=n&&"rgba("+n.join(",")+","+t+")",ir[s+t]=e}return e}class qc{constructor(){}draw(t,e,n,i){n.config.visible&&(e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o);ae(t,l.lineWidth,n,i,l.hoveredLineWidth);const c=(a=i.singleColor)!=null?a:l.color;t.strokeStyle=c,this.drawLine(t,r,n.view)}),n.linkedDataSeriesModels.forEach((r,o)=>{if(or(r.config.type)&&or(n.config.type)&&r.config.visible){const a=[],l=n,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)=>{const g=Math.min(d.length,h[u].length);for(let _=0;_<g;_++){const M=[d[_].clone(),h[u][_].clone()];a.push({diffPoints:M})}const w=l.getPaintConfig(u).color,y=r.getPaintConfig(o).color;this.drawDifference(t,w,y,a,l,r,i)})}}))}drawLine(t,e,n){t.beginPath(),nr(e,t,n),t.stroke()}drawDifference(t,e,n,i,r,o,a){const[l,c]=[[],[]];i.forEach(u=>{const[g,w]=u.diffPoints;l.push(g),c.push(w)});const h=rr(l,r.view),d=rr(c,o.view);this.fillCloud(t,n,h,d,a),this.fillCloud(t,e,d,h,a)}fillCloud(t,e,n,i,r){var o,a,l,c;t.save(),t.beginPath();const h=(a=(o=fe(n))==null?void 0:o.x)!=null?a:0,d=(c=(l=wt(n))==null?void 0:l.x)!=null?c:0;t.lineTo(h,0),n.forEach(u=>{t.lineTo(u.x,u.y)}),t.lineTo(d,0),t.closePath(),t.clip(),t.beginPath(),n.forEach((u,g)=>{g===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.singleColor?r.singleColor:Kc(e||"#383838",.3),t.fill(),t.restore()}}const rr=(s,t)=>s.map(e=>{const{centerUnit:n,close:i}=e,r=t.toX(n),o=t.toY(i);return{x:r,y:o}}),or=s=>s==="DIFFERENCE";class Jc{constructor(){}draw(t,e,n,i){const r=n.view.toY(0);e.forEach((o,a)=>{var l;const c=n.getPaintConfig(a);ae(t,c.lineWidth,n,i,c.hoveredLineWidth),t.strokeStyle=(l=i.singleColor)!=null?l:c.color,t.beginPath(),o.forEach(h=>{const d=n.view.toX(h.centerUnit),u=n.view.toY(h.close);t.moveTo(d,nt(r)),t.lineTo(d,nt(u))}),t.stroke()})}}class Qc{constructor(){}draw(t,e,n,i){e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o);ae(t,l.lineWidth,n,i,l.hoveredLineWidth),t.strokeStyle=(a=i.singleColor)!=null?a:l.color,this.drawLinePath(t,r,n.view)})}drawLinePath(t,e,n){t.beginPath(),nr(e,t,n),t.stroke()}}class th{constructor(){}draw(t,e,n,i){e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o),c=l.lineWidth;t.fillStyle=(a=i.singleColor)!=null?a:l.color,t.lineWidth=1,r.forEach(h=>{t.beginPath();const d=n.view.toX(h.centerUnit),u=n.view.toY(h.close);t.arc(d,u,c,0,Math.PI*2),t.fill()})})}}class eh{constructor(t){this.config=t}draw(t,e,n,i){t.save(),e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o);t.fillStyle=(a=i.singleColor)!=null?a:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,r.forEach(h=>{const d=n.getTextForPoint(h),u=yt(d,t,c),g=Ht(c,t),w=n.view.toX(h.centerUnit)-u/2,y=n.view.toY(h.close)+g;t.fillText(d,w,y)})}),t.restore()}}class sh{constructor(){}draw(t,e,n,i){e.forEach((r,o)=>{var a;const l=n.getPaintConfig(o);t.fillStyle=(a=i.singleColor)!=null?a:l.color,r.forEach(c=>{const h=n.view.toX(c.centerUnit),d=n.view.toY(c.close);this.drawCandleTriangle(t,h,d,l.lineWidth)})})}drawCandleTriangle(t,e,n,i){t.beginPath(),t.moveTo(e-i/2,n),t.lineTo(e,n-i),t.lineTo(e+i/2,n),t.fill()}}const Hs="resized_local",Ge="draw",Vf="draw_last_candle",le={width:20,height:20};class ar{constructor(t,e,n,i,r,o={}){this.eventBus=t,this.canvas=e,this.drawingManager=n,this.resizer=r,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.type=ks;var a;i.push(this),this.parent=rh(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:n}=t,i=window.devicePixelRatio;this.canvas.style.height=n+"px",this.canvas.style.width=e+"px",this.canvas.width=e*i,this.canvas.height=n*i,this.width=e,this.height=n,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 n=e.height;n!==this.height&&(t.style.height=n+"px",this.height=n,t.height=n,this.prevHeight=n)}getChartResizerElement(){var t;return(t=this.resizer)!=null?t:this.parent}isReady(){return this.width>le.width&&this.height>le.height}}const ks={name:"candle"},nh={candle:ks,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function ih(s,t,e,n,i,r,o){var a;const l=ce(s,t,i,r,o,e);return l.type=(a=nh[n])!=null?a:ks,l}function ce(s,t,e,n,i,r,o){const a=new ar(s,t,n,i,r,o);return lr(a,e),a}function lr(s,t){const e=s.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",s.width=t.fixedSize.width,s.height=t.fixedSize.height),e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.direction="ltr"}function rh(s){let t=s;for(;t;){if(t.nodeType===1&&t.hasAttribute("data-chart-container"))return t;if(t.parentElement!==null)t=t.parentElement;else break}return t}let Ys=!1,js=0;const Ze=new Map,Ns=new Map,cr=()=>{Ys||(Ys=!0,js=requestAnimationFrame(()=>{Ns.forEach((s,t)=>{s(),Ns.delete(t)}),Ze.forEach((s,t)=>{s(),Ze.delete(t)}),Ys=!1}))},hr=(s,t)=>{Ze.set(s,t),cr()},Kf=s=>{Ze.delete(s)},Xs=(s,t)=>{Ns.set(s,t),cr()},$e="HIT_TEST_",qf=null;class oh{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${Ct()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(n=>{n.indexOf($e)!==-1&&this.drawersMap[n].draw()})},t.on(Ge,n=>{e.wasResized()&&(this.canvasIdsList&&(n&&n.length!==0?this.canvasIdsList=this.canvasIdsList.concat(n):this.canvasIdsList=void 0),hr(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf($e)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf($e)===-1){const n=this.drawersMap[e];if(!t||t.length===0){n.draw();return}La(t,n.getCanvasIds()).length&&n.draw()}})}isDrawable(){var t,e,n,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>le.width&&((i=(n=this.chartResizeHandler.previousBCR)==null?void 0:n.width)!=null?i:0)>le.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=Ct()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,n){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(e);this.drawingOrder.splice(i,1);const r=this.drawingOrder.indexOf(n);this.drawingOrder.splice(r+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,n){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(n);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 n=this.drawingOrder.indexOf(e);n!==-1&&this.drawingOrder.splice(n,1)}})}reorderDrawers(t){this.drawingOrder=Xn(this.drawingOrder,t)}}class dr{static paneResizer(t){return`PANE_RESIZER_${t}`}}class ah{constructor(t,e,n){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=n}draw(){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),Ut(t,e.getBounds()),e.dataSeries.forEach(n=>this.drawSeries(t,n)),t.restore()})}drawSeries(t,e){if(e.config.visible){const n=e.config.type,i=this.seriesDrawers[n];if(i){const r={singleColor:this.canvasModel.idToColor(e.htId),forceBold:7};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const ur={disableChartPanning:!0};class gr extends X{constructor(t,e,n,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=n,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o),this.dragComponentOptions.disableChartPanning&&this.chartPanComponent.deactivatePanHandlers()},this.onDragTick=o=>{this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels),this.dragComponentOptions.disableChartPanning&&this.chartPanComponent.activateChartPanHandlers())}}doActivate(){super.doActivate()}doDeactivate(){super.doDeactivate()}}class Ke extends gr{constructor(t,e,n,i,r=ur){super(t,e,n,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))}doDeactivate(){super.doDeactivate()}}const lh="BASELINE_RESIZER";class ch extends X{constructor(t,e,n,i,r,o,a){super(),this.chartModel=t,this.canvasModel=n,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.baselineYPercents=50,this.ht=Es.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(x.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&ll(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new Ke(this.ht,{onDragTick:this.dragTickCb},i,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(x.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(x.CHART),e=this.canvasBoundContainer.getBounds(x.Y_AXIS);this.resizerBounds.x=t.x,this.resizerBounds.width=t.width+e.width,this.resizerBounds.height=this.config.components.baseline.height;const n=t.y+t.height*(this.baselineYPercents/100);this.resizerBounds.y=n,this.canvasBoundContainer.bounds[lh]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(x.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const qe=s=>{var t;const e=ue(s.close,s.open,s.hi,s.lo);if(!isFinite(e))throw new Error("Received candle without any price");const n=ue(s.hi,Math.max(s.open,s.close),e),i=ue(s.lo,Math.min(s.open,s.close),e),r=ue(s.open,s.lo,e),o=ue(s.close,s.hi,e);return{hi:n,lo:i,open:r,close:o,timestamp:s.timestamp,volume:(t=s.volume)!=null?t:0,expansion:s.expansion,idx:s.idx,impVolatility:s.impVolatility}},zs=s=>{for(let t=0;t<s.length;++t)s[t].idx=t},fr=s=>{s.forEach(t=>{t.idx=void 0})};class hh{constructor(){}draw(t,e,n){const i=n.view.toY(0),r=pt(e),o=[[],[]];r.forEach((a,l,c)=>{o[a.close<this.previousValue(c,l)?1:0].push(a)}),o.forEach((a,l)=>{const c=n.getPaintConfig(l);t.strokeStyle=l===0?c.color:c.aditionalColor||"#FF00FF",t.lineWidth=c.lineWidth,t.beginPath(),a.forEach(h=>{const d=n.view.toX(h.centerUnit),u=n.view.toY(h.close);t.moveTo(d,nt(i)),t.lineTo(d,nt(u))}),t.stroke()})}previousValue(t,e){do e--;while(e>=0&&!isFinite(t[e]&&t[e].close));return t[e]?t[e].close:Number.NaN}}var dh=Object.defineProperty,pr=Object.getOwnPropertySymbols,uh=Object.prototype.hasOwnProperty,gh=Object.prototype.propertyIsEnumerable,mr=(s,t,e)=>t in s?dh(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,fh=(s,t)=>{for(var e in t||(t={}))uh.call(t,e)&&mr(s,e,t[e]);if(pr)for(var e of pr(t))gh.call(t,e)&&mr(s,e,t[e]);return s};class ph{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class mh extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u,g,w){super(),this.chartModel=t,this.canvasModel=e,this.config=n,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=g,this.chartResizeHandler=w,this._dataSeriesDrawers={},this.backgroundDrawPredicateSubj=new Tt(!0),this.strToBarType=_=>{var M;return(M=this.barTypeValues.find(B=>B===_))!=null?M:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new ch(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const y=new ah(this._dataSeriesDrawers,this.hitTestCanvasModel,d);this.drawingManager.addDrawerBefore(y,$e+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new Kl(c,this.config,()=>this.backgroundDrawPredicateSubj.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(x.PANE_UUID(q),n.components.chart.cursor),this.dataSeriesDrawer=new Fc(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,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)})),this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(()=>{this.backgroundDrawPredicateSubj.next(!1)})),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawPredicateSubj.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",ki),this.registerCandlesTransformer("trend",Yi),this.registerCandlesTransformer("hollow",ql),this.registerCandlesTransformer("line",Jl)}get barTypeValues(){return Si(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 Yc(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new Hc(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new Nc(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new zc(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new Bc(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new kc(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new jc(this.config.components.chart.histogram));const e=x.PANE_UUID(q),n=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new Qc),this.registerDataSeriesTypeDrawer("HISTOGRAM",new Jc),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new hh),this.registerDataSeriesTypeDrawer("POINTS",new th),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new Uc(new Vc(this.chartModel),this.config,n)),this.registerDataSeriesTypeDrawer("TEXT",new eh(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new sh),this.registerDataSeriesTypeDrawer("DIFFERENCE",new qc)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(fh({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e,n=!0){return this.chartModel.setTimestampRange(t,e,n)}setXScale(t,e,n=!0){return this.scale.setXScale(t,e,n)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.fireDraw()}setMainSeries(t){var e;const n=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument;this.chartModel.mainCandleSeries.instrument=n,this.chartModel.setAllSeries({candles:t.candles,instrument:n},this.chartModel.getSecondarySeries().map(i=>{var r;const o=(r=i.instrument)!=null?r:this.chartModel.mainCandleSeries.instrument,a=i.dataPoints;return fr(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(n)}setSecondarySeries(t){var e;const n=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,n);if(this.updatePriceIncrementsIfNeeded(n),i)return i}setAllSeries(t,e=[]){var n;const i=(n=t.instrument)!=null?n: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)}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||!Bt.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[Bt.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}}class vr extends Wt{constructor(t,e,n,i,r,o,a,l,c,h){super(e,n,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}}const vh=s=>t=>{if(t.length!==0){const e=t.slice(Math.max(t.length-s.state.defaultViewportItems,0)),n=e[0],i=e[e.length-1];s.setXScale(n.startUnit,i.startUnit+i.width+s.offsets.right),s.doAutoScale(!0),s.recalculateZoomXYRatio(),s.fireChanged()}},bh=(s,t)=>(e,n=null)=>{const[i,r]=e,o=t.candleFromTimestamp(i).startUnit,a=t.candleFromTimestamp(r).startUnit,l=n===null?0:t.mainCandleSeries.meanCandleWidth*2,c=n?o-l:o+l,h=n?a+l:a-l;s.setXScale(c,h)};var Ch=Object.defineProperty,wh=Object.defineProperties,yh=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,Sh=Object.prototype.hasOwnProperty,xh=Object.prototype.propertyIsEnumerable,Cr=(s,t,e)=>t in s?Ch(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,xe=(s,t)=>{for(var e in t||(t={}))Sh.call(t,e)&&Cr(s,e,t[e]);if(br)for(var e of br(t))xh.call(t,e)&&Cr(s,e,t[e]);return s},Ws=(s,t)=>wh(s,yh(t));class _h{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,n)=>Ws(xe({},e),{[n]:0}),{})}createColorPool(t){return t.reduce((e,n,i)=>(e[`color${i}`]=Ws(xe({},Ce(this.config.colors)),{lineTheme:xe({},n.lineTheme),areaTheme:xe({},n.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,n="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,n=i);return this.usedChartColors[n]=this.usedChartColors[n]+1,this.symbolsToColorKeys[t]=n,this.secondaryChartColorsPool[n]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var n,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=Ws(xe({},e),{lineTheme:Object.assign(r.lineTheme,(n=o.lineTheme)!=null?n:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var Ph=Object.defineProperty,wr=Object.getOwnPropertySymbols,Th=Object.prototype.hasOwnProperty,Mh=Object.prototype.propertyIsEnumerable,yr=(s,t,e)=>t in s?Ph(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Je=(s,t)=>{for(var e in t||(t={}))Th.call(t,e)&&yr(s,e,t[e]);if(wr)for(var e of wr(t))Mh.call(t,e)&&yr(s,e,t[e]);return s};class Ah extends X{constructor(t,e,n,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=n,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.nextCandleTimeStampSubject=new I,this.chartTypeChanged=new I,this.mainInstrumentChangedSubject=new I,this.offsetsChanged=new I,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new _h(this.config);const d=new vr(this.chartBaseModel,this.paneManager.panes[q].mainExtent,Ct(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new ph,this.candlesTransformersByChartType,this.candleWidthByChartType,Je({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),o.addXConstraint((u,g)=>pc(g,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=vh(o),this.timeFrameViewportTransformer=bh(o,this),this.pane=this.paneManager.panes[q]}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(x.PANE_UUID(q)).pipe(Lt(di)).subscribe(t=>{this.handleChartResize(t)}))}handleChartResize(t){if(t.width>le.width&&t.height>le.height){const e=this.getEffectiveChartWidth(),n=this.getEffectiveYAxisWidth();if(this.prevChartWidth===0){this.scale.isViewportValid()?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=n;return}if(n!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=Yt(n-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-r)}else this.scale.recalculateZoomX();this.prevYWidth=n,this.prevChartWidth=e;return}const i=Yt(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-i,this.scale.xEnd),this.scale.recalculateZoomY(),this.prevYWidth=n,this.prevChartWidth=e}}setMainCandleSeries(t,e){this.mainCandleSeries.instrument=e,this.setAllSeries({candles:t,instrument:e},this.getSecondarySeries().map(n=>{const i=n.dataPoints;return fr(i),{candles:i,instrument:n.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,n=!0){const i=Qe(t.map(qe)),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,n&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var n;this.mainCandleSeries.instrument=(n=t.instrument)!=null?n:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=Qe(t.candles.map(qe));this.mainCandleSeries.clearData(),zs(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.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=Je({},t),t.instrument||(t.instrument=this.mainCandleSeries.instrument);const n=[t,...e];if(!this.candleSeries.every(l=>n.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=Qe(t.candles.map(qe)),r=xr(this.mainCandleSeries.dataPoints,i),o=r.candles;zs(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const g=Qe(l.candles.map(qe)),w=xr((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],g).candles;return this.setSecondaryCandleSeries(w,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(n=>{const i=zt(n.dataPoints,t,o=>o.timestamp),r=i.exact?i.index:i.index+1;n.dataPoints=n.dataPoints.slice(0,r)})}),this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}createSecondaryCandleSeriesModel(t){const e=Je(Je({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const n=new Wt(this.paneManager.panes[q].mainExtent,Ct(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,t,this.candlesTransformersByChartType,this.candleWidthByChartType,e);return n.config.type="line",this.candleSeries.push(n),n}removeSecondaryCandleSeries(t){return this.secondaryChartColors.addColorToPool(t.instrument.symbol),this.candleSeries=this.candleSeries.filter(e=>e!==t),t.deactivate(),this.paneManager.panes[q].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const n=[];return t.forEach(i=>{var r;const o=(r=i.idx)!=null?r:0,a=e[o];if(a)n.push(a);else{let l=Sr(e,o,-1);if(l||(l=Sr(e,o,1)),l){const c=xl(l,o,!0);n.push(c)}}}),n}updateSecondaryCandleSeriesConfig(t,e,n){const i=Dt(t,Ye().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=n,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}getEffectiveYAxisWidth(){return this.canvasBoundsContainer.getBounds(x.PANE_UUID_Y_AXIS(q)).width}getEffectiveChartWidth(){return this.canvasBoundsContainer.getBounds(x.PANE_UUID(q)).width}getEffectiveChartHeight(){return this.canvasBoundsContainer.getBounds(x.PANE_UUID(q)).height}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),n=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=n.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,n=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,n)}candleFromUnit(t,e=!1,n=this.mainCandleSeries){var i,r;const o=zt(n.visualPoints,t,d=>d.startUnit),a=n.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=Kt((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?ye(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:ye(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e=!0,n=this.mainCandleSeries){const i=n.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,i)}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,n,i;const r=t-((i=(n=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:n.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,n=!0){const i=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),o=r.startUnit+r.width;return this.scale.setXScale(i,o,n)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return wt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return wt(t)}getMaxCandlesFitLength(){return nt(this.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((n,i)=>{const r=i.timestamp,o=be(r,!1,t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,n[o.index]=i),n},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const n=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=be(h.timestamp,!0,o,this.getPeriod()),g=Math.min(u.index,o.length);a=a||g===o.length,o[g]=h,h.idx=g,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(g);const w=g>=o.length-1,y=c&&h.timestamp<c.timestamp;if(w&&!y&&(c=h),a&&c&&n&&l){const _=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:ji;this.scale.moveXStart(this.scale.xStart+_(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.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return ft(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=0,e){let n=this.getCandles().slice();const i=this.getCandlesCount(),r=e!=null?e:i+this.FAKE_CANDLES_DEFAULT;n=n.slice(Math.max(0,t),Math.min(i,r));const o=[],a=[];for(let c=i;c<r;c++)o.push(ye(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=t;c<l;c++)a.push(ye(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...a,...n,...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 n=t.slice(),i=[];return e.forEach(r=>{const a=be(r.timestamp,!1,t).index;a<0?i.push(r):t[a].timestamp===r.timestamp?n[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...n]}}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){const n=this.findSeriesBySymbol(e);if(n.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}n.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),zs(i.dataPoints),i.recalculateVisualPoints()}),this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const Qe=s=>s.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Sr=(s,t,e)=>{if(t>=s.length)return s[s.length-1];for(let n=t;n<s.length&&n>=0;n+=e){const i=s[n];if(i)return i}},xr=(s,t)=>{const e=s.slice(),n=[],i=[];return t.forEach(r=>{const a=be(r.timestamp,!0,s).index;a<0?n.push(r):a>=s.length?i.push(r):s[a].timestamp===r.timestamp?e[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:n,appended:i,candles:[...n,...e,...i]}};class _e{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class Us{constructor(t){this.drawers=t!=null?t:new Map}draw(){this.drawers.forEach(t=>t.draw())}addDrawer(t,e){const n=e!=null?e:"drawer"+this.drawers.size;this.drawers.set(n,t)}drawLastBar(){this.drawers.forEach(t=>t.drawLastBar&&t.drawLastBar())}removeDrawer(t){const e=yi(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=yi(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=pt(Array.from(this.drawers).map(([,n])=>n.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class Eh{constructor(t,e,n){this.model=t,this.crossToolCanvasModel=e,this.crossToolTypeDrawers=n}draw(){const t=this.crossToolTypeDrawers[this.model.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.model.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}class Lh extends X{constructor(t,e,n,i){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=n,this.hoverProducer=i,this.currentHoverSubject=new Tt(null),this.type="cross-and-labels",this.type=t.type}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.type=t}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?this.updateHover(t):this.currentHover=null,this.fireDraw()}))}fireDraw(){this.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateHover(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===q)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)}}const Mt=4;function Dh(s,t,e,n,i,r,o,a=!0){var l,c,h,d,u,g,w;const y=r.align,_=(l=i.textFont)!=null?l:Jt(r),M=i.bgColor,B=(c=i.textColor)!=null?c:qt(M,o.labelTextColor,o.labelInvertedTextColor),F=(h=i.paddingTop)!=null?h:Mt,j=(d=i.paddingBottom)!=null?d:Mt,H=(u=i.paddingEnd)!=null?u:Mt,R=Kt(Ht(_,s)/2),Y=n-R-F,K=n+R+j-Y;if(a&&!ts(n,t,K))return;s.save(),s.fillStyle=M,s.strokeStyle=M;const U=Kt(t.width/6),W=y==="right"?t.x:t.x+t.width,J=y==="right"?W+U:W-U,Q=r.labelBoxMargin.end,tt=Q-H,et=t.width-U-tt;Oc(s,J,Y,W,Y+Kt(K/2),J,Y+K,et,(w=(g=r.typeConfig.badge)==null?void 0:g.rounded)!=null?w:!1,y),s.fillStyle=B,s.font=_;const it=y==="right"?t.x+t.width-yt(e,s,_)-Q:t.x+Q;s.fillText(e,it,n+R-1),s.restore()}function Ih(s,t,e,n,i,r,o,a=!0){var l,c,h,d,u,g,w,y,_,M,B;const F=r.align,j=(l=i.textFont)!=null?l:Jt(r),H=i.bgColor,R=(c=i.textColor)!=null?c:qt(H,o.labelTextColor,o.labelInvertedTextColor),Y=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,Z=(u=(d=i.paddingTop)!=null?d:Y==null?void 0:Y.top)!=null?u:Mt,K=(w=(g=i.paddingBottom)!=null?g:Y==null?void 0:Y.bottom)!=null?w:Mt,U=(_=(y=i.paddingEnd)!=null?y:Y==null?void 0:Y.end)!=null?_:Mt,W=i.paddingStart,J=Ht(j,s),Q=n-J/2-Z,et=n+J/2+K-Q,it=(B=i.rounded)!=null?B:(M=r.typeConfig.rectangle)==null?void 0:M.rounded;if(a&&!ts(n,t,et))return;s.save(),s.fillStyle=H,s.strokeStyle=H;const ot=r.labelBoxMargin.end;s.font=j;const St=yt(e,s,j),xt=ot-U,_t=W!==void 0?St+W+U:t.width-xt,se=F==="right"?t.x+t.width-xt-_t:t.x+xt,Ae=F==="right"?t.x+t.width-St-ot:ot;it?tr(s,se,Q,_t,et,4,!0):s.fillRect(se,Q,_t,et),s.fillStyle=R,s.fillText(e,Ae,n+J/2-1),s.restore()}function Bh(s,t,e,n,i,r,o,a=!0,l){var c,h,d,u,g,w,y,_,M;const B=r.align,F=(c=i.textFont)!=null?c:Jt(r),j=i.bgColor,H=(h=i.textColor)!=null?h:qt(j,o.labelTextColor,o.labelInvertedTextColor),R=(d=r.typeConfig.rectangle)==null?void 0:d.paddings,Y=(g=(u=i.paddingTop)!=null?u:R==null?void 0:R.top)!=null?g:Mt,Z=(y=(w=i.paddingBottom)!=null?w:R==null?void 0:R.bottom)!=null?y:Mt,K=(M=(_=i.paddingEnd)!=null?_:R==null?void 0:R.end)!=null?M:Mt,U=i.paddingStart,W=Ht(F,s),J=n-W/2-Y,tt=n+W/2+Z-J;if(a&&!ts(n,t,tt))return;s.save(),s.fillStyle=j,s.strokeStyle=j;const et=r.labelBoxMargin.end;s.font=F;const it=yt(e,s,F),ot=et-K,St=U!==void 0?it+U+K:t.width-ot,xt=B==="right"?t.x+t.width-ot-St:t.x+ot,_t=B==="right"?t.x+t.width-it-et:et;l&&Ve(l,s,xt,J,St,tt),s.fillStyle=H,s.fillText(e,_t,n+W/2-1),s.restore()}function Oh(s,t,e=Mt){return Ht(s,t)/2+e}function ts(s,t,e){return!(s<t.y+e/2||s>t.y+t.height-e/2)}const Rh="badge",_r=4,Pr={badge:Dh,rectangle:Ih,plain:Bh};function Tr(s,t,e,n,i,r,o,a){var l,c,h,d,u;const g=i.y,w=i.labelText,y=(l=i.mode)!=null?l:"label",_=(c=i.labelType)!=null?c:Rh,M=i.description,B=(h=i.textFont)!=null?h:Jt(o),F=i.bgColor,j=(d=i.lineColor)!=null?d:F,H=yt(M!=null?M:"",s,B)+8,R=nt(i.y),Y=Ht(B,s),Z=g-Y/2,U=g+Y/2-Z;s.save(),s.fillStyle=F,s.strokeStyle=j;const W=r.getBounds(x.PANE_UUID(q)),J=Pr[_],Q=o.labels.descriptions,tt=Fh(e,R,U),et=()=>Q&&Hh(t,s,e,n,i,o.align,o);let it,ot;const St=2;o.align==="right"?(it=W.x,ot=Q?W.x+W.width-H:W.x+W.width+St):(it=Q?W.x+H:W.x-St,ot=W.x+W.width);const xt=(u=i.lineY)!=null?u:i.y,_t=()=>tt&&te(s,()=>Rc(s,it,xt,ot,xt,1)),se=()=>J(s,e,w,g,i,o,a,!1,t),wf={line:()=>{_t(),et()},"line-label":()=>{_t(),se(),et()},label:()=>{et(),se()}};y!=="none"&&ts(g,e,U)&&wf[y](),s.restore()}const Fh=(s,t,e)=>t>s.y+e/2&&t<s.y+s.height-e/2;function Hh(s,t,e,n,i,r="right",o){var a,l,c;const h=i.description;if(!h||h.length===0)return;const d=i.y,u=Jt(o),g=yt(h,t,u),w=Ht(u,t),y=(a=i.paddingTop)!=null?a:_r,_=(l=i.paddingBottom)!=null?l:_r,M=d-w/2-y,F=d+w/2+_-M;t.save();const j=g+5,H=4,R=g+H*2,Y=n.x+n.width,Z=r==="right"?Y-R:n.x+H;Ve(s,t,Z,M,j,F,.8),t.fillStyle=(c=i.descColor)!=null?c:i.bgColor,t.font=u;const K=r==="right"?Y-g-H*2:n.x+H*2;t.fillText(h,K,d+w/2-1),t.restore()}class Mr{constructor(t,e,n,i,r=()=>!0,o){this.config=t,this.canvasBoundsContainer=e,this.paneManager=n,this.backgroundCanvasModel=i,this.crossDrawPredicate=r,this.noLines=o}draw(t,e){this.crossDrawPredicate()&&te(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var n,i,r,o,a;const l=this.canvasBoundsContainer.getBounds(x.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(x.ALL_PANES,{extensionY:1e-4}),h=(n=this.config.components.xAxis.padding.top)!=null?n: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,g=(a=this.paneManager.panes[e.paneId])==null?void 0:a.ht;if(c(e.x,l.y)){const w={start:[l.x,e.y],end:[l.x+l.width+u,e.y]},y={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},_=g==null?void 0:g(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),_&&(t.moveTo(...w.start),t.lineTo(...w.end)),t.moveTo(...y.start),t.lineTo(...y.end),t.stroke()),_&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var n,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,g=t.measureText(u).width,w=this.config.components.xAxis.fontSize,y=this.canvasBoundsContainer.getBounds(x.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const _=(n=l==null?void 0:l.left)!=null?n:0,M=(i=l==null?void 0:l.right)!=null?i:0,B=(r=l==null?void 0:l.top)!=null?r:0,F=(o=l==null?void 0:l.bottom)!=null?o:0,j=(a=c==null?void 0:c.top)!=null?a:0,H=g+_+M,R=w+B+F,Y=Math.max(d-H/2,0),Z=y.y+j;tr(t,Y,Z,H,R),t.fillStyle=h.labelTextColor;const K=Math.max(d-g/2,_),U=y.y+j+w+B-1;t.fillText(u,K,U),t.restore()}}drawYLabel(t,e){const n=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(x.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=Pr[a],g=a==="plain"?i.lineColor:i.labelTextColor;u(t,d,h,o,{textColor:g,bgColor:i.labelBoxColor,paddingBottom:n==null?void 0:n.bottom,paddingEnd:n==null?void 0:n.end,paddingTop:n==null?void 0:n.top},l.yAxis.state,this.config.colors.yAxis,!0,this.backgroundCanvasModel.ctx)}}}}class kh{draw(){}}class Yh extends X{constructor(t,e,n,i,r,o,a,l){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=n,this.drawingManager=i,this.paneManager=r,this.backgroundCanvasModel=l,this.crossToolTypeDrawers={},this.model=new Lh(t.components.crossTool,this.crossToolCanvasModel,o,a),this.addChildEntity(this.model);const c=new _e(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const h=new Eh(this.model,this.crossToolCanvasModel,this.crossToolTypeDrawers),d=new Us;d.addDrawer(c,"CLEAR_CANVAS"),d.addDrawer(h,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(d,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new Mr(this.config,this.canvasBoundsContainer,this.paneManager,this.backgroundCanvasModel,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new Mr(this.config,this.canvasBoundsContainer,this.paneManager,this.backgroundCanvasModel,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new kh)}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 jh{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,n])=>{for(const i of n){const{model:r,drawer:o}=i;o.draw(this.canvasModel,r,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class jt{constructor(t){this.data=t,this.next=null}}class Nh{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 jt(t);if(this.head===null)this._head=e;else{let n=this.head;for(;n.next;)n=n.next;n.next=e}this._tail=e,this.length++}insertAt(t,e){if(!this.head||t<0||t>this.length)return null;const n=new jt(e);if(t===0)n.next=this.head,this._head=n;else{let i=this.head,r=i,o=0;for(;i&&o<t;)o++,r=i,i=i.next;n.next=i,r.next=n,t===this.length-1&&(this._tail=n)}this.length++}removeAt(t){if(!this.head||t<0||t>=this.length)return null;let e=this.head,n=e,i=0;if(t===0)this._head=e.next;else{for(;e.next&&i<t;)i++,n=e,e=e.next;n.next=e.next,t===this.length-1&&(this._tail=n)}this.length--}getNodePosition(t){let e=0,n=this.head;for(;n;){if(n.data===t.data)return e;n=n.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 Xh extends X{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._objects=new Tt({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const n=e.paneId,r=this.objects[n];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[n,i]=e,r=new jt(n);return i.getNodePosition(r)}addObject(t){var e;const n=t.paneId,i=this.objects,r=(e=i[n])!=null?e:new Nh;Object.keys(i).find(o=>o===n)||(i[n]=r),r.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.setDynamicObjects(i)}removeObject(t){const e=this.getObjectInfoById(t);if(!e)return;const[n,i]=e,r=new jt(n),o=i.getNodePosition(r);i.removeAt(o),this.modelIdToObjectMap.delete(t),i.size()===0&&delete this.objects[n.paneId],this.setDynamicObjects(this.objects)}moveToPosition(t,e){const n=this.getObjectInfoById(t);if(!n)return;const[i,r]=n,o=new jt(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[n,i]=e,r=new jt(n),o=i.getNodePosition(r);o>=0&&o<i.size()&&(i.removeAt(o),i.insertAtEnd(n),this.setDynamicObjects(this.objects))}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[n,i]=e,r=new jt(n),o=i.getNodePosition(r);o>0&&o<=i.size()&&(i.removeAt(o),i.insertAt(0,n),this.setDynamicObjects(this.objects))}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[n,i]=e,r=new jt(n),o=i.getNodePosition(r);o>=0&&o+1<i.size()&&(i.removeAt(o),i.insertAt(o+1,n),this.setDynamicObjects(this.objects))}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[n,i]=e,r=new jt(n),o=i.getNodePosition(r);o>0&&o<i.size()&&(i.removeAt(o),i.insertAt(o-1,n),this.setDynamicObjects(this.objects))}get objects(){return this._objects.getValue()}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class zh extends X{constructor(t,e){super();const n=new Xh(t);this.model=n,this.addChildEntity(n);const i=new jh(n,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Wh=()=>s=>s.toString(),Uh=(s,t)=>{var e;const n="date.get"+(t((e=s.timezone)!=null?e:"")?"":"UTC"),i={YYYY:o("FullYear"),YY:o("FullYear")+" % 100",MMM:a("shortMonths","Month"),MMMM:l(a("shortMonths","Month")),M:"1+"+o("Month"),d:o("Date"),H:o("Hours"),m:o("Minutes"),s:o("Seconds"),sss:o("Milliseconds"),EEE:a("shortDays","Day"),SSS:"this.addTwoZeros("+o("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(h){i[h+h]="this.addZero("+i[h]+")"});const r=new RegExp(Object.keys(i).sort().reverse().join("|"),"g");function o(h){return n+h+"()"}function a(h,d){return"this."+h+"["+o(d)+"]"}function l(h){return h+".toUpperCase()"}function c(h){return"' + ("+i[h]+") + '"}return function(h){var d;const u={shortDays:Vh(s),shortMonths:Gh(s),addZero(g){return g<10?"0"+g:g},addTwoZeros(g){return(g<100?"0":"")+(g<10?"0":"")+g},tzDate:t((d=s.timezone)!=null?d:"")||function(g){return g instanceof Date?g:new Date(+g)}};return new Function("date","date=this.tzDate(date); return '"+h.replace(r,c)+"'").bind(u)}};function Vh(s){var t;return(t=s.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function Gh(s){var t;return(t=s.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const Ar=(s,t,e)=>{if(s){if(typeof s=="string")return e(s);if(Array.isArray(s)){const n=s.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(n.length>0){const i=n[0];if(i.format)return e(i.format);if(i.customFormatter)return i.customFormatter}}}return Wh()},Zh={"rhombus-small":4,rhombus:6,"rhombus-large":8},Pe=(s,t)=>`${s}_${t}`;class $h{constructor(t,e,n,i,r,o,a){this.backgroundCanvas=t,this.canvasModel=e,this.chartModel=n,this.config=i,this.canvasBoundsContainer=r,this.model=o,this.formatterProvider=a,this.customIcons={};const l=this.config.components.events.icons;l&&(this.createCustomIcon("earnings",l.earnings),this.createCustomIcon("dividends",l.dividends),this.createCustomIcon("splits",l.splits),this.createCustomIcon("conference-calls",l.conferenceCalls))}createCustomIcon(t,e){if(e){const n=this.createIconImage(e.normal),i=this.createIconImage(e.hover);this.customIcons[Pe(t,"normal")]=n,this.customIcons[Pe(t,"hover")]=i}}createIconImage(t){var e;const i=new DOMParser().parseFromString(t,"text/html").querySelector("svg");let r=0;i&&(r=parseInt((e=i.getAttribute("height"))!=null?e:"",10));const l="data:image/svg+xml;base64,"+btoa(t),c=new Image;return c.src=l,{img:c,svgHeight:r}}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(x.EVENTS),e=this.canvasBoundsContainer.getBounds(x.ALL_PANES),n=this.canvasModel.ctx;n.save(),this.model.events.filter(i=>this.config.components.events.eventsVisibility[i.type]).forEach(i=>{const r=this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale);if(r>e.x&&r<e.x+e.width){const o=this.config.colors.events[i.type].color;n.strokeStyle=o,this.customIcons[Pe(i.type,"hover")]!==void 0?this.drawCustomSvgEvent(n,r,t,i):this.drawDefaultEvent(n,r,t,i,o),this.model.hoveredEvent.getValue()===i&&(n.beginPath(),n.moveTo(r,e.y),n.lineTo(r,t.y+t.height/2),n.stroke(),n.closePath(),this.config.components.xAxis.visible&&this.drawLabel(r,i))}}),n.restore()}drawCustomSvgEvent(t,e,n,i){const r=n.y+n.height/2,o=this.customIcons[Pe(i.type,"normal")],a=this.customIcons[Pe(i.type,"hover")];this.model.hoveredEvent.getValue()===i?t.drawImage(a.img,e-a.svgHeight/2,r-a.svgHeight/2):t.drawImage(o.img,e-o.svgHeight/2,r-o.svgHeight/2)}drawDefaultEvent(t,e,n,i,r){const o=n.y+n.height/2;t.fillStyle=r,t.lineWidth=1.5;const a=Vs(i);t.beginPath(),t.moveTo(e-a,o),t.lineTo(e,o-a),t.lineTo(e+a,o),t.lineTo(e,o+a),t.closePath(),this.model.hoveredEvent.getValue()===i?t.fill():t.stroke()}drawLabel(t,e){var n;const i=this.canvasModel.ctx,r=this.canvasBoundsContainer.getBounds(x.X_AXIS),o=this.config.components.xAxis.fontFamily,a=this.config.components.xAxis.fontSize,l=(n=this.config.components.xAxis.padding.top)!=null?n:0,c=r.y+a-1+l;i.font=`${a}px ${o}`;const h=this.formatterProvider()(e.timestamp),d=i.measureText(h).width;Ve(this.backgroundCanvas.ctx,i,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 Vs(s){return Zh[s.style]}const es=5;class Kh{constructor(t,e,n,i,r){this.hitTestCanvasModel=t,this.chartModel=e,this.config=n,this.canvasBoundsContainer=i,this.model=r}draw(){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(x.EVENTS);t.save(),this.model.events.forEach((n,i)=>{const r=this.model.events[i-1],o=r&&this.chartModel.candleFromTimestamp(r.timestamp).xCenter(this.chartModel.scale),a=this.chartModel.candleFromTimestamp(n.timestamp).xCenter(this.chartModel.scale);if(a>e.x&&a<e.x+e.width){const l=this.config.colors.events[n.type].color;t.strokeStyle=l,t.fillStyle=l;const c=Vs(n);t.fillStyle=this.hitTestCanvasModel.idToColor(n.id);const h=(c+es)*2;if(o!==void 0){const d=Vs(r);if(o+d>a-h/2){const g=c*2+es;t.fillRect(o+d,e.y,g,e.height)}else t.fillRect(a-c-es,e.y,h,e.height)}else t.fillRect(a-c-es,e.y,h,e.height)}}),t.restore()}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var qh=Object.defineProperty,Er=Object.getOwnPropertySymbols,Jh=Object.prototype.hasOwnProperty,Qh=Object.prototype.propertyIsEnumerable,Lr=(s,t,e)=>t in s?qh(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,td=(s,t)=>{for(var e in t||(t={}))Jh.call(t,e)&&Lr(s,e,t[e]);if(Er)for(var e of Er(t))Qh.call(t,e)&&Lr(s,e,t[e]);return s};const Dr=317,Gs={DRAWINGS:[1,199],NEWS:[200,299],DATA_SERIES:[300,2999],EVENTS:[3e3,4e3],EXECUTED_ORDERS:[4001,5e3]};class ed extends ar{constructor(t,e,n,i,r,o,a,l){super(t,e,r,a,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=n,this.canvasBoundsContainer=i,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new I,this.touchStartSubject=new I,this.dblClickSubject=new I,this.rightClickSubject=new I,this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,lr(this,o),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(x.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(ve(100,me,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),n=this.canvasInputListener.observeTouchStart().pipe(ct(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=ft(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(ct(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=ft(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(ct(()=>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(ct(()=>td({},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,n,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*Dr).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/Dr}observeHoverOnElement(){return this.hoverSubject.asObservable()}observeTouchStartOnElement(){return this.touchStartSubject.asObservable()}observeDblClickOnElement(){return this.dblClickSubject.asObservable()}observeRightClickOnElement(){return this.rightClickSubject.asObservable()}getPixel(t,e){const n=window.devicePixelRatio;return this.prevAnimationFrameId!==js&&(this.curImgData=this.ctx.getImageData(t*n,e*n,1,1).data,this.prevAnimationFrameId=js),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),n=this.colorToId(e[0]*65536+e[1]*256+e[2]),i=Number(n),[r]=Zs(this.hitTestSubscribers,i);return r==null?void 0:r.lookup(n)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const n=this.getPixel(t.x,t.y),i=this.colorToId(n[0]*65536+n[1]*256+n[2]),r=Number(i),[o]=Zs(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 n,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),[g,w]=Zs(this.hitTestSubscribers,u),y=g==null?void 0:g.lookup(d),_={point:t,model:y};switch(e){case"mousedown":y&&((n=g==null?void 0:g.onMouseDown)==null||n.call(g,y,t)),w.forEach(M=>M.onMouseDown&&M.onMouseDown(null,t));break;case"mouseup":y&&((i=g==null?void 0:g.onMouseUp)==null||i.call(g,y,t)),w.forEach(M=>M.onMouseUp&&M.onMouseUp(null,t));break;case"hover":y&&((r=g==null?void 0:g.onHover)==null||r.call(g,y,t)),w.forEach(M=>M.onHover&&M.onHover(null,t)),this.hoverSubject.next(_);break;case"touchstart":y&&((o=g==null?void 0:g.onTouchStart)==null||o.call(g,y,t)),w.forEach(M=>M.onTouchStart&&M.onTouchStart(null,t)),this.touchStartSubject.next(_);break;case"dblclick":y&&((a=g==null?void 0:g.onDblClick)==null||a.call(g,y,t)),this.dblClickSubject.next(_);break;case"contextmenu":y&&((l=g==null?void 0:g.onRightClick)==null||l.call(g,y,t)),this.rightClickSubject.next(_);break;case"zoom":y&&((c=g==null?void 0:g.onZoom)==null||c.call(g,y,t)),w.forEach(M=>M.onZoom&&M.onZoom(null,t));break;default:break}}}const Zs=(s,t)=>{let e;const n=[];return s.forEach(i=>{const[r,o]=i.getIdRange();t>=r&&t<=o?e=i:n.push(i)}),[e,n]};var sd=Object.defineProperty,nd=Object.defineProperties,id=Object.getOwnPropertyDescriptors,Ir=Object.getOwnPropertySymbols,rd=Object.prototype.hasOwnProperty,od=Object.prototype.propertyIsEnumerable,Br=(s,t,e)=>t in s?sd(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,ad=(s,t)=>{for(var e in t||(t={}))rd.call(t,e)&&Br(s,e,t[e]);if(Ir)for(var e of Ir(t))od.call(t,e)&&Br(s,e,t[e]);return s},ld=(s,t)=>nd(s,id(t));class cd extends X{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new Tt(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((n,i)=>ld(ad({},n),{id:i+e})).sort((n,i)=>n.timestamp-i.timestamp)}getIdRange(){return Gs.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 hd extends X{constructor(t,e,n,i,r,o,a,l,c){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>Ar(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const h=new cd(e);this.eventsModel=h,this.addChildEntity(h),n.addSubscriber(h);const d=new $h(c,e,i,t,r,h,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(d,"EVENTS");const u=new Kh(n,i,t,r,h);this.drawingManager.addDrawerBefore(u,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(x.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){Dt(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class dd{constructor(t,e,n,i,r,o,a,l,c=()=>!0,h){this.canvasModel=t,this.viewportModel=e,this.config=n,this.yAxisState=i,this.xBoundsProvider=r,this.yBoundsProvider=o,this.xLabelsProvider=a,this.yLabelsProvider=l,this.drawPredicate=c,this.getBaseline=h}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;te(t,()=>this.drawVertical(t)),te(t,()=>this.drawHorizontal(t)),te(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const n=this.xBoundsProvider(),i=nt(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(n.x,i),t.lineTo(n.x+n.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 n=this.xBoundsProvider(),i=n.x+n.width;for(const r of e){const o=V(this.viewportModel.toX(r.value));o>n.x&&o<i&&(t.beginPath(),t.moveTo(o,n.y),t.lineTo(o,n.y+n.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 n=this.yBoundsProvider();for(const i of e){const r=nt(this.viewportModel.toY(i.value)),o=Oh(i.text,t,Mt);r>n.y+o&&r<n.y+n.height-o&&(t.beginPath(),t.moveTo(n.x,r),t.lineTo(n.x+n.width,r),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Or extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new dd(t,e,n,i,a,l,c,h,u,d)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class ud{constructor(t,e,n,i){this.canvasModel=t,this.chartModel=e,this.config=n,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:n,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+n,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");const c=this.canvasBoundsContainer.getBounds("PANE_CHART");l.restore(),Ut(l,c)}}drawMarkerLabel(t,e,n,i){const r=this.getMarkerY(t,n,i==="low"),o=ke(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(n,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)}getMarkerText(t,e){const n=this.chartModel.pane.regularFormatter(t);return`${e==="high"?"H:":"L:"} ${n}`}getMarkerY(t,e,n=!1){const i=this.chartModel.toY(e);if(n){const r=ke(t,!1);return i+r}return i}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(x.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,n){let i=this.chartModel.toX(e);const r=this.canvasBoundsContainer.getBounds(x.CHART),o=4,a=t.measureText(n).width;return i+o+a>r.width&&(i=i-(o+a)),i+o}getCanvasIds(){return[this.canvasModel.canvasId]}}class gd extends X{constructor(t,e,n,i,r){super();const o=new ud(e,n,t,i);r.addDrawer(o,"HIGH_LOW")}}const fd=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],pd=24*60*60*1e3;class md extends X{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new I}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()+pd;ka(this.highlights,t,e,vd).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,n)=>e.to-n.to),this.highlightsUpdatedSubject.next(this.highlights),this.highlights.length?this.recalculateVisualHighlights():this.visualHighlights={}}observeHighlightsUpdated(){return this.highlightsUpdatedSubject.asObservable()}}const vd=s=>s.to,Vt=[20,10];class bd{constructor(t,e,n,i,r){this.highlightsModel=t,this.chartModel=e,this.canvasModel=n,this.canvasBoundsContainer=i,this.config=r}draw(){var t,e,n,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(x.ALL_PANES);o.save(),Ut(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=(n=this.config.components.highlights.fontSize)!=null?n:11,g=(i=this.config.components.highlights.fontFamily)!=null?i:"monospace",w=`${u}px ${g}, monospace`;o.font=w,o.lineWidth=h,o.setLineDash(d),fd.forEach(y=>{var _,M;const B=a[y];if(B){const F=this.config.colors.highlights[y],j=(_=F==null?void 0:F.border)!=null?_:"#ffffff",H=(M=F==null?void 0:F.background)!=null?M:"#ffffff";o.save(),o.beginPath(),o.fillStyle=H,o.strokeStyle=j,B.forEach(R=>{var Y,Z,K;const U=this.chartModel.candleFromTimestamp(R.from),W=dt(U.width,this.chartModel.scale.zoomX),J=U.xStart(this.chartModel.scale),Q=this.chartModel.candleFromTimestamp(R.to),tt=dt(Q.width,this.chartModel.scale.zoomX),et=Q.xStart(this.chartModel.scale)+tt;if(R.border&&this.drawBorders(R.border,o,J+W,et-tt,c),o.fillRect(J,c.y,et-J,c.y+c.height),R.label){const it=(Y=R.label.text)!=null?Y:"",ot=this.config.colors.highlights[R.type];o.save(),o.fillStyle=(Z=ot==null?void 0:ot.label)!=null?Z:"#ffffff";const St=yt(it,o,w),[xt,_t]=this.resolveHighlightLabelPosition((K=R.label.placement)!=null?K:"left-left",c,[J,et],St);o.fillText(it,xt,_t),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}resolveHighlightLabelPosition(t,e,n,i){const[r,o]=n;switch(t){case"right-left":return[o-Vt[1]-i,e.y+Vt[0]];case"left-left":return[r-Vt[1]-i,e.y+Vt[0]];case"right-right":return[o+Vt[1],e.y+Vt[0]];case"left-right":default:return[r+Vt[1],e.y+Vt[0]]}}drawBorders(t,e,n,i,r){const o=t.left,a=t.right;o&&(e.beginPath(),e.moveTo(n,r.y),e.lineTo(n,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 Cd="HIGHLIGHTS_PLUGIN";class wd extends X{constructor(t,e,n,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new md(n),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new bd(this.highlightsModel,n,i,r,e),o.addDrawer(this.highLightsDrawer,Cd)}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 yd(){return N(function(s,t){var e,n=!1;s.subscribe(Pt(t,function(i){var r=e;e=i,n&&t.next([r,i]),n=!0}))})}function $(s,t){return N(function(e,n){var i=0;e.subscribe(Pt(n,function(r){return s.call(t,r,i++)&&n.next(r)}))})}var Sd=Object.defineProperty,xd=Object.defineProperties,_d=Object.getOwnPropertyDescriptors,Rr=Object.getOwnPropertySymbols,Pd=Object.prototype.hasOwnProperty,Td=Object.prototype.propertyIsEnumerable,Fr=(s,t,e)=>t in s?Sd(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Hr=(s,t)=>{for(var e in t||(t={}))Pd.call(t,e)&&Fr(s,e,t[e]);if(Rr)for(var e of Rr(t))Td.call(t,e)&&Fr(s,e,t[e]);return s},kr=(s,t)=>xd(s,_d(t));const Nt=4;class Md{constructor(t,e,n,i,r,o){this.config=t,this.chartModel=e,this.canvasModel=n,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(x.N_MAP),n=this.canvasBoundsContainer.getBounds(x.N_MAP_BTN_L),i=this.canvasBoundsContainer.getBounds(x.N_MAP_BTN_R),r=this.canvasBoundsContainer.getBounds(x.N_MAP_KNOT_L),o=this.canvasBoundsContainer.getBounds(x.N_MAP_KNOT_R),a=this.canvasBoundsContainer.getBounds(x.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(x.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(),n.width!==0&&this.drawLeftArrowButton(c,n,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,n,a),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,n,i){t.x<=n.x+n.width&&(t.x=n.x+n.width,i.x=t.x+t.width,e.x=i.x+i.width)}drawSlider(t,e,n,i,r){this.blockDrawSliderOnLeftArrow(e,n,i,r),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,n,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(r.x,r.y,r.width,r.height)}drawLeftArrowButton(t,e,n){t.fillStyle=n.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Nt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r),t.lineTo(i+Nt,r+Nt),t.lineTo(i+Nt,r-Nt),t.fillStyle=n.colors.navigationMap.buttonArrowColor,t.fill()}drawRightArrowButton(t,e,n){t.fillStyle=n.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Nt/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r-Nt),t.lineTo(i,r+Nt),t.lineTo(i+Nt,r),t.fillStyle=n.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,n,i){const r=n.components.navigationMap.knots.border;t.fillStyle=n.colors.navigationMap.knotColor;const o=i?e.x-r:e.x+r;t.fillRect(o,e.y,e.width,e.height),t.lineWidth=n.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=n.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=n.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=pt(this.chartModel.mainCandleSeries.getSeriesInViewport()),n=this.config.components.navigationMap.timeLabels,i=n.visible;if(e.length&&i){const r=e[0].candle.timestamp,o=e[e.length-1].candle.timestamp,a=this.canvasBoundsContainer.getBounds(x.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(x.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:n.fontFamily,textSize:`${n.fontSize}px`},d={dateFormat:n.dateFormat,padding:n.padding,textProperties:kr(Hr({},h),{textAlign:"left"})},u={dateFormat:n.dateFormat,padding:n.padding,textProperties:kr(Hr({},h),{textAlign:"right"})};this.drawTimeLabel(t,a,r,d),this.drawTimeLabel(t,l,o,u)}}drawTimeLabel(t,e,n,i){const r=i.padding,o=Zn(n,i.dateFormat,this.formatterFactory);Un(t,i.textProperties);const a=ke(t),l=Gn(o);ja(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}class Te extends gr{constructor(t,e,n,i,r=ur){super(t,e,n,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))}doDeactivate(){super.doDeactivate()}}const Yr=4;class Ad extends X{constructor(t,e,n,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=n,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=g=>{const w=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART);this.leftKnotDragStartXRelative=g.x-w.x-Yr},this.leftKnotDragTick=g=>{const{delta:w}=g,_=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART).width,M=(this.leftKnotDragStartXRelative+w)/_;this.canvasBoundsContainer.leftRatio=M,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=g=>{const w=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART);this.rightKnotDragStartXRelative=g.x-w.x+Yr},this.rightKnotDragTick=g=>{const{delta:w}=g,_=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART).width,M=(this.rightKnotDragStartXRelative+w)/_;this.canvasBoundsContainer.rightRatio=M,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=g=>{const{delta:w}=g,y=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART),_=this.chartModel.mainCandleSeries.meanCandleWidth/(y.width/this.chartModel.mainCandleSeries.dataPoints.length),M=(this.lastMousePosition-w)*_;this.scale.moveXStart(this.scale.xStart-M),this.lastMousePosition=w};const a=this.canvasBoundsContainer.getBoundsHitTest(x.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(x.N_MAP_KNOT_R),c=new Te(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Te(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(x.N_MAP_SLIDER_WINDOW),u=new Te(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(x.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(x.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 n=this.chartModel.mainCandleSeries;this.canvasBoundsContainer.leftRatio=n.dataIdxStart/(n.dataPoints.length-1),this.canvasBoundsContainer.rightRatio=n.dataIdxEnd/(n.dataPoints.length-1),this.canvasBoundsContainer.recalculateNavigationMapElementBounds(),this.bus.fireDraw()}))}}class Ed extends X{constructor(t,e,n,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=n,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new Md(i,e,n,o,l,()=>this.visualCandles);a.addDrawer(d,x.N_MAP_CHART),this.navigationMapMoveHandler=new Ad(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(x.N_MAP_CHART,i.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(x.N_MAP_BTN_L,i.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(x.N_MAP_BTN_R,i.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(x.N_MAP_KNOT_L,i.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(x.N_MAP_KNOT_R,i.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(x.N_MAP_SLIDER_WINDOW,i.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(ft(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(x.N_MAP),this.chartModel.scale.xChanged.pipe(yd(),$(([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 n=this.chartModel.mainCandleSeries.dataIdxStart,i=this.chartModel.mainCandleSeries.dataIdxEnd,r=Math.round(Math.max(-n,0)),o=Math.max(this.chartModel.getCandlesCountWithRightOffset(),i)+r;let a=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(x.N_MAP_CHART),h=c.width,d=[];let u=0,g,w;for(g=0;g<h;g++)w=nt(g*o/h)-r,w in e?(d[g]=e[w].close,u=(t=d[g])!=null?t:0,a=Math.max(a,u),l=Math.min(l,u)):d[g]=0;return a-=l,d.map((y,_)=>[_+c.x,(a+l-y)*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(Hs),this.canvasModel.fireDraw())}}class Ld extends X{constructor(t,e,n){super(),this.scale=t,this.canvasInputListeners=e,this.mainCanvasParent=n,this.touchedCandleIndexes=[0,0]}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart().subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove().subscribe(t=>this.handleTouchMoveEvent(t)))}handleTouchStartEvent(t){t.touches.length===2&&(this.touchedCandleIndexes=this.getXPositions(t).map(e=>this.scale.fromX(e)))}handleTouchMoveEvent(t){t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),n=[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];n[r]=a.pageX-e.left-i}return n}pinchHandler(t,e){const n=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),i=n+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;this.scale.setXScale(n,i)}}const jr=()=>{const s=/Mac|iPod|iPhone|iPad/i.test(navigator.userAgent),e=[/Android/i,/webOS/i,/BlackBerry/i,/Windows Phone/i].some(n=>navigator.userAgent.match(n));return s?"apple":e?"mobile":"other"},Jf=(s,t)=>s==="apple"||s==="mobile"?3:t,Dd=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Id=!!window.chrome,Nr=typeof InstallTrigger!="undefined",Bd=navigator.platform.indexOf("Win")>-1,Xr=s=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:n}=s;if(e||n){let i;if(Dd)i=e===s.deltaY*-3||Math.abs(e+Math.sign(e))===Math.abs(Math.round(s.deltaY)*3)||Math.abs(e-Math.sign(e))===Math.abs(Math.round(s.deltaY)*3);else if(Id){if(i=e+Math.sign(e)===s.deltaY*-3?e+Math.sign(e)===s.deltaY*-3:e===s.deltaY*-3,Bd){const r=Math.round(s.deltaY)===e||Math.abs(Math.round(s.deltaY)+Math.sign(s.deltaY))===Math.abs(e)||Math.abs(Math.round(s.deltaY)-Math.sign(s.deltaY))===Math.abs(e);i=Math.abs(e)===Math.abs(s.deltaY)||r}}else Nr?Math.abs(s.deltaY)>Math.abs(s.deltaX)?i=!1:i=n===s.deltaX*-3:i=e===s.deltaY*-3;i&&(t=!0)}else s.deltaMode===0&&(t=!0);return Nr&&s.deltaY>=16&&Math.abs(s.deltaY)%16===0&&(t=!1),s.ctrlKey&&(t=!0),t},zr=(s,t)=>s==="percent"?t/4:t;var $s=Math.pow;class Od extends X{constructor(t,e,n,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=n,this.mainCanvasParent=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.canvasAnimation=a,this.chartPanComponent=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelTrottleTime=15,this.zoomXHandler=(d,u)=>{const g=d.deltaY<0;if(this.config.scale.zoomToCursor){const y=this.canvasBoundsContainer.getBounds(x.CANVAS).width,M=d.offsetX/y;this.scale.zoomXToPercent(M,g,!1,u)}else this.scale.zoomXToEnd(g,u);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(Cs),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart},this.onXDragTick=d=>{const{delta:u}=d;this.currentPoint.x=u;const g=Yt(u,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-g),this.bus.fireDraw()},this.touchHandler=new Ld(this.scale,this.canvasInputListener,this.mainCanvasParent);const c=this.canvasBoundsContainer.getBoundsHitTest(x.ALL_PANES),h=new Te(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});this.addChildEntity(h)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(x.ALL_PANES);this.addRxSubscription(ft(this.canvasInputListener.observeWheel(t),this.canvasInputListener.observePinch(t)).pipe(ve(this.wheelTrottleTime,me,{trailing:!0,leading:!0})).subscribe(e=>{const i=Xr(e)?zr(this.config.components.yAxis.type,this.config.scale.zoomSensitivity.pinch):this.config.scale.zoomSensitivity.wheel;this.zoomXHandler(e,i)})),this.addRxSubscription(this.canvasInputListener.observeScrollGesture().pipe(ve(this.wheelTrottleTime,me,{trailing:!0,leading:!0})).subscribe(e=>{let n=-1;const i=jr();(i==="apple"||i==="mobile")&&(n=1);let r=0,o=0;if(r+=e.deltaX*n,o+=e.deltaY*-n,r!==0&&Math.abs(r)>Math.abs(o)){const a=Yt(r,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-a)}else if(o!==0&&Math.abs(o)>Math.abs(r)){const a=zr(this.config.components.yAxis.type,this.config.scale.zoomSensitivity.glide);this.zoomXHandler(e,a)}this.bus.fireDraw()})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e})),this.touchHandler.activate(),this.addSubscription(this.touchHandler.deactivate.bind(this.touchHandler))}registerChartYPanHandler(t,e){let n=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(Cs),this.currentPoint={x:0,y:0},n=t.yStart},r=a=>{const{delta:l}=a;if(this.currentPoint.y=l,t.state.auto)Rd(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const c=Yt(t.state.inverse?-l:l,t.zoomY);t.moveYStart(n+c)}},o=new Ke(e,{onDragTick:r,onDragStart:i},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});return this.addChildEntity(o),o}}const Rd=(s,t)=>{if(!t.enabled)return!1;const e=Math.abs(s.y),n=$s($s(Math.abs(s.x),2)+$s(e,2),.5),i=Math.abs(Math.acos(e/n));return e>t.yDiff&&i<t.edgeAngle};class Fd extends X{constructor(t,e,n,i,r,o,a,l){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=n,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.chartPanComponents=[],this.chartAreaPanHandler=new Od(this.eventBus,this.config,this.mainScale,this.mainCanvasParent,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this),this.chartPanComponents.push(this.chartAreaPanHandler)}doActivate(){this.activateChartPanHandlers()}doDeactivate(){this.deactivatePanHandlers()}activateChartPanHandlers(){this.chartPanComponents.forEach(t=>t.activate())}deactivatePanHandlers(){this.chartPanComponents.forEach(t=>t.deactivate())}}const Wr=s=>t=>{const{top:e,bottom:n}=s(),i=t.high-t.low,r=i===0?1:i,o=r*e/100,a=r*n/100,l=t.low-a,c=t.high+o;return{low:l,high:c}},Ur=(s,t)=>{const e=Wr(s);return{isHighLowActive:()=>!0,calculateHighLow:n=>{const i=t.calculateHighLow(n);return e(i)}}};function Hd(){return Ln(1)}function Vr(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];return Hd()(Re(s,Oe(s)))}function kd(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];var e=Oe(s);return N(function(n,i){(e?Vr(s,n,e):Vr(s,n)).subscribe(i)})}function Yd(s){return $(function(t,e){return s<=e})}class jd{constructor(t,e,n,i,r){this.config=t,this.boundsProvider=e,this.canvasModel=n,this.canvasAnimation=i,this.animationId=r}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),n=this.canvasModel.ctx,i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),r=this.config.components.paneResizer.dragZone;!t&&i&&(n.fillStyle=i.getColor(0),n.fillRect(e.x,e.y-r,e.width,e.height+2*r)),n.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?n.fillRect(e.x,e.y,e.width,e.height):n.fillRect(e.x,e.y-r,e.width,e.height+2*r)}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Nd extends X{constructor(t,e,n,i,r,o,a,l,c,h,d){super(),this.id=t,this.boundsProvider=e,this.hitTest=n,this.dragTickCb=i,this.chartPanComponent=r,this.canvasModel=o,this.drawingManager=a,this.canvasInputListener=l,this.canvasAnimation=c,this.config=h,this.canvasBoundsContainer=d,this.initialY=0,this.resizeEvent$=new I,this.onYDragStart=()=>{this.config.components.crossTool.type="none",this.initialY=this.boundsProvider().y},this.onYDragEnd=()=>{this.config.components.crossTool.type="cross-and-labels",this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio)},this.onYDragTick=u=>{const{delta:g,draggedPixels:w}=u;Math.abs(this.initialY-this.boundsProvider().y+w)>=0&&(this.dragTickCb(g),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const n=new Ke(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent);this.addChildEntity(n),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(kd(!1),Lt(),Yd(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new jd(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,dr.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(dr.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 Xd=s=>t=>{let e;if(typeof t=="number")e=t;else if(typeof t=="string")e=Number(t);else return"\u2014";const[n]=s.dataSeries;if(n!==void 0){const i=Bt.getPricePrecision(e,n.pricePrecisions);return e.toFixed(i)}return`${e}`},zd=s=>(t,e)=>{const[n]=s.dataSeries;let i=t;const r=e!=null?e:n;r!==void 0&&(i=Pi(t,r.getBaseline()));const o=i.toFixed(Bt.DEFAULT_PRECISION).replace("-","\u2212")+" %";return o==="\u22120.00 %"?"0.00 %":o},Wd=s=>({percent:zd(s),regular:Xd(s)});class Ud extends X{constructor(t,e,n,i,r,o,a,l,c,h,d=new Set,u={regular:Ii}){super(),this.paneUUID=t,this.idx=e,this.paneComponent=n,this.chartBaseModel=i,this.canvasBoundsContainer=r,this.hitTestController=o,this.dynamicObjectsCanvasModel=a,this.scale=l,this.dragNDrop=h,this.dataSeries=d,this.formatters=u,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(x.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(x.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=g=>g.map(w=>new we(this.chartBaseModel.dataFromTimestamp(w.timestamp).centerUnit,w.close)),this.toY=g=>{var w,y;return(y=(w=this.mainDataSeries)==null?void 0:w.view.toY(g))!=null?y:1},this.valueFormatter=(g,w)=>{var y;return((y=this.formatters[this.yAxis.getAxisType()])!=null?y:this.formatters.regular)(g,w)},this.addChildEntity(l),this.setValueFormatters(Wd(this)),this.yAxis=c(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 Di(this,Ct(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){this.dataSeries.add(t),this.dataSeries.size===1&&(this.mainDataSeries=t),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,n;return(n=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?n:this.scale.fromY(t)}}const Gr=s=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(s.dataSeries).filter(n=>n.highLowProvider.isHighLowActive()).map(n=>n.highLowProvider.calculateHighLow(t));return Ui(e)}});class Vd{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=Gs.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return Gs.DATA_SERIES}get allDataSeries(){return ge(ge(Object.values(this.panes),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(n=>n.htId===t)}onHover(t){this.allDataSeries.forEach(e=>e.hovered=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(n=>n.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.panes).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}const Xt="#FF00FF";function Qf(s,t,e,n){const i=s.yAxis.backgroundColor,r=s.chartAreaTheme.backgroundColor,o=s.chartAreaTheme.backgroundGradientTopColor,a=s.chartAreaTheme.backgroundGradientBottomColor,l=n.align==="left"?o:a,c=s.chartAreaTheme.backgroundMode==="gradient"?l:r,h=i==="transparent"?c:i;return getLabelTextColorByBackgroundColor(h,t,e)}const Gd=(s,t)=>s==="down"?t.lastPrice.textNegative:s==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,Zd=(s,t)=>{const e=t.barTheme[`${s}Color`];return e!=null?e:Xt},$d=(s,t)=>{const e=t.lineTheme[`${s}Color`];return e!=null?e:Xt},Kd=(s,t)=>{const e=t.candleTheme[`${s}Color`];return e!=null?e:Xt},qd=(s,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Xt},Jd=(s,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Xt},Qd=(s,t)=>{const e=t.histogram[`${s}Cap`];return e!=null?e:Xt},tu=(s,t)=>{const e=s==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Xt},Zr=(s,t)=>{const e=t.candleTheme[`${s}WickColor`];return e!=null?e:Xt},eu=()=>(console.warn("Fallback for label default color"),Xt);function su(s,t){if(s.filter(a=>a!==null).length<=1)return s.map(a=>a.y);const e=t-2,n=s.map((a,l)=>nu(a,l,e)).filter(Nn).sort(iu),i=new Array(n.length),r=n.reduce((a,l)=>Math.min(a,l.labelWeight),Number.POSITIVE_INFINITY),o=n.findIndex(a=>a.labelWeight===r);for(let a=o;a>=0;a--){const l=n[a],c=n[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<n.length;a++){const l=n[a],c=n[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 nu=(s,t,e)=>s?{top:s.y-e/2,bottom:s.y+e/2,labelWeight:s.weight,actualIndex:t}:null,iu=(s,t)=>{const e=s.top,n=t.top;return e>n?1:e<n||e===n&&s.labelWeight<t.labelWeight?-1:0};var ru=Object.defineProperty,ou=Object.defineProperties,au=Object.getOwnPropertyDescriptors,$r=Object.getOwnPropertySymbols,lu=Object.prototype.hasOwnProperty,cu=Object.prototype.propertyIsEnumerable,Kr=(s,t,e)=>t in s?ru(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,qr=(s,t)=>{for(var e in t||(t={}))lu.call(t,e)&&Kr(s,e,t[e]);if($r)for(var e of $r(t))cu.call(t,e)&&Kr(s,e,t[e]);return s},Jr=(s,t)=>ou(s,au(t));const Ks={MAIN:"MAIN"};class hu extends X{constructor(t,e,n,i,r,o,a){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=n,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.orderedLabels=[],this.customLabels={},this.labelsProviders={},this.labelsPositionRecalculatedSubject=new I,this.animFrameId=`anim_cache_${Ct()}`,this.initModel()}doActivate(){super.doActivate(),this.addRxSubscription(ft(this.canvasBoundsContainer.observeBoundsChanged(x.PANE_UUID(this.paneUUID)),this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed).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,n])=>{this.addToGroup(n,t,e)})}updateLabels(t=!1){this.recalculateLabels(),Xs(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const n=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=pt(Object.values(i).map(l=>l.getUnorderedLabels())),o=pt(r.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),a=su(o,n);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,n){this.labelsProviders[e]&&(Object.values(this.labelsProviders[e]).includes(t)||(this.labelsProviders[e][n]=t))}updateLabelsCoordinates(t,e){return Jr(qr({},t),{labels:t.labels.map((n,i)=>Jr(qr({},n),{lineY:n.y,y:e[i]}))})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,n){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[n]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var n;const i=(n=this.labelsProviders[t])!=null?n:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}const Qr=10;class du extends X{constructor(t,e,n,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.autoScaleCallback=l,this.yAxisDragEndSubject=new I,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=this.bounds.getBounds(x.Y_AXIS).height},this.onYDragTick=c=>{const{delta:h}=c;let d;h<0?d=1/(1+-h/this.lastYPxHeight*(Qr-1)):d=1+h/this.lastYPxHeight*(Qr-1);const g=(this.lastYHeight*d-this.lastYHeight)/2,w=this.lastYStart-g,y=this.lastYEnd+g;this.autoScaleCallback(!1),this.scale.setYScale(w,y),this.bus.fireDraw()},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next()},e.customScale){const c=()=>e.type!=="percent"&&e.visible,h=new Ke(a,{onDragTick:qs(this.onYDragTick,c),onDragStart:qs(this.onYDragStart,c),onDragEnd:qs(this.onYDragEnd,c)},r,n,{disableChartPanning:!1});this.addChildEntity(h)}}doActivate(){this.config.customScaleDblClick&&this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>{this.autoScaleCallback(!0),this.bus.fireDraw()}))}}const qs=(s,t)=>(...e)=>t()&&s(...e);class uu{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${Ct()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),hr(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 gu=0,fu=.01;class Js{constructor(t,e,n,i,r=!1,o,a,l=ws,c=23){this.increment=t,this.startEndProvider=e,this.lengthProvider=n,this.valueFormatter=i,this.withZero=r,this.axisTypeProvider=o,this.baseLineProvider=a,this.labelFilter=l,this.singleLabelHeightPixels=c,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new I,this.newGeneratedLabelsSubject=new I,this.lastStart=0,this.lastEnd=0,this.labelsCache=new uu(()=>this.labelFilter(this.doGenerateLabels()))}generateRegularLabels(t,e,n){const i=[];this.withZero&&i.push({value:0,text:"0"});let r=ht.roundToNearest(t,n);for(;r<e;){const o=ht.roundToNearest(r,n),a=this.valueFormatter(o);i.push({value:o,text:a}),r=ht.roundDecimal(r+n)}return i}generatePercentLabels(t,e,n){const i=[],r=this.baseLineProvider();let o=ht.roundToNearest(t,n);for(;o<e;){const a=ht.roundToNearest(o,n),l=Ti(a,r),c=this.valueFormatter(l);i.push({value:a,text:c}),o=ht.roundDecimal(o+n)}return i}generateLogarithmLabels(t,e,n){const i=[];let r=ht.roundToNearest(t,n);for(;r<e;){const o=Rs(r),a=this.valueFormatter(o);i.push({value:r,text:a}),r=ht.roundDecimal(r+n)}return i}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[n,i]=this.calculateMinMax(),r=this.getAxisStep(n,i,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=r);let o;const a=this.axisTypeProvider();if(a==="logarithmic"?o=this.generateLogarithmLabels(n,i,r):a==="percent"?o=this.generatePercentLabels(n,i,r):o=this.generateRegularLabels(n,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(),n=this.lengthProvider(),i=Js.getLabelBounds(t,e,n);return[i[0],i[1]]}getAxisStep(t,e,n){const i=e-t,r=n/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){if(this.increment)return this.increment;if(!isNaN(t)){const e=Bt.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(e)}return this.adjustIncrementOnAxisType(fu)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=Rs(e)+t;return Mi(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,n){const i=Math.abs((e-t)*(gu/n));return[t-i,e+i]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let n=e,i=e,r=0;for(;n<t&&n>0;)r>=this.gridDistanceMultipliers.length&&(r=0,i*=10),n=i*this.gridDistanceMultipliers[r++];return n}}class pu extends Js{constructor(t,e,n,i,r=()=>"regular",o=23){super(t,()=>[n.yStart,n.yEnd],()=>n.getBounds().height,i,!1,r,()=>{var a,l;return(l=(a=e())==null?void 0:a.getBaseline())!=null?l:1},void 0,o),this.dataSeriesProvider=e}getLargestLabel(){var t;return((t=this.labelsCache.getLastCachedValue())!=null?t:[]).reduce((e,n)=>n.text.length>e.length?n.text:e,"")}calculateIncrement(t){var e;const n=this.dataSeriesProvider();if(n){const i=wt(n.dataPoints),r=(e=i==null?void 0:i.close)!=null?e:0,o=Ql(r,n.pricePrecisions);return this.adjustIncrementOnAxisType(o)}return super.calculateIncrement(t)}}function to(s,t,e){var n=k(s)||t||e?{next:s,error:t,complete:e}:s;return n?N(function(i,r){var o;(o=n.subscribe)===null||o===void 0||o.call(n);var a=!0;i.subscribe(Pt(r,function(l){var c;(c=n.next)===null||c===void 0||c.call(n,l),r.next(l)},function(){var l;a=!1,(l=n.complete)===null||l===void 0||l.call(n),r.complete()},function(l){var c;a=!1,(c=n.error)===null||c===void 0||c.call(n,l),r.error(l)},function(){var l,c;a&&((l=n.unsubscribe)===null||l===void 0||l.call(n)),(c=n.finalize)===null||c===void 0||c.call(n)}))}):ie}class mu extends X{constructor(t,e,n,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=n,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${Ct()}`}doActivate(){super.doActivate(),this.addRxSubscription(ft(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(x.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(ct(t=>t.height),$(t=>fa(t,this.prevYAxisHeight,1.5)),to(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}updateLabels(){this.labels=this.labelsGenerator.generateNumericLabels(),Xs(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}}class vu extends X{constructor(t,e,n,i,r,o,a,l,c){super(),this.paneUUID=t,this.state=n,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new pu(null,l,o,a,()=>this.state.type,n.labelHeight),this.baseLabelsModel=new mu(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new hu(e,o,i,n,r,t,()=>this.canvasBoundsContainer.updateYAxisWidths()),this.addChildEntity(this.fancyLabelsModel)}doActivate(){const t={getLargestLabel:()=>{var e;return((e=this.labelsGenerator.labelsCache.getLastCachedValue())!=null?e:[]).map(n=>n.text).concat(this.fancyLabelsModel.orderedLabels.flatMap(n=>n.labels).map(n=>n.labelText)).reduce((n,i)=>i.length>n.length?i:n,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class bu extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u){super(),this.eventBus=t,this.config=e,this.canvasModel=n,this.scale=i,this.canvasBoundsContainer=o,this.cursors=l,this.paneUUID=d,this.extentIdx=u,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new I,this.state=Ce(e.components.yAxis),this.yAxisScaleHandler=new du(t,this.state,a,i,r,o,o.getBoundsHitTest(x.PANE_UUID_Y_AXIS(d,u)),g=>i.autoScale(g)),this.addChildEntity(this.yAxisScaleHandler),this.model=new vu(this.paneUUID,t,this.state,o,n,i,c,h,u),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",Kd),this.registerLabelColorResolver("bar",Zd),this.registerLabelColorResolver("line",$d),this.registerLabelColorResolver("area",qd),this.registerLabelColorResolver("scatterPlot",Jd),this.registerLabelColorResolver("histogram",Qd),this.registerLabelColorResolver("baseline",tu),this.registerLabelColorResolver("trend",Zr),this.registerLabelColorResolver("hollow",Zr)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(x.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(x.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:eu}registerYAxisLabelsProvider(t,e=Ks.MAIN,n=Ct()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,n),n}addSimpleYAxisLabel(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=Ks.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(x.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())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.enable():this.disable(),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){this.scale.state.inverse=t,this.scale.inverseY=t,this.scale.scaleInversedSubject.next(t)}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}class Cu extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u,g,w,y,_,M,B){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=n,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=g,this.canvasBoundsContainer=w,this.uuid=y,this.seriesAddedSubject=_,this.seriesRemovedSubject=M,this._paneOrder=0,this.yExtentComponents=[],this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(x.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(j,H)=>this.mainExtent.valueFormatter(j,H);const F=this.createExtentComponent(B);this.mainExtent=F,this.ht=this.canvasBoundsContainer.getBoundsHitTest(x.PANE_UUID(y),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get dataSeries(){return ge(this.yExtentComponents,t=>Array.from(t.dataSeries))}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(x.PANE_UUID(this.uuid)).pipe(Lt(di)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()}))}toY(t){var e,n;return(n=(e=this.mainExtent.mainDataSeries)==null?void 0:e.view.toY(t))!=null?n:this.scale.toY(t)}createGridComponent(t,e,n,i){const r=x.PANE_UUID(t);return new Or(this.mainCanvasModel,e,this.config,i,`PANE_${t}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(r),()=>this.canvasBoundsContainer.getBounds(r),()=>[],()=>n.generateNumericLabels())}createYPanHandler(t,e){const n=x.PANE_UUID(t),i=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(n));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(i),i.disable()},i]}addCursors(t,e){const n=x.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(n,e.state.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(n)}createExtentComponent(t){var e,n;const i=this.yExtentComponents.length,r=x.PANE_UUID(this.uuid),o=()=>this.canvasBoundsContainer.getBounds(r),a=(e=t==null?void 0:t.scale)!=null?e:new Dc(this.mainScale,this.config,o,this.canvasAnimation),[l,c]=this.createYPanHandler(this.uuid,a),h=(w,y)=>new bu(this.eventBus,this.config,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,w,y,this.uuid,i),d=new Ud(this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,h,c);d.addSubscription(l),d.addSubscription(this.addCursors(i,d.yAxis)),t!=null&&t.paneFormatters&&d.setValueFormatters(t.paneFormatters),((n=t==null?void 0:t.useDefaultHighLow)!=null?n:!0)&&a.autoScaleModel.setHighLowProvider("default",Ur(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),Gr(d)));const g=this.createGridComponent(this.uuid,a,d.yAxis.model.labelsGenerator,d.yAxis.state);return d.addChildEntity(g),d.activate(),this.yExtentComponents.push(d),this.canvasBoundsContainer.updateYAxisWidths(),d}removeExtentComponent(t){t.disable(),this.yExtentComponents.splice(t.idx,1),this.yExtentComponents.forEach((e,n)=>e.idx=n),this.canvasBoundsContainer.updateYAxisWidths()}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(n=>n.moveToExtent(this.mainExtent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainExtent]}getBounds(){return this.mainExtent.getBounds()}hide(){this._paneOrder=this.canvasBoundsContainer.panesOrder.indexOf(this.uuid),this.canvasBoundsContainer.removedPaneBounds(this.uuid),this.eventBus.fireDraw()}show(){this.canvasBoundsContainer.addPaneBounds(this.uuid,this._paneOrder),this.eventBus.fireDraw()}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=fe(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}canMoveDown(){const t=wt(this.canvasBoundsContainer.panesOrder);return this.uuid!==t}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}class wu extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u,g,w,y){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=n,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=g,this.mainCanvasModel=w,this.yAxisLabelsCanvasModel=y,this.panes={},this.paneRemovedSubject=new I,this.paneAddedSubject=new I,this.dataSeriesAddedSubject=new I,this.dataSeriesRemovedSubject=new I,this.hitTestController=new Vd(this.panes,this.dynamicObjectsCanvasModel);const _=this.createPane(q,{useDefaultHighLow:!1,scale:this.mainScale});_.mainExtent.scale.autoScaleModel.setHighLowProvider("series",Gr(_.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",Wr(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removedPaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(x.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone}),n=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},i=x.PANE_UUID_RESIZER(t),r=new Nd(i,()=>this.canvasBoundsContainer.getBounds(i),e,n,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer);return this.userInputListenerComponents.push(r),r}get yExtents(){return ge(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(n=>this.canvasBoundsContainer.getBoundsHitTest(x.PANE_UUID(n.uuid))(t.x,t.y))}createPane(t=Ct(),e){if(this.panes[t]!==void 0)return this.panes[t];const n=new Cu(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,e);return this.config.components.paneResizer.visible&&n.addChildEntity(this.addResizer(t)),n.addSubscription(this.addBounds(t,e==null?void 0:e.order)),n.addSubscription(this.addCursors(t)),n.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,n.ht)),this.panes[t]=n,n.activate(),this.recalculateState(),n.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),n}removePane(t){const e=this.panes[t];e!==void 0&&(this.paneRemovedSubject.next(e),e.disable(),e.yExtentComponents.forEach(n=>n.disable()),delete this.panes[t],this.recalculateState())}addCursors(t,e=this.config.components.chart.cursor){const n=x.PANE_UUID(t),i=x.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(n,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone),()=>{this.cursorHandler.removeCursorForCanvasEl(n),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 yu extends X{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,n=this.canvasModel.ctx;if(n){n.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return n.drawImage(this.elements.backgroundCanvas,0,0,i,r),n.drawImage(this.elements.mainCanvas,0,0,i,r),n.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),n.drawImage(this.elements.crossToolCanvas,0,0,i,r),n.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(n),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 Su=(s,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 n(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 n(s)},ss=class extends X{constructor(s,t,e,n,i){super(),this.chartComponent=s,this.drawingManager=t,this.config=e,this.volumesModel=n,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var s,t;return!((s=this.pane)!=null&&s.scale.isViewportValid())&&((t=this.pane)==null?void 0:t.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var s;return(s=this.pane)==null?void 0:s.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[ss.UUID]===void 0){const t=this.paneManager.createPane(ss.UUID,{paneFormatters:{regular:i=>Su(i,1)},useDefaultHighLow:!1,increment:1});this.pane=t,t.mainExtent.yAxis.setAxisType("regular");const{scale:e}=t,n=Ur(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);e.autoScaleModel.setHighLowProvider("volumes",n),e.doAutoScale(!0)}}deactiveSeparateVolumes(){this.paneManager.removePane(ss.UUID),delete this.pane,this.drawingManager.removeDrawerByName("UNDERLAY_VOLUMES_AREA")}fromY(s){var t,e;return(e=(t=this.pane)==null?void 0:t.scale.fromY(s))!=null?e:0}};let eo=ss;eo.UUID="volumes";const ns=.3,xu=(s,t)=>{const e=t.barTheme[`${s}Color`];return Et()(e).alpha(ns).toString()},_u=(s,t)=>{const e=t.volume[`${s}BarColor`];return Et()(e).alpha(ns).toString()},Pu=(s,t)=>{const e=t.lineTheme[`${s}Color`];return Et()(e).alpha(ns).toString()},Qs=(s,t)=>{const e=t.candleTheme[`${s}Color`];return Et()(e).alpha(ns).toString()},Tu=3;class Mu{constructor(t,e,n,i,r,o){this.config=t,this.volumesModel=e,this.chartModel=n,this.getViewportModel=i,this.volumesColorByChartTypeMap=r,this.drawPredicate=o,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const n=(e=this.volumesColorByChartTypeMap[t])!=null?e:_u;this.volumeBarColors.down=n("down",this.config.colors),this.volumeBarColors.up=n("up",this.config.colors),this.volumeBarColors.none=n("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 n=this.getViewportModel().getBounds();Ut(e,n),this.drawVolumes(t),e.restore()}}drawLastBar(){this.config.components.volumes.visible}drawVolumes(t){const e=this.volumesModel.volumeMax.getValue();if(e===0)return;const n=pt(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1)),i=this.getViewportModel();n.forEach((r,o)=>{if(r.candle.volume){const a=i.getBounds(),l=a.height,c=n[o+1]!==void 0?V(i.toX(n[o+1].startUnit)):void 0,h=V(i.toX(r.startUnit)),d=c!==void 0?c-h:V(dt(r.width,i.zoomX));if(this.config.components.volumes.showSeparately){const u=V(i.toY(r.candle.volume)),g=V(i.toY(0))-u;this.drawVolume(t,r,h,u,d,g)}else{const u=e/(l/Tu),g=Math.max(dt(r.candle.volume,u),2),w=V(a.y+l-g);this.drawVolume(t,r,h,w,d,g)}}})}drawVolume(t,e,n,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(n,l),a.lineTo(n,wi(c)),a.stroke()):a.fillRect(n,i,r,wi(o))}}const Au=Ha(s=>s.candle.volume),so="volumes";class Eu extends X{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=so,this.volumeMax=new Tt(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(ft(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=fe(Au(this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport().flat())))!=null?t:0)}}class Lu extends X{constructor(t,e,n,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new Tt(!1),this.volumeIsSeparateModeChangedSubject=new Tt(!1);const c=new Eu(e,n);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new eo(e,r,o,c,a),this.volumesDrawer=new Mu(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:n},this.volumesColorByChartTypeMap,()=>!0),o.components.volumes.visible&&this.addVolumesToDynamicObjects(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(o.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(o.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",Qs),this.registerVolumeColorResolver("trend",Qs),this.registerVolumeColorResolver("hollow",Qs),this.registerVolumeColorResolver("line",Pu),this.registerVolumeColorResolver("bar",xu)}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))}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),t?this.addVolumesToDynamicObjects():this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.canvasModel.fireDraw()}addVolumesToDynamicObjects(){this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1&&this.dynamicObjectsComponent.model.addObject({id:this.volumesModel.id,paneId:this.config.components.volumes.showSeparately?so:q,drawer:this.volumesDrawer,model:this.volumesModel})}}class Du{constructor(t,e,n,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=n,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,g=this.canvasBoundsContainer.getBounds(x.PANE_UUID(q)),{position:w,offsetY:y,offsetX:_}=this.config.components.waterMark;let M;switch(d?M=d:(u.font=is(this.config,l),M=u.measureText(a).width,g.width-10<M&&(u.font=Iu(this.config,this.canvasBoundsContainer,l,M),M=u.measureText(a).width)),w){case"left-top":return{x:_+g.x,y:y+o+g.y,font:u.font,text:a,color:c};case"left-bottom":return{x:_+g.x,y:g.height-h-y+o+g.y,font:u.font,text:a,color:c};case"center":return{x:g.width/2-M/2+g.x,y:(g.height-h)/2+o+g.y,font:u.font,text:a,color:c}}}}draw(){var t,e,n,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,g=this.canvasModel.ctx;let w=0,y=0,_=0,M=0,B=0;if(g.save(),d.firstRowFontSize&&l){g.font=is(this.config,d.firstRowFontSize);const R=g.measureText(l);w=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){g.font=is(this.config,d.secondRowFontSize);const R=g.measureText(c);y=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,_=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){g.font=is(this.config,d.thirdRowFontSize);const R=g.measureText(h);M=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,B=(n=d.secondRowBottomPadding)!=null?n:0}const F=(i=d.thirdRowBottomPadding)!=null?i:0,j=(r=d.logoHeight)!=null?r:0,H=w+y+_+M+B+F+j;if(l&&this.drawWaterMark(this.getConfig(w,l,d.firstRowFontSize,u.firstRowColor,H)),c&&this.drawWaterMark(this.getConfig(w+_+y,c,d.secondRowFontSize,u.secondRowColor,H)),h&&this.drawWaterMark(this.getConfig(w+_+y+B+M,h,d.thirdRowFontSize,u.thirdRowColor,H)),this.logoImage){const R=this.getConfig(w+_+y+B+M+F,"",d.thirdRowFontSize,u.thirdRowColor,H,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,R.x,R.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}g.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const n=this.canvasModel.ctx;n.font=t.font,n.fillStyle=t.color;const i=t.x,r=t.y;n.fillText(e,i,r)}reset(){}}const Iu=(s,t,e,n)=>{const r=((a,l)=>t.getBounds(x.CHART).width/l*a)(e,n);let o;return s.components&&s.components.waterMark&&(o=s.components.waterMark.fontFamily),r+"px "+o},is=(s,t)=>{let e;return s.components&&s.components.waterMark&&(e=s.components.waterMark.fontFamily),t+"px "+e};var Bu=Object.defineProperty,no=Object.getOwnPropertySymbols,Ou=Object.prototype.hasOwnProperty,Ru=Object.prototype.propertyIsEnumerable,io=(s,t,e)=>t in s?Bu(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,ro=(s,t)=>{for(var e in t||(t={}))Ou.call(t,e)&&io(s,e,t[e]);if(no)for(var e of no(t))Ru.call(t,e)&&io(s,e,t[e]);return s};class Fu extends X{constructor(t,e,n,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=n,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Du(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(Dt(r.observeBoundsChanged(x.PANE_UUID(q)),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={};Dt(e,t),Dt(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 ro(ro({},this.config.components.waterMark),h)}}const oo={x:4,y:4};function Hu(s,t,e,n,i){var r,o;const a=(r=i.alignType)!=null?r:"middle",{fontSize:l,fontFamily:c,padding:h}=n.components.xAxis,d=(o=h.top)!=null?o:0,u=e.getBounds(x.X_AXIS);t.save(),t.font=`bold ${l}px ${c}`;const w=t.measureText(i.text).width+oo.x*2;let y=0;const _=i.x;switch(a){case"start":y=_-w;break;case"end":y=_;break;case"middle":default:y=_-w/2;break}Ve(s,t,y,u.y,w,u.height-1),a!=="middle"&&(t.strokeStyle=i.color,t.beginPath(),t.moveTo(_,u.y),t.lineTo(_,u.y+u.height),t.stroke()),t.fillStyle=i.color;const M=y+oo.x,B=u.y+d+l;t.fillText(i.text,M,B),t.restore()}class ku{constructor(t,e,n,i,r){this.backgroundCanvasModel=t,this.config=e,this.canvasModel=n,this.canvasBoundsContainer=i,this.xAxisLabelsModel=r}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{Hu(this.backgroundCanvasModel.ctx,t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},n=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(n).forEach(i=>{const r=n[i];if(r.length===2){const o=this.canvasBoundsContainer.getBounds(x.X_AXIS);t.fillStyle=Et().rgb(r[0].color).alpha(.1).toString(),er(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const tp="week-weekday",Yu=["second","minute","hour","day","month","year"],ju=["lessThanSecond"],Nu=s=>Yu.some(t=>t===s),Xu=s=>s==="week-weekday",zu=s=>ju.some(t=>t===s),ao=s=>{const t={"!":!1,$:!1};return s.includes("!")&&(t["!"]=!0),s.includes("$")&&(t.$=!0),t},tn=s=>parseInt(s,10),lo=s=>{const[t,...e]=s.split("_");if(Nu(t)){const[n]=e,i=ao(n),r=tn(n);return{key:t,value:r,exact:i["!"]}}else if(Xu(t)){const[n,i]=e,r=ao(n),o=tn(n),a=tn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return zu(t)?{key:t}:(console.warn(`${s} is not fit, check the documentation to see available formats https://webdev.prosp.devexperts.com:8095/docs/chart/x-axis`),null)};class rs{constructor(t,e,n,i,r,o=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=n,this.canvasBoundsContainer=i,this.labelsProvider=r,this.drawPredicate=o}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,n=this.config.colors.xAxis,i=this.config.components.xAxis.fontFamily,r=rs.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=n.backgroundColor;const l=this.canvasBoundsContainer.getBounds(x.X_AXIS);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.restore()}}drawLabels(t,e,n,i,r,o,a){const l=`${r}px ${o}`;t.fillStyle=i;for(const c of e){const h=this.viewportModel.toX(c.value)-yt(c.text,t,l)/2,d=n.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 en={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},co=s=>{switch(s.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return en[s.key]+s.value;case"lessThanSecond":return en[s.key];case"week-weekday":return en[s.key]+(s.week==="$"?9:s.week)+s.weekday*10}},ho=s=>{const t={};for(const e of s){const n=t[e.weight];n===void 0?t[e.weight]=[e]:n.push(e)}return t},Wu=(s,t)=>{const e=Object.keys(s).map(i=>parseInt(i,10)).sort((i,r)=>r-i);let n=[];for(const i of e){const r=s[i];if(!r)continue;const o=[...n];n=[];const a=o.length,l=r.length;let c=0,h=1/0,d=-1/0;for(let u=0;u<l;u++){const g=r[u],w=g.idx;for(;c<a;){const y=o[c],_=y.idx;if(w>_)c++,n.push(y),d=_,h=1/0;else{h=_;break}}h-w>=t&&w-d>=t&&(n.push(g),d=w)}for(;c<a;)n.push(o[c]),c++}return n},Uu=(s,t,e,n,i,r)=>{const o=rs.getFontFromConfig(t),a=yt(e.text,s,o),l=yt(n.text,s,o),c=i.toX(e.value)+a/2;return i.toX(n.value)-l/2-c<r};function sn(s){"@babel/helpers - typeof";return sn=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},sn(s)}function mt(s,t){if(t.length<s)throw new TypeError(s+" argument"+(s>1?"s":"")+" required, but only "+t.length+" present")}function vt(s){mt(1,arguments);var t=Object.prototype.toString.call(s);return s instanceof Date||sn(s)==="object"&&t==="[object Date]"?new Date(s.getTime()):typeof s=="number"||t==="[object Number]"?new Date(s):((typeof s=="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 Vu(s){return mt(1,arguments),vt(s).getDay()===1}function Gu(s){return mt(1,arguments),vt(s).getDay()===2}function Zu(s){return mt(1,arguments),vt(s).getDay()===3}function $u(s){return mt(1,arguments),vt(s).getDay()===4}function Ku(s){return mt(1,arguments),vt(s).getDay()===5}function qu(s){return mt(1,arguments),vt(s).getDay()===6}function Ju(s){return mt(1,arguments),vt(s).getDay()===0}function Qu(s,t){var e;mt(1,arguments);var n=s||{},i=vt(n.start),r=vt(n.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(vt(l)),l.setDate(l.getDate()+c),l.setHours(0,0,0,0);return a}function tg(s){mt(1,arguments);var t=vt(s);return t.setDate(1),t.setHours(0,0,0,0),t}function eg(s){mt(1,arguments);var t=vt(s),e=t.getMonth();return t.setFullYear(t.getFullYear(),e+1,0),t.setHours(23,59,59,999),t}function uo(s){mt(1,arguments);var t=vt(s);return t.setHours(0,0,0,0),t}function go(s,t){mt(2,arguments);var e=uo(s),n=uo(t);return e.getTime()===n.getTime()}const sg=s=>{switch(s.key){case"lessThanSecond":return og(s);case"month":return ag(s);case"second":case"minute":case"hour":case"day":case"year":return lg(s);case"week-weekday":return cg(s);default:return()=>!1}},Gt=(s,t)=>{switch(t){case"lessThanSecond":return s.getMilliseconds();case"month":return s.getMonth();case"second":return s.getSeconds();case"minute":return s.getMinutes();case"hour":return s.getHours();case"day":return s.getDate();case"year":return s.getFullYear();case"week-weekday":return s.getDate()}},nn=s=>(t,e)=>{const n=Gt(t,s),i=Gt(e,s);return n!==i},ng=s=>(t,e)=>{const n=Gt(t,s),i=Gt(e,s);return n>=i},ig={1:Vu,2:Gu,3:Zu,4:$u,5:Ku,6:qu,7:Ju},rg=(s,t,e)=>{var n;const i=Qu({start:tg(s),end:eg(s)}),r=(n=ig[e])!=null?n:()=>!1;if(t==="$"){for(const o of i.reverse())if(r(o))return go(s,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return go(s,a);o++}}return!1},fo=(s,t)=>t===1?s===1:s/t===1,po=(s,t)=>t===1?!0:s%t===0,og=s=>(t,e)=>ng(s.key)(t,e),ag=s=>(t,e)=>{const n=nn(s.key)(t,e),i=s.exact?fo(Gt(t,s.key)+1,s.value):po(Gt(t,s.key)+1,s.value);return n&&i},lg=s=>(t,e)=>{const n=nn(s.key)(t,e),i=s.exact?fo(Gt(t,s.key),s.value):po(Gt(t,s.key),s.value);return n&&i},cg=s=>(t,e)=>{const n=nn(s.key)(t,e),i=rg(t,s.week,s.weekday);return n&&i},hg=s=>{switch(s.key){case"second":case"minute":return dg(s.value);case"hour":return ug(s.value);case"day":return gg(s.value);case"month":return mg(s.value);case"year":return vg(s.value);case"week-weekday":const t=pg(s.week),e=fg(s.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},dg=s=>s>0&&s<=60,ug=s=>s>0&&s<=24,gg=s=>s>0&&s<=31,fg=s=>mo(s)?s>=1&&s<=7:!1,pg=s=>s==="$"?!0:mo(s)?s>=1&&s<=6:!1,mg=s=>s>0&&s<=12,vg=s=>s>0,mo=s=>!isNaN(s)&&isFinite(s),bg=(s,t,e)=>{var n,i;for(const[r,o]of e)if(o(s,t))return r;return(i=(n=e[e.length-1])==null?void 0:n[0])!=null?i:0};function rn(s,t,e){const n=new Array(s.length);let i=e(0);for(let r=0;r<s.length;r++){const o=s[r],a=e(o.candle.timestamp),l={weight:bg(a,i,t)};n[r]=l,i=a}return n}const vo=s=>{const t={},e={};return Bs(s).forEach(([n,i])=>{const r=lo(n),o=r===null?!1:hg(r);if(r&&o){const a=co(r);t[a]=i,e[a]=sg(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class bo{constructor(t,e,n,i,r,o,a){this.eventBus=t,this.config=e,this.chartModel=n,this.scale=i,this.timeZoneModel=r,this.canvasModel=o,this.canvasBoundsContainer=a,this.labelsGroupedByWeight={},this.levelsCache={},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?dt(d,h.animationConfig.targetZoomX):dt(d,this.scale.zoomX);if(!isFinite(u))return-1;const g=this.config.components.xAxis.fontSize,w=Object.values(this.formatsByWeightMap).reduce((_,M)=>Math.max(M.length,_),1),y=g*w;return Math.round(y/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=vo(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(x.X_AXIS),n=[];for(const i of t){const r=this.scale.toX(i.value);r<0||r>e.width||n.push(i)}return n}getLabelsFromChartType(){var t,e;const n=(e=(t=this.weightedCache)==null?void 0:t.labels)!=null?e:[];return this.config.components.chart.type==="equivolume"?this.postProcessing(n):n}getAllCandlesWithFake(){const t=this.chartModel.mainCandleSeries.visualPoints;if(t.length===0)return[];const n=Array.from({length:750}).map((i,r)=>Bi(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,t.length+r,this.chartModel.getPeriod()));return[...t,...n]}mapWeightedPointsToLabels(t,e){var n;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:(n=a.candle.idx)!=null?n:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:n}=vo(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(n).map(([i,r])=>[parseInt(i,10),r]).sort(([i],[r])=>r-i),this.weightToTimeFormatsDict=e,this.generateWeightedLabels()}generateWeightedLabels(){const t=this.getAllCandlesWithFake(),e=rn(t,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),n=this.mapWeightedPointsToLabels(e,t);this.labelsGroupedByWeight=ho(n),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}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=rn([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(g=>g.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]),n=rn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(n,e),r=ho(i),o=Ce(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),g=this.labelsGroupedByWeight[u];if(u===this.weightToTimeFormatMatcherArray[0][0]&&g.shift(),g){const w=g.map(y=>(y.idx=y.idx+t.length,y.value=a.startUnit+a.width+y.value,y));r[u]?c[h]=d.concat(w):c[h]=w}else c[h]=d;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(){this.generateWeightedLabels()}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 n=Wu(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,t),t);this.levelsCache[t]=n,this.weightedCache={labels:n,coverUpLevel:t},this.eventBus.fireDraw()}}postProcessing(t){var e,n;const i=[];let r=0,o=1;for(;o<=t.length-1;){const a=t[r],l=t[o];Uu(this.canvasModel.ctx,this.config,a,l,this.scale,30)?((e=l.weight)!=null?e:0)>((n=a.weight)!=null?n:0)&&(r=o):(i.push(a),r=o,o===t.length-1&&i.push(l)),o++}return i}filterLabelsByExtendedRules(t,e){const n=Bs(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=lo(o);if(l){const c=co(l);i[c]=a}}return i},{});return Bs(t).reduce((i,[r,o])=>(n[r]&&n[r](e)||(i[r]=o),i),{})}}class Cg extends X{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(Ge,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}class wg extends X{constructor(t,e,n,i,r){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=n,this.chartPanComponent=i,this.chartModel=r,this.lastXStart=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const a=this.canvasBoundsContainer.getBounds(x.X_AXIS);this.lastXPxWidth=a.width-this.canvasInputListener.currentPoint.x},this.onXDragTick=a=>{const{delta:l}=a,c=this.lastXPxWidth-l;if(c<0)return;const h=this.lastXPxWidth/c,d=this.lastXWidth*h,u=this.lastXStart+(this.lastXWidth-d);this.scale.setXScale(u,this.scale.xEnd)};const o=new Te(this.canvasBoundsContainer.getBoundsHitTest(x.X_AXIS),{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick},this.canvasInputListener,this.chartPanComponent,{disableChartPanning:!1});this.addChildEntity(o)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.canvasBoundsContainer.getBoundsHitTest(x.X_AXIS)).subscribe(()=>this.chartModel.doBasicScale())),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class yg extends X{constructor(t,e,n,i,r,o,a,l,c,h,d,u,g){super(),this.eventBus=t,this.config=e,this.canvasModel=n,this.chartComponent=i,this.scale=r,this.chartResizeHandler=l,this.timeZoneModel=h;const w=new bo(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=w,this.xAxisLabelsModel=new Cg(t,[]);const y=new Us;c.addDrawer(y,"X_AXIS"),this.xAxisDrawer=new rs(e,n,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),y.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new ku(g,e,n,o,this.xAxisLabelsModel),y.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new wg(r,a,o,d,this.chartComponent.chartModel),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(x.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(ft(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe($(({prependedCandles:t})=>t.length!==0),ct(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,n;$a.includes(this.config.components.chart.type)&&((n=(e=this.xAxisLabelsGenerator).updateHistoryLabels)==null||n.call(e,t))})),this.addRxSubscription(ft(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(ve(50,me,{trailing:!0,leading:!0})).subscribe(()=>{this.xAxisLabelsGenerator.recalculateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(ct(()=>wt(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),Lt((t,e)=>{var n,i;return((n=t==null?void 0:t.candle)==null?void 0:n.timestamp)===((i=e==null?void 0:e.candle)==null?void 0:i.timestamp)}),$(Nn)).subscribe(t=>{var e,n;return(n=(e=this.xAxisLabelsGenerator)==null?void 0:e.updateLastLabel)==null?void 0:n.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 bo?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 Sg=Object.defineProperty,Co=Object.getOwnPropertySymbols,xg=Object.prototype.hasOwnProperty,_g=Object.prototype.propertyIsEnumerable,wo=(s,t,e)=>t in s?Sg(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,os=(s,t)=>{for(var e in t||(t={}))xg.call(t,e)&&wo(s,e,t[e]);if(Co)for(var e of Co(t))_g.call(t,e)&&wo(s,e,t[e]);return s};class Pg{constructor(t,e,n,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=n,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const n=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=n&&os(os({},n),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&&os(os({},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 n=t.view.toY(e.close);if(isFinite(n)){const i=this.yAxisConfig.labels.settings.lastPrice.mode,r=this.yAxisConfig.labels.settings.lastPrice.type;return{y:n,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,t),mode:i,labelType:r,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const n=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 c=Gd(t.lastPriceMovement,i);return{bgColor:l,textColor:n==="plain"?a(t.lastPriceMovement,t.colors):qt(l,c,o),rounded:!0}}return{bgColor:l,textColor:n==="plain"?a(t.lastPriceMovement,t.colors):qt(l,r,o),rounded:!0}}}class Tg{constructor(t,e,n,i,r){this.yAxisLabelsCanvasModel=t,this.backgroundCanvasModel=e,this.canvasBoundsContainer=n,this.fullConfig=i,this.paneManager=r}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx;this.paneManager.yExtents.forEach(n=>{if(n.yAxis.state.visible){const i=n.getYAxisBounds(),r=this.canvasBoundsContainer.getBounds(x.ALL_PANES),o=n.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(o),o.forEach(a=>{var l;const c=(l=a.bounds)!=null?l:i;a.labels.forEach(h=>Tr(t,e,c,r,h,this.canvasBoundsContainer,n.yAxis.state,this.fullConfig.colors.yAxis))}),Object.values(n.yAxis.model.fancyLabelsModel.customLabels).forEach(a=>Tr(t,e,i,r,a,this.canvasBoundsContainer,n.yAxis.state,this.fullConfig.colors.yAxis))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,n={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=n[r.subGroupId])!=null?o:[];if(n[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(x.PANE_UUID_Y_AXIS(q));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];er(e,{x:h.x,y:hi(d,h)},{x:h.x+h.width-6,y:hi(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Mg{constructor(t,e,n){this.fullConfig=t,this.canvasModel=e,this.paneManager=n}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const n=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height);const o=Jt(e.state),a=Ht(o,r),l=this.getLabelTextColor();r.save(),Ut(r,i),this.drawLabels(r,n,i,a,o,l,e),r.restore()}})}drawLabels(t,e,n,i,r,o,a){t.fillStyle=o,t.font=r;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=n.y+c,d=n.y+n.height-c;e.forEach(u=>{const g=a.scale.toY(u.value);g>h&&g<d&&Ag(t,n,u.text,g,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 Ag=(s,t,e,n,i,r,o,a)=>{const l=a==="right"?t.x+t.width-yt(e,s,r)-o:t.x+o;s.fillText(e,l,n+i/2-1)};class Eg{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const n=this.handlers[t];n!==void 0&&Ra.call(n,e)},this.add=(t,e,n)=>(e in this.handlers?t.call(this.handlers[e],n):this.handlers[e]=[n],this.unsub.bind(this,e,n)),this.on=(t,e)=>this.add(this.UNKNOWN_ARR.push,t,e),this.observe=t=>{const e=new I,n=e.next.bind(e),i=e.unsubscribe.bind(e);return this.on(t,n),e.unsubscribe=()=>{this.unsub(t,n),i()},e.asObservable()},this.onPrior=(t,e)=>this.add(this.UNKNOWN_ARR.unshift,t,e),this.off=this.unsub,this.fire=(t,...e)=>{var n;if(!this.muted){const i=(n=this.handlers[t])!=null?n:[];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(Ge,t)}}class Lg extends X{constructor(t,e,n,i){super(),n.observeTouchStart().pipe(ct(r=>i.components.chart.highlightActiveCandle?r:void 0),Lt()).subscribe(r=>{r&&this.setCandleAsActive(r,t,e)})}setCandleAsActive(t,e,n){if(t.touches.length===1){const i=t.touches.item(0);if(i!==null){const r=this.getTouchXPosition(i,e),o=n.candleFromX(r);o&&n.mainCandleSeries.setActiveCandle(o)}}}getTouchXPosition(t,e){const n=e.getBoundingClientRect(),i=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-n.left-i}}class Dg{constructor(t,e,n,i,r){this.frameElement=t,this.resizerElement=e,this.bus=n,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${Ct()}`,this.canvasResized=new I,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){Xs(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(n=>this.previousBCR&&n.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(Hs,e),this.bus.fire(Ge))}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 Ig=Array.isArray,Bg=Object.getPrototypeOf,Og=Object.prototype,Rg=Object.keys;function Fg(s){if(s.length===1){var t=s[0];if(Ig(t))return{args:t,keys:null};if(Hg(t)){var e=Rg(t);return{args:e.map(function(n){return t[n]}),keys:e}}}return{args:s,keys:null}}function Hg(s){return s&&typeof s=="object"&&Bg(s)===Og}var kg=Array.isArray;function Yg(s,t){return kg(t)?s.apply(void 0,L([],p(t))):s(t)}function jg(s){return ct(function(t){return Yg(s,t)})}function Ng(s,t){return s.reduce(function(e,n,i){return e[n]=t[i],e},{})}function Xg(){for(var s=[],t=0;t<arguments.length;t++)s[t]=arguments[t];var e=Oe(s),n=sa(s),i=Fg(s),r=i.args,o=i.keys;if(r.length===0)return Re([],e);var a=new gt(zg(r,e,o?function(l){return Ng(o,l)}:ie));return n?a.pipe(jg(n)):a}function zg(s,t,e){return e===void 0&&(e=ie),function(n){yo(t,function(){for(var i=s.length,r=new Array(i),o=i,a=i,l=function(h){yo(t,function(){var d=Re(s[h],t),u=!1;d.subscribe(Pt(n,function(g){r[h]=g,u||(u=!0,a--),a||n.next(e(r.slice()))},function(){--o||n.complete()}))},n)},c=0;c<i;c++)l(c)},n)}}function yo(s,t,e){s?Ft(e,s,t):t()}class Wg extends X{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new Tt(null)}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,n){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,n)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const n=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=Xg([n,i]).pipe($(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}else this.crossSubject.next(null),r=!0});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}class Ug{constructor(t,e,n,i){this.visualCandle=t,this.price=e,this.priceFormatter=n,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 Vg{constructor(t){this.chartModel=t}getData(t){const{x:e,y:n}=t,r=this.chartModel.candleFromX(e).idx||0,o=this.chartModel.getVisualCandle(r),a=this.chartModel.priceFromY(n);return o&&new Ug(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class Gg{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof vr)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 Zg=Object.defineProperty,$g=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,So=Object.getOwnPropertySymbols,qg=Object.prototype.hasOwnProperty,Jg=Object.prototype.propertyIsEnumerable,xo=(s,t,e)=>t in s?Zg(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,Me=(s,t)=>{for(var e in t||(t={}))qg.call(t,e)&&xo(s,e,t[e]);if(So)for(var e of So(t))Jg.call(t,e)&&xo(s,e,t[e]);return s},on=(s,t)=>$g(s,Kg(t));class Qg extends X{constructor(t,e,n,i,r,o,a,l,c){super(),this.crossEventProducer=t,this.scale=e,this.config=n,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.formatterFactory=c,this.hoverSubject=new Tt(null),this.longTouchActivatedSubject=new Tt(!1),this.xFormatter=()=>"";const h=new Vg(this.chartModel),d=new Gg(this.chartModel);this.hoverProducerParts={candleHover:h,compareSeriesHover:d}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.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(this.canvasInputListener.observeTouchStart().subscribe(e=>{const n=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,i=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.chartModel.candleFromX(n,!0)&&this.createAndFireHover([n,i,""])}));const t=this.canvasBoundsContainer.getBoundsHitTest(x.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{this.paneManager.chartPanComponent.deactivatePanHandlers(),this.longTouchActivatedSubject.next(!0);const n=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,i=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.createAndFireHover([n,i,""]),this.crossEventProducer.crossSubject.next([n,i,""])})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(()=>{this.paneManager.chartPanComponent.activateChartPanHandlers(),this.longTouchActivatedSubject.getValue()&&(this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose())})),this.addRxSubscription(ft(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter()))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=Ar(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),n=this.scale.toY(t.close);return this.createHover(e,n,q)}createHover(t,e,n){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:n},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>on(Me({},l),{[c[0]]:c[1].getData(o)}),{});return Me(Me({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){const e=this.createHoverFromCandle(t);if(this.hover&&e){const n=on(Me({},e),{x:this.hover.x,y:this.hover.y});this.fireHover(n)}}createAndFireHover([t,e,n]){const i=this.createHover(t,e,n);this.fireHover(i)}fireHover(t){var e;if(t){if(_s()&&this.config.components.crossTool.type!=="none"){const n=(e=t.candleHover)==null?void 0:e.visualCandle.candle;n&&this.chartModel.mainCandleSeries.setActiveCandle(n)}this.hoverSubject.next(t)}else this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}registerHoverProducerPart(t,e){this.hoverProducerParts=on(Me({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const _o={left:0,middle:1,right:2};function ut(s,t,e,n){return s.addEventListener(e,t,n),function(){s.removeEventListener(e,t,n)}}function he(s){return t=>{t.button===_o.left&&s(t)}}var tf=Object.defineProperty,Po=Object.getOwnPropertySymbols,ef=Object.prototype.hasOwnProperty,sf=Object.prototype.propertyIsEnumerable,To=(s,t,e)=>t in s?tf(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,nf=(s,t)=>{for(var e in t||(t={}))ef.call(t,e)&&To(s,e,t[e]);if(Po)for(var e of Po(t))sf.call(t,e)&&To(s,e,t[e]);return s};const ee=class extends X{constructor(s,t){super(),this.eventBus=s,this.element=t,this.xDragStartSubject=new I,this.xDragSubject=new I,this.xDragTickSubject=new I,this.xDragEndSubject=new I,this.yDragStartSubject=new I,this.yDragSubject=new I,this.yDragTickSubject=new I,this.yDragEndSubject=new I,this.mouseMoveSubject=new I,this.mouseMoveDocumentSubject=new I,this.clickSubject=new I,this.clickDocumentSubject=new I,this.dbClickSubject=new I,this.dbTapSubject=new I,this.mouseDownSubject=new I,this.mouseUpSubject=new I,this.mouseUpDocumentSubject=new I,this.wheelSubject=new I,this.touchStartSubject=new I,this.touchStartTimestamp=0,this.touchMoveSubject=new I,this.touchEndSubject=new I,this.touchCancelSubject=new I,this.longTouchStartSubject=new I,this.longTouchEndSubject=new I,this.contextMenuSubject=new I,this.pinchSubject=new I,this.scrollGestureSubject=new I,this.fastTouchScroll=new I,this.mouseLeavesCanvasSubject=new I,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=e=>{this.isDraggable(e)&&(this.updateCurrentPoints(e),this.dragging=!0,this.dragStartEvent=e,this.documentDragListeners.forEach(n=>n()),this.dragStartPoint=ee.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=nf({},this.dragStartPoint),ee.DRAG_EVENTS.forEach(n=>{document.addEventListener(n,this.dragProcessListener,!0);const i=document.removeEventListener.bind(document,n,this.dragProcessListener,!0);this.documentDragListeners.push(i),this.addSubscription(i)}),this.dragProcessListener())},this.dragListener=()=>this.mouseMoveDocumentSubject.next(this.currentPoint),this.updateElementOffsetListener=()=>this.mouseMoveSubject.next(this.currentPoint),this.dragEndListener=()=>{this.dragging=!1,this.documentDragListeners.forEach(e=>e()),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=e=>{this.updateCurrentDocumentPoint(e),this.updateCurrentMousePoint(e)}}isDraggable(s){return s instanceof MouseEvent?s.button===_o.left:s instanceof TouchEvent}startDragging(s){this.updateCurrentPoints(s),this.dragStartListener(s)}movePointer(s){this.updateCurrentPoints(s),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const s=t=>(t.preventDefault(),!1);this.element.addEventListener("selectstart",s,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",s,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],ee.DRAG_START_EVENTS.forEach(e=>{this.element.addEventListener(e,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(e,this.dragStartListener))}),this.trackMousePosition(),ee.DRAG_EVENTS.forEach(e=>{document.addEventListener(e,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,e,this.dragListener)),this.element.addEventListener(e,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,e,this.updateElementOffsetListener))}),ee.DRAG_END_EVENTS.forEach(e=>{document.addEventListener(e,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,e,this.dragEndListener))}),this.addSubscription(ut(this.element,he(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(ut(document,he(e=>this.clickDocumentSubject.next(e)),"click"));const s=jr();if(s==="apple"||s==="mobile"){let e=null;const n=o=>{o.preventDefault(),e?(this.dbTapSubject.next(this.currentPoint),clearTimeout(e),e=null):e=window.setTimeout(()=>{e=null},250)};this.addSubscription(ut(this.element,n,"touchend"));const i=(o,a=700,l=3)=>{o.preventDefault();const c={x:o.touches[0].clientX,y:o.touches[0].clientY};let h={x:0,y:0},d=!1,u=null;u=setTimeout(()=>{d=!0,this.longTouchStartSubject.next(o)},a);const g=y=>{y.preventDefault(),h={x:y.touches[0].clientX,y:y.touches[0].clientY},(Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2))>l||y.touches.length>1)&&u&&clearTimeout(u)},w=y=>{y.preventDefault(),u&&clearTimeout(u),d&&(d=!1,this.longTouchEndSubject.next(y)),this.element.removeEventListener("touchend",w),this.element.removeEventListener("touchmove",g)};this.element.addEventListener("touchmove",g),this.element.addEventListener("touchend",w)};this.addSubscription(ut(this.element,o=>i(o),"touchstart"));const r=o=>{if(o.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const c=this.touchStartTimestamp,d=Date.now()-c,g=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,w=d<=250;g&&w&&this.fastTouchScroll.next(o)}};this.addSubscription(ut(this.element,r,"touchend"))}this.addSubscription(ut(this.element,he(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(ut(this.element,e=>{this.touchStartSubject.next(e),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(ut(this.element,e=>this.touchMoveSubject.next(e),"touchmove",!0)),this.addSubscription(ut(this.element,e=>this.touchEndSubject.next(e),"touchend")),this.addSubscription(ut(this.element,e=>this.touchCancelSubject.next(e),"touchcancel")),this.addSubscription(ut(this.element,e=>{e.ctrlKey?this.pinchSubject.next(e):Xr(e)?this.scrollGestureSubject.next(e):this.wheelSubject.next(e),e.preventDefault()},"wheel")),this.addSubscription(ut(this.element,e=>this.contextMenuSubject.next(e),"contextmenu")),this.addSubscription(ut(this.element,he(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(ut(this.element,he(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(ut(document,he(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(Hs).subscribe(()=>{const e=this.element.getBoundingClientRect();this.canvasBounds.x=e.left,this.canvasBounds.y=e.top,this.canvasBounds.width=e.width,this.canvasBounds.height=e.height}));const t=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",t,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){ee.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(s,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(s){"pageX"in s?this.currentPointDocument.x=s.pageX:s.touches!==void 0&&(this.currentPointDocument.x=s.touches[0].pageX),"pageY"in s?this.currentPointDocument.y=s.pageY:s.touches!==void 0&&(this.currentPointDocument.y=s.touches[0].pageY)}updateCurrentMousePoint(s){const t=this.element.getBoundingClientRect();"clientX"in s?this.currentPoint.x=s.clientX-t.left:s.touches!==void 0&&(this.currentPoint.x=s.touches[0].clientX-t.left),"clientY"in s?this.currentPoint.y=s.clientY-t.top:s.touches!==void 0&&(this.currentPoint.y=s.touches[0].clientY-t.top)}static copyPoint(s){return{x:s.x,y:s.y}}observeMouseMove(s=()=>!0){return this.mouseMoveSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe($(()=>!this.dragging))}observeMouseMoveDocument(s=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(s=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe($(()=>s(this.currentPointDocument.x,this.currentPointDocument.y)),ct(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(s=()=>!0){return this.xDragStartSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(s=()=>!0){return this.xDragSubject.pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(s=()=>!0){return this.xDragEndSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(s=()=>!0){return this.yDragStartSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(s=()=>!0){return this.yDragSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(s=()=>!0){return this.yDragEndSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(s=()=>!0,t=!1){const e=this.mouseMoveSubject.asObservable().pipe($(()=>!(t&&this.dragging)),ct(()=>s(this.currentPoint.x,this.currentPoint.y))),n=this.observeMouseLeavesCanvas().pipe(ct(()=>!1));return ft(e,n).pipe(Lt())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(s=()=>!0){return this.clickSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(s=()=>!0){return this.dbClickSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(s=()=>!0){return this.dbTapSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeWheel(s=()=>!0){return this.wheelSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observePinch(s=()=>!0){return this.pinchSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeScrollGesture(){return this.scrollGestureSubject.asObservable()}observeTouchStart(s=()=>!0){return this.touchStartSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(s=()=>!0){return this.touchMoveSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(s=()=>!0){return this.mouseDownSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(s=()=>!0){return this.mouseUpSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(s=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(s=()=>!0){return this.contextMenuSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)),to(t=>t.preventDefault()))}observeLongTouchStart(s=()=>!0){return this.longTouchStartSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(s=()=>!0){return this.longTouchEndSubject.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(s=()=>!0){return this.fastTouchScroll.asObservable().pipe($(()=>s(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};let as=ee;as.DRAG_START_EVENTS=["mousedown","touchstart"],as.DRAG_EVENTS=["mousemove","touchmove"],as.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];var rf=function(s){z(t,s);function t(e,n,i){e===void 0&&(e=1/0),n===void 0&&(n=1/0),i===void 0&&(i=Ls);var r=s.call(this)||this;return r._bufferSize=e,r._windowTime=n,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=n===1/0,r._bufferSize=Math.max(1,e),r._windowTime=Math.max(1,n),r}return t.prototype.next=function(e){var n=this,i=n.isStopped,r=n._buffer,o=n._infiniteTimeWindow,a=n._timestampProvider,l=n._windowTime;i||(r.push(e),!o&&r.push(a.now()+l)),this._trimBuffer(),s.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var n=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),n},t.prototype._trimBuffer=function(){var e=this,n=e._bufferSize,i=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*n;if(n<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}(I);const an={};function of(s){return an[s]||(an[s]=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:s,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),an[s]}const Mo=(s,t=Date.now())=>{const n=of(s).format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+)/.exec(n);if(i){const r=Date.UTC(+i[3],+i[1]-1,+i[2],+i[4]%24,+i[5],0);let o=t;const a=o%1e3;return o-=a>=0?a:1e3+a,r-o}return 0},Ao=60*1e3;class af{constructor(t){this.config=t,this.timeZoneChangedSubject=new rf,this.currentTzOffset=e=>Mo(this.config.timezone,e)+new Date(e).getTimezoneOffset()*Ao,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 n=t.createFormatterFunction;e=i=>n(i).bind(t)}else e=Uh(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+Mo(t,e)+new Date(e).getTimezoneOffset()*Ao):e=>new Date(e)}}class ln{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var n,i;this.parentElement=t;const r=e;Ka(r),this.config=r;const o=Cl(r);t.innerHTML="",t.appendChild(o.content),this.id=(n=t.getAttribute("data-id"))!=null?n:"",r.fixedSize&&(t.style.width=r.fixedSize.width+"px",t.style.height=r.fixedSize.height+"px");const a=new af(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=wl(t);this.elements=c;const h=new Eg;this.bus=h;const d=new Dg(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 oh(h,d);this.drawingManager=u;const g=ih(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=g,this.dynamicObjectsCanvasModel=ce(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const w=new _e(this.dynamicObjectsCanvasModel);u.addDrawer(w,"SERIES_CLEAR");const y=ce(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),_=new Es(r,h,g,l,d);this.canvasBoundsContainer=_;const M=c.mainCanvas.parentElement;if(M===null)throw new Error("Couldn't get main canvas parent");const B=new as(h,M);this.canvasInputListener=B,this.chartComponents.push(this.canvasInputListener);const F=new ed(h,c.hitTestCanvas,B,_,u,r,this.canvasModels,c.chartResizer);this.hitTestCanvasModel=F;const j=new _e(F);u.addDrawer(j,"HIT_TEST_CLEAR");const H=new Ta(h);this.canvasAnimation=H;const R=x.PANE_UUID(q),Y=new Qi(r,()=>_.getBounds(R),H);this.scaleModel=Y;const Z=ce(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=Z,this.cursorHandler=new ml(c.canvasArea,B,_,F),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new Wg(B,_),this.chartComponents.push(this.crossEventProducer);const K=new Ul("candle");this.chartBaseModel=K;const U=new Fd(h,Y,_,r,H,B,M,K);this.chartPanComponent=U,this.chartComponents.push(U),this.userInputListenerComponents.push(U.chartAreaPanHandler);const W=new wu(K,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,Y,_,r,H,B,u,this.cursorHandler,this.crossEventProducer,U,g,y);this.paneManager=W;const J=this.paneManager.panes[q];this.mainPane=J,this.chartComponents.push(W),this.dynamicObjects=new zh(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new Ah(K,W,h,this.dynamicObjectsCanvasModel,r,Y,l,M,_,d);const Q=new mh(this.chartModel,this.dynamicObjectsCanvasModel,r,Y,_,u,F,B,Z,U,W,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(Q),this.chartComponent=Q;const tt=this.chartComponent.chartModel;this.chartModel=tt,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),F.addSubscriber(W.hitTestController),this.xAxisComponent=new yg(h,r,g,Q,Y,_,B,d,this.drawingManager,a,U,this.cursorHandler,Z),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const et=new _e(g);u.addDrawer(et,"MAIN_CLEAR");const it=new Lg(M,tt,B,r);this.chartComponents.push(it),this.watermarkComponent=new Fu(W,tt,h,r,_,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const ot=ce(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new wd(h,r,tt,g,_,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(tt)),this.navigationMapComponent=new Ed(h,tt,g,r,B,_,u,l,U,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const St=new gd(r,this.dynamicObjectsCanvasModel,tt,_,u);this.chartComponents.push(St),this.initYAxisDrawer(y),this.yAxisComponent=J.mainExtent.yAxis;const xt=new Pg(this.chartModel,this.config,J.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(xt,Ks.MAIN),this.volumesComponent=new Lu(this.dynamicObjectsCanvasModel,Q,Y,_,u,r,W,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const _t=new Or(g,Y,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(x.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(R),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>this.yAxisComponent.model.baseLabelsModel.labels,()=>J.mainExtent.toY(J.mainExtent.getBaseline()),()=>r.components.grid.visible);this.chartComponents.push(_t),this.hoverProducer=new Qg(this.crossEventProducer,Y,r,tt,B,this.canvasBoundsContainer,this.paneManager,a,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new Yh(r,ot,_,u,W,this.crossEventProducer,this.hoverProducer,this.backgroundCanvasModel),this.chartComponents.push(this.crossToolComponent);const se=ce(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),Ae=new yu(this.elements,se);this.snapshotComponent=Ae,this.chartComponents.push(Ae);const cn=new hd(r,this.dynamicObjectsCanvasModel,F,tt,_,u,l,this.cursorHandler,Z);this.eventsComponent=cn,this.chartComponents.push(cn),this.chartComponents.forEach(Bo=>Bo.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=Ea(this.components)}initYAxisDrawer(t){const e=new Us,n=new _e(t);e.addDrawer(n,"YAXIS_CLEAR"),this.drawingManager.addDrawer(e,"Y_AXIS");const i=new Mg(this.config,t,this.paneManager);e.addDrawer(i);const r=new Tg(t,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);e.addDrawer(r)}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:n=>e.test(n)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const n in e)n in t?typeof t[n]=="object"&&ln.mergeConfig(t[n],e[n]):t[n]=e[n];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,n,i,r,o;const a=this.config.components.grid;a.visible=(e=t.visible)!=null?e:!1,a.dash=(n=t.dash)!=null?n:[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){Dt(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const n=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseMove(n).subscribe(e);return()=>i.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,n=!1){const i=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseEnter(i,n).subscribe(e);return()=>r.unsubscribe()}addClickOnChartElementHandler(t,e){const n=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeClick(n).subscribe(e);return()=>i.unsubscribe()}addDragEventsListener(t,e){const n=this.canvasBoundsContainer.getBoundsHitTest(t),i=ft(this.canvasInputListener.observeYDrag(n),this.canvasInputListener.observeXDrag(n)).subscribe(e);return()=>i.unsubscribe()}registerComponent(t,e){const n=t(this);this.components.push(n),e&&e(n),n.activate()}}class Eo extends ln{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 n;(n=this.paneManager.panes[t])==null||n.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,...n]=t;this.chartComponent.setAllSeries(e,n)}else this.chartComponent.setMainSeries(t)}updateData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...n]=t;this.chartComponent.updateAllSeries(e,n)}else this.chartComponent.updateAllSeries(t)}setAutoScale(t=!0){this.scale.autoScale(t)}setRtl(t){this.config.rtl=t,this.bus.fireDraw()}setChartType(t){this.chartComponent.setChartType(t)}createPane(){return this.paneManager.createPane()}}var lf=Object.defineProperty,cf=Object.defineProperties,hf=Object.getOwnPropertyDescriptors,Lo=Object.getOwnPropertySymbols,df=Object.prototype.hasOwnProperty,uf=Object.prototype.propertyIsEnumerable,Do=(s,t,e)=>t in s?lf(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,gf=(s,t)=>{for(var e in t||(t={}))df.call(t,e)&&Do(s,e,t[e]);if(Lo)for(var e of Lo(t))uf.call(t,e)&&Do(s,e,t[e]);return s},ff=(s,t)=>cf(s,hf(t));function Io(s){s=s||{},s.quantity=s.quantity||200,s.startY=s.startY||50,s.avgCandleSize=s.avgCandleSize||2,s.avgTrendLength=s.avgTrendLength||{},s.avgTrendLength.sw=s.avgTrendLength.sw||10,s.avgTrendLength.down=s.avgTrendLength.down||10,s.avgTrendLength.up=s.avgTrendLength.up||10,s.withVolume=s.withVolume===!0||!1,s.period=s.period||3600;var t=[],e=s.quantity||200,n=10,i=10,r=10;s.avgTrendLength&&(n=s.avgTrendLength.sw||10,i=s.avgTrendLength.down||10,r=s.avgTrendLength.up||10);var o=s.startY||50,a=s.avgCandleSize||2,l=o-a,c=o+a,h=ls(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(vf(t[t.length-1],a,n)):d>3?t=t.concat(pf(t[t.length-1],a,r)):t=t.concat(mf(t[t.length-1],a,i))}t=t.slice(0,s.quantity);let u=Math.round(new Date().getTime()/3e5)*3e5;u-=e*1e3*s.period;for(let g=0;g<t.length;g++){const w=t[g];Object.assign(w,{timestamp:u,isVisible:!0}),u+=1e3*s.period,s.withVolume&&(w.volume=Math.ceil(Math.random()*1e3+200))}return t}function ls(s,t,e,n){var i=Math.random()*(t-s)+s,r;if(n&&n==="bull"||!n&&Math.random()>.5){var o=i+e;r=o<t?o:t}else{var a=i-e;r=a>s?a:s}var l=Math.max(i,r)+Math.random()*e*.2,c=Math.min(i,r)-Math.random()*e*.2;return{hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function pf(s,t,e){for(var n=[],i=Math.random()*e+e/2,r=s.lo,o=s.hi+t*1.2,a=0;a<i;a++){var l=Math.random()>.9?"bear":"bull",c=ls(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),n.push(c)}return n}function mf(s,t,e){for(var n=[],i=Math.random()*e+e/2,r=s.hi-t*1.2,o=s.hi,a=0;a<i;a++){var l=Math.random()<.9?"bear":"bull",c=ls(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),n.push(c)}return n}function vf(s,t,e){var n=[],i=Math.random()*e+e/2;function r(u){var g,w;return Math.random()>.5?(g=u.lo-t*.2,w=u.hi+t*1.2):(g=u.lo-t*1.2,w=u.hi+t*.2),{from:g,to:w}}for(var o=r(s),a=o.from,l=o.to,c=0;c<i;c++){var h=Math.random()<.5?"bear":"bull",d=ls(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),n.push(d)}return n}window.DXChart=ff(gf({},window.DXChart),{generateCandlesData:Io});function bf(s){return Io(s)}const Cf=(s,t={})=>new Eo(s,t)})(),window.DXChart=cs})();})();
|