UNPKG

lightweight-charts

Version:

Financial lightweight charts built with HTML5 canvas

7 lines 139 kB
/*! * @license * TradingView Lightweight Charts v3.5.0 * Copyright (c) 2020 TradingView, Inc. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ import{bindToDevicePixelRatio as t}from"fancy-canvas/coordinate-space";var i,n;function h(t,i){var n,h=((n={})[0]=[],n[1]=[t.lineWidth,t.lineWidth],n[2]=[2*t.lineWidth,2*t.lineWidth],n[3]=[6*t.lineWidth,6*t.lineWidth],n[4]=[t.lineWidth,4*t.lineWidth],n)[i];t.setLineDash(h)}function s(t,i,n,h){t.beginPath();var s=t.lineWidth%2?.5:0;t.moveTo(n,i+s),t.lineTo(h,i+s),t.stroke()}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(n||(n={}));var r=function(t,i){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])})(t,i)};function e(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}r(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var i,n=1,h=arguments.length;n<h;n++)for(var s in i=arguments[n])Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s]);return t}).apply(this,arguments)};function a(t,i){for(var n=0,h=i.length,s=t.length;n<h;n++,s++)t[s]=i[n];return t}function o(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function l(t){if(void 0===t)throw new Error("Value is undefined");return t}function f(t){if(null===t)throw new Error("Value is null");return t}function c(t){return f(l(t))}function v(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];for(var h=0,s=i;h<s.length;h++){var r=s[h];for(var e in r)void 0!==r[e]&&("object"!=typeof r[e]||void 0===t[e]?t[e]=r[e]:v(t[e],r[e]))}return t}function _(t){return"number"==typeof t&&isFinite(t)}function d(t){return"number"==typeof t&&t%1==0}function w(t){return"string"==typeof t}function M(t){return"boolean"==typeof t}function b(t){var i,n,h,s=t;if(!s||"object"!=typeof s)return s;for(n in i=Array.isArray(s)?[]:{},s)s.hasOwnProperty(n)&&(h=s[n],i[n]=h&&"object"==typeof h?b(h):h);return i}function m(t){return null!==t}function g(t){return null===t?void 0:t}var p=function(){function t(){this.t=[]}return t.prototype.i=function(t){this.t=t},t.prototype.h=function(t,i,n,h){this.t.forEach((function(s){t.save(),s.h(t,i,n,h),t.restore()}))},t}(),y=function(){function t(){}return t.prototype.h=function(t,i,n,h){t.save(),t.scale(i,i),this.u(t,n,h),t.restore()},t.prototype.o=function(t,i,n,h){t.save(),t.scale(i,i),this.l(t,n,h),t.restore()},t.prototype.l=function(t,i,n){},t}(),k=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.v=null,i}return e(i,t),i.prototype._=function(t){this.v=t},i.prototype.u=function(t){if(null!==this.v&&null!==this.v.M){var i=this.v.M,n=this.v,h=function(h){t.beginPath();for(var s=i.to-1;s>=i.from;--s){var r=n.m[s];t.moveTo(r.g,r.p),t.arc(r.g,r.p,h,0,2*Math.PI)}t.fill()};t.fillStyle=n.k,h(n.N+2),t.fillStyle=n.S,h(n.N)}},i}(y);var x={from:0,to:1},N=function(){function t(t,i){this.C=new p,this.D=[],this.T=[],this.B=!0,this.L=t,this.A=i,this.C.i(this.D)}return t.prototype.V=function(t){var i=this,n=this.L.O();n.length!==this.D.length&&(this.T=n.map((function(){return{m:[{g:0,p:0,P:0,F:0}],S:"",k:i.L.I().layout.backgroundColor,N:0,M:null}})),this.D=this.T.map((function(t){var i=new k;return i._(t),i})),this.C.i(this.D)),this.B=!0},t.prototype.W=function(t,i,n){return this.B&&(this.R(),this.B=!1),this.C},t.prototype.R=function(){var t=this,i=this.L.O(),n=this.A.j(),h=this.L.U();i.forEach((function(i,s){var r=t.T[s],e=i.q(n);if(null!==e&&i.H()){var u=f(i.Y());r.S=e.K,r.k=e.$,r.N=e.N,r.m[0].F=e.F,r.m[0].p=i.Z().X(e.F,u.J),r.m[0].P=n,r.m[0].g=h.G(n),r.M=x}else r.M=null}))},t}(),S=function(){function t(t){this.tt=t}return t.prototype.h=function(t,i,n,r){if(null!==this.tt){var e=this.tt.it.H,u=this.tt.nt.H;if(e||u){t.save();var a=Math.round(this.tt.g*i),o=Math.round(this.tt.p*i),l=Math.ceil(this.tt.ht*i),f=Math.ceil(this.tt.st*i);t.lineCap="butt",e&&a>=0&&(t.lineWidth=Math.floor(this.tt.it.rt*i),t.strokeStyle=this.tt.it.et,t.fillStyle=this.tt.it.et,h(t,this.tt.it.ut),function(t,i,n,h){t.beginPath();var s=t.lineWidth%2?.5:0;t.moveTo(i+s,n),t.lineTo(i+s,h),t.stroke()}(t,a,0,f)),u&&o>=0&&(t.lineWidth=Math.floor(this.tt.nt.rt*i),t.strokeStyle=this.tt.nt.et,t.fillStyle=this.tt.nt.et,h(t,this.tt.nt.ut),s(t,o,0,l)),t.restore()}}},t}(),C=function(){function t(t){this.B=!0,this.at={it:{rt:1,ut:0,et:"",H:!1},nt:{rt:1,ut:0,et:"",H:!1},ht:0,st:0,g:0,p:0},this.ot=new S(this.at),this.lt=t}return t.prototype.V=function(){this.B=!0},t.prototype.W=function(t,i){return this.B&&(this.R(),this.B=!1),this.ot},t.prototype.R=function(){var t=this.lt.H(),i=f(this.lt.ft()),n=i.ct().I().crosshair,h=this.at;h.nt.H=t&&this.lt.vt(i),h.it.H=t&&this.lt._t(),h.nt.rt=n.horzLine.width,h.nt.ut=n.horzLine.style,h.nt.et=n.horzLine.color,h.it.rt=n.vertLine.width,h.it.ut=n.vertLine.style,h.it.et=n.vertLine.color,h.ht=i.dt(),h.st=i.wt(),h.g=this.lt.Mt(),h.p=this.lt.bt()},t}(),D={khaki:"#f0e68c",azure:"#f0ffff",aliceblue:"#f0f8ff",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",gray:"#808080",green:"#008000",honeydew:"#f0fff0",floralwhite:"#fffaf0",lightblue:"#add8e6",lightcoral:"#f08080",lemonchiffon:"#fffacd",hotpink:"#ff69b4",lightyellow:"#ffffe0",greenyellow:"#adff2f",lightgoldenrodyellow:"#fafad2",limegreen:"#32cd32",linen:"#faf0e6",lightcyan:"#e0ffff",magenta:"#f0f",maroon:"#800000",olive:"#808000",orange:"#ffa500",oldlace:"#fdf5e6",mediumblue:"#0000cd",transparent:"#0000",lime:"#0f0",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",midnightblue:"#191970",orchid:"#da70d6",mediumorchid:"#ba55d3",mediumturquoise:"#48d1cc",orangered:"#ff4500",royalblue:"#4169e1",powderblue:"#b0e0e6",red:"#f00",coral:"#ff7f50",turquoise:"#40e0d0",white:"#fff",whitesmoke:"#f5f5f5",wheat:"#f5deb3",teal:"#008080",steelblue:"#4682b4",bisque:"#ffe4c4",aquamarine:"#7fffd4",aqua:"#0ff",sienna:"#a0522d",silver:"#c0c0c0",springgreen:"#00ff7f",antiquewhite:"#faebd7",burlywood:"#deb887",brown:"#a52a2a",beige:"#f5f5dc",chocolate:"#d2691e",chartreuse:"#7fff00",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cadetblue:"#5f9ea0",tomato:"#ff6347",fuchsia:"#f0f",blue:"#00f",salmon:"#fa8072",blanchedalmond:"#ffebcd",slateblue:"#6a5acd",slategray:"#708090",thistle:"#d8bfd8",tan:"#d2b48c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",blueviolet:"#8a2be2",black:"#000",darkmagenta:"#8b008b",darkslateblue:"#483d8b",darkkhaki:"#bdb76b",darkorchid:"#9932cc",darkorange:"#ff8c00",darkgreen:"#006400",darkred:"#8b0000",dodgerblue:"#1e90ff",darkslategray:"#2f4f4f",dimgray:"#696969",deepskyblue:"#00bfff",firebrick:"#b22222",forestgreen:"#228b22",indigo:"#4b0082",ivory:"#fffff0",lavenderblush:"#fff0f5",feldspar:"#d19275",indianred:"#cd5c5c",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightskyblue:"#87cefa",lightslategray:"#789",lightslateblue:"#8470ff",snow:"#fffafa",lightseagreen:"#20b2aa",lightsalmon:"#ffa07a",darksalmon:"#e9967a",darkviolet:"#9400d3",mediumpurple:"#9370d8",mediumaquamarine:"#66cdaa",skyblue:"#87ceeb",lavender:"#e6e6fa",lightsteelblue:"#b0c4de",mediumvioletred:"#c71585",mintcream:"#f5fffa",navajowhite:"#ffdead",navy:"#000080",olivedrab:"#6b8e23",palevioletred:"#d87093",violetred:"#d02090",yellow:"#ff0",yellowgreen:"#9acd32",lawngreen:"#7cfc00",pink:"#ffc0cb",paleturquoise:"#afeeee",palegoldenrod:"#eee8aa",darkolivegreen:"#556b2f",darkseagreen:"#8fbc8f",darkturquoise:"#00ced1",peachpuff:"#ffdab9",deeppink:"#ff1493",violet:"#ee82ee",palegreen:"#98fb98",mediumseagreen:"#3cb371",peru:"#cd853f",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",purple:"#800080",seagreen:"#2e8b57",seashell:"#fff5ee",papayawhip:"#ffefd5",mediumslateblue:"#7b68ee",plum:"#dda0dd",mediumspringgreen:"#00fa9a"};function T(t){return t<0?0:t>255?255:Math.round(t)||0}var B=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i,E=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i,L=/^rgb\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*\)$/,A=/^rgba\(\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?\d{1,10})\s*,\s*(-?[\d]{0,10}(?:\.\d+)?)\s*\)$/;function V(t){var i,n=function(t){var i;if((t=t.toLowerCase())in D&&(t=D[t]),i=A.exec(t)||L.exec(t))return[T(parseInt(i[1],10)),T(parseInt(i[2],10)),T(parseInt(i[3],10))];if(i=E.exec(t))return[T(parseInt(i[1],16)),T(parseInt(i[2],16)),T(parseInt(i[3],16))];if(i=B.exec(t))return[T(17*parseInt(i[1],16)),T(17*parseInt(i[2],16)),T(17*parseInt(i[3],16))];throw new Error("Cannot parse color: "+t)}(t);return{gt:"rgb("+n[0]+", "+n[1]+", "+n[2]+")",yt:(i=n,.199*i[0]+.687*i[1]+.114*i[2]>160?"black":"white")}}function O(t,i,n,h,s,r){t.fillRect(i+r,n,h-2*r,r),t.fillRect(i+r,n+s-r,h-2*r,r),t.fillRect(i,n,r,s),t.fillRect(i+h-r,n,r,s)}function z(t,i,n){t.save(),t.scale(i,i),n(),t.restore()}function P(t,i,n,h,s,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,h,s),t.restore()}var F,I=function(){function t(t,i){this._(t,i)}return t.prototype._=function(t,i){this.tt=t,this.kt=i},t.prototype.h=function(t,i,n,h,s,r){if(this.tt.H){t.font=i.xt;var e=this.tt.Nt||!this.tt.St?i.Ct:0,u=i.Dt,a=i.Tt,o=i.Bt,l=i.Et,f=i.Lt,c=this.tt.At,v=Math.ceil(n.Vt(t,c)),_=i.Ot,d=i.zt+a+o,w=Math.ceil(.5*d),M=u+v+l+f+e,b=this.kt.Pt;this.kt.Ft&&(b=this.kt.Ft);var m,g,p=(b=Math.round(b))-w,y=p+d,k="right"===s,x=k?h:0,N=Math.ceil(h*r),S=x;if(t.fillStyle=this.kt.gt,t.lineWidth=1,t.lineCap="butt",c){k?(m=x-e,g=(S=x-M)+f):(S=x+M,m=x+e,g=x+u+e+l);var C=Math.max(1,Math.floor(r)),D=Math.max(1,Math.floor(u*r)),T=k?N:0,B=Math.round(p*r),E=Math.round(S*r),L=Math.round(b*r)-Math.floor(.5*r),A=L+C+(L-B),V=Math.round(m*r);t.save(),t.beginPath(),t.moveTo(T,B),t.lineTo(E,B),t.lineTo(E,A),t.lineTo(T,A),t.fill(),t.fillStyle=this.tt.$,t.fillRect(k?N-D:0,B,D,A-B),this.tt.Nt&&(t.fillStyle=this.kt.et,t.fillRect(T,L,V-T,C)),t.textAlign="left",t.fillStyle=this.kt.et,z(t,r,(function(){t.fillText(c,g,y-o-_)})),t.restore()}}},t.prototype.wt=function(t,i){return this.tt.H?t.zt+t.Tt+t.Bt:0},t}(),W=function(){function t(t){this.It={Pt:0,et:"#FFF",gt:"#000"},this.Wt={At:"",H:!1,Nt:!0,St:!1,$:""},this.Rt={At:"",H:!1,Nt:!1,St:!0,$:""},this.B=!0,this.jt=new(t||I)(this.Wt,this.It),this.Ut=new(t||I)(this.Rt,this.It)}return t.prototype.At=function(){return this.Wt.At},t.prototype.Pt=function(){return this.qt(),this.It.Pt},t.prototype.V=function(){this.B=!0},t.prototype.wt=function(t,i){return void 0===i&&(i=!1),Math.max(this.jt.wt(t,i),this.Ut.wt(t,i))},t.prototype.Ht=function(){return this.It.Ft||0},t.prototype.Yt=function(t){this.It.Ft=t},t.prototype.Kt=function(){return this.qt(),this.Wt.H||this.Rt.H},t.prototype.$t=function(){return this.qt(),this.Wt.H},t.prototype.W=function(t){return this.qt(),this.Wt.Nt=this.Wt.Nt&&t.I().drawTicks,this.Rt.Nt=this.Rt.Nt&&t.I().drawTicks,this.jt._(this.Wt,this.It),this.Ut._(this.Rt,this.It),this.jt},t.prototype.Xt=function(){return this.qt(),this.jt._(this.Wt,this.It),this.Ut._(this.Rt,this.It),this.Ut},t.prototype.qt=function(){this.B&&(this.Wt.Nt=!0,this.Rt.Nt=!1,this.Zt(this.Wt,this.Rt,this.It))},t}(),R=function(t){function i(i,n,h){var s=t.call(this)||this;return s.lt=i,s.Jt=n,s.Gt=h,s}return e(i,t),i.prototype.Zt=function(t,i,n){t.H=!1;var h=this.lt.I().horzLine;if(h.labelVisible){var s=this.Jt.Y();if(this.lt.H()&&!this.Jt.Qt()&&null!==s){var r=V(h.labelBackgroundColor);n.gt=r.gt,n.et=r.yt;var e=this.Gt(this.Jt);n.Pt=e.Pt,t.At=this.Jt.ti(e.F,s),t.H=!0}}},i}(W),j=/[1-9]/g,U=function(){function t(){this.tt=null}return t.prototype._=function(t){this.tt=t},t.prototype.h=function(t,i,n){var h=this;if(null!==this.tt&&!1!==this.tt.H&&0!==this.tt.At.length){t.font=i.xt;var s=Math.round(i.ii.Vt(t,this.tt.At,j));if(!(s<=0)){t.save();var r=i.ni,e=s+2*r,u=e/2,a=this.tt.dt,o=this.tt.Pt,l=Math.floor(o-u)+.5;l<0?(o+=Math.abs(0-l),l=Math.floor(o-u)+.5):l+e>a&&(o-=Math.abs(a-(l+e)),l=Math.floor(o-u)+.5);var c=l+e,v=0+i.Dt+i.Tt+i.zt+i.Bt;t.fillStyle=this.tt.gt;var _=Math.round(l*n),d=Math.round(0*n),w=Math.round(c*n),M=Math.round(v*n);t.fillRect(_,d,w-_,M-d);var b=Math.round(this.tt.Pt*n),m=d,g=Math.round((m+i.Dt+i.Ct)*n);t.fillStyle=this.tt.et;var p=Math.max(1,Math.floor(n)),y=Math.floor(.5*n);t.fillRect(b-y,m,p,g-m);var k=v-i.Ot-i.Bt;t.textAlign="left",t.fillStyle=this.tt.et,z(t,n,(function(){t.fillText(f(h.tt).At,l+r,k)})),t.restore()}}},t}(),q=function(){function t(t,i,n){this.B=!0,this.ot=new U,this.at={H:!1,gt:"#4c525e",et:"white",At:"",dt:0,Pt:NaN},this.A=t,this.hi=i,this.Gt=n}return t.prototype.V=function(){this.B=!0},t.prototype.W=function(){return this.B&&(this.R(),this.B=!1),this.ot._(this.at),this.ot},t.prototype.R=function(){var t=this.at;t.H=!1;var i=this.A.I().vertLine;if(i.labelVisible){var n=this.hi.U();if(!n.Qt()){var h=n.si(this.A.j());t.dt=n.dt();var s=this.Gt();if(s.P){t.Pt=s.Pt,t.At=n.ri(f(h)),t.H=!0;var r=V(i.labelBackgroundColor);t.gt=r.gt,t.et=r.yt}}}},t}(),H=function(){function t(){this.ei=null,this.ui=0}return t.prototype.ai=function(){return this.ui},t.prototype.oi=function(t){this.ui=t},t.prototype.Z=function(){return this.ei},t.prototype.li=function(t){this.ei=t},t.prototype.fi=function(t,i){return[]},t.prototype.ci=function(t){return[]},t.prototype.vi=function(){return[]},t.prototype.H=function(){return!0},t}();!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet"}(F||(F={}));var Y=function(t){function i(i,n){var h=t.call(this)||this;h._i=null,h.di=NaN,h.wi=0,h.Mi=!0,h.bi=new Map,h.mi=!1,h.gi=NaN,h.pi=NaN,h.yi=NaN,h.ki=NaN,h.hi=i,h.xi=n,h.Ni=new N(i,h);var s,r;h.Si=(s=function(){return h.di},r=function(){return h.pi},function(t){var i=r(),n=s();if(t===f(h._i).Ci())return{F:n,Pt:i};var e=f(t.Y());return{F:t.Di(i,e),Pt:i}});var e=function(t,i){return function(){return{P:h.hi.U().si(t()),Pt:i()}}}((function(){return h.wi}),(function(){return h.Mt()}));return h.Ti=new q(h,i,e),h.Bi=new C(h),h}return e(i,t),i.prototype.I=function(){return this.xi},i.prototype.Ei=function(t,i){this.yi=t,this.ki=i},i.prototype.Li=function(){this.yi=NaN,this.ki=NaN},i.prototype.Ai=function(){return this.yi},i.prototype.Vi=function(){return this.ki},i.prototype.Oi=function(t,i,n){this.mi||(this.mi=!0),this.Mi=!0,this.zi(t,i,n)},i.prototype.j=function(){return this.wi},i.prototype.Mt=function(){return this.gi},i.prototype.bt=function(){return this.pi},i.prototype.H=function(){return this.Mi},i.prototype.Pi=function(){this.Mi=!1,this.Fi(),this.di=NaN,this.gi=NaN,this.pi=NaN,this._i=null,this.Li()},i.prototype.ci=function(t){return null!==this._i?[this.Bi,this.Ni]:[]},i.prototype.vt=function(t){return t===this._i&&this.xi.horzLine.visible},i.prototype._t=function(){return this.xi.vertLine.visible},i.prototype.fi=function(t,i){this.Mi&&this._i===t||this.bi.clear();var n=[];return this._i===t&&n.push(this.Ii(this.bi,i,this.Si)),n},i.prototype.vi=function(){return this.Mi?[this.Ti]:[]},i.prototype.ft=function(){return this._i},i.prototype.Wi=function(){this.Bi.V(),this.bi.forEach((function(t){return t.V()})),this.Ti.V(),this.Ni.V()},i.prototype.Ri=function(t){return t&&!t.Ci().Qt()?t.Ci():null},i.prototype.zi=function(t,i,n){this.ji(t,i,n)&&this.Wi()},i.prototype.ji=function(t,i,n){var h=this.gi,s=this.pi,r=this.di,e=this.wi,u=this._i,a=this.Ri(n);this.wi=t,this.gi=isNaN(t)?NaN:this.hi.U().G(t),this._i=n;var o=null!==a?a.Y():null;return null!==a&&null!==o?(this.di=i,this.pi=a.X(i,o)):(this.di=NaN,this.pi=NaN),h!==this.gi||s!==this.pi||e!==this.wi||r!==this.di||u!==this._i},i.prototype.Fi=function(){var t=this.hi.O().map((function(t){return t.qi().Ui()})).filter(m),i=0===t.length?null:Math.max.apply(Math,t);this.wi=null!==i?i:NaN},i.prototype.Ii=function(t,i,n){var h=t.get(i);return void 0===h&&(h=new R(this,i,n),t.set(i,h)),h},i}(H),K=".";function $(t,i){if(!_(t))return"n/a";if(!d(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}var X=function(){function t(t,i){if(i||(i=1),_(t)&&d(t)||(t=100),t<0)throw new TypeError("invalid base");this.Jt=t,this.Hi=i,this.Yi()}return t.prototype.format=function(t){var i=t<0?"−":"";return t=Math.abs(t),i+this.Ki(t)},t.prototype.Yi=function(){if(this.$i=0,this.Jt>0&&this.Hi>0)for(var t=this.Jt;t>1;)t/=10,this.$i++},t.prototype.Ki=function(t){var i=this.Jt/this.Hi,n=Math.floor(t),h="",s=void 0!==this.$i?this.$i:NaN;if(i>1){var r=+(Math.round(t*i)-n*i).toFixed(this.$i);r>=i&&(r-=i,n+=1),h=K+$(+r.toFixed(this.$i)*this.Hi,s)}else n=Math.round(n*i)/i,s>0&&(h=K+$(0,s));return n.toFixed(0)+h},t}(),Z=function(t){function i(i){return void 0===i&&(i=100),t.call(this,i)||this}return e(i,t),i.prototype.format=function(i){return t.prototype.format.call(this,i)+"%"},i}(X),J=function(){function t(){this.Xi=[]}return t.prototype.Zi=function(t,i,n){var h={Ji:t,Gi:i,Qi:!0===n};this.Xi.push(h)},t.prototype.tn=function(t){var i=this.Xi.findIndex((function(i){return t===i.Ji}));i>-1&&this.Xi.splice(i,1)},t.prototype.nn=function(t){this.Xi=this.Xi.filter((function(i){return i.Gi===t}))},t.prototype.hn=function(t,i){var n=a([],this.Xi);this.Xi=this.Xi.filter((function(t){return!t.Qi})),n.forEach((function(n){return n.Ji(t,i)}))},t.prototype.sn=function(){return this.Xi.length>0},t.prototype.rn=function(){this.Xi=[]},t}(),G=function(){function t(t,i){this.en=t,this.un=i}return t.prototype.an=function(t){return null!==t&&(this.en===t.en&&this.un===t.un)},t.prototype.on=function(){return new t(this.en,this.un)},t.prototype.ln=function(){return this.en},t.prototype.fn=function(){return this.un},t.prototype.cn=function(){return this.un-this.en},t.prototype.Qt=function(){return this.un===this.en||Number.isNaN(this.un)||Number.isNaN(this.en)},t.prototype.vn=function(i){return null===i?this:new t(Math.min(this.ln(),i.ln()),Math.max(this.fn(),i.fn()))},t.prototype._n=function(t){if(_(t)&&0!==this.un-this.en){var i=.5*(this.un+this.en),n=this.un-i,h=this.en-i;n*=t,h*=t,this.un=i+n,this.en=i+h}},t.prototype.dn=function(t){_(t)&&(this.un+=t,this.en+=t)},t.prototype.wn=function(){return{minValue:this.en,maxValue:this.un}},t.Mn=function(i){return null===i?null:new t(i.minValue,i.maxValue)},t}();function Q(t,i,n){return Math.min(Math.max(t,i),n)}function tt(t,i,n){return i-t<=n}function it(t){return t<=0?NaN:Math.log(t)/Math.log(10)}function nt(t){var i=Math.ceil(t);return i%2!=0?i-1:i}function ht(t){var i=Math.ceil(t);return i%2==0?i-1:i}function st(t,i){var n=100*(t-i)/i;return i<0?-n:n}function rt(t,i){var n=st(t.ln(),i),h=st(t.fn(),i);return new G(n,h)}function et(t,i){var n=100*(t-i)/i+100;return i<0?-n:n}function ut(t,i){var n=et(t.ln(),i),h=et(t.fn(),i);return new G(n,h)}function at(t){var i=Math.abs(t);if(i<1e-8)return 0;var n=it(i+1e-4)+4;return t<0?-n:n}function ot(t){var i=Math.abs(t);if(i<1e-8)return 0;var n=Math.pow(10,i-4)-1e-4;return t<0?-n:n}function lt(t){if(null===t)return null;var i=at(t.ln()),n=at(t.fn());return new G(i,n)}var ft,ct=function(){function t(t,i){if(this.bn=t,this.mn=i,function(t){if(t<0)return!1;for(var i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.bn))this.gn=[2,2.5,2];else{this.gn=[];for(var n=this.bn;1!==n;){if(n%2==0)this.gn.push(2),n/=2;else{if(n%5!=0)throw new Error("unexpected base");this.gn.push(2,2.5),n/=5}if(this.gn.length>100)throw new Error("something wrong with base")}}}return t.prototype.pn=function(t,i,n){for(var h,s,r,e=0===this.bn?0:1/this.bn,u=1e-9,a=Math.pow(10,Math.max(0,Math.ceil(it(t-i)))),o=0,l=this.mn[0];;){var f=tt(a,e,u)&&a>e+u,c=tt(a,n*l,u),v=tt(a,1,u);if(!(f&&c&&v))break;a/=l,l=this.mn[++o%this.mn.length]}if(a<=e+u&&(a=e),a=Math.max(1,a),this.gn.length>0&&(h=a,s=1,r=u,Math.abs(h-s)<r))for(o=0,l=this.gn[0];tt(a,n*l,u)&&a>e+u;)a/=l,l=this.gn[++o%this.gn.length];return a},t}(),vt=function(){function t(t,i,n,h){this.yn=[],this.Jt=t,this.bn=i,this.kn=n,this.xn=h}return t.prototype.pn=function(t,i){if(t<i)throw new Error("high < low");var n=this.Jt.wt(),h=(t-i)*this.Nn()/n,s=new ct(this.bn,[2,2.5,2]),r=new ct(this.bn,[2,2,2.5]),e=new ct(this.bn,[2.5,2,2]),u=[];return u.push(s.pn(t,i,h),r.pn(t,i,h),e.pn(t,i,h)),function(t){if(t.length<1)throw Error("array is empty");for(var i=t[0],n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(u)},t.prototype.Sn=function(){var t=this.Jt,i=t.Y();if(null!==i){var n=t.wt(),h=this.kn(n-1,i),s=this.kn(0,i),r=this.Jt.I().entireTextOnly?this.Cn()/2:0,e=r,u=n-1-r,a=Math.max(h,s),o=Math.min(h,s);if(a!==o){for(var l=this.pn(a,o),f=a%l,c=a>=o?1:-1,v=null,_=0,d=a-(f+=f<0?l:0);d>o;d-=l){var w=this.xn(d,i,!0);null!==v&&Math.abs(w-v)<this.Nn()||(w<e||w>u||(_<this.yn.length?(this.yn[_].Dn=w,this.yn[_].Tn=t.Bn(d)):this.yn.push({Dn:w,Tn:t.Bn(d)}),_++,v=w,t.En()&&(l=this.pn(d*c,o))))}this.yn.length=_}else this.yn=[]}else this.yn=[]},t.prototype.Ln=function(){return this.yn},t.prototype.Cn=function(){return this.Jt.zt()},t.prototype.Nn=function(){return Math.ceil(2.5*this.Cn())},t}();function _t(t){return t.slice().sort((function(t,i){return f(t.ai())-f(i.ai())}))}!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(ft||(ft={}));var dt,wt=new Z,Mt=new X(100,1),bt=function(){function t(t,i,n,h){this.An=0,this.Vn=null,this.On=null,this.zn=null,this.Pn={Fn:!1,In:null},this.Wn=0,this.Rn=0,this.jn=new J,this.Un=new J,this.qn=[],this.Hn=null,this.Yn=null,this.Kn=null,this.$n=null,this.Xn=Mt,this.Zn=t,this.xi=i,this.Jn=n,this.Gn=h,this.Qn=new vt(this,100,this.th.bind(this),this.ih.bind(this))}return t.prototype.nh=function(){return this.Zn},t.prototype.I=function(){return this.xi},t.prototype.hh=function(t){if(v(this.xi,t),this.sh(),void 0!==t.mode&&this.rh({eh:t.mode}),void 0!==t.scaleMargins){var i=l(t.scaleMargins.top),n=l(t.scaleMargins.bottom);if(i<0||i>1)throw new Error("Invalid top margin - expect value between 0 and 1, given="+i);if(n<0||n>1||i+n>1)throw new Error("Invalid bottom margin - expect value between 0 and 1, given="+n);if(i+n>1)throw new Error("Invalid margins - sum of margins must be less than 1, given="+(i+n));this.uh(),this.Yn=null}},t.prototype.ah=function(){return this.xi.autoScale},t.prototype.En=function(){return 1===this.xi.mode},t.prototype.oh=function(){return 2===this.xi.mode},t.prototype.lh=function(){return 3===this.xi.mode},t.prototype.eh=function(){return{fh:this.xi.autoScale,_h:this.xi.invertScale,eh:this.xi.mode}},t.prototype.rh=function(t){var i=this.eh(),n=null;void 0!==t.fh&&(this.xi.autoScale=t.fh),void 0!==t.eh&&(this.xi.mode=t.eh,2!==t.eh&&3!==t.eh||(this.xi.autoScale=!0),this.Pn.Fn=!1),1===i.eh&&t.eh!==i.eh&&(!function(t){if(null===t)return!1;var i=ot(t.ln()),n=ot(t.fn());return isFinite(i)&&isFinite(n)}(this.On)?this.xi.autoScale=!0:null!==(n=function(t){if(null===t)return null;var i=ot(t.ln()),n=ot(t.fn());return new G(i,n)}(this.On))&&this.dh(n)),1===t.eh&&t.eh!==i.eh&&null!==(n=lt(this.On))&&this.dh(n);var h=i.eh!==this.xi.mode;h&&(2===i.eh||this.oh())&&this.sh(),h&&(3===i.eh||this.lh())&&this.sh(),void 0!==t._h&&i._h!==t._h&&(this.xi.invertScale=t._h,this.wh()),this.Un.hn(i,this.eh())},t.prototype.Mh=function(){return this.Un},t.prototype.zt=function(){return this.Jn.fontSize},t.prototype.wt=function(){return this.An},t.prototype.bh=function(t){this.An!==t&&(this.An=t,this.uh(),this.Yn=null)},t.prototype.mh=function(){if(this.Vn)return this.Vn;var t=this.wt()-this.gh()-this.ph();return this.Vn=t,t},t.prototype.yh=function(){return this.kh(),this.On},t.prototype.dh=function(t,i){var n=this.On;(i||null===n&&null!==t||null!==n&&!n.an(t))&&(this.Yn=null,this.On=t)},t.prototype.Qt=function(){return this.kh(),0===this.An||!this.On||this.On.Qt()},t.prototype.xh=function(t){return this._h()?t:this.wt()-1-t},t.prototype.X=function(t,i){return this.oh()?t=st(t,i):this.lh()&&(t=et(t,i)),this.ih(t,i)},t.prototype.Nh=function(t,i,n){this.kh();for(var h=this.ph(),s=f(this.yh()),r=s.ln(),e=s.fn(),u=this.mh()-1,a=this._h(),o=u/(e-r),l=void 0===n?0:n.from,c=void 0===n?t.length:n.to,v=this.Sh(),_=l;_<c;_++){var d=t[_],w=d.F;if(!isNaN(w)){var M=w;null!==v&&(M=v(d.F,i));var b=h+o*(M-r),m=a?b:this.An-1-b;d.p=m}}},t.prototype.Ch=function(t,i,n){this.kh();for(var h=this.ph(),s=f(this.yh()),r=s.ln(),e=s.fn(),u=this.mh()-1,a=this._h(),o=u/(e-r),l=void 0===n?0:n.from,c=void 0===n?t.length:n.to,v=this.Sh(),_=l;_<c;_++){var d=t[_],w=d.open,M=d.high,b=d.low,m=d.close;null!==v&&(w=v(d.open,i),M=v(d.high,i),b=v(d.low,i),m=v(d.close,i));var g=h+o*(w-r),p=a?g:this.An-1-g;d.Dh=p,g=h+o*(M-r),p=a?g:this.An-1-g,d.Th=p,g=h+o*(b-r),p=a?g:this.An-1-g,d.Bh=p,g=h+o*(m-r),p=a?g:this.An-1-g,d.Eh=p}},t.prototype.Di=function(t,i){var n=this.th(t,i);return this.Lh(n,i)},t.prototype.Lh=function(t,i){var n=t;return this.oh()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this.lh()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n},t.prototype.Ah=function(){return this.qn},t.prototype.Vh=function(){if(this.Hn)return this.Hn;for(var t=[],i=0;i<this.qn.length;i++){var n=this.qn[i];null===n.ai()&&n.oi(i+1),t.push(n)}return t=_t(t),this.Hn=t,this.Hn},t.prototype.Oh=function(t){-1===this.qn.indexOf(t)&&(this.qn.push(t),this.sh(),this.zh())},t.prototype.Ph=function(t){var i=this.qn.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.qn.splice(i,1),0===this.qn.length&&(this.rh({fh:!0}),this.dh(null)),this.sh(),this.zh()},t.prototype.Y=function(){for(var t=null,i=0,n=this.qn;i<n.length;i++){var h=n[i].Y();null!==h&&((null===t||h.Fh<t.Fh)&&(t=h))}return null===t?null:t.J},t.prototype._h=function(){return this.xi.invertScale},t.prototype.Ln=function(){return this.Yn||(this.Qn.Sn(),this.Yn=this.Qn.Ln(),this.jn.hn()),this.Yn},t.prototype.Ih=function(){return this.jn},t.prototype.Wh=function(t){this.oh()||this.lh()||null===this.Kn&&null===this.zn&&(this.Qt()||(this.Kn=this.An-t,this.zn=f(this.yh()).on()))},t.prototype.Rh=function(t){if(!this.oh()&&!this.lh()&&null!==this.Kn){this.rh({fh:!1}),(t=this.An-t)<0&&(t=0);var i=(this.Kn+.2*(this.An-1))/(t+.2*(this.An-1)),n=f(this.zn).on();i=Math.max(i,.1),n._n(i),this.dh(n)}},t.prototype.jh=function(){this.oh()||this.lh()||(this.Kn=null,this.zn=null)},t.prototype.Uh=function(t){this.ah()||null===this.$n&&null===this.zn&&(this.Qt()||(this.$n=t,this.zn=f(this.yh()).on()))},t.prototype.qh=function(t){if(!this.ah()&&null!==this.$n){var i=f(this.yh()).cn()/(this.mh()-1),n=t-this.$n;this._h()&&(n*=-1);var h=n*i,s=f(this.zn).on();s.dn(h),this.dh(s,!0),this.Yn=null}},t.prototype.Hh=function(){this.ah()||null!==this.$n&&(this.$n=null,this.zn=null)},t.prototype.Yh=function(){return this.Xn||this.sh(),this.Xn},t.prototype.ti=function(t,i){switch(this.xi.mode){case 2:return this.Yh().format(st(t,i));case 3:return this.Yh().format(et(t,i));default:return this.Kh(t)}},t.prototype.Bn=function(t){switch(this.xi.mode){case 2:case 3:return this.Yh().format(t);default:return this.Kh(t)}},t.prototype.$h=function(t){return this.Kh(t,f(this.Xh()).Yh())},t.prototype.Zh=function(t,i){return t=st(t,i),wt.format(t)},t.prototype.Jh=function(){return this.qn},t.prototype.Gh=function(t){this.Pn={In:t,Fn:!1}},t.prototype.Wi=function(){this.qn.forEach((function(t){return t.Wi()}))},t.prototype.sh=function(){this.Yn=null;var t=this.Xh(),i=100;null!==t&&(i=Math.round(1/t.Qh())),this.Xn=Mt,this.oh()?(this.Xn=wt,i=100):this.lh()?(this.Xn=new X(100,1),i=100):null!==t&&(this.Xn=t.Yh()),this.Qn=new vt(this,i,this.th.bind(this),this.ih.bind(this)),this.Qn.Sn()},t.prototype.zh=function(){this.Hn=null},t.prototype.Xh=function(){return this.qn[0]||null},t.prototype.gh=function(){return this._h()?this.xi.scaleMargins.bottom*this.wt()+this.Rn:this.xi.scaleMargins.top*this.wt()+this.Wn},t.prototype.ph=function(){return this._h()?this.xi.scaleMargins.top*this.wt()+this.Wn:this.xi.scaleMargins.bottom*this.wt()+this.Rn},t.prototype.kh=function(){this.Pn.Fn||(this.Pn.Fn=!0,this.ts())},t.prototype.uh=function(){this.Vn=null},t.prototype.ih=function(t,i){if(this.kh(),this.Qt())return 0;t=this.En()&&t?at(t):t;var n=f(this.yh()),h=this.ph()+(this.mh()-1)*(t-n.ln())/n.cn();return this.xh(h)},t.prototype.th=function(t,i){if(this.kh(),this.Qt())return 0;var n=this.xh(t),h=f(this.yh()),s=h.ln()+h.cn()*((n-this.ph())/(this.mh()-1));return this.En()?ot(s):s},t.prototype.wh=function(){this.Yn=null,this.Qn.Sn()},t.prototype.ts=function(){var t=this.Pn.In;if(null!==t){for(var i=null,n=0,h=0,s=0,r=this.Jh();s<r.length;s++){var e=r[s];if(e.H()){var u=e.Y();if(null!==u){var a=e.ns(t.hs(),t.ss()),o=a&&a.yh();if(null!==o){switch(this.xi.mode){case 1:o=lt(o);break;case 2:o=rt(o,u.J);break;case 3:o=ut(o,u.J)}if(i=null===i?o:i.vn(f(o)),null!==a){var l=a.rs();null!==l&&(n=Math.max(n,l.above),h=Math.max(n,l.below))}}}}}if(n===this.Wn&&h===this.Rn||(this.Wn=n,this.Rn=h,this.Yn=null,this.uh()),null!==i){if(i.ln()===i.fn()){var c=this.Xh(),v=5*(null===c||this.oh()||this.lh()?1:c.Qh());i=new G(i.ln()-v,i.fn()+v)}this.dh(i)}else null===this.On&&this.dh(new G(-.5,.5));this.Pn.Fn=!0}},t.prototype.Sh=function(){return this.oh()?st:this.lh()?et:this.En()?at:null},t.prototype.Kh=function(t,i){return void 0===this.Gn.priceFormatter?(void 0===i&&(i=this.Yh()),i.format(t)):this.Gn.priceFormatter(t)},t}();function mt(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}!function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(dt||(dt={}));var gt=function(t){return t.getUTCFullYear()};function pt(t,i,n){return i.replace(/yyyy/g,function(t){return $(gt(t),4)}(t)).replace(/yy/g,function(t){return $(gt(t)%100,2)}(t)).replace(/MMMM/g,function(t,i){return new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"})}(t,n)).replace(/MMM/g,function(t,i){return new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"})}(t,n)).replace(/MM/g,function(t){return $(function(t){return t.getUTCMonth()+1}(t),2)}(t)).replace(/dd/g,function(t){return $(function(t){return t.getUTCDate()}(t),2)}(t))}var yt=function(){function t(t,i){void 0===t&&(t="yyyy-MM-dd"),void 0===i&&(i="default"),this.es=t,this.us=i}return t.prototype.os=function(t){return pt(t,this.es,this.us)},t}(),kt=function(){function t(t){this.ls=t||"%h:%m:%s"}return t.prototype.os=function(t){return this.ls.replace("%h",$(t.getUTCHours(),2)).replace("%m",$(t.getUTCMinutes(),2)).replace("%s",$(t.getUTCSeconds(),2))},t}(),xt={fs:"yyyy-MM-dd",cs:"%h:%m:%s",vs:" ",_s:"default"},Nt=function(){function t(t){void 0===t&&(t={});var i=u(u({},xt),t);this.ds=new yt(i.fs,i._s),this.ws=new kt(i.cs),this.Ms=i.vs}return t.prototype.os=function(t){return""+this.ds.os(t)+this.Ms+this.ws.os(t)},t}();var St=function(){function t(t,i){void 0===i&&(i=50),this.bs=0,this.gs=1,this.ps=1,this.ys=new Map,this.ks=new Map,this.xs=t,this.Ns=i}return t.prototype.os=function(t){var i=void 0===t.Ss?new Date(1e3*t.Cs).getTime():new Date(Date.UTC(t.Ss.year,t.Ss.month-1,t.Ss.day)).getTime(),n=this.ys.get(i);if(void 0!==n)return n.Ds;if(this.bs===this.Ns){var h=this.ks.get(this.ps);this.ks.delete(this.ps),this.ys.delete(l(h)),this.ps++,this.bs--}var s=this.xs(t);return this.ys.set(i,{Ds:s,Ts:this.gs}),this.ks.set(this.gs,i),this.bs++,this.gs++,s},t}(),Ct=function(){function t(t,i){o(t<=i,"right should be >= left"),this.Bs=t,this.Es=i}return t.prototype.hs=function(){return this.Bs},t.prototype.ss=function(){return this.Es},t.prototype.Ls=function(){return this.Es-this.Bs+1},t.prototype.As=function(t){return this.Bs<=t&&t<=this.Es},t.prototype.an=function(t){return this.Bs===t.hs()&&this.Es===t.ss()},t}();function Dt(t,i){return null===t||null===i?t===i:t.an(i)}var Tt,Bt=function(){function t(){this.Vs=new Map,this.ys=null}return t.prototype.Os=function(t){var i=this;this.ys=null,this.Vs.clear(),t.forEach((function(t,n){var h=i.Vs.get(t.zs);void 0===h&&(h=[],i.Vs.set(t.zs,h)),h.push({Ps:n,P:t.P,Fs:t.zs})}))},t.prototype.Is=function(t,i){var n=Math.ceil(i/t);return null!==this.ys&&this.ys.Ws===n||(this.ys={Ln:this.Rs(n),Ws:n}),this.ys.Ln},t.prototype.Rs=function(t){for(var i=[],n=0,h=Array.from(this.Vs.keys()).sort((function(t,i){return i-t}));n<h.length;n++){var s=h[n];if(this.Vs.get(s)){var r=i;i=[];for(var e=r.length,u=0,a=l(this.Vs.get(s)),o=a.length,f=1/0,c=-1/0,v=0;v<o;v++){for(var _=a[v],d=_.Ps;u<e;){var w=r[u],M=w.Ps;if(!(M<d)){f=M;break}u++,i.push(w),c=M,f=1/0}f-d>=t&&d-c>=t&&(i.push(_),c=d)}for(;u<e;u++)i.push(r[u])}}return i},t}(),Et=function(){function t(t){this.js=t}return t.prototype.Us=function(){return null===this.js?null:new Ct(Math.floor(this.js.hs()),Math.ceil(this.js.ss()))},t.prototype.qs=function(){return this.js},t.Hs=function(){return new t(null)},t}();!function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Tt||(Tt={}));var Lt=function(){function t(t,i,n){this.Ys=0,this.Ks=null,this.$s=[],this.$n=null,this.Kn=null,this.Xs=new Bt,this.Zs=new Map,this.Js=Et.Hs(),this.Gs=!0,this.Qs=new J,this.tr=new J,this.ir=new J,this.nr=null,this.hr=null,this.sr=[],this.xi=i,this.Gn=n,this.rr=i.rightOffset,this.er=i.barSpacing,this.hi=t,this.ur()}return t.prototype.I=function(){return this.xi},t.prototype.ar=function(t){v(this.Gn,t),this.lr(),this.ur()},t.prototype.hh=function(t,i){var n;v(this.xi,t),this.xi.fixLeftEdge&&this.cr(),this.xi.fixRightEdge&&this.vr(),void 0!==t.barSpacing&&this.hi._r(t.barSpacing),void 0!==t.rightOffset&&this.hi.dr(t.rightOffset),void 0!==t.minBarSpacing&&this.hi._r(null!==(n=t.barSpacing)&&void 0!==n?n:this.er),this.lr(),this.ur(),this.ir.hn()},t.prototype.si=function(t){var i;return(null===(i=this.$s[t])||void 0===i?void 0:i.P)||null},t.prototype.wr=function(t,i){if(this.$s.length<1)return null;if(t.Cs>this.$s[this.$s.length-1].P.Cs)return i?this.$s.length-1:null;for(var n=0;n<this.$s.length;++n){if(t.Cs===this.$s[n].P.Cs)return n;if(t.Cs<this.$s[n].P.Cs)return i?n:null}return null},t.prototype.Qt=function(){return 0===this.Ys||0===this.$s.length},t.prototype.Mr=function(){return this.br(),this.Js.Us()},t.prototype.mr=function(){return this.br(),this.Js.qs()},t.prototype.gr=function(){var t=this.Mr();if(null===t)return null;var i={from:t.hs(),to:t.ss()};return this.pr(i)},t.prototype.pr=function(t){var i=Math.round(t.from),n=Math.round(t.to),h=f(this.yr()),s=f(this.kr());return{from:f(this.si(Math.max(h,i))),to:f(this.si(Math.min(s,n)))}},t.prototype.Nr=function(t){return{from:f(this.wr(t.from,!0)),to:f(this.wr(t.to,!0))}},t.prototype.Sr=function(){return this.Xs},t.prototype.dt=function(){return this.Ys},t.prototype.Cr=function(t){if(isFinite(t)&&!(t<=0)&&this.Ys!==t){if(this.xi.lockVisibleTimeRangeOnResize&&this.Ys){var i=this.er*t/this.Ys;this.Dr(i)}if(this.xi.fixLeftEdge){var n=this.Mr();if(null!==n)if(n.hs()<=0){var h=this.Ys-t;this.rr-=Math.round(h/this.er)+1}}this.Ys=t,this.Gs=!0,this.Tr(),this.Br()}},t.prototype.G=function(t){if(this.Qt()||!d(t))return 0;var i=this.Er()+this.rr-t;return this.Ys-(i+.5)*this.er-1},t.prototype.Lr=function(t,i){for(var n=this.Er(),h=void 0===i?0:i.from,s=void 0===i?t.length:i.to,r=h;r<s;r++){var e=t[r].P,u=n+this.rr-e,a=this.Ys-(u+.5)*this.er-1;t[r].g=a}},t.prototype.Ar=function(t){return Math.ceil(this.Vr(t))},t.prototype.dr=function(t){this.Gs=!0,this.rr=t,this.Br(),this.hi.Or(),this.hi.zr()},t.prototype.Pr=function(){return this.er},t.prototype._r=function(t){this.Dr(t),this.Br(),this.hi.Or(),this.hi.zr()},t.prototype.Fr=function(){return this.rr},t.prototype.Ln=function(){if(this.Qt())return null;if(null!==this.hr)return this.hr;for(var t=this.er,i=5*(this.hi.I().layout.fontSize+4),n=Math.round(i/t),h=f(this.Mr()),s=Math.max(h.hs(),h.hs()-n),r=Math.max(h.ss(),h.ss()-n),e=0,u=0,a=this.Xs.Is(t,i);u<a.length;u++){var o=a[u];if(s<=o.Ps&&o.Ps<=r){var l=this.si(o.Ps);if(null!==l){if(e<this.sr.length){var c=this.sr[e];c.Dn=this.G(o.Ps),c.Tn=this.Ir(l,o.Fs),c.Fs=o.Fs}else this.sr.push({Dn:this.G(o.Ps),Tn:this.Ir(l,o.Fs),Fs:o.Fs});e++}}}return this.sr.length=e,this.hr=this.sr,this.sr},t.prototype.Wr=function(){this.Gs=!0,this._r(this.xi.barSpacing),this.dr(this.xi.rightOffset)},t.prototype.Rr=function(t){this.Gs=!0,this.Ks=t,this.Br(),this.cr()},t.prototype.jr=function(t,i){var n=this.Vr(t),h=this.Pr(),s=h+i*(h/10);this._r(s),this.xi.rightBarStaysOnScroll||this.dr(this.Fr()+(n-this.Vr(t)))},t.prototype.Wh=function(t){this.$n&&this.Hh(),null===this.Kn&&null===this.nr&&(this.Qt()||(this.Kn=t,this.Ur()))},t.prototype.Rh=function(t){if(null!==this.nr){var i=Q(this.Ys-t,0,this.Ys),n=Q(this.Ys-f(this.Kn),0,this.Ys);0!==i&&0!==n&&this._r(this.nr.Pr*i/n)}},t.prototype.jh=function(){null!==this.Kn&&(this.Kn=null,this.qr())},t.prototype.Uh=function(t){null===this.$n&&null===this.nr&&(this.Qt()||(this.$n=t,this.Ur()))},t.prototype.qh=function(t){if(null!==this.$n){var i=(this.$n-t)/this.Pr();this.rr=f(this.nr).Fr+i,this.Gs=!0,this.Br()}},t.prototype.Hh=function(){null!==this.$n&&(this.$n=null,this.qr())},t.prototype.Hr=function(){this.Yr(this.xi.rightOffset)},t.prototype.Yr=function(t,i){var n=this;if(void 0===i&&(i=400),!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");var h=this.rr,s=Date.now(),r=function(){var e=(Date.now()-s)/i,u=e>=1,a=u?t:h+(t-h)*e;n.dr(a),u||setTimeout(r,20)};r()},t.prototype.V=function(t){this.Gs=!0,this.$s=t,this.Xs.Os(t),this.Br()},t.prototype.Kr=function(){return this.Qs},t.prototype.$r=function(){return this.tr},t.prototype.Xr=function(){return this.ir},t.prototype.Er=function(){return this.Ks||0},t.prototype.Zr=function(t){var i=t.Ls();this.Dr(this.Ys/i),this.rr=t.ss()-this.Er(),this.Br(),this.Gs=!0,this.hi.Or(),this.hi.zr()},t.prototype.Jr=function(){var t=this.yr(),i=this.kr();null!==t&&null!==i&&this.Zr(new Ct(t,i+this.xi.rightOffset))},t.prototype.Gr=function(t){var i=new Ct(t.from,t.to);this.Zr(i)},t.prototype.ri=function(t){return void 0!==this.Gn.timeFormatter?this.Gn.timeFormatter(t.Ss||t.Cs):this.Qr.os(new Date(1e3*t.Cs))},t.prototype.yr=function(){return 0===this.$s.length?null:0},t.prototype.kr=function(){return 0===this.$s.length?null:this.$s.length-1},t.prototype.te=function(t){return(this.Ys-1-t)/this.er},t.prototype.Vr=function(t){var i=this.te(t),n=this.Er()+this.rr-i;return Math.round(1e6*n)/1e6},t.prototype.Dr=function(t){var i=this.er;this.er=t,this.Tr(),i!==this.er&&(this.Gs=!0,this.ie())},t.prototype.br=function(){if(this.Gs)if(this.Gs=!1,this.Qt())this.ne(Et.Hs());else{var t=this.Er(),i=this.Ys/this.er,n=this.rr+t,h=new Ct(n-i+1,n);this.ne(new Et(h))}},t.prototype.Tr=function(){var t=this.he();if(this.er<t&&(this.er=t,this.Gs=!0),0!==this.Ys){var i=.5*this.Ys;this.er>i&&(this.er=i,this.Gs=!0)}},t.prototype.he=function(){return this.xi.fixLeftEdge&&this.xi.fixRightEdge?this.Ys/this.$s.length:this.xi.minBarSpacing},t.prototype.Br=function(){var t=this.se();this.rr>t&&(this.rr=t,this.Gs=!0);var i=this.re();null!==i&&this.rr<i&&(this.rr=i,this.Gs=!0)},t.prototype.re=function(){var t=this.yr(),i=this.Ks;return null===t||null===i?null:t-i-1+(this.xi.fixLeftEdge?this.Ys/this.er:Math.min(2,this.$s.length))},t.prototype.se=function(){return this.xi.fixRightEdge?0:this.Ys/this.er-Math.min(2,this.$s.length)},t.prototype.Ur=function(){this.nr={Pr:this.Pr(),Fr:this.Fr()}},t.prototype.qr=function(){this.nr=null},t.prototype.Ir=function(t,i){var n=this,h=this.Zs.get(i);return void 0===h&&(h=new St((function(t){return n.ee(t,i)})),this.Zs.set(i,h)),h.os(t)},t.prototype.ee=function(t,i){var n,h,s=this.xi.timeVisible;return h=i<20&&s?this.xi.secondsVisible?4:3:i<40&&s?3:i<50||i<60?2:i<70?1:0,void 0!==this.xi.tickMarkFormatter?this.xi.tickMarkFormatter(null!==(n=t.Ss)&&void 0!==n?n:t.Cs,h,this.Gn.locale):function(t,i,n){var h={};switch(i){case 0:h.year="numeric";break;case 1:h.month="short";break;case 2:h.day="numeric";break;case 3:h.hour12=!1,h.hour="2-digit",h.minute="2-digit";break;case 4:h.hour12=!1,h.hour="2-digit",h.minute="2-digit",h.second="2-digit"}var s=void 0===t.Ss?new Date(1e3*t.Cs):new Date(Date.UTC(t.Ss.year,t.Ss.month-1,t.Ss.day));return new Date(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()).toLocaleString(n,h)}(t,h,this.Gn.locale)},t.prototype.ne=function(t){var i=this.Js;this.Js=t,Dt(i.Us(),this.Js.Us())||this.Qs.hn(),Dt(i.qs(),this.Js.qs())||this.tr.hn(),this.ie()},t.prototype.ie=function(){this.hr=null},t.prototype.lr=function(){this.ie(),this.Zs.clear()},t.prototype.ur=function(){var t=this.Gn.dateFormat;this.xi.timeVisible?this.Qr=new Nt({fs:t,cs:this.xi.secondsVisible?"%h:%m:%s":"%h:%m",vs:" ",_s:this.Gn.locale}):this.Qr=new yt(t,this.Gn.locale)},t.prototype.cr=function(){if(this.xi.fixLeftEdge){var t=this.yr();if(null!==t){var i=f(this.Mr()).hs()-t;if(i<0){var n=this.rr-i-1;this.dr(n)}this.Tr()}}},t.prototype.vr=function(){this.Br(),this.Tr()},t}();function At(t){return!_(t)&&!w(t)}function Vt(t){return _(t)}var Ot="'Trebuchet MS', Roboto, Ubuntu, sans-serif";function zt(t,i,n){return void 0!==n?n+=" ":n="",void 0===i&&(i=Ot),""+n+t+"px "+i}var Pt=function(){function t(t){this.ue={Dt:1,Ct:4,zt:NaN,xt:"",ae:"",et:"",Bt:0,Et:0,Lt:0,Tt:0,Ot:0},this.L=t}return t.prototype.I=function(){var t=this.ue,i=this.oe(),n=this.le();return t.zt===i&&t.ae===n||(t.zt=i,t.ae=n,t.xt=zt(i,n),t.Tt=Math.floor(i/3.5),t.Bt=t.Tt,t.Et=Math.max(Math.ceil(i/2-t.Ct/2),0),t.Lt=Math.ceil(i/2+t.Ct/2),t.Ot=Math.round(i/10)),t.et=this.fe(),this.ue},t.prototype.fe=function(){return this.L.I().layout.textColor},t.prototype.oe=function(){return this.L.I().layout.fontSize},t.prototype.le=function(){return this.L.I().layout.fontFamily},t}();function Ft(t){return"left"===t||"right"===t}var It=function(){function t(t){this.ce=new Map,this.ve=!1,this._e=[],this.de=t}return t.prototype.we=function(t,i){var n=function(t,i){return void 0===t?i:{Me:Math.max(t.Me,i.Me),fh:t.fh||i.fh}}(this.ce.get(t),i);this.ce.set(t,n)},t.prototype.be=function(){return this.de},t.prototype.me=function(t){var i=this.ce.get(t);return void 0===i?{Me:this.de}:{Me:Math.max(this.de,i.Me),fh:i.fh}},t.prototype.ge=function(){this._e=[{pe:0}]},t.prototype.ye=function(t){this._e=[{pe:1,J:t}]},t.prototype.ke=function(){this._e=[{pe:4}]},t.prototype._r=function(t){this._e.push({pe:2,J:t})},t.prototype.dr=function(t){this._e.push({pe:3,J:t})},t.prototype.xe=function(){return this._e},t.prototype.vn=function(t){var i=this;this.ve=this.ve||t.ve,this._e=this._e.concat(t._e);for(var n=0,h=t._e;n<h.length;n++){var s=h[n];this.Ne(s)}this.de=Math.max(this.de,t.de),t.ce.forEach((function(t,n){i.we(n,t)}))},t.prototype.Ne=function(t){switch(t.pe){case 0:this.ge();break;case 1:this.ye(t.J);break;case 2:this._r(t.J);break;case 3:this.dr(t.J);break;case 4:this.ke()}},t}(),Wt=function(){function t(t){this.Se=t}return t.prototype.format=function(t){var i="";return t<0&&(i="-",t=-t),t<995?i+this.Ce(t):t<999995?i+this.Ce(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Ce(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Ce(t/1e9)+"B")},t.prototype.Ce=function(t){var i=Math.pow(10,this.Se);return((t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this.Se).replace(/\.?0+$/,""):String(t)).replace(/(\.[1-9]*)0+$/,(function(t,i){return i}))},t}();function Rt(t,i,n,h){if(0!==i.length){var s=i[h.from].g,r=i[h.from].p;t.moveTo(s,r);for(var e=h.from+1;e<h.to;++e){var u=i[e];if(1===n){var a=i[e-1].p,o=u.g;t.lineTo(o,a)}t.lineTo(u.g,u.p)}}}var jt=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.v=null,i}return e(i,t),i.prototype._=function(t){this.v=t},i.prototype.u=function(t){if(null!==this.v&&0!==this.v.m.length&&null!==this.v.M){if(t.lineCap="butt",t.lineJoin="round",t.strokeStyle=this.v.S,t.lineWidth=this.v.rt,h(t,this.v.ut),t.lineWidth=1,t.beginPath(),1===this.v.m.length){var i=this.v.m[0],n=this.v.De/2;t.moveTo(i.g-n,this.v.Te),t.lineTo(i.g-n,i.p),t.lineTo(i.g+n,i.p),t.lineTo(i.g+n,this.v.Te)}else t.moveTo(this.v.m[this.v.M.from].g,this.v.Te),t.lineTo(this.v.m[this.v.M.from].g,this.v.m[this.v.M.from].p),Rt(t,this.v.m,this.v.Be,this.v.M),this.v.M.to>this.v.M.from&&(t.lineTo(this.v.m[this.v.M.to-1].g,this.v.Te),t.lineTo(this.v.m[this.v.M.from].g,this.v.Te));t.closePath();var s=t.createLinearGradient(0,0,0,this.v.Te);s.addColorStop(0,this.v.Ee),s.addColorStop(1,this.v.Le),t.fillStyle=s,t.fill()}},i}(y),Ut=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.v=null,i}return e(i,t),i.prototype._=function(t){this.v=t},i.prototype.u=function(t){if(null!==this.v&&0!==this.v.m.length&&null!==this.v.M){if(t.lineCap="butt",t.lineWidth=this.v.rt,h(t,this.v.ut),t.strokeStyle=this.v.S,t.lineJoin="round",t.beginPath(),1===this.v.m.length){var i=this.v.m[0];t.moveTo(i.g-this.v.De/2,i.p),t.lineTo(i.g+this.v.De/2,i.p)}else Rt(t,this.v.m,this.v.Be,this.v.M);t.stroke()}},i}(y);function qt(t,i,n,h,s){void 0===h&&(h=0),void 0===s&&(s=t.length);for(var r=s-h;0<r;){var e=r>>1,u=h+e;n(t[u],i)?(h=u+1,r-=e+1):r=e}return h}function Ht(t,i,n,h,s){void 0===h&&(h=0),void 0===s&&(s=t.length);for(var r=s-h;0<r;){var e=r>>1,u=h+e;n(i,t[u])?r=e:(h=u+1,r-=e+1)}return h}function Yt(t,i){return t.P<i}function Kt(t,i){return t<i.P}function $t(t,i,n){var h=i.hs(),s=i.ss(),r=qt(t,h,Yt),e=Ht(t,s,Kt);if(!n)return{from:r,to:e};var u=r,a=e;return r>0&&r<t.length&&t[r].P>=h&&(u=r-1),e>0&&e<t.length&&t[e-1].P<=s&&(a=e+1),{from:u,to:a}}var Xt=function(){function t(t,i,n){this.Ae=!0,this.Ve=!0,this.Oe=!0,this.ze=[],this.Pe=null,this.Fe=t,this.Ie=i,this.We=n}return t.prototype.V=function(t){this.Ae=!0,"data"===t&&(this.Ve=!0),"options"===t&&(this.Oe=!0)},t.prototype.Re=function(){this.Ve&&(this.je(),this.Ve=!1),this.Ae&&(this.Ue(),this.Ae=!1),this.Oe&&(this.qe(),this.Oe=!1)},t.prototype.He=function(){this.Pe=null},t.prototype.Ue=function(){var t=this.Fe.Z(),i=this.Ie.U();if(this.He(),!i.Qt()&&!t.Qt()){var n=i.Mr();if(null!==n&&0!==this.Fe.qi().Ye()){var h=this.Fe.Y();null!==h&&(this.Pe=$t(this.ze,n,this.We),this.Ke(t,i,h.J))}}},t}(),Zt=function(t){function i(i,n){return t.call(this,i,n,!0)||this}return e(i,t),i.prototype.Ke=function(t,i,n){i.Lr(this.ze,g(this.Pe)),t.Nh(this.ze,n,g(this.Pe))},i.prototype.$e=function(t,i){return{P:t,F:i,g:NaN,p:NaN}},i.prototype.qe=function(){},i.prototype.je=function(){var t=this,i=this.Fe.Xe();this.ze=this.Fe.qi().Ze().map((function(n){var h=n.J[3];return t.Je(n.Ps,h,i)}))},i}(Xt),Jt=function(t){function i(i,n){var h=t.call(this,i,n)||this;return h.ot=new p,h.Ge=new jt,h.Qe=new Ut,h.ot.i([h.Ge,h.Qe]),h}return e(i,t),i.prototype.W=function(t,i){if(!this.Fe.H())return null;var n=this.Fe.I();this.Re();var h={Be:n.lineType,m:this.ze,S:n.lineColor,ut:n.lineStyle,rt:n.lineWidth,Ee:n.topColor,Le:n.bottomColor,Te:t,M:this.Pe,De:this.Ie.U().Pr()};return this.Ge._(h),this.Qe._(h),this.ot},i.prototype.Je=function(t,i){return this.$e(t,i)},i}(Zt);var Gt=function(){function t(){this.tt=null,this.tu=0,this.iu=0}return t.prototype._=function(t){this.tt=t},t.prototype.h=function(t,i,n,h){if(null!==this.tt&&0!==this.tt.qi.length&&null!==this.tt.M){if(this.tu=this.nu(i),this.tu>=2)Math.max(1,Math.floor(i))%2!=this.tu%2&&this.tu--;this.iu=this.tt.hu?Math.min(this.tu,Math.floor(i)):this.tu;for(var s=null,r=this.iu<=this.tu&&this.tt.Pr>=Math.floor(1.5*i),e=this.tt.M.from;e<this.tt.M.to;++e){var u=this.tt.qi[e];s!==u.et&&(t.fillStyle=u.et,s=u.et);var a=Math.floor(.5*this.iu),o=Math.round(u.g*i),l=o-a,f=this.iu,c=l+f-1,v=Math.min(u.Th,u.Bh),_=Math.max(u.Th,u.Bh),d=Math.round(v*i)-a,w=Math.round(_*i)+a,M=Math.max(w-d,this.iu);t.fillRect(l,d,f,M);var b=Math.ceil(1.5*this.tu);if(r){if(this.tt.su){var m=o-b,g=Math.max(d,Math.round(u.Dh*i)-a),p=g+f-1;p>d+M-1&&(g=(p=d+M-1)-f+1),t.fillRect(m,g,l-m,p-g+1)}var y=o+b,k=Math.max(d,Math.round(u.Eh*i)-a),x=k+f-1;x>d+M-1&&(k=(x=d+M-1)-f+1),t.fillRect(c+1,k,y-c,x-k+1)}}}},t.prototype.nu=function(t){var i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(f(this.tt).Pr,t)))},t}(),Qt=function(t){function i(i,n){return t.call(this,i,n,!1)||this}return e(i,t),i.prototype.Ke=function(t,i,n){i.Lr(this.ze,g(this.Pe)),t.Ch(this.ze,n,g(this.Pe))},i.prototype.ru=function(t,i,n){return{P:t,open:i.J[0],high:i.J[1],low:i.J[2],close:i.J[3],g:NaN,Dh:NaN,Th:NaN,Bh:NaN,Eh:NaN}},i.prototype.je=function(){var t=this,i=this.Fe.Xe();this.ze=this.Fe.qi().Ze().map((function(n){return t.Je(n.Ps,n,i)}))},i}(Xt),ti=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i.ot=new Gt,i}return e(i,t),i.prototype.W=function(t,i){if(!this.Fe.H())return null;var n=this.Fe.I();this.Re();var h={qi:this.ze,Pr:this.Ie.U().Pr(),su:n.openVisible,hu:n.thinBars,M:this.Pe};return this.ot._(h),this.ot},i.prototype.qe=function(){var t=this;this.ze.forEach((function(i){i.et=t.Fe.Xe().uu(i.P).eu}))},i.prototype.Je=function(t,i,n){return u(u({},this.ru(t,i,n)),{et:n.uu(t).eu})},i}(Qt),ii=function(){function t(){this.tt=null,this.tu=0}return t.prototype._=function(t){this.tt=t},t.prototype.h=function(t,i,n,h){if(null!==this.tt&&0!==this.tt.qi.length&&null!==this.tt.M){if(this.tu=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);var n=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),h=Math.floor(t*n*i),s=Math.floor(t*i),r=Math.min(h,s);return Math.max(Math.floor(i),r)}(this.tt.Pr,i),this.tu>=2)Math.floor(i)%2!=this.tu%2&&this.tu--;var s=this.tt.qi;this.tt.au&&this.ou(t,s,this.tt.M,i),this.tt.lu&&this.fu(t,s,this.tt.M,this.tt.Pr,i);var r=this.cu(i);(!this.tt.lu||this.tu>2*r)&&this.vu(t,s,this.tt.M,i)}},t.prototype.ou=function(t,i,n,h){if(null!==this.tt){var s="",r=Math.min(Math.floor(h),Math.floor(this.tt.Pr*h));r=Math.max(Math.floor(h),Math.min(r,this.tu));for(var e=Math.floor(.5*r),u=null,a=n.from;a<n.to;a++){var o=i[a];o._u!==s&&(t.fillStyle=o._u,s=o._