@devexperts/dxcharts-lite 2.7.29 → 2.7.30

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.
@@ -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 rt=Math.pow;(()=>{var _a={165(k,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"]}};k.exports=O;for(const b of Object.keys(O)){if(!("channels"in O[b]))throw new Error("missing channels property: "+b);if(!("labels"in O[b]))throw new Error("missing channel labels property: "+b);if(O[b].labels.length!==O[b].channels)throw new Error("channel and label counts mismatch: "+b);const{channels:y,labels:C}=O[b];delete O[b].channels,delete O[b].labels,Object.defineProperty(O[b],"channels",{value:y}),Object.defineProperty(O[b],"labels",{value:C})}O.rgb.hsl=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(y,C,w),S=Math.max(y,C,w),P=S-g;let I,v;S===g?I=0:y===S?I=(C-w)/P:C===S?I=2+(w-y)/P:w===S&&(I=4+(y-C)/P),I=Math.min(I*60,360),I<0&&(I+=360);const T=(g+S)/2;return S===g?v=0:T<=.5?v=P/(S+g):v=P/(2-S-g),[I,v*100,T*100]},O.rgb.hsv=function(b){let y,C,w,g,S;const P=b[0]/255,I=b[1]/255,v=b[2]/255,T=Math.max(P,I,v),E=T-Math.min(P,I,v),D=function(R){return(T-R)/6/E+1/2};return E===0?(g=0,S=0):(S=E/T,y=D(P),C=D(I),w=D(v),P===T?g=w-C:I===T?g=.3333333333333333+y-w:v===T&&(g=.6666666666666666+C-y),g<0?g+=1:g>1&&(g-=1)),[g*360,S*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],S=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,S*100,w*100]},O.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),S=(1-y-g)/(1-g)||0,P=(1-C-g)/(1-g)||0,I=(1-w-g)/(1-g)||0;return[S*100,P*100,I*100,g*100]};function ht(b,y){return rt(b[0]-y[0],2)+rt(b[1]-y[1],2)+rt(b[2]-y[2],2)}O.rgb.keyword=function(b){const y=z[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(q)){const S=q[g],P=ht(b,S);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?rt((y+.055)/1.055,2.4):y/12.92,C=C>.04045?rt((C+.055)/1.055,2.4):C/12.92,w=w>.04045?rt((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,S=y*.2126+C*.7152+w*.0722,P=y*.0193+C*.1192+w*.9505;return[g*100,S*100,P*100]},O.rgb.lab=function(b){const y=O.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?rt(g,.3333333333333333):7.787*g+.13793103448275862;const S=116*w-16,P=500*(C-w),I=200*(w-g);return[S,P,I]},O.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,S,P;if(C===0)return P=w*255,[P,P,P];w<.5?g=w*(1+C):g=w+C-w*C;const I=2*w-g,v=[0,0,0];for(let T=0;T<3;T++)S=y+.3333333333333333*-(T-1),S<0&&S++,S>1&&S--,6*S<1?P=I+(g-I)*6*S:2*S<1?P=g:3*S<2?P=I+(g-I)*(.6666666666666666-S)*6:P=I,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 S=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=S<=1?S:2-S;const P=(w+C)/2,I=w===0?2*g/(S+g):2*C/(w+C);return[y,I*100,P*100]},O.hsv.rgb=function(b){const y=b[0]/60,C=b[1]/100;let w=b[2]/100;const g=Math.floor(y)%6,S=y-Math.floor(y),P=255*w*(1-C),I=255*w*(1-C*S),v=255*w*(1-C*(1-S));switch(w*=255,g){case 0:return[w,v,P];case 1:return[I,w,P];case 2:return[P,w,v];case 3:return[P,I,w];case 4:return[v,P,w];case 5:return[w,P,I]}},O.hsv.hsl=function(b){const y=b[0],C=b[1]/100,w=b[2]/100,g=Math.max(w,.01);let S,P;P=(2-C)*w;const I=(2-C)*g;return S=C*g,S/=I<=1?I:2-I,S=S||0,P/=2,[y,S*100,P*100]},O.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let S;g>1&&(C/=g,w/=g);const P=Math.floor(6*y),I=1-w;S=6*y-P,(P&1)!==0&&(S=1-S);const v=C+S*(I-C);let T,E,D;switch(P){default:case 6:case 0:T=I,E=v,D=C;break;case 1:T=v,E=I,D=C;break;case 2:T=C,E=I,D=v;break;case 3:T=C,E=v,D=I;break;case 4:T=v,E=C,D=I;break;case 5:T=I,E=C,D=v;break}return[T*255,E*255,D*255]},O.cmyk.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100,g=b[3]/100,S=1-Math.min(1,y*(1-g)+g),P=1-Math.min(1,C*(1-g)+g),I=1-Math.min(1,w*(1-g)+g);return[S*255,P*255,I*255]},O.xyz.rgb=function(b){const y=b[0]/100,C=b[1]/100,w=b[2]/100;let g,S,P;return g=y*3.2406+C*-1.5372+w*-.4986,S=y*-.9689+C*1.8758+w*.0415,P=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*rt(g,.4166666666666667)-.055:g*12.92,S=S>.0031308?1.055*rt(S,.4166666666666667)-.055:S*12.92,P=P>.0031308?1.055*rt(P,.4166666666666667)-.055:P*12.92,g=Math.min(Math.max(0,g),1),S=Math.min(Math.max(0,S),1),P=Math.min(Math.max(0,P),1),[g*255,S*255,P*255]},O.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?rt(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,S=500*(y-C),P=200*(C-w);return[g,S,P]},O.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,S,P;S=(y+16)/116,g=C/500+S,P=S-w/200;const I=rt(S,3),v=rt(g,3),T=rt(P,3);return S=I>.008856?I:(S-.13793103448275862)/7.787,g=v>.008856?v:(g-.13793103448275862)/7.787,P=T>.008856?T:(P-.13793103448275862)/7.787,g*=95.047,S*=100,P*=108.883,[g,S,P]},O.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const P=Math.sqrt(C*C+w*w);return[y,P,g]},O.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,S=C*Math.cos(g),P=C*Math.sin(g);return[y,S,P]},O.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let S=y===null?O.rgb.hsv(b)[2]:y;if(S=Math.round(S/50),S===0)return 30;let P=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return S===2&&(P+=60),P},O.hsv.ansi16=function(b){return O.rgb.ansi16(O.hsv.rgb(b),b[2])},O.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},O.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,S=(y>>2&1)*C*255;return[w,g,S]},O.ansi256.rgb=function(b){if(b>=232){const S=(b-232)*10+8;return[S,S,S]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},O.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},O.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(I=>I+I).join(""));const w=parseInt(C,16),g=w>>16&255,S=w>>8&255,P=w&255;return[g,S,P]},O.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),S=Math.min(Math.min(y,C),w),P=g-S;let I,v;return P<1?I=S/(1-P):I=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,I*100]},O.hsl.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=C<.5?2*y*C:2*y*(1-C);let g=0;return w<1&&(g=(C-.5*w)/(1-w)),[b[0],w*100,g*100]},O.hsv.hcg=function(b){const y=b[1]/100,C=b[2]/100,w=y*C;let g=0;return w<1&&(g=(C-w)/(1-w)),[b[0],w*100,g*100]},O.hcg.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;if(C===0)return[w*255,w*255,w*255];const g=[0,0,0],S=y%1*6,P=S%1,I=1-P;let v=0;switch(Math.floor(S)){case 0:g[0]=1,g[1]=P,g[2]=0;break;case 1:g[0]=I,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]=I,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]=I}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 S=0;return g<1&&(S=(w-g)/(1-g)),[b[0],g*100,S*100]},O.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},O.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},O.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},O.gray.hsl=function(b){return[0,0,b[0]]},O.gray.hsv=O.gray.hsl,O.gray.hwb=function(b){return[0,100,b[0]]},O.gray.cmyk=function(b){return[0,0,0,b[0]]},O.gray.lab=function(b){return[b[0],0,0]},O.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},O.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}},880(k,it,N){const q=N(165),z=N(985),O={},ht=Object.keys(q);function b(C){const w=function(...g){const S=g[0];return S==null?S:(S.length>1&&(g=S),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const S=g[0];if(S==null)return S;S.length>1&&(g=S);const P=C(g);if(typeof P=="object")for(let I=P.length,v=0;v<I;v++)P[v]=Math.round(P[v]);return P};return"conversion"in C&&(w.conversion=C.conversion),w}ht.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(S=>{const P=w[S];O[C][S]=y(P),O[C][S].raw=b(P)})}),k.exports=O},985(k,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(),S=Object.keys(q[g]);for(let P=S.length,I=0;I<P;I++){const v=S[I],T=C[v];T.distance===-1&&(T.distance=C[g].distance+1,T.parent=g,w.unshift(v))}}return C}function ht(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=q[C[y].parent][y],S=C[y].parent;for(;C[S].parent;)w.unshift(C[S].parent),g=ht(q[C[S].parent][S],g),S=C[S].parent;return g.conversion=w,g}k.exports=function(y){const C=O(y),w={},g=Object.keys(C);for(let S=g.length,P=0;P<S;P++){const I=g[P];C[I].parent!==null&&(w[I]=b(I,C))}return w}},877(k){"use strict";k.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},138(k,it,N){var q=N(877),z=N(403),O=Object.hasOwnProperty,ht=Object.create(null);for(var b in q)O.call(q,b)&&(ht[q[b]]=b);var y=k.exports={to:{},get:{}};y.get=function(g){var S=g.substring(0,3).toLowerCase(),P,I;switch(S){case"hsl":P=y.get.hsl(g),I="hsl";break;case"hwb":P=y.get.hwb(g),I="hwb";break;default:P=y.get.rgb(g),I="rgb";break}return P?{model:I,value:P}:null},y.get.rgb=function(g){if(!g)return null;var S=/^#([a-f0-9]{3,4})$/i,P=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,I=/^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+)$/,E=[0,0,0,1],D,R,dt;if(D=g.match(P)){for(dt=D[2],D=D[1],R=0;R<3;R++){var Dt=R*2;E[R]=parseInt(D.slice(Dt,Dt+2),16)}dt&&(E[3]=parseInt(dt,16)/255)}else if(D=g.match(S)){for(D=D[1],dt=D[3],R=0;R<3;R++)E[R]=parseInt(D[R]+D[R],16);dt&&(E[3]=parseInt(dt+dt,16)/255)}else if(D=g.match(I)){for(R=0;R<3;R++)E[R]=parseInt(D[R+1],0);D[4]&&(D[5]?E[3]=parseFloat(D[4])*.01:E[3]=parseFloat(D[4]))}else if(D=g.match(v)){for(R=0;R<3;R++)E[R]=Math.round(parseFloat(D[R+1])*2.55);D[4]&&(D[5]?E[3]=parseFloat(D[4])*.01:E[3]=parseFloat(D[4]))}else return(D=g.match(T))?D[1]==="transparent"?[0,0,0,0]:O.call(q,D[1])?(E=q[D[1]],E[3]=1,E):null:null;for(R=0;R<3;R++)E[R]=C(E[R],0,255);return E[3]=C(E[3],0,1),E},y.get.hsl=function(g){if(!g)return null;var S=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var I=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),E=C(parseFloat(P[3]),0,100),D=C(isNaN(I)?1:I,0,1);return[v,T,E,D]}return null},y.get.hwb=function(g){if(!g)return null;var S=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var I=parseFloat(P[4]),v=(parseFloat(P[1])%360+360)%360,T=C(parseFloat(P[2]),0,100),E=C(parseFloat(P[3]),0,100),D=C(isNaN(I)?1:I,0,1);return[v,T,E,D]}return null},y.to.hex=function(){var g=z(arguments);return"#"+w(g[0])+w(g[1])+w(g[2])+(g[3]<1?w(Math.round(g[3]*255)):"")},y.to.rgb=function(){var g=z(arguments);return g.length<4||g[3]===1?"rgb("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+")":"rgba("+Math.round(g[0])+", "+Math.round(g[1])+", "+Math.round(g[2])+", "+g[3]+")"},y.to.rgb.percent=function(){var g=z(arguments),S=Math.round(g[0]/255*100),P=Math.round(g[1]/255*100),I=Math.round(g[2]/255*100);return g.length<4||g[3]===1?"rgb("+S+"%, "+P+"%, "+I+"%)":"rgba("+S+"%, "+P+"%, "+I+"%, "+g[3]+")"},y.to.hsl=function(){var g=z(arguments);return g.length<4||g[3]===1?"hsl("+g[0]+", "+g[1]+"%, "+g[2]+"%)":"hsla("+g[0]+", "+g[1]+"%, "+g[2]+"%, "+g[3]+")"},y.to.hwb=function(){var g=z(arguments),S="";return g.length>=4&&g[3]!==1&&(S=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+S+")"},y.to.keyword=function(g){return ht[g.slice(0,3)]};function C(g,S,P){return Math.min(Math.max(S,g),P)}function w(g){var S=Math.round(g).toString(16).toUpperCase();return S.length<2?"0"+S:S}},742(k,it,N){const q=N(138),z=N(880),O=["keyword","gray","hex"],ht={};for(const v of Object.keys(z))ht[[...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 E,D;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 R=q.get(v);if(R===null)throw new Error("Unable to parse color from string: "+v);this.model=R.model,D=z[this.model].channels,this.color=R.value.slice(0,D),this.valpha=typeof R.value[D]=="number"?R.value[D]:1}else if(v.length>0){this.model=T||"rgb",D=z[this.model].channels;const R=Array.prototype.slice.call(v,0,D);this.color=I(R,D),this.valpha=typeof v[D]=="number"?v[D]: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 R=Object.keys(v);"alpha"in v&&(R.splice(R.indexOf("alpha"),1),this.valpha=typeof v.alpha=="number"?v.alpha:0);const dt=R.sort().join("");if(!(dt in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(v));this.model=ht[dt];const{labels:Dt}=z[this.model],ot=[];for(E=0;E<Dt.length;E++)ot.push(v[Dt[E]]);this.color=I(ot)}if(b[this.model])for(D=z[this.model].channels,E=0;E<D;E++){const R=b[this.model][E];R&&(this.color[E]=R(this.color[E]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}y.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(v){let T=this.model in q.to?this:this.rgb();T=T.round(typeof v=="number"?v:1);const E=T.valpha===1?T.color:[...T.color,this.valpha];return q.to[T.model](E)},percentString(v){const T=this.rgb().round(typeof v=="number"?v:1),E=T.valpha===1?T.color:[...T.color,this.valpha];return q.to.rgb.percent(E)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){const v={},{channels:T}=z[this.model],{labels:E}=z[this.model];for(let D=0;D<T;D++)v[E[D]]=this.color[D];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,S(255)),green:g("rgb",1,S(255)),blue:g("rgb",2,S(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,v=>(v%360+360)%360),saturationl:g("hsl",1,S(100)),lightness:g("hsl",2,S(100)),saturationv:g("hsv",1,S(100)),value:g("hsv",2,S(100)),chroma:g("hcg",1,S(100)),gray:g("hcg",2,S(100)),white:g("hwb",1,S(100)),wblack:g("hwb",2,S(100)),cyan:g("cmyk",0,S(100)),magenta:g("cmyk",1,S(100)),yellow:g("cmyk",2,S(100)),black:g("cmyk",3,S(100)),x:g("xyz",0,S(95.047)),y:g("xyz",1,S(100)),z:g("xyz",2,S(108.833)),l:g("lab",0,S(100)),a:g("lab",1),b:g("lab",2),keyword(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 E=Math.round(this.valpha*255).toString(16).toUpperCase();return E.length===1&&(E="0"+E),q.to.hex(T)+E},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[E,D]of v.entries()){const R=D/255;T[E]=R<=.04045?R/12.92:rt((R+.055)/1.055,2.4)}return .2126*T[0]+.7152*T[1]+.0722*T[2]},contrast(v){const T=this.luminosity(),E=v.luminosity();return T>E?(T+.05)/(E+.05):(E+.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 E=T.color[0];return E=(E+v)%360,E=E<0?360+E:E,T.color[0]=E,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 E=v.rgb(),D=this.rgb(),R=T===void 0?.5:T,dt=2*R-1,Dt=E.alpha()-D.alpha(),ot=((dt*Dt===-1?dt:(dt+Dt)/(1+dt*Dt))+1)/2,Tt=1-ot;return y.rgb(ot*E.red()+Tt*D.red(),ot*E.green()+Tt*D.green(),ot*E.blue()+Tt*D.blue(),E.alpha()*R+D.alpha()*(1-R))}};for(const v of Object.keys(z)){if(O.includes(v))continue;const{channels:T}=z[v];y.prototype[v]=function(...E){return this.model===v?new y(this):E.length>0?new y(E,v):new y([...P(z[this.model][v].raw(this.color)),this.valpha],v)},y[v]=function(...E){let D=E[0];return typeof D=="number"&&(D=I(E,T)),new y(D,v)}}function C(v,T){return Number(v.toFixed(T))}function w(v){return function(T){return C(T,v)}}function g(v,T,E){v=Array.isArray(v)?v:[v];for(const D of v)(b[D]||(b[D]=[]))[T]=E;return v=v[0],function(D){let R;return D!==void 0?(E&&(D=E(D)),R=this[v](),R.color[T]=D,R):(R=this[v]().color[T],E&&(R=E(R)),R)}}function S(v){return function(T){return Math.max(0,Math.min(v,T))}}function P(v){return Array.isArray(v)?v:[v]}function I(v,T){for(let E=0;E<T;E++)typeof v[E]!="number"&&(v[E]=0);return v}k.exports=y},94(k){k.exports=function(N){return!N||typeof N=="string"?!1:N instanceof Array||Array.isArray(N)||N.length>=0&&(N.splice instanceof Function||Object.getOwnPropertyDescriptor(N,N.length-1)&&N.constructor.name!=="String")}},403(k,it,N){"use strict";var q=N(94),z=Array.prototype.concat,O=Array.prototype.slice,ht=k.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var S=y[w];q(S)?C=z.call(C,O.call(S)):C.push(S)}return C};ht.wrap=function(b){return function(){return b(ht(arguments))}}}},Mn={};function Pt(k){var it=Mn[k];if(it!==void 0)return it.exports;var N=Mn[k]={exports:{}};return _a[k](N,N.exports,Pt),N.exports}Pt.n=k=>{var it=k&&k.__esModule?()=>k.default:()=>k;return Pt.d(it,{a:it}),it},Pt.d=(k,it)=>{for(var N in it)Pt.o(it,N)&&!Pt.o(k,N)&&Object.defineProperty(k,N,{enumerable:!0,get:it[N]})},Pt.o=(k,it)=>Object.prototype.hasOwnProperty.call(k,it),Pt.r=k=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(k,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(k,"__esModule",{value:!0})};var Ps={};(()=>{"use strict";Pt.r(Ps),Pt.d(Ps,{Chart:()=>ba,createChart:()=>Mm,generateCandlesData:()=>Tm});function k(n){return typeof n=="function"}function it(n){return k(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 ht(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t,e,s,i,r){function o(_){if(_!==void 0&&typeof _!="function")throw new TypeError("Function expected");return _}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(_){if(u)throw new TypeError("Cannot add initializers after decoration has completed");r.push(o(_||null))};var x=(0,e[f])(a==="accessor"?{get:h.get,set:h.set}:h[l],p);if(a==="accessor"){if(x===void 0)continue;if(x===null||typeof x!="object")throw new TypeError("Object expected");(d=o(x.get))&&(h.get=d),(d=o(x.set))&&(h.set=d),(d=o(x.init))&&i.unshift(d)}else(d=o(x))&&(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 S(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 I(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 E(n,t){for(var e in n)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&T(t,n,e)}function D(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 R(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 dt(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(R(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 ot(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 An(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(x,_){r.push([f,m,x,_])>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 Pa(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 En(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 D=="function"?D(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 Ta(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var Ma=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},Ts=function(n){return Ts=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[e.length]=s);return e},Ts(n)};function Aa(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=Ts(n),s=0;s<e.length;s++)e[s]!=="default"&&T(t,n,e[s]);return Ma(t,n),t}function Ea(n){return n&&n.__esModule?n:{default:n}}function Ia(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 Da(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 La(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 Oa(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 Ba=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 Ra(n){function t(r){n.error=n.hasError?new Ba(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 Fa(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 Em={__extends:z,__assign:O,__rest:ht,__decorate:b,__param:y,__esDecorate:C,__runInitializers:w,__propKey:g,__setFunctionName:S,__metadata:P,__awaiter:I,__generator:v,__createBinding:T,__exportStar:E,__values:D,__read:R,__spread:dt,__spreadArrays:Dt,__spreadArray:ot,__await:Tt,__asyncGenerator:An,__asyncDelegator:Pa,__asyncValues:En,__makeTemplateObject:Ta,__importStar:Aa,__importDefault:Ea,__classPrivateFieldGet:Ia,__classPrivateFieldSet:Da,__classPrivateFieldIn:La,__addDisposableResource:Oa,__disposeResources:Ra,__rewriteRelativeImportExtension:Fa};function In(n){var t=function(s){Error.call(s),s.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Ms=In(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
6
+ (()=>{var rt=Math.pow;(()=>{var Pa={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),S=Math.max(y,C,w),P=S-g;let D,v;S===g?D=0:y===S?D=(C-w)/P:C===S?D=2+(w-y)/P:w===S&&(D=4+(y-C)/P),D=Math.min(D*60,360),D<0&&(D+=360);const T=(g+S)/2;return S===g?v=0:T<=.5?v=P/(S+g):v=P/(2-S-g),[D,v*100,T*100]},O.rgb.hsv=function(b){let y,C,w,g,S;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(F){return(T-F)/6/I+1/2};return I===0?(g=0,S=0):(S=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,S*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],S=1/255*Math.min(y,Math.min(C,w));return w=1-.00392156862745098*Math.max(y,Math.max(C,w)),[g,S*100,w*100]},O.rgb.cmyk=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.min(1-y,1-C,1-w),S=(1-y-g)/(1-g)||0,P=(1-C-g)/(1-g)||0,D=(1-w-g)/(1-g)||0;return[S*100,P*100,D*100,g*100]};function ht(b,y){return rt(b[0]-y[0],2)+rt(b[1]-y[1],2)+rt(b[2]-y[2],2)}O.rgb.keyword=function(b){const y=z[b];if(y)return y;let C=1/0,w;for(const g of Object.keys(q)){const S=q[g],P=ht(b,S);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?rt((y+.055)/1.055,2.4):y/12.92,C=C>.04045?rt((C+.055)/1.055,2.4):C/12.92,w=w>.04045?rt((w+.055)/1.055,2.4):w/12.92;const g=y*.4124+C*.3576+w*.1805,S=y*.2126+C*.7152+w*.0722,P=y*.0193+C*.1192+w*.9505;return[g*100,S*100,P*100]},O.rgb.lab=function(b){const y=O.rgb.xyz(b);let C=y[0],w=y[1],g=y[2];C/=95.047,w/=100,g/=108.883,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862,g=g>.008856?rt(g,.3333333333333333):7.787*g+.13793103448275862;const S=116*w-16,P=500*(C-w),D=200*(w-g);return[S,P,D]},O.hsl.rgb=function(b){const y=b[0]/360,C=b[1]/100,w=b[2]/100;let g,S,P;if(C===0)return P=w*255,[P,P,P];w<.5?g=w*(1+C):g=w+C-w*C;const D=2*w-g,v=[0,0,0];for(let T=0;T<3;T++)S=y+.3333333333333333*-(T-1),S<0&&S++,S>1&&S--,6*S<1?P=D+(g-D)*6*S:2*S<1?P=g:3*S<2?P=D+(g-D)*(.6666666666666666-S)*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 S=Math.max(w,.01);w*=2,C*=w<=1?w:2-w,g*=S<=1?S:2-S;const P=(w+C)/2,D=w===0?2*g/(S+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,S=y-Math.floor(y),P=255*w*(1-C),D=255*w*(1-C*S),v=255*w*(1-C*(1-S));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 S,P;P=(2-C)*w;const D=(2-C)*g;return S=C*g,S/=D<=1?D:2-D,S=S||0,P/=2,[y,S*100,P*100]},O.hwb.rgb=function(b){const y=b[0]/360;let C=b[1]/100,w=b[2]/100;const g=C+w;let S;g>1&&(C/=g,w/=g);const P=Math.floor(6*y),D=1-w;S=6*y-P,(P&1)!==0&&(S=1-S);const v=C+S*(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,S=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[S*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,S,P;return g=y*3.2406+C*-1.5372+w*-.4986,S=y*-.9689+C*1.8758+w*.0415,P=y*.0557+C*-.204+w*1.057,g=g>.0031308?1.055*rt(g,.4166666666666667)-.055:g*12.92,S=S>.0031308?1.055*rt(S,.4166666666666667)-.055:S*12.92,P=P>.0031308?1.055*rt(P,.4166666666666667)-.055:P*12.92,g=Math.min(Math.max(0,g),1),S=Math.min(Math.max(0,S),1),P=Math.min(Math.max(0,P),1),[g*255,S*255,P*255]},O.xyz.lab=function(b){let y=b[0],C=b[1],w=b[2];y/=95.047,C/=100,w/=108.883,y=y>.008856?rt(y,.3333333333333333):7.787*y+.13793103448275862,C=C>.008856?rt(C,.3333333333333333):7.787*C+.13793103448275862,w=w>.008856?rt(w,.3333333333333333):7.787*w+.13793103448275862;const g=116*C-16,S=500*(y-C),P=200*(C-w);return[g,S,P]},O.lab.xyz=function(b){const y=b[0],C=b[1],w=b[2];let g,S,P;S=(y+16)/116,g=C/500+S,P=S-w/200;const D=rt(S,3),v=rt(g,3),T=rt(P,3);return S=D>.008856?D:(S-.13793103448275862)/7.787,g=v>.008856?v:(g-.13793103448275862)/7.787,P=T>.008856?T:(P-.13793103448275862)/7.787,g*=95.047,S*=100,P*=108.883,[g,S,P]},O.lab.lch=function(b){const y=b[0],C=b[1],w=b[2];let g;g=Math.atan2(w,C)*360/2/Math.PI,g<0&&(g+=360);const P=Math.sqrt(C*C+w*w);return[y,P,g]},O.lch.lab=function(b){const y=b[0],C=b[1],g=b[2]/360*2*Math.PI,S=C*Math.cos(g),P=C*Math.sin(g);return[y,S,P]},O.rgb.ansi16=function(b,y=null){const[C,w,g]=b;let S=y===null?O.rgb.hsv(b)[2]:y;if(S=Math.round(S/50),S===0)return 30;let P=30+(Math.round(g/255)<<2|Math.round(w/255)<<1|Math.round(C/255));return S===2&&(P+=60),P},O.hsv.ansi16=function(b){return O.rgb.ansi16(O.hsv.rgb(b),b[2])},O.rgb.ansi256=function(b){const y=b[0],C=b[1],w=b[2];return y===C&&C===w?y<8?16:y>248?231:Math.round((y-8)/247*24)+232:16+36*Math.round(y/255*5)+6*Math.round(C/255*5)+Math.round(w/255*5)},O.ansi16.rgb=function(b){let y=b%10;if(y===0||y===7)return b>50&&(y+=3.5),y=y/10.5*255,[y,y,y];const C=(~~(b>50)+1)*.5,w=(y&1)*C*255,g=(y>>1&1)*C*255,S=(y>>2&1)*C*255;return[w,g,S]},O.ansi256.rgb=function(b){if(b>=232){const S=(b-232)*10+8;return[S,S,S]}b-=16;let y;const C=Math.floor(b/36)/5*255,w=Math.floor((y=b%36)/6)/5*255,g=y%6/5*255;return[C,w,g]},O.rgb.hex=function(b){const C=(((Math.round(b[0])&255)<<16)+((Math.round(b[1])&255)<<8)+(Math.round(b[2])&255)).toString(16).toUpperCase();return"000000".substring(C.length)+C},O.hex.rgb=function(b){const y=b.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!y)return[0,0,0];let C=y[0];y[0].length===3&&(C=C.split("").map(D=>D+D).join(""));const w=parseInt(C,16),g=w>>16&255,S=w>>8&255,P=w&255;return[g,S,P]},O.rgb.hcg=function(b){const y=b[0]/255,C=b[1]/255,w=b[2]/255,g=Math.max(Math.max(y,C),w),S=Math.min(Math.min(y,C),w),P=g-S;let D,v;return P<1?D=S/(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],S=y%1*6,P=S%1,D=1-P;let v=0;switch(Math.floor(S)){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 S=0;return g<1&&(S=(w-g)/(1-g)),[b[0],g*100,S*100]},O.apple.rgb=function(b){return[b[0]/65535*255,b[1]/65535*255,b[2]/65535*255]},O.rgb.apple=function(b){return[b[0]/255*65535,b[1]/255*65535,b[2]/255*65535]},O.gray.rgb=function(b){return[b[0]/100*255,b[0]/100*255,b[0]/100*255]},O.gray.hsl=function(b){return[0,0,b[0]]},O.gray.hsv=O.gray.hsl,O.gray.hwb=function(b){return[0,100,b[0]]},O.gray.cmyk=function(b){return[0,0,0,b[0]]},O.gray.lab=function(b){return[b[0],0,0]},O.gray.hex=function(b){const y=Math.round(b[0]/100*255)&255,w=((y<<16)+(y<<8)+y).toString(16).toUpperCase();return"000000".substring(w.length)+w},O.rgb.gray=function(b){return[(b[0]+b[1]+b[2])/3/255*100]}},880(j,it,N){const q=N(165),z=N(985),O={},ht=Object.keys(q);function b(C){const w=function(...g){const S=g[0];return S==null?S:(S.length>1&&(g=S),C(g))};return"conversion"in C&&(w.conversion=C.conversion),w}function y(C){const w=function(...g){const S=g[0];if(S==null)return S;S.length>1&&(g=S);const 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}ht.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(S=>{const P=w[S];O[C][S]=y(P),O[C][S].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(),S=Object.keys(q[g]);for(let P=S.length,D=0;D<P;D++){const v=S[D],T=C[v];T.distance===-1&&(T.distance=C[g].distance+1,T.parent=g,w.unshift(v))}}return C}function ht(y,C){return function(w){return C(y(w))}}function b(y,C){const w=[C[y].parent,y];let g=q[C[y].parent][y],S=C[y].parent;for(;C[S].parent;)w.unshift(C[S].parent),g=ht(q[C[S].parent][S],g),S=C[S].parent;return g.conversion=w,g}j.exports=function(y){const C=O(y),w={},g=Object.keys(C);for(let S=g.length,P=0;P<S;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,ht=Object.create(null);for(var b in q)O.call(q,b)&&(ht[q[b]]=b);var y=j.exports={to:{},get:{}};y.get=function(g){var S=g.substring(0,3).toLowerCase(),P,D;switch(S){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 S=/^#([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,F,dt;if(L=g.match(P)){for(dt=L[2],L=L[1],F=0;F<3;F++){var Dt=F*2;I[F]=parseInt(L.slice(Dt,Dt+2),16)}dt&&(I[3]=parseInt(dt,16)/255)}else if(L=g.match(S)){for(L=L[1],dt=L[3],F=0;F<3;F++)I[F]=parseInt(L[F]+L[F],16);dt&&(I[3]=parseInt(dt+dt,16)/255)}else if(L=g.match(D)){for(F=0;F<3;F++)I[F]=parseInt(L[F+1],0);L[4]&&(L[5]?I[3]=parseFloat(L[4])*.01:I[3]=parseFloat(L[4]))}else if(L=g.match(v)){for(F=0;F<3;F++)I[F]=Math.round(parseFloat(L[F+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(F=0;F<3;F++)I[F]=C(I[F],0,255);return I[3]=C(I[3],0,1),I},y.get.hsl=function(g){if(!g)return null;var S=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var 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 S=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,P=g.match(S);if(P){var 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),S=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("+S+"%, "+P+"%, "+D+"%)":"rgba("+S+"%, "+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),S="";return g.length>=4&&g[3]!==1&&(S=", "+g[3]),"hwb("+g[0]+", "+g[1]+"%, "+g[2]+"%"+S+")"},y.to.keyword=function(g){return ht[g.slice(0,3)]};function C(g,S,P){return Math.min(Math.max(S,g),P)}function w(g){var S=Math.round(g).toString(16).toUpperCase();return S.length<2?"0"+S:S}},742(j,it,N){const q=N(138),z=N(880),O=["keyword","gray","hex"],ht={};for(const v of Object.keys(z))ht[[...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 F=q.get(v);if(F===null)throw new Error("Unable to parse color from string: "+v);this.model=F.model,L=z[this.model].channels,this.color=F.value.slice(0,L),this.valpha=typeof F.value[L]=="number"?F.value[L]:1}else if(v.length>0){this.model=T||"rgb",L=z[this.model].channels;const F=Array.prototype.slice.call(v,0,L);this.color=D(F,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 F=Object.keys(v);"alpha"in v&&(F.splice(F.indexOf("alpha"),1),this.valpha=typeof v.alpha=="number"?v.alpha:0);const dt=F.sort().join("");if(!(dt in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(v));this.model=ht[dt];const{labels:Dt}=z[this.model],ot=[];for(I=0;I<Dt.length;I++)ot.push(v[Dt[I]]);this.color=D(ot)}if(b[this.model])for(L=z[this.model].channels,I=0;I<L;I++){const F=b[this.model][I];F&&(this.color[I]=F(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,S(255)),green:g("rgb",1,S(255)),blue:g("rgb",2,S(255)),hue:g(["hsl","hsv","hsl","hwb","hcg"],0,v=>(v%360+360)%360),saturationl:g("hsl",1,S(100)),lightness:g("hsl",2,S(100)),saturationv:g("hsv",1,S(100)),value:g("hsv",2,S(100)),chroma:g("hcg",1,S(100)),gray:g("hcg",2,S(100)),white:g("hwb",1,S(100)),wblack:g("hwb",2,S(100)),cyan:g("cmyk",0,S(100)),magenta:g("cmyk",1,S(100)),yellow:g("cmyk",2,S(100)),black:g("cmyk",3,S(100)),x:g("xyz",0,S(95.047)),y:g("xyz",1,S(100)),z:g("xyz",2,S(108.833)),l:g("lab",0,S(100)),a:g("lab",1),b:g("lab",2),keyword(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 F=L/255;T[I]=F<=.04045?F/12.92:rt((F+.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(),F=T===void 0?.5:T,dt=2*F-1,Dt=I.alpha()-L.alpha(),ot=((dt*Dt===-1?dt:(dt+Dt)/(1+dt*Dt))+1)/2,Tt=1-ot;return y.rgb(ot*I.red()+Tt*L.red(),ot*I.green()+Tt*L.green(),ot*I.blue()+Tt*L.blue(),I.alpha()*F+L.alpha()*(1-F))}};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 F;return L!==void 0?(I&&(L=I(L)),F=this[v](),F.color[T]=L,F):(F=this[v]().color[T],I&&(F=I(F)),F)}}function S(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,ht=j.exports=function(y){for(var C=[],w=0,g=y.length;w<g;w++){var S=y[w];q(S)?C=z.call(C,O.call(S)):C.push(S)}return C};ht.wrap=function(b){return function(){return b(ht(arguments))}}}},An={};function Pt(j){var it=An[j];if(it!==void 0)return it.exports;var N=An[j]={exports:{}};return Pa[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 Ms={};(()=>{"use strict";Pt.r(Ms),Pt.d(Ms,{Chart:()=>Ca,createChart:()=>Am,generateCandlesData:()=>Mm});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 ht(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}function b(n,t,e,s){var i=arguments.length,r=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,t,e,s);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r}function y(n,t){return function(e,s){t(e,s,n)}}function C(n,t,e,s,i,r){function o(x){if(x!==void 0&&typeof x!="function")throw new TypeError("Function expected");return x}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(x){if(u)throw new TypeError("Cannot add initializers after decoration has completed");r.push(o(x||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 S(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 F(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 dt(){for(var n=[],t=0;t<arguments.length;t++)n=n.concat(F(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 ot(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 En(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(_,x){r.push([f,m,_,x])>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 Ta(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 In(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 Ma(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var Aa=Object.create?(function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}):function(n,t){n.default=t},As=function(n){return As=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[e.length]=s);return e},As(n)};function Ea(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e=As(n),s=0;s<e.length;s++)e[s]!=="default"&&T(t,n,e[s]);return Aa(t,n),t}function Ia(n){return n&&n.__esModule?n:{default:n}}function Da(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 La(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 Oa(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 Ba(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 Ra=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 Fa(n){function t(r){n.error=n.hasError?new Ra(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 Ha(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 Em={__extends:z,__assign:O,__rest:ht,__decorate:b,__param:y,__esDecorate:C,__runInitializers:w,__propKey:g,__setFunctionName:S,__metadata:P,__awaiter:D,__generator:v,__createBinding:T,__exportStar:I,__values:L,__read:F,__spread:dt,__spreadArrays:Dt,__spreadArray:ot,__await:Tt,__asyncGenerator:En,__asyncDelegator:Ta,__asyncValues:In,__makeTemplateObject:Ma,__importStar:Ea,__importDefault:Ia,__classPrivateFieldGet:Da,__classPrivateFieldSet:La,__classPrivateFieldIn:Oa,__addDisposableResource:Ba,__disposeResources:Fa,__rewriteRelativeImportExtension:Ha};function Dn(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 Es=Dn(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 Xe(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ue=(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=D(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(k(h))try{h()}catch(m){r=m instanceof Ms?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var u=D(d),f=u.next();!f.done;f=u.next()){var p=f.value;try{On(p)}catch(m){r=r!=null?r:[],m instanceof Ms?r=ot(ot([],R(r)),R(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 Ms(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)On(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)&&Xe(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Xe(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=(function(){var t=new n;return t.closed=!0,t})(),n})(),Dn=ue.EMPTY;function Ln(n){return n instanceof ue||n&&"closed"in n&&k(n.remove)&&k(n.add)&&k(n.unsubscribe)}function On(n){k(n)?n():n.unsubscribe()}var te={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},We={setTimeout:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=We.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,ot([n,t],R(e))):setTimeout.apply(void 0,ot([n,t],R(e)))},clearTimeout:function(n){var t=We.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Bn(n){We.setTimeout(function(){var t=te.onUnhandledError;if(t)t(n);else throw n})}function Rn(){}var Ha=(function(){return As("C",void 0,void 0)})();function ka(n){return As("E",void 0,n)}function ja(n){return As("N",n,void 0)}function As(n,t,e){return{kind:n,value:t,error:e}}var ee=null;function ze(n){if(te.useDeprecatedSynchronousErrorHandling){var t=!ee;if(t&&(ee={errorThrown:!1,error:null}),n(),t){var e=ee,s=e.errorThrown,i=e.error;if(ee=null,s)throw i}}else n()}function Ya(n){te.useDeprecatedSynchronousErrorHandling&&ee&&(ee.errorThrown=!0,ee.error=n)}var Es=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,Ln(e)&&e.add(s)):s.destination=za,s}return t.create=function(e,s,i){return new _e(e,s,i)},t.prototype.next=function(e){this.isStopped?Ds(ja(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Ds(ka(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Ds(Ha,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})(ue),Na=Function.prototype.bind;function Is(n,t){return Na.call(n,t)}var Xa=(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){Ve(s)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(s){Ve(s)}else Ve(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){Ve(e)}},n})(),_e=(function(n){z(t,n);function t(e,s,i){var r=n.call(this)||this,o;if(k(e)||!e)o={next:e!=null?e:void 0,error:s!=null?s:void 0,complete:i!=null?i:void 0};else{var a;r&&te.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&Is(e.next,a),error:e.error&&Is(e.error,a),complete:e.complete&&Is(e.complete,a)}):o=e}return r.destination=new Xa(o),r}return t})(Es);function Ve(n){te.useDeprecatedSynchronousErrorHandling?Ya(n):Bn(n)}function Wa(n){throw n}function Ds(n,t){var e=te.onStoppedNotification;e&&We.setTimeout(function(){return e(n,t)})}var za={closed:!0,next:Rn,error:Wa,complete:Rn};function yt(n,t,e,s,i){return new Va(n,t,e,s,i)}var Va=(function(n){z(t,n);function t(e,s,i,r,o,a){var l=n.call(this,e)||this;return l.onFinalize=o,l.shouldUnsubscribe=a,l._next=s?function(c){try{s(c)}catch(h){e.error(h)}}:n.prototype._next,l._error=r?function(c){try{r(c)}catch(h){e.error(h)}finally{this.unsubscribe()}}:n.prototype._error,l._complete=i?function(){try{i()}catch(c){e.error(c)}finally{this.unsubscribe()}}:n.prototype._complete,l}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;n.prototype.unsubscribe.call(this),!s&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t})(Es);function at(n,t){return N(function(e,s){var i=0;e.subscribe(yt(s,function(r){s.next(n.call(t,r,i++))}))})}var Ls=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function Fn(n){return k(n==null?void 0:n.then)}var Os=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function se(n){return n}function Im(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Hn(n)}function Hn(n){return n.length===0?se: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=Ga(t)?t:new _e(t,e,s);return ze(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=kn(e),new e(function(i,r){var o=new _e({next:function(a){try{t(a)}catch(l){r(l),o.unsubscribe()}},error:r,complete:i});s.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Os]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Hn(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=kn(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 kn(n){var t;return(t=n!=null?n:te.Promise)!==null&&t!==void 0?t:Promise}function Ua(n){return n&&k(n.next)&&k(n.error)&&k(n.complete)}function Ga(n){return n&&n instanceof Es||Ua(n)&&Ln(n)}function jn(n){return k(n[Os])}function Yn(n){return Symbol.asyncIterator&&k(n==null?void 0:n[Symbol.asyncIterator])}function Nn(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 Za(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Xn=Za();function Wn(n){return k(n==null?void 0:n[Xn])}function zn(n){return An(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 Vn(n){return k(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof gt)return n;if(n!=null){if(jn(n))return $a(n);if(Ls(n))return Ka(n);if(Fn(n))return qa(n);if(Yn(n))return Un(n);if(Wn(n))return Ja(n);if(Vn(n))return Qa(n)}throw Nn(n)}function $a(n){return new gt(function(t){var e=n[Os]();if(k(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ka(n){return new gt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function qa(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,Bn)})}function Ja(n){return new gt(function(t){var e,s;try{for(var i=D(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 Un(n){return new gt(function(t){tl(n,t).catch(function(e){return t.error(e)})})}function Qa(n){return Un(zn(n))}function tl(n,t){var e,s,i,r;return I(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=En(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 jt(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 el(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 x=!1;Lt(e(m,h++)).subscribe(yt(t,function(_){i==null||i(_),r?f(_):t.next(_)},function(){x=!0},void 0,function(){if(x)try{c--;for(var _=function(){var A=l.shift();o?jt(t,o,function(){return p(A)}):p(A)};l.length&&c<s;)_();u()}catch(A){t.error(A)}}))};return n.subscribe(yt(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Bs(n,t,e){return e===void 0&&(e=1/0),k(t)?Bs(function(s,i){return at(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return el(s,i,n,e)}))}function Gn(n){return n===void 0&&(n=1/0),Bs(se,n)}var sl,Zn=new gt(function(n){return n.complete()});function Dm(n){return n?nl(n):Zn}function nl(n){return new sl(function(t){return n.schedule(function(){return t.complete()})})}function $n(n){return n&&k(n.schedule)}function Rs(n){return n[n.length-1]}function il(n){return k(Rs(n))?n.pop():void 0}function Ue(n){return $n(Rs(n))?n.pop():void 0}function rl(n,t){return typeof Rs(n)=="number"?n.pop():t}function Kn(n,t){return t===void 0&&(t=0),N(function(e,s){e.subscribe(yt(s,function(i){return jt(s,n,function(){return s.next(i)},t)},function(){return jt(s,n,function(){return s.complete()},t)},function(i){return jt(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 ol(n,t){return Lt(n).pipe(qn(t),Kn(t))}function al(n,t){return Lt(n).pipe(qn(t),Kn(t))}function ll(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 cl(n,t){return new gt(function(e){var s;return jt(e,t,function(){s=n[Xn](),jt(e,t,function(){var i,r,o;try{i=s.next(),r=i.value,o=i.done}catch(a){e.error(a);return}o?e.complete():e.next(r)},0,!0)}),function(){return k(s==null?void 0:s.return)&&s.return()}})}function Jn(n,t){if(!n)throw new Error("Iterable cannot be null");return new gt(function(e){jt(e,t,function(){var s=n[Symbol.asyncIterator]();jt(e,t,function(){s.next().then(function(i){i.done?e.complete():e.next(i.value)})},0,!0)})})}function hl(n,t){return Jn(zn(n),t)}function dl(n,t){if(n!=null){if(jn(n))return ol(n,t);if(Ls(n))return ll(n,t);if(Fn(n))return al(n,t);if(Yn(n))return Jn(n,t);if(Wn(n))return cl(n,t);if(Vn(n))return hl(n,t)}throw Nn(n)}function Ge(n,t){return t?dl(n,t):Lt(n)}function wt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ue(n),s=rl(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):Gn(s)(Ge(i,e)):Zn}var ul=In(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 Qn(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new ul},t.prototype.next=function(e){var s=this;ze(function(){var i,r;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=D(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;ze(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;ze(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?Dn:(this.currentObservers=null,a.push(e),new ue(function(){s.currentObservers=null,Xe(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 Qn(e,s)},t})(gt),Qn=(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:Dn},t})(F),ut=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(F);let Fs=!1,Hs=0;const Ze=new Map,$e=new Map,ti=()=>{Fs||(Fs=!0,Hs=requestAnimationFrame(()=>{$e.forEach((n,t)=>{n(),$e.delete(t)}),Ze.forEach((n,t)=>{n(),Ze.delete(t)}),Fs=!1}))},ei=(n,t)=>{Ze.set(n,t),ti()},fl=n=>{Ze.delete(n)},pl=n=>{$e.delete(n)},Pe=(n,t)=>{$e.set(n,t),ti()};function St(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}const si="\u2212",gl="-";var ml=Math.pow;const Ke=14,qe=[];for(let n=0;n<Ke+1;n++)qe.push(ml(10,n));const ks=5e-13;class pt{static roundToNearest(t,e){return isFinite(t)?pt.isZero(t)?0:(t>0?t+=ks:t<0&&(t-=ks),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(Ke,Ke-1-Math.floor(Math.log10(s)));for(let r=i;r>=0;r--){const o=Math.floor(qe[r]*s+.5);if(o<qe[Ke])return e*o/qe[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,ks)===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 vl(n,t,e){const s=n/t;return s>=e||s<=1/e}function js(n,t,e){return Math.max(t,Math.min(n,e))}function bl(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Te(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const lt=n=>~~n,Cl=n=>~~(n+1),Me=n=>~~(n+.5),yl=(n,t)=>n>>t;function Lm(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 Je=n=>n.replace(gl,si);class Ys{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 wl=Pt(742),Rt=Pt.n(wl);class ni extends Ys{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbColor=Rt().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=js(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 ii extends Ys{constructor(t,e,s=()=>{}){super(t,s),this.colorConfigs=e,e.forEach(i=>{i.rgbStartColor=Rt().rgb(i.startColor),i.rgbEndColor=Rt().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 Rt().rgb(i,r,o)}}class ri extends Ys{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:bl}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 Ae=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Sl=!!window.chrome,oi=typeof InstallTrigger!="undefined",xl=navigator.platform.indexOf("Win")>-1,Om=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(Ae)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(Sl){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,xl){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 oi?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 oi&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},_l=(n,t)=>n==="percent"?t/4:t;var Pl=Object.defineProperty,Tl=Object.defineProperties,Ml=Object.getOwnPropertyDescriptors,ai=Object.getOwnPropertySymbols,Al=Object.prototype.hasOwnProperty,El=Object.prototype.propertyIsEnumerable,li=(n,t,e)=>t in n?Pl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Il=(n,t)=>{for(var e in t||(t={}))Al.call(t,e)&&li(n,e,t[e]);if(ai)for(var e of ai(t))El.call(t,e)&&li(n,e,t[e]);return n},Dl=(n,t)=>Tl(n,Ml(t));const Ee=Ae?150:400,fe="VIEWPORT_ANIMATION";class ci{constructor(t){this.animations={},this.animationInProgressSubject=new ut(!1),this.animFrameId=`canvas_animation_${St()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=fe,i){const r=new ri(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ni(Dl(Il({},i),{duration:i&&i.duration||Ee}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ee,i){const r=new ii({duration:s},e,i);return this.animations[t]=r,this.processAnimation(),r}getAnimation(t){return this.animations[t]}getColorAlphaAnimation(t){return this.getAnimation(t)}getColorTransitionAnimation(t){return this.getAnimation(t)}forceStopAnimation(t){const e=this.animations[t];e&&(e.animationInProgress=!1,e.animationStartTime=0)}processAnimation(){Pe(this.animFrameId,()=>this.tick())}tick(){let t=!0;for(const e of Object.keys(this.animations)){const s=this.animations[e];s.tick(),s.animationInProgress&&(t=!1)}this.animationInProgressSubject.next(!t),t?this.stopInterval():queueMicrotask(()=>{this.processAnimation(),this.eventBus.fireDraw()})}stopInterval(){fl(this.animFrameId)}}function mt(n,t){return t===void 0&&(t=se),n=n!=null?n:Ll,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 Ll(n,t){return n===t}function Ol(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Ns(n){return n}function hi(n){return n!=null}const Bm=()=>{};function Rm(n){return n!=null}function Bl(n,t,e=Rl,s=!0){const i=n.filter(r=>t.some(o=>e(r,o)));return s?i.filter((r,o,a)=>a.indexOf(r)===o):i}const di=(n,t)=>{const e=t.slice().filter(s=>n.find(i=>i===s));return n.map(s=>{var i;return t.indexOf(s)>=0&&(i=e.shift())!=null?i:s})},Rl=(n,t)=>n===t,Fm=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),Fl=(n,t)=>n===t,ui=(n,t,e=Fl)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function Hm(n,t,e){const s=n.slice(),i=s[t];return s.splice(t,1),s.splice(e,0,i),s}function Xs(n,t,e){const s=n.length,i=js(t,0,s-1),r=js(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 jm=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},Ym=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),Nm=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),Xm=n=>Array.isArray(n[0]),fi=n=>Array.isArray(n[0])?n:[n],Hl=(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},kl=(n,t)=>n>=0?t[n]:t[t.length+n],vt=n=>Array.prototype.flat?n.flat():Ie(n,Ns),Ie=(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 Yt(n,t,e){const s=e!=null?e:Ns;return!n.length||t!==t?{index:-1,exact:!0}:Ws(n,t,0,n.length,s)}function Ws(n,t,e,s,i){const r=yl(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Ws(n,t,e,r,i):Ws(n,t,r,s,i)}function xt(n){if(n&&n.length)return n[n.length-1]}function jl(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Yl(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function pe(n){if(n)return n[0]}function Nl(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 Xl(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 zs,pi;const Nt=()=>{if(typeof navigator=="undefined")return!1;const n=navigator.userAgent;return(pi!==n||zs===void 0)&&(pi=n,zs=!!n.match(/Android|iPhone|Opera Mini/)),zs},Wl=1.33,gi=4.5;function mi(n,t){let e="";t.textStyle&&(t.textStyle.italic&&(e+="italic "),t.textStyle.bold&&(e+="bold ")),n.font=e+(t.textSize||12)+" "+(t.textFontFamily||"monospace"),n.fillStyle=t.textFill||"#FFFFFF",t.rtl?n.textAlign="right":n.textAlign="start"}function Qe(n,t=!0){const e=n.font.match(/(\d+.)?\d+(px|pt)/gi);let s="10px";return e&&e.length&&(e[0].includes("pt")?s=+e[0].slice(0,e[0].indexOf("pt"))*96/72+"px":s=e[0]),t?parseInt(s,10)*Wl:parseInt(s,10)}function vi(n,t,e){n.save(),mi(n,e);const s=Math.ceil(Math.max.apply(Math,t.map(o=>n.measureText(o).width))),i=Qe(n),r=i*t.length;return n.restore(),[s,r,i]}function bi(n){return(n||"").split(/\r\n|\r|\n/)}function zl(n,t,e,s,i){n.save();const[r,,o]=vi(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=Vl(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&Ul(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 Vl(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function Ul(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 Wm(n){return`${n}px`}function Ci(n){const t=Rt().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 yi(n,t){const e=Ci(n),s=Ci(t),i=Math.max(e,s),r=Math.min(e,s);return(i+.05)/(r+.05)}function ne(n,t,e){const s=yi(n,t),i=yi(n,e),r=s>=gi,o=i>=gi;return r&&!o?t:o&&!r?e:s>=i?t:e}function Gl(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=wi(t,i.dateFormat,e),a=bi(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=vi(n,a,l);return[c+r.x*2,h+r.y*2]}function wi(n,t,e){return e(t)(n).split(" ").join(`
9
- `)}const Si={};function Xt(n,t){let e=Si[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,Si[n]=e,t.restore()),e}const xi=new Map;function Mt(n,t,e){const s=e+n;let i=xi.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,xi.set(s,i),t.restore()),i}function At(n,t,e=_i){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 zm(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 _i={overrideExisting:!1,addIfMissing:!0};function Zl(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 Vs=1,$l=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Pi=(n,t)=>`${n}_${Zl(t.toString())}`;function ts(n,t){return t===n?"none":t>n?"up":"down"}function Kl(n,t){return t>n?"up":"down"}function ql(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 Jl,Ql,tc=Object.defineProperty,Ti=Object.getOwnPropertySymbols,ec=Object.prototype.hasOwnProperty,sc=Object.prototype.propertyIsEnumerable,Mi=(n,t,e)=>t in n?tc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,nc=(n,t)=>{for(var e in t||(t={}))ec.call(t,e)&&Mi(n,e,t[e]);if(Ti)for(var e of Ti(t))sc.call(t,e)&&Mi(n,e,t[e]);return n};const Ai="Open Sans Semibold, sans-serif",ic=null,rc=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],Vm=n=>ic.find(t=>t===n)!==void 0,es=()=>({devexpertsPromoLink:!0,useUTCTimeOverride:!1,shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rtl:!1,intlFormatter:{decimalSeparator:".",thousandsSeparator:""},scale:{keepZoomXOnYAxisChange:!0,auto:!0,zoomToCursor:!1,lockPriceToBarRatio:!1,autoScaleOnCandles:!0,autoScaleDisableOnDrag:{enabled:!0,edgeAngle:Math.PI/15,yDiff:80},inverse:!1,zoomSensitivity:{wheel:.25},defaultViewportItems:100,disableAnimations:!1},timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,components:{chart:{type:"candle",showCandlesBorder:!0,showActiveCandlesBorder:!0,showWicks:!0,candleLineWidth:1,lineWidth:1,areaLineWidth:1,barLineWidth:1,minWidth:.5,minCandles:10,candlePaddingPercent:.25,highlightActiveCandle:!0,cursor:"default",selectedWidth:3,minCandlesOffset:2,defaultZoomCandleWidth:7,zoomStep:0,histogram:{barCapSize:1},maxYAxisScalesAmount:10,applyBackgroundToAxes:{x:!0,y:!0},sortCandles:$l},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:Ai,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:Ai,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 oc(n,t=es()){return At(n,t,_i),n}function Um(n,t=es()){const e=nc({},n);return Jl(e,t,Ql),e}function Gm(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function Ei(n){return typeof n=="object"&&n!==null}function Ii(n,t){return[...n].map(s=>Us(s,t))}const ac=n=>Array.isArray(n);function Us(n,t){if(!Ei(n))return n;if(ac(n))return Ii(n,t);{const e=Di({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function Di(n,t,e){if(!Ei(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return Ii(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=Us(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=Di(n[i],t[i],e):e.addIfMissing&&(s[i]=Us(t[i],e))}),s}const ie=n=>`${n.fontSize}px ${n.fontFamily}`;class lc{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=ie(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 cc=Object.defineProperty,hc=Object.defineProperties,dc=Object.getOwnPropertyDescriptors,Li=Object.getOwnPropertySymbols,uc=Object.prototype.hasOwnProperty,fc=Object.prototype.propertyIsEnumerable,Oi=(n,t,e)=>t in n?cc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wt=(n,t)=>{for(var e in t||(t={}))uc.call(t,e)&&Oi(n,e,t[e]);if(Li)for(var e of Li(t))fc.call(t,e)&&Oi(n,e,t[e]);return n},Bi=(n,t)=>hc(n,dc(t));const Z="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(Z),nt.Y_AXIS=nt.PANE_UUID_Y_AXIS(Z);let M=nt;const Ri={x:0,y:0,pageX:0,pageY:0,width:0,height:0},Fi=20,Hi=35,Gs=15,ki=1.5,ji=Nt()?8*ki:8,De=Nt()?5:0,pc=1e-6;class Zs{constructor(t,e,s,i,r){this.config=t,this.eventBus=e,this.canvasModel=s,this.formatterFactory=i,this.bounds={},this.canvasOnPageLocation={x:0,y:0,pageX:0,pageY:0,width:0,height:0},this.panesOrder=[],this.panesOrderChangedSubject=new 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={[Z]: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 lc(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);Xs(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)<pc?(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&&(Xs(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&&(Xs(this.panesOrder,e,e+1),this.recalculateBounds(),this.eventBus.fireDraw(),this.panesOrderChangedSubject.next(this.panesOrder),this.paneMovedSubject.next())}reorderPanes(t){this.panesOrder=di(this.panesOrder,t),this.recalculateBounds(),this.panesOrderChangedSubject.next(this.panesOrder)}hidePaneBounds(t){this.graphsHeightRatio[t]=0,this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}showPaneBounds(t){if(t===Z){const[e]=Yi(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){Yl(this.panesOrder,t),delete this.graphsHeightRatio[t],delete this.bounds[M.PANE_UUID(t)],this.yAxisWidths.left.concat(this.yAxisWidths.right).forEach((e,s)=>delete this.bounds[M.PANE_UUID_Y_AXIS(t,s)]),delete this.bounds[M.PANE_UUID_RESIZER(t)],this.recalculatePanesHeightRatios(),this.panesOrderChangedSubject.next(this.panesOrder)}recalculateBounds(){const t=this.canvasOnPageLocation.width,e=this.canvasOnPageLocation.height,s=this.config.components.paneResizer.height,i=this.getBounds(M.CANVAS);i.x=0,i.y=0,i.width=t,i.height=e;const r=this.yAxisWidths,o=this.getNavMapBounds(i),a=this.getXAxisBounds(o,i),l=e-a.height-o.height,c=r.left.reduce((H,B)=>H+B,0),h=r.right.reduce((H,B)=>H+B,0),d=0,u=i.width-h,f=d+c,p=0,m=i.width-c-h;let x=p;const _=this.panesOrder.findIndex(H=>this.graphsHeightRatio[H]>0);this.panesOrder.forEach((H,B)=>{var j;const K=this.graphsHeightRatio[this.panesOrder[B]],W=M.PANE_UUID_RESIZER(H),U=M.PANE_UUID(H),G=this.config.components.paneResizer.visible&&B>_&&K>0;G?ge(this.bounds,W,0,x,i.width,s,this.canvasOnPageLocation):ge(this.bounds,W,0,0,0,0,this.canvasOnPageLocation);const V=x+(G?s:0),Q=ge(this.bounds,U,f,V,m,l*K-(G?s:0),this.canvasOnPageLocation);if(this.config.components.yAxis.visible){const J=this.yAxisBoundsContainer.extentsOrder.get(H);if(J===void 0)return;const et=l*K-(G?s:0);let tt=f-((j=r.left[0])!=null?j:0),st=u;J.left.forEach((ft,ct)=>{var _t;ge(this.bounds,M.PANE_UUID_Y_AXIS(H,ft),tt,V,r.left[ct],et,this.canvasOnPageLocation),tt-=(_t=r.left[ct+1])!=null?_t:0}),J.right.forEach((ft,ct)=>{ge(this.bounds,M.PANE_UUID_Y_AXIS(H,ft),st,V,r.right[ct],et,this.canvasOnPageLocation),st+=r.right[ct]})}else ge(this.bounds,M.PANE_UUID_Y_AXIS(H),0,0,0,0,this.canvasOnPageLocation);x=Q.y+Q.height});const A=this.getBounds(M.ALL_PANES);A.x=f,A.y=p,A.width=m,A.height=x;const L=this.getBounds(M.CHART_WITH_Y_AXIS),Y=this.getBounds(M.CHART);this.getEventsBounds(Y),this.copyBounds(Y,L),L.width=i.width,this.recalculateNavigationMapElementBounds(),this.updateAllBoundsPageCoordinates(),this.notifyBoundsSubscribers()}updateCanvasOnPageLocation(t){this.canvasOnPageLocation=Bi(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-Hi,e.width=t.width,e.height=Hi):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)+De}return this.xAxisHeight}setYAxisWidths(t){(!ui(this.yAxisWidths.left,t.left)||!ui(this.yAxisWidths.right,t.right))&&(this.yAxisWidths=t,this.recalculateBounds())}setXAxisHeight(t){t!==this.xAxisHeight&&(this.xAxisHeight=t,this.recalculateBounds())}setPanesOrder(t){this.panesOrder=t,this.recalculateBounds()}recalculatePanesHeightRatios(){this.calculateGraphsHeightRatios(),this.recalculateBounds()}calculateGraphsHeightRatios(){let t=this.graphsHeightRatio[Z];const e=[];e.push(...this.panesOrder.filter(p=>p!==Z));const s=e.map(p=>this.graphsHeightRatio[p]===void 0?void 0:this.graphsHeightRatio[p]),i=s.filter(p=>p!==0),r=i.length,o=i.filter(p=>p!==void 0).length,a=s.filter(p=>p===void 0).length,l=a>0;let c=0,h=0,d=1,u=0;if(l&&([d,u]=Yi(r)),(!this.graphsHeightRatio[Z]||this.graphsHeightRatio[Z]===0)&&(t=0),this.graphsHeightRatio[Z]&&this.graphsHeightRatio[Z]!==0)if(l)t=1*d;else{const p=Object.values(this.graphsHeightRatio).reduce((m,x)=>x+=m);p<1&&this.graphsHeightRatio[Z]!==0&&(t+=1-p)}o===0&&(t=1-u*a),h=1-t-u*a,i.forEach(p=>{p&&(h-=p*d)}),c=h/(r||1);const f=s.map(p=>p===0?p:p?p*d+c:u+c);this._graphsHeightRatio={},this.graphsHeightRatio[Z]=t,f.forEach((p,m)=>{const x=e[m];this.graphsHeightRatio[x]=p})}recalculateNavigationMapElementBounds(){var t,e,s,i;if(!this.config.components.navigationMap.visible)return;const r=this.getBounds(M.N_MAP),{height:o,width:a}=this.config.components.navigationMap.knots,l=o!=null?o:0,c=Nt()?a*ki:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=et=>Gl(this.canvasModel.ctx,et,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,x=Math.max(p,m);if(d){const et=this.getBounds(M.N_MAP_LABEL_L);et.x=r.x,et.y=r.y,et.width=x,et.height=r.height;const tt=this.getBounds(M.N_MAP_LABEL_R);tt.x=r.x+r.width-x,tt.y=r.y,tt.width=x,tt.height=r.height}const _=this.getBounds(M.N_MAP_BTN_L);_.x=r.x+x,_.y=r.y,_.width=Gs,_.height=r.height;const A=this.getBounds(M.N_MAP_BTN_R);A.x=r.x+r.width-Gs-x,A.y=r.y,A.width=Gs,A.height=r.height;const L=_.x+_.width,Y=A.x-L,H=L+Y,B=this.config.components.navigationMap.minSliderWindowWidth,j=c!=null?c:ji,K=l!=null?l:r.height,W=j+B,U=this.getBounds(M.N_MAP_KNOT_L);U.x=L+Y*this.leftRatio,U.x=Math.min(U.x,H-W),U.y=h,U.width=j,U.height=K;const G=this.getBounds(M.N_MAP_KNOT_R);G.x=L+Y*this.rightRatio-ji,G.x=Math.max(G.x,L+W),G.y=h,G.width=j,G.height=K;const V=W-(G.x-U.x);V>0&&(U.x-=V);const Q=this.getBounds(M.N_MAP_SLIDER_WINDOW);Q.x=U.x+U.width,Q.y=r.y,Q.width=G.x-Q.x,Q.height=r.height;const J=this.getBounds(M.N_MAP_CHART);J.x=L,J.y=r.y,J.width=Y,J.height=r.height}isVolumesInSeparatePane(){return this.config.components.volumes.visible&&this.config.components.volumes.showSeparately}getBounds(t){let e=this.bounds[t];return e===void 0&&(e=this.copyOf(Ri),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>Bi(Wt({},t),{[e]:this.bounds[M.PANE_UUID(e)]}),{})}getBoundsHitTest(t,e=ss){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},ss),e);return r?(o,a)=>{const l=this.getBounds(t);return o>l.pageX-s&&o<l.pageX+l.width+s&&a>l.pageY-i&&a<l.pageY+l.height+i}:(o,a)=>{const l=this.getBounds(t);return o>l.x-s&&o<l.x+l.width+s&&a>l.y-i&&a<l.y+l.height+i}}static hitTestOf(t,e=ss){const{extensionX:s,extensionY:i,wholePage:r}=Wt(Wt({},ss),e);return r?(o,a)=>o>t.pageX-s&&o<t.pageX+t.width+s&&a>t.pageY-i&&a<t.pageY+t.height+i:(o,a)=>o>t.x-s&&o<t.x+t.width+s&&a>t.y-i&&a<t.y+t.height+i}isChartBoundsAvailable(){const t=this.getBounds(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=Fi,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ut(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(at(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(Ri,t)}setMainCandleSeries(t){this.mainCandleSeries=t}getEffectiveYAxisWidth(){return this.getBounds(M.PANE_UUID_Y_AXIS(Z)).width}getEffectiveChartWidth(){return this.getBounds(M.PANE_UUID(Z)).width}getEffectiveChartHeight(){return this.getBounds(M.PANE_UUID(Z)).height}}const gc={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},Yi=n=>{var t;const e=(t=gc[n])!=null?t:.4,s=(1-e)/n;return[e,s]},Zm=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,mc=(n,t)=>n>t.y&&n<t.y+t.height,ge=(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},Ni=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),ss={extensionX:0,extensionY:0,wholePage:!1},Xi=(n,t)=>n.width===t.width&&n.height===t.height;var vc=(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})(ue),ns={setInterval:function(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];var i=ns.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,ot([n,t],R(e))):setInterval.apply(void 0,ot([n,t],R(e)))},clearInterval:function(n){var t=ns.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Wi=(function(n){z(t,n);function t(e,s){var i=n.call(this,e,s)||this;return i.scheduler=e,i.work=s,i.pending=!1,i}return t.prototype.schedule=function(e,s){var i;if(s===void 0&&(s=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(o,r,s)),this.pending=!0,this.delay=s,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,s),this},t.prototype.requestAsyncId=function(e,s,i){return i===void 0&&(i=0),ns.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,s,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return s;s!=null&&ns.clearInterval(s)},t.prototype.execute=function(e,s){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,s);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,s){var i=!1,r;try{this.work(e)}catch(o){i=!0,r=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,s=e.id,i=e.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Xe(r,this),s!=null&&(this.id=this.recycleAsyncId(i,s,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t})(vc),Le={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=Le.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new ue(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=Le.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,ot([],R(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Le.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,ot([],R(n)))},delegate:void 0},bc=(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=Le.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&&(Le.cancelAnimationFrame(s),e._scheduled=void 0)},t})(Wi),$s={now:function(){return($s.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=$s.now,n})(),Vi=(function(n){z(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),Cc=(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})(Vi),Ot=new Cc(bc),$m=null,is=new Vi(Wi),yc=is;function wc(n,t){return N(function(e,s){var i=t!=null?t:{},r=i.leading,o=r===void 0?!0:r,a=i.trailing,l=a===void 0?!1:a,c=!1,h=null,d=null,u=!1,f=function(){d==null||d.unsubscribe(),d=null,l&&(x(),u&&s.complete())},p=function(){d=null,u&&s.complete()},m=function(_){return d=Lt(n(_)).subscribe(yt(s,f,p))},x=function(){if(c){c=!1;var _=h;h=null,s.next(_),!u&&m(_)}};e.subscribe(yt(s,function(_){c=!0,h=_,!(d&&!d.closed)&&(o?x():m(_))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function Sc(n){return n instanceof Date&&!isNaN(n)}function xc(n,t,e){n===void 0&&(n=0),e===void 0&&(e=yc);var s=-1;return t!=null&&($n(t)?e=t:s=t),new gt(function(i){var r=Sc(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=is);var s=xc(n,t);return wc(function(){return s},e)}class X{constructor(){this.subscriptions=[],this._state="initial",this.entities=[]}doActivate(){}doDeactivate(){this.subscriptions.forEach(t=>t()),this.subscriptions=[]}enable(){this._state!=="active"&&(this._state="deactivated",this.activate())}disable(){this._state!=="disabled"&&(this.deactivate(),this._state="disabled")}activate(){this._state!=="disabled"&&(this._state!=="active"&&(this.doActivate(),this._state="active"),this.entities.forEach(t=>t.activate()))}deactivate(){this._state!=="disabled"&&(this._state!=="deactivated"&&(this.doDeactivate(),this._state="deactivated"),this.entities.forEach(t=>t.deactivate()))}getState(){return this._state}addSubscription(t){this.subscriptions.push(t)}addRxSubscription(t){t&&this.subscriptions.push(t.unsubscribe.bind(t))}addChildEntity(t){this.entities.push(t),this._state==="active"&&t.activate()}removeChildEntity(t){this.entities=this.entities.filter(e=>e!==t)}}class _c extends X{constructor(t,e,s,i){super(),this.element=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.hitTestCanvasModel=i,this.normalLayer=new Map,this.extensionLayer=new Map,this.cursorChangedSubject=new F}doActivate(){super.doActivate(),this.canvasInputListener.observeMouseMoveNoDrag().pipe(Et(100,Ot,{trailing:!0})).subscribe(t=>{const e=this.hitTestCanvasModel.resolveCursor(t);if(e!==void 0){this.updateCursor(e);return}t&&(this.normalLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}),this.extensionLayer.forEach(s=>{s.hitTest(t.x,t.y)&&this.updateCursor(s.cursor)}))})}setCursorForBounds(t,e,s,i=0){const r=Zs.hitTestOf(e,{extensionY:i});i?this.extensionLayer.set(t,{cursor:s,hitTest:r}):this.normalLayer.set(t,{cursor:s,hitTest:r})}setCursorForCanvasEl(t,e,s){this.observeCursorType(t,e,s)}removeCursorForCanvasEl(t){this.normalLayer.delete(t),this.extensionLayer.delete(t)}observeCursorChanged(){return this.cursorChangedSubject.pipe(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 Pc=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},Ks=(n=>`<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">
8
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function We(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var fe=(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 Es?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{Bn(p)}catch(m){r=r!=null?r:[],m instanceof Es?r=ot(ot([],F(r)),F(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 Es(r)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Bn(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})(),Ln=fe.EMPTY;function On(n){return n instanceof fe||n&&"closed"in n&&j(n.remove)&&j(n.add)&&j(n.unsubscribe)}function Bn(n){j(n)?n():n.unsubscribe()}var te={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,ot([n,t],F(e))):setTimeout.apply(void 0,ot([n,t],F(e)))},clearTimeout:function(n){var t=ze.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Rn(n){ze.setTimeout(function(){var t=te.onUnhandledError;if(t)t(n);else throw n})}function Fn(){}var ka=(function(){return Is("C",void 0,void 0)})();function ja(n){return Is("E",void 0,n)}function Ya(n){return Is("N",n,void 0)}function Is(n,t,e){return{kind:n,value:t,error:e}}var ee=null;function Ve(n){if(te.useDeprecatedSynchronousErrorHandling){var t=!ee;if(t&&(ee={errorThrown:!1,error:null}),n(),t){var e=ee,s=e.errorThrown,i=e.error;if(ee=null,s)throw i}}else n()}function Na(n){te.useDeprecatedSynchronousErrorHandling&&ee&&(ee.errorThrown=!0,ee.error=n)}var Ds=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s.isStopped=!1,e?(s.destination=e,On(e)&&e.add(s)):s.destination=Va,s}return t.create=function(e,s,i){return new Pe(e,s,i)},t.prototype.next=function(e){this.isStopped?Os(Ya(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Os(ja(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Os(ka,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})(fe),Xa=Function.prototype.bind;function Ls(n,t){return Xa.call(n,t)}var Wa=(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})(),Pe=(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&&te.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return r.unsubscribe()},o={next:e.next&&Ls(e.next,a),error:e.error&&Ls(e.error,a),complete:e.complete&&Ls(e.complete,a)}):o=e}return r.destination=new Wa(o),r}return t})(Ds);function Ue(n){te.useDeprecatedSynchronousErrorHandling?Na(n):Rn(n)}function za(n){throw n}function Os(n,t){var e=te.onStoppedNotification;e&&ze.setTimeout(function(){return e(n,t)})}var Va={closed:!0,next:Fn,error:za,complete:Fn};function yt(n,t,e,s,i){return new Ua(n,t,e,s,i)}var Ua=(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})(Ds);function at(n,t){return N(function(e,s){var i=0;e.subscribe(yt(s,function(r){s.next(n.call(t,r,i++))}))})}var Bs=(function(n){return n&&typeof n.length=="number"&&typeof n!="function"});function Hn(n){return j(n==null?void 0:n.then)}var Rs=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function se(n){return n}function Im(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return kn(n)}function kn(n){return n.length===0?se: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=Za(t)?t:new Pe(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=jn(e),new e(function(i,r){var o=new Pe({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[Rs]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return kn(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=jn(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 jn(n){var t;return(t=n!=null?n:te.Promise)!==null&&t!==void 0?t:Promise}function Ga(n){return n&&j(n.next)&&j(n.error)&&j(n.complete)}function Za(n){return n&&n instanceof Ds||Ga(n)&&On(n)}function Yn(n){return j(n[Rs])}function Nn(n){return Symbol.asyncIterator&&j(n==null?void 0:n[Symbol.asyncIterator])}function Xn(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 $a(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Wn=$a();function zn(n){return j(n==null?void 0:n[Wn])}function Vn(n){return En(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 Un(n){return j(n==null?void 0:n.getReader)}function Lt(n){if(n instanceof gt)return n;if(n!=null){if(Yn(n))return Ka(n);if(Bs(n))return qa(n);if(Hn(n))return Ja(n);if(Nn(n))return Gn(n);if(zn(n))return Qa(n);if(Un(n))return tl(n)}throw Xn(n)}function Ka(n){return new gt(function(t){var e=n[Rs]();if(j(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function qa(n){return new gt(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}function Ja(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,Rn)})}function Qa(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 Gn(n){return new gt(function(t){el(n,t).catch(function(e){return t.error(e)})})}function tl(n){return Gn(Vn(n))}function el(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=In(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 sl(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(x){i==null||i(x),r?f(x):t.next(x)},function(){_=!0},void 0,function(){if(_)try{c--;for(var x=function(){var A=l.shift();o?Yt(t,o,function(){return p(A)}):p(A)};l.length&&c<s;)x();u()}catch(A){t.error(A)}}))};return n.subscribe(yt(t,f,function(){d=!0,u()})),function(){a==null||a()}}function Fs(n,t,e){return e===void 0&&(e=1/0),j(t)?Fs(function(s,i){return at(function(r,o){return t(s,r,i,o)})(Lt(n(s,i)))},e):(typeof t=="number"&&(e=t),N(function(s,i){return sl(s,i,n,e)}))}function Zn(n){return n===void 0&&(n=1/0),Fs(se,n)}var nl,$n=new gt(function(n){return n.complete()});function Dm(n){return n?il(n):$n}function il(n){return new nl(function(t){return n.schedule(function(){return t.complete()})})}function Kn(n){return n&&j(n.schedule)}function Hs(n){return n[n.length-1]}function rl(n){return j(Hs(n))?n.pop():void 0}function Ge(n){return Kn(Hs(n))?n.pop():void 0}function ol(n,t){return typeof Hs(n)=="number"?n.pop():t}function qn(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 Jn(n,t){return t===void 0&&(t=0),N(function(e,s){s.add(n.schedule(function(){return e.subscribe(s)},t))})}function al(n,t){return Lt(n).pipe(Jn(t),qn(t))}function ll(n,t){return Lt(n).pipe(Jn(t),qn(t))}function cl(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 hl(n,t){return new gt(function(e){var s;return Yt(e,t,function(){s=n[Wn](),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 Qn(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 dl(n,t){return Qn(Vn(n),t)}function ul(n,t){if(n!=null){if(Yn(n))return al(n,t);if(Bs(n))return cl(n,t);if(Hn(n))return ll(n,t);if(Nn(n))return Qn(n,t);if(zn(n))return hl(n,t);if(Un(n))return dl(n,t)}throw Xn(n)}function Ze(n,t){return t?ul(n,t):Lt(n)}function wt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=ol(n,1/0),i=n;return i.length?i.length===1?Lt(i[0]):Zn(s)(Ze(i,e)):$n}var fl=Dn(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),H=(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 ti(this,this);return s.operator=e,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new fl},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?Ln:(this.currentObservers=null,a.push(e),new fe(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 ti(e,s)},t})(gt),ti=(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:Ln},t})(H),ut=(function(n){z(t,n);function t(e){var s=n.call(this)||this;return s._value=e,s}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var s=n.prototype._subscribe.call(this,e);return!s.closed&&e.next(this._value),s},t.prototype.getValue=function(){var e=this,s=e.hasError,i=e.thrownError,r=e._value;if(s)throw i;return this._throwIfClosed(),r},t.prototype.next=function(e){n.prototype.next.call(this,this._value=e)},t})(H);let ks=!1,js=0;const $e=new Map,Ke=new Map,ei=()=>{ks||(ks=!0,js=requestAnimationFrame(()=>{Ke.forEach((n,t)=>{n(),Ke.delete(t)}),$e.forEach((n,t)=>{n(),$e.delete(t)}),ks=!1}))},si=(n,t)=>{$e.set(n,t),ei()},pl=n=>{$e.delete(n)},gl=n=>{Ke.delete(n)},Te=(n,t)=>{Ke.set(n,t),ei()};function St(){const n=()=>Math.random().toString(16).slice(-4);return`${n()+n()}-${n()}-${n()}-${n()}-${n()+n()+n()}`}const ni="\u2212",ml="-";var vl=Math.pow;const qe=14,Je=[];for(let n=0;n<qe+1;n++)Je.push(vl(10,n));const Ys=5e-13;class pt{static roundToNearest(t,e){return isFinite(t)?pt.isZero(t)?0:(t>0?t+=Ys:t<0&&(t-=Ys),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,Ys)===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 bl(n,t,e){const s=n/t;return s>=e||s<=1/e}function Ns(n,t,e){return Math.max(t,Math.min(n,e))}function Cl(n){return 1-(Math.pow(2,-10*n)-.0009765625)*1.0009775171065494}function Me(...n){for(const t of n)if(t!==void 0&&isFinite(t))return t;return NaN}const lt=n=>~~n,yl=n=>~~(n+1),Ae=n=>~~(n+.5),wl=(n,t)=>n>>t;function Lm(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(ml,ni);class Xs{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 Sl=Pt(742),Ft=Pt.n(Sl);class ii extends Xs{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=Ns(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 ri extends Xs{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 oi extends Xs{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:Cl}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 Ee=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),xl=!!window.chrome,ai=typeof InstallTrigger!="undefined",_l=navigator.platform.indexOf("Win")>-1,Om=n=>{let t=!1;const{wheelDeltaY:e,wheelDeltaX:s}=n;if(e||s){let i;if(Ee)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(xl){if(i=e+Math.sign(e)===n.deltaY*-3?e+Math.sign(e)===n.deltaY*-3:e===n.deltaY*-3,_l){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 ai?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 ai&&n.deltaY>=16&&Math.abs(n.deltaY)%16===0&&(t=!1),n.ctrlKey&&(t=!0),t},Pl=(n,t)=>n==="percent"?t/4:t;var Tl=Object.defineProperty,Ml=Object.defineProperties,Al=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,El=Object.prototype.hasOwnProperty,Il=Object.prototype.propertyIsEnumerable,ci=(n,t,e)=>t in n?Tl(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Dl=(n,t)=>{for(var e in t||(t={}))El.call(t,e)&&ci(n,e,t[e]);if(li)for(var e of li(t))Il.call(t,e)&&ci(n,e,t[e]);return n},Ll=(n,t)=>Ml(n,Al(t));const Ie=Ee?150:400,pe="VIEWPORT_ANIMATION";class hi{constructor(t){this.animations={},this.animationInProgressSubject=new ut(!1),this.animFrameId=`canvas_animation_${St()}`,this.eventBus=t}startViewportMovementAnimation(t,e,s=pe,i){const r=new oi(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ii(Ll(Dl({},i),{duration:i&&i.duration||Ie}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ie,i){const r=new ri({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(){Te(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(){pl(this.animFrameId)}}function mt(n,t){return t===void 0&&(t=se),n=n!=null?n:Ol,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 Ol(n,t){return n===t}function Bl(n){return function(){n.forEach(e=>typeof e=="function"&&e()),n.length=0}}function Ws(n){return n}function di(n){return n!=null}const Bm=()=>{};function Rm(n){return n!=null}function Rl(n,t,e=Fl,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 ui=(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})},Fl=(n,t)=>n===t,Fm=(n,t,e)=>n.filter(s=>t.filter(i=>e(s,i)).length===0),Hl=(n,t)=>n===t,fi=(n,t,e=Hl)=>n.length===t.length&&n.every((s,i)=>e(s,t[i]));function Hm(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=Ns(t,0,s-1),r=Ns(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 jm=n=>{const t={};return n.filter(e=>t[e]?!1:t[e]=!0)},Ym=(n,t)=>n.reduce((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e),{}),Nm=(n,t)=>[].concat(...n.map(e=>[e,t])).slice(0,-1),Xm=n=>Array.isArray(n[0]),pi=n=>Array.isArray(n[0])?n:[n],kl=(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},jl=(n,t)=>n>=0?t[n]:t[t.length+n],vt=n=>Array.prototype.flat?n.flat():De(n,Ws),De=(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:Ws;return!n.length||t!==t?{index:-1,exact:!0}:Vs(n,t,0,n.length,s)}function Vs(n,t,e,s,i){const r=wl(e+s,1),o=i(n[r]);return t===o?{index:r,exact:!0}:e===r?{index:e,exact:!1}:t<o?Vs(n,t,e,r,i):Vs(n,t,r,s,i)}function xt(n){if(n&&n.length)return n[n.length-1]}function Yl(n){const t=this.indexOf(n);return t!==-1&&this.splice(t,1),this}function Nl(n,t){if(!n)return;const e=n.indexOf(t);e!==-1&&n.splice(e,1)}function ge(n){if(n)return n[0]}function Xl(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 Wl(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 Us,gi;const Ot=()=>{if(typeof navigator=="undefined")return!1;const n=navigator.userAgent;return(gi!==n||Us===void 0)&&(gi=n,Us=!!n.match(/Android|iPhone|Opera Mini/)),Us},zl=1.33,mi=4.5;function vi(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)*zl:parseInt(s,10)}function bi(n,t,e){n.save(),vi(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 Ci(n){return(n||"").split(/\r\n|\r|\n/)}function Vl(n,t,e,s,i){n.save();const[r,,o]=bi(n,t,i);t.forEach((a,l)=>{var c,h,d;const u=n.measureText(a).width,f=Ul(e,r,u,(c=i.textAlign)!=null?c:"left");i.textStyle&&i.textStyle.underline&&Gl(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 Ul(n,t,e,s){switch(s){case"left":return n;case"right":return n+t-e;default:return n}}function Gl(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 Wm(n){return`${n}px`}function yi(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 wi(n,t){const e=yi(n),s=yi(t),i=Math.max(e,s),r=Math.min(e,s);return(i+.05)/(r+.05)}function ne(n,t,e){const s=wi(n,t),i=wi(n,e),r=s>=mi,o=i>=mi;return r&&!o?t:o&&!r?e:s>=i?t:e}function Zl(n,t,e,s){const i=s.components.navigationMap.timeLabels,r=i.padding,o=Si(t,i.dateFormat,e),a=Ci(o),l={textFontFamily:i.fontFamily,textSize:`${i.fontSize}px`},[c,h]=bi(n,a,l);return[c+r.x*2,h+r.y*2]}function Si(n,t,e){return e(t)(n).split(" ").join(`
9
+ `)}const xi={};function Xt(n,t){let e=xi[n];return e!==void 0||(t.save(),t.font=n,e=t.measureText("M").width,xi[n]=e,t.restore()),e}const _i=new Map;function Mt(n,t,e){const s=e+n;let i=_i.get(s);return i||(t.save(),t.font=e,i=t.measureText(n).width,_i.set(s,i),t.restore()),i}function At(n,t,e=Pi){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 zm(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 Pi={overrideExisting:!1,addIfMissing:!0};function $l(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 Gs=1,Kl=n=>n.slice().sort((t,e)=>t.timestamp===e.timestamp?0:t.timestamp>e.timestamp?1:-1),Ti=(n,t)=>`${n}_${$l(t.toString())}`;function es(n,t){return t===n?"none":t>n?"up":"down"}function ql(n,t){return t>n?"up":"down"}function Jl(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 Ql,tc,ec=Object.defineProperty,Mi=Object.getOwnPropertySymbols,sc=Object.prototype.hasOwnProperty,nc=Object.prototype.propertyIsEnumerable,Ai=(n,t,e)=>t in n?ec(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ic=(n,t)=>{for(var e in t||(t={}))sc.call(t,e)&&Ai(n,e,t[e]);if(Mi)for(var e of Mi(t))nc.call(t,e)&&Ai(n,e,t[e]);return n};const Ei="Open Sans Semibold, sans-serif",rc=null,oc=["candle","line","area","bar","scatterPlot","trend","hollow","histogram","baseline"],Vm=n=>rc.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:Kl},yAxis:{type:"regular",visible:!0,labelHeight:23,zeroPercentLine:!0,customScale:!0,customScaleDblClick:!0,align:"right",fontSize:12,fontFamily:Ei,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:Ei,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 ac(n,t=ss()){return At(n,t,Pi),n}function Um(n,t=ss()){const e=ic({},n);return Ql(e,t,tc),e}function Gm(n,t){Object.keys(n).forEach(e=>delete n[e]),Object.keys(t).forEach(e=>n[e]=t[e])}function Ii(n){return typeof n=="object"&&n!==null}function Di(n,t){return[...n].map(s=>Zs(s,t))}const lc=n=>Array.isArray(n);function Zs(n,t){if(!Ii(n))return n;if(lc(n))return Di(n,t);{const e=Li({},n,t);return Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}}function Li(n,t,e){if(!Ii(n))return e.overrideExisting?t:n;if(Array.isArray(n)&&Array.isArray(t)){const i=e.overrideExisting?t:n;return Di(i,e)}const s=Object.create(Object.getPrototypeOf(n));return Object.keys(n).forEach(i=>s[i]=Zs(n[i],e)),Object.keys(t).forEach(i=>{i in n?s[i]=Li(n[i],t[i],e):e.addIfMissing&&(s[i]=Zs(t[i],e))}),s}const ie=n=>`${n.fontSize}px ${n.fontFamily}`;class cc{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=ie(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 hc=Object.defineProperty,dc=Object.defineProperties,uc=Object.getOwnPropertyDescriptors,Oi=Object.getOwnPropertySymbols,fc=Object.prototype.hasOwnProperty,pc=Object.prototype.propertyIsEnumerable,Bi=(n,t,e)=>t in n?hc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wt=(n,t)=>{for(var e in t||(t={}))fc.call(t,e)&&Bi(n,e,t[e]);if(Oi)for(var e of Oi(t))pc.call(t,e)&&Bi(n,e,t[e]);return n},Ri=(n,t)=>dc(n,uc(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 Fi={x:0,y:0,pageX:0,pageY:0,width:0,height:0},Hi=20,ki=35,$s=15,ji=1.5,Yi=Ot()?8*ji:8,Le=Ot()?5:0,gc=1e-6;class Ks{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 H,this.paneMovedSubject=new H,this.paneVisibilityChangedSubject=new H,this.xAxisHeight=void 0,this.yAxisWidths={right:[0],left:[0]},this.leftRatio=0,this.rightRatio=0,this.boundsChangedSubject=new H,this.barResizerChangedSubject=new H,this._graphsHeightRatio={[$]:1},this.graphsHeightRatioChangedSubject=new H,this.boundsChangedSubscriptions={},r.canvasResized.subscribe(o=>{let a=o;a||(a=this.canvasModel.canvas.getBoundingClientRect()),this.updateCanvasOnPageLocation(a),this.recalculateBounds()}),this.yAxisBoundsContainer=new cc(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)<gc?(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=ui(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]=Ni(this.panesOrder.length-1);this.graphsHeightRatio[t]=e}else delete this.graphsHeightRatio[t];this.recalculatePanesHeightRatios(),this.paneVisibilityChangedSubject.next()}removePaneBounds(t){Nl(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 x=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),G=M.PANE_UUID(B),Z=this.config.components.paneResizer.visible&&R>x&&V>0;Z?me(this.bounds,X,0,_,i.width,s,this.canvasOnPageLocation):me(this.bounds,X,0,0,0,0,this.canvasOnPageLocation);const U=_+(Z?s:0),Q=me(this.bounds,G,f,U,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 et=l*V-(Z?s:0);let tt=f-((k=r.left[0])!=null?k:0),st=u;J.left.forEach((ft,ct)=>{var _t;me(this.bounds,M.PANE_UUID_Y_AXIS(B,ft),tt,U,r.left[ct],et,this.canvasOnPageLocation),tt-=(_t=r.left[ct+1])!=null?_t:0}),J.right.forEach((ft,ct)=>{me(this.bounds,M.PANE_UUID_Y_AXIS(B,ft),st,U,r.right[ct],et,this.canvasOnPageLocation),st+=r.right[ct]})}else me(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=Ri(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-ki,e.width=t.width,e.height=ki):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)+Le}return this.xAxisHeight}setYAxisWidths(t){(!fi(this.yAxisWidths.left,t.left)||!fi(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]=Ni(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*ji:a!=null?a:0,h=l?r.y+(r.height-l)/2:r.y,d=(e=(t=this.config.components.navigationMap)==null?void 0:t.timeLabels)==null?void 0:e.visible,u=et=>Zl(this.canvasModel.ctx,et,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 et=this.getBounds(M.N_MAP_LABEL_L);et.x=r.x,et.y=r.y,et.width=_,et.height=r.height;const tt=this.getBounds(M.N_MAP_LABEL_R);tt.x=r.x+r.width-_,tt.y=r.y,tt.width=_,tt.height=r.height}const x=this.getBounds(M.N_MAP_BTN_L);x.x=r.x+_,x.y=r.y,x.width=$s,x.height=r.height;const A=this.getBounds(M.N_MAP_BTN_R);A.x=r.x+r.width-$s-_,A.y=r.y,A.width=$s,A.height=r.height;const E=x.x+x.width,Y=A.x-E,B=E+Y,R=this.config.components.navigationMap.minSliderWindowWidth,k=c!=null?c:Yi,V=l!=null?l:r.height,X=k+R,G=this.getBounds(M.N_MAP_KNOT_L);G.x=E+Y*this.leftRatio,G.x=Math.min(G.x,B-X),G.y=h,G.width=k,G.height=V;const Z=this.getBounds(M.N_MAP_KNOT_R);Z.x=E+Y*this.rightRatio-Yi,Z.x=Math.max(Z.x,E+X),Z.y=h,Z.width=k,Z.height=V;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=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(Fi),this.bounds[t]=e),e}getCanvasOnPageLocation(){return this.canvasOnPageLocation}getBoundsPanes(){return this.panesOrder.reduce((t,e)=>Ri(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=Hi,a=r*this.graphsHeightRatio[this.panesOrder[t]],l=r*this.graphsHeightRatio[this.panesOrder[s]],c=a+e>o,h=l-e>o;if(c&&h){const d=e/r;this.graphsHeightRatio[this.panesOrder[t]]+=d,this.graphsHeightRatio[this.panesOrder[s]]-=d,this.recalculateBounds()}}notifyBoundsSubscribers(){Object.keys(this.boundsChangedSubscriptions).forEach(t=>{this.boundsChangedSubscriptions[t].next(this.getBounds(t))}),this.boundsChangedSubject.next()}observeBoundsChanged(t){let e=this.boundsChangedSubscriptions[t];return e||(e=new ut(this.getBounds(t)),this.boundsChangedSubscriptions[t]=e),e.pipe(at(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(Fi,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 mc={0:1,1:.8,2:.6,3:.5,4:.4,5:.4,6:.4},Ni=n=>{var t;const e=(t=mc[n])!=null?t:.4,s=(1-e)/n;return[e,s]},Zm=(n,t)=>n.x>t.x&&n.x<t.x+t.width&&n.y>t.y&&n.y<t.y+t.height,vc=(n,t)=>n>t.y&&n<t.y+t.height,me=(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},Xi=(n,t)=>Math.min(Math.max(n,t.y),t.y+t.height),ns={extensionX:0,extensionY:0,wholePage:!1},Wi=(n,t)=>n.width===t.width&&n.height===t.height;var bc=(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})(fe),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,ot([n,t],F(e))):setInterval.apply(void 0,ot([n,t],F(e)))},clearInterval:function(n){var t=is.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},zi=(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})(bc),Oe={schedule:function(n){var t=requestAnimationFrame,e=cancelAnimationFrame,s=Oe.delegate;s&&(t=s.requestAnimationFrame,e=s.cancelAnimationFrame);var i=t(function(r){e=void 0,n(r)});return new fe(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=Oe.delegate;return((e==null?void 0:e.requestAnimationFrame)||requestAnimationFrame).apply(void 0,ot([],F(n)))},cancelAnimationFrame:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Oe.delegate;return((e==null?void 0:e.cancelAnimationFrame)||cancelAnimationFrame).apply(void 0,ot([],F(n)))},delegate:void 0},Cc=(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=Oe.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&&(Oe.cancelAnimationFrame(s),e._scheduled=void 0)},t})(zi),qs={now:function(){return(qs.delegate||Date).now()},delegate:void 0},Vi=(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=qs.now,n})(),Ui=(function(n){z(t,n);function t(e,s){s===void 0&&(s=Vi.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})(Vi),yc=(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})(Ui),Bt=new yc(Cc),$m=null,rs=new Ui(zi),wc=rs;function Sc(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(x){return d=Lt(n(x)).subscribe(yt(s,f,p))},_=function(){if(c){c=!1;var x=h;h=null,s.next(x),!u&&m(x)}};e.subscribe(yt(s,function(x){c=!0,h=x,!(d&&!d.closed)&&(o?_():m(x))},function(){u=!0,!(l&&c&&d&&!d.closed)&&s.complete()}))})}function xc(n){return n instanceof Date&&!isNaN(n)}function _c(n,t,e){n===void 0&&(n=0),e===void 0&&(e=wc);var s=-1;return t!=null&&(Kn(t)?e=t:s=t),new gt(function(i){var r=xc(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=_c(n,t);return Sc(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 Pc 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 H}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=Ks.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 Tc=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},Js=(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(Ks,"name")||{}).writable||Object.defineProperty(Ks,"name",{value:"default",configurable:!0});function Tc(n){const t=document.createElement("template");return t.innerHTML=Ks(n.devexpertsPromoLink),t}function Mc(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}),Pc(t))return t;throw new Error("Some chart elements are missing")}function Ac(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 Ec=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Oe=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Ec(!!c),u=d(n),f=d((r=(i=pe(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=xt(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:lt((u-f)/s),exact:!0}:{index:-1,exact:!0}:Yt(e,u,m=>d(m.timestamp))},Km=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))},Ui={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Gi={paintConfig:[Ui],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var Ic=Object.defineProperty,Zi=Object.getOwnPropertySymbols,Dc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,$i=(n,t,e)=>t in n?Ic(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Oc=(n,t)=>{for(var e in t||(t={}))Dc.call(t,e)&&$i(n,e,t[e]);if(Zi)for(var e of Zi(t))Lc.call(t,e)&&$i(n,e,t[e]);return n};class Bc{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:[Oc({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:Ui).color;return{textColor:ne(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function Rc(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)=>Fc(a,l,e)).filter(hi).sort(Hc),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 Fc=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,Hc=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var kc=Object.defineProperty,jc=Object.defineProperties,Yc=Object.getOwnPropertyDescriptors,Ki=Object.getOwnPropertySymbols,Nc=Object.prototype.hasOwnProperty,Xc=Object.prototype.propertyIsEnumerable,qi=(n,t,e)=>t in n?kc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ji=(n,t)=>{for(var e in t||(t={}))Nc.call(t,e)&&qi(n,e,t[e]);if(Ki)for(var e of Ki(t))Xc.call(t,e)&&qi(n,e,t[e]);return n},Qi=(n,t)=>jc(n,Yc(t));const re={MAIN:"MAIN"};class Wc extends X{constructor(t,e,s,i,r,o,a,l){super(),this.eventBus=t,this.scale=e,this.canvasBoundsContainer=s,this.state=i,this.canvasModel=r,this.paneUUID=o,this.updateYAxisWidth=a,this.chartResizeHandler=l,this.orderedLabels=[],this.customLabels={},this._labelsProviders={},this.labelsPositionRecalculatedSubject=new F,this.animFrameId=`anim_cache_${St()}`,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,Ot,{trailing:!0,leading:!0}))).subscribe(()=>{this.updateLabels()}))}initModel(){this.initLabelsGroups(),this.recalculateLabels(),this.canvasModel.fireDraw()}initLabelsGroups(){for(const t of Object.keys(this.labelsProviders))this.createGroup(t),Object.entries(this.labelsProviders[t]).forEach(([e,s])=>{this.addToGroup(s,t,e)})}updateLabels(t=!1){this.recalculateLabels(),Pe(this.animFrameId,()=>{t&&this.updateYAxisWidth(),this.canvasModel.fireDraw()})}recalculateLabels(){var t,e;this.orderedLabels=[];const s=this.state.fontSize+((t=this.state.labelBoxMargin.top)!=null?t:0)+((e=this.state.labelBoxMargin.bottom)!=null?e:0);for(const i of Object.values(this.labelsProviders)){const r=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=Rc(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 Qi(Ji({},t),{labels:t.labels.map((s,i)=>Qi(Ji({},s),{lineY:s.y,y:e[i]}))})}observeLabelsPositionsRecalculated(){return this.labelsPositionRecalculatedSubject.asObservable()}registerYAxisLabelsProvider(t,e,s){var i;const r=(i=this.labelsProviders[t])!=null?i:{};r[s]=e,this.labelsProviders[t]=r,this.initModel()}unregisterYAxisLabelsProvider(t,e){var s;const i=(s=this.labelsProviders[t])!=null?s:{};delete i[e],this.labelsProviders[t]&&Object.keys(this.labelsProviders[t]).length===0&&delete this.labelsProviders[t],this.initModel()}}var zc;let Ft=window.devicePixelRatio,rs=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const qs=()=>{rs.removeEventListener("change",qs),Ft=window.devicePixelRatio,rs=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),rs.addEventListener("change",qs)};rs.addEventListener("change",qs);const Vc=()=>Ft,qm=n=>zc(Ft*n)/Ft,It=n=>lt(Ft*n)/Ft,Js=n=>Cl(Ft*n)/Ft,oe=n=>JSON.parse(JSON.stringify(n));function Qs(n){return Object.entries(n)}const tr=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function er(n){return Object.keys(n)}function sr(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])||!sr(n[e[i]],t[e[i]]))return!1;return!0}const Uc=n=>Object.keys(n).length===0&&n.constructor===Object;function nr(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,x=function(){d==null||d.unsubscribe(),d=void 0},_=function(){x(),h=u=void 0,p=m=!1},A=function(){var L=h;_(),L==null||L.unsubscribe()};return N(function(L,Y){f++,!m&&!p&&x();var H=u=u!=null?u:e();Y.add(function(){f--,f===0&&!m&&!p&&(d=tn(A,l))}),H.subscribe(Y),!h&&f>0&&(h=new _e({next:function(B){return H.next(B)},error:function(B){m=!0,x(),d=tn(_,i,B),H.error(B)},complete:function(){p=!0,x(),d=tn(_,o),H.complete()}}),Lt(L).subscribe(h))})(c)}}function tn(n,t){for(var e=[],s=2;s<arguments.length;s++)e[s-2]=arguments[s];if(t===!0){n();return}if(t!==!1){var i=new _e({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,ot([],R(e)))).subscribe(i)}}const os=(n,t)=>n/t,bt=(n,t)=>n/t,Ht=(n,t)=>n*t,ir=(n,t)=>(n-t)*100/t,rr=(n,t)=>n*t/100+t,or=n=>Math.log2(n),en=n=>Math.pow(2,n);class Gc extends X{constructor(){super(...arguments),this._xStart=0,this._xEnd=0,this._yStart=0,this._yEnd=0,this._zoomX=1,this._zoomY=1,this._inverseY=!1,this.changed=new F,this.xChanged=this.changed.pipe(at(()=>({start:this.xStart,end:this.xEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),nr()),this.yChanged=this.changed.pipe(at(()=>({start:this.yStart,end:this.yEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),nr()),this.initialViewportValidSubject=new ut(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+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 Ht(e+bt(this.xStart,this.zoomX),this.zoomX)}fromY(t){const e=this.getBounds(),s=t-e.y;return this.inverseY?Ht(s+bt(this.yStart,this.zoomY),this.zoomY):Ht(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 os(e-t,this.getBounds().width)}calculateZoomY(t,e){return os(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 Zc=(n,t)=>!er(n).some(e=>n[e]!==t[e]);class $c{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(Yt(this.dataSeries.visualPoints,e.xStart,r=>r.centerUnit).index)),this.targetBaseline===void 0&&(this.targetBaseline=t(Yt(this.dataSeries.visualPoints,e.animationConfig.targetXStart,r=>r.centerUnit).index)),s=this.initialBaseline+(this.targetBaseline-this.initialBaseline)*i}else s=t();return s}}class ar{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 $c(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return ir(t,s);case"logarithmic":return t<=0?t:or(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 rr(t,this.getBaseline());case"logarithmic":return en(t);case"regular":return t}}}const zt=16;var Kc=Object.defineProperty,qc=Object.defineProperties,Jc=Object.getOwnPropertyDescriptors,lr=Object.getOwnPropertySymbols,Qc=Object.prototype.hasOwnProperty,th=Object.prototype.propertyIsEnumerable,cr=(n,t,e)=>t in n?Kc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,hr=(n,t)=>{for(var e in t||(t={}))Qc.call(t,e)&&cr(n,e,t[e]);if(lr)for(var e of lr(t))th.call(t,e)&&cr(n,e,t[e]);return n},eh=(n,t)=>qc(n,Jc(t));class Be{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 Be(this.centerUnit,this.close)}}class dr extends X{constructor(t,e,s,i,r){var o;super(),this.extentComponent=t,this.id=e,this.htId=s,this.parentId=i,this.name="",this.highlighted=!1,this._dataPoints=[],this.pricePrecisions=[2],this.linkedDataSeriesModels=[],this._dataPointsFlat=[],this._visualPoints=[],this._visualPointsFlat=[],this.dataIdxStart=0,this.dataIdxEnd=0,this.getPaintConfig=l=>{var c;return(c=this.config.paintConfig[l])!=null?c:this.config.paintConfig[0]},this.getBaseline=(l=this.dataIdxStart)=>{var c,h,d;return(c=this.visualPoints[l])!=null&&c.close&&((h=this.visualPoints[l])==null?void 0:h.close)>=0?(d=this.visualPoints[l])==null?void 0:d.close:1},this.getTextForPoint=l=>`${l.close}`,this.getLastVisualSeriesPoint=()=>{const l=this.visualPoints;if(l.length!==0)return l[this.dataIdxEnd]},this.getLastDataSeriesPoint=()=>{const l=this.visualPoints;return xt(l)};const a=r!=null?r:oe(Gi);this.config=At(a,Gi),this.scale=t.scale,this.view=new ar(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Bc(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=nh(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=fi(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=fi(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.pipe(Et(zt,Ot,{trailing:!0,leading:!0}),at(()=>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=hr({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new ar(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[re.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[re.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(re.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(re.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=Yt(this.visualPoints,t,r=>r.centerUnit).index,i=Yt(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 Hl(this.visualPoints2D,s,i)}}const sh=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},nh=n=>({isHighLowActive:()=>n.config.highLowActive&&n.config.visible,calculateHighLow:t=>{const e=sh(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return eh(hr({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),ih=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 as extends Be{constructor(t,e,s,i,r,o,a,l,c=!1,h=!1,d=!1){super(t,i),this.startUnit=t-e/2,this.endUnit=t+e/2,this.width=e,this.open=s,this.high=r,this.low=o,this.name=a,this.candle=l,this.hasBorder=c,this.isActive=h,this.isHollow=d}bodyHeight(t){return Math.max(Math.abs(t.toY(this.open)-t.toY(this.close)),1)}candleHeight(t){return Math.abs(t.toY(this.high)-t.toY(this.low))}bodyAsVLine(t){if(this.width<2)return[this.centerUnit,this.yLineStart(t),this.width,this.candleHeight(t)]}bodyRect(t){return[this.startUnit,this.yBodyStart(t),this.width,this.bodyHeight(t)]}getCandle(){return this.candle}yBodyKeyPoints(t){const e=t.toY(this.high),s=t.toY(this.low),i=t.toY(this.open),r=t.toY(this.close),[o,a]=i>r?[r,i]:[i,r],[l,c]=e>s?[s,e]:[e,s];return[l,o,a,c]}yLineEnd(t){return Math.max(t.toY(this.high),t.toY(this.low))}yLineStart(t){return Math.min(t.toY(this.high),t.toY(this.low))}yBodyStart(t){return Math.min(t.toY(this.open),t.toY(this.close))}yBodyEnd(t){return Math.max(t.toY(this.open),t.toY(this.close))}xCenter(t){return this.x(t)}xStart(t){return t.toX(this.startUnit)}}const me=60,Re=(n,t,e=me)=>{const s=ur(n,t,e);return{id:Pi(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},rh=(n,t,e=me)=>({close:NaN,timestamp:ur(n,t,e)});function ur(n,t,e=me){var s,i;const r=Me(t);if(n.length===0)return 0;const o=xt(n);if(r>=n.length&&o)return fr(o,n.length-1,r,e);const a=pe(n);return r<0&&a?fr(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const fr=(n,t,e,s=me)=>n.timestamp+(e-(t!=null?t:0))*s,sn=(n,t,e,s,i=me)=>{const r=Re(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 as(o,e,r.open,r.close,r.lo,r.hi,ts(r.open,r.close),r)},oh=(n,t,e,s,i=me)=>{const r=rh(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 Be(o,r.close)};class ah{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}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=Oe(t,e,s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=Ac(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?sn(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):oh(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var lh=Object.defineProperty,pr=Object.getOwnPropertySymbols,ch=Object.prototype.hasOwnProperty,hh=Object.prototype.propertyIsEnumerable,gr=(n,t,e)=>t in n?lh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dh=(n,t)=>{for(var e in t||(t={}))ch.call(t,e)&&gr(n,e,t[e]);if(pr)for(var e of pr(t))hh.call(t,e)&&gr(n,e,t[e]);return n};class uh{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!sr(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=dh({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const fh=(n,t,e,s,i,r,o)=>{const a=Vc(),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]=lt(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?lt(u*o):lt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},mr=(n,{x:t,width:e,activeCandle:s})=>new as(t,e,n.open,n.close,n.hi,n.lo,ts(n.open,n.close),n,!0,nn(n,s)),ph=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new as(t,e,n.open,n.close,n.hi,n.lo,Kl((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,nn(n,s),n.close>n.open)},vr=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new as(t,e,n.open,n.close,n.hi,n.lo,ts((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,nn(n,s),n.close>n.open)},gh=vr,nn=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},br=()=>Vs,Fe=class he{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>lt(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=he.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]=he.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*he.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<he.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*he.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return he.MAXIMUM_PRECISION}static validatePriceIncrementsOrPrecisions(t){return!(t.length===0||!Array.isArray(t)||t.findIndex(e=>e!==0)===-1)}};Fe.DEFAULT_INCREMENT=.01,Fe.DEFAULT_PRECISION=2,Fe.RELATIVE_EPS=1e-8,Fe.MAXIMUM_PRECISION=10;let ve=Fe;const mh=(n,t)=>{var e;const s=(e=xt(t))!=null?e:1;return Math.pow(10,-s)};var vh=Object.defineProperty,bh=Object.defineProperties,Ch=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,yh=Object.prototype.hasOwnProperty,wh=Object.prototype.propertyIsEnumerable,yr=(n,t,e)=>t in n?vh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Sh=(n,t)=>{for(var e in t||(t={}))yh.call(t,e)&&yr(n,e,t[e]);if(Cr)for(var e of Cr(t))wh.call(t,e)&&yr(n,e,t[e]);return n},xh=(n,t)=>bh(n,Ch(t));const _h=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=wr(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return xh(Sh({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),wr=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 Ph{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){Th(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Th=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=Sr(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 Sr(n){if(n.length===0)return Mh();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 Mh=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),xr=(n,t)=>n/t,Ah=(n,t)=>n/t,Eh=(n,t)=>n*t,_r=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=xr(e,s),r=n.yEnd-n.yStart;t.zoomY=Ah(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Ih=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=xr(e,s),r=n.xEnd-n.xStart;t.zoomX=Eh(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Dh=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},Lh=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},Pr=(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},Oh=(n,t,e,s)=>Pr(n,t,1,e,s),Bh=Ee,Rh=.9,Fh=(n,t,e,s)=>{t.currentAnimation&&t.currentAnimation.animationInProgress&&t.currentAnimation.getProgress()>Rh&&(t.currentAnimation.finishAnimation(),t.currentAnimation=void 0),s&&s.doAutoYScale(e),ls(n,t,e)},ls=(n,t,e)=>{const s=n.startViewportMovementAnimation(t,{duration:Bh,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},fe,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s};var Hh=Object.defineProperty,kh=Object.defineProperties,jh=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,Yh=Object.prototype.hasOwnProperty,Nh=Object.prototype.propertyIsEnumerable,Mr=(n,t,e)=>t in n?Hh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ae=(n,t)=>{for(var e in t||(t={}))Yh.call(t,e)&&Mr(n,e,t[e]);if(Tr)for(var e of Tr(t))Nh.call(t,e)&&Mr(n,e,t[e]);return n},Ar=(n,t)=>kh(n,jh(t));const Xh=new F,Wh=new F,zh=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Er extends Gc{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=oe(t.scale),this.autoScaleModel=new Ph(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=ae(ae({},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();Pr(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();Oh(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(fe),this.doAutoScale())}zoomXTo(t,e,s){var i;const r=this.export(),o=this.scalePostProcessor(r,t);this.zoomReached=this.calculateZoomReached(o.zoomX,e),!(this.zoomReached.zoomIn||this.zoomReached.zoomOut)&&(this.state.lockPriceToBarRatio&&_r(r,o),this.state.auto&&this.autoScaleModel.doAutoYScale(o),s?this.apply(o):((i=this.currentAnimation)==null||i.tick(),ls(this.canvasAnimation,this,o)))}calculateZoomReached(t,e=!0){const s=this.getBounds().width,i=.001;if(s>0){const r=os(this.config.components.chart.minCandles,s),a=t!==r&&t-r<=i&&e,l=os(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=Ar(ae({},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&&_r(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(),Ae?Fh(this.canvasAnimation,this,l,this.state.auto?this.autoScaleModel:void 0):ls(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=Ar(ae({},s),{xStart:a,xEnd:o}),c=this.scalePostProcessor(s,l);this.state.auto&&this.autoScaleModel.doAutoYScale(c),(e=this.currentAnimation)==null||e.tick(),ls(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);Ih(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=ae({},e);this.haltAnimation(),Dh(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();Lh(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),Zc(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=Xh.pipe(Et(zt,Ot,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ae({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)}),this.autoScalePanSubscription=Wh.pipe(Et(zt,Ot,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ae({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)})}}class Vh extends Er{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 Uh=es().colors;class $t extends dr{constructor(t,e,s,i,r,o,a,l,c=Uh){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=zh(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new F,this.meanCandleWidth=Vs,this._instrument=o,this.instrument=o,this.highLowProvider=_h(this),this.scale=r,this.name=o.symbol}get dataPoints(){return super.dataPoints}set dataPoints(t){super.dataPoints=t,this.applyPriceMovement()}get instrument(){return this._instrument}set instrument(t){var e;this._instrument=t,this.pricePrecisions=ve.computePrecisions((e=t.priceIncrements)!=null?e:[.01])}recalculateDataViewportIndexes(t=this.scale.xStart,e=this.scale.xEnd){const{dataIdxStart:s,dataIdxEnd:i}=this.calculateDataViewportIndexes(t,e);this.dataIdxStart=s,this.dataIdxEnd=i,this.recalculateZippedHighLow(),this.eventBus.fireDraw()}calculateDataViewportIndexes(t,e){const s=Yt(this.visualPoints,t,r=>r.startUnit).index,i=Yt(this.visualPoints,e,r=>r.startUnit).index;return{dataIdxStart:s,dataIdxEnd:i}}applyPriceMovement(){const t=xt(this.dataPoints);t&&(this.lastPriceMovement=ts(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=wr(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:br;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:mr;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=Vs}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 Jm(n){switch(n){case"line":case"area":return!0;default:return!1}}class Gh{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=!!i.color;if(s instanceof $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),x=s.view.toY(p.close),_=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(lt(m),_),t.moveTo(lt(m),x);else if(f===void 0){t.lineTo(lt(m),x),t.stroke(),t.lineTo(lt(m),_),t.lineTo(lt(h),_),t.closePath();let A;i.color?t.fillStyle=i.color:t.fillStyle=s.colors.areaTheme.startColor&&s.colors.areaTheme.stopColor?(A=t.createLinearGradient(0,0,0,l.height),A.addColorStop(0,s.colors.areaTheme.startColor),A.addColorStop(1,s.colors.areaTheme.stopColor),A):"",o||t.fill()}else t.lineTo(m,x)}}}}function Ir(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 Zh(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 $h(n,t,e,s,i,r=1,o=[]){n.save(),n.setLineDash(o),n.lineWidth=r,n.beginPath(),n.moveTo(t,e),n.lineTo(s,i),n.stroke(),n.closePath(),n.restore()}function le(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function Dr(n,t,e){const s=Math.min(t.x,e.x)+.5,i=Math.min(t.y,e.y),r=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);n.fillRect(s,i,r,o)}const Kt=(n,t)=>{n.beginPath(),n.rect(t.x,t.y,t.width,t.height),n.clip(),n.closePath()},Qm=n=>Array.isArray(n[0])?n:[n];class Kh{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&&!Uc(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 qh{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),le(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 Jh{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),x=s.view.toY(d.close),_=u?s.view.toY(u.close)<l:!1,A=x<l;if(u!==void 0&&_!==A){Lr(t,s,i,_);const L=s.view.toX(u.centerUnit),Y=s.view.toY(u.close),H=m-L,B=x-Y,j=H/B,K=x-l,W=j*K,U=L+(H-W);t.lineTo(U,l),t.stroke(),t.lineTo(p,l),t.closePath(),t.fill(),t.beginPath(),t.moveTo(U,l)}u===void 0?(t.beginPath(),t.moveTo(m,x)):f===void 0?(Lr(t,s,i,A),t.lineTo(m,x),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,x)}}}}const Lr=(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 Qh{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),le(t,()=>{this.pixelLength=1/Ft,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,x]=i.yBodyKeyPoints(s.view),_=p===m?p+1:m,A=f===x?f+1:x,L=l[`${a}Color`],Y=a==="none"?L:l[`${a}WickColor`];t.fillStyle=L,e.color?t.strokeStyle=e.color:t.strokeStyle=Y;const H=c||(i.hasBorder&&i.isActive?this.config.showActiveCandlesBorder:this.config.showCandlesBorder),B=this.config.showWicks;if(d<2)t.beginPath(),t.moveTo(h,B?f:p),t.lineTo(h,B?A:_),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,B?f:p),t.lineTo(h,B?A:_),t.moveTo(h+1,p),t.lineTo(h+1,_),t.stroke();else if(d===3){const j=d/Ft;this.drawCandlesWicks(t,h+j,f,A,p,_),c||(t.beginPath(),t.moveTo(h+j,p),t.lineTo(h+j,_),t.stroke()),this.drawCandleBorder(t,e,l,i,h+this.halfLineWidthCU,p+this.halfLineWidthCU,d-this.lineWidthCU,u-this.lineWidthCU)}else{const j=i.x(s.view);this.drawCandlesWicks(t,j,f,A,p,_);const K=this.config.candlePaddingPercent,W=Math.max(d*K/2,this.pixelLength),U=h+W,G=d-W*2;if(!c){e.color&&(t.fillStyle=e.color);const V=e.hoverWidth?d+W:G,Q=e.hoverWidth?u+e.hoverWidth+W:u;t.fillRect(U,p,V,Q)}H&&this.drawCandleBorder(t,e,l,i,U+this.halfLineWidthCU,p+this.halfLineWidthCU,G-this.lineWidthCU,u-this.lineWidthCU)}}drawCandlesWicks(t,e,s,i,r,o){this.config.showWicks&&(t.beginPath(),t.moveTo(e,s),t.lineTo(e,r),t.moveTo(e,o),t.lineTo(e,i),t.stroke())}drawCandleBorder(t,e,s,i,r,o,a,l){if(e.color)t.strokeStyle=e.color;else{const c=i.name;t.strokeStyle=c==="none"?s[`${c}Color`]:s[`${c}WickColor`]}t.strokeRect(r,o,a,l)}}class td{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 ed{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 sd=1.5;class nd{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:sd;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 id=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class rd{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 id.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Kt(t,e.scale.getBounds())}}class od{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(lt(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,x=h.yBodyStart(this.chartModel.scale),_=this.chartModel.config.components.chart.candlePaddingPercent,A=It(f*_/2),L=m+A,Y=f-A*2;t.fillRect(L,x,Y,p)}})})}}const ad=(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)},Or=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{ad(s,t,e,i)})},ld=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,cd=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,hd=/^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*[)]$/,dd=n=>ld.exec(n),ud=n=>cd.exec(n),tv=n=>hd.exec(n);function fd(n){const t=dd(n)||ud(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const Br={};function pd(n,t){let e=Br[n+t];if(!e){const s=fd(n);e=s&&"rgba("+s.join(",")+","+t+")",Br[n+t]=e}return e}const Rr="#383838";class gd{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(Fr(l.config.type)&&Fr(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,x)=>{var _,A;const L=[],Y=Math.min(m.length,(A=(_=p[x])==null?void 0:_.length)!=null?A:0);for(let j=0;j<Y;j++){const K=[m[j].clone(),p[x][j].clone()];L.push({diffPoints:K})}const H=u.getPaintConfig(x).color,B=l.getPaintConfig(c).color;this.drawDifference(t,H,B,L,u,l,i,r)})}})}drawLine(t,e,s){t.beginPath(),Or(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a,l){const[c,h]=[[],[]];i.forEach(x=>{const[_,A]=x.diffPoints;c.push(_),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=pe(s))==null?void 0:a.x)!=null?l:0,u=(h=(c=xt(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:Rr:t.fillStyle=pd(e!=null?e:Rr,.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 Fr=n=>n==="DIFFERENCE";class md{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,lt(r)),t.lineTo(d,lt(u))}),t.stroke()})}}class vd{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(),Or(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 Cd{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 yd{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 cs="resized_local",hs="draw",ev="draw_last_candle",be={width:20,height:20};class Hr{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=rn;var a;i.push(this),this.parent=xd(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>be.width&&this.height>be.height}}const rn={name:"candle"},wd={candle:rn,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function Sd(n,t,e,s,i,r,o){var a;const l=ce(n,t,i,r,o,e);return l.type=(a=wd[s])!=null?a:rn,l}function ce(n,t,e,s,i,r,o){const a=new Hr(n,t,s,i,r,o);return kr(a,e),a}function kr(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 xd(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 ds="HIT_TEST_",rv=null;class _d{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${St()}`,this.drawHitTestCanvas=()=>{this.drawingOrder.forEach(s=>{s.indexOf(ds)!==-1&&this.drawersMap[s].draw()})},t.on(hs,s=>{e.wasResized()&&(this.canvasIdsList&&(s&&s.length!==0?this.canvasIdsList=this.canvasIdsList.concat(s):this.canvasIdsList=void 0),ei(this.animFrameId,()=>{this.forceDraw(this.canvasIdsList),this.canvasIdsList=[],this.drawHitTestCanvas()}))})}redrawCanvasesImmediate(){this.chartResizeHandler.fireUpdates(),this.forceDraw()}drawLastBar(){this.drawingOrder.forEach(t=>{if(t.indexOf(ds)===-1){const e=this.drawersMap[t];e.drawLastBar&&e.drawLastBar()}})}forceDraw(t){this.isDrawable()&&this.drawingOrder.forEach(e=>{if(e.indexOf(ds)===-1){const s=this.drawersMap[e];if(!t||t.length===0){s.draw();return}Bl(t,s.getCanvasIds()).length&&s.draw()}})}isDrawable(){var t,e,s,i;return((e=(t=this.chartResizeHandler.previousBCR)==null?void 0:t.height)!=null?e:0)>be.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>be.height}drawHitTestOnly(){this.drawHitTestCanvas()}addDrawer(t,e=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=di(this.drawingOrder,t)}}class jr{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Pd=7;class Td{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:Pd};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Yr={dragPredicate:()=>!0};class Nr extends X{constructor(t,e,s,i,r){super(),this.hitTest=t,this.dragCallbacks=e,this.canvasInputListener=s,this.chartPanComponent=i,this.dragComponentOptions=r,this.dragging=!1,this.draggedPixels=0,this.onDragStart=o=>{this.dragComponentOptions.dragPredicate()&&(this.dragging=!0,this.draggedPixels=0,this.dragCallbacks.onDragStart&&this.dragCallbacks.onDragStart(o))},this.onDragTick=o=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.draggedPixels+=o,this.dragCallbacks.onDragTick({delta:o,draggedPixels:this.draggedPixels}))},this.onDragEnd=()=>{this.dragComponentOptions.dragPredicate()&&this.dragging&&(this.dragging=!1,this.dragCallbacks.onDragEnd&&this.dragCallbacks.onDragEnd(this.draggedPixels))}}}class us extends Nr{constructor(t,e,s,i,r=Yr){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 Md="BASELINE_RESIZER";class Ad extends X{constructor(t,e,s,i,r,o,a){super(),this.chartModel=t,this.chartPanComponent=e,this.canvasModel=s,this.canvasInputListener=i,this.config=r,this.canvasBoundContainer=o,this.cursorHandler=a,this.resizerBounds={x:0,y:0,pageX:0,pageY:0,height:0,width:0},this.dragPredicate=new ut(!1),this.baselineYPercents=50,this.ht=Zs.hitTestOf(this.resizerBounds,{extensionY:this.config.components.paneResizer.dragZone}),this.dragStartCb=()=>{this.chartPanComponent.deactivatePanHandlers(),this.dragPredicate.next(!0)},this.dragEndCb=()=>{this.chartPanComponent.activateChartPanHandlers(),this.dragPredicate.next(!1)},this.dragTickCb=c=>{const{delta:h}=c,d=this.canvasBoundContainer.getBounds(M.CHART),u=this.canvasInputListener.getCurrentPoint().y;h!==0&&mc(u,d)&&(this.moveBaseLine(u),this.canvasModel.fireDraw())};const l=new us(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[Md]=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 Ed=n=>{var t;try{const e=Te(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Te(n.hi,Math.max(n.open,n.close),e),i=Te(n.lo,Math.min(n.open,n.close),e),r=Te(n.open,n.lo,e),o=Te(n.close,n.hi,e),a=Number.isNaN(n.vwap)?void 0:n.vwap;return{id:n.id,hi:s,lo:i,open:r,close:o,timestamp:n.timestamp,volume:(t=n.volume)!=null?t:0,expansion:n.expansion,idx:n.idx,impVolatility:n.impVolatility,openInterest:n.openInterest,vwap:a,typicalPrice:n.typicalPrice}}catch(e){console.warn(e);return}},He=(n,t=0)=>{for(let e=t;e<n.length;++e)n[e].idx=e},Xr=n=>{n.forEach(t=>{t.idx=void 0})},Id=n=>n!==void 0;class Dd{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,x,_;const A=Ld(o,c),L=A&&l.close<A;if(((h=a.multiplyColors)==null?void 0:h.length)===2){t.strokeStyle=(d=i.color)!=null?d:(L?a.multiplyColors[1]:a.multiplyColors[0])||a.color||"#FF00FF",t.beginPath();const B=s.view.toX(l.centerUnit),j=s.view.toY(l.close);t.moveTo(B,r),t.lineTo(B,j),t.stroke();return}if(((u=a.multiplyColors)==null?void 0:u.length)===4){L&&l.close<0&&(t.strokeStyle=(f=i.color)!=null?f:a.multiplyColors[0]||a.color||"#FF00FF"),!L&&l.close<0&&(t.strokeStyle=(p=i.color)!=null?p:a.multiplyColors[1]||a.color||"#FF00FF"),L&&l.close>0&&(t.strokeStyle=(m=i.color)!=null?m:a.multiplyColors[2]||a.color||"#FF00FF"),!L&&l.close>0&&(t.strokeStyle=(x=i.color)!=null?x:a.multiplyColors[3]||a.color||"#FF00FF"),t.beginPath();const B=s.view.toX(l.centerUnit),j=s.view.toY(l.close);t.moveTo(B,r),t.lineTo(B,j),t.stroke();return}t.strokeStyle=(_=i.color)!=null?_:a.color||"#FF00FF",t.beginPath();const Y=s.view.toX(l.centerUnit),H=s.view.toY(l.close);t.moveTo(Y,r),t.lineTo(Y,H),t.stroke()})}}const Ld=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},Od=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class Bd{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=Rd(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),x=s.view.toY(d.close);t.beginPath(),t.moveTo(m,x),t.lineTo(f,p),t.stroke();return}})}}const Rd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0},Ce="#FF00FF";class Fd{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,x,_;const A=Hd(r,c),L=A&&l.close<A;if(((h=o.multiplyColors)==null?void 0:h.length)===2){t.fillStyle=(d=i.color)!=null?d:(L?o.multiplyColors[1]:o.multiplyColors[0])||o.color||Ce;const B=s.view.toX(l.centerUnit),j=s.view.toY(l.close);t.arc(B,j,a,0,Math.PI*2),t.fill();return}if(((u=o.multiplyColors)==null?void 0:u.length)===4){L&&l.close<0&&(t.fillStyle=(f=i.color)!=null?f:o.multiplyColors[0]||o.color||Ce),!L&&l.close<0&&(t.fillStyle=(p=i.color)!=null?p:o.multiplyColors[1]||o.color||Ce),L&&l.close>0&&(t.fillStyle=(m=i.color)!=null?m:o.multiplyColors[2]||o.color||Ce),!L&&l.close>0&&(t.fillStyle=(x=i.color)!=null?x:o.multiplyColors[3]||o.color||Ce),t.beginPath();const B=s.view.toX(l.centerUnit),j=s.view.toY(l.close);t.arc(B,j,a,0,Math.PI*2),t.fill();return}t.fillStyle=(_=i.color)!=null?_:o.color||Ce,t.beginPath();const Y=s.view.toX(l.centerUnit),H=s.view.toY(l.close);t.arc(Y,H,a,0,Math.PI*2),t.fill()})}}const Hd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0};var kd=Object.defineProperty,Wr=Object.getOwnPropertySymbols,jd=Object.prototype.hasOwnProperty,Yd=Object.prototype.propertyIsEnumerable,zr=(n,t,e)=>t in n?kd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Vr=(n,t)=>{for(var e in t||(t={}))jd.call(t,e)&&zr(n,e,t[e]);if(Wr)for(var e of Wr(t))Yd.call(t,e)&&zr(n,e,t[e]);return n};class Nd{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class Xd extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.chartModel=t,this.canvasModel=e,this.config=s,this.scale=i,this.canvasBoundsContainer=r,this.drawingManager=o,this.hitTestCanvasModel=a,this.canvasInputListener=l,this.paneManager=d,this.dynamicObjects=f,this.chartResizeHandler=p,this._dataSeriesDrawers={},this.backgroundDrawerPredicateSubject=new ut(!0),this.strToBarType=x=>{var _;return(_=this.barTypeValues.find(A=>A===x))!=null?_:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new Ad(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const m=new Td(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(m,ds+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new uh(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(M.PANE_UUID(Z),s.components.chart.cursor),this.dataSeriesDrawer=new Kh(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(Od(()=>{this.backgroundDrawerPredicateSubject.next(!1)},zt))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",mr),this.registerCandlesTransformer("trend",vr),this.registerCandlesTransformer("hollow",ph),this.registerCandlesTransformer("line",gh)}get barTypeValues(){return er(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 Qh(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new qh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new ed(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new nd(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new Gh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new Jh(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new td(this.config.components.chart.histogram));const e=M.PANE_UUID(Z),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new vd),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new Bd),this.registerDataSeriesTypeDrawer("HISTOGRAM",new md),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new Dd),this.registerDataSeriesTypeDrawer("POINTS",new bd),this.registerDataSeriesTypeDrawer("TREND_POINTS",new Fd),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new rd(new od(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new Cd(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new yd),this.registerDataSeriesTypeDrawer("DIFFERENCE",new gd)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(Vr({},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=Vr({},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 Xr(a),{candles:a,instrument:o}})),this.updatePriceIncrementsIfNeeded(s)}setSecondarySeries(t){var e;const s=(e=t.instrument)!=null?e:this.chartModel.mainCandleSeries.instrument,i=this.chartModel.setSecondaryCandleSeries(t.candles,s);if(this.updatePriceIncrementsIfNeeded(s),i)return i}setAllSeries(t,e=[]){var s;const i=(s=t.instrument)!=null?s:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(i),e.forEach(r=>{var o;const a=(o=r.instrument)!=null?o:this.chartModel.mainCandleSeries.instrument;this.updatePriceIncrementsIfNeeded(a)}),this.chartModel.setAllSeries(t,e)}toXFromCandleIndex(t){return this.chartModel.toX(t)}toXFromTimestamp(t){return this.chartModel.candleFromTimestamp(t).xCenter(this.chartModel.scale)}toY(t){return this.chartModel.toY(t)}updateAllSeries(t,e=[]){this.chartModel.updateAllSeries(t,e),this.canvasModel.fireDraw()}removeDataFrom(t){this.chartModel.removeDataFrom(t)}removeSecondarySeries(t){this.chartModel.removeSecondaryCandleSeries(t)}prependCandles(t,e){this.chartModel.prependCandles(t,e)}addLastCandle(t,e){this.chartModel.addLastCandle(t,e)}removeCandleByIdx(t,e){this.chartModel.removeCandleByIdx(t,e)}removeCandlesByIdsSequence(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIdsSequence(t,e)}removeCandlesByIds(t,e=this.chartModel.mainCandleSeries){this.chartModel.removeCandlesByIds(t,e)}addCandlesById(t,e,s=this.chartModel.mainCandleSeries){this.chartModel.addCandlesById(t,e,s)}updateLastCandle(t,e){this.chartModel.updateLastCandle(t,e)}updateCandles(t,e){this.chartModel.updateCandles(t,e)}setOffsets(t){this.chartModel.setOffsets(t)}getDataSeriesDrawer(t){return this._dataSeriesDrawers[t]}registerDataSeriesTypeDrawer(t,e){this._dataSeriesDrawers[t]=e}updatePriceIncrementsIfNeeded(t){(!t.priceIncrements||!ve.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[ve.autoDetectIncrementOfValueRange(this.scale.yEnd-this.scale.yStart)])}observeOffsetsChanged(){return this.chartModel.offsetsChanged}observeChartTypeChanged(){return this.chartModel.chartTypeChanged}observeCandlesChanged(){return this.chartModel.observeCandlesChanged()}observeCandlesUpdated(){return this.chartModel.candlesUpdatedSubject}observeCandlesPrepended(){return this.chartModel.candlesPrependSubject}}function Ur(n,t){return t===void 0&&(t=is),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 Gr 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 Wd=Object.defineProperty,Zr=Object.getOwnPropertySymbols,zd=Object.prototype.hasOwnProperty,Vd=Object.prototype.propertyIsEnumerable,$r=(n,t,e)=>t in n?Wd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ud=(n,t)=>{for(var e in t||(t={}))zd.call(t,e)&&$r(n,e,t[e]);if(Zr)for(var e of Zr(t))Vd.call(t,e)&&$r(n,e,t[e]);return n};const Gd=(n,t,e,s)=>{var i,r,o,a;const l=Ud({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=kl(-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-Ht(s.width,l.zoomX),u=c),l.xStart=d,l.xEnd=u,l},Zd=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()}},$d=(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 Kd=Object.defineProperty,qd=Object.defineProperties,Jd=Object.getOwnPropertyDescriptors,Kr=Object.getOwnPropertySymbols,Qd=Object.prototype.hasOwnProperty,tu=Object.prototype.propertyIsEnumerable,qr=(n,t,e)=>t in n?Kd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ke=(n,t)=>{for(var e in t||(t={}))Qd.call(t,e)&&qr(n,e,t[e]);if(Kr)for(var e of Kr(t))tu.call(t,e)&&qr(n,e,t[e]);return n},on=(n,t)=>qd(n,Jd(t));class eu{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)=>on(ke({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=on(ke({},oe(this.config.colors)),{lineTheme:ke({},s.lineTheme),areaTheme:ke({},s.areaTheme)}),e),{})}takeColorFromPool(t){let e=Number.MAX_SAFE_INTEGER,s="";for(const[i,r]of Object.entries(this.usedChartColors))r<e&&(e=r,s=i);return this.usedChartColors[s]=this.usedChartColors[s]+1,this.symbolsToColorKeys[t]=s,this.secondaryChartColorsPool[s]}addColorToPool(t){const e=this.symbolsToColorKeys[t];this.usedChartColors[e]&&(this.usedChartColors[e]=this.usedChartColors[e]-1)}updateColorConfig(t,e){var s,i;const r=this.secondaryChartColorsPool[this.usedChartColors[t]];if(r){const o=e;this.secondaryChartColorsPool[this.usedChartColors[t]]=on(ke({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var su=Object.defineProperty,Jr=Object.getOwnPropertySymbols,nu=Object.prototype.hasOwnProperty,iu=Object.prototype.propertyIsEnumerable,Qr=(n,t,e)=>t in n?su(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fs=(n,t)=>{for(var e in t||(t={}))nu.call(t,e)&&Qr(n,e,t[e]);if(Jr)for(var e of Jr(t))iu.call(t,e)&&Qr(n,e,t[e]);return n};class ru extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.chartBaseModel=t,this.paneManager=e,this.bus=s,this.canvasModel=i,this.config=r,this.scale=o,this.formatterFactory=a,this.mainCanvasParent=l,this.canvasBoundsContainer=c,this.chartResizeHandler=h,this.prevChartWidth=0,this.prevYWidth=0,this.candleSeries=[],this.chartTypeChanged=new 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(Ed).filter(Id),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new eu(this.config);const d=new Gr(this.chartBaseModel,this.paneManager.panes[Z].mainExtent,St(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new Nd,this.candlesTransformersByChartType,this.candleWidthByChartType,fs({},this.config.colors));d.config.type=this.config.components.chart.type,this.candleSeries.push(d),this.config.components.chart.minCandlesOffset>0&&o.addXConstraint((u,f)=>Gd(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=Zd(o),this.timeFrameViewportTransformer=$d(o,this),this.pane=this.paneManager.panes[Z]}get mainCandleSeries(){return this.candleSeries[0]}get secondaryCandleSeries(){return this.candleSeries.filter(t=>t!==this.mainCandleSeries)}get candlesUpdatedSubject(){return this.chartBaseModel.dataUpdatedSubject}get candlesSetSubject(){return this.chartBaseModel.dataSetSubject}get candlesRemovedSubject(){return this.chartBaseModel.dataRemovedSubject}get candlesPrependSubject(){return this.chartBaseModel.dataPrependSubject}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID(Z)).pipe(mt(Xi)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(Ur(zt)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>be.width&&t.height>be.height){const e=this.canvasBoundsContainer.getEffectiveChartWidth(),s=this.canvasBoundsContainer.getEffectiveYAxisWidth();if(this.prevChartWidth===0&&this.scale){this.scale.isViewportValid(!1)?this.scale.recalculateZoom():this.doBasicScale(),this.prevChartWidth=e,this.prevYWidth=s;return}if(s!==this.prevYWidth){if(this.config.scale.keepZoomXOnYAxisChange){const r=Ht(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=Ht(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 Xr(i),{candles:i,instrument:s.instrument}}))}setSecondaryCandleSeries(t,e=this.mainCandleSeries.instrument,s=!0){const i=this.prepareCandles(t),r=this.reindexCandlesBasedOnSeries(this.mainCandleSeries.dataPoints,i),o=this.secondarySeriesAdjustments(this.mainCandleSeries.dataPoints,r),l=this.secondaryCandleSeries.some(c=>c.instrument.symbol===e.symbol)?this.secondaryCandleSeries.find(c=>c.instrument.symbol===e.symbol):this.createSecondaryCandleSeriesModel(e);if(l)return l.dataPoints=o,s&&(this.scale.doAutoScale(),l.recalculateVisualPoints(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()),l}setAllSeries(t,e=[]){var s;this.mainCandleSeries.instrument=(s=t.instrument)!=null?s:this.mainCandleSeries.instrument,t.instrument&&this.mainInstrumentChangedSubject.next(t.instrument),this.rememberCurrentTimeframe();const i=this.prepareCandles(t.candles);this.mainCandleSeries.clearData(),He(i),this.mainCandleSeries.dataPoints=i,this.secondaryCandleSeries.filter(r=>e.filter(o=>{var a;return((a=o.instrument)==null?void 0:a.symbol)===r.instrument.symbol}).length===0).forEach(r=>this.removeSecondaryCandleSeries(r)),e.map(r=>this.setSecondaryCandleSeries(r.candles,r.instrument,!1)),this.candleSeries.forEach(r=>{r.recalculateDataViewportIndexes(),r.recalculateVisualPoints()}),this.chartBaseModel.recalculatePeriod(),this.autoScaleOnCandles(),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesSetSubject.next(),this.canvasModel.fireDraw()}autoScaleOnCandles(){this.scale.state.autoScaleOnCandles&&(this.doBasicScale(),this.scale.autoScale(!0))}doBasicScale(){this.basicScaleViewportTransformer(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doBasicXScale(){this.scale.setXScaleWithoutYScale(this.mainCandleSeries.visualPoints),this.bus.fireDraw()}doPreviousTimeFrameScale(t=null){this.timeFrameViewportTransformer(this.lastTimeFrame,t),this.scale.state.autoScaleOnCandles&&this.scale.doAutoScale(!0),this.bus.fireDraw()}rememberCurrentTimeframe(){this.mainCandleSeries.visualPoints.length!==0&&(this.lastTimeFrame=[this.candleFromX(this.scale.toX(this.scale.xStart),!0).timestamp,this.candleFromX(this.scale.toX(this.scale.xEnd),!0).timestamp])}updateAllSeries(t,e=[]){t=fs({},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=eo(this.mainCandleSeries.dataPoints,i),o=r.candles;He(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=eo((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints()});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=Yt(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=fs(fs({},this.config.colors),this.secondaryChartColors.takeColorFromPool(t.symbol));return this.createCandleSeriesModel(t,e)}createCandleSeriesModel(t,e){const s=new $t(this.paneManager.panes[Z].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[Z].removeDataSeries(t),this.scale.doAutoScale(),t.colors}secondarySeriesAdjustments(t,e){const s=[];return t.forEach(i=>{const r=this.candleIdxFromId(i.id),o=r>0?r:0,a=e[o];if(a)s.push(a);else{let l=to(e,o,-1);if(l||(l=to(e,o,1)),l){const c=ql(l,o,!0);s.push(c)}}}),s}updateSecondaryCandleSeriesConfig(t,e,s){const i=At(t,es().colors);this.secondaryChartColors.updateColorConfig(e,i);const r=this.findSecondarySeriesBySymbol(e);r&&(r.config.type=s,r.updateCandleSeriesColors(i)),this.bus.fireDraw([this.canvasModel.canvasId])}setAutoScale(t){this.scale.autoScale(t)}setOffsets(t){this.scale.updateOffsets(t);const e=this.getCandlesCountWithRightOffset(),s=this.mainCandleSeries.visualPoints;this.hasCandles()&&e>=s.length&&this.scale.setXScale(this.scale.xStart,this.candleFromIdx(e).startUnit),this.offsetsChanged.next(),this.bus.fireDraw()}getOffsets(){return this.scale.getOffsets()}fromY(t){return this.scale.fromY(t)}priceFromY(t,e){return(e!=null?e:this.mainCandleSeries).view.priceFromY(t)}fromX(t){return this.scale.fromX(t)}toX(t){const e=this.candleFromIdx(t);return this.scale.toX(e.centerUnit)}candleFromX(t,e=!1,s=this.mainCandleSeries){const i=this.scale.fromX(t);return this.candleFromUnit(i,e,s)}candleFromUnit(t,e=!1,s=this.mainCandleSeries){var i,r;const o=Yt(s.visualPoints,t,d=>d.startUnit),a=s.visualPoints,l=this.getLastVisualCandle();a[o.index]!==void 0&&(t<0||l&&t>l.startUnit+l.width)&&(o.index+=Me((t-a[o.index].centerUnit)/this.mainCandleSeries.meanCandleWidth));const c=o.index,h=Math.max(Math.min(a.length-1,c),0);return(c<0||c>=a.length)&&e?Re(this.mainCandleSeries.dataPoints,c,this.chartBaseModel.period):(r=(i=a[h])==null?void 0:i.candle)!=null?r:Re(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 xt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return xt(t)}getMaxCandlesFitLength(){return lt(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=Oe(r,{extrapolate:!1},t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}isLastCandleInViewport(){const t=this.getLastCandle();return t&&t.idx?this.isCandleInViewport(t.idx):!1}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=Oe(h.timestamp,{extrapolate:!0},o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,m=c&&h.timestamp<c.timestamp;if(p&&!m&&(c=h),a&&c&&s&&l){const x=(d=this.candleWidthByChartType[this.config.components.chart.type])!=null?d:br;this.scale.moveXStart(this.scale.xStart+x(c))}}),c&&(r.updateCurrentPrice(c.close),this.paneManager.yExtents.forEach(h=>h.yAxis.updateOrderedLabels(!0))),l&&c&&t.length===1?this.canvasModel.fireDraw():r.recalculateVisualPoints()}),this.config.scale.auto&&this.scale.doAutoScale(),this.candlesUpdatedSubject.next()}observeCandlesChanged(){return 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(Re(this.mainCandleSeries.dataPoints,c,this.getPeriod()));const l=Math.min(0,r);for(let c=e;c<l;c++)a.push(Re(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=Oe(r.timestamp,{extrapolate:!1},t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),He(i.dataPoints),i.recalculateVisualPoints()}),this.candlesChangedRedraw()}removeCandlesByIdsSequence(t,e){const s=this.candleIdxFromId(t[0],e),i=this.candleIdxFromId(t[t.length-1],e);if(s<0||i<0){console.warn("Candle is not found");return}e.dataPoints=e.dataPoints.slice(0,s).concat(e.dataPoints.slice(i+1)),He(e.dataPoints,i),e.recalculateVisualPoints(),this.candlesChangedRedraw()}removeCandlesByIds(t,e){t.forEach(s=>this.removeCandleByIdx(this.candleIdxFromId(s,e)))}addCandlesById(t,e,s){const i=this.candleIdxFromId(e);if(i<0){console.warn("Selected start candle is not found");return}const r=s.dataPoints.slice(0,i),o=s.dataPoints.slice(i);s.dataPoints=r.concat(t).concat(o),He(s.dataPoints),s.recalculateVisualPoints(),this.candlesChangedRedraw()}candlesChangedRedraw(){this.candlesRemovedSubject.next(),this.candlesUpdatedSubject.next(),this.canvasModel.fireDraw()}}const to=(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}},eo=(n,t)=>{const e=n.slice(),s=[],i=[];return t.forEach(r=>{const a=Oe(r.timestamp,{extrapolate:!0},n).index;a<0?s.push(r):a>=n.length?i.push(r):n[a].timestamp===r.timestamp?e[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:s,appended:i,candles:[...s,...e,...i]}};class ye{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class an{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=tr(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=tr(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 ou{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 au=Object.defineProperty,lu=Object.defineProperties,cu=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,hu=Object.prototype.hasOwnProperty,du=Object.prototype.propertyIsEnumerable,no=(n,t,e)=>t in n?au(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,uu=(n,t)=>{for(var e in t||(t={}))hu.call(t,e)&&no(n,e,t[e]);if(so)for(var e of so(t))du.call(t,e)&&no(n,e,t[e]);return n},fu=(n,t)=>lu(n,cu(t));class pu extends X{constructor(t,e,s,i,r,o,a){super(),this.config=t,this.crossToolCanvasModel=e,this.crossEventProducer=s,this.hoverProducer=i,this.canvasBoundsContainer=r,this.baselineModel=o,this.chartModel=a,this.currentHoverSubject=new ut(null)}get currentHover(){return this.currentHoverSubject.getValue()}set currentHover(t){this.currentHoverSubject.next(t)}setType(t){this.config.type=t}doActivate(){super.doActivate(),this.addRxSubscription(this.hoverProducer.hoverSubject.subscribe(t=>{this.crossEventProducer.crossSubject.getValue()!==null&&t!==null?Nt()?this.updateCrossToolMobile(t):this.updateCrossTool(t):this.currentHover=null,this.fireDraw()})),this.addRxSubscription(this.baselineModel.dragPredicate.subscribe(t=>{if(Nt())if(t)this.hoverProducer.deactivate();else{const e=this.crossEventProducer.crossToolTouchInfo;e.isSet&&this.crossEventProducer.crossSubject.next([e.temp.x,e.temp.y,Z]),this.hoverProducer.activate()}}))}fireDraw(){this.config.type!=="none"&&this.crossToolCanvasModel.fireDraw()}updateCrossTool(t,e=this.config.magnetTarget,s=this.config.discrete){var i;const r=s?this.chartModel.toX((i=this.chartModel.candleFromX(t.x,!0).idx)!=null?i:0):t.x;if(this.currentHover===null?this.currentHover={x:r,y:0,time:t.timeFormatted,paneId:t.paneId}:(this.currentHover.x=r,this.currentHover.time=t.timeFormatted),t.candleHover&&t.paneId===Z)switch(e){case"O":this.currentHover.y=t.candleHover.openY;break;case"C":this.currentHover.y=t.candleHover.closeY;break;case"H":this.currentHover.y=t.candleHover.highY;break;case"L":this.currentHover.y=t.candleHover.lowY;break;case"OHLC":this.currentHover.y=t.candleHover.closestOHLCY;break;case"none":this.currentHover.y=t.y;break}else this.currentHover.y=t.y;this.currentHover.paneId=t.paneId,this.currentHoverSubject.next(this.currentHover)}updateCrossToolMobile(t){var e;if(!this.hoverProducer.longTouchActivatedSubject.getValue())return;const{fixed:s,temp:i,isSet:r}=this.crossEventProducer.crossToolTouchInfo;if(!r){this.updateCrossTool(t);return}const o=this.canvasBoundsContainer.getBounds(M.PANE_UUID(t.paneId)),a=5,l=t.x-i.x,c=t.y-i.y,h=s.x+l,d=s.y+c,u=o.y+a,f=o.y+o.height-a,p=h<a?a:h>o.width-a?o.width-a:h,m=d<u?u:d>f?f:d,x=(e=this.hoverProducer.createHover(p,m,t.paneId))!=null?e:t,_=fu(uu({},x),{x:p,y:m});this.crossEventProducer.crossToolHover=_,this.updateCrossTool(_)}}const Bt=4;function gu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p;const m=r.align,x=(l=i.textFont)!=null?l:ie(r),_=i.bgColor,A=(c=i.textColor)!=null?c:ne(_,o.labelTextColor,o.labelInvertedTextColor),L=(h=i.paddingTop)!=null?h:Bt,Y=(d=i.paddingBottom)!=null?d:Bt,H=(u=i.paddingEnd)!=null?u:Bt,B=Me(Xt(x,n)/2),j=s-B-L,W=s+B+Y-j;if(a&&!ps(s,t,W))return;n.save(),n.fillStyle=_,n.strokeStyle=_;const U=Me(t.width/6),G=m==="right"?t.x:t.x+t.width,V=m==="right"?G+U:G-U,Q=r.labelBoxMargin.end,J=Q-H,et=t.width-U-J;Zh(n,V,j,G,j+Me(W/2),V,j+W,et,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,m),n.fillStyle=A,n.font=x;const tt=m==="right"?t.x+t.width-Mt(e,n,x)-Q:t.x+Q;n.fillText(e,tt,s+B-1),n.restore()}function mu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,x,_,A;const L=r.align,Y=(l=i.textFont)!=null?l:ie(r),H=i.bgColor,B=(c=i.textColor)!=null?c:ne(H,o.labelTextColor,o.labelInvertedTextColor),j=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,K=(u=(d=i.paddingTop)!=null?d:j==null?void 0:j.top)!=null?u:Bt,W=(p=(f=i.paddingBottom)!=null?f:j==null?void 0:j.bottom)!=null?p:Bt,U=(x=(m=i.paddingEnd)!=null?m:j==null?void 0:j.end)!=null?x:Bt,G=i.paddingStart,V=Xt(Y,n),Q=s-V/2-K,et=s+V/2+W-Q,tt=(A=i.rounded)!=null?A:(_=r.typeConfig.rectangle)==null?void 0:_.rounded;if(a&&!ps(s,t,et))return;n.save(),n.fillStyle=H,n.strokeStyle=H;const st=r.labelBoxMargin.end;n.font=Y;const ft=Mt(e,n,Y),ct=st-U,_t=G!==void 0?ft+G+U:t.width-ct,Zt=L==="right"?t.x+t.width-ct-_t:t.x+ct,xe=L==="right"?t.x+t.width-ft-st:st;tt?Ir(n,Zt,Q,_t,et,4,!0):n.fillRect(Zt,Q,_t,et),n.fillStyle=B,n.fillText(e,xe,s+V/2-1),n.restore()}function vu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,x;const _=r.align,A=(l=i.textFont)!=null?l:ie(r),L=o.backgroundColor,Y=(c=i.textColor)!=null?c:ne(L,o.labelTextColor,o.labelInvertedTextColor),H=(h=r.typeConfig.rectangle)==null?void 0:h.paddings,B=(u=(d=i.paddingTop)!=null?d:H==null?void 0:H.top)!=null?u:Bt,j=(p=(f=i.paddingBottom)!=null?f:H==null?void 0:H.bottom)!=null?p:Bt,K=(x=(m=i.paddingEnd)!=null?m:H==null?void 0:H.end)!=null?x:Bt,W=i.paddingStart,U=Xt(A,n),G=s-U/2-B,Q=s+U/2+j-G;if(a&&!ps(s,t,Q))return;n.save(),n.fillStyle=L,n.strokeStyle=L;const J=r.labelBoxMargin.end;n.font=A;const et=Mt(e,n,A),tt=J-K,st=W!==void 0?et+W+K:t.width-tt,ft=_==="right"?t.x+t.width-tt-st:t.x+tt,ct=_==="right"?t.x+t.width-et-J:J;n.fillStyle=L,n.strokeStyle=L,n.fillRect(ft,G,st,Q),n.fillStyle=Y,n.fillText(e,ct,s+U/2-1),n.restore()}function bu(n,t,e=Bt){return Xt(n,t)/2+e}function ps(n,t,e){return!(n<t.y+e/2||n>t.y+t.height-e/2)}const Cu="badge",io=4,ro={badge:gu,rectangle:mu,plain:vu};function oo(n,t,e,s,i,r,o,a,l){var c,h,d,u,f;const p=r.y,m=r.labelText,x=(c=r.mode)!=null?c:"label",_=(h=r.labelType)!=null?h:Cu,A=r.description,L=(d=r.textFont)!=null?d:ie(a),Y=r.bgColor,H=(u=r.lineColor)!=null?u:Y,B=Mt(A!=null?A:"",n,L)+8,j=lt(r.y),K=Xt(L,n),W=p-K/2,G=p+K/2-W;n.save(),n.fillStyle=Y,n.strokeStyle=H;const V=o.getBounds(M.PANE_UUID(Z)),Q=ro[_],J=a.labels.descriptions,et=yu(s,j,G),tt=()=>J&&wu(e,t,s,i,r,a);let st,ft;const ct=2;a.align==="right"?(st=V.x,ft=J?V.x+V.width-B:V.x+V.width+ct):(st=J?V.x+B:V.x-ct,ft=V.x+V.width);const _t=(f=r.lineY)!=null?f:r.y,Zt=()=>et&&le(n,()=>$h(n,st,_t,ft,_t,1,r.lineDash)),xe=()=>Q(n,s,Je(m),p,r,a,l.yAxis,!1),xs={line:()=>{Zt(),tt()},"line-label":()=>{Zt(),xe(),tt()},label:()=>{tt(),xe()}};x!=="none"&&ps(p,s,G)&&xs[x](),n.restore()}const yu=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function wu(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=ie(r),f=Mt(h,t,u),p=Xt(u,t),m=(o=i.paddingTop)!=null?o:io,x=(a=i.paddingBottom)!=null?a:io,_=d-p/2-m,L=d+p/2+x-_;t.save();const Y=f+5,H=4,B=f+H*2,j=s.x+s.width,K=c==="right"?j-B:s.x+H;fh(n,t,K,_,Y,L,.8),t.fillStyle=(l=i.descColor)!=null?l:i.bgColor,t.font=u;const W=c==="right"?j-f-H*2:s.x+H*2;t.fillText(h,W,d+p/2-1),t.restore()}class ao{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()&&le(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]},x=f==null?void 0:f(e.x,e.y);this.noLines||(t.strokeStyle=this.config.colors.crossTool.lineColor,t.setLineDash(this.config.components.crossTool.lineDash),t.beginPath(),x&&(t.moveTo(...p.start),t.lineTo(...p.end)),t.moveTo(...m.start),t.lineTo(...m.end),t.stroke()),x&&this.drawYLabel(t,e),this.drawXLabel(t,e)}}drawXLabel(t,e){var s,i,r,o,a;const l=this.config.components.crossTool.xLabel.padding,c=this.config.components.crossTool.xLabel.margin,h=this.config.colors.crossTool;if(this.config.components.xAxis.visible){t.font=this.config.components.xAxis.fontSize+"px "+this.config.components.xAxis.fontFamily;const d=e.x,u=e.time,f=t.measureText(u).width,p=this.config.components.xAxis.fontSize,m=this.canvasBoundsContainer.getBounds(M.X_AXIS);t.save(),t.fillStyle=h.labelBoxColor;const x=(s=l==null?void 0:l.left)!=null?s:0,_=(i=l==null?void 0:l.right)!=null?i:0,A=(r=l==null?void 0:l.top)!=null?r:0,L=(o=l==null?void 0:l.bottom)!=null?o:0,Y=(a=c==null?void 0:c.top)!=null?a:0,H=f+x+_,B=p+A+L,j=Math.max(d-H/2,0),K=m.y+Y+De/2;Ir(t,j,K,H,B),t.fillStyle=h.labelTextColor;const W=Math.max(d-f/2,x),U=m.y+Y+p+De/2+A-1;t.fillText(u,W,U),t.restore()}}drawYLabel(t,e){const s=this.config.components.crossTool.yLabel.padding,i=this.config.colors.crossTool;if(this.config.components.yAxis.visible){const r=this.paneManager.panes[e.paneId],o=e.y,a=this.config.components.crossTool.yLabel.type;if(!r)return;for(const l of r.yExtentComponents){const c=l.regularValueFromY(o),h=l.valueFormatter(c),d=this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=ro[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 Su{draw(){}}class xu extends X{constructor(t,e,s,i,r,o,a,l,c){super(),this.config=t,this.crossToolCanvasModel=e,this.canvasBoundsContainer=s,this.drawingManager=i,this.paneManager=r,this.crossEventProducer=o,this.hoverProducer=a,this.baselineModel=l,this.chartModel=c,this.crossToolTypeDrawers={},this.model=new pu(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel,this.chartModel),this.addChildEntity(this.model);const h=new ye(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const d=new ou(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),u=new an;u.addDrawer(h,"CLEAR_CANVAS"),u.addDrawer(d,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(u,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new ao(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new ao(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new Su)}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 _u{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 Pu{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 Tu extends X{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this._objects=new ut({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new 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 Pu;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))}bringToFront(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))}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))}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))}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))}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Mu extends X{constructor(t,e){super();const s=new Tu(t);this.model=s,this.addChildEntity(s);const i=new _u(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Au=()=>n=>n.toString(),Eu=(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:Iu(n),shortMonths:Du(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=>Lu(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function Iu(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function Du(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const lo=(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 Au()},Lu=(n,t,e,s)=>{t||(t="M/d/yyyy");const i=n.getDate(),r=n.getMonth(),o=n.getFullYear(),a=n.getHours(),l=n.getMinutes(),c=n.getSeconds(),h=n.getMilliseconds(),d=a%12,u=we(d),f=we(a),p=we(l),m=we(c),x=a<12?"AM":"PM",_=e[n.getDay()],A=_.substring(0,3),L=we(i),Y=r+1,H=we(Y),B=s[r],j=B.substring(0,3),K=o+"",W=K.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",L+"").replace("d",i+"").replace("EEEE",_).replace("EEE",A).replace("YYYY",K).replace("yyyy",K).replace("YY",W).replace("yy",W).replace("aaa",x),t.indexOf("MMM")>-1?t=t.replace("MMMM",B).replace("MMM",j):t=t.replace("MM",H+"").replace("M",Y+""),t},we=n=>typeof n=="number"&&n<10?"0"+n:n,je=(n,t)=>`${n}_${t}`,Ou=(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}},Bu=(n,t,e,s,i)=>{if(i){const r=t[je(s,"hover")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}else{const r=t[je(s,"normal")];n.drawImage(r.img,e.x-r.svgHeight/2,e.y-r.svgHeight/2)}},Ru={"rhombus-small":4,rhombus:6,"rhombus-large":8},Fu=["earnings","dividends","splits","conference-calls"];class Hu{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&&Fu.forEach(l=>{const c=Ou(l,a[l]);c&&(this.customIcons[je(c.type,"normal")]=c.normal,this.customIcons[je(c.type,"hover")]=c.hover)})}draw(){if(!this.config.components.events.visible)return;const t=this.canvasBoundsContainer.getBounds(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[je(i.type,"hover")]!==void 0){const d={x:c,y:t.y+t.height/2},u=this.model.hoveredEvent.getValue()===i;Bu(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=ln(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 ln(n){return Ru[n.style]}const gs=5;class ku{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=ln(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+gs)*2;if(a!==void 0){const u=ln(o);if(this.config.components.events.eventsVisibility[o.type]&&a+u>l-d/2){const m=h*2+gs;t.fillRect(a+u,e.y,m,e.height)}else t.fillRect(l-h-gs,e.y,d,e.height)}else t.fillRect(l-h-gs,e.y,d,e.height)}}),t.restore()}}getCanvasIds(){return[this.hitTestCanvasModel.canvasId]}}var ju=Object.defineProperty,ho=Object.getOwnPropertySymbols,Yu=Object.prototype.hasOwnProperty,Nu=Object.prototype.propertyIsEnumerable,uo=(n,t,e)=>t in n?ju(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Xu=(n,t)=>{for(var e in t||(t={}))Yu.call(t,e)&&uo(n,e,t[e]);if(ho)for(var e of ho(t))Nu.call(t,e)&&uo(n,e,t[e]);return n};const fo=317,cn={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999]};class Wu extends Hr{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 ut(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,kr(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,Ot,{trailing:!0})).subscribe(c=>this.eventHandler(c,"hover")),s=this.canvasInputListener.observeTouchStart().pipe(at(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=wt(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(at(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=wt(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(at(()=>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(at(()=>Xu({},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*fo).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/fo}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!==Hs&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=Hs),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]=hn(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]=hn(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]=hn(this.hitTestSubscribers,u),m=f==null?void 0:f.lookup(d),x={point:t,model:m};switch(e){case"mousedown":m&&((s=f==null?void 0:f.onMouseDown)==null||s.call(f,m,t)),p.forEach(_=>_.onMouseDown&&_.onMouseDown(null,t));break;case"mouseup":m&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,m,t)),p.forEach(_=>_.onMouseUp&&_.onMouseUp(null,t));break;case"hover":m&&((r=f==null?void 0:f.onHover)==null||r.call(f,m,t)),p.forEach(_=>_.onHover&&_.onHover(null,t)),this.hoverSubject.next(x);break;case"touchstart":m&&((o=f==null?void 0:f.onTouchStart)==null||o.call(f,m,t)),p.forEach(_=>_.onTouchStart&&_.onTouchStart(null,t)),this.touchStartSubject.next(x);break;case"dblclick":m&&((a=f==null?void 0:f.onDblClick)==null||a.call(f,m,t)),this.dblClickSubject.next(x);break;case"contextmenu":m&&((l=f==null?void 0:f.onRightClick)==null||l.call(f,m,t)),this.rightClickSubject.next(x);break;case"zoom":m&&((c=f==null?void 0:f.onZoom)==null||c.call(f,m,t)),p.forEach(_=>_.onZoom&&_.onZoom(null,t));break;default:break}}}const hn=(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 zu=Object.defineProperty,Vu=Object.defineProperties,Uu=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,Gu=Object.prototype.hasOwnProperty,Zu=Object.prototype.propertyIsEnumerable,go=(n,t,e)=>t in n?zu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$u=(n,t)=>{for(var e in t||(t={}))Gu.call(t,e)&&go(n,e,t[e]);if(po)for(var e of po(t))Zu.call(t,e)&&go(n,e,t[e]);return n},Ku=(n,t)=>Vu(n,Uu(t));class qu extends X{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ut(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>Ku($u({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return cn.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 Ju extends X{constructor(t,e,s,i,r,o,a,l){super(),this.config=t,this.canvasModel=e,this.canvasBoundsContainer=r,this.drawingManager=o,this.formatterFactory=a,this.eventsXAxisLabelFormatterProvider=()=>lo(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new qu(e);this.eventsModel=c,this.addChildEntity(c),s.addSubscriber(c);const h=new Hu(e,i,t,r,c,this.eventsXAxisLabelFormatterProvider);this.drawingManager.addDrawer(h,"EVENTS");const d=new ku(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 Qu{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;le(t,()=>this.drawVertical(t)),le(t,()=>this.drawHorizontal(t)),le(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=lt(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=lt(this.viewportModel.toY(i.value)),o=bu(i.text,t,Bt);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 mo extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p){super(),this.drawerName=r,this.drawingManager=o,this.drawer=new Qu(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 tf{constructor(t,e,s,i){this.canvasModel=t,this.chartModel=e,this.config=s,this.canvasBoundsContainer=i}draw(){if(this.config.components.highLow.visible&&this.chartModel.isReady()){const{high:t,low:e,highIdx:s,lowIdx:i}=this.chartModel.mainCandleSeries.zippedHighLow,r=this.chartModel.mainCandleSeries.dataIdxStart,o=r+s,a=r+i,l=this.canvasModel.ctx;l.save(),l.font=this.config.components.highLow.font,this.drawMarkerLabel(l,o,t,"high"),this.drawMarkerLabel(l,a,e,"low"),l.restore()}}drawMarkerLabel(t,e,s,i){const r=this.getMarkerY(t,s,i==="low"),o=Qe(t,!1),a=i==="low"?r-o:r;if(!this.checkMarkerInBounds(a))return;const l=this.getMarkerText(s,i),c=this.getMarkerX(t,e,l);t.fillStyle=i==="high"?this.config.colors.highLowTheme.highColor:this.config.colors.highLowTheme.lowColor,t.fillText(l,c,r);const h=this.canvasBoundsContainer.getBounds("PANE_CHART");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=Qe(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 ef extends X{constructor(t,e,s,i,r){super();const o=new tf(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const sf=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],nf=1440*60*1e3;class rf extends X{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()+nf;Xl(this.highlights,t,e,of).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 of=n=>n.to,Jt=[20,10];class af{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),sf.forEach(m=>{var x,_;const A=a[m];if(A){const L=this.config.colors.highlights[m],Y=(x=L==null?void 0:L.border)!=null?x:"#ffffff",H=(_=L==null?void 0:L.background)!=null?_:"#ffffff";o.save(),o.beginPath(),o.fillStyle=H,o.strokeStyle=Y,A.forEach(B=>{var j,K,W;const U=this.chartModel.candleFromTimestamp(B.from),G=bt(U.width,this.chartModel.scale.zoomX),V=U.xStart(this.chartModel.scale),Q=B.to-this.chartModel.chartBaseModel.period,J=this.chartModel.candleFromTimestamp(Q),et=bt(J.width,this.chartModel.scale.zoomX),tt=J.xStart(this.chartModel.scale)+et;if(B.border&&this.drawBorders(B.border,o,V+G,tt-et,c),o.fillRect(V,c.y,tt-V,c.y+c.height),B.label){const st=(j=B.label.text)!=null?j:"",ft=this.config.colors.highlights[B.type];o.save(),o.fillStyle=(K=ft==null?void 0:ft.label)!=null?K:"#ffffff";const ct=Mt(st,o,p),[_t,Zt]=this.resolveHighlightLabelPosition((W=B.label.placement)!=null?W:"left-left",c,[V,tt],ct);o.fillText(st,_t,Zt),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}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 lf="HIGHLIGHTS_PLUGIN";class cf extends X{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new rf(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new af(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,lf)}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 hf(){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 $(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 df=Object.defineProperty,uf=Object.defineProperties,ff=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertySymbols,pf=Object.prototype.hasOwnProperty,gf=Object.prototype.propertyIsEnumerable,bo=(n,t,e)=>t in n?df(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Co=(n,t)=>{for(var e in t||(t={}))pf.call(t,e)&&bo(n,e,t[e]);if(vo)for(var e of vo(t))gf.call(t,e)&&bo(n,e,t[e]);return n},yo=(n,t)=>uf(n,ff(t));const Ut=4;class mf{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:yo(Co({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:yo(Co({},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=wi(s,i.dateFormat,this.formatterFactory);mi(t,i.textProperties);const a=Qe(t),l=bi(o);zl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}function wo(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 Ye extends Nr{constructor(t,e,s,i,r=Yr,o){super(t,e,s,i,r),this.shouldThrottleSubject=new ut(!!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(),wo(e=>this.canvasInputListener.observeXDrag().pipe(e?Et(t,Ot,{trailing:!0,leading:!0}):se))).subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const So=4;class vf extends X{constructor(t,e,s,i,r,o){super(),this.bus=t,this.chartModel=e,this.scale=s,this.canvasInputListeners=i,this.canvasBoundsContainer=r,this.chartPanComponent=o,this.leftKnotDragStartXRelative=0,this.rightKnotDragStartXRelative=0,this.lastMousePosition=0,this.leftKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.leftKnotDragStartXRelative=f.x-p.x-So},this.leftKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,_=(this.leftKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.leftRatio=_,this.scale.setXScale(Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.leftRatio),this.scale.xEnd)},this.rightKnotDragStart=f=>{const p=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART);this.rightKnotDragStartXRelative=f.x-p.x+So},this.rightKnotDragTick=f=>{const{delta:p}=f,x=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,_=(this.rightKnotDragStartXRelative+p)/x;this.canvasBoundsContainer.rightRatio=_,this.scale.setXScale(this.scale.xStart,Math.round(this.chartModel.mainCandleSeries.dataPoints.length*this.canvasBoundsContainer.rightRatio))},this.sliderDragStart=()=>{this.lastMousePosition=0},this.sliderDragTick=f=>{const{delta:p}=f,m=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART),x=this.chartModel.mainCandleSeries.meanCandleWidth/(m.width/this.chartModel.mainCandleSeries.dataPoints.length),_=(this.lastMousePosition-p)*x;this.scale.moveXStart(this.scale.xStart-_),this.lastMousePosition=p};const a=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_L),l=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_KNOT_R),c=new Ye(a,{onDragStart:this.leftKnotDragStart,onDragTick:this.leftKnotDragTick},this.canvasInputListeners,this.chartPanComponent),h=new Ye(l,{onDragStart:this.rightKnotDragStart,onDragTick:this.rightKnotDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(c),this.addChildEntity(h);const d=this.canvasBoundsContainer.getBoundsHitTest(M.N_MAP_SLIDER_WINDOW),u=new Ye(d,{onDragStart:this.sliderDragStart,onDragTick:this.sliderDragTick},this.canvasInputListeners,this.chartPanComponent);this.addChildEntity(u)}doActivate(){super.doActivate();const t=this.canvasBoundsContainer.getBoundsHitTest(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 bf extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.eventBus=t,this.chartModel=e,this.canvasModel=s,this.config=i,this.canvasInputListeners=r,this.canvasBoundsContainer=o,this.chartPanComponent=c,this.visualCandles=[];const d=new mf(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,M.N_MAP_CHART),this.navigationMapMoveHandler=new vf(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(hf(),$(([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=lt(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,x)=>[x+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(cs),this.canvasModel.fireDraw())}}const ms=()=>{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"},ov=(n,t)=>n==="apple"||n==="mobile"?3:t;var dn=Math.pow;class xo extends X{constructor(t,e,s,i,r,o,a,l){super(),this.bus=t,this.config=e,this.scale=s,this.canvasInputListener=i,this.canvasBoundsContainer=r,this.canvasAnimation=o,this.chartPanComponent=a,this.hitTestCanvasModel=l,this.currentPoint={x:0,y:0},this.xDraggedCandlesDelta=0,this.lastXStart=0,this.wheelThrottleTime=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,x=h.offsetX/p;this.scale.zoomXToPercent(x,u,!1,d)}else this.scale.zoomXToEnd(u,d);this.bus.fireDraw()},this.onXDragStart=()=>{this.canvasAnimation.forceStopAnimation(fe),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=Ht(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 Ye(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($(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),Et(this.wheelThrottleTime,Ot,{trailing:!0,leading:!0})).subscribe(e=>{const s=ms(),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=Ht(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 _l(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(fe),this.currentPoint={x:0,y:0},s=t.yStart,this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!1)},r=l=>{const{delta:c}=l;if(this.currentPoint.y=c,t.state.auto)Cf(this.currentPoint,t.state.autoScaleDisableOnDrag)&&t.autoScale(!1);else{const h=Ht(t.state.inverse?-c:c,t.zoomY);t.moveYStart(s+h)}},o=()=>{this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!0)},a=new us(e,{onDragTick:r,onDragStart:i,onDragEnd:o},this.canvasInputListener,this.chartPanComponent,{dragPredicate:()=>this.chartPanningOptions.vertical});return this.addChildEntity(a),a}}const Cf=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=dn(dn(Math.abs(n.x),2)+dn(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},yf=2;class wf extends X{constructor(t,e,s,i,r){super(),this.chartAreaPanHandler=t,this.scale=e,this.canvasInputListeners=s,this.mainCanvasParent=i,this.hitTest=r,this.touchedCandleIndexes=[0,0],this.canvasTouchInfo={touchStart:{x:0,y:0},isMoving:!1}}doActivate(){this.addRxSubscription(this.canvasInputListeners.observeTouchStart(this.hitTest).subscribe(t=>this.handleTouchStartEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchMove(this.hitTest).subscribe(t=>this.handleTouchMoveEvent(t))),this.addRxSubscription(this.canvasInputListeners.observeTouchEndDocument().subscribe(t=>this.handleTouchEndEvent(t)))}handleTouchStartEvent(t){const{clientX:e,clientY:s}=t.touches[0];t.touches.length===1&&(this.canvasTouchInfo.touchStart={x:e,y:s}),t.touches.length===2&&(this.chartAreaPanHandler.deactivate(),this.touchedCandleIndexes=this.getXPositions(t).map(i=>this.scale.fromX(i)))}handleTouchMoveEvent(t){const{clientX:e,clientY:s}=t.touches[0],{touchStart:i}=this.canvasTouchInfo;t.touches.length===1&&(this.canvasTouchInfo.isMoving=_o(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 _o=(n,t,e,s,i=yf)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i,av={MAX_DIMENSION:2048,MAX_TOTAL_PIXELS:18e5,ZOOM_OPTIMIZED_PIXELS:12e5},Sf=2e6,xf=24,_f=20,Pf=16,Tf=10,Mf=1e3,lv=5e4,cv={MIN:60,LOW:80,MEDIUM:100,HIGH:120,MAX:150};class Af extends xo{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(cs).pipe(Ur(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>Sf?this.wheelThrottleTime=xf:this.wheelThrottleTime=_f:this.wheelThrottleTime=Pf,this.wheelSubscription=this.canvasInputListener.observeWheel(t).pipe($(()=>this.chartPanningOptions.horizontal&&this.chartPanningOptions.vertical),$(i=>ms()==="apple"?Math.abs(i.deltaY)>1||Math.abs(i.deltaX)>1:!0),Et(this.wheelThrottleTime,Ot,{trailing:!0,leading:!0})).subscribe(i=>{const r=performance.now();this.lastWheelTime||(this.lastWheelTime=r,this.wheelCount=0),this.wheelCount++,r-this.lastWheelTime>Mf&&(Math.round(this.wheelCount*1e3/(r-this.lastWheelTime))<Tf?(this.consecutiveLowWheelEvents++,this.consecutiveLowWheelEvents>=1&&(this.triggerPerformanceCleanup(),this.consecutiveLowWheelEvents=0)):this.consecutiveLowWheelEvents=0,this.lastWheelTime=r,this.wheelCount=0);const o=ms(),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=Ht(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 Ef extends X{constructor(t,e,s,i,r,o,a,l,c){super(),this.eventBus=t,this.mainScale=e,this.canvasBoundsContainer=s,this.config=i,this.canvasAnimation=r,this.canvasInputListener=o,this.mainCanvasParent=a,this.chartBaseModel=l,this.hitTestCanvasModel=c;const h=[this.eventBus,this.config,this.mainScale,this.canvasInputListener,this.canvasBoundsContainer,this.canvasAnimation,this,this.hitTestCanvasModel],d=Ae?new Af(...h):new xo(...h);this.chartAreaPanHandler=d,this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new wf(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 Po=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}},To=(n,t)=>{const e=Po(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function If(){return Gn(1)}function Mo(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return If()(Ge(n,Ue(n)))}function un(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ue(n);return N(function(s,i){(e?Mo(n,s,e):Mo(n,s)).subscribe(i)})}function Df(n){return $(function(t,e){return n<=e})}class Lf{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 Ao=8;class fn extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f){super(),this.id=t,this.boundsProvider=e,this.hitTest=s,this.dragTickCb=i,this.dragPredicate=r,this.chartPanComponent=o,this.canvasModel=a,this.drawingManager=l,this.canvasInputListener=c,this.canvasAnimation=h,this.config=d,this.canvasBoundsContainer=u,this.hitTestCanvasModel=f,this.initialY=0,this.resizeEvent$=new 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:x}=p;Math.abs(this.initialY-this.boundsProvider().y+x)>=0&&(this.dragTickCb(m),this.resizeEvent$.next())},this.animationId=`${this.id}_RESIZER`}doActivate(){if(super.doActivate(),!this.config.components.paneResizer.fixedMode){const s=new us(this.hitTest,{onDragTick:this.onYDragTick,onDragStart:Nt()?this.onYDragStartMobile:this.onYDragStart,onDragEnd:Nt()?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(un(!1),$(this.dragPredicate),mt(),Df(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Lf(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,jr.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(jr.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 pn=1/32,Of=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}`},Eo=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),hv=n=>!!Eo(n),dv=n=>{const t=Eo(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*pn;return e+i}return Number(n)},Bf=(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 Of(s);const[r]=n.dataSeries;if(r!==void 0){const o=ve.getPricePrecision(s,r.pricePrecisions);return s.toFixed(o)}return`${s}`},Rf=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=ir(t,r.getBaseline()));const o=Je(i.toFixed(ve.DEFAULT_PRECISION))+" %";return o===`${si}0.00 %`?"0.00 %":o},Ff=(n,t)=>({percent:Rf(n),regular:Bf(n,t)});class Hf extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:ih}){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 Be(this.chartBaseModel.dataFromTimestamp(m.timestamp).centerUnit,m.close)),this.toY=p=>{var m,x;return(x=(m=this.mainDataSeries)==null?void 0:m.view.toY(p))!=null?x:1},this.valueFormatter=(p,m)=>{if(!this.formatters[this.yAxis.getAxisType()])return this.formatters.regular(p);const{regular:x,percent:_,logarithmic:A}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p);case"percent":return _?_(p,m):x(p);case"logarithmic":return A?A(p):x(p);default:return this.regularFormatter(p)}},this.addChildEntity(c),this.setValueFormatters(Ff(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 dr(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!==Z){this.mainDataSeries=t;const e=Array.from(this.paneComponent.mainExtent.dataSeries);this.paneComponent.mainExtent.mainDataSeries=e[e.length-1]}this.paneComponent.updateView(),this.paneComponent.seriesAddedSubject.next(t)}removeDataSeries(t){this.dataSeries.delete(t),this.paneComponent.updateView(),this.paneComponent.seriesRemovedSubject.next(t)}get regularFormatter(){return this.formatters.regular}setValueFormatters(t){this.formatters=t}regularValueFromY(t){var e,s;return(s=(e=this.mainDataSeries)==null?void 0:e.view.priceFromY(t))!=null?s:this.scale.fromY(t)}}const Io=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}:Sr(r)}});class kf{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=cn.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return cn.DATA_SERIES}get allDataSeries(){return Ie(Ie(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 uv(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 Yf=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,Nf=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Gt},Xf=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Gt},Wf=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Gt},zf=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Gt},Vf=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Gt},Uf=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Gt},Gf=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Gt},Do=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Gt},Zf=()=>(console.warn("Fallback for label default color"),Gt),Lo=10;class Oo extends X{constructor(t,e,s,i,r,o,a,l){if(super(),this.bus=t,this.config=e,this.scale=i,this.canvasInputListener=r,this.bounds=o,this.hitTest=a,this.hitTestCanvasModel=l,this.yAxisDragEndSubject=new 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,Fi),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*(Lo-1)):d=1+h/this.lastYPxHeight*(Lo-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 us(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 $f{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),ei(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 Kf=0,qf=.01;class gn{constructor(t,e,s,i,r=!1,o,a,l=Ns,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 $f(()=>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=Je(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=rr(a,r),c=Je(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=en(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=gn.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?pn:ve.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(qf)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=en(e)+t;return or(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)*(Kf/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 Jf extends gn{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=xt(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=mh(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?pn:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function Bo(n,t,e){var s=k(n)||t||e?{next:n,error:t,complete:e}:n;return s?N(function(i,r){var o;(o=s.subscribe)===null||o===void 0||o.call(s);var a=!0;i.subscribe(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)}))}):se}class Qf extends X{constructor(t,e,s,i,r){super(),this.scale=t,this.labelsGenerator=e,this.canvasBoundsContainer=s,this.paneUUID=i,this.extentIdx=r,this.labels=[],this.prevYAxisHeight=0,this.animFrameId=`anim_cache_${St()}`}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(at(t=>t.height),$(t=>vl(t,this.prevYAxisHeight,1.5)),Bo(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,Pe(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){Pe(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class tp extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.paneUUID=t,this.state=s,this.canvasBoundsContainer=i,this.extentIdx=c,this.labelsGenerator=new Jf(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new Qf(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new Wc(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 ep extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,x){super(),this.eventBus=t,this.config=e,this.mainCanvasModel=s,this.canvasModel=i,this.scale=r,this.canvasInputListeners=o,this.canvasBoundsContainer=a,this.chartPanComponent=l,this.cursors=c,this.paneUUID=u,this.extentIdx=f,this.hitTestCanvasModel=p,this.chartResizeHandler=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 _=x?oe(x):{};this.state=At(_,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new Oo(t,this.state,l,r,o,a,a.getBoundsHitTest(M.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new tp(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 Oo(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",Wf),this.registerLabelColorResolver("bar",Nf),this.registerLabelColorResolver("line",Xf),this.registerLabelColorResolver("area",zf),this.registerLabelColorResolver("scatterPlot",Vf),this.registerLabelColorResolver("histogram",Uf),this.registerLabelColorResolver("baseline",Gf),this.registerLabelColorResolver("trend",Do),this.registerLabelColorResolver("hollow",Do)}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:Zf}registerYAxisLabelsProvider(t,e=re.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=re.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 sp extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,x,_,A,L,Y){super(),this.chartBaseModel=t,this.mainCanvasModel=e,this.yAxisLabelsCanvasModel=s,this.dynamicObjectsCanvasModel=i,this.hitTestController=r,this.config=o,this.mainScale=a,this.drawingManager=l,this.chartPanComponent=c,this.canvasInputListener=h,this.canvasAnimation=d,this.cursorHandler=u,this.eventBus=f,this.canvasBoundsContainer=p,this.uuid=m,this.seriesAddedSubject=x,this.seriesRemovedSubject=_,this.hitTestCanvasModel=A,this.chartResizeHandler=L,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new F,this.getYAxisBounds=()=>this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(this.uuid)),this.valueFormatter=(B,j)=>this.mainExtent.valueFormatter(B,j);const H=this.createExtentComponent(Y);this.mainExtent=H,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 Ie(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(Xi)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()})),this.uuid===Z&&this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(un(this.yAxis.getAxisType()),mt(),at(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 mo(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 Vh(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(m,x)=>new ep(this.eventBus,this.config,this.mainCanvasModel,this.yAxisLabelsCanvasModel,a,this.canvasInputListener,this.canvasBoundsContainer,this.chartPanComponent,this.cursorHandler,m,x,this.uuid,i,this.hitTestCanvasModel,this.chartResizeHandler,l),u=new Hf(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",To(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),Io(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=oe(s.yAxis.state),o=oe(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=pe(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=xt(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 np=Object.defineProperty,ip=Object.defineProperties,rp=Object.getOwnPropertyDescriptors,Ro=Object.getOwnPropertySymbols,op=Object.prototype.hasOwnProperty,ap=Object.prototype.propertyIsEnumerable,Fo=(n,t,e)=>t in n?np(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,lp=(n,t)=>{for(var e in t||(t={}))op.call(t,e)&&Fo(n,e,t[e]);if(Ro)for(var e of Ro(t))ap.call(t,e)&&Fo(n,e,t[e]);return n},cp=(n,t)=>ip(n,rp(t));class hp extends X{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,x,_){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=m,this.hitTestCanvasModel=x,this.chartResizeHandler=_,this.panes={},this.paneRemovedSubject=new F,this.paneAddedSubject=new F,this.dataSeriesAddedSubject=new F,this.dataSeriesRemovedSubject=new F,this.hitTestController=new kf(this.panes,this.dynamicObjectsCanvasModel);const A=this.createPane(Z,{useDefaultHighLow:!1,scale:this.mainScale});A.mainExtent.scale.autoScaleModel.setHighLowProvider("series",Io(A.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",Po(()=>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+Ao}),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 fn(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 Ie(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 sp(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=pe(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=xt(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 fn&&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 fn&&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?cp(lp({},s.yAxis.state),{align:l}):void 0,p=c&&c>0;if(!u){const m=a&&a==="above"?d:d+1,x=this.createPane(r,{order:m,initialYAxisState:f,inverse:s.scale.state.inverse,lockToPriceRatio:s.scale.state.lockPriceToBarRatio});x.moveDataSeriesToExistingExtentComponent(t,e,s,x.mainExtent,h),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid);return}o&&!p?u.moveDataSeriesToExistingExtentComponent(t,e,s,o):u.moveDataSeriesToNewExtentComponent(t,e,s,l!=null?l:s.yAxis.state.align),!h&&e.yExtentComponents.length===0&&this.removePane(e.uuid)}addCursors(t,e=this.config.components.chart.cursor){const s=M.PANE_UUID(t),i=M.PANE_UUID_RESIZER(t);return this.cursorHandler.setCursorForCanvasEl(s,e),this.config.components.paneResizer.visible&&this.cursorHandler.setCursorForCanvasEl(i,this.config.components.paneResizer.cursor,this.config.components.paneResizer.dragZone+Ao),()=>{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 dp extends X{constructor(t,e){super(),this.elements=t,this.canvasModel=e}doActivate(){super.doActivate()}createSnapshot(t){const e=this.canvasModel.canvas,s=this.canvasModel.ctx;if(s){s.clearRect(0,0,e.width,e.height);const i=e.width/window.devicePixelRatio,r=e.height/window.devicePixelRatio;return s.drawImage(this.elements.backgroundCanvas,0,0,i,r),s.drawImage(this.elements.mainCanvas,0,0,i,r),s.drawImage(this.elements.dynamicObjectsCanvas,0,0,i,r),s.drawImage(this.elements.crossToolCanvas,0,0,i,r),s.drawImage(this.elements.yAxisLabelsCanvas,0,0,i,r),t&&t(s),new Promise((o,a)=>this.elements.snapshotCanvas.toBlob(l=>l?o(l):a("Blob is null")))}else return console.error("Snapshot isn't supported"),Promise.reject()}}const up=(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)},Ho=class _s extends X{constructor(t,e,s,i){super(),this.chartComponent=t,this.config=e,this.volumesModel=s,this.paneManager=i,e.components.volumes.showSeparately&&this.activateSeparateVolumes()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.subscribe(()=>{var t,e;return!((t=this.pane)!=null&&t.scale.isViewportValid())&&((e=this.pane)==null?void 0:e.scale.doAutoScale(!0))})),this.addRxSubscription(this.volumesModel.volumeMax.subscribe(()=>{var t;return(t=this.pane)==null?void 0:t.scale.doAutoScale()}))}activateSeparateVolumes(){if(this.paneManager.panes[_s.UUID]===void 0){const e=this.paneManager.createPane(_s.UUID,{paneFormatters:{regular:r=>up(r,1)},useDefaultHighLow:!1,increment:1});this.pane=e,e.mainExtent.yAxis.setAxisType("regular");const{scale:s}=e,i=To(()=>({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(_s.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};Ho.UUID="volumes";let fp=Ho;const vs=.3,pp=(n,t)=>{const e=t.barTheme[`${n}Color`];return Rt()(e).alpha(vs).toString()},gp=(n,t)=>{const e=t.volume[`${n}BarColor`];return Rt()(e).alpha(vs).toString()},mp=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Rt()(e).alpha(vs).toString()},mn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Rt()(e).alpha(vs).toString()},vp=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:gp;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=Js(s.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=l/vp;if(u<=0)return;const f=e/u;if(!isFinite(f)||f<=0)return;const p=Math.max(Js(bt(r.candle.volume,f)),2),m=Math.min(p,l),x=It(a.y+l-m);this.drawVolume(t,r,h,x,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,Js(c)),a.stroke()):a.fillRect(s,i,r,o)}}const Cp=Nl(n=>n.candle.volume),ko="volumes";class yp extends X{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=ko,this.volumeMax=new ut(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=pe(Cp(e.flat())))!=null?t:0)}}class wp extends X{constructor(t,e,s,i,r,o,a,l){super(),this.canvasModel=t,this.canvasBoundsContainer=i,this.config=o,this.dynamicObjectsComponent=l,this.volumesColorByChartTypeMap={},this.volumeVisibilityChangedSubject=new ut(!1),this.volumeIsSeparateModeChangedSubject=new ut(!1);const c=new yp(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new fp(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",mn),this.registerVolumeColorResolver("trend",mn),this.registerVolumeColorResolver("hollow",mn),this.registerVolumeColorResolver("line",mp),this.registerVolumeColorResolver("bar",pp)}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?ko:Z,s={id:this.volumesModel.id,paneId:e,drawer:this.volumesDrawer,model:this.volumesModel};if(this.dynamicObjectsComponent.model.getObjectPosition(this.volumesModel.id)===-1){this.dynamicObjectsComponent.model.addObject(s);return}this.dynamicObjectsComponent.model.updateObject(s)}}class Sp{constructor(t,e,s,i,r){this.config=t,this.canvasBoundsContainer=e,this.canvasModel=s,this.waterMarkConfigProvider=i,this.watermarkDataProvider=r,this.getConfig=(o=0,a,l,c,h,d)=>{const u=this.canvasModel.ctx,f=this.canvasBoundsContainer.getBounds(M.PANE_UUID(Z)),{position:p,offsetY:m,offsetX:x}=this.config.components.waterMark;let _;switch(d?_=d:(u.font=bs(this.config,l),_=u.measureText(a).width,f.width-10<_&&(u.font=xp(this.config,this.canvasBoundsContainer,l,_),_=u.measureText(a).width)),p){case"left-top":return{x:x+f.x,y:m+o+f.y,font:u.font,text:a,color:c};case"left-bottom":return{x: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-_/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,x=0,_=0,A=0;if(f.save(),d.firstRowFontSize&&l){f.font=bs(this.config,d.firstRowFontSize);const B=f.measureText(l);p=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent}if(d.secondRowFontSize&&c){f.font=bs(this.config,d.secondRowFontSize);const B=f.measureText(c);m=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent,x=(e=d.firstRowBottomPadding)!=null?e:0}if(d.thirdRowFontSize&&h){f.font=bs(this.config,d.thirdRowFontSize);const B=f.measureText(h);_=B.actualBoundingBoxAscent+B.actualBoundingBoxDescent,A=(s=d.secondRowBottomPadding)!=null?s:0}const L=(i=d.thirdRowBottomPadding)!=null?i:0,Y=(r=d.logoHeight)!=null?r:0,H=p+m+x+_+A+L+Y;if(l&&this.drawWaterMark(this.getConfig(p,l,d.firstRowFontSize,u.firstRowColor,H)),c&&this.drawWaterMark(this.getConfig(p+x+m,c,d.secondRowFontSize,u.secondRowColor,H)),h&&this.drawWaterMark(this.getConfig(p+x+m+A+_,h,d.thirdRowFontSize,u.thirdRowColor,H)),this.logoImage){const B=this.getConfig(p+x+m+A+_+L,"",d.thirdRowFontSize,u.thirdRowColor,H,d.logoWidth);this.canvasModel.ctx.drawImage(this.logoImage,B.x,B.y,(o=d.logoWidth)!=null?o:0,(a=d.logoHeight)!=null?a:0)}f.restore()}}getCanvasIds(){return[this.canvasModel.canvasId]}setLogoImage(t){this.logoImage=t}drawWaterMark(t){const e=t.text;if(!e||!e.length)return;const s=this.canvasModel.ctx;s.font=t.font,s.fillStyle=t.color;const i=t.x,r=t.y;s.fillText(e,i,r)}reset(){}}const xp=(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},bs=(n,t)=>{let e;return n.components&&n.components.waterMark&&(e=n.components.waterMark.fontFamily),t+"px "+e};var _p=Object.defineProperty,jo=Object.getOwnPropertySymbols,Pp=Object.prototype.hasOwnProperty,Tp=Object.prototype.propertyIsEnumerable,Yo=(n,t,e)=>t in n?_p(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,No=(n,t)=>{for(var e in t||(t={}))Pp.call(t,e)&&Yo(n,e,t[e]);if(jo)for(var e of jo(t))Tp.call(t,e)&&Yo(n,e,t[e]);return n};class Mp extends X{constructor(t,e,s,i,r,o,a){super(),this.paneManager=t,this.chartModel=e,this.eventBus=s,this.config=i,this.canvasModel=o,this.waterMarkConfig=this.config.components.waterMark,this.waterMarkData=this.getWaterMarkData(),this.waterMarkDrawer=new Sp(this.config,r,o,()=>this.waterMarkConfig,()=>this.waterMarkData),this.addRxSubscription(At(r.observeBoundsChanged(M.PANE_UUID(Z)),this.paneManager.paneAddedSubject).subscribe(l=>{this.waterMarkConfig=this.recalculateTextSize(l.width,l.height)})),this.addRxSubscription(this.chartModel.candlesSetSubject.subscribe(()=>{this.waterMarkData=this.getWaterMarkData()})),a.addDrawerAfter(this.waterMarkDrawer,"WATERMARK","DYNAMIC_OBJECTS")}setWaterMarkVisible(t){this.config.components&&this.config.components.waterMark&&(this.config.components.waterMark.visible=t,this.canvasModel.fireDraw())}setWaterMarkData(t){this.waterMarkData=t,this.canvasModel.fireDraw()}getWaterMarkData(){return this.waterMarkData||{}}setWaterMarkConfig(t){if(!(!t||!this.config.components)){if(!this.config.components.waterMark)this.config.components.waterMark=JSON.parse(JSON.stringify(t));else{const e={};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 No(No({},this.config.components.waterMark),h)}}const Xo={x:4,y:4};function Ap(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+Xo.x*2;let m=0;const x=s.x;switch(o){case"start":m=x-p;break;case"end":m=x;break;default:m=x-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(x,u.y),n.lineTo(x,u.y+u.height),n.stroke()),n.fillStyle=s.color;const _=m+Xo.x,A=u.y+d+a+De/2;n.fillText(s.text,_,A),n.restore()}class Ep{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=>{Ap(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=Rt().rgb(r[0].color).alpha(.1).toString(),Dr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const fv="week-weekday",Ip=["second","minute","hour","day","month","year"],Dp=["lessThanSecond"],Lp=n=>Ip.some(t=>t===n),Op=n=>n==="week-weekday",Bp=n=>Dp.some(t=>t===n),Wo=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},vn=n=>parseInt(n,10),zo=n=>{const[t,...e]=n.split("_");if(Lp(t)){const[s]=e,i=Wo(s),r=vn(s);return{key:t,value:r,exact:i["!"]}}else if(Op(t)){const[s,i]=e,r=Wo(s),o=vn(s),a=vn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return Bp(t)?{key:t}:(console.warn(`${n} is not fit, check the documentation to see available formats in dxchart-lite documentation.`),null)};class Cs{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=Cs.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+De/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 bn={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Vo=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return bn[n.key]+n.value;case"lessThanSecond":return bn[n.key];case"week-weekday":return bn[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},Uo=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},Rp=(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],x=m.idx;if(p>x)c++,s.push(m),d=x,h=1/0;else{h=x;break}}h-p>=t&&p-d>=t&&(s.push(f),d=p)}for(;c<a;)s.push(o[c]),c++}return s},Fp=(n,t,e,s,i,r)=>{const o=Cs.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},pv=7,Hp=365.2425,mv=-(Math.pow(10,8)*24*60*60*1e3),vv=6048e5,bv=864e5,Cv=6e4,yv=36e5,wv=1e3,Sv=525600,xv=43200,_v=1440,Pv=60,Tv=3,Mv=12,Av=4,kp=3600,Ev=60,Go=kp*24,Iv=Go*7,Ov=Go*Hp/12*3,Zo=Symbol.for("constructDateFrom");function Cn(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&Zo in n?n[Zo](t):n instanceof Date?new n.constructor(t):new Date(t)}const Bv=null;function kt(n,t){return Cn(t||n,n)}const Rv=null;function jp(n,t){return kt(n,t==null?void 0:t.in).getDay()===1}const Fv=null;function Yp(n,t){return kt(n,t==null?void 0:t.in).getDay()===2}const Hv=null;function Np(n,t){return kt(n,t==null?void 0:t.in).getDay()===3}const kv=null;function Xp(n,t){return kt(n,t==null?void 0:t.in).getDay()===4}const jv=null;function Wp(n,t){return kt(n,t==null?void 0:t.in).getDay()===5}const Yv=null;function zp(n,t){return kt(n,t==null?void 0:t.in).getDay()===6}const Nv=null;function Vp(n,t){return kt(n,t==null?void 0:t.in).getDay()===0}const Xv=null;function $o(n,...t){const e=Cn.bind(null,n||t.find(s=>typeof s=="object"));return t.map(e)}function Up(n,t){const[e,s]=$o(n,t.start,t.end);return{start:e,end:s}}function Gp(n,t){var c;const{start:e,end:s}=Up(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(Cn(e,o)),o.setDate(o.getDate()+a),o.setHours(0,0,0,0);return i?l.reverse():l}const Wv=null;function Zp(n,t){const e=kt(n,t==null?void 0:t.in);return e.setDate(1),e.setHours(0,0,0,0),e}const zv=null;function $p(n,t){const e=kt(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 Vv=null;function Ko(n,t){const e=kt(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}const Uv=null;function qo(n,t,e){const[s,i]=$o(e==null?void 0:e.in,n,t);return+Ko(s)==+Ko(i)}const Gv=null,Kp=n=>{switch(n.key){case"lessThanSecond":return tg(n);case"month":return eg(n);case"second":case"minute":case"hour":case"day":case"year":return sg(n);case"week-weekday":return ng(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()}},yn=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s!==i},qp=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s>=i},Jp={1:jp,2:Yp,3:Np,4:Xp,5:Wp,6:zp,7:Vp},Qp=(n,t,e)=>{var s;const i=Gp({start:Zp(n),end:$p(n)}),r=(s=Jp[e])!=null?s:(()=>!1);if(t==="$"){for(const o of i.reverse())if(r(o))return qo(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return qo(n,a);o++}}return!1},Jo=(n,t)=>t===1?n===1:n/t===1,Qo=(n,t)=>t===1?!0:n%t===0,tg=n=>(t,e)=>qp(n.key)(t,e),eg=n=>(t,e)=>{const s=yn(n.key)(t,e),i=n.exact?Jo(Qt(t,n.key)+1,n.value):Qo(Qt(t,n.key)+1,n.value);return s&&i},sg=n=>(t,e)=>{const s=yn(n.key)(t,e),i=n.exact?Jo(Qt(t,n.key),n.value):Qo(Qt(t,n.key),n.value);return s&&i},ng=n=>(t,e)=>{const s=yn(n.key)(t,e),i=Qp(t,n.week,n.weekday);return s&&i},ig=n=>{switch(n.key){case"second":case"minute":return rg(n.value);case"hour":return og(n.value);case"day":return ag(n.value);case"month":return hg(n.value);case"year":return dg(n.value);case"week-weekday":const t=cg(n.week),e=lg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},rg=n=>n>0&&n<=60,og=n=>n>0&&n<=24,ag=n=>n>0&&n<=31,lg=n=>ta(n)?n>=1&&n<=7:!1,cg=n=>n==="$"?!0:ta(n)?n>=1&&n<=6:!1,hg=n=>n>0&&n<=12,dg=n=>n>0,ta=n=>!isNaN(n)&&isFinite(n),ug=(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 wn(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:ug(a,i,t)};s[r]=l,i=a}return s}const ea=n=>{const t={},e={};return Qs(n).forEach(([s,i])=>{const r=zo(s),o=r===null?!1:ig(r);if(r&&o){const a=Vo(r);t[a]=i,e[a]=Kp(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class sa{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((x,_)=>Math.max(_.length,x),1),m=f*p;return Math.round(m/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=ea(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]:sn(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)=>sn(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 L=e[0];d=L.centerUnit-((t=L.candle.idx)!=null?t:0)*s}const u=500,f=500,p=Math.floor((c-d)/s)-u,m=Math.ceil((h-d)/s)+u,x=Math.floor(p/f)*f,_=Math.ceil(m/f)*f,A=[];for(let L=x;L<=_;L++)A.push(this.getVisualCandleAtIndex(L,r,e,s,i));return[...A]}getAllCandlesWithFake(t=[]){return this.config.components.chart.minCandlesOffset?this.getVisualCandlesWithFake(t):this.getViewportCandlesWithFake()}mapWeightedPointsToLabels(t,e){var s;const i=new Array(t.length);for(let r=0;r<t.length;++r){const o=t[r],a=e[r],l=this.weightToTimeFormatsDict[o.weight],c=this.timeZoneModel.getDateTimeFormatter(l)(a.candle.timestamp);i[r]={weight:o.weight,idx:(s=a.candle.idx)!=null?s:0,value:a.centerUnit,time:a.candle.timestamp,text:c}}return i}setFormatsForLabelsConfig(t){this.clearLabelCache();const{weightToTimeFormatsDict:e,weightToTimeFormatMatcherDict:s}=ea(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=wn([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=wn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=Uo(i),o=oe(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=wn(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=Uo(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=Rp(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];Fp(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=Qs(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=zo(o);if(l){const c=Vo(l);i[c]=a}}return i},{});return Qs(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class fg extends X{constructor(t,e){super(),this.eventBus=t,this.labelProviders=e,this.labels=[],this.initModel(),this.addSubscription(this.eventBus.on(hs,()=>this.recalculateLabels()))}initModel(){this.recalculateLabels()}recalculateLabels(){this.labels=[];for(const t of this.labelProviders)this.labels.push(...t.getUnorderedLabels())}}const na=3;class pg extends X{constructor(t,e,s,i,r,o,a){super(),this.scale=t,this.canvasInputListener=e,this.canvasBoundsContainer=s,this.chartPanComponent=i,this.chartModel=r,this.hitTest=o,this.hitTestCanvasModel=a,this.lastXStart=0,this.lastXEnd=0,this.lastXWidth=0,this.lastXPxWidth=0,this.onXDragStart=()=>{this.lastXStart=this.scale.xStart,this.lastXEnd=this.scale.xEnd,this.lastXWidth=this.scale.xEnd-this.scale.xStart;const 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*(na-1)):d=1+c/this.lastXPxWidth*(na-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 Ye(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 gg extends X{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=_=>this.xAxisScaleHandler.setDblClickCallback(_),this.setDblTapCallback=_=>this.xAxisScaleHandler.setDblTapCallback(_);const m=new sa(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=m,this.xAxisLabelsModel=new fg(t,[]);const x=new an;c.addDrawer(x,"X_AXIS"),this.xAxisDrawer=new Cs(e,s,r,o,()=>this.xAxisLabelsGenerator.labels,()=>e.components.xAxis.visible),x.addDrawer(this.xAxisDrawer),this.xAxisLabelsDrawer=new Ep(e,s,o,this.xAxisLabelsModel),x.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new pg(r,a,o,d,this.chartComponent.chartModel,o.getBoundsHitTest(M.X_AXIS),f),this.addChildEntity(this.xAxisScaleHandler),u.setCursorForCanvasEl(M.X_AXIS,e.components.xAxis.cursor)}doActivate(){super.doActivate(),this.addRxSubscription(wt(this.chartComponent.chartModel.candlesSetSubject,this.timeZoneModel.observeTimeZoneChanged()).subscribe(()=>{this.xAxisLabelsGenerator.generateLabels()})),this.addRxSubscription(this.chartComponent.chartModel.candlesPrependSubject.pipe($(({prependedCandles:t})=>t.length!==0),at(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;rc.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,Ot,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.recalculateLabels())):this.addRxSubscription(wt(this.scale.xChanged,this.chartResizeHandler.canvasResized).pipe(Et(150,Ot,{trailing:!0,leading:!0})).subscribe(()=>this.xAxisLabelsGenerator.generateLabels(void 0,!0))),this.addRxSubscription(this.chartComponent.chartModel.candlesUpdatedSubject.pipe(at(()=>xt(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)}),$(hi)).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(un(this.yAxis.getAxisType()),mt(),at(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 sa?this.xAxisLabelsGenerator.setFormatsForLabelsConfig(t):console.error("Format config for x-axis is not available")}isVisible(){var t,e;return(e=(t=this.config.components)==null?void 0:t.xAxis.visible)!=null?e:!1}}var mg=Object.defineProperty,ia=Object.getOwnPropertySymbols,vg=Object.prototype.hasOwnProperty,bg=Object.prototype.propertyIsEnumerable,ra=(n,t,e)=>t in n?mg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ys=(n,t)=>{for(var e in t||(t={}))vg.call(t,e)&&ra(n,e,t[e]);if(ia)for(var e of ia(t))bg.call(t,e)&&ra(n,e,t[e]);return n};class Cg{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&&ys(ys({},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&&ys(ys({},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=xt(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:ne("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:Yf(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ne(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ne(l,r,o),rounded:!0}}}class yg{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=>oo(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>oo(t,s,e,r,o,l,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}})}drawHighlightedBackgroundBetweenLabels(t){const e=this.yAxisLabelsCanvasModel.ctx,s={};t.forEach(i=>{i.labels.forEach(r=>{var o,a,l;if(r.subGroupId){const c=(o=s[r.subGroupId])!=null?o:[];if(s[r.subGroupId]=c,c.push(r),c.length===2){const h=(a=i.bounds)!=null?a:this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(Z));e.save(),e.fillStyle=(l=c[0].highlightColor)!=null?l:c[0].bgColor;const[d,u]=c[0].y>c[1].y?[c[1].y,c[0].y]:[c[0].y,c[1].y];Dr(e,{x:h.x,y:Ni(d,h)},{x:h.x+h.width-6,y:Ni(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class wg{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=ie(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&&Sg(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 Sg=(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 xg{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&jl.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(hs,t)}}class _g extends X{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(at(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 Pg{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(){Pe(this.animFrameId,()=>this.fireUpdates())}fireUpdates(){const t=this.resizerElement.getBoundingClientRect(),e={x:t.x,y:t.y,width:t.width,height:t.height};this.config||(this.frameElement.style.height=this.resizerElement.clientHeight+"px"),(this.previousBCR===void 0||this.isBCRDimensionsDiffer(this.previousBCR,e))&&(this.previousBCR=e,this.recentlyResized=!0,this.canvasModels.forEach(s=>this.previousBCR&&s.updateDPR(this.previousBCR)),this.canvasResized.next(e),this.bus.fire(cs,e),this.bus.fire(hs))}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 Tg=Array.isArray,Mg=Object.getPrototypeOf,Ag=Object.prototype,Eg=Object.keys;function Ig(n){if(n.length===1){var t=n[0];if(Tg(t))return{args:t,keys:null};if(Dg(t)){var e=Eg(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function Dg(n){return n&&typeof n=="object"&&Mg(n)===Ag}var Lg=Array.isArray;function Og(n,t){return Lg(t)?n.apply(void 0,ot([],R(t))):n(t)}function oa(n){return at(function(t){return Og(n,t)})}function Bg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function Rg(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ue(n),s=il(n),i=Ig(n),r=i.args,o=i.keys;if(r.length===0)return Ge([],e);var a=new gt(Fg(r,e,o?function(l){return Bg(o,l)}:se));return s?a.pipe(oa(s)):a}function Fg(n,t,e){return e===void 0&&(e=se),function(s){aa(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){aa(t,function(){var d=Ge(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 aa(n,t,e){n?jt(e,n,t):t()}class Hg extends X{constructor(t,e){super(),this.canvasInputListener=t,this.canvasBoundsContainer=e,this.panesSubscriptions={},this.crossSubject=new ut(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=Rg([s,i]).pipe($(([,a])=>!r||r&&a)).subscribe(([a,l])=>{if(l){const c=[a.x,a.y,t];this.crossSubject.next(c),r=!1}!l&&!Nt()&&(this.crossSubject.next(null),r=!0)});return this.panesSubscriptions[t]=o,()=>o.unsubscribe()}}class kg{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 kg(o,a,this.chartModel.pane.regularFormatter,this.chartModel.toY)}}class Yg{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof Gr)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 Ng=Object.defineProperty,Xg=Object.defineProperties,Wg=Object.getOwnPropertyDescriptors,la=Object.getOwnPropertySymbols,zg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,ca=(n,t,e)=>t in n?Ng(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ne=(n,t)=>{for(var e in t||(t={}))zg.call(t,e)&&ca(n,e,t[e]);if(la)for(var e of la(t))Vg.call(t,e)&&ca(n,e,t[e]);return n},Sn=(n,t)=>Xg(n,Wg(t));class Ug extends X{constructor(t,e,s,i,r,o,a,l,c,h){super(),this.crossEventProducer=t,this.scale=e,this.config=s,this.chartModel=i,this.canvasInputListener=r,this.canvasBoundsContainer=o,this.paneManager=a,this.timeZoneModel=l,this.mainCanvasTouchHandler=c,this.formatterFactory=h,this.hoverSubject=new ut(null),this.longTouchActivatedSubject=new ut(!1),this.longTouchCrosshairSuppressed=!1,this.xFormatter=()=>"";const d=new jg(this.chartModel),u=new Yg(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(wo(()=>this.scale.initialViewportValidSubject.pipe($(Boolean)))).subscribe(()=>{const e=this.chartModel.getLastVisualCandle();e&&this.createAndFireHoverFromCandle(e)})),this.addRxSubscription(this.chartModel.candlesUpdatedSubject.subscribe(()=>{const e=this.chartModel.getLastVisualCandle();this.hover!==null&&e!==void 0&&e.candle.timestamp<=this.hover.timestamp&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?this.hoverSubject.next(null):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(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;const{clientX:r,clientY:o}=e.changedTouches[0],{fixed:a,temp:l}=this.crossEventProducer.crossToolTouchInfo,c=r-this.canvasBoundsContainer.canvasOnPageLocation.x,h=o-this.canvasBoundsContainer.canvasOnPageLocation.y;if(this.crossEventProducer.crossToolTouchInfo.isCommonTap&&!_o(c,l.x,h,l.y)){this.paneManager.chartPanComponent.setChartPanningOptions(!0,!0),this.longTouchActivatedSubject.next(!1),this.crossEventProducer.fireCrossClose(),this.crossEventProducer.crossToolHover=null,this.crossEventProducer.crossToolTouchInfo.isSet=!1;return}if(!this.crossEventProducer.crossToolTouchInfo.isSet)this.crossEventProducer.crossToolTouchInfo.isSet=!0,this.crossEventProducer.crossToolTouchInfo.temp={x:this.crossEventProducer.crossToolTouchInfo.fixed.x,y:this.crossEventProducer.crossToolTouchInfo.fixed.y},this.crossEventProducer.crossToolTouchInfo.fixed={x:c,y:h},this.crossEventProducer.crossToolTouchInfo.isSet=!0;else{const d=(i=(s=this.crossEventProducer.crossToolHover)==null?void 0:s.paneId)!=null?i:"CHART",u=this.canvasBoundsContainer.getBounds(M.PANE_UUID(d)),f=u.y+5,p=u.y+u.height-5,m=c-l.x,x=h-l.y,_=a.x<0?0:a.x>u.width?u.width:a.x+=m,A=a.y<f?f:a.y>p?p:a.y+=x;this.crossEventProducer.crossToolTouchInfo.fixed={x:_,y:A}}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=lo(t,this.chartModel.getPeriod(),this.formatterFactory)}createHoverFromCandle(t){const e=t.xCenter(this.scale),s=this.scale.toY(t.close);return this.createHover(e,s,Z)}createHover(t,e,s){if(this.chartModel.getCandles().length===0)return;const r=this.chartModel.candleFromX(t,!0).timestamp,o={x:t,y:e,timestamp:r,timeFormatted:this.xFormatter(r),paneId:s},a=Object.entries(this.hoverProducerParts).reduce((l,c)=>Sn(Ne({},l),{[c[0]]:c[1].getData(o)}),{});return Ne(Ne({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){const e=this.createHoverFromCandle(t);if(this.hover&&e){const s=Sn(Ne({},e),{x:this.hover.x,y:this.hover.y});this.fireHover(s)}}createAndFireHover([t,e,s]){const i=this.createHover(t,e,s);this.fireHover(i)}fireHover(t){var e,s;if(t){if(Nt()&&this.config.components.crossTool.type!=="none"){const i=this.crossEventProducer.crossToolHover,r=i?(e=i.candleHover)==null?void 0:e.visualCandle.candle:(s=t.candleHover)==null?void 0:s.visualCandle.candle;r&&this.chartModel.mainCandleSeries.setActiveCandle(r)}this.hoverSubject.next(t)}else this.crossEventProducer.fireCrossClose()}fireLastCross(){const t=this.crossEventProducer.crossSubject.getValue();t&&this.createAndFireHover(t)}setLongTouchCrosshairSuppressed(t){this.longTouchCrosshairSuppressed=t}registerHoverProducerPart(t,e){this.hoverProducerParts=Sn(Ne({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const ha={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 Se(n){return t=>{t.button===ha.left&&n(t)}}var Gg=["addListener","removeListener"],Zg=["addEventListener","removeEventListener"],$g=["on","off"];function xn(n,t,e,s){if(k(e)&&(s=e,e=void 0),s)return xn(n,t,e).pipe(oa(s));var i=R(Jg(n)?Zg.map(function(a){return function(l){return n[a](t,l,e)}}):Kg(n)?Gg.map(da(n,t)):qg(n)?$g.map(da(n,t)):[],2),r=i[0],o=i[1];if(!r&&Ls(n))return Bs(function(a){return xn(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 da(n,t){return function(e){return function(s){return n[e](t,s)}}}function Kg(n){return k(n.addListener)&&k(n.removeListener)}function qg(n){return k(n.on)&&k(n.off)}function Jg(n){return k(n.addEventListener)&&k(n.removeEventListener)}var Qg=Object.defineProperty,ua=Object.getOwnPropertySymbols,tm=Object.prototype.hasOwnProperty,em=Object.prototype.propertyIsEnumerable,fa=(n,t,e)=>t in n?Qg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,sm=(n,t)=>{for(var e in t||(t={}))tm.call(t,e)&&fa(n,e,t[e]);if(ua)for(var e of ua(t))em.call(t,e)&&fa(n,e,t[e]);return n};const ws=class de extends X{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=de.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=sm({},this.dragStartPoint),de.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===ha.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=[],de.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),de.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))}),de.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(Ct(this.element,Se(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(Ct(document,Se(s=>this.clickDocumentSubject.next(s)),"click"));const t=ms();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,Se(()=>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,Se(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(Ct(this.element,Se(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(Ct(document,Se(()=>this.mouseUpDocumentSubject.next(this.currentPoint)),"mouseup")),this.addRxSubscription(this.eventBus.observe(cs).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(xn(document,"scroll",{capture:!0,passive:!0}).pipe(Et(zt,is,{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(){de.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($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveNoDrag(){return this.mouseMoveSubject.asObservable().pipe($(()=>!this.dragging))}observeMouseMoveDocument(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseMoveDocumentAnyElement(t=()=>!0){return this.mouseMoveDocumentSubject.asObservable().pipe($(()=>t(this.currentPointDocument.x,this.currentPointDocument.y)),at(()=>this.currentPointDocument))}observeClickOnDocument(){return this.clickDocumentSubject.asObservable()}observeXDragStart(t=()=>!0){return this.xDragStartSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDrag(t=()=>!0){return this.xDragSubject.pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragEnd(t=()=>!0){return this.xDragEndSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeXDragTick(){return this.xDragTickSubject.asObservable()}observeYDragStart(t=()=>!0){return this.yDragStartSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDrag(t=()=>!0){return this.yDragSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragEnd(t=()=>!0){return this.yDragEndSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeYDragTick(){return this.yDragTickSubject.asObservable()}observeMouseEnter(t=()=>!0,e=!1){const s=this.mouseMoveSubject.asObservable().pipe($(()=>!(e&&this.dragging)),at(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(at(()=>!1));return wt(s,i).pipe(mt())}observeMouseLeavesCanvas(){return this.mouseLeavesCanvasSubject.asObservable()}observeClick(t=()=>!0){return this.clickSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbClick(t=()=>!0){return this.dbClickSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeDbTap(t=()=>!0){return this.dbTapSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeWheel(t=()=>!0){return this.wheelSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchStart(t=()=>!0){return this.touchStartSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeTouchMove(t=()=>!0){return this.touchMoveSubject.asObservable().pipe($(()=>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($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUp(t=()=>!0){return this.mouseUpSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeMouseUpDocument(t=()=>!0){return this.mouseUpDocumentSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeContextMenu(t=()=>!0){return this.contextMenuSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)),Bo(e=>e.preventDefault()))}observeLongTouchStart(t=()=>!0){return this.longTouchStartSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeLongTouchEnd(t=()=>!0){return this.longTouchEndSubject.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}observeFastTouchScroll(t=()=>!0){return this.fastTouchScroll.asObservable().pipe($(()=>t(this.currentPoint.x,this.currentPoint.y)))}getCurrentPoint(){return this.currentPoint}};ws.DRAG_START_EVENTS=["mousedown","touchstart"],ws.DRAG_EVENTS=["mousemove","touchmove"],ws.DRAG_END_EVENTS=["mouseup","touchend","touchcancel"];let nm=ws;var im=(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=$s);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 _n={};function rm(n){return _n[n]||(_n[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"})),_n[n]}const pa=(n,t=Date.now())=>{const s=rm(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},ga=60*1e3;class om{constructor(t){this.config=t,this.timeZoneChangedSubject=new im,this.currentTzOffset=e=>pa(this.config.timezone,e)+new Date(e).getTimezoneOffset()*ga,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=Eu(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+pa(t,e)+new Date(e).getTimezoneOffset()*ga):e=>new Date(e)}}class am extends X{constructor(t,e,s){super(),this.hitTestCanvasModel=t,this.canvasAnimation=e,this.eventBus=s}doActivate(){super.doActivate(),this.addRxSubscription(this.canvasAnimation.animationInProgressSubject.subscribe(()=>{const t=this.canvasAnimation.animationInProgressSubject.getValue();this.hitTestCanvasModel.hitTestDrawersPredicateSubject.next(!t)})),this.addRxSubscription(this.hitTestCanvasModel.hitTestDrawersPredicateSubject.pipe(mt((t,e)=>t!==e&&t===!0&&e===!1)).subscribe(()=>this.eventBus.fireDraw([this.hitTestCanvasModel.canvasId])))}}var lm=Object.defineProperty,cm=Object.defineProperties,hm=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,dm=Object.prototype.hasOwnProperty,um=Object.prototype.propertyIsEnumerable,va=(n,t,e)=>t in n?lm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fm=(n,t)=>{for(var e in t||(t={}))dm.call(t,e)&&va(n,e,t[e]);if(ma)for(var e of ma(t))um.call(t,e)&&va(n,e,t[e]);return n},pm=(n,t)=>cm(n,hm(t));class gm extends ci{constructor(t){super(t),this.animations={},this.animFrameId="animation",this.animationInProgressSubject=new ut(!1),this.microtaskQueued=!1}startViewportMovementAnimation(t,e,s=fe,i){const r=new ri(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ni(pm(fm({},i),{duration:i&&i.duration||Ee}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ee,i){const r=new ii({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(){pl(this.animFrameId),this.microtaskQueued=!1}}class Pn{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;oc(r),this.config=r;const o=Tc(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 om(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=Mc(t);this.elements=c;const h=new xg;this.bus=h;const d=new Pg(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 _d(h,d);this.drawingManager=u;const f=Sd(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=ce(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new ye(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const m=ce(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),x=ce(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),_=new Zs(r,h,f,l,d);this.canvasBoundsContainer=_;const A=c.mainCanvas.parentElement;if(A===null)throw new Error("Couldn't get main canvas parent");const L=new nm(h,A);this.canvasInputListener=L,this.chartComponents.push(this.canvasInputListener);const Y=[h,c.hitTestCanvas,L,_,u,r,this.canvasModels,c.chartResizer],H=new Wu(...Y);this.hitTestCanvasModel=H;const B=new ye(H);u.addDrawer(B,"HIT_TEST_CLEAR");const j=Ae?new gm(h):new ci(h);this.canvasAnimation=j;const K=M.PANE_UUID(Z),W=new Er(r,()=>_.getBounds(K),j);this.scaleModel=W;const U=ce(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=U,this.cursorHandler=new _c(c.canvasArea,L,_,H),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new Hg(L,_),this.chartComponents.push(this.crossEventProducer);const G=new ah("candle");this.chartBaseModel=G;const V=new Ef(h,W,_,r,j,L,A,G,H);this.chartPanComponent=V,this.chartComponents.push(V),this.userInputListenerComponents.push(V.chartAreaPanHandler);const Q=new am(H,j,h);this.hitTestComponent=Q,this.chartComponents.push(Q);const J=new hp(G,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,W,_,r,j,L,u,this.cursorHandler,this.crossEventProducer,V,f,m,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=J;const et=this.paneManager.panes[Z];this.mainPane=et,this.chartComponents.push(J),this.dynamicObjects=new Mu(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new ru(G,J,h,this.dynamicObjectsCanvasModel,r,W,l,A,_,d);const tt=new Xd(this.chartModel,this.dynamicObjectsCanvasModel,r,W,_,u,H,L,U,V,J,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(tt),this.chartComponent=tt;const st=this.chartComponent.chartModel;this.chartModel=st,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),H.addSubscriber(J.hitTestController),this.xAxisComponent=new gg(h,r,f,tt,W,_,L,d,this.drawingManager,a,V,this.cursorHandler,this.hitTestCanvasModel,this.mainPane.yAxis),this.chartComponents.push(this.xAxisComponent),this.userInputListenerComponents.push(this.xAxisComponent.xAxisScaleHandler);const ft=new ye(f);u.addDrawer(ft,"MAIN_CLEAR");const ct=new _g(A,st,L,r);this.chartComponents.push(ct),this.watermarkComponent=new Mp(J,st,h,r,_,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const _t=ce(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new cf(h,r,st,f,_,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(st)),this.navigationMapComponent=new bf(h,st,f,r,L,_,u,l,V,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Zt=new ef(r,this.dynamicObjectsCanvasModel,st,_,u);this.chartComponents.push(Zt),this.initYAxisDrawer(m,x),this.yAxisComponent=et.mainExtent.yAxis;const xe=new Cg(this.chartModel,this.config,et.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(xe,re.MAIN),this.volumesComponent=new wp(this.dynamicObjectsCanvasModel,tt,W,_,u,r,J,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const Sa=new mo(f,W,r,this.yAxisComponent.state,"GRID",u,()=>this.canvasBoundsContainer.getBounds(M.ALL_PANES),()=>this.canvasBoundsContainer.getBounds(K),()=>this.xAxisComponent.xAxisLabelsGenerator.labels,()=>[],void 0,void 0,()=>r.components.grid.visible,this.mainPane.mainExtent.idx);this.chartComponents.push(Sa),this.hoverProducer=new Ug(this.crossEventProducer,W,r,st,L,this.canvasBoundsContainer,this.paneManager,a,V.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new xu(r,_t,_,u,J,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel,this.chartModel),this.chartComponents.push(this.crossToolComponent);const xa=ce(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),Tn=new dp(this.elements,xa);this.snapshotComponent=Tn,this.chartComponents.push(Tn);const xs=new Ju(r,this.dynamicObjectsCanvasModel,H,st,_,u,l,this.cursorHandler);this.eventsComponent=xs,this.chartComponents.push(xs),this.chartComponents.forEach(Am=>Am.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=Ol(this.components)}initYAxisDrawer(t,e){const s=new an,i=new ye(t),r=new ye(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new wg(this.config,t,this.paneManager);s.addDrawer(o);const a=new yg(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"&&Pn.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 ba extends Pn{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 mm=Object.defineProperty,vm=Object.defineProperties,bm=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,Cm=Object.prototype.hasOwnProperty,ym=Object.prototype.propertyIsEnumerable,ya=(n,t,e)=>t in n?mm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,wm=(n,t)=>{for(var e in t||(t={}))Cm.call(t,e)&&ya(n,e,t[e]);if(Ca)for(var e of Ca(t))ym.call(t,e)&&ya(n,e,t[e]);return n},Sm=(n,t)=>vm(n,bm(t));function wa(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=Ss(l,c,a);for(t.push(h);t.length<e;){var d=Math.random()*10;d>6?t=t.concat(Pm(t[t.length-1],a,s)):d>3?t=t.concat(xm(t[t.length-1],a,r)):t=t.concat(_m(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 Ss(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:Pi(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function xm(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=Ss(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 _m(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=Ss(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 Pm(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=Ss(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=Sm(wm({},window.DXChart),{generateCandlesData:wa});function Tm(n){return wa(n)}const Mm=((n,t={})=>new ba(n,t))})(),window.DXChart=Ps})();})();
24
+ `);(Object.getOwnPropertyDescriptor(Js,"name")||{}).writable||Object.defineProperty(Js,"name",{value:"default",configurable:!0});function Mc(n){const t=document.createElement("template");return t.innerHTML=Js(n.devexpertsPromoLink),t}function Ac(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}),Tc(t))return t;throw new Error("Some chart elements are missing")}function Ec(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 Ic=n=>t=>n?new Date(t).setHours(0,0,0,0):t,Be=(n,t={},e,s=1e3)=>{var i,r,o,a;const{extrapolate:l,isDaysPeriod:c}=t,h=!!l,d=Ic(!!c),u=d(n),f=d((r=(i=ge(e))==null?void 0:i.timestamp)!=null?r:0),p=d((a=(o=xt(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:lt((u-f)/s),exact:!0}:{index:-1,exact:!0}:Nt(e,u,m=>d(m.timestamp))},Km=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))},Gi={color:"#FF00FF",lineWidth:1,hoveredLineWidth:2,offset:0},Zi={paintConfig:[Gi],type:"LINEAR",highLowActive:!0,visible:!0,labelLastValue:"viewport",labelMode:"label",labelAppearanceType:"badge"};var Dc=Object.defineProperty,$i=Object.getOwnPropertySymbols,Lc=Object.prototype.hasOwnProperty,Oc=Object.prototype.propertyIsEnumerable,Ki=(n,t,e)=>t in n?Dc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bc=(n,t)=>{for(var e in t||(t={}))Lc.call(t,e)&&Ki(n,e,t[e]);if($i)for(var e of $i(t))Oc.call(t,e)&&Ki(n,e,t[e]);return n};class Rc{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:[Bc({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:Gi).color;return{textColor:ne(i,"white","black"),bgColor:i,paddingBottom:e.labelPaddingBottom,paddingEnd:e.labelPaddingEnd,paddingTop:e.labelPaddingTop}}}function Fc(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)=>Hc(a,l,e)).filter(di).sort(kc),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 Hc=(n,t,e)=>n?{top:n.y-e/2,bottom:n.y+e/2,labelWeight:n.weight,actualIndex:t}:null,kc=(n,t)=>{const e=n.top,s=t.top;return e>s?1:e<s||e===s&&n.labelWeight<t.labelWeight?-1:0};var jc=Object.defineProperty,Yc=Object.defineProperties,Nc=Object.getOwnPropertyDescriptors,qi=Object.getOwnPropertySymbols,Xc=Object.prototype.hasOwnProperty,Wc=Object.prototype.propertyIsEnumerable,Ji=(n,t,e)=>t in n?jc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Qi=(n,t)=>{for(var e in t||(t={}))Xc.call(t,e)&&Ji(n,e,t[e]);if(qi)for(var e of qi(t))Wc.call(t,e)&&Ji(n,e,t[e]);return n},tr=(n,t)=>Yc(n,Nc(t));const re={MAIN:"MAIN"};class zc 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 H,this.animFrameId=`anim_cache_${St()}`,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(),Te(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=Fc(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 tr(Qi({},t),{labels:t.labels.map((s,i)=>{var r;return tr(Qi({},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 Vc;let Ht=window.devicePixelRatio,os=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);const Qs=()=>{os.removeEventListener("change",Qs),Ht=window.devicePixelRatio,os=window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`),os.addEventListener("change",Qs)};os.addEventListener("change",Qs);const Uc=()=>Ht,qm=n=>Vc(Ht*n)/Ht,It=n=>lt(Ht*n)/Ht,tn=n=>yl(Ht*n)/Ht,oe=n=>JSON.parse(JSON.stringify(n));function en(n){return Object.entries(n)}const er=(n,t)=>{for(const[e,s]of Array.from(n.entries()))if(s===t)return e};function sr(n){return Object.keys(n)}function nr(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])||!nr(n[e[i]],t[e[i]]))return!1;return!0}const Gc=n=>Object.keys(n).length===0&&n.constructor===Object;function ir(n){n===void 0&&(n={});var t=n.connector,e=t===void 0?function(){return new H}: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},x=function(){_(),h=u=void 0,p=m=!1},A=function(){var E=h;x(),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=sn(A,l))}),B.subscribe(Y),!h&&f>0&&(h=new Pe({next:function(R){return B.next(R)},error:function(R){m=!0,_(),d=sn(x,i,R),B.error(R)},complete:function(){p=!0,_(),d=sn(x,o),B.complete()}}),Lt(E).subscribe(h))})(c)}}function sn(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 Pe({next:function(){i.unsubscribe(),n()}});return Lt(t.apply(void 0,ot([],F(e)))).subscribe(i)}}const as=(n,t)=>n/t,bt=(n,t)=>n/t,kt=(n,t)=>n*t,rr=(n,t)=>(n-t)*100/t,or=(n,t)=>n*t/100+t,ar=n=>Math.log2(n),nn=n=>Math.pow(2,n);class Zc 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 H,this.xChanged=this.changed.pipe(at(()=>({start:this.xStart,end:this.xEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),ir()),this.yChanged=this.changed.pipe(at(()=>({start:this.yStart,end:this.yEnd})),mt((t,e)=>t.start===e.start&&t.end===e.end),ir()),this.initialViewportValidSubject=new ut(!1)}doActivate(){super.doActivate(),this.addRxSubscription(this.changed.subscribe(()=>{!this.initialViewportValidSubject.getValue()&&this.initialViewportValidSubject.next(this.isViewportValid())}))}doDeactivate(){super.doDeactivate(),this.changed.complete()}toX(t){return this.getBounds().x+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 $c=(n,t)=>!sr(n).some(e=>n[e]!==t[e]);class Kc{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 lr{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 Kc(this.scale,this.dataSeries)}toAxisUnits(t,e=this.getBaseline){switch(this.getAxisType()){case"percent":const s=this.percentAnimationHandler.getBaselineForPercent(e);return rr(t,s);case"logarithmic":return t<=0?t:ar(t);case"regular":return t}}priceFromY(t){const e=this.scale.fromY(t);return this.fromAxisUnits(e)}fromAxisUnits(t){switch(this.getAxisType()){case"percent":return or(t,this.getBaseline());case"logarithmic":return nn(t);case"regular":return t}}}const zt=16;var qc=Object.defineProperty,Jc=Object.defineProperties,Qc=Object.getOwnPropertyDescriptors,cr=Object.getOwnPropertySymbols,th=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,hr=(n,t,e)=>t in n?qc(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dr=(n,t)=>{for(var e in t||(t={}))th.call(t,e)&&hr(n,e,t[e]);if(cr)for(var e of cr(t))eh.call(t,e)&&hr(n,e,t[e]);return n},sh=(n,t)=>Jc(n,Qc(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 ur 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 xt(l)};const a=r!=null?r:oe(Zi);this.config=At(a,Zi),this.scale=t.scale,this.view=new lr(this,this.scale,()=>this.extentComponent.yAxis.getAxisType(),this.getBaseline),this.yAxisLabelProvider=new Rc(this,this.config,t.getYAxisBounds,(o=t.yAxis)==null?void 0:o.state),this.highLowProvider=ih(this),t.addDataSeries(this),this.activate()}get dataPoints2D(){return this._dataPoints}get dataPoints(){return this._dataPointsFlat}set dataPoints(t){this._dataPoints=pi(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=pi(t),this._visualPointsFlat=this._visualPoints.flat()}doActivate(){this.addRxSubscription(this.scale.xChanged.pipe(Et(zt,Bt,{trailing:!0,leading:!0}),at(()=>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=dr({},this.extentComponent);this.extentComponent.removeDataSeries(this),this.extentComponent=t,this.scale=t.scale,this.view=new lr(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[re.MAIN],r=i&&Object.keys(i).find(a=>this.parentId&&a===this.parentId),o=this.extentComponent.yAxis.model.fancyLabelsModel.labelsProviders[re.MAIN];if(r){const a=i[r];a.yAxisBoundsProvider=t.getYAxisBounds,(!o||o&&!o[r])&&(this.extentComponent.yAxis.model.fancyLabelsModel.registerYAxisLabelsProvider(re.MAIN,a,r),s.yAxis.model.fancyLabelsModel.unregisterYAxisLabelsProvider(re.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 kl(this.visualPoints2D,s,i)}}const nh=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},ih=n=>({isHighLowActive:()=>n.config.highLowActive&&n.config.visible,calculateHighLow:t=>{const e=nh(n.getSeriesInViewport(t==null?void 0:t.xStart,t==null?void 0:t.xEnd).flat());return sh(dr({},e),{high:n.view.toAxisUnits(e.high),low:n.view.toAxisUnits(e.low)})}}),rh=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 ve=60,Fe=(n,t,e=ve)=>{const s=fr(n,t,e);return{id:Ti(s,s),hi:NaN,lo:NaN,open:NaN,close:NaN,timestamp:s,volume:NaN,expansion:!0,idx:t}},oh=(n,t,e=ve)=>({close:NaN,timestamp:fr(n,t,e)});function fr(n,t,e=ve){var s,i;const r=Ae(t);if(n.length===0)return 0;const o=xt(n);if(r>=n.length&&o)return pr(o,n.length-1,r,e);const a=ge(n);return r<0&&a?pr(a,0,r,e):(i=(s=n[r])==null?void 0:s.timestamp)!=null?i:0}const pr=(n,t,e,s=ve)=>n.timestamp+(e-(t!=null?t:0))*s,rn=(n,t,e,s,i=ve)=>{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)},ah=(n,t,e,s,i=ve)=>{const r=oh(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)};class lh{constructor(t){this.type=t,this.mainDataPoints=[],this.mainVisualPoints=[],this.dataUpdatedSubject=new H,this.dataSetSubject=new H,this.dataRemovedSubject=new H,this.dataPrependSubject=new H,this.meanDataWidth=1,this.period=1}dataFromTimestamp(t,e={extrapolate:!0},s=this.mainDataPoints){const i=Be(t,e,s,this.period);return this.dataFromIdx(i.index)}recalculatePeriod(){const t=Ec(this.mainDataPoints);t&&(this.period=t)}dataFromIdx(t){const e=this.mainVisualPoints[t];return e||(this.type==="candle"?rn(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period):ah(this.mainDataPoints,this.mainVisualPoints,this.meanDataWidth,t,this.period))}}var ch=Object.defineProperty,gr=Object.getOwnPropertySymbols,hh=Object.prototype.hasOwnProperty,dh=Object.prototype.propertyIsEnumerable,mr=(n,t,e)=>t in n?ch(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,uh=(n,t)=>{for(var e in t||(t={}))hh.call(t,e)&&mr(n,e,t[e]);if(gr)for(var e of gr(t))dh.call(t,e)&&mr(n,e,t[e]);return n};class fh{constructor(t,e,s=()=>!0){this.canvasModel=t,this.config=e,this.drawPredicate=s,this.prevState={},this.isColorsChanged=()=>!nr(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=uh({},this.config.colors.chartAreaTheme)}getCanvasIds(){return[this.canvasModel.canvasId]}}const ph=(n,t,e,s,i,r,o)=>{const a=Uc(),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]=lt(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?lt(u*o):lt(h*u)}c=new ImageData(c.data,c.width,c.height,{colorSpace:c.colorSpace})}t.putImageData(c,l[0],l[1])},vr=(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,on(n,s)),gh=(n,{x:t,width:e,activeCandle:s,prevCandle:i})=>{var r;return new ls(t,e,n.open,n.close,n.hi,n.lo,ql((r=i==null?void 0:i.close)!=null?r:n.close,n.close),n,!0,on(n,s),n.close>n.open)},br=(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,on(n,s),n.close>n.open)},mh=br,on=(n,t)=>{const e=t&&t.id===n.id;return e!=null?e:!1},Cr=()=>Gs,He=class de{static autoDetectIncrementOfValueRange(t){const e=this.getDigitsInNumber(t);return t===0?.01:Math.pow(10,e-3)}static getDigitsInNumber(t){const e=i=>lt(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=de.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]=de.calculatePrecision(t[s]);for(let s=1;s<t.length;s+=2)e[s]=t[s]+Math.min(t[s-1],t[s+1])*de.RELATIVE_EPS;return e}static calculatePrecision(t){let e=t>1?Math.abs(Math.floor(t)-t):t;for(let s=0;s<de.MAXIMUM_PRECISION;s++){const i=Math.floor(e+.5),r=Math.abs(e*de.RELATIVE_EPS);if(i>=e-r&&i<=e+r)return s;e*=10}return de.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 be=He;const vh=(n,t)=>{var e;const s=(e=xt(t))!=null?e:1;return Math.pow(10,-s)};var bh=Object.defineProperty,Ch=Object.defineProperties,yh=Object.getOwnPropertyDescriptors,yr=Object.getOwnPropertySymbols,wh=Object.prototype.hasOwnProperty,Sh=Object.prototype.propertyIsEnumerable,wr=(n,t,e)=>t in n?bh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,xh=(n,t)=>{for(var e in t||(t={}))wh.call(t,e)&&wr(n,e,t[e]);if(yr)for(var e of yr(t))Sh.call(t,e)&&wr(n,e,t[e]);return n},_h=(n,t)=>Ch(n,yh(t));const Ph=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=Sr(o),l=()=>{var c,h;return(h=(c=n.visualPoints[i])==null?void 0:c.close)!=null?h:1};return _h(xh({},a),{low:n.view.toAxisUnits(a.low,l),high:n.view.toAxisUnits(a.high,l)})}}),Sr=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 Th{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){Mh(this.delegate,t,Object.values(this.highLowProviders),Object.values(this.highLowPostProcessor))}}const Mh=(n,t,e,s)=>{const i=e.filter(a=>a.isHighLowActive()).map(a=>a.calculateHighLow(t)),r=xr(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 xr(n){if(n.length===0)return Ah();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 Ah=()=>({high:Number.MIN_SAFE_INTEGER,low:Number.MAX_SAFE_INTEGER}),_r=(n,t)=>n/t,Eh=(n,t)=>n/t,Ih=(n,t)=>n*t,Pr=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=_r(e,s),r=n.yEnd-n.yStart;t.zoomY=Eh(t.zoomX,i);const o=t.zoomY/s,l=r*o-r;t.yEnd=t.yEnd+l/2,t.yStart=t.yStart-l/2},Dh=(n,t)=>{const e=n.zoomX,s=n.zoomY,i=_r(e,s),r=n.xEnd-n.xStart;t.zoomX=Ih(t.zoomY,i);const o=t.zoomX/e,l=r*o-r;t.xStart=t.xStart-l},Lh=(n,t)=>{const e=n.xStart;n.xStart=t,n.xEnd=n.xEnd+(t-e)},Oh=(n,t)=>{const e=n.yStart;n.yStart=t,n.yEnd=n.yEnd+(t-e)},Tr=(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},Bh=(n,t,e,s)=>Tr(n,t,1,e,s),Rh=Ie,Fh=.9,Hh=(n,t,e,s)=>{t.currentAnimation&&t.currentAnimation.animationInProgress&&t.currentAnimation.getProgress()>Fh&&(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:Rh,targetXStart:e.xStart,targetXEnd:e.xEnd,targetYStart:e.yStart,targetYEnd:e.yEnd,targetZoomX:e.zoomX,targetZoomY:e.zoomY},pe,()=>t.xStart===e.xStart&&t.xEnd===e.xEnd&&t.yStart===e.yStart&&t.yEnd===e.yEnd);t.currentAnimation=s};var kh=Object.defineProperty,jh=Object.defineProperties,Yh=Object.getOwnPropertyDescriptors,Mr=Object.getOwnPropertySymbols,Nh=Object.prototype.hasOwnProperty,Xh=Object.prototype.propertyIsEnumerable,Ar=(n,t,e)=>t in n?kh(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ae=(n,t)=>{for(var e in t||(t={}))Nh.call(t,e)&&Ar(n,e,t[e]);if(Mr)for(var e of Mr(t))Xh.call(t,e)&&Ar(n,e,t[e]);return n},Er=(n,t)=>jh(n,Yh(t));const Wh=new H,zh=new H,Vh=()=>({high:Number.NEGATIVE_INFINITY,low:Number.POSITIVE_INFINITY,highIdx:0,lowIdx:0});class Ir extends Zc{constructor(t,e,s){super(),this.config=t,this.getBounds=e,this.canvasAnimation=s,this.scaleInversedSubject=new H,this.beforeStartAnimationSubject=new H,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=oe(t.scale),this.autoScaleModel=new Th(this),this.offsets=this.config.components.offsets,this.initAutoScaleThrottling()}doActivate(){super.doActivate(),this.scaleInversedSubject=new H,this.beforeStartAnimationSubject=new H,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=ae(ae({},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();Tr(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();Bh(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(pe),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&&Pr(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=Er(ae({},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&&Pr(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(),Ee?Hh(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=Er(ae({},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);Dh(i,a),this.zoomReached=this.calculateZoomReached(a.zoomX,r),this.apply(a),this.fireChanged()}moveXStart(t){const e=this.export(),s=ae({},e);this.haltAnimation(),Lh(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();Oh(e,t),this.apply(e)}}doAutoScale(t=!1){if(!this.isViewportAnimationInProgress()&&this.state.auto||t){const e=this.export();this.autoScaleModel.doAutoYScale(e),$c(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=Wh.pipe(Et(zt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ae({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)}),this.autoScalePanSubscription=zh.pipe(Et(zt,Bt,{trailing:!0,leading:!1})).subscribe(()=>{const t=this.export(),e=ae({},t),s=this.scalePostProcessor(e,t);this.autoScaleModel.doAutoYScale(s)})}}class Uh extends Ir{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 Gh=ss().colors;class $t extends ur{constructor(t,e,s,i,r,o,a,l,c=Gh){super(t,e,s),this.eventBus=i,this.candlesTransformersByChartType=a,this.candleWidthByChartType=l,this.colors=c,this.zippedHighLow=Vh(),this.lastPriceMovement="none",this.lastVisualCandleChangedSubject=new H,this.meanCandleWidth=Gs,this._instrument=o,this.instrument=o,this.highLowProvider=Ph(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=be.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=xt(this.dataPoints);t&&(this.lastPriceMovement=es(t.open,t.close))}recalculateVisualPoints(){super.recalculateVisualPoints(),this.recalculateMeanCandleWidth(this.visualPoints)}recalculateZippedHighLow(){return this.zippedHighLow=Sr(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:Cr;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:vr;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=Gs}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 Jm(n){switch(n){case"line":case"area":return!0;default:return!1}}class Zh{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),x=l.y+l.height;if(u===void 0)t.beginPath(),t.lineTo(lt(m),x),t.moveTo(lt(m),_);else if(f===void 0){t.lineTo(lt(m),_),t.stroke(),t.lineTo(lt(m),x),t.lineTo(lt(h),x),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 Dr(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 $h(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 Kh(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 le(n,t){n.save(),n.lineWidth%2&&n.translate(.5,.5),t(),n.restore()}function Lr(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()},Qm=n=>Array.isArray(n[0])?n:[n];class qh{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&&!Gc(s)){const i=e.config.type,r=this.seriesDrawers[i];if(r){const o=e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1);o&&o.length>=1&&r.draw(t,o,e,{})}else console.error(`Data series drawer with type ${i} isn't registered!`)}}}const 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 Jh{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),le(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 Qh{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),x=u?s.view.toY(u.close)<l:!1,A=_<l;if(u!==void 0&&x!==A){Or(t,s,i,x);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,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?(Or(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 Or=(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 td{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),le(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),x=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:x),t.stroke();else if(d<3)t.beginPath(),t.moveTo(h,R?f:p),t.lineTo(h,R?A:x),t.moveTo(h+1,p),t.lineTo(h+1,x),t.stroke();else if(d===3){const k=d/Ht;this.drawCandlesWicks(t,h+k,f,A,p,x),c||(t.beginPath(),t.moveTo(h+k,p),t.lineTo(h+k,x),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,x);const V=this.config.candlePaddingPercent,X=Math.max(d*V/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 ed{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 sd{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 nd=1.5;class id{constructor(t){this.config=t}draw(t,e,s,i){var r;const o=i.hoverWidth?i.hoverWidth/2:nd;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 rd=["candle","bar","line","area","scatterPlot","hollow","histogram","baseline","trend"];class od{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 rd.includes(this.config.components.chart.type)}afterDraw(t,e){t.restore(),t.save(),Kt(t,e.scale.getBounds())}}class ad{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(lt(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),x=this.chartModel.config.components.chart.candlePaddingPercent,A=It(f*x/2),E=m+A,Y=f-A*2;t.fillRect(E,_,Y,p)}})})}}const ld=(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)},Br=(n,t,e)=>{n.length!==0&&n.forEach((s,i)=>{ld(s,t,e,i)})},cd=/^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i,hd=/^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i,dd=/^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*[)]$/,ud=n=>cd.exec(n),fd=n=>hd.exec(n),tv=n=>dd.exec(n);function pd(n){const t=ud(n)||fd(n);let e=[];return t&&(e=t.slice(2,5),t[1]==="#")?e.map(function(s){return parseInt(s,16)}):e}const Rr={};function gd(n,t){let e=Rr[n+t];if(!e){const s=pd(n);e=s&&"rgba("+s.join(",")+","+t+")",Rr[n+t]=e}return e}const Fr="#383838";class md{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(Hr(l.config.type)&&Hr(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 x,A;const E=[],Y=Math.min(m.length,(A=(x=p[_])==null?void 0:x.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(),Br(e,t,s),t.stroke()}drawDifference(t,e,s,i,r,o,a,l){const[c,h]=[[],[]];i.forEach(_=>{const[x,A]=_.diffPoints;c.push(x),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=ge(s))==null?void 0:a.x)!=null?l:0,u=(h=(c=xt(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:Fr:t.fillStyle=gd(e!=null?e:Fr,.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 Hr=n=>n==="DIFFERENCE";class vd{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,lt(r)),t.lineTo(d,lt(u))}),t.stroke()})}}class bd{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(),Br(e,t,s),t.stroke()}}class Cd{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 yd{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 wd{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",ev="draw_last_candle",Ce={width:20,height:20};class kr{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=an;var a;i.push(this),this.parent=_d(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>Ce.width&&this.height>Ce.height}}const an={name:"candle"},Sd={candle:an,bar:{name:"candle"},line:{name:"line",linked:!0},area:{name:"area",linked:!0}};function xd(n,t,e,s,i,r,o){var a;const l=ce(n,t,i,r,o,e);return l.type=(a=Sd[s])!=null?a:an,l}function ce(n,t,e,s,i,r,o){const a=new kr(n,t,s,i,r,o);return jr(a,e),a}function jr(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 _d(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_",rv=null;class Pd{constructor(t,e){this.chartResizeHandler=e,this.drawingOrder=[],this.drawersMap={},this.canvasIdsList=[],this.animFrameId=`draw_${St()}`,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),si(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}Rl(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)>Ce.width&&((i=(s=this.chartResizeHandler.previousBCR)==null?void 0:s.width)!=null?i:0)>Ce.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=ui(this.drawingOrder,t)}}class Yr{static paneResizer(t){return`PANE_RESIZER_${t}`}}const Td=7;class Md{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:Td};i.draw(t,e.getSeriesInViewport(e.scale.xStart-1,e.scale.xEnd+1),e,r)}}}getCanvasIds(){return[this.canvasModel.canvasId]}}const Nr={dragPredicate:()=>!0};class Xr 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 Xr{constructor(t,e,s,i,r=Nr){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 Ad="BASELINE_RESIZER";class Ed 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 ut(!1),this.baselineYPercents=50,this.ht=Ks.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&&vc(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[Ad]=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 Id=n=>{var t;try{const e=Me(n.close,n.open,n.hi,n.lo);if(!isFinite(e))throw new Error("Received candle without any price");const s=Me(n.hi,Math.max(n.open,n.close),e),i=Me(n.lo,Math.min(n.open,n.close),e),r=Me(n.open,n.lo,e),o=Me(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},Wr=n=>{n.forEach(t=>{t.idx=void 0})},Dd=n=>n!==void 0;class Ld{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,_,x;const A=Od(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=(x=i.color)!=null?x: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 Od=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0},Bd=(n,t)=>{let e=0;return(...s)=>{clearTimeout(e),e=+setTimeout(()=>n(...s),t)}};class Rd{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=Fd(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 Fd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t]:void 0},ye="#FF00FF";class Hd{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,_,x;const A=kd(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||ye;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||ye),!E&&l.close<0&&(t.fillStyle=(p=i.color)!=null?p:o.multiplyColors[1]||o.color||ye),E&&l.close>0&&(t.fillStyle=(m=i.color)!=null?m:o.multiplyColors[2]||o.color||ye),!E&&l.close>0&&(t.fillStyle=(_=i.color)!=null?_:o.multiplyColors[3]||o.color||ye),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=(x=i.color)!=null?x:o.color||ye,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 kd=(n,t)=>{do t--;while(t>=0&&!isFinite(n[t]&&n[t].close));return n[t]?n[t].close:void 0};var jd=Object.defineProperty,zr=Object.getOwnPropertySymbols,Yd=Object.prototype.hasOwnProperty,Nd=Object.prototype.propertyIsEnumerable,Vr=(n,t,e)=>t in n?jd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ur=(n,t)=>{for(var e in t||(t={}))Yd.call(t,e)&&Vr(n,e,t[e]);if(zr)for(var e of zr(t))Nd.call(t,e)&&Vr(n,e,t[e]);return n};class Xd{constructor(){this.symbol="MOCK",this.priceIncrements=[.01]}}class Wd 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 ut(!0),this.strToBarType=_=>{var x;return(x=this.barTypeValues.find(A=>A===_))!=null?x:"candle"},this.addChildEntity(this.chartModel),this.registerDefaultCandlesTransformers(),this.baselineModel=new Ed(this.chartModel,h,this.canvasModel,this.canvasInputListener,this.config,this.canvasBoundsContainer,u),this.addChildEntity(this.baselineModel);const m=new Md(this._dataSeriesDrawers,this.hitTestCanvasModel,d,()=>this.hitTestCanvasModel.hitTestDrawersPredicateSubject.getValue());this.drawingManager.addDrawerBefore(m,us+"DATA_SERIES","HIT_TEST_EVENTS"),this.registerDefaultDataSeriesDrawers(),this.backgroundDrawer=new fh(c,this.config,()=>this.backgroundDrawerPredicateSubject.getValue()),o.addDrawer(this.backgroundDrawer,"MAIN_BACKGROUND"),u.setCursorForCanvasEl(M.PANE_UUID($),s.components.chart.cursor),this.dataSeriesDrawer=new qh(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(Bd(()=>{this.backgroundDrawerPredicateSubject.next(!1)},zt))),this.addRxSubscription(this.chartResizeHandler.canvasResized.subscribe(()=>{this.backgroundDrawerPredicateSubject.next(!0)}))}registerDefaultCandlesTransformers(){this.registerCandlesTransformer("candle",vr),this.registerCandlesTransformer("trend",br),this.registerCandlesTransformer("hollow",gh),this.registerCandlesTransformer("line",mh)}get barTypeValues(){return sr(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 td(this.config.components.chart);this.registerDataSeriesTypeDrawer("candle",t),this.registerDataSeriesTypeDrawer("trend",t),this.registerDataSeriesTypeDrawer("hollow",t),this.registerDataSeriesTypeDrawer("bar",new Jh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("line",new sd(this.config.components.chart)),this.registerDataSeriesTypeDrawer("scatterPlot",new id(this.config.colors.scatterPlot)),this.registerDataSeriesTypeDrawer("area",new Zh(this.config.components.chart)),this.registerDataSeriesTypeDrawer("baseline",new Qh(this.baselineModel,this.canvasBoundsContainer)),this.registerDataSeriesTypeDrawer("histogram",new ed(this.config.components.chart.histogram));const e=M.PANE_UUID($),s=()=>this.canvasBoundsContainer.getBounds(e);this.registerDataSeriesTypeDrawer("LINEAR",new bd),this.registerDataSeriesTypeDrawer("LINEAR_TREND",new Rd),this.registerDataSeriesTypeDrawer("HISTOGRAM",new vd),this.registerDataSeriesTypeDrawer("TREND_HISTOGRAM",new Ld),this.registerDataSeriesTypeDrawer("POINTS",new Cd),this.registerDataSeriesTypeDrawer("TREND_POINTS",new Hd),this.registerDataSeriesTypeDrawer("COLOR_CANDLE",new od(new ad(this.chartModel),this.config,s)),this.registerDataSeriesTypeDrawer("TEXT",new yd(this.config)),this.registerDataSeriesTypeDrawer("TRIANGLE",new wd),this.registerDataSeriesTypeDrawer("DIFFERENCE",new md)}setChartType(t){this.config.components.chart.type=t,this.chartModel.rememberCurrentTimeframe(),this.chartModel.mainCandleSeries.setType(t),this.chartModel.mainCandleSeries.updateCandleSeriesColors(Ur({},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=Ur({},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 Wr(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||!be.validatePriceIncrementsOrPrecisions(t.priceIncrements))&&(t.priceIncrements=[be.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 Gr(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 Zr 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 zd=Object.defineProperty,$r=Object.getOwnPropertySymbols,Vd=Object.prototype.hasOwnProperty,Ud=Object.prototype.propertyIsEnumerable,Kr=(n,t,e)=>t in n?zd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Gd=(n,t)=>{for(var e in t||(t={}))Vd.call(t,e)&&Kr(n,e,t[e]);if($r)for(var e of $r(t))Ud.call(t,e)&&Kr(n,e,t[e]);return n};const Zd=(n,t,e,s)=>{var i,r,o,a;const l=Gd({},n),c=(r=(i=t[e])==null?void 0:i.startUnit)!=null?r:0,h=(a=(o=jl(-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},$d=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()}},Kd=(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 qd=Object.defineProperty,Jd=Object.defineProperties,Qd=Object.getOwnPropertyDescriptors,qr=Object.getOwnPropertySymbols,tu=Object.prototype.hasOwnProperty,eu=Object.prototype.propertyIsEnumerable,Jr=(n,t,e)=>t in n?qd(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,je=(n,t)=>{for(var e in t||(t={}))tu.call(t,e)&&Jr(n,e,t[e]);if(qr)for(var e of qr(t))eu.call(t,e)&&Jr(n,e,t[e]);return n},ln=(n,t)=>Jd(n,Qd(t));class su{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)=>ln(je({},e),{[s]:0}),{})}createColorPool(t){return t.reduce((e,s,i)=>(e[`color${i}`]=ln(je({},oe(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]]=ln(je({},e),{lineTheme:Object.assign(r.lineTheme,(s=o.lineTheme)!=null?s:{}),areaTheme:Object.assign(r.areaTheme,(i=o.areaTheme)!=null?i:{})})}}}var nu=Object.defineProperty,Qr=Object.getOwnPropertySymbols,iu=Object.prototype.hasOwnProperty,ru=Object.prototype.propertyIsEnumerable,to=(n,t,e)=>t in n?nu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ps=(n,t)=>{for(var e in t||(t={}))iu.call(t,e)&&to(n,e,t[e]);if(Qr)for(var e of Qr(t))ru.call(t,e)&&to(n,e,t[e]);return n};class ou 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 H,this.mainInstrumentChangedSubject=new H,this.offsetsChanged=new H,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(Id).filter(Dd),{sortCandles:p}=this.config.components.chart;return p?p(f):f},this.chartTypeChanged.next(this.config.components.chart.type),this.secondaryChartColors=new su(this.config);const d=new Zr(this.chartBaseModel,this.paneManager.panes[$].mainExtent,St(),this.paneManager.hitTestController.getNewDataSeriesHitTestId(),this.bus,this.scale,new Xd,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)=>Zd(f,this.mainCandleSeries.visualPoints,this.config.components.chart.minCandlesOffset,o.getBounds())),this.basicScaleViewportTransformer=$d(o),this.timeFrameViewportTransformer=Kd(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(Wi)).subscribe(t=>{this.handleChartResize(t)})),this.addRxSubscription(this.scale.changed.pipe(Gr(zt)).subscribe(()=>this.paneManager.yExtents.forEach(t=>t.yAxis.updateOrderedLabels(!0))))}handleChartResize(t){if(t.width>Ce.width&&t.height>Ce.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 Wr(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=so(this.mainCandleSeries.dataPoints,i),o=r.candles;ke(o),this.mainCandleSeries.dataPoints=o,e.map(l=>{var c,h,d,u;const f=this.prepareCandles(l.candles),p=so((u=(d=this.findSecondarySeriesBySymbol((h=(c=l.instrument)==null?void 0:c.symbol)!=null?h:""))==null?void 0:d.dataPoints)!=null?u:[],f).candles;return this.setSecondaryCandleSeries(p,l.instrument,!1)}),this.candleSeries.forEach(l=>{l.recalculateVisualPoints()});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,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=eo(e,o,-1);if(l||(l=eo(e,o,1)),l){const c=Jl(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+=Ae((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 xt(t)}getLastVisualCandle(){const t=this.mainCandleSeries.visualPoints;return xt(t)}getMaxCandlesFitLength(){return lt(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,{extrapolate:!1},t,this.chartBaseModel.period);return o.index>=0&&o.index<t.length&&(i.idx=o.index,s[o.index]=i),s},[])}getPeriod(){return this.chartBaseModel.period}isCandleInViewport(t){return this.getFirstIdx()<=t&&t<=this.getLastIdx()}isLastCandleInViewport(){const t=this.getLastCandle();return t&&t.idx?this.isCandleInViewport(t.idx):!1}updateCandles(t,e=this.mainCandleSeries.instrument.symbol){const s=this.mainCandleSeries.instrument.symbol===e,i=this.findSeriesBySymbol(e);if(i.length===0){console.warn("updateCandles failed. Can't find series",e);return}i.forEach(r=>{const o=r.dataPoints;let a=!1,l=!1,c;t.forEach(h=>{var d;if(!h)return;const u=Be(h.timestamp,{extrapolate:!0},o,this.getPeriod()),f=Math.min(u.index,o.length);a=a||f===o.length,o[f]=h,h.idx=f,r.dataPoints=o,r.recalculateDataViewportIndexes(),l=l||this.isCandleInViewport(f);const p=f>=o.length-1,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:Cr;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,{extrapolate:!1},t).index;a<0?i.push(r):t[a].id===r.id?s[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:i,candles:[...i,...s]}}addLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}updateLastCandle(t,e=this.mainCandleSeries.instrument.symbol){this.updateCandles([t],e)}removeCandleByIdx(t,e=this.mainCandleSeries.instrument.symbol){if(t<0)return;const s=this.findSeriesBySymbol(e);if(s.length===0){console.warn("removeCandle by id failed. Can't find series",e);return}s.forEach(i=>{i.dataPoints=i.dataPoints.slice(0,t).concat(i.dataPoints.slice(t+1)),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 eo=(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}},so=(n,t)=>{const e=n.slice(),s=[],i=[];return t.forEach(r=>{const a=Be(r.timestamp,{extrapolate:!0},n).index;a<0?s.push(r):a>=n.length?i.push(r):n[a].timestamp===r.timestamp?e[a]=r:console.warn(`Couldn't update candle with timestamp ${r.timestamp}`)}),{prepended:s,appended:i,candles:[...s,...e,...i]}};class we{constructor(t){this.canvasModel=t}draw(){this.canvasModel.clear()}getCanvasIds(){return[this.canvasModel.canvasId]}}class cn{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=er(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=er(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 au{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 lu=Object.defineProperty,cu=Object.defineProperties,hu=Object.getOwnPropertyDescriptors,no=Object.getOwnPropertySymbols,du=Object.prototype.hasOwnProperty,uu=Object.prototype.propertyIsEnumerable,io=(n,t,e)=>t in n?lu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,fu=(n,t)=>{for(var e in t||(t={}))du.call(t,e)&&io(n,e,t[e]);if(no)for(var e of no(t))uu.call(t,e)&&io(n,e,t[e]);return n},pu=(n,t)=>cu(n,hu(t));class gu 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 ut(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.canvasBoundsContainer.getBounds(M.PANE_UUID(t.paneId)),a=5,l=t.x-i.x,c=t.y-i.y,h=s.x+l,d=s.y+c,u=o.y+a,f=o.y+o.height-a,p=h<a?a:h>o.width-a?o.width-a:h,m=d<u?u:d>f?f:d,_=(e=this.hoverProducer.createHover(p,m,t.paneId))!=null?e:t,x=pu(fu({},_),{x:p,y:m});this.crossEventProducer.crossToolHover=x,this.updateCrossTool(x)}}const Rt=4;function mu(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:ie(r),x=i.bgColor,A=(c=i.textColor)!=null?c:ne(x,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=Ae(Xt(_,n)/2),k=s-R-E,X=s+R+Y-k;if(a&&!gs(s,t,X))return;n.save(),n.fillStyle=x,n.strokeStyle=x;const G=Ae(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,et=t.width-G-J;$h(n,U,k,Z,k+Ae(X/2),U,k+X,et,(p=(f=r.typeConfig.badge)==null?void 0:f.rounded)!=null?p:!1,m),n.fillStyle=A,n.font=_;const tt=m==="right"?t.x+t.width-Mt(e,n,_)-Q:t.x+Q;n.fillText(e,tt,s+R-1),n.restore()}function vu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_,x,A;const E=r.align,Y=(l=i.textFont)!=null?l:ie(r),B=i.bgColor,R=(c=i.textColor)!=null?c:ne(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,G=(_=(m=i.paddingEnd)!=null?m:k==null?void 0:k.end)!=null?_:Rt,Z=i.paddingStart,U=Xt(Y,n),Q=s-U/2-V,et=s+U/2+X-Q,tt=(A=i.rounded)!=null?A:(x=r.typeConfig.rectangle)==null?void 0:x.rounded;if(a&&!gs(s,t,et))return;n.save(),n.fillStyle=B,n.strokeStyle=B;const st=r.labelBoxMargin.end;n.font=Y;const ft=Mt(e,n,Y),ct=st-G,_t=Z!==void 0?ft+Z+G:t.width-ct,Zt=E==="right"?t.x+t.width-ct-_t:t.x+ct,_e=E==="right"?t.x+t.width-ft-st:st;tt?Dr(n,Zt,Q,_t,et,4,!0):n.fillRect(Zt,Q,_t,et),n.fillStyle=R,n.fillText(e,_e,s+U/2-1),n.restore()}function bu(n,t,e,s,i,r,o,a=!0){var l,c,h,d,u,f,p,m,_;const x=r.align,A=(l=i.textFont)!=null?l:ie(r),E=o.backgroundColor,Y=(c=i.textColor)!=null?c:ne(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,G=Xt(A,n),Z=s-G/2-R,Q=s+G/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 et=Mt(e,n,A),tt=J-V,st=X!==void 0?et+X+V:t.width-tt,ft=x==="right"?t.x+t.width-tt-st:t.x+tt,ct=x==="right"?t.x+t.width-et-J:J;n.fillStyle=E,n.strokeStyle=E,n.fillRect(ft,Z,st,Q),n.fillStyle=Y,n.fillText(e,ct,s+G/2-1),n.restore()}function Cu(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 yu="badge",ro=4,oo={badge:mu,rectangle:vu,plain:bu};function ao(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",x=(h=r.labelType)!=null?h:yu,A=r.description,E=(d=r.textFont)!=null?d:ie(a),Y=r.bgColor,B=(u=r.lineColor)!=null?u:Y,R=Mt(A!=null?A:"",n,E)+8,k=lt(r.y),V=Xt(E,n),X=p-V/2,Z=p+V/2-X;n.save(),n.fillStyle=Y,n.strokeStyle=B;const U=o.getBounds(M.PANE_UUID($)),Q=oo[x],J=a.labels.descriptions,et=wu(s,k,Z),tt=()=>J&&Su(e,t,s,i,r,a);let st,ft;const ct=2;a.align==="right"?(st=U.x,ft=J?U.x+U.width-R:U.x+U.width+ct):(st=J?U.x+R:U.x-ct,ft=U.x+U.width);const _t=(f=r.lineY)!=null?f:r.y,Zt=()=>et&&le(n,()=>{var Ps;return Kh(n,st,_t,ft,_t,1,(Ps=r.lineDash)!=null?Ps:[],r.lineCap)}),_e=()=>Q(n,s,Qe(m),p,r,a,l.yAxis,!1),_s={line:()=>{Zt(),tt()},"line-label":()=>{Zt(),_e(),tt()},label:()=>{tt(),_e()}};_!=="none"&&gs(p,s,Z)&&_s[_](),n.restore()}const wu=(n,t,e)=>t>n.y+e/2&&t<n.y+n.height-e/2;function Su(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=ie(r),f=Mt(h,t,u),p=Xt(u,t),m=(o=i.paddingTop)!=null?o:ro,_=(a=i.paddingBottom)!=null?a:ro,x=d-p/2-m,E=d+p/2+_-x;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;ph(n,t,V,x,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 lo{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()&&le(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,x=(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+_+x,R=p+A+E,k=Math.max(d-B/2,0),V=m.y+Y+Le/2;Dr(t,k,V,B,R),t.fillStyle=h.labelTextColor;const X=Math.max(d-f/2,_),G=m.y+Y+p+Le/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),d=this.canvasBoundsContainer.getBounds(M.PANE_UUID_Y_AXIS(r.uuid,l.idx)),u=oo[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 xu{draw(){}}class _u 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 gu(t.components.crossTool,this.crossToolCanvasModel,this.crossEventProducer,this.hoverProducer,this.canvasBoundsContainer,this.baselineModel,this.chartModel),this.addChildEntity(this.model);const h=new we(this.crossToolCanvasModel);this.registerDefaultDrawerTypes();const d=new au(this.model,this.config,this.crossToolCanvasModel,this.crossToolTypeDrawers),u=new cn;u.addDrawer(h,"CLEAR_CANVAS"),u.addDrawer(d,"CROSS_TOOL_DRAWER"),this.drawingManager.addDrawer(u,"CROSS_TOOL")}registerDefaultDrawerTypes(){this.registerCrossToolTypeDrawer("cross-and-labels",new lo(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0)),this.registerCrossToolTypeDrawer("just-labels",new lo(this.config,this.canvasBoundsContainer,this.paneManager,()=>!0,!0)),this.registerCrossToolTypeDrawer("none",new xu)}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 Pu{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 Tu{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 Mu extends W{constructor(t){super(),this.canvasModel=t,this.modelIdToObjectMap=new Map,this._uniqueObjects={},this._objects=new ut({})}getObjectInfoById(t){const e=this.modelIdToObjectMap.get(t);if(!e)return;const s=e.paneId,r=this.objects[s];if(r)return[e,r]}getObjectPosition(t){const e=this.getObjectInfoById(t);if(!e)return-1;const[s,i]=e,r=new 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 Tu;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))}bringToFront(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))}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))}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))}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))}get objects(){return this._objects.getValue()}get uniqueObjects(){return this._uniqueObjects}setDynamicObjects(t){this._objects.next(t),this.canvasModel.fireDraw()}}class Au extends W{constructor(t,e){super();const s=new Mu(t);this.model=s,this.addChildEntity(s);const i=new Pu(s,t);e.addDrawer(i,"DYNAMIC_OBJECTS")}}const Eu=()=>n=>n.toString(),Iu=(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:Du(n),shortMonths:Lu(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=>Ou(h.tzDate(d),l,h.shortDays,h.shortMonths)}};function Du(n){var t;return(t=n.shortDays)!=null?t:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]}function Lu(n){var t;return(t=n.shortMonths)!=null?t:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}const co=(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 Eu()},Ou=(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=Se(d),f=Se(a),p=Se(l),m=Se(c),_=a<12?"AM":"PM",x=e[n.getDay()],A=x.substring(0,3),E=Se(i),Y=r+1,B=Se(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",x).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},Se=n=>typeof n=="number"&&n<10?"0"+n:n,Ye=(n,t)=>`${n}_${t}`,Bu=(n,t)=>{if(t){const e=ho(t.normal),s=ho(t.hover);return{type:n,normal:e,hover:s}}},ho=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}},Ru=(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)}},Fu={"rhombus-small":4,rhombus:6,"rhombus-large":8},Hu=["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&&Hu.forEach(l=>{const c=Bu(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;Ru(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=hn(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 hn(n){return Fu[n.style]}const ms=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=hn(s);t.fillStyle=this.hitTestCanvasModel.idToColor(s.id);const d=(h+ms)*2;if(a!==void 0){const u=hn(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 Yu=Object.defineProperty,uo=Object.getOwnPropertySymbols,Nu=Object.prototype.hasOwnProperty,Xu=Object.prototype.propertyIsEnumerable,fo=(n,t,e)=>t in n?Yu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Wu=(n,t)=>{for(var e in t||(t={}))Nu.call(t,e)&&fo(n,e,t[e]);if(uo)for(var e of uo(t))Xu.call(t,e)&&fo(n,e,t[e]);return n};const po=317,dn={DRAWINGS:[1,4999],NEWS:[5e3,5999],DATA_SERIES:[6e3,9999],EVENTS:[1e4,12999],EXECUTED_ORDERS:[13e3,15999]};class zu extends kr{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 H,this.touchStartSubject=new H,this.dblClickSubject=new H,this.rightClickSubject=new H,this.hitTestDrawersPredicateSubject=new ut(!0),this.curImgData=new Uint8ClampedArray(4),this.prevAnimationFrameId=-1,jr(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(at(()=>this.canvasInputListener.currentPoint)).subscribe(c=>this.eventHandler(c,"touchstart")),i=wt(this.canvasInputListener.observeMouseDown(t),this.canvasInputListener.observeTouchStart().pipe(at(()=>this.canvasInputListener.currentPoint))).subscribe(c=>this.eventHandler(c,"mousedown")),r=wt(this.canvasInputListener.observeMouseUp(t),this.canvasInputListener.observeTouchEndDocument().pipe(at(()=>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(at(()=>Wu({},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*po).toString(16);return"#000000".substr(0,7-e.length)+e}colorToId(t){return t/po}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!==js&&(this.curImgData=this.ctx.getImageData(t*s,e*s,1,1).data,this.prevAnimationFrameId=js),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]=un(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]=un(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]=un(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(x=>x.onMouseDown&&x.onMouseDown(null,t));break;case"mouseup":m&&((i=f==null?void 0:f.onMouseUp)==null||i.call(f,m,t)),p.forEach(x=>x.onMouseUp&&x.onMouseUp(null,t));break;case"hover":m&&((r=f==null?void 0:f.onHover)==null||r.call(f,m,t)),p.forEach(x=>x.onHover&&x.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(x=>x.onTouchStart&&x.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(x=>x.onZoom&&x.onZoom(null,t));break;default:break}}}const un=(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 Vu=Object.defineProperty,Uu=Object.defineProperties,Gu=Object.getOwnPropertyDescriptors,go=Object.getOwnPropertySymbols,Zu=Object.prototype.hasOwnProperty,$u=Object.prototype.propertyIsEnumerable,mo=(n,t,e)=>t in n?Vu(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ku=(n,t)=>{for(var e in t||(t={}))Zu.call(t,e)&&mo(n,e,t[e]);if(go)for(var e of go(t))$u.call(t,e)&&mo(n,e,t[e]);return n},qu=(n,t)=>Uu(n,Gu(t));class Ju extends W{constructor(t){super(),this.canvasModel=t,this.events=[],this.hoveredEvent=new ut(null)}setEvents(t){this.events=this.indexEvents(t)}indexEvents(t){const e=this.getIdRange()[0];return t.map((s,i)=>qu(Ku({},s),{id:i+e})).sort((s,i)=>s.timestamp-i.timestamp)}getIdRange(){return dn.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 Qu 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=()=>co(this.config.components.events.xAxisLabelFormat,i.getPeriod(),this.formatterFactory);const c=new Ju(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 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 tf{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;le(t,()=>this.drawVertical(t)),le(t,()=>this.drawHorizontal(t)),le(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=lt(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=lt(this.viewportModel.toY(i.value)),o=Cu(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 vo 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 tf(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 ef{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 sf extends W{constructor(t,e,s,i,r){super();const o=new ef(e,s,t,i);r.addDrawer(o,"HIGH_LOW")}}const nf=["AFTER_MARKET","PRE_MARKET","NO_TRADING","REGULAR"],rf=1440*60*1e3;class of extends W{constructor(t){super(),this.chartModel=t,this.highlights=[],this.visualHighlights={},this.highlightsUpdatedSubject=new H}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()+rf;Wl(this.highlights,t,e,af).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 af=n=>n.to,Jt=[20,10];class lf{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),nf.forEach(m=>{var _,x;const A=a[m];if(A){const E=this.config.colors.highlights[m],Y=(_=E==null?void 0:E.border)!=null?_:"#ffffff",B=(x=E==null?void 0:E.background)!=null?x:"#ffffff";o.save(),o.beginPath(),o.fillStyle=B,o.strokeStyle=Y,A.forEach(R=>{var k,V,X;const G=this.chartModel.candleFromTimestamp(R.from),Z=bt(G.width,this.chartModel.scale.zoomX),U=G.xStart(this.chartModel.scale),Q=R.to-this.chartModel.chartBaseModel.period,J=this.chartModel.candleFromTimestamp(Q),et=bt(J.width,this.chartModel.scale.zoomX),tt=J.xStart(this.chartModel.scale)+et;if(R.border&&this.drawBorders(R.border,o,U+Z,tt-et,c),o.fillRect(U,c.y,tt-U,c.y+c.height),R.label){const st=(k=R.label.text)!=null?k:"",ft=this.config.colors.highlights[R.type];o.save(),o.fillStyle=(V=ft==null?void 0:ft.label)!=null?V:"#ffffff";const ct=Mt(st,o,p),[_t,Zt]=this.resolveHighlightLabelPosition((X=R.label.placement)!=null?X:"left-left",c,[U,tt],ct);o.fillText(st,_t,Zt),o.restore()}}),o.closePath(),o.restore()}}),o.restore()}}}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 cf="HIGHLIGHTS_PLUGIN";class hf extends W{constructor(t,e,s,i,r,o){super(),this.eventBus=t,this.config=e,this.highlightsModel=new of(s),this.addChildEntity(this.highlightsModel),this.highLightsDrawer=new lf(this.highlightsModel,s,i,r,e),o.addDrawer(this.highLightsDrawer,cf)}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 df(){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 uf=Object.defineProperty,ff=Object.defineProperties,pf=Object.getOwnPropertyDescriptors,bo=Object.getOwnPropertySymbols,gf=Object.prototype.hasOwnProperty,mf=Object.prototype.propertyIsEnumerable,Co=(n,t,e)=>t in n?uf(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,yo=(n,t)=>{for(var e in t||(t={}))gf.call(t,e)&&Co(n,e,t[e]);if(bo)for(var e of bo(t))mf.call(t,e)&&Co(n,e,t[e]);return n},wo=(n,t)=>ff(n,pf(t));const Ut=4;class vf{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:wo(yo({},h),{textAlign:"left"})},u={dateFormat:s.dateFormat,padding:s.padding,textProperties:wo(yo({},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=Si(s,i.dateFormat,this.formatterFactory);vi(t,i.textProperties);const a=ts(t),l=Ci(o);Vl(t,l,e.x+r.x,e.y+a+r.y,i.textProperties)}getCanvasIds(){return[this.canvasModel.canvasId]}}function So(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 Xr{constructor(t,e,s,i,r=Nr,o){super(t,e,s,i,r),this.shouldThrottleSubject=new ut(!!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(),So(e=>this.canvasInputListener.observeXDrag().pipe(e?Et(t,Bt,{trailing:!0,leading:!0}):se))).subscribe(this.onDragTick)),this.addRxSubscription(this.canvasInputListener.observeXDragEnd().subscribe(this.onDragEnd))}}const xo=4;class bf 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-xo},this.leftKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,x=(this.leftKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.leftRatio=x,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+xo},this.rightKnotDragTick=f=>{const{delta:p}=f,_=this.canvasBoundsContainer.getBounds(M.N_MAP_CHART).width,x=(this.rightKnotDragStartXRelative+p)/_;this.canvasBoundsContainer.rightRatio=x,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),x=(this.lastMousePosition-p)*_;this.scale.moveXStart(this.scale.xStart-x),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 Cf 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 vf(i,e,s,o,l,()=>this.visualCandles);a.addDrawer(d,M.N_MAP_CHART),this.navigationMapMoveHandler=new bf(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(df(),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=lt(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"},ov=(n,t)=>n==="apple"||n==="mobile"?3:t;var fn=Math.pow;class _o 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(pe),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 Pl(this.config.components.yAxis.type,r)}registerChartYPanHandler(t,e){let s=t.yStart;const i=()=>{this.canvasAnimation.forceStopAnimation(pe),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)yf(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 yf=(n,t)=>{if(!t.enabled)return!1;const e=Math.abs(n.y),s=fn(fn(Math.abs(n.x),2)+fn(e,2),.5),i=Math.abs(Math.acos(e/s));return e>t.yDiff&&i<t.edgeAngle},wf=2;class Sf 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=Po(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 Po=(n,t,e,s,i=wf)=>Math.sqrt(Math.pow(n-t,2)+Math.pow(e-s,2))>i,av={MAX_DIMENSION:2048,MAX_TOTAL_PIXELS:18e5,ZOOM_OPTIMIZED_PIXELS:12e5},xf=2e6,_f=24,Pf=20,Tf=16,Mf=10,Af=1e3,lv=5e4,cv={MIN:60,LOW:80,MEDIUM:100,HIGH:120,MAX:150};class Ef extends _o{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(Gr(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>xf?this.wheelThrottleTime=_f:this.wheelThrottleTime=Pf:this.wheelThrottleTime=Tf,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>Af&&(Math.round(this.wheelCount*1e3/(r-this.lastWheelTime))<Mf?(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 If 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=Ee?new Ef(...h):new _o(...h);this.chartAreaPanHandler=d,this.addChildEntity(this.chartAreaPanHandler),this.mainCanvasTouchHandler=new Sf(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 To=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}},Mo=(n,t)=>{const e=To(n);return{isHighLowActive:()=>!0,calculateHighLow:s=>{const i=t.calculateHighLow(s);return e(i)}}};function Df(){return Zn(1)}function Ao(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Df()(Ze(n,Ge(n)))}function pn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n);return N(function(s,i){(e?Ao(n,s,e):Ao(n,s)).subscribe(i)})}function Lf(n){return K(function(t,e){return n<=e})}class Of{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 Eo=8;class gn 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 H,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(pn(!1),K(this.dragPredicate),mt(),Lf(1)).subscribe(i=>{i?this.handleHoverAnimation("appearing"):this.handleHoverAnimation("fading")}))}const e=new Of(this.config,this.boundsProvider,this.canvasModel,this.canvasAnimation,this.animationId);this.drawingManager.addDrawer(e,Yr.paneResizer(this.id)),this.addSubscription(()=>this.drawingManager.removeDrawerByName(Yr.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 mn=1/32,Bf=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}`},Io=n=>n.match(/^\-?0*(\d+)'(\d{2})$/),hv=n=>!!Io(n),dv=n=>{const t=Io(n);if(t){const e=parseInt(t[1],10),i=parseInt(t[2],10)*mn;return e+i}return Number(n)},Rf=(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 Bf(s);const[r]=n.dataSeries;if(r!==void 0){const o=be.getPricePrecision(s,r.pricePrecisions);return s.toFixed(o)}return`${s}`},Ff=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=rr(t,r.getBaseline()));const o=Qe(i.toFixed(be.DEFAULT_PRECISION))+" %";return o===`${ni}0.00 %`?"0.00 %":o},Hf=(n,t)=>({percent:Ff(n),regular:Rf(n,t)});class kf extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u=new Set,f={regular:rh}){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:x,logarithmic:A}=this.formatters;switch(this.yAxis.getAxisType()){case"regular":return this.formatters.regular(p);case"percent":return x?x(p,m):_(p);case"logarithmic":return A?A(p):_(p);default:return this.regularFormatter(p)}},this.addChildEntity(c),this.setValueFormatters(Hf(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 ur(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 Do=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}:xr(r)}});class jf{constructor(t,e){this.panes=t,this.canvasModel=e,this.dataSeriesIdCounter=dn.DATA_SERIES[0],this.getNewDataSeriesHitTestId=()=>this.dataSeriesIdCounter++}getIdRange(){return dn.DATA_SERIES}get allDataSeries(){return De(De(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 Yf;const Gt="#FF00FF";function uv(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 Yf(i==="transparent"?c:i,t,e)}const Nf=(n,t)=>n==="down"?t.lastPrice.textNegative:n==="up"?t.lastPrice.textPositive:t.lastPrice.textSelected,Xf=(n,t)=>{const e=t.barTheme[`${n}Color`];return e!=null?e:Gt},Wf=(n,t)=>{const e=t.lineTheme[`${n}Color`];return e!=null?e:Gt},zf=(n,t)=>{const e=t.candleTheme[`${n}Color`];return e!=null?e:Gt},Vf=(n,t)=>{const e=t.areaTheme.lineColor;return e!=null?e:Gt},Uf=(n,t)=>{const e=t.scatterPlot.mainColor;return e!=null?e:Gt},Gf=(n,t)=>{const e=t.histogram[`${n}Bright`];return e!=null?e:Gt},Zf=(n,t)=>{const e=n==="up"?t.baseLineTheme.upperSectionStrokeColor:t.baseLineTheme.lowerSectionStrokeColor;return e!=null?e:Gt},Lo=(n,t)=>{const e=t.candleTheme[`${n}WickColor`];return e!=null?e:Gt},$f=()=>(console.warn("Fallback for label default color"),Gt),Oo=10;class Bo 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 H,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,Hi),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*(Oo-1)):d=1+h/this.lastYPxHeight*(Oo-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 Kf{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),si(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 qf=0,Jf=.01;class vn{constructor(t,e,s,i,r=!1,o,a,l=Ws,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 H,this.newGeneratedLabelsSubject=new H,this.lastStart=0,this.lastEnd=0,this.labelsCache=new Kf(()=>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=or(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=nn(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=vn.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?mn:be.autoDetectIncrementOfValueRange(t);return this.adjustIncrementOnAxisType(s)}return this.adjustIncrementOnAxisType(Jf)}adjustIncrementOnAxisType(t){switch(this.axisTypeProvider()){case"percent":return t;case"logarithmic":const[e]=this.calculateMinMax(),i=nn(e)+t;return ar(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)*(qf/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 Qf extends vn{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=xt(i.dataPoints),o=(e=r==null?void 0:r.close)!=null?e:0,a=vh(o,i.pricePrecisions),l=(s=this.treasuryFormat)!=null&&s.enabled?mn:a;return this.adjustIncrementOnAxisType(l)}return super.calculateIncrement(t)}}function Ro(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)}))}):se}class tp 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(wt(this.scale.yChanged,this.canvasBoundsContainer.observeBoundsChanged(M.PANE_UUID_Y_AXIS(this.paneUUID,this.extentIdx)).pipe(at(t=>t.height),K(t=>bl(t,this.prevYAxisHeight,1.5)),Ro(t=>{this.labelsGenerator.labelsCache.invalidate(),this.prevYAxisHeight=t}))).subscribe(()=>this.updateLabels()))}recalculateLabels(){const t=this.labelsGenerator.doGenerateLabels();this.labels=t,Te(this.animFrameId,()=>this.canvasBoundsContainer.updateYAxisWidths())}updateLabels(){Te(this.animFrameId,()=>{this.labels=this.labelsGenerator.generateNumericLabels(),this.canvasBoundsContainer.updateYAxisWidths()})}}class ep 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 Qf(null,l,o,a,()=>this.state.type,s.labelHeight,s),this.baseLabelsModel=new tp(o,this.labelsGenerator,this.canvasBoundsContainer,t,c),this.addChildEntity(this.baseLabelsModel),this.fancyLabelsModel=new zc(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 sp 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 H,this.axisAlignSetSubject=new H,this.axisAlignMovedSubject=new H,this.setDblClickCallback=A=>this.yAxisScaleHandler.setDblClickCallback(A),this.setDblTapCallback=A=>this.yAxisScaleHandler.setDblTapCallback(A);const x=_?oe(_):{};this.state=At(x,e.components.yAxis,{overrideExisting:!1,addIfMissing:!0}),this.yAxisScaleHandler=new Bo(t,this.state,l,r,o,a,a.getBoundsHitTest(M.PANE_UUID_Y_AXIS(u,f)),p),this.addChildEntity(this.yAxisScaleHandler),this.model=new ep(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 Bo(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",zf),this.registerLabelColorResolver("bar",Xf),this.registerLabelColorResolver("line",Wf),this.registerLabelColorResolver("area",Vf),this.registerLabelColorResolver("scatterPlot",Uf),this.registerLabelColorResolver("histogram",Gf),this.registerLabelColorResolver("baseline",Zf),this.registerLabelColorResolver("trend",Lo),this.registerLabelColorResolver("hollow",Lo)}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:$f}registerYAxisLabelsProvider(t,e=re.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=re.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 np extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,x,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=x,this.hitTestCanvasModel=A,this.chartResizeHandler=E,this.yExtentComponents=[],this.yExtentComponentsChangedSubject=new H,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 De(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(Wi)).subscribe(()=>{this.yExtentComponents.forEach(t=>t.scale.recalculateZoomY()),this.dynamicObjectsCanvasModel.fireDraw()})),this.uuid===$&&this.addRxSubscription(this.yAxis.axisTypeSetSubject.pipe(pn(this.yAxis.getAxisType()),mt(),at(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 vo(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 Uh(this.mainScale,this.config,o,this.canvasAnimation),l=t==null?void 0:t.initialYAxisState,[c,h]=this.createYPanHandler(this.uuid,a),d=(m,_)=>new sp(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",Mo(()=>({top:10,bottom:10,left:0,right:0,visible:!0}),Do(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=oe(s.yAxis.state),o=oe(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=ge(this.canvasBoundsContainer.panesOrder.filter(e=>this.canvasBoundsContainer.graphsHeightRatio[e]>0));return this.uuid!==t&&this.visible}canMoveDown(){const t=xt(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 ip=Object.defineProperty,rp=Object.defineProperties,op=Object.getOwnPropertyDescriptors,Fo=Object.getOwnPropertySymbols,ap=Object.prototype.hasOwnProperty,lp=Object.prototype.propertyIsEnumerable,Ho=(n,t,e)=>t in n?ip(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,cp=(n,t)=>{for(var e in t||(t={}))ap.call(t,e)&&Ho(n,e,t[e]);if(Fo)for(var e of Fo(t))lp.call(t,e)&&Ho(n,e,t[e]);return n},hp=(n,t)=>rp(n,op(t));class dp extends W{constructor(t,e,s,i,r,o,a,l,c,h,d,u,f,p,m,_,x){super(),this.chartBaseModel=t,this.dynamicObjectsCanvasModel=e,this.userInputListenerComponents=s,this.eventBus=i,this.mainScale=r,this.canvasBoundsContainer=o,this.config=a,this.canvasAnimation=l,this.canvasInputListener=c,this.drawingManager=h,this.cursorHandler=d,this.crossEventProducer=u,this.chartPanComponent=f,this.mainCanvasModel=p,this.yAxisLabelsCanvasModel=m,this.hitTestCanvasModel=_,this.chartResizeHandler=x,this.panes={},this.paneRemovedSubject=new H,this.paneAddedSubject=new H,this.dataSeriesAddedSubject=new H,this.dataSeriesRemovedSubject=new H,this.hitTestController=new jf(this.panes,this.dynamicObjectsCanvasModel);const A=this.createPane($,{useDefaultHighLow:!1,scale:this.mainScale});A.mainExtent.scale.autoScaleModel.setHighLowProvider("series",Do(A.mainExtent)),r.autoScaleModel.setHighLowPostProcessor("offsets",To(()=>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+Eo}),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 gn(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 De(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 np(this.chartBaseModel,this.mainCanvasModel,this.yAxisLabelsCanvasModel,this.dynamicObjectsCanvasModel,this.hitTestController,this.config,this.mainScale,this.drawingManager,this.chartPanComponent,this.canvasInputListener,this.canvasAnimation,this.cursorHandler,this.eventBus,this.canvasBoundsContainer,t,this.dataSeriesAddedSubject,this.dataSeriesRemovedSubject,this.hitTestCanvasModel,this.chartResizeHandler,e);return this.config.components.paneResizer.visible&&s.addChildEntity(this.addResizer(t)),s.addSubscription(this.addBounds(t,e==null?void 0:e.order)),s.addSubscription(this.addCursors(t)),s.addSubscription(this.crossEventProducer.subscribeMouseOverHT(t,s.ht)),this.panes[t]=s,s.activate(),this.recalculateState(),s.mainExtent.scale.autoScale(!0),this.paneAddedSubject.next(this.panes),s}movePaneUp(t){this.canvasBoundsContainer.movePaneUp(t)}movePaneDown(t){this.canvasBoundsContainer.movePaneDown(t)}canMovePaneUp(t){var e,s;const i=ge(this.canvasBoundsContainer.panesOrder.filter(r=>{var o,a;return(a=(o=this.panes[r])==null?void 0:o.visible)!=null?a:!1}));return t!==i&&((s=(e=this.panes[t])==null?void 0:e.visible)!=null?s:!1)}canMovePaneDown(t){var e,s;const i=xt(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 gn&&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 gn&&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?hp(cp({},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+Eo),()=>{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 up 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 fp=(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)},ko=class Ts 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[Ts.UUID]===void 0){const e=this.paneManager.createPane(Ts.UUID,{paneFormatters:{regular:r=>fp(r,1)},useDefaultHighLow:!1,increment:1});this.pane=e,e.mainExtent.yAxis.setAxisType("regular");const{scale:s}=e,i=Mo(()=>({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(Ts.UUID),delete this.pane}fromY(t){var e,s;return(s=(e=this.pane)==null?void 0:e.scale.fromY(t))!=null?s:0}};ko.UUID="volumes";let pp=ko;const bs=.3,gp=(n,t)=>{const e=t.barTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},mp=(n,t)=>{const e=t.volume[`${n}BarColor`];return Ft()(e).alpha(bs).toString()},vp=(n,t)=>{const e=t.lineTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},bn=(n,t)=>{const e=t.candleTheme[`${n}Color`];return Ft()(e).alpha(bs).toString()},bp=3;class Cp{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:mp;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=tn(s.toY(0))-u;this.drawVolume(t,r,h,u,d,f)}else{const u=l/bp;if(u<=0)return;const f=e/u;if(!isFinite(f)||f<=0)return;const p=Math.max(tn(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,tn(c)),a.stroke()):a.fillRect(s,i,r,o)}}const yp=Xl(n=>n.candle.volume),jo="volumes";class wp extends W{constructor(t,e){super(),this.chartComponent=t,this.scale=e,this.id=jo,this.volumeMax=new ut(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=ge(yp(e.flat())))!=null?t:0)}}class Sp 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 ut(!1),this.volumeIsSeparateModeChangedSubject=new ut(!1);const c=new wp(e,s);this.volumesModel=c,this.addChildEntity(c),this.separateVolumes=new pp(e,o,c,a),this.volumesDrawer=new Cp(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",bn),this.registerVolumeColorResolver("trend",bn),this.registerVolumeColorResolver("hollow",bn),this.registerVolumeColorResolver("line",vp),this.registerVolumeColorResolver("bar",gp)}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?jo:$,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 xp{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 x;switch(d?x=d:(u.font=Cs(this.config,l),x=u.measureText(a).width,f.width-10<x&&(u.font=_p(this.config,this.canvasBoundsContainer,l,x),x=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-x/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,x=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);x=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+_+x+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+x,h,d.thirdRowFontSize,u.thirdRowColor,B)),this.logoImage){const R=this.getConfig(p+_+m+A+x+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 _p=(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 Pp=Object.defineProperty,Yo=Object.getOwnPropertySymbols,Tp=Object.prototype.hasOwnProperty,Mp=Object.prototype.propertyIsEnumerable,No=(n,t,e)=>t in n?Pp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Xo=(n,t)=>{for(var e in t||(t={}))Tp.call(t,e)&&No(n,e,t[e]);if(Yo)for(var e of Yo(t))Mp.call(t,e)&&No(n,e,t[e]);return n};class Ap 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 xp(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 Xo(Xo({},this.config.components.waterMark),h)}}const Wo={x:4,y:4};function Ep(n,t,e,s){var i,r;const o=(i=s.alignType)!=null?i:"middle",{fontSize:a,fontFamily:l,padding:c}=e.components.xAxis,h=e.colors.xAxis,d=(r=c.top)!=null?r:0,u=t.getBounds(M.X_AXIS);n.save(),n.font=`bold ${a}px ${l}`;const p=n.measureText(s.text).width+Wo.x*2;let 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 x=m+Wo.x,A=u.y+d+a+Le/2;n.fillText(s.text,x,A),n.restore()}class Ip{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=>{Ep(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(),Lr(t,{x:r[0].x,y:o.y},{x:r[1].x,y:o.y+o.height})}})}getCanvasIds(){return[this.canvasModel.canvasId]}}const fv="week-weekday",Dp=["second","minute","hour","day","month","year"],Lp=["lessThanSecond"],Op=n=>Dp.some(t=>t===n),Bp=n=>n==="week-weekday",Rp=n=>Lp.some(t=>t===n),zo=n=>{const t={"!":!1,$:!1};return n.includes("!")&&(t["!"]=!0),n.includes("$")&&(t.$=!0),t},Cn=n=>parseInt(n,10),Vo=n=>{const[t,...e]=n.split("_");if(Op(t)){const[s]=e,i=zo(s),r=Cn(s);return{key:t,value:r,exact:i["!"]}}else if(Bp(t)){const[s,i]=e,r=zo(s),o=Cn(s),a=Cn(i);return{key:t,week:r.$?"$":o,weekday:a}}else return Rp(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+Le/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 yn={lessThanSecond:0,second:100,minute:200,hour:300,day:400,"week-weekday":500,month:600,year:1e4},Uo=n=>{switch(n.key){case"second":case"minute":case"hour":case"day":case"month":case"year":return yn[n.key]+n.value;case"lessThanSecond":return yn[n.key];case"week-weekday":return yn[n.key]+(n.week==="$"?9:n.week)+n.weekday*10}},Go=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},Fp=(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},Hp=(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},pv=7,kp=365.2425,mv=-(Math.pow(10,8)*24*60*60*1e3),vv=6048e5,bv=864e5,Cv=6e4,yv=36e5,wv=1e3,Sv=525600,xv=43200,_v=1440,Pv=60,Tv=3,Mv=12,Av=4,jp=3600,Ev=60,Zo=jp*24,Iv=Zo*7,Ov=Zo*kp/12*3,$o=Symbol.for("constructDateFrom");function wn(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&$o in n?n[$o](t):n instanceof Date?new n.constructor(t):new Date(t)}const Bv=null;function jt(n,t){return wn(t||n,n)}const Rv=null;function Yp(n,t){return jt(n,t==null?void 0:t.in).getDay()===1}const Fv=null;function Np(n,t){return jt(n,t==null?void 0:t.in).getDay()===2}const Hv=null;function Xp(n,t){return jt(n,t==null?void 0:t.in).getDay()===3}const kv=null;function Wp(n,t){return jt(n,t==null?void 0:t.in).getDay()===4}const jv=null;function zp(n,t){return jt(n,t==null?void 0:t.in).getDay()===5}const Yv=null;function Vp(n,t){return jt(n,t==null?void 0:t.in).getDay()===6}const Nv=null;function Up(n,t){return jt(n,t==null?void 0:t.in).getDay()===0}const Xv=null;function Ko(n,...t){const e=wn.bind(null,n||t.find(s=>typeof s=="object"));return t.map(e)}function Gp(n,t){const[e,s]=Ko(n,t.start,t.end);return{start:e,end:s}}function Zp(n,t){var c;const{start:e,end:s}=Gp(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(wn(e,o)),o.setDate(o.getDate()+a),o.setHours(0,0,0,0);return i?l.reverse():l}const Wv=null;function $p(n,t){const e=jt(n,t==null?void 0:t.in);return e.setDate(1),e.setHours(0,0,0,0),e}const zv=null;function Kp(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 Vv=null;function qo(n,t){const e=jt(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}const Uv=null;function Jo(n,t,e){const[s,i]=Ko(e==null?void 0:e.in,n,t);return+qo(s)==+qo(i)}const Gv=null,qp=n=>{switch(n.key){case"lessThanSecond":return eg(n);case"month":return sg(n);case"second":case"minute":case"hour":case"day":case"year":return ng(n);case"week-weekday":return ig(n);default:return()=>!1}},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()}},Sn=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s!==i},Jp=n=>(t,e)=>{const s=Qt(t,n),i=Qt(e,n);return s>=i},Qp={1:Yp,2:Np,3:Xp,4:Wp,5:zp,6:Vp,7:Up},tg=(n,t,e)=>{var s;const i=Zp({start:$p(n),end:Kp(n)}),r=(s=Qp[e])!=null?s:(()=>!1);if(t==="$"){for(const o of i.reverse())if(r(o))return Jo(n,o)}else{let o=1;for(const a of i)if(r(a)){if(o===t)return Jo(n,a);o++}}return!1},Qo=(n,t)=>t===1?n===1:n/t===1,ta=(n,t)=>t===1?!0:n%t===0,eg=n=>(t,e)=>Jp(n.key)(t,e),sg=n=>(t,e)=>{const s=Sn(n.key)(t,e),i=n.exact?Qo(Qt(t,n.key)+1,n.value):ta(Qt(t,n.key)+1,n.value);return s&&i},ng=n=>(t,e)=>{const s=Sn(n.key)(t,e),i=n.exact?Qo(Qt(t,n.key),n.value):ta(Qt(t,n.key),n.value);return s&&i},ig=n=>(t,e)=>{const s=Sn(n.key)(t,e),i=tg(t,n.week,n.weekday);return s&&i},rg=n=>{switch(n.key){case"second":case"minute":return og(n.value);case"hour":return ag(n.value);case"day":return lg(n.value);case"month":return dg(n.value);case"year":return ug(n.value);case"week-weekday":const t=hg(n.week),e=cg(n.weekday);return t&&e;case"lessThanSecond":return!0;default:return!1}},og=n=>n>0&&n<=60,ag=n=>n>0&&n<=24,lg=n=>n>0&&n<=31,cg=n=>ea(n)?n>=1&&n<=7:!1,hg=n=>n==="$"?!0:ea(n)?n>=1&&n<=6:!1,dg=n=>n>0&&n<=12,ug=n=>n>0,ea=n=>!isNaN(n)&&isFinite(n),fg=(n,t,e)=>{var s,i;for(const[r,o]of e)if(o(n,t))return r;return(i=(s=e[e.length-1])==null?void 0:s[0])!=null?i:0};function xn(n,t,e){const s=new Array(n.length);let i=e(0);for(let r=0;r<n.length;r++){const o=n[r],a=e(o.candle.timestamp),l={weight:fg(a,i,t)};s[r]=l,i=a}return s}const sa=n=>{const t={},e={};return en(n).forEach(([s,i])=>{const r=Vo(s),o=r===null?!1:rg(r);if(r&&o){const a=Uo(r);t[a]=i,e[a]=qp(r)}}),{weightToTimeFormatsDict:t,weightToTimeFormatMatcherDict:e}};class na{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((_,x)=>Math.max(x.length,_),1),m=f*p;return Math.round(m/u)},this.formatsByWeightMap=e.components.xAxis.formatsForLabelsConfig;const{weightToTimeFormatsDict:l,weightToTimeFormatMatcherDict:c}=sa(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]:rn(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)=>rn(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,x=Math.ceil(m/f)*f,A=[];for(let E=_;E<=x;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}=sa(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=xn([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=xn(e,this.weightToTimeFormatMatcherArray,this.timeZoneModel.tzOffset(this.config.timezone)),i=this.mapWeightedPointsToLabels(s,e),r=Go(i),o=oe(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=xn(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=Go(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=Fp(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];Hp(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=en(this.extendedLabelsFilterConfig).reduce((i,r)=>{if(!r)return i;const[o,a]=r;if(a){const l=Vo(o);if(l){const c=Uo(l);i[c]=a}}return i},{});return en(t).reduce((i,[r,o])=>(s[r]&&s[r](e)||(i[r]=o),i),{})}clearLabelCache(){this.labelCache.clear()}}class pg 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 ia=3;class gg 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*(ia-1)):d=1+c/this.lastXPxWidth*(ia-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 mg 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=x=>this.xAxisScaleHandler.setDblClickCallback(x),this.setDblTapCallback=x=>this.xAxisScaleHandler.setDblTapCallback(x);const m=new na(t,e,i.chartModel,r,h,this.canvasModel,o);this.xAxisLabelsGenerator=m,this.xAxisLabelsModel=new pg(t,[]);const _=new cn;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 Ip(e,s,o,this.xAxisLabelsModel),_.addDrawer(this.xAxisLabelsDrawer),this.xAxisScaleHandler=new gg(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),at(({prependedCandles:t})=>this.chartComponent.chartModel.mainCandleSeries.visualPoints.slice(0,t.length))).subscribe(t=>{var e,s;oc.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(at(()=>xt(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(di)).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(pn(this.yAxis.getAxisType()),mt(),at(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 na?this.xAxisLabelsGenerator.setFormatsForLabelsConfig(t):console.error("Format config for x-axis is not available")}isVisible(){var t,e;return(e=(t=this.config.components)==null?void 0:t.xAxis.visible)!=null?e:!1}}var vg=Object.defineProperty,ra=Object.getOwnPropertySymbols,bg=Object.prototype.hasOwnProperty,Cg=Object.prototype.propertyIsEnumerable,oa=(n,t,e)=>t in n?vg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ws=(n,t)=>{for(var e in t||(t={}))bg.call(t,e)&&oa(n,e,t[e]);if(ra)for(var e of ra(t))Cg.call(t,e)&&oa(n,e,t[e]);return n};class yg{constructor(t,e,s,i,r){this.chartModel=t,this.chartConfig=e,this.yAxisConfig=s,this.lastCandleLabelsByChartType=i,this.resolveLabelColorFn=r}getUnorderedLabels(){const t=[];if(!(this.yAxisConfig.labels.settings.lastPrice.mode!=="none"&&this.yAxisConfig.visible))return t;const s=this.getYAxisVisualLabel(this.chartModel.mainCandleSeries),i=s&&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=xt(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:ne("#FFFFFF","#000000",o),rounded:!0};const l=a(t.lastPriceMovement,t.colors);if(e){const h=t.config.type==="scatterPlot"?r:Nf(t.lastPriceMovement,i);return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ne(l,h,o),rounded:!0}}return{bgColor:l,textColor:s==="plain"?a(t.lastPriceMovement,t.colors):ne(l,r,o),rounded:!0}}}class wg{constructor(t,e,s,i,r,o){this.yAxisLabelsCanvasModel=t,this.yAxisDescriptionsCanvasModel=e,this.backgroundCanvasModel=s,this.canvasBoundsContainer=i,this.fullConfig=r,this.paneManager=o}draw(){const t=this.yAxisLabelsCanvasModel.ctx,e=this.backgroundCanvasModel.ctx,s=this.yAxisDescriptionsCanvasModel.ctx;this.paneManager.yExtents.forEach(i=>{if(i.yAxis.state.visible){const r=i.getYAxisBounds(),o=this.canvasBoundsContainer.getBounds(M.ALL_PANES),a=i.yAxis.model.fancyLabelsModel.orderedLabels;this.drawHighlightedBackgroundBetweenLabels(a),a.forEach(l=>{var c;const h=(c=l.bounds)!=null?c:r;l.labels.forEach(d=>ao(t,s,e,h,o,d,this.canvasBoundsContainer,i.yAxis.state,this.fullConfig.colors))}),Object.values(i.yAxis.model.fancyLabelsModel.customLabels).forEach(l=>ao(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];Lr(e,{x:h.x,y:Xi(d,h)},{x:h.x+h.width-6,y:Xi(u,h)}),e.restore()}}})})}getCanvasIds(){return[this.yAxisLabelsCanvasModel.canvasId]}}class Sg{constructor(t,e,s){this.fullConfig=t,this.canvasModel=e,this.paneManager=s}draw(){this.paneManager.yExtents.forEach(t=>{const e=t.yAxis;if(e.state.visible){const s=e.model.baseLabelsModel.labels,i=e.getBounds(),r=this.canvasModel.ctx;this.fullConfig.components.chart.applyBackgroundToAxes.y||(r.fillStyle=this.getBackgroundColor(),r.fillRect(i.x,i.y,i.width,i.height));const o=ie(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&&xg(t,s,u.text,f,i,r,a.state.labelBoxMargin.end,a.state.align)})}getCanvasIds(){return[this.canvasModel.canvasId]}getBackgroundColor(){return this.fullConfig.colors.yAxis.backgroundColor}getLabelTextColor(){return this.fullConfig.colors.yAxis.labelTextColor}}const xg=(n,t,e,s,i,r,o,a)=>{const l=a==="right"?t.x+t.width-Mt(e,n,r)-o:t.x+o;n.fillText(e,l,s+i/2-1)};class _g{constructor(){this.UNKNOWN_ARR=[],this.handlers={},this.muted=!1,this.unsub=(t,e)=>{const s=this.handlers[t];s!==void 0&&Yl.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 H,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 Pg extends W{constructor(t,e,s,i){super(),s.observeTouchStart().pipe(at(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 Tg{constructor(t,e,s,i,r){this.frameElement=t,this.resizerElement=e,this.bus=s,this.canvasModels=i,this.config=r,this.previousBCR=void 0,this.animFrameId=`resize_${St()}`,this.canvasResized=new H,this.recentlyResized=!1,this.elementResizeDetector=new ResizeObserver(()=>this.handleResize())}subscribeResize(){this.elementResizeDetector.observe(this.resizerElement)}handleResize(){Te(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 Mg=Array.isArray,Ag=Object.getPrototypeOf,Eg=Object.prototype,Ig=Object.keys;function Dg(n){if(n.length===1){var t=n[0];if(Mg(t))return{args:t,keys:null};if(Lg(t)){var e=Ig(t);return{args:e.map(function(s){return t[s]}),keys:e}}}return{args:n,keys:null}}function Lg(n){return n&&typeof n=="object"&&Ag(n)===Eg}var Og=Array.isArray;function Bg(n,t){return Og(t)?n.apply(void 0,ot([],F(t))):n(t)}function aa(n){return at(function(t){return Bg(n,t)})}function Rg(n,t){return n.reduce(function(e,s,i){return e[s]=t[i],e},{})}function Fg(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var e=Ge(n),s=rl(n),i=Dg(n),r=i.args,o=i.keys;if(r.length===0)return Ze([],e);var a=new gt(Hg(r,e,o?function(l){return Rg(o,l)}:se));return s?a.pipe(aa(s)):a}function Hg(n,t,e){return e===void 0&&(e=se),function(s){la(t,function(){for(var i=n.length,r=new Array(i),o=i,a=i,l=function(h){la(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 la(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 ut(null),this.crossToolHover=null,this.crossToolTouchInfo={fixed:{x:0,y:0},temp:{x:0,y:0},isSet:!1,isCommonTap:!1}}doActivate(){super.doActivate()}fireCrossClose(){this.crossSubject.next(null)}unsubscribeMouseOver(t){var e;(e=this.panesSubscriptions[t])==null||e.unsubscribe()}subscribeMouseOver(t,e,s){const i=e.map(o=>this.canvasBoundsContainer.getBoundsHitTest(o,s)),r=(o,a)=>i.some(l=>l(o,a));return this.subscribeMouseOverHT(t,r)}subscribeMouseOverHT(t,e){const s=this.canvasInputListener.observeMouseMoveDocument(),i=this.canvasInputListener.observeMouseEnter(e);let r=!1;const o=Fg([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 Yg{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 Ng{constructor(t){this.chartModel=t}getData(t){if(this.chartModel.candleSeries.length===1&&this.chartModel.candleSeries[0]instanceof Zr)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 Xg=Object.defineProperty,Wg=Object.defineProperties,zg=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,Vg=Object.prototype.hasOwnProperty,Ug=Object.prototype.propertyIsEnumerable,ha=(n,t,e)=>t in n?Xg(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,he=(n,t)=>{for(var e in t||(t={}))Vg.call(t,e)&&ha(n,e,t[e]);if(ca)for(var e of ca(t))Ug.call(t,e)&&ha(n,e,t[e]);return n},Xe=(n,t)=>Wg(n,zg(t));class Gg 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 ut(null),this.longTouchActivatedSubject=new ut(!1),this.longTouchCrosshairSuppressed=!1,this.xFormatter=()=>"";const d=new Yg(this.chartModel),u=new Ng(this.chartModel);this.hoverProducerParts={candleHover:d,compareSeriesHover:u}}get hover(){return this.hoverSubject.getValue()}doActivate(){super.doActivate(),this.addRxSubscription(this.chartModel.candlesSetSubject.pipe(So(()=>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&&e.candle.timestamp<=this.hover.timestamp&&this.updateHover(e)})),this.addRxSubscription(this.crossEventProducer.crossSubject.subscribe(e=>{e===null?this.hoverSubject.next(null):this.createAndFireHover(e)})),this.addRxSubscription(this.scale.xChanged.subscribe(()=>this.fireLastCross())),this.addRxSubscription(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&&!Po(m,p.x,_,p.y)){this.resetCrossTool();return}if(this.crossEventProducer.crossToolTouchInfo.isSet){const x=(c=(l=this.crossEventProducer.crossToolHover)==null?void 0:l.paneId)!=null?c:"CHART",A=this.canvasBoundsContainer.getBounds(M.PANE_UUID(x)),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(he({},X),{x:k,y:V,paneId:x}),this.crossEventProducer.crossSubject.next([k,V,x])}else{this.crossEventProducer.crossToolTouchInfo.isSet=!0;const x=this.crossEventProducer.crossToolHover,A=(s=x==null?void 0:x.x)!=null?s:m,E=(i=x==null?void 0:x.y)!=null?i:_;this.crossEventProducer.crossToolTouchInfo.temp={x:A,y:E},this.crossEventProducer.crossToolTouchInfo.fixed={x:A,y:E};const Y=(a=(o=x==null?void 0:x.paneId)!=null?o:(r=this.paneManager.getPaneIfHit({x:A,y:E}))==null?void 0:r.uuid)!=null?a:"",B=x!=null?x:this.hover;if(!B)return;this.crossEventProducer.crossToolHover=Xe(he({},B),{x:A,y:E,paneId:Y}),this.crossEventProducer.crossSubject.next([A,E,Y])}}))}recalculateCrossToolXFormatter(){const t=this.config.components.crossTool.xAxisLabelFormat;this.xFormatter=co(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(he({},l),{[c[0]]:c[1].getData(o)}),{});return he(he({},o),a)}createAndFireHoverFromCandle(t){const e=this.createHoverFromCandle(t);this.fireHover(e)}updateHover(t){var e,s;const i=this.createHoverFromCandle(t);if(this.hover&&i){const r=Ot()&&this.longTouchActivatedSubject.getValue()&&this.crossEventProducer.crossSubject.getValue()!==null,o=this.crossEventProducer.crossToolHover,a=r?(e=o==null?void 0:o.x)!=null?e:this.hover.x:this.hover.x,l=r?(s=o==null?void 0:o.y)!=null?s:this.hover.y:this.hover.y,c=Xe(he({},i),{x:a,y:l});this.fireHover(c)}}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.hoverSubject.next(t)}else 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(he({},this.hoverProducerParts),{[t]:e})}unregisterHoverProducerPart(t){delete this.hoverProducerParts[t]}}const da={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 xe(n){return t=>{t.button===da.left&&n(t)}}var Zg=["addListener","removeListener"],$g=["addEventListener","removeEventListener"],Kg=["on","off"];function _n(n,t,e,s){if(j(e)&&(s=e,e=void 0),s)return _n(n,t,e).pipe(aa(s));var i=F(Qg(n)?$g.map(function(a){return function(l){return n[a](t,l,e)}}):qg(n)?Zg.map(ua(n,t)):Jg(n)?Kg.map(ua(n,t)):[],2),r=i[0],o=i[1];if(!r&&Bs(n))return Fs(function(a){return _n(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 ua(n,t){return function(e){return function(s){return n[e](t,s)}}}function qg(n){return j(n.addListener)&&j(n.removeListener)}function Jg(n){return j(n.on)&&j(n.off)}function Qg(n){return j(n.addEventListener)&&j(n.removeEventListener)}var tm=Object.defineProperty,fa=Object.getOwnPropertySymbols,em=Object.prototype.hasOwnProperty,sm=Object.prototype.propertyIsEnumerable,pa=(n,t,e)=>t in n?tm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,nm=(n,t)=>{for(var e in t||(t={}))em.call(t,e)&&pa(n,e,t[e]);if(fa)for(var e of fa(t))sm.call(t,e)&&pa(n,e,t[e]);return n};const Ss=class ue extends W{constructor(t,e){super(),this.eventBus=t,this.element=e,this.xDragStartSubject=new H,this.xDragSubject=new H,this.xDragTickSubject=new H,this.xDragEndSubject=new H,this.yDragStartSubject=new H,this.yDragSubject=new H,this.yDragTickSubject=new H,this.yDragEndSubject=new H,this.mouseMoveSubject=new H,this.mouseMoveDocumentSubject=new H,this.clickSubject=new H,this.clickDocumentSubject=new H,this.dbClickSubject=new H,this.dbTapSubject=new H,this.mouseDownSubject=new H,this.mouseUpSubject=new H,this.mouseUpDocumentSubject=new H,this.wheelSubject=new H,this.touchStartSubject=new H,this.touchStartTimestamp=0,this.touchMoveSubject=new H,this.touchEndSubject=new H,this.touchCancelSubject=new H,this.longTouchStartSubject=new H,this.longTouchEndSubject=new H,this.contextMenuSubject=new H,this.fastTouchScroll=new H,this.mouseLeavesCanvasSubject=new H,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=ue.copyPoint(this.currentPoint),this.xDragStartSubject.next(this.dragStartPoint),this.yDragStartSubject.next(this.dragStartPoint),this.prevDragPoint=nm({},this.dragStartPoint),ue.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===da.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=[],ue.DRAG_START_EVENTS.forEach(s=>{this.element.addEventListener(s,this.dragStartListener),this.addSubscription(()=>this.element.removeEventListener(s,this.dragStartListener))}),this.trackMousePosition(),ue.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))}),ue.DRAG_END_EVENTS.forEach(s=>{document.addEventListener(s,this.dragEndListener),this.addSubscription(document.removeEventListener.bind(document,s,this.dragEndListener))}),this.addSubscription(Ct(this.element,xe(()=>this.clickSubject.next(this.currentPoint)),"click")),this.addSubscription(Ct(document,xe(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,xe(()=>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,xe(()=>this.mouseDownSubject.next(this.currentPoint)),"mousedown")),this.addSubscription(Ct(this.element,xe(()=>this.mouseUpSubject.next(this.currentPoint)),"mouseup")),this.addSubscription(Ct(document,xe(()=>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(_n(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(){ue.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)),at(()=>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)),at(()=>t(this.currentPoint.x,this.currentPoint.y))),i=this.observeMouseLeavesCanvas().pipe(at(()=>!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)),Ro(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 im=Ss;var rm=(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=qs);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})(H);const Pn={};function om(n){return Pn[n]||(Pn[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"})),Pn[n]}const ga=(n,t=Date.now())=>{const s=om(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},ma=60*1e3;class am{constructor(t){this.config=t,this.timeZoneChangedSubject=new rm,this.currentTzOffset=e=>ga(this.config.timezone,e)+new Date(e).getTimezoneOffset()*ma,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=Iu(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+ga(t,e)+new Date(e).getTimezoneOffset()*ma):e=>new Date(e)}}class lm 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 cm=Object.defineProperty,hm=Object.defineProperties,dm=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertySymbols,um=Object.prototype.hasOwnProperty,fm=Object.prototype.propertyIsEnumerable,ba=(n,t,e)=>t in n?cm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,pm=(n,t)=>{for(var e in t||(t={}))um.call(t,e)&&ba(n,e,t[e]);if(va)for(var e of va(t))fm.call(t,e)&&ba(n,e,t[e]);return n},gm=(n,t)=>hm(n,dm(t));class mm extends hi{constructor(t){super(t),this.animations={},this.animFrameId="animation",this.animationInProgressSubject=new ut(!1),this.microtaskQueued=!1}startViewportMovementAnimation(t,e,s=pe,i){const r=new oi(t,e,i);return this.animations[s]=r,this.processAnimation(),r}startColorAlphaAnimation(t,e,s,i){const r=new ii(gm(pm({},i),{duration:i&&i.duration||Ie}),e,s);return this.animations[t]=r,this.processAnimation(),r}startColorTransitionAnimation(t,e,s=Ie,i){const r=new ri({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(){gl(this.animFrameId),this.microtaskQueued=!1}}class Tn{constructor(t,e={}){this.components=[],this.chartComponents=[],this.userInputListenerComponents=[],this.canvasModels=[];var s,i;this.parentElement=t;const r=e;ac(r),this.config=r;const o=Mc(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 am(r);this.timeZoneModel=a;const l=this.timeZoneModel.getFormatterFactory(),c=Ac(t);this.elements=c;const h=new _g;this.bus=h;const d=new Tg(t,(i=c.chartResizer)!=null?i:t,h,this.canvasModels,r);this.chartResizeHandler=d,d.subscribeResize(),this.components.push(d.unsubscribeAnimationUpdate.bind(d));const u=new Pd(h,d);this.drawingManager=u;const f=xd(h,c.mainCanvas,c.chartResizer,this.config.components.chart.type,this.config,u,this.canvasModels);this.mainCanvasModel=f,this.dynamicObjectsCanvasModel=ce(h,c.dynamicObjectsCanvas,r,u,this.canvasModels,c.chartResizer);const p=new we(this.dynamicObjectsCanvasModel);u.addDrawer(p,"SERIES_CLEAR");const m=ce(h,c.yAxisLabelsCanvas,r,u,this.canvasModels,c.chartResizer),_=ce(h,c.yAxisDescriptionsCanvas,r,u,this.canvasModels,c.chartResizer),x=new Ks(r,h,f,l,d);this.canvasBoundsContainer=x;const A=c.mainCanvas.parentElement;if(A===null)throw new Error("Couldn't get main canvas parent");const E=new im(h,A);this.canvasInputListener=E,this.chartComponents.push(this.canvasInputListener);const Y=[h,c.hitTestCanvas,E,x,u,r,this.canvasModels,c.chartResizer],B=new zu(...Y);this.hitTestCanvasModel=B;const R=new we(B);u.addDrawer(R,"HIT_TEST_CLEAR");const k=Ee?new mm(h):new hi(h);this.canvasAnimation=k;const V=M.PANE_UUID($),X=new Ir(r,()=>x.getBounds(V),k);this.scaleModel=X;const G=ce(h,c.backgroundCanvas,r,u,this.canvasModels,c.chartResizer,{willReadFrequently:!0});this.backgroundCanvasModel=G,this.cursorHandler=new Pc(c.canvasArea,E,x,B),this.chartComponents.push(this.cursorHandler),this.crossEventProducer=new kg(E,x),this.chartComponents.push(this.crossEventProducer);const Z=new lh("candle");this.chartBaseModel=Z;const U=new If(h,X,x,r,k,E,A,Z,B);this.chartPanComponent=U,this.chartComponents.push(U),this.userInputListenerComponents.push(U.chartAreaPanHandler);const Q=new lm(B,k,h);this.hitTestComponent=Q,this.chartComponents.push(Q);const J=new dp(Z,this.dynamicObjectsCanvasModel,this.userInputListenerComponents,h,X,x,r,k,E,u,this.cursorHandler,this.crossEventProducer,U,f,m,this.hitTestCanvasModel,this.chartResizeHandler);this.paneManager=J;const et=this.paneManager.panes[$];this.mainPane=et,this.chartComponents.push(J),this.dynamicObjects=new Au(this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.dynamicObjects),this.chartModel=new ou(Z,J,h,this.dynamicObjectsCanvasModel,r,X,l,A,x,d);const tt=new Wd(this.chartModel,this.dynamicObjectsCanvasModel,r,X,x,u,B,E,G,U,J,this.cursorHandler,this.dynamicObjects,this.chartResizeHandler);this.chartComponents.push(tt),this.chartComponent=tt;const st=this.chartComponent.chartModel;this.chartModel=st,this.canvasBoundsContainer.setMainCandleSeries(this.chartModel.mainCandleSeries),B.addSubscriber(J.hitTestController),this.xAxisComponent=new mg(h,r,f,tt,X,x,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 ft=new we(f);u.addDrawer(ft,"MAIN_CLEAR");const ct=new Pg(A,st,E,r);this.chartComponents.push(ct),this.watermarkComponent=new Ap(J,st,h,r,x,this.dynamicObjectsCanvasModel,u),this.chartComponents.push(this.watermarkComponent);const _t=ce(h,c.crossToolCanvas,r,u,this.canvasModels,c.chartResizer);this.highlightsComponent=new hf(h,r,st,f,x,u),this.chartComponents.push(this.highlightsComponent),r.useUTCTimeOverride&&r.dateFormatter&&!r.dateFormatter.utcTimeOverride&&(r.dateFormatter.utcTimeOverride=this.createUTCTimeOverrideConfig(st)),this.navigationMapComponent=new Cf(h,st,f,r,E,x,u,l,U,this.cursorHandler),this.chartComponents.push(this.navigationMapComponent),this.userInputListenerComponents.push(this.navigationMapComponent.navigationMapMoveHandler);const Zt=new sf(r,this.dynamicObjectsCanvasModel,st,x,u);this.chartComponents.push(Zt),this.initYAxisDrawer(m,_),this.yAxisComponent=et.mainExtent.yAxis;const _e=new yg(this.chartModel,this.config,et.mainExtent.yAxis.state,this.chartModel.lastCandleLabelsByChartType,this.yAxisComponent.getLabelsColorResolver.bind(this.yAxisComponent));this.yAxisComponent.registerYAxisLabelsProvider(_e,re.MAIN),this.volumesComponent=new Sp(this.dynamicObjectsCanvasModel,tt,X,x,u,r,J,this.dynamicObjects),this.chartComponents.push(this.volumesComponent);const xa=new vo(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(xa),this.hoverProducer=new Gg(this.crossEventProducer,X,r,st,E,this.canvasBoundsContainer,this.paneManager,a,U.mainCanvasTouchHandler,l),this.chartComponents.push(this.hoverProducer),this.crossToolComponent=new _u(r,_t,x,u,J,this.crossEventProducer,this.hoverProducer,this.chartComponent.baselineModel,this.chartModel),this.chartComponents.push(this.crossToolComponent);const _a=ce(h,c.snapshotCanvas,r,u,this.canvasModels,c.chartResizer),Mn=new up(this.elements,_a);this.snapshotComponent=Mn,this.chartComponents.push(Mn);const _s=new Qu(r,this.dynamicObjectsCanvasModel,B,st,x,u,l,this.cursorHandler);this.eventsComponent=_s,this.chartComponents.push(_s),this.chartComponents.forEach(Ps=>Ps.activate()),this.enableUserControls(),u.reorderDrawers(r.drawingOrder),this.clearer=Bl(this.components)}initYAxisDrawer(t,e){const s=new cn,i=new we(t),r=new we(e);s.addDrawer(i,"YAXIS_CLEAR"),s.addDrawer(r,"Y_AXIS_DESCRIPTIONS_CLEAR"),this.drawingManager.addDrawer(s,"Y_AXIS");const o=new Sg(this.config,t,this.paneManager);s.addDrawer(o);const a=new wg(t,e,this.backgroundCanvasModel,this.canvasBoundsContainer,this.config,this.paneManager);this.drawingManager.addDrawer(a,"Y_AXIS_PRICE_LABELS")}createUTCTimeOverrideConfig(t){const e=new RegExp("HH|H|mm|m|s|ss|sss|SSS");return{pattern:"MM/dd/YY",test:s=>e.test(s)&&(t.getPeriod()||0)>=86400}}static mergeConfig(t,e){for(const s in e)s in t?typeof t[s]=="object"&&Tn.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 Ca extends Tn{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 vm=Object.defineProperty,bm=Object.defineProperties,Cm=Object.getOwnPropertyDescriptors,ya=Object.getOwnPropertySymbols,ym=Object.prototype.hasOwnProperty,wm=Object.prototype.propertyIsEnumerable,wa=(n,t,e)=>t in n?vm(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Sm=(n,t)=>{for(var e in t||(t={}))ym.call(t,e)&&wa(n,e,t[e]);if(ya)for(var e of ya(t))wm.call(t,e)&&wa(n,e,t[e]);return n},xm=(n,t)=>bm(n,Cm(t));function Sa(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(Tm(t[t.length-1],a,s)):d>3?t=t.concat(_m(t[t.length-1],a,r)):t=t.concat(Pm(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:Ti(0,l+c+i+r),hi:l,lo:c,open:i,close:r,timestamp:0,volume:0}}function _m(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 Pm(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 Tm(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=xm(Sm({},window.DXChart),{generateCandlesData:Sa});function Mm(n){return Sa(n)}const Am=((n,t={})=>new Ca(n,t))})(),window.DXChart=Ms})();})();