@devexperts/dxcharts-lite 2.7.31 → 2.7.33
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/components/chart/price-formatters/__tests__/price.formatter.test.d.ts +6 -0
- package/dist/chart/components/chart/price-formatters/__tests__/price.formatter.test.js +150 -0
- package/dist/chart/components/chart/price-formatters/price.formatter.d.ts +1 -1
- package/dist/chart/components/chart/price-formatters/price.formatter.js +10 -3
- package/dist/chart/components/chart/price-formatters/treasury-price.formatter.d.ts +1 -1
- package/dist/chart/components/chart/price-formatters/treasury-price.formatter.js +7 -2
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +1 -1
- package/dist/chart/components/highlights/highlights.drawer.d.ts +3 -4
- package/dist/chart/components/highlights/highlights.drawer.js +38 -29
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +7 -2
- package/dist/chart/components/pane/extent/y-extent-component.js +9 -5
- package/dist/chart/components/pane/pane.component.d.ts +7 -5
- package/dist/chart/components/pane/pane.component.js +15 -4
- package/dist/chart/components/volumes/separate-volumes.component.d.ts +3 -1
- package/dist/chart/components/volumes/separate-volumes.component.js +19 -3
- package/dist/chart/components/volumes/volumes.component.d.ts +2 -0
- package/dist/chart/components/volumes/volumes.component.js +9 -0
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +1 -1
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +4 -1
- package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
- package/dist/chart/model/hit-test-canvas.model.js +1 -0
- package/dist/chart/model/scale.model.js +4 -0
- package/dist/chart/utils/math.utils.d.ts +2 -0
- package/dist/chart/utils/math.utils.js +8 -1
- package/dist/dxchart.min.js +4 -4
- package/package.json +7 -7
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 ot=Math.pow;(()=>{var Ia={165(j,it,N){const q=N(877),z={};for(const b of Object.keys(q))z[q[b]]=b;const O={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};j.exports=O;for(const b of Object.keys(O)){if(!("channels"in O[b]))throw new Error("missing channels property: "+b);if(!("labels"in O[b]))throw new Error("missing channel labels property: "+b);if(O[b].labels.length!==O[b].channels)throw new Error("channel and label counts mismatch: "+b);const{channels:y,labels:C}=O[b];delete O[b].channels,delete O[b].labels,Object.defineProperty(O[b],"channels",{value:y}),Object.defineProperty(O[b],"labels",{value:C})}O.rgb.hsl=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(y,C,w),x=Math.max(y,C,w),P=x-g;let D,v;x===g?D=0:y===x?D=(C-w)/P:C===x?D=2+(w-y)/P:w===x&&(D=4+(y-C)/P),D=Math.min(D*60,360),D<0&&(D+=360);const T=(g+x)/2;return x===g?v=0:T<=.5?v=P/(x+g):v=P/(2-x-g),[D,v*100,T*100]},O.rgb.hsv=function(b){let y,C,w,g,x;const P=b[0]/255,D=b[1]/255,v=b[2]/255,T=Math.max(P,D,v),I=T-Math.min(P,D,v),L=function(H){return(T-H)/6/I+1/2};return I===0?(g=0,x=0):(x=I/T,y=L(P),C=L(D),w=L(v),P===T?g=w-C:D===T?g=.3333333333333333+y-w:v===T&&(g=.6666666666666666+C-y),g<0?g+=1:g>1&&(g-=1)),[g*360,x*100,T*100]},O.rgb.hwb=function(b){const y=b[0],C=b[1];let w=b[2];const g=O.rgb.hsl(b)[0],x=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,x*100,w*100]},O.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),x=(1-y-g)/(1-g)||0,P=(1-C-g)/(1-g)||0,D=(1-w-g)/(1-g)||0;return[x*100,P*100,D*100,g*100]};function dt(b,y){return ot(b[0]-y[0],2)+ot(b[1]-y[1],2)+ot(b[2]-y[2],2)}O.rgb.keyword=function(b){const y=z[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(q)){const x=q[g],P=dt(b,x);P<C&&(C=P,w=g)}return w},O.keyword.rgb=function(b){return q[b]},O.rgb.xyz=function(b){let y=b[0]/255,C=b[1]/255,w=b[2]/255;y=y>.04045?ot((y+.055)/1.055,2.4):y/12.92,C=C>.04045?ot((C+.055)/1.055,2.4):C/12.92,w=w>.04045?ot((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,x=y*.2126+C*.7152+w*.0722,P=y*.0193+C*.1192+w*.9505;return[g*100,x*100,P*100]},O.rgb.lab=function(b){const y=O.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?ot(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?ot(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?ot(g,.3333333333333333):7.787*g+.13793103448275862;const x=116*w-16,P=500*(C-w),D=200*(w-g);return[x,P,D]},O.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,x,P;if(C===0)return P=w*255,[P,P,P];w<.5?g=w*(1+C):g=w+C-w*C;const D=2*w-g,v=[0,0,0];for(let T=0;T<3;T++)x=y+.3333333333333333*-(T-1),x<0&&x++,x>1&&x--,6*x<1?P=D+(g-D)*6*x:2*x<1?P=g:3*x<2?P=D+(g-D)*(.6666666666666666-x)*6:P=D,v[T]=P*255;return v},O.hsl.hsv=function(b){const y=b[0];let C=b[1]/100,w=b[2]/100,g=C;const x=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=x<=1?x:2-x;const P=(w+C)/2,D=w===0?2*g/(x+g):2*C/(w+C);return[y,D*100,P*100]},O.hsv.rgb=function(b){const y=b[0]/60,C=b[1]/100;let w=b[2]/100;const g=Math.floor(y)%6,x=y-Math.floor(y),P=255*w*(1-C),D=255*w*(1-C*x),v=255*w*(1-C*(1-x));switch(w*=255,g){case 0:return[w,v,P];case 1:return[D,w,P];case 2:return[P,w,v];case 3:return[P,D,w];case 4:return[v,P,w];case 5:return[w,P,D]}},O.hsv.hsl=function(b){const y=b[0],C=b[1]/100,w=b[2]/100,g=Math.max(w,.01);let x,P;P=(2-C)*w;const D=(2-C)*g;return x=C*g,x/=D<=1?D:2-D,x=x||0,P/=2,[y,x*100,P*100]},O.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let x;g>1&&(C/=g,w/=g);const P=Math.floor(6*y),D=1-w;x=6*y-P,(P&1)!==0&&(x=1-x);const v=C+x*(D-C);let T,I,L;switch(P){default:case 6:case 0:T=D,I=v,L=C;break;case 1:T=v,I=D,L=C;break;case 2:T=C,I=D,L=v;break;case 3:T=C,I=v,L=D;break;case 4:T=v,I=C,L=D;break;case 5:T=D,I=C,L=v;break}return[T*255,I*255,L*255]},O.cmyk.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100,g=b[3]/100,x=1-Math.min(1,y*(1-g)+g),P=1-Math.min(1,C*(1-g)+g),D=1-Math.min(1,w*(1-g)+g);return[x*255,P*255,D*255]},O.xyz.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100;let g,x,P;return g=y*3.2406+C*-1.5372+w*-.4986,x=y*-.9689+C*1.8758+w*.0415,P=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*ot(g,.4166666666666667)-.055:g*12.92,x=x>.0031308?1.055*ot(x,.4166666666666667)-.055:x*12.92,P=P>.0031308?1.055*ot(P,.4166666666666667)-.055:P*12.92,g=Math.min(Math.max(0,g),1),x=Math.min(Math.max(0,x),1),P=Math.min(Math.max(0,P),1),[g*255,x*255,P*255]},O.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?ot(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?ot(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?ot(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,x=500*(y-C),P=200*(C-w);return[g,x,P]},O.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,x,P;x=(y+16)/116,g=C/500+x,P=x-w/200;const D=ot(x,3),v=ot(g,3),T=ot(P,3);return x=D>.008856?D:(x-.13793103448275862)/7.787,g=v>.008856?v:(g-.13793103448275862)/7.787,P=T>.008856?T:(P-.13793103448275862)/7.787,g*=95.047,x*=100,P*=108.883,[g,x,P]},O.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const P=Math.sqrt(C*C+w*w);return[y,P,g]},O.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,x=C*Math.cos(g),P=C*Math.sin(g);return[y,x,P]},O.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let x=y===null?O.rgb.hsv(b)[2]:y;if(x=Math.round(x/50),x===0)return 30;let P=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return x===2&&(P+=60),P},O.hsv.ansi16=function(b){return O.rgb.ansi16(O.hsv.rgb(b),b[2])},O.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},O.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,x=(y>>2&1)*C*255;return[w,g,x]},O.ansi256.rgb=function(b){if(b>=232){const x=(b-232)*10+8;return[x,x,x]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},O.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},O.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(D=>D+D).join(""));const w=parseInt(C,16),g=w>>16&255,x=w>>8&255,P=w&255;return[g,x,P]},O.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),x=Math.min(Math.min(y,C),w),P=g-x;let D,v;return P<1?D=x/(1-P):D=0,P<=0?v=0:g===y?v=(C-w)/P%6:g===C?v=2+(w-y)/P:v=4+(y-C)/P,v/=6,v%=1,[v*360,P*100,D*100]},O.hsl.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=C<.5?2*y*C:2*y*(1-C);let g=0;return w<1&&(g=(C-.5*w)/(1-w)),[b[0],w*100,g*100]},O.hsv.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=y*C;let g=0;return w<1&&(g=(C-w)/(1-w)),[b[0],w*100,g*100]},O.hcg.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;if(C===0)return[w*255,w*255,w*255];const g=[0,0,0],x=y%1*6,P=x%1,D=1-P;let v=0;switch(Math.floor(x)){case 0:g[0]=1,g[1]=P,g[2]=0;break;case 1:g[0]=D,g[1]=1,g[2]=0;break;case 2:g[0]=0,g[1]=1,g[2]=P;break;case 3:g[0]=0,g[1]=D,g[2]=1;break;case 4:g[0]=P,g[1]=0,g[2]=1;break;default:g[0]=1,g[1]=0,g[2]=D}return v=(1-C)*w,[(C*g[0]+v)*255,(C*g[1]+v)*255,(C*g[2]+v)*255]},O.hcg.hsv=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);let g=0;return w>0&&(g=y/w),[b[0],g*100,w*100]},O.hcg.hsl=function(b){const y=b[1]/100,w=b[2]/100*(1-y)+.5*y;let g=0;return w>0&&w<.5?g=y/(2*w):w>=.5&&w<1&&(g=y/(2*(1-w))),[b[0],g*100,w*100]},O.hcg.hwb=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);return[b[0],(w-y)*100,(1-w)*100]},O.hwb.hcg=function(b){const y=b[1]/100,w=1-b[2]/100,g=w-y;let x=0;return g<1&&(x=(w-g)/(1-g)),[b[0],g*100,x*100]},O.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},O.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},O.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},O.gray.hsl=function(b){return[0,0,b[0]]},O.gray.hsv=O.gray.hsl,O.gray.hwb=function(b){return[0,100,b[0]]},O.gray.cmyk=function(b){return[0,0,0,b[0]]},O.gray.lab=function(b){return[b[0],0,0]},O.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},O.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}},880(j,it,N){const q=N(165),z=N(985),O={},dt=Object.keys(q);function b(C){const w=function(...g){const x=g[0];return x==null?x:(x.length>1&&(g=x),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const x=g[0];if(x==null)return x;x.length>1&&(g=x);const P=C(g);if(typeof P=="object")for(let D=P.length,v=0;v<D;v++)P[v]=Math.round(P[v]);return P};return"conversion"in C&&(w.conversion=C.conversion),w}dt.forEach(C=>{O[C]={},Object.defineProperty(O[C],"channels",{value:q[C].channels}),Object.defineProperty(O[C],"labels",{value:q[C].labels});const w=z(C);Object.keys(w).forEach(x=>{const P=w[x];O[C][x]=y(P),O[C][x].raw=b(P)})}),j.exports=O},985(j,it,N){const q=N(165);function z(){const y={},C=Object.keys(q);for(let w=C.length,g=0;g<w;g++)y[C[g]]={distance:-1,parent:null};return y}function O(y){const C=z(),w=[y];for(C[y].distance=0;w.length;){const g=w.pop(),x=Object.keys(q[g]);for(let P=x.length,D=0;D<P;D++){const v=x[D],T=C[v];T.distance===-1&&(T.distance=C[g].distance+1,T.parent=g,w.unshift(v))}}return C}function dt(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=q[C[y].parent][y],x=C[y].parent;for(;C[x].parent;)w.unshift(C[x].parent),g=dt(q[C[x].parent][x],g),x=C[x].parent;return g.conversion=w,g}j.exports=function(y){const C=O(y),w={},g=Object.keys(C);for(let x=g.length,P=0;P<x;P++){const D=g[P];C[D].parent!==null&&(w[D]=b(D,C))}return w}},877(j){"use strict";j.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},138(j,it,N){var q=N(877),z=N(403),O=Object.hasOwnProperty,dt=Object.create(null);for(var b in q)O.call(q,b)&&(dt[q[b]]=b);var y=j.exports={to:{},get:{}};y.get=function(g){var x=g.substring(0,3).toLowerCase(),P,D;switch(x){case"hsl":P=y.get.hsl(g),D="hsl";break;case"hwb":P=y.get.hwb(g),D="hwb";break;default:P=y.get.rgb(g),D="rgb";break}return P?{model:D,value:P}:null},y.get.rgb=function(g){if(!g)return null;var x=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,D=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,v=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,T=/^(\w+)$/,I=[0,0,0,1],L,H,ut;if(L=g.match(P)){for(ut=L[2],L=L[1],H=0;H<3;H++){var Dt=H*2;I[H]=parseInt(L.slice(Dt,Dt+2),16)}ut&&(I[3]=parseInt(ut,16)/255)}else if(L=g.match(x)){for(L=L[1],ut=L[3],H=0;H<3;H++)I[H]=parseInt(L[H]+L[H],16);ut&&(I[3]=parseInt(ut+ut,16)/255)}else if(L=g.match(D)){for(H=0;H<3;H++)I[H]=parseInt(L[H+1],0);L[4]&&(L[5]?I[3]=parseFloat(L[4])*.01:I[3]=parseFloat(L[4]))}else if(L=g.match(v)){for(H=0;H<3;H++)I[H]=Math.round(parseFloat(L[H+1])*2.55);L[4]&&(L[5]?I[3]=parseFloat(L[4])*.01:I[3]=parseFloat(L[4]))}else return(L=g.match(T))?L[1]==="transparent"?[0,0,0,0]:O.call(q,L[1])?(I=q[L[1]],I[3]=1,I):null:null;for(H=0;H<3;H++)I[H]=C(I[H],0,255);return I[3]=C(I[3],0,1),I},y.get.hsl=function(g){if(!g)return null;var x=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(x);if(P){var D=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),L=C(isNaN(D)?1:D,0,1);return[v,T,I,L]}return null},y.get.hwb=function(g){if(!g)return null;var x=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(x);if(P){var D=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),L=C(isNaN(D)?1:D,0,1);return[v,T,I,L]}return null},y.to.hex=function(){var g=z(arguments);return"#"+w(g[0])+w(g[1])+w(g[2])+(g[3]<1?w(Math.round(g[3]*255)):"")},y.to.rgb=function(){var g=z(arguments);return g.length<4||g[3]===1?"rgb("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+")":"rgba("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+", "+g[3]+")"},y.to.rgb.percent=function(){var g=z(arguments),x=Math.round(g[0]/255*100),P=Math.round(g[1]/255*100),D=Math.round(g[2]/255*100);return g.length<4||g[3]===1?"rgb("+x+"%, "+P+"%, "+D+"%)":"rgba("+x+"%, "+P+"%, "+D+"%, "+g[3]+")"},y.to.hsl=function(){var g=z(arguments);return g.length<4||g[3]===1?"hsl("+g[0]+", "+g[1]+"%, "+g[2]+"%)":"hsla("+g[0]+", "+g[1]+"%, "+g[2]+"%, "+g[3]+")"},y.to.hwb=function(){var g=z(arguments),x="";return g.length>=4&&g[3]!==1&&(x=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+x+")"},y.to.keyword=function(g){return dt[g.slice(0,3)]};function C(g,x,P){return Math.min(Math.max(x,g),P)}function w(g){var x=Math.round(g).toString(16).toUpperCase();return x.length<2?"0"+x:x}},742(j,it,N){const q=N(138),z=N(880),O=["keyword","gray","hex"],dt={};for(const v of Object.keys(z))dt[[...z[v].labels].sort().join("")]=v;const b={};function y(v,T){if(!(this instanceof y))return new y(v,T);if(T&&T in O&&(T=null),T&&!(T in z))throw new Error("Unknown model: "+T);let I,L;if(v==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(v instanceof y)this.model=v.model,this.color=[...v.color],this.valpha=v.valpha;else if(typeof v=="string"){const H=q.get(v);if(H===null)throw new Error("Unable to parse color from string: "+v);this.model=H.model,L=z[this.model].channels,this.color=H.value.slice(0,L),this.valpha=typeof H.value[L]=="number"?H.value[L]:1}else if(v.length>0){this.model=T||"rgb",L=z[this.model].channels;const H=Array.prototype.slice.call(v,0,L);this.color=D(H,L),this.valpha=typeof v[L]=="number"?v[L]:1}else if(typeof v=="number")this.model="rgb",this.color=[v>>16&255,v>>8&255,v&255],this.valpha=1;else{this.valpha=1;const H=Object.keys(v);"alpha"in v&&(H.splice(H.indexOf("alpha"),1),this.valpha=typeof v.alpha=="number"?v.alpha:0);const ut=H.sort().join("");if(!(ut in dt))throw new Error("Unable to parse color from object: "+JSON.stringify(v));this.model=dt[ut];const{labels:Dt}=z[this.model],at=[];for(I=0;I<Dt.length;I++)at.push(v[Dt[I]]);this.color=D(at)}if(b[this.model])for(L=z[this.model].channels,I=0;I<L;I++){const H=b[this.model][I];H&&(this.color[I]=H(this.color[I]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}y.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(v){let T=this.model in q.to?this:this.rgb();T=T.round(typeof v=="number"?v:1);const I=T.valpha===1?T.color:[...T.color,this.valpha];return q.to[T.model](I)},percentString(v){const T=this.rgb().round(typeof v=="number"?v:1),I=T.valpha===1?T.color:[...T.color,this.valpha];return q.to.rgb.percent(I)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const v={},{channels:T}=z[this.model],{labels:I}=z[this.model];for(let L=0;L<T;L++)v[I[L]]=this.color[L];return this.valpha!==1&&(v.alpha=this.valpha),v},unitArray(){const v=this.rgb().color;return v[0]/=255,v[1]/=255,v[2]/=255,this.valpha!==1&&v.push(this.valpha),v},unitObject(){const v=this.rgb().object();return v.r/=255,v.g/=255,v.b/=255,this.valpha!==1&&(v.alpha=this.valpha),v},round(v){return v=Math.max(v||0,0),new y([...this.color.map(w(v)),this.valpha],this.model)},alpha(v){return v!==void 0?new y([...this.color,Math.max(0,Math.min(1,v))],this.model):this.valpha},red:g("rgb",0,x(255)),green:g("rgb",1,x(255)),blue:g("rgb",2,x(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,v=>(v%360+360)%360),saturationl:g("hsl",1,x(100)),lightness:g("hsl",2,x(100)),saturationv:g("hsv",1,x(100)),value:g("hsv",2,x(100)),chroma:g("hcg",1,x(100)),gray:g("hcg",2,x(100)),white:g("hwb",1,x(100)),wblack:g("hwb",2,x(100)),cyan:g("cmyk",0,x(100)),magenta:g("cmyk",1,x(100)),yellow:g("cmyk",2,x(100)),black:g("cmyk",3,x(100)),x:g("xyz",0,x(95.047)),y:g("xyz",1,x(100)),z:g("xyz",2,x(108.833)),l:g("lab",0,x(100)),a:g("lab",1),b:g("lab",2),keyword(v){return v!==void 0?new y(v):z[this.model].keyword(this.color)},hex(v){return v!==void 0?new y(v):q.to.hex(this.rgb().round().color)},hexa(v){if(v!==void 0)return new y(v);const T=this.rgb().round().color;let I=Math.round(this.valpha*255).toString(16).toUpperCase();return I.length===1&&(I="0"+I),q.to.hex(T)+I},rgbNumber(){const v=this.rgb().color;return(v[0]&255)<<16|(v[1]&255)<<8|v[2]&255},luminosity(){const v=this.rgb().color,T=[];for(const[I,L]of v.entries()){const H=L/255;T[I]=H<=.04045?H/12.92:ot((H+.055)/1.055,2.4)}return .2126*T[0]+.7152*T[1]+.0722*T[2]},contrast(v){const T=this.luminosity(),I=v.luminosity();return T>I?(T+.05)/(I+.05):(I+.05)/(T+.05)},level(v){const T=this.contrast(v);return T>=7?"AAA":T>=4.5?"AA":""},isDark(){const v=this.rgb().color;return(v[0]*2126+v[1]*7152+v[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const v=this.rgb();for(let T=0;T<3;T++)v.color[T]=255-v.color[T];return v},lighten(v){const T=this.hsl();return T.color[2]+=T.color[2]*v,T},darken(v){const T=this.hsl();return T.color[2]-=T.color[2]*v,T},saturate(v){const T=this.hsl();return T.color[1]+=T.color[1]*v,T},desaturate(v){const T=this.hsl();return T.color[1]-=T.color[1]*v,T},whiten(v){const T=this.hwb();return T.color[1]+=T.color[1]*v,T},blacken(v){const T=this.hwb();return T.color[2]+=T.color[2]*v,T},grayscale(){const v=this.rgb().color,T=v[0]*.3+v[1]*.59+v[2]*.11;return y.rgb(T,T,T)},fade(v){return this.alpha(this.valpha-this.valpha*v)},opaquer(v){return this.alpha(this.valpha+this.valpha*v)},rotate(v){const T=this.hsl();let I=T.color[0];return I=(I+v)%360,I=I<0?360+I:I,T.color[0]=I,T},mix(v,T){if(!v||!v.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof v);const I=v.rgb(),L=this.rgb(),H=T===void 0?.5:T,ut=2*H-1,Dt=I.alpha()-L.alpha(),at=((ut*Dt===-1?ut:(ut+Dt)/(1+ut*Dt))+1)/2,Tt=1-at;return y.rgb(at*I.red()+Tt*L.red(),at*I.green()+Tt*L.green(),at*I.blue()+Tt*L.blue(),I.alpha()*H+L.alpha()*(1-H))}};for(const v of Object.keys(z)){if(O.includes(v))continue;const{channels:T}=z[v];y.prototype[v]=function(...I){return this.model===v?new y(this):I.length>0?new y(I,v):new y([...P(z[this.model][v].raw(this.color)),this.valpha],v)},y[v]=function(...I){let L=I[0];return typeof L=="number"&&(L=D(I,T)),new y(L,v)}}function C(v,T){return Number(v.toFixed(T))}function w(v){return function(T){return C(T,v)}}function g(v,T,I){v=Array.isArray(v)?v:[v];for(const L of v)(b[L]||(b[L]=[]))[T]=I;return v=v[0],function(L){let H;return L!==void 0?(I&&(L=I(L)),H=this[v](),H.color[T]=L,H):(H=this[v]().color[T],I&&(H=I(H)),H)}}function x(v){return function(T){return Math.max(0,Math.min(v,T))}}function P(v){return Array.isArray(v)?v:[v]}function D(v,T){for(let I=0;I<T;I++)typeof v[I]!="number"&&(v[I]=0);return v}j.exports=y},94(j){j.exports=function(N){return!N||typeof N=="string"?!1:N instanceof Array||Array.isArray(N)||N.length>=0&&(N.splice instanceof Function||Object.getOwnPropertyDescriptor(N,N.length-1)&&N.constructor.name!=="String")}},403(j,it,N){"use strict";var q=N(94),z=Array.prototype.concat,O=Array.prototype.slice,dt=j.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var x=y[w];q(x)?C=z.call(C,O.call(x)):C.push(x)}return C};dt.wrap=function(b){return function(){return b(dt(arguments))}}}},En={};function Pt(j){var it=En[j];if(it!==void 0)return it.exports;var N=En[j]={exports:{}};return Ia[j](N,N.exports,Pt),N.exports}Pt.n=j=>{var it=j&&j.__esModule?()=>j.default:()=>j;return Pt.d(it,{a:it}),it},Pt.d=(j,it)=>{for(var N in it)Pt.o(it,N)&&!Pt.o(j,N)&&Object.defineProperty(j,N,{enumerable:!0,get:it[N]})},Pt.o=(j,it)=>Object.prototype.hasOwnProperty.call(j,it),Pt.r=j=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(j,"__esModule",{value:!0})};var As={};(()=>{"use strict";Pt.r(As),Pt.d(As,{Chart:()=>Pa,createChart:()=>Ym,generateCandlesData:()=>jm});function j(n){return typeof n=="function"}function it(n){return j(n==null?void 0:n.lift)}function N(n){return function(t){if(it(t))return t.lift(function(e){try{return n(e,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}var q=function(n,t){return q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])},q(n,t)};function z(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");q(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var O=function(){return O=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++){e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},O.apply(this,arguments)};function dt(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t,e,s,i,r){function o(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=s.kind,l=a==="getter"?"get":a==="setter"?"set":"value",c=!t&&n?s.static?n:n.prototype:null,h=t||(c?Object.getOwnPropertyDescriptor(c,s.name):{}),d,u=!1,f=e.length-1;f>=0;f--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(S){if(u)throw new TypeError("Cannot add initializers after decoration has completed");r.push(o(S||null))};var _=(0,e[f])(a==="accessor"?{get:h.get,set:h.set}:h[l],p);if(a==="accessor"){if(_===void 0)continue;if(_===null||typeof _!="object")throw new TypeError("Object expected");(d=o(_.get))&&(h.get=d),(d=o(_.set))&&(h.set=d),(d=o(_.init))&&i.unshift(d)}else(d=o(_))&&(a==="field"?i.unshift(d):h[l]=d)}c&&Object.defineProperty(c,s.name,h),u=!0}function w(n,t,e){for(var s=arguments.length>2,i=0;i<t.length;i++)e=s?t[i].call(n,e):t[i].call(n);return s?e:void 0}function g(n){return typeof n=="symbol"?n:"".concat(n)}function x(n,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function P(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function D(n,t,e,s){function i(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(d){o(d)}}function l(h){try{c(s.throw(h))}catch(d){o(d)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,t||[])).next())})}function v(n,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,i,r,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(s=1,i&&(r=c[0]&2?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,i=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){e.label=c[1];break}if(c[0]===6&&e.label<r[1]){e.label=r[1],r=c;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(c);break}r[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],i=0}finally{s=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var T=Object.create?(function(n,t,e,s){s===void 0&&(s=e);var i=Object.getOwnPropertyDescriptor(t,e);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,s,i)}):(function(n,t,e,s){s===void 0&&(s=e),n[s]=t[e]});function I(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&T(t,n,e)}function L(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 H(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var s=e.call(n),i,r=[],o;try{for(;(t===void 0||t-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return r}function ut(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(H(arguments[t]));return n}function Dt(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var s=Array(n),i=0,t=0;t<e;t++)for(var r=arguments[t],o=0,a=r.length;o<a;o++,i++)s[i]=r[o];return s}function at(n,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,r;s<i;s++)(r||!(s in t))&&(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return n.concat(r||Array.prototype.slice.call(t))}function Tt(n){return this instanceof Tt?(this.v=n,this):new Tt(n)}function In(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=e.apply(n,t||[]),i,r=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(f){return function(p){return Promise.resolve(p).then(f,d)}}function a(f,p){s[f]&&(i[f]=function(m){return new Promise(function(_,S){r.push([f,m,_,S])>1||l(f,m)})},p&&(i[f]=p(i[f])))}function l(f,p){try{c(s[f](p))}catch(m){u(r[0][3],m)}}function c(f){f.value instanceof Tt?Promise.resolve(f.value.v).then(h,d):u(r[0][2],f)}function h(f){l("next",f)}function d(f){l("throw",f)}function u(f,p){f(p),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Da(n){var t,e;return t={},s("next"),s("throw",function(i){throw i}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(i,r){t[i]=n[i]?function(o){return(e=!e)?{value:Tt(n[i](o)),done:!1}:r?r(o):o}:r}}function Dn(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 L=="function"?L(n):n[Symbol.iterator](),e={},s("next"),s("throw"),s("return"),e[Symbol.asyncIterator]=function(){return this},e);function s(r){e[r]=n[r]&&function(o){return new Promise(function(a,l){o=n[r](o),i(a,l,o.done,o.value)})}}function i(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}function La(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var Oa=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},Es=function(n){return Es=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[e.length]=s);return e},Es(n)};function Ba(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=Es(n),s=0;s<e.length;s++)e[s]!=="default"&&T(t,n,e[s]);return Oa(t,n),t}function Ra(n){return n&&n.__esModule?n:{default:n}}function Fa(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 Ha(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e}function ka(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 ja(n,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,i;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],e&&(i=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");i&&(s=function(){try{i.call(this)}catch(r){return Promise.reject(r)}}),n.stack.push({value:t,dispose:s,async:e})}else e&&n.stack.push({async:!0});return t}var Ya=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var s=new Error(e);return s.name="SuppressedError",s.error=n,s.suppressed=t,s};function Na(n){function t(r){n.error=n.hasError?new Ya(r,n.error,"An error was suppressed during disposal."):r,n.hasError=!0}var e,s=0;function i(){for(;e=n.stack.pop();)try{if(!e.async&&s===1)return s=0,n.stack.push(e),Promise.resolve().then(i);if(e.dispose){var r=e.dispose.call(e.value);if(e.async)return s|=2,Promise.resolve(r).then(i,function(o){return t(o),i()})}else s|=1}catch(o){t(o)}if(s===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return i()}function Xa(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,s,i,r,o){return s?t?".jsx":".js":i&&(!r||!o)?e:i+r+"."+o.toLowerCase()+"js"}):n}const Nm={__extends:z,__assign:O,__rest:dt,__decorate:b,__param:y,__esDecorate:C,__runInitializers:w,__propKey:g,__setFunctionName:x,__metadata:P,__awaiter:D,__generator:v,__createBinding:T,__exportStar:I,__values:L,__read:H,__spread:ut,__spreadArrays:Dt,__spreadArray:at,__await:Tt,__asyncGenerator:In,__asyncDelegator:Da,__asyncValues:Dn,__makeTemplateObject:La,__importStar:Ba,__importDefault:Ra,__classPrivateFieldGet:Fa,__classPrivateFieldSet:Ha,__classPrivateFieldIn:ka,__addDisposableResource:ja,__disposeResources:Na,__rewriteRelativeImportExtension:Xa};function Ln(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 Is=Ln(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
6
|
+
(()=>{var lt=Math.pow;(()=>{var La={165(Y,it,N){const q=N(877),V={};for(const b of Object.keys(q))V[q[b]]=b;const O={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Y.exports=O;for(const b of Object.keys(O)){if(!("channels"in O[b]))throw new Error("missing channels property: "+b);if(!("labels"in O[b]))throw new Error("missing channel labels property: "+b);if(O[b].labels.length!==O[b].channels)throw new Error("channel and label counts mismatch: "+b);const{channels:y,labels:C}=O[b];delete O[b].channels,delete O[b].labels,Object.defineProperty(O[b],"channels",{value:y}),Object.defineProperty(O[b],"labels",{value:C})}O.rgb.hsl=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(y,C,w),x=Math.max(y,C,w),P=x-g;let D,v;x===g?D=0:y===x?D=(C-w)/P:C===x?D=2+(w-y)/P:w===x&&(D=4+(y-C)/P),D=Math.min(D*60,360),D<0&&(D+=360);const T=(g+x)/2;return x===g?v=0:T<=.5?v=P/(x+g):v=P/(2-x-g),[D,v*100,T*100]},O.rgb.hsv=function(b){let y,C,w,g,x;const P=b[0]/255,D=b[1]/255,v=b[2]/255,T=Math.max(P,D,v),I=T-Math.min(P,D,v),L=function(H){return(T-H)/6/I+1/2};return I===0?(g=0,x=0):(x=I/T,y=L(P),C=L(D),w=L(v),P===T?g=w-C:D===T?g=.3333333333333333+y-w:v===T&&(g=.6666666666666666+C-y),g<0?g+=1:g>1&&(g-=1)),[g*360,x*100,T*100]},O.rgb.hwb=function(b){const y=b[0],C=b[1];let w=b[2];const g=O.rgb.hsl(b)[0],x=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,x*100,w*100]},O.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),x=(1-y-g)/(1-g)||0,P=(1-C-g)/(1-g)||0,D=(1-w-g)/(1-g)||0;return[x*100,P*100,D*100,g*100]};function dt(b,y){return lt(b[0]-y[0],2)+lt(b[1]-y[1],2)+lt(b[2]-y[2],2)}O.rgb.keyword=function(b){const y=V[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(q)){const x=q[g],P=dt(b,x);P<C&&(C=P,w=g)}return w},O.keyword.rgb=function(b){return q[b]},O.rgb.xyz=function(b){let y=b[0]/255,C=b[1]/255,w=b[2]/255;y=y>.04045?lt((y+.055)/1.055,2.4):y/12.92,C=C>.04045?lt((C+.055)/1.055,2.4):C/12.92,w=w>.04045?lt((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,x=y*.2126+C*.7152+w*.0722,P=y*.0193+C*.1192+w*.9505;return[g*100,x*100,P*100]},O.rgb.lab=function(b){const y=O.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?lt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?lt(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?lt(g,.3333333333333333):7.787*g+.13793103448275862;const x=116*w-16,P=500*(C-w),D=200*(w-g);return[x,P,D]},O.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,x,P;if(C===0)return P=w*255,[P,P,P];w<.5?g=w*(1+C):g=w+C-w*C;const D=2*w-g,v=[0,0,0];for(let T=0;T<3;T++)x=y+.3333333333333333*-(T-1),x<0&&x++,x>1&&x--,6*x<1?P=D+(g-D)*6*x:2*x<1?P=g:3*x<2?P=D+(g-D)*(.6666666666666666-x)*6:P=D,v[T]=P*255;return v},O.hsl.hsv=function(b){const y=b[0];let C=b[1]/100,w=b[2]/100,g=C;const x=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=x<=1?x:2-x;const P=(w+C)/2,D=w===0?2*g/(x+g):2*C/(w+C);return[y,D*100,P*100]},O.hsv.rgb=function(b){const y=b[0]/60,C=b[1]/100;let w=b[2]/100;const g=Math.floor(y)%6,x=y-Math.floor(y),P=255*w*(1-C),D=255*w*(1-C*x),v=255*w*(1-C*(1-x));switch(w*=255,g){case 0:return[w,v,P];case 1:return[D,w,P];case 2:return[P,w,v];case 3:return[P,D,w];case 4:return[v,P,w];case 5:return[w,P,D]}},O.hsv.hsl=function(b){const y=b[0],C=b[1]/100,w=b[2]/100,g=Math.max(w,.01);let x,P;P=(2-C)*w;const D=(2-C)*g;return x=C*g,x/=D<=1?D:2-D,x=x||0,P/=2,[y,x*100,P*100]},O.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let x;g>1&&(C/=g,w/=g);const P=Math.floor(6*y),D=1-w;x=6*y-P,(P&1)!==0&&(x=1-x);const v=C+x*(D-C);let T,I,L;switch(P){default:case 6:case 0:T=D,I=v,L=C;break;case 1:T=v,I=D,L=C;break;case 2:T=C,I=D,L=v;break;case 3:T=C,I=v,L=D;break;case 4:T=v,I=C,L=D;break;case 5:T=D,I=C,L=v;break}return[T*255,I*255,L*255]},O.cmyk.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100,g=b[3]/100,x=1-Math.min(1,y*(1-g)+g),P=1-Math.min(1,C*(1-g)+g),D=1-Math.min(1,w*(1-g)+g);return[x*255,P*255,D*255]},O.xyz.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100;let g,x,P;return g=y*3.2406+C*-1.5372+w*-.4986,x=y*-.9689+C*1.8758+w*.0415,P=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*lt(g,.4166666666666667)-.055:g*12.92,x=x>.0031308?1.055*lt(x,.4166666666666667)-.055:x*12.92,P=P>.0031308?1.055*lt(P,.4166666666666667)-.055:P*12.92,g=Math.min(Math.max(0,g),1),x=Math.min(Math.max(0,x),1),P=Math.min(Math.max(0,P),1),[g*255,x*255,P*255]},O.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?lt(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?lt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?lt(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,x=500*(y-C),P=200*(C-w);return[g,x,P]},O.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,x,P;x=(y+16)/116,g=C/500+x,P=x-w/200;const D=lt(x,3),v=lt(g,3),T=lt(P,3);return x=D>.008856?D:(x-.13793103448275862)/7.787,g=v>.008856?v:(g-.13793103448275862)/7.787,P=T>.008856?T:(P-.13793103448275862)/7.787,g*=95.047,x*=100,P*=108.883,[g,x,P]},O.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const P=Math.sqrt(C*C+w*w);return[y,P,g]},O.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,x=C*Math.cos(g),P=C*Math.sin(g);return[y,x,P]},O.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let x=y===null?O.rgb.hsv(b)[2]:y;if(x=Math.round(x/50),x===0)return 30;let P=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return x===2&&(P+=60),P},O.hsv.ansi16=function(b){return O.rgb.ansi16(O.hsv.rgb(b),b[2])},O.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},O.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,x=(y>>2&1)*C*255;return[w,g,x]},O.ansi256.rgb=function(b){if(b>=232){const x=(b-232)*10+8;return[x,x,x]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},O.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},O.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(D=>D+D).join(""));const w=parseInt(C,16),g=w>>16&255,x=w>>8&255,P=w&255;return[g,x,P]},O.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),x=Math.min(Math.min(y,C),w),P=g-x;let D,v;return P<1?D=x/(1-P):D=0,P<=0?v=0:g===y?v=(C-w)/P%6:g===C?v=2+(w-y)/P:v=4+(y-C)/P,v/=6,v%=1,[v*360,P*100,D*100]},O.hsl.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=C<.5?2*y*C:2*y*(1-C);let g=0;return w<1&&(g=(C-.5*w)/(1-w)),[b[0],w*100,g*100]},O.hsv.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=y*C;let g=0;return w<1&&(g=(C-w)/(1-w)),[b[0],w*100,g*100]},O.hcg.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;if(C===0)return[w*255,w*255,w*255];const g=[0,0,0],x=y%1*6,P=x%1,D=1-P;let v=0;switch(Math.floor(x)){case 0:g[0]=1,g[1]=P,g[2]=0;break;case 1:g[0]=D,g[1]=1,g[2]=0;break;case 2:g[0]=0,g[1]=1,g[2]=P;break;case 3:g[0]=0,g[1]=D,g[2]=1;break;case 4:g[0]=P,g[1]=0,g[2]=1;break;default:g[0]=1,g[1]=0,g[2]=D}return v=(1-C)*w,[(C*g[0]+v)*255,(C*g[1]+v)*255,(C*g[2]+v)*255]},O.hcg.hsv=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);let g=0;return w>0&&(g=y/w),[b[0],g*100,w*100]},O.hcg.hsl=function(b){const y=b[1]/100,w=b[2]/100*(1-y)+.5*y;let g=0;return w>0&&w<.5?g=y/(2*w):w>=.5&&w<1&&(g=y/(2*(1-w))),[b[0],g*100,w*100]},O.hcg.hwb=function(b){const y=b[1]/100,C=b[2]/100,w=y+C*(1-y);return[b[0],(w-y)*100,(1-w)*100]},O.hwb.hcg=function(b){const y=b[1]/100,w=1-b[2]/100,g=w-y;let x=0;return g<1&&(x=(w-g)/(1-g)),[b[0],g*100,x*100]},O.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},O.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},O.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},O.gray.hsl=function(b){return[0,0,b[0]]},O.gray.hsv=O.gray.hsl,O.gray.hwb=function(b){return[0,100,b[0]]},O.gray.cmyk=function(b){return[0,0,0,b[0]]},O.gray.lab=function(b){return[b[0],0,0]},O.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},O.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}},880(Y,it,N){const q=N(165),V=N(985),O={},dt=Object.keys(q);function b(C){const w=function(...g){const x=g[0];return x==null?x:(x.length>1&&(g=x),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const x=g[0];if(x==null)return x;x.length>1&&(g=x);const P=C(g);if(typeof P=="object")for(let D=P.length,v=0;v<D;v++)P[v]=Math.round(P[v]);return P};return"conversion"in C&&(w.conversion=C.conversion),w}dt.forEach(C=>{O[C]={},Object.defineProperty(O[C],"channels",{value:q[C].channels}),Object.defineProperty(O[C],"labels",{value:q[C].labels});const w=V(C);Object.keys(w).forEach(x=>{const P=w[x];O[C][x]=y(P),O[C][x].raw=b(P)})}),Y.exports=O},985(Y,it,N){const q=N(165);function V(){const y={},C=Object.keys(q);for(let w=C.length,g=0;g<w;g++)y[C[g]]={distance:-1,parent:null};return y}function O(y){const C=V(),w=[y];for(C[y].distance=0;w.length;){const g=w.pop(),x=Object.keys(q[g]);for(let P=x.length,D=0;D<P;D++){const v=x[D],T=C[v];T.distance===-1&&(T.distance=C[g].distance+1,T.parent=g,w.unshift(v))}}return C}function dt(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=q[C[y].parent][y],x=C[y].parent;for(;C[x].parent;)w.unshift(C[x].parent),g=dt(q[C[x].parent][x],g),x=C[x].parent;return g.conversion=w,g}Y.exports=function(y){const C=O(y),w={},g=Object.keys(C);for(let x=g.length,P=0;P<x;P++){const D=g[P];C[D].parent!==null&&(w[D]=b(D,C))}return w}},877(Y){"use strict";Y.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]}},138(Y,it,N){var q=N(877),V=N(403),O=Object.hasOwnProperty,dt=Object.create(null);for(var b in q)O.call(q,b)&&(dt[q[b]]=b);var y=Y.exports={to:{},get:{}};y.get=function(g){var x=g.substring(0,3).toLowerCase(),P,D;switch(x){case"hsl":P=y.get.hsl(g),D="hsl";break;case"hwb":P=y.get.hwb(g),D="hwb";break;default:P=y.get.rgb(g),D="rgb";break}return P?{model:D,value:P}:null},y.get.rgb=function(g){if(!g)return null;var x=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,D=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,v=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,T=/^(\w+)$/,I=[0,0,0,1],L,H,ut;if(L=g.match(P)){for(ut=L[2],L=L[1],H=0;H<3;H++){var Dt=H*2;I[H]=parseInt(L.slice(Dt,Dt+2),16)}ut&&(I[3]=parseInt(ut,16)/255)}else if(L=g.match(x)){for(L=L[1],ut=L[3],H=0;H<3;H++)I[H]=parseInt(L[H]+L[H],16);ut&&(I[3]=parseInt(ut+ut,16)/255)}else if(L=g.match(D)){for(H=0;H<3;H++)I[H]=parseInt(L[H+1],0);L[4]&&(L[5]?I[3]=parseFloat(L[4])*.01:I[3]=parseFloat(L[4]))}else if(L=g.match(v)){for(H=0;H<3;H++)I[H]=Math.round(parseFloat(L[H+1])*2.55);L[4]&&(L[5]?I[3]=parseFloat(L[4])*.01:I[3]=parseFloat(L[4]))}else return(L=g.match(T))?L[1]==="transparent"?[0,0,0,0]:O.call(q,L[1])?(I=q[L[1]],I[3]=1,I):null:null;for(H=0;H<3;H++)I[H]=C(I[H],0,255);return I[3]=C(I[3],0,1),I},y.get.hsl=function(g){if(!g)return null;var x=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(x);if(P){var D=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),L=C(isNaN(D)?1:D,0,1);return[v,T,I,L]}return null},y.get.hwb=function(g){if(!g)return null;var x=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(x);if(P){var D=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),I=C(parseFloat(P[3]),0,100),L=C(isNaN(D)?1:D,0,1);return[v,T,I,L]}return null},y.to.hex=function(){var g=V(arguments);return"#"+w(g[0])+w(g[1])+w(g[2])+(g[3]<1?w(Math.round(g[3]*255)):"")},y.to.rgb=function(){var g=V(arguments);return g.length<4||g[3]===1?"rgb("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+")":"rgba("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+", "+g[3]+")"},y.to.rgb.percent=function(){var g=V(arguments),x=Math.round(g[0]/255*100),P=Math.round(g[1]/255*100),D=Math.round(g[2]/255*100);return g.length<4||g[3]===1?"rgb("+x+"%, "+P+"%, "+D+"%)":"rgba("+x+"%, "+P+"%, "+D+"%, "+g[3]+")"},y.to.hsl=function(){var g=V(arguments);return g.length<4||g[3]===1?"hsl("+g[0]+", "+g[1]+"%, "+g[2]+"%)":"hsla("+g[0]+", "+g[1]+"%, "+g[2]+"%, "+g[3]+")"},y.to.hwb=function(){var g=V(arguments),x="";return g.length>=4&&g[3]!==1&&(x=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+x+")"},y.to.keyword=function(g){return dt[g.slice(0,3)]};function C(g,x,P){return Math.min(Math.max(x,g),P)}function w(g){var x=Math.round(g).toString(16).toUpperCase();return x.length<2?"0"+x:x}},742(Y,it,N){const q=N(138),V=N(880),O=["keyword","gray","hex"],dt={};for(const v of Object.keys(V))dt[[...V[v].labels].sort().join("")]=v;const b={};function y(v,T){if(!(this instanceof y))return new y(v,T);if(T&&T in O&&(T=null),T&&!(T in V))throw new Error("Unknown model: "+T);let I,L;if(v==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(v instanceof y)this.model=v.model,this.color=[...v.color],this.valpha=v.valpha;else if(typeof v=="string"){const H=q.get(v);if(H===null)throw new Error("Unable to parse color from string: "+v);this.model=H.model,L=V[this.model].channels,this.color=H.value.slice(0,L),this.valpha=typeof H.value[L]=="number"?H.value[L]:1}else if(v.length>0){this.model=T||"rgb",L=V[this.model].channels;const H=Array.prototype.slice.call(v,0,L);this.color=D(H,L),this.valpha=typeof v[L]=="number"?v[L]:1}else if(typeof v=="number")this.model="rgb",this.color=[v>>16&255,v>>8&255,v&255],this.valpha=1;else{this.valpha=1;const H=Object.keys(v);"alpha"in v&&(H.splice(H.indexOf("alpha"),1),this.valpha=typeof v.alpha=="number"?v.alpha:0);const ut=H.sort().join("");if(!(ut in dt))throw new Error("Unable to parse color from object: "+JSON.stringify(v));this.model=dt[ut];const{labels:Dt}=V[this.model],ct=[];for(I=0;I<Dt.length;I++)ct.push(v[Dt[I]]);this.color=D(ct)}if(b[this.model])for(L=V[this.model].channels,I=0;I<L;I++){const H=b[this.model][I];H&&(this.color[I]=H(this.color[I]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}y.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(v){let T=this.model in q.to?this:this.rgb();T=T.round(typeof v=="number"?v:1);const I=T.valpha===1?T.color:[...T.color,this.valpha];return q.to[T.model](I)},percentString(v){const T=this.rgb().round(typeof v=="number"?v:1),I=T.valpha===1?T.color:[...T.color,this.valpha];return q.to.rgb.percent(I)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const v={},{channels:T}=V[this.model],{labels:I}=V[this.model];for(let L=0;L<T;L++)v[I[L]]=this.color[L];return this.valpha!==1&&(v.alpha=this.valpha),v},unitArray(){const v=this.rgb().color;return v[0]/=255,v[1]/=255,v[2]/=255,this.valpha!==1&&v.push(this.valpha),v},unitObject(){const v=this.rgb().object();return v.r/=255,v.g/=255,v.b/=255,this.valpha!==1&&(v.alpha=this.valpha),v},round(v){return v=Math.max(v||0,0),new y([...this.color.map(w(v)),this.valpha],this.model)},alpha(v){return v!==void 0?new y([...this.color,Math.max(0,Math.min(1,v))],this.model):this.valpha},red:g("rgb",0,x(255)),green:g("rgb",1,x(255)),blue:g("rgb",2,x(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,v=>(v%360+360)%360),saturationl:g("hsl",1,x(100)),lightness:g("hsl",2,x(100)),saturationv:g("hsv",1,x(100)),value:g("hsv",2,x(100)),chroma:g("hcg",1,x(100)),gray:g("hcg",2,x(100)),white:g("hwb",1,x(100)),wblack:g("hwb",2,x(100)),cyan:g("cmyk",0,x(100)),magenta:g("cmyk",1,x(100)),yellow:g("cmyk",2,x(100)),black:g("cmyk",3,x(100)),x:g("xyz",0,x(95.047)),y:g("xyz",1,x(100)),z:g("xyz",2,x(108.833)),l:g("lab",0,x(100)),a:g("lab",1),b:g("lab",2),keyword(v){return v!==void 0?new y(v):V[this.model].keyword(this.color)},hex(v){return v!==void 0?new y(v):q.to.hex(this.rgb().round().color)},hexa(v){if(v!==void 0)return new y(v);const T=this.rgb().round().color;let I=Math.round(this.valpha*255).toString(16).toUpperCase();return I.length===1&&(I="0"+I),q.to.hex(T)+I},rgbNumber(){const v=this.rgb().color;return(v[0]&255)<<16|(v[1]&255)<<8|v[2]&255},luminosity(){const v=this.rgb().color,T=[];for(const[I,L]of v.entries()){const H=L/255;T[I]=H<=.04045?H/12.92:lt((H+.055)/1.055,2.4)}return .2126*T[0]+.7152*T[1]+.0722*T[2]},contrast(v){const T=this.luminosity(),I=v.luminosity();return T>I?(T+.05)/(I+.05):(I+.05)/(T+.05)},level(v){const T=this.contrast(v);return T>=7?"AAA":T>=4.5?"AA":""},isDark(){const v=this.rgb().color;return(v[0]*2126+v[1]*7152+v[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){const v=this.rgb();for(let T=0;T<3;T++)v.color[T]=255-v.color[T];return v},lighten(v){const T=this.hsl();return T.color[2]+=T.color[2]*v,T},darken(v){const T=this.hsl();return T.color[2]-=T.color[2]*v,T},saturate(v){const T=this.hsl();return T.color[1]+=T.color[1]*v,T},desaturate(v){const T=this.hsl();return T.color[1]-=T.color[1]*v,T},whiten(v){const T=this.hwb();return T.color[1]+=T.color[1]*v,T},blacken(v){const T=this.hwb();return T.color[2]+=T.color[2]*v,T},grayscale(){const v=this.rgb().color,T=v[0]*.3+v[1]*.59+v[2]*.11;return y.rgb(T,T,T)},fade(v){return this.alpha(this.valpha-this.valpha*v)},opaquer(v){return this.alpha(this.valpha+this.valpha*v)},rotate(v){const T=this.hsl();let I=T.color[0];return I=(I+v)%360,I=I<0?360+I:I,T.color[0]=I,T},mix(v,T){if(!v||!v.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof v);const I=v.rgb(),L=this.rgb(),H=T===void 0?.5:T,ut=2*H-1,Dt=I.alpha()-L.alpha(),ct=((ut*Dt===-1?ut:(ut+Dt)/(1+ut*Dt))+1)/2,Pt=1-ct;return y.rgb(ct*I.red()+Pt*L.red(),ct*I.green()+Pt*L.green(),ct*I.blue()+Pt*L.blue(),I.alpha()*H+L.alpha()*(1-H))}};for(const v of Object.keys(V)){if(O.includes(v))continue;const{channels:T}=V[v];y.prototype[v]=function(...I){return this.model===v?new y(this):I.length>0?new y(I,v):new y([...P(V[this.model][v].raw(this.color)),this.valpha],v)},y[v]=function(...I){let L=I[0];return typeof L=="number"&&(L=D(I,T)),new y(L,v)}}function C(v,T){return Number(v.toFixed(T))}function w(v){return function(T){return C(T,v)}}function g(v,T,I){v=Array.isArray(v)?v:[v];for(const L of v)(b[L]||(b[L]=[]))[T]=I;return v=v[0],function(L){let H;return L!==void 0?(I&&(L=I(L)),H=this[v](),H.color[T]=L,H):(H=this[v]().color[T],I&&(H=I(H)),H)}}function x(v){return function(T){return Math.max(0,Math.min(v,T))}}function P(v){return Array.isArray(v)?v:[v]}function D(v,T){for(let I=0;I<T;I++)typeof v[I]!="number"&&(v[I]=0);return v}Y.exports=y},94(Y){Y.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")}},403(Y,it,N){"use strict";var q=N(94),V=Array.prototype.concat,O=Array.prototype.slice,dt=Y.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var x=y[w];q(x)?C=V.call(C,O.call(x)):C.push(x)}return C};dt.wrap=function(b){return function(){return b(dt(arguments))}}}},In={};function _t(Y){var it=In[Y];if(it!==void 0)return it.exports;var N=In[Y]={exports:{}};return La[Y](N,N.exports,_t),N.exports}_t.n=Y=>{var it=Y&&Y.__esModule?()=>Y.default:()=>Y;return _t.d(it,{a:it}),it},_t.d=(Y,it)=>{for(var N in it)_t.o(it,N)&&!_t.o(Y,N)&&Object.defineProperty(Y,N,{enumerable:!0,get:it[N]})},_t.o=(Y,it)=>Object.prototype.hasOwnProperty.call(Y,it),_t.r=Y=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Y,"__esModule",{value:!0})};var As={};(()=>{"use strict";_t.r(As),_t.d(As,{Chart:()=>Ta,createChart:()=>Nm,generateCandlesData:()=>Ym});function Y(n){return typeof n=="function"}function it(n){return Y(n==null?void 0:n.lift)}function N(n){return function(t){if(it(t))return t.lift(function(e){try{return n(e,this)}catch(s){this.error(s)}});throw new TypeError("Unable to lift unknown Observable type")}}var q=function(n,t){return q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,s){e.__proto__=s}||function(e,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i])},q(n,t)};function V(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");q(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var O=function(){return O=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++){e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},O.apply(this,arguments)};function dt(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t,e,s,i,r){function o(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=s.kind,l=a==="getter"?"get":a==="setter"?"set":"value",c=!t&&n?s.static?n:n.prototype:null,h=t||(c?Object.getOwnPropertyDescriptor(c,s.name):{}),d,u=!1,f=e.length-1;f>=0;f--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(S){if(u)throw new TypeError("Cannot add initializers after decoration has completed");r.push(o(S||null))};var _=(0,e[f])(a==="accessor"?{get:h.get,set:h.set}:h[l],p);if(a==="accessor"){if(_===void 0)continue;if(_===null||typeof _!="object")throw new TypeError("Object expected");(d=o(_.get))&&(h.get=d),(d=o(_.set))&&(h.set=d),(d=o(_.init))&&i.unshift(d)}else(d=o(_))&&(a==="field"?i.unshift(d):h[l]=d)}c&&Object.defineProperty(c,s.name,h),u=!0}function w(n,t,e){for(var s=arguments.length>2,i=0;i<t.length;i++)e=s?t[i].call(n,e):t[i].call(n);return s?e:void 0}function g(n){return typeof n=="symbol"?n:"".concat(n)}function x(n,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(n,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function P(n,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,t)}function D(n,t,e,s){function i(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function a(h){try{c(s.next(h))}catch(d){o(d)}}function l(h){try{c(s.throw(h))}catch(d){o(d)}}function c(h){h.done?r(h.value):i(h.value).then(a,l)}c((s=s.apply(n,t||[])).next())})}function v(n,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},s,i,r,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(c){return function(h){return l([c,h])}}function l(c){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(e=0)),e;)try{if(s=1,i&&(r=c[0]&2?i.return:c[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,c[1])).done)return r;switch(i=0,r&&(c=[c[0]&2,r.value]),c[0]){case 0:case 1:r=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,i=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!r||c[1]>r[0]&&c[1]<r[3])){e.label=c[1];break}if(c[0]===6&&e.label<r[1]){e.label=r[1],r=c;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(c);break}r[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(h){c=[6,h],i=0}finally{s=r=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var T=Object.create?(function(n,t,e,s){s===void 0&&(s=e);var i=Object.getOwnPropertyDescriptor(t,e);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(n,s,i)}):(function(n,t,e,s){s===void 0&&(s=e),n[s]=t[e]});function I(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&T(t,n,e)}function L(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 H(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var s=e.call(n),i,r=[],o;try{for(;(t===void 0||t-- >0)&&!(i=s.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return r}function ut(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(H(arguments[t]));return n}function Dt(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var s=Array(n),i=0,t=0;t<e;t++)for(var r=arguments[t],o=0,a=r.length;o<a;o++,i++)s[i]=r[o];return s}function ct(n,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,r;s<i;s++)(r||!(s in t))&&(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return n.concat(r||Array.prototype.slice.call(t))}function Pt(n){return this instanceof Pt?(this.v=n,this):new Pt(n)}function Dn(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=e.apply(n,t||[]),i,r=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(f){return function(p){return Promise.resolve(p).then(f,d)}}function a(f,p){s[f]&&(i[f]=function(m){return new Promise(function(_,S){r.push([f,m,_,S])>1||l(f,m)})},p&&(i[f]=p(i[f])))}function l(f,p){try{c(s[f](p))}catch(m){u(r[0][3],m)}}function c(f){f.value instanceof Pt?Promise.resolve(f.value.v).then(h,d):u(r[0][2],f)}function h(f){l("next",f)}function d(f){l("throw",f)}function u(f,p){f(p),r.shift(),r.length&&l(r[0][0],r[0][1])}}function Oa(n){var t,e;return t={},s("next"),s("throw",function(i){throw i}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(i,r){t[i]=n[i]?function(o){return(e=!e)?{value:Pt(n[i](o)),done:!1}:r?r(o):o}:r}}function Ln(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 L=="function"?L(n):n[Symbol.iterator](),e={},s("next"),s("throw"),s("return"),e[Symbol.asyncIterator]=function(){return this},e);function s(r){e[r]=n[r]&&function(o){return new Promise(function(a,l){o=n[r](o),i(a,l,o.done,o.value)})}}function i(r,o,a,l){Promise.resolve(l).then(function(c){r({value:c,done:a})},o)}}function Ba(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var Ra=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},Es=function(n){return Es=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[e.length]=s);return e},Es(n)};function Fa(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=Es(n),s=0;s<e.length;s++)e[s]!=="default"&&T(t,n,e[s]);return Ra(t,n),t}function Ha(n){return n&&n.__esModule?n:{default:n}}function ka(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 ja(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e}function Ya(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 Na(n,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,i;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],e&&(i=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");i&&(s=function(){try{i.call(this)}catch(r){return Promise.reject(r)}}),n.stack.push({value:t,dispose:s,async:e})}else e&&n.stack.push({async:!0});return t}var Xa=typeof SuppressedError=="function"?SuppressedError:function(n,t,e){var s=new Error(e);return s.name="SuppressedError",s.error=n,s.suppressed=t,s};function Wa(n){function t(r){n.error=n.hasError?new Xa(r,n.error,"An error was suppressed during disposal."):r,n.hasError=!0}var e,s=0;function i(){for(;e=n.stack.pop();)try{if(!e.async&&s===1)return s=0,n.stack.push(e),Promise.resolve().then(i);if(e.dispose){var r=e.dispose.call(e.value);if(e.async)return s|=2,Promise.resolve(r).then(i,function(o){return t(o),i()})}else s|=1}catch(o){t(o)}if(s===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return i()}function Va(n,t){return typeof n=="string"&&/^\.\.?\//.test(n)?n.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,s,i,r,o){return s?t?".jsx":".js":i&&(!r||!o)?e:i+r+"."+o.toLowerCase()+"js"}):n}const Xm={__extends:V,__assign:O,__rest:dt,__decorate:b,__param:y,__esDecorate:C,__runInitializers:w,__propKey:g,__setFunctionName:x,__metadata:P,__awaiter:D,__generator:v,__createBinding:T,__exportStar:I,__values:L,__read:H,__spread:ut,__spreadArrays:Dt,__spreadArray:ct,__await:Pt,__asyncGenerator:Dn,__asyncDelegator:Oa,__asyncValues:Ln,__makeTemplateObject:Ba,__importStar:Fa,__importDefault:Ha,__classPrivateFieldGet:ka,__classPrivateFieldSet:ja,__classPrivateFieldIn:Ya,__addDisposableResource:Na,__disposeResources:Wa,__rewriteRelativeImportExtension:Va};function On(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 Is=On(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
7
7
|
`+e.map(function(s,i){return i+1+") "+s.toString()}).join(`
|
|
8
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function We(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ge=(function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,s,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=L(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(m){t={error:m}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var h=this.initialTeardown;if(j(h))try{h()}catch(m){r=m instanceof Is?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=L(d),f=u.next();!f.done;f=u.next()){var p=f.value;try{Rn(p)}catch(m){r=r!=null?r:[],m instanceof Is?r=at(at([],H(r)),H(m.errors)):r.push(m)}}}catch(m){s={error:m}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}if(r)throw new Is(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Rn(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&We(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&We(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),On=ge.EMPTY;function Bn(n){return n instanceof ge||n&&"closed"in n&&j(n.remove)&&j(n.add)&&j(n.unsubscribe)}function Rn(n){j(n)?n():n.unsubscribe()}var ee={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ze={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=ze.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,at([n,t],H(e))):setTimeout.apply(void 0,at([n,t],H(e)))},clearTimeout:function(n){var t=ze.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Fn(n){ze.setTimeout(function(){var t=ee.onUnhandledError;if(t)t(n);else throw n})}function Hn(){}var Wa=(function(){return Ds("C",void 0,void 0)})();function za(n){return Ds("E",void 0,n)}function Va(n){return Ds("N",n,void 0)}function Ds(n,t,e){return{kind:n,value:t,error:e}}var se=null;function Ve(n){if(ee.useDeprecatedSynchronousErrorHandling){var t=!se;if(t&&(se={errorThrown:!1,error:null}),n(),t){var e=se,s=e.errorThrown,i=e.error;if(se=null,s)throw i}}else n()}function Ua(n){ee.useDeprecatedSynchronousErrorHandling&&se&&(se.errorThrown=!0,se.error=n)}var Ls=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,Bn(e)&&e.add(s)):s.destination=Ka,s}return t.create=function(e,s,i){return new Te(e,s,i)},t.prototype.next=function(e){this.isStopped?Bs(Va(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Bs(za(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Bs(Wa,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})(ge),Ga=Function.prototype.bind;function Os(n,t){return Ga.call(n,t)}var Za=(function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(s){Ue(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Ue(s)}else Ue(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Ue(e)}},n})(),Te=(function(n){z(t,n);function t(e,s,i){var r=n.call(this)||this,o;if(j(e)||!e)o={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:i!=null?i:void 0};else{var a;r&&ee.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&Os(e.next,a),error:e.error&&Os(e.error,a),complete:e.complete&&Os(e.complete,a)}):o=e}return r.destination=new Za(o),r}return t})(Ls);function Ue(n){ee.useDeprecatedSynchronousErrorHandling?Ua(n):Fn(n)}function $a(n){throw n}function Bs(n,t){var e=ee.onStoppedNotification;e&&ze.setTimeout(function(){return e(n,t)})}var Ka={closed:!0,next:Hn,error:$a,complete:Hn};function yt(n,t,e,s,i){return new qa(n,t,e,s,i)}var qa=(function(n){z(t,n);function t(e,s,i,r,o,a){var l=n.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;n.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(Ls);function lt(n,t){return N(function(e,s){var i=0;e.subscribe(yt(s,function(r){s.next(n.call(t,r,i++))}))})}var Rs=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function kn(n){return j(n==null?void 0:n.then)}var Fs=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ne(n){return n}function Xm(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return jn(n)}function jn(n){return n.length===0?ne:n.length===1?n[0]:function(e){return n.reduce(function(s,i){return i(s)},e)}}var gt=(function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,s){var i=this,r=Qa(t)?t:new Te(t,e,s);return Ve(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var s=this;return e=Yn(e),new e(function(i,r){var o=new Te({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});s.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Fs]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return jn(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Yn(t),new t(function(s,i){var r;e.subscribe(function(o){return r=o},function(o){return i(o)},function(){return s(r)})})},n.create=function(t){return new n(t)},n})();function Yn(n){var t;return(t=n!=null?n:ee.Promise)!==null&&t!==void 0?t:Promise}function Ja(n){return n&&j(n.next)&&j(n.error)&&j(n.complete)}function Qa(n){return n&&n instanceof Ls||Ja(n)&&Bn(n)}function Nn(n){return j(n[Fs])}function Xn(n){return Symbol.asyncIterator&&j(n==null?void 0:n[Symbol.asyncIterator])}function Wn(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 tl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var zn=tl();function Vn(n){return j(n==null?void 0:n[zn])}function Un(n){return In(this,arguments,function(){var e,s,i,r;return v(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Tt(e.read())];case 3:return s=o.sent(),i=s.value,r=s.done,r?[4,Tt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Tt(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 Gn(n){return j(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof gt)return n;if(n!=null){if(Nn(n))return el(n);if(Rs(n))return sl(n);if(kn(n))return nl(n);if(Xn(n))return Zn(n);if(Vn(n))return il(n);if(Gn(n))return rl(n)}throw Wn(n)}function el(n){return new gt(function(t){var e=n[Fs]();if(j(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function sl(n){return new gt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function nl(n){return new gt(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Fn)})}function il(n){return new gt(function(t){var e,s;try{for(var i=L(n),r=i.next();!r.done;r=i.next()){var o=r.value;if(t.next(o),t.closed)return}}catch(a){e={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(e)throw e.error}}t.complete()})}function Zn(n){return new gt(function(t){ol(n,t).catch(function(e){return t.error(e)})})}function rl(n){return Zn(Un(n))}function ol(n,t){var e,s,i,r;return D(this,void 0,void 0,function(){var o,a;return v(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=Dn(n),l.label=1;case 1:return[4,e.next()];case 2:if(s=l.sent(),!!s.done)return[3,4];if(o=s.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),s&&!s.done&&(r=e.return)?[4,r.call(e)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Yt(n,t,e,s,i){s===void 0&&(s=0),i===void 0&&(i=!1);var r=t.schedule(function(){e(),i?n.add(this.schedule(null,s)):this.unsubscribe()},s);if(n.add(r),!i)return r}function al(n,t,e,s,i,r,o,a){var l=[],c=0,h=0,d=!1,u=function(){d&&!l.length&&!c&&t.complete()},f=function(m){return c<s?p(m):l.push(m)},p=function(m){r&&t.next(m),c++;var _=!1;Lt(e(m,h++)).subscribe(yt(t,function(S){i==null||i(S),r?f(S):t.next(S)},function(){_=!0},void 0,function(){if(_)try{c--;for(var S=function(){var A=l.shift();o?Yt(t,o,function(){return p(A)}):p(A)};l.length&&c<s;)S();u()}catch(A){t.error(A)}}))};return n.subscribe(yt(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Hs(n,t,e){return e===void 0&&(e=1/0),j(t)?Hs(function(s,i){return lt(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return al(s,i,n,e)}))}function $n(n){return n===void 0&&(n=1/0),Hs(ne,n)}var ll,Kn=new gt(function(n){return n.complete()});function Wm(n){return n?cl(n):Kn}function cl(n){return new ll(function(t){return n.schedule(function(){return t.complete()})})}function qn(n){return n&&j(n.schedule)}function ks(n){return n[n.length-1]}function hl(n){return j(ks(n))?n.pop():void 0}function Ge(n){return qn(ks(n))?n.pop():void 0}function dl(n,t){return typeof ks(n)=="number"?n.pop():t}function Jn(n,t){return t===void 0&&(t=0),N(function(e,s){e.subscribe(yt(s,function(i){return Yt(s,n,function(){return s.next(i)},t)},function(){return Yt(s,n,function(){return s.complete()},t)},function(i){return Yt(s,n,function(){return s.error(i)},t)}))})}function Qn(n,t){return t===void 0&&(t=0),N(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function ul(n,t){return Lt(n).pipe(Qn(t),Jn(t))}function fl(n,t){return Lt(n).pipe(Qn(t),Jn(t))}function pl(n,t){return new gt(function(e){var s=0;return t.schedule(function(){s===n.length?e.complete():(e.next(n[s++]),e.closed||this.schedule())})})}function gl(n,t){return new gt(function(e){var s;return Yt(e,t,function(){s=n[zn](),Yt(e,t,function(){var i,r,o;try{i=s.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return j(s==null?void 0:s.return)&&s.return()}})}function ti(n,t){if(!n)throw new Error("Iterable cannot be null");return new gt(function(e){Yt(e,t,function(){var s=n[Symbol.asyncIterator]();Yt(e,t,function(){s.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function ml(n,t){return ti(Un(n),t)}function vl(n,t){if(n!=null){if(Nn(n))return ul(n,t);if(Rs(n))return pl(n,t);if(kn(n))return fl(n,t);if(Xn(n))return ti(n,t);if(Vn(n))return gl(n,t);if(Gn(n))return ml(n,t)}throw Wn(n)}function Ze(n,t){return t?vl(n,t):Lt(n)}function wt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=dl(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):$n(s)(Ze(i,e)):Kn}var bl=Ln(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),F=(function(n){z(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var s=new ei(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new bl},t.prototype.next=function(e){var s=this;Ve(function(){var i,r;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=L(s.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(e)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var s=this;Ve(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var i=s.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ve(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var s=e.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var s=this,i=this,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?On:(this.currentObservers=null,a.push(e),new ge(function(){s.currentObservers=null,We(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,i=s.hasError,r=s.thrownError,o=s.isStopped;i?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new gt;return e.source=this,e},t.create=function(e,s){return new ei(e,s)},t})(gt),ei=(function(n){z(t,n);function t(e,s){var i=n.call(this)||this;return i.destination=e,i.source=s,i}return t.prototype.next=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.next)===null||i===void 0||i.call(s,e)},t.prototype.error=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.error)===null||i===void 0||i.call(s,e)},t.prototype.complete=function(){var e,s;(s=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||s===void 0||s.call(e)},t.prototype._subscribe=function(e){var s,i;return(i=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&i!==void 0?i:On},t})(F),ft=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(F);let js=!1,Ys=0;const $e=new Map,Ke=new Map,si=()=>{js||(js=!0,Ys=requestAnimationFrame(()=>{Ke.forEach((n,t)=>{n(),Ke.delete(t)}),$e.forEach((n,t)=>{n(),$e.delete(t)}),js=!1}))},ni=(n,t)=>{$e.set(n,t),si()},Cl=n=>{$e.delete(n)},yl=n=>{Ke.delete(n)},Me=(n,t)=>{Ke.set(n,t),si()};function _t(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}const ii="\u2212",wl="-";var Sl=Math.pow;const qe=14,Je=[];for(let n=0;n<qe+1;n++)Je.push(Sl(10,n));const Ns=5e-13;class pt{static roundToNearest(t,e){return isFinite(t)?pt.isZero(t)?0:(t>0?t+=Ns:t<0&&(t-=Ns),pt.roundDecimal(Math.round(pt.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return pt.roundDecimal(Math.ceil(t/e))*e}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const e=Math.sign(t),s=Math.abs(t),i=Math.min(qe,qe-1-Math.floor(Math.log10(s)));for(let r=i;r>=0;r--){const o=Math.floor(Je[r]*s+.5);if(o<Je[qe])return e*o/Je[r]}return Math.round(t)}static makeDecimal(t,e,s,i){if(!isFinite(t))return"";if(isFinite(t)){let r=t.toFixed(e);if(!i)return s?r.replace(".",s):r;if(s===i)throw new Error("Grouping symbol cannot be the same as decimal separator.");const o=r.split(".");let a=o[0];const l=o[1];return Math.abs(t)>=1e3&&(a=a.replace(RegExp("\\d(?=(\\d{3})+$)","g"),`$&${i}`)),l?(r=[a,l].join(s),r):a}return""}static compare(t,e,s){return t>e+s?1:t<e-s?-1:(isNaN(t)?1:0)-(isNaN(e)?1:0)}static isZero(t){return pt.compare(t,0,Ns)===0}static cutNumber(t,e,s=0){return{K:r=>r/1e3,M:r=>r/1e6}[e](t).toFixed(s)+e}static isExponential(t){return/\de(\-|\+)\d/.test(t.toString())}}function xl(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 _l(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Ae(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const rt=n=>~~n,Pl=n=>~~(n+1),Ee=n=>~~(n+.5),Tl=(n,t)=>n>>t;function zm(n){if(!Number.isFinite(n))throw new Error("Input must be a finite number.");const t=n.toString();return t.includes(".")?t.split(".")[1].length:0}const Qe=n=>n.replace(wl,ii);class Ws{constructor(t,e){this.animationTimeLeft=0,this.onTickFunction=e,this.animationTime=t.duration,this.animationStartTime=Date.now(),this.animationInProgress=!0}tick(){var t;Date.now()>this.animationStartTime+this.animationTime&&(this.animationInProgress=!1),(t=this.onTickFunction)==null||t.call(this)}getProgress(){return Math.min((Date.now()-this.animationStartTime)/this.animationTime,1)}finishAnimation(){this.animationInProgress=!1,this.animationStartTime=0}}var Ml=Pt(742),Ft=Pt.n(Ml);class ri extends Ws{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Ft().rgb(i.color),i.initialAlpha=i.rgbColor.valpha,i.currentAnimationColor=i.rgbColor})}tick(){super.tick(),this.colorConfigs.forEach(t=>{if(t.initialAlpha===void 0||t.rgbColor===void 0)return;const e=t.initialAlpha*(t.type==="fading"?1-this.getProgress():this.getProgress());t.currentAnimationColor=t.rgbColor.alpha(e)})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){const t=Xs(Date.now()-this.animationStartTime,0,this.animationTime);this.animationStartTime=Date.now()-this.animationTime+t,this.colorConfigs.forEach(e=>{e.type=e.type==="fading"?"appearing":"fading"})}}class oi extends Ws{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Ft().rgb(i.startColor),i.rgbEndColor=Ft().rgb(i.endColor),i.currentAnimationColor=i.type==="appearing"?i.rgbStartColor:i.rgbEndColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{const e=1-this.animationTimeLeft/this.animationTime;!t.rgbStartColor||!t.rgbEndColor||(t.type==="fading"?t.currentAnimationColor=this.calculateTransitionColor(t.rgbEndColor,t.rgbStartColor,e):t.type==="appearing"&&(t.currentAnimationColor=this.calculateTransitionColor(t.rgbStartColor,t.rgbEndColor,e)))})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){this.animationTimeLeft=Math.max(this.animationTime-this.animationTimeLeft,1),this.colorConfigs.forEach(t=>{t.type==="fading"?t.type="appearing":t.type="fading"})}moveToLastTick(){this.animationTimeLeft=1}calculateTransitionColor(t,e,s){const i=t.red()-(t.red()-e.red())*s,r=t.green()-(t.green()-e.green())*s,o=t.blue()-(t.blue()-e.blue())*s;return Ft().rgb(i,r,o)}}class ai extends Ws{constructor(t,e,s){var i;super(e,s),this.viewportModel=t,this.animationConfig=e,this.id=_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.easingFn=(i=e.easingFn)!=null?i:_l}tick(){if(super.tick(),this.animationInProgress){const t=this.easingFn(this.getProgress()),e=this.xStart+(this.animationConfig.targetXStart-this.xStart)*t,s=this.xEnd+(this.animationConfig.targetXEnd-this.xEnd)*t,i=this.yStart+(this.animationConfig.targetYStart-this.yStart)*t,r=this.yEnd+(this.animationConfig.targetYEnd-this.yEnd)*t,o=this.zoomX+(this.animationConfig.targetZoomX-this.zoomX)*t,a=this.zoomY+(this.animationConfig.targetZoomY-this.zoomY)*t;this.viewportModel.apply({xStart:e,xEnd:s,yStart:i,yEnd:r,zoomX:o,zoomY:a,inverseY:this.viewportModel.inverseY})}}finishAnimation(){super.finishAnimation(),this.viewportModel.apply({xStart:this.animationConfig.targetXStart,xEnd:this.animationConfig.targetXEnd,yStart:this.animationConfig.targetYStart,yEnd:this.animationConfig.targetYEnd,zoomX:this.animationConfig.targetZoomX,zoomY:this.animationConfig.targetZoomY,inverseY:this.viewportModel.inverseY})}}const Ie=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Al=!!window.chrome,li=typeof InstallTrigger!="undefined",El=navigator.platform.indexOf("Win")>-1,Vm=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(Ie)i=e===n.deltaY*-3||Math.abs(e+Math.sign(e))===Math.abs(Math.round(n.deltaY)*3)||Math.abs(e-Math.sign(e))===Math.abs(Math.round(n.deltaY)*3);else if(Al){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,El){const r=Math.round(n.deltaY)===e||Math.abs(Math.round(n.deltaY)+Math.sign(n.deltaY))===Math.abs(e)||Math.abs(Math.round(n.deltaY)-Math.sign(n.deltaY))===Math.abs(e);i=Math.abs(e)===Math.abs(n.deltaY)||r}}else li?Math.abs(n.deltaY)>Math.abs(n.deltaX)?i=!1:i=s===n.deltaX*-3:i=e===n.deltaY*-3;i&&(t=!0)}else n.deltaMode===0&&(t=!0);return li&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Il=(n,t)=>n==="percent"?t/4:t;var Dl=Object.defineProperty,Ll=Object.defineProperties,Ol=Object.getOwnPropertyDescriptors,ci=Object.getOwnPropertySymbols,Bl=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable,hi=(n,t,e)=>t in n?Dl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Fl=(n,t)=>{for(var e in t||(t={}))Bl.call(t,e)&&hi(n,e,t[e]);if(ci)for(var e of ci(t))Rl.call(t,e)&&hi(n,e,t[e]);return n},Hl=(n,t)=>Ll(n,Ol(t));const De=Ie?150:400,me="VIEWPORT_ANIMATION";class di{constructor(t){this.animations={},this.animationInProgressSubject=new ft(!1),this.animFrameId=`canvas_animation_${_t()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=me,i){const r=new ai(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ri(Hl(Fl({},i),{duration:i&&i.duration||De}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=De,i){const r=new oi({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0)}processAnimation(){Me(this.animFrameId,()=>this.tick())}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():queueMicrotask(()=>{this.processAnimation(),this.eventBus.fireDraw()})}stopInterval(){Cl(this.animFrameId)}}function mt(n,t){return t===void 0&&(t=ne),n=n!=null?n:kl,N(function(e,s){var i,r=!0;e.subscribe(yt(s,function(o){var a=t(o);(r||!n(i,a))&&(r=!1,i=a,s.next(o))}))})}function kl(n,t){return n===t}function jl(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function zs(n){return n}function ui(n){return n!=null}const Um=()=>{};function Gm(n){return n!=null}function Yl(n,t,e=Nl,s=!0){const i=n.filter(r=>t.some(o=>e(r,o)));return s?i.filter((r,o,a)=>a.indexOf(r)===o):i}const fi=(n,t)=>{const e=t.slice().filter(s=>n.find(i=>i===s));return n.map(s=>{var i;return t.indexOf(s)>=0&&(i=e.shift())!=null?i:s})},Nl=(n,t)=>n===t,Zm=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),Xl=(n,t)=>n===t,pi=(n,t,e=Xl)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function $m(n,t,e){const s=n.slice(),i=s[t];return s.splice(t,1),s.splice(e,0,i),s}function Vs(n,t,e){const s=n.length,i=Xs(t,0,s-1),r=Xs(e,0,s-1),o=n[i];return n.splice(i,1),n.splice(r,0,o),n}function Km(n,t,e){const s=n.slice(),i=s.findIndex(t);return i!==-1&&(s.splice(i,1),s.splice(i,0,e)),s}const qm=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},Jm=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),Qm=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),tv=n=>Array.isArray(n[0]),gi=n=>Array.isArray(n[0])?n:[n],Wl=(n,t,e)=>{const s=[];let i=0;for(const r of n){const o=Math.max(t-i,0),a=Math.max(e-i,-1),l=r.slice(o,a+1);l.length>0&&s.push(l),i+=r.length}return s},zl=(n,t)=>n>=0?t[n]:t[t.length+n],vt=n=>Array.prototype.flat?n.flat():Le(n,zs),Le=(n,t)=>{if(Array.prototype.flatMap)return n.flatMap(t);const e=[];for(let s=0;s<n.length;s++){const i=n[s];e.push(...t(i,s,n))}return e};function Nt(n,t,e){const s=e!=null?e:zs;return!n.length||t!==t?{index:-1,exact:!0}:Us(n,t,0,n.length,s)}function Us(n,t,e,s,i){const r=Tl(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Us(n,t,e,r,i):Us(n,t,r,s,i)}function St(n){if(n&&n.length)return n[n.length-1]}function Vl(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Ul(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ie(n){if(n)return n[0]}function Gl(n){function t(e,s){const i=n(s);return i==null||!isFinite(i)?e:[Math.max(e[0],i),Math.min(e[1],i)]}return function(e){const s=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,s):s}}function Zl(n,t,e,s=()=>0){const i=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])<=a?l=h+1:c=h-1}return c},r=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])>=a?c=h-1:l=h+1}return l};return n.slice(r(n,t),i(n,e)+1)}let Gs,mi;const Ot=()=>{if(typeof navigator=="undefined")return!1;const n=navigator.userAgent;return(mi!==n||Gs===void 0)&&(mi=n,Gs=!!n.match(/Android|iPhone|Opera Mini/)),Gs},$l=1.33,vi=4.5;function bi(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 ts(n,t=!0){const e=n.font.match(/(\d+.)?\d+(px|pt)/gi);let s="10px";return e&&e.length&&(e[0].includes("pt")?s=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":s=e[0]),t?parseInt(s,10)*$l:parseInt(s,10)}function Ci(n,t,e){n.save(),bi(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(o=>n.measureText(o).width))),i=ts(n),r=i*t.length;return n.restore(),[s,r,i]}function yi(n){return(n||"").split(/\r\n|\r|\n/)}function Kl(n,t,e,s,i){n.save();const[r,,o]=Ci(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=ql(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&Jl(n,a,f,s+o*l,(h=i.textFill)!=null?h:"",(d=i.textSize)!=null?d:""),n.fillText(a,f,s+o*l)}),n.restore()}function ql(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function Jl(n,t,e,s,i,r){n.save();const o=n.measureText(t).width,a=e,l=e+o,c=s+2,h=c;let d=parseInt(r,10)/15;d<1&&(d=1),n.beginPath(),n.strokeStyle=i,n.lineWidth=d,n.moveTo(a,c),n.lineTo(l,h),n.stroke(),n.restore()}function ev(n){return`${n}px`}function wi(n){const t=Ft().rgb(n).array(),[e,s,i]=t.map(r=>{const o=r/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*e+.7152*s+.0722*i}function Si(n,t){const e=wi(n),s=wi(t),i=Math.max(e,s),r=Math.min(e,s);return(i+.05)/(r+.05)}function re(n,t,e){const s=Si(n,t),i=Si(n,e),r=s>=vi,o=i>=vi;return r&&!o?t:o&&!r?e:s>=i?t:e}function Ql(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=xi(t,i.dateFormat,e),a=yi(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=Ci(n,a,l);return[c+r.x*2,h+r.y*2]}function xi(n,t,e){return e(t)(n).split(" ").join(`
|
|
9
|
-
`)}const _i={};function Xt(n,t){let e=_i[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,_i[n]=e,t.restore()),e}const Pi=new Map;function Mt(n,t,e){const s=e+n;let i=Pi.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,Pi.set(s,i),t.restore()),i}function At(n,t,e=Ti){function s(i,r){for(const o in r)o in i?typeof i[o]=="object"&&i[o]!==null&&!Array.isArray(i[o])?s(i[o],r[o]):e!=null&&e.overrideExisting&&(i[o]=r[o]):e!=null&&e.addIfMissing&&(i[o]=r[o]);return i}return s(n,t)}function sv(n,t,e,s=!1){!n||!t||t.length===0||t.forEach(i=>{const r=e(i),o=n.findIndex(a=>e(a)===r);o===-1?n.push(i):s?At(n[o],i,{overrideExisting:!0,addIfMissing:!0}):n.splice(o,1,i)})}const Ti={overrideExisting:!1,addIfMissing:!0};function tc(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){const s=n.charCodeAt(e);t=(t<<5)-t+s,t|=0}return t}const Zs=1,ec=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Mi=(n,t)=>`${n}_${tc(t.toString())}`;function es(n,t){return t===n?"none":t>n?"up":"down"}function sc(n,t){return t>n?"up":"down"}function nc(n,t,e=!1){const{id:s,expansion:i,impVolatility:r,openInterest:o,vwap:a,typicalPrice:l,volume:c,timestamp:h}=n;let d=n.hi,u=n.lo,f=n.open;const p=n.close;e&&(d=p,u=p,f=p);let m=n.idx;return t!==void 0&&(m=t),{id:s,hi:d,lo:u,open:f,close:p,timestamp:h,volume:c,expansion:i,idx:m,impVolatility:r,openInterest:o,vwap:a,typicalPrice:l}}var ic,rc,oc=Object.defineProperty,Ai=Object.getOwnPropertySymbols,ac=Object.prototype.hasOwnProperty,lc=Object.prototype.propertyIsEnumerable,Ei=(n,t,e)=>t in n?oc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,cc=(n,t)=>{for(var e in t||(t={}))ac.call(t,e)&&Ei(n,e,t[e]);if(Ai)for(var e of Ai(t))lc.call(t,e)&&Ei(n,e,t[e]);return n};const Ii="Open Sans Semibold, sans-serif",hc=null,dc=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],nv=n=>hc.find(t=>t===n)!==void 0,ss=()=>({devexpertsPromoLink:!0,useUTCTimeOverride:!1,shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rtl:!1,intlFormatter:{decimalSeparator:".",thousandsSeparator:""},scale:{keepZoomXOnYAxisChange:!0,auto:!0,zoomToCursor:!1,lockPriceToBarRatio:!1,autoScaleOnCandles:!0,autoScaleDisableOnDrag:{enabled:!0,edgeAngle:Math.PI/15,yDiff:80},inverse:!1,zoomSensitivity:{wheel:.25},defaultViewportItems:100,disableAnimations:!1},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,components:{chart:{type:"candle",showCandlesBorder:!0,showActiveCandlesBorder:!0,showWicks:!0,candleLineWidth:1,lineWidth:1,areaLineWidth:1,barLineWidth:1,minWidth:.5,minCandles:10,candlePaddingPercent:.25,highlightActiveCandle:!0,cursor:"default",selectedWidth:3,minCandlesOffset:2,defaultZoomCandleWidth:7,zoomStep:0,histogram:{barCapSize:1},maxYAxisScalesAmount:10,applyBackgroundToAxes:{x:!0,y:!0},sortCandles:ec,candleTimestampAnchor:"open"},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:Ii,cursor:"ns-resize",resizeDisabledCursor:"default",labelBoxMargin:{top:4,bottom:4,end:8,start:10},typeConfig:{badge:{rounded:!0,paddings:{top:4,bottom:4,end:4,start:4}},plain:{},rectangle:{rounded:!1,paddings:{top:4,bottom:4,end:4,start:4}}},labels:{descriptions:!1,settings:{lastPrice:{mode:"label",type:"badge"},countdownToBarClose:{mode:"none",type:"rectangle"}}},treasuryFormat:{enabled:!1}},xAxis:{visible:!0,formatsForLabelsConfig:{lessThanSecond:"HH:mm:ss",second_1:"HH:mm:ss",minute_1:"HH:mm",minute_5:"HH:mm",minute_30:"HH:mm",hour_1:"HH:mm",day_1:"dd.MM",month_1:"MMM",year_1:"YYYY"},fontSize:12,fontFamily:Ii,cursor:"ew-resize",padding:{top:8,bottom:16},fontStyle:""},events:{visible:!1,eventsVisibility:{"conference-calls":!0,dividends:!0,splits:!0,earnings:!0},height:20,cursor:"default",xAxisLabelFormat:[{format:"d MMM"}],icons:{earnings:{normal:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" stroke="#D92C40" stroke-width="1.5"/></svg>',hover:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" fill="#D92C40" stroke="#D92C40" stroke-width="1.5"/></svg>'}}},offsets:{visible:!0,right:10,top:10,bottom:20,left:0},waterMark:{visible:!1,fontFamily:"Open Sans, sans-serif",firstRowFontSize:80,firstRowBottomPadding:10,secondRowFontSize:40,secondRowBottomPadding:25,thirdRowFontSize:40,thirdRowBottomPadding:15,position:"center",offsetX:20,offsetY:20,logoWidth:20,logoHeight:20},highLow:{visible:!1,font:"12px sans-serif",prefix:{high:"H: ",low:"L: "},lineDash:[2,4]},highlights:{visible:!1,fontFamily:"Open Sans",fontSize:13,border:{width:1,dash:[8,4]}},crossTool:{type:"cross-and-labels",discrete:!0,magnetTarget:"none",lineDash:[4,6],xAxisLabelFormat:[{format:"dd.MM.YYYY",showWhen:{periodMoreThen:1440*60*1e3}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:1440*60*1e3,periodMoreThen:6*1e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6*1e3}}],xLabel:{padding:{top:4,bottom:4,right:8,left:8},margin:{top:4}},yLabel:{padding:{top:4,bottom:4,end:4,start:4},type:"badge"}},grid:{visible:!0,horizontal:!1,vertical:!0,width:1,dash:[0,0],color:"#FFFFFF"},volumes:{visible:!0,showSeparately:!1,valueLines:15,barCapSize:1,volumeBarSpace:0,volumeFillColor:"#FFFFFF"},navigationMap:{visible:!1,allCandlesHistory:!0,timeLabels:{visible:!1,dateFormat:"dd.MM.YYYY HH:mm",fontFamily:"Open Sans",fontSize:13,padding:{x:10,y:1}},minSliderWindowWidth:10,cursors:{chart:"default",buttonLeft:"pointer",buttonRight:"pointer",leftResizer:"ew-resize",rightResizer:"ew-resize",slider:"grab"},knots:{height:35,width:7,border:0,lineWidth:1}},baseline:{cursor:"ns-resize",dragZone:3,height:1},paneResizer:{cursor:"ns-resize",height:1,visible:!0,fixedMode:!1,dragZone:3}},colors:{candleTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(77,153,83,1)",downWickColor:"rgba(217,44,64,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:1},barTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},lineTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},chartAreaTheme:{backgroundMode:"regular",backgroundColor:"rgba(20,20,19,1)",backgroundGradientTopColor:"red",backgroundGradientBottomColor:"blue",gridColor:"rgba(37,37,36,1)"},scatterPlot:{mainColor:"rgba(255,255,255,1)"},areaTheme:{lineColor:"rgba(127,120,214,1)",startColor:"rgba(169,38,251,1)",stopColor:"rgba(169,38,251,0.8)"},baseLineTheme:{lowerSectionStrokeColor:"rgba(217,44,64,1)",upperSectionStrokeColor:"rgba(77,153,83,1)",lowerSectionFillColor:"rgba(217, 44, 64, 0.07)",upperSectionFillColor:"rgba(77, 153, 83, 0.07)",baselineColor:"rgba(55,55,54,1)"},histogram:{upCap:"rgba(77,153,83,1)",upBottom:"rgba(77,153,83,0.1)",upBright:"rgba(77,153,83,0.4)",downCap:"rgba(217,44,64,1)",downBottom:"rgba(217,44,64,0.1)",downBright:"rgba(217,44,64,0.4)",noneCap:"rgba(255,255,255,1)",noneBottom:"rgba(255,255,255,0.1)",noneBright:"rgba(255,255,255,0.4)"},crossTool:{lineColor:"rgba(107,96,86,1)",labelBoxColor:"rgba(107,96,86,1)",labelTextColor:"rgba(255,255,255,1)"},waterMarkTheme:{firstRowColor:"rgba(255,255,255,0.2)",secondRowColor:"rgba(255,255,255,0.2)",thirdRowColor:"rgba(255,255,255,0.2)"},highlights:{NO_TRADING:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"},AFTER_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(38, 251, 149, 0.05)",label:"transparent"},PRE_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(255, 170, 0, 0.05)",label:"transparent"},REGULAR:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"}},activeCandleTheme:{upColor:"rgba(98,201,93,1)",downColor:"rgba(255,47,47,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(98,201,93,1)",downWickColor:"rgba(255,47,47,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:.5},volume:{downBarColor:"rgba(99,30,37,1)",upBarColor:"rgba(42,72,44,1)",noneBarColor:"rgba(255,255,255,0.4)",upCapColor:"rgba(42,72,44,1)",downCapColor:"rgba(99,30,37,1)",noneCapColor:"rgba(255,255,255,0.4)"},highLowTheme:{highColor:"rgba(223,222,223,1)",lowColor:"rgba(223,222,223,1)"},instrumentInfo:{textColor:"#aeb1b3"},paneResizer:{lineColor:"rgba(61,61,61,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)",normal:"rgba(217,44,64,1)",hover:"rgba(217,44,64,1)",line:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)",normal:"rgba(169,38,251,1)",hover:"rgba(169,38,251,1)",line:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)",normal:"rgba(244,187,63,1)",hover:"rgba(244,187,63,1)",line:"rgba(244,187,63,1)"},"conference-calls":{color:"rgba(48,194,97,1)",normal:"rgba(48,194,97,1)",hover:"rgba(48,194,97,1)",line:"rgba(48,194,97,1)"}},secondaryChartTheme:[{lineTheme:{upColor:"rgba(226,61,25,1)",downColor:"rgba(226,61,25,1)",noneColor:"rgba(226,61,25,1)"},areaTheme:{lineColor:"rgba(226,61,25,1)",startColor:"rgba(226,61,25,0.8)",stopColor:"rgba(226,61,25,0)"}},{lineTheme:{upColor:"rgba(250,191,64,1)",downColor:"rgba(250,191,64,1)",noneColor:"rgba(250,191,64,1)"},areaTheme:{lineColor:"rgba(250,191,64,1)",startColor:"rgba(250,191,64,0.8)",stopColor:"rgba(250,191,64,0)"}},{lineTheme:{upColor:"rgba(169,38,251,1)",downColor:"rgba(169,38,251,1)",noneColor:"rgba(169,38,251,1)"},areaTheme:{lineColor:"rgba(169,38,251,1)",startColor:"rgba(169,38,251,0.8)",stopColor:"rgba(169,38,251,0)"}},{lineTheme:{upColor:"rgba(77,211,240,1)",downColor:"rgba(77,211,240,1)",noneColor:"rgba(77,211,240,1)"},areaTheme:{lineColor:"rgba(77,211,240,1)",startColor:"rgba(77,211,240,0.8)",stopColor:"rgba(77,211,240,0)"}},{lineTheme:{upColor:"rgba(59,203,91,1)",downColor:"rgba(59,203,91,1)",noneColor:"rgba(59,203,91,1)"},areaTheme:{lineColor:"rgba(59,203,91,1)",startColor:"rgba(59,203,91,0.8)",stopColor:"rgba(59,203,91,0)"}}],yAxis:{backgroundColor:"rgba(20,20,19,1)",labelBoxColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)",labelInvertedTextColor:"rgba(20,20,19,1)",rectLabelTextColor:"rgba(255,255,255,1)",rectLabelInvertedTextColor:"rgba(20,20,19,1)",zeroPercentLine:"rgba(55,55,54,1)"},labels:{lastPrice:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(0,0,0,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},countdownToBarClose:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(255,255,255,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},highLow:{high:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"High"},low:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Low"}},bidAsk:{bid:{boxColor:"rgba(77,153,83,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Bid"},ask:{boxColor:"rgba(217,44,64,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Ask"}},prePostMarket:{post:{boxColor:"rgba(38,251,149,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Post"},pre:{boxColor:"rgba(255,170,0,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Pre"}},prevDayClose:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)"}},xAxis:{backgroundColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)"},navigationMap:{backgroundColor:"transparent",buttonColor:"rgba(255,255,255,0.1)",buttonArrowColor:"rgba(212,212,211,1)",knotColor:"rgba(255,255,255,0.1)",knotLineColor:"rgba(212,212,211,1)",sliderColor:"rgba(255,255,255,0.08)",knotBorderColor:"#0b0d1a",timeLabelsTextColor:"rgba(128,128,128,1)",mapColor:"rgba(255,255,255,0.1)",mapFillColor:"rgba(255,255,255,0.1)",mapGradientTopColor:"rgba(255,255,255,0.1)",mapGradientBottomColor:"rgba(255,255,255,0.1)"}},animation:{moveDuration:1e3,candleDuration:200,paneResizer:{bgMode:!0,enabled:!0,duration:40},yAxis:{background:{enabled:!1,duration:40}}},drawingOrder:["OVER_SERIES_CLEAR","MAIN_CLEAR","SERIES_CLEAR","GRID","X_AXIS","Y_AXIS","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function uc(n,t=ss()){return At(n,t,Ti),n}function iv(n,t=ss()){const e=cc({},n);return ic(e,t,rc),e}function rv(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function Di(n){return typeof n=="object"&&n!==null}function Li(n,t){return[...n].map(s=>$s(s,t))}const fc=n=>Array.isArray(n);function $s(n,t){if(!Di(n))return n;if(fc(n))return Li(n,t);{const e=Oi({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function Oi(n,t,e){if(!Di(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return Li(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=$s(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=Oi(n[i],t[i],e):e.addIfMissing&&(s[i]=$s(t[i],e))}),s}const ov=null,oe=n=>`${n.fontSize}px ${n.fontFamily}`;class pc{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=oe(this.config.components.yAxis);return Mt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(s=>{var i,r,o;const a=s.getYAxisState();if(!a.visible)return;const l=a.labelBoxMargin.start+a.labelBoxMargin.end,c=this.getTextWidth(s.getLargestLabel())+l,h=s.getYAxisIndex(),d=s.getPaneUUID(),u=(i=this.extentsOrder.get(d))!=null?i:{left:[],right:[]};if(a.align==="left"){const f=u.left.length;t[f]=Math.max((r=t[f])!=null?r:0,c),u.left.push(h)}else{const f=u.right.length;e[f]=Math.max((o=e[f])!=null?o:0,c),u.right.push(h)}this.extentsOrder.set(d,u)}),{left:t,right:e}}}var gc=Object.defineProperty,mc=Object.defineProperties,vc=Object.getOwnPropertyDescriptors,Bi=Object.getOwnPropertySymbols,bc=Object.prototype.hasOwnProperty,Cc=Object.prototype.propertyIsEnumerable,Ri=(n,t,e)=>t in n?gc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wt=(n,t)=>{for(var e in t||(t={}))bc.call(t,e)&&Ri(n,e,t[e]);if(Bi)for(var e of Bi(t))Cc.call(t,e)&&Ri(n,e,t[e]);return n},Fi=(n,t)=>mc(n,vc(t));const $="CHART",nt=class{};nt.CANVAS="CANVAS",nt.N_MAP="N_MAP",nt.X_AXIS="X_AXIS",nt.N_MAP_KNOT_L="N_MAP_KNOT_L",nt.N_MAP_KNOT_R="N_MAP_KNOT_R",nt.N_MAP_BTN_L="N_MAP_BTN_L",nt.N_MAP_BTN_R="N_MAP_BTN_R",nt.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",nt.N_MAP_CHART="N_MAP_CHART",nt.N_MAP_LABEL_R="N_MAP_LABEL_R",nt.N_MAP_LABEL_L="N_MAP_LABEL_L",nt.PANE_UUID=n=>"PANE_"+n,nt.PANE_UUID_Y_AXIS=(n,t=0)=>"PANE_"+n+"_Y_AXIS_"+t,nt.PANE_UUID_RESIZER=n=>"PANE_"+n+"_RESIZER",nt.ALL_PANES="ALL_PANES",nt.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",nt.EVENTS="EVENTS",nt.CHART=nt.PANE_UUID($),nt.Y_AXIS=nt.PANE_UUID_Y_AXIS($);let M=nt;const Hi={x:0,y:0,pageX:0,pageY:0,width:0,height:0},ki=20,ji=35,Ks=15,Yi=1.5,Ni=Ot()?8*Yi:8,Oe=Ot()?5:0,yc=1e-6;class qs{constructor(t,e,s,i,r){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new F,this.paneMovedSubject=new F,this.paneVisibilityChangedSubject=new F,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new F,this.barResizerChangedSubject=new F,this._graphsHeightRatio={[$]:1},this.graphsHeightRatioChangedSubject=new F,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new pc(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);Vs(this.panesOrder,s,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=Wt(Wt({},this.graphsHeightRatio),t),s=Object.values(e).reduce((i,r)=>i+r,0);Math.abs(s-1)<yc?(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&&(Vs(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(Vs(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}reorderPanes(t){this.panesOrder=fi(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}hidePaneBounds(t){this.graphsHeightRatio[t]=0,this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}showPaneBounds(t){if(t===$){const[e]=Xi(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){Ul(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[M.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[M.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[M.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,s=this.config.components.paneResizer.height,i=this.getBounds(M.CANVAS);i.x=0,i.y=0,i.width=t,i.height=e;const r=this.yAxisWidths,o=this.getNavMapBounds(i),a=this.getXAxisBounds(o,i),l=e-a.height-o.height,c=r.left.reduce((B,R)=>B+R,0),h=r.right.reduce((B,R)=>B+R,0),d=0,u=i.width-h,f=d+c,p=0,m=i.width-c-h;let _=p;const S=this.panesOrder.findIndex(B=>this.graphsHeightRatio[B]>0);this.panesOrder.forEach((B,R)=>{var k;const V=this.graphsHeightRatio[this.panesOrder[R]],X=M.PANE_UUID_RESIZER(B),U=M.PANE_UUID(B),Z=this.config.components.paneResizer.visible&&R>S&&V>0;Z?ve(this.bounds,X,0,_,i.width,s,this.canvasOnPageLocation):ve(this.bounds,X,0,0,0,0,this.canvasOnPageLocation);const G=_+(Z?s:0),Q=ve(this.bounds,U,f,G,m,l*V-(Z?s:0),this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const J=this.yAxisBoundsContainer.extentsOrder.get(B);if(J===void 0)return;const tt=l*V-(Z?s:0);let et=f-((k=r.left[0])!=null?k:0),st=u;J.left.forEach((ht,ct)=>{var xt;ve(this.bounds,M.PANE_UUID_Y_AXIS(B,ht),et,G,r.left[ct],tt,this.canvasOnPageLocation),et-=(xt=r.left[ct+1])!=null?xt:0}),J.right.forEach((ht,ct)=>{ve(this.bounds,M.PANE_UUID_Y_AXIS(B,ht),st,G,r.right[ct],tt,this.canvasOnPageLocation),st+=r.right[ct]})}else ve(this.bounds,M.PANE_UUID_Y_AXIS(B),0,0,0,0,this.canvasOnPageLocation);_=Q.y+Q.height});const A=this.getBounds(M.ALL_PANES);A.x=f,A.y=p,A.width=m,A.height=_;const E=this.getBounds(M.CHART_WITH_Y_AXIS),Y=this.getBounds(M.CHART);this.getEventsBounds(Y),this.copyBounds(Y,E),E.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=Fi(Wt({},this.canvasOnPageLocation),{x:t.x,y:t.y,width:t.width,height:t.height})}updateAllBoundsPageCoordinates(){for(const t of Object.keys(this.bounds)){const e=this.bounds[t];e.pageX=e.x+this.canvasOnPageLocation.x,e.pageY=e.y+this.canvasOnPageLocation.y}}getEventsBounds(t){const e=this.getBounds(M.EVENTS);return this.config.components.events.visible?(e.x=0,e.y=t.y+t.height-this.config.components.events.height,e.width=t.width,e.height=this.config.components.events.height):this.applyDefaultBounds(e),e}getNavMapBounds(t){const e=this.getBounds(M.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-ji,e.width=t.width,e.height=ji):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const s=this.getBounds(M.X_AXIS),i=this.yAxisWidths.left.length+this.yAxisWidths.right.length===1,r=i?0:this.yAxisWidths.left.reduce((a,l)=>a+=l,0),o=i?0:this.yAxisWidths.right.reduce((a,l)=>a+=l,0);if(this.config.components.xAxis.visible){const a=this.getXAxisHeight();s.x=r,s.y=e.height-a-t.height,s.width=e.width-o,s.height=a}else this.applyDefaultBounds(s);return s}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const s=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,i=Xt(s,this.canvasModel.ctx);this.xAxisHeight=i+((t=this.config.components.xAxis.padding.top)!=null?t:0)+((e=this.config.components.xAxis.padding.bottom)!=null?e:0)+Oe}return this.xAxisHeight}setYAxisWidths(t){(!pi(this.yAxisWidths.left,t.left)||!pi(this.yAxisWidths.right,t.right))&&(this.yAxisWidths=t,this.recalculateBounds())}setXAxisHeight(t){t!==this.xAxisHeight&&(this.xAxisHeight=t,this.recalculateBounds())}setPanesOrder(t){this.panesOrder=t,this.recalculateBounds()}recalculatePanesHeightRatios(){this.calculateGraphsHeightRatios(),this.recalculateBounds()}calculateGraphsHeightRatios(){let t=this.graphsHeightRatio[$];const e=[];e.push(...this.panesOrder.filter(p=>p!==$));const s=e.map(p=>this.graphsHeightRatio[p]===void 0?void 0:this.graphsHeightRatio[p]),i=s.filter(p=>p!==0),r=i.length,o=i.filter(p=>p!==void 0).length,a=s.filter(p=>p===void 0).length,l=a>0;let c=0,h=0,d=1,u=0;if(l&&([d,u]=Xi(r)),(!this.graphsHeightRatio[$]||this.graphsHeightRatio[$]===0)&&(t=0),this.graphsHeightRatio[$]&&this.graphsHeightRatio[$]!==0)if(l)t=1*d;else{const p=Object.values(this.graphsHeightRatio).reduce((m,_)=>_+=m);p<1&&this.graphsHeightRatio[$]!==0&&(t+=1-p)}o===0&&(t=1-u*a),h=1-t-u*a,i.forEach(p=>{p&&(h-=p*d)}),c=h/(r||1);const f=s.map(p=>p===0?p:p?p*d+c:u+c);this._graphsHeightRatio={},this.graphsHeightRatio[$]=t,f.forEach((p,m)=>{const _=e[m];this.graphsHeightRatio[_]=p})}recalculateNavigationMapElementBounds(){var t,e,s,i;if(!this.config.components.navigationMap.visible)return;const r=this.getBounds(M.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=Ot()?a*Yi:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=tt=>Ql(this.canvasModel.ctx,tt,this.formatterFactory,this.config)[0],f=vt((i=(s=this.mainCandleSeries)==null?void 0:s.getSeriesInViewport())!=null?i:[]),p=d&&f.length?u(f[0].candle.timestamp):0,m=d&&f.length?u(f[f.length-1].candle.timestamp):0,_=Math.max(p,m);if(d){const tt=this.getBounds(M.N_MAP_LABEL_L);tt.x=r.x,tt.y=r.y,tt.width=_,tt.height=r.height;const et=this.getBounds(M.N_MAP_LABEL_R);et.x=r.x+r.width-_,et.y=r.y,et.width=_,et.height=r.height}const S=this.getBounds(M.N_MAP_BTN_L);S.x=r.x+_,S.y=r.y,S.width=Ks,S.height=r.height;const A=this.getBounds(M.N_MAP_BTN_R);A.x=r.x+r.width-Ks-_,A.y=r.y,A.width=Ks,A.height=r.height;const E=S.x+S.width,Y=A.x-E,B=E+Y,R=this.config.components.navigationMap.minSliderWindowWidth,k=c!=null?c:Ni,V=l!=null?l:r.height,X=k+R,U=this.getBounds(M.N_MAP_KNOT_L);U.x=E+Y*this.leftRatio,U.x=Math.min(U.x,B-X),U.y=h,U.width=k,U.height=V;const Z=this.getBounds(M.N_MAP_KNOT_R);Z.x=E+Y*this.rightRatio-Ni,Z.x=Math.max(Z.x,E+X),Z.y=h,Z.width=k,Z.height=V;const G=X-(Z.x-U.x);G>0&&(U.x-=G);const Q=this.getBounds(M.N_MAP_SLIDER_WINDOW);Q.x=U.x+U.width,Q.y=r.y,Q.width=Z.x-Q.x,Q.height=r.height;const J=this.getBounds(M.N_MAP_CHART);J.x=E,J.y=r.y,J.width=Y,J.height=r.height}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){let e=this.bounds[t];return e===void 0&&(e=this.copyOf(Hi),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>Fi(Wt({},t),{[e]:this.bounds[M.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=ns){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},ns),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-s&&o<l.pageX+l.width+s&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-s&&o<l.x+l.width+s&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=ns){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},ns),e);return r?(o,a)=>o>t.pageX-s&&o<t.pageX+t.width+s&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-s&&o<t.x+t.width+s&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(M.CANVAS);return t.width>0&&t.height>0}isAllBoundsAvailable(){return Object.values(this.bounds).every(t=>t.width>=0&&t.height>=0)}resizePaneVertically(t,e){const s=this.panesOrder.indexOf(t),i=this.getBounds(M.PANE_UUID_RESIZER(t));this.doResizePaneVertically(s,i.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){let s=t-1;const i=this.panesOrder[s];if(this._graphsHeightRatio[i]<=0)for(let d=0;d<t;d++)this._graphsHeightRatio[this.panesOrder[d]]>0&&(s=d);const r=this.getBounds(M.ALL_PANES).height,o=ki,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ft(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(lt(s=>this.copyOf(s)),mt((s,i)=>this.sameBounds(s,i)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return Wt({},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(Hi,t)}setMainCandleSeries(t){this.mainCandleSeries=t}getEffectiveYAxisWidth(){return this.getBounds(M.PANE_UUID_Y_AXIS($)).width}getEffectiveChartWidth(){return this.getBounds(M.PANE_UUID($)).width}getEffectiveChartHeight(){return this.getBounds(M.PANE_UUID($)).height}}const wc={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},Xi=n=>{var t;const e=(t=wc[n])!=null?t:.4,s=(1-e)/n;return[e,s]},av=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,Sc=(n,t)=>n>t.y&&n<t.y+t.height,ve=(n,t,e,s,i,r,o)=>{const a=n[t];if(a)return a.x=e,a.y=s,a.pageX=e+o.x,a.pageY=s+o.y,a.width=i,a.height=r,a;const l={x:e,y:s,pageX:e+o.x,pageY:s+o.y,width:i,height:r};return n[t]=l,l},Wi=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),ns={extensionX:0,extensionY:0,wholePage:!1},zi=(n,t)=>n.width===t.width&&n.height===t.height;var xc=(function(n){z(t,n);function t(e,s){return n.call(this)||this}return t.prototype.schedule=function(e,s){return s===void 0&&(s=0),this},t})(ge),is={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=is.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,at([n,t],H(e))):setInterval.apply(void 0,at([n,t],H(e)))},clearInterval:function(n){var t=is.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Vi=(function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i.pending=!1,i}return t.prototype.schedule=function(e,s){var i;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,s)),this.pending=!0,this.delay=s,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,s),this},t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),is.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,s,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return s;s!=null&&is.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,s);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var i=!1,r;try{this.work(e)}catch(o){i=!0,r=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,We(r,this),s!=null&&(this.id=this.recycleAsyncId(i,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(xc),Be={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=Be.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new ge(function(){return e==null?void 0:e(i)})},requestAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Be.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,at([],H(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Be.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,at([],H(n)))},delegate:void 0},_c=(function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i}return t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),i!==null&&i>0?n.prototype.requestAsyncId.call(this,e,s,i):(e.actions.push(this),e._scheduled||(e._scheduled=Be.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,s,i){var r;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return n.prototype.recycleAsyncId.call(this,e,s,i);var o=e.actions;s!=null&&s===e._scheduled&&((r=o[o.length-1])===null||r===void 0?void 0:r.id)!==s&&(Be.cancelAnimationFrame(s),e._scheduled=void 0)},t})(Vi),Js={now:function(){return(Js.delegate||Date).now()},delegate:void 0},Ui=(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=Js.now,n})(),Gi=(function(n){z(t,n);function t(e,s){s===void 0&&(s=Ui.now);var i=n.call(this,e,s)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var s=this.actions;if(this._active){s.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=s.shift());if(this._active=!1,i){for(;e=s.shift();)e.unsubscribe();throw i}},t})(Ui),Pc=(function(n){z(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var s;e?s=e.id:(s=this._scheduled,this._scheduled=void 0);var i=this.actions,r;e=e||i.shift();do if(r=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===s&&i.shift());if(this._active=!1,r){for(;(e=i[0])&&e.id===s&&i.shift();)e.unsubscribe();throw r}},t})(Gi),Bt=new Pc(_c),lv=null,rs=new Gi(Vi),Tc=rs;function Mc(n,t){return N(function(e,s){var i=t!=null?t:{},r=i.leading,o=r===void 0?!0:r,a=i.trailing,l=a===void 0?!1:a,c=!1,h=null,d=null,u=!1,f=function(){d==null||d.unsubscribe(),d=null,l&&(_(),u&&s.complete())},p=function(){d=null,u&&s.complete()},m=function(S){return d=Lt(n(S)).subscribe(yt(s,f,p))},_=function(){if(c){c=!1;var S=h;h=null,s.next(S),!u&&m(S)}};e.subscribe(yt(s,function(S){c=!0,h=S,!(d&&!d.closed)&&(o?_():m(S))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function Ac(n){return n instanceof Date&&!isNaN(n)}function Ec(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Tc);var s=-1;return t!=null&&(qn(t)?e=t:s=t),new gt(function(i){var r=Ac(n)?+n-e.now():n;r<0&&(r=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=s?this.schedule(void 0,s):i.complete())},r)})}function Et(n,t,e){t===void 0&&(t=rs);var s=Ec(n,t);return Mc(function(){return s},e)}class W{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 Ic extends W{constructor(t,e,s,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new F}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(Et(100,Bt,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(t,e,s,i=0){const r=qs.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:s,hitTest:r}):this.normalLayer.set(t,{cursor:s,hitTest:r})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(mt())}observeCursorType(t,e,s){const i=s?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(t);s?this.extensionLayer.set(t,{cursor:e,hitTest:i}):this.normalLayer.set(t,{cursor:e,hitTest:i})}updateCursor(t){this.element.style.cursor!==t&&(this.element.style.cursor=t,this.cursorChangedSubject.next(t))}}const Dc=n=>{const t=n.canvasArea!==null,e=n.snapshotCanvas!==null,s=n.backgroundCanvas!==null,i=n.mainCanvas!==null,r=n.yAxisLabelsCanvas!==null,o=n.crossToolCanvas!==null,a=n.hitTestCanvas!==null,l=n.chartResizer!==null,c=n.chartContainer!==null,h=n.dynamicObjectsCanvas!==null;return t&&e&&s&&i&&r&&o&&a&&l&&c&&h},Qs=(n=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
|
|
8
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function ze(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ge=(function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,s,i,r;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=L(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(m){t={error:m}}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(Y(h))try{h()}catch(m){r=m instanceof Is?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=L(d),f=u.next();!f.done;f=u.next()){var p=f.value;try{Fn(p)}catch(m){r=r!=null?r:[],m instanceof Is?r=ct(ct([],H(r)),H(m.errors)):r.push(m)}}}catch(m){s={error:m}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(s)throw s.error}}}if(r)throw new Is(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Fn(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)&&ze(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&ze(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),Bn=ge.EMPTY;function Rn(n){return n instanceof ge||n&&"closed"in n&&Y(n.remove)&&Y(n.add)&&Y(n.unsubscribe)}function Fn(n){Y(n)?n():n.unsubscribe()}var ee={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ue={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=Ue.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,ct([n,t],H(e))):setTimeout.apply(void 0,ct([n,t],H(e)))},clearTimeout:function(n){var t=Ue.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Hn(n){Ue.setTimeout(function(){var t=ee.onUnhandledError;if(t)t(n);else throw n})}function kn(){}var za=(function(){return Ds("C",void 0,void 0)})();function Ua(n){return Ds("E",void 0,n)}function Ga(n){return Ds("N",n,void 0)}function Ds(n,t,e){return{kind:n,value:t,error:e}}var se=null;function Ge(n){if(ee.useDeprecatedSynchronousErrorHandling){var t=!se;if(t&&(se={errorThrown:!1,error:null}),n(),t){var e=se,s=e.errorThrown,i=e.error;if(se=null,s)throw i}}else n()}function Za(n){ee.useDeprecatedSynchronousErrorHandling&&se&&(se.errorThrown=!0,se.error=n)}var Ls=(function(n){V(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,Rn(e)&&e.add(s)):s.destination=Ja,s}return t.create=function(e,s,i){return new Te(e,s,i)},t.prototype.next=function(e){this.isStopped?Bs(Ga(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Bs(Ua(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Bs(za,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})(ge),$a=Function.prototype.bind;function Os(n,t){return $a.call(n,t)}var Ka=(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){Ze(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Ze(s)}else Ze(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Ze(e)}},n})(),Te=(function(n){V(t,n);function t(e,s,i){var r=n.call(this)||this,o;if(Y(e)||!e)o={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:i!=null?i:void 0};else{var a;r&&ee.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&Os(e.next,a),error:e.error&&Os(e.error,a),complete:e.complete&&Os(e.complete,a)}):o=e}return r.destination=new Ka(o),r}return t})(Ls);function Ze(n){ee.useDeprecatedSynchronousErrorHandling?Za(n):Hn(n)}function qa(n){throw n}function Bs(n,t){var e=ee.onStoppedNotification;e&&Ue.setTimeout(function(){return e(n,t)})}var Ja={closed:!0,next:kn,error:qa,complete:kn};function Ct(n,t,e,s,i){return new Qa(n,t,e,s,i)}var Qa=(function(n){V(t,n);function t(e,s,i,r,o,a){var l=n.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;n.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(Ls);function ht(n,t){return N(function(e,s){var i=0;e.subscribe(Ct(s,function(r){s.next(n.call(t,r,i++))}))})}var Rs=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function jn(n){return Y(n==null?void 0:n.then)}var Fs=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ne(n){return n}function Wm(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Yn(n)}function Yn(n){return n.length===0?ne:n.length===1?n[0]:function(e){return n.reduce(function(s,i){return i(s)},e)}}var pt=(function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,s){var i=this,r=el(t)?t:new Te(t,e,s);return Ge(function(){var o=i,a=o.operator,l=o.source;r.add(a?a.call(r,l):l?i._subscribe(r):i._trySubscribe(r))}),r},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var s=this;return e=Nn(e),new e(function(i,r){var o=new Te({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});s.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Fs]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Yn(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Nn(t),new t(function(s,i){var r;e.subscribe(function(o){return r=o},function(o){return i(o)},function(){return s(r)})})},n.create=function(t){return new n(t)},n})();function Nn(n){var t;return(t=n!=null?n:ee.Promise)!==null&&t!==void 0?t:Promise}function tl(n){return n&&Y(n.next)&&Y(n.error)&&Y(n.complete)}function el(n){return n&&n instanceof Ls||tl(n)&&Rn(n)}function Xn(n){return Y(n[Fs])}function Wn(n){return Symbol.asyncIterator&&Y(n==null?void 0:n[Symbol.asyncIterator])}function Vn(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 sl(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var zn=sl();function Un(n){return Y(n==null?void 0:n[zn])}function Gn(n){return Dn(this,arguments,function(){var e,s,i,r;return v(this,function(o){switch(o.label){case 0:e=n.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Pt(e.read())];case 3:return s=o.sent(),i=s.value,r=s.done,r?[4,Pt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Pt(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 Zn(n){return Y(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof pt)return n;if(n!=null){if(Xn(n))return nl(n);if(Rs(n))return il(n);if(jn(n))return rl(n);if(Wn(n))return $n(n);if(Un(n))return ol(n);if(Zn(n))return al(n)}throw Vn(n)}function nl(n){return new pt(function(t){var e=n[Fs]();if(Y(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function il(n){return new pt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function rl(n){return new pt(function(t){n.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Hn)})}function ol(n){return new pt(function(t){var e,s;try{for(var i=L(n),r=i.next();!r.done;r=i.next()){var o=r.value;if(t.next(o),t.closed)return}}catch(a){e={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(e)throw e.error}}t.complete()})}function $n(n){return new pt(function(t){ll(n,t).catch(function(e){return t.error(e)})})}function al(n){return $n(Gn(n))}function ll(n,t){var e,s,i,r;return D(this,void 0,void 0,function(){var o,a;return v(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),e=Ln(n),l.label=1;case 1:return[4,e.next()];case 2:if(s=l.sent(),!!s.done)return[3,4];if(o=s.value,t.next(o),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),s&&!s.done&&(r=e.return)?[4,r.call(e)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Yt(n,t,e,s,i){s===void 0&&(s=0),i===void 0&&(i=!1);var r=t.schedule(function(){e(),i?n.add(this.schedule(null,s)):this.unsubscribe()},s);if(n.add(r),!i)return r}function cl(n,t,e,s,i,r,o,a){var l=[],c=0,h=0,d=!1,u=function(){d&&!l.length&&!c&&t.complete()},f=function(m){return c<s?p(m):l.push(m)},p=function(m){r&&t.next(m),c++;var _=!1;Lt(e(m,h++)).subscribe(Ct(t,function(S){i==null||i(S),r?f(S):t.next(S)},function(){_=!0},void 0,function(){if(_)try{c--;for(var S=function(){var A=l.shift();o?Yt(t,o,function(){return p(A)}):p(A)};l.length&&c<s;)S();u()}catch(A){t.error(A)}}))};return n.subscribe(Ct(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Hs(n,t,e){return e===void 0&&(e=1/0),Y(t)?Hs(function(s,i){return ht(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return cl(s,i,n,e)}))}function Kn(n){return n===void 0&&(n=1/0),Hs(ne,n)}var hl,qn=new pt(function(n){return n.complete()});function Vm(n){return n?dl(n):qn}function dl(n){return new hl(function(t){return n.schedule(function(){return t.complete()})})}function Jn(n){return n&&Y(n.schedule)}function ks(n){return n[n.length-1]}function ul(n){return Y(ks(n))?n.pop():void 0}function $e(n){return Jn(ks(n))?n.pop():void 0}function fl(n,t){return typeof ks(n)=="number"?n.pop():t}function Qn(n,t){return t===void 0&&(t=0),N(function(e,s){e.subscribe(Ct(s,function(i){return Yt(s,n,function(){return s.next(i)},t)},function(){return Yt(s,n,function(){return s.complete()},t)},function(i){return Yt(s,n,function(){return s.error(i)},t)}))})}function ti(n,t){return t===void 0&&(t=0),N(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function pl(n,t){return Lt(n).pipe(ti(t),Qn(t))}function gl(n,t){return Lt(n).pipe(ti(t),Qn(t))}function ml(n,t){return new pt(function(e){var s=0;return t.schedule(function(){s===n.length?e.complete():(e.next(n[s++]),e.closed||this.schedule())})})}function vl(n,t){return new pt(function(e){var s;return Yt(e,t,function(){s=n[zn](),Yt(e,t,function(){var i,r,o;try{i=s.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return Y(s==null?void 0:s.return)&&s.return()}})}function ei(n,t){if(!n)throw new Error("Iterable cannot be null");return new pt(function(e){Yt(e,t,function(){var s=n[Symbol.asyncIterator]();Yt(e,t,function(){s.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function bl(n,t){return ei(Gn(n),t)}function Cl(n,t){if(n!=null){if(Xn(n))return pl(n,t);if(Rs(n))return ml(n,t);if(jn(n))return gl(n,t);if(Wn(n))return ei(n,t);if(Un(n))return vl(n,t);if(Zn(n))return bl(n,t)}throw Vn(n)}function Ke(n,t){return t?Cl(n,t):Lt(n)}function yt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=$e(n),s=fl(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):Kn(s)(Ke(i,e)):qn}var yl=On(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),F=(function(n){V(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 si(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new yl},t.prototype.next=function(e){var s=this;Ge(function(){var i,r;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=L(s.currentObservers),a=o.next();!a.done;a=o.next()){var l=a.value;l.next(e)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var s=this;Ge(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=e;for(var i=s.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ge(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var s=e.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var s=this,i=this,r=i.hasError,o=i.isStopped,a=i.observers;return r||o?Bn:(this.currentObservers=null,a.push(e),new ge(function(){s.currentObservers=null,ze(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var s=this,i=s.hasError,r=s.thrownError,o=s.isStopped;i?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new pt;return e.source=this,e},t.create=function(e,s){return new si(e,s)},t})(pt),si=(function(n){V(t,n);function t(e,s){var i=n.call(this)||this;return i.destination=e,i.source=s,i}return t.prototype.next=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.next)===null||i===void 0||i.call(s,e)},t.prototype.error=function(e){var s,i;(i=(s=this.destination)===null||s===void 0?void 0:s.error)===null||i===void 0||i.call(s,e)},t.prototype.complete=function(){var e,s;(s=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||s===void 0||s.call(e)},t.prototype._subscribe=function(e){var s,i;return(i=(s=this.source)===null||s===void 0?void 0:s.subscribe(e))!==null&&i!==void 0?i:Bn},t})(F),ft=(function(n){V(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(F);let js=!1,Ys=0;const qe=new Map,Je=new Map,ni=()=>{js||(js=!0,Ys=requestAnimationFrame(()=>{Je.forEach((n,t)=>{n(),Je.delete(t)}),qe.forEach((n,t)=>{n(),qe.delete(t)}),js=!1}))},ii=(n,t)=>{qe.set(n,t),ni()},wl=n=>{qe.delete(n)},Sl=n=>{Je.delete(n)},Me=(n,t)=>{Je.set(n,t),ni()};function St(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}const ri="\u2212",xl="-";var _l=Math.pow;const Qe=14,ts=[];for(let n=0;n<Qe+1;n++)ts.push(_l(10,n));const Ns=5e-13,oi=class te{static roundToNearest(t,e){return isFinite(t)?te.isZero(t)?0:(t>0?t+=Ns:t<0&&(t-=Ns),te.roundDecimal(Math.round(te.roundDecimal(t/e))*e)):t}static roundUpToNearest(t,e){return te.roundDecimal(Math.ceil(t/e))*e}static roundDecimal(t){if(isNaN(t)||t===Math.floor(t))return t;const e=Math.sign(t),s=Math.abs(t),i=Math.min(Qe,Qe-1-Math.floor(Math.log10(s)));for(let r=i;r>=0;r--){const o=Math.floor(ts[r]*s+.5);if(o<ts[Qe])return e*o/ts[r]}return Math.round(t)}static formatIntegerWithSeparator(t,e){return Math.abs(t)<1e3?t.toString():t.toString().replace(te.THOUSANDS_SEPARATOR_REGEX,`$&${e}`)}static makeDecimal(t,e,s,i){if(!isFinite(t))return"";if(isFinite(t)){let r=t.toFixed(e);if(!i)return s?r.replace(".",s):r;if(s===i)throw new Error("Grouping symbol cannot be the same as decimal separator.");const o=r.split(".");let a=o[0];const l=o[1];return Math.abs(t)>=1e3&&(a=a.replace(te.THOUSANDS_SEPARATOR_REGEX,`$&${i}`)),l?(r=[a,l].join(s),r):a}return""}static compare(t,e,s){return t>e+s?1:t<e-s?-1:(isNaN(t)?1:0)-(isNaN(e)?1:0)}static isZero(t){return te.compare(t,0,Ns)===0}static cutNumber(t,e,s=0){return{K:r=>r/1e3,M:r=>r/1e6}[e](t).toFixed(s)+e}static isExponential(t){return/\de(\-|\+)\d/.test(t.toString())}};oi.THOUSANDS_SEPARATOR_REGEX=/\d(?=(\d{3})+$)/g;let Tt=oi;function Pl(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 Tl(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Ae(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const rt=n=>~~n,Ml=n=>~~(n+1),Ee=n=>~~(n+.5),Al=(n,t)=>n>>t;function zm(n){if(!Number.isFinite(n))throw new Error("Input must be a finite number.");const t=n.toString();return t.includes(".")?t.split(".")[1].length:0}const es=n=>n.replace(xl,ri);class Ws{constructor(t,e){this.animationTimeLeft=0,this.onTickFunction=e,this.animationTime=t.duration,this.animationStartTime=Date.now(),this.animationInProgress=!0}tick(){var t;Date.now()>this.animationStartTime+this.animationTime&&(this.animationInProgress=!1),(t=this.onTickFunction)==null||t.call(this)}getProgress(){return Math.min((Date.now()-this.animationStartTime)/this.animationTime,1)}finishAnimation(){this.animationInProgress=!1,this.animationStartTime=0}}var El=_t(742),Ft=_t.n(El);class ai extends Ws{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Ft().rgb(i.color),i.initialAlpha=i.rgbColor.valpha,i.currentAnimationColor=i.rgbColor})}tick(){super.tick(),this.colorConfigs.forEach(t=>{if(t.initialAlpha===void 0||t.rgbColor===void 0)return;const e=t.initialAlpha*(t.type==="fading"?1-this.getProgress():this.getProgress());t.currentAnimationColor=t.rgbColor.alpha(e)})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){const t=Xs(Date.now()-this.animationStartTime,0,this.animationTime);this.animationStartTime=Date.now()-this.animationTime+t,this.colorConfigs.forEach(e=>{e.type=e.type==="fading"?"appearing":"fading"})}}class li extends Ws{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Ft().rgb(i.startColor),i.rgbEndColor=Ft().rgb(i.endColor),i.currentAnimationColor=i.type==="appearing"?i.rgbStartColor:i.rgbEndColor})}tick(){super.tick(),this.animationInProgress&&this.colorConfigs.forEach(t=>{const e=1-this.animationTimeLeft/this.animationTime;!t.rgbStartColor||!t.rgbEndColor||(t.type==="fading"?t.currentAnimationColor=this.calculateTransitionColor(t.rgbEndColor,t.rgbStartColor,e):t.type==="appearing"&&(t.currentAnimationColor=this.calculateTransitionColor(t.rgbStartColor,t.rgbEndColor,e)))})}getColor(t){var e,s;return(s=(e=this.colorConfigs[t].currentAnimationColor)==null?void 0:e.toString())!=null?s:"#FFFFFF"}revert(){this.animationTimeLeft=Math.max(this.animationTime-this.animationTimeLeft,1),this.colorConfigs.forEach(t=>{t.type==="fading"?t.type="appearing":t.type="fading"})}moveToLastTick(){this.animationTimeLeft=1}calculateTransitionColor(t,e,s){const i=t.red()-(t.red()-e.red())*s,r=t.green()-(t.green()-e.green())*s,o=t.blue()-(t.blue()-e.blue())*s;return Ft().rgb(i,r,o)}}class ci extends Ws{constructor(t,e,s){var i;super(e,s),this.viewportModel=t,this.animationConfig=e,this.id=St(),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:Tl}tick(){if(super.tick(),this.animationInProgress){const t=this.easingFn(this.getProgress()),e=this.xStart+(this.animationConfig.targetXStart-this.xStart)*t,s=this.xEnd+(this.animationConfig.targetXEnd-this.xEnd)*t,i=this.yStart+(this.animationConfig.targetYStart-this.yStart)*t,r=this.yEnd+(this.animationConfig.targetYEnd-this.yEnd)*t,o=this.zoomX+(this.animationConfig.targetZoomX-this.zoomX)*t,a=this.zoomY+(this.animationConfig.targetZoomY-this.zoomY)*t;this.viewportModel.apply({xStart:e,xEnd:s,yStart:i,yEnd:r,zoomX:o,zoomY:a,inverseY:this.viewportModel.inverseY})}}finishAnimation(){super.finishAnimation(),this.viewportModel.apply({xStart:this.animationConfig.targetXStart,xEnd:this.animationConfig.targetXEnd,yStart:this.animationConfig.targetYStart,yEnd:this.animationConfig.targetYEnd,zoomX:this.animationConfig.targetZoomX,zoomY:this.animationConfig.targetZoomY,inverseY:this.viewportModel.inverseY})}}const Ie=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Il=!!window.chrome,hi=typeof InstallTrigger!="undefined",Dl=navigator.platform.indexOf("Win")>-1,Um=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(Ie)i=e===n.deltaY*-3||Math.abs(e+Math.sign(e))===Math.abs(Math.round(n.deltaY)*3)||Math.abs(e-Math.sign(e))===Math.abs(Math.round(n.deltaY)*3);else if(Il){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,Dl){const r=Math.round(n.deltaY)===e||Math.abs(Math.round(n.deltaY)+Math.sign(n.deltaY))===Math.abs(e)||Math.abs(Math.round(n.deltaY)-Math.sign(n.deltaY))===Math.abs(e);i=Math.abs(e)===Math.abs(n.deltaY)||r}}else hi?Math.abs(n.deltaY)>Math.abs(n.deltaX)?i=!1:i=s===n.deltaX*-3:i=e===n.deltaY*-3;i&&(t=!0)}else n.deltaMode===0&&(t=!0);return hi&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Ll=(n,t)=>n==="percent"?t/4:t;var Ol=Object.defineProperty,Bl=Object.defineProperties,Rl=Object.getOwnPropertyDescriptors,di=Object.getOwnPropertySymbols,Fl=Object.prototype.hasOwnProperty,Hl=Object.prototype.propertyIsEnumerable,ui=(n,t,e)=>t in n?Ol(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,kl=(n,t)=>{for(var e in t||(t={}))Fl.call(t,e)&&ui(n,e,t[e]);if(di)for(var e of di(t))Hl.call(t,e)&&ui(n,e,t[e]);return n},jl=(n,t)=>Bl(n,Rl(t));const De=Ie?150:400,me="VIEWPORT_ANIMATION";class fi{constructor(t){this.animations={},this.animationInProgressSubject=new ft(!1),this.animFrameId=`canvas_animation_${St()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=me,i){const r=new ci(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ai(jl(kl({},i),{duration:i&&i.duration||De}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=De,i){const r=new li({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0)}processAnimation(){Me(this.animFrameId,()=>this.tick())}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():queueMicrotask(()=>{this.processAnimation(),this.eventBus.fireDraw()})}stopInterval(){wl(this.animFrameId)}}function gt(n,t){return t===void 0&&(t=ne),n=n!=null?n:Yl,N(function(e,s){var i,r=!0;e.subscribe(Ct(s,function(o){var a=t(o);(r||!n(i,a))&&(r=!1,i=a,s.next(o))}))})}function Yl(n,t){return n===t}function Nl(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Vs(n){return n}function pi(n){return n!=null}const Gm=()=>{};function Zm(n){return n!=null}function Xl(n,t,e=Wl,s=!0){const i=n.filter(r=>t.some(o=>e(r,o)));return s?i.filter((r,o,a)=>a.indexOf(r)===o):i}const gi=(n,t)=>{const e=t.slice().filter(s=>n.find(i=>i===s));return n.map(s=>{var i;return t.indexOf(s)>=0&&(i=e.shift())!=null?i:s})},Wl=(n,t)=>n===t,$m=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),Vl=(n,t)=>n===t,mi=(n,t,e=Vl)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function Km(n,t,e){const s=n.slice(),i=s[t];return s.splice(t,1),s.splice(e,0,i),s}function zs(n,t,e){const s=n.length,i=Xs(t,0,s-1),r=Xs(e,0,s-1),o=n[i];return n.splice(i,1),n.splice(r,0,o),n}function qm(n,t,e){const s=n.slice(),i=s.findIndex(t);return i!==-1&&(s.splice(i,1),s.splice(i,0,e)),s}const Jm=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},Qm=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),tv=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),ev=n=>Array.isArray(n[0]),vi=n=>Array.isArray(n[0])?n:[n],zl=(n,t,e)=>{const s=[];let i=0;for(const r of n){const o=Math.max(t-i,0),a=Math.max(e-i,-1),l=r.slice(o,a+1);l.length>0&&s.push(l),i+=r.length}return s},Ul=(n,t)=>n>=0?t[n]:t[t.length+n],mt=n=>Array.prototype.flat?n.flat():Le(n,Vs),Le=(n,t)=>{if(Array.prototype.flatMap)return n.flatMap(t);const e=[];for(let s=0;s<n.length;s++){const i=n[s];e.push(...t(i,s,n))}return e};function Nt(n,t,e){const s=e!=null?e:Vs;return!n.length||t!==t?{index:-1,exact:!0}:Us(n,t,0,n.length,s)}function Us(n,t,e,s,i){const r=Al(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Us(n,t,e,r,i):Us(n,t,r,s,i)}function wt(n){if(n&&n.length)return n[n.length-1]}function Gl(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Zl(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ie(n){if(n)return n[0]}function $l(n){function t(e,s){const i=n(s);return i==null||!isFinite(i)?e:[Math.max(e[0],i),Math.min(e[1],i)]}return function(e){const s=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY];return e?e.reduce(t,s):s}}function Kl(n,t,e,s=()=>0){const i=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])<=a?l=h+1:c=h-1}return c},r=(o,a)=>{let l=0,c=o.length-1;for(;c>=l;){const h=Math.ceil((l+c)/2);s(o[h])>=a?c=h-1:l=h+1}return l};return n.slice(r(n,t),i(n,e)+1)}let Gs,bi;const Ot=()=>{if(typeof navigator=="undefined")return!1;const n=navigator.userAgent;return(bi!==n||Gs===void 0)&&(bi=n,Gs=!!n.match(/Android|iPhone|Opera Mini/)),Gs},ql=1.33,Ci=4.5;function yi(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 ss(n,t=!0){const e=n.font.match(/(\d+.)?\d+(px|pt)/gi);let s="10px";return e&&e.length&&(e[0].includes("pt")?s=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":s=e[0]),t?parseInt(s,10)*ql:parseInt(s,10)}function wi(n,t,e){n.save(),yi(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(o=>n.measureText(o).width))),i=ss(n),r=i*t.length;return n.restore(),[s,r,i]}function Si(n){return(n||"").split(/\r\n|\r|\n/)}function Jl(n,t,e,s,i){n.save();const[r,,o]=wi(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=Ql(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&tc(n,a,f,s+o*l,(h=i.textFill)!=null?h:"",(d=i.textSize)!=null?d:""),n.fillText(a,f,s+o*l)}),n.restore()}function Ql(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function tc(n,t,e,s,i,r){n.save();const o=n.measureText(t).width,a=e,l=e+o,c=s+2,h=c;let d=parseInt(r,10)/15;d<1&&(d=1),n.beginPath(),n.strokeStyle=i,n.lineWidth=d,n.moveTo(a,c),n.lineTo(l,h),n.stroke(),n.restore()}function sv(n){return`${n}px`}function xi(n){const t=Ft().rgb(n).array(),[e,s,i]=t.map(r=>{const o=r/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)});return .2126*e+.7152*s+.0722*i}function _i(n,t){const e=xi(n),s=xi(t),i=Math.max(e,s),r=Math.min(e,s);return(i+.05)/(r+.05)}function re(n,t,e){const s=_i(n,t),i=_i(n,e),r=s>=Ci,o=i>=Ci;return r&&!o?t:o&&!r?e:s>=i?t:e}function ec(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=Pi(t,i.dateFormat,e),a=Si(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=wi(n,a,l);return[c+r.x*2,h+r.y*2]}function Pi(n,t,e){return e(t)(n).split(" ").join(`
|
|
9
|
+
`)}const Ti={};function Xt(n,t){let e=Ti[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,Ti[n]=e,t.restore()),e}const Mi=new Map;function Mt(n,t,e){const s=e+n;let i=Mi.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,Mi.set(s,i),t.restore()),i}function At(n,t,e=Ai){function s(i,r){for(const o in r)o in i?typeof i[o]=="object"&&i[o]!==null&&!Array.isArray(i[o])?s(i[o],r[o]):e!=null&&e.overrideExisting&&(i[o]=r[o]):e!=null&&e.addIfMissing&&(i[o]=r[o]);return i}return s(n,t)}function nv(n,t,e,s=!1){!n||!t||t.length===0||t.forEach(i=>{const r=e(i),o=n.findIndex(a=>e(a)===r);o===-1?n.push(i):s?At(n[o],i,{overrideExisting:!0,addIfMissing:!0}):n.splice(o,1,i)})}const Ai={overrideExisting:!1,addIfMissing:!0};function sc(n){let t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){const s=n.charCodeAt(e);t=(t<<5)-t+s,t|=0}return t}const Zs=1,nc=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Ei=(n,t)=>`${n}_${sc(t.toString())}`;function ns(n,t){return t===n?"none":t>n?"up":"down"}function ic(n,t){return t>n?"up":"down"}function rc(n,t,e=!1){const{id:s,expansion:i,impVolatility:r,openInterest:o,vwap:a,typicalPrice:l,volume:c,timestamp:h}=n;let d=n.hi,u=n.lo,f=n.open;const p=n.close;e&&(d=p,u=p,f=p);let m=n.idx;return t!==void 0&&(m=t),{id:s,hi:d,lo:u,open:f,close:p,timestamp:h,volume:c,expansion:i,idx:m,impVolatility:r,openInterest:o,vwap:a,typicalPrice:l}}var oc,ac,lc=Object.defineProperty,Ii=Object.getOwnPropertySymbols,cc=Object.prototype.hasOwnProperty,hc=Object.prototype.propertyIsEnumerable,Di=(n,t,e)=>t in n?lc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dc=(n,t)=>{for(var e in t||(t={}))cc.call(t,e)&&Di(n,e,t[e]);if(Ii)for(var e of Ii(t))hc.call(t,e)&&Di(n,e,t[e]);return n};const Li="Open Sans Semibold, sans-serif",uc=null,fc=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],iv=n=>uc.find(t=>t===n)!==void 0,is=()=>({devexpertsPromoLink:!0,useUTCTimeOverride:!1,shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rtl:!1,intlFormatter:{decimalSeparator:".",thousandsSeparator:""},scale:{keepZoomXOnYAxisChange:!0,auto:!0,zoomToCursor:!1,lockPriceToBarRatio:!1,autoScaleOnCandles:!0,autoScaleDisableOnDrag:{enabled:!0,edgeAngle:Math.PI/15,yDiff:80},inverse:!1,zoomSensitivity:{wheel:.25},defaultViewportItems:100,disableAnimations:!1},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,components:{chart:{type:"candle",showCandlesBorder:!0,showActiveCandlesBorder:!0,showWicks:!0,candleLineWidth:1,lineWidth:1,areaLineWidth:1,barLineWidth:1,minWidth:.5,minCandles:10,candlePaddingPercent:.25,highlightActiveCandle:!0,cursor:"default",selectedWidth:3,minCandlesOffset:2,defaultZoomCandleWidth:7,zoomStep:0,histogram:{barCapSize:1},maxYAxisScalesAmount:10,applyBackgroundToAxes:{x:!0,y:!0},sortCandles:nc,candleTimestampAnchor:"open"},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:Li,cursor:"ns-resize",resizeDisabledCursor:"default",labelBoxMargin:{top:4,bottom:4,end:8,start:10},typeConfig:{badge:{rounded:!0,paddings:{top:4,bottom:4,end:4,start:4}},plain:{},rectangle:{rounded:!1,paddings:{top:4,bottom:4,end:4,start:4}}},labels:{descriptions:!1,settings:{lastPrice:{mode:"label",type:"badge"},countdownToBarClose:{mode:"none",type:"rectangle"}}},treasuryFormat:{enabled:!1}},xAxis:{visible:!0,formatsForLabelsConfig:{lessThanSecond:"HH:mm:ss",second_1:"HH:mm:ss",minute_1:"HH:mm",minute_5:"HH:mm",minute_30:"HH:mm",hour_1:"HH:mm",day_1:"dd.MM",month_1:"MMM",year_1:"YYYY"},fontSize:12,fontFamily:Li,cursor:"ew-resize",padding:{top:8,bottom:16},fontStyle:""},events:{visible:!1,eventsVisibility:{"conference-calls":!0,dividends:!0,splits:!0,earnings:!0},height:20,cursor:"default",xAxisLabelFormat:[{format:"d MMM"}],icons:{earnings:{normal:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" stroke="#D92C40" stroke-width="1.5"/></svg>',hover:'<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.06066 6.5L6.5 1.06066L11.9393 6.5L6.5 11.9393L1.06066 6.5Z" fill="#D92C40" stroke="#D92C40" stroke-width="1.5"/></svg>'}}},offsets:{visible:!0,right:10,top:10,bottom:20,left:0},waterMark:{visible:!1,fontFamily:"Open Sans, sans-serif",firstRowFontSize:80,firstRowBottomPadding:10,secondRowFontSize:40,secondRowBottomPadding:25,thirdRowFontSize:40,thirdRowBottomPadding:15,position:"center",offsetX:20,offsetY:20,logoWidth:20,logoHeight:20},highLow:{visible:!1,font:"12px sans-serif",prefix:{high:"H: ",low:"L: "},lineDash:[2,4]},highlights:{visible:!1,fontFamily:"Open Sans",fontSize:13,border:{width:1,dash:[8,4]}},crossTool:{type:"cross-and-labels",discrete:!0,magnetTarget:"none",lineDash:[4,6],xAxisLabelFormat:[{format:"dd.MM.YYYY",showWhen:{periodMoreThen:1440*60*1e3}},{format:"dd.MM.YYYY HH:mm",showWhen:{periodLessThen:1440*60*1e3,periodMoreThen:6*1e3}},{format:"dd.MM.YYYY HH:mm:ss",showWhen:{periodLessThen:6*1e3}}],xLabel:{padding:{top:4,bottom:4,right:8,left:8},margin:{top:4}},yLabel:{padding:{top:4,bottom:4,end:4,start:4},type:"badge"}},grid:{visible:!0,horizontal:!1,vertical:!0,width:1,dash:[0,0],color:"#FFFFFF"},volumes:{visible:!0,showSeparately:!1,valueLines:15,barCapSize:1,volumeBarSpace:0,volumeFillColor:"#FFFFFF"},navigationMap:{visible:!1,allCandlesHistory:!0,timeLabels:{visible:!1,dateFormat:"dd.MM.YYYY HH:mm",fontFamily:"Open Sans",fontSize:13,padding:{x:10,y:1}},minSliderWindowWidth:10,cursors:{chart:"default",buttonLeft:"pointer",buttonRight:"pointer",leftResizer:"ew-resize",rightResizer:"ew-resize",slider:"grab"},knots:{height:35,width:7,border:0,lineWidth:1}},baseline:{cursor:"ns-resize",dragZone:3,height:1},paneResizer:{cursor:"ns-resize",height:1,visible:!0,fixedMode:!1,dragZone:3}},colors:{candleTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(77,153,83,1)",downWickColor:"rgba(217,44,64,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:1},barTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},lineTheme:{upColor:"rgba(77,153,83,1)",downColor:"rgba(217,44,64,1)",noneColor:"rgba(255,255,255,1)"},chartAreaTheme:{backgroundMode:"regular",backgroundColor:"rgba(20,20,19,1)",backgroundGradientTopColor:"red",backgroundGradientBottomColor:"blue",gridColor:"rgba(37,37,36,1)"},scatterPlot:{mainColor:"rgba(255,255,255,1)"},areaTheme:{lineColor:"rgba(127,120,214,1)",startColor:"rgba(169,38,251,1)",stopColor:"rgba(169,38,251,0.8)"},baseLineTheme:{lowerSectionStrokeColor:"rgba(217,44,64,1)",upperSectionStrokeColor:"rgba(77,153,83,1)",lowerSectionFillColor:"rgba(217, 44, 64, 0.07)",upperSectionFillColor:"rgba(77, 153, 83, 0.07)",baselineColor:"rgba(55,55,54,1)"},histogram:{upCap:"rgba(77,153,83,1)",upBottom:"rgba(77,153,83,0.1)",upBright:"rgba(77,153,83,0.4)",downCap:"rgba(217,44,64,1)",downBottom:"rgba(217,44,64,0.1)",downBright:"rgba(217,44,64,0.4)",noneCap:"rgba(255,255,255,1)",noneBottom:"rgba(255,255,255,0.1)",noneBright:"rgba(255,255,255,0.4)"},crossTool:{lineColor:"rgba(107,96,86,1)",labelBoxColor:"rgba(107,96,86,1)",labelTextColor:"rgba(255,255,255,1)"},waterMarkTheme:{firstRowColor:"rgba(255,255,255,0.2)",secondRowColor:"rgba(255,255,255,0.2)",thirdRowColor:"rgba(255,255,255,0.2)"},highlights:{NO_TRADING:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"},AFTER_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(38, 251, 149, 0.05)",label:"transparent"},PRE_MARKET:{border:"rgba(107,96,86,1)",background:"rgba(255, 170, 0, 0.05)",label:"transparent"},REGULAR:{border:"rgba(107,96,86,1)",background:"transparent",label:"transparent"}},activeCandleTheme:{upColor:"rgba(98,201,93,1)",downColor:"rgba(255,47,47,1)",noneColor:"rgba(255,255,255,1)",upWickColor:"rgba(98,201,93,1)",downWickColor:"rgba(255,47,47,1)",noneWickColor:"rgba(255,255,255,1)",borderOpacity:.5},volume:{downBarColor:"rgba(99,30,37,1)",upBarColor:"rgba(42,72,44,1)",noneBarColor:"rgba(255,255,255,0.4)",upCapColor:"rgba(42,72,44,1)",downCapColor:"rgba(99,30,37,1)",noneCapColor:"rgba(255,255,255,0.4)"},highLowTheme:{highColor:"rgba(223,222,223,1)",lowColor:"rgba(223,222,223,1)"},instrumentInfo:{textColor:"#aeb1b3"},paneResizer:{lineColor:"rgba(61,61,61,1)",bgColor:"rgba(20,20,19,1)",bgHoverColor:"rgba(55,55,54,0.6)"},events:{earnings:{color:"rgba(217,44,64,1)",normal:"rgba(217,44,64,1)",hover:"rgba(217,44,64,1)",line:"rgba(217,44,64,1)"},dividends:{color:"rgba(169,38,251,1)",normal:"rgba(169,38,251,1)",hover:"rgba(169,38,251,1)",line:"rgba(169,38,251,1)"},splits:{color:"rgba(244,187,63,1)",normal:"rgba(244,187,63,1)",hover:"rgba(244,187,63,1)",line:"rgba(244,187,63,1)"},"conference-calls":{color:"rgba(48,194,97,1)",normal:"rgba(48,194,97,1)",hover:"rgba(48,194,97,1)",line:"rgba(48,194,97,1)"}},secondaryChartTheme:[{lineTheme:{upColor:"rgba(226,61,25,1)",downColor:"rgba(226,61,25,1)",noneColor:"rgba(226,61,25,1)"},areaTheme:{lineColor:"rgba(226,61,25,1)",startColor:"rgba(226,61,25,0.8)",stopColor:"rgba(226,61,25,0)"}},{lineTheme:{upColor:"rgba(250,191,64,1)",downColor:"rgba(250,191,64,1)",noneColor:"rgba(250,191,64,1)"},areaTheme:{lineColor:"rgba(250,191,64,1)",startColor:"rgba(250,191,64,0.8)",stopColor:"rgba(250,191,64,0)"}},{lineTheme:{upColor:"rgba(169,38,251,1)",downColor:"rgba(169,38,251,1)",noneColor:"rgba(169,38,251,1)"},areaTheme:{lineColor:"rgba(169,38,251,1)",startColor:"rgba(169,38,251,0.8)",stopColor:"rgba(169,38,251,0)"}},{lineTheme:{upColor:"rgba(77,211,240,1)",downColor:"rgba(77,211,240,1)",noneColor:"rgba(77,211,240,1)"},areaTheme:{lineColor:"rgba(77,211,240,1)",startColor:"rgba(77,211,240,0.8)",stopColor:"rgba(77,211,240,0)"}},{lineTheme:{upColor:"rgba(59,203,91,1)",downColor:"rgba(59,203,91,1)",noneColor:"rgba(59,203,91,1)"},areaTheme:{lineColor:"rgba(59,203,91,1)",startColor:"rgba(59,203,91,0.8)",stopColor:"rgba(59,203,91,0)"}}],yAxis:{backgroundColor:"rgba(20,20,19,1)",labelBoxColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)",labelInvertedTextColor:"rgba(20,20,19,1)",rectLabelTextColor:"rgba(255,255,255,1)",rectLabelInvertedTextColor:"rgba(20,20,19,1)",zeroPercentLine:"rgba(55,55,54,1)"},labels:{lastPrice:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(0,0,0,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},countdownToBarClose:{textNegative:"rgba(255,255,255,1)",textPositive:"rgba(255,255,255,1)",textSelected:"rgba(255,255,255,1)",boxNegative:"rgba(217,44,64,1)",boxPositive:"rgba(77,153,83,1)",boxSelected:"rgba(255,255,255,1)"},highLow:{high:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"High"},low:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Low"}},bidAsk:{bid:{boxColor:"rgba(77,153,83,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Bid"},ask:{boxColor:"rgba(217,44,64,1)",textColor:"rgba(255,255,255,1)",descriptionText:"Ask"}},prePostMarket:{post:{boxColor:"rgba(38,251,149,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Post"},pre:{boxColor:"rgba(255,170,0,1)",textColor:"rgba(20,20,19,1)",descriptionText:"Pre"}},prevDayClose:{boxColor:"rgba(107,96,86,1)",textColor:"rgba(255,255,255,1)"}},xAxis:{backgroundColor:"rgba(20,20,19,1)",labelTextColor:"rgba(128,128,128,1)"},navigationMap:{backgroundColor:"transparent",buttonColor:"rgba(255,255,255,0.1)",buttonArrowColor:"rgba(212,212,211,1)",knotColor:"rgba(255,255,255,0.1)",knotLineColor:"rgba(212,212,211,1)",sliderColor:"rgba(255,255,255,0.08)",knotBorderColor:"#0b0d1a",timeLabelsTextColor:"rgba(128,128,128,1)",mapColor:"rgba(255,255,255,0.1)",mapFillColor:"rgba(255,255,255,0.1)",mapGradientTopColor:"rgba(255,255,255,0.1)",mapGradientBottomColor:"rgba(255,255,255,0.1)"}},animation:{moveDuration:1e3,candleDuration:200,paneResizer:{bgMode:!0,enabled:!0,duration:40},yAxis:{background:{enabled:!1,duration:40}}},drawingOrder:["OVER_SERIES_CLEAR","MAIN_CLEAR","SERIES_CLEAR","GRID","X_AXIS","Y_AXIS","DYNAMIC_OBJECTS","WATERMARK","N_MAP_CHART","EVENTS"]});function pc(n,t=is()){return At(n,t,Ai),n}function rv(n,t=is()){const e=dc({},n);return oc(e,t,ac),e}function ov(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function Oi(n){return typeof n=="object"&&n!==null}function Bi(n,t){return[...n].map(s=>$s(s,t))}const gc=n=>Array.isArray(n);function $s(n,t){if(!Oi(n))return n;if(gc(n))return Bi(n,t);{const e=Ri({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function Ri(n,t,e){if(!Oi(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return Bi(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=$s(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=Ri(n[i],t[i],e):e.addIfMissing&&(s[i]=$s(t[i],e))}),s}const av=null,oe=n=>`${n.fontSize}px ${n.fontFamily}`;class mc{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=oe(this.config.components.yAxis);return Mt(t,this.mainCanvasModel.ctx,e)}getYAxisWidths(){this.extentsOrder.clear();const t=[],e=[];return this.yAxisWidthContributors.forEach(s=>{var i,r,o;const a=s.getYAxisState();if(!a.visible)return;const l=a.labelBoxMargin.start+a.labelBoxMargin.end,c=this.getTextWidth(s.getLargestLabel())+l,h=s.getYAxisIndex(),d=s.getPaneUUID(),u=(i=this.extentsOrder.get(d))!=null?i:{left:[],right:[]};if(a.align==="left"){const f=u.left.length;t[f]=Math.max((r=t[f])!=null?r:0,c),u.left.push(h)}else{const f=u.right.length;e[f]=Math.max((o=e[f])!=null?o:0,c),u.right.push(h)}this.extentsOrder.set(d,u)}),{left:t,right:e}}}var vc=Object.defineProperty,bc=Object.defineProperties,Cc=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,yc=Object.prototype.hasOwnProperty,wc=Object.prototype.propertyIsEnumerable,Hi=(n,t,e)=>t in n?vc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wt=(n,t)=>{for(var e in t||(t={}))yc.call(t,e)&&Hi(n,e,t[e]);if(Fi)for(var e of Fi(t))wc.call(t,e)&&Hi(n,e,t[e]);return n},ki=(n,t)=>bc(n,Cc(t));const $="CHART",nt=class{};nt.CANVAS="CANVAS",nt.N_MAP="N_MAP",nt.X_AXIS="X_AXIS",nt.N_MAP_KNOT_L="N_MAP_KNOT_L",nt.N_MAP_KNOT_R="N_MAP_KNOT_R",nt.N_MAP_BTN_L="N_MAP_BTN_L",nt.N_MAP_BTN_R="N_MAP_BTN_R",nt.N_MAP_SLIDER_WINDOW="N_MAP_SLIDER_WINDOW",nt.N_MAP_CHART="N_MAP_CHART",nt.N_MAP_LABEL_R="N_MAP_LABEL_R",nt.N_MAP_LABEL_L="N_MAP_LABEL_L",nt.PANE_UUID=n=>"PANE_"+n,nt.PANE_UUID_Y_AXIS=(n,t=0)=>"PANE_"+n+"_Y_AXIS_"+t,nt.PANE_UUID_RESIZER=n=>"PANE_"+n+"_RESIZER",nt.ALL_PANES="ALL_PANES",nt.CHART_WITH_Y_AXIS="CHART_WITH_Y_AXIS",nt.EVENTS="EVENTS",nt.CHART=nt.PANE_UUID($),nt.Y_AXIS=nt.PANE_UUID_Y_AXIS($);let M=nt;const ji={x:0,y:0,pageX:0,pageY:0,width:0,height:0},Yi=20,Ni=35,Ks=15,Xi=1.5,Wi=Ot()?8*Xi:8,Oe=Ot()?5:0,Sc=1e-6;class qs{constructor(t,e,s,i,r){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new F,this.paneMovedSubject=new F,this.paneVisibilityChangedSubject=new F,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new F,this.barResizerChangedSubject=new F,this._graphsHeightRatio={[$]:1},this.graphsHeightRatioChangedSubject=new F,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new mc(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);zs(this.panesOrder,s,e)}this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}}overrideChartHeightRatios(t){const e=Wt(Wt({},this.graphsHeightRatio),t),s=Object.values(e).reduce((i,r)=>i+r,0);Math.abs(s-1)<Sc?(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&&(zs(this.panesOrder,e,e-1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}movePaneDown(t){const e=this.panesOrder.indexOf(t);e!==-1&&(zs(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}reorderPanes(t){this.panesOrder=gi(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}hidePaneBounds(t){this.graphsHeightRatio[t]=0,this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}showPaneBounds(t){if(t===$){const[e]=Vi(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){Zl(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[M.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[M.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[M.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,s=this.config.components.paneResizer.height,i=this.getBounds(M.CANVAS);i.x=0,i.y=0,i.width=t,i.height=e;const r=this.yAxisWidths,o=this.getNavMapBounds(i),a=this.getXAxisBounds(o,i),l=e-a.height-o.height,c=r.left.reduce((B,R)=>B+R,0),h=r.right.reduce((B,R)=>B+R,0),d=0,u=i.width-h,f=d+c,p=0,m=i.width-c-h;let _=p;const S=this.panesOrder.findIndex(B=>this.graphsHeightRatio[B]>0);this.panesOrder.forEach((B,R)=>{var k;const z=this.graphsHeightRatio[this.panesOrder[R]],X=M.PANE_UUID_RESIZER(B),G=M.PANE_UUID(B),Z=this.config.components.paneResizer.visible&&R>S&&z>0;Z?ve(this.bounds,X,0,_,i.width,s,this.canvasOnPageLocation):ve(this.bounds,X,0,0,0,0,this.canvasOnPageLocation);const U=_+(Z?s:0),Q=ve(this.bounds,G,f,U,m,l*z-(Z?s:0),this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const J=this.yAxisBoundsContainer.extentsOrder.get(B);if(J===void 0)return;const tt=l*z-(Z?s:0);let et=f-((k=r.left[0])!=null?k:0),st=u;J.left.forEach((ot,at)=>{var xt;ve(this.bounds,M.PANE_UUID_Y_AXIS(B,ot),et,U,r.left[at],tt,this.canvasOnPageLocation),et-=(xt=r.left[at+1])!=null?xt:0}),J.right.forEach((ot,at)=>{ve(this.bounds,M.PANE_UUID_Y_AXIS(B,ot),st,U,r.right[at],tt,this.canvasOnPageLocation),st+=r.right[at]})}else ve(this.bounds,M.PANE_UUID_Y_AXIS(B),0,0,0,0,this.canvasOnPageLocation);_=Q.y+Q.height});const A=this.getBounds(M.ALL_PANES);A.x=f,A.y=p,A.width=m,A.height=_;const E=this.getBounds(M.CHART_WITH_Y_AXIS),j=this.getBounds(M.CHART);this.getEventsBounds(j),this.copyBounds(j,E),E.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=ki(Wt({},this.canvasOnPageLocation),{x:t.x,y:t.y,width:t.width,height:t.height})}updateAllBoundsPageCoordinates(){for(const t of Object.keys(this.bounds)){const e=this.bounds[t];e.pageX=e.x+this.canvasOnPageLocation.x,e.pageY=e.y+this.canvasOnPageLocation.y}}getEventsBounds(t){const e=this.getBounds(M.EVENTS);return this.config.components.events.visible?(e.x=0,e.y=t.y+t.height-this.config.components.events.height,e.width=t.width,e.height=this.config.components.events.height):this.applyDefaultBounds(e),e}getNavMapBounds(t){const e=this.getBounds(M.N_MAP);return this.config.components.navigationMap.visible?(e.x=0,e.y=t.height-Ni,e.width=t.width,e.height=Ni):this.applyDefaultBounds(e),e}getXAxisBounds(t,e){const s=this.getBounds(M.X_AXIS),i=this.yAxisWidths.left.length+this.yAxisWidths.right.length===1,r=i?0:this.yAxisWidths.left.reduce((a,l)=>a+=l,0),o=i?0:this.yAxisWidths.right.reduce((a,l)=>a+=l,0);if(this.config.components.xAxis.visible){const a=this.getXAxisHeight();s.x=r,s.y=e.height-a-t.height,s.width=e.width-o,s.height=a}else this.applyDefaultBounds(s);return s}getXAxisHeight(){var t,e;if(!this.xAxisHeight){const s=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily,i=Xt(s,this.canvasModel.ctx);this.xAxisHeight=i+((t=this.config.components.xAxis.padding.top)!=null?t:0)+((e=this.config.components.xAxis.padding.bottom)!=null?e:0)+Oe}return this.xAxisHeight}setYAxisWidths(t){(!mi(this.yAxisWidths.left,t.left)||!mi(this.yAxisWidths.right,t.right))&&(this.yAxisWidths=t,this.recalculateBounds())}setXAxisHeight(t){t!==this.xAxisHeight&&(this.xAxisHeight=t,this.recalculateBounds())}setPanesOrder(t){this.panesOrder=t,this.recalculateBounds()}recalculatePanesHeightRatios(){this.calculateGraphsHeightRatios(),this.recalculateBounds()}calculateGraphsHeightRatios(){let t=this.graphsHeightRatio[$];const e=[];e.push(...this.panesOrder.filter(p=>p!==$));const s=e.map(p=>this.graphsHeightRatio[p]===void 0?void 0:this.graphsHeightRatio[p]),i=s.filter(p=>p!==0),r=i.length,o=i.filter(p=>p!==void 0).length,a=s.filter(p=>p===void 0).length,l=a>0;let c=0,h=0,d=1,u=0;if(l&&([d,u]=Vi(r)),(!this.graphsHeightRatio[$]||this.graphsHeightRatio[$]===0)&&(t=0),this.graphsHeightRatio[$]&&this.graphsHeightRatio[$]!==0)if(l)t=1*d;else{const p=Object.values(this.graphsHeightRatio).reduce((m,_)=>_+=m);p<1&&this.graphsHeightRatio[$]!==0&&(t+=1-p)}o===0&&(t=1-u*a),h=1-t-u*a,i.forEach(p=>{p&&(h-=p*d)}),c=h/(r||1);const f=s.map(p=>p===0?p:p?p*d+c:u+c);this._graphsHeightRatio={},this.graphsHeightRatio[$]=t,f.forEach((p,m)=>{const _=e[m];this.graphsHeightRatio[_]=p})}recalculateNavigationMapElementBounds(){var t,e,s,i;if(!this.config.components.navigationMap.visible)return;const r=this.getBounds(M.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=Ot()?a*Xi:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=tt=>ec(this.canvasModel.ctx,tt,this.formatterFactory,this.config)[0],f=mt((i=(s=this.mainCandleSeries)==null?void 0:s.getSeriesInViewport())!=null?i:[]),p=d&&f.length?u(f[0].candle.timestamp):0,m=d&&f.length?u(f[f.length-1].candle.timestamp):0,_=Math.max(p,m);if(d){const tt=this.getBounds(M.N_MAP_LABEL_L);tt.x=r.x,tt.y=r.y,tt.width=_,tt.height=r.height;const et=this.getBounds(M.N_MAP_LABEL_R);et.x=r.x+r.width-_,et.y=r.y,et.width=_,et.height=r.height}const S=this.getBounds(M.N_MAP_BTN_L);S.x=r.x+_,S.y=r.y,S.width=Ks,S.height=r.height;const A=this.getBounds(M.N_MAP_BTN_R);A.x=r.x+r.width-Ks-_,A.y=r.y,A.width=Ks,A.height=r.height;const E=S.x+S.width,j=A.x-E,B=E+j,R=this.config.components.navigationMap.minSliderWindowWidth,k=c!=null?c:Wi,z=l!=null?l:r.height,X=k+R,G=this.getBounds(M.N_MAP_KNOT_L);G.x=E+j*this.leftRatio,G.x=Math.min(G.x,B-X),G.y=h,G.width=k,G.height=z;const Z=this.getBounds(M.N_MAP_KNOT_R);Z.x=E+j*this.rightRatio-Wi,Z.x=Math.max(Z.x,E+X),Z.y=h,Z.width=k,Z.height=z;const U=X-(Z.x-G.x);U>0&&(G.x-=U);const Q=this.getBounds(M.N_MAP_SLIDER_WINDOW);Q.x=G.x+G.width,Q.y=r.y,Q.width=Z.x-Q.x,Q.height=r.height;const J=this.getBounds(M.N_MAP_CHART);J.x=E,J.y=r.y,J.width=j,J.height=r.height}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){let e=this.bounds[t];return e===void 0&&(e=this.copyOf(ji),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>ki(Wt({},t),{[e]:this.bounds[M.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=rs){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},rs),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-s&&o<l.pageX+l.width+s&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-s&&o<l.x+l.width+s&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=rs){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},rs),e);return r?(o,a)=>o>t.pageX-s&&o<t.pageX+t.width+s&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-s&&o<t.x+t.width+s&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(M.CANVAS);return t.width>0&&t.height>0}isAllBoundsAvailable(){return Object.values(this.bounds).every(t=>t.width>=0&&t.height>=0)}resizePaneVertically(t,e){const s=this.panesOrder.indexOf(t),i=this.getBounds(M.PANE_UUID_RESIZER(t));this.doResizePaneVertically(s,i.y-e),this.barResizerChangedSubject.next()}doResizePaneVertically(t,e){let s=t-1;const i=this.panesOrder[s];if(this._graphsHeightRatio[i]<=0)for(let d=0;d<t;d++)this._graphsHeightRatio[this.panesOrder[d]]>0&&(s=d);const r=this.getBounds(M.ALL_PANES).height,o=Yi,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ft(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(ht(s=>this.copyOf(s)),gt((s,i)=>this.sameBounds(s,i)))}observeAnyBoundsChanged(){return this.boundsChangedSubject.asObservable()}copyOf(t){return Wt({},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(ji,t)}setMainCandleSeries(t){this.mainCandleSeries=t}getEffectiveYAxisWidth(){return this.getBounds(M.PANE_UUID_Y_AXIS($)).width}getEffectiveChartWidth(){return this.getBounds(M.PANE_UUID($)).width}getEffectiveChartHeight(){return this.getBounds(M.PANE_UUID($)).height}}const xc={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},Vi=n=>{var t;const e=(t=xc[n])!=null?t:.4,s=(1-e)/n;return[e,s]},lv=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,_c=(n,t)=>n>t.y&&n<t.y+t.height,ve=(n,t,e,s,i,r,o)=>{const a=n[t];if(a)return a.x=e,a.y=s,a.pageX=e+o.x,a.pageY=s+o.y,a.width=i,a.height=r,a;const l={x:e,y:s,pageX:e+o.x,pageY:s+o.y,width:i,height:r};return n[t]=l,l},zi=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),rs={extensionX:0,extensionY:0,wholePage:!1},Ui=(n,t)=>n.width===t.width&&n.height===t.height;var Pc=(function(n){V(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})(ge),os={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=os.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,ct([n,t],H(e))):setInterval.apply(void 0,ct([n,t],H(e)))},clearInterval:function(n){var t=os.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Gi=(function(n){V(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i.pending=!1,i}return t.prototype.schedule=function(e,s){var i;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,s)),this.pending=!0,this.delay=s,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,s),this},t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),os.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,s,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return s;s!=null&&os.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,s);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var i=!1,r;try{this.work(e)}catch(o){i=!0,r=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ze(r,this),s!=null&&(this.id=this.recycleAsyncId(i,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(Pc),Be={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=Be.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new ge(function(){return e==null?void 0:e(i)})},requestAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Be.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,ct([],H(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Be.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,ct([],H(n)))},delegate:void 0},Tc=(function(n){V(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i}return t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),i!==null&&i>0?n.prototype.requestAsyncId.call(this,e,s,i):(e.actions.push(this),e._scheduled||(e._scheduled=Be.requestAnimationFrame(function(){return e.flush(void 0)})))},t.prototype.recycleAsyncId=function(e,s,i){var r;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return n.prototype.recycleAsyncId.call(this,e,s,i);var o=e.actions;s!=null&&s===e._scheduled&&((r=o[o.length-1])===null||r===void 0?void 0:r.id)!==s&&(Be.cancelAnimationFrame(s),e._scheduled=void 0)},t})(Gi),Js={now:function(){return(Js.delegate||Date).now()},delegate:void 0},Zi=(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=Js.now,n})(),$i=(function(n){V(t,n);function t(e,s){s===void 0&&(s=Zi.now);var i=n.call(this,e,s)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var s=this.actions;if(this._active){s.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=s.shift());if(this._active=!1,i){for(;e=s.shift();)e.unsubscribe();throw i}},t})(Zi),Mc=(function(n){V(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.flush=function(e){this._active=!0;var s;e?s=e.id:(s=this._scheduled,this._scheduled=void 0);var i=this.actions,r;e=e||i.shift();do if(r=e.execute(e.state,e.delay))break;while((e=i[0])&&e.id===s&&i.shift());if(this._active=!1,r){for(;(e=i[0])&&e.id===s&&i.shift();)e.unsubscribe();throw r}},t})($i),Bt=new Mc(Tc),cv=null,as=new $i(Gi),Ac=as;function Ec(n,t){return N(function(e,s){var i=t!=null?t:{},r=i.leading,o=r===void 0?!0:r,a=i.trailing,l=a===void 0?!1:a,c=!1,h=null,d=null,u=!1,f=function(){d==null||d.unsubscribe(),d=null,l&&(_(),u&&s.complete())},p=function(){d=null,u&&s.complete()},m=function(S){return d=Lt(n(S)).subscribe(Ct(s,f,p))},_=function(){if(c){c=!1;var S=h;h=null,s.next(S),!u&&m(S)}};e.subscribe(Ct(s,function(S){c=!0,h=S,!(d&&!d.closed)&&(o?_():m(S))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function Ic(n){return n instanceof Date&&!isNaN(n)}function Dc(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ac);var s=-1;return t!=null&&(Jn(t)?e=t:s=t),new pt(function(i){var r=Ic(n)?+n-e.now():n;r<0&&(r=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=s?this.schedule(void 0,s):i.complete())},r)})}function Et(n,t,e){t===void 0&&(t=as);var s=Dc(n,t);return Ec(function(){return s},e)}class W{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 Lc extends W{constructor(t,e,s,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new F}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(Et(100,Bt,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(t,e,s,i=0){const r=qs.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:s,hitTest:r}):this.normalLayer.set(t,{cursor:s,hitTest:r})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(gt())}observeCursorType(t,e,s){const i=s?this.canvasBoundsContainer.getBoundsHitTest(t,{extensionY:s}):this.canvasBoundsContainer.getBoundsHitTest(t);s?this.extensionLayer.set(t,{cursor:e,hitTest:i}):this.normalLayer.set(t,{cursor:e,hitTest:i})}updateCursor(t){this.element.style.cursor!==t&&(this.element.style.cursor=t,this.cursorChangedSubject.next(t))}}const Oc=n=>{const t=n.canvasArea!==null,e=n.snapshotCanvas!==null,s=n.backgroundCanvas!==null,i=n.mainCanvas!==null,r=n.yAxisLabelsCanvas!==null,o=n.crossToolCanvas!==null,a=n.hitTestCanvas!==null,l=n.chartResizer!==null,c=n.chartContainer!==null,h=n.dynamicObjectsCanvas!==null;return t&&e&&s&&i&&r&&o&&a&&l&&c&&h},Qs=(n=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
|
|
10
10
|
<div data-element="chartContainer" style="position: absolute; height: 100%; width: 100%;" class="chart chartArea--graph">
|
|
11
11
|
<div data-element="canvasArea" style="position: relative; height: 100%; width: 100%; touch-action: manipulation;">
|
|
12
12
|
<canvas data-element="snapshotCanvas"></canvas>
|
|
@@ -21,4 +21,4 @@ ${n?` <p style="position: absolute; visibility: hidden;">If you have any sugge
|
|
|
21
21
|
`:""} </div>
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
|
-
`);(Object.getOwnPropertyDescriptor(Qs,"name")||{}).writable||Object.defineProperty(Qs,"name",{value:"default",configurable:!0});function Lc(n){const t=document.createElement("template");return t.innerHTML=Qs(n.devexpertsPromoLink),t}function Oc(n){const t={},e=Array.from(n.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(s=>{var i;t[(i=s.getAttribute("data-element"))!=null?i:""]=s}),Dc(t))return t;throw new Error("Some chart elements are missing")}function Bc(n){if(n.length>1){const t=n.reduce((i,r,o)=>{if(o!==n.length-1){const a=n[o+1].timestamp-r.timestamp;i[a]?i[a]++:i[a]=1}return i},{});let e=0,s;for(const i of Object.keys(t)){const r=parseInt(i,10),o=t[r];o>e&&r>0&&(e=o,s=r)}if(s)return s}}const Zi=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Rc=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Zi(!!c),u=d(n),f=d((r=(i=ie(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=St(e))==null?void 0:o.timestamp)!=null?a:0);return u>p?h?{index:e.length-1+Math.ceil((u-p)/s),exact:!0}:{index:e.length-1,exact:!0}:u<f?h?{index:rt((u-f)/s),exact:!0}:{index:-1,exact:!0}:Nt(e,u,m=>d(m.timestamp))},Fc=(n,t={},e,s=1e3)=>{var i,r,o,a,l,c;const{extrapolate:h,isDaysPeriod:d}=t,u=!!h,f=Zi(!!d),p=f(n);if(!e.length)return{index:-1,exact:!0};const m=f((r=(i=ie(e))==null?void 0:i.timestamp)!=null?r:0),_=f((a=(o=St(e))==null?void 0:o.timestamp)!=null?a:0);if(p>_)return u?{index:e.length-1+Math.ceil((p-_)/s),exact:!0}:{index:e.length-1,exact:!0};if(p<=m){const B=f((c=(l=e[0])==null?void 0:l.timestamp)!=null?c:m)-s;return p<=B?u?{index:rt((p-m)/s),exact:!0}:{index:-1,exact:!0}:{index:0,exact:p===m}}let S=0,A=e.length;for(;S<A;){const Y=rt((S+A)/2);f(e[Y].timestamp)<p?S=Y+1:A=Y}const E=S;return{index:E>=e.length?e.length-1:E,exact:E<e.length&&f(e[E].timestamp)===p}},be=(n,t={},e,s=1e3)=>{var i;return((i=t.candleTimestampAnchor)!=null?i:"open")==="close"?Fc(n,t,e,s):Rc(n,t,e,s)},Hc=(n,t,e,s)=>{var i,r;return s==="close"?(r=(i=n[t-1])==null?void 0:i.timestamp)!=null?r:n[t].timestamp-e:n[t].timestamp},cv=(n,t,e)=>e==="close"?n.timestamp:n.timestamp+t,hv=n=>{const t=n[0],e=n[n.length-1];return n.length>0&&[t,e].some(s=>s!==void 0&&s.impVolatility!==null&&s.impVolatility!==void 0&&!isNaN(s.impVolatility))},$i={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Ki={paintConfig:[$i],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var kc=Object.defineProperty,qi=Object.getOwnPropertySymbols,jc=Object.prototype.hasOwnProperty,Yc=Object.prototype.propertyIsEnumerable,Ji=(n,t,e)=>t in n?kc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Nc=(n,t)=>{for(var e in t||(t={}))jc.call(t,e)&&Ji(n,e,t[e]);if(qi)for(var e of qi(t))Yc.call(t,e)&&Ji(n,e,t[e]);return n};class Xc{constructor(t,e,s,i){this.series=t,this.config=e,this.yAxisBoundsProvider=s,this.axisState=i}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,s=this.yAxisBoundsProvider(),i=this.config.labelMode,r=this.config.labelAppearanceType,o=e();if(o===void 0)return[];const a=this.series.view.toY(o.close);if(!isFinite(a))return[];const l=this.series.valueFormatter(o.close),c=this.getLabelDrawConfig();return[{labels:[Nc({y:a,description:this.series.name,mode:i,labelType:r,labelText:l},c)],axisState:this.axisState,bounds:s}]}getLabelDrawConfig(){var t;const e=this.series.config,i=((t=e.paintConfig[0])!=null?t:$i).color;return{textColor:re(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function Wc(n,t){if(n.filter(a=>a!==null).length<=1)return n.map(a=>a.y);const e=t-2,s=n.map((a,l)=>zc(a,l,e)).filter(ui).sort(Vc),i=new Array(s.length),r=s.reduce((a,l)=>Math.min(a,l.labelWeight),Number.POSITIVE_INFINITY),o=s.findIndex(a=>a.labelWeight===r);for(let a=o;a>=0;a--){const l=s[a],c=s[a-1];if(l){if(c&&c.bottom>l.top){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.bottom=l.top-h,c.top=c.bottom-t}i[l.actualIndex]=(l.top+l.bottom)/2}}for(let a=o;a<s.length;a++){const l=s[a],c=s[a+1];if(!l)break;if(c&&c.top<l.bottom){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.top=l.bottom+h,c.bottom=c.top+t}i[l.actualIndex]=(l.top+l.bottom)/2}return i}const zc=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,Vc=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var Uc=Object.defineProperty,Gc=Object.defineProperties,Zc=Object.getOwnPropertyDescriptors,Qi=Object.getOwnPropertySymbols,$c=Object.prototype.hasOwnProperty,Kc=Object.prototype.propertyIsEnumerable,tr=(n,t,e)=>t in n?Uc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,er=(n,t)=>{for(var e in t||(t={}))$c.call(t,e)&&tr(n,e,t[e]);if(Qi)for(var e of Qi(t))Kc.call(t,e)&&tr(n,e,t[e]);return n},sr=(n,t)=>Gc(n,Zc(t));const ae={MAIN:"MAIN"};class qc extends W{constructor(t,e,s,i,r,o,a,l){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.chartResizeHandler=l,this.orderedLabels=[],this.customLabels={},this._labelsProviders={},this.labelsPositionRecalculatedSubject=new F,this.animFrameId=`anim_cache_${_t()}`,this.initModel()}get labelsProviders(){return this._labelsProviders}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed,wt(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.paneUUID)),this.chartResizeHandler.canvasResized).pipe(Et(50,Bt,{trailing:!0,leading:!0}))).subscribe(()=>{this.updateLabels()}))}initModel(){this.initLabelsGroups(),this.recalculateLabels(),this.canvasModel.fireDraw()}initLabelsGroups(){for(const t of Object.keys(this.labelsProviders))this.createGroup(t),Object.entries(this.labelsProviders[t]).forEach(([e,s])=>{this.addToGroup(s,t,e)})}updateLabels(t=!1){this.recalculateLabels(),Me(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const s=this.state.fontSize+((t=this.state.labelBoxMargin.top)!=null?t:0)+((e=this.state.labelBoxMargin.bottom)!=null?e:0);for(const i of Object.values(this.labelsProviders)){const r=vt(Object.values(i).map(l=>l.getUnorderedLabels())),o=vt(r.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),a=Wc(o,s);r.forEach(l=>{const c=a.splice(0,l.labels.length);this.orderedLabels.push(this.updateLabelsCoordinates(l,c))})}this.orderedLabels=this.orderedLabels.reverse()}createGroup(t){!this.labelsProviders[t]&&(this.labelsProviders[t]={})}addToGroup(t,e,s){this.labelsProviders[e]&&(Object.values(this.labelsProviders[e]).includes(t)||(this.labelsProviders[e][s]=t))}updateLabelsCoordinates(t,e){return sr(er({},t),{labels:t.labels.map((s,i)=>{var r;return sr(er({},s),{lineY:(r=s.lineY)!=null?r:s.y,y:e[i]})})})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[s]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const i=(s=this.labelsProviders[t])!=null?s:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}var Jc;let Ht=window.devicePixelRatio,os=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const tn=()=>{os.removeEventListener("change",tn),Ht=window.devicePixelRatio,os=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),os.addEventListener("change",tn)};os.addEventListener("change",tn);const Qc=()=>Ht,dv=n=>Jc(Ht*n)/Ht,It=n=>rt(Ht*n)/Ht,en=n=>Pl(Ht*n)/Ht,le=n=>JSON.parse(JSON.stringify(n));function sn(n){return Object.entries(n)}const nr=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function ir(n){return Object.keys(n)}function rr(n,t){if(Object.is(n,t))return!0;if(typeof n!="object"||n===null||typeof t!="object"||t===null)return!1;const e=Object.keys(n),s=Object.keys(t);if(e.length!==s.length)return!1;for(let i=0,r=e.length;i<r;i++)if(!hasOwnProperty.call(t,e[i])||!rr(n[e[i]],t[e[i]]))return!1;return!0}const th=n=>Object.keys(n).length===0&&n.constructor===Object;function or(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new F}:t,s=n.resetOnError,i=s===void 0?!0:s,r=n.resetOnComplete,o=r===void 0?!0:r,a=n.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var h,d,u,f=0,p=!1,m=!1,_=function(){d==null||d.unsubscribe(),d=void 0},S=function(){_(),h=u=void 0,p=m=!1},A=function(){var E=h;S(),E==null||E.unsubscribe()};return N(function(E,Y){f++,!m&&!p&&_();var B=u=u!=null?u:e();Y.add(function(){f--,f===0&&!m&&!p&&(d=nn(A,l))}),B.subscribe(Y),!h&&f>0&&(h=new Te({next:function(R){return B.next(R)},error:function(R){m=!0,_(),d=nn(S,i,R),B.error(R)},complete:function(){p=!0,_(),d=nn(S,o),B.complete()}}),Lt(E).subscribe(h))})(c)}}function nn(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t===!0){n();return}if(t!==!1){var i=new Te({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,at([],H(e)))).subscribe(i)}}const as=(n,t)=>n/t,bt=(n,t)=>n/t,kt=(n,t)=>n*t,ar=(n,t)=>(n-t)*100/t,lr=(n,t)=>n*t/100+t,cr=n=>Math.log2(n),rn=n=>Math.pow(2,n);class eh extends W{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 F,this.xChanged=this.changed.pipe(lt(()=>({start:this.xStart,end:this.xEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),or()),this.yChanged=this.changed.pipe(lt(()=>({start:this.yStart,end:this.yEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),or()),this.initialViewportValidSubject=new ft(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+bt(t-this.xStart,this.zoomX)}xPixels(t){return bt(t,this.zoomX)}toY(t){const e=this.getBounds();return this.inverseY?e.y+bt(t-this.yStart,this.zoomY):e.y+e.height-bt(t-this.yStart,this.zoomY)}yPixels(t){return bt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return kt(e+bt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),s=t-e.y;return this.inverseY?kt(s+bt(this.yStart,this.zoomY),this.zoomY):kt(e.height-s+bt(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 as(e-t,this.getBounds().width)}calculateZoomY(t,e){return as(e-t,this.getBounds().height)}recalculateZoom(t=!0){this.recalculateZoomX(),this.recalculateZoomY(),t&&this.fireChanged()}setXScale(t,e,s=!0){this.xStart=t,this.xEnd=e,this.recalculateZoomX(),s&&this.fireChanged()}setYScale(t,e,s=!0){this.yStart=t,this.yEnd=e,this.recalculateZoomY(),s&&this.fireChanged()}export(){return{xStart:this.xStart,xEnd:this.xEnd,yStart:this.yStart,yEnd:this.yEnd,zoomX:this.zoomX,zoomY:this.zoomY,inverseY:this.inverseY}}apply(t){this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.inverseY=t.inverseY,this.fireChanged()}fireChanged(){this.changed.next()}get xStart(){return this._xStart}set xStart(t){this._xStart=t}get xEnd(){return this._xEnd}set xEnd(t){this._xEnd=t}get yStart(){return this._yStart}set yStart(t){this._yStart=t}get yEnd(){return this._yEnd}set yEnd(t){this._yEnd=t}get zoomX(){return this._zoomX}set zoomX(t){this._zoomX=t}get zoomY(){return this._zoomY}set zoomY(t){this._zoomY=t}get inverseY(){return this._inverseY}set inverseY(t){this._inverseY=t}isViewportValid(t=!0){const e=t===!1||this.zoomX>0&&this.zoomY>0;return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)&&e}}const sh=(n,t)=>!ir(n).some(e=>n[e]!==t[e]);class nh{constructor(t,e){this.scale=t,this.dataSeries=e,this.prevAnimationId=""}getBaselineForPercent(t){const e=this.scale.currentAnimation;let s;if(e!=null&&e.animationInProgress){e.id!==this.prevAnimationId&&(this.initialBaseline=void 0,this.targetBaseline=void 0,this.prevAnimationId=e.id);const i=e.easingFn(e.getProgress());this.initialBaseline===void 0&&(this.initialBaseline=t(Nt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(Nt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else s=t();return s}}class hr{constructor(t,e,s,i){this.dataSeries=t,this.scale=e,this.getAxisType=s,this.getBaseline=i,this.toY=r=>this.scale.toY(this.toAxisUnits(r)),this.toX=r=>this.scale.toX(r),this.xPixels=r=>this.scale.xPixels(r),this.yPixels=r=>this.scale.yPixels(r),this.percentAnimationHandler=new nh(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return ar(t,s);case"logarithmic":return t<=0?t:cr(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 lr(t,this.getBaseline());case"logarithmic":return rn(t);case"regular":return t}}}const zt=16;var ih=Object.defineProperty,rh=Object.defineProperties,oh=Object.getOwnPropertyDescriptors,dr=Object.getOwnPropertySymbols,ah=Object.prototype.hasOwnProperty,lh=Object.prototype.propertyIsEnumerable,ur=(n,t,e)=>t in n?ih(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fr=(n,t)=>{for(var e in t||(t={}))ah.call(t,e)&&ur(n,e,t[e]);if(dr)for(var e of dr(t))lh.call(t,e)&&ur(n,e,t[e]);return n},ch=(n,t)=>rh(n,oh(t));class Re{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return It(t.toY(this.close))}x(t){return t.toX(this.centerUnit)}clone(){return new Re(this.centerUnit,this.close)}}class pr extends W{constructor(t,e,s,i,r){var o;super(),this.extentComponent=t,this.id=e,this.htId=s,this.parentId=i,this.name="",this.highlighted=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=l=>{var c;return(c=this.config.paintConfig[l])!=null?c:this.config.paintConfig[0]},this.getBaseline=(l=this.dataIdxStart)=>{var c,h,d;return(c=this.visualPoints[l])!=null&&c.close&&((h=this.visualPoints[l])==null?void 0:h.close)>=0?(d=this.visualPoints[l])==null?void 0:d.close:1},this.getTextForPoint=l=>`${l.close}`,this.getLastVisualSeriesPoint=()=>{const l=this.visualPoints;if(l.length!==0)return l[this.dataIdxEnd]},this.getLastDataSeriesPoint=()=>{const l=this.visualPoints;return St(l)};const a=r!=null?r:le(Ki);this.config=At(a,Ki),this.scale=t.scale,this.view=new hr(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Xc(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=dh(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=gi(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=gi(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.pipe(Et(zt,Bt,{trailing:!0,leading:!0}),lt(()=>this.calculateDataViewportIndexes(this.scale.xStart,this.scale.xEnd)),mt((t,e)=>t.dataIdxStart===e.dataIdxStart&&t.dataIdxEnd===e.dataIdxEnd)).subscribe(()=>{this.recalculateDataViewportIndexes(this.scale.xStart,this.scale.xEnd)})),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>{this.recalculateVisualPoints(),this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;const s=fr({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new hr(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider.yAxisBoundsProvider=t.getYAxisBounds,this.yAxisLabelProvider.axisState=(e=t.yAxis)==null?void 0:e.state;const i=s.yAxis.model.fancyLabelsModel.labelsProviders[ae.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[ae.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(ae.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(ae.MAIN,r))}this.deactivate(),this.activate(),t.addDataSeries(this)}toVisualPoints(t){return t.map((e,s)=>({centerUnit:s,close:e.close}))}setType(t){this.config.type=t,this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}recalculateVisualPoints(){this.visualPoints=this._toVisualPoints(this.dataPoints2D)}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i}calculateDataViewportIndexes(t,e){const s=Nt(this.visualPoints,t,r=>r.centerUnit).index,i=Nt(this.visualPoints,e,r=>r.centerUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}valueFormatter(t){return this.extentComponent.formatters.regular(t)}getSeriesInViewport(t,e){let s=this.dataIdxStart,i=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const r=this.calculateDataViewportIndexes(t,e);s=r.dataIdxStart,i=r.dataIdxEnd}return Wl(this.visualPoints2D,s,i)}}const hh=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},dh=n=>({isHighLowActive:()=>n.config.highLowActive&&n.config.visible,calculateHighLow:t=>{const e=hh(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return ch(fr({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),uh=n=>{const e=r=>Math.ceil(Math.log(Math.abs(r))*Math.LOG10E),i=((r,o=5)=>Math.max(0,o-Math.max(0,e(r))))(n);return pt.makeDecimal(n,i)};class ls extends Re{constructor(t,e,s,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.endUnit=t+e/2,this.width=e,this.open=s,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return Math.max(Math.abs(t.toY(this.open)-t.toY(this.close)),1)}candleHeight(t){return Math.abs(t.toY(this.high)-t.toY(this.low))}bodyAsVLine(t){if(this.width<2)return[this.centerUnit,this.yLineStart(t),this.width,this.candleHeight(t)]}bodyRect(t){return[this.startUnit,this.yBodyStart(t),this.width,this.bodyHeight(t)]}getCandle(){return this.candle}yBodyKeyPoints(t){const e=t.toY(this.high),s=t.toY(this.low),i=t.toY(this.open),r=t.toY(this.close),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>s?[s,e]:[e,s];return[l,o,a,c]}yLineEnd(t){return Math.max(t.toY(this.high),t.toY(this.low))}yLineStart(t){return Math.min(t.toY(this.high),t.toY(this.low))}yBodyStart(t){return Math.min(t.toY(this.open),t.toY(this.close))}yBodyEnd(t){return Math.max(t.toY(this.open),t.toY(this.close))}xCenter(t){return this.x(t)}xStart(t){return t.toX(this.startUnit)}}const Ce=60,Fe=(n,t,e=Ce)=>{const s=gr(n,t,e);return{id:Mi(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},fh=(n,t,e=Ce)=>({close:NaN,timestamp:gr(n,t,e)});function gr(n,t,e=Ce){var s,i;const r=Ee(t);if(n.length===0)return 0;const o=St(n);if(r>=n.length&&o)return mr(o,n.length-1,r,e);const a=ie(n);return r<0&&a?mr(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const mr=(n,t,e,s=Ce)=>n.timestamp+(e-(t!=null?t:0))*s,on=(n,t,e,s,i=Ce)=>{const r=Fe(n,s,i);r.volume=e;let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new ls(o,e,r.open,r.close,r.lo,r.hi,es(r.open,r.close),r)},ph=(n,t,e,s,i=Ce)=>{const r=fh(n,s,i);let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new Re(o,r.close)};var gh=Object.defineProperty,mh=Object.defineProperties,vh=Object.getOwnPropertyDescriptors,vr=Object.getOwnPropertySymbols,bh=Object.prototype.hasOwnProperty,Ch=Object.prototype.propertyIsEnumerable,br=(n,t,e)=>t in n?gh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,yh=(n,t)=>{for(var e in t||(t={}))bh.call(t,e)&&br(n,e,t[e]);if(vr)for(var e of vr(t))Ch.call(t,e)&&br(n,e,t[e]);return n},wh=(n,t)=>mh(n,vh(t));class Sh{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new F,this.dataSetSubject=new F,this.dataRemovedSubject=new F,this.dataPrependSubject=new F,this.meanDataWidth=1,this.period=1,this.candleTimestampAnchor="open"}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=be(t,wh(yh({},e),{candleTimestampAnchor:this.candleTimestampAnchor}),s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=Bc(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?on(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):ph(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var xh=Object.defineProperty,Cr=Object.getOwnPropertySymbols,_h=Object.prototype.hasOwnProperty,Ph=Object.prototype.propertyIsEnumerable,yr=(n,t,e)=>t in n?xh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Th=(n,t)=>{for(var e in t||(t={}))_h.call(t,e)&&yr(n,e,t[e]);if(Cr)for(var e of Cr(t))Ph.call(t,e)&&yr(n,e,t[e]);return n};class Mh{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!rr(this.config.colors.chartAreaTheme,this.prevState)}draw(){if(this.drawPredicate()||this.isColorsChanged()){this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0+this.canvasModel.height/2,this.canvasModel.width,0+this.canvasModel.height/2);e.addColorStop(0,this.config.colors.chartAreaTheme.backgroundGradientTopColor),e.addColorStop(1,this.config.colors.chartAreaTheme.backgroundGradientBottomColor),t.fillStyle=e}else t.fillStyle=this.config.colors.chartAreaTheme.backgroundColor;t.fillRect(0,0,this.canvasModel.width,this.canvasModel.height)}this.prevState=Th({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const Ah=(n,t,e,s,i,r,o)=>{const a=Qc(),l=[e*a,s*a,i*a,r*a];let c=n.getImageData(...l);if(o!==void 0){const h=c.data[3]/255;if(h===1)for(let d=3;d<c.data.length;d+=4)c.data[d]=rt(c.data[d]*o);else for(let d=0;d<c.data.length;d++){const u=c.data[d];c.data[d]=d%4===3?rt(u*o):rt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},wr=(n,{x:t,width:e,activeCandle:s})=>new ls(t,e,n.open,n.close,n.hi,n.lo,es(n.open,n.close),n,!0,an(n,s)),Eh=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new ls(t,e,n.open,n.close,n.hi,n.lo,sc((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,an(n,s),n.close>n.open)},Sr=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new ls(t,e,n.open,n.close,n.hi,n.lo,es((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,an(n,s),n.close>n.open)},Ih=Sr,an=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},xr=()=>Zs,He=class fe{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>rt(Math.log10((i^i>>31)-(i>>31)))+1;let s=e(t);return s===1&&t<1&&(s=e(t*1e9)-9),s}static getPriceIncrement(t,e=[]){if(!this.validatePriceIncrementsOrPrecisions(e))return this.DEFAULT_INCREMENT;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;const i=1e-6;for(;s<e.length&&t>e[s]+Math.min(e[s-1],e[s+1])*i;)s+=2;return s>=e.length||t<e[s]-Math.min(e[s-1],e[s+1])*i?e[s-1]:Math.min(e[s-1],e[s+1])}static getPricePrecision(t,e){if(!this.validatePriceIncrementsOrPrecisions(e))return 0;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;for(;s<e.length&&t>e[s];)s+=2;return Math.round(e[s-1])}static roundPriceToIncrement(t,e,s){const i=fe.getPriceIncrement(s||t,e);return pt.roundToNearest(t,i)}static computePrecisions(t){const e=[...t];for(let s=0;s<t.length;s+=2)e[s]=fe.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*fe.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<fe.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*fe.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return fe.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(t){return!(t.length===0||!Array.isArray(t)||t.findIndex(e=>e!==0)===-1)}};He.DEFAULT_INCREMENT=.01,He.DEFAULT_PRECISION=2,He.RELATIVE_EPS=1e-8,He.MAXIMUM_PRECISION=10;let ye=He;const Dh=(n,t)=>{var e;const s=(e=St(t))!=null?e:1;return Math.pow(10,-s)};var Lh=Object.defineProperty,Oh=Object.defineProperties,Bh=Object.getOwnPropertyDescriptors,_r=Object.getOwnPropertySymbols,Rh=Object.prototype.hasOwnProperty,Fh=Object.prototype.propertyIsEnumerable,Pr=(n,t,e)=>t in n?Lh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Hh=(n,t)=>{for(var e in t||(t={}))Rh.call(t,e)&&Pr(n,e,t[e]);if(_r)for(var e of _r(t))Fh.call(t,e)&&Pr(n,e,t[e]);return n},kh=(n,t)=>Oh(n,Bh(t));const jh=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:n.scale.xStart,s=t?t.xEnd:n.scale.xEnd,{dataIdxStart:i,dataIdxEnd:r}=n.calculateDataViewportIndexes(e,s),o=n.visualPoints.slice(i,r+1),a=Tr(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return kh(Hh({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),Tr=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.high>t.high&&(t.high=s.high,t.highIdx=e),s.low<t.low&&(t.low=s.low,t.lowIdx=e)}return t};class Yh{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){Nh(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Nh=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=Mr(i),o=s.reduce((a,l)=>l(a),r);t.yStart=o.low,t.yEnd=o.high,t.zoomY=n.calculateZoomY(t.yStart,t.yEnd)};function Mr(n){if(n.length===0)return Xh();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 Xh=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),Ar=(n,t)=>n/t,Wh=(n,t)=>n/t,zh=(n,t)=>n*t,Er=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=Ar(e,s),r=n.yEnd-n.yStart;t.zoomY=Wh(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Vh=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=Ar(e,s),r=n.xEnd-n.xStart;t.zoomX=zh(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Uh=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},Gh=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},Ir=(n,t,e,s,i)=>{const r=(t.xEnd-t.xStart)*s,o=r*e,a=r*(1-e);return i?(t.xStart=t.xStart+o,t.xEnd=t.xEnd-a):(t.xStart=t.xStart-o,t.xEnd=t.xEnd+a),t.zoomX=n.calculateZoomX(t.xStart,t.xEnd),t},Zh=(n,t,e,s)=>Ir(n,t,1,e,s),$h=De,Kh=.9,qh=(n,t,e,s)=>{t.currentAnimation&&t.currentAnimation.animationInProgress&&t.currentAnimation.getProgress()>Kh&&(t.currentAnimation.finishAnimation(),t.currentAnimation=void 0),s&&s.doAutoYScale(e),cs(n,t,e)},cs=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:$h,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},me,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s};var Jh=Object.defineProperty,Qh=Object.defineProperties,td=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,ed=Object.prototype.hasOwnProperty,sd=Object.prototype.propertyIsEnumerable,Lr=(n,t,e)=>t in n?Jh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ce=(n,t)=>{for(var e in t||(t={}))ed.call(t,e)&&Lr(n,e,t[e]);if(Dr)for(var e of Dr(t))sd.call(t,e)&&Lr(n,e,t[e]);return n},Or=(n,t)=>Qh(n,td(t));const nd=new F,id=new F,rd=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Br extends eh{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new F,this.beforeStartAnimationSubject=new F,this.zoomReached={zoomIn:!1,zoomOut:!1},this.history=[],this.xConstraints=[],this.autoScaleZoomSubscription=null,this.autoScalePanSubscription=null,this.scalePostProcessor=(i,r)=>this.xConstraints.reduce((o,a)=>a(i,o),r),this.state=le(t.scale),this.autoScaleModel=new Yh(this),this.offsets=this.config.components.offsets,this.initAutoScaleThrottling()}doActivate(){super.doActivate(),this.scaleInversedSubject=new F,this.beforeStartAnimationSubject=new F,this.zoomReached=this.calculateZoomReached(this.export().zoomX),this.addRxSubscription(this.scaleInversedSubject.subscribe(()=>{this.fireChanged()}))}doDeactivate(){this.autoScaleZoomSubscription&&(this.autoScaleZoomSubscription.unsubscribe(),this.autoScaleZoomSubscription=null),this.autoScalePanSubscription&&(this.autoScalePanSubscription.unsubscribe(),this.autoScalePanSubscription=null),super.doDeactivate(),this.scaleInversedSubject.complete(),this.beforeStartAnimationSubject.complete()}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=ce(ce({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,s=!1,i){const r=this.config.scale.disableAnimations||s;r&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const o=this.export();Ir(this,o,t,i,e),this.zoomXTo(o,e,r)}zoomXToEnd(t,e){const s=this.config.scale.disableAnimations||this.config.components.yAxis.type==="percent";s&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const i=this.export();Zh(this,i,e,t),this.zoomXTo(i,t,s)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.currentAnimation=void 0,this.canvasAnimation.forceStopAnimation(me),this.doAutoScale())}zoomXTo(t,e,s){var i;const r=this.export(),o=this.scalePostProcessor(r,t);this.zoomReached=this.calculateZoomReached(o.zoomX,e),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&Er(r,o),this.state.auto&&this.autoScaleModel.doAutoYScale(o),s?this.apply(o):((i=this.currentAnimation)==null||i.tick(),cs(this.canvasAnimation,this,o)))}calculateZoomReached(t,e=!0){const s=this.getBounds().width,i=.001;if(s>0){const r=as(this.config.components.chart.minCandles,s),a=t!==r&&t-r<=i&&e,l=as(s/this.config.components.chart.minWidth,s),h=t-l>=i&&!e;return{zoomIn:a,zoomOut:h}}return{zoomIn:!1,zoomOut:!1}}setXScale(t,e,s=!0){var i;const r=this.export(),o=this.calculateZoomX(t,e);if(r.xStart===t&&r.xEnd===e&&r.zoomX>0)return;const a=Or(ce({},r),{zoomX:o,xStart:t,xEnd:e}),l=this.scalePostProcessor(r,a),c=l.xEnd-l.xStart<r.xEnd-r.xStart;this.zoomReached=this.calculateZoomReached(o,c),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&Er(r,l),this.state.auto&&this.autoScaleModel.doAutoYScale(l),s||this.config.scale.disableAnimations?(this.haltAnimation(),this.apply(l)):((i=this.currentAnimation)==null||i.tick(),Ie?qh(this.canvasAnimation,this,l,this.state.auto?this.autoScaleModel:void 0):cs(this.canvasAnimation,this,l)))}setXScaleWithoutYScale(t){var e;const s=this.export(),i=t.slice(Math.max(t.length-this.state.defaultViewportItems,0)),r=i[i.length-1],o=r.startUnit+r.width+this.offsets.right,a=o-this.getBounds().width*this.zoomX,l=Or(ce({},s),{xStart:a,xEnd:o}),c=this.scalePostProcessor(s,l);this.state.auto&&this.autoScaleModel.doAutoYScale(c),(e=this.currentAnimation)==null||e.tick(),cs(this.canvasAnimation,this,c)}setYScale(t,e,s=!1){const i=this.export();if(i.yStart===t&&i.yEnd===e&&i.zoomY>0)return;if(this.state.lockPriceToBarRatio&&this.initialViewportValidSubject.getValue()){this.setLockedYScale(t,e,s,i);return}super.setYScale(t,e,s);const r=this.export(),o=this.scalePostProcessor(i,r);this.state.auto&&this.autoScaleModel.doAutoYScale(o),this.apply(o)}setLockedYScale(t,e,s=!1,i){const r=e<i.yEnd;if(this.zoomReached.zoomOut&&r===!1||this.zoomReached.zoomIn&&r===!0)return;super.setYScale(t,e,s);const o=this.export(),a=this.scalePostProcessor(i,o);Vh(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=ce({},e);this.haltAnimation(),Uh(e,t);const i=this.scalePostProcessor(s,e);this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();Gh(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),sh(e,this.export())||this.apply(e)}}isViewportAnimationInProgress(){const t=this.currentAnimation;return t==null?void 0:t.animationInProgress}pushToHistory(t){this.history.push(t)}popFromHistory(){return this.history.pop()}clearHistory(){this.history=[]}isDefaultXBounds(){return this.xStart===0&&this.xEnd===0}isDefaultYBounds(){return this.yStart===0&&this.yEnd===0}isScaleReady(){return!this.isDefaultXBounds()&&!this.isDefaultYBounds()}autoScale(t=!0){this.config.components.yAxis.type==="percent"?this.state.auto=!0:this.state.auto=t,t&&(this.clearHistory(),this.doAutoScale())}setLockPriceToBarRatio(t=!1){const{type:e}=this.config.components.yAxis;if(e==="percent"||e==="logarithmic"){this.state.lockPriceToBarRatio=!1;return}this.state.lockPriceToBarRatio=t}initAutoScaleThrottling(){this.autoScaleZoomSubscription=nd.pipe(Et(zt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ce({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)}),this.autoScalePanSubscription=id.pipe(Et(zt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ce({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)})}}class od extends Br{constructor(t,e,s,i){super(e,s,i),this.delegate=t,this.config=e,this.getBounds=s}doActivate(){this.addRxSubscription(this.delegate.xChanged.subscribe(()=>this.doAutoScale(this.state.auto)))}get xStart(){return this.delegate.xStart}set xStart(t){this.delegate.xStart=t}get xEnd(){return this.delegate.xEnd}set xEnd(t){this.delegate.xEnd=t}get zoomX(){return this.delegate.zoomX}set zoomX(t){this.delegate.zoomX=t}observeXChanged(){return this.delegate.xChanged}fireChanged(){this.delegate.changed.next(),this.changed.next()}}const ad=ss().colors;class $t extends pr{constructor(t,e,s,i,r,o,a,l,c=ad){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=rd(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new F,this.meanCandleWidth=Zs,this._instrument=o,this.instrument=o,this.highLowProvider=jh(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=ye.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i,this.recalculateZippedHighLow(),this.eventBus.fireDraw()}calculateDataViewportIndexes(t,e){const s=Nt(this.visualPoints,t,r=>r.startUnit).index,i=Nt(this.visualPoints,e,r=>r.startUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}applyPriceMovement(){const t=St(this.dataPoints);t&&(this.lastPriceMovement=es(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=Tr(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd+1))}updateCurrentPrice(t){this.previousPrice=this.currentPrice||t,this.currentPrice=t,this.currentPrice!==this.previousPrice&&(this.lastPriceMovement=this.currentPrice>this.previousPrice?"up":"down")}updateCandleSeriesColors(t){this.colors=At(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var s,i;if(t.length===0)return[];const r=this.config.type,o=[];let a=e;const l=(s=this.candleWidthByChartType[r])!=null?s:xr;for(let c=0;c<t.length;c++){const h=t[c],d=t[c-1],u=l(h),f=a+u/2,p=(i=this.candlesTransformersByChartType[r])!=null?i:wr;o.push(p(h,{x:f,width:u,prevCandle:d,activeCandle:this.activeCandle},o[c-1])),a+=u}return o}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,s)=>e+s.width,0)/t.length:this.meanCandleWidth=Zs}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 uv(n){switch(n){case"line":case"area":return!0;default:return!1}}class ld{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=!!i.color;if(s instanceof $t){const a=vt(e);if(a.length===0)return;i.color?t.strokeStyle=i.color:t.strokeStyle=s.colors.areaTheme.lineColor,o?t.lineWidth=(r=i.hoverWidth)!=null?r:this.config.selectedWidth*3:s.highlighted?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const l=s.extentComponent.getBounds(),c=a[0],h=s.view.toX(c.centerUnit);for(let d=0;d<a.length;d++){const u=a[d-1],f=a[d+1],p=a[d],m=s.view.toX(p.centerUnit),_=s.view.toY(p.close),S=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(rt(m),S),t.moveTo(rt(m),_);else if(f===void 0){t.lineTo(rt(m),_),t.stroke(),t.lineTo(rt(m),S),t.lineTo(rt(h),S),t.closePath();let A;i.color?t.fillStyle=i.color:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(A=t.createLinearGradient(0,0,0,l.height),A.addColorStop(0,s.colors.areaTheme.startColor),A.addColorStop(1,s.colors.areaTheme.stopColor),A):"",o||t.fill()}else t.lineTo(m,_)}}}}function Rr(n,t,e,s,i,r=4,o=!0,a=!1){n.save(),n.beginPath(),n.moveTo(t+r,e),n.lineTo(t+s-r,e),n.quadraticCurveTo(t+s,e,t+s,e+r),n.lineTo(t+s,e+i-r),n.quadraticCurveTo(t+s,e+i,t+s-r,e+i),n.lineTo(t+r,e+i),n.quadraticCurveTo(t,e+i,t,e+i-r),n.lineTo(t,e+r),n.quadraticCurveTo(t,e,t+r,e),n.closePath(),o&&n.fill(),a&&n.stroke(),n.restore()}function cd(n,t,e,s,i,r,o,a,l,c,h=4,d=!0,u=!1){const f=c==="right"?a:-a,p=c==="right"?h:-h,m=h;n.save(),n.beginPath(),l?n.moveTo(r+p,o):n.moveTo(r,o),l?(n.lineTo(r+f-p,o),n.quadraticCurveTo(r+f,o,r+f,o-m),n.lineTo(r+f,e+m),n.quadraticCurveTo(r+f,e,r+f-p,e),n.lineTo(t+p,e)):(n.lineTo(r+f,o),n.lineTo(r+f,e),n.lineTo(t,e)),l?(n.quadraticCurveTo(t,e,t-p/3,e+m/3),n.lineTo(s+p/3,i-m/3),n.quadraticCurveTo(s,i,s+p/3,i+m/3),n.lineTo(r-p/3,o-m/3),n.quadraticCurveTo(r,o,r+p/3,o)):(n.lineTo(s,i),n.lineTo(r,o)),n.closePath(),d&&n.fill(),u&&n.stroke(),n.restore()}function hd(n,t,e,s,i,r=1,o=[],a){n.save(),n.setLineDash(o),n.lineWidth=r,a!==void 0&&(n.lineCap=a),n.beginPath(),n.moveTo(t,e),n.lineTo(s,i),n.stroke(),n.closePath(),n.restore()}function he(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function Fr(n,t,e){const s=Math.min(t.x,e.x)+.5,i=Math.min(t.y,e.y),r=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);n.fillRect(s,i,r,o)}const Kt=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},fv=n=>Array.isArray(n[0])?n:[n];class dd{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,s){const i=t.ctx,r=s&&this.paneManager.panes[s];e&&(i.save(),r&&Kt(i,r.getBounds()),this.drawSeries(i,e),i.restore())}drawSeries(t,e){const s=e.config.additionalVisibilityPredicatesMap;if(e.config.visible||s&&!th(s)){const i=e.config.type,r=this.seriesDrawers[i];if(r){const o=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);o&&o.length>=1&&r.draw(t,o,e,{})}else console.error(`Data series drawer with type ${i} isn't registered!`)}}}const qt=(n,t,e,s,i=t)=>{s.hoverWidth?n.lineWidth=s.hoverWidth:e.highlighted?n.lineWidth=t!==i?t+1:i:n.lineWidth=t};class ud{constructor(t){this.config=t}setFillStyle(t,e,s,i){if(e.color)t.strokeStyle=e.color;else{const r=s.colors.barTheme;r&&(t.strokeStyle=r[`${i.name}Color`])}}draw(t,e,s,i){if(s instanceof $t){const r=vt(e);qt(t,this.config.barLineWidth,s,i),he(t,()=>{for(const o of r){this.setFillStyle(t,i,s,o),t.beginPath();const a=s.view.toX(o.centerUnit),l=s.view.toX(o.startUnit),[c,h,d,u]=o.yBodyKeyPoints(s.view),f=It(s.view.xPixels(o.width)/2),p=s.view.toY(o.close),m=s.view.toY(o.open);this.config.showWicks?(t.moveTo(a,c),t.lineTo(a,u)):(t.moveTo(a,h),t.lineTo(a,d)),t.moveTo(a,p),t.lineTo(a+f,p),t.moveTo(l,m),t.lineTo(a,m),t.stroke()}})}}}class fd{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,s,i){if(i!==void 0&&s instanceof $t){const r=vt(e),o=this.baseLineModel.baselineYPercents,a=this.canvasBoundContainer.getBounds(M.CHART),l=a.y+a.height*(o/100),c=r[0];for(let h=0;h<r.length;h++){const d=r[h],u=r[h-1],f=r[h+1],p=s.view.toX(c.centerUnit),m=s.view.toX(d.centerUnit),_=s.view.toY(d.close),S=u?s.view.toY(u.close)<l:!1,A=_<l;if(u!==void 0&&S!==A){Hr(t,s,i,S);const E=s.view.toX(u.centerUnit),Y=s.view.toY(u.close),B=m-E,R=_-Y,k=B/R,V=_-l,X=k*V,U=E+(B-X);t.lineTo(U,l),t.stroke(),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(U,l)}u===void 0?(t.beginPath(),t.moveTo(m,_)):f===void 0?(Hr(t,s,i,A),t.lineTo(m,_),t.stroke(),t.lineTo(m,l),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(p,l),t.lineTo(m,l),t.strokeStyle=s.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(m,_)}}}}const Hr=(n,t,e,s)=>{e.color?(n.fillStyle=e.color,n.strokeStyle=e.color):(n.fillStyle=s?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,n.strokeStyle=s?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class pd{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,s,i){if(s instanceof $t){const r=vt(e);qt(t,this.config.candleLineWidth,s,i,this.config.candleLineWidth),he(t,()=>{this.pixelLength=1/Ht,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const o of r){const{candleTheme:a,activeCandleTheme:l}=s.colors;a&&l&&this.drawCandle(t,i,s,o)}})}}drawCandle(t,e,s,i){const{candleTheme:r,activeCandleTheme:o}=s.colors,a=i.name,l=i.isActive?o:r,c=i.isHollow;e.color?t.fillStyle=e.color:c?t.fillStyle=l[`${a}WickColor`]:t.fillStyle=l[`${a}Color`];const h=s.view.toX(i.startUnit),d=s.view.xPixels(i.width),u=i.bodyHeight(s.view),[f,p,m,_]=i.yBodyKeyPoints(s.view),S=p===m?p+1:m,A=f===_?f+1:_,E=l[`${a}Color`],Y=a==="none"?E:l[`${a}WickColor`];t.fillStyle=E,e.color?t.strokeStyle=e.color:t.strokeStyle=Y;const B=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),R=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:S),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:S),t.moveTo(h+1,p),t.lineTo(h+1,S),t.stroke();else if(d===3){const k=d/Ht;this.drawCandlesWicks(t,h+k,f,A,p,S),c||(t.beginPath(),t.moveTo(h+k,p),t.lineTo(h+k,S),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,p+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const k=i.x(s.view);this.drawCandlesWicks(t,k,f,A,p,S);const V=this.config.candlePaddingPercent,X=Math.max(d*V/2,this.pixelLength),U=h+X,Z=d-X*2;if(!c){e.color&&(t.fillStyle=e.color);const G=e.hoverWidth?d+X:Z,Q=e.hoverWidth?u+e.hoverWidth+X:u;t.fillRect(U,p,G,Q)}B&&this.drawCandleBorder(t,e,l,i,U+this.halfLineWidthCU,p+this.halfLineWidthCU,Z-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,s,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,s,i,r,o,a,l){if(e.color)t.strokeStyle=e.color;else{const c=i.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class gd{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof $t){const r=e.flat(),o=s.scale.getBounds(),a=o.y+o.height;for(const l of r){t.beginPath();const c=l.name,h=this.config.barCapSize,d=s.colors.histogram;if(d===void 0)return;i.color?t.fillStyle=i.color:t.fillStyle=d[`${c}Bright`];const u=l.xStart(s.view),f=s.view.toY(l.close),p=It(s.view.xPixels(l.width));t.fillRect(u,f,p,h);const m=t.createLinearGradient(0,f+h,0,a);i.color?t.fillStyle=i.color:(m.addColorStop(0,d[`${c}Cap`]),m.addColorStop(1,d[`${c}Bottom`]),t.fillStyle=m),p===0?(t.beginPath(),t.strokeStyle=m,t.moveTo(u,f+h),t.lineTo(u,a),t.stroke(),t.closePath()):t.fillRect(u,f+h,p,a-f-h)}}}}class md{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof $t){const r=vt(e);qt(t,this.config.lineWidth,s,i,this.config.selectedWidth);const o=s.colors.lineTheme;t.lineCap="round",i.color&&(t.strokeStyle=i.color);for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a],h=c.name;i.color||(t.strokeStyle=o[`${h}Color`]);const d=s.view.toX(l.centerUnit),u=s.view.toY(l.close),f=s.view.toX(c.centerUnit),p=s.view.toY(c.close);t.beginPath(),t.moveTo(d,u),t.lineTo(f,p),t.stroke()}}}}const vd=1.5;class bd{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:vd;t.fillStyle=(r=i.color)!=null?r:this.config.mainColor;for(const a of vt(e)){t.beginPath();const l=s.view.toX(a.centerUnit),c=s.view.toY(a.close);t.arc(l,c,o,0,Math.PI*2,!0),t.fill()}}}const Cd=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class yd{constructor(t,e,s){this.drawer=t,this.config=e,this.chartBounds=s}draw(t,e,s,i){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,s,i),this.afterDraw(t,s))}beforeDraw(t){t.restore(),t.save(),Kt(t,this.chartBounds())}isChartTypeAllowed(){return Cd.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Kt(t,e.scale.getBounds())}}class wd{constructor(t){this.chartModel=t}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=this.chartModel.getVisualCandle(rt(c.centerUnit)),d=c.close;if(h&&d===1){const u=this.chartModel.scale.zoomX,f=It(bt(h.width,u)),p=It(h.bodyHeight(this.chartModel.scale)),m=h.xCenter(this.chartModel.scale)-f/2,_=h.yBodyStart(this.chartModel.scale),S=this.chartModel.config.components.chart.candlePaddingPercent,A=It(f*S/2),E=m+A,Y=f-A*2;t.fillRect(E,_,Y,p)}})})}}const Sd=(n,t,e,s)=>{const{centerUnit:i,close:r}=n,o=e.toX(i),a=e.toY(r);s===0?t.moveTo(o,a):t.lineTo(o,a)},kr=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{Sd(s,t,e,i)})},xd=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,_d=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,Pd=/^rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}\s*0*(?:\.\d+|1(?:\.0*)?)\s*[)]$/,Td=n=>xd.exec(n),Md=n=>_d.exec(n),pv=n=>Pd.exec(n);function Ad(n){const t=Td(n)||Md(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const jr={};function Ed(n,t){let e=jr[n+t];if(!e){const s=Ad(n);e=s&&"rgba("+s.join(",")+","+t+")",jr[n+t]=e}return e}const Yr="#383838";class Id{constructor(){}draw(t,e,s,i){const r=s.config.additionalVisibilityPredicatesMap,o=(r==null?void 0:r.showLine)!==void 0?r.showLine:s.config.visible,a=(r==null?void 0:r.showCloud)!==void 0?r.showCloud:s.config.visible;o&&e.forEach((l,c)=>{var h;const d=s.getPaintConfig(c);qt(t,d.lineWidth,s,i,d.hoveredLineWidth);const u=(h=i.color)!=null?h:d.color;t.strokeStyle=u,this.drawLine(t,l,s.view)}),a&&s.linkedDataSeriesModels.forEach((l,c)=>{const h=l.config.additionalVisibilityPredicatesMap,d=(h==null?void 0:h.showCloud)!==void 0?h.showCloud:l.config.visible;if(Nr(l.config.type)&&Nr(s.config.type)&&d){const u=s,f=u.getSeriesInViewport(u.scale.xStart-1,u.scale.xEnd+1),p=l.getSeriesInViewport(l.scale.xStart-1,l.scale.xEnd+1);f.forEach((m,_)=>{var S,A;const E=[],Y=Math.min(m.length,(A=(S=p[_])==null?void 0:S.length)!=null?A:0);for(let k=0;k<Y;k++){const V=[m[k].clone(),p[_][k].clone()];E.push({diffPoints:V})}const B=u.getPaintConfig(_).color,R=l.getPaintConfig(c).color;this.drawDifference(t,B,R,E,u,l,i,r)})}})}drawLine(t,e,s){t.beginPath(),kr(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a,l){const[c,h]=[[],[]];i.forEach(_=>{const[S,A]=_.diffPoints;c.push(S),h.push(A)});const d=this.mapDataSeriesDiffPointsIntoPoints(c,r.view),u=this.mapDataSeriesDiffPointsIntoPoints(h,o.view),f=l==null?void 0:l.backgroundColor,p=f!==void 0?f:s,m=f!==void 0?f:e;this.fillCloud(t,p,d,u,a,l),this.fillCloud(t,m,u,d,a,l)}fillCloud(t,e,s,i,r,o){var a,l,c,h;t.save(),t.beginPath();const d=(l=(a=ie(s))==null?void 0:a.x)!=null?l:0,u=(h=(c=St(s))==null?void 0:c.x)!=null?h:0;t.lineTo(d,0),s.forEach(p=>{t.lineTo(p.x,p.y)}),t.lineTo(u,0),t.closePath(),t.clip(),t.beginPath(),s.forEach((p,m)=>{m===0?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y)}),i.slice().reverse().forEach(p=>{t.lineTo(p.x,p.y)}),t.closePath();const f=(o==null?void 0:o.backgroundColor)!==void 0;r.color?t.fillStyle=r.color:f?t.fillStyle=e!=null?e:Yr:t.fillStyle=Ed(e!=null?e:Yr,.3),t.fill(),t.restore()}mapDataSeriesDiffPointsIntoPoints(t,e){return t.map(s=>{const{centerUnit:i,close:r}=s,o=e.toX(i),a=e.toY(r);return{x:o,y:a}})}}const Nr=n=>n==="DIFFERENCE";class Dd{constructor(){}draw(t,e,s,i){const r=s.view.toY(0);e.forEach((o,a)=>{var l;const c=s.getPaintConfig(a);qt(t,c.lineWidth,s,i,c.hoveredLineWidth),t.strokeStyle=(l=i.color)!=null?l:c.color,t.beginPath(),o.forEach(h=>{const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.moveTo(d,rt(r)),t.lineTo(d,rt(u))}),t.stroke()})}}class Ld{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);qt(t,l.lineWidth,s,i,l.hoveredLineWidth),t.strokeStyle=(a=i.color)!=null?a:l.color,this.drawLinePath(t,r,s.view)})}drawLinePath(t,e,s){t.beginPath(),kr(e,t,s),t.stroke()}}class Od{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o),c=i.hoverWidth?i.hoverWidth/2:l.lineWidth;t.fillStyle=(a=i.color)!=null?a:l.color,t.lineWidth=1,r.forEach(h=>{t.beginPath();const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.arc(d,u,c,0,Math.PI*2),t.fill()})})}}class Bd{constructor(t){this.config=t}draw(t,e,s,i){t.save(),e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,r.forEach(h=>{const d=s.getTextForPoint(h),u=Mt(d,t,c),f=Xt(c,t),p=s.view.toX(h.centerUnit)-u/2,m=s.view.toY(h.close)+f;t.fillText(d,p,m)})}),t.restore()}}class Rd{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=s.view.toX(c.centerUnit),d=s.view.toY(c.close);this.drawCandleTriangle(t,h,d,l.lineWidth)})})}drawCandleTriangle(t,e,s,i){t.beginPath(),t.moveTo(e-i/2,s),t.lineTo(e,s-i),t.lineTo(e+i/2,s),t.fill()}}const hs="resized_local",ds="draw",gv="draw_last_candle",we={width:20,height:20};class Xr{constructor(t,e,s,i,r,o={}){this.eventBus=t,this.canvas=e,this.drawingManager=s,this.resizer=r,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.lastDPR=0,this.type=ln;var a;i.push(this),this.parent=kd(e);const l=e.getContext("2d",o);if(l===null)throw new Error("Couldn't get 2d context????");this.context=l,this._canvasId=(a=e.getAttribute("data-element"))!=null?a:"",this.updateCanvasWidthHeight(e,this.getChartResizerElement().getBoundingClientRect())}updateDPR(t){const{width:e,height:s}=t,i=window.devicePixelRatio;e===this.width&&s===this.height&&i===this.lastDPR||(this.lastDPR=i,this.canvas.style.height=s+"px",this.canvas.style.width=e+"px",this.canvas.width=e*i,this.canvas.height=s*i,this.width=e,this.height=s,this.ctx.scale(i,i))}get canvasId(){return this._canvasId}get ctx(){return this.context}clear(){this.context.clearRect(0,0,this.width,this.height)}isLinked(){var t,e;return(e=(t=this.type)==null?void 0:t.linked)!=null?e:!1}fireDraw(){this.eventBus.fireDraw([this.canvasId])}updateCanvasWidthHeight(t,e=this.getChartResizerElement().getBoundingClientRect()){t.clientWidth!==this.width&&(t.width=t.clientWidth,this.width=t.clientWidth);const s=e.height;s!==this.height&&(t.style.height=s+"px",this.height=s,t.height=s,this.prevHeight=s)}getChartResizerElement(){var t;return(t=this.resizer)!=null?t:this.parent}isReady(){return this.width>we.width&&this.height>we.height}}const ln={name:"candle"},Fd={candle:ln,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function Hd(n,t,e,s,i,r,o){var a;const l=de(n,t,i,r,o,e);return l.type=(a=Fd[s])!=null?a:ln,l}function de(n,t,e,s,i,r,o){const a=new Xr(n,t,s,i,r,o);return Wr(a,e),a}function Wr(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 kd(n){let t=n;for(;t;){if(t.nodeType===1&&t.hasAttribute("data-chart-container"))return t;if(t.parentElement!==null)t=t.parentElement;else break}return t}const us="HIT_TEST_",Cv=null;class jd{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${_t()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(us)!==-1&&this.drawersMap[s].draw()})},t.on(ds,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),ni(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(us)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(us)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}Yl(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>we.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>we.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=_t()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(e);this.drawingOrder.splice(i,1);const r=this.drawingOrder.indexOf(s);this.drawingOrder.splice(r+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(s);if(i!==-1){const r=this.drawingOrder.indexOf(e);return this.drawingOrder.splice(r,1),this.drawingOrder.splice(i,0,e),this.reorderDrawers(this.drawingOrder),!0}return!1}getDrawerByName(t){return this.drawersMap[t]}getNameByDrawer(t){for(const e in this.drawersMap)if(this.drawersMap[e]===t)return e}removeDrawerByName(t){const e=this.drawersMap[t];this.removeDrawer(e)}removeDrawer(t){Object.keys(this.drawersMap).forEach(e=>{if(this.drawersMap[e]===t){delete this.drawersMap[e];const s=this.drawingOrder.indexOf(e);s!==-1&&this.drawingOrder.splice(s,1)}})}reorderDrawers(t){this.drawingOrder=fi(this.drawingOrder,t)}}class zr{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Yd=7;class Nd{constructor(t,e,s,i=()=>!0){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=s,this.drawPredicate=i}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),Kt(t,e.getBounds()),e.dataSeries.forEach(s=>this.drawSeries(t,s)),t.restore()})}}drawSeries(t,e){if(e.config.visible){const s=e.config.type,i=this.seriesDrawers[s];if(i){const r={color:this.canvasModel.idToColor(e.htId),hoverWidth:Yd};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Vr={dragPredicate:()=>!0};class Ur extends W{constructor(t,e,s,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragComponentOptions.dragPredicate()&&(this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o))},this.onDragTick=o=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels))}}}class fs extends Ur{constructor(t,e,s,i,r=Vr){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeYDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeYDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeYDragEnd().subscribe(this.onDragEnd))}}const Xd="BASELINE_RESIZER";class Wd extends W{constructor(t,e,s,i,r,o,a){super(),this.chartModel=t,this.chartPanComponent=e,this.canvasModel=s,this.canvasInputListener=i,this.config=r,this.canvasBoundContainer=o,this.cursorHandler=a,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.dragPredicate=new ft(!1),this.baselineYPercents=50,this.ht=qs.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragStartCb=()=>{this.chartPanComponent.deactivatePanHandlers(),this.dragPredicate.next(!0)},this.dragEndCb=()=>{this.chartPanComponent.activateChartPanHandlers(),this.dragPredicate.next(!1)},this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(M.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&Sc(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new fs(this.ht,{onDragTick:this.dragTickCb,onDragStart:this.dragStartCb,onDragEnd:this.dragEndCb},i,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(M.CHART).subscribe(()=>this.recalculateBounds())),this.chartModel.chartTypeChanged.subscribe(t=>{t==="baseline"?this.cursorHandler.setCursorForBounds("BASELINE_RESIZER",this.resizerBounds,this.config.components.baseline.cursor,this.config.components.baseline.dragZone):this.cursorHandler.removeCursorForCanvasEl("BASELINE_RESIZER")})}recalculateBounds(){const t=this.canvasBoundContainer.getBounds(M.CHART),e=this.canvasBoundContainer.getBounds(M.Y_AXIS);this.resizerBounds.x=t.x,this.resizerBounds.width=t.width+e.width,this.resizerBounds.height=this.config.components.baseline.height;const s=t.y+t.height*(this.baselineYPercents/100);this.resizerBounds.y=s,this.canvasBoundContainer.bounds[Xd]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(M.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const zd=n=>{var t;try{const e=Ae(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Ae(n.hi,Math.max(n.open,n.close),e),i=Ae(n.lo,Math.min(n.open,n.close),e),r=Ae(n.open,n.lo,e),o=Ae(n.close,n.hi,e),a=Number.isNaN(n.vwap)?void 0:n.vwap;return{id:n.id,hi:s,lo:i,open:r,close:o,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility,openInterest:n.openInterest,vwap:a,typicalPrice:n.typicalPrice}}catch(e){console.warn(e);return}},ke=(n,t=0)=>{for(let e=t;e<n.length;++e)n[e].idx=e},Gr=n=>{n.forEach(t=>{t.idx=void 0})},Vd=n=>n!==void 0;class Ud{constructor(){}draw(t,e,s,i){const r=s.view.toY(0),o=vt(e),a=s.getPaintConfig(0);qt(t,a.lineWidth,s,i,a.hoveredLineWidth),o.forEach((l,c)=>{var h,d,u,f,p,m,_,S;const A=Gd(o,c),E=A&&l.close<A;if(((h=a.multiplyColors)==null?void 0:h.length)===2){t.strokeStyle=(d=i.color)!=null?d:(E?a.multiplyColors[1]:a.multiplyColors[0])||a.color||"#FF00FF",t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}if(((u=a.multiplyColors)==null?void 0:u.length)===4){E&&l.close<0&&(t.strokeStyle=(f=i.color)!=null?f:a.multiplyColors[0]||a.color||"#FF00FF"),!E&&l.close<0&&(t.strokeStyle=(p=i.color)!=null?p:a.multiplyColors[1]||a.color||"#FF00FF"),E&&l.close>0&&(t.strokeStyle=(m=i.color)!=null?m:a.multiplyColors[2]||a.color||"#FF00FF"),!E&&l.close>0&&(t.strokeStyle=(_=i.color)!=null?_:a.multiplyColors[3]||a.color||"#FF00FF"),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}t.strokeStyle=(S=i.color)!=null?S:a.color||"#FF00FF",t.beginPath();const Y=s.view.toX(l.centerUnit),B=s.view.toY(l.close);t.moveTo(Y,r),t.lineTo(Y,B),t.stroke()})}}const Gd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},Zd=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class $d{constructor(){}draw(t,e,s,i){const r=vt(e),o=s.getPaintConfig(0);qt(t,o.lineWidth,s,i,o.hoveredLineWidth),t.lineCap="round",r.forEach((a,l)=>{var c,h;const d=Kd(r,l)||r[0],u=d&&a.close<d.close;if(((c=o.multiplyColors)==null?void 0:c.length)===2){t.strokeStyle=(h=i.color)!=null?h:(u?o.multiplyColors[1]:o.multiplyColors[0])||o.color||"#FF00FF";const f=s.view.toX(a.centerUnit),p=s.view.toY(a.close),m=s.view.toX(d.centerUnit),_=s.view.toY(d.close);t.beginPath(),t.moveTo(m,_),t.lineTo(f,p),t.stroke();return}})}}const Kd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0},Se="#FF00FF";class qd{constructor(){}draw(t,e,s,i){const r=vt(e),o=s.getPaintConfig(0),a=i.hoverWidth?i.hoverWidth/2:o.lineWidth;r.forEach((l,c)=>{var h,d,u,f,p,m,_,S;const A=Jd(r,c),E=A&&l.close<A;if(((h=o.multiplyColors)==null?void 0:h.length)===2){t.fillStyle=(d=i.color)!=null?d:(E?o.multiplyColors[1]:o.multiplyColors[0])||o.color||Se;const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}if(((u=o.multiplyColors)==null?void 0:u.length)===4){E&&l.close<0&&(t.fillStyle=(f=i.color)!=null?f:o.multiplyColors[0]||o.color||Se),!E&&l.close<0&&(t.fillStyle=(p=i.color)!=null?p:o.multiplyColors[1]||o.color||Se),E&&l.close>0&&(t.fillStyle=(m=i.color)!=null?m:o.multiplyColors[2]||o.color||Se),!E&&l.close>0&&(t.fillStyle=(_=i.color)!=null?_:o.multiplyColors[3]||o.color||Se),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}t.fillStyle=(S=i.color)!=null?S:o.color||Se,t.beginPath();const Y=s.view.toX(l.centerUnit),B=s.view.toY(l.close);t.arc(Y,B,a,0,Math.PI*2),t.fill()})}}const Jd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0};var Qd=Object.defineProperty,Zr=Object.getOwnPropertySymbols,tu=Object.prototype.hasOwnProperty,eu=Object.prototype.propertyIsEnumerable,$r=(n,t,e)=>t in n?Qd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Kr=(n,t)=>{for(var e in t||(t={}))tu.call(t,e)&&$r(n,e,t[e]);if(Zr)for(var e of Zr(t))eu.call(t,e)&&$r(n,e,t[e]);return n};class su{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class nu extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=f,this.chartResizeHandler=p,this._dataSeriesDrawers={},this.backgroundDrawerPredicateSubject=new ft(!0),this.strToBarType=_=>{var S;return(S=this.barTypeValues.find(A=>A===_))!=null?S:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new Wd(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const m=new Nd(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(m,us+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new Mh(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(M.PANE_UUID($),s.components.chart.cursor),this.dataSeriesDrawer=new dd(d,this.dataSeriesDrawers)}doActivate(){super.doActivate(),this.dynamicObjects.model.addObject({id:this.chartModel.mainCandleSeries.id,paneId:this.chartModel.mainCandleSeries.extentComponent.paneUUID,model:this.chartModel.mainCandleSeries,drawer:this.dataSeriesDrawer}),this.addRxSubscription(this.paneManager.dataSeriesAddedSubject.subscribe(t=>{this.dynamicObjects.model.addObject({id:t.id,paneId:t.extentComponent.paneUUID,parentId:t.parentId,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)})),this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe(Zd(()=>{this.backgroundDrawerPredicateSubject.next(!1)},zt))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",wr),this.registerCandlesTransformer("trend",Sr),this.registerCandlesTransformer("hollow",Eh),this.registerCandlesTransformer("line",Ih)}get barTypeValues(){return ir(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 pd(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new ud(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new md(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new bd(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new ld(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new fd(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new gd(this.config.components.chart.histogram));const e=M.PANE_UUID($),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new Ld),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new $d),this.registerDataSeriesTypeDrawer("HISTOGRAM",new Dd),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new Ud),this.registerDataSeriesTypeDrawer("POINTS",new Od),this.registerDataSeriesTypeDrawer("TREND_POINTS",new qd),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new yd(new wd(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new Bd(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new Rd),this.registerDataSeriesTypeDrawer("DIFFERENCE",new Id)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(Kr({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e,s=!0){return this.chartModel.setTimestampRange(t,e,s)}setXScale(t,e,s=!0){return this.scale.setXScale(t,e,s)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.fireDraw()}setApplyBackgroundToAxes(t){this.config.components.chart.applyBackgroundToAxes=Kr({},t),this.chartModel.bus.fireDraw()}setMainSeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument;this.chartModel.mainCandleSeries.instrument=s,this.chartModel.setAllSeries({candles:t.candles,instrument:s},this.chartModel.getSecondarySeries().map(i=>{var r;const o=(r=i.instrument)!=null?r:this.chartModel.mainCandleSeries.instrument,a=i.dataPoints;return Gr(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),i)return i}setAllSeries(t,e=[]){var s;const i=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(i),e.forEach(r=>{var o;const a=(o=r.instrument)!=null?o:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(a)}),this.chartModel.setAllSeries(t,e)}toXFromCandleIndex(t){return this.chartModel.toX(t)}toXFromTimestamp(t){return this.chartModel.candleFromTimestamp(t).xCenter(this.chartModel.scale)}toY(t){return this.chartModel.toY(t)}updateAllSeries(t,e=[]){this.chartModel.updateAllSeries(t,e),this.canvasModel.fireDraw()}removeDataFrom(t){this.chartModel.removeDataFrom(t)}removeSecondarySeries(t){this.chartModel.removeSecondaryCandleSeries(t)}prependCandles(t,e){this.chartModel.prependCandles(t,e)}addLastCandle(t,e){this.chartModel.addLastCandle(t,e)}removeCandleByIdx(t,e){this.chartModel.removeCandleByIdx(t,e)}removeCandlesByIdsSequence(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIdsSequence(t,e)}removeCandlesByIds(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIds(t,e)}addCandlesById(t,e,s=this.chartModel.mainCandleSeries){this.chartModel.addCandlesById(t,e,s)}updateLastCandle(t,e){this.chartModel.updateLastCandle(t,e)}updateCandles(t,e){this.chartModel.updateCandles(t,e)}setOffsets(t){this.chartModel.setOffsets(t)}getDataSeriesDrawer(t){return this._dataSeriesDrawers[t]}registerDataSeriesTypeDrawer(t,e){this._dataSeriesDrawers[t]=e}updatePriceIncrementsIfNeeded(t){(!t.priceIncrements||!ye.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[ye.autoDetectIncrementOfValueRange(this.scale.yEnd-this.scale.yStart)])}observeOffsetsChanged(){return this.chartModel.offsetsChanged}observeChartTypeChanged(){return this.chartModel.chartTypeChanged}observeCandlesChanged(){return this.chartModel.observeCandlesChanged()}observeCandlesUpdated(){return this.chartModel.candlesUpdatedSubject}observeCandlesPrepended(){return this.chartModel.candlesPrependSubject}}function qr(n,t){return t===void 0&&(t=rs),N(function(e,s){var i=null,r=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var c=r;r=null,s.next(c)}};function l(){var c=o+n,h=t.now();if(h<c){i=this.schedule(void 0,c-h),s.add(i);return}a()}e.subscribe(yt(s,function(c){r=c,o=t.now(),i||(i=t.schedule(l,n),s.add(i))},function(){a(),s.complete()},void 0,function(){r=i=null}))})}class Jr extends $t{constructor(t,e,s,i,r,o,a,l,c,h){super(e,s,i,r,o,a,l,c,h),this.baseModel=t}set visualPoints(t){super.visualPoints=t,this.baseModel.mainVisualPoints=super.visualPoints}get visualPoints(){return super.visualPoints}set dataPoints(t){super.dataPoints=t,this.baseModel.mainDataPoints=super.dataPoints}get dataPoints(){return super.dataPoints}recalculateMeanCandleWidth(t){super.recalculateMeanCandleWidth(t),this.baseModel.meanDataWidth=this.meanCandleWidth}}var iu=Object.defineProperty,Qr=Object.getOwnPropertySymbols,ru=Object.prototype.hasOwnProperty,ou=Object.prototype.propertyIsEnumerable,to=(n,t,e)=>t in n?iu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,au=(n,t)=>{for(var e in t||(t={}))ru.call(t,e)&&to(n,e,t[e]);if(Qr)for(var e of Qr(t))ou.call(t,e)&&to(n,e,t[e]);return n};const lu=(n,t,e,s)=>{var i,r,o,a;const l=au({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=zl(-e,t))==null?void 0:o.startUnit)!=null?a:0;let d=n.xStart,u=n.xEnd;return l.xStart>=h&&(d=h,u=u-(l.xStart-h)),l.xEnd<c&&(d=c-kt(s.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},cu=n=>(t,e={xScale:!0,yScale:!0})=>{if(t.length!==0){if(e.xScale){const s=t.slice(Math.max(t.length-n.state.defaultViewportItems,0)),i=s[0],r=s[s.length-1];n.setXScale(i.startUnit,r.startUnit+r.width+n.offsets.right)}e.yScale&&n.doAutoScale(!0),n.fireChanged()}},hu=(n,t)=>(e,s=null)=>{const[i,r]=e,o=t.candleFromTimestamp(i).startUnit,a=t.candleFromTimestamp(r).startUnit,l=s===null?0:t.mainCandleSeries.meanCandleWidth*2,c=s?o-l:o+l,h=s?a+l:a-l;n.setXScale(c,h)};var du=Object.defineProperty,uu=Object.defineProperties,fu=Object.getOwnPropertyDescriptors,eo=Object.getOwnPropertySymbols,pu=Object.prototype.hasOwnProperty,gu=Object.prototype.propertyIsEnumerable,so=(n,t,e)=>t in n?du(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,je=(n,t)=>{for(var e in t||(t={}))pu.call(t,e)&&so(n,e,t[e]);if(eo)for(var e of eo(t))gu.call(t,e)&&so(n,e,t[e]);return n},cn=(n,t)=>uu(n,fu(t));class mu{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)=>cn(je({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=cn(je({},le(this.config.colors)),{lineTheme:je({},s.lineTheme),areaTheme:je({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,s=i);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[t]=s,this.secondaryChartColorsPool[s]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var s,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=cn(je({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var vu=Object.defineProperty,no=Object.getOwnPropertySymbols,bu=Object.prototype.hasOwnProperty,Cu=Object.prototype.propertyIsEnumerable,io=(n,t,e)=>t in n?vu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ps=(n,t)=>{for(var e in t||(t={}))bu.call(t,e)&&io(n,e,t[e]);if(no)for(var e of no(t))Cu.call(t,e)&&io(n,e,t[e]);return n};class yu extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=i,this.config=r,this.scale=o,this.formatterFactory=a,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.chartTypeChanged=new F,this.mainInstrumentChangedSubject=new F,this.offsetsChanged=new F,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.prepareCandles=u=>{const f=u.map(zd).filter(Vd),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.chartBaseModel.candleTimestampAnchor=this.getCandleTimestampAnchor(),this.secondaryChartColors=new mu(this.config);const d=new Jr(this.chartBaseModel,this.paneManager.panes[$].mainExtent,_t(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new su,this.candlesTransformersByChartType,this.candleWidthByChartType,ps({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),this.config.components.chart.minCandlesOffset>0&&o.addXConstraint((u,f)=>lu(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=cu(o),this.timeFrameViewportTransformer=hu(o,this),this.pane=this.paneManager.panes[$]}get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(t=>t!==this.mainCandleSeries)}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID($)).pipe(mt(zi)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(qr(zt)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>we.width&&t.height>we.height){const e=this.canvasBoundsContainer.getEffectiveChartWidth(),s=this.canvasBoundsContainer.getEffectiveYAxisWidth();if(this.prevChartWidth===0&&this.scale){this.scale.isViewportValid(!1)?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=kt(s-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-r)}else this.scale.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=e;return}const i=kt(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-i,this.scale.xEnd),this.scale.recalculateZoomY(),this.prevYWidth=s,this.prevChartWidth=e}}setMainCandleSeries(t,e){this.mainCandleSeries.instrument=e,this.setAllSeries({candles:t,instrument:e},this.getSecondarySeries().map(s=>{const i=s.dataPoints;return Gr(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const i=this.prepareCandles(t),r=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),o=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,r),l=this.secondaryCandleSeries.some(c=>c.instrument.symbol===e.symbol)?this.secondaryCandleSeries.find(c=>c.instrument.symbol===e.symbol):this.createSecondaryCandleSeriesModel(e);if(l)return l.dataPoints=o,s&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var s;this.mainCandleSeries.instrument=(s=t.instrument)!=null?s:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=this.prepareCandles(t.candles);this.mainCandleSeries.clearData(),ke(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(r=>e.filter(o=>{var a;return((a=o.instrument)==null?void 0:a.symbol)===r.instrument.symbol}).length===0).forEach(r=>this.removeSecondaryCandleSeries(r)),e.map(r=>this.setSecondaryCandleSeries(r.candles,r.instrument,!1)),this.candleSeries.forEach(r=>{r.recalculateDataViewportIndexes(),r.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()}autoScaleOnCandles(){this.scale.state.autoScaleOnCandles&&(this.doBasicScale(),this.scale.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doBasicXScale(){this.scale.setXScaleWithoutYScale(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(t=null){this.timeFrameViewportTransformer(this.lastTimeFrame,t),this.scale.state.autoScaleOnCandles&&this.scale.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scale.toX(this.scale.xStart),!0).timestamp,this.candleFromX(this.scale.toX(this.scale.xEnd),!0).timestamp])}updateAllSeries(t,e=[]){t=ps({},t),t.instrument||(t.instrument=this.mainCandleSeries.instrument);const s=[t,...e];if(!this.candleSeries.every(l=>s.find(c=>{var h;return((h=c.instrument)==null?void 0:h.symbol)===l.instrument.symbol}))||e.length!==this.secondaryCandleSeries.length){console.error("All series update failed. Instruments for series are different.");return}const i=this.prepareCandles(t.candles),r=oo(this.mainCandleSeries.dataPoints,i,this.getCandleTimestampAnchor()),o=r.candles;ke(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=oo((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f,this.getCandleTimestampAnchor()).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints()});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.candleSeries.forEach(l=>{l.recalculateDataViewportIndexes()}),this.candlesPrependSubject.next({prependedCandlesWidth:a,prependedCandles:r.prepended}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(t){Object.values(this.paneManager.panes).forEach(e=>{e.dataSeries.forEach(s=>{const i=Nt(s.dataPoints,t,o=>o.timestamp),r=i.exact?i.index:i.index+1;s.dataPoints=s.dataPoints.slice(0,r)})}),this.candlesChangedRedraw()}createSecondaryCandleSeriesModel(t){const e=ps(ps({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new $t(this.paneManager.panes[$].mainExtent,_t(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,t,this.candlesTransformersByChartType,this.candleWidthByChartType,e);return s.config.type="line",this.candleSeries.push(s),s}removeSecondaryCandleSeries(t){return this.secondaryChartColors.addColorToPool(t.instrument.symbol),this.candleSeries=this.candleSeries.filter(e=>e!==t),t.deactivate(),this.paneManager.panes[$].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(i=>{const r=this.candleIdxFromId(i.id),o=r>0?r:0,a=e[o];if(a)s.push(a);else{let l=ro(e,o,-1);if(l||(l=ro(e,o,1)),l){const c=nc(l,o,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const i=At(t,ss().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=s,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=s.length&&this.scale.setXScale(this.scale.xStart,this.candleFromIdx(e).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scale.getOffsets()}fromY(t){return this.scale.fromY(t)}priceFromY(t,e){return(e!=null?e:this.mainCandleSeries).view.priceFromY(t)}fromX(t){return this.scale.fromX(t)}toX(t){const e=this.candleFromIdx(t);return this.scale.toX(e.centerUnit)}candleFromX(t,e=!1,s=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var i,r;const o=Nt(s.visualPoints,t,d=>d.startUnit),a=s.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=Ee((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?Fe(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:Fe(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e={extrapolate:!0},s=this.mainCandleSeries){const i=s.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,i)}candleFromId(t,e=this.mainCandleSeries){return e.visualPoints.find(s=>s.candle.id===t)}candleIdxFromId(t,e=this.mainCandleSeries){return e.visualPoints.findIndex(s=>s.candle.id===t)}candleFromIdx(t){return this.chartBaseModel.dataFromIdx(t)}isReady(){return this.canvasModel.isReady()&&this.hasCandles()}registerCandlesTransformer(t,e){this.candlesTransformersByChartType[t]=e}registerCandlesWidthCalculator(t,e){this.candleWidthByChartType[t]=e}registerLastCandleLabelHandler(t,e){this.lastCandleLabelsByChartType[t]=e}hasCandles(){return this.mainCandleSeries.visualPoints.length!==0}getVisualCandle(t){var e,s,i;const r=t-((i=(s=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:s.idx)!=null?i:0);return this.mainCandleSeries.visualPoints[r]}getFirstIdx(){return this.mainCandleSeries.dataIdxStart}getLastIdx(){return this.mainCandleSeries.dataIdxEnd}getFirstTimestamp(t=!0){return t?this.candleFromIdx(this.getFirstIdx()).candle.timestamp:this.candleFromUnit(this.scale.xStart,!0).timestamp}getLastTimestamp(t=!0){return t?this.candleFromIdx(this.getLastIdx()).candle.timestamp:this.candleFromUnit(this.scale.xEnd,!0).timestamp}setTimestampRange(t,e,s=!0){const i=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),o=r.startUnit+r.width;return this.scale.setXScale(i,o,s)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return St(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return St(t)}getMaxCandlesFitLength(){return rt(this.canvasBoundsContainer.getEffectiveChartWidth()/this.config.components.chart.minWidth)}getSecondarySeries(){return this.secondaryCandleSeries}isSeriesInstrument(t,e){return t.instrument.symbol===e}findSeriesBySymbol(t){return this.candleSeries.filter(e=>this.isSeriesInstrument(e,t))}findSecondarySeriesBySymbol(t){return this.secondaryCandleSeries.find(e=>this.isSeriesInstrument(e,t))}reindexCandlesBasedOnSeries(t,e){return e.reduce((s,i)=>{const r=i.timestamp,o=be(r,this.candleSearchOptions(!1),t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}getCandleTimestampAnchor(){var t;return(t=this.config.components.chart.candleTimestampAnchor)!=null?t:"open"}candleSearchOptions(t,e){return{extrapolate:t,isDaysPeriod:e,candleTimestampAnchor:this.getCandleTimestampAnchor()}}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}isLastCandleInViewport(){const t=this.getLastCandle();return t&&t.idx?this.isCandleInViewport(t.idx):!1}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=be(h.timestamp,this.candleSearchOptions(!0),o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,m=c&&h.timestamp<c.timestamp;if(p&&!m&&(c=h),a&&c&&s&&l){const _=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:xr;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.config.scale.auto&&this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return wt(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=this.getCandles(),e=0,s){const i=this.getCandlesCount(),r=s!=null?s:i+this.FAKE_CANDLES_DEFAULT;t=t.slice(Math.max(0,e),Math.min(i,r));const o=[],a=[];for(let c=i;c<r;c++)o.push(Fe(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=e;c<l;c++)a.push(Fe(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...a,...t,...o]}getCandlesCount(){return this.mainCandleSeries.dataPoints.length}getCandlesCountWithRightOffset(){return this.getCandlesCount()+this.getOffsets().right}clearData(){this.candleSeries.forEach(t=>t.clearData())}prependCandles(t,e){const s=t.slice(),i=[];return e.forEach(r=>{const a=be(r.timestamp,this.candleSearchOptions(!1),t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),ke(i.dataPoints),i.recalculateVisualPoints()}),this.candlesChangedRedraw()}removeCandlesByIdsSequence(t,e){const s=this.candleIdxFromId(t[0],e),i=this.candleIdxFromId(t[t.length-1],e);if(s<0||i<0){console.warn("Candle is not found");return}e.dataPoints=e.dataPoints.slice(0,s).concat(e.dataPoints.slice(i+1)),ke(e.dataPoints,i),e.recalculateVisualPoints(),this.candlesChangedRedraw()}removeCandlesByIds(t,e){t.forEach(s=>this.removeCandleByIdx(this.candleIdxFromId(s,e)))}addCandlesById(t,e,s){const i=this.candleIdxFromId(e);if(i<0){console.warn("Selected start candle is not found");return}const r=s.dataPoints.slice(0,i),o=s.dataPoints.slice(i);s.dataPoints=r.concat(t).concat(o),ke(s.dataPoints),s.recalculateVisualPoints(),this.candlesChangedRedraw()}candlesChangedRedraw(){this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const ro=(n,t,e)=>{if(t>=n.length)return n[n.length-1];for(let s=t;s<n.length&&s>=0;s+=e){const i=n[s];if(i)return i}},oo=(n,t,e="open")=>{const s=n.slice(),i=[],r=[];return t.forEach(o=>{const l=be(o.timestamp,{extrapolate:!0,candleTimestampAnchor:e},n).index;l<0?i.push(o):l>=n.length?r.push(o):n[l].timestamp===o.timestamp?s[l]=o:console.warn(`Couldn't update candle with timestamp ${o.timestamp}`)}),{prepended:i,appended:r,candles:[...i,...s,...r]}};class xe{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class hn{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=nr(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=nr(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=vt(Array.from(this.drawers).map(([,s])=>s.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class wu{constructor(t,e,s,i){this.model=t,this.config=e,this.crossToolCanvasModel=s,this.crossToolTypeDrawers=i}draw(){const t=this.crossToolTypeDrawers[this.config.components.crossTool.type];t?this.model.currentHover&&t.draw(this.crossToolCanvasModel.ctx,this.model.currentHover):console.error(`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}var Su=Object.defineProperty,xu=Object.defineProperties,_u=Object.getOwnPropertyDescriptors,ao=Object.getOwnPropertySymbols,Pu=Object.prototype.hasOwnProperty,Tu=Object.prototype.propertyIsEnumerable,lo=(n,t,e)=>t in n?Su(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,co=(n,t)=>{for(var e in t||(t={}))Pu.call(t,e)&&lo(n,e,t[e]);if(ao)for(var e of ao(t))Tu.call(t,e)&&lo(n,e,t[e]);return n},ho=(n,t)=>xu(n,_u(t));class Mu extends W{constructor(t,e,s,i,r,o,a){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=i,this.canvasBoundsContainer=r,this.baselineModel=o,this.chartModel=a,this.currentHoverSubject=new ft(null)}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.config.type=t}shouldKeepXForMobileTouchCrosshair(){return Ot()&&this.hoverProducer.longTouchActivatedSubject.getValue()&&this.crossEventProducer.crossSubject.getValue()!==null}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?Ot()?this.updateCrossToolMobile(t):this.updateCrossTool(t):this.currentHover=null,this.fireDraw()})),this.addRxSubscription(this.baselineModel.dragPredicate.subscribe(t=>{if(Ot())if(t)this.hoverProducer.deactivate();else{const e=this.crossEventProducer.crossToolTouchInfo;e.isSet&&this.crossEventProducer.crossSubject.next([e.temp.x,e.temp.y,$]),this.hoverProducer.activate()}}))}fireDraw(){this.config.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateCrossTool(t,e=this.config.magnetTarget,s=this.config.discrete){var i;const r=s&&!this.shouldKeepXForMobileTouchCrosshair()?this.chartModel.toX((i=this.chartModel.candleFromX(t.x,!0).idx)!=null?i:0):t.x;if(this.currentHover===null?this.currentHover={x:r,y:0,time:t.timeFormatted,paneId:t.paneId}:(this.currentHover.x=r,this.currentHover.time=t.timeFormatted),t.candleHover&&t.paneId===$)switch(e){case"O":this.currentHover.y=t.candleHover.openY;break;case"C":this.currentHover.y=t.candleHover.closeY;break;case"H":this.currentHover.y=t.candleHover.highY;break;case"L":this.currentHover.y=t.candleHover.lowY;break;case"OHLC":this.currentHover.y=t.candleHover.closestOHLCY;break;case"none":this.currentHover.y=t.y;break}else this.currentHover.y=t.y;this.currentHover.paneId=t.paneId,this.currentHoverSubject.next(this.currentHover)}updateCrossToolMobile(t){var e;if(!this.hoverProducer.longTouchActivatedSubject.getValue())return;const{fixed:s,temp:i,isSet:r}=this.crossEventProducer.crossToolTouchInfo;if(!r){this.updateCrossTool(t);return}const o=this.crossEventProducer.crossToolHover;if(o&&t.x===o.x&&t.y===o.y){const E=ho(co({},t),{x:o.x,y:o.y});this.crossEventProducer.crossToolHover=E,this.updateCrossTool(E);return}const a=this.canvasBoundsContainer.getBounds(M.PANE_UUID(t.paneId)),l=5,c=t.x-i.x,h=t.y-i.y,d=s.x+c,u=s.y+h,f=a.y+l,p=a.y+a.height-l,m=d<l?l:d>a.width-l?a.width-l:d,_=u<f?f:u>p?p:u,S=(e=this.hoverProducer.createHover(m,_,t.paneId))!=null?e:t,A=ho(co({},S),{x:m,y:_});this.crossEventProducer.crossToolHover=A,this.updateCrossTool(A)}}const Rt=4;function Au(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p;const m=r.align,_=(l=i.textFont)!=null?l:oe(r),S=i.bgColor,A=(c=i.textColor)!=null?c:re(S,o.labelTextColor,o.labelInvertedTextColor),E=(h=i.paddingTop)!=null?h:Rt,Y=(d=i.paddingBottom)!=null?d:Rt,B=(u=i.paddingEnd)!=null?u:Rt,R=Ee(Xt(_,n)/2),k=s-R-E,X=s+R+Y-k;if(a&&!gs(s,t,X))return;n.save(),n.fillStyle=S,n.strokeStyle=S;const U=Ee(t.width/6),Z=m==="right"?t.x:t.x+t.width,G=m==="right"?Z+U:Z-U,Q=r.labelBoxMargin.end,J=Q-B,tt=t.width-U-J;cd(n,G,k,Z,k+Ee(X/2),G,k+X,tt,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,m),n.fillStyle=A,n.font=_;const et=m==="right"?t.x+t.width-Mt(e,n,_)-Q:t.x+Q;n.fillText(e,et,s+R-1),n.restore()}function Eu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_,S,A;const E=r.align,Y=(l=i.textFont)!=null?l:oe(r),B=i.bgColor,R=(c=i.textColor)!=null?c:re(B,o.labelTextColor,o.labelInvertedTextColor),k=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,V=(u=(d=i.paddingTop)!=null?d:k==null?void 0:k.top)!=null?u:Rt,X=(p=(f=i.paddingBottom)!=null?f:k==null?void 0:k.bottom)!=null?p:Rt,U=(_=(m=i.paddingEnd)!=null?m:k==null?void 0:k.end)!=null?_:Rt,Z=i.paddingStart,G=Xt(Y,n),Q=s-G/2-V,tt=s+G/2+X-Q,et=(A=i.rounded)!=null?A:(S=r.typeConfig.rectangle)==null?void 0:S.rounded;if(a&&!gs(s,t,tt))return;n.save(),n.fillStyle=B,n.strokeStyle=B;const st=r.labelBoxMargin.end;n.font=Y;const ht=Mt(e,n,Y),ct=st-U,xt=Z!==void 0?ht+Z+U:t.width-ct,Zt=E==="right"?t.x+t.width-ct-xt:t.x+ct,te=E==="right"?t.x+t.width-ht-st:st;et?Rr(n,Zt,Q,xt,tt,4,!0):n.fillRect(Zt,Q,xt,tt),n.fillStyle=R,n.fillText(e,te,s+G/2-1),n.restore()}function Iu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_;const S=r.align,A=(l=i.textFont)!=null?l:oe(r),E=o.backgroundColor,Y=(c=i.textColor)!=null?c:re(E,o.labelTextColor,o.labelInvertedTextColor),B=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,R=(u=(d=i.paddingTop)!=null?d:B==null?void 0:B.top)!=null?u:Rt,k=(p=(f=i.paddingBottom)!=null?f:B==null?void 0:B.bottom)!=null?p:Rt,V=(_=(m=i.paddingEnd)!=null?m:B==null?void 0:B.end)!=null?_:Rt,X=i.paddingStart,U=Xt(A,n),Z=s-U/2-R,Q=s+U/2+k-Z;if(a&&!gs(s,t,Q))return;n.save(),n.fillStyle=E,n.strokeStyle=E;const J=r.labelBoxMargin.end;n.font=A;const tt=Mt(e,n,A),et=J-V,st=X!==void 0?tt+X+V:t.width-et,ht=S==="right"?t.x+t.width-et-st:t.x+et,ct=S==="right"?t.x+t.width-tt-J:J;n.fillStyle=E,n.strokeStyle=E,n.fillRect(ht,Z,st,Q),n.fillStyle=Y,n.fillText(e,ct,s+U/2-1),n.restore()}function Du(n,t,e=Rt){return Xt(n,t)/2+e}function gs(n,t,e){return!(n<t.y+e/2||n>t.y+t.height-e/2)}const Lu="badge",uo=4,fo={badge:Au,rectangle:Eu,plain:Iu};function po(n,t,e,s,i,r,o,a,l){var c,h,d,u,f;const p=r.y,m=r.labelText,_=(c=r.mode)!=null?c:"label",S=(h=r.labelType)!=null?h:Lu,A=r.description,E=(d=r.textFont)!=null?d:oe(a),Y=r.bgColor,B=(u=r.lineColor)!=null?u:Y,R=Mt(A!=null?A:"",n,E)+8,k=rt(r.y),V=Xt(E,n),X=p-V/2,Z=p+V/2-X;n.save(),n.fillStyle=Y,n.strokeStyle=B;const G=o.getBounds(M.PANE_UUID($)),Q=fo[S],J=a.labels.descriptions,tt=Ou(s,k,Z),et=()=>J&&Bu(e,t,s,i,r,a);let st,ht;const ct=2;a.align==="right"?(st=G.x,ht=J?G.x+G.width-R:G.x+G.width+ct):(st=J?G.x+R:G.x-ct,ht=G.x+G.width);const xt=(f=r.lineY)!=null?f:r.y,Zt=()=>tt&&he(n,()=>{var Ts;return hd(n,st,xt,ht,xt,1,(Ts=r.lineDash)!=null?Ts:[],r.lineCap)}),te=()=>Q(n,s,Qe(m),p,r,a,l.yAxis,!1),Ps={line:()=>{Zt(),et()},"line-label":()=>{Zt(),te(),et()},label:()=>{et(),te()}};_!=="none"&&gs(p,s,Z)&&Ps[_](),n.restore()}const Ou=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Bu(n,t,e,s,i,r){var o,a,l;const c=r.align||"right",h=i.description;if(!h||h.length===0)return;const d=i.y,u=oe(r),f=Mt(h,t,u),p=Xt(u,t),m=(o=i.paddingTop)!=null?o:uo,_=(a=i.paddingBottom)!=null?a:uo,S=d-p/2-m,E=d+p/2+_-S;t.save();const Y=f+5,B=4,R=f+B*2,k=s.x+s.width,V=c==="right"?k-R:s.x+B;Ah(n,t,V,S,Y,E,.8),t.fillStyle=(l=i.descColor)!=null?l:i.bgColor,t.font=u;const X=c==="right"?k-f-B*2:s.x+B*2;t.fillText(h,X,d+p/2-1),t.restore()}class go{constructor(t,e,s,i=()=>!0,r){this.config=t,this.canvasBoundsContainer=e,this.paneManager=s,this.crossDrawPredicate=i,this.noLines=r}draw(t,e){this.crossDrawPredicate()&&he(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var s,i,r,o,a;const l=this.canvasBoundsContainer.getBounds(M.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES,{extensionY:1e-4}),h=(s=this.config.components.xAxis.padding.top)!=null?s:0,d=(r=this.config.components.yAxis.typeConfig[(i=this.config.components.crossTool.yLabel.type)!=null?i:"badge"])==null?void 0:r.paddings,u=(o=d==null?void 0:d.start)!=null?o:0,f=(a=this.paneManager.panes[e.paneId])==null?void 0:a.ht;if(c(e.x,l.y)){const p={start:[l.x,e.y],end:[l.x+l.width+u,e.y]},m={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},_=f==null?void 0:f(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),_&&(t.moveTo(...p.start),t.lineTo(...p.end)),t.moveTo(...m.start),t.lineTo(...m.end),t.stroke()),_&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,i,r,o,a;const l=this.config.components.crossTool.xLabel.padding,c=this.config.components.crossTool.xLabel.margin,h=this.config.colors.crossTool;if(this.config.components.xAxis.visible){t.font=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily;const d=e.x,u=e.time,f=t.measureText(u).width,p=this.config.components.xAxis.fontSize,m=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const _=(s=l==null?void 0:l.left)!=null?s:0,S=(i=l==null?void 0:l.right)!=null?i:0,A=(r=l==null?void 0:l.top)!=null?r:0,E=(o=l==null?void 0:l.bottom)!=null?o:0,Y=(a=c==null?void 0:c.top)!=null?a:0,B=f+_+S,R=p+A+E,k=Math.max(d-B/2,0),V=m.y+Y+Oe/2;Rr(t,k,V,B,R),t.fillStyle=h.labelTextColor;const X=Math.max(d-f/2,_),U=m.y+Y+p+Oe/2+A-1;t.fillText(u,X,U),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,i=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const r=this.paneManager.panes[e.paneId],o=e.y,a=this.config.components.crossTool.yLabel.type;if(!r)return;for(const l of r.yExtentComponents){const c=l.regularValueFromY(o),h=l.valueFormatter(c),d=this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=fo[a],f=a==="plain"?i.lineColor:i.labelTextColor;u(t,d,h,o,{textColor:f,bgColor:i.labelBoxColor,paddingBottom:s==null?void 0:s.bottom,paddingEnd:s==null?void 0:s.end,paddingTop:s==null?void 0:s.top},l.yAxis.state,this.config.colors.yAxis,!0)}}}}class Ru{draw(){}}class Fu extends W{constructor(t,e,s,i,r,o,a,l,c){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=i,this.paneManager=r,this.crossEventProducer=o,this.hoverProducer=a,this.baselineModel=l,this.chartModel=c,this.crossToolTypeDrawers={},this.model=new Mu(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel,this.chartModel),this.addChildEntity(this.model);const h=new xe(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const d=new wu(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),u=new hn;u.addDrawer(h,"CLEAR_CANVAS"),u.addDrawer(d,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(u,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new go(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new go(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Ru)}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 Hu{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,s])=>{for(const i of s){const{model:r,drawer:o}=i;o.draw(this.canvasModel,r,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class Vt{constructor(t){this.data=t,this.next=null}}class ku{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 Vt(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 Vt(e);if(t===0)s.next=this.head,this._head=s;else{let i=this.head,r=i,o=0;for(;i&&o<t;)o++,r=i,i=i.next;s.next=i,r.next=s,t===this.length-1&&(this._tail=s)}this.length++}removeAt(t){if(!this.head||t<0||t>=this.length)return null;let e=this.head,s=e,i=0;if(t===0)this._head=e.next;else{for(;e.next&&i<t;)i++,s=e,e=e.next;s.next=e.next,t===this.length-1&&(this._tail=s)}this.length--}getNodePosition(t){let e=0,s=this.head;for(;s;){if(s.data===t.data)return e;s=s.next,e++}return-1}size(){return this.length}get head(){return this._head}get tail(){return this._tail}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.data,t=t.next}}class ju extends W{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this.orderChangedSubject=new F,this._objects=new ft({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new Vt(s);return i.getNodePosition(r)}addObject(t){var e,s;const i=t.paneId,r=this.objects,o=(e=r[i])!=null?e:new ku;Object.keys(r).find(a=>a===i)||(r[i]=o),o.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.uniqueObjects[i]||(this.uniqueObjects[i]=new Set),this.uniqueObjects[i].add((s=t.parentId)!=null?s:t.id),this.setDynamicObjects(r)}removeObject(t){var e;const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new Vt(i),a=r.getNodePosition(o);r.removeAt(a),this.modelIdToObjectMap.delete(t),this.uniqueObjects[i.paneId]&&this.uniqueObjects[i.paneId].delete((e=i.parentId)!=null?e:i.id),r.size()===0&&delete this.objects[i.paneId],this.setDynamicObjects(this.objects)}updateObject(t){const e=this.getObjectInfoById(t.id);if(!e)return;const[s]=e;this.removeObject(s.id),this.addObject(t)}moveToPosition(t,e){const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new Vt(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))}getPaneObjectIds(t){const e=this.objects[t];return e?[...e].map(s=>s.id):[]}setPaneOrder(t,e,s=!0){if(!this.objects[t]||e.length===0)return;const r=this.getPaneObjectIds(t),o=e.filter(c=>r.includes(c)),a=r.filter(c=>!o.includes(c)),l=[...o,...a];for(let c=0;c<l.length;c++){const h=l[c],d=this.getObjectPosition(h);d>=0&&d!==c&&this.moveToPosition(h,c)}s&&this.notifyOrderChanged()}reorderObjectIds(t,e,s=!0){const i=new Set(e),r=this.getPaneObjectIds(t).filter(o=>i.has(o));if(r.length!==0){for(const o of e)r.includes(o)&&this.moveObjectToFront(o);s&&this.notifyOrderChanged()}}notifyOrderChanged(){this.orderChangedSubject.next()}moveObjectToFront(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Vt(s),o=i.getNodePosition(r);o>=0&&o<i.size()&&(i.removeAt(o),i.insertAtEnd(s),this.setDynamicObjects(this.objects))}bringToFront(t){this.moveObjectToFront(t),this.notifyOrderChanged()}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Vt(s),o=i.getNodePosition(r);o>0&&o<=i.size()&&(i.removeAt(o),i.insertAt(0,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Vt(s),o=i.getNodePosition(r);o>=0&&o+1<i.size()&&(i.removeAt(o),i.insertAt(o+1,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new Vt(s),o=i.getNodePosition(r);o>0&&o<i.size()&&(i.removeAt(o),i.insertAt(o-1,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Yu extends W{constructor(t,e){super();const s=new ju(t);this.model=s,this.addChildEntity(s);const i=new Hu(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Nu=()=>n=>n.toString(),Xu=(n,t)=>{var e;const s="date.get"+(t((e=n.timezone)!=null?e:"")?"":"UTC"),i={YYYY:r("FullYear"),YY:r("FullYear")+" % 100",MMM:o("shortMonths","Month"),MMMM:a(o("shortMonths","Month")),M:"1+"+r("Month"),d:r("Date"),H:r("Hours"),m:r("Minutes"),s:r("Seconds"),sss:r("Milliseconds"),EEE:o("shortDays","Day"),SSS:"this.addTwoZeros("+r("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(l){i[l+l]="this.addZero("+i[l]+")"});function r(l){return s+l+"()"}function o(l,c){return"this."+l+"["+r(c)+"]"}function a(l){return l+".toUpperCase()"}return function(l){var c;const h={shortDays:Wu(n),shortMonths:zu(n),addZero(d){return d<10?"0"+d:d},addTwoZeros(d){return(d<100?"0":"")+(d<10?"0":"")+d},tzDate:t((c=n.timezone)!=null?c:"")||function(d){return new Date(+d)}};return d=>Vu(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function Wu(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function zu(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const mo=(n,t,e)=>{if(n){if(typeof n=="string")return e(n);if(Array.isArray(n)){const s=n.filter(i=>{if(i.showWhen){const r=[];return i.showWhen.periodLessThen&&r.push(()=>{var o,a;return t<((a=(o=i.showWhen)==null?void 0:o.periodLessThen)!=null?a:0)}),i.showWhen.periodMoreThen&&r.push(()=>{var o,a;return t>=((a=(o=i.showWhen)==null?void 0:o.periodMoreThen)!=null?a:0)}),r.every(o=>o())}else return!0});if(s.length>0){const i=s[0];if(i.format)return e(i.format);if(i.customFormatter)return i.customFormatter}}}return Nu()},Vu=(n,t,e,s)=>{t||(t="M/d/yyyy");const i=n.getDate(),r=n.getMonth(),o=n.getFullYear(),a=n.getHours(),l=n.getMinutes(),c=n.getSeconds(),h=n.getMilliseconds(),d=a%12,u=_e(d),f=_e(a),p=_e(l),m=_e(c),_=a<12?"AM":"PM",S=e[n.getDay()],A=S.substring(0,3),E=_e(i),Y=r+1,B=_e(Y),R=s[r],k=R.substring(0,3),V=o+"",X=V.substring(2,4);return t=t.replace("hh",u+"").replace("h",d+"").replace("HH",f+"").replace("H",a+"").replace("mm",p+"").replace("m",l+"").replace("ss",m+"").replace("s",c+"").replace("S",h+"").replace("dd",E+"").replace("d",i+"").replace("EEEE",S).replace("EEE",A).replace("YYYY",V).replace("yyyy",V).replace("YY",X).replace("yy",X).replace("aaa",_),t.indexOf("MMM")>-1?t=t.replace("MMMM",R).replace("MMM",k):t=t.replace("MM",B+"").replace("M",Y+""),t},_e=n=>typeof n=="number"&&n<10?"0"+n:n,Ye=(n,t)=>`${n}_${t}`,Uu=(n,t)=>{if(t){const e=vo(t.normal),s=vo(t.hover);return{type:n,normal:e,hover:s}}},vo=n=>{var t;const s=new DOMParser().parseFromString(n,"text/html").querySelector("svg");let i=0;s&&(i=parseInt((t=s.getAttribute("height"))!=null?t:"",10));const a="data:image/svg+xml;base64,"+btoa(n),l=new Image;return l.src=a,{img:l,svgHeight:i}},Gu=(n,t,e,s,i)=>{if(i){const r=t[Ye(s,"hover")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}else{const r=t[Ye(s,"normal")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}},Zu={"rhombus-small":4,rhombus:6,"rhombus-large":8},$u=["earnings","dividends","splits","conference-calls"];class Ku{constructor(t,e,s,i,r,o){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.formatterProvider=o,this.customIcons={};const a=this.config.components.events.icons;a&&$u.forEach(l=>{const c=Uu(l,a[l]);c&&(this.customIcons[Ye(c.type,"normal")]=c.normal,this.customIcons[Ye(c.type,"hover")]=c.hover)})}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(M.EVENTS),e=this.canvasBoundsContainer.getBounds(M.ALL_PANES),s=this.canvasModel.ctx;s.save(),this.model.events.filter(i=>this.config.components.events.eventsVisibility[i.type]).forEach(i=>{var r,o,a,l;const c=this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale);if(c>e.x&&c<e.x+e.width){const h=this.config.colors.events[i.type];if(s.strokeStyle=(o=(r=h.line)!=null?r:h.normal)!=null?o:h.color,this.customIcons[Ye(i.type,"hover")]!==void 0){const d={x:c,y:t.y+t.height/2},u=this.model.hoveredEvent.getValue()===i;Gu(s,this.customIcons,d,i.type,u)}else this.drawDefaultEvent(s,c,t,i,h);if(this.model.hoveredEvent.getValue()===i){const d=this.config.components.events.line,u=d&&d[i.type]&&((a=d[i.type])==null?void 0:a.width),f=d&&d[i.type]&&((l=d[i.type])==null?void 0:l.dash);s.lineWidth=u!=null?u:1,s.beginPath(),s.setLineDash(f!=null?f:[]),s.moveTo(c,e.y),s.lineTo(c,t.y+t.height/2),s.stroke(),s.closePath(),this.config.components.xAxis.visible&&this.drawLabel(c,i)}}}),s.restore()}drawDefaultEvent(t,e,s,i,r){var o,a,l;const c=s.y+s.height/2;t.fillStyle=(o=r.normal)!=null?o:r.color,t.lineWidth=1.5;const h=dn(i);t.beginPath(),t.moveTo(e-h,c),t.lineTo(e,c-h),t.lineTo(e+h,c),t.lineTo(e,c+h),t.closePath(),this.model.hoveredEvent.getValue()===i?(t.fillStyle=(a=r.hover)!=null?a:r.color,t.fill()):(t.strokeStyle=(l=r.normal)!=null?l:r.color,t.stroke())}drawLabel(t,e){var s;const i=this.canvasModel.ctx,r=this.canvasBoundsContainer.getBounds(M.X_AXIS),o=this.config.components.xAxis.fontFamily,a=this.config.components.xAxis.fontSize,l=(s=this.config.components.xAxis.padding.top)!=null?s:0,c=r.y+a-1+l;i.font=`${a}px ${o}`;const h=this.formatterProvider()(e.timestamp),d=i.measureText(h).width;i.fillStyle=this.config.colors.xAxis.backgroundColor,i.strokeStyle=this.config.colors.xAxis.backgroundColor,i.fillRect(t-d/2,r.y+1,d,r.height-1),i.fillStyle=this.config.colors.events[e.type].color,i.fillText(h,t-d/2,c)}getCanvasIds(){return[this.canvasModel.canvasId]}}function dn(n){return Zu[n.style]}const ms=5;class qu{constructor(t,e,s,i,r,o=()=>!0){this.hitTestCanvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.drawPredicate=o}draw(){if(this.drawPredicate()){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(M.EVENTS);t.save(),this.model.events.forEach((s,i)=>{if(!this.config.components.events.eventsVisibility[s.type])return;const o=this.model.events[i-1],a=o&&this.chartModel.candleFromTimestamp(o.timestamp).xCenter(this.chartModel.scale),l=this.chartModel.candleFromTimestamp(s.timestamp).xCenter(this.chartModel.scale);if(l>e.x&&l<e.x+e.width){const c=this.config.colors.events[s.type].color;t.strokeStyle=c,t.fillStyle=c;const h=dn(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+ms)*2;if(a!==void 0){const u=dn(o);if(this.config.components.events.eventsVisibility[o.type]&&a+u>l-d/2){const m=h*2+ms;t.fillRect(a+u,e.y,m,e.height)}else t.fillRect(l-h-ms,e.y,d,e.height)}else t.fillRect(l-h-ms,e.y,d,e.height)}}),t.restore()}}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var Ju=Object.defineProperty,bo=Object.getOwnPropertySymbols,Qu=Object.prototype.hasOwnProperty,tf=Object.prototype.propertyIsEnumerable,Co=(n,t,e)=>t in n?Ju(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ef=(n,t)=>{for(var e in t||(t={}))Qu.call(t,e)&&Co(n,e,t[e]);if(bo)for(var e of bo(t))tf.call(t,e)&&Co(n,e,t[e]);return n};const yo=317,un={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999]};class sf extends Xr{constructor(t,e,s,i,r,o,a,l){super(t,e,r,a,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=s,this.canvasBoundsContainer=i,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new F,this.touchStartSubject=new F,this.dblClickSubject=new F,this.rightClickSubject=new F,this.hitTestDrawersPredicateSubject=new ft(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,Wr(this,o),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(Et(100,Bt,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(lt(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=wt(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(lt(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=wt(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(lt(()=>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(lt(()=>ef({},this.canvasInputListener.currentPoint))).subscribe(c=>{this.eventHandler(c,"contextmenu")}),l=this.canvasInputListener.observeWheel(t).subscribe(c=>setTimeout(()=>this.eventHandler(c,"zoom"),0));this.eventsSubscriptions.push(e,i,o,a,l,s,r)}}disableUserControls(){this.eventsSubscriptions.forEach(t=>t.unsubscribe()),this.eventsSubscriptions=[]}addSubscriber(t){this.hitTestSubscribers.push(t)}removeSubscriber(t){this.hitTestSubscribers=this.hitTestSubscribers.filter(e=>e===t)}idToColor(t){const e=(t*yo).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/yo}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!==Ys&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=Ys),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),s=this.colorToId(e[0]*65536+e[1]*256+e[2]),i=Number(s),[r]=fn(this.hitTestSubscribers,i);return r==null?void 0:r.lookup(s)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const s=this.getPixel(t.x,t.y),i=this.colorToId(s[0]*65536+s[1]*256+s[2]),r=Number(i),[o]=fn(this.hitTestSubscribers,r),a=o==null?void 0:o.lookup(i);return(e=o==null?void 0:o.resolveCursor)==null?void 0:e.call(o,t,a)}eventHandler(t,e){var s,i,r,o,a,l,c;const h=this.getPixel(t.x,t.y),d=this.colorToId(h[0]*65536+h[1]*256+h[2]),u=Number(d),[f,p]=fn(this.hitTestSubscribers,u),m=f==null?void 0:f.lookup(d),_={point:t,model:m};switch(e){case"mousedown":m&&((s=f==null?void 0:f.onMouseDown)==null||s.call(f,m,t)),p.forEach(S=>S.onMouseDown&&S.onMouseDown(null,t));break;case"mouseup":m&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,m,t)),p.forEach(S=>S.onMouseUp&&S.onMouseUp(null,t));break;case"hover":m&&((r=f==null?void 0:f.onHover)==null||r.call(f,m,t)),p.forEach(S=>S.onHover&&S.onHover(null,t)),this.hoverSubject.next(_);break;case"touchstart":m&&((o=f==null?void 0:f.onTouchStart)==null||o.call(f,m,t)),p.forEach(S=>S.onTouchStart&&S.onTouchStart(null,t)),this.touchStartSubject.next(_);break;case"dblclick":m&&((a=f==null?void 0:f.onDblClick)==null||a.call(f,m,t)),this.dblClickSubject.next(_);break;case"contextmenu":m&&((l=f==null?void 0:f.onRightClick)==null||l.call(f,m,t)),this.rightClickSubject.next(_);break;case"zoom":m&&((c=f==null?void 0:f.onZoom)==null||c.call(f,m,t)),p.forEach(S=>S.onZoom&&S.onZoom(null,t));break;default:break}}}const fn=(n,t)=>{let e;const s=[];return n.forEach(i=>{const[r,o]=i.getIdRange();t>=r&&t<=o?e=i:s.push(i)}),[e,s]};var nf=Object.defineProperty,rf=Object.defineProperties,of=Object.getOwnPropertyDescriptors,wo=Object.getOwnPropertySymbols,af=Object.prototype.hasOwnProperty,lf=Object.prototype.propertyIsEnumerable,So=(n,t,e)=>t in n?nf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,cf=(n,t)=>{for(var e in t||(t={}))af.call(t,e)&&So(n,e,t[e]);if(wo)for(var e of wo(t))lf.call(t,e)&&So(n,e,t[e]);return n},hf=(n,t)=>rf(n,of(t));class df extends W{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ft(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>hf(cf({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return un.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 uf extends W{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>mo(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new df(e);this.eventsModel=c,this.addChildEntity(c),s.addSubscriber(c);const h=new Ku(e,i,t,r,c,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(h,"EVENTS");const d=new qu(s,i,t,r,c,()=>s.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(d,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(M.EVENTS,t.components.events.cursor)}setEvents(t){this.eventsModel.setEvents(t),this.canvasModel.fireDraw()}setVisible(t){this.config.components.events.visible=t,this.canvasBoundsContainer.recalculateBounds(),this.canvasModel.fireDraw()}setEventTypeVisible(t){At(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class ff{constructor(t,e,s,i,r,o,a,l,c=()=>!0,h,d,u){this.canvasModel=t,this.viewportModel=e,this.config=s,this.yAxisState=i,this.xBoundsProvider=r,this.yBoundsProvider=o,this.xLabelsProvider=a,this.yLabelsProvider=l,this.drawPredicate=c,this.extentIdx=h,this.getBaseline=d,this.mainExtentIdx=u}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;he(t,()=>this.drawVertical(t)),he(t,()=>this.drawHorizontal(t)),he(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.extentIdx===0&&this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const s=this.xBoundsProvider(),i=rt(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(s.x,i),t.lineTo(s.x+s.width,i),t.stroke(),t.closePath()}}drawVertical(t){const e=this.xLabelsProvider();if(e.length&&this.config.components.grid.vertical){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.xBoundsProvider(),i=s.x+s.width;for(const r of e){const o=It(this.viewportModel.toX(r.value));o>s.x&&o<i&&(t.beginPath(),t.moveTo(o,s.y),t.lineTo(o,s.y+s.height),t.stroke())}}}drawHorizontal(t){const e=this.yLabelsProvider();if(e.length>0&&this.config.components.grid.horizontal&&this.extentIdx===this.mainExtentIdx){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.yBoundsProvider();for(const i of e){const r=rt(this.viewportModel.toY(i.value)),o=Du(i.text,t,Rt);r>s.y+o&&r<s.y+s.height-o&&(t.beginPath(),t.moveTo(s.x,r),t.lineTo(s.x+s.width,r),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class xo extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new ff(t,e,s,i,a,l,c,h,f,d,u,p)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class pf{constructor(t,e,s,i){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+s,a=r+i,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,o,t,"high"),this.drawMarkerLabel(l,a,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,i){const r=this.getMarkerY(t,s,i==="low"),o=ts(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(s,i),c=this.getMarkerX(t,e,l);t.fillStyle=i==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(l,c,r);const h=this.canvasBoundsContainer.getBounds("PANE_CHART");Kt(t,h)}getMarkerText(t,e){const s=this.chartModel.pane.regularFormatter(t);return`${e==="high"?this.config.components.highLow.prefix.high:this.config.components.highLow.prefix.low} ${s}`}getMarkerY(t,e,s=!1){const i=this.chartModel.toY(e);if(s){const r=ts(t,!1);return i+r}return i}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(M.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,s){let i=this.chartModel.toX(e);const r=this.canvasBoundsContainer.getBounds(M.CHART),o=4,a=t.measureText(s).width;return i+o+a>r.width&&(i=i-(o+a)),i+o}getCanvasIds(){return[this.canvasModel.canvasId]}}class gf extends W{constructor(t,e,s,i,r){super();const o=new pf(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const mf=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],vf=1440*60*1e3;class bf extends W{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new F}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()+vf;Zl(this.highlights,t,e,Cf).forEach(i=>{var r;this.visualHighlights[i.type]||(this.visualHighlights[i.type]=[]),(r=this.visualHighlights[i.type])==null||r.push(i)})}setHighlights(t){this.highlights=t,this.highlights.sort((e,s)=>e.to-s.to),this.highlightsUpdatedSubject.next(this.highlights),this.highlights.length?this.recalculateVisualHighlights():this.visualHighlights={}}observeHighlightsUpdated(){return this.highlightsUpdatedSubject.asObservable()}}const Cf=n=>n.to,Jt=[20,10];class yf{constructor(t,e,s,i,r){this.highlightsModel=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.config=r}draw(){var t,e,s,i;if(this.config.components.highlights.visible){const r=this.chartModel.getCandles(),o=this.canvasModel.ctx,a=this.highlightsModel.getVisualHighlights();if(this.highlightsModel.getHighlights().length&&r.length!==0&&this.chartModel.scale.isScaleReady()){const c=this.canvasBoundsContainer.getBounds(M.ALL_PANES);o.save(),Kt(o,c);const h=(t=this.config.components.highlights.border.width)!=null?t:1,d=(e=this.config.components.highlights.border.dash)!=null?e:[0,0],u=(s=this.config.components.highlights.fontSize)!=null?s:11,f=(i=this.config.components.highlights.fontFamily)!=null?i:"monospace",p=`${u}px ${f}, monospace`;o.font=p,o.lineWidth=h,o.setLineDash(d),mf.forEach(m=>{var _,S;const A=a[m];if(A){const E=this.config.colors.highlights[m],Y=(_=E==null?void 0:E.border)!=null?_:"#ffffff",B=(S=E==null?void 0:E.background)!=null?S:"#ffffff";o.save(),o.beginPath(),o.fillStyle=B,o.strokeStyle=Y,A.forEach(R=>{var k,V,X;const U=this.chartModel.chartBaseModel.period,Z=this.chartModel.getCandleTimestampAnchor(),G=this.chartModel.getCandles(),Q=this.resolveHighlightFromCandle(R.from,G,U,Z),J=bt(Q.width,this.chartModel.scale.zoomX),tt=Q.xStart(this.chartModel.scale),et=this.resolveHighlightToCandle(R.to,G,U,Z),st=bt(et.width,this.chartModel.scale.zoomX),ht=et.xStart(this.chartModel.scale)+st;if(R.border&&this.drawBorders(R.border,o,tt+J,ht-st,c),o.fillRect(tt,c.y,ht-tt,c.y+c.height),R.label){const ct=(k=R.label.text)!=null?k:"",xt=this.config.colors.highlights[R.type];o.save(),o.fillStyle=(V=xt==null?void 0:xt.label)!=null?V:"#ffffff";const Zt=Mt(ct,o,p),[te,_s]=this.resolveHighlightLabelPosition((X=R.label.placement)!=null?X:"left-left",c,[tt,ht],Zt);o.fillText(ct,te,_s),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}findHighlightStartIndex(t,e,s,i){return i==="open"?be(e,{extrapolate:!1,candleTimestampAnchor:"open"},t,s).index:t.findIndex((r,o)=>Hc(t,o,s,"close")===e)}resolveHighlightFromCandle(t,e,s,i){const r=this.findHighlightStartIndex(e,t,s,i);return r>=0?this.chartModel.candleFromIdx(r):this.chartModel.candleFromTimestamp(t)}resolveHighlightToCandle(t,e,s,i){const r=this.getHighlightEndLookupTimestamp(t,s,i);return this.chartModel.candleFromTimestamp(r)}getHighlightEndLookupTimestamp(t,e,s){return s==="close"?t-1:t-e}resolveHighlightLabelPosition(t,e,s,i){const[r,o]=s;switch(t){case"right-left":return[o-Jt[1]-i,e.y+Jt[0]];case"left-left":return[r-Jt[1]-i,e.y+Jt[0]];case"right-right":return[o+Jt[1],e.y+Jt[0]];default:return[r+Jt[1],e.y+Jt[0]]}}drawBorders(t,e,s,i,r){const o=t.left,a=t.right;o&&(e.beginPath(),e.moveTo(s,r.y),e.lineTo(s,r.y+r.height),e.stroke(),e.closePath()),a&&(e.beginPath(),e.moveTo(i,r.y),e.lineTo(i,r.y+r.height),e.stroke(),e.closePath())}getCanvasIds(){return[this.canvasModel.canvasId]}}const wf="HIGHLIGHTS_PLUGIN";class Sf extends W{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new bf(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new yf(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,wf)}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 xf(){return N(function(n,t){var e,s=!1;n.subscribe(yt(t,function(i){var r=e;e=i,s&&t.next([r,i]),s=!0}))})}function K(n,t){return N(function(e,s){var i=0;e.subscribe(yt(s,function(r){return n.call(t,r,i++)&&s.next(r)}))})}var _f=Object.defineProperty,Pf=Object.defineProperties,Tf=Object.getOwnPropertyDescriptors,_o=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Af=Object.prototype.propertyIsEnumerable,Po=(n,t,e)=>t in n?_f(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,To=(n,t)=>{for(var e in t||(t={}))Mf.call(t,e)&&Po(n,e,t[e]);if(_o)for(var e of _o(t))Af.call(t,e)&&Po(n,e,t[e]);return n},Mo=(n,t)=>Pf(n,Tf(t));const Ut=4;class Ef{constructor(t,e,s,i,r,o){this.config=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.formatterFactory=r,this.visualCandlesProvider=o}draw(){if(this.config.components.navigationMap.visible){const t=this.visualCandlesProvider();if(t.length){const e=this.canvasBoundsContainer.getBounds(M.N_MAP),s=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_L),i=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_R),r=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_L),o=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_R),a=this.canvasBoundsContainer.getBounds(M.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),c=this.canvasModel.ctx;c.fillStyle=this.config.colors.navigationMap.backgroundColor,c.fillRect(e.x,e.y,e.width,e.height),c.strokeStyle=this.config.colors.paneResizer.lineColor,c.lineWidth=1,c.beginPath(),c.moveTo(e.x,e.y),c.lineTo(e.x+e.width,e.y),c.closePath(),c.stroke(),s.width!==0&&this.drawLeftArrowButton(c,s,this.config),i.width!==0&&this.drawRightArrowButton(c,i,this.config),c.fillStyle=this.config.colors.navigationMap.mapFillColor,c.beginPath(),c.moveTo(l.x,l.y+l.height);for(const h of t)c.lineTo(h[0],h[1]);if(c.lineTo(l.x+l.width,l.y+l.height),c.lineTo(l.x,l.y+l.height),c.closePath(),this.config.colors.navigationMap.mapGradientTopColor&&this.config.colors.navigationMap.mapGradientBottomColor){const h=c.createLinearGradient(l.x,l.y,l.x,l.y+l.height);h.addColorStop(0,this.config.colors.navigationMap.mapGradientTopColor),h.addColorStop(1,this.config.colors.navigationMap.mapGradientBottomColor),c.fillStyle=h}c.fill(),this.config.colors.navigationMap.mapColor&&(c.strokeStyle=this.config.colors.navigationMap.mapColor,c.stroke()),this.drawSlider(c,r,o,s,a),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,s,i){t.x<=s.x+s.width&&(t.x=s.x+s.width,i.x=t.x+t.width,e.x=i.x+i.width)}drawSlider(t,e,s,i,r){this.blockDrawSliderOnLeftArrow(e,s,i,r),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,s,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(r.x,r.y,r.width,r.height)}drawLeftArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Ut/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r),t.lineTo(i+Ut,r+Ut),t.lineTo(i+Ut,r-Ut),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawRightArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Ut/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r-Ut),t.lineTo(i,r+Ut),t.lineTo(i+Ut,r),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,s,i){const r=s.components.navigationMap.knots.border;t.fillStyle=s.colors.navigationMap.knotColor;const o=i?e.x-r:e.x+r;t.fillRect(o,e.y,e.width,e.height),t.lineWidth=s.components.navigationMap.knots.lineWidth,r>0&&(t.beginPath(),t.moveTo(o,e.y),t.lineTo(o,e.y+e.height),t.lineTo(o+e.width,e.y+e.height),t.lineTo(o+e.width,e.y),t.lineTo(o,e.y),t.lineWidth=r,t.strokeStyle=s.colors.navigationMap.knotBorderColor,t.stroke()),t.beginPath(),t.moveTo(o+e.width/2,e.y+e.height/4),t.lineTo(o+e.width/2,e.y+3*e.height/4),t.strokeStyle=s.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=vt(this.chartModel.mainCandleSeries.getSeriesInViewport()),s=this.config.components.navigationMap.timeLabels,i=s.visible;if(e.length&&i){const r=e[0].candle.timestamp,o=e[e.length-1].candle.timestamp,a=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:s.fontFamily,textSize:`${s.fontSize}px`},d={dateFormat:s.dateFormat,padding:s.padding,textProperties:Mo(To({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:Mo(To({},h),{textAlign:"right"})};this.drawTimeLabel(t,a,r,d),this.drawTimeLabel(t,l,o,u)}}drawTimeLabel(t,e,s,i){const r=i.padding,o=xi(s,i.dateFormat,this.formatterFactory);bi(t,i.textProperties);const a=ts(t),l=yi(o);Kl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}function Ao(n,t){return N(function(e,s){var i=null,r=0,o=!1,a=function(){return o&&!i&&s.complete()};e.subscribe(yt(s,function(l){i==null||i.unsubscribe();var c=0,h=r++;Lt(n(l,h)).subscribe(i=yt(s,function(d){return s.next(t?t(l,d,h,c++):d)},function(){i=null,a()}))},function(){o=!0,a()}))})}class Ne extends Ur{constructor(t,e,s,i,r=Vr,o){super(t,e,s,i,r),this.shouldThrottleSubject=new ft(!!o)}setShouldThrottle(t){this.shouldThrottleSubject.next(t)}doActivate(){const t=zt;super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeXDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.shouldThrottleSubject.pipe(mt(),Ao(e=>this.canvasInputListener.observeXDrag().pipe(e?Et(t,Bt,{trailing:!0,leading:!0}):ne))).subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const Eo=4;class If extends W{constructor(t,e,s,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.leftKnotDragStartXRelative=f.x-p.x-Eo},this.leftKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,S=(this.leftKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.leftRatio=S,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.rightKnotDragStartXRelative=f.x-p.x+Eo},this.rightKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,S=(this.rightKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.rightRatio=S,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=f=>{const{delta:p}=f,m=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),_=this.chartModel.mainCandleSeries.meanCandleWidth/(m.width/this.chartModel.mainCandleSeries.dataPoints.length),S=(this.lastMousePosition-p)*_;this.scale.moveXStart(this.scale.xStart-S),this.lastMousePosition=p};const a=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_R),c=new Ne(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Ne(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_SLIDER_WINDOW),u=new Ne(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_L);this.addRxSubscription(this.canvasInputListeners.observeClick(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)}));const e=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_R);this.addRxSubscription(this.canvasInputListeners.observeClick(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>{const s=this.chartModel.mainCandleSeries;this.canvasBoundsContainer.leftRatio=s.dataIdxStart/(s.dataPoints.length-1),this.canvasBoundsContainer.rightRatio=s.dataIdxEnd/(s.dataPoints.length-1),this.canvasBoundsContainer.recalculateNavigationMapElementBounds(),this.bus.fireDraw()}))}}class Df extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new Ef(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,M.N_MAP_CHART),this.navigationMapMoveHandler=new If(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(M.N_MAP_CHART,i.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(M.N_MAP_BTN_L,i.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(M.N_MAP_BTN_R,i.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(M.N_MAP_KNOT_L,i.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(M.N_MAP_KNOT_R,i.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(M.N_MAP_SLIDER_WINDOW,i.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(M.N_MAP),this.chartModel.scale.xChanged.pipe(xf(),K(([t,e])=>{const i=t.start<0||t.end>0,r=e.start<0||e.end>0;return i&&!r||r}))).subscribe(()=>{this.config.components.navigationMap.visible&&(this.visualCandles=this.makeVisualCandles(),this.canvasModel.fireDraw())}))}makeVisualCandles(){var t;const e=this.chartModel.getCandles();if(!e.length)return[];const s=this.chartModel.mainCandleSeries.dataIdxStart,i=this.chartModel.mainCandleSeries.dataIdxEnd,r=Math.round(Math.max(-s,0)),o=Math.max(this.chartModel.getCandlesCountWithRightOffset(),i)+r;let a=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),h=c.width,d=[];let u=0,f,p;for(f=0;f<h;f++)p=rt(f*o/h)-r,p in e?(d[f]=e[p].close,u=(t=d[f])!=null?t:0,a=Math.max(a,u),l=Math.min(l,u)):d[f]=0;return a-=l,d.map((m,_)=>[_+c.x,(a+l-m)*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())}}const vs=()=>{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"},yv=(n,t)=>n==="apple"||n==="mobile"?3:t;var pn=Math.pow;class Io extends W{constructor(t,e,s,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=zt,this.chartPanningOptions={horizontal:!0,vertical:!0},this.zoomXHandler=(h,d)=>{const u=h.deltaY<0;if(this.config.scale.zoomToCursor){const p=this.canvasBoundsContainer.getBounds(M.CANVAS).width,_=h.offsetX/p;this.scale.zoomXToPercent(_,u,!1,d)}else this.scale.zoomXToEnd(u,d);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(me),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=h=>{const{delta:d}=h;this.currentPoint.x=d;const u=kt(d,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-u),this.bus.fireDraw()},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)};const c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.dragNDropXComponent=new Ne(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.horizontal},this.config.components.yAxis.type==="percent"),this.addChildEntity(this.dragNDropXComponent)}setChartAreaXDragThrottled(t){this.dragNDropXComponent.setShouldThrottle(t)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeWheel(t).pipe(K(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),Et(this.wheelThrottleTime,Bt,{trailing:!0,leading:!0})).subscribe(e=>{const s=vs(),i=s==="apple"||s==="mobile"?-1:1,r=0+e.deltaX*i,o=0+e.deltaY*i;if(e.ctrlKey){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw();return}if(o!==0&&Math.abs(o)>Math.abs(r)){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw()}if(r!==0&&Math.abs(r)>Math.abs(o)){const a=kt(r,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-a),this.bus.fireDraw();return}})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e}))}calculateDynamicSesitivity(t,e){const i=Math.max(Math.abs(t.deltaY),Math.abs(t.deltaX)),r=e*i/100;return Il(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(me),this.currentPoint={x:0,y:0},s=t.yStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},r=l=>{const{delta:c}=l;if(this.currentPoint.y=c,t.state.auto)Lf(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const h=kt(t.state.inverse?-c:c,t.zoomY);t.moveYStart(s+h)}},o=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},a=new fs(e,{onDragTick:r,onDragStart:i,onDragEnd:o},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.vertical});return this.addChildEntity(a),a}}const Lf=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=pn(pn(Math.abs(n.x),2)+pn(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},Of=2;class Bf extends W{constructor(t,e,s,i,r){super(),this.chartAreaPanHandler=t,this.scale=e,this.canvasInputListeners=s,this.mainCanvasParent=i,this.hitTest=r,this.touchedCandleIndexes=[0,0],this.canvasTouchInfo={touchStart:{x:0,y:0},isMoving:!1}}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart(this.hitTest).subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove(this.hitTest).subscribe(t=>this.handleTouchMoveEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(t=>this.handleTouchEndEvent(t)))}handleTouchStartEvent(t){const{clientX:e,clientY:s}=t.touches[0];t.touches.length===1&&(this.canvasTouchInfo.touchStart={x:e,y:s}),t.touches.length===2&&(this.chartAreaPanHandler.deactivate(),this.touchedCandleIndexes=this.getXPositions(t).map(i=>this.scale.fromX(i)))}handleTouchMoveEvent(t){const{clientX:e,clientY:s}=t.touches[0],{touchStart:i}=this.canvasTouchInfo;t.touches.length===1&&(this.canvasTouchInfo.isMoving=Do(e,i.x,s,i.y)),t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}handleTouchEndEvent(t){this.canvasTouchInfo.isMoving=!1,t.touches.length===0&&this.chartAreaPanHandler.activate()}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),s=[0,0],i=document.body.scrollLeft||document.documentElement.scrollLeft;for(let r=0,o=t.touches.length;r<o;r++){const a=t.touches[r];s[r]=a.pageX-e.left-i}return s}pinchHandler(t,e){const s=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),i=s+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;s>=i||e[0]===e[1]||this.scale.setXScale(s,i)}}const Do=(n,t,e,s,i=Of)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i,wv={MAX_DIMENSION:2048,MAX_TOTAL_PIXELS:18e5,ZOOM_OPTIMIZED_PIXELS:12e5},Rf=2e6,Ff=24,Hf=20,kf=16,jf=10,Yf=1e3,Sv=5e4,xv={MIN:60,LOW:80,MEDIUM:100,HIGH:120,MAX:150};class Nf extends Io{constructor(t,e,s,i,r,o,a,l){super(t,e,s,i,r,o,a,l),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=zt,this.wheelSubscription=null,this.initFrameId=null,this.isActivated=!1,this.lastWheelTime=0,this.wheelCount=0,this.consecutiveLowWheelEvents=0,this.chartPanningOptions={horizontal:!0,vertical:!0}}doActivate(){this.isActivated||(this.isActivated=!0,super.doActivate(),this.canvasInputListener.initializeRectCache(),this.createWheelSubscription(),this.initFrameId=requestAnimationFrame(()=>{this.bus.fireDraw()}),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:t})=>{this.lastXStart+=t})),this.addRxSubscription(this.bus.observe(hs).pipe(qr(100)).subscribe(()=>{this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation()})))}createWheelSubscription(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null);const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),e=this.canvasBoundsContainer.getBounds(M.CANVAS),s=e.width*e.height;s>0?s>Rf?this.wheelThrottleTime=Ff:this.wheelThrottleTime=Hf:this.wheelThrottleTime=kf,this.wheelSubscription=this.canvasInputListener.observeWheel(t).pipe(K(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),K(i=>vs()==="apple"?Math.abs(i.deltaY)>1||Math.abs(i.deltaX)>1:!0),Et(this.wheelThrottleTime,Bt,{trailing:!0,leading:!0})).subscribe(i=>{const r=performance.now();this.lastWheelTime||(this.lastWheelTime=r,this.wheelCount=0),this.wheelCount++,r-this.lastWheelTime>Yf&&(Math.round(this.wheelCount*1e3/(r-this.lastWheelTime))<jf?(this.consecutiveLowWheelEvents++,this.consecutiveLowWheelEvents>=1&&(this.triggerPerformanceCleanup(),this.consecutiveLowWheelEvents=0)):this.consecutiveLowWheelEvents=0,this.lastWheelTime=r,this.wheelCount=0);const o=vs(),a=o==="apple"||o==="mobile"?-1:1,l=0+i.deltaX*a,c=0+i.deltaY*a;if(i.ctrlKey){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw();return}if(c!==0&&Math.abs(c)>Math.abs(l)){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw()}if(l!==0&&Math.abs(l)>Math.abs(c)){const h=kt(l,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-h),this.bus.fireDraw();return}}),this.addRxSubscription(this.wheelSubscription)}triggerPerformanceCleanup(){window.dispatchEvent(new Event("resize")),window.gc&&window.gc(),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation(),this.consecutiveLowWheelEvents=0,this.wheelCount=0,this.lastWheelTime=0}doDeactivate(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.isActivated=!1,super.doDeactivate()}}class Xf extends W{constructor(t,e,s,i,r,o,a,l,c){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.hitTestCanvasModel=c;const h=[this.eventBus,this.config,this.mainScale,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this,this.hitTestCanvasModel],d=Ie?new Nf(...h):new Io(...h);this.chartAreaPanHandler=d,this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new Bf(this.chartAreaPanHandler,this.mainScale,this.canvasInputListener,this.mainCanvasParent,this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES)),this.addChildEntity(this.mainCanvasTouchHandler)}activateChartPanHandlers(){this.activate()}deactivatePanHandlers(){this.deactivate()}setChartPanningOptions(t,e){this.chartAreaPanHandler.chartPanningOptions={horizontal:t,vertical:e}}}const Lo=n=>t=>{const{top:e,bottom:s}=n(),i=t.high-t.low,r=i===0?1:i,o=r*e/100,a=r*s/100,l=t.low-a,c=t.high+o;return{low:l,high:c}},Oo=(n,t)=>{const e=Lo(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function Wf(){return $n(1)}function Bo(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Wf()(Ze(n,Ge(n)))}function gn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n);return N(function(s,i){(e?Bo(n,s,e):Bo(n,s)).subscribe(i)})}function zf(n){return K(function(t,e){return n<=e})}class Vf{constructor(t,e,s,i,r){this.config=t,this.boundsProvider=e,this.canvasModel=s,this.canvasAnimation=i,this.animationId=r}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),s=this.canvasModel.ctx,i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),r=this.config.components.paneResizer.dragZone;!t&&i&&(s.fillStyle=i.getColor(0),s.fillRect(e.x,e.y-r,e.width,e.height+2*r)),s.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?s.fillRect(e.x,e.y,e.width,e.height):s.fillRect(e.x,e.y-r,e.width,e.height+2*r)}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Ro=8;class mn extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=i,this.dragPredicate=r,this.chartPanComponent=o,this.canvasModel=a,this.drawingManager=l,this.canvasInputListener=c,this.canvasAnimation=h,this.config=d,this.canvasBoundsContainer=u,this.hitTestCanvasModel=f,this.initialY=0,this.resizeEvent$=new F,this.onYDragStartMobile=()=>{this.config.components.crossTool.type="none",this.onYDragStart()},this.onYDragStart=()=>{this.initialY=this.boundsProvider().y,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1),this.chartPanComponent.deactivatePanHandlers()},this.onYDragEndMobile=()=>{this.config.components.crossTool.type="cross-and-labels",this.onYDragEnd()},this.onYDragEnd=()=>{this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0),this.chartPanComponent.activateChartPanHandlers()},this.onYDragTick=p=>{const{delta:m,draggedPixels:_}=p;Math.abs(this.initialY-this.boundsProvider().y+_)>=0&&(this.dragTickCb(m),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new fs(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:Ot()?this.onYDragStartMobile:this.onYDragStart,onDragEnd:Ot()?this.onYDragEndMobile:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:this.dragPredicate});this.addChildEntity(s),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(gn(!1),K(this.dragPredicate),mt(),zf(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Vf(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,zr.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(zr.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 vn=1/32,Uf=n=>{const t=Math.floor(n),e=n-t,s=Math.round(e*64),r=Math.floor(s/2).toString().padStart(2,"0");return`${t}'${r}`},Fo=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),_v=n=>!!Fo(n),Pv=n=>{const t=Fo(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*vn;return e+i}return Number(n)},Gf=(n,t)=>e=>{let s;if(typeof e=="number")s=e;else if(typeof e=="string")s=Number(e);else return"\u2014";const i=t.treasuryFormat;if(i&&i.enabled)return Uf(s);const[r]=n.dataSeries;if(r!==void 0){const o=ye.getPricePrecision(s,r.pricePrecisions);return s.toFixed(o)}return`${s}`},Zf=n=>(t,e)=>{if(t===0)return"0.00 %";const[s]=n.dataSeries;let i=t;const r=e!=null?e:s;r!==void 0&&(i=ar(t,r.getBaseline()));const o=Qe(i.toFixed(ye.DEFAULT_PRECISION))+" %";return o===`${ii}0.00 %`?"0.00 %":o},$f=(n,t)=>({percent:Zf(n),regular:Gf(n,t)});class Kf extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:uh}){super(),this.config=t,this.paneUUID=e,this.idx=s,this.paneComponent=i,this.chartBaseModel=r,this.canvasBoundsContainer=o,this.hitTestController=a,this.dynamicObjectsCanvasModel=l,this.scale=c,this.dragNDrop=d,this.dataSeries=u,this.formatters=f,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=p=>p.map(m=>new Re(this.chartBaseModel.dataFromTimestamp(m.timestamp).centerUnit,m.close)),this.toY=p=>{var m,_;return(_=(m=this.mainDataSeries)==null?void 0:m.view.toY(p))!=null?_:1},this.valueFormatter=(p,m)=>{if(!this.formatters[this.yAxis.getAxisType()])return this.formatters.regular(p);const{regular:_,percent:S,logarithmic:A}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p);case"percent":return S?S(p,m):_(p);case"logarithmic":return A?A(p):_(p);default:return this.regularFormatter(p)}},this.addChildEntity(c),this.setValueFormatters($f(this,t)),this.yAxis=h(this.valueFormatter.bind(this),()=>this.mainDataSeries),this.addChildEntity(this.yAxis)}doDeactivate(){super.doDeactivate(),this.dataSeries.forEach(t=>{this.paneComponent.seriesRemovedSubject.next(t),t.deactivate()})}getBounds(){return this.scale.getBounds()}getBaseline(){var t,e;return(e=(t=this.mainDataSeries)==null?void 0:t.getBaseline())!=null?e:1}createDataSeries(){const t=new pr(this,_t(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){if(this.dataSeries.add(t),this.dataSeries.size===1)this.mainDataSeries=t;else if(this.paneComponent.yExtentComponents.length>1&&this.paneUUID!==$){this.mainDataSeries=t;const e=Array.from(this.paneComponent.mainExtent.dataSeries);this.paneComponent.mainExtent.mainDataSeries=e[e.length-1]}this.paneComponent.updateView(),this.paneComponent.seriesAddedSubject.next(t)}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView(),this.paneComponent.seriesRemovedSubject.next(t)}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var e,s;return(s=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?s:this.scale.fromY(t)}}const Ho=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(n.dataSeries),s=e.filter(o=>o.highLowProvider.isHighLowActive()),i=s.length>0?s:e;if(i.length===0)return{low:0,high:100};const r=i.map(o=>o.highLowProvider.calculateHighLow(t)).filter(o=>o.high>=o.low);return r.length===0?{low:0,high:100}:Mr(r)}});class qf{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=un.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return un.DATA_SERIES}get allDataSeries(){return Le(Le(Object.values(this.panes),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(s=>s.htId===t)}onHover(t){this.allDataSeries.forEach(e=>e.highlighted=e.htId===(t==null?void 0:t.htId)),this.canvasModel.fireDraw()}onMouseDown(t){t&&this.handleYExtentDragStart(t)}onMouseUp(){this.handleYExtentDragEnd()}handleYExtentDragStart(t){Object.values(this.panes).forEach(e=>e.yExtentComponents.forEach(s=>s.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.panes).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}var Jf;const Gt="#FF00FF";function Tv(n,t,e,s){const i=n.yAxis.backgroundColor,r=n.chartAreaTheme.backgroundColor,o=n.chartAreaTheme.backgroundGradientTopColor,a=n.chartAreaTheme.backgroundGradientBottomColor,l=s.align==="left"?o:a,c=n.chartAreaTheme.backgroundMode==="gradient"?l:r;return Jf(i==="transparent"?c:i,t,e)}const Qf=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,tp=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Gt},ep=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Gt},sp=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Gt},np=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Gt},ip=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Gt},rp=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Gt},op=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Gt},ko=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Gt},ap=()=>(console.warn("Fallback for label default color"),Gt),jo=10;class Yo extends W{constructor(t,e,s,i,r,o,a,l){if(super(),this.bus=t,this.config=e,this.scale=i,this.canvasInputListener=r,this.bounds=o,this.hitTest=a,this.hitTestCanvasModel=l,this.yAxisDragEndSubject=new F,this.lastYStart=0,this.lastYEnd=0,this.lastYHeight=0,this.lastYPxHeight=0,this.onYDragStart=()=>{this.scale.haltAnimation(),this.lastYStart=this.scale.yStart,this.lastYEnd=this.scale.yEnd,this.lastYHeight=this.scale.yEnd-this.scale.yStart,this.lastYPxHeight=Math.max(this.bounds.getBounds(M.Y_AXIS).height,ki),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onYDragTick=c=>{let{delta:h}=c;this.touches&&this.touches.length>1&&(h=Math.min(this.touches[0].clientY,this.touches[1].clientY)===this.touches[0].clientY?h:-h);let d;h<0?d=1/(1+-h/this.lastYPxHeight*(jo-1)):d=1+h/this.lastYPxHeight*(jo-1);const f=(this.lastYHeight*d-this.lastYHeight)/2,p=this.lastYStart-f,m=this.lastYEnd+f;(this.lastYStart!==p||this.lastYEnd!==m)&&(this.scale.setYScale(p,m),this.scale.state.auto=!1,this.bus.fireDraw())},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next(),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>i.autoScale(!0),this.dblTapCallback=()=>i.autoScale(!0),e.customScale){const c=new fs(a,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},r,s,{dragPredicate:()=>s.chartAreaPanHandler.chartPanningOptions.vertical&&e.type!=="percent"});this.addChildEntity(c),this.dragNDropYComponent=c}}isDragging(){return this.dragNDropYComponent?Math.abs(this.dragNDropYComponent.draggedPixels)>0:!1}doActivate(){this.config.customScaleDblClick&&(this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>{this.dblClickCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})))}}class lp{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${_t()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),ni(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 cp=0,hp=.01;class bn{constructor(t,e,s,i,r=!1,o,a,l=zs,c=23,h){this.increment=t,this.startEndProvider=e,this.lengthProvider=s,this.valueFormatter=i,this.withZero=r,this.axisTypeProvider=o,this.baseLineProvider=a,this.labelFilter=l,this.singleLabelHeightPixels=c,this.yAxisConfig=h,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new F,this.newGeneratedLabelsSubject=new F,this.lastStart=0,this.lastEnd=0,this.labelsCache=new lp(()=>this.labelFilter(this.doGenerateLabels())),this.treasuryFormat=this.yAxisConfig&&this.yAxisConfig.treasuryFormat}generateRegularLabels(t,e,s){const i=[];this.withZero&&i.push({value:0,text:"0"});let r=pt.roundToNearest(t,s);for(;r<e;){const o=pt.roundToNearest(r,s),a=Qe(this.valueFormatter(o));i.push({value:o,text:a}),r=pt.roundDecimal(r+s)}return i}generatePercentLabels(t,e,s){const i=[],r=this.baseLineProvider();let o=pt.roundToNearest(t,s);for(;o<e;){const a=pt.roundToNearest(o,s),l=lr(a,r),c=Qe(this.valueFormatter(l));i.push({value:a,text:c}),o=pt.roundDecimal(o+s)}return i}generateLogarithmLabels(t,e,s){const i=[];let r=pt.roundToNearest(t,s);for(;r<e;){const o=rn(r),a=this.valueFormatter(o);i.push({value:r,text:a}),r=pt.roundDecimal(r+s)}return i}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[s,i]=this.calculateMinMax(),r=this.getAxisStep(s,i,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=r);let o;const a=this.axisTypeProvider();if(a==="logarithmic"?o=this.generateLogarithmLabels(s,i,r):a==="percent"?o=this.generatePercentLabels(s,i,r):o=this.generateRegularLabels(s,i,r),this.lastSingleLabelHeightValue!==r&&this.labelsCache.cache){const l=(t=this.labelsCache.getLastCachedValue())!=null?t:[];this.distanceBetweenLabelsChangeSubject.next([l,o]),this.lastSingleLabelHeightValue=r}return this.newGeneratedLabelsSubject.next(o),o}calculateMinMax(){const[t,e]=this.startEndProvider(),s=this.lengthProvider(),i=bn.getLabelBounds(t,e,s);return[i[0],i[1]]}getAxisStep(t,e,s){const i=e-t,r=s/this.singleLabelHeightPixels,o=this.calculateIncrement(i),a=i/r;return this.calculateAxisStep(a,o)}observeDistanceBetweenLabelsChanged(){return this.distanceBetweenLabelsChangeSubject.asObservable()}observeLabelsChanged(){return this.newGeneratedLabelsSubject.asObservable()}calculateIncrement(t){var e;if(this.increment)return this.increment;if(!isNaN(t)){const s=(e=this.treasuryFormat)!=null&&e.enabled?vn:ye.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(hp)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=rn(e)+t;return cr(i)-e;case"regular":return t}}generateNumericLabels(){const[t,e]=this.startEndProvider();return(t!==this.lastStart||e!==this.lastEnd)&&this.labelsCache.invalidate(),this.lastStart=t,this.lastEnd=e,this.labelsCache.calculateOrGet()}static getLabelBounds(t,e,s){const i=Math.abs((e-t)*(cp/s));return[t-i,e+i]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let s=e,i=e,r=0;for(;s<t&&s>0;)r>=this.gridDistanceMultipliers.length&&(r=0,i*=10),s=i*this.gridDistanceMultipliers[r++];return s}}class dp extends bn{constructor(t,e,s,i,r=()=>"regular",o=23,a){super(t,()=>[s.yStart,s.yEnd],()=>s.getBounds().height,i,!1,r,()=>{var l,c;return(c=(l=e())==null?void 0:l.getBaseline())!=null?c:1},void 0,o,a),this.dataSeriesProvider=e}getLargestLabel(){var t;return((t=this.labelsCache.getLastCachedValue())!=null?t:[]).reduce((e,s)=>s.text.length>e.length?s.text:e,"")}updateTreasuryFormat(t){this.treasuryFormat=t}calculateIncrement(t){var e,s;const i=this.dataSeriesProvider();if(i){const r=St(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=Dh(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?vn:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function No(n,t,e){var s=j(n)||t||e?{next:n,error:t,complete:e}:n;return s?N(function(i,r){var o;(o=s.subscribe)===null||o===void 0||o.call(s);var a=!0;i.subscribe(yt(r,function(l){var c;(c=s.next)===null||c===void 0||c.call(s,l),r.next(l)},function(){var l;a=!1,(l=s.complete)===null||l===void 0||l.call(s),r.complete()},function(l){var c;a=!1,(c=s.error)===null||c===void 0||c.call(s,l),r.error(l)},function(){var l,c;a&&((l=s.unsubscribe)===null||l===void 0||l.call(s)),(c=s.finalize)===null||c===void 0||c.call(s)}))}):ne}class up extends W{constructor(t,e,s,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${_t()}`}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(lt(t=>t.height),K(t=>xl(t,this.prevYAxisHeight,1.5)),No(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,Me(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){Me(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class fp extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new dp(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new up(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new qc(e,o,i,s,r,t,()=>this.canvasBoundsContainer.updateYAxisWidths(),h),this.addChildEntity(this.fancyLabelsModel)}doActivate(){const t={getLargestLabel:()=>{var e;return((e=this.labelsGenerator.labelsCache.getLastCachedValue())!=null?e:[]).map(s=>s.text).concat(this.fancyLabelsModel.orderedLabels.flatMap(s=>s.labels).map(s=>s.labelText)).reduce((s,i)=>i.length>s.length?i:s,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class pp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_){super(),this.eventBus=t,this.config=e,this.mainCanvasModel=s,this.canvasModel=i,this.scale=r,this.canvasInputListeners=o,this.canvasBoundsContainer=a,this.chartPanComponent=l,this.cursors=c,this.paneUUID=u,this.extentIdx=f,this.hitTestCanvasModel=p,this.chartResizeHandler=m,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new F,this.axisAlignSetSubject=new F,this.axisAlignMovedSubject=new F,this.setDblClickCallback=A=>this.yAxisScaleHandler.setDblClickCallback(A),this.setDblTapCallback=A=>this.yAxisScaleHandler.setDblTapCallback(A);const S=_?le(_):{};this.state=At(S,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new Yo(t,this.state,l,r,o,a,a.getBoundsHitTest(M.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new fp(this.paneUUID,t,this.state,a,i,r,h,d,f,this.chartResizeHandler),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}setExtentIdx(t){this.extentIdx=t,this.model.extentIdx=t,this.yAxisScaleHandler.deactivate(),this.removeChildEntity(this.yAxisScaleHandler),this.yAxisScaleHandler=new Yo(this.eventBus,this.state,this.chartPanComponent,this.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,t)),this.hitTestCanvasModel),this.addChildEntity(this.yAxisScaleHandler)}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",sp),this.registerLabelColorResolver("bar",tp),this.registerLabelColorResolver("line",ep),this.registerLabelColorResolver("area",np),this.registerLabelColorResolver("scatterPlot",ip),this.registerLabelColorResolver("histogram",rp),this.registerLabelColorResolver("baseline",op),this.registerLabelColorResolver("trend",ko),this.registerLabelColorResolver("hollow",ko)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.cursor)}updateOrderedLabels(t=!1){this.model.fancyLabelsModel.updateLabels(t)}registerLabelColorResolver(t,e){this.labelsColorByChartTypeMap[t]=e}getLabelsColorResolver(t){var e;return(e=this.labelsColorByChartTypeMap[t])!=null?e:ap}registerYAxisLabelsProvider(t,e=ae.MAIN,s=_t()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,s),s}addSimpleYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}updateCustomYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}deleteSimpleYAxisLabel(t){delete this.model.fancyLabelsModel.customLabels[t],this.canvasModel.fireDraw()}getAxisType(){return this.state.type}unregisterYAxisLabelsProvider(t=ae.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx))}registerYAxisWidthContributor(t){this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t)}setAxisType(t){t!==this.state.type&&(this.state.type=t,this.config.components.yAxis.type=t,this.axisTypeSetSubject.next(t),this.scale.autoScale(!0),this.model.fancyLabelsModel.updateLabels(!0),this.updateCursor(),this.mainCanvasModel.fireDraw())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.axisAlignSetSubject.next(t),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.activate():this.deactivate(),this.model.fancyLabelsModel.updateLabels(),this.model.baseLabelsModel.updateLabels()}isVisible(){return this.state.visible}setLockPriceToBarRatio(t=!1){this.scale.setLockPriceToBarRatio(t)}changeLabelMode(t,e){this.state.labels.settings[t].mode=e,this.model.fancyLabelsModel.updateLabels()}changeLabelAppearance(t,e){this.state.labels.settings[t].type=e,this.model.fancyLabelsModel.updateLabels()}togglePriceScaleInverse(t=!1){this.scale.state.inverse=t,this.scale.inverseY=t,this.model.fancyLabelsModel.updateLabels(),this.scale.scaleInversedSubject.next(t),this.canvasModel.fireDraw()}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}class gp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,S,A,E,Y){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=i,this.hitTestController=r,this.config=o,this.mainScale=a,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=d,this.cursorHandler=u,this.eventBus=f,this.canvasBoundsContainer=p,this.uuid=m,this.seriesAddedSubject=_,this.seriesRemovedSubject=S,this.hitTestCanvasModel=A,this.chartResizeHandler=E,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new F,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(R,k)=>this.mainExtent.valueFormatter(R,k);const B=this.createExtentComponent(Y);this.mainExtent=B,this.ht=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(m),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get dataSeries(){return Le(this.yExtentComponents,t=>Array.from(t.dataSeries))}get visible(){return this.canvasBoundsContainer.graphsHeightRatio[this.uuid]>0}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.uuid)).pipe(mt(zi)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()})),this.uuid===$&&this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(gn(this.yAxis.getAxisType()),mt(),lt(t=>t==="percent")).subscribe(t=>{this.chartPanComponent.chartAreaPanHandler.setChartAreaXDragThrottled(t)}))}toY(t){var e,s;return(s=(e=this.mainExtent.mainDataSeries)==null?void 0:e.view.toY(t))!=null?s:this.scale.toY(t)}createGridComponent(t,e,s,i,r,o){var a,l;const c=M.PANE_UUID(t),h=(l=(a=this.mainExtent)==null?void 0:a.idx)!=null?l:0;return new xo(this.mainCanvasModel,s,this.config,i,`PANE_${t}_${e}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(c),()=>this.canvasBoundsContainer.getBounds(c),()=>[],r,e,o,()=>this.config.components.grid.visible,h)}createYPanHandler(t,e){const s=M.PANE_UUID(t),i=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(s));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(i),i.disable()},i]}addCursors(t,e){const s=M.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(s,e.state.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(s)}createExtentComponent(t){var e,s;const i=this.yExtentComponents.length,r=M.PANE_UUID(this.uuid),o=()=>this.canvasBoundsContainer.getBounds(r),a=(e=t==null?void 0:t.scale)!=null?e:new od(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(m,_)=>new pp(this.eventBus,this.config,this.mainCanvasModel,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,m,_,this.uuid,i,this.hitTestCanvasModel,this.chartResizeHandler,l),u=new Kf(this.config.components.yAxis,this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,d,h);u.addSubscription(c),u.addSubscription(this.addCursors(i,u.yAxis)),t!=null&&t.paneFormatters&&u.setValueFormatters(t.paneFormatters),u.yAxis.togglePriceScaleInverse(t==null?void 0:t.inverse),u.scale.setLockPriceToBarRatio(t==null?void 0:t.lockToPriceRatio),((s=t==null?void 0:t.useDefaultHighLow)==null||s)&&a.autoScaleModel.setHighLowProvider("default",Oo(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),Ho(u)));const p=this.createGridComponent(this.uuid,u.idx,a,u.yAxis.state,()=>u.yAxis.model.baseLabelsModel.labels,()=>u.toY(u.getBaseline()));return u.addChildEntity(p),u.activate(),this.yExtentComponents.push(u),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next(),u}removeExtentComponents(t){t.forEach(e=>e.disable()),this.yExtentComponents=this.yExtentComponents.filter(e=>!t.map(s=>s.idx).includes(e.idx)),this.yExtentComponents.forEach((e,s)=>{e.yAxis.setExtentIdx(s),e.idx=s,e.yAxis.updateCursor()}),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next()}moveDataSeriesToNewExtentComponent(t,e,s,i="right"){const r=le(s.yAxis.state),o=le(s.scale.state),a=At(r,this.config.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),l=this.createExtentComponent({initialYAxisState:a,inverse:o.inverse,lockToPriceRatio:o.lockPriceToBarRatio});l.yAxis.setYAxisAlign(i),t.forEach(c=>c.moveToExtent(l)),s.dataSeries.size===0&&e.removeExtentComponents([s])}moveDataSeriesToExistingExtentComponent(t,e,s,i,r){t.forEach(o=>o.moveToExtent(i)),!r&&s.dataSeries.size===0&&e.removeExtentComponents([s]),this.yExtentComponentsChangedSubject.next()}updateView(){this.yExtentComponents.forEach(t=>{t.scale.doAutoScale(),t.yAxis.model.labelsGenerator.generateNumericLabels()}),this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}mergeYExtents(){for(let t=1;t<this.yExtentComponents.length;t++){const e=this.yExtentComponents[t];e.dataSeries.forEach(s=>s.moveToExtent(this.mainExtent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainExtent]}getBounds(){return this.mainExtent.getBounds()}createDataSeries(){var t;return(t=this.mainExtent)==null?void 0:t.createDataSeries()}addDataSeries(t){this.mainExtent.addDataSeries(t),this.updateView()}removeDataSeries(t){this.mainExtent.removeDataSeries(t),this.updateView()}getAxisType(){return"regular"}moveUp(){this.canvasBoundsContainer.movePaneUp(this.uuid)}moveDown(){this.canvasBoundsContainer.movePaneDown(this.uuid)}canMoveUp(){const t=ie(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=St(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}var mp=Object.defineProperty,vp=Object.defineProperties,bp=Object.getOwnPropertyDescriptors,Xo=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,yp=Object.prototype.propertyIsEnumerable,Wo=(n,t,e)=>t in n?mp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,wp=(n,t)=>{for(var e in t||(t={}))Cp.call(t,e)&&Wo(n,e,t[e]);if(Xo)for(var e of Xo(t))yp.call(t,e)&&Wo(n,e,t[e]);return n},Sp=(n,t)=>vp(n,bp(t));class xp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,S){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=m,this.hitTestCanvasModel=_,this.chartResizeHandler=S,this.panes={},this.paneRemovedSubject=new F,this.paneAddedSubject=new F,this.dataSeriesAddedSubject=new F,this.dataSeriesRemovedSubject=new F,this.hitTestController=new qf(this.panes,this.dynamicObjectsCanvasModel);const A=this.createPane($,{useDefaultHighLow:!1,scale:this.mainScale});A.mainExtent.scale.autoScaleModel.setHighLowProvider("series",Ho(A.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",Lo(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removePaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone+Ro}),s=()=>this.chartBaseModel.mainVisualPoints.length!==0,i=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},r=M.PANE_UUID_RESIZER(t),o=new mn(r,()=>this.canvasBoundsContainer.getBounds(r),e,i,s,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer,this.hitTestCanvasModel);return this.userInputListenerComponents.push(o),o}get yExtents(){return Le(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(s=>this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(s.uuid))(t.x,t.y))}createPane(t=_t(),e){if(this.panes[t]!==void 0)return this.panes[t];const s=new gp(this.chartBaseModel,this.mainCanvasModel,this.yAxisLabelsCanvasModel,this.dynamicObjectsCanvasModel,this.hitTestController,this.config,this.mainScale,this.drawingManager,this.chartPanComponent,this.canvasInputListener,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,t,this.dataSeriesAddedSubject,this.dataSeriesRemovedSubject,this.hitTestCanvasModel,this.chartResizeHandler,e);return this.config.components.paneResizer.visible&&s.addChildEntity(this.addResizer(t)),s.addSubscription(this.addBounds(t,e==null?void 0:e.order)),s.addSubscription(this.addCursors(t)),s.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,s.ht)),this.panes[t]=s,s.activate(),this.recalculateState(),s.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),s}movePaneUp(t){this.canvasBoundsContainer.movePaneUp(t)}movePaneDown(t){this.canvasBoundsContainer.movePaneDown(t)}canMovePaneUp(t){var e,s;const i=ie(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}canMovePaneDown(t){var e,s;const i=St(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}removePane(t){const e=this.panes[t];e!==void 0&&(this.paneRemovedSubject.next(e),e.disable(),e.yExtentComponents.forEach(s=>s.disable()),delete this.panes[t],this.recalculateState())}hidePane(t){const e=this.panes[t];if(e===void 0||!e.visible)return;const s=M.PANE_UUID_RESIZER(t),i=this.userInputListenerComponents.find(r=>r instanceof mn&&r.id===s);i==null||i.disable(),this.canvasBoundsContainer.hidePaneBounds(t),this.recalculateState()}showPane(t){const e=this.panes[t],s=M.PANE_UUID_RESIZER(t);if(e===void 0||e.visible)return;const i=this.userInputListenerComponents.find(r=>r instanceof mn&&r.id===s);i==null||i.enable(),this.canvasBoundsContainer.showPaneBounds(t),this.recalculateState()}moveDataSeriesToPane(t,e,s,i){const{paneUUID:r,extent:o,direction:a,align:l,extentIdx:c,isForceKeepPane:h,index:d=0}=i,u=r&&this.panes[r],f=l?Sp(wp({},s.yAxis.state),{align:l}):void 0,p=c&&c>0;if(!u){const m=a&&a==="above"?d:d+1,_=this.createPane(r,{order:m,initialYAxisState:f,inverse:s.scale.state.inverse,lockToPriceRatio:s.scale.state.lockPriceToBarRatio});_.moveDataSeriesToExistingExtentComponent(t,e,s,_.mainExtent,h),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid);return}o&&!p?u.moveDataSeriesToExistingExtentComponent(t,e,s,o):u.moveDataSeriesToNewExtentComponent(t,e,s,l!=null?l:s.yAxis.state.align),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid)}addCursors(t,e=this.config.components.chart.cursor){const s=M.PANE_UUID(t),i=M.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone+Ro),()=>{this.cursorHandler.removeCursorForCanvasEl(s),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(i)}}recalculateState(){Object.values(this.panes).forEach(t=>t.scale.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])}}class _p extends W{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,s=this.canvasModel.ctx;if(s){s.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,i,r),s.drawImage(this.elements.mainCanvas,0,0,i,r),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),s.drawImage(this.elements.crossToolCanvas,0,0,i,r),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(s),new Promise((o,a)=>this.elements.snapshotCanvas.toBlob(l=>l?o(l):a("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const Pp=(n,t=1)=>{function e(i){let r;const o=Math.pow(10,t);return i=Math.round(i*o)/o,i>=1e-15&&i<1?r=i.toFixed(t).replace(/\.?0+$/,""):r=String(i),r.replace(/(\.[1-9]*)0+$/,(a,l)=>l)}function s(i){let r="";return i<0&&(r="-",i=-i),i<995?r+e(i):i<999995?r+e(i/1e3)+"K":i<999999995?(i=1e3*Math.round(i/1e3),r+e(i/1e6)+"M"):(i=1e6*Math.round(i/1e6),r+e(i/1e9)+"B")}return s(n)},zo=class Ms extends W{constructor(t,e,s,i){super(),this.chartComponent=t,this.config=e,this.volumesModel=s,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var t,e;return!((t=this.pane)!=null&&t.scale.isViewportValid())&&((e=this.pane)==null?void 0:e.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var t;return(t=this.pane)==null?void 0:t.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[Ms.UUID]===void 0){const e=this.paneManager.createPane(Ms.UUID,{paneFormatters:{regular:r=>Pp(r,1)},useDefaultHighLow:!1,increment:1});this.pane=e,e.mainExtent.yAxis.setAxisType("regular");const{scale:s}=e,i=Oo(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);s.autoScaleModel.setHighLowProvider("volumes",i),s.doAutoScale(!0)}}deactiveSeparateVolumes(){this.paneManager.removePane(Ms.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};zo.UUID="volumes";let Tp=zo;const bs=.3,Mp=(n,t)=>{const e=t.barTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},Ap=(n,t)=>{const e=t.volume[`${n}BarColor`];return Ft()(e).alpha(bs).toString()},Ep=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},Cn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},Ip=3;class Dp{constructor(t,e,s,i,r,o){this.config=t,this.volumesModel=e,this.chartModel=s,this.getViewportModel=i,this.volumesColorByChartTypeMap=r,this.drawPredicate=o,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const s=(e=this.volumesColorByChartTypeMap[t])!=null?e:Ap;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();Kt(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=this.getViewportModel();if(!s.isViewportValid())return;const i=vt(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1));i.forEach((r,o)=>{if(r.candle.volume){const a=s.getBounds(),l=a.height;if(l<=0)return;const c=i[o+1]!==void 0?It(s.toX(i[o+1].startUnit)):void 0,h=It(s.toX(r.startUnit)),d=c!==void 0?c-h:It(bt(r.width,s.zoomX));if(this.config.components.volumes.showSeparately){const u=It(s.toY(r.candle.volume)),f=en(s.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=l/Ip;if(u<=0)return;const f=e/u;if(!isFinite(f)||f<=0)return;const p=Math.max(en(bt(r.candle.volume,f)),2),m=Math.min(p,l),_=It(a.y+l-m);this.drawVolume(t,r,h,_,d,m)}}})}drawVolume(t,e,s,i,r,o){const a=t.ctx,l=i,c=i+o,h=e.name;a.fillStyle=this.volumeBarColors[h],a.strokeStyle=this.volumeBarColors[h],r===0?(a.beginPath(),a.moveTo(s,l),a.lineTo(s,en(c)),a.stroke()):a.fillRect(s,i,r,o)}}const Lp=Gl(n=>n.candle.volume),Vo="volumes";class Op extends W{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=Vo,this.volumeMax=new ft(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.chartComponent.chartModel.observeCandlesChanged(),this.scale.xChanged).subscribe(()=>this.updateVolumeMax())),this.addRxSubscription(this.chartComponent.chartModel.mainCandleSeries.observeLastVisualCandleChanged().subscribe(()=>this.recalculateLastVisualVolume()))}recalculateLastVisualVolume(){}updateVolumeMax(){var t;const e=this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport(this.scale.xStart-1,this.scale.xEnd+1);this.volumeMax.next((t=ie(Lp(e.flat())))!=null?t:0)}}class Bp extends W{constructor(t,e,s,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new ft(!1),this.volumeIsSeparateModeChangedSubject=new ft(!1);const c=new Op(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new Tp(e,o,c,a),this.volumesDrawer=new Dp(o,this.volumesModel,e.chartModel,()=>{var h,d;return this.config.components.volumes.showSeparately&&(d=(h=this.separateVolumes.pane)==null?void 0:h.scale)!=null?d:s},this.volumesColorByChartTypeMap,()=>!0),o.components.volumes.visible&&this.syncVolumesDynamicObject(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(o.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(o.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",Cn),this.registerVolumeColorResolver("trend",Cn),this.registerVolumeColorResolver("hollow",Cn),this.registerVolumeColorResolver("line",Ep),this.registerVolumeColorResolver("bar",Mp)}setShowVolumesSeparatly(t){this.config.components.volumes.showSeparately!==t&&(this.config.components.volumes.showSeparately=t,t?this.separateVolumes.activateSeparateVolumes():this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(t),this.syncVolumesDynamicObject())}doDeactivate(){super.doDeactivate(),this.setVisible(!1)}registerVolumeColorResolver(t,e){this.volumesColorByChartTypeMap[t]=e}setVisible(t=!0){this.config.components.volumes.visible=t,this.volumeVisibilityChangedSubject.next(t),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.syncVolumesDynamicObject(),this.canvasModel.fireDraw()}syncVolumesDynamicObject(){if(!this.config.components.volumes.visible){this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);return}const e=this.config.components.volumes.showSeparately?Vo:$,s={id:this.volumesModel.id,paneId:e,drawer:this.volumesDrawer,model:this.volumesModel};if(this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1){this.dynamicObjectsComponent.model.addObject(s);return}this.dynamicObjectsComponent.model.updateObject(s)}}class Rp{constructor(t,e,s,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,f=this.canvasBoundsContainer.getBounds(M.PANE_UUID($)),{position:p,offsetY:m,offsetX:_}=this.config.components.waterMark;let S;switch(d?S=d:(u.font=Cs(this.config,l),S=u.measureText(a).width,f.width-10<S&&(u.font=Fp(this.config,this.canvasBoundsContainer,l,S),S=u.measureText(a).width)),p){case"left-top":return{x:_+f.x,y:m+o+f.y,font:u.font,text:a,color:c};case"left-bottom":return{x:_+f.x,y:f.height-h-m+o+f.y,font:u.font,text:a,color:c};case"center":return{x:f.width/2-S/2+f.x,y:(f.height-h)/2+o+f.y,font:u.font,text:a,color:c}}}}draw(){var t,e,s,i,r,o,a;if((t=this.config.components.waterMark)!=null&&t.visible&&this.config.colors){const{firstRow:l,secondRow:c,thirdRow:h}=this.watermarkDataProvider(),d=this.waterMarkConfigProvider(),u=this.config.colors.waterMarkTheme,f=this.canvasModel.ctx;let p=0,m=0,_=0,S=0,A=0;if(f.save(),d.firstRowFontSize&&l){f.font=Cs(this.config,d.firstRowFontSize);const R=f.measureText(l);p=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){f.font=Cs(this.config,d.secondRowFontSize);const R=f.measureText(c);m=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,_=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){f.font=Cs(this.config,d.thirdRowFontSize);const R=f.measureText(h);S=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,A=(s=d.secondRowBottomPadding)!=null?s:0}const E=(i=d.thirdRowBottomPadding)!=null?i:0,Y=(r=d.logoHeight)!=null?r:0,B=p+m+_+S+A+E+Y;if(l&&this.drawWaterMark(this.getConfig(p,l,d.firstRowFontSize,u.firstRowColor,B)),c&&this.drawWaterMark(this.getConfig(p+_+m,c,d.secondRowFontSize,u.secondRowColor,B)),h&&this.drawWaterMark(this.getConfig(p+_+m+A+S,h,d.thirdRowFontSize,u.thirdRowColor,B)),this.logoImage){const R=this.getConfig(p+_+m+A+S+E,"",d.thirdRowFontSize,u.thirdRowColor,B,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,R.x,R.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}f.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const s=this.canvasModel.ctx;s.font=t.font,s.fillStyle=t.color;const i=t.x,r=t.y;s.fillText(e,i,r)}reset(){}}const Fp=(n,t,e,s)=>{const r=((a,l)=>t.getBounds(M.CHART).width/l*a)(e,s);let o;return n.components&&n.components.waterMark&&(o=n.components.waterMark.fontFamily),r+"px "+o},Cs=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var Hp=Object.defineProperty,Uo=Object.getOwnPropertySymbols,kp=Object.prototype.hasOwnProperty,jp=Object.prototype.propertyIsEnumerable,Go=(n,t,e)=>t in n?Hp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Zo=(n,t)=>{for(var e in t||(t={}))kp.call(t,e)&&Go(n,e,t[e]);if(Uo)for(var e of Uo(t))jp.call(t,e)&&Go(n,e,t[e]);return n};class Yp extends W{constructor(t,e,s,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Rp(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(At(r.observeBoundsChanged(M.PANE_UUID($)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),a.addDrawerAfter(this.waterMarkDrawer,"WATERMARK","DYNAMIC_OBJECTS")}setWaterMarkVisible(t){this.config.components&&this.config.components.waterMark&&(this.config.components.waterMark.visible=t,this.canvasModel.fireDraw())}setWaterMarkData(t){this.waterMarkData=t,this.canvasModel.fireDraw()}getWaterMarkData(){return this.waterMarkData||{}}setWaterMarkConfig(t){if(!(!t||!this.config.components)){if(!this.config.components.waterMark)this.config.components.waterMark=JSON.parse(JSON.stringify(t));else{const e={};At(e,t),At(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 Zo(Zo({},this.config.components.waterMark),h)}}const $o={x:4,y:4};function Np(n,t,e,s){var i,r;const o=(i=s.alignType)!=null?i:"middle",{fontSize:a,fontFamily:l,padding:c}=e.components.xAxis,h=e.colors.xAxis,d=(r=c.top)!=null?r:0,u=t.getBounds(M.X_AXIS);n.save(),n.font=`bold ${a}px ${l}`;const p=n.measureText(s.text).width+$o.x*2;let m=0;const _=s.x;switch(o){case"start":m=_-p;break;case"end":m=_;break;default:m=_-p/2;break}n.fillStyle=h.backgroundColor,n.strokeStyle=h.backgroundColor,n.fillRect(m,u.y,p,u.height),o!=="middle"&&(n.strokeStyle=s.color,n.beginPath(),n.moveTo(_,u.y),n.lineTo(_,u.y+u.height),n.stroke()),n.fillStyle=s.color;const S=m+$o.x,A=u.y+d+a+Oe/2;n.fillText(s.text,S,A),n.restore()}class Xp{constructor(t,e,s,i){this.config=t,this.canvasModel=e,this.canvasBoundsContainer=s,this.xAxisLabelsModel=i}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{Np(t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},s=this.xAxisLabelsModel.labels.reduce((i,r)=>{if(r.subGroupId!==void 0){let o=i[r.subGroupId];o||(o=[],i[r.subGroupId]=o),o.push(r)}return i},e);Object.keys(s).forEach(i=>{const r=s[i];if(r.length===2){const o=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.fillStyle=Ft().rgb(r[0].color).alpha(.1).toString(),Fr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const Mv="week-weekday",Wp=["second","minute","hour","day","month","year"],zp=["lessThanSecond"],Vp=n=>Wp.some(t=>t===n),Up=n=>n==="week-weekday",Gp=n=>zp.some(t=>t===n),Ko=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},yn=n=>parseInt(n,10),qo=n=>{const[t,...e]=n.split("_");if(Vp(t)){const[s]=e,i=Ko(s),r=yn(s);return{key:t,value:r,exact:i["!"]}}else if(Up(t)){const[s,i]=e,r=Ko(s),o=yn(s),a=yn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return Gp(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats in dxchart-lite documentation.`),null)};class ys{constructor(t,e,s,i,r,o=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=s,this.canvasBoundsContainer=i,this.labelsProvider=r,this.drawPredicate=o}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,s=this.config.colors.xAxis,i=this.config.components.xAxis.fontFamily,r=ys.getFontFromConfig(this.config),o=this.config.components.xAxis.fontSize,a=(t=this.config.components.xAxis.padding.top)!=null?t:0;e.save(),e.font=r,e.fillStyle=s.backgroundColor;const l=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.config.components.chart.applyBackgroundToAxes.x||e.fillRect(l.x,l.y,l.width,l.height);const c=this.config.colors.xAxis.labelTextColor,h=this.labelsProvider();this.drawLabels(e,h,l,c,o,i,a+Oe/2),e.restore()}}drawLabels(t,e,s,i,r,o,a){const l=`${r}px ${o}`;t.fillStyle=i;for(const c of e){const h=this.viewportModel.toX(c.value)-Mt(c.text,t,l)/2;if(h<s.x||h>s.width)continue;const d=s.y+r-1+a,u=c.text;t.font=l,t.fillText(u,h,d)}}static getFontFromConfig(t){return`${t.components.xAxis.fontStyle} ${t.components.xAxis.fontSize}px ${t.components.xAxis.fontFamily}`}getCanvasIds(){return[this.canvasModel.canvasId]}}const wn={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Jo=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return wn[n.key]+n.value;case"lessThanSecond":return wn[n.key];case"week-weekday":return wn[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},Qo=n=>{const t={};for(const e of n){const s=t[e.weight];s===void 0?t[e.weight]=[e]:s.push(e)}return t},Zp=(n,t)=>{const e=Object.keys(n).map(i=>parseInt(i,10)).sort((i,r)=>r-i);let s=[];for(const i of e){const r=n[i];if(!r)continue;const o=[...s];s=[];const a=o.length,l=r.length;let c=0,h=1/0,d=-1/0;for(let u=0;u<l;u++){const f=r[u],p=f.idx;for(;c<a;){const m=o[c],_=m.idx;if(p>_)c++,s.push(m),d=_,h=1/0;else{h=_;break}}h-p>=t&&p-d>=t&&(s.push(f),d=p)}for(;c<a;)s.push(o[c]),c++}return s},$p=(n,t,e,s,i,r)=>{const o=ys.getFontFromConfig(t),a=Mt(e.text,n,o),l=Mt(s.text,n,o),c=i.toX(e.value)+a/2;return i.toX(s.value)-l/2-c<r},Av=7,Kp=365.2425,Iv=-(Math.pow(10,8)*24*60*60*1e3),Dv=6048e5,Lv=864e5,Ov=6e4,Bv=36e5,Rv=1e3,Fv=525600,Hv=43200,kv=1440,jv=60,Yv=3,Nv=12,Xv=4,qp=3600,Wv=60,ta=qp*24,zv=ta*7,Gv=ta*Kp/12*3,ea=Symbol.for("constructDateFrom");function Sn(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&ea in n?n[ea](t):n instanceof Date?new n.constructor(t):new Date(t)}const Zv=null;function jt(n,t){return Sn(t||n,n)}const $v=null;function Jp(n,t){return jt(n,t==null?void 0:t.in).getDay()===1}const Kv=null;function Qp(n,t){return jt(n,t==null?void 0:t.in).getDay()===2}const qv=null;function tg(n,t){return jt(n,t==null?void 0:t.in).getDay()===3}const Jv=null;function eg(n,t){return jt(n,t==null?void 0:t.in).getDay()===4}const Qv=null;function sg(n,t){return jt(n,t==null?void 0:t.in).getDay()===5}const tb=null;function ng(n,t){return jt(n,t==null?void 0:t.in).getDay()===6}const eb=null;function ig(n,t){return jt(n,t==null?void 0:t.in).getDay()===0}const sb=null;function sa(n,...t){const e=Sn.bind(null,n||t.find(s=>typeof s=="object"));return t.map(e)}function rg(n,t){const[e,s]=sa(n,t.start,t.end);return{start:e,end:s}}function og(n,t){var c;const{start:e,end:s}=rg(t==null?void 0:t.in,n);let i=+e>+s;const r=i?+e:+s,o=i?s:e;o.setHours(0,0,0,0);let a=(c=t==null?void 0:t.step)!=null?c:1;if(!a)return[];a<0&&(a=-a,i=!i);const l=[];for(;+o<=r;)l.push(Sn(e,o)),o.setDate(o.getDate()+a),o.setHours(0,0,0,0);return i?l.reverse():l}const nb=null;function ag(n,t){const e=jt(n,t==null?void 0:t.in);return e.setDate(1),e.setHours(0,0,0,0),e}const ib=null;function lg(n,t){const e=jt(n,t==null?void 0:t.in),s=e.getMonth();return e.setFullYear(e.getFullYear(),s+1,0),e.setHours(23,59,59,999),e}const rb=null;function na(n,t){const e=jt(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}const ob=null;function ia(n,t,e){const[s,i]=sa(e==null?void 0:e.in,n,t);return+na(s)==+na(i)}const ab=null,cg=n=>{switch(n.key){case"lessThanSecond":return fg(n);case"month":return pg(n);case"second":case"minute":case"hour":case"day":case"year":return gg(n);case"week-weekday":return mg(n);default:return()=>!1}},Qt=(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()}},xn=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s!==i},hg=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s>=i},dg={1:Jp,2:Qp,3:tg,4:eg,5:sg,6:ng,7:ig},ug=(n,t,e)=>{var s;const i=og({start:ag(n),end:lg(n)}),r=(s=dg[e])!=null?s:(()=>!1);if(t==="$"){for(const o of i.reverse())if(r(o))return ia(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return ia(n,a);o++}}return!1},ra=(n,t)=>t===1?n===1:n/t===1,oa=(n,t)=>t===1?!0:n%t===0,fg=n=>(t,e)=>hg(n.key)(t,e),pg=n=>(t,e)=>{const s=xn(n.key)(t,e),i=n.exact?ra(Qt(t,n.key)+1,n.value):oa(Qt(t,n.key)+1,n.value);return s&&i},gg=n=>(t,e)=>{const s=xn(n.key)(t,e),i=n.exact?ra(Qt(t,n.key),n.value):oa(Qt(t,n.key),n.value);return s&&i},mg=n=>(t,e)=>{const s=xn(n.key)(t,e),i=ug(t,n.week,n.weekday);return s&&i},vg=n=>{switch(n.key){case"second":case"minute":return bg(n.value);case"hour":return Cg(n.value);case"day":return yg(n.value);case"month":return xg(n.value);case"year":return _g(n.value);case"week-weekday":const t=Sg(n.week),e=wg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},bg=n=>n>0&&n<=60,Cg=n=>n>0&&n<=24,yg=n=>n>0&&n<=31,wg=n=>aa(n)?n>=1&&n<=7:!1,Sg=n=>n==="$"?!0:aa(n)?n>=1&&n<=6:!1,xg=n=>n>0&&n<=12,_g=n=>n>0,aa=n=>!isNaN(n)&&isFinite(n),Pg=(n,t,e)=>{var s,i;for(const[r,o]of e)if(o(n,t))return r;return(i=(s=e[e.length-1])==null?void 0:s[0])!=null?i:0};function _n(n,t,e){const s=new Array(n.length);let i=e(0);for(let r=0;r<n.length;r++){const o=n[r],a=e(o.candle.timestamp),l={weight:Pg(a,i,t)};s[r]=l,i=a}return s}const la=n=>{const t={},e={};return sn(n).forEach(([s,i])=>{const r=qo(s),o=r===null?!1:vg(r);if(r&&o){const a=Jo(r);t[a]=i,e[a]=cg(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class ca{constructor(t,e,s,i,r,o,a){this.eventBus=t,this.config=e,this.chartModel=s,this.scale=i,this.timeZoneModel=r,this.canvasModel=o,this.canvasBoundsContainer=a,this.labelsGroupedByWeight={},this.levelsCache={},this.labelCache=new Map,this.weightToTimeFormatMatcherArray=[],this.weightToTimeFormatsDict={},this.extendedLabelsFilterConfig={minute_1:h=>h>=2},this.calculateCoverUpLevel=()=>{const h=this.scale.currentAnimation,d=this.chartModel.mainCandleSeries.meanCandleWidth;if(Object.getOwnPropertyNames(this.labelsGroupedByWeight).length===0)return-1;const u=h!=null&&h.animationInProgress?bt(d,h.animationConfig.targetZoomX):bt(d,this.scale.zoomX);if(!isFinite(u))return-1;const f=this.config.components.xAxis.fontSize,p=Object.values(this.formatsByWeightMap).reduce((_,S)=>Math.max(S.length,_),1),m=f*p;return Math.round(m/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=la(this.formatsByWeightMap);this.weightToTimeFormatMatcherArray=Object.entries(c).map(([h,d])=>[parseInt(h,10),d]).sort(([h],[d])=>d-h),this.weightToTimeFormatsDict=l}get labels(){return this.filterLabelsInViewport(this.getLabelsFromChartType())}filterLabelsInViewport(t){const e=this.canvasBoundsContainer.getBounds(M.X_AXIS),s=[];for(const i of t){const r=this.scale.toX(i.value);r<0||r>e.width||s.push(i)}return s}getLabelsFromChartType(){var t,e;const s=(e=(t=this.weightedCache)==null?void 0:t.labels)!=null?e:[];return this.config.components.chart.type==="equivolume"?this.postProcessing(s):s}getVisualCandleAtIndex(t,e,s,i,r){return t>=0&&t<s.length?s[t]:on(e,s,i,t,r)}getVisualCandlesWithFake(t=[]){const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0)return[];const i=Array.from({length:750}).map((r,o)=>on(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,e.length+o,this.chartModel.getPeriod()));return[...t,...e,...i]}getViewportCandlesWithFake(){var t;const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0||this.scale.xEnd-this.scale.xStart<=1)return[];const s=this.chartModel.mainCandleSeries.meanCandleWidth,i=this.chartModel.getPeriod(),r=this.chartModel.mainCandleSeries.dataPoints,o=this.canvasBoundsContainer.getBounds(M.CHART),a=0,l=o.width,c=this.scale.fromX(a),h=this.scale.fromX(l);let d=0;if(e.length>0){const E=e[0];d=E.centerUnit-((t=E.candle.idx)!=null?t:0)*s}const u=500,f=500,p=Math.floor((c-d)/s)-u,m=Math.ceil((h-d)/s)+u,_=Math.floor(p/f)*f,S=Math.ceil(m/f)*f,A=[];for(let E=_;E<=S;E++)A.push(this.getVisualCandleAtIndex(E,r,e,s,i));return[...A]}getAllCandlesWithFake(t=[]){return this.config.components.chart.minCandlesOffset?this.getVisualCandlesWithFake(t):this.getViewportCandlesWithFake()}mapWeightedPointsToLabels(t,e){var s;const i=new Array(t.length);for(let r=0;r<t.length;++r){const o=t[r],a=e[r],l=this.weightToTimeFormatsDict[o.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(a.candle.timestamp);i[r]={weight:o.weight,idx:(s=a.candle.idx)!=null?s:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){this.clearLabelCache();const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=la(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(s).map(([i,r])=>[parseInt(i,10),r]).sort(([i],[r])=>r-i),this.weightToTimeFormatsDict=e,this.generateLabels()}getLabelsFromCache(t){if(this.levelsCache[t])return this.levelsCache[t]}updateLastLabel(t){const e=this.chartModel.mainCandleSeries.visualPoints[this.chartModel.mainCandleSeries.visualPoints.length-2];if(e){const i=_n([e,t],this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),r=this.mapWeightedPointsToLabels([i[1]],[t]),[o]=r;this.labelsGroupedByWeight=Object.entries(this.labelsGroupedByWeight).reduce((a,[l,c])=>{const h=c.findIndex(u=>u.idx===o.idx);let d=c;if(h!==-1&&(d=c.filter(u=>u.idx!==o.idx)),parseInt(l,10)===o.weight){const u=d.findIndex(f=>f.idx>o.idx);u!==-1?d=[...d.slice(0,u),o,...d.slice(u)]:d.push(o)}return a[l]=d,a},{}),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}}updateHistoryLabels(t){const e=t.concat(this.chartModel.mainCandleSeries.visualPoints[t.length]),s=_n(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=Qo(i),o=le(r);for(const c in this.labelsGroupedByWeight)o[c]===void 0&&(o[c]=this.labelsGroupedByWeight[c]);const a=this.chartModel.mainCandleSeries.visualPoints[t.length-1],l=Object.entries(o).sort(([c],[h])=>parseInt(h,10)-parseInt(c,10)).reduce((c,[h,d])=>{const u=parseInt(h,10),f=this.labelsGroupedByWeight[u];if(u===this.weightToTimeFormatMatcherArray[0][0]&&f.shift(),f){const p=f.map(m=>(m.idx=m.idx+t.length,m.value=a.startUnit+a.width+m.value,m));r[u]?c[h]=d.concat(p):c[h]=p}else c[h]=d;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(t,e=!1){var s;const i=this.getAllCandlesWithFake(t),r=_n(i,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone));let o=[];if(e)for(let a=0;a<i.length;a++){const l=(s=i[a].candle.idx)!=null?s:a,c=i[a].candle.timestamp,h=`${l}_${c}`;let d=this.labelCache.get(h);d||(d=this.mapWeightedPointsToLabels([r[a]],[i[a]])[0],this.labelCache.set(h,d)),o.push(d)}else o=this.mapWeightedPointsToLabels(r,i);this.labelsGroupedByWeight=Qo(o),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}recalculateLabels(){this.recalculateCachedLabels()}recalculateCachedLabels(){const t=this.calculateCoverUpLevel();if(!(t<0)&&(this.weightedCache===void 0||t!==this.weightedCache.coverUpLevel)){const e=this.getLabelsFromCache(t);if(e){this.weightedCache={labels:e,coverUpLevel:t};return}const s=Zp(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,t),t);this.levelsCache[t]=s,this.weightedCache={labels:s,coverUpLevel:t},this.eventBus.fireDraw()}}postProcessing(t){var e,s;const i=[];let r=0,o=1;for(;o<=t.length-1;){const a=t[r],l=t[o];$p(this.canvasModel.ctx,this.config,a,l,this.scale,30)?((e=l.weight)!=null?e:0)>((s=a.weight)!=null?s:0)&&(r=o):(i.push(a),r=o,o===t.length-1&&i.push(l)),o++}return i}filterLabelsByExtendedRules(t,e){const s=sn(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=qo(o);if(l){const c=Jo(l);i[c]=a}}return i},{});return sn(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class Tg extends W{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(ds,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}const ha=3;class Mg extends W{constructor(t,e,s,i,r,o,a){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=i,this.chartModel=r,this.hitTest=o,this.hitTestCanvasModel=a,this.lastXStart=0,this.lastXEnd=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXEnd=this.scale.xEnd,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const l=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.lastXPxWidth=l.width-this.canvasInputListener.currentPoint.x,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=l=>{let{delta:c}=l;if(!this.touches||this.touches.length===1){const h=this.lastXPxWidth-c;if(h<0)return;const d=this.lastXPxWidth/h,u=this.lastXWidth*d,f=this.lastXStart+(this.lastXWidth-u);this.scale.setXScale(f,this.scale.xEnd);return}if(this.touches.length>1){c=Math.min(this.touches[0].clientX,this.touches[1].clientX)===this.touches[0].clientX?c:-c;let d;c<0?d=1/(1+-c/this.lastXPxWidth*(ha-1)):d=1+c/this.lastXPxWidth*(ha-1);const f=(this.lastXWidth*d-this.lastXWidth)/2,p=this.lastXStart-f,m=this.lastXEnd+f;(this.lastXStart!==p||this.lastXEnd!==m)&&this.scale.setXScale(p,m)}},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=l=>this.dblTapCallback=l,this.setDblClickCallback=l=>this.dblClickCallback=l,this.dblClickCallback=()=>r.doBasicScale(),this.dblTapCallback=()=>r.doBasicScale(),this.dragNDropXComponent=new Ne(o,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>i.chartAreaPanHandler.chartPanningOptions.horizontal}),this.addChildEntity(this.dragNDropXComponent)}setChartAreaXDragThrottled(t){this.dragNDropXComponent.setShouldThrottle(t)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>this.dblClickCallback())),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class Ag extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.chartComponent=i,this.scale=r,this.chartResizeHandler=l,this.timeZoneModel=h,this.yAxis=p,this.setDblClickCallback=S=>this.xAxisScaleHandler.setDblClickCallback(S),this.setDblTapCallback=S=>this.xAxisScaleHandler.setDblTapCallback(S);const m=new ca(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=m,this.xAxisLabelsModel=new Tg(t,[]);const _=new hn;c.addDrawer(_,"X_AXIS"),this.xAxisDrawer=new ys(e,s,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),_.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Xp(e,s,o,this.xAxisLabelsModel),_.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new Mg(r,a,o,d,this.chartComponent.chartModel,o.getBoundsHitTest(M.X_AXIS),f),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(M.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe(K(({prependedCandles:t})=>t.length!==0),lt(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;dc.includes(this.config.components.chart.type)&&((s=(e=this.xAxisLabelsGenerator).updateHistoryLabels)==null||s.call(e,t))})),this.config.components.chart.minCandlesOffset?this.addRxSubscription(wt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Et(50,Bt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.recalculateLabels())):this.addRxSubscription(wt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Et(150,Bt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.generateLabels(void 0,!0))),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(lt(()=>St(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),mt((t,e)=>{var s,i;return((s=t==null?void 0:t.candle)==null?void 0:s.id)===((i=e==null?void 0:e.candle)==null?void 0:i.id)}),K(ui)).subscribe(t=>{var e,s;return(s=(e=this.xAxisLabelsGenerator)==null?void 0:e.updateLastLabel)==null?void 0:s.call(e,t)})),this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(gn(this.yAxis.getAxisType()),mt(),lt(t=>t==="percent")).subscribe(t=>{this.xAxisScaleHandler.setChartAreaXDragThrottled(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 ca?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 Eg=Object.defineProperty,da=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,Dg=Object.prototype.propertyIsEnumerable,ua=(n,t,e)=>t in n?Eg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ws=(n,t)=>{for(var e in t||(t={}))Ig.call(t,e)&&ua(n,e,t[e]);if(da)for(var e of da(t))Dg.call(t,e)&&ua(n,e,t[e]);return n};class Lg{constructor(t,e,s,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=s&&ws(ws({},s),this.getLabelDrawConfig(this.chartModel.mainCandleSeries,!0));if(i){const r={labels:[i]},o=this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];o==null||o(r,this.chartModel.mainCandleSeries),t.push(r)}return this.chartModel.candleSeries.forEach((r,o)=>{if(o===0)return;const a=this.getYAxisVisualLabel(r),l=a&&ws(ws({},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=St(t.dataPoints);if(e){const s=t.view.toY(e.close);if(isFinite(s)){const i=this.yAxisConfig.labels.settings.lastPrice.mode,r=this.yAxisConfig.labels.settings.lastPrice.type;return{y:s,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,t),mode:i,labelType:r,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const s=this.yAxisConfig.labels.settings.lastPrice.type,i=t.colors.labels,{rectLabelTextColor:r="white",rectLabelInvertedTextColor:o="black"}=this.chartConfig.colors.yAxis,a=this.resolveLabelColorFn(t.config.type);if(!i)return{bgColor:"#FFFFFF",textColor:re("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:Qf(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):re(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):re(l,r,o),rounded:!0}}}class Og{constructor(t,e,s,i,r,o){this.yAxisLabelsCanvasModel=t,this.yAxisDescriptionsCanvasModel=e,this.backgroundCanvasModel=s,this.canvasBoundsContainer=i,this.fullConfig=r,this.paneManager=o}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx,s=this.yAxisDescriptionsCanvasModel.ctx;this.paneManager.yExtents.forEach(i=>{if(i.yAxis.state.visible){const r=i.getYAxisBounds(),o=this.canvasBoundsContainer.getBounds(M.ALL_PANES),a=i.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(l=>{var c;const h=(c=l.bounds)!=null?c:r;l.labels.forEach(d=>po(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>po(t,s,e,r,o,l,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=s[r.subGroupId])!=null?o:[];if(s[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS($));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];Fr(e,{x:h.x,y:Wi(d,h)},{x:h.x+h.width-6,y:Wi(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Bg{constructor(t,e,s){this.fullConfig=t,this.canvasModel=e,this.paneManager=s}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const s=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;this.fullConfig.components.chart.applyBackgroundToAxes.y||(r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height));const o=oe(e.state),a=Xt(o,r),l=this.getLabelTextColor();r.save(),Kt(r,i),this.drawLabels(r,s,i,a,o,l,e),r.restore()}})}drawLabels(t,e,s,i,r,o,a){t.fillStyle=o,t.font=r;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=s.y+c,d=s.y+s.height-c;e.forEach(u=>{const f=a.scale.toY(u.value);f>h&&f<d&&Rg(t,s,u.text,f,i,r,a.state.labelBoxMargin.end,a.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const Rg=(n,t,e,s,i,r,o,a)=>{const l=a==="right"?t.x+t.width-Mt(e,n,r)-o:t.x+o;n.fillText(e,l,s+i/2-1)};class Fg{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&Vl.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 F,s=e.next.bind(e),i=e.unsubscribe.bind(e);return this.on(t,s),e.unsubscribe=()=>{this.unsub(t,s),i()},e.asObservable()},this.onPrior=(t,e)=>this.add(this.UNKNOWN_ARR.unshift,t,e),this.off=this.unsub,this.fire=(t,...e)=>{var s;if(!this.muted){const i=(s=this.handlers[t])!=null?s:[];let r;for(r=0,i.length;r<i.length;r++)i[r].apply(null,e)}},this.fireAsync=(t,e)=>{if(!this.muted)return window.setTimeout(this.fire.bind(this,t,e),0)},this.setMuted=t=>{this.muted=t},this.clear=()=>{this.handlers={}}}fireDraw(t){this.fire(ds,t)}}class Hg extends W{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(lt(r=>i.components.chart.highlightActiveCandle?r:void 0),mt()).subscribe(r=>{r&&this.setCandleAsActive(r,t,e)})}setCandleAsActive(t,e,s){if(t.touches.length===1){const i=t.touches.item(0);if(i!==null){const r=this.getTouchXPosition(i,e),o=s.candleFromX(r);o&&s.mainCandleSeries.setActiveCandle(o)}}}getTouchXPosition(t,e){const s=e.getBoundingClientRect(),i=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-s.left-i}}class kg{constructor(t,e,s,i,r){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${_t()}`,this.canvasResized=new F,this.recentlyResized=!1,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){Me(this.animFrameId,()=>this.fireUpdates())}fireUpdates(){const t=this.resizerElement.getBoundingClientRect(),e={x:t.x,y:t.y,width:t.width,height:t.height};this.config||(this.frameElement.style.height=this.resizerElement.clientHeight+"px"),(this.previousBCR===void 0||this.isBCRDimensionsDiffer(this.previousBCR,e))&&(this.previousBCR=e,this.recentlyResized=!0,this.canvasModels.forEach(s=>this.previousBCR&&s.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(hs,e),this.bus.fire(ds))}clearResizedFlag(){this.recentlyResized=!1}isBCRDimensionsDiffer(t,e){return t.height!==e.height||t.width!==e.width}unsubscribeAnimationUpdate(){if(this.resizerElement)try{this.elementResizeDetector.unobserve(this.resizerElement)}catch(t){console.warn("ChartResizeHandler.ts, unsubscribeAnimationUpdate failed")}}wasResized(){return this.recentlyResized}}var jg=Array.isArray,Yg=Object.getPrototypeOf,Ng=Object.prototype,Xg=Object.keys;function Wg(n){if(n.length===1){var t=n[0];if(jg(t))return{args:t,keys:null};if(zg(t)){var e=Xg(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function zg(n){return n&&typeof n=="object"&&Yg(n)===Ng}var Vg=Array.isArray;function Ug(n,t){return Vg(t)?n.apply(void 0,at([],H(t))):n(t)}function fa(n){return lt(function(t){return Ug(n,t)})}function Gg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function Zg(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=hl(n),i=Wg(n),r=i.args,o=i.keys;if(r.length===0)return Ze([],e);var a=new gt($g(r,e,o?function(l){return Gg(o,l)}:ne));return s?a.pipe(fa(s)):a}function $g(n,t,e){return e===void 0&&(e=ne),function(s){pa(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){pa(t,function(){var d=Ze(n[h],t),u=!1;d.subscribe(yt(s,function(f){r[h]=f,u||(u=!0,a--),a||s.next(e(r.slice()))},function(){--o||s.complete()}))},s)},c=0;c<i;c++)l(c)},s)}}function pa(n,t,e){n?Yt(e,n,t):t()}class Kg extends W{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new ft(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=Zg([s,i]).pipe(K(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}!l&&!Ot()&&(this.crossSubject.next(null),r=!0)});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}class qg{constructor(t,e,s,i){this.visualCandle=t,this.price=e,this.priceFormatter=s,this.toY=i}get high(){return this.visualCandle.high}get low(){return this.visualCandle.low}get open(){return this.visualCandle.open}get close(){return this.visualCandle.close}get volume(){return this.visualCandle.candle.volume}get openY(){return this.toY(this.open)}get closeY(){return this.toY(this.close)}get highY(){return this.toY(this.high)}get lowY(){return this.toY(this.low)}get openFormatted(){return this.priceFormatter(this.open)}get closeFormatted(){return this.priceFormatter(this.close)}get highFormatted(){return this.priceFormatter(this.high)}get lowFormatted(){return this.priceFormatter(this.low)}get closestOHLCY(){return this.toY([this.close,this.open,this.high,this.low].sort((t,e)=>Math.abs(t-this.price)-Math.abs(e-this.price))[0])}}class Jg{constructor(t){this.chartModel=t}getData(t){const{x:e,y:s}=t,r=this.chartModel.candleFromX(e).idx||0,o=this.chartModel.getVisualCandle(r),a=this.chartModel.priceFromY(s);return o&&new qg(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class Qg{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof Jr)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 tm=Object.defineProperty,em=Object.defineProperties,sm=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,nm=Object.prototype.hasOwnProperty,im=Object.prototype.propertyIsEnumerable,ma=(n,t,e)=>t in n?tm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ue=(n,t)=>{for(var e in t||(t={}))nm.call(t,e)&&ma(n,e,t[e]);if(ga)for(var e of ga(t))im.call(t,e)&&ma(n,e,t[e]);return n},Xe=(n,t)=>em(n,sm(t));class rm extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.mainCanvasTouchHandler=c,this.formatterFactory=h,this.hoverSubject=new ft(null),this.longTouchActivatedSubject=new ft(!1),this.longTouchCrosshairSuppressed=!1,this.hoverOverLastCandle=!1,this.xFormatter=()=>"";const d=new Jg(this.chartModel),u=new Qg(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(Ao(()=>this.scale.initialViewportValidSubject.pipe(K(Boolean)))).subscribe(()=>{const e=this.chartModel.getLastVisualCandle();e&&this.createAndFireHoverFromCandle(e)})),this.addRxSubscription(this.chartModel.candlesUpdatedSubject.subscribe(()=>{const e=this.chartModel.getLastVisualCandle();this.hover!==null&&e!==void 0&&this.hoverOverLastCandle&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?(this.hoverOverLastCandle=!1,this.hoverSubject.next(null)):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(wt(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter())),this.addRxSubscription(this.canvasInputListener.observeTouchStart().subscribe(e=>{var s;this.crossEventProducer.crossToolTouchInfo.isCommonTap=!0;const{clientX:i,clientY:r}=e.touches[0];if(this.longTouchActivatedSubject.getValue())this.crossEventProducer.crossToolTouchInfo.temp={x:i-this.canvasBoundsContainer.canvasOnPageLocation.x,y:r-this.canvasBoundsContainer.canvasOnPageLocation.y};else{const o=((s=this.paneManager.getPaneIfHit({x:i,y:r}))==null?void 0:s.uuid)||"";this.createAndFireHover([i,r,o])}}));const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{var s;if(this.longTouchCrosshairSuppressed||(this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.mainCanvasTouchHandler.canvasTouchInfo.isMoving||this.chartModel.config.components.crossTool.type==="none"||e.touches.length>1))return;this.longTouchActivatedSubject.next(!0),this.crossEventProducer.crossToolTouchInfo.isSet=!1;const r=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,o=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.crossEventProducer.crossToolTouchInfo.fixed={x:r,y:o};const a=((s=this.paneManager.getPaneIfHit({x:r,y:o}))==null?void 0:s.uuid)||"";this.createAndFireHover([r,o,a]),this.crossEventProducer.crossSubject.next([r,o,a]),this.paneManager.chartPanComponent.setChartPanningOptions(!1,!1)})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(e=>{var s,i,r,o,a,l,c,h;const{clientX:d,clientY:u}=e.changedTouches[0],{fixed:f,temp:p}=this.crossEventProducer.crossToolTouchInfo,m=d-this.canvasBoundsContainer.canvasOnPageLocation.x,_=u-this.canvasBoundsContainer.canvasOnPageLocation.y;if(this.crossEventProducer.crossToolTouchInfo.isCommonTap&&!Do(m,p.x,_,p.y)){this.resetCrossTool();return}if(this.crossEventProducer.crossToolTouchInfo.isSet){const S=(c=(l=this.crossEventProducer.crossToolHover)==null?void 0:l.paneId)!=null?c:"CHART",A=this.canvasBoundsContainer.getBounds(M.PANE_UUID(S)),E=A.y+5,Y=A.y+A.height-5,B=m-p.x,R=_-p.y,k=f.x<0?0:f.x>A.width?A.width:f.x+=B,V=f.y<E?E:f.y>Y?Y:f.y+=R;this.crossEventProducer.crossToolTouchInfo.fixed={x:k,y:V},this.crossEventProducer.crossToolTouchInfo.temp={x:k,y:V};const X=(h=this.crossEventProducer.crossToolHover)!=null?h:this.hover;if(!X)return;this.crossEventProducer.crossToolHover=Xe(ue({},X),{x:k,y:V,paneId:S}),this.crossEventProducer.crossSubject.next([k,V,S])}else{this.crossEventProducer.crossToolTouchInfo.isSet=!0;const S=this.crossEventProducer.crossToolHover,A=(s=S==null?void 0:S.x)!=null?s:m,E=(i=S==null?void 0:S.y)!=null?i:_;this.crossEventProducer.crossToolTouchInfo.temp={x:A,y:E},this.crossEventProducer.crossToolTouchInfo.fixed={x:A,y:E};const Y=(a=(o=S==null?void 0:S.paneId)!=null?o:(r=this.paneManager.getPaneIfHit({x:A,y:E}))==null?void 0:r.uuid)!=null?a:"",B=S!=null?S:this.hover;if(!B)return;this.crossEventProducer.crossToolHover=Xe(ue({},B),{x:A,y:E,paneId:Y}),this.crossEventProducer.crossSubject.next([A,E,Y])}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=mo(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),s=this.scale.toY(t.close);return this.createHover(e,s,$)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const r=this.chartModel.candleFromX(t,!0).timestamp,o={x:t,y:e,timestamp:r,timeFormatted:this.xFormatter(r),paneId:s},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>Xe(ue({},l),{[c[0]]:c[1].getData(o)}),{});return ue(ue({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){var e,s;if(!this.hover)return;const i=Ot()&&this.longTouchActivatedSubject.getValue()&&this.crossEventProducer.crossSubject.getValue()!==null,r=this.crossEventProducer.crossToolHover,o=i?(e=r==null?void 0:r.x)!=null?e:this.hover.x:this.hover.x,a=i?(s=r==null?void 0:r.y)!=null?s:this.hover.y:this.hover.y,l=this.chartModel.candleFromX(o,!0),c=t.candle.idx,h=l.idx;if(c!==void 0&&h!==void 0&&h<c&&o<t.xStart(this.scale))return;const d=this.createHoverFromCandle(t);if(d){const u=Xe(ue({},d),{x:o,y:a});this.fireHover(u)}}updateHoverLastCandle(t){const e=this.chartModel.getLastVisualCandle();if(!e){this.hoverOverLastCandle=!1;return}const s=this.chartModel.candleFromX(t.x,!0),i=e.candle.idx,r=s.idx,o=i!==void 0&&r!==void 0&&r<i&&t.x<e.xStart(this.scale);this.hoverOverLastCandle=!o&&(e.candle.timestamp<=t.timestamp||i!==void 0&&r!==void 0&&r===i)}createAndFireHover([t,e,s]){const i=this.createHover(t,e,s);this.fireHover(i)}fireHover(t){var e,s;if(t){if(Ot()&&this.config.components.crossTool.type!=="none"){const i=this.crossEventProducer.crossToolHover,r=i?(e=i.candleHover)==null?void 0:e.visualCandle.candle:(s=t.candleHover)==null?void 0:s.visualCandle.candle;r&&this.chartModel.mainCandleSeries.setActiveCandle(r)}this.updateHoverLastCandle(t),this.hoverSubject.next(t)}else this.hoverOverLastCandle=!1,this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}setLongTouchCrosshairSuppressed(t){this.longTouchCrosshairSuppressed=t}resetCrossTool(t=!1){this.paneManager.chartPanComponent.setChartPanningOptions(!0,!0),this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose(),this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isSet=!1,t&&(this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.crossEventProducer.crossToolTouchInfo.fixed={x:0,y:0},this.crossEventProducer.crossToolTouchInfo.temp={x:0,y:0})}registerHoverProducerPart(t,e){this.hoverProducerParts=Xe(ue({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const va={left:0,middle:1,right:2};function Ct(n,t,e,s){return n.addEventListener(e,t,s),function(){n.removeEventListener(e,t,s)}}function Pe(n){return t=>{t.button===va.left&&n(t)}}var om=["addListener","removeListener"],am=["addEventListener","removeEventListener"],lm=["on","off"];function Pn(n,t,e,s){if(j(e)&&(s=e,e=void 0),s)return Pn(n,t,e).pipe(fa(s));var i=H(dm(n)?am.map(function(a){return function(l){return n[a](t,l,e)}}):cm(n)?om.map(ba(n,t)):hm(n)?lm.map(ba(n,t)):[],2),r=i[0],o=i[1];if(!r&&Rs(n))return Hs(function(a){return Pn(a,t,e)})(Lt(n));if(!r)throw new TypeError("Invalid event target");return new gt(function(a){var l=function(){for(var c=[],h=0;h<arguments.length;h++)c[h]=arguments[h];return a.next(1<c.length?c:c[0])};return r(l),function(){return o(l)}})}function ba(n,t){return function(e){return function(s){return n[e](t,s)}}}function cm(n){return j(n.addListener)&&j(n.removeListener)}function hm(n){return j(n.on)&&j(n.off)}function dm(n){return j(n.addEventListener)&&j(n.removeEventListener)}var um=Object.defineProperty,Ca=Object.getOwnPropertySymbols,fm=Object.prototype.hasOwnProperty,pm=Object.prototype.propertyIsEnumerable,ya=(n,t,e)=>t in n?um(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,gm=(n,t)=>{for(var e in t||(t={}))fm.call(t,e)&&ya(n,e,t[e]);if(Ca)for(var e of Ca(t))pm.call(t,e)&&ya(n,e,t[e]);return n};const Ss=class pe extends W{constructor(t,e){super(),this.eventBus=t,this.element=e,this.xDragStartSubject=new F,this.xDragSubject=new F,this.xDragTickSubject=new F,this.xDragEndSubject=new F,this.yDragStartSubject=new F,this.yDragSubject=new F,this.yDragTickSubject=new F,this.yDragEndSubject=new F,this.mouseMoveSubject=new F,this.mouseMoveDocumentSubject=new F,this.clickSubject=new F,this.clickDocumentSubject=new F,this.dbClickSubject=new F,this.dbTapSubject=new F,this.mouseDownSubject=new F,this.mouseUpSubject=new F,this.mouseUpDocumentSubject=new F,this.wheelSubject=new F,this.touchStartSubject=new F,this.touchStartTimestamp=0,this.touchMoveSubject=new F,this.touchEndSubject=new F,this.touchCancelSubject=new F,this.longTouchStartSubject=new F,this.longTouchEndSubject=new F,this.contextMenuSubject=new F,this.fastTouchScroll=new F,this.mouseLeavesCanvasSubject=new F,this.dragStartPoint={x:0,y:0},this.prevDragPoint={x:0,y:0},this.currentPoint={x:0,y:0},this.currentPointDocument={x:0,y:0},this.dragging=!1,this.canvasBounds={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.cachedElementRect=null,this.rectCacheValid=!1,this.documentDragListeners=[],this.dragProcessListener=()=>{this.xDragSubject.next(this.currentPoint.x-this.dragStartPoint.x),this.yDragSubject.next(this.currentPoint.y-this.dragStartPoint.y),this.xDragTickSubject.next(this.currentPoint.x-this.prevDragPoint.x),this.yDragTickSubject.next(this.currentPoint.y-this.prevDragPoint.y),this.prevDragPoint.x=this.currentPoint.x,this.prevDragPoint.y=this.currentPoint.y},this.dragStartListener=s=>{this.isDraggable(s)&&(this.updateCurrentPoints(s),this.dragging=!0,this.dragStartEvent=s,this.cleanupDocumentDragListeners(),this.dragStartPoint=pe.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=gm({},this.dragStartPoint),pe.DRAG_EVENTS.forEach(i=>{document.addEventListener(i,this.dragProcessListener,!0);const r=document.removeEventListener.bind(document,i,this.dragProcessListener,!0);this.documentDragListeners.push(r),this.addSubscription(r)}),this.dragProcessListener())},this.dragListener=()=>this.mouseMoveDocumentSubject.next(this.currentPoint),this.updateElementOffsetListener=()=>this.mouseMoveSubject.next(this.currentPoint),this.dragEndListener=()=>{this.dragging=!1,this.cleanupDocumentDragListeners(),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=s=>{this.updateCurrentDocumentPoint(s),this.updateCurrentMousePoint(s)}}getElementRect(){if(this.rectCacheValid&&this.cachedElementRect)return this.cachedElementRect;try{if(!this.element||!this.element.isConnected)return this.createFallbackRect();const t=this.element.getBoundingClientRect();return this.cachedElementRect=t,this.rectCacheValid=!0,t}catch(t){return this.createFallbackRect()}}createFallbackRect(){return typeof DOMRect!="undefined"?new DOMRect(0,0,0,0):{x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>({})}}invalidateRectCache(){this.rectCacheValid=!1}initializeRectCache(){this.invalidateRectCache();const t=this.getElementRect();this.canvasBounds.x=t.left,this.canvasBounds.y=t.top,this.canvasBounds.width=t.width,this.canvasBounds.height=t.height}cleanupDocumentDragListeners(){if(!this.documentDragListeners||!Array.isArray(this.documentDragListeners)){this.documentDragListeners=[];return}this.documentDragListeners.forEach(t=>{try{t()}catch(e){console.warn("Error cleaning up drag listener:",e)}}),this.documentDragListeners=[]}doDeactivate(){this.invalidateRectCache(),this.cachedElementRect=null,this.cleanupDocumentDragListeners(),super.doDeactivate()}isDraggable(t){return t instanceof MouseEvent?t.button===va.left:t instanceof TouchEvent}startDragging(t){this.updateCurrentPoints(t),this.dragStartListener(t)}movePointer(t){this.updateCurrentPoints(t),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const t=e=>(e.preventDefault(),!1);this.element.addEventListener("selectstart",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",t,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],pe.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),pe.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragListener)),this.element.addEventListener(s,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,s,this.updateElementOffsetListener))}),pe.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(Ct(this.element,Pe(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(Ct(document,Pe(s=>this.clickDocumentSubject.next(s)),"click"));const t=vs();if(t==="apple"||t==="mobile"){let s=null;const i=a=>{a.preventDefault(),s?(this.dbTapSubject.next(this.currentPoint),clearTimeout(s),s=null):s=window.setTimeout(()=>{s=null},250)};this.addSubscription(Ct(this.element,i,"touchend"));const r=(a,l=200)=>{a.preventDefault();let c=!1,h=null;h=setTimeout(()=>{c=!0,this.longTouchStartSubject.next(a)},l);const d=f=>{f.preventDefault(),f.touches.length>1&&h&&clearTimeout(h)},u=f=>{f.preventDefault(),h&&clearTimeout(h),c&&(c=!1,this.longTouchEndSubject.next(f)),this.element.removeEventListener("touchend",u),this.element.removeEventListener("touchmove",d)};this.element.addEventListener("touchmove",d),this.element.addEventListener("touchend",u)};this.addSubscription(Ct(this.element,a=>r(a),"touchstart"));const o=a=>{if(a.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const h=this.touchStartTimestamp,u=Date.now()-h,p=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,m=u<=250;p&&m&&this.fastTouchScroll.next(a)}};this.addSubscription(Ct(this.element,o,"touchend"))}this.addSubscription(Ct(this.element,Pe(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(Ct(this.element,s=>{this.touchStartSubject.next(s),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(Ct(this.element,s=>this.touchMoveSubject.next(s),"touchmove",!0)),this.addSubscription(Ct(this.element,s=>this.touchEndSubject.next(s),"touchend")),this.addSubscription(Ct(this.element,s=>this.touchCancelSubject.next(s),"touchcancel")),this.addSubscription(Ct(this.element,s=>{this.updateCurrentPoints(s),this.wheelSubject.next(s),s.preventDefault()},"wheel")),this.addSubscription(Ct(this.element,s=>this.contextMenuSubject.next(s),"contextmenu")),this.addSubscription(Ct(this.element,Pe(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(Ct(this.element,Pe(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(Ct(document,Pe(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(hs).subscribe(()=>{this.invalidateRectCache();const s=this.getElementRect();this.canvasBounds.x=s.left,this.canvasBounds.y=s.top,this.canvasBounds.width=s.width,this.canvasBounds.height=s.height})),this.addRxSubscription(Pn(document,"scroll",{capture:!0,passive:!0}).pipe(Et(zt,rs,{trailing:!0})).subscribe(()=>this.invalidateRectCache()));const e=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",e,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",e,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){pe.DRAG_EVENTS.forEach(t=>{document.addEventListener(t,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(t,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(t){"pageX"in t?this.currentPointDocument.x=t.pageX:t.touches!==void 0&&(this.currentPointDocument.x=t.touches[0].pageX),"pageY"in t?this.currentPointDocument.y=t.pageY:t.touches!==void 0&&(this.currentPointDocument.y=t.touches[0].pageY)}updateCurrentMousePoint(t){const e=this.getElementRect();"clientX"in t?this.currentPoint.x=t.clientX-e.left:t.touches!==void 0&&(this.currentPoint.x=t.touches[0].clientX-e.left),"clientY"in t?this.currentPoint.y=t.clientY-e.top:t.touches!==void 0&&(this.currentPoint.y=t.touches[0].clientY-e.top)}static copyPoint(t){return{x:t.x,y:t.y}}observeMouseMove(t=()=>!0){return this.mouseMoveSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe(K(()=>!this.dragging))}observeMouseMoveDocument(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(K(()=>t(this.currentPointDocument.x,this.currentPointDocument.y)),lt(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(t=()=>!0){return this.xDragStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(t=()=>!0){return this.xDragSubject.pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(t=()=>!0){return this.xDragEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(t=()=>!0){return this.yDragStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(t=()=>!0){return this.yDragSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(t=()=>!0){return this.yDragEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(t=()=>!0,e=!1){const s=this.mouseMoveSubject.asObservable().pipe(K(()=>!(e&&this.dragging)),lt(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(lt(()=>!1));return wt(s,i).pipe(mt())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(t=()=>!0){return this.clickSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(t=()=>!0){return this.dbClickSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(t=()=>!0){return this.dbTapSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeWheel(t=()=>!0){return this.wheelSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchStart(t=()=>!0){return this.touchStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(t=()=>!0){return this.touchMoveSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(t=()=>!0){return this.mouseDownSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(t=()=>!0){return this.mouseUpSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(t=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(t=()=>!0){return this.contextMenuSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)),No(e=>e.preventDefault()))}observeLongTouchStart(t=()=>!0){return this.longTouchStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(t=()=>!0){return this.longTouchEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(t=()=>!0){return this.fastTouchScroll.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};Ss.DRAG_START_EVENTS=["mousedown","touchstart"],Ss.DRAG_EVENTS=["mousemove","touchmove"],Ss.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];let mm=Ss;var vm=(function(n){z(t,n);function t(e,s,i){e===void 0&&(e=1/0),s===void 0&&(s=1/0),i===void 0&&(i=Js);var r=n.call(this)||this;return r._bufferSize=e,r._windowTime=s,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=s===1/0,r._bufferSize=Math.max(1,e),r._windowTime=Math.max(1,s),r}return t.prototype.next=function(e){var s=this,i=s.isStopped,r=s._buffer,o=s._infiniteTimeWindow,a=s._timestampProvider,l=s._windowTime;i||(r.push(e),!o&&r.push(a.now()+l)),this._trimBuffer(),n.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var s=this._innerSubscribe(e),i=this,r=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!e.closed;l+=r?1:2)e.next(a[l]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,i=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*s;if(s<1/0&&a<r.length&&r.splice(0,r.length-a),!o){for(var l=i.now(),c=0,h=1;h<r.length&&r[h]<=l;h+=2)c=h;c&&r.splice(0,c+1)}},t})(F);const Tn={};function bm(n){return Tn[n]||(Tn[n]=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Tn[n]}const wa=(n,t=Date.now())=>{const s=bm(n).format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(s);if(i){const r=Date.UTC(+i[3],+i[1]-1,+i[2],+i[4]%24,+i[5],+i[6]);let o=t;const a=o%1e3;return o-=a>=0?a:1e3+a,r-o}return 0},Sa=60*1e3;class Cm{constructor(t){this.config=t,this.timeZoneChangedSubject=new vm,this.currentTzOffset=e=>wa(this.config.timezone,e)+new Date(e).getTimezoneOffset()*Sa,this.formatterCache={},this.dateTimeFormatterFactory=this.initFormatterFactory(this.config.dateFormatter)}setTimeZone(t){this.config.timezone=t,this.formatterCache={},this.timeZoneChangedSubject.next(t)}observeTimeZoneChanged(){return this.timeZoneChangedSubject.asObservable()}initFormatterFactory(t){let e;if(t&&typeof t=="function")e=t;else if(t&&t.createFormatterFunction&&typeof t.createFormatterFunction=="function"){const s=t.createFormatterFunction;e=i=>s(i).bind(t)}else e=Xu(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+wa(t,e)+new Date(e).getTimezoneOffset()*Sa):e=>new Date(e)}}class ym extends W{constructor(t,e,s){super(),this.hitTestCanvasModel=t,this.canvasAnimation=e,this.eventBus=s}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasAnimation.animationInProgressSubject.subscribe(()=>{const t=this.canvasAnimation.animationInProgressSubject.getValue();this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!t)})),this.addRxSubscription(this.hitTestCanvasModel.hitTestDrawersPredicateSubject.pipe(mt((t,e)=>t!==e&&t===!0&&e===!1)).subscribe(()=>this.eventBus.fireDraw([this.hitTestCanvasModel.canvasId])))}}var wm=Object.defineProperty,Sm=Object.defineProperties,xm=Object.getOwnPropertyDescriptors,xa=Object.getOwnPropertySymbols,_m=Object.prototype.hasOwnProperty,Pm=Object.prototype.propertyIsEnumerable,_a=(n,t,e)=>t in n?wm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Tm=(n,t)=>{for(var e in t||(t={}))_m.call(t,e)&&_a(n,e,t[e]);if(xa)for(var e of xa(t))Pm.call(t,e)&&_a(n,e,t[e]);return n},Mm=(n,t)=>Sm(n,xm(t));class Am extends di{constructor(t){super(t),this.animations={},this.animFrameId="animation",this.animationInProgressSubject=new ft(!1),this.microtaskQueued=!1}startViewportMovementAnimation(t,e,s=me,i){const r=new ai(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ri(Mm(Tm({},i),{duration:i&&i.duration||De}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=De,i){const r=new oi({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0,delete this.animations[t]),Object.keys(this.animations).length===0&&this.stopInterval()}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():this.microtaskQueued||(this.microtaskQueued=!0,queueMicrotask(()=>{this.microtaskQueued=!1,this.processAnimation(),this.eventBus.fireDraw()}))}stopInterval(){yl(this.animFrameId),this.microtaskQueued=!1}}class Mn{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;uc(r),this.config=r;const o=Lc(r);t.innerHTML="",t.appendChild(o.content),this.id=(s=t.getAttribute("data-id"))!=null?s:"",r.fixedSize&&(t.style.width=r.fixedSize.width+"px",t.style.height=r.fixedSize.height+"px");const a=new Cm(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=Oc(t);this.elements=c;const h=new Fg;this.bus=h;const d=new kg(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 jd(h,d);this.drawingManager=u;const f=Hd(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=de(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new xe(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const m=de(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),_=de(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),S=new qs(r,h,f,l,d);this.canvasBoundsContainer=S;const A=c.mainCanvas.parentElement;if(A===null)throw new Error("Couldn't get main canvas parent");const E=new mm(h,A);this.canvasInputListener=E,this.chartComponents.push(this.canvasInputListener);const Y=[h,c.hitTestCanvas,E,S,u,r,this.canvasModels,c.chartResizer],B=new sf(...Y);this.hitTestCanvasModel=B;const R=new xe(B);u.addDrawer(R,"HIT_TEST_CLEAR");const k=Ie?new Am(h):new di(h);this.canvasAnimation=k;const V=M.PANE_UUID($),X=new Br(r,()=>S.getBounds(V),k);this.scaleModel=X;const U=de(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=U,this.cursorHandler=new Ic(c.canvasArea,E,S,B),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new Kg(E,S),this.chartComponents.push(this.crossEventProducer);const Z=new Sh("candle");this.chartBaseModel=Z;const G=new Xf(h,X,S,r,k,E,A,Z,B);this.chartPanComponent=G,this.chartComponents.push(G),this.userInputListenerComponents.push(G.chartAreaPanHandler);const Q=new ym(B,k,h);this.hitTestComponent=Q,this.chartComponents.push(Q);const J=new xp(Z,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,X,S,r,k,E,u,this.cursorHandler,this.crossEventProducer,G,f,m,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=J;const tt=this.paneManager.panes[$];this.mainPane=tt,this.chartComponents.push(J),this.dynamicObjects=new Yu(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new yu(Z,J,h,this.dynamicObjectsCanvasModel,r,X,l,A,S,d);const et=new nu(this.chartModel,this.dynamicObjectsCanvasModel,r,X,S,u,B,E,U,G,J,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(et),this.chartComponent=et;const st=this.chartComponent.chartModel;this.chartModel=st,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),B.addSubscriber(J.hitTestController),this.xAxisComponent=new Ag(h,r,f,et,X,S,E,d,this.drawingManager,a,G,this.cursorHandler,this.hitTestCanvasModel,this.mainPane.yAxis),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const ht=new xe(f);u.addDrawer(ht,"MAIN_CLEAR");const ct=new Hg(A,st,E,r);this.chartComponents.push(ct),this.watermarkComponent=new Yp(J,st,h,r,S,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const xt=de(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new Sf(h,r,st,f,S,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(st)),this.navigationMapComponent=new Df(h,st,f,r,E,S,u,l,G,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Zt=new gf(r,this.dynamicObjectsCanvasModel,st,S,u);this.chartComponents.push(Zt),this.initYAxisDrawer(m,_),this.yAxisComponent=tt.mainExtent.yAxis;const te=new Lg(this.chartModel,this.config,tt.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(te,ae.MAIN),this.volumesComponent=new Bp(this.dynamicObjectsCanvasModel,et,X,S,u,r,J,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const _s=new xo(f,X,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(M.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(V),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>[],void 0,void 0,()=>r.components.grid.visible,this.mainPane.mainExtent.idx);this.chartComponents.push(_s),this.hoverProducer=new rm(this.crossEventProducer,X,r,st,E,this.canvasBoundsContainer,this.paneManager,a,G.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new Fu(r,xt,S,u,J,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel,this.chartModel),this.chartComponents.push(this.crossToolComponent);const Ea=de(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),An=new _p(this.elements,Ea);this.snapshotComponent=An,this.chartComponents.push(An);const Ps=new uf(r,this.dynamicObjectsCanvasModel,B,st,S,u,l,this.cursorHandler);this.eventsComponent=Ps,this.chartComponents.push(Ps),this.chartComponents.forEach(Ts=>Ts.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=jl(this.components)}initYAxisDrawer(t,e){const s=new hn,i=new xe(t),r=new xe(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new Bg(this.config,t,this.paneManager);s.addDrawer(o);const a=new Og(t,e,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);this.drawingManager.addDrawer(a,"Y_AXIS_PRICE_LABELS")}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:s=>e.test(s)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const s in e)s in t?typeof t[s]=="object"&&Mn.mergeConfig(t[s],e[s]):t[s]=e[s];return t}getConfig(){return this.config}disableUserControls(){this.userInputListenerComponents.forEach(t=>t.deactivate()),this.hitTestCanvasModel.disableUserControls()}enableUserControls(){this.userInputListenerComponents.forEach(t=>t.activate()),this.hitTestCanvasModel.enableUserControls()}setGridConfig(t){var e,s,i,r,o;const a=this.config.components.grid;a.visible=(e=t.visible)!=null?e:!1,a.dash=(s=t.dash)!=null?s:[0,0],a.width=(i=t.width)!=null?i:1,a.color=(r=t.color)!=null?r:"#FFFFFF",this.config.colors.chartAreaTheme.gridColor=(o=t.color)!=null?o:"#FFFFFF",this.redraw()}setGridVisible(t){this.config.components&&this.config.components.grid&&(this.config.components.grid.visible=t,this.redraw())}setGridVertical(t){this.config.components.grid.vertical=t,this.redraw()}setGridHorizontal(t){this.config.components.grid.horizontal=t,this.redraw()}redraw(){this.bus.fireDraw()}getOffsets(){return this.config.components&&this.config.components.offsets}setShowCandleBorders(t=!0){this.config.components&&this.config.components.chart&&(this.config.components.chart.showCandlesBorder=t,this.redraw())}setHighLowVisible(t=!0){this.config.components&&this.config.components.highLow&&(this.config.components.highLow.visible=t,this.redraw())}setCrossToolVisible(t="cross-and-labels"){this.config.components&&this.config.components.crossTool&&(this.config.components.crossTool.type=t,this.redraw())}setHighlightsVisible(t=!0){var e;(e=this.config.components)!=null&&e.highlights&&(this.config.components.highlights.visible=t,this.redraw())}setHighlightsData(t){this.highlightsComponent.setHighlights(t)}setColors(t){At(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseMove(s).subscribe(e);return()=>i.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,s=!1){const i=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseEnter(i,s).subscribe(e);return()=>r.unsubscribe()}addClickOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeClick(s).subscribe(e);return()=>i.unsubscribe()}addDragEventsListener(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=wt(this.canvasInputListener.observeYDrag(s),this.canvasInputListener.observeXDrag(s)).subscribe(e);return()=>i.unsubscribe()}registerComponent(t,e){const s=t(this);this.components.push(s),e&&e(s),s.activate()}}class Pa extends Mn{constructor(t,e={}){super(t,e),this.yAxis=this.yAxisComponent,this.xAxis=this.xAxisComponent,this.watermark=this.watermarkComponent,this.highlights=this.highlightsComponent,this.events=this.eventsComponent,this.snapshot=this.snapshotComponent,this.crosshair=this.crossToolComponent,this.navigationMap=this.navigationMapComponent,this.volumes=this.volumesComponent,this.cursors=this.cursorHandler,this.data=this.chartComponent,this.scale=this.scaleModel,this.panning=this.chartPanComponent,this.bounds=this.canvasBoundsContainer,this.hover=this.hoverProducer}registerPaneFormatters(t,e){var s;(s=this.paneManager.panes[t])==null||s.setPaneValueFormatters(e)}destroy(){this.bus.setMuted(!0),this.chartComponents.forEach(t=>t.disable()),this.parentElement.childNodes.forEach(t=>t.remove()),this.parentElement.style.width="",this.parentElement.style.height=""}showSeparateVolumes(t=!1){this.volumes&&(this.volumes.setShowVolumesSeparatly(t),this.bounds.updateYAxisWidths())}setData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.setAllSeries(e,s)}else this.chartComponent.setMainSeries(t)}updateData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.updateAllSeries(e,s)}else this.chartComponent.updateAllSeries(t)}setAutoScale(t=!0){this.scale.autoScale(t)}setRtl(t){this.config.rtl=t,this.bus.fireDraw()}setChartType(t){this.data.setChartType(t),this.yAxis.updateOrderedLabels()}setTreasuryFormat(t){this.config.components.yAxis.treasuryFormat=t,this.paneManager.yExtents.forEach(e=>{e.yAxis.model.labelsGenerator.updateTreasuryFormat(t),e.yAxis.model.labelsGenerator.doGenerateLabels(),e.yAxis.model.fancyLabelsModel.updateLabels(!0),e.yAxis.model.baseLabelsModel.updateLabels()})}createPane(){return this.paneManager.createPane()}}var Em=Object.defineProperty,Im=Object.defineProperties,Dm=Object.getOwnPropertyDescriptors,Ta=Object.getOwnPropertySymbols,Lm=Object.prototype.hasOwnProperty,Om=Object.prototype.propertyIsEnumerable,Ma=(n,t,e)=>t in n?Em(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bm=(n,t)=>{for(var e in t||(t={}))Lm.call(t,e)&&Ma(n,e,t[e]);if(Ta)for(var e of Ta(t))Om.call(t,e)&&Ma(n,e,t[e]);return n},Rm=(n,t)=>Im(n,Dm(t));function Aa(n){n=n||{},n.quantity=n.quantity||200,n.startY=n.startY||50,n.avgCandleSize=n.avgCandleSize||2,n.avgTrendLength=n.avgTrendLength||{},n.avgTrendLength.sw=n.avgTrendLength.sw||10,n.avgTrendLength.down=n.avgTrendLength.down||10,n.avgTrendLength.up=n.avgTrendLength.up||10,n.withVolume=n.withVolume===!0||!1,n.period=n.period||3600;var t=[],e=n.quantity||200,s=10,i=10,r=10;n.avgTrendLength&&(s=n.avgTrendLength.sw||10,i=n.avgTrendLength.down||10,r=n.avgTrendLength.up||10);var o=n.startY||50,a=n.avgCandleSize||2,l=o-a,c=o+a,h=xs(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(km(t[t.length-1],a,s)):d>3?t=t.concat(Fm(t[t.length-1],a,r)):t=t.concat(Hm(t[t.length-1],a,i))}t=t.slice(0,n.quantity);let u=Math.round(new Date().getTime()/3e5)*3e5;u-=e*1e3*n.period;for(let f=0;f<t.length;f++){const p=t[f];Object.assign(p,{timestamp:u,isVisible:!0}),u+=1e3*n.period,n.withVolume&&(p.volume=Math.ceil(Math.random()*1e3+200))}return t}function xs(n,t,e,s){var i=Math.random()*(t-n)+n,r;if(s&&s==="bull"||!s&&Math.random()>.5){var o=i+e;r=o<t?o:t}else{var a=i-e;r=a>n?a:n}var l=Math.max(i,r)+Math.random()*e*.2,c=Math.min(i,r)-Math.random()*e*.2;return{id:Mi(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function Fm(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.lo,o=n.hi+t*1.2,a=0;a<i;a++){var l=Math.random()>.9?"bear":"bull",c=xs(r,o,t,l);r=c.lo-t*(Math.random()*.1+.1),o=c.hi+t*(Math.random()*1.3+.1),Math.random()>.9&&(o=c.hi+t),s.push(c)}return s}function Hm(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.hi-t*1.2,o=n.hi,a=0;a<i;a++){var l=Math.random()<.9?"bear":"bull",c=xs(r,o,t,l);r=c.lo-t*(Math.random()*.3+.1),o=c.hi-t*(Math.random()*.1+.1),Math.random()>.9&&(o=c.lo-t),s.push(c)}return s}function km(n,t,e){var s=[],i=Math.random()*e+e/2;function r(u){var f,p;return Math.random()>.5?(f=u.lo-t*.2,p=u.hi+t*1.2):(f=u.lo-t*1.2,p=u.hi+t*.2),{from:f,to:p}}for(var o=r(n),a=o.from,l=o.to,c=0;c<i;c++){var h=Math.random()<.5?"bear":"bull",d=xs(a,l,t,h);o=r(d),a=o.from,l=o.to,Math.random()>.9&&(Math.random()>.5?a=d.lo-t:l=d.hi+t),s.push(d)}return s}window.DXChart=Rm(Bm({},window.DXChart),{generateCandlesData:Aa});function jm(n){return Aa(n)}const Ym=((n,t={})=>new Pa(n,t))})(),window.DXChart=As})();})();
|
|
24
|
+
`);(Object.getOwnPropertyDescriptor(Qs,"name")||{}).writable||Object.defineProperty(Qs,"name",{value:"default",configurable:!0});function Bc(n){const t=document.createElement("template");return t.innerHTML=Qs(n.devexpertsPromoLink),t}function Rc(n){const t={},e=Array.from(n.querySelectorAll("[data-element]"));if(e.length!==0&&e.forEach(s=>{var i;t[(i=s.getAttribute("data-element"))!=null?i:""]=s}),Oc(t))return t;throw new Error("Some chart elements are missing")}function Fc(n){if(n.length>1){const t=n.reduce((i,r,o)=>{if(o!==n.length-1){const a=n[o+1].timestamp-r.timestamp;i[a]?i[a]++:i[a]=1}return i},{});let e=0,s;for(const i of Object.keys(t)){const r=parseInt(i,10),o=t[r];o>e&&r>0&&(e=o,s=r)}if(s)return s}}const Ki=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Hc=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Ki(!!c),u=d(n),f=d((r=(i=ie(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=wt(e))==null?void 0:o.timestamp)!=null?a:0);return u>p?h?{index:e.length-1+Math.ceil((u-p)/s),exact:!0}:{index:e.length-1,exact:!0}:u<f?h?{index:rt((u-f)/s),exact:!0}:{index:-1,exact:!0}:Nt(e,u,m=>d(m.timestamp))},kc=(n,t={},e,s=1e3)=>{var i,r,o,a,l,c;const{extrapolate:h,isDaysPeriod:d}=t,u=!!h,f=Ki(!!d),p=f(n);if(!e.length)return{index:-1,exact:!0};const m=f((r=(i=ie(e))==null?void 0:i.timestamp)!=null?r:0),_=f((a=(o=wt(e))==null?void 0:o.timestamp)!=null?a:0);if(p>_)return u?{index:e.length-1+Math.ceil((p-_)/s),exact:!0}:{index:e.length-1,exact:!0};if(p<=m){const B=f((c=(l=e[0])==null?void 0:l.timestamp)!=null?c:m)-s;return p<=B?u?{index:rt((p-m)/s),exact:!0}:{index:-1,exact:!0}:{index:0,exact:p===m}}let S=0,A=e.length;for(;S<A;){const j=rt((S+A)/2);f(e[j].timestamp)<p?S=j+1:A=j}const E=S;return{index:E>=e.length?e.length-1:E,exact:E<e.length&&f(e[E].timestamp)===p}},Re=(n,t={},e,s=1e3)=>{var i;return((i=t.candleTimestampAnchor)!=null?i:"open")==="close"?kc(n,t,e,s):Hc(n,t,e,s)},hv=(n,t,e,s)=>{var i,r;return s==="close"?(r=(i=n[t-1])==null?void 0:i.timestamp)!=null?r:n[t].timestamp-e:n[t].timestamp},dv=(n,t,e)=>e==="close"?n.timestamp:n.timestamp+t,uv=n=>{const t=n[0],e=n[n.length-1];return n.length>0&&[t,e].some(s=>s!==void 0&&s.impVolatility!==null&&s.impVolatility!==void 0&&!isNaN(s.impVolatility))},qi={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Ji={paintConfig:[qi],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var jc=Object.defineProperty,Qi=Object.getOwnPropertySymbols,Yc=Object.prototype.hasOwnProperty,Nc=Object.prototype.propertyIsEnumerable,tr=(n,t,e)=>t in n?jc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Xc=(n,t)=>{for(var e in t||(t={}))Yc.call(t,e)&&tr(n,e,t[e]);if(Qi)for(var e of Qi(t))Nc.call(t,e)&&tr(n,e,t[e]);return n};class Wc{constructor(t,e,s,i){this.series=t,this.config=e,this.yAxisBoundsProvider=s,this.axisState=i}getUnorderedLabels(){if(!this.config.visible)return[];const e=this.config.labelLastValue==="series"?this.series.getLastDataSeriesPoint:this.series.getLastVisualSeriesPoint,s=this.yAxisBoundsProvider(),i=this.config.labelMode,r=this.config.labelAppearanceType,o=e();if(o===void 0)return[];const a=this.series.view.toY(o.close);if(!isFinite(a))return[];const l=this.series.extentComponent.valueFormatter(o.close,{formatWithSeparators:!0}),c=this.getLabelDrawConfig();return[{labels:[Xc({y:a,description:this.series.name,mode:i,labelType:r,labelText:l},c)],axisState:this.axisState,bounds:s}]}getLabelDrawConfig(){var t;const e=this.series.config,i=((t=e.paintConfig[0])!=null?t:qi).color;return{textColor:re(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function Vc(n,t){if(n.filter(a=>a!==null).length<=1)return n.map(a=>a.y);const e=t-2,s=n.map((a,l)=>zc(a,l,e)).filter(pi).sort(Uc),i=new Array(s.length),r=s.reduce((a,l)=>Math.min(a,l.labelWeight),Number.POSITIVE_INFINITY),o=s.findIndex(a=>a.labelWeight===r);for(let a=o;a>=0;a--){const l=s[a],c=s[a-1];if(l){if(c&&c.bottom>l.top){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.bottom=l.top-h,c.top=c.bottom-t}i[l.actualIndex]=(l.top+l.bottom)/2}}for(let a=o;a<s.length;a++){const l=s[a],c=s[a+1];if(!l)break;if(c&&c.top<l.bottom){const h=Math.abs(c.labelWeight-l.labelWeight)===1?2:0;c.top=l.bottom+h,c.bottom=c.top+t}i[l.actualIndex]=(l.top+l.bottom)/2}return i}const zc=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,Uc=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var Gc=Object.defineProperty,Zc=Object.defineProperties,$c=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,Kc=Object.prototype.hasOwnProperty,qc=Object.prototype.propertyIsEnumerable,sr=(n,t,e)=>t in n?Gc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,nr=(n,t)=>{for(var e in t||(t={}))Kc.call(t,e)&&sr(n,e,t[e]);if(er)for(var e of er(t))qc.call(t,e)&&sr(n,e,t[e]);return n},ir=(n,t)=>Zc(n,$c(t));const ae={MAIN:"MAIN"};class Jc extends W{constructor(t,e,s,i,r,o,a,l){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.chartResizeHandler=l,this.orderedLabels=[],this.customLabels={},this._labelsProviders={},this.labelsPositionRecalculatedSubject=new F,this.animFrameId=`anim_cache_${St()}`,this.initModel()}get labelsProviders(){return this._labelsProviders}doActivate(){super.doActivate(),this.addRxSubscription(yt(this.canvasBoundsContainer.barResizerChangedSubject,this.scale.changed,yt(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.paneUUID)),this.chartResizeHandler.canvasResized).pipe(Et(50,Bt,{trailing:!0,leading:!0}))).subscribe(()=>{this.updateLabels()}))}initModel(){this.initLabelsGroups(),this.recalculateLabels(),this.canvasModel.fireDraw()}initLabelsGroups(){for(const t of Object.keys(this.labelsProviders))this.createGroup(t),Object.entries(this.labelsProviders[t]).forEach(([e,s])=>{this.addToGroup(s,t,e)})}updateLabels(t=!1){this.recalculateLabels(),Me(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const s=this.state.fontSize+((t=this.state.labelBoxMargin.top)!=null?t:0)+((e=this.state.labelBoxMargin.bottom)!=null?e:0);for(const i of Object.values(this.labelsProviders)){const r=mt(Object.values(i).map(l=>l.getUnorderedLabels())),o=mt(r.map(l=>l.labels)).map(l=>{var c;return{y:l.y,weight:(c=l.labelWeight)!=null?c:Number.POSITIVE_INFINITY}}),a=Vc(o,s);r.forEach(l=>{const c=a.splice(0,l.labels.length);this.orderedLabels.push(this.updateLabelsCoordinates(l,c))})}this.orderedLabels=this.orderedLabels.reverse()}createGroup(t){!this.labelsProviders[t]&&(this.labelsProviders[t]={})}addToGroup(t,e,s){this.labelsProviders[e]&&(Object.values(this.labelsProviders[e]).includes(t)||(this.labelsProviders[e][s]=t))}updateLabelsCoordinates(t,e){return ir(nr({},t),{labels:t.labels.map((s,i)=>{var r;return ir(nr({},s),{lineY:(r=s.lineY)!=null?r:s.y,y:e[i]})})})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[s]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const i=(s=this.labelsProviders[t])!=null?s:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}var Qc;let Ht=window.devicePixelRatio,ls=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const tn=()=>{ls.removeEventListener("change",tn),Ht=window.devicePixelRatio,ls=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),ls.addEventListener("change",tn)};ls.addEventListener("change",tn);const th=()=>Ht,fv=n=>Qc(Ht*n)/Ht,It=n=>rt(Ht*n)/Ht,en=n=>Ml(Ht*n)/Ht,le=n=>JSON.parse(JSON.stringify(n));function sn(n){return Object.entries(n)}const rr=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function or(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 i=0,r=e.length;i<r;i++)if(!hasOwnProperty.call(t,e[i])||!ar(n[e[i]],t[e[i]]))return!1;return!0}const eh=n=>Object.keys(n).length===0&&n.constructor===Object;function lr(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new F}:t,s=n.resetOnError,i=s===void 0?!0:s,r=n.resetOnComplete,o=r===void 0?!0:r,a=n.resetOnRefCountZero,l=a===void 0?!0:a;return function(c){var h,d,u,f=0,p=!1,m=!1,_=function(){d==null||d.unsubscribe(),d=void 0},S=function(){_(),h=u=void 0,p=m=!1},A=function(){var E=h;S(),E==null||E.unsubscribe()};return N(function(E,j){f++,!m&&!p&&_();var B=u=u!=null?u:e();j.add(function(){f--,f===0&&!m&&!p&&(d=nn(A,l))}),B.subscribe(j),!h&&f>0&&(h=new Te({next:function(R){return B.next(R)},error:function(R){m=!0,_(),d=nn(S,i,R),B.error(R)},complete:function(){p=!0,_(),d=nn(S,o),B.complete()}}),Lt(E).subscribe(h))})(c)}}function nn(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t===!0){n();return}if(t!==!1){var i=new Te({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,ct([],H(e)))).subscribe(i)}}const cs=(n,t)=>n/t,vt=(n,t)=>n/t,kt=(n,t)=>n*t,cr=(n,t)=>(n-t)*100/t,hr=(n,t)=>n*t/100+t,dr=n=>Math.log2(n),rn=n=>Math.pow(2,n);class sh extends W{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 F,this.xChanged=this.changed.pipe(ht(()=>({start:this.xStart,end:this.xEnd})),gt((t,e)=>t.start===e.start&&t.end===e.end),lr()),this.yChanged=this.changed.pipe(ht(()=>({start:this.yStart,end:this.yEnd})),gt((t,e)=>t.start===e.start&&t.end===e.end),lr()),this.initialViewportValidSubject=new ft(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+vt(t-this.xStart,this.zoomX)}xPixels(t){return vt(t,this.zoomX)}toY(t){const e=this.getBounds();return this.inverseY?e.y+vt(t-this.yStart,this.zoomY):e.y+e.height-vt(t-this.yStart,this.zoomY)}yPixels(t){return vt(t,this.zoomY)}fromX(t){const e=t-this.getBounds().x;return kt(e+vt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),s=t-e.y;return this.inverseY?kt(s+vt(this.yStart,this.zoomY),this.zoomY):kt(e.height-s+vt(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 cs(e-t,this.getBounds().width)}calculateZoomY(t,e){return cs(e-t,this.getBounds().height)}recalculateZoom(t=!0){this.recalculateZoomX(),this.recalculateZoomY(),t&&this.fireChanged()}setXScale(t,e,s=!0){this.xStart=t,this.xEnd=e,this.recalculateZoomX(),s&&this.fireChanged()}setYScale(t,e,s=!0){this.yStart=t,this.yEnd=e,this.recalculateZoomY(),s&&this.fireChanged()}export(){return{xStart:this.xStart,xEnd:this.xEnd,yStart:this.yStart,yEnd:this.yEnd,zoomX:this.zoomX,zoomY:this.zoomY,inverseY:this.inverseY}}apply(t){this.xStart=t.xStart,this.xEnd=t.xEnd,this.yStart=t.yStart,this.yEnd=t.yEnd,this.zoomX=t.zoomX,this.zoomY=t.zoomY,this.inverseY=t.inverseY,this.fireChanged()}fireChanged(){this.changed.next()}get xStart(){return this._xStart}set xStart(t){this._xStart=t}get xEnd(){return this._xEnd}set xEnd(t){this._xEnd=t}get yStart(){return this._yStart}set yStart(t){this._yStart=t}get yEnd(){return this._yEnd}set yEnd(t){this._yEnd=t}get zoomX(){return this._zoomX}set zoomX(t){this._zoomX=t}get zoomY(){return this._zoomY}set zoomY(t){this._zoomY=t}get inverseY(){return this._inverseY}set inverseY(t){this._inverseY=t}isViewportValid(t=!0){const e=t===!1||this.zoomX>0&&this.zoomY>0;return this.xStart!==this.xEnd&&this.yStart!==this.yEnd&&isFinite(this.yStart)&&isFinite(this.yEnd)&&e}}const nh=(n,t)=>!or(n).some(e=>n[e]!==t[e]);class ih{constructor(t,e){this.scale=t,this.dataSeries=e,this.prevAnimationId=""}getBaselineForPercent(t){const e=this.scale.currentAnimation;let s;if(e!=null&&e.animationInProgress){e.id!==this.prevAnimationId&&(this.initialBaseline=void 0,this.targetBaseline=void 0,this.prevAnimationId=e.id);const i=e.easingFn(e.getProgress());this.initialBaseline===void 0&&(this.initialBaseline=t(Nt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(Nt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else s=t();return s}}class ur{constructor(t,e,s,i){this.dataSeries=t,this.scale=e,this.getAxisType=s,this.getBaseline=i,this.toY=r=>this.scale.toY(this.toAxisUnits(r)),this.toX=r=>this.scale.toX(r),this.xPixels=r=>this.scale.xPixels(r),this.yPixels=r=>this.scale.yPixels(r),this.percentAnimationHandler=new ih(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return cr(t,s);case"logarithmic":return t<=0?t:dr(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 hr(t,this.getBaseline());case"logarithmic":return rn(t);case"regular":return t}}}const Vt=16;var rh=Object.defineProperty,oh=Object.defineProperties,ah=Object.getOwnPropertyDescriptors,fr=Object.getOwnPropertySymbols,lh=Object.prototype.hasOwnProperty,ch=Object.prototype.propertyIsEnumerable,pr=(n,t,e)=>t in n?rh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,gr=(n,t)=>{for(var e in t||(t={}))lh.call(t,e)&&pr(n,e,t[e]);if(fr)for(var e of fr(t))ch.call(t,e)&&pr(n,e,t[e]);return n},hh=(n,t)=>oh(n,ah(t));class Fe{constructor(t,e){this.centerUnit=t,this.close=e}y(t){return It(t.toY(this.close))}x(t){return t.toX(this.centerUnit)}clone(){return new Fe(this.centerUnit,this.close)}}class mr extends W{constructor(t,e,s,i,r){var o;super(),this.extentComponent=t,this.id=e,this.htId=s,this.parentId=i,this.name="",this.highlighted=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=l=>{var c;return(c=this.config.paintConfig[l])!=null?c:this.config.paintConfig[0]},this.getBaseline=(l=this.dataIdxStart)=>{var c,h,d;return(c=this.visualPoints[l])!=null&&c.close&&((h=this.visualPoints[l])==null?void 0:h.close)>=0?(d=this.visualPoints[l])==null?void 0:d.close:1},this.getTextForPoint=l=>`${l.close}`,this.getLastVisualSeriesPoint=()=>{const l=this.visualPoints;if(l.length!==0)return l[this.dataIdxEnd]},this.getLastDataSeriesPoint=()=>{const l=this.visualPoints;return wt(l)};const a=r!=null?r:le(Ji);this.config=At(a,Ji),this.scale=t.scale,this.view=new ur(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Wc(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=uh(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=vi(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=vi(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.pipe(Et(Vt,Bt,{trailing:!0,leading:!0}),ht(()=>this.calculateDataViewportIndexes(this.scale.xStart,this.scale.xEnd)),gt((t,e)=>t.dataIdxStart===e.dataIdxStart&&t.dataIdxEnd===e.dataIdxEnd)).subscribe(()=>{this.recalculateDataViewportIndexes(this.scale.xStart,this.scale.xEnd)})),this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(()=>{this.recalculateVisualPoints(),this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}))}setDataPoints(t){this.dataPoints=t,this.extentComponent.paneComponent.updateView()}_toVisualPoints(t){return t.map(e=>this.toVisualPoints(e))}moveToExtent(t){var e;const s=gr({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new ur(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider.yAxisBoundsProvider=t.getYAxisBounds,this.yAxisLabelProvider.axisState=(e=t.yAxis)==null?void 0:e.state;const i=s.yAxis.model.fancyLabelsModel.labelsProviders[ae.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[ae.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(ae.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(ae.MAIN,r))}this.deactivate(),this.activate(),t.addDataSeries(this)}toVisualPoints(t){return t.map((e,s)=>({centerUnit:s,close:e.close}))}setType(t){this.config.type=t,this.extentComponent.dynamicObjectsCanvasModel.fireDraw()}recalculateVisualPoints(){this.visualPoints=this._toVisualPoints(this.dataPoints2D)}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i}calculateDataViewportIndexes(t,e){const s=Nt(this.visualPoints,t,r=>r.centerUnit).index,i=Nt(this.visualPoints,e,r=>r.centerUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}valueFormatter(t){return this.extentComponent.formatters.regular(t)}getSeriesInViewport(t,e){let s=this.dataIdxStart,i=this.dataIdxEnd;if(e!==void 0&&t!==void 0){const r=this.calculateDataViewportIndexes(t,e);s=r.dataIdxStart,i=r.dataIdxEnd}return zl(this.visualPoints2D,s,i)}}const dh=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},uh=n=>({isHighLowActive:()=>n.config.highLowActive&&n.config.visible,calculateHighLow:t=>{const e=dh(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return hh(gr({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),fh=n=>{const e=r=>Math.ceil(Math.log(Math.abs(r))*Math.LOG10E),i=((r,o=5)=>Math.max(0,o-Math.max(0,e(r))))(n);return Tt.makeDecimal(n,i)};class hs extends Fe{constructor(t,e,s,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.endUnit=t+e/2,this.width=e,this.open=s,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return Math.max(Math.abs(t.toY(this.open)-t.toY(this.close)),1)}candleHeight(t){return Math.abs(t.toY(this.high)-t.toY(this.low))}bodyAsVLine(t){if(this.width<2)return[this.centerUnit,this.yLineStart(t),this.width,this.candleHeight(t)]}bodyRect(t){return[this.startUnit,this.yBodyStart(t),this.width,this.bodyHeight(t)]}getCandle(){return this.candle}yBodyKeyPoints(t){const e=t.toY(this.high),s=t.toY(this.low),i=t.toY(this.open),r=t.toY(this.close),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>s?[s,e]:[e,s];return[l,o,a,c]}yLineEnd(t){return Math.max(t.toY(this.high),t.toY(this.low))}yLineStart(t){return Math.min(t.toY(this.high),t.toY(this.low))}yBodyStart(t){return Math.min(t.toY(this.open),t.toY(this.close))}yBodyEnd(t){return Math.max(t.toY(this.open),t.toY(this.close))}xCenter(t){return this.x(t)}xStart(t){return t.toX(this.startUnit)}}const be=60,He=(n,t,e=be)=>{const s=vr(n,t,e);return{id:Ei(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},ph=(n,t,e=be)=>({close:NaN,timestamp:vr(n,t,e)});function vr(n,t,e=be){var s,i;const r=Ee(t);if(n.length===0)return 0;const o=wt(n);if(r>=n.length&&o)return br(o,n.length-1,r,e);const a=ie(n);return r<0&&a?br(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const br=(n,t,e,s=be)=>n.timestamp+(e-(t!=null?t:0))*s,on=(n,t,e,s,i=be)=>{const r=He(n,s,i);r.volume=e;let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new hs(o,e,r.open,r.close,r.lo,r.hi,ns(r.open,r.close),r)},gh=(n,t,e,s,i=be)=>{const r=ph(n,s,i);let o;if(t.length===0)o=0;else if(s>=t.length){const a=t[t.length-1],c=(s-(t.length-1))*e;o=a.centerUnit+c}else{const a=t[0],c=-s*e;o=a.centerUnit-c}return new Fe(o,r.close)};var mh=Object.defineProperty,vh=Object.defineProperties,bh=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,Ch=Object.prototype.hasOwnProperty,yh=Object.prototype.propertyIsEnumerable,yr=(n,t,e)=>t in n?mh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,wh=(n,t)=>{for(var e in t||(t={}))Ch.call(t,e)&&yr(n,e,t[e]);if(Cr)for(var e of Cr(t))yh.call(t,e)&&yr(n,e,t[e]);return n},Sh=(n,t)=>vh(n,bh(t));class xh{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new F,this.dataSetSubject=new F,this.dataRemovedSubject=new F,this.dataPrependSubject=new F,this.meanDataWidth=1,this.period=1,this.candleTimestampAnchor="open"}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=Re(t,Sh(wh({},e),{candleTimestampAnchor:this.candleTimestampAnchor}),s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=Fc(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?on(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):gh(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var _h=Object.defineProperty,wr=Object.getOwnPropertySymbols,Ph=Object.prototype.hasOwnProperty,Th=Object.prototype.propertyIsEnumerable,Sr=(n,t,e)=>t in n?_h(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mh=(n,t)=>{for(var e in t||(t={}))Ph.call(t,e)&&Sr(n,e,t[e]);if(wr)for(var e of wr(t))Th.call(t,e)&&Sr(n,e,t[e]);return n};class Ah{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!ar(this.config.colors.chartAreaTheme,this.prevState)}draw(){if(this.drawPredicate()||this.isColorsChanged()){this.canvasModel.clear();const t=this.canvasModel.ctx;if(this.config.colors.chartAreaTheme.backgroundMode==="gradient"){const e=t.createLinearGradient(0,0+this.canvasModel.height/2,this.canvasModel.width,0+this.canvasModel.height/2);e.addColorStop(0,this.config.colors.chartAreaTheme.backgroundGradientTopColor),e.addColorStop(1,this.config.colors.chartAreaTheme.backgroundGradientBottomColor),t.fillStyle=e}else t.fillStyle=this.config.colors.chartAreaTheme.backgroundColor;t.fillRect(0,0,this.canvasModel.width,this.canvasModel.height)}this.prevState=Mh({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const Eh=(n,t,e,s,i,r,o)=>{const a=th(),l=[e*a,s*a,i*a,r*a];let c=n.getImageData(...l);if(o!==void 0){const h=c.data[3]/255;if(h===1)for(let d=3;d<c.data.length;d+=4)c.data[d]=rt(c.data[d]*o);else for(let d=0;d<c.data.length;d++){const u=c.data[d];c.data[d]=d%4===3?rt(u*o):rt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},xr=(n,{x:t,width:e,activeCandle:s})=>new hs(t,e,n.open,n.close,n.hi,n.lo,ns(n.open,n.close),n,!0,an(n,s)),Ih=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new hs(t,e,n.open,n.close,n.hi,n.lo,ic((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,an(n,s),n.close>n.open)},_r=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new hs(t,e,n.open,n.close,n.hi,n.lo,ns((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,an(n,s),n.close>n.open)},Dh=_r,an=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},Pr=()=>Zs,ke=class fe{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>rt(Math.log10((i^i>>31)-(i>>31)))+1;let s=e(t);return s===1&&t<1&&(s=e(t*1e9)-9),s}static getPriceIncrement(t,e=[]){if(!this.validatePriceIncrementsOrPrecisions(e))return this.DEFAULT_INCREMENT;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;const i=1e-6;for(;s<e.length&&t>e[s]+Math.min(e[s-1],e[s+1])*i;)s+=2;return s>=e.length||t<e[s]-Math.min(e[s-1],e[s+1])*i?e[s-1]:Math.min(e[s-1],e[s+1])}static getPricePrecision(t,e){if(!this.validatePriceIncrementsOrPrecisions(e))return 0;if(isNaN(t))return Math.round(e[0]);t=Math.abs(t);let s=1;for(;s<e.length&&t>e[s];)s+=2;return Math.round(e[s-1])}static roundPriceToIncrement(t,e,s){const i=fe.getPriceIncrement(s||t,e);return Tt.roundToNearest(t,i)}static computePrecisions(t){const e=[...t];for(let s=0;s<t.length;s+=2)e[s]=fe.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*fe.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<fe.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*fe.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return fe.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(t){return!(t.length===0||!Array.isArray(t)||t.findIndex(e=>e!==0)===-1)}};ke.DEFAULT_INCREMENT=.01,ke.DEFAULT_PRECISION=2,ke.RELATIVE_EPS=1e-8,ke.MAXIMUM_PRECISION=10;let Ce=ke;const Lh=(n,t)=>{var e;const s=(e=wt(t))!=null?e:1;return Math.pow(10,-s)};var Oh=Object.defineProperty,Bh=Object.defineProperties,Rh=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,Fh=Object.prototype.hasOwnProperty,Hh=Object.prototype.propertyIsEnumerable,Mr=(n,t,e)=>t in n?Oh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,kh=(n,t)=>{for(var e in t||(t={}))Fh.call(t,e)&&Mr(n,e,t[e]);if(Tr)for(var e of Tr(t))Hh.call(t,e)&&Mr(n,e,t[e]);return n},jh=(n,t)=>Bh(n,Rh(t));const Yh=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=t?t.xStart:n.scale.xStart,s=t?t.xEnd:n.scale.xEnd,{dataIdxStart:i,dataIdxEnd:r}=n.calculateDataViewportIndexes(e,s),o=n.visualPoints.slice(i,r+1),a=Ar(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return jh(kh({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),Ar=n=>{const t={high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER,highIdx:0,lowIdx:0};for(let e=0;e<n.length;e++){const s=n[e];s.high>t.high&&(t.high=s.high,t.highIdx=e),s.low<t.low&&(t.low=s.low,t.lowIdx=e)}return t};class Nh{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){Xh(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Xh=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=Er(i),o=s.reduce((a,l)=>l(a),r);t.yStart=o.low,t.yEnd=o.high,t.zoomY=n.calculateZoomY(t.yStart,t.yEnd)};function Er(n){if(n.length===0)return Wh();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 Wh=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),Ir=(n,t)=>n/t,Vh=(n,t)=>n/t,zh=(n,t)=>n*t,Dr=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=Ir(e,s),r=n.yEnd-n.yStart;t.zoomY=Vh(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Uh=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=Ir(e,s),r=n.xEnd-n.xStart;t.zoomX=zh(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Gh=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},Zh=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},Lr=(n,t,e,s,i)=>{const r=(t.xEnd-t.xStart)*s,o=r*e,a=r*(1-e);return i?(t.xStart=t.xStart+o,t.xEnd=t.xEnd-a):(t.xStart=t.xStart-o,t.xEnd=t.xEnd+a),t.zoomX=n.calculateZoomX(t.xStart,t.xEnd),t},$h=(n,t,e,s)=>Lr(n,t,1,e,s),Kh=De,qh=.9,Jh=(n,t,e,s)=>{t.currentAnimation&&t.currentAnimation.animationInProgress&&t.currentAnimation.getProgress()>qh&&(t.currentAnimation.finishAnimation(),t.currentAnimation=void 0),s&&s.doAutoYScale(e),ds(n,t,e)},ds=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:Kh,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},me,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s};var Qh=Object.defineProperty,td=Object.defineProperties,ed=Object.getOwnPropertyDescriptors,Or=Object.getOwnPropertySymbols,sd=Object.prototype.hasOwnProperty,nd=Object.prototype.propertyIsEnumerable,Br=(n,t,e)=>t in n?Qh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ce=(n,t)=>{for(var e in t||(t={}))sd.call(t,e)&&Br(n,e,t[e]);if(Or)for(var e of Or(t))nd.call(t,e)&&Br(n,e,t[e]);return n},Rr=(n,t)=>td(n,ed(t));const id=new F,rd=new F,od=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Fr extends sh{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new F,this.beforeStartAnimationSubject=new F,this.zoomReached={zoomIn:!1,zoomOut:!1},this.history=[],this.xConstraints=[],this.autoScaleZoomSubscription=null,this.autoScalePanSubscription=null,this.scalePostProcessor=(i,r)=>this.xConstraints.reduce((o,a)=>a(i,o),r),this.state=le(t.scale),this.autoScaleModel=new Nh(this),this.offsets=this.config.components.offsets,this.initAutoScaleThrottling()}doActivate(){super.doActivate(),this.scaleInversedSubject=new F,this.beforeStartAnimationSubject=new F,this.zoomReached=this.calculateZoomReached(this.export().zoomX),this.addRxSubscription(this.scaleInversedSubject.subscribe(()=>{this.fireChanged()}))}doDeactivate(){this.autoScaleZoomSubscription&&(this.autoScaleZoomSubscription.unsubscribe(),this.autoScaleZoomSubscription=null),this.autoScalePanSubscription&&(this.autoScalePanSubscription.unsubscribe(),this.autoScalePanSubscription=null),super.doDeactivate(),this.scaleInversedSubject.complete(),this.beforeStartAnimationSubject.complete()}addXConstraint(t){this.xConstraints=[...this.xConstraints,t]}updateOffsets(t){this.offsets=ce(ce({},this.offsets),t),this.doAutoScale(!0)}getOffsets(){return this.offsets}zoomXToPercent(t,e,s=!1,i){const r=this.config.scale.disableAnimations||s;r&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const o=this.export();Lr(this,o,t,i,e),this.zoomXTo(o,e,r)}zoomXToEnd(t,e){const s=this.config.scale.disableAnimations||this.config.components.yAxis.type==="percent";s&&this.haltAnimation(),this.beforeStartAnimationSubject.next();const i=this.export();$h(this,i,e,t),this.zoomXTo(i,t,s)}haltAnimation(){var t;(t=this.currentAnimation)!=null&&t.animationInProgress&&(this.currentAnimation.finishAnimation(),this.currentAnimation=void 0,this.canvasAnimation.forceStopAnimation(me),this.doAutoScale())}zoomXTo(t,e,s){var i;const r=this.export(),o=this.scalePostProcessor(r,t);this.zoomReached=this.calculateZoomReached(o.zoomX,e),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&Dr(r,o),this.state.auto&&this.autoScaleModel.doAutoYScale(o),s?this.apply(o):((i=this.currentAnimation)==null||i.tick(),ds(this.canvasAnimation,this,o)))}calculateZoomReached(t,e=!0){const s=this.getBounds().width,i=.001;if(s>0){const r=cs(this.config.components.chart.minCandles,s),a=t!==r&&t-r<=i&&e,l=cs(s/this.config.components.chart.minWidth,s),h=t-l>=i&&!e;return{zoomIn:a,zoomOut:h}}return{zoomIn:!1,zoomOut:!1}}setXScale(t,e,s=!0){var i;const r=this.export(),o=this.calculateZoomX(t,e);if(r.xStart===t&&r.xEnd===e&&r.zoomX>0)return;const a=Rr(ce({},r),{zoomX:o,xStart:t,xEnd:e}),l=this.scalePostProcessor(r,a),c=l.xEnd-l.xStart<r.xEnd-r.xStart;this.zoomReached=this.calculateZoomReached(o,c),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&Dr(r,l),this.state.auto&&this.autoScaleModel.doAutoYScale(l),s||this.config.scale.disableAnimations?(this.haltAnimation(),this.apply(l)):((i=this.currentAnimation)==null||i.tick(),Ie?Jh(this.canvasAnimation,this,l,this.state.auto?this.autoScaleModel:void 0):ds(this.canvasAnimation,this,l)))}setXScaleWithoutYScale(t){var e;const s=this.export(),i=t.slice(Math.max(t.length-this.state.defaultViewportItems,0)),r=i[i.length-1],o=r.startUnit+r.width+this.offsets.right,a=o-this.getBounds().width*this.zoomX,l=Rr(ce({},s),{xStart:a,xEnd:o}),c=this.scalePostProcessor(s,l);this.state.auto&&this.autoScaleModel.doAutoYScale(c),(e=this.currentAnimation)==null||e.tick(),ds(this.canvasAnimation,this,c)}setYScale(t,e,s=!1){const i=this.export();if(i.yStart===t&&i.yEnd===e&&i.zoomY>0)return;if(this.state.lockPriceToBarRatio&&this.initialViewportValidSubject.getValue()){this.setLockedYScale(t,e,s,i);return}super.setYScale(t,e,s);const r=this.export(),o=this.scalePostProcessor(i,r);this.state.auto&&this.autoScaleModel.doAutoYScale(o),this.apply(o)}setLockedYScale(t,e,s=!1,i){const r=e<i.yEnd;if(this.zoomReached.zoomOut&&r===!1||this.zoomReached.zoomIn&&r===!0)return;super.setYScale(t,e,s);const o=this.export(),a=this.scalePostProcessor(i,o);Uh(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=ce({},e);this.haltAnimation(),Gh(e,t);const i=this.scalePostProcessor(s,e);this.state.auto&&this.autoScaleModel.doAutoYScale(i),this.apply(i)}moveYStart(t){if(this.haltAnimation(),!this.state.auto){const e=this.export();Zh(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),nh(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){const e=this.state.auto;this.config.components.yAxis.type==="percent"?this.state.auto=!0:this.state.auto=t,t?(this.clearHistory(),this.doAutoScale()):e!==this.state.auto&&this.fireChanged()}setLockPriceToBarRatio(t=!1){const{type:e}=this.config.components.yAxis;if(e==="percent"||e==="logarithmic"){this.state.lockPriceToBarRatio=!1;return}this.state.lockPriceToBarRatio=t}initAutoScaleThrottling(){this.autoScaleZoomSubscription=id.pipe(Et(Vt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ce({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)}),this.autoScalePanSubscription=rd.pipe(Et(Vt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ce({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)})}}class ad extends Fr{constructor(t,e,s,i){super(e,s,i),this.delegate=t,this.config=e,this.getBounds=s}doActivate(){this.addRxSubscription(this.delegate.xChanged.subscribe(()=>this.doAutoScale(this.state.auto)))}get xStart(){return this.delegate.xStart}set xStart(t){this.delegate.xStart=t}get xEnd(){return this.delegate.xEnd}set xEnd(t){this.delegate.xEnd=t}get zoomX(){return this.delegate.zoomX}set zoomX(t){this.delegate.zoomX=t}observeXChanged(){return this.delegate.xChanged}fireChanged(){this.delegate.changed.next(),this.changed.next()}}const ld=is().colors;class $t extends mr{constructor(t,e,s,i,r,o,a,l,c=ld){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=od(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new F,this.meanCandleWidth=Zs,this._instrument=o,this.instrument=o,this.highLowProvider=Yh(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=Ce.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i,this.recalculateZippedHighLow(),this.eventBus.fireDraw()}calculateDataViewportIndexes(t,e){const s=Nt(this.visualPoints,t,r=>r.startUnit).index,i=Nt(this.visualPoints,e,r=>r.startUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}applyPriceMovement(){const t=wt(this.dataPoints);t&&(this.lastPriceMovement=ns(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=Ar(this.visualPoints.slice(this.dataIdxStart,this.dataIdxEnd+1))}updateCurrentPrice(t){this.previousPrice=this.currentPrice||t,this.currentPrice=t,this.currentPrice!==this.previousPrice&&(this.lastPriceMovement=this.currentPrice>this.previousPrice?"up":"down")}updateCandleSeriesColors(t){this.colors=At(t,this.colors),this.recalculateVisualPoints()}observeLastVisualCandleChanged(){return this.lastVisualCandleChangedSubject.asObservable()}doDeactivate(){super.doDeactivate()}toVisualPoints(t,e=0){var s,i;if(t.length===0)return[];const r=this.config.type,o=[];let a=e;const l=(s=this.candleWidthByChartType[r])!=null?s:Pr;for(let c=0;c<t.length;c++){const h=t[c],d=t[c-1],u=l(h),f=a+u/2,p=(i=this.candlesTransformersByChartType[r])!=null?i:xr;o.push(p(h,{x:f,width:u,prevCandle:d,activeCandle:this.activeCandle},o[c-1])),a+=u}return o}recalculateMeanCandleWidth(t){t.length!==0?this.meanCandleWidth=t.reduce((e,s)=>e+s.width,0)/t.length:this.meanCandleWidth=Zs}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 pv(n){switch(n){case"line":case"area":return!0;default:return!1}}class cd{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=!!i.color;if(s instanceof $t){const a=mt(e);if(a.length===0)return;i.color?t.strokeStyle=i.color:t.strokeStyle=s.colors.areaTheme.lineColor,o?t.lineWidth=(r=i.hoverWidth)!=null?r:this.config.selectedWidth*3:s.highlighted?t.lineWidth=this.config.selectedWidth:t.lineWidth=this.config.areaLineWidth;const l=s.extentComponent.getBounds(),c=a[0],h=s.view.toX(c.centerUnit);for(let d=0;d<a.length;d++){const u=a[d-1],f=a[d+1],p=a[d],m=s.view.toX(p.centerUnit),_=s.view.toY(p.close),S=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(rt(m),S),t.moveTo(rt(m),_);else if(f===void 0){t.lineTo(rt(m),_),t.stroke(),t.lineTo(rt(m),S),t.lineTo(rt(h),S),t.closePath();let A;i.color?t.fillStyle=i.color:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(A=t.createLinearGradient(0,0,0,l.height),A.addColorStop(0,s.colors.areaTheme.startColor),A.addColorStop(1,s.colors.areaTheme.stopColor),A):"",o||t.fill()}else t.lineTo(m,_)}}}}function Hr(n,t,e,s,i,r=4,o=!0,a=!1){n.save(),n.beginPath(),n.moveTo(t+r,e),n.lineTo(t+s-r,e),n.quadraticCurveTo(t+s,e,t+s,e+r),n.lineTo(t+s,e+i-r),n.quadraticCurveTo(t+s,e+i,t+s-r,e+i),n.lineTo(t+r,e+i),n.quadraticCurveTo(t,e+i,t,e+i-r),n.lineTo(t,e+r),n.quadraticCurveTo(t,e,t+r,e),n.closePath(),o&&n.fill(),a&&n.stroke(),n.restore()}function hd(n,t,e,s,i,r,o,a,l,c,h=4,d=!0,u=!1){const f=c==="right"?a:-a,p=c==="right"?h:-h,m=h;n.save(),n.beginPath(),l?n.moveTo(r+p,o):n.moveTo(r,o),l?(n.lineTo(r+f-p,o),n.quadraticCurveTo(r+f,o,r+f,o-m),n.lineTo(r+f,e+m),n.quadraticCurveTo(r+f,e,r+f-p,e),n.lineTo(t+p,e)):(n.lineTo(r+f,o),n.lineTo(r+f,e),n.lineTo(t,e)),l?(n.quadraticCurveTo(t,e,t-p/3,e+m/3),n.lineTo(s+p/3,i-m/3),n.quadraticCurveTo(s,i,s+p/3,i+m/3),n.lineTo(r-p/3,o-m/3),n.quadraticCurveTo(r,o,r+p/3,o)):(n.lineTo(s,i),n.lineTo(r,o)),n.closePath(),d&&n.fill(),u&&n.stroke(),n.restore()}function dd(n,t,e,s,i,r=1,o=[],a){n.save(),n.setLineDash(o),n.lineWidth=r,a!==void 0&&(n.lineCap=a),n.beginPath(),n.moveTo(t,e),n.lineTo(s,i),n.stroke(),n.closePath(),n.restore()}function he(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function kr(n,t,e){const s=Math.min(t.x,e.x)+.5,i=Math.min(t.y,e.y),r=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);n.fillRect(s,i,r,o)}const Kt=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},gv=n=>Array.isArray(n[0])?n:[n];class ud{constructor(t,e){this.paneManager=t,this.seriesDrawers=e}draw(t,e,s){const i=t.ctx,r=s&&this.paneManager.panes[s];e&&(i.save(),r&&Kt(i,r.getBounds()),this.drawSeries(i,e),i.restore())}drawSeries(t,e){const s=e.config.additionalVisibilityPredicatesMap;if(e.config.visible||s&&!eh(s)){const i=e.config.type,r=this.seriesDrawers[i];if(r){const o=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);o&&o.length>=1&&r.draw(t,o,e,{})}else console.error(`Data series drawer with type ${i} isn't registered!`)}}}const qt=(n,t,e,s,i=t)=>{s.hoverWidth?n.lineWidth=s.hoverWidth:e.highlighted?n.lineWidth=t!==i?t+1:i:n.lineWidth=t};class fd{constructor(t){this.config=t}setFillStyle(t,e,s,i){if(e.color)t.strokeStyle=e.color;else{const r=s.colors.barTheme;r&&(t.strokeStyle=r[`${i.name}Color`])}}draw(t,e,s,i){if(s instanceof $t){const r=mt(e);qt(t,this.config.barLineWidth,s,i),he(t,()=>{for(const o of r){this.setFillStyle(t,i,s,o),t.beginPath();const a=s.view.toX(o.centerUnit),l=s.view.toX(o.startUnit),[c,h,d,u]=o.yBodyKeyPoints(s.view),f=It(s.view.xPixels(o.width)/2),p=s.view.toY(o.close),m=s.view.toY(o.open);this.config.showWicks?(t.moveTo(a,c),t.lineTo(a,u)):(t.moveTo(a,h),t.lineTo(a,d)),t.moveTo(a,p),t.lineTo(a+f,p),t.moveTo(l,m),t.lineTo(a,m),t.stroke()}})}}}class pd{constructor(t,e){this.baseLineModel=t,this.canvasBoundContainer=e}draw(t,e,s,i){if(i!==void 0&&s instanceof $t){const r=mt(e),o=this.baseLineModel.baselineYPercents,a=this.canvasBoundContainer.getBounds(M.CHART),l=a.y+a.height*(o/100),c=r[0];for(let h=0;h<r.length;h++){const d=r[h],u=r[h-1],f=r[h+1],p=s.view.toX(c.centerUnit),m=s.view.toX(d.centerUnit),_=s.view.toY(d.close),S=u?s.view.toY(u.close)<l:!1,A=_<l;if(u!==void 0&&S!==A){jr(t,s,i,S);const E=s.view.toX(u.centerUnit),j=s.view.toY(u.close),B=m-E,R=_-j,k=B/R,z=_-l,X=k*z,G=E+(B-X);t.lineTo(G,l),t.stroke(),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(G,l)}u===void 0?(t.beginPath(),t.moveTo(m,_)):f===void 0?(jr(t,s,i,A),t.lineTo(m,_),t.stroke(),t.lineTo(m,l),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(p,l),t.lineTo(m,l),t.strokeStyle=s.colors.baseLineTheme.baselineColor,t.stroke()):t.lineTo(m,_)}}}}const jr=(n,t,e,s)=>{e.color?(n.fillStyle=e.color,n.strokeStyle=e.color):(n.fillStyle=s?t.colors.baseLineTheme.upperSectionFillColor:t.colors.baseLineTheme.lowerSectionFillColor,n.strokeStyle=s?t.colors.baseLineTheme.upperSectionStrokeColor:t.colors.baseLineTheme.lowerSectionStrokeColor)};class gd{constructor(t){this.config=t,this.pixelLength=1,this.lineWidthCU=1,this.halfLineWidthCU=1}draw(t,e,s,i){if(s instanceof $t){const r=mt(e);qt(t,this.config.candleLineWidth,s,i,this.config.candleLineWidth),he(t,()=>{this.pixelLength=1/Ht,this.halfLineWidthCU=t.lineWidth/2,this.lineWidthCU=t.lineWidth;for(const o of r){const{candleTheme:a,activeCandleTheme:l}=s.colors;a&&l&&this.drawCandle(t,i,s,o)}})}}drawCandle(t,e,s,i){const{candleTheme:r,activeCandleTheme:o}=s.colors,a=i.name,l=i.isActive?o:r,c=i.isHollow;e.color?t.fillStyle=e.color:c?t.fillStyle=l[`${a}WickColor`]:t.fillStyle=l[`${a}Color`];const h=s.view.toX(i.startUnit),d=s.view.xPixels(i.width),u=i.bodyHeight(s.view),[f,p,m,_]=i.yBodyKeyPoints(s.view),S=p===m?p+1:m,A=f===_?f+1:_,E=l[`${a}Color`],j=a==="none"?E:l[`${a}WickColor`];t.fillStyle=E,e.color?t.strokeStyle=e.color:t.strokeStyle=j;const B=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),R=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:S),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:S),t.moveTo(h+1,p),t.lineTo(h+1,S),t.stroke();else if(d===3){const k=d/Ht;this.drawCandlesWicks(t,h+k,f,A,p,S),c||(t.beginPath(),t.moveTo(h+k,p),t.lineTo(h+k,S),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,p+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const k=i.x(s.view);this.drawCandlesWicks(t,k,f,A,p,S);const z=this.config.candlePaddingPercent,X=Math.max(d*z/2,this.pixelLength),G=h+X,Z=d-X*2;if(!c){e.color&&(t.fillStyle=e.color);const U=e.hoverWidth?d+X:Z,Q=e.hoverWidth?u+e.hoverWidth+X:u;t.fillRect(G,p,U,Q)}B&&this.drawCandleBorder(t,e,l,i,G+this.halfLineWidthCU,p+this.halfLineWidthCU,Z-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,s,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,s,i,r,o,a,l){if(e.color)t.strokeStyle=e.color;else{const c=i.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class md{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof $t){const r=e.flat(),o=s.scale.getBounds(),a=o.y+o.height;for(const l of r){t.beginPath();const c=l.name,h=this.config.barCapSize,d=s.colors.histogram;if(d===void 0)return;i.color?t.fillStyle=i.color:t.fillStyle=d[`${c}Bright`];const u=l.xStart(s.view),f=s.view.toY(l.close),p=It(s.view.xPixels(l.width));t.fillRect(u,f,p,h);const m=t.createLinearGradient(0,f+h,0,a);i.color?t.fillStyle=i.color:(m.addColorStop(0,d[`${c}Cap`]),m.addColorStop(1,d[`${c}Bottom`]),t.fillStyle=m),p===0?(t.beginPath(),t.strokeStyle=m,t.moveTo(u,f+h),t.lineTo(u,a),t.stroke(),t.closePath()):t.fillRect(u,f+h,p,a-f-h)}}}}class vd{constructor(t){this.config=t}draw(t,e,s,i){if(s instanceof $t){const r=mt(e);qt(t,this.config.lineWidth,s,i,this.config.selectedWidth);const o=s.colors.lineTheme;t.lineCap="round",i.color&&(t.strokeStyle=i.color);for(let a=1;a<r.length;a++){const l=r[a-1],c=r[a],h=c.name;i.color||(t.strokeStyle=o[`${h}Color`]);const d=s.view.toX(l.centerUnit),u=s.view.toY(l.close),f=s.view.toX(c.centerUnit),p=s.view.toY(c.close);t.beginPath(),t.moveTo(d,u),t.lineTo(f,p),t.stroke()}}}}const bd=1.5;class Cd{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:bd;t.fillStyle=(r=i.color)!=null?r:this.config.mainColor;for(const a of mt(e)){t.beginPath();const l=s.view.toX(a.centerUnit),c=s.view.toY(a.close);t.arc(l,c,o,0,Math.PI*2,!0),t.fill()}}}const yd=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class wd{constructor(t,e,s){this.drawer=t,this.config=e,this.chartBounds=s}draw(t,e,s,i){this.isChartTypeAllowed()&&(this.beforeDraw(t),this.drawer.draw(t,e,s,i),this.afterDraw(t,s))}beforeDraw(t){t.restore(),t.save(),Kt(t,this.chartBounds())}isChartTypeAllowed(){return yd.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Kt(t,e.scale.getBounds())}}class Sd{constructor(t){this.chartModel=t}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=this.chartModel.getVisualCandle(rt(c.centerUnit)),d=c.close;if(h&&d===1){const u=this.chartModel.scale.zoomX,f=It(vt(h.width,u)),p=It(h.bodyHeight(this.chartModel.scale)),m=h.xCenter(this.chartModel.scale)-f/2,_=h.yBodyStart(this.chartModel.scale),S=this.chartModel.config.components.chart.candlePaddingPercent,A=It(f*S/2),E=m+A,j=f-A*2;t.fillRect(E,_,j,p)}})})}}const xd=(n,t,e,s)=>{const{centerUnit:i,close:r}=n,o=e.toX(i),a=e.toY(r);s===0?t.moveTo(o,a):t.lineTo(o,a)},Yr=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{xd(s,t,e,i)})},_d=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,Pd=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,Td=/^rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}\s*0*(?:\.\d+|1(?:\.0*)?)\s*[)]$/,Md=n=>_d.exec(n),Ad=n=>Pd.exec(n),mv=n=>Td.exec(n);function Ed(n){const t=Md(n)||Ad(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const Nr={};function Id(n,t){let e=Nr[n+t];if(!e){const s=Ed(n);e=s&&"rgba("+s.join(",")+","+t+")",Nr[n+t]=e}return e}const Xr="#383838";class Dd{constructor(){}draw(t,e,s,i){const r=s.config.additionalVisibilityPredicatesMap,o=(r==null?void 0:r.showLine)!==void 0?r.showLine:s.config.visible,a=(r==null?void 0:r.showCloud)!==void 0?r.showCloud:s.config.visible;o&&e.forEach((l,c)=>{var h;const d=s.getPaintConfig(c);qt(t,d.lineWidth,s,i,d.hoveredLineWidth);const u=(h=i.color)!=null?h:d.color;t.strokeStyle=u,this.drawLine(t,l,s.view)}),a&&s.linkedDataSeriesModels.forEach((l,c)=>{const h=l.config.additionalVisibilityPredicatesMap,d=(h==null?void 0:h.showCloud)!==void 0?h.showCloud:l.config.visible;if(Wr(l.config.type)&&Wr(s.config.type)&&d){const u=s,f=u.getSeriesInViewport(u.scale.xStart-1,u.scale.xEnd+1),p=l.getSeriesInViewport(l.scale.xStart-1,l.scale.xEnd+1);f.forEach((m,_)=>{var S,A;const E=[],j=Math.min(m.length,(A=(S=p[_])==null?void 0:S.length)!=null?A:0);for(let k=0;k<j;k++){const z=[m[k].clone(),p[_][k].clone()];E.push({diffPoints:z})}const B=u.getPaintConfig(_).color,R=l.getPaintConfig(c).color;this.drawDifference(t,B,R,E,u,l,i,r)})}})}drawLine(t,e,s){t.beginPath(),Yr(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a,l){const[c,h]=[[],[]];i.forEach(_=>{const[S,A]=_.diffPoints;c.push(S),h.push(A)});const d=this.mapDataSeriesDiffPointsIntoPoints(c,r.view),u=this.mapDataSeriesDiffPointsIntoPoints(h,o.view),f=l==null?void 0:l.backgroundColor,p=f!==void 0?f:s,m=f!==void 0?f:e;this.fillCloud(t,p,d,u,a,l),this.fillCloud(t,m,u,d,a,l)}fillCloud(t,e,s,i,r,o){var a,l,c,h;t.save(),t.beginPath();const d=(l=(a=ie(s))==null?void 0:a.x)!=null?l:0,u=(h=(c=wt(s))==null?void 0:c.x)!=null?h:0;t.lineTo(d,0),s.forEach(p=>{t.lineTo(p.x,p.y)}),t.lineTo(u,0),t.closePath(),t.clip(),t.beginPath(),s.forEach((p,m)=>{m===0?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y)}),i.slice().reverse().forEach(p=>{t.lineTo(p.x,p.y)}),t.closePath();const f=(o==null?void 0:o.backgroundColor)!==void 0;r.color?t.fillStyle=r.color:f?t.fillStyle=e!=null?e:Xr:t.fillStyle=Id(e!=null?e:Xr,.3),t.fill(),t.restore()}mapDataSeriesDiffPointsIntoPoints(t,e){return t.map(s=>{const{centerUnit:i,close:r}=s,o=e.toX(i),a=e.toY(r);return{x:o,y:a}})}}const Wr=n=>n==="DIFFERENCE";class Ld{constructor(){}draw(t,e,s,i){const r=s.view.toY(0);e.forEach((o,a)=>{var l;const c=s.getPaintConfig(a);qt(t,c.lineWidth,s,i,c.hoveredLineWidth),t.strokeStyle=(l=i.color)!=null?l:c.color,t.beginPath(),o.forEach(h=>{const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.moveTo(d,rt(r)),t.lineTo(d,rt(u))}),t.stroke()})}}class Od{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);qt(t,l.lineWidth,s,i,l.hoveredLineWidth),t.strokeStyle=(a=i.color)!=null?a:l.color,this.drawLinePath(t,r,s.view)})}drawLinePath(t,e,s){t.beginPath(),Yr(e,t,s),t.stroke()}}class Bd{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o),c=i.hoverWidth?i.hoverWidth/2:l.lineWidth;t.fillStyle=(a=i.color)!=null?a:l.color,t.lineWidth=1,r.forEach(h=>{t.beginPath();const d=s.view.toX(h.centerUnit),u=s.view.toY(h.close);t.arc(d,u,c,0,Math.PI*2),t.fill()})})}}class Rd{constructor(t){this.config=t}draw(t,e,s,i){t.save(),e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color;const c=l.lineWidth+"px "+this.config.components.yAxis.fontFamily;t.font=c,r.forEach(h=>{const d=s.getTextForPoint(h),u=Mt(d,t,c),f=Xt(c,t),p=s.view.toX(h.centerUnit)-u/2,m=s.view.toY(h.close)+f;t.fillText(d,p,m)})}),t.restore()}}class Fd{constructor(){}draw(t,e,s,i){e.forEach((r,o)=>{var a;const l=s.getPaintConfig(o);t.fillStyle=(a=i.color)!=null?a:l.color,r.forEach(c=>{const h=s.view.toX(c.centerUnit),d=s.view.toY(c.close);this.drawCandleTriangle(t,h,d,l.lineWidth)})})}drawCandleTriangle(t,e,s,i){t.beginPath(),t.moveTo(e-i/2,s),t.lineTo(e,s-i),t.lineTo(e+i/2,s),t.fill()}}const us="resized_local",fs="draw",vv="draw_last_candle",ye={width:20,height:20};class Vr{constructor(t,e,s,i,r,o={}){this.eventBus=t,this.canvas=e,this.drawingManager=s,this.resizer=r,this.width=0,this.height=0,this.prevHeight=0,this.prevWidth=0,this.lastDPR=0,this.type=ln;var a;i.push(this),this.parent=jd(e);const l=e.getContext("2d",o);if(l===null)throw new Error("Couldn't get 2d context????");this.context=l,this._canvasId=(a=e.getAttribute("data-element"))!=null?a:"",this.updateCanvasWidthHeight(e,this.getChartResizerElement().getBoundingClientRect())}updateDPR(t){const{width:e,height:s}=t,i=window.devicePixelRatio;e===this.width&&s===this.height&&i===this.lastDPR||(this.lastDPR=i,this.canvas.style.height=s+"px",this.canvas.style.width=e+"px",this.canvas.width=e*i,this.canvas.height=s*i,this.width=e,this.height=s,this.ctx.scale(i,i))}get canvasId(){return this._canvasId}get ctx(){return this.context}clear(){this.context.clearRect(0,0,this.width,this.height)}isLinked(){var t,e;return(e=(t=this.type)==null?void 0:t.linked)!=null?e:!1}fireDraw(){this.eventBus.fireDraw([this.canvasId])}updateCanvasWidthHeight(t,e=this.getChartResizerElement().getBoundingClientRect()){t.clientWidth!==this.width&&(t.width=t.clientWidth,this.width=t.clientWidth);const s=e.height;s!==this.height&&(t.style.height=s+"px",this.height=s,t.height=s,this.prevHeight=s)}getChartResizerElement(){var t;return(t=this.resizer)!=null?t:this.parent}isReady(){return this.width>ye.width&&this.height>ye.height}}const ln={name:"candle"},Hd={candle:ln,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function kd(n,t,e,s,i,r,o){var a;const l=de(n,t,i,r,o,e);return l.type=(a=Hd[s])!=null?a:ln,l}function de(n,t,e,s,i,r,o){const a=new Vr(n,t,s,i,r,o);return zr(a,e),a}function zr(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 jd(n){let t=n;for(;t;){if(t.nodeType===1&&t.hasAttribute("data-chart-container"))return t;if(t.parentElement!==null)t=t.parentElement;else break}return t}const ps="HIT_TEST_",wv=null;class Yd{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${St()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(ps)!==-1&&this.drawersMap[s].draw()})},t.on(fs,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),ii(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(ps)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(ps)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}Xl(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>ye.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>ye.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=St()){this.drawingOrder.indexOf(e)===-1&&this.drawingOrder.push(e),this.drawersMap[e]=t}addDrawerAfter(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(e);this.drawingOrder.splice(i,1);const r=this.drawingOrder.indexOf(s);this.drawingOrder.splice(r+1,0,e),this.reorderDrawers(this.drawingOrder)}addDrawerBefore(t,e,s){this.addDrawer(t,e);const i=this.drawingOrder.indexOf(s);if(i!==-1){const r=this.drawingOrder.indexOf(e);return this.drawingOrder.splice(r,1),this.drawingOrder.splice(i,0,e),this.reorderDrawers(this.drawingOrder),!0}return!1}getDrawerByName(t){return this.drawersMap[t]}getNameByDrawer(t){for(const e in this.drawersMap)if(this.drawersMap[e]===t)return e}removeDrawerByName(t){const e=this.drawersMap[t];this.removeDrawer(e)}removeDrawer(t){Object.keys(this.drawersMap).forEach(e=>{if(this.drawersMap[e]===t){delete this.drawersMap[e];const s=this.drawingOrder.indexOf(e);s!==-1&&this.drawingOrder.splice(s,1)}})}reorderDrawers(t){this.drawingOrder=gi(this.drawingOrder,t)}}class Ur{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Nd=7;class Xd{constructor(t,e,s,i=()=>!0){this.seriesDrawers=t,this.canvasModel=e,this.paneManager=s,this.drawPredicate=i}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;this.paneManager.yExtents.forEach(e=>{t.save(),Kt(t,e.getBounds()),e.dataSeries.forEach(s=>this.drawSeries(t,s)),t.restore()})}}drawSeries(t,e){if(e.config.visible){const s=e.config.type,i=this.seriesDrawers[s];if(i){const r={color:this.canvasModel.idToColor(e.htId),hoverWidth:Nd};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Gr={dragPredicate:()=>!0};class Zr extends W{constructor(t,e,s,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragComponentOptions.dragPredicate()&&(this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o))},this.onDragTick=o=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels))}}}class gs extends Zr{constructor(t,e,s,i,r=Gr){super(t,e,s,i,r)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeYDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.canvasInputListener.observeYDrag().subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeYDragEnd().subscribe(this.onDragEnd))}}const Wd="BASELINE_RESIZER";class Vd extends W{constructor(t,e,s,i,r,o,a){super(),this.chartModel=t,this.chartPanComponent=e,this.canvasModel=s,this.canvasInputListener=i,this.config=r,this.canvasBoundContainer=o,this.cursorHandler=a,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.dragPredicate=new ft(!1),this.baselineYPercents=50,this.ht=qs.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragStartCb=()=>{this.chartPanComponent.deactivatePanHandlers(),this.dragPredicate.next(!0)},this.dragEndCb=()=>{this.chartPanComponent.activateChartPanHandlers(),this.dragPredicate.next(!1)},this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(M.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&_c(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new gs(this.ht,{onDragTick:this.dragTickCb,onDragStart:this.dragStartCb,onDragEnd:this.dragEndCb},i,e);this.addChildEntity(l)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundContainer.observeBoundsChanged(M.CHART).subscribe(()=>this.recalculateBounds())),this.chartModel.chartTypeChanged.subscribe(t=>{t==="baseline"?this.cursorHandler.setCursorForBounds("BASELINE_RESIZER",this.resizerBounds,this.config.components.baseline.cursor,this.config.components.baseline.dragZone):this.cursorHandler.removeCursorForCanvasEl("BASELINE_RESIZER")})}recalculateBounds(){const t=this.canvasBoundContainer.getBounds(M.CHART),e=this.canvasBoundContainer.getBounds(M.Y_AXIS);this.resizerBounds.x=t.x,this.resizerBounds.width=t.width+e.width,this.resizerBounds.height=this.config.components.baseline.height;const s=t.y+t.height*(this.baselineYPercents/100);this.resizerBounds.y=s,this.canvasBoundContainer.bounds[Wd]=this.resizerBounds}moveBaseLine(t){const e=this.canvasBoundContainer.getBounds(M.CHART);this.baselineYPercents=(t-e.y)*100/e.height,this.resizerBounds.y=t}doDeactivate(){super.doDeactivate()}}const zd=n=>{var t;try{const e=Ae(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Ae(n.hi,Math.max(n.open,n.close),e),i=Ae(n.lo,Math.min(n.open,n.close),e),r=Ae(n.open,n.lo,e),o=Ae(n.close,n.hi,e),a=Number.isNaN(n.vwap)?void 0:n.vwap;return{id:n.id,hi:s,lo:i,open:r,close:o,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility,openInterest:n.openInterest,vwap:a,typicalPrice:n.typicalPrice}}catch(e){console.warn(e);return}},je=(n,t=0)=>{for(let e=t;e<n.length;++e)n[e].idx=e},$r=n=>{n.forEach(t=>{t.idx=void 0})},Ud=n=>n!==void 0;class Gd{constructor(){}draw(t,e,s,i){const r=s.view.toY(0),o=mt(e),a=s.getPaintConfig(0);qt(t,a.lineWidth,s,i,a.hoveredLineWidth),o.forEach((l,c)=>{var h,d,u,f,p,m,_,S;const A=Zd(o,c),E=A&&l.close<A;if(((h=a.multiplyColors)==null?void 0:h.length)===2){t.strokeStyle=(d=i.color)!=null?d:(E?a.multiplyColors[1]:a.multiplyColors[0])||a.color||"#FF00FF",t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}if(((u=a.multiplyColors)==null?void 0:u.length)===4){E&&l.close<0&&(t.strokeStyle=(f=i.color)!=null?f:a.multiplyColors[0]||a.color||"#FF00FF"),!E&&l.close<0&&(t.strokeStyle=(p=i.color)!=null?p:a.multiplyColors[1]||a.color||"#FF00FF"),E&&l.close>0&&(t.strokeStyle=(m=i.color)!=null?m:a.multiplyColors[2]||a.color||"#FF00FF"),!E&&l.close>0&&(t.strokeStyle=(_=i.color)!=null?_:a.multiplyColors[3]||a.color||"#FF00FF"),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.moveTo(R,r),t.lineTo(R,k),t.stroke();return}t.strokeStyle=(S=i.color)!=null?S:a.color||"#FF00FF",t.beginPath();const j=s.view.toX(l.centerUnit),B=s.view.toY(l.close);t.moveTo(j,r),t.lineTo(j,B),t.stroke()})}}const Zd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},$d=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class Kd{constructor(){}draw(t,e,s,i){const r=mt(e),o=s.getPaintConfig(0);qt(t,o.lineWidth,s,i,o.hoveredLineWidth),t.lineCap="round",r.forEach((a,l)=>{var c,h;const d=qd(r,l)||r[0],u=d&&a.close<d.close;if(((c=o.multiplyColors)==null?void 0:c.length)===2){t.strokeStyle=(h=i.color)!=null?h:(u?o.multiplyColors[1]:o.multiplyColors[0])||o.color||"#FF00FF";const f=s.view.toX(a.centerUnit),p=s.view.toY(a.close),m=s.view.toX(d.centerUnit),_=s.view.toY(d.close);t.beginPath(),t.moveTo(m,_),t.lineTo(f,p),t.stroke();return}})}}const qd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0},we="#FF00FF";class Jd{constructor(){}draw(t,e,s,i){const r=mt(e),o=s.getPaintConfig(0),a=i.hoverWidth?i.hoverWidth/2:o.lineWidth;r.forEach((l,c)=>{var h,d,u,f,p,m,_,S;const A=Qd(r,c),E=A&&l.close<A;if(((h=o.multiplyColors)==null?void 0:h.length)===2){t.fillStyle=(d=i.color)!=null?d:(E?o.multiplyColors[1]:o.multiplyColors[0])||o.color||we;const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}if(((u=o.multiplyColors)==null?void 0:u.length)===4){E&&l.close<0&&(t.fillStyle=(f=i.color)!=null?f:o.multiplyColors[0]||o.color||we),!E&&l.close<0&&(t.fillStyle=(p=i.color)!=null?p:o.multiplyColors[1]||o.color||we),E&&l.close>0&&(t.fillStyle=(m=i.color)!=null?m:o.multiplyColors[2]||o.color||we),!E&&l.close>0&&(t.fillStyle=(_=i.color)!=null?_:o.multiplyColors[3]||o.color||we),t.beginPath();const R=s.view.toX(l.centerUnit),k=s.view.toY(l.close);t.arc(R,k,a,0,Math.PI*2),t.fill();return}t.fillStyle=(S=i.color)!=null?S:o.color||we,t.beginPath();const j=s.view.toX(l.centerUnit),B=s.view.toY(l.close);t.arc(j,B,a,0,Math.PI*2),t.fill()})}}const Qd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0};var tu=Object.defineProperty,Kr=Object.getOwnPropertySymbols,eu=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,qr=(n,t,e)=>t in n?tu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Jr=(n,t)=>{for(var e in t||(t={}))eu.call(t,e)&&qr(n,e,t[e]);if(Kr)for(var e of Kr(t))su.call(t,e)&&qr(n,e,t[e]);return n};class nu{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class iu extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=f,this.chartResizeHandler=p,this._dataSeriesDrawers={},this.backgroundDrawerPredicateSubject=new ft(!0),this.strToBarType=_=>{var S;return(S=this.barTypeValues.find(A=>A===_))!=null?S:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new Vd(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const m=new Xd(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(m,ps+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new Ah(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(M.PANE_UUID($),s.components.chart.cursor),this.dataSeriesDrawer=new ud(d,this.dataSeriesDrawers)}doActivate(){super.doActivate(),this.dynamicObjects.model.addObject({id:this.chartModel.mainCandleSeries.id,paneId:this.chartModel.mainCandleSeries.extentComponent.paneUUID,model:this.chartModel.mainCandleSeries,drawer:this.dataSeriesDrawer}),this.addRxSubscription(this.paneManager.dataSeriesAddedSubject.subscribe(t=>{this.dynamicObjects.model.addObject({id:t.id,paneId:t.extentComponent.paneUUID,parentId:t.parentId,model:t,drawer:this.dataSeriesDrawer})})),this.addRxSubscription(this.paneManager.dataSeriesRemovedSubject.subscribe(t=>{this.dynamicObjects.model.removeObject(t.id)})),this.addRxSubscription(this.canvasBoundsContainer.observeAnyBoundsChanged().subscribe($d(()=>{this.backgroundDrawerPredicateSubject.next(!1)},Vt))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",xr),this.registerCandlesTransformer("trend",_r),this.registerCandlesTransformer("hollow",Ih),this.registerCandlesTransformer("line",Dh)}get barTypeValues(){return or(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 gd(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new fd(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new vd(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new Cd(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new cd(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new pd(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new md(this.config.components.chart.histogram));const e=M.PANE_UUID($),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new Od),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new Kd),this.registerDataSeriesTypeDrawer("HISTOGRAM",new Ld),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new Gd),this.registerDataSeriesTypeDrawer("POINTS",new Bd),this.registerDataSeriesTypeDrawer("TREND_POINTS",new Jd),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new wd(new Sd(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new Rd(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new Fd),this.registerDataSeriesTypeDrawer("DIFFERENCE",new Dd)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(Jr({},this.config.colors)),this.chartModel.mainCandleSeries.recalculateVisualPoints(),this.chartModel.chartTypeChanged.next(t)}resetChartScale(){this.chartModel.doBasicScale()}setTimestampRange(t,e,s=!0){return this.chartModel.setTimestampRange(t,e,s)}setXScale(t,e,s=!0){return this.scale.setXScale(t,e,s)}setShowWicks(t){this.config.components.chart.showWicks=t,this.canvasModel.fireDraw()}setApplyBackgroundToAxes(t){this.config.components.chart.applyBackgroundToAxes=Jr({},t),this.chartModel.bus.fireDraw()}setMainSeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument;this.chartModel.mainCandleSeries.instrument=s,this.chartModel.setAllSeries({candles:t.candles,instrument:s},this.chartModel.getSecondarySeries().map(i=>{var r;const o=(r=i.instrument)!=null?r:this.chartModel.mainCandleSeries.instrument,a=i.dataPoints;return $r(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),i)return i}setAllSeries(t,e=[]){var s;const i=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(i),e.forEach(r=>{var o;const a=(o=r.instrument)!=null?o:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(a)}),this.chartModel.setAllSeries(t,e)}toXFromCandleIndex(t){return this.chartModel.toX(t)}toXFromTimestamp(t){return this.chartModel.candleFromTimestamp(t).xCenter(this.chartModel.scale)}toY(t){return this.chartModel.toY(t)}updateAllSeries(t,e=[]){this.chartModel.updateAllSeries(t,e),this.canvasModel.fireDraw()}removeDataFrom(t){this.chartModel.removeDataFrom(t)}removeSecondarySeries(t){this.chartModel.removeSecondaryCandleSeries(t)}prependCandles(t,e){this.chartModel.prependCandles(t,e)}addLastCandle(t,e){this.chartModel.addLastCandle(t,e)}removeCandleByIdx(t,e){this.chartModel.removeCandleByIdx(t,e)}removeCandlesByIdsSequence(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIdsSequence(t,e)}removeCandlesByIds(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIds(t,e)}addCandlesById(t,e,s=this.chartModel.mainCandleSeries){this.chartModel.addCandlesById(t,e,s)}updateLastCandle(t,e){this.chartModel.updateLastCandle(t,e)}updateCandles(t,e){this.chartModel.updateCandles(t,e)}setOffsets(t){this.chartModel.setOffsets(t)}getDataSeriesDrawer(t){return this._dataSeriesDrawers[t]}registerDataSeriesTypeDrawer(t,e){this._dataSeriesDrawers[t]=e}updatePriceIncrementsIfNeeded(t){(!t.priceIncrements||!Ce.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[Ce.autoDetectIncrementOfValueRange(this.scale.yEnd-this.scale.yStart)])}observeOffsetsChanged(){return this.chartModel.offsetsChanged}observeChartTypeChanged(){return this.chartModel.chartTypeChanged}observeCandlesChanged(){return this.chartModel.observeCandlesChanged()}observeCandlesUpdated(){return this.chartModel.candlesUpdatedSubject}observeCandlesPrepended(){return this.chartModel.candlesPrependSubject}}function Qr(n,t){return t===void 0&&(t=as),N(function(e,s){var i=null,r=null,o=null,a=function(){if(i){i.unsubscribe(),i=null;var c=r;r=null,s.next(c)}};function l(){var c=o+n,h=t.now();if(h<c){i=this.schedule(void 0,c-h),s.add(i);return}a()}e.subscribe(Ct(s,function(c){r=c,o=t.now(),i||(i=t.schedule(l,n),s.add(i))},function(){a(),s.complete()},void 0,function(){r=i=null}))})}class to extends $t{constructor(t,e,s,i,r,o,a,l,c,h){super(e,s,i,r,o,a,l,c,h),this.baseModel=t}set visualPoints(t){super.visualPoints=t,this.baseModel.mainVisualPoints=super.visualPoints}get visualPoints(){return super.visualPoints}set dataPoints(t){super.dataPoints=t,this.baseModel.mainDataPoints=super.dataPoints}get dataPoints(){return super.dataPoints}recalculateMeanCandleWidth(t){super.recalculateMeanCandleWidth(t),this.baseModel.meanDataWidth=this.meanCandleWidth}}var ru=Object.defineProperty,eo=Object.getOwnPropertySymbols,ou=Object.prototype.hasOwnProperty,au=Object.prototype.propertyIsEnumerable,so=(n,t,e)=>t in n?ru(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,lu=(n,t)=>{for(var e in t||(t={}))ou.call(t,e)&&so(n,e,t[e]);if(eo)for(var e of eo(t))au.call(t,e)&&so(n,e,t[e]);return n};const cu=(n,t,e,s)=>{var i,r,o,a;const l=lu({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=Ul(-e,t))==null?void 0:o.startUnit)!=null?a:0;let d=n.xStart,u=n.xEnd;return l.xStart>=h&&(d=h,u=u-(l.xStart-h)),l.xEnd<c&&(d=c-kt(s.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},hu=n=>(t,e={xScale:!0,yScale:!0})=>{if(t.length!==0){if(e.xScale){const s=t.slice(Math.max(t.length-n.state.defaultViewportItems,0)),i=s[0],r=s[s.length-1];n.setXScale(i.startUnit,r.startUnit+r.width+n.offsets.right)}e.yScale&&n.doAutoScale(!0),n.fireChanged()}},du=(n,t)=>(e,s=null)=>{const[i,r]=e,o=t.candleFromTimestamp(i).startUnit,a=t.candleFromTimestamp(r).startUnit,l=s===null?0:t.mainCandleSeries.meanCandleWidth*2,c=s?o-l:o+l,h=s?a+l:a-l;n.setXScale(c,h)};var uu=Object.defineProperty,fu=Object.defineProperties,pu=Object.getOwnPropertyDescriptors,no=Object.getOwnPropertySymbols,gu=Object.prototype.hasOwnProperty,mu=Object.prototype.propertyIsEnumerable,io=(n,t,e)=>t in n?uu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ye=(n,t)=>{for(var e in t||(t={}))gu.call(t,e)&&io(n,e,t[e]);if(no)for(var e of no(t))mu.call(t,e)&&io(n,e,t[e]);return n},cn=(n,t)=>fu(n,pu(t));class vu{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)=>cn(Ye({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=cn(Ye({},le(this.config.colors)),{lineTheme:Ye({},s.lineTheme),areaTheme:Ye({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,s=i);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[t]=s,this.secondaryChartColorsPool[s]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var s,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=cn(Ye({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var bu=Object.defineProperty,ro=Object.getOwnPropertySymbols,Cu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,oo=(n,t,e)=>t in n?bu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ms=(n,t)=>{for(var e in t||(t={}))Cu.call(t,e)&&oo(n,e,t[e]);if(ro)for(var e of ro(t))yu.call(t,e)&&oo(n,e,t[e]);return n};class wu extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=i,this.config=r,this.scale=o,this.formatterFactory=a,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.chartTypeChanged=new F,this.mainInstrumentChangedSubject=new F,this.offsetsChanged=new F,this.candlesTransformersByChartType={},this.lastCandleLabelsByChartType={},this.candleWidthByChartType={},this.lastTimeFrame=[0,0],this.FAKE_CANDLES_DEFAULT=100,this.toY=u=>this.mainCandleSeries.view.toY(u),this.prepareCandles=u=>{const f=u.map(zd).filter(Ud),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.chartBaseModel.candleTimestampAnchor=this.getCandleTimestampAnchor(),this.secondaryChartColors=new vu(this.config);const d=new to(this.chartBaseModel,this.paneManager.panes[$].mainExtent,St(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new nu,this.candlesTransformersByChartType,this.candleWidthByChartType,ms({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),this.config.components.chart.minCandlesOffset>0&&o.addXConstraint((u,f)=>cu(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=hu(o),this.timeFrameViewportTransformer=du(o,this),this.pane=this.paneManager.panes[$]}get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(t=>t!==this.mainCandleSeries)}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID($)).pipe(gt(Ui)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(Qr(Vt)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>ye.width&&t.height>ye.height){const e=this.canvasBoundsContainer.getEffectiveChartWidth(),s=this.canvasBoundsContainer.getEffectiveYAxisWidth();if(this.prevChartWidth===0&&this.scale){this.scale.isViewportValid(!1)?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=kt(s-this.prevYWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart,this.scale.xEnd-r)}else this.scale.recalculateZoomX();this.prevYWidth=s,this.prevChartWidth=e;return}const i=kt(e-this.prevChartWidth,this.scale.zoomX);this.scale.setXScale(this.scale.xStart-i,this.scale.xEnd),this.scale.recalculateZoomY(),this.prevYWidth=s,this.prevChartWidth=e}}setMainCandleSeries(t,e){this.mainCandleSeries.instrument=e,this.setAllSeries({candles:t,instrument:e},this.getSecondarySeries().map(s=>{const i=s.dataPoints;return $r(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const i=this.prepareCandles(t),r=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),o=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,r),l=this.secondaryCandleSeries.some(c=>c.instrument.symbol===e.symbol)?this.secondaryCandleSeries.find(c=>c.instrument.symbol===e.symbol):this.createSecondaryCandleSeriesModel(e);if(l)return l.dataPoints=o,s&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var s;this.mainCandleSeries.instrument=(s=t.instrument)!=null?s:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=this.prepareCandles(t.candles);this.mainCandleSeries.clearData(),je(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(r=>e.filter(o=>{var a;return((a=o.instrument)==null?void 0:a.symbol)===r.instrument.symbol}).length===0).forEach(r=>this.removeSecondaryCandleSeries(r)),e.map(r=>this.setSecondaryCandleSeries(r.candles,r.instrument,!1)),this.candleSeries.forEach(r=>{r.recalculateDataViewportIndexes(),r.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()}autoScaleOnCandles(){this.scale.state.autoScaleOnCandles&&(this.doBasicScale(),this.scale.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doBasicXScale(){this.scale.setXScaleWithoutYScale(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(t=null){this.timeFrameViewportTransformer(this.lastTimeFrame,t),this.scale.state.autoScaleOnCandles&&this.scale.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scale.toX(this.scale.xStart),!0).timestamp,this.candleFromX(this.scale.toX(this.scale.xEnd),!0).timestamp])}updateAllSeries(t,e=[]){t=ms({},t),t.instrument||(t.instrument=this.mainCandleSeries.instrument);const s=[t,...e];if(!this.candleSeries.every(l=>s.find(c=>{var h;return((h=c.instrument)==null?void 0:h.symbol)===l.instrument.symbol}))||e.length!==this.secondaryCandleSeries.length){console.error("All series update failed. Instruments for series are different.");return}const i=this.prepareCandles(t.candles),r=lo(this.mainCandleSeries.dataPoints,i,this.getCandleTimestampAnchor()),o=r.candles;je(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=lo((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f,this.getCandleTimestampAnchor()).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints()});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.candleSeries.forEach(l=>{l.recalculateDataViewportIndexes()}),this.candlesPrependSubject.next({prependedCandlesWidth:a,prependedCandles:r.prepended}),this.chartBaseModel.recalculatePeriod(),this.candlesUpdatedSubject.next(),this.bus.fireDraw()}removeDataFrom(t){Object.values(this.paneManager.panes).forEach(e=>{e.dataSeries.forEach(s=>{const i=Nt(s.dataPoints,t,o=>o.timestamp),r=i.exact?i.index:i.index+1;s.dataPoints=s.dataPoints.slice(0,r)})}),this.candlesChangedRedraw()}createSecondaryCandleSeriesModel(t){const e=ms(ms({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new $t(this.paneManager.panes[$].mainExtent,St(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,t,this.candlesTransformersByChartType,this.candleWidthByChartType,e);return s.config.type="line",this.candleSeries.push(s),s}removeSecondaryCandleSeries(t){return this.secondaryChartColors.addColorToPool(t.instrument.symbol),this.candleSeries=this.candleSeries.filter(e=>e!==t),t.deactivate(),this.paneManager.panes[$].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(i=>{const r=this.candleIdxFromId(i.id),o=r>0?r:0,a=e[o];if(a)s.push(a);else{let l=ao(e,o,-1);if(l||(l=ao(e,o,1)),l){const c=rc(l,o,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const i=At(t,is().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=s,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=s.length&&this.scale.setXScale(this.scale.xStart,this.candleFromIdx(e).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scale.getOffsets()}fromY(t){return this.scale.fromY(t)}priceFromY(t,e){return(e!=null?e:this.mainCandleSeries).view.priceFromY(t)}fromX(t){return this.scale.fromX(t)}toX(t){const e=this.candleFromIdx(t);return this.scale.toX(e.centerUnit)}candleFromX(t,e=!1,s=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var i,r;const o=Nt(s.visualPoints,t,d=>d.startUnit),a=s.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=Ee((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?He(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:He(this.mainCandleSeries.dataPoints,h,this.chartBaseModel.period)}candleFromTimestamp(t,e={extrapolate:!0},s=this.mainCandleSeries){const i=s.dataPoints;return this.chartBaseModel.dataFromTimestamp(t,e,i)}candleFromId(t,e=this.mainCandleSeries){return e.visualPoints.find(s=>s.candle.id===t)}candleIdxFromId(t,e=this.mainCandleSeries){return e.visualPoints.findIndex(s=>s.candle.id===t)}candleFromIdx(t){return this.chartBaseModel.dataFromIdx(t)}isReady(){return this.canvasModel.isReady()&&this.hasCandles()}registerCandlesTransformer(t,e){this.candlesTransformersByChartType[t]=e}registerCandlesWidthCalculator(t,e){this.candleWidthByChartType[t]=e}registerLastCandleLabelHandler(t,e){this.lastCandleLabelsByChartType[t]=e}hasCandles(){return this.mainCandleSeries.visualPoints.length!==0}getVisualCandle(t){var e,s,i;const r=t-((i=(s=(e=this.mainCandleSeries.visualPoints[0])==null?void 0:e.candle)==null?void 0:s.idx)!=null?i:0);return this.mainCandleSeries.visualPoints[r]}getFirstIdx(){return this.mainCandleSeries.dataIdxStart}getLastIdx(){return this.mainCandleSeries.dataIdxEnd}getFirstTimestamp(t=!0){return t?this.candleFromIdx(this.getFirstIdx()).candle.timestamp:this.candleFromUnit(this.scale.xStart,!0).timestamp}getLastTimestamp(t=!0){return t?this.candleFromIdx(this.getLastIdx()).candle.timestamp:this.candleFromUnit(this.scale.xEnd,!0).timestamp}setTimestampRange(t,e,s=!0){const i=this.candleFromTimestamp(t).startUnit,r=this.candleFromTimestamp(e),o=r.startUnit+r.width;return this.scale.setXScale(i,o,s)}getLastCandle(){const t=this.mainCandleSeries.dataPoints;return wt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return wt(t)}getMaxCandlesFitLength(){return rt(this.canvasBoundsContainer.getEffectiveChartWidth()/this.config.components.chart.minWidth)}getSecondarySeries(){return this.secondaryCandleSeries}isSeriesInstrument(t,e){return t.instrument.symbol===e}findSeriesBySymbol(t){return this.candleSeries.filter(e=>this.isSeriesInstrument(e,t))}findSecondarySeriesBySymbol(t){return this.secondaryCandleSeries.find(e=>this.isSeriesInstrument(e,t))}reindexCandlesBasedOnSeries(t,e){return e.reduce((s,i)=>{const r=i.timestamp,o=Re(r,this.candleSearchOptions(!1),t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}getCandleTimestampAnchor(){var t;return(t=this.config.components.chart.candleTimestampAnchor)!=null?t:"open"}candleSearchOptions(t,e){return{extrapolate:t,isDaysPeriod:e,candleTimestampAnchor:this.getCandleTimestampAnchor()}}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}isLastCandleInViewport(){const t=this.getLastCandle();return t&&t.idx?this.isCandleInViewport(t.idx):!1}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=Re(h.timestamp,this.candleSearchOptions(!0),o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,m=c&&h.timestamp<c.timestamp;if(p&&!m&&(c=h),a&&c&&s&&l){const _=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:Pr;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.config.scale.auto&&this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return yt(this.candlesSetSubject,this.candlesUpdatedSubject)}getCandles(){return this.mainCandleSeries.dataPoints}getCandlesWithFake(t=this.getCandles(),e=0,s){const i=this.getCandlesCount(),r=s!=null?s:i+this.FAKE_CANDLES_DEFAULT;t=t.slice(Math.max(0,e),Math.min(i,r));const o=[],a=[];for(let c=i;c<r;c++)o.push(He(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=e;c<l;c++)a.push(He(this.mainCandleSeries.dataPoints,c,this.getPeriod()));return[...a,...t,...o]}getCandlesCount(){return this.mainCandleSeries.dataPoints.length}getCandlesCountWithRightOffset(){return this.getCandlesCount()+this.getOffsets().right}clearData(){this.candleSeries.forEach(t=>t.clearData())}prependCandles(t,e){const s=t.slice(),i=[];return e.forEach(r=>{const a=Re(r.timestamp,this.candleSearchOptions(!1),t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),je(i.dataPoints),i.recalculateVisualPoints()}),this.candlesChangedRedraw()}removeCandlesByIdsSequence(t,e){const s=this.candleIdxFromId(t[0],e),i=this.candleIdxFromId(t[t.length-1],e);if(s<0||i<0){console.warn("Candle is not found");return}e.dataPoints=e.dataPoints.slice(0,s).concat(e.dataPoints.slice(i+1)),je(e.dataPoints,i),e.recalculateVisualPoints(),this.candlesChangedRedraw()}removeCandlesByIds(t,e){t.forEach(s=>this.removeCandleByIdx(this.candleIdxFromId(s,e)))}addCandlesById(t,e,s){const i=this.candleIdxFromId(e);if(i<0){console.warn("Selected start candle is not found");return}const r=s.dataPoints.slice(0,i),o=s.dataPoints.slice(i);s.dataPoints=r.concat(t).concat(o),je(s.dataPoints),s.recalculateVisualPoints(),this.candlesChangedRedraw()}candlesChangedRedraw(){this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const ao=(n,t,e)=>{if(t>=n.length)return n[n.length-1];for(let s=t;s<n.length&&s>=0;s+=e){const i=n[s];if(i)return i}},lo=(n,t,e="open")=>{const s=n.slice(),i=[],r=[];return t.forEach(o=>{const l=Re(o.timestamp,{extrapolate:!0,candleTimestampAnchor:e},n).index;l<0?i.push(o):l>=n.length?r.push(o):n[l].timestamp===o.timestamp?s[l]=o:console.warn(`Couldn't update candle with timestamp ${o.timestamp}`)}),{prepended:i,appended:r,candles:[...i,...s,...r]}};class Se{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class hn{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=rr(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=rr(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=mt(Array.from(this.drawers).map(([,s])=>s.getCanvasIds())),e=new Set([...t]);return Array.from(e)}}class Su{constructor(t,e,s,i){this.model=t,this.config=e,this.crossToolCanvasModel=s,this.crossToolTypeDrawers=i}draw(){const t=this.crossToolTypeDrawers[this.config.components.crossTool.type];t?this.model.currentHover&&t.draw(this.crossToolCanvasModel.ctx,this.model.currentHover):console.error(`No cross tool drawer type registered for drawer type ${this.config.components.crossTool.type}`)}getCanvasIds(){return[this.crossToolCanvasModel.canvasId]}}var xu=Object.defineProperty,_u=Object.defineProperties,Pu=Object.getOwnPropertyDescriptors,co=Object.getOwnPropertySymbols,Tu=Object.prototype.hasOwnProperty,Mu=Object.prototype.propertyIsEnumerable,ho=(n,t,e)=>t in n?xu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,uo=(n,t)=>{for(var e in t||(t={}))Tu.call(t,e)&&ho(n,e,t[e]);if(co)for(var e of co(t))Mu.call(t,e)&&ho(n,e,t[e]);return n},fo=(n,t)=>_u(n,Pu(t));class Au extends W{constructor(t,e,s,i,r,o,a){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=i,this.canvasBoundsContainer=r,this.baselineModel=o,this.chartModel=a,this.currentHoverSubject=new ft(null)}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.config.type=t}shouldKeepXForMobileTouchCrosshair(){return Ot()&&this.hoverProducer.longTouchActivatedSubject.getValue()&&this.crossEventProducer.crossSubject.getValue()!==null}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?Ot()?this.updateCrossToolMobile(t):this.updateCrossTool(t):this.currentHover=null,this.fireDraw()})),this.addRxSubscription(this.baselineModel.dragPredicate.subscribe(t=>{if(Ot())if(t)this.hoverProducer.deactivate();else{const e=this.crossEventProducer.crossToolTouchInfo;e.isSet&&this.crossEventProducer.crossSubject.next([e.temp.x,e.temp.y,$]),this.hoverProducer.activate()}}))}fireDraw(){this.config.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateCrossTool(t,e=this.config.magnetTarget,s=this.config.discrete){var i;const r=s&&!this.shouldKeepXForMobileTouchCrosshair()?this.chartModel.toX((i=this.chartModel.candleFromX(t.x,!0).idx)!=null?i:0):t.x;if(this.currentHover===null?this.currentHover={x:r,y:0,time:t.timeFormatted,paneId:t.paneId}:(this.currentHover.x=r,this.currentHover.time=t.timeFormatted),t.candleHover&&t.paneId===$)switch(e){case"O":this.currentHover.y=t.candleHover.openY;break;case"C":this.currentHover.y=t.candleHover.closeY;break;case"H":this.currentHover.y=t.candleHover.highY;break;case"L":this.currentHover.y=t.candleHover.lowY;break;case"OHLC":this.currentHover.y=t.candleHover.closestOHLCY;break;case"none":this.currentHover.y=t.y;break}else this.currentHover.y=t.y;this.currentHover.paneId=t.paneId,this.currentHoverSubject.next(this.currentHover)}updateCrossToolMobile(t){var e;if(!this.hoverProducer.longTouchActivatedSubject.getValue())return;const{fixed:s,temp:i,isSet:r}=this.crossEventProducer.crossToolTouchInfo;if(!r){this.updateCrossTool(t);return}const o=this.crossEventProducer.crossToolHover;if(o&&t.x===o.x&&t.y===o.y){const E=fo(uo({},t),{x:o.x,y:o.y});this.crossEventProducer.crossToolHover=E,this.updateCrossTool(E);return}const a=this.canvasBoundsContainer.getBounds(M.PANE_UUID(t.paneId)),l=5,c=t.x-i.x,h=t.y-i.y,d=s.x+c,u=s.y+h,f=a.y+l,p=a.y+a.height-l,m=d<l?l:d>a.width-l?a.width-l:d,_=u<f?f:u>p?p:u,S=(e=this.hoverProducer.createHover(m,_,t.paneId))!=null?e:t,A=fo(uo({},S),{x:m,y:_});this.crossEventProducer.crossToolHover=A,this.updateCrossTool(A)}}const Rt=4;function Eu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p;const m=r.align,_=(l=i.textFont)!=null?l:oe(r),S=i.bgColor,A=(c=i.textColor)!=null?c:re(S,o.labelTextColor,o.labelInvertedTextColor),E=(h=i.paddingTop)!=null?h:Rt,j=(d=i.paddingBottom)!=null?d:Rt,B=(u=i.paddingEnd)!=null?u:Rt,R=Ee(Xt(_,n)/2),k=s-R-E,X=s+R+j-k;if(a&&!vs(s,t,X))return;n.save(),n.fillStyle=S,n.strokeStyle=S;const G=Ee(t.width/6),Z=m==="right"?t.x:t.x+t.width,U=m==="right"?Z+G:Z-G,Q=r.labelBoxMargin.end,J=Q-B,tt=t.width-G-J;hd(n,U,k,Z,k+Ee(X/2),U,k+X,tt,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,m),n.fillStyle=A,n.font=_;const et=m==="right"?t.x+t.width-Mt(e,n,_)-Q:t.x+Q;n.fillText(e,et,s+R-1),n.restore()}function Iu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_,S,A;const E=r.align,j=(l=i.textFont)!=null?l:oe(r),B=i.bgColor,R=(c=i.textColor)!=null?c:re(B,o.labelTextColor,o.labelInvertedTextColor),k=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,z=(u=(d=i.paddingTop)!=null?d:k==null?void 0:k.top)!=null?u:Rt,X=(p=(f=i.paddingBottom)!=null?f:k==null?void 0:k.bottom)!=null?p:Rt,G=(_=(m=i.paddingEnd)!=null?m:k==null?void 0:k.end)!=null?_:Rt,Z=i.paddingStart,U=Xt(j,n),Q=s-U/2-z,tt=s+U/2+X-Q,et=(A=i.rounded)!=null?A:(S=r.typeConfig.rectangle)==null?void 0:S.rounded;if(a&&!vs(s,t,tt))return;n.save(),n.fillStyle=B,n.strokeStyle=B;const st=r.labelBoxMargin.end;n.font=j;const ot=Mt(e,n,j),at=st-G,xt=Z!==void 0?ot+Z+G:t.width-at,Zt=E==="right"?t.x+t.width-at-xt:t.x+at,Pe=E==="right"?t.x+t.width-ot-st:st;et?Hr(n,Zt,Q,xt,tt,4,!0):n.fillRect(Zt,Q,xt,tt),n.fillStyle=R,n.fillText(e,Pe,s+U/2-1),n.restore()}function Du(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_;const S=r.align,A=(l=i.textFont)!=null?l:oe(r),E=o.backgroundColor,j=(c=i.textColor)!=null?c:re(E,o.labelTextColor,o.labelInvertedTextColor),B=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,R=(u=(d=i.paddingTop)!=null?d:B==null?void 0:B.top)!=null?u:Rt,k=(p=(f=i.paddingBottom)!=null?f:B==null?void 0:B.bottom)!=null?p:Rt,z=(_=(m=i.paddingEnd)!=null?m:B==null?void 0:B.end)!=null?_:Rt,X=i.paddingStart,G=Xt(A,n),Z=s-G/2-R,Q=s+G/2+k-Z;if(a&&!vs(s,t,Q))return;n.save(),n.fillStyle=E,n.strokeStyle=E;const J=r.labelBoxMargin.end;n.font=A;const tt=Mt(e,n,A),et=J-z,st=X!==void 0?tt+X+z:t.width-et,ot=S==="right"?t.x+t.width-et-st:t.x+et,at=S==="right"?t.x+t.width-tt-J:J;n.fillStyle=E,n.strokeStyle=E,n.fillRect(ot,Z,st,Q),n.fillStyle=j,n.fillText(e,at,s+G/2-1),n.restore()}function Lu(n,t,e=Rt){return Xt(n,t)/2+e}function vs(n,t,e){return!(n<t.y+e/2||n>t.y+t.height-e/2)}const Ou="badge",po=4,go={badge:Eu,rectangle:Iu,plain:Du};function mo(n,t,e,s,i,r,o,a,l){var c,h,d,u,f;const p=r.y,m=r.labelText,_=(c=r.mode)!=null?c:"label",S=(h=r.labelType)!=null?h:Ou,A=r.description,E=(d=r.textFont)!=null?d:oe(a),j=r.bgColor,B=(u=r.lineColor)!=null?u:j,R=Mt(A!=null?A:"",n,E)+8,k=rt(r.y),z=Xt(E,n),X=p-z/2,Z=p+z/2-X;n.save(),n.fillStyle=j,n.strokeStyle=B;const U=o.getBounds(M.PANE_UUID($)),Q=go[S],J=a.labels.descriptions,tt=Bu(s,k,Z),et=()=>J&&Ru(e,t,s,i,r,a);let st,ot;const at=2;a.align==="right"?(st=U.x,ot=J?U.x+U.width-R:U.x+U.width+at):(st=J?U.x+R:U.x-at,ot=U.x+U.width);const xt=(f=r.lineY)!=null?f:r.y,Zt=()=>tt&&he(n,()=>{var Ms;return dd(n,st,xt,ot,xt,1,(Ms=r.lineDash)!=null?Ms:[],r.lineCap)}),Pe=()=>Q(n,s,es(m),p,r,a,l.yAxis,!1),Ts={line:()=>{Zt(),et()},"line-label":()=>{Zt(),Pe(),et()},label:()=>{et(),Pe()}};_!=="none"&&vs(p,s,Z)&&Ts[_](),n.restore()}const Bu=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Ru(n,t,e,s,i,r){var o,a,l;const c=r.align||"right",h=i.description;if(!h||h.length===0)return;const d=i.y,u=oe(r),f=Mt(h,t,u),p=Xt(u,t),m=(o=i.paddingTop)!=null?o:po,_=(a=i.paddingBottom)!=null?a:po,S=d-p/2-m,E=d+p/2+_-S;t.save();const j=f+5,B=4,R=f+B*2,k=s.x+s.width,z=c==="right"?k-R:s.x+B;Eh(n,t,z,S,j,E,.8),t.fillStyle=(l=i.descColor)!=null?l:i.bgColor,t.font=u;const X=c==="right"?k-f-B*2:s.x+B*2;t.fillText(h,X,d+p/2-1),t.restore()}class vo{constructor(t,e,s,i=()=>!0,r){this.config=t,this.canvasBoundsContainer=e,this.paneManager=s,this.crossDrawPredicate=i,this.noLines=r}draw(t,e){this.crossDrawPredicate()&&he(t,()=>this.drawCrossTool(t,e))}drawCrossTool(t,e){var s,i,r,o,a;const l=this.canvasBoundsContainer.getBounds(M.ALL_PANES),c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES,{extensionY:1e-4}),h=(s=this.config.components.xAxis.padding.top)!=null?s:0,d=(r=this.config.components.yAxis.typeConfig[(i=this.config.components.crossTool.yLabel.type)!=null?i:"badge"])==null?void 0:r.paddings,u=(o=d==null?void 0:d.start)!=null?o:0,f=(a=this.paneManager.panes[e.paneId])==null?void 0:a.ht;if(c(e.x,l.y)){const p={start:[l.x,e.y],end:[l.x+l.width+u,e.y]},m={start:[e.x,l.y],end:[e.x,l.y+l.height+h]},_=f==null?void 0:f(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),_&&(t.moveTo(...p.start),t.lineTo(...p.end)),t.moveTo(...m.start),t.lineTo(...m.end),t.stroke()),_&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,i,r,o,a;const l=this.config.components.crossTool.xLabel.padding,c=this.config.components.crossTool.xLabel.margin,h=this.config.colors.crossTool;if(this.config.components.xAxis.visible){t.font=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily;const d=e.x,u=e.time,f=t.measureText(u).width,p=this.config.components.xAxis.fontSize,m=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const _=(s=l==null?void 0:l.left)!=null?s:0,S=(i=l==null?void 0:l.right)!=null?i:0,A=(r=l==null?void 0:l.top)!=null?r:0,E=(o=l==null?void 0:l.bottom)!=null?o:0,j=(a=c==null?void 0:c.top)!=null?a:0,B=f+_+S,R=p+A+E,k=Math.max(d-B/2,0),z=m.y+j+Oe/2;Hr(t,k,z,B,R),t.fillStyle=h.labelTextColor;const X=Math.max(d-f/2,_),G=m.y+j+p+Oe/2+A-1;t.fillText(u,X,G),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,i=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const r=this.paneManager.panes[e.paneId],o=e.y,a=this.config.components.crossTool.yLabel.type;if(!r)return;for(const l of r.yExtentComponents){const c=l.regularValueFromY(o),h=l.valueFormatter(c,{formatWithSeparators:!0}),d=this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=go[a],f=a==="plain"?i.lineColor:i.labelTextColor;u(t,d,h,o,{textColor:f,bgColor:i.labelBoxColor,paddingBottom:s==null?void 0:s.bottom,paddingEnd:s==null?void 0:s.end,paddingTop:s==null?void 0:s.top},l.yAxis.state,this.config.colors.yAxis,!0)}}}}class Fu{draw(){}}class Hu extends W{constructor(t,e,s,i,r,o,a,l,c){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=i,this.paneManager=r,this.crossEventProducer=o,this.hoverProducer=a,this.baselineModel=l,this.chartModel=c,this.crossToolTypeDrawers={},this.model=new Au(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel,this.chartModel),this.addChildEntity(this.model);const h=new Se(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const d=new Su(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),u=new hn;u.addDrawer(h,"CLEAR_CANVAS"),u.addDrawer(d,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(u,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new vo(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new vo(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Fu)}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 ku{constructor(t,e){this.dynamicObjectsModel=t,this.canvasModel=e}draw(){const t=this.dynamicObjectsModel.objects;Object.entries(t).forEach(([e,s])=>{for(const i of s){const{model:r,drawer:o}=i;o.draw(this.canvasModel,r,e)}})}getCanvasIds(){return[this.canvasModel.canvasId]}}class zt{constructor(t){this.data=t,this.next=null}}class ju{constructor(t){if(this._head=null,this._tail=null,this.length=0,this._head=t!=null?t:null,this.head!==null){let e=this.head;for(;e.next;)e=e.next;this._tail=e,this.length++}}insertAtEnd(t){const e=new zt(t);if(this.head===null)this._head=e;else{let s=this.head;for(;s.next;)s=s.next;s.next=e}this._tail=e,this.length++}insertAt(t,e){if(!this.head||t<0||t>this.length)return null;const s=new zt(e);if(t===0)s.next=this.head,this._head=s;else{let i=this.head,r=i,o=0;for(;i&&o<t;)o++,r=i,i=i.next;s.next=i,r.next=s,t===this.length-1&&(this._tail=s)}this.length++}removeAt(t){if(!this.head||t<0||t>=this.length)return null;let e=this.head,s=e,i=0;if(t===0)this._head=e.next;else{for(;e.next&&i<t;)i++,s=e,e=e.next;s.next=e.next,t===this.length-1&&(this._tail=s)}this.length--}getNodePosition(t){let e=0,s=this.head;for(;s;){if(s.data===t.data)return e;s=s.next,e++}return-1}size(){return this.length}get head(){return this._head}get tail(){return this._tail}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.data,t=t.next}}class Yu extends W{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this.orderChangedSubject=new F,this._objects=new ft({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new zt(s);return i.getNodePosition(r)}addObject(t){var e,s;const i=t.paneId,r=this.objects,o=(e=r[i])!=null?e:new ju;Object.keys(r).find(a=>a===i)||(r[i]=o),o.insertAtEnd(t),this.modelIdToObjectMap.set(t.id,t),this.uniqueObjects[i]||(this.uniqueObjects[i]=new Set),this.uniqueObjects[i].add((s=t.parentId)!=null?s:t.id),this.setDynamicObjects(r)}removeObject(t){var e;const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new zt(i),a=r.getNodePosition(o);r.removeAt(a),this.modelIdToObjectMap.delete(t),this.uniqueObjects[i.paneId]&&this.uniqueObjects[i.paneId].delete((e=i.parentId)!=null?e:i.id),r.size()===0&&delete this.objects[i.paneId],this.setDynamicObjects(this.objects)}updateObject(t){const e=this.getObjectInfoById(t.id);if(!e)return;const[s]=e;this.removeObject(s.id),this.addObject(t)}moveToPosition(t,e){const s=this.getObjectInfoById(t);if(!s)return;const[i,r]=s,o=new zt(i),a=r.getNodePosition(o);a!==e&&(a<e?(r.insertAt(e,i),r.removeAt(a)):(r.removeAt(a),r.insertAt(e,i)),this.setDynamicObjects(this.objects))}getPaneObjectIds(t){const e=this.objects[t];return e?[...e].map(s=>s.id):[]}setPaneOrder(t,e,s=!0){if(!this.objects[t]||e.length===0)return;const r=this.getPaneObjectIds(t),o=e.filter(c=>r.includes(c)),a=r.filter(c=>!o.includes(c)),l=[...o,...a];for(let c=0;c<l.length;c++){const h=l[c],d=this.getObjectPosition(h);d>=0&&d!==c&&this.moveToPosition(h,c)}s&&this.notifyOrderChanged()}reorderObjectIds(t,e,s=!0){const i=new Set(e),r=this.getPaneObjectIds(t).filter(o=>i.has(o));if(r.length!==0){for(const o of e)r.includes(o)&&this.moveObjectToFront(o);s&&this.notifyOrderChanged()}}notifyOrderChanged(){this.orderChangedSubject.next()}moveObjectToFront(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>=0&&o<i.size()&&(i.removeAt(o),i.insertAtEnd(s),this.setDynamicObjects(this.objects))}bringToFront(t){this.moveObjectToFront(t),this.notifyOrderChanged()}bringToBack(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>0&&o<=i.size()&&(i.removeAt(o),i.insertAt(0,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}moveForward(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>=0&&o+1<i.size()&&(i.removeAt(o),i.insertAt(o+1,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}moveBackwards(t){const e=this.getObjectInfoById(t);if(!e)return;const[s,i]=e,r=new zt(s),o=i.getNodePosition(r);o>0&&o<i.size()&&(i.removeAt(o),i.insertAt(o-1,s),this.setDynamicObjects(this.objects),this.notifyOrderChanged())}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Nu extends W{constructor(t,e){super();const s=new Yu(t);this.model=s,this.addChildEntity(s);const i=new ku(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Xu=()=>n=>n.toString(),Wu=(n,t)=>{var e;const s="date.get"+(t((e=n.timezone)!=null?e:"")?"":"UTC"),i={YYYY:r("FullYear"),YY:r("FullYear")+" % 100",MMM:o("shortMonths","Month"),MMMM:a(o("shortMonths","Month")),M:"1+"+r("Month"),d:r("Date"),H:r("Hours"),m:r("Minutes"),s:r("Seconds"),sss:r("Milliseconds"),EEE:o("shortDays","Day"),SSS:"this.addTwoZeros("+r("Milliseconds")+")",T:"date.getTime()"};["s","m","H","d","M"].forEach(function(l){i[l+l]="this.addZero("+i[l]+")"});function r(l){return s+l+"()"}function o(l,c){return"this."+l+"["+r(c)+"]"}function a(l){return l+".toUpperCase()"}return function(l){var c;const h={shortDays:Vu(n),shortMonths:zu(n),addZero(d){return d<10?"0"+d:d},addTwoZeros(d){return(d<100?"0":"")+(d<10?"0":"")+d},tzDate:t((c=n.timezone)!=null?c:"")||function(d){return new Date(+d)}};return d=>Uu(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function Vu(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function zu(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const bo=(n,t,e)=>{if(n){if(typeof n=="string")return e(n);if(Array.isArray(n)){const s=n.filter(i=>{if(i.showWhen){const r=[];return i.showWhen.periodLessThen&&r.push(()=>{var o,a;return t<((a=(o=i.showWhen)==null?void 0:o.periodLessThen)!=null?a:0)}),i.showWhen.periodMoreThen&&r.push(()=>{var o,a;return t>=((a=(o=i.showWhen)==null?void 0:o.periodMoreThen)!=null?a:0)}),r.every(o=>o())}else return!0});if(s.length>0){const i=s[0];if(i.format)return e(i.format);if(i.customFormatter)return i.customFormatter}}}return Xu()},Uu=(n,t,e,s)=>{t||(t="M/d/yyyy");const i=n.getDate(),r=n.getMonth(),o=n.getFullYear(),a=n.getHours(),l=n.getMinutes(),c=n.getSeconds(),h=n.getMilliseconds(),d=a%12,u=xe(d),f=xe(a),p=xe(l),m=xe(c),_=a<12?"AM":"PM",S=e[n.getDay()],A=S.substring(0,3),E=xe(i),j=r+1,B=xe(j),R=s[r],k=R.substring(0,3),z=o+"",X=z.substring(2,4);return t=t.replace("hh",u+"").replace("h",d+"").replace("HH",f+"").replace("H",a+"").replace("mm",p+"").replace("m",l+"").replace("ss",m+"").replace("s",c+"").replace("S",h+"").replace("dd",E+"").replace("d",i+"").replace("EEEE",S).replace("EEE",A).replace("YYYY",z).replace("yyyy",z).replace("YY",X).replace("yy",X).replace("aaa",_),t.indexOf("MMM")>-1?t=t.replace("MMMM",R).replace("MMM",k):t=t.replace("MM",B+"").replace("M",j+""),t},xe=n=>typeof n=="number"&&n<10?"0"+n:n,Ne=(n,t)=>`${n}_${t}`,Gu=(n,t)=>{if(t){const e=Co(t.normal),s=Co(t.hover);return{type:n,normal:e,hover:s}}},Co=n=>{var t;const s=new DOMParser().parseFromString(n,"text/html").querySelector("svg");let i=0;s&&(i=parseInt((t=s.getAttribute("height"))!=null?t:"",10));const a="data:image/svg+xml;base64,"+btoa(n),l=new Image;return l.src=a,{img:l,svgHeight:i}},Zu=(n,t,e,s,i)=>{if(i){const r=t[Ne(s,"hover")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}else{const r=t[Ne(s,"normal")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}},$u={"rhombus-small":4,rhombus:6,"rhombus-large":8},Ku=["earnings","dividends","splits","conference-calls"];class qu{constructor(t,e,s,i,r,o){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.formatterProvider=o,this.customIcons={};const a=this.config.components.events.icons;a&&Ku.forEach(l=>{const c=Gu(l,a[l]);c&&(this.customIcons[Ne(c.type,"normal")]=c.normal,this.customIcons[Ne(c.type,"hover")]=c.hover)})}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(M.EVENTS),e=this.canvasBoundsContainer.getBounds(M.ALL_PANES),s=this.canvasModel.ctx;s.save(),this.model.events.filter(i=>this.config.components.events.eventsVisibility[i.type]).forEach(i=>{var r,o,a,l;const c=this.chartModel.candleFromTimestamp(i.timestamp).xCenter(this.chartModel.scale);if(c>e.x&&c<e.x+e.width){const h=this.config.colors.events[i.type];if(s.strokeStyle=(o=(r=h.line)!=null?r:h.normal)!=null?o:h.color,this.customIcons[Ne(i.type,"hover")]!==void 0){const d={x:c,y:t.y+t.height/2},u=this.model.hoveredEvent.getValue()===i;Zu(s,this.customIcons,d,i.type,u)}else this.drawDefaultEvent(s,c,t,i,h);if(this.model.hoveredEvent.getValue()===i){const d=this.config.components.events.line,u=d&&d[i.type]&&((a=d[i.type])==null?void 0:a.width),f=d&&d[i.type]&&((l=d[i.type])==null?void 0:l.dash);s.lineWidth=u!=null?u:1,s.beginPath(),s.setLineDash(f!=null?f:[]),s.moveTo(c,e.y),s.lineTo(c,t.y+t.height/2),s.stroke(),s.closePath(),this.config.components.xAxis.visible&&this.drawLabel(c,i)}}}),s.restore()}drawDefaultEvent(t,e,s,i,r){var o,a,l;const c=s.y+s.height/2;t.fillStyle=(o=r.normal)!=null?o:r.color,t.lineWidth=1.5;const h=dn(i);t.beginPath(),t.moveTo(e-h,c),t.lineTo(e,c-h),t.lineTo(e+h,c),t.lineTo(e,c+h),t.closePath(),this.model.hoveredEvent.getValue()===i?(t.fillStyle=(a=r.hover)!=null?a:r.color,t.fill()):(t.strokeStyle=(l=r.normal)!=null?l:r.color,t.stroke())}drawLabel(t,e){var s;const i=this.canvasModel.ctx,r=this.canvasBoundsContainer.getBounds(M.X_AXIS),o=this.config.components.xAxis.fontFamily,a=this.config.components.xAxis.fontSize,l=(s=this.config.components.xAxis.padding.top)!=null?s:0,c=r.y+a-1+l;i.font=`${a}px ${o}`;const h=this.formatterProvider()(e.timestamp),d=i.measureText(h).width;i.fillStyle=this.config.colors.xAxis.backgroundColor,i.strokeStyle=this.config.colors.xAxis.backgroundColor,i.fillRect(t-d/2,r.y+1,d,r.height-1),i.fillStyle=this.config.colors.events[e.type].color,i.fillText(h,t-d/2,c)}getCanvasIds(){return[this.canvasModel.canvasId]}}function dn(n){return $u[n.style]}const bs=5;class Ju{constructor(t,e,s,i,r,o=()=>!0){this.hitTestCanvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i,this.model=r,this.drawPredicate=o}draw(){if(this.drawPredicate()){const t=this.hitTestCanvasModel.ctx,e=this.canvasBoundsContainer.getBounds(M.EVENTS);t.save(),this.model.events.forEach((s,i)=>{if(!this.config.components.events.eventsVisibility[s.type])return;const o=this.model.events[i-1],a=o&&this.chartModel.candleFromTimestamp(o.timestamp).xCenter(this.chartModel.scale),l=this.chartModel.candleFromTimestamp(s.timestamp).xCenter(this.chartModel.scale);if(l>e.x&&l<e.x+e.width){const c=this.config.colors.events[s.type].color;t.strokeStyle=c,t.fillStyle=c;const h=dn(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+bs)*2;if(a!==void 0){const u=dn(o);if(this.config.components.events.eventsVisibility[o.type]&&a+u>l-d/2){const m=h*2+bs;t.fillRect(a+u,e.y,m,e.height)}else t.fillRect(l-h-bs,e.y,d,e.height)}else t.fillRect(l-h-bs,e.y,d,e.height)}}),t.restore()}}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var Qu=Object.defineProperty,yo=Object.getOwnPropertySymbols,tf=Object.prototype.hasOwnProperty,ef=Object.prototype.propertyIsEnumerable,wo=(n,t,e)=>t in n?Qu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,sf=(n,t)=>{for(var e in t||(t={}))tf.call(t,e)&&wo(n,e,t[e]);if(yo)for(var e of yo(t))ef.call(t,e)&&wo(n,e,t[e]);return n};const So=317,un={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999],CUSTOM_STUDY_LABELS:[16e3,19999]};class nf extends Vr{constructor(t,e,s,i,r,o,a,l){super(t,e,r,a,l,{willReadFrequently:!0,desynchronized:!0}),this.canvasInputListener=s,this.canvasBoundsContainer=i,this.hitTestSubscribers=[],this.eventsSubscriptions=[],this.hoverSubject=new F,this.touchStartSubject=new F,this.dblClickSubject=new F,this.rightClickSubject=new F,this.hitTestDrawersPredicateSubject=new ft(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,zr(this,o),e.style.visibility="hidden",this.enableUserControls()}enableUserControls(){if(this.eventsSubscriptions.length===0){const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),e=this.canvasInputListener.observeMouseMove().pipe(Et(100,Bt,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(ht(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=yt(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(ht(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=yt(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(ht(()=>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(ht(()=>sf({},this.canvasInputListener.currentPoint))).subscribe(c=>{this.eventHandler(c,"contextmenu")}),l=this.canvasInputListener.observeWheel(t).subscribe(c=>setTimeout(()=>this.eventHandler(c,"zoom"),0));this.eventsSubscriptions.push(e,i,o,a,l,s,r)}}disableUserControls(){this.eventsSubscriptions.forEach(t=>t.unsubscribe()),this.eventsSubscriptions=[]}addSubscriber(t){this.hitTestSubscribers.push(t)}removeSubscriber(t){this.hitTestSubscribers=this.hitTestSubscribers.filter(e=>e===t)}idToColor(t){const e=(t*So).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/So}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!==Ys&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=Ys),this.curImgData}resolveModel(t){const e=this.getPixel(t.x,t.y),s=this.colorToId(e[0]*65536+e[1]*256+e[2]),i=Number(s),[r]=fn(this.hitTestSubscribers,i);return r==null?void 0:r.lookup(s)}resolveCursor(t){var e;if(!this.hitTestSubscribers.some(l=>l.resolveCursor!==void 0))return;const s=this.getPixel(t.x,t.y),i=this.colorToId(s[0]*65536+s[1]*256+s[2]),r=Number(i),[o]=fn(this.hitTestSubscribers,r),a=o==null?void 0:o.lookup(i);return(e=o==null?void 0:o.resolveCursor)==null?void 0:e.call(o,t,a)}eventHandler(t,e){var s,i,r,o,a,l,c;const h=this.getPixel(t.x,t.y),d=this.colorToId(h[0]*65536+h[1]*256+h[2]),u=Number(d),[f,p]=fn(this.hitTestSubscribers,u),m=f==null?void 0:f.lookup(d),_={point:t,model:m};switch(e){case"mousedown":m&&((s=f==null?void 0:f.onMouseDown)==null||s.call(f,m,t)),p.forEach(S=>S.onMouseDown&&S.onMouseDown(null,t));break;case"mouseup":m&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,m,t)),p.forEach(S=>S.onMouseUp&&S.onMouseUp(null,t));break;case"hover":m&&((r=f==null?void 0:f.onHover)==null||r.call(f,m,t)),p.forEach(S=>S.onHover&&S.onHover(null,t)),this.hoverSubject.next(_);break;case"touchstart":m&&((o=f==null?void 0:f.onTouchStart)==null||o.call(f,m,t)),p.forEach(S=>S.onTouchStart&&S.onTouchStart(null,t)),this.touchStartSubject.next(_);break;case"dblclick":m&&((a=f==null?void 0:f.onDblClick)==null||a.call(f,m,t)),this.dblClickSubject.next(_);break;case"contextmenu":m&&((l=f==null?void 0:f.onRightClick)==null||l.call(f,m,t)),this.rightClickSubject.next(_);break;case"zoom":m&&((c=f==null?void 0:f.onZoom)==null||c.call(f,m,t)),p.forEach(S=>S.onZoom&&S.onZoom(null,t));break;default:break}}}const fn=(n,t)=>{let e;const s=[];return n.forEach(i=>{const[r,o]=i.getIdRange();t>=r&&t<=o?e=i:s.push(i)}),[e,s]};var rf=Object.defineProperty,of=Object.defineProperties,af=Object.getOwnPropertyDescriptors,xo=Object.getOwnPropertySymbols,lf=Object.prototype.hasOwnProperty,cf=Object.prototype.propertyIsEnumerable,_o=(n,t,e)=>t in n?rf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hf=(n,t)=>{for(var e in t||(t={}))lf.call(t,e)&&_o(n,e,t[e]);if(xo)for(var e of xo(t))cf.call(t,e)&&_o(n,e,t[e]);return n},df=(n,t)=>of(n,af(t));class uf extends W{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ft(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>df(hf({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return un.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 ff extends W{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>bo(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new uf(e);this.eventsModel=c,this.addChildEntity(c),s.addSubscriber(c);const h=new qu(e,i,t,r,c,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(h,"EVENTS");const d=new Ju(s,i,t,r,c,()=>s.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(d,"HIT_TEST_EVENTS","HIT_TEST_DRAWINGS"),l.setCursorForCanvasEl(M.EVENTS,t.components.events.cursor)}setEvents(t){this.eventsModel.setEvents(t),this.canvasModel.fireDraw()}setVisible(t){this.config.components.events.visible=t,this.canvasBoundsContainer.recalculateBounds(),this.canvasModel.fireDraw()}setEventTypeVisible(t){At(this.config.components.events.eventsVisibility,t,{overrideExisting:!0,addIfMissing:!1}),this.canvasModel.fireDraw()}observeEventHovered(){return this.eventsModel.hoveredEvent.asObservable()}}class pf{constructor(t,e,s,i,r,o,a,l,c=()=>!0,h,d,u){this.canvasModel=t,this.viewportModel=e,this.config=s,this.yAxisState=i,this.xBoundsProvider=r,this.yBoundsProvider=o,this.xLabelsProvider=a,this.yLabelsProvider=l,this.drawPredicate=c,this.extentIdx=h,this.getBaseline=d,this.mainExtentIdx=u}draw(){if(this.drawPredicate()){const t=this.canvasModel.ctx;he(t,()=>this.drawVertical(t)),he(t,()=>this.drawHorizontal(t)),he(t,()=>this.drawZeroLine(t))}}drawZeroLine(t){const e=this.yLabelsProvider();if(this.extentIdx===0&&this.getBaseline&&this.yAxisState.type==="percent"&&this.yAxisState.zeroPercentLine&&e.length){const s=this.xBoundsProvider(),i=rt(this.getBaseline());t.beginPath(),t.strokeStyle=this.config.colors.yAxis.zeroPercentLine,t.setLineDash([]),t.moveTo(s.x,i),t.lineTo(s.x+s.width,i),t.stroke(),t.closePath()}}drawVertical(t){const e=this.xLabelsProvider();if(e.length&&this.config.components.grid.vertical){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.xBoundsProvider(),i=s.x+s.width;for(const r of e){const o=It(this.viewportModel.toX(r.value));o>s.x&&o<i&&(t.beginPath(),t.moveTo(o,s.y),t.lineTo(o,s.y+s.height),t.stroke())}}}drawHorizontal(t){const e=this.yLabelsProvider();if(e.length>0&&this.config.components.grid.horizontal&&this.extentIdx===this.mainExtentIdx){t.lineWidth=this.config.components.grid.width,t.strokeStyle=this.config.colors.chartAreaTheme.gridColor,t.setLineDash(this.config.components.grid.dash||[]);const s=this.yBoundsProvider();for(const i of e){const r=rt(this.viewportModel.toY(i.value)),o=Lu(i.text,t,Rt);r>s.y+o&&r<s.y+s.height-o&&(t.beginPath(),t.moveTo(s.x,r),t.lineTo(s.x+s.width,r),t.stroke())}}}getCanvasIds(){return[this.canvasModel.canvasId]}}class Po extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new pf(t,e,s,i,a,l,c,h,f,d,u,p)}doDeactivate(){super.doDeactivate(),this.drawingManager.removeDrawer(this.drawer)}doActivate(){super.doActivate(),this.drawingManager.addDrawer(this.drawer,this.drawerName)}}class gf{constructor(t,e,s,i){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+s,a=r+i,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,o,t,"high"),this.drawMarkerLabel(l,a,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,i){const r=this.getMarkerY(t,s,i==="low"),o=ss(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(s,i),c=this.getMarkerX(t,e,l);t.fillStyle=i==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(l,c,r);const h=this.canvasBoundsContainer.getBounds("PANE_CHART");Kt(t,h)}getMarkerText(t,e){const s=this.chartModel.pane.regularFormatter(t);return`${e==="high"?this.config.components.highLow.prefix.high:this.config.components.highLow.prefix.low} ${s}`}getMarkerY(t,e,s=!1){const i=this.chartModel.toY(e);if(s){const r=ss(t,!1);return i+r}return i}checkMarkerInBounds(t){const e=this.canvasBoundsContainer.getBounds(M.CHART);return t>e.y&&t<e.y+e.height}getMarkerX(t,e,s){let i=this.chartModel.toX(e);const r=this.canvasBoundsContainer.getBounds(M.CHART),o=4,a=t.measureText(s).width;return i+o+a>r.width&&(i=i-(o+a)),i+o}getCanvasIds(){return[this.canvasModel.canvasId]}}class mf extends W{constructor(t,e,s,i,r){super();const o=new gf(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const vf=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],bf=1440*60*1e3;class Cf extends W{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new F}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()+bf;Kl(this.highlights,t,e,yf).forEach(i=>{var r;this.visualHighlights[i.type]||(this.visualHighlights[i.type]=[]),(r=this.visualHighlights[i.type])==null||r.push(i)})}setHighlights(t){this.highlights=t,this.highlights.sort((e,s)=>e.to-s.to),this.highlightsUpdatedSubject.next(this.highlights),this.highlights.length?this.recalculateVisualHighlights():this.visualHighlights={}}observeHighlightsUpdated(){return this.highlightsUpdatedSubject.asObservable()}}const yf=n=>n.to,Jt=[20,10];class wf{constructor(t,e,s,i,r){this.highlightsModel=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.config=r}draw(){var t,e,s,i;if(this.config.components.highlights.visible){const r=this.chartModel.getCandles(),o=this.canvasModel.ctx,a=this.highlightsModel.getVisualHighlights();if(this.highlightsModel.getHighlights().length&&r.length!==0&&this.chartModel.scale.isScaleReady()){const c=this.canvasBoundsContainer.getBounds(M.ALL_PANES);o.save(),Kt(o,c);const h=(t=this.config.components.highlights.border.width)!=null?t:1,d=(e=this.config.components.highlights.border.dash)!=null?e:[0,0],u=(s=this.config.components.highlights.fontSize)!=null?s:11,f=(i=this.config.components.highlights.fontFamily)!=null?i:"monospace",p=`${u}px ${f}, monospace`;o.font=p,o.lineWidth=h,o.setLineDash(d),vf.forEach(m=>{var _,S;const A=a[m];if(A){const E=this.config.colors.highlights[m],j=(_=E==null?void 0:E.border)!=null?_:"#ffffff",B=(S=E==null?void 0:E.background)!=null?S:"#ffffff";o.save(),o.beginPath(),o.fillStyle=B,o.strokeStyle=j,A.forEach(R=>{var k,z,X;const G=this.chartModel.getCandleTimestampAnchor(),Z=this.chartModel.getCandles(),U=this.findCandleIndicesInHighlight(Z,R.from,R.to),Q=this.getHighlightBoundaryX(R.from,G),J=this.getHighlightBoundaryX(R.to,G);let tt=Q,et=J;if(R.border&&this.drawBorders(R.border,o,Q,J,c),U){const st=this.chartModel.candleFromIdx(U.startIdx),ot=this.chartModel.candleFromIdx(U.endIdx);tt=st.xStart(this.chartModel.scale);const at=vt(ot.width,this.chartModel.scale.zoomX);et=ot.xStart(this.chartModel.scale)+at,o.fillRect(tt,c.y,et-tt,c.y+c.height)}if(R.label){const st=(k=R.label.text)!=null?k:"",ot=this.config.colors.highlights[R.type];o.save(),o.fillStyle=(z=ot==null?void 0:ot.label)!=null?z:"#ffffff";const at=Mt(st,o,p),[xt,Zt]=this.resolveHighlightLabelPosition((X=R.label.placement)!=null?X:"left-left",c,[tt,et],at);o.fillText(st,xt,Zt),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}getHighlightBoundaryX(t,e){const s=this.chartModel.candleFromTimestamp(t,{extrapolate:!0}),i=vt(s.width,this.chartModel.scale.zoomX),r=s.xStart(this.chartModel.scale);return e==="close"||s.candle.timestamp<t?r+i:r}findCandleIndicesInHighlight(t,e,s){let i=-1,r=-1;for(let o=0;o<t.length;o++)this.isCandleTimestampInHighlight(t[o].timestamp,e,s)&&(i===-1&&(i=o),r=o);return i===-1?null:{startIdx:i,endIdx:r}}isCandleTimestampInHighlight(t,e,s){return e<=t&&t<s}resolveHighlightLabelPosition(t,e,s,i){const[r,o]=s;switch(t){case"right-left":return[o-Jt[1]-i,e.y+Jt[0]];case"left-left":return[r-Jt[1]-i,e.y+Jt[0]];case"right-right":return[o+Jt[1],e.y+Jt[0]];default:return[r+Jt[1],e.y+Jt[0]]}}drawBorders(t,e,s,i,r){const o=t.left,a=t.right;o&&(e.beginPath(),e.moveTo(s,r.y),e.lineTo(s,r.y+r.height),e.stroke(),e.closePath()),a&&(e.beginPath(),e.moveTo(i,r.y),e.lineTo(i,r.y+r.height),e.stroke(),e.closePath())}getCanvasIds(){return[this.canvasModel.canvasId]}}const Sf="HIGHLIGHTS_PLUGIN";class xf extends W{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new Cf(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new wf(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,Sf)}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 _f(){return N(function(n,t){var e,s=!1;n.subscribe(Ct(t,function(i){var r=e;e=i,s&&t.next([r,i]),s=!0}))})}function K(n,t){return N(function(e,s){var i=0;e.subscribe(Ct(s,function(r){return n.call(t,r,i++)&&s.next(r)}))})}var Pf=Object.defineProperty,Tf=Object.defineProperties,Mf=Object.getOwnPropertyDescriptors,To=Object.getOwnPropertySymbols,Af=Object.prototype.hasOwnProperty,Ef=Object.prototype.propertyIsEnumerable,Mo=(n,t,e)=>t in n?Pf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ao=(n,t)=>{for(var e in t||(t={}))Af.call(t,e)&&Mo(n,e,t[e]);if(To)for(var e of To(t))Ef.call(t,e)&&Mo(n,e,t[e]);return n},Eo=(n,t)=>Tf(n,Mf(t));const Ut=4;class If{constructor(t,e,s,i,r,o){this.config=t,this.chartModel=e,this.canvasModel=s,this.canvasBoundsContainer=i,this.formatterFactory=r,this.visualCandlesProvider=o}draw(){if(this.config.components.navigationMap.visible){const t=this.visualCandlesProvider();if(t.length){const e=this.canvasBoundsContainer.getBounds(M.N_MAP),s=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_L),i=this.canvasBoundsContainer.getBounds(M.N_MAP_BTN_R),r=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_L),o=this.canvasBoundsContainer.getBounds(M.N_MAP_KNOT_R),a=this.canvasBoundsContainer.getBounds(M.N_MAP_SLIDER_WINDOW),l=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),c=this.canvasModel.ctx;c.fillStyle=this.config.colors.navigationMap.backgroundColor,c.fillRect(e.x,e.y,e.width,e.height),c.strokeStyle=this.config.colors.paneResizer.lineColor,c.lineWidth=1,c.beginPath(),c.moveTo(e.x,e.y),c.lineTo(e.x+e.width,e.y),c.closePath(),c.stroke(),s.width!==0&&this.drawLeftArrowButton(c,s,this.config),i.width!==0&&this.drawRightArrowButton(c,i,this.config),c.fillStyle=this.config.colors.navigationMap.mapFillColor,c.beginPath(),c.moveTo(l.x,l.y+l.height);for(const h of t)c.lineTo(h[0],h[1]);if(c.lineTo(l.x+l.width,l.y+l.height),c.lineTo(l.x,l.y+l.height),c.closePath(),this.config.colors.navigationMap.mapGradientTopColor&&this.config.colors.navigationMap.mapGradientBottomColor){const h=c.createLinearGradient(l.x,l.y,l.x,l.y+l.height);h.addColorStop(0,this.config.colors.navigationMap.mapGradientTopColor),h.addColorStop(1,this.config.colors.navigationMap.mapGradientBottomColor),c.fillStyle=h}c.fill(),this.config.colors.navigationMap.mapColor&&(c.strokeStyle=this.config.colors.navigationMap.mapColor,c.stroke()),this.drawSlider(c,r,o,s,a),this.drawTimeLabels(c)}}}blockDrawSliderOnLeftArrow(t,e,s,i){t.x<=s.x+s.width&&(t.x=s.x+s.width,i.x=t.x+t.width,e.x=i.x+i.width)}drawSlider(t,e,s,i,r){this.blockDrawSliderOnLeftArrow(e,s,i,r),this.drawKnotButton(t,e,this.config,!0),this.drawKnotButton(t,s,this.config,!1),t.fillStyle=this.config.colors.navigationMap.sliderColor,t.fillRect(r.x,r.y,r.width,r.height)}drawLeftArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Ut/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r),t.lineTo(i+Ut,r+Ut),t.lineTo(i+Ut,r-Ut),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawRightArrowButton(t,e,s){t.fillStyle=s.colors.navigationMap.buttonColor,t.fillRect(e.x,e.y,e.width,e.height),t.beginPath();const i=Math.round(e.x+e.width/2-Ut/2),r=Math.round(e.y+e.height/2);t.moveTo(i,r-Ut),t.lineTo(i,r+Ut),t.lineTo(i+Ut,r),t.fillStyle=s.colors.navigationMap.buttonArrowColor,t.fill()}drawKnotButton(t,e,s,i){const r=s.components.navigationMap.knots.border;t.fillStyle=s.colors.navigationMap.knotColor;const o=i?e.x-r:e.x+r;t.fillRect(o,e.y,e.width,e.height),t.lineWidth=s.components.navigationMap.knots.lineWidth,r>0&&(t.beginPath(),t.moveTo(o,e.y),t.lineTo(o,e.y+e.height),t.lineTo(o+e.width,e.y+e.height),t.lineTo(o+e.width,e.y),t.lineTo(o,e.y),t.lineWidth=r,t.strokeStyle=s.colors.navigationMap.knotBorderColor,t.stroke()),t.beginPath(),t.moveTo(o+e.width/2,e.y+e.height/4),t.lineTo(o+e.width/2,e.y+3*e.height/4),t.strokeStyle=s.colors.navigationMap.knotLineColor,t.stroke()}drawTimeLabels(t){const e=mt(this.chartModel.mainCandleSeries.getSeriesInViewport()),s=this.config.components.navigationMap.timeLabels,i=s.visible;if(e.length&&i){const r=e[0].candle.timestamp,o=e[e.length-1].candle.timestamp,a=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_L),l=this.canvasBoundsContainer.getBounds(M.N_MAP_LABEL_R),h={textFill:this.config.colors.navigationMap.timeLabelsTextColor,textFontFamily:s.fontFamily,textSize:`${s.fontSize}px`},d={dateFormat:s.dateFormat,padding:s.padding,textProperties:Eo(Ao({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:Eo(Ao({},h),{textAlign:"right"})};this.drawTimeLabel(t,a,r,d),this.drawTimeLabel(t,l,o,u)}}drawTimeLabel(t,e,s,i){const r=i.padding,o=Pi(s,i.dateFormat,this.formatterFactory);yi(t,i.textProperties);const a=ss(t),l=Si(o);Jl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}function Io(n,t){return N(function(e,s){var i=null,r=0,o=!1,a=function(){return o&&!i&&s.complete()};e.subscribe(Ct(s,function(l){i==null||i.unsubscribe();var c=0,h=r++;Lt(n(l,h)).subscribe(i=Ct(s,function(d){return s.next(t?t(l,d,h,c++):d)},function(){i=null,a()}))},function(){o=!0,a()}))})}class Xe extends Zr{constructor(t,e,s,i,r=Gr,o){super(t,e,s,i,r),this.shouldThrottleSubject=new ft(!!o)}setShouldThrottle(t){this.shouldThrottleSubject.next(t)}doActivate(){const t=Vt;super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeXDragStart(this.hitTest).subscribe(this.onDragStart)),this.addRxSubscription(this.shouldThrottleSubject.pipe(gt(),Io(e=>this.canvasInputListener.observeXDrag().pipe(e?Et(t,Bt,{trailing:!0,leading:!0}):ne))).subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const Do=4;class Df extends W{constructor(t,e,s,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.leftKnotDragStartXRelative=f.x-p.x-Do},this.leftKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,S=(this.leftKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.leftRatio=S,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.rightKnotDragStartXRelative=f.x-p.x+Do},this.rightKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,S=(this.rightKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.rightRatio=S,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=f=>{const{delta:p}=f,m=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),_=this.chartModel.mainCandleSeries.meanCandleWidth/(m.width/this.chartModel.mainCandleSeries.dataPoints.length),S=(this.lastMousePosition-p)*_;this.scale.moveXStart(this.scale.xStart-S),this.lastMousePosition=p};const a=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_R),c=new Xe(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Xe(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_SLIDER_WINDOW),u=new Xe(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_L);this.addRxSubscription(this.canvasInputListeners.observeClick(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(t).subscribe(()=>{this.scale.moveXStart(this.scale.xStart-1)}));const e=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_BTN_R);this.addRxSubscription(this.canvasInputListeners.observeClick(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.canvasInputListeners.observeTouchStart(e).subscribe(()=>{this.scale.moveXStart(this.scale.xStart+1)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>{const s=this.chartModel.mainCandleSeries;this.canvasBoundsContainer.leftRatio=s.dataIdxStart/(s.dataPoints.length-1),this.canvasBoundsContainer.rightRatio=s.dataIdxEnd/(s.dataPoints.length-1),this.canvasBoundsContainer.recalculateNavigationMapElementBounds(),this.bus.fireDraw()}))}}class Lf extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new If(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,M.N_MAP_CHART),this.navigationMapMoveHandler=new Df(this.eventBus,this.chartModel,this.chartModel.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.chartPanComponent),h.setCursorForCanvasEl(M.N_MAP_CHART,i.components.navigationMap.cursors.chart),h.setCursorForCanvasEl(M.N_MAP_BTN_L,i.components.navigationMap.cursors.buttonLeft),h.setCursorForCanvasEl(M.N_MAP_BTN_R,i.components.navigationMap.cursors.buttonRight),h.setCursorForCanvasEl(M.N_MAP_KNOT_L,i.components.navigationMap.cursors.leftResizer),h.setCursorForCanvasEl(M.N_MAP_KNOT_R,i.components.navigationMap.cursors.rightResizer),h.setCursorForCanvasEl(M.N_MAP_SLIDER_WINDOW,i.components.navigationMap.cursors.slider)}doActivate(){super.doActivate(),this.addRxSubscription(yt(this.chartModel.observeCandlesChanged(),this.canvasBoundsContainer.observeBoundsChanged(M.N_MAP),this.chartModel.scale.xChanged.pipe(_f(),K(([t,e])=>{const i=t.start<0||t.end>0,r=e.start<0||e.end>0;return i&&!r||r}))).subscribe(()=>{this.config.components.navigationMap.visible&&(this.visualCandles=this.makeVisualCandles(),this.canvasModel.fireDraw())}))}makeVisualCandles(){var t;const e=this.chartModel.getCandles();if(!e.length)return[];const s=this.chartModel.mainCandleSeries.dataIdxStart,i=this.chartModel.mainCandleSeries.dataIdxEnd,r=Math.round(Math.max(-s,0)),o=Math.max(this.chartModel.getCandlesCountWithRightOffset(),i)+r;let a=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY;const c=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),h=c.width,d=[];let u=0,f,p;for(f=0;f<h;f++)p=rt(f*o/h)-r,p in e?(d[f]=e[p].close,u=(t=d[f])!=null?t:0,a=Math.max(a,u),l=Math.min(l,u)):d[f]=0;return a-=l,d.map((m,_)=>[_+c.x,(a+l-m)*c.height/a+c.y])}setVisible(t=!0){var e;(e=this.config.components)!=null&&e.navigationMap&&(this.config.components.navigationMap.visible=t,this.eventBus.fire(us),this.canvasModel.fireDraw())}}const Cs=()=>{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"},Sv=(n,t)=>n==="apple"||n==="mobile"?3:t;var pn=Math.pow;class Lo extends W{constructor(t,e,s,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=Vt,this.chartPanningOptions={horizontal:!0,vertical:!0},this.zoomXHandler=(h,d)=>{const u=h.deltaY<0;if(this.config.scale.zoomToCursor){const p=this.canvasBoundsContainer.getBounds(M.CANVAS).width,_=h.offsetX/p;this.scale.zoomXToPercent(_,u,!1,d)}else this.scale.zoomXToEnd(u,d);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(me),this.xDraggedCandlesDelta=0,this.lastXStart=this.scale.xStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=h=>{const{delta:d}=h;this.currentPoint.x=d;const u=kt(d,this.scale.zoomX);this.scale.moveXStart(this.lastXStart-u),this.bus.fireDraw()},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)};const c=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.dragNDropXComponent=new Xe(c,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.horizontal},this.config.components.yAxis.type==="percent"),this.addChildEntity(this.dragNDropXComponent)}setChartAreaXDragThrottled(t){this.dragNDropXComponent.setShouldThrottle(t)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeWheel(t).pipe(K(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),Et(this.wheelThrottleTime,Bt,{trailing:!0,leading:!0})).subscribe(e=>{const s=Cs(),i=s==="apple"||s==="mobile"?-1:1,r=0+e.deltaX*i,o=0+e.deltaY*i;if(e.ctrlKey){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw();return}if(o!==0&&Math.abs(o)>Math.abs(r)){const a=this.calculateDynamicSesitivity(e,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(e,a),this.bus.fireDraw()}if(r!==0&&Math.abs(r)>Math.abs(o)){const a=kt(r,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-a),this.bus.fireDraw();return}})),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:e})=>{this.lastXStart+=e}))}calculateDynamicSesitivity(t,e){const i=Math.max(Math.abs(t.deltaY),Math.abs(t.deltaX)),r=e*i/100;return Ll(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(me),this.currentPoint={x:0,y:0},s=t.yStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},r=l=>{const{delta:c}=l;if(this.currentPoint.y=c,t.state.auto)Of(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const h=kt(t.state.inverse?-c:c,t.zoomY);t.moveYStart(s+h)}},o=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},a=new gs(e,{onDragTick:r,onDragStart:i,onDragEnd:o},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.vertical});return this.addChildEntity(a),a}}const Of=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=pn(pn(Math.abs(n.x),2)+pn(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},Bf=2;class Rf extends W{constructor(t,e,s,i,r){super(),this.chartAreaPanHandler=t,this.scale=e,this.canvasInputListeners=s,this.mainCanvasParent=i,this.hitTest=r,this.touchedCandleIndexes=[0,0],this.canvasTouchInfo={touchStart:{x:0,y:0},isMoving:!1}}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart(this.hitTest).subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove(this.hitTest).subscribe(t=>this.handleTouchMoveEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(t=>this.handleTouchEndEvent(t)))}handleTouchStartEvent(t){const{clientX:e,clientY:s}=t.touches[0];t.touches.length===1&&(this.canvasTouchInfo.touchStart={x:e,y:s}),t.touches.length===2&&(this.chartAreaPanHandler.deactivate(),this.touchedCandleIndexes=this.getXPositions(t).map(i=>this.scale.fromX(i)))}handleTouchMoveEvent(t){const{clientX:e,clientY:s}=t.touches[0],{touchStart:i}=this.canvasTouchInfo;t.touches.length===1&&(this.canvasTouchInfo.isMoving=Oo(e,i.x,s,i.y)),t.touches.length===2&&this.pinchHandler(this.touchedCandleIndexes,this.getXPositions(t))}handleTouchEndEvent(t){this.canvasTouchInfo.isMoving=!1,t.touches.length===0&&this.chartAreaPanHandler.activate()}getXPositions(t){const e=this.mainCanvasParent.getBoundingClientRect(),s=[0,0],i=document.body.scrollLeft||document.documentElement.scrollLeft;for(let r=0,o=t.touches.length;r<o;r++){const a=t.touches[r];s[r]=a.pageX-e.left-i}return s}pinchHandler(t,e){const s=(e[0]*t[1]-e[1]*t[0])/(e[0]-e[1]),i=s+(t[0]-t[1])/(e[0]-e[1])*this.scale.getBounds().width;s>=i||e[0]===e[1]||this.scale.setXScale(s,i)}}const Oo=(n,t,e,s,i=Bf)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i,xv={MAX_DIMENSION:2048,MAX_TOTAL_PIXELS:18e5,ZOOM_OPTIMIZED_PIXELS:12e5},Ff=2e6,Hf=24,kf=20,jf=16,Yf=10,Nf=1e3,_v=5e4,Pv={MIN:60,LOW:80,MEDIUM:100,HIGH:120,MAX:150};class Xf extends Lo{constructor(t,e,s,i,r,o,a,l){super(t,e,s,i,r,o,a,l),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=Vt,this.wheelSubscription=null,this.initFrameId=null,this.isActivated=!1,this.lastWheelTime=0,this.wheelCount=0,this.consecutiveLowWheelEvents=0,this.chartPanningOptions={horizontal:!0,vertical:!0}}doActivate(){this.isActivated||(this.isActivated=!0,super.doActivate(),this.canvasInputListener.initializeRectCache(),this.createWheelSubscription(),this.initFrameId=requestAnimationFrame(()=>{this.bus.fireDraw()}),this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject.asObservable().subscribe(({prependedCandlesWidth:t})=>{this.lastXStart+=t})),this.addRxSubscription(this.bus.observe(us).pipe(Qr(100)).subscribe(()=>{this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation()})))}createWheelSubscription(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null);const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES),e=this.canvasBoundsContainer.getBounds(M.CANVAS),s=e.width*e.height;s>0?s>Ff?this.wheelThrottleTime=Hf:this.wheelThrottleTime=kf:this.wheelThrottleTime=jf,this.wheelSubscription=this.canvasInputListener.observeWheel(t).pipe(K(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),K(i=>Cs()==="apple"?Math.abs(i.deltaY)>1||Math.abs(i.deltaX)>1:!0),Et(this.wheelThrottleTime,Bt,{trailing:!0,leading:!0})).subscribe(i=>{const r=performance.now();this.lastWheelTime||(this.lastWheelTime=r,this.wheelCount=0),this.wheelCount++,r-this.lastWheelTime>Nf&&(Math.round(this.wheelCount*1e3/(r-this.lastWheelTime))<Yf?(this.consecutiveLowWheelEvents++,this.consecutiveLowWheelEvents>=1&&(this.triggerPerformanceCleanup(),this.consecutiveLowWheelEvents=0)):this.consecutiveLowWheelEvents=0,this.lastWheelTime=r,this.wheelCount=0);const o=Cs(),a=o==="apple"||o==="mobile"?-1:1,l=0+i.deltaX*a,c=0+i.deltaY*a;if(i.ctrlKey){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw();return}if(c!==0&&Math.abs(c)>Math.abs(l)){const h=this.calculateDynamicSesitivity(i,this.config.scale.zoomSensitivity.wheel);this.zoomXHandler(i,h),this.bus.fireDraw()}if(l!==0&&Math.abs(l)>Math.abs(c)){const h=kt(l,this.scale.zoomX);this.scale.moveXStart(this.scale.xStart-h),this.bus.fireDraw();return}}),this.addRxSubscription(this.wheelSubscription)}triggerPerformanceCleanup(){window.dispatchEvent(new Event("resize")),window.gc&&window.gc(),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.scale&&typeof this.scale.haltAnimation=="function"&&this.scale.haltAnimation(),this.consecutiveLowWheelEvents=0,this.wheelCount=0,this.lastWheelTime=0}doDeactivate(){this.wheelSubscription&&(this.wheelSubscription.unsubscribe(),this.wheelSubscription=null),this.initFrameId&&(cancelAnimationFrame(this.initFrameId),this.initFrameId=null),this.isActivated=!1,super.doDeactivate()}}class Wf extends W{constructor(t,e,s,i,r,o,a,l,c){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.hitTestCanvasModel=c;const h=[this.eventBus,this.config,this.mainScale,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this,this.hitTestCanvasModel],d=Ie?new Xf(...h):new Lo(...h);this.chartAreaPanHandler=d,this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new Rf(this.chartAreaPanHandler,this.mainScale,this.canvasInputListener,this.mainCanvasParent,this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES)),this.addChildEntity(this.mainCanvasTouchHandler)}activateChartPanHandlers(){this.activate()}deactivatePanHandlers(){this.deactivate()}setChartPanningOptions(t,e){this.chartAreaPanHandler.chartPanningOptions={horizontal:t,vertical:e}}}const Bo=n=>t=>{const{top:e,bottom:s}=n(),i=t.high-t.low,r=i===0?1:i,o=r*e/100,a=r*s/100,l=t.low-a,c=t.high+o;return{low:l,high:c}},Ro=(n,t)=>{const e=Bo(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function Vf(){return Kn(1)}function Fo(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Vf()(Ke(n,$e(n)))}function gn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=$e(n);return N(function(s,i){(e?Fo(n,s,e):Fo(n,s)).subscribe(i)})}function zf(n){return K(function(t,e){return n<=e})}class Uf{constructor(t,e,s,i,r){this.config=t,this.boundsProvider=e,this.canvasModel=s,this.canvasAnimation=i,this.animationId=r}draw(){if(this.config.components.paneResizer.visible){const t=this.config.components.paneResizer.fixedMode,e=this.boundsProvider(),s=this.canvasModel.ctx,i=this.canvasAnimation.getColorAlphaAnimation(this.animationId),r=this.config.components.paneResizer.dragZone;!t&&i&&(s.fillStyle=i.getColor(0),s.fillRect(e.x,e.y-r,e.width,e.height+2*r)),s.fillStyle=this.config.colors.paneResizer.lineColor,this.config.animation.paneResizer.bgMode?s.fillRect(e.x,e.y,e.width,e.height):s.fillRect(e.x,e.y-r,e.width,e.height+2*r)}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Ho=8;class mn extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=i,this.dragPredicate=r,this.chartPanComponent=o,this.canvasModel=a,this.drawingManager=l,this.canvasInputListener=c,this.canvasAnimation=h,this.config=d,this.canvasBoundsContainer=u,this.hitTestCanvasModel=f,this.initialY=0,this.resizeEvent$=new F,this.onYDragStartMobile=()=>{this.config.components.crossTool.type="none",this.onYDragStart()},this.onYDragStart=()=>{this.initialY=this.boundsProvider().y,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1),this.chartPanComponent.deactivatePanHandlers()},this.onYDragEndMobile=()=>{this.config.components.crossTool.type="cross-and-labels",this.onYDragEnd()},this.onYDragEnd=()=>{this.initialY=this.boundsProvider().y,this.canvasBoundsContainer.graphsHeightRatioChangedSubject.next(this.canvasBoundsContainer.graphsHeightRatio),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0),this.chartPanComponent.activateChartPanHandlers()},this.onYDragTick=p=>{const{delta:m,draggedPixels:_}=p;Math.abs(this.initialY-this.boundsProvider().y+_)>=0&&(this.dragTickCb(m),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new gs(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:Ot()?this.onYDragStartMobile:this.onYDragStart,onDragEnd:Ot()?this.onYDragEndMobile:this.onYDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:this.dragPredicate});this.addChildEntity(s),this.config.animation.paneResizer.enabled&&this.addRxSubscription(this.canvasInputListener.observeMouseEnter(this.hitTest,!0).pipe(gn(!1),K(this.dragPredicate),gt(),zf(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Uf(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,Ur.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(Ur.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 vn=1/32,Gf=(n,t)=>{const e=Math.floor(n),s=t!==void 0?Tt.formatIntegerWithSeparator(e,t):e.toString(),i=n-e,r=Math.round(i*64),a=Math.floor(r/2).toString().padStart(2,"0");return`${s}'${a}`},ko=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),Tv=n=>!!ko(n),Mv=n=>{const t=ko(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*vn;return e+i}return Number(n)},Zf=(n,t)=>(e,s=!1)=>{let i;if(typeof e=="number")i=e;else if(typeof e=="string")i=Number(e);else return"\u2014";const r=n.paneComponent.intlFormatter,o=c=>Tt.makeDecimal(i,c,r.decimalSeparator,r.thousandsSeparator),a=t.treasuryFormat;if(a&&a.enabled)return Gf(i,s?r.thousandsSeparator:void 0);const[l]=n.dataSeries;if(l!==void 0){const c=Ce.getPricePrecision(i,l.pricePrecisions);return s&&Math.abs(i)>=1e3?o(c):i.toFixed(c)}return`${i}`},$f=n=>(t,e)=>{if(t===0)return"0.00 %";const[s]=n.dataSeries;let i=t;const r=e!=null?e:s;r!==void 0&&(i=cr(t,r.getBaseline()));const o=es(i.toFixed(Ce.DEFAULT_PRECISION))+" %";return o===`${ri}0.00 %`?"0.00 %":o},Kf=(n,t)=>({percent:$f(n),regular:Zf(n,t)});class qf extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:fh}){super(),this.config=t,this.paneUUID=e,this.idx=s,this.paneComponent=i,this.chartBaseModel=r,this.canvasBoundsContainer=o,this.hitTestController=a,this.dynamicObjectsCanvasModel=l,this.scale=c,this.dragNDrop=d,this.dataSeries=u,this.formatters=f,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.yAxisHT=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,this.idx)),this.toVisualPoints=p=>p.map(m=>new Fe(this.chartBaseModel.dataFromTimestamp(m.timestamp).centerUnit,m.close)),this.toY=p=>{var m,_;return(_=(m=this.mainDataSeries)==null?void 0:m.view.toY(p))!=null?_:1},this.valueFormatter=(p,m)=>{const{dataSeries:_,formatWithSeparators:S=!1}=m!=null?m:{};if(!this.formatters[this.yAxis.getAxisType()])return this.formatters.regular(p,S);const{regular:A,percent:E,logarithmic:j}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p,S);case"percent":return E?E(p,_):A(p);case"logarithmic":return j?j(p):A(p);default:return this.regularFormatter(p,S)}},this.yAxisNumericLabelsFormatter=p=>this.valueFormatter(p,{formatWithSeparators:!0}),this.addChildEntity(c),this.setValueFormatters(Kf(this,t)),this.yAxis=h(p=>this.yAxisNumericLabelsFormatter(p),()=>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 mr(this,St(),this.hitTestController.getNewDataSeriesHitTestId());return t.toVisualPoints=this.toVisualPoints,t}addDataSeries(t){if(this.dataSeries.add(t),this.dataSeries.size===1)this.mainDataSeries=t;else if(this.paneComponent.yExtentComponents.length>1&&this.paneUUID!==$){this.mainDataSeries=t;const e=Array.from(this.paneComponent.mainExtent.dataSeries);this.paneComponent.mainExtent.mainDataSeries=e[e.length-1]}this.paneComponent.updateView(),this.paneComponent.seriesAddedSubject.next(t)}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView(),this.paneComponent.seriesRemovedSubject.next(t)}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var e,s;return(s=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?s:this.scale.fromY(t)}}const jo=n=>({isHighLowActive:()=>!0,calculateHighLow:t=>{const e=Array.from(n.dataSeries),s=e.filter(o=>o.highLowProvider.isHighLowActive()),i=s.length>0?s:e;if(i.length===0)return{low:0,high:100};const r=i.map(o=>o.highLowProvider.calculateHighLow(t)).filter(o=>o.high>=o.low);return r.length===0?{low:0,high:100}:Er(r)}});class Jf{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=un.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return un.DATA_SERIES}get allDataSeries(){return Le(Le(Object.values(this.panes),t=>t.yExtentComponents),t=>Array.from(t.dataSeries))}lookup(t){return this.allDataSeries.find(s=>s.htId===t)}onHover(t){this.allDataSeries.forEach(e=>e.highlighted=e.htId===(t==null?void 0:t.htId)),this.canvasModel.fireDraw()}onMouseDown(t){t&&this.handleYExtentDragStart(t)}onMouseUp(){this.handleYExtentDragEnd()}handleYExtentDragStart(t){Object.values(this.panes).forEach(e=>e.yExtentComponents.forEach(s=>s.dragNDrop.deactivate())),t.extentComponent.dragNDrop.activate()}handleYExtentDragEnd(){Object.values(this.panes).forEach(t=>t.yExtentComponents.forEach(e=>e.dragNDrop.activate()))}}var Qf;const Gt="#FF00FF";function Av(n,t,e,s){const i=n.yAxis.backgroundColor,r=n.chartAreaTheme.backgroundColor,o=n.chartAreaTheme.backgroundGradientTopColor,a=n.chartAreaTheme.backgroundGradientBottomColor,l=s.align==="left"?o:a,c=n.chartAreaTheme.backgroundMode==="gradient"?l:r;return Qf(i==="transparent"?c:i,t,e)}const tp=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,ep=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Gt},sp=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Gt},np=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Gt},ip=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Gt},rp=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Gt},op=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Gt},ap=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Gt},Yo=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Gt},lp=()=>(console.warn("Fallback for label default color"),Gt),No=10;class Xo extends W{constructor(t,e,s,i,r,o,a,l){if(super(),this.bus=t,this.config=e,this.scale=i,this.canvasInputListener=r,this.bounds=o,this.hitTest=a,this.hitTestCanvasModel=l,this.yAxisDragEndSubject=new F,this.lastYStart=0,this.lastYEnd=0,this.lastYHeight=0,this.lastYPxHeight=0,this.onYDragStart=()=>{this.scale.haltAnimation(),this.lastYStart=this.scale.yStart,this.lastYEnd=this.scale.yEnd,this.lastYHeight=this.scale.yEnd-this.scale.yStart,this.lastYPxHeight=Math.max(this.bounds.getBounds(M.Y_AXIS).height,Yi),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onYDragTick=c=>{let{delta:h}=c;this.touches&&this.touches.length>1&&(h=Math.min(this.touches[0].clientY,this.touches[1].clientY)===this.touches[0].clientY?h:-h);let d;h<0?d=1/(1+-h/this.lastYPxHeight*(No-1)):d=1+h/this.lastYPxHeight*(No-1);const f=(this.lastYHeight*d-this.lastYHeight)/2,p=this.lastYStart-f,m=this.lastYEnd+f;(this.lastYStart!==p||this.lastYEnd!==m)&&(this.scale.setYScale(p,m),this.scale.state.auto=!1,this.bus.fireDraw())},this.onYDragEnd=()=>{this.yAxisDragEndSubject.next(),this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=c=>this.dblTapCallback=c,this.setDblClickCallback=c=>this.dblClickCallback=c,this.dblClickCallback=()=>i.autoScale(!0),this.dblTapCallback=()=>i.autoScale(!0),e.customScale){const c=new gs(a,{onDragTick:this.onYDragTick,onDragStart:this.onYDragStart,onDragEnd:this.onYDragEnd},r,s,{dragPredicate:()=>s.chartAreaPanHandler.chartPanningOptions.vertical&&e.type!=="percent"});this.addChildEntity(c),this.dragNDropYComponent=c}}isDragging(){return this.dragNDropYComponent?Math.abs(this.dragNDropYComponent.draggedPixels)>0:!1}doActivate(){this.config.customScaleDblClick&&(this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>{this.dblClickCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback(),this.bus.fireDraw()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})))}}class cp{constructor(t,e=()=>!0){this.dataProvider=t,this.dataUpdatedPredicate=e,this.calculatedInThisFrame=!1,this.animFrameId=`anim_cache_${St()}`}calculateOrGet(){var t;return this.calculatedInThisFrame||(this.cache=this.dataProvider(),this.dataUpdatedPredicate()&&(this.calculatedInThisFrame=!0),ii(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 hp=0,dp=.01;class bn{constructor(t,e,s,i,r=!1,o,a,l=Vs,c=23,h){this.increment=t,this.startEndProvider=e,this.lengthProvider=s,this.valueFormatter=i,this.withZero=r,this.axisTypeProvider=o,this.baseLineProvider=a,this.labelFilter=l,this.singleLabelHeightPixels=c,this.yAxisConfig=h,this.gridDistanceMultipliers=[2,4,5,10],this.lastSingleLabelHeightValue=0,this.distanceBetweenLabelsChangeSubject=new F,this.newGeneratedLabelsSubject=new F,this.lastStart=0,this.lastEnd=0,this.labelsCache=new cp(()=>this.labelFilter(this.doGenerateLabels())),this.treasuryFormat=this.yAxisConfig&&this.yAxisConfig.treasuryFormat}generateRegularLabels(t,e,s){const i=[];this.withZero&&i.push({value:0,text:"0"});let r=Tt.roundToNearest(t,s);for(;r<e;){const o=Tt.roundToNearest(r,s),a=es(this.valueFormatter(o));i.push({value:o,text:a}),r=Tt.roundDecimal(r+s)}return i}generatePercentLabels(t,e,s){const i=[],r=this.baseLineProvider();let o=Tt.roundToNearest(t,s);for(;o<e;){const a=Tt.roundToNearest(o,s),l=hr(a,r),c=es(this.valueFormatter(l));i.push({value:a,text:c}),o=Tt.roundDecimal(o+s)}return i}generateLogarithmLabels(t,e,s){const i=[];let r=Tt.roundToNearest(t,s);for(;r<e;){const o=rn(r),a=this.valueFormatter(o);i.push({value:r,text:a}),r=Tt.roundDecimal(r+s)}return i}doGenerateLabels(){var t;const e=this.lengthProvider();if(e<=0)return[];const[s,i]=this.calculateMinMax(),r=this.getAxisStep(s,i,e);this.lastSingleLabelHeightValue||(this.lastSingleLabelHeightValue=r);let o;const a=this.axisTypeProvider();if(a==="logarithmic"?o=this.generateLogarithmLabels(s,i,r):a==="percent"?o=this.generatePercentLabels(s,i,r):o=this.generateRegularLabels(s,i,r),this.lastSingleLabelHeightValue!==r&&this.labelsCache.cache){const l=(t=this.labelsCache.getLastCachedValue())!=null?t:[];this.distanceBetweenLabelsChangeSubject.next([l,o]),this.lastSingleLabelHeightValue=r}return this.newGeneratedLabelsSubject.next(o),o}calculateMinMax(){const[t,e]=this.startEndProvider(),s=this.lengthProvider(),i=bn.getLabelBounds(t,e,s);return[i[0],i[1]]}getAxisStep(t,e,s){const i=e-t,r=s/this.singleLabelHeightPixels,o=this.calculateIncrement(i),a=i/r;return this.calculateAxisStep(a,o)}observeDistanceBetweenLabelsChanged(){return this.distanceBetweenLabelsChangeSubject.asObservable()}observeLabelsChanged(){return this.newGeneratedLabelsSubject.asObservable()}calculateIncrement(t){var e;if(this.increment)return this.increment;if(!isNaN(t)){const s=(e=this.treasuryFormat)!=null&&e.enabled?vn:Ce.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(dp)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=rn(e)+t;return dr(i)-e;case"regular":return t}}generateNumericLabels(){const[t,e]=this.startEndProvider();return(t!==this.lastStart||e!==this.lastEnd)&&this.labelsCache.invalidate(),this.lastStart=t,this.lastEnd=e,this.labelsCache.calculateOrGet()}static getLabelBounds(t,e,s){const i=Math.abs((e-t)*(hp/s));return[t-i,e+i]}calculateAxisStep(t,e){if(e===0)return console.error("NumericAxisLabelsGenerator failed at calculateAxisStep: increment = 0"),0;let s=e,i=e,r=0;for(;s<t&&s>0;)r>=this.gridDistanceMultipliers.length&&(r=0,i*=10),s=i*this.gridDistanceMultipliers[r++];return s}}class up extends bn{constructor(t,e,s,i,r=()=>"regular",o=23,a){super(t,()=>[s.yStart,s.yEnd],()=>s.getBounds().height,i,!1,r,()=>{var l,c;return(c=(l=e())==null?void 0:l.getBaseline())!=null?c:1},void 0,o,a),this.dataSeriesProvider=e}getLargestLabel(){var t;return((t=this.labelsCache.getLastCachedValue())!=null?t:[]).reduce((e,s)=>s.text.length>e.length?s.text:e,"")}updateTreasuryFormat(t){this.treasuryFormat=t}calculateIncrement(t){var e,s;const i=this.dataSeriesProvider();if(i){const r=wt(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=Lh(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?vn:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function Wo(n,t,e){var s=Y(n)||t||e?{next:n,error:t,complete:e}:n;return s?N(function(i,r){var o;(o=s.subscribe)===null||o===void 0||o.call(s);var a=!0;i.subscribe(Ct(r,function(l){var c;(c=s.next)===null||c===void 0||c.call(s,l),r.next(l)},function(){var l;a=!1,(l=s.complete)===null||l===void 0||l.call(s),r.complete()},function(l){var c;a=!1,(c=s.error)===null||c===void 0||c.call(s,l),r.error(l)},function(){var l,c;a&&((l=s.unsubscribe)===null||l===void 0||l.call(s)),(c=s.finalize)===null||c===void 0||c.call(s)}))}):ne}class fp extends W{constructor(t,e,s,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${St()}`}doActivate(){super.doActivate(),this.addRxSubscription(yt(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(ht(t=>t.height),K(t=>Pl(t,this.prevYAxisHeight,1.5)),Wo(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,Me(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){Me(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class pp extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new up(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new fp(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new Jc(e,o,i,s,r,t,()=>this.canvasBoundsContainer.updateYAxisWidths(),h),this.addChildEntity(this.fancyLabelsModel)}doActivate(){const t={getLargestLabel:()=>{var e;return((e=this.labelsGenerator.labelsCache.getLastCachedValue())!=null?e:[]).map(s=>s.text).concat(this.fancyLabelsModel.orderedLabels.flatMap(s=>s.labels).map(s=>s.labelText)).reduce((s,i)=>i.length>s.length?i:s,"")},getYAxisIndex:()=>this.extentIdx,getYAxisState:()=>this.state,getPaneUUID:()=>this.paneUUID};this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t),this.addSubscription(()=>this.canvasBoundsContainer.yAxisBoundsContainer.removeYAxisWidthContributor(t))}}class gp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_){super(),this.eventBus=t,this.config=e,this.mainCanvasModel=s,this.canvasModel=i,this.scale=r,this.canvasInputListeners=o,this.canvasBoundsContainer=a,this.chartPanComponent=l,this.cursors=c,this.paneUUID=u,this.extentIdx=f,this.hitTestCanvasModel=p,this.chartResizeHandler=m,this.labelsColorByChartTypeMap={},this.axisTypeSetSubject=new F,this.axisAlignSetSubject=new F,this.axisAlignMovedSubject=new F,this.setDblClickCallback=A=>this.yAxisScaleHandler.setDblClickCallback(A),this.setDblTapCallback=A=>this.yAxisScaleHandler.setDblTapCallback(A);const S=_?le(_):{};this.state=At(S,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new Xo(t,this.state,l,r,o,a,a.getBoundsHitTest(M.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new pp(this.paneUUID,t,this.state,a,i,r,h,d,f,this.chartResizeHandler),this.addChildEntity(this.model),this.updateCursor(),this.registerDefaultLabelColorResolvers()}setExtentIdx(t){this.extentIdx=t,this.model.extentIdx=t,this.yAxisScaleHandler.deactivate(),this.removeChildEntity(this.yAxisScaleHandler),this.yAxisScaleHandler=new Xo(this.eventBus,this.state,this.chartPanComponent,this.scale,this.canvasInputListeners,this.canvasBoundsContainer,this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_Y_AXIS(this.paneUUID,t)),this.hitTestCanvasModel),this.addChildEntity(this.yAxisScaleHandler)}registerDefaultLabelColorResolvers(){this.registerLabelColorResolver("candle",np),this.registerLabelColorResolver("bar",ep),this.registerLabelColorResolver("line",sp),this.registerLabelColorResolver("area",ip),this.registerLabelColorResolver("scatterPlot",rp),this.registerLabelColorResolver("histogram",op),this.registerLabelColorResolver("baseline",ap),this.registerLabelColorResolver("trend",Yo),this.registerLabelColorResolver("hollow",Yo)}doActivate(){this.addRxSubscription(this.scale.beforeStartAnimationSubject.subscribe(()=>this.state.type==="percent"&&this.scale.haltAnimation()))}updateCursor(){this.state.type==="percent"?this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.resizeDisabledCursor):this.cursors.setCursorForCanvasEl(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx),this.state.cursor)}updateOrderedLabels(t=!1){this.model.fancyLabelsModel.updateLabels(t)}registerLabelColorResolver(t,e){this.labelsColorByChartTypeMap[t]=e}getLabelsColorResolver(t){var e;return(e=this.labelsColorByChartTypeMap[t])!=null?e:lp}registerYAxisLabelsProvider(t,e=ae.MAIN,s=St()){return this.model.fancyLabelsModel.registerYAxisLabelsProvider(e,t,s),s}addSimpleYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}updateCustomYAxisLabel(t,e){this.model.fancyLabelsModel.customLabels[t]=e,this.canvasModel.fireDraw()}deleteSimpleYAxisLabel(t){delete this.model.fancyLabelsModel.customLabels[t],this.canvasModel.fireDraw()}getAxisType(){return this.state.type}unregisterYAxisLabelsProvider(t=ae.MAIN,e){return this.model.fancyLabelsModel.unregisterYAxisLabelsProvider(t,e),e}getBounds(){return this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx))}registerYAxisWidthContributor(t){this.canvasBoundsContainer.yAxisBoundsContainer.registerYAxisWidthContributor(t)}setAxisType(t){t!==this.state.type&&(this.state.type=t,this.config.components.yAxis.type=t,this.axisTypeSetSubject.next(t),this.scale.autoScale(!0),this.model.fancyLabelsModel.updateLabels(!0),this.updateCursor(),this.mainCanvasModel.fireDraw())}setYAxisAlign(t){this.state.align=t,this.canvasBoundsContainer.updateYAxisWidths(),this.axisAlignSetSubject.next(t),this.eventBus.fireDraw()}setVisible(t){this.state.visible=t,this.config.components.yAxis.visible=t,t?this.activate():this.deactivate(),this.model.fancyLabelsModel.updateLabels(),this.model.baseLabelsModel.updateLabels()}isVisible(){return this.state.visible}setLockPriceToBarRatio(t=!1){this.scale.setLockPriceToBarRatio(t)}changeLabelMode(t,e){this.state.labels.settings[t].mode=e,this.model.fancyLabelsModel.updateLabels()}changeLabelAppearance(t,e){this.state.labels.settings[t].type=e,this.model.fancyLabelsModel.updateLabels()}togglePriceScaleInverse(t=!1){this.scale.state.inverse=t,this.scale.inverseY=t,this.model.fancyLabelsModel.updateLabels(),this.scale.scaleInversedSubject.next(t),this.canvasModel.fireDraw()}changeLabelsDescriptionVisibility(t){this.state.labels.descriptions=t,this.canvasModel.fireDraw()}}const mp=$l(n=>n.candle.volume),Cn="volumes";class vp extends W{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=Cn,this.volumeMax=new ft(0),this.highLowProvider={calculateHighLow:()=>({high:this.volumeMax.getValue(),low:0}),isHighLowActive:()=>!0}}doActivate(){super.doActivate(),this.addRxSubscription(yt(this.chartComponent.chartModel.observeCandlesChanged(),this.scale.xChanged).subscribe(()=>this.updateVolumeMax())),this.addRxSubscription(this.chartComponent.chartModel.mainCandleSeries.observeLastVisualCandleChanged().subscribe(()=>this.recalculateLastVisualVolume()))}recalculateLastVisualVolume(){}updateVolumeMax(){var t;const e=this.chartComponent.chartModel.mainCandleSeries.getSeriesInViewport(this.scale.xStart-1,this.scale.xEnd+1);this.volumeMax.next((t=ie(mp(e.flat())))!=null?t:0)}}class bp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,S,A,E,j){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=i,this.hitTestController=r,this.config=o,this.mainScale=a,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=d,this.cursorHandler=u,this.eventBus=f,this.canvasBoundsContainer=p,this.uuid=m,this.seriesAddedSubject=_,this.seriesRemovedSubject=S,this.hitTestCanvasModel=A,this.chartResizeHandler=E,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new F,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(R,k)=>this.mainExtent.valueFormatter(R,k);const B=this.createExtentComponent(j);this.mainExtent=B,this.ht=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(m),{extensionY:-this.config.components.paneResizer.dragZone})}get scale(){return this.mainExtent.scale}get yAxis(){return this.mainExtent.yAxis}get intlFormatter(){return this.config.intlFormatter}get dataSeries(){return Le(this.yExtentComponents,t=>Array.from(t.dataSeries))}get visible(){return this.canvasBoundsContainer.graphsHeightRatio[this.uuid]>0}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(this.uuid)).pipe(gt(Ui)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()})),this.uuid===$&&this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(gn(this.yAxis.getAxisType()),gt(),ht(t=>t==="percent")).subscribe(t=>{this.chartPanComponent.chartAreaPanHandler.setChartAreaXDragThrottled(t)}))}toY(t){var e,s;return(s=(e=this.mainExtent.mainDataSeries)==null?void 0:e.view.toY(t))!=null?s:this.scale.toY(t)}createGridComponent(t,e,s,i,r,o){var a,l;const c=M.PANE_UUID(t),h=(l=(a=this.mainExtent)==null?void 0:a.idx)!=null?l:0;return new Po(this.mainCanvasModel,s,this.config,i,`PANE_${t}_${e}_grid_drawer`,this.drawingManager,()=>this.canvasBoundsContainer.getBounds(c),()=>this.canvasBoundsContainer.getBounds(c),()=>[],r,e,o,()=>this.config.components.grid.visible,h)}createYPanHandler(t,e){const s=M.PANE_UUID(t),i=this.chartPanComponent.chartAreaPanHandler.registerChartYPanHandler(e,this.canvasBoundsContainer.getBoundsHitTest(s));return[()=>{this.chartPanComponent.chartAreaPanHandler.removeChildEntity(i),i.disable()},i]}addCursors(t,e){const s=M.PANE_UUID_Y_AXIS(this.uuid,t);return this.cursorHandler.setCursorForCanvasEl(s,e.state.cursor),()=>this.cursorHandler.removeCursorForCanvasEl(s)}createExtentComponent(t){var e,s;const i=this.yExtentComponents.length,r=M.PANE_UUID(this.uuid),o=()=>this.canvasBoundsContainer.getBounds(r),a=(e=t==null?void 0:t.scale)!=null?e:new ad(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(m,_)=>new gp(this.eventBus,this.config,this.mainCanvasModel,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,m,_,this.uuid,i,this.hitTestCanvasModel,this.chartResizeHandler,l),u=new qf(this.config.components.yAxis,this.uuid,i,this,this.chartBaseModel,this.canvasBoundsContainer,this.hitTestController,this.dynamicObjectsCanvasModel,a,d,h);u.addSubscription(c),u.addSubscription(this.addCursors(i,u.yAxis)),t!=null&&t.paneFormatters&&u.setValueFormatters(t.paneFormatters),u.yAxis.togglePriceScaleInverse(t==null?void 0:t.inverse),u.scale.setLockPriceToBarRatio(t==null?void 0:t.lockToPriceRatio),((s=t==null?void 0:t.useDefaultHighLow)==null||s)&&a.autoScaleModel.setHighLowProvider("default",Ro(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),jo(u)));const p=this.createGridComponent(this.uuid,u.idx,a,u.yAxis.state,()=>u.yAxis.model.baseLabelsModel.labels,()=>u.toY(u.getBaseline()));return u.addChildEntity(p),u.activate(),this.yExtentComponents.push(u),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next(),u}shouldKeepVolumeHostExtent(t){return this.uuid===Cn&&t===this.mainExtent&&this.config.components.volumes.showSeparately}removeExtentComponents(t){const e=t.filter(s=>!this.shouldKeepVolumeHostExtent(s));e.length!==0&&(e.forEach(s=>s.disable()),this.yExtentComponents=this.yExtentComponents.filter(s=>!e.map(i=>i.idx).includes(s.idx)),this.yExtentComponents.forEach((s,i)=>{s.yAxis.setExtentIdx(i),s.idx=i,s.yAxis.updateCursor()}),this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponentsChangedSubject.next())}moveDataSeriesToNewExtentComponent(t,e,s,i="right"){const r=le(s.yAxis.state),o=le(s.scale.state),a=At(r,this.config.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),l=this.createExtentComponent({initialYAxisState:a,inverse:o.inverse,lockToPriceRatio:o.lockPriceToBarRatio});l.yAxis.setYAxisAlign(i),t.forEach(c=>c.moveToExtent(l)),s.dataSeries.size===0&&e.removeExtentComponents([s])}moveDataSeriesToExistingExtentComponent(t,e,s,i,r){t.forEach(o=>o.moveToExtent(i)),!r&&s.dataSeries.size===0&&e.removeExtentComponents([s]),this.yExtentComponentsChangedSubject.next()}updateView(){this.yExtentComponents.forEach(t=>{t.scale.doAutoScale(),t.yAxis.model.labelsGenerator.generateNumericLabels()}),this.canvasBoundsContainer.updateYAxisWidths(),this.eventBus.fireDraw()}mergeYExtents(){for(let t=1;t<this.yExtentComponents.length;t++){const e=this.yExtentComponents[t];e.dataSeries.forEach(s=>s.moveToExtent(this.mainExtent)),e.disable()}this.canvasBoundsContainer.updateYAxisWidths(),this.yExtentComponents=[this.mainExtent]}getBounds(){return this.mainExtent.getBounds()}createDataSeries(){var t;return(t=this.mainExtent)==null?void 0:t.createDataSeries()}addDataSeries(t){this.mainExtent.addDataSeries(t),this.updateView()}removeDataSeries(t){this.mainExtent.removeDataSeries(t),this.updateView()}getAxisType(){return"regular"}moveUp(){this.canvasBoundsContainer.movePaneUp(this.uuid)}moveDown(){this.canvasBoundsContainer.movePaneDown(this.uuid)}canMoveUp(){const t=ie(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=wt(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}get regularFormatter(){return this.mainExtent.formatters.regular}setPaneValueFormatters(t){this.mainExtent.setValueFormatters(t)}regularValueFromY(t){return this.mainExtent.regularValueFromY(t)}}var Cp=Object.defineProperty,yp=Object.defineProperties,wp=Object.getOwnPropertyDescriptors,Vo=Object.getOwnPropertySymbols,Sp=Object.prototype.hasOwnProperty,xp=Object.prototype.propertyIsEnumerable,zo=(n,t,e)=>t in n?Cp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_p=(n,t)=>{for(var e in t||(t={}))Sp.call(t,e)&&zo(n,e,t[e]);if(Vo)for(var e of Vo(t))xp.call(t,e)&&zo(n,e,t[e]);return n},Pp=(n,t)=>yp(n,wp(t));class Tp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,S){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=m,this.hitTestCanvasModel=_,this.chartResizeHandler=S,this.panes={},this.paneRemovedSubject=new F,this.paneAddedSubject=new F,this.dataSeriesAddedSubject=new F,this.dataSeriesRemovedSubject=new F,this.hitTestController=new Jf(this.panes,this.dynamicObjectsCanvasModel);const A=this.createPane($,{useDefaultHighLow:!1,scale:this.mainScale});A.mainExtent.scale.autoScaleModel.setHighLowProvider("series",jo(A.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",Bo(()=>this.mainScale.getOffsets()))}get panesOrder(){return this.canvasBoundsContainer.panesOrder}addBounds(t,e){return this.canvasBoundsContainer.addPaneBounds(t,e),()=>this.canvasBoundsContainer.removePaneBounds(t)}addResizer(t){const e=this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID_RESIZER(t),{extensionY:this.config.components.paneResizer.dragZone+Ho}),s=()=>this.chartBaseModel.mainVisualPoints.length!==0,i=()=>{this.canvasBoundsContainer.resizePaneVertically(t,this.canvasInputListener.getCurrentPoint().y),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])},r=M.PANE_UUID_RESIZER(t),o=new mn(r,()=>this.canvasBoundsContainer.getBounds(r),e,i,s,this.chartPanComponent,this.mainCanvasModel,this.drawingManager,this.canvasInputListener,this.canvasAnimation,this.config,this.canvasBoundsContainer,this.hitTestCanvasModel);return this.userInputListenerComponents.push(o),o}get yExtents(){return Le(Object.values(this.panes),t=>t.yExtentComponents)}getPaneIfHit(t){return Object.values(this.panes).find(s=>this.canvasBoundsContainer.getBoundsHitTest(M.PANE_UUID(s.uuid))(t.x,t.y))}createPane(t=St(),e){if(this.panes[t]!==void 0)return this.panes[t];const s=new bp(this.chartBaseModel,this.mainCanvasModel,this.yAxisLabelsCanvasModel,this.dynamicObjectsCanvasModel,this.hitTestController,this.config,this.mainScale,this.drawingManager,this.chartPanComponent,this.canvasInputListener,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,t,this.dataSeriesAddedSubject,this.dataSeriesRemovedSubject,this.hitTestCanvasModel,this.chartResizeHandler,e);return this.config.components.paneResizer.visible&&s.addChildEntity(this.addResizer(t)),s.addSubscription(this.addBounds(t,e==null?void 0:e.order)),s.addSubscription(this.addCursors(t)),s.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,s.ht)),this.panes[t]=s,s.activate(),this.recalculateState(),s.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),s}movePaneUp(t){this.canvasBoundsContainer.movePaneUp(t)}movePaneDown(t){this.canvasBoundsContainer.movePaneDown(t)}canMovePaneUp(t){var e,s;const i=ie(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}canMovePaneDown(t){var e,s;const i=wt(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}removePane(t){const e=this.panes[t];e!==void 0&&(this.paneRemovedSubject.next(e),e.disable(),e.yExtentComponents.forEach(s=>s.disable()),delete this.panes[t],this.recalculateState())}hidePane(t){const e=this.panes[t];if(e===void 0||!e.visible)return;const s=M.PANE_UUID_RESIZER(t),i=this.userInputListenerComponents.find(r=>r instanceof mn&&r.id===s);i==null||i.disable(),this.canvasBoundsContainer.hidePaneBounds(t),this.recalculateState()}showPane(t){const e=this.panes[t],s=M.PANE_UUID_RESIZER(t);if(e===void 0||e.visible)return;const i=this.userInputListenerComponents.find(r=>r instanceof mn&&r.id===s);i==null||i.enable(),this.canvasBoundsContainer.showPaneBounds(t),this.recalculateState()}moveDataSeriesToPane(t,e,s,i){const{paneUUID:r,extent:o,direction:a,align:l,extentIdx:c,isForceKeepPane:h,index:d=0}=i,u=r&&this.panes[r],f=l?Pp(_p({},s.yAxis.state),{align:l}):void 0,p=c&&c>0;if(!u){const m=a&&a==="above"?d:d+1,_=this.createPane(r,{order:m,initialYAxisState:f,inverse:s.scale.state.inverse,lockToPriceRatio:s.scale.state.lockPriceToBarRatio});_.moveDataSeriesToExistingExtentComponent(t,e,s,_.mainExtent,h),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid);return}o&&!p?u.moveDataSeriesToExistingExtentComponent(t,e,s,o):u.moveDataSeriesToNewExtentComponent(t,e,s,l!=null?l:s.yAxis.state.align),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid)}addCursors(t,e=this.config.components.chart.cursor){const s=M.PANE_UUID(t),i=M.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone+Ho),()=>{this.cursorHandler.removeCursorForCanvasEl(s),this.config.components.paneResizer.visible&&this.cursorHandler.removeCursorForCanvasEl(i)}}recalculateState(){Object.values(this.panes).forEach(t=>t.scale.recalculateZoomY()),this.eventBus.fireDraw([this.mainCanvasModel.canvasId,"dynamicObjectsCanvas"])}}class Mp extends W{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,s=this.canvasModel.ctx;if(s){s.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,i,r),s.drawImage(this.elements.mainCanvas,0,0,i,r),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),s.drawImage(this.elements.crossToolCanvas,0,0,i,r),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(s),new Promise((o,a)=>this.elements.snapshotCanvas.toBlob(l=>l?o(l):a("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const Ap=(n,t=1)=>{function e(i){let r;const o=Math.pow(10,t);return i=Math.round(i*o)/o,i>=1e-15&&i<1?r=i.toFixed(t).replace(/\.?0+$/,""):r=String(i),r.replace(/(\.[1-9]*)0+$/,(a,l)=>l)}function s(i){let r="";return i<0&&(r="-",i=-i),i<995?r+e(i):i<999995?r+e(i/1e3)+"K":i<999999995?(i=1e3*Math.round(i/1e3),r+e(i/1e6)+"M"):(i=1e6*Math.round(i/1e6),r+e(i/1e9)+"B")}return s(n)},Uo=class Ve extends W{constructor(t,e,s,i){super(),this.chartComponent=t,this.config=e,this.volumesModel=s,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var t,e;return!((t=this.pane)!=null&&t.scale.isViewportValid())&&((e=this.pane)==null?void 0:e.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var t;return(t=this.pane)==null?void 0:t.scale.doAutoScale()}))}paneHasStudyDataSeries(t){return t.dataSeries.length>0}activateSeparateVolumes(){const t=this.paneManager.panes[Ve.UUID];if(t===void 0){const s=this.paneManager.createPane(Ve.UUID,{paneFormatters:{regular:o=>Ap(o,1)},useDefaultHighLow:!1,increment:1});s.mainExtent.yAxis.setAxisType("regular");const{scale:i}=s,r=Ro(()=>({top:10,bottom:0,left:0,right:0,visible:!0}),this.volumesModel.highLowProvider);i.autoScaleModel.setHighLowProvider("volumes",r),i.doAutoScale(!0),this.pane=s;return}this.pane=t}deactiveSeparateVolumes(){const t=this.paneManager.panes[Ve.UUID];if(t===void 0){delete this.pane;return}if(this.paneHasStudyDataSeries(t)){this.pane=void 0;return}this.paneManager.removePane(Ve.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};Uo.UUID="volumes";let Ep=Uo;const ys=.3,Ip=(n,t)=>{const e=t.barTheme[`${n}Color`];return Ft()(e).alpha(ys).toString()},Dp=(n,t)=>{const e=t.volume[`${n}BarColor`];return Ft()(e).alpha(ys).toString()},Lp=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Ft()(e).alpha(ys).toString()},yn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Ft()(e).alpha(ys).toString()},Op=3;class Bp{constructor(t,e,s,i,r,o){this.config=t,this.volumesModel=e,this.chartModel=s,this.getViewportModel=i,this.volumesColorByChartTypeMap=r,this.drawPredicate=o,this.volumeBarColors={down:"#FF00FF",up:"#FF00FF",none:"#FF00FF"}}calculateColors(t){var e;const s=(e=this.volumesColorByChartTypeMap[t])!=null?e:Dp;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();Kt(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=this.getViewportModel();if(!s.isViewportValid())return;const i=mt(this.chartModel.mainCandleSeries.getSeriesInViewport(this.chartModel.scale.xStart-1,this.chartModel.scale.xEnd+1));i.forEach((r,o)=>{if(r.candle.volume){const a=s.getBounds(),l=a.height;if(l<=0)return;const c=i[o+1]!==void 0?It(s.toX(i[o+1].startUnit)):void 0,h=It(s.toX(r.startUnit)),d=c!==void 0?c-h:It(vt(r.width,s.zoomX));if(this.config.components.volumes.showSeparately){const u=It(s.toY(r.candle.volume)),f=en(s.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=l/Op;if(u<=0)return;const f=e/u;if(!isFinite(f)||f<=0)return;const p=Math.max(en(vt(r.candle.volume,f)),2),m=Math.min(p,l),_=It(a.y+l-m);this.drawVolume(t,r,h,_,d,m)}}})}drawVolume(t,e,s,i,r,o){const a=t.ctx,l=i,c=i+o,h=e.name;a.fillStyle=this.volumeBarColors[h],a.strokeStyle=this.volumeBarColors[h],r===0?(a.beginPath(),a.moveTo(s,l),a.lineTo(s,en(c)),a.stroke()):a.fillRect(s,i,r,o)}}class Rp extends W{constructor(t,e,s,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new ft(!1),this.volumeIsSeparateModeChangedSubject=new ft(!1);const c=new vp(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new Ep(e,o,c,a),this.volumesDrawer=new Bp(o,this.volumesModel,e.chartModel,()=>{var h,d;return this.config.components.volumes.showSeparately&&(d=(h=this.separateVolumes.pane)==null?void 0:h.scale)!=null?d:s},this.volumesColorByChartTypeMap,()=>!0),o.components.volumes.visible&&this.syncVolumesDynamicObject(),this.addChildEntity(this.separateVolumes),this.registerDefaultVolumeColorResolvers(),this.volumeVisibilityChangedSubject.next(o.components.volumes.visible),this.volumeIsSeparateModeChangedSubject.next(o.components.volumes.showSeparately)}registerDefaultVolumeColorResolvers(){this.registerVolumeColorResolver("candle",yn),this.registerVolumeColorResolver("trend",yn),this.registerVolumeColorResolver("hollow",yn),this.registerVolumeColorResolver("line",Lp),this.registerVolumeColorResolver("bar",Ip)}ensureSeparateVolumesHost(){this.config.components.volumes.showSeparately&&(this.separateVolumes.activateSeparateVolumes(),this.syncVolumesDynamicObject(),this.canvasModel.fireDraw())}setShowVolumesSeparatly(t){this.config.components.volumes.showSeparately!==t&&(this.config.components.volumes.showSeparately=t,t?this.separateVolumes.activateSeparateVolumes():this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(t),this.syncVolumesDynamicObject())}doDeactivate(){super.doDeactivate(),this.setVisible(!1)}registerVolumeColorResolver(t,e){this.volumesColorByChartTypeMap[t]=e}setVisible(t=!0){this.config.components.volumes.visible=t,this.volumeVisibilityChangedSubject.next(t),this.config.components.volumes.showSeparately&&(t?(this.separateVolumes.activateSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!0)):(this.separateVolumes.deactiveSeparateVolumes(),this.volumeIsSeparateModeChangedSubject.next(!1))),this.canvasBoundsContainer.recalculatePanesHeightRatios(),this.syncVolumesDynamicObject(),this.canvasModel.fireDraw()}syncVolumesDynamicObject(){if(!this.config.components.volumes.visible){this.dynamicObjectsComponent.model.removeObject(this.volumesModel.id);return}const e=this.config.components.volumes.showSeparately?Cn:$,s={id:this.volumesModel.id,paneId:e,drawer:this.volumesDrawer,model:this.volumesModel};if(this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1){this.dynamicObjectsComponent.model.addObject(s);return}this.dynamicObjectsComponent.model.updateObject(s)}}class Fp{constructor(t,e,s,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,f=this.canvasBoundsContainer.getBounds(M.PANE_UUID($)),{position:p,offsetY:m,offsetX:_}=this.config.components.waterMark;let S;switch(d?S=d:(u.font=ws(this.config,l),S=u.measureText(a).width,f.width-10<S&&(u.font=Hp(this.config,this.canvasBoundsContainer,l,S),S=u.measureText(a).width)),p){case"left-top":return{x:_+f.x,y:m+o+f.y,font:u.font,text:a,color:c};case"left-bottom":return{x:_+f.x,y:f.height-h-m+o+f.y,font:u.font,text:a,color:c};case"center":return{x:f.width/2-S/2+f.x,y:(f.height-h)/2+o+f.y,font:u.font,text:a,color:c}}}}draw(){var t,e,s,i,r,o,a;if((t=this.config.components.waterMark)!=null&&t.visible&&this.config.colors){const{firstRow:l,secondRow:c,thirdRow:h}=this.watermarkDataProvider(),d=this.waterMarkConfigProvider(),u=this.config.colors.waterMarkTheme,f=this.canvasModel.ctx;let p=0,m=0,_=0,S=0,A=0;if(f.save(),d.firstRowFontSize&&l){f.font=ws(this.config,d.firstRowFontSize);const R=f.measureText(l);p=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){f.font=ws(this.config,d.secondRowFontSize);const R=f.measureText(c);m=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,_=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){f.font=ws(this.config,d.thirdRowFontSize);const R=f.measureText(h);S=R.actualBoundingBoxAscent+R.actualBoundingBoxDescent,A=(s=d.secondRowBottomPadding)!=null?s:0}const E=(i=d.thirdRowBottomPadding)!=null?i:0,j=(r=d.logoHeight)!=null?r:0,B=p+m+_+S+A+E+j;if(l&&this.drawWaterMark(this.getConfig(p,l,d.firstRowFontSize,u.firstRowColor,B)),c&&this.drawWaterMark(this.getConfig(p+_+m,c,d.secondRowFontSize,u.secondRowColor,B)),h&&this.drawWaterMark(this.getConfig(p+_+m+A+S,h,d.thirdRowFontSize,u.thirdRowColor,B)),this.logoImage){const R=this.getConfig(p+_+m+A+S+E,"",d.thirdRowFontSize,u.thirdRowColor,B,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,R.x,R.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}f.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const s=this.canvasModel.ctx;s.font=t.font,s.fillStyle=t.color;const i=t.x,r=t.y;s.fillText(e,i,r)}reset(){}}const Hp=(n,t,e,s)=>{const r=((a,l)=>t.getBounds(M.CHART).width/l*a)(e,s);let o;return n.components&&n.components.waterMark&&(o=n.components.waterMark.fontFamily),r+"px "+o},ws=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var kp=Object.defineProperty,Go=Object.getOwnPropertySymbols,jp=Object.prototype.hasOwnProperty,Yp=Object.prototype.propertyIsEnumerable,Zo=(n,t,e)=>t in n?kp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$o=(n,t)=>{for(var e in t||(t={}))jp.call(t,e)&&Zo(n,e,t[e]);if(Go)for(var e of Go(t))Yp.call(t,e)&&Zo(n,e,t[e]);return n};class Np extends W{constructor(t,e,s,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Fp(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(At(r.observeBoundsChanged(M.PANE_UUID($)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),a.addDrawerAfter(this.waterMarkDrawer,"WATERMARK","DYNAMIC_OBJECTS")}setWaterMarkVisible(t){this.config.components&&this.config.components.waterMark&&(this.config.components.waterMark.visible=t,this.canvasModel.fireDraw())}setWaterMarkData(t){this.waterMarkData=t,this.canvasModel.fireDraw()}getWaterMarkData(){return this.waterMarkData||{}}setWaterMarkConfig(t){if(!(!t||!this.config.components)){if(!this.config.components.waterMark)this.config.components.waterMark=JSON.parse(JSON.stringify(t));else{const e={};At(e,t),At(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 $o($o({},this.config.components.waterMark),h)}}const Ko={x:4,y:4};function Xp(n,t,e,s){var i,r;const o=(i=s.alignType)!=null?i:"middle",{fontSize:a,fontFamily:l,padding:c}=e.components.xAxis,h=e.colors.xAxis,d=(r=c.top)!=null?r:0,u=t.getBounds(M.X_AXIS);n.save(),n.font=`bold ${a}px ${l}`;const p=n.measureText(s.text).width+Ko.x*2;let m=0;const _=s.x;switch(o){case"start":m=_-p;break;case"end":m=_;break;default:m=_-p/2;break}n.fillStyle=h.backgroundColor,n.strokeStyle=h.backgroundColor,n.fillRect(m,u.y,p,u.height),o!=="middle"&&(n.strokeStyle=s.color,n.beginPath(),n.moveTo(_,u.y),n.lineTo(_,u.y+u.height),n.stroke()),n.fillStyle=s.color;const S=m+Ko.x,A=u.y+d+a+Oe/2;n.fillText(s.text,S,A),n.restore()}class Wp{constructor(t,e,s,i){this.config=t,this.canvasModel=e,this.canvasBoundsContainer=s,this.xAxisLabelsModel=i}draw(){const t=this.canvasModel.ctx;this.drawHighlightedBackgroundBetweenLabels(),this.xAxisLabelsModel.labels.forEach(e=>{Xp(t,this.canvasBoundsContainer,this.config,e)})}drawHighlightedBackgroundBetweenLabels(){const t=this.canvasModel.ctx,e={},s=this.xAxisLabelsModel.labels.reduce((i,r)=>{if(r.subGroupId!==void 0){let o=i[r.subGroupId];o||(o=[],i[r.subGroupId]=o),o.push(r)}return i},e);Object.keys(s).forEach(i=>{const r=s[i];if(r.length===2){const o=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.fillStyle=Ft().rgb(r[0].color).alpha(.1).toString(),kr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const Ev="week-weekday",Vp=["second","minute","hour","day","month","year"],zp=["lessThanSecond"],Up=n=>Vp.some(t=>t===n),Gp=n=>n==="week-weekday",Zp=n=>zp.some(t=>t===n),qo=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},wn=n=>parseInt(n,10),Jo=n=>{const[t,...e]=n.split("_");if(Up(t)){const[s]=e,i=qo(s),r=wn(s);return{key:t,value:r,exact:i["!"]}}else if(Gp(t)){const[s,i]=e,r=qo(s),o=wn(s),a=wn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return Zp(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats in dxchart-lite documentation.`),null)};class Ss{constructor(t,e,s,i,r,o=()=>!0){this.config=t,this.canvasModel=e,this.viewportModel=s,this.canvasBoundsContainer=i,this.labelsProvider=r,this.drawPredicate=o}draw(){var t;if(this.drawPredicate()){const e=this.canvasModel.ctx,s=this.config.colors.xAxis,i=this.config.components.xAxis.fontFamily,r=Ss.getFontFromConfig(this.config),o=this.config.components.xAxis.fontSize,a=(t=this.config.components.xAxis.padding.top)!=null?t:0;e.save(),e.font=r,e.fillStyle=s.backgroundColor;const l=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.config.components.chart.applyBackgroundToAxes.x||e.fillRect(l.x,l.y,l.width,l.height);const c=this.config.colors.xAxis.labelTextColor,h=this.labelsProvider();this.drawLabels(e,h,l,c,o,i,a+Oe/2),e.restore()}}drawLabels(t,e,s,i,r,o,a){const l=`${r}px ${o}`;t.fillStyle=i;for(const c of e){const h=this.viewportModel.toX(c.value)-Mt(c.text,t,l)/2;if(h<s.x||h>s.width)continue;const d=s.y+r-1+a,u=c.text;t.font=l,t.fillText(u,h,d)}}static getFontFromConfig(t){return`${t.components.xAxis.fontStyle} ${t.components.xAxis.fontSize}px ${t.components.xAxis.fontFamily}`}getCanvasIds(){return[this.canvasModel.canvasId]}}const Sn={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Qo=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return Sn[n.key]+n.value;case"lessThanSecond":return Sn[n.key];case"week-weekday":return Sn[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},ta=n=>{const t={};for(const e of n){const s=t[e.weight];s===void 0?t[e.weight]=[e]:s.push(e)}return t},$p=(n,t)=>{const e=Object.keys(n).map(i=>parseInt(i,10)).sort((i,r)=>r-i);let s=[];for(const i of e){const r=n[i];if(!r)continue;const o=[...s];s=[];const a=o.length,l=r.length;let c=0,h=1/0,d=-1/0;for(let u=0;u<l;u++){const f=r[u],p=f.idx;for(;c<a;){const m=o[c],_=m.idx;if(p>_)c++,s.push(m),d=_,h=1/0;else{h=_;break}}h-p>=t&&p-d>=t&&(s.push(f),d=p)}for(;c<a;)s.push(o[c]),c++}return s},Kp=(n,t,e,s,i,r)=>{const o=Ss.getFontFromConfig(t),a=Mt(e.text,n,o),l=Mt(s.text,n,o),c=i.toX(e.value)+a/2;return i.toX(s.value)-l/2-c<r},Iv=7,qp=365.2425,Lv=-(Math.pow(10,8)*24*60*60*1e3),Ov=6048e5,Bv=864e5,Rv=6e4,Fv=36e5,Hv=1e3,kv=525600,jv=43200,Yv=1440,Nv=60,Xv=3,Wv=12,Vv=4,Jp=3600,zv=60,ea=Jp*24,Uv=ea*7,$v=ea*qp/12*3,sa=Symbol.for("constructDateFrom");function xn(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&sa in n?n[sa](t):n instanceof Date?new n.constructor(t):new Date(t)}const Kv=null;function jt(n,t){return xn(t||n,n)}const qv=null;function Qp(n,t){return jt(n,t==null?void 0:t.in).getDay()===1}const Jv=null;function tg(n,t){return jt(n,t==null?void 0:t.in).getDay()===2}const Qv=null;function eg(n,t){return jt(n,t==null?void 0:t.in).getDay()===3}const tb=null;function sg(n,t){return jt(n,t==null?void 0:t.in).getDay()===4}const eb=null;function ng(n,t){return jt(n,t==null?void 0:t.in).getDay()===5}const sb=null;function ig(n,t){return jt(n,t==null?void 0:t.in).getDay()===6}const nb=null;function rg(n,t){return jt(n,t==null?void 0:t.in).getDay()===0}const ib=null;function na(n,...t){const e=xn.bind(null,n||t.find(s=>typeof s=="object"));return t.map(e)}function og(n,t){const[e,s]=na(n,t.start,t.end);return{start:e,end:s}}function ag(n,t){var c;const{start:e,end:s}=og(t==null?void 0:t.in,n);let i=+e>+s;const r=i?+e:+s,o=i?s:e;o.setHours(0,0,0,0);let a=(c=t==null?void 0:t.step)!=null?c:1;if(!a)return[];a<0&&(a=-a,i=!i);const l=[];for(;+o<=r;)l.push(xn(e,o)),o.setDate(o.getDate()+a),o.setHours(0,0,0,0);return i?l.reverse():l}const rb=null;function lg(n,t){const e=jt(n,t==null?void 0:t.in);return e.setDate(1),e.setHours(0,0,0,0),e}const ob=null;function cg(n,t){const e=jt(n,t==null?void 0:t.in),s=e.getMonth();return e.setFullYear(e.getFullYear(),s+1,0),e.setHours(23,59,59,999),e}const ab=null;function ia(n,t){const e=jt(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}const lb=null;function ra(n,t,e){const[s,i]=na(e==null?void 0:e.in,n,t);return+ia(s)==+ia(i)}const cb=null,hg=n=>{switch(n.key){case"lessThanSecond":return pg(n);case"month":return gg(n);case"second":case"minute":case"hour":case"day":case"year":return mg(n);case"week-weekday":return vg(n);default:return()=>!1}},Qt=(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()}},_n=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s!==i},dg=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s>=i},ug={1:Qp,2:tg,3:eg,4:sg,5:ng,6:ig,7:rg},fg=(n,t,e)=>{var s;const i=ag({start:lg(n),end:cg(n)}),r=(s=ug[e])!=null?s:(()=>!1);if(t==="$"){for(const o of i.reverse())if(r(o))return ra(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return ra(n,a);o++}}return!1},oa=(n,t)=>t===1?n===1:n/t===1,aa=(n,t)=>t===1?!0:n%t===0,pg=n=>(t,e)=>dg(n.key)(t,e),gg=n=>(t,e)=>{const s=_n(n.key)(t,e),i=n.exact?oa(Qt(t,n.key)+1,n.value):aa(Qt(t,n.key)+1,n.value);return s&&i},mg=n=>(t,e)=>{const s=_n(n.key)(t,e),i=n.exact?oa(Qt(t,n.key),n.value):aa(Qt(t,n.key),n.value);return s&&i},vg=n=>(t,e)=>{const s=_n(n.key)(t,e),i=fg(t,n.week,n.weekday);return s&&i},bg=n=>{switch(n.key){case"second":case"minute":return Cg(n.value);case"hour":return yg(n.value);case"day":return wg(n.value);case"month":return _g(n.value);case"year":return Pg(n.value);case"week-weekday":const t=xg(n.week),e=Sg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},Cg=n=>n>0&&n<=60,yg=n=>n>0&&n<=24,wg=n=>n>0&&n<=31,Sg=n=>la(n)?n>=1&&n<=7:!1,xg=n=>n==="$"?!0:la(n)?n>=1&&n<=6:!1,_g=n=>n>0&&n<=12,Pg=n=>n>0,la=n=>!isNaN(n)&&isFinite(n),Tg=(n,t,e)=>{var s,i;for(const[r,o]of e)if(o(n,t))return r;return(i=(s=e[e.length-1])==null?void 0:s[0])!=null?i:0};function Pn(n,t,e){const s=new Array(n.length);let i=e(0);for(let r=0;r<n.length;r++){const o=n[r],a=e(o.candle.timestamp),l={weight:Tg(a,i,t)};s[r]=l,i=a}return s}const ca=n=>{const t={},e={};return sn(n).forEach(([s,i])=>{const r=Jo(s),o=r===null?!1:bg(r);if(r&&o){const a=Qo(r);t[a]=i,e[a]=hg(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class ha{constructor(t,e,s,i,r,o,a){this.eventBus=t,this.config=e,this.chartModel=s,this.scale=i,this.timeZoneModel=r,this.canvasModel=o,this.canvasBoundsContainer=a,this.labelsGroupedByWeight={},this.levelsCache={},this.labelCache=new Map,this.weightToTimeFormatMatcherArray=[],this.weightToTimeFormatsDict={},this.extendedLabelsFilterConfig={minute_1:h=>h>=2},this.calculateCoverUpLevel=()=>{const h=this.scale.currentAnimation,d=this.chartModel.mainCandleSeries.meanCandleWidth;if(Object.getOwnPropertyNames(this.labelsGroupedByWeight).length===0)return-1;const u=h!=null&&h.animationInProgress?vt(d,h.animationConfig.targetZoomX):vt(d,this.scale.zoomX);if(!isFinite(u))return-1;const f=this.config.components.xAxis.fontSize,p=Object.values(this.formatsByWeightMap).reduce((_,S)=>Math.max(S.length,_),1),m=f*p;return Math.round(m/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=ca(this.formatsByWeightMap);this.weightToTimeFormatMatcherArray=Object.entries(c).map(([h,d])=>[parseInt(h,10),d]).sort(([h],[d])=>d-h),this.weightToTimeFormatsDict=l}get labels(){return this.filterLabelsInViewport(this.getLabelsFromChartType())}filterLabelsInViewport(t){const e=this.canvasBoundsContainer.getBounds(M.X_AXIS),s=[];for(const i of t){const r=this.scale.toX(i.value);r<0||r>e.width||s.push(i)}return s}getLabelsFromChartType(){var t,e;const s=(e=(t=this.weightedCache)==null?void 0:t.labels)!=null?e:[];return this.config.components.chart.type==="equivolume"?this.postProcessing(s):s}getVisualCandleAtIndex(t,e,s,i,r){return t>=0&&t<s.length?s[t]:on(e,s,i,t,r)}getVisualCandlesWithFake(t=[]){const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0)return[];const i=Array.from({length:750}).map((r,o)=>on(this.chartModel.mainCandleSeries.dataPoints,this.chartModel.mainCandleSeries.visualPoints,this.chartModel.mainCandleSeries.meanCandleWidth,e.length+o,this.chartModel.getPeriod()));return[...t,...e,...i]}getViewportCandlesWithFake(){var t;const e=this.chartModel.mainCandleSeries.visualPoints;if(e.length===0||this.scale.xEnd-this.scale.xStart<=1)return[];const s=this.chartModel.mainCandleSeries.meanCandleWidth,i=this.chartModel.getPeriod(),r=this.chartModel.mainCandleSeries.dataPoints,o=this.canvasBoundsContainer.getBounds(M.CHART),a=0,l=o.width,c=this.scale.fromX(a),h=this.scale.fromX(l);let d=0;if(e.length>0){const E=e[0];d=E.centerUnit-((t=E.candle.idx)!=null?t:0)*s}const u=500,f=500,p=Math.floor((c-d)/s)-u,m=Math.ceil((h-d)/s)+u,_=Math.floor(p/f)*f,S=Math.ceil(m/f)*f,A=[];for(let E=_;E<=S;E++)A.push(this.getVisualCandleAtIndex(E,r,e,s,i));return[...A]}getAllCandlesWithFake(t=[]){return this.config.components.chart.minCandlesOffset?this.getVisualCandlesWithFake(t):this.getViewportCandlesWithFake()}mapWeightedPointsToLabels(t,e){var s;const i=new Array(t.length);for(let r=0;r<t.length;++r){const o=t[r],a=e[r],l=this.weightToTimeFormatsDict[o.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(a.candle.timestamp);i[r]={weight:o.weight,idx:(s=a.candle.idx)!=null?s:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){this.clearLabelCache();const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=ca(t);this.formatsByWeightMap=t,this.weightToTimeFormatMatcherArray=Object.entries(s).map(([i,r])=>[parseInt(i,10),r]).sort(([i],[r])=>r-i),this.weightToTimeFormatsDict=e,this.generateLabels()}getLabelsFromCache(t){if(this.levelsCache[t])return this.levelsCache[t]}updateLastLabel(t){const e=this.chartModel.mainCandleSeries.visualPoints[this.chartModel.mainCandleSeries.visualPoints.length-2];if(e){const i=Pn([e,t],this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),r=this.mapWeightedPointsToLabels([i[1]],[t]),[o]=r;this.labelsGroupedByWeight=Object.entries(this.labelsGroupedByWeight).reduce((a,[l,c])=>{const h=c.findIndex(u=>u.idx===o.idx);let d=c;if(h!==-1&&(d=c.filter(u=>u.idx!==o.idx)),parseInt(l,10)===o.weight){const u=d.findIndex(f=>f.idx>o.idx);u!==-1?d=[...d.slice(0,u),o,...d.slice(u)]:d.push(o)}return a[l]=d,a},{}),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}}updateHistoryLabels(t){const e=t.concat(this.chartModel.mainCandleSeries.visualPoints[t.length]),s=Pn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=ta(i),o=le(r);for(const c in this.labelsGroupedByWeight)o[c]===void 0&&(o[c]=this.labelsGroupedByWeight[c]);const a=this.chartModel.mainCandleSeries.visualPoints[t.length-1],l=Object.entries(o).sort(([c],[h])=>parseInt(h,10)-parseInt(c,10)).reduce((c,[h,d])=>{const u=parseInt(h,10),f=this.labelsGroupedByWeight[u];if(u===this.weightToTimeFormatMatcherArray[0][0]&&f.shift(),f){const p=f.map(m=>(m.idx=m.idx+t.length,m.value=a.startUnit+a.width+m.value,m));r[u]?c[h]=d.concat(p):c[h]=p}else c[h]=d;return c},{});this.labelsGroupedByWeight=l,this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}generateLabels(t,e=!1){var s;const i=this.getAllCandlesWithFake(t),r=Pn(i,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone));let o=[];if(e)for(let a=0;a<i.length;a++){const l=(s=i[a].candle.idx)!=null?s:a,c=i[a].candle.timestamp,h=`${l}_${c}`;let d=this.labelCache.get(h);d||(d=this.mapWeightedPointsToLabels([r[a]],[i[a]])[0],this.labelCache.set(h,d)),o.push(d)}else o=this.mapWeightedPointsToLabels(r,i);this.labelsGroupedByWeight=ta(o),this.weightedCache=void 0,this.levelsCache={},this.recalculateCachedLabels()}recalculateLabels(){this.recalculateCachedLabels()}recalculateCachedLabels(){const t=this.calculateCoverUpLevel();if(!(t<0)&&(this.weightedCache===void 0||t!==this.weightedCache.coverUpLevel)){const e=this.getLabelsFromCache(t);if(e){this.weightedCache={labels:e,coverUpLevel:t};return}const s=$p(this.filterLabelsByExtendedRules(this.labelsGroupedByWeight,t),t);this.levelsCache[t]=s,this.weightedCache={labels:s,coverUpLevel:t},this.eventBus.fireDraw()}}postProcessing(t){var e,s;const i=[];let r=0,o=1;for(;o<=t.length-1;){const a=t[r],l=t[o];Kp(this.canvasModel.ctx,this.config,a,l,this.scale,30)?((e=l.weight)!=null?e:0)>((s=a.weight)!=null?s:0)&&(r=o):(i.push(a),r=o,o===t.length-1&&i.push(l)),o++}return i}filterLabelsByExtendedRules(t,e){const s=sn(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=Jo(o);if(l){const c=Qo(l);i[c]=a}}return i},{});return sn(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class Mg extends W{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(fs,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}const da=3;class Ag extends W{constructor(t,e,s,i,r,o,a){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=i,this.chartModel=r,this.hitTest=o,this.hitTestCanvasModel=a,this.lastXStart=0,this.lastXEnd=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXEnd=this.scale.xEnd,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const l=this.canvasBoundsContainer.getBounds(M.X_AXIS);this.lastXPxWidth=l.width-this.canvasInputListener.currentPoint.x,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},this.onXDragTick=l=>{let{delta:c}=l;if(!this.touches||this.touches.length===1){const h=this.lastXPxWidth-c;if(h<0)return;const d=this.lastXPxWidth/h,u=this.lastXWidth*d,f=this.lastXStart+(this.lastXWidth-u);this.scale.setXScale(f,this.scale.xEnd);return}if(this.touches.length>1){c=Math.min(this.touches[0].clientX,this.touches[1].clientX)===this.touches[0].clientX?c:-c;let d;c<0?d=1/(1+-c/this.lastXPxWidth*(da-1)):d=1+c/this.lastXPxWidth*(da-1);const f=(this.lastXWidth*d-this.lastXWidth)/2,p=this.lastXStart-f,m=this.lastXEnd+f;(this.lastXStart!==p||this.lastXEnd!==m)&&this.scale.setXScale(p,m)}},this.onXDragEnd=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},this.setDblTapCallback=l=>this.dblTapCallback=l,this.setDblClickCallback=l=>this.dblClickCallback=l,this.dblClickCallback=()=>r.doBasicScale(),this.dblTapCallback=()=>r.doBasicScale(),this.dragNDropXComponent=new Xe(o,{onDragStart:this.onXDragStart,onDragTick:this.onXDragTick,onDragEnd:this.onXDragEnd},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>i.chartAreaPanHandler.chartPanningOptions.horizontal}),this.addChildEntity(this.dragNDropXComponent)}setChartAreaXDragThrottled(t){this.dragNDropXComponent.setShouldThrottle(t)}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasInputListener.observeDbClick(this.hitTest).subscribe(()=>this.dblClickCallback())),this.addRxSubscription(this.canvasInputListener.observeDbTap(this.hitTest).subscribe(()=>{var t;if(this.touches&&((t=this.touches)==null?void 0:t.length)>1){this.touches=void 0;return}this.dblTapCallback()})),this.addRxSubscription(this.canvasInputListener.observeTouchStart(this.hitTest).subscribe(t=>{this.touches=t.touches})),this.addRxSubscription(this.chartModel.candlesPrependSubject.subscribe(({prependedCandlesWidth:t})=>this.lastXStart+=t))}}class Eg extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.eventBus=t,this.config=e,this.canvasModel=s,this.chartComponent=i,this.scale=r,this.chartResizeHandler=l,this.timeZoneModel=h,this.yAxis=p,this.setDblClickCallback=S=>this.xAxisScaleHandler.setDblClickCallback(S),this.setDblTapCallback=S=>this.xAxisScaleHandler.setDblTapCallback(S);const m=new ha(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=m,this.xAxisLabelsModel=new Mg(t,[]);const _=new hn;c.addDrawer(_,"X_AXIS"),this.xAxisDrawer=new Ss(e,s,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),_.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Wp(e,s,o,this.xAxisLabelsModel),_.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new Ag(r,a,o,d,this.chartComponent.chartModel,o.getBoundsHitTest(M.X_AXIS),f),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(M.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(yt(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe(K(({prependedCandles:t})=>t.length!==0),ht(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;fc.includes(this.config.components.chart.type)&&((s=(e=this.xAxisLabelsGenerator).updateHistoryLabels)==null||s.call(e,t))})),this.config.components.chart.minCandlesOffset?this.addRxSubscription(yt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Et(50,Bt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.recalculateLabels())):this.addRxSubscription(yt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Et(150,Bt,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.generateLabels(void 0,!0))),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(ht(()=>wt(this.chartComponent.chartModel.mainCandleSeries.visualPoints)),gt((t,e)=>{var s,i;return((s=t==null?void 0:t.candle)==null?void 0:s.id)===((i=e==null?void 0:e.candle)==null?void 0:i.id)}),K(pi)).subscribe(t=>{var e,s;return(s=(e=this.xAxisLabelsGenerator)==null?void 0:e.updateLastLabel)==null?void 0:s.call(e,t)})),this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(gn(this.yAxis.getAxisType()),gt(),ht(t=>t==="percent")).subscribe(t=>{this.xAxisScaleHandler.setChartAreaXDragThrottled(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 ha?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 Ig=Object.defineProperty,ua=Object.getOwnPropertySymbols,Dg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,fa=(n,t,e)=>t in n?Ig(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,xs=(n,t)=>{for(var e in t||(t={}))Dg.call(t,e)&&fa(n,e,t[e]);if(ua)for(var e of ua(t))Lg.call(t,e)&&fa(n,e,t[e]);return n};class Og{constructor(t,e,s,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=s&&xs(xs({},s),this.getLabelDrawConfig(this.chartModel.mainCandleSeries,!0));if(i){const r={labels:[i]},o=this.lastCandleLabelsByChartType[this.chartConfig.components.chart.type];o==null||o(r,this.chartModel.mainCandleSeries),t.push(r)}return this.chartModel.candleSeries.forEach((r,o)=>{if(o===0)return;const a=this.getYAxisVisualLabel(r),l=a&&xs(xs({},a),this.getLabelDrawConfig(r,!1));if(l){const c={labels:[l]},h=this.lastCandleLabelsByChartType[r.config.type];h==null||h(c,this.chartModel.mainCandleSeries),t.push(c)}}),t}getYAxisVisualLabel(t){const e=wt(t.dataPoints);if(e){const s=t.view.toY(e.close);if(isFinite(s)){const i=this.yAxisConfig.labels.settings.lastPrice.mode,r=this.yAxisConfig.labels.settings.lastPrice.type;return{y:s,labelWeight:0,labelText:this.chartModel.pane.valueFormatter(e.close,{formatWithSeparators:!0,dataSeries:t}),mode:i,labelType:r,description:t.instrument.symbol}}}return null}getLabelDrawConfig(t,e){const s=this.yAxisConfig.labels.settings.lastPrice.type,i=t.colors.labels,{rectLabelTextColor:r="white",rectLabelInvertedTextColor:o="black"}=this.chartConfig.colors.yAxis,a=this.resolveLabelColorFn(t.config.type);if(!i)return{bgColor:"#FFFFFF",textColor:re("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:tp(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):re(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):re(l,r,o),rounded:!0}}}class Bg{constructor(t,e,s,i,r,o){this.yAxisLabelsCanvasModel=t,this.yAxisDescriptionsCanvasModel=e,this.backgroundCanvasModel=s,this.canvasBoundsContainer=i,this.fullConfig=r,this.paneManager=o}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx,s=this.yAxisDescriptionsCanvasModel.ctx;this.paneManager.yExtents.forEach(i=>{if(i.yAxis.state.visible){const r=i.getYAxisBounds(),o=this.canvasBoundsContainer.getBounds(M.ALL_PANES),a=i.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(l=>{var c;const h=(c=l.bounds)!=null?c:r;l.labels.forEach(d=>mo(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>mo(t,s,e,r,o,l,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=s[r.subGroupId])!=null?o:[];if(s[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS($));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];kr(e,{x:h.x,y:zi(d,h)},{x:h.x+h.width-6,y:zi(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Rg{constructor(t,e,s){this.fullConfig=t,this.canvasModel=e,this.paneManager=s}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const s=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;this.fullConfig.components.chart.applyBackgroundToAxes.y||(r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height));const o=oe(e.state),a=Xt(o,r),l=this.getLabelTextColor();r.save(),Kt(r,i),this.drawLabels(r,s,i,a,o,l,e),r.restore()}})}drawLabels(t,e,s,i,r,o,a){t.fillStyle=o,t.font=r;const l=t.measureText("00.0"),c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent,h=s.y+c,d=s.y+s.height-c;e.forEach(u=>{const f=a.scale.toY(u.value);f>h&&f<d&&Fg(t,s,u.text,f,i,r,a.state.labelBoxMargin.end,a.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const Fg=(n,t,e,s,i,r,o,a)=>{const l=a==="right"?t.x+t.width-Mt(e,n,r)-o:t.x+o;n.fillText(e,l,s+i/2-1)};class Hg{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&Gl.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 F,s=e.next.bind(e),i=e.unsubscribe.bind(e);return this.on(t,s),e.unsubscribe=()=>{this.unsub(t,s),i()},e.asObservable()},this.onPrior=(t,e)=>this.add(this.UNKNOWN_ARR.unshift,t,e),this.off=this.unsub,this.fire=(t,...e)=>{var s;if(!this.muted){const i=(s=this.handlers[t])!=null?s:[];let r;for(r=0,i.length;r<i.length;r++)i[r].apply(null,e)}},this.fireAsync=(t,e)=>{if(!this.muted)return window.setTimeout(this.fire.bind(this,t,e),0)},this.setMuted=t=>{this.muted=t},this.clear=()=>{this.handlers={}}}fireDraw(t){this.fire(fs,t)}}class kg extends W{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(ht(r=>i.components.chart.highlightActiveCandle?r:void 0),gt()).subscribe(r=>{r&&this.setCandleAsActive(r,t,e)})}setCandleAsActive(t,e,s){if(t.touches.length===1){const i=t.touches.item(0);if(i!==null){const r=this.getTouchXPosition(i,e),o=s.candleFromX(r);o&&s.mainCandleSeries.setActiveCandle(o)}}}getTouchXPosition(t,e){const s=e.getBoundingClientRect(),i=document.body.scrollLeft||document.documentElement.scrollLeft;return t.pageX-s.left-i}}class jg{constructor(t,e,s,i,r){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${St()}`,this.canvasResized=new F,this.recentlyResized=!1,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){Me(this.animFrameId,()=>this.fireUpdates())}fireUpdates(){const t=this.resizerElement.getBoundingClientRect(),e={x:t.x,y:t.y,width:t.width,height:t.height};this.config||(this.frameElement.style.height=this.resizerElement.clientHeight+"px"),(this.previousBCR===void 0||this.isBCRDimensionsDiffer(this.previousBCR,e))&&(this.previousBCR=e,this.recentlyResized=!0,this.canvasModels.forEach(s=>this.previousBCR&&s.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(us,e),this.bus.fire(fs))}clearResizedFlag(){this.recentlyResized=!1}isBCRDimensionsDiffer(t,e){return t.height!==e.height||t.width!==e.width}unsubscribeAnimationUpdate(){if(this.resizerElement)try{this.elementResizeDetector.unobserve(this.resizerElement)}catch(t){console.warn("ChartResizeHandler.ts, unsubscribeAnimationUpdate failed")}}wasResized(){return this.recentlyResized}}var Yg=Array.isArray,Ng=Object.getPrototypeOf,Xg=Object.prototype,Wg=Object.keys;function Vg(n){if(n.length===1){var t=n[0];if(Yg(t))return{args:t,keys:null};if(zg(t)){var e=Wg(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function zg(n){return n&&typeof n=="object"&&Ng(n)===Xg}var Ug=Array.isArray;function Gg(n,t){return Ug(t)?n.apply(void 0,ct([],H(t))):n(t)}function pa(n){return ht(function(t){return Gg(n,t)})}function Zg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function $g(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=$e(n),s=ul(n),i=Vg(n),r=i.args,o=i.keys;if(r.length===0)return Ke([],e);var a=new pt(Kg(r,e,o?function(l){return Zg(o,l)}:ne));return s?a.pipe(pa(s)):a}function Kg(n,t,e){return e===void 0&&(e=ne),function(s){ga(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){ga(t,function(){var d=Ke(n[h],t),u=!1;d.subscribe(Ct(s,function(f){r[h]=f,u||(u=!0,a--),a||s.next(e(r.slice()))},function(){--o||s.complete()}))},s)},c=0;c<i;c++)l(c)},s)}}function ga(n,t,e){n?Yt(e,n,t):t()}class qg extends W{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new ft(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=$g([s,i]).pipe(K(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}!l&&!Ot()&&(this.crossSubject.next(null),r=!0)});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}class Jg{constructor(t,e,s,i){this.visualCandle=t,this.price=e,this.priceFormatter=s,this.toY=i}get high(){return this.visualCandle.high}get low(){return this.visualCandle.low}get open(){return this.visualCandle.open}get close(){return this.visualCandle.close}get volume(){return this.visualCandle.candle.volume}get openY(){return this.toY(this.open)}get closeY(){return this.toY(this.close)}get highY(){return this.toY(this.high)}get lowY(){return this.toY(this.low)}get openFormatted(){return this.priceFormatter(this.open)}get closeFormatted(){return this.priceFormatter(this.close)}get highFormatted(){return this.priceFormatter(this.high)}get lowFormatted(){return this.priceFormatter(this.low)}get closestOHLCY(){return this.toY([this.close,this.open,this.high,this.low].sort((t,e)=>Math.abs(t-this.price)-Math.abs(e-this.price))[0])}}class Qg{constructor(t){this.chartModel=t}getData(t){const{x:e,y:s}=t,r=this.chartModel.candleFromX(e).idx||0,o=this.chartModel.getVisualCandle(r),a=this.chartModel.priceFromY(s);return o&&new Jg(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class tm{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof to)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 em=Object.defineProperty,sm=Object.defineProperties,nm=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,im=Object.prototype.hasOwnProperty,rm=Object.prototype.propertyIsEnumerable,va=(n,t,e)=>t in n?em(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ue=(n,t)=>{for(var e in t||(t={}))im.call(t,e)&&va(n,e,t[e]);if(ma)for(var e of ma(t))rm.call(t,e)&&va(n,e,t[e]);return n},We=(n,t)=>sm(n,nm(t));class om extends W{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.mainCanvasTouchHandler=c,this.formatterFactory=h,this.hoverSubject=new ft(null),this.longTouchActivatedSubject=new ft(!1),this.longTouchCrosshairSuppressed=!1,this.hoverOverLastCandle=!1,this.xFormatter=()=>"";const d=new Qg(this.chartModel),u=new tm(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(Io(()=>this.scale.initialViewportValidSubject.pipe(K(Boolean)))).subscribe(()=>{const e=this.chartModel.getLastVisualCandle();e&&this.createAndFireHoverFromCandle(e)})),this.addRxSubscription(this.chartModel.candlesUpdatedSubject.subscribe(()=>{const e=this.chartModel.getLastVisualCandle();this.hover!==null&&e!==void 0&&this.hoverOverLastCandle&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?(this.hoverOverLastCandle=!1,this.hoverSubject.next(null)):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(yt(this.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>this.recalculateCrossToolXFormatter())),this.addRxSubscription(this.canvasInputListener.observeTouchStart().subscribe(e=>{var s;this.crossEventProducer.crossToolTouchInfo.isCommonTap=!0;const{clientX:i,clientY:r}=e.touches[0];if(this.longTouchActivatedSubject.getValue())this.crossEventProducer.crossToolTouchInfo.temp={x:i-this.canvasBoundsContainer.canvasOnPageLocation.x,y:r-this.canvasBoundsContainer.canvasOnPageLocation.y};else{const o=((s=this.paneManager.getPaneIfHit({x:i,y:r}))==null?void 0:s.uuid)||"";this.createAndFireHover([i,r,o])}}));const t=this.canvasBoundsContainer.getBoundsHitTest(M.ALL_PANES);this.addRxSubscription(this.canvasInputListener.observeLongTouchStart(t).subscribe(e=>{var s;if(this.longTouchCrosshairSuppressed||(this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.mainCanvasTouchHandler.canvasTouchInfo.isMoving||this.chartModel.config.components.crossTool.type==="none"||e.touches.length>1))return;this.longTouchActivatedSubject.next(!0),this.crossEventProducer.crossToolTouchInfo.isSet=!1;const r=e.touches[0].clientX-this.canvasBoundsContainer.canvasOnPageLocation.x,o=e.touches[0].clientY-this.canvasBoundsContainer.canvasOnPageLocation.y;this.crossEventProducer.crossToolTouchInfo.fixed={x:r,y:o};const a=((s=this.paneManager.getPaneIfHit({x:r,y:o}))==null?void 0:s.uuid)||"";this.createAndFireHover([r,o,a]),this.crossEventProducer.crossSubject.next([r,o,a]),this.paneManager.chartPanComponent.setChartPanningOptions(!1,!1)})),this.addRxSubscription(this.canvasInputListener.observeTouchEndDocument().subscribe(e=>{var s,i,r,o,a,l,c,h;const{clientX:d,clientY:u}=e.changedTouches[0],{fixed:f,temp:p}=this.crossEventProducer.crossToolTouchInfo,m=d-this.canvasBoundsContainer.canvasOnPageLocation.x,_=u-this.canvasBoundsContainer.canvasOnPageLocation.y;if(this.crossEventProducer.crossToolTouchInfo.isCommonTap&&!Oo(m,p.x,_,p.y)){this.resetCrossTool();return}if(this.crossEventProducer.crossToolTouchInfo.isSet){const S=(c=(l=this.crossEventProducer.crossToolHover)==null?void 0:l.paneId)!=null?c:"CHART",A=this.canvasBoundsContainer.getBounds(M.PANE_UUID(S)),E=A.y+5,j=A.y+A.height-5,B=m-p.x,R=_-p.y,k=f.x<0?0:f.x>A.width?A.width:f.x+=B,z=f.y<E?E:f.y>j?j:f.y+=R;this.crossEventProducer.crossToolTouchInfo.fixed={x:k,y:z},this.crossEventProducer.crossToolTouchInfo.temp={x:k,y:z};const X=(h=this.crossEventProducer.crossToolHover)!=null?h:this.hover;if(!X)return;this.crossEventProducer.crossToolHover=We(ue({},X),{x:k,y:z,paneId:S}),this.crossEventProducer.crossSubject.next([k,z,S])}else{this.crossEventProducer.crossToolTouchInfo.isSet=!0;const S=this.crossEventProducer.crossToolHover,A=(s=S==null?void 0:S.x)!=null?s:m,E=(i=S==null?void 0:S.y)!=null?i:_;this.crossEventProducer.crossToolTouchInfo.temp={x:A,y:E},this.crossEventProducer.crossToolTouchInfo.fixed={x:A,y:E};const j=(a=(o=S==null?void 0:S.paneId)!=null?o:(r=this.paneManager.getPaneIfHit({x:A,y:E}))==null?void 0:r.uuid)!=null?a:"",B=S!=null?S:this.hover;if(!B)return;this.crossEventProducer.crossToolHover=We(ue({},B),{x:A,y:E,paneId:j}),this.crossEventProducer.crossSubject.next([A,E,j])}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=bo(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),s=this.scale.toY(t.close);return this.createHover(e,s,$)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const r=this.chartModel.candleFromX(t,!0).timestamp,o={x:t,y:e,timestamp:r,timeFormatted:this.xFormatter(r),paneId:s},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>We(ue({},l),{[c[0]]:c[1].getData(o)}),{});return ue(ue({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){var e,s;if(!this.hover)return;const i=Ot()&&this.longTouchActivatedSubject.getValue()&&this.crossEventProducer.crossSubject.getValue()!==null,r=this.crossEventProducer.crossToolHover,o=i?(e=r==null?void 0:r.x)!=null?e:this.hover.x:this.hover.x,a=i?(s=r==null?void 0:r.y)!=null?s:this.hover.y:this.hover.y,l=this.chartModel.candleFromX(o,!0),c=t.candle.idx,h=l.idx;if(c!==void 0&&h!==void 0&&h<c&&o<t.xStart(this.scale))return;const d=this.createHoverFromCandle(t);if(d){const u=We(ue({},d),{x:o,y:a});this.fireHover(u)}}updateHoverLastCandle(t){const e=this.chartModel.getLastVisualCandle();if(!e){this.hoverOverLastCandle=!1;return}const s=this.chartModel.candleFromX(t.x,!0),i=e.candle.idx,r=s.idx,o=i!==void 0&&r!==void 0&&r<i&&t.x<e.xStart(this.scale);this.hoverOverLastCandle=!o&&(e.candle.timestamp<=t.timestamp||i!==void 0&&r!==void 0&&r===i)}createAndFireHover([t,e,s]){const i=this.createHover(t,e,s);this.fireHover(i)}fireHover(t){var e,s;if(t){if(Ot()&&this.config.components.crossTool.type!=="none"){const i=this.crossEventProducer.crossToolHover,r=i?(e=i.candleHover)==null?void 0:e.visualCandle.candle:(s=t.candleHover)==null?void 0:s.visualCandle.candle;r&&this.chartModel.mainCandleSeries.setActiveCandle(r)}this.updateHoverLastCandle(t),this.hoverSubject.next(t)}else this.hoverOverLastCandle=!1,this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}setLongTouchCrosshairSuppressed(t){this.longTouchCrosshairSuppressed=t}resetCrossTool(t=!1){this.paneManager.chartPanComponent.setChartPanningOptions(!0,!0),this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose(),this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isSet=!1,t&&(this.crossEventProducer.crossToolTouchInfo.isCommonTap=!1,this.crossEventProducer.crossToolTouchInfo.fixed={x:0,y:0},this.crossEventProducer.crossToolTouchInfo.temp={x:0,y:0})}registerHoverProducerPart(t,e){this.hoverProducerParts=We(ue({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const ba={left:0,middle:1,right:2};function bt(n,t,e,s){return n.addEventListener(e,t,s),function(){n.removeEventListener(e,t,s)}}function _e(n){return t=>{t.button===ba.left&&n(t)}}var am=["addListener","removeListener"],lm=["addEventListener","removeEventListener"],cm=["on","off"];function Tn(n,t,e,s){if(Y(e)&&(s=e,e=void 0),s)return Tn(n,t,e).pipe(pa(s));var i=H(um(n)?lm.map(function(a){return function(l){return n[a](t,l,e)}}):hm(n)?am.map(Ca(n,t)):dm(n)?cm.map(Ca(n,t)):[],2),r=i[0],o=i[1];if(!r&&Rs(n))return Hs(function(a){return Tn(a,t,e)})(Lt(n));if(!r)throw new TypeError("Invalid event target");return new pt(function(a){var l=function(){for(var c=[],h=0;h<arguments.length;h++)c[h]=arguments[h];return a.next(1<c.length?c:c[0])};return r(l),function(){return o(l)}})}function Ca(n,t){return function(e){return function(s){return n[e](t,s)}}}function hm(n){return Y(n.addListener)&&Y(n.removeListener)}function dm(n){return Y(n.on)&&Y(n.off)}function um(n){return Y(n.addEventListener)&&Y(n.removeEventListener)}var fm=Object.defineProperty,ya=Object.getOwnPropertySymbols,pm=Object.prototype.hasOwnProperty,gm=Object.prototype.propertyIsEnumerable,wa=(n,t,e)=>t in n?fm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,mm=(n,t)=>{for(var e in t||(t={}))pm.call(t,e)&&wa(n,e,t[e]);if(ya)for(var e of ya(t))gm.call(t,e)&&wa(n,e,t[e]);return n};const _s=class pe extends W{constructor(t,e){super(),this.eventBus=t,this.element=e,this.xDragStartSubject=new F,this.xDragSubject=new F,this.xDragTickSubject=new F,this.xDragEndSubject=new F,this.yDragStartSubject=new F,this.yDragSubject=new F,this.yDragTickSubject=new F,this.yDragEndSubject=new F,this.mouseMoveSubject=new F,this.mouseMoveDocumentSubject=new F,this.clickSubject=new F,this.clickDocumentSubject=new F,this.dbClickSubject=new F,this.dbTapSubject=new F,this.mouseDownSubject=new F,this.mouseUpSubject=new F,this.mouseUpDocumentSubject=new F,this.wheelSubject=new F,this.touchStartSubject=new F,this.touchStartTimestamp=0,this.touchMoveSubject=new F,this.touchEndSubject=new F,this.touchCancelSubject=new F,this.longTouchStartSubject=new F,this.longTouchEndSubject=new F,this.contextMenuSubject=new F,this.fastTouchScroll=new F,this.mouseLeavesCanvasSubject=new F,this.dragStartPoint={x:0,y:0},this.prevDragPoint={x:0,y:0},this.currentPoint={x:0,y:0},this.currentPointDocument={x:0,y:0},this.dragging=!1,this.canvasBounds={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.cachedElementRect=null,this.rectCacheValid=!1,this.documentDragListeners=[],this.dragProcessListener=()=>{this.xDragSubject.next(this.currentPoint.x-this.dragStartPoint.x),this.yDragSubject.next(this.currentPoint.y-this.dragStartPoint.y),this.xDragTickSubject.next(this.currentPoint.x-this.prevDragPoint.x),this.yDragTickSubject.next(this.currentPoint.y-this.prevDragPoint.y),this.prevDragPoint.x=this.currentPoint.x,this.prevDragPoint.y=this.currentPoint.y},this.dragStartListener=s=>{this.isDraggable(s)&&(this.updateCurrentPoints(s),this.dragging=!0,this.dragStartEvent=s,this.cleanupDocumentDragListeners(),this.dragStartPoint=pe.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=mm({},this.dragStartPoint),pe.DRAG_EVENTS.forEach(i=>{document.addEventListener(i,this.dragProcessListener,!0);const r=document.removeEventListener.bind(document,i,this.dragProcessListener,!0);this.documentDragListeners.push(r),this.addSubscription(r)}),this.dragProcessListener())},this.dragListener=()=>this.mouseMoveDocumentSubject.next(this.currentPoint),this.updateElementOffsetListener=()=>this.mouseMoveSubject.next(this.currentPoint),this.dragEndListener=()=>{this.dragging=!1,this.cleanupDocumentDragListeners(),this.xDragEndSubject.next(),this.yDragEndSubject.next()},this.updateCurrentPoints=s=>{this.updateCurrentDocumentPoint(s),this.updateCurrentMousePoint(s)}}getElementRect(){if(this.rectCacheValid&&this.cachedElementRect)return this.cachedElementRect;try{if(!this.element||!this.element.isConnected)return this.createFallbackRect();const t=this.element.getBoundingClientRect();return this.cachedElementRect=t,this.rectCacheValid=!0,t}catch(t){return this.createFallbackRect()}}createFallbackRect(){return typeof DOMRect!="undefined"?new DOMRect(0,0,0,0):{x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0,toJSON:()=>({})}}invalidateRectCache(){this.rectCacheValid=!1}initializeRectCache(){this.invalidateRectCache();const t=this.getElementRect();this.canvasBounds.x=t.left,this.canvasBounds.y=t.top,this.canvasBounds.width=t.width,this.canvasBounds.height=t.height}cleanupDocumentDragListeners(){if(!this.documentDragListeners||!Array.isArray(this.documentDragListeners)){this.documentDragListeners=[];return}this.documentDragListeners.forEach(t=>{try{t()}catch(e){console.warn("Error cleaning up drag listener:",e)}}),this.documentDragListeners=[]}doDeactivate(){this.invalidateRectCache(),this.cachedElementRect=null,this.cleanupDocumentDragListeners(),super.doDeactivate()}isDraggable(t){return t instanceof MouseEvent?t.button===ba.left:t instanceof TouchEvent}startDragging(t){this.updateCurrentPoints(t),this.dragStartListener(t)}movePointer(t){this.updateCurrentPoints(t),this.dragListener(),this.updateElementOffsetListener(),this.dragging&&this.dragProcessListener()}stopDragging(){this.dragEndListener()}fixTextSelection(){const t=e=>(e.preventDefault(),!1);this.element.addEventListener("selectstart",t,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"selectstart",t,!1))}doActivate(){this.fixTextSelection(),this.documentDragListeners=[],pe.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),pe.DRAG_EVENTS.forEach(s=>{document.addEventListener(s,this.dragListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragListener)),this.element.addEventListener(s,this.updateElementOffsetListener),this.addSubscription(this.element.removeEventListener.bind(this.element,s,this.updateElementOffsetListener))}),pe.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(bt(this.element,_e(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(bt(document,_e(s=>this.clickDocumentSubject.next(s)),"click"));const t=Cs();if(t==="apple"||t==="mobile"){let s=null;const i=a=>{a.preventDefault(),s?(this.dbTapSubject.next(this.currentPoint),clearTimeout(s),s=null):s=window.setTimeout(()=>{s=null},250)};this.addSubscription(bt(this.element,i,"touchend"));const r=(a,l=200)=>{a.preventDefault();let c=!1,h=null;h=setTimeout(()=>{c=!0,this.longTouchStartSubject.next(a)},l);const d=f=>{f.preventDefault(),f.touches.length>1&&h&&clearTimeout(h)},u=f=>{f.preventDefault(),h&&clearTimeout(h),c&&(c=!1,this.longTouchEndSubject.next(f)),this.element.removeEventListener("touchend",u),this.element.removeEventListener("touchmove",d)};this.element.addEventListener("touchmove",d),this.element.addEventListener("touchend",u)};this.addSubscription(bt(this.element,a=>r(a),"touchstart"));const o=a=>{if(a.preventDefault(),this.prevDragPoint.x>this.dragStartPoint.x){const h=this.touchStartTimestamp,u=Date.now()-h,p=(this.prevDragPoint.x-this.dragStartPoint.x)/this.canvasBounds.width*100>35,m=u<=250;p&&m&&this.fastTouchScroll.next(a)}};this.addSubscription(bt(this.element,o,"touchend"))}this.addSubscription(bt(this.element,_e(()=>this.dbClickSubject.next(this.currentPoint)),"dblclick")),this.addSubscription(bt(this.element,s=>{this.touchStartSubject.next(s),this.touchStartTimestamp=Date.now()},"touchstart")),this.addSubscription(bt(this.element,s=>this.touchMoveSubject.next(s),"touchmove",!0)),this.addSubscription(bt(this.element,s=>this.touchEndSubject.next(s),"touchend")),this.addSubscription(bt(this.element,s=>this.touchCancelSubject.next(s),"touchcancel")),this.addSubscription(bt(this.element,s=>{this.updateCurrentPoints(s),this.wheelSubject.next(s),s.preventDefault()},"wheel")),this.addSubscription(bt(this.element,s=>this.contextMenuSubject.next(s),"contextmenu")),this.addSubscription(bt(this.element,_e(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(bt(this.element,_e(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(bt(document,_e(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(us).subscribe(()=>{this.invalidateRectCache();const s=this.getElementRect();this.canvasBounds.x=s.left,this.canvasBounds.y=s.top,this.canvasBounds.width=s.width,this.canvasBounds.height=s.height})),this.addRxSubscription(Tn(document,"scroll",{capture:!0,passive:!0}).pipe(Et(Vt,as,{trailing:!0})).subscribe(()=>this.invalidateRectCache()));const e=()=>{this.mouseLeavesCanvasSubject.next(!0)};this.element.addEventListener("mouseleave",e,!1),this.addSubscription(this.element.removeEventListener.bind(this.element,"mouseleave",e,!1))}getCurrentMousePoint(){return this.currentPoint}trackMousePosition(){pe.DRAG_EVENTS.forEach(t=>{document.addEventListener(t,this.updateCurrentPoints,!0),this.addSubscription(()=>document.removeEventListener(t,this.updateCurrentPoints,!0))})}updateCurrentDocumentPoint(t){"pageX"in t?this.currentPointDocument.x=t.pageX:t.touches!==void 0&&(this.currentPointDocument.x=t.touches[0].pageX),"pageY"in t?this.currentPointDocument.y=t.pageY:t.touches!==void 0&&(this.currentPointDocument.y=t.touches[0].pageY)}updateCurrentMousePoint(t){const e=this.getElementRect();"clientX"in t?this.currentPoint.x=t.clientX-e.left:t.touches!==void 0&&(this.currentPoint.x=t.touches[0].clientX-e.left),"clientY"in t?this.currentPoint.y=t.clientY-e.top:t.touches!==void 0&&(this.currentPoint.y=t.touches[0].clientY-e.top)}static copyPoint(t){return{x:t.x,y:t.y}}observeMouseMove(t=()=>!0){return this.mouseMoveSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe(K(()=>!this.dragging))}observeMouseMoveDocument(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe(K(()=>t(this.currentPointDocument.x,this.currentPointDocument.y)),ht(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(t=()=>!0){return this.xDragStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(t=()=>!0){return this.xDragSubject.pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(t=()=>!0){return this.xDragEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(t=()=>!0){return this.yDragStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(t=()=>!0){return this.yDragSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(t=()=>!0){return this.yDragEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(t=()=>!0,e=!1){const s=this.mouseMoveSubject.asObservable().pipe(K(()=>!(e&&this.dragging)),ht(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(ht(()=>!1));return yt(s,i).pipe(gt())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(t=()=>!0){return this.clickSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(t=()=>!0){return this.dbClickSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(t=()=>!0){return this.dbTapSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeWheel(t=()=>!0){return this.wheelSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchStart(t=()=>!0){return this.touchStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(t=()=>!0){return this.touchMoveSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchEndDocument(){return this.touchEndSubject.asObservable()}observeTouchCancelDocument(){return this.touchCancelSubject.asObservable()}observeMouseDown(t=()=>!0){return this.mouseDownSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(t=()=>!0){return this.mouseUpSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(t=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(t=()=>!0){return this.contextMenuSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)),Wo(e=>e.preventDefault()))}observeLongTouchStart(t=()=>!0){return this.longTouchStartSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(t=()=>!0){return this.longTouchEndSubject.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(t=()=>!0){return this.fastTouchScroll.asObservable().pipe(K(()=>t(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};_s.DRAG_START_EVENTS=["mousedown","touchstart"],_s.DRAG_EVENTS=["mousemove","touchmove"],_s.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];let vm=_s;var bm=(function(n){V(t,n);function t(e,s,i){e===void 0&&(e=1/0),s===void 0&&(s=1/0),i===void 0&&(i=Js);var r=n.call(this)||this;return r._bufferSize=e,r._windowTime=s,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=s===1/0,r._bufferSize=Math.max(1,e),r._windowTime=Math.max(1,s),r}return t.prototype.next=function(e){var s=this,i=s.isStopped,r=s._buffer,o=s._infiniteTimeWindow,a=s._timestampProvider,l=s._windowTime;i||(r.push(e),!o&&r.push(a.now()+l)),this._trimBuffer(),n.prototype.next.call(this,e)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var s=this._innerSubscribe(e),i=this,r=i._infiniteTimeWindow,o=i._buffer,a=o.slice(),l=0;l<a.length&&!e.closed;l+=r?1:2)e.next(a[l]);return this._checkFinalizedStatuses(e),s},t.prototype._trimBuffer=function(){var e=this,s=e._bufferSize,i=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,a=(o?1:2)*s;if(s<1/0&&a<r.length&&r.splice(0,r.length-a),!o){for(var l=i.now(),c=0,h=1;h<r.length&&r[h]<=l;h+=2)c=h;c&&r.splice(0,c+1)}},t})(F);const Mn={};function Cm(n){return Mn[n]||(Mn[n]=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Mn[n]}const Sa=(n,t=Date.now())=>{const s=Cm(n).format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(s);if(i){const r=Date.UTC(+i[3],+i[1]-1,+i[2],+i[4]%24,+i[5],+i[6]);let o=t;const a=o%1e3;return o-=a>=0?a:1e3+a,r-o}return 0},xa=60*1e3;class ym{constructor(t){this.config=t,this.timeZoneChangedSubject=new bm,this.currentTzOffset=e=>Sa(this.config.timezone,e)+new Date(e).getTimezoneOffset()*xa,this.formatterCache={},this.dateTimeFormatterFactory=this.initFormatterFactory(this.config.dateFormatter)}setTimeZone(t){this.config.timezone=t,this.formatterCache={},this.timeZoneChangedSubject.next(t)}observeTimeZoneChanged(){return this.timeZoneChangedSubject.asObservable()}initFormatterFactory(t){let e;if(t&&typeof t=="function")e=t;else if(t&&t.createFormatterFunction&&typeof t.createFormatterFunction=="function"){const s=t.createFormatterFunction;e=i=>s(i).bind(t)}else e=Wu(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+Sa(t,e)+new Date(e).getTimezoneOffset()*xa):e=>new Date(e)}}class wm extends W{constructor(t,e,s){super(),this.hitTestCanvasModel=t,this.canvasAnimation=e,this.eventBus=s}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasAnimation.animationInProgressSubject.subscribe(()=>{const t=this.canvasAnimation.animationInProgressSubject.getValue();this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!t)})),this.addRxSubscription(this.hitTestCanvasModel.hitTestDrawersPredicateSubject.pipe(gt((t,e)=>t!==e&&t===!0&&e===!1)).subscribe(()=>this.eventBus.fireDraw([this.hitTestCanvasModel.canvasId])))}}var Sm=Object.defineProperty,xm=Object.defineProperties,_m=Object.getOwnPropertyDescriptors,_a=Object.getOwnPropertySymbols,Pm=Object.prototype.hasOwnProperty,Tm=Object.prototype.propertyIsEnumerable,Pa=(n,t,e)=>t in n?Sm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mm=(n,t)=>{for(var e in t||(t={}))Pm.call(t,e)&&Pa(n,e,t[e]);if(_a)for(var e of _a(t))Tm.call(t,e)&&Pa(n,e,t[e]);return n},Am=(n,t)=>xm(n,_m(t));class Em extends fi{constructor(t){super(t),this.animations={},this.animFrameId="animation",this.animationInProgressSubject=new ft(!1),this.microtaskQueued=!1}startViewportMovementAnimation(t,e,s=me,i){const r=new ci(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ai(Am(Mm({},i),{duration:i&&i.duration||De}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=De,i){const r=new li({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0,delete this.animations[t]),Object.keys(this.animations).length===0&&this.stopInterval()}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():this.microtaskQueued||(this.microtaskQueued=!0,queueMicrotask(()=>{this.microtaskQueued=!1,this.processAnimation(),this.eventBus.fireDraw()}))}stopInterval(){Sl(this.animFrameId),this.microtaskQueued=!1}}class An{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;pc(r),this.config=r;const o=Bc(r);t.innerHTML="",t.appendChild(o.content),this.id=(s=t.getAttribute("data-id"))!=null?s:"",r.fixedSize&&(t.style.width=r.fixedSize.width+"px",t.style.height=r.fixedSize.height+"px");const a=new ym(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=Rc(t);this.elements=c;const h=new Hg;this.bus=h;const d=new jg(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 Yd(h,d);this.drawingManager=u;const f=kd(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=de(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new Se(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const m=de(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),_=de(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),S=new qs(r,h,f,l,d);this.canvasBoundsContainer=S;const A=c.mainCanvas.parentElement;if(A===null)throw new Error("Couldn't get main canvas parent");const E=new vm(h,A);this.canvasInputListener=E,this.chartComponents.push(this.canvasInputListener);const j=[h,c.hitTestCanvas,E,S,u,r,this.canvasModels,c.chartResizer],B=new nf(...j);this.hitTestCanvasModel=B;const R=new Se(B);u.addDrawer(R,"HIT_TEST_CLEAR");const k=Ie?new Em(h):new fi(h);this.canvasAnimation=k;const z=M.PANE_UUID($),X=new Fr(r,()=>S.getBounds(z),k);this.scaleModel=X;const G=de(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=G,this.cursorHandler=new Lc(c.canvasArea,E,S,B),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new qg(E,S),this.chartComponents.push(this.crossEventProducer);const Z=new xh("candle");this.chartBaseModel=Z;const U=new Wf(h,X,S,r,k,E,A,Z,B);this.chartPanComponent=U,this.chartComponents.push(U),this.userInputListenerComponents.push(U.chartAreaPanHandler);const Q=new wm(B,k,h);this.hitTestComponent=Q,this.chartComponents.push(Q);const J=new Tp(Z,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,X,S,r,k,E,u,this.cursorHandler,this.crossEventProducer,U,f,m,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=J;const tt=this.paneManager.panes[$];this.mainPane=tt,this.chartComponents.push(J),this.dynamicObjects=new Nu(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new wu(Z,J,h,this.dynamicObjectsCanvasModel,r,X,l,A,S,d);const et=new iu(this.chartModel,this.dynamicObjectsCanvasModel,r,X,S,u,B,E,G,U,J,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(et),this.chartComponent=et;const st=this.chartComponent.chartModel;this.chartModel=st,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),B.addSubscriber(J.hitTestController),this.xAxisComponent=new Eg(h,r,f,et,X,S,E,d,this.drawingManager,a,U,this.cursorHandler,this.hitTestCanvasModel,this.mainPane.yAxis),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const ot=new Se(f);u.addDrawer(ot,"MAIN_CLEAR");const at=new kg(A,st,E,r);this.chartComponents.push(at),this.watermarkComponent=new Np(J,st,h,r,S,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const xt=de(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new xf(h,r,st,f,S,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(st)),this.navigationMapComponent=new Lf(h,st,f,r,E,S,u,l,U,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Zt=new mf(r,this.dynamicObjectsCanvasModel,st,S,u);this.chartComponents.push(Zt),this.initYAxisDrawer(m,_),this.yAxisComponent=tt.mainExtent.yAxis;const Pe=new Og(this.chartModel,this.config,tt.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(Pe,ae.MAIN),this.volumesComponent=new Rp(this.dynamicObjectsCanvasModel,et,X,S,u,r,J,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const Ia=new Po(f,X,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(M.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(z),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>[],void 0,void 0,()=>r.components.grid.visible,this.mainPane.mainExtent.idx);this.chartComponents.push(Ia),this.hoverProducer=new om(this.crossEventProducer,X,r,st,E,this.canvasBoundsContainer,this.paneManager,a,U.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new Hu(r,xt,S,u,J,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel,this.chartModel),this.chartComponents.push(this.crossToolComponent);const Da=de(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),En=new Mp(this.elements,Da);this.snapshotComponent=En,this.chartComponents.push(En);const Ts=new ff(r,this.dynamicObjectsCanvasModel,B,st,S,u,l,this.cursorHandler);this.eventsComponent=Ts,this.chartComponents.push(Ts),this.chartComponents.forEach(Ms=>Ms.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=Nl(this.components)}initYAxisDrawer(t,e){const s=new hn,i=new Se(t),r=new Se(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new Rg(this.config,t,this.paneManager);s.addDrawer(o);const a=new Bg(t,e,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);this.drawingManager.addDrawer(a,"Y_AXIS_PRICE_LABELS")}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:s=>e.test(s)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const s in e)s in t?typeof t[s]=="object"&&An.mergeConfig(t[s],e[s]):t[s]=e[s];return t}getConfig(){return this.config}disableUserControls(){this.userInputListenerComponents.forEach(t=>t.deactivate()),this.hitTestCanvasModel.disableUserControls()}enableUserControls(){this.userInputListenerComponents.forEach(t=>t.activate()),this.hitTestCanvasModel.enableUserControls()}setGridConfig(t){var e,s,i,r,o;const a=this.config.components.grid;a.visible=(e=t.visible)!=null?e:!1,a.dash=(s=t.dash)!=null?s:[0,0],a.width=(i=t.width)!=null?i:1,a.color=(r=t.color)!=null?r:"#FFFFFF",this.config.colors.chartAreaTheme.gridColor=(o=t.color)!=null?o:"#FFFFFF",this.redraw()}setGridVisible(t){this.config.components&&this.config.components.grid&&(this.config.components.grid.visible=t,this.redraw())}setGridVertical(t){this.config.components.grid.vertical=t,this.redraw()}setGridHorizontal(t){this.config.components.grid.horizontal=t,this.redraw()}redraw(){this.bus.fireDraw()}getOffsets(){return this.config.components&&this.config.components.offsets}setShowCandleBorders(t=!0){this.config.components&&this.config.components.chart&&(this.config.components.chart.showCandlesBorder=t,this.redraw())}setHighLowVisible(t=!0){this.config.components&&this.config.components.highLow&&(this.config.components.highLow.visible=t,this.redraw())}setCrossToolVisible(t="cross-and-labels"){this.config.components&&this.config.components.crossTool&&(this.config.components.crossTool.type=t,this.redraw())}setHighlightsVisible(t=!0){var e;(e=this.config.components)!=null&&e.highlights&&(this.config.components.highlights.visible=t,this.redraw())}setHighlightsData(t){this.highlightsComponent.setHighlights(t)}setColors(t){At(this.config.colors,t,{addIfMissing:!0,overrideExisting:!0}),this.redraw()}addMouseMoveOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeMouseMove(s).subscribe(e);return()=>i.unsubscribe()}addMouseEnterOnChartElementHandler(t,e,s=!1){const i=this.canvasBoundsContainer.getBoundsHitTest(t),r=this.canvasInputListener.observeMouseEnter(i,s).subscribe(e);return()=>r.unsubscribe()}addClickOnChartElementHandler(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=this.canvasInputListener.observeClick(s).subscribe(e);return()=>i.unsubscribe()}addDragEventsListener(t,e){const s=this.canvasBoundsContainer.getBoundsHitTest(t),i=yt(this.canvasInputListener.observeYDrag(s),this.canvasInputListener.observeXDrag(s)).subscribe(e);return()=>i.unsubscribe()}registerComponent(t,e){const s=t(this);this.components.push(s),e&&e(s),s.activate()}}class Ta extends An{constructor(t,e={}){super(t,e),this.yAxis=this.yAxisComponent,this.xAxis=this.xAxisComponent,this.watermark=this.watermarkComponent,this.highlights=this.highlightsComponent,this.events=this.eventsComponent,this.snapshot=this.snapshotComponent,this.crosshair=this.crossToolComponent,this.navigationMap=this.navigationMapComponent,this.volumes=this.volumesComponent,this.cursors=this.cursorHandler,this.data=this.chartComponent,this.scale=this.scaleModel,this.panning=this.chartPanComponent,this.bounds=this.canvasBoundsContainer,this.hover=this.hoverProducer}registerPaneFormatters(t,e){var s;(s=this.paneManager.panes[t])==null||s.setPaneValueFormatters(e)}destroy(){this.bus.setMuted(!0),this.chartComponents.forEach(t=>t.disable()),this.parentElement.childNodes.forEach(t=>t.remove()),this.parentElement.style.width="",this.parentElement.style.height=""}showSeparateVolumes(t=!1){this.volumes&&(this.volumes.setShowVolumesSeparatly(t),this.bounds.updateYAxisWidths())}setData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.setAllSeries(e,s)}else this.chartComponent.setMainSeries(t)}updateData(t){if(Array.isArray(t)){if(t.length===0)return;const[e,...s]=t;this.chartComponent.updateAllSeries(e,s)}else this.chartComponent.updateAllSeries(t)}setAutoScale(t=!0){this.scale.autoScale(t)}setRtl(t){this.config.rtl=t,this.bus.fireDraw()}setChartType(t){this.data.setChartType(t),this.yAxis.updateOrderedLabels()}setTreasuryFormat(t){this.config.components.yAxis.treasuryFormat=t,this.paneManager.yExtents.forEach(e=>{e.yAxis.model.labelsGenerator.updateTreasuryFormat(t),e.yAxis.model.labelsGenerator.doGenerateLabels(),e.yAxis.model.fancyLabelsModel.updateLabels(!0),e.yAxis.model.baseLabelsModel.updateLabels()})}createPane(){return this.paneManager.createPane()}}var Im=Object.defineProperty,Dm=Object.defineProperties,Lm=Object.getOwnPropertyDescriptors,Ma=Object.getOwnPropertySymbols,Om=Object.prototype.hasOwnProperty,Bm=Object.prototype.propertyIsEnumerable,Aa=(n,t,e)=>t in n?Im(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Rm=(n,t)=>{for(var e in t||(t={}))Om.call(t,e)&&Aa(n,e,t[e]);if(Ma)for(var e of Ma(t))Bm.call(t,e)&&Aa(n,e,t[e]);return n},Fm=(n,t)=>Dm(n,Lm(t));function Ea(n){n=n||{},n.quantity=n.quantity||200,n.startY=n.startY||50,n.avgCandleSize=n.avgCandleSize||2,n.avgTrendLength=n.avgTrendLength||{},n.avgTrendLength.sw=n.avgTrendLength.sw||10,n.avgTrendLength.down=n.avgTrendLength.down||10,n.avgTrendLength.up=n.avgTrendLength.up||10,n.withVolume=n.withVolume===!0||!1,n.period=n.period||3600;var t=[],e=n.quantity||200,s=10,i=10,r=10;n.avgTrendLength&&(s=n.avgTrendLength.sw||10,i=n.avgTrendLength.down||10,r=n.avgTrendLength.up||10);var o=n.startY||50,a=n.avgCandleSize||2,l=o-a,c=o+a,h=Ps(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(jm(t[t.length-1],a,s)):d>3?t=t.concat(Hm(t[t.length-1],a,r)):t=t.concat(km(t[t.length-1],a,i))}t=t.slice(0,n.quantity);let u=Math.round(new Date().getTime()/3e5)*3e5;u-=e*1e3*n.period;for(let f=0;f<t.length;f++){const p=t[f];Object.assign(p,{timestamp:u,isVisible:!0}),u+=1e3*n.period,n.withVolume&&(p.volume=Math.ceil(Math.random()*1e3+200))}return t}function Ps(n,t,e,s){var i=Math.random()*(t-n)+n,r;if(s&&s==="bull"||!s&&Math.random()>.5){var o=i+e;r=o<t?o:t}else{var a=i-e;r=a>n?a:n}var l=Math.max(i,r)+Math.random()*e*.2,c=Math.min(i,r)-Math.random()*e*.2;return{id:Ei(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function Hm(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.lo,o=n.hi+t*1.2,a=0;a<i;a++){var l=Math.random()>.9?"bear":"bull",c=Ps(r,o,t,l);r=c.lo-t*(Math.random()*.1+.1),o=c.hi+t*(Math.random()*1.3+.1),Math.random()>.9&&(o=c.hi+t),s.push(c)}return s}function km(n,t,e){for(var s=[],i=Math.random()*e+e/2,r=n.hi-t*1.2,o=n.hi,a=0;a<i;a++){var l=Math.random()<.9?"bear":"bull",c=Ps(r,o,t,l);r=c.lo-t*(Math.random()*.3+.1),o=c.hi-t*(Math.random()*.1+.1),Math.random()>.9&&(o=c.lo-t),s.push(c)}return s}function jm(n,t,e){var s=[],i=Math.random()*e+e/2;function r(u){var f,p;return Math.random()>.5?(f=u.lo-t*.2,p=u.hi+t*1.2):(f=u.lo-t*1.2,p=u.hi+t*.2),{from:f,to:p}}for(var o=r(n),a=o.from,l=o.to,c=0;c<i;c++){var h=Math.random()<.5?"bear":"bull",d=Ps(a,l,t,h);o=r(d),a=o.from,l=o.to,Math.random()>.9&&(Math.random()>.5?a=d.lo-t:l=d.hi+t),s.push(d)}return s}window.DXChart=Fm(Rm({},window.DXChart),{generateCandlesData:Ea});function Ym(n){return Ea(n)}const Nm=((n,t={})=>new Ta(n,t))})(),window.DXChart=As})();})();
|