klinecharts
Version:
Lightweight k-line chart built with html5 canvas
8 lines • 234 kB
JavaScript
/**
* @license
* KLineChart v10.0.3
* Copyright (c) 2019 lihu.
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).klinecharts={})}(this,(function(t){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},e(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},r.apply(this,arguments)};function n(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}function o(t,e,i,r){return new(i||(i=Promise))((function(n,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function a(t,e){var i,r,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],r=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return a}function u(t,e,i){if(i||2===arguments.length)for(var r,n=0,o=e.length;n<o;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}function c(t,e){if(g(t)||g(e))for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=t[i],n=e[i];g(n)&&g(r)?c(r,n):t[i]=h(n)}}function h(t){if(!g(t))return t;var e=null;for(var i in e=d(t)?[]:{},t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];g(r)?e[i]=h(r):e[i]=r}return e}function d(t){return"[object Array]"===Object.prototype.toString.call(t)}function p(t){return"function"==typeof t}function g(t){return"object"==typeof t&&f(t)}function v(t){return"number"==typeof t&&Number.isFinite(t)}function f(t){return null!=t}function y(t){return"boolean"==typeof t}function m(t){return"string"==typeof t}"function"==typeof SuppressedError&&SuppressedError;var _=-1;function x(t){return p(window.requestAnimationFrame)?window.requestAnimationFrame(t):window.setTimeout(t,20)}function b(t){p(window.cancelAnimationFrame)?window.cancelAnimationFrame(t):window.clearTimeout(t)}var w=function(){function t(t){this._options={duration:500,iterationCount:1},this._currentIterationCount=0,this._running=!1,this._requestAnimationId=_,this._time=0,c(this._options,t)}return t.prototype._loop=function(){var t=this;this._running=!0,this._time=performance.now();var e=function(i){var r;if(t._requestAnimationId=_,t._running){var n="number"==typeof i?i:performance.now(),o=Math.max(0,n-t._time);o<t._options.duration?(null===(r=t._doFrameCallback)||void 0===r||r.call(t,o),t._running&&t._requestAnimationId===_&&(t._requestAnimationId=x(e))):(t.stop(),t._currentIterationCount++,t._currentIterationCount<t._options.iterationCount&&t._loop())}};this._requestAnimationId=x(e)},t.prototype.doFrame=function(t){return this._doFrameCallback=t,this},t.prototype.setDuration=function(t){return this._options.duration=t,this},t.prototype.setIterationCount=function(t){return this._options.iterationCount=t,this},t.prototype.start=function(){this._running||(this._currentIterationCount=0,this._loop())},t.prototype.stop=function(){var t;this._running&&(this.cancel(),null===(t=this._doFrameCallback)||void 0===t||t.call(this,this._options.duration)),this._running=!1},t.prototype.cancel=function(){this._requestAnimationId!==_&&(b(this._requestAnimationId),this._requestAnimationId=_),this._running=!1},t}();function C(t){var e={width:0,height:0,left:0,right:0,top:0,bottom:0};return f(t)&&c(e,t),e}var E=null;function I(t){var e,i;return null!==(i=null===(e=t.ownerDocument.defaultView)||void 0===e?void 0:e.devicePixelRatio)&&void 0!==i?i:1}function T(t,e,i){return"".concat(null!=e?e:"normal"," ").concat(null!=t?t:12,"px ").concat(null!=i?i:"Helvetica Neue")}function S(t,e,i,r){if(!f(E)){var n=document.createElement("canvas"),o=I(n);(E=n.getContext("2d")).scale(o,o)}return E.font=T(e,i,r),Math.round(E.measureText(t).width)}function A(t,e){var i,r=document.createElement(t),n=null!=e?e:{};for(var o in n)r.style[o]=null!==(i=n[o])&&void 0!==i?i:"";return r}var M=1,P=Date.now();function D(t){var e=Date.now();return e===P?++M:M=1,P=e,"".concat(null!=t?t:"").concat(e,"_").concat(M)}function k(t,e,i){var r=0,n=0;for(n=t.length-1;r!==n;){var o=Math.floor((n+r)/2),a=n-r,s=t[o][e];if(i===t[r][e])return r;if(i===t[n][e])return n;if(i===s)return o;if(i>s?r=o:n=o,a<=2)break}return r}function B(t,e){e=Math.max(0,null!=e?e:0);var i=Math.pow(10,e);return Math.round(t*i)/i}function F(t,e,i){for(var r,n,o=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],a=t.length,s=0;s<a;){var l=t[s];o[0]=Math.max(null!==(r=l[e])&&void 0!==r?r:Number.MIN_SAFE_INTEGER,o[0]),o[1]=Math.min(null!==(n=l[i])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,o[1]),++s}return o}function R(t){return 0===t?0:Math.log10(t)}function L(t){return Math.pow(10,t)}var O=2,Y=0,W=/\\(\\)?/g,z=new RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");function V(t,e,i){if(e.length>0&&!e.includes(".")&&!e.includes("[")&&!e.includes("]"))return f(t)&&f(n=t[e])?n:null!=i?i:"--";if(f(t)){var r=[];e.replace(z,(function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=t;return f(e[1])?n=e[2].replace(W,"$1"):f(e[0])&&(n=e[0].trim()),r.push(n),""}));for(var n=t,o=0,a=r.length;f(n)&&o<a;)n=null==n?void 0:n[r[o++]];return f(n)?n:null!=i?i:"--"}return null!=i?i:"--"}function N(t,e,i){var r=function(t,e){var i={};return t.formatToParts(new Date(e)).forEach((function(t){var e=t.type,r=t.value;switch(e){case"year":i.YYYY=r;break;case"month":i.MM=r;break;case"day":i.DD=r;break;case"hour":i.HH="24"===r?"00":r;break;case"minute":i.mm=r;break;case"second":i.ss=r}})),i}(t,e);return i.replace(/YYYY|MM|DD|HH|mm|ss/g,(function(t){return r[t]}))}function H(t,e){var i=+t;return v(i)?i.toFixed(null!=e?e:2):"".concat(t)}function X(t){var e=+t;if(v(e)){var i=e<0?"-":"",r=Math.abs(e);if(r>=1e9)return"".concat(i).concat(+(r/1e9).toFixed(3),"B");if(r>=1e6)return"".concat(i).concat(+(r/1e6).toFixed(3),"M");if(r>=1e3)return"".concat(i).concat(+(r/1e3).toFixed(3),"K")}return"".concat(t)}function U(t,e){var i="".concat(t);if(0===e.length)return i;if(i.includes(".")){var r=i.split(".");return"".concat(r[0].replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)})),".").concat(r[1])}return i.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)}))}function G(t,e){var i="".concat(t);if(new RegExp("\\.0{"+e+",}[1-9][0-9]*$").test(i)){var r=i.split("."),n=r.length-1,o=r[n],a=/0*/.exec(o);if(f(a)){var s=a[0].length;return r[n]=o.replace(/0*/,"0{".concat(s,"}")),r.join(".")}}return i}function Z(t,e){return t.replace(/\{(\w+)\}/g,(function(t,i){var r=e[i];return f(r)?r:"{".concat(i,"}")}))}var j="candle_pane",q="indicator_pane_",K="x_axis_pane";var Q=function(){function t(t){this.scrollZoomEnabled=!0,this._range={from:0,to:0,range:0,realFrom:0,realTo:0,realRange:0,displayFrom:0,displayTo:0,displayRange:0},this._prevRange={from:0,to:0,range:0,realFrom:0,realTo:0,realRange:0,displayFrom:0,displayTo:0,displayRange:0},this._ticks=[],this._autoCalcTickFlag=!0,this._parent=t}return t.prototype.getParent=function(){return this._parent},t.prototype.buildTicks=function(t){return this._autoCalcTickFlag&&(this._range=this.createRangeImp()),!(this._prevRange.from===this._range.from&&this._prevRange.to===this._range.to&&!t)&&(this._prevRange=this._range,this._ticks=this.createTicksImp(),!0)},t.prototype.getTicks=function(){return this._ticks},t.prototype.setRange=function(t){this._autoCalcTickFlag=!1,this._range=t},t.prototype.getRange=function(){return this._range},t.prototype.setAutoCalcTickFlag=function(t){this._autoCalcTickFlag=t},t.prototype.getAutoCalcTickFlag=function(){return this._autoCalcTickFlag},t}(),$="yAxis_",J=function(t){function e(e,i){var r=t.call(this,e)||this;r.id="",r.paneId="",r.reverse=!1,r.inside=!1,r.position="right",r.gap={top:.2,bottom:.1},r.createRange=function(t){return t.defaultRange},r.minSpan=function(t){return L(-t)},r.valueToRealValue=function(t){return t},r.realValueToDisplayValue=function(t){return t},r.displayValueToRealValue=function(t){return t},r.realValueToValue=function(t){return t},r.displayValueToText=function(t,e){return H(t,e)};var o=i.minSpan,a=i.valueToRealValue,s=i.realValueToDisplayValue,l=i.displayValueToRealValue,u=i.realValueToValue,c=i.displayValueToText,h=n(i,["minSpan","valueToRealValue","realValueToDisplayValue","displayValueToRealValue","realValueToValue","displayValueToText"]);return p(o)&&(r.minSpan=o),p(a)&&(r.valueToRealValue=a),p(s)&&(r.realValueToDisplayValue=s),p(l)&&(r.displayValueToRealValue=l),p(u)&&(r.realValueToValue=u),p(c)&&(r.displayValueToText=c),r.override(h),r}return i(e,t),e.prototype.override=function(t){var e=t.id,i=t.name,r=t.gap,o=n(t,["id","name","gap"]);f(e)&&0===this.id.length&&(this.id=e),!m(this.name)&&m(i)&&(this.name=i),c(this.gap,r),c(this,o)},e.prototype._getIndicatorsByYAxisIds=function(){var t=this.getParent(),e=new Set([this.id]);if(t.isManualYAxis(this.id)){var i=t.getDefaultYAxisId();f(i)&&e.add(i)}return t.getChart().getChartStore().getIndicatorsByPaneId(t.getId()).filter((function(t){return e.has(t.yAxisId)}))},e.prototype._shouldUseCandleData=function(){var t=this.getParent();return this.isInCandle()&&(t.isDefaultYAxis(this.id)||t.isManualYAxis(this.id))},e.prototype.createRangeImp=function(){var t,e,i=this.getParent(),r=i.getChart(),n=r.getChartStore(),o=i.getId(),a=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,l=!1,u=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=this._getIndicatorsByYAxisIds();d.forEach((function(t){l||(l=t.shouldOhlc),h=Math.min(h,t.precision),v(t.minValue)&&(u=Math.min(u,t.minValue)),v(t.maxValue)&&(c=Math.max(c,t.maxValue))}));var p=4,g=this.isInCandle();if(g){var y=null!==(e=null===(t=n.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O;p=h!==Number.MAX_SAFE_INTEGER?Math.min(h,y):y}else h!==Number.MAX_SAFE_INTEGER&&(p=h);var m=n.getVisibleRangeDataList(),_=r.getStyles().candle,x="area"===_.type,b=_.area.value,w=this._shouldUseCandleData(),C=w&&!x||!g&&l;m.forEach((function(t){var e=t.dataIndex,i=t.data.current;if(f(i)&&(C&&(a=Math.min(a,i.low),s=Math.max(s,i.high)),w&&x)){var r=i[b];v(r)&&(a=Math.min(a,r),s=Math.max(s,r))}d.forEach((function(t){var i,r=t.result,n=t.figures,o=null!==(i=r[e])&&void 0!==i?i:{};n.forEach((function(t){var e=o[t.key];v(e)&&(a=Math.min(a,e),s=Math.max(s,e))}))}))})),a!==Number.MAX_SAFE_INTEGER&&s!==Number.MIN_SAFE_INTEGER?(a=Math.min(u,a),s=Math.max(c,s)):(a=0,s=10);var E=s-a,I={from:a,to:s,range:E,realFrom:a,realTo:s,realRange:E,displayFrom:a,displayTo:s,displayRange:E},T=this.createRange({chart:r,paneId:o,defaultRange:I}),S=T.realFrom,A=T.realTo,M=T.realRange,P=this.minSpan(p);if(S===A||M<P){var D=u===S,k=c===A;S=D?S:k?S-8*P:S-4*P,A=k?A:D?A+8*P:A+4*P}var B=this.getBounding().height,F=this.gap,R=F.top;R>=1&&(R/=B);var L=F.bottom;L>=1&&(L/=B),S-=(M=A-S)*L,A+=M*R;var Y=this.realValueToValue(S,{range:T}),W=this.realValueToValue(A,{range:T}),z=this.realValueToDisplayValue(S,{range:T}),V=this.realValueToDisplayValue(A,{range:T});return{from:Y,to:W,range:W-Y,realFrom:S,realTo:A,realRange:A-S,displayFrom:z,displayTo:V,displayRange:V-z}},e.prototype.isInCandle=function(){return this.getParent().getId()===j},e.prototype.isFromZero=function(){return"left"===this.position&&this.inside||"right"===this.position&&!this.inside},e.prototype.createTicksImp=function(){var t,e,i=this,r=this.getRange(),n=r.displayFrom,o=r.displayTo,a=r.displayRange,s=[];if(a>=0){var l=function(t){var e=Math.floor(R(t)),i=L(e),r=t/i;return+(t=(r<1.5?1:r<2.5?2:r<3.5?3:r<4.5?4:r<5.5?5:r<6.5?6:8)*i).toFixed(Math.abs(e))}(a/8),u=function(t){var e=t.toString(),i=e.indexOf("e");if(i>0){var r=+e.slice(i+1);return r<0?-r:0}var n=e.indexOf(".");return n<0?0:e.length-1-n}(l),c=B(Math.ceil(n/l)*l,u),h=B(Math.floor(o/l)*l,u),d=0,g=c;if(0!==l)for(;g<=h;){var f=g.toFixed(u);s[d]={text:f,coord:0,value:f},++d,g+=l}}var y=this.getParent(),m=this.getBounding().height,_=y.getChart().getChartStore(),x=[],b=this._getIndicatorsByYAxisIds(),w=_.getStyles(),C=0,E=!1;this._shouldUseCandleData()?C=null!==(e=null===(t=_.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O:b.forEach((function(t){C=Math.max(C,t.precision),E||(E=t.shouldFormatBigNumber)}));var I=_.getInnerFormatter(),T=_.getThousandsSeparator(),S=_.getDecimalFold(),A=w.yAxis.tickText.size,M=NaN;return s.forEach((function(t){var e=t.value,n=i.displayValueToText(+e,C),o=i.convertToPixel(i.realValueToValue(i.displayValueToRealValue(+e,{range:r}),{range:r}));E&&(n=I.formatBigNumber(e)),n=S.format(T.format(n));var a=v(M);o>A&&o<m-A&&(a&&Math.abs(M-o)>2*A||!a)&&(x.push({text:n,coord:o,value:e}),M=o)})),p(this.createTicks)?this.createTicks({range:this.getRange(),bounding:this.getBounding(),defaultTicks:x}):x},e.prototype.getAutoSize=function(){var t,e,i=this.getParent().getChart().getChartStore(),r=i.getStyles(),n=r.yAxis,o=n.size;if("auto"!==o)return o;var a=0;if(n.show&&(n.axisLine.show&&(a+=n.axisLine.size),n.tickLine.show&&(a+=n.tickLine.length),n.tickText.show)){var s=0;this.getTicks().forEach((function(t){s=Math.max(s,S(t.text,n.tickText.size,n.tickText.weight,n.tickText.family))})),a+=n.tickText.marginStart+n.tickText.marginEnd+s}var l=r.candle.priceMark,u=l.show&&l.last.show&&l.last.text.show,c=0,h=r.crosshair,d=h.show&&h.horizontal.show&&h.horizontal.text.show,p=0;if(u||d){var g=null!==(e=null===(t=i.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O,v=this.getRange().displayTo;if(u){var y=i.getDataList(),m=y[y.length-1];if(f(m)){var _=l.last.text,x=_.paddingLeft,b=_.paddingRight,w=_.size,C=_.family,E=_.weight;c=x+S(H(m.close,g),w,E,C)+b;var I=i.getInnerFormatter().formatExtendText;l.last.extendTexts.forEach((function(t,e){var i=I({type:"last_price",data:m,index:e});i.length>0&&t.show&&(c=Math.max(c,t.paddingLeft+S(i,t.size,t.weight,t.family)+t.paddingRight))}))}}if(d){var T=this._getIndicatorsByYAxisIds(),A=0,M=!1;T.forEach((function(t){A=Math.max(t.precision,A),M||(M=t.shouldFormatBigNumber)}));var P=2;if(this._shouldUseCandleData()){var D=r.indicator.lastValueMark;P=D.show&&D.text.show?Math.max(A,g):g}else P=A;var k=H(v,P);M&&(k=i.getInnerFormatter().formatBigNumber(k)),k=i.getDecimalFold().format(k),p+=h.horizontal.text.paddingLeft+h.horizontal.text.paddingRight+2*h.horizontal.text.borderSize+S(k,h.horizontal.text.size,h.horizontal.text.weight,h.horizontal.text.family)}}return Math.max(a,c,p)},e.prototype.getBounding=function(){var t,e;return null!==(e=null===(t=this.getParent().getYAxisWidgetById(this.id))||void 0===t?void 0:t.getBounding())&&void 0!==e?e:this.getParent().getMainWidget().getBounding()},e.prototype.convertFromPixel=function(t){var e=this.getBounding().height,i=this.getRange(),r=i.realFrom,n=i.realRange,o=(this.reverse?t/e:1-t/e)*n+r;return this.realValueToValue(o,{range:i})},e.prototype.convertToPixel=function(t){var e=this.getRange(),i=this.valueToRealValue(t,{range:e}),r=this.getBounding().height,n=(i-e.realFrom)/e.realRange;return this.reverse?Math.round(n*r):Math.round((1-n)*r)},e.prototype.convertToNicePixel=function(t){var e=this.getBounding().height,i=this.convertToPixel(t);return Math.round(Math.max(.05*e,Math.min(i,.98*e)))},e.extend=function(t){var r=function(e){function r(i){return e.call(this,i,t)||this}return i(r,e),r}(e);return r},e}(Q);function tt(){return"undefined"!=typeof window&&window.navigator.userAgent.toLowerCase().includes("firefox")}function et(){return"undefined"!=typeof window&&/iPhone|iPad|iPod|iOS/.test(window.navigator.userAgent)}var it,rt=500,nt=500,ot=500,at=5,st=5,lt=5,ut=30,ct=0,ht=1,dt=2,pt=function(){function t(t,e,i){var r=this;this._clickCount=0,this._clickTimeoutId=null,this._clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._tapCount=0,this._tapTimeoutId=null,this._tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartCoordinate=null,this._touchMoveStartCoordinate=null,this._touchMoveExceededManhattanDistance=!1,this._cancelClick=!1,this._cancelTap=!1,this._unsubscribeOutsideMouseEvents=null,this._unsubscribeOutsideTouchEvents=null,this._unsubscribeMobileSafariEvents=null,this._unsubscribeMousemove=null,this._unsubscribeMouseWheel=null,this._unsubscribeContextMenu=null,this._unsubscribeRootMouseEvents=null,this._unsubscribeRootTouchEvents=null,this._startPinchMiddleCoordinate=null,this._startPinchDistance=0,this._pinchPrevented=!1,this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!et(),this._onFirefoxOutsideMouseUp=function(t){r._mouseUpHandler(t)},this._onMobileSafariDoubleClick=function(t){r._firesTouchEvents(t)?(++r._tapCount,null!==r._tapTimeoutId&&r._tapCount>1&&(r._mouseTouchMoveWithDownInfo(r._getCoordinate(t),r._tapCoordinate).manhattanDistance<ut&&!r._cancelTap&&r._processEvent(r._makeCompatEvent(t),r._handler.doubleTapEvent),r._resetTapTimeout())):(++r._clickCount,null!==r._clickTimeoutId&&r._clickCount>1&&(r._mouseTouchMoveWithDownInfo(r._getCoordinate(t),r._clickCoordinate).manhattanDistance<lt&&!r._cancelClick&&r._processEvent(r._makeCompatEvent(t),r._handler.mouseDoubleClickEvent),r._resetClickTimeout()))},this._target=t,this._handler=e,this._options=i,this._init()}return t.prototype.destroy=function(){null!==this._unsubscribeOutsideMouseEvents&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),null!==this._unsubscribeOutsideTouchEvents&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeMouseWheel&&(this._unsubscribeMouseWheel(),this._unsubscribeMouseWheel=null),null!==this._unsubscribeContextMenu&&(this._unsubscribeContextMenu(),this._unsubscribeContextMenu=null),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),null!==this._unsubscribeMobileSafariEvents&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout()},t.prototype._mouseEnterHandler=function(t){var e,i,r,n=this;null===(e=this._unsubscribeMousemove)||void 0===e||e.call(this),null===(i=this._unsubscribeMouseWheel)||void 0===i||i.call(this),null===(r=this._unsubscribeContextMenu)||void 0===r||r.call(this);var o=this._mouseMoveHandler.bind(this);this._unsubscribeMousemove=function(){n._target.removeEventListener("mousemove",o)},this._target.addEventListener("mousemove",o);var a=this._mouseWheelHandler.bind(this);this._unsubscribeMouseWheel=function(){n._target.removeEventListener("wheel",a)},this._target.addEventListener("wheel",a,{passive:!1});var s=this._contextMenuHandler.bind(this);this._unsubscribeContextMenu=function(){n._target.removeEventListener("contextmenu",s)},this._target.addEventListener("contextmenu",s,{passive:!1}),this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseEnterEvent),this._acceptMouseLeave=!0)},t.prototype._resetClickTimeout=function(){null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}},t.prototype._resetTapTimeout=function(){null!==this._tapTimeoutId&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}},t.prototype._mouseMoveHandler=function(t){this._mousePressed||null!==this._touchMoveStartCoordinate||this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseMoveEvent),this._acceptMouseLeave=!0)},t.prototype._mouseWheelHandler=function(t){if(Math.abs(t.deltaX)>Math.abs(t.deltaY)){if(!f(this._handler.mouseWheelHortEvent))return;if(this._preventDefault(t),0===Math.abs(t.deltaX))return;this._handler.mouseWheelHortEvent(this._makeCompatEvent(t),-t.deltaX)}else{if(!f(this._handler.mouseWheelVertEvent))return;var e=-t.deltaY/100;if(0===e)return;switch(this._preventDefault(t),t.deltaMode){case t.DOM_DELTA_PAGE:e*=120;break;case t.DOM_DELTA_LINE:e*=32}if(0!==e){var i=Math.sign(e)*Math.min(1,Math.abs(e));this._handler.mouseWheelVertEvent(this._makeCompatEvent(t),i)}}},t.prototype._contextMenuHandler=function(t){this._preventDefault(t)},t.prototype._touchMoveHandler=function(t){var e=this._touchWithId(t.changedTouches,this._activeTouchId);if(null!==e&&(this._lastTouchEventTimeStamp=this._eventTimeStamp(t),null===this._startPinchMiddleCoordinate&&!this._preventTouchDragProcess)){this._pinchPrevented=!0;var i=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._touchMoveStartCoordinate),r=i.xOffset,n=i.yOffset,o=i.manhattanDistance;if(this._touchMoveExceededManhattanDistance||!(o<st)){if(!this._touchMoveExceededManhattanDistance){var a=.5*r,s=n>=a&&!this._options.treatVertDragAsPageScroll(),l=a>n&&!this._options.treatHorzDragAsPageScroll();s||l||(this._preventTouchDragProcess=!0),this._touchMoveExceededManhattanDistance=!0,this._cancelTap=!0,this._clearLongTapTimeout(),this._resetTapTimeout()}this._preventTouchDragProcess||(this._processEvent(this._makeCompatEvent(t,e),this._handler.touchMoveEvent),this._preventDefault(t))}}},t.prototype._mouseMoveWithDownHandler=function(t){t.button===ct&&(this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._mouseMoveStartCoordinate).manhattanDistance>=at&&(this._cancelClick=!0,this._resetClickTimeout()),this._cancelClick&&this._processEvent(this._makeCompatEvent(t),this._handler.pressedMouseMoveEvent))},t.prototype._mouseTouchMoveWithDownInfo=function(t,e){var i=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return{xOffset:i,yOffset:r,manhattanDistance:i+r}},t.prototype._touchEndHandler=function(t){var e=this._touchWithId(t.changedTouches,this._activeTouchId);if(null===e&&0===t.touches.length&&(e=t.changedTouches[0]),null!==e){this._activeTouchId=null,this._lastTouchEventTimeStamp=this._eventTimeStamp(t),this._clearLongTapTimeout(),this._touchMoveStartCoordinate=null,null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);var i=this._makeCompatEvent(t,e);if(this._processEvent(i,this._handler.touchEndEvent),++this._tapCount,null!==this._tapTimeoutId&&this._tapCount>1)this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._tapCoordinate).manhattanDistance<ut&&!this._cancelTap&&this._processEvent(i,this._handler.doubleTapEvent),this._resetTapTimeout();else this._cancelTap||(this._processEvent(i,this._handler.tapEvent),f(this._handler.tapEvent)&&this._preventDefault(t));0===this._tapCount&&this._preventDefault(t),0===t.touches.length&&this._longTapActive&&(this._longTapActive=!1,this._preventDefault(t))}},t.prototype._mouseUpHandler=function(t){if(t.button===ct){var e=this._makeCompatEvent(t);if(this._mouseMoveStartCoordinate=null,this._mousePressed=!1,null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),tt())this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp);if(!this._firesTouchEvents(t))if(this._processEvent(e,this._handler.mouseUpEvent),++this._clickCount,null!==this._clickTimeoutId&&this._clickCount>1)this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._clickCoordinate).manhattanDistance<lt&&!this._cancelClick&&this._processEvent(e,this._handler.mouseDoubleClickEvent),this._resetClickTimeout();else this._cancelClick||this._processEvent(e,this._handler.mouseClickEvent)}},t.prototype._clearLongTapTimeout=function(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)},t.prototype._touchStartHandler=function(t){if(null===this._activeTouchId){var e=t.changedTouches[0];this._activeTouchId=e.identifier,this._lastTouchEventTimeStamp=this._eventTimeStamp(t);var i=this._target.ownerDocument.documentElement;this._cancelTap=!1,this._touchMoveExceededManhattanDistance=!1,this._preventTouchDragProcess=!1,this._touchMoveStartCoordinate=this._getCoordinate(e),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);var r=this._touchMoveHandler.bind(this),n=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=function(){i.removeEventListener("touchmove",r),i.removeEventListener("touchend",n)},i.addEventListener("touchmove",r,{passive:!1}),i.addEventListener("touchend",n,{passive:!1}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,t),nt),this._processEvent(this._makeCompatEvent(t,e),this._handler.touchStartEvent),null===this._tapTimeoutId&&(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),rt),this._tapCoordinate=this._getCoordinate(e))}},t.prototype._mouseDownHandler=function(t){if(t.button===dt)return this._preventDefault(t),void this._processEvent(this._makeCompatEvent(t),this._handler.mouseRightClickEvent);if(t.button===ct){var e=this._target.ownerDocument.documentElement;tt()&&e.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=!1,this._mouseMoveStartCoordinate=this._getCoordinate(t),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);var i=this._mouseMoveWithDownHandler.bind(this),r=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=function(){e.removeEventListener("mousemove",i),e.removeEventListener("mouseup",r)},e.addEventListener("mousemove",i),e.addEventListener("mouseup",r),this._mousePressed=!0,this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseDownEvent),null===this._clickTimeoutId&&(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),rt),this._clickCoordinate=this._getCoordinate(t)))}},t.prototype._init=function(){var t=this;this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));var e=this._target.ownerDocument,i=function(e){null!=t._handler.mouseDownOutsideEvent&&(e.composed&&t._target.contains(e.composedPath()[0])||null!==e.target&&t._target.contains(e.target)||t._handler.mouseDownOutsideEvent({x:0,y:0,pageX:0,pageY:0}))};this._unsubscribeOutsideTouchEvents=function(){e.removeEventListener("touchstart",i)},this._unsubscribeOutsideMouseEvents=function(){e.removeEventListener("mousedown",i)},e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0}),et()&&(this._unsubscribeMobileSafariEvents=function(){t._target.removeEventListener("dblclick",t._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:!0}),this._target.addEventListener("mousedown",(function(t){if(t.button===ht)return t.preventDefault(),!1})),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(function(){}),{passive:!1})},t.prototype._initPinch=function(){var t=this;(f(this._handler.pinchStartEvent)||f(this._handler.pinchEvent)||f(this._handler.pinchEndEvent))&&(this._target.addEventListener("touchstart",(function(e){t._checkPinchState(e.touches)}),{passive:!0}),this._target.addEventListener("touchmove",(function(e){if(2===e.touches.length&&null!==t._startPinchMiddleCoordinate&&f(t._handler.pinchEvent)){var i=t._getTouchDistance(e.touches[0],e.touches[1])/t._startPinchDistance;t._handler.pinchEvent(r(r({},t._startPinchMiddleCoordinate),{pageX:0,pageY:0}),i),t._preventDefault(e)}}),{passive:!1}),this._target.addEventListener("touchend",(function(e){t._checkPinchState(e.touches)})))},t.prototype._checkPinchState=function(t){1===t.length&&(this._pinchPrevented=!1),2!==t.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(t)},t.prototype._startPinch=function(t){var e=this._target.getBoundingClientRect();this._startPinchMiddleCoordinate={x:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,y:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this._startPinchDistance=this._getTouchDistance(t[0],t[1]),f(this._handler.pinchStartEvent)&&this._handler.pinchStartEvent({x:0,y:0,pageX:0,pageY:0}),this._clearLongTapTimeout()},t.prototype._stopPinch=function(){null!==this._startPinchMiddleCoordinate&&(this._startPinchMiddleCoordinate=null,f(this._handler.pinchEndEvent)&&this._handler.pinchEndEvent({x:0,y:0,pageX:0,pageY:0}))},t.prototype._mouseLeaveHandler=function(t){var e,i,r;null===(e=this._unsubscribeMousemove)||void 0===e||e.call(this),null===(i=this._unsubscribeMouseWheel)||void 0===i||i.call(this),null===(r=this._unsubscribeContextMenu)||void 0===r||r.call(this),this._firesTouchEvents(t)||this._acceptMouseLeave&&(this._processEvent(this._makeCompatEvent(t),this._handler.mouseLeaveEvent),this._acceptMouseLeave=!et())},t.prototype._longTapHandler=function(t){var e=this._touchWithId(t.touches,this._activeTouchId);null!==e&&(this._processEvent(this._makeCompatEvent(t,e),this._handler.longTapEvent),this._cancelTap=!0,this._longTapActive=!0)},t.prototype._firesTouchEvents=function(t){var e;return f(null===(e=t.sourceCapabilities)||void 0===e?void 0:e.firesTouchEvents)?t.sourceCapabilities.firesTouchEvents:this._eventTimeStamp(t)<this._lastTouchEventTimeStamp+ot},t.prototype._processEvent=function(t,e){null==e||e.call(this._handler,t)},t.prototype._makeCompatEvent=function(t,e){var i=this,r=null!=e?e:t,n=this._target.getBoundingClientRect();return{x:r.clientX-n.left,y:r.clientY-n.top,pageX:r.pageX,pageY:r.pageY,isTouch:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type&&"wheel"!==t.type,preventDefault:function(){"touchstart"!==t.type&&i._preventDefault(t)}}},t.prototype._getTouchDistance=function(t,e){var i=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(i*i+r*r)},t.prototype._preventDefault=function(t){t.cancelable&&t.preventDefault()},t.prototype._getCoordinate=function(t){return{x:t.pageX,y:t.pageY}},t.prototype._eventTimeStamp=function(t){var e;return null!==(e=t.timeStamp)&&void 0!==e?e:performance.now()},t.prototype._touchWithId=function(t,e){for(var i=0;i<t.length;++i)if(t[i].identifier===e)return t[i];return null},t}(),gt={name:"scrollLeft",keys:"Shift+ArrowLeft",action:function(t){var e=t.chart;e.scrollByDistance(-3*e.getBarSpace().bar)}},vt={name:"scrollRight",keys:"Shift+ArrowRight",action:function(t){var e=t.chart;e.scrollByDistance(3*e.getBarSpace().bar)}},ft={name:"zoomIn",keys:["Shift+Equal","Shift+NumpadAdd"],action:function(t){t.chart.zoomAtCoordinate(1.05)}},yt={name:"zoomOut",keys:["Shift+Minus","Shift+NumpadSubtract"],action:function(t){t.chart.zoomAtCoordinate(.95)}},mt=((it={})[gt.name]=gt,it[vt.name]=vt,it[ft.name]=ft,it[yt.name]=yt,it);function _t(t){var e;return null!==(e=mt[t])&&void 0!==e?e:null}function xt(){return Object.keys(mt)}var bt="main",wt="xAxis",Ct="yAxis",Et="separator",It=.975,Tt=1e3/60,St={command:"meta",cmd:"meta",control:"ctrl",option:"alt",mod:/Mac|iPhone|iPad|iPod|iOS/.test(window.navigator.userAgent)?"meta":"ctrl"},At={"+":"equal",plus:"equal",add:"equal",numpadadd:"equal","-":"minus",subtract:"minus",numpadsubtract:"minus",esc:"escape",del:"delete",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown"},Mt=["ctrl","alt","shift","meta"],Pt=function(){function t(t,e){var i=this;this._flingStartTime=performance.now(),this._flingScrollAnimation=null,this._startScrollCoordinate=null,this._touchCoordinate=null,this._touchCancelCrosshair=!1,this._touchZoomed=!1,this._pinchScale=1,this._mouseDownWidget=null,this._prevYAxisRanges=new Map,this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0,this._mouseMoveTriggerWidgetInfo={pane:null,widget:null},this._boundKeyBoardDownEvent=function(t){var e,r,n,o=t.target,a=null==o?void 0:o.tagName.toLowerCase();if("input"!==a&&"textarea"!==a&&!0!==(null==o?void 0:o.isContentEditable)){var s=i._chart.getHotKey(),c=s.enabled,h=s.exclude;if(c){var g=[];t.ctrlKey&&g.push("ctrl"),t.altKey&&g.push("alt"),t.shiftKey&&g.push("shift"),t.metaKey&&g.push("meta");var v=t.code.trim().toLowerCase();/^key[a-z]$/.test(v)?g.push(v.slice(3)):/^digit[0-9]$/.test(v)?g.push(v.slice(5)):g.push(null!==(e=At[v])&&void 0!==e?e:v);for(var y=g.join("+"),m=xt(),_=m.length-1;_>=0;_--){var x=m[_],b=_t(x);if(!h.includes(x)&&f(b)){var w=(d(b.keys)?b.keys:[b.keys]).some((function(t){var e=[],i="";return t.replace(/\+\+$/,"+Plus").replace(/\+=$/,"+Equal").split("+").forEach((function(t){var r,n,o=(null!==(r=St[t.trim().toLowerCase()])&&void 0!==r?r:t).trim().toLowerCase(),a="";a=/^key[a-z]$/.test(o)?o.slice(3):/^digit[0-9]$/.test(o)?o.slice(5):null!==(n=At[o])&&void 0!==n?n:o,Mt.includes(a)?e.includes(a)||e.push(a):a.length>0&&(i=a)})),e.sort((function(t,e){return Mt.indexOf(t)-Mt.indexOf(e)})),u(u([],l(e),!1),[i],!1).filter((function(t){return t.length>0})).join("+")===y}));if(w){var C={chart:i._chart,event:t,key:y,hotkey:b};if(!p(b.check)||b.check(C))return(null===(r=b.preventDefault)||void 0===r||r)&&t.preventDefault(),null!==(n=b.stopPropagation)&&void 0!==n&&n&&t.stopPropagation(),void b.action(C)}}}}}},this._chart=e,this._event=new pt(t,this,{treatVertDragAsPageScroll:function(){return!1},treatHorzDragAsPageScroll:function(){return!1}}),document.addEventListener("keydown",this._boundKeyBoardDownEvent)}return t.prototype._getYAxisByWidget=function(t){return t.getName()===Ct?t.getAxisComponent():t.getPane().getYAxisComponentById()},t.prototype._getYAxisScaleTargetByWidget=function(t){var e=this._getYAxisByWidget(t),i=t.getPane();return i.isManualYAxis(e.id)?i.getYAxisComponentById():e},t.prototype._syncYAxisValueRange=function(t,e){var i=t.getRange(),r=e.from,n=e.to,o=t.valueToRealValue(r,{range:i}),a=t.valueToRealValue(n,{range:i}),s=t.realValueToDisplayValue(o,{range:i}),l=t.realValueToDisplayValue(a,{range:i});t.setRange({from:r,to:n,range:n-r,realFrom:o,realTo:a,realRange:a-o,displayFrom:s,displayTo:l,displayRange:l-s})},t.prototype._syncManualYAxesValueRange=function(t,e){var i=this,r=e.getRange();t.getPane().getYAxisComponents().forEach((function(n){var o=n;o!==e&&t.getPane().isManualYAxis(o.id)&&i._syncYAxisValueRange(o,r)}))},t.prototype._resetYAxisAndManualYAxes=function(t,e){e.setAutoCalcTickFlag(!0),t.getPane().getYAxisComponents().forEach((function(e){var i=e;t.getPane().isManualYAxis(i.id)&&i.setAutoCalcTickFlag(!0)})),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0})},t.prototype.pinchStartEvent=function(){return this._touchZoomed=!0,this._pinchScale=1,!0},t.prototype.pinchEvent=function(t,e){void 0===e&&(e=1);var i=this._findWidgetByEvent(t),r=i.pane,n=i.widget;if((null==r?void 0:r.getId())!==K&&(null==n?void 0:n.getName())===bt){var o=this._makeWidgetEvent(t,n),a=5*(e-this._pinchScale);return this._pinchScale=e,this._chart.getChartStore().zoom(a,{x:o.x,y:o.y},"main"),!0}return!1},t.prototype.mouseWheelHortEvent=function(t,e){void 0===e&&(e=0);var i=this._chart.getChartStore();return i.startScroll(),i.scroll(e),!0},t.prototype.mouseWheelVertEvent=function(t,e){void 0===e&&(e=0);var i=this._findWidgetByEvent(t).widget,r=this._makeWidgetEvent(t,i),n=null==i?void 0:i.getName();if(n===bt)return this._chart.getChartStore().zoom(e,{x:r.x,y:r.y},"main"),!0;if(n===Ct){var o=i;if(this._getYAxisByWidget(o).scrollZoomEnabled){var a=1+.05*e,s=this._getYAxisScaleTargetByWidget(o);return this._zoomYAxis(s,a),this._syncManualYAxesValueRange(o,s),!0}}return!1},t.prototype.mouseDownEvent=function(t){var e,i,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget;if(this._mouseDownWidget=a,null!==a){var l=this._makeWidgetEvent(t,a);switch(a.getName()){case Et:return a.dispatchEvent("mouseDownEvent",l);case bt:var u=a.dispatchEvent("mouseDownEvent",l);if(!u){var c=o.getYAxisComponents();try{for(var h=s(c),d=h.next();!d.done;d=h.next()){var p=d.value;if(!p.getAutoCalcTickFlag()){var g=p.getRange();this._prevYAxisRanges.set(p,r({},g))}}}catch(t){e={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(e)throw e.error}}this._startScrollCoordinate={x:l.x,y:l.y},this._chart.getChartStore().startScroll()}return u;case wt:return this._processXAxisScrollStartEvent(a,l);case Ct:return this._processYAxisScaleStartEvent(a,l)}}return!1},t.prototype.mouseMoveEvent=function(t){var e,i,r,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget,s=this._makeWidgetEvent(t,a);if((null===(e=this._mouseMoveTriggerWidgetInfo.pane)||void 0===e?void 0:e.getId())===(null==o?void 0:o.getId())&&(null===(i=this._mouseMoveTriggerWidgetInfo.widget)||void 0===i?void 0:i.getName())===(null==a?void 0:a.getName())||(null==a||a.dispatchEvent("mouseEnterEvent",s),null===(r=this._mouseMoveTriggerWidgetInfo.widget)||void 0===r||r.dispatchEvent("mouseLeaveEvent",s),this._mouseMoveTriggerWidgetInfo={pane:o,widget:a}),null!==a)switch(a.getName()){case bt:var l=a.dispatchEvent("mouseMoveEvent",s),u={x:s.x,y:s.y,paneId:null==o?void 0:o.getId()};return l?("pointer"!==a.getForceCursor()&&(u=void 0),a.setCursor("pointer")):a.setCursor("crosshair"),this._chart.getChartStore().setCrosshair(u),l;case Et:case wt:case Ct:l=a.dispatchEvent("mouseMoveEvent",s);return this._chart.getChartStore().setCrosshair(),l}return!1},t.prototype.pressedMouseMoveEvent=function(t){var e,i;if(null!==this._mouseDownWidget&&this._mouseDownWidget.getName()===Et)return this._mouseDownWidget.dispatchEvent("pressedMouseMoveEvent",t);var r=this._findWidgetByEvent(t),n=r.pane,o=r.widget;if(null!==o&&(null===(e=this._mouseDownWidget)||void 0===e?void 0:e.getPane().getId())===(null==n?void 0:n.getId())&&(null===(i=this._mouseDownWidget)||void 0===i?void 0:i.getName())===o.getName()){var a=this._makeWidgetEvent(t,o);switch(o.getName()){case bt:var s=void 0,l=o.dispatchEvent("pressedMouseMoveEvent",a);return l?this._chart.updatePane(1):this._processMainScrollingEvent(o,a),l&&"pointer"!==o.getForceCursor()||(s={x:a.x,y:a.y,paneId:null==n?void 0:n.getId()}),this._chart.getChartStore().setCrosshair(s,{forceInvalidate:!0}),l;case wt:return this._processXAxisScrollingEvent(o,a);case Ct:return this._processYAxisScalingEvent(o,a)}}return!1},t.prototype.mouseUpEvent=function(t){var e=this._findWidgetByEvent(t).widget,i=!1;if(null!==e){var r=this._makeWidgetEvent(t,e);switch(e.getName()){case bt:case Et:case wt:case Ct:i=e.dispatchEvent("mouseUpEvent",r)}i&&this._chart.updatePane(1)}return this._mouseDownWidget=null,this._startScrollCoordinate=null,this._prevYAxisRanges.clear(),this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0,i},t.prototype.mouseClickEvent=function(t){var e=this._findWidgetByEvent(t).widget;if(null!==e){var i=this._makeWidgetEvent(t,e);return e.dispatchEvent("mouseClickEvent",i)}return!1},t.prototype.mouseRightClickEvent=function(t){var e=this._findWidgetByEvent(t).widget,i=!1;if(null!==e){var r=this._makeWidgetEvent(t,e);switch(e.getName()){case bt:case wt:case Ct:i=e.dispatchEvent("mouseRightClickEvent",r)}i&&this._chart.updatePane(1)}return!1},t.prototype.mouseDoubleClickEvent=function(t){var e=this._findWidgetByEvent(t).widget;if(null!==e)switch(e.getName()){case bt:var i=this._makeWidgetEvent(t,e);return e.dispatchEvent("mouseDoubleClickEvent",i);case Ct:var r=e,n=this._getYAxisByWidget(r),o=this._getYAxisScaleTargetByWidget(r);if(!o.getAutoCalcTickFlag()||!n.getAutoCalcTickFlag())return this._resetYAxisAndManualYAxes(r,o),!0}return!1},t.prototype.mouseLeaveEvent=function(){return this._chart.getChartStore().setCrosshair(),!0},t.prototype.touchStartEvent=function(t){var e,i,n,o=this._findWidgetByEvent(t),a=o.pane,l=o.widget;if(null!==l){var u=this._makeWidgetEvent(t,l);switch(null===(n=u.preventDefault)||void 0===n||n.call(u),l.getName()){case bt:var c=this._chart.getChartStore();if(l.dispatchEvent("mouseDownEvent",u))return this._touchCancelCrosshair=!0,this._touchCoordinate=null,c.setCrosshair(void 0,{notInvalidate:!0}),this._chart.updatePane(1),!0;null!==this._flingScrollAnimation&&(this._flingScrollAnimation.cancel(),this._flingScrollAnimation=null),this._flingStartTime=performance.now();var h=a.getYAxisComponents();try{for(var d=s(h),p=d.next();!p.done;p=d.next()){var g=p.value;if(!g.getAutoCalcTickFlag()){var v=g.getRange();this._prevYAxisRanges.set(g,r({},v))}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}if(this._startScrollCoordinate={x:u.x,y:u.y},c.startScroll(),this._touchZoomed=!1,null!==this._touchCoordinate){var f=u.x-this._touchCoordinate.x,y=u.y-this._touchCoordinate.y;Math.sqrt(f*f+y*y)<10?(this._touchCoordinate={x:u.x,y:u.y},c.setCrosshair({x:u.x,y:u.y,paneId:null==a?void 0:a.getId()})):(this._touchCoordinate=null,this._touchCancelCrosshair=!0,c.setCrosshair())}return!0;case wt:return this._processXAxisScrollStartEvent(l,u);case Ct:return this._processYAxisScaleStartEvent(l,u)}}return!1},t.prototype.touchMoveEvent=function(t){var e,i,r,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget;if(null!==a){var s=this._makeWidgetEvent(t,a),l=a.getName(),u=this._chart.getChartStore();switch(l){case bt:return a.dispatchEvent("pressedMouseMoveEvent",s)?(null===(e=s.preventDefault)||void 0===e||e.call(s),u.setCrosshair(void 0,{notInvalidate:!0}),this._chart.updatePane(1),!0):(null!==this._touchCoordinate?(null===(i=s.preventDefault)||void 0===i||i.call(s),u.setCrosshair({x:s.x,y:s.y,paneId:null==o?void 0:o.getId()})):this._processMainScrollingEvent(a,s),!0);case wt:return null===(r=s.preventDefault)||void 0===r||r.call(s),this._processXAxisScrollingEvent(a,s);case Ct:return this._processYAxisScalingEvent(a,s)}}return!1},t.prototype.touchEndEvent=function(t){var e=this,i=this._findWidgetByEvent(t).widget;if(null!==i){var r=this._makeWidgetEvent(t,i);switch(i.getName()){case bt:if(i.dispatchEvent("mouseUpEvent",r),null!==this._startScrollCoordinate){var n=performance.now()-this._flingStartTime,o=(r.x-this._startScrollCoordinate.x)/(n>0?n:1)*20;if(n<200&&Math.abs(o)>1){var a=this._chart.getChartStore(),s=Math.log(1/Math.abs(o))/Math.log(It)*Tt,l=new w({duration:s}).doFrame((function(t){var i=t/Tt,r=o*(1-Math.pow(It,i))/(1-It);a.scroll(r),t>=s&&e._flingScrollAnimation===l&&(e._flingScrollAnimation=null)}));a.startScroll(),this._flingScrollAnimation=l,l.start()}}return!0;case wt:case Ct:i.dispatchEvent("mouseUpEvent",r)&&this._chart.updatePane(1)}this._startScrollCoordinate=null,this._prevYAxisRanges.clear(),this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0}return!1},t.prototype.tapEvent=function(t){var e=this._findWidgetByEvent(t),i=e.pane,r=e.widget,n=!1;if(null!==r){var o=this._makeWidgetEvent(t,r),a=r.dispatchEvent("mouseClickEvent",o);if(r.getName()===bt){var s=this._makeWidgetEvent(t,r),l=this._chart.getChartStore();a?(this._touchCancelCrosshair=!0,this._touchCoordinate=null,l.setCrosshair(void 0,{notInvalidate:!0}),n=!0):(this._touchCancelCrosshair||this._touchZoomed||(this._touchCoordinate={x:s.x,y:s.y},l.setCrosshair({x:s.x,y:s.y,paneId:null==i?void 0:i.getId()},{notInvalidate:!0}),n=!0),this._touchCancelCrosshair=!1)}(n||a)&&this._chart.updatePane(1)}return n},t.prototype.doubleTapEvent=function(t){return this.mouseDoubleClickEvent(t)},t.prototype.longTapEvent=function(t){var e=this._findWidgetByEvent(t),i=e.pane,r=e.widget;if(null!==r&&r.getName()===bt){var n=this._makeWidgetEvent(t,r);return this._touchCoordinate={x:n.x,y:n.y},this._chart.getChartStore().setCrosshair({x:n.x,y:n.y,paneId:null==i?void 0:i.getId()}),!0}return!1},t.prototype._processMainScrollingEvent=function(t,e){var i,r,n;if(null!==this._startScrollCoordinate){var o=t.getPane().getYAxisComponents();try{for(var a=s(o),l=a.next();!l.done;l=a.next()){var u=l.value,c=this._prevYAxisRanges.get(u);if(f(c)&&!u.getAutoCalcTickFlag()&&u.scrollZoomEnabled){null===(n=e.preventDefault)||void 0===n||n.call(e);var h=c.from,d=c.to,p=c.range,g=p*((u.reverse?this._startScrollCoordinate.y-e.y:e.y-this._startScrollCoordinate.y)/t.getBounding().height),v=h+g,y=d+g,m=u.valueToRealValue(v,{range:c}),_=u.valueToRealValue(y,{range:c}),x=u.realValueToDisplayValue(m,{range:c}),b=u.realValueToDisplayValue(_,{range:c});u.setRange({from:v,to:y,range:y-v,realFrom:m,realTo:_,realRange:_-m,displayFrom:x,displayTo:b,displayRange:b-x})}}}catch(t){i={error:t}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}var w=e.x-this._startScrollCoordinate.x;this._chart.getChartStore().scroll(w)}},t.prototype._processXAxisScrollStartEvent=function(t,e){var i=t.dispatchEvent("mouseDownEvent",e);return i&&this._chart.updatePane(1),this._xAxisStartScaleCoordinate={x:e.x,y:e.y},this._xAxisStartScaleDistance=e.pageX,i},t.prototype._processXAxisScrollingEvent=function(t,e){var i=t.dispatchEvent("pressedMouseMoveEvent",e);if(i)this._chart.updatePane(1);else if(t.getPane().getXAxisComponent().scrollZoomEnabled&&0!==this._xAxisStartScaleDistance){var r=this._xAxisStartScaleDistance/e.pageX;if(Number.isFinite(r)){var n=10*(r-this._xAxisScale);this._xAxisScale=r,this._chart.getChartStore().zoom(n,this._xAxisStartScaleCoordinate,"xAxis")}}return i},t.prototype._processYAxisScaleStartEvent=function(t,e){var i=t.dispatchEvent("mouseDownEvent",e);i&&this._chart.updatePane(1);var n=this._getYAxisScaleTargetByWidget(t),o=n.getRange();return this._prevYAxisRanges.set(n,r({},o)),this._yAxisStartScaleDistance=e.pageY,i},t.prototype._processYAxisScalingEvent=function(t,e){var i,r=t.dispatchEvent("pressedMouseMoveEvent",e);if(r)this._chart.updatePane(1);else{var n=this._getYAxisByWidget(t),o=this._getYAxisScaleTargetByWidget(t),a=this._prevYAxisRanges.get(o);if(f(a)&&n.scrollZoomEnabled&&0!==this._yAxisStartScaleDistance){null===(i=e.preventDefault)||void 0===i||i.call(e);var s=e.pageY/this._yAxisStartScaleDistance;this._zoomYAxis(o,s,a),this._syncManualYAxesValueRange(t,o)}}return r},t.prototype._zoomYAxis=function(t,e,i){var r=null!=i?i:t.getRange(),n=r.from,o=r.to,a=r.range,s=a*e,l=(s-a)/2,u=n-l,c=o+l,h=t.valueToRealValue(u,{range:r}),d=t.valueToRealValue(c,{range:r}),p=t.realValueToDisplayValue(h,{range:r}),g=t.realValueToDisplayValue(d,{range:r});t.setRange({from:u,to:c,range:s,realFrom:h,realTo:d,realRange:d-h,displayFrom:p,displayTo:g,displayRange:g-p}),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0})},t.prototype._findWidgetByEvent=function(t){var e,i,r,n,o,a,l=t.x,u=t.y,c=this._chart.getSeparatorPanes(),h=this._chart.getStyles().separator.size;try{for(var d=s(c),p=d.next();!p.done;p=d.next()){var g=p.value[1],v=(b=g.getBounding()).top-Math.round((7-h)/2);if(l>=b.left&&l<=b.left+b.width&&u>=v&&u<=v+7)return{pane:g,widget:g.getWidget()}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}var y=this._chart.getDrawPanes(),m=null;try{for(var _=s(y),x=_.next();!x.done;x=_.next()){var b,w=x.value;if(l>=(b=w.getBounding()).left&&l<=b.left+b.width&&u>=b.top&&u<=b.top+b.height){m=w;break}}}catch(t){r={error:t}}finally{try{x&&!x.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}var C=null;if(null!==m){if(!f(C)){var E=m.getMainWidget(),I=E.getBounding();l>=I.left&&l<=I.left+I.width&&u>=I.top&&u<=I.top+I.height&&(C=E)}if(!f(C))try{for(var T=s(m.getYAxisWidgets()),S=T.next();!S.done;S=T.next()){var A=S.value,M=A.getBounding();if(l>=M.left&&l<=M.left+M.width&&u>=M.top&&u<=M.top+M.height){C=A;break}}}catch(t){o={error:t}}finally{try{S&&!S.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}return{pane:m,widget:C}},t.prototype._makeWidgetEvent=function(t,e){var i,n,o,a=null!==(i=null==e?void 0:e.getBounding())&&void 0!==i?i:null;return r(r({},t),{x:t.x-(null!==(n=null==a?void 0:a.left)&&void 0!==n?n:0),y:t.y-(null!==(o=null==a?void 0:a.top)&&void 0!==o?o:0)})},t.prototype.destroy=function(){var t;null===(t=this._flingScrollAnimation)||void 0===t||t.cancel(),this._flingScrollAnimation=null,document.removeEventListener("keydown",this._boundKeyBoardDownEvent),this._event.destroy()},t}();function Dt(t,e){var i,n=t.figures,o=t.styles,a=V(o,"texts",e.texts),s=a.length,l=V(o,"circles",e.circles),u=l.length,c=V(o,"bars",e.bars),h=c.length,d=V(o,"lines",e.lines),p=d.length,g=0,v=0,y=0,m=0,_=[],x=0;return n.forEach((function(t){switch(t.type){case"text":x=g,i=a[g%s],g++;break;case"circle":x=v;var e=l[v%u];i=r(r({},e),{color:e.noChangeColor}),v++;break;case"bar":x=y;var n=c[y%h];i=r(r({},n),{color:n.noChangeColor}),y++;break;case"line":x=m,i=d[m%p],m++}f(t.type)&&_.push({figure:t,defaultStyles:r({},i),index:x})})),_}function kt(t,e,i,n,o,a){void 0===a&&(a=Dt(t,n));var s=t.result;a.forEach((function(a){var l,u=a.figure,c=a.defaultStyles,h=a.index,d=null===(l=u.styles)||void 0===l?void 0:l.call(u,{data:{prev:s[e-1],current:s[e],next:s[e+1]},indicator:t,barSpace:i,defaultStyles:n}),p=f(d)?r(r({},c),d):c;o(u,p,h)}))}var Bt=function(){function t(t){this.precision=4,this.calcParams=[],this.shouldOhlc=!1,this.shouldFormatBigNumber=!1,this.visible=!0,this.zLevel=0,this.series="normal",this.figures=[],this.minValue=null,this.maxValue=null,this.styles=null,this.shouldUpdate=function(t,e){var i=JSON.stringify(t.calcParams)!==JSON.stringify(e.calcParams)||t.figures!==e.figures||t.calc!==e.calc;return{calc:i,draw:i||t.shortName!==e.shortName||t.paneId!==e.paneId||t.yAxisId!==e.yAxisId||t.series!==e.series||t.minValue!==e.minValue||t.maxValue!==e.maxValue||t.precision!==e.precision||t.shouldOhlc!==e.shouldOhlc||t.shouldFormatBigNumber!==e.shouldFormatBigNumber||t.visible!==e.visible||t.zLevel!==e.zLevel||t.extendData!==e.extendData||t.regenerateFigures!==e.regenerateFigures||t.createTooltipDataSource!==e.createTooltipDataSource||t.draw!==e.draw}},this.calc=function(){return[]},this.regenerateFigures=null,this.createTooltipDataSource=null,this.draw=null,this.result=[],this._lockSeriesPrecision=!1,this.override(t),this._lockSeriesPrecision=!1}return t.prototype.override=function(t){var e,i,o=this,a=o.result;o._prevIndicator;var s=n(o,["result","_prevIndicator"]);this._prevIndicator=r(r({},h(s)),{result:a});var l=t.id,u=t.name,d=t.shortName,g=t.precision,y=t.styles,_=t.figures,x=t.calcParams,b=n(t,["id","name","shortName","precision","styles","figures","calcParams"]);!m(this.id)&&m(l)&&(this.id=l),m(this.name)||(this.name=null!=u?u:""),this.shortName=null!==(e=null!=d?d:this.shortName)&&void 0!==e?e:this.name,v(g)&&(this.precision=g,this._lockSeriesPrecision=!0),f(y)&&(null!==(i=this.styles)&&void 0!==i||(this.styles={}),c(this.styles,y)),c(this,b),f(x)&&(this.calcParams=x,p(this.regenerateFigures)&&(this.figures=this.regenerateFigures(this.calcParams))),this.figures=null!=_?_:this.figures},t.prototype.setSeriesPrecision=function(t){this._lockSeriesPrecision||(this.precision=t)},t.prototype.shouldUpdateImp=function(){var t=this._prevIndicator.zLevel!==this.zLevel,e=this.shouldUpdate(this._prevIndicator,this);return y(e)?{calc:e,draw:e,sort:t}:r(r({},e),{sort:t})},t.prototype.calcImp=function(t){return o(this,void 0,void 0,(function(){var e;return a(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.calc(t,this)];case 1:return e=i.sent(),this.result=e,[2,!0];case 2:return i.sent(),[2,!1];case 3:return[2]}}))}))},t.extend=function(e){return function(t){function r(){return t.call(this,e)||this}return i(r,t),r}(t)},t}(),Ft={name:"AO",shortName:"AO",calcParams:[5,34],figures:[{key:"ao",title:"AO: ",type:"bar",baseValue:0,styles:function(t){var e,i,r=t.data,n=t.indicator,o=t.defaultStyles,a=r.prev,s=r.current,l=null!==(e=null==a?void 0:a.ao)&&void 0!==e?e:Number.MIN_SAFE_INTEGER,u=null!==(i=null==s?void 0:s.ao)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c="";return{color:c=u>l?V(n.styles,"bars[0].upColor",o.bars[0].upColor):V(n.styles,"bars[0].downColor",o.bars[0].downColor),style:u>l?"stroke":"fill",borderColor:c}}}],calc:function(t,e){var i=e.calcParams,r=Math.max(i[0],i[1]),n=0,o=0,a=0,s=0;return t.map((function(e,l){var u={},c=(e.low+e.high)/2;if(n+=c,o+=c,l>=i[0]-1){a=n/i[0];var h=t[l-(i[0]-1)];n-=(h.low+h.high)/2}if(l>=i[1]-1){s=o/i[1];h=t[l-(i[1]-1)];o-=(h.low+h.high)/2}return l>=r-1&&(u.ao=a-s),u}))}};var Rt={name:"BOLL",shortName:"BOLL",series:"price",calcParams:[20,2],precision:2,shouldOhlc:!0,figures:[{key:"up",title:"UP: ",type:"line"},{key:"mid",title:"MID: ",type:"line"},{key:"dn",title:"DN: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=i[0]-1,n=0;return t.map((function(e,o){var a=e.close,s={};if(n+=a,o>=r){s.mid=n/i[0];var l=function(t,e){var i=t.length,r=0;return t.forEach((function(t){var i=t.close-e;r+=i*i})),r=Math.abs(r),Math.sqrt(r/i)}(t.slice(o-r,o+1),s.mid);s.up=s.mid+i[1]*l,s.dn=s.mid-i[1]*l,n-=t[o-r].close}return s}))}},Lt={name:"BBI",shortName:"BBI",series:"price",precision:2,calcParams:[3,6,12,24],shouldOhlc:!0,figures:[{key:"bbi",title:"BBI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.max.apply(Math,u([],l(i),!1)),n=[],o=[];return t.map((function(e,a){var s={},l=e.close;if(i.forEach((function(e,i){var r;n[i]=(null!==(r=n[i])&&void 0!==r?r:0)+l,a>=e-1&&(o[i]=n[i]/e,n[i]-=t[a-(e-1)].close)})),a>=r-1){var u=0;o.forEach((function(t){u+=t})),s.bbi=u/4}return s}))}},Ot={name:"CCI",shortName:"CCI",calcParams:[20],figures:[{key:"cci",title:"CCI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=i[0]-1,n=0,o=[];return t.map((function(e,a){var s={},l=(e.high+e.low+e.close)/3;if(n+=l,o.push(l),a>=r){var u=n/i[0],c=o.slice(a-r,a+1),h=0;c.forEach((function(t){h+=Math.abs(t-u)}));var d=h/i[0];s.cci=0!==d?(l-u)/d/.015:0;var p=(t[a-r].high+t[a-r].low+t[a-r].close)/3;n-=p}return s}))}},Yt={name:"CR",shortName:"CR",calcParams:[26,10,20,40,60],figures:[{key:"cr",title:"CR: ",type:"line"},{key:"ma1",title:"MA1: ",type:"line"},{key:"ma2",title:"MA2: ",type:"line"},{key:"ma3",title:"MA3: ",type:"line"},{key:"ma4",title:"MA4: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.ceil(i[1]/2.5+1),n=Math.ceil(i[2]/2.5+1),o=Math.ceil(i[3]/2.5+1),a=Math.ceil(i[4]/2.5+1),s=0,l=[],u=0,c=[],h=0,d=[],p=0,g=[],v=[];return t.forEach((function(e,f){var y,m,_,x,b,w={},C=null!==(y=t[f-1])&&void 0!==y?y:e,E=(C.high+C.low)/2,I=Math.max(0,e.high-E),T=Math.max(0,E-e.low);f>=i[0]-1&&(w.cr=0!==T?I/T*100:0,s+=w.cr,u+=w.cr,h+=w.cr,p+=w.cr,f>=i[0]+i[1]-2&&(l.push(s/i[1]),f>=i[0]+i[1]+r-3&&(w.ma1=l[l.length-1-r]),s-=null!==(m=v[f-(i[1]-1)].cr)&&void 0!==m?m:0),f>=i[0]+i[2]-2&&(c.push(u/i[2]),f>=i[0]+i[2]+n-3&&(w.ma2=c[c.length-1-n]),u-=null!==(_=v[f-(i[2]-1)].cr)&&void 0!==_?_:0),f>=i[0]+i[3]-2&&(d.push(h/i[3]),f>=i[0]+i[3]+o-3&&(w.ma3=d[d.length-1-o]),h-=null!==(x=v[f-(i[3]-1)].cr)&&void 0!==x?x:0),f>=i[0]+i[4]-2&&(g.push(p/i[4]),f>=i[0]+i[4]+a-3&&(w.ma4=g[g.length-1-a]),p-=null!==(b=v[f-(i[4]-1)].cr)&&void 0!==b?b:0)),v.push(w)})),v}},Wt={name:"DMA",shortName:"DMA",calcParams:[10,50,10],figures:[{key:"dma",title:"DMA: ",type:"line"},{key:"ama",title:"AMA: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=Math.max(i[0],i[1]),n=0,o=0,a=0,s=[];return t.forEach((function(e,l){var u,c={},h=e.close;n+=h,o+=h;var d=0,p=0;if(l>=i[0]-1&&(d=n/i[0],n-=t[l-(i[0]-1)].close),l>=i[1]-1&&(p=o/i[1],o-=t[l-(i[1]-1)].close),l>=r-1){var g=d-p;c.dma=g,a+=g,l>=r+i[2]-2&&(c.ama=a/i[2],a-=null!==(u=s[l-(i[2]-1)].dma)&&void 0!==u?u:0)}s.push(c)})),s}},zt={name:"DMI",shortName:"DMI",calcParams:[14,6],figures:[{key:"pdi",title:"PDI: ",type:"line"},{key:"mdi",title:"MDI: ",type:"line"},{key:"adx",title:"ADX: ",type:"line"},{key:"adxr",title:"ADXR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=0,c=0,h=[];return t.forEach((function(e,d){var p,g,v={},f=null!==(p=t[d-1])&&void 0!==p?p:e,y=f.close,m=e.high,_=e.low,x=m-_,b=Math.abs(m-y),w=Math.abs(y-_),C=m-f.high,E=f.low-_,I=Math.max(Math.max(x,b),w),T=C>0&&C>E?C:0,S=E>0&&E>C?E:0;if(r+=I,n+=T,o+=S,d>=i[0]-1){d>i[0]-1?(a=a-a/i[0]+I,s=s-s/i[0]+T,l=l-l/i[0]+S):(a=r,s=n,l=o);var A=0,M=0;0!==a&&(A=100*s/a,M=100*l/a),v.pdi=A,v.mdi=M;var P=0;M+A!==0&&(P=Math.abs(M-A)/(M+A)*100),u+=P,d>=2*i[0]-2&&(c=d>2*i[0]-2?(c*(i[0]-1)+P)/i[0]:u/i[0],v.adx=c,d>=2*i[0]+i[1]-3&&(v.adxr=((null!==(g=h[d-(i[1]-1)].adx)&&void 0!==g?g:0)+c)/2))}h.push(v)})),h}},Vt={name:"MACD",shortName:"MACD",calcParams:[12,26,9],figures:[{key:"dif",title:"DIF: ",type:"line"},{key:"dea",title:"DEA: ",type:"line"},{key:"macd",title:"MACD: ",type:"bar",baseValue:0,styles:function(t){var e,i,r=t.data,n=t.indicator,o=t.defaultStyles,a=r.prev,s=r.current,l=null!==(e=null==a?void 0:a.macd)&&void 0!==e?e:Number.MIN_SAFE_INTEGER,u=null!==(i=null==s?void 0:s.macd)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c="";return{style:l<u?"stroke":"fill",color:c=u>0?V(n.styles,"bars[0].upColor",o.bars[0].upColor):u<0?V(n.styles,"bars[0].downColor",o.bars[0].downColor):V(n.styles,"bars[0].noChangeColor",o.bars[0].noChangeColor),borderColor:c}}}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=Math.max(i[0],i[1]);return t.map((function(t,e){var c={},h=t.close;return r+=h,e>=i[0]-1&&(n=e>i[0]-1?(2*h+(i[0]-1)*n)/(i[0]+1):r/i[0]),e>=i[1]-1&&(o=e>i[1]-1?(2*h+(i[1]-1)*o)/(i[1]+1):r/i[1]),e>=u-1&&(a=n-o,c.dif=a,s+=a,e>=u+i[2]-2&&(l=e>u+i[2]-2?(2*a+l*(i[2]-1))/(i[2]+1):s/i[2],c.macd=2*(a-l),c.dea=l)),c}))}},Nt={name:"RSI",shortName:"RSI",calcParams:[6,12,24],figures:[{key:"rsi1",title:"RSI1: ",type:"line"},{key:"rsi2",title:"RSI2: ",type:"line"},{key:"rsi3",title:"RSI3: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){var i=e+1;return{key:"rsi".concat(i),title:"RSI".concat(i,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[],o=[],a=[],s=[];return t.map((function(e,l){var u={},c=0===l?0:e.close-t[l-1].close,h=Math.max(c,0),d=Math.max(-c,0);return i.forEach((function(t,e){var i,c;n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+h,o[e]=(null!==(c=o[e])&&void 0!==c?c:0)+d,l<t||(void 0===a[e]||void 0===s[e]?(a[e]=n[e]/t,s[e]=o[e]/t):(a[e]=(a[e]*(t-1)+h)/t,s[e]=(s[e]*(t-1)+d)/t),0===s[e]?u[r[e].key]=100:0===a[e]?u[r[e].key]=0:u[r[e].key]=100-100/(1+a[e]/s[e]))})),u}))}},Ht={name:"KDJ",shortName:"KDJ",calcParams:[9,3,3],figures:[{key:"k",title:"K: ",type:"line"},{key:"d",title:"D: ",type:"line"},{key:"j",title:"J: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=[];return t.forEach((function(e,n){var o,a,s,l,u={},c=e.close;if(n>=i[0]-1){var h=F(t.slice(n-(i[0]-1),n+1),"high","low"),d=h[0],p=h[1],g=d-p,v=(c-p)/(0===g?1:g)*100;u.k=((i[1]-1)*(null!==(a=null===(o=r[n-1])||void 0===o?void 0:o.k)&&void 0!==a?a:50)+v)/i[1],u.d=((i[2]-1)*(null!==(l=null===(s=r[n-1])||void 0===s?void 0:s.d)&&void 0!==l?l:50)+u.k)/i[2],u.j=3*u.k-2*u.d}r.push(u)})),r}},Xt={name:"SAR",shortName:"SAR",series:"price",calcParams:[2,2,20],precision:2,shouldOhlc:!0,figures:[{key:"sar",title:"SAR: ",type:"circle",styles:function(t){var e,i,r,n=t.data,o=t.indicator,a=t.defaultStyles,s=n.current;return{color:(null!==(e=null==s?void 0:s.sar)&&void 0!==e?e:Number.MIN_SAFE_INTEGER)<((null!==(i=null==s?void 0:s.high)&&void 0!==i?i:0)+(null!==(r=null==s?void 0:s.low)&&void 0!==r?r:0))/2?V(o.styles,"circles[0].upColor",a.circles[0].upColor):V(o.styles,"circles[0].downColor",a.circles[0].downColor)}}}],calc:function(t,e){var i=e.calcParams,r=i[0]/100,n=i[1]/100,o=i[2]/100,a=r,s=-100,l=!1,u=0;return t.map((function(e,i){var c=u,h=e.high,d=e.low;if(l){(-100===s||s<h)&&(s=h,a=Math.min(a+n,o)),u=c+a*(s-c);var p=Math.min(t[Math.max(1,i)-1].low,d);u>e.low?(u=s,a=r,s=-100,l=!l):u>p&&(u=p)}else{(-100===s||s>d)&&(s=d,a=Math.min(a+n,o)),u=c+a*(s-c);var g=Math.max(t[Math.max(1,i)-1].high,h);u<e.high?(u=s,a=r,s=-100,l=!l):u<g&&(u=g)}return{high:h,low:d,sar:u}}))}};function Ut(){return{key:"volume",title:"VOLUME: ",type:"bar",baseValue:0,styles:function(t){var e=t.data,i=t.indicator,r=t.defaultStyles,n=e.current,o=V(i.styles,"bars[0].noChangeColor",r.bars[0].noChangeColor);return f(n)&&(n.close>n.open?o=V(i.styles,"bars[0].upColor",r.bars[0].upColor):n.close<n.open&&(o=V(i.styles,"bars[0].downColor",r.bars[0].downColor))),{color:o}}}}var Gt={name:"VOL",shortName:"VOL",series:"volume",calcParams:[5,10,20],shouldFormatBigNumber:!0,precision:0,minValue:0,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA20: ",type:"line"},Ut()],regenerateFigures:function(t){var e=t.map((function(t,e){return{key:"ma".concat(e+1),title:"MA".concat(t,": "),type:"line"}}));return e.push(Ut()),e},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.map((function(e,o){var a,s=null!==(a=e.volume)&&void 0!==a?a:0,l={volume:s,open:e.open,close:e.close};return i.forEach((function(e,i){var a,u;n[i]=(null!==(a=n[i])&&void 0!==a?a:0)+s,o>=e-1&&(l[r[i].key]=n[i]/e,n[i]-=null!==(u=t[o-(e-1)].volume)&&void 0!==u?u:0)})),l}))}},Zt={name:"WR",shortName:"WR",calcParams:[6,10,14],figures:[{key:"wr1",title:"WR1: ",type:"line"},{key:"wr2",title:"WR2: ",type:"line"},{key:"wr3",title:"WR3: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"wr".concat(e+1),title:"WR".concat(e+1,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures;return t.map((function(e,n){var o={},a=e.close;return i.forEach((function(e,i){var s=e-1;if(n>=s){var l=F(t.slice(n-s,n+1),"high","low"),u=l[0],c=u-l[1];o[r[i].key]=0===c?0:(a-u)/c*100}})),o}))}},jt={},qt=[{name:"AVP",shortName:"AVP",series:"price",precision:2,figures:[{key:"avp",title:"AVP: ",type:"line"}],calc:function(t){var e=0,i=0;return t.map((function(t){var r,n,o={},a=null!==(r=t.turnover)&&void 0!==r?r:0,s=null!==(n=t.volume)&&void 0!==n?n:0;return e+=a,0!==(i+=s)&&(o.avp=e/i),o}))}},Ft,{name:"BIAS",shortName:"BIAS",calcParams:[6,12,24],figures:[{key:"bias1",title:"BIAS6: ",type:"line"},{key:"bias2",title:"BIAS12: ",type:"line"},{key:"bias3",title:"BIAS24: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"bias".concat(e+1),title:"BIAS".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.map((function(e,o){var a={},s=e.close;return i.forEach((function(e,l){var u;if(n[l]=(null!==(u=n[l])&&void 0!==u?u:0)+s,o>=e-1){var c=n[l]/i[l];a[r[l].key]=(s-c)/c*100,n[l]-=t[o-(e-1)].close}})),a}))}},Rt,{name:"BRAR",shortName:"BRAR",calcParams:[26],figures:[{key:"br",title:"BR: ",type:"line"},{key:"ar",title:"AR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0;return t.map((function(e,s){var l,u,c={},h=e.high,d=e.low,p=e.open,g=(null!==(l=t[s-1])&&void 0!==l?l:e).close;if(o+=h-p,a+=p-d,r+=h-g,n+=g-d,s>=i[0]-1){c.ar=0!==a?o/a*100:0,c.br=0!==n?r/n*100:0;var v=t[s-(i[0]-1)],f=v.high,y=v.low,m=v.open,_=(null!==(u=t[s-i[0]])&&void 0!==u?u:t[s-(i[0]-1)]).close;r-=f-_,n-=_-y,o-=f-m,a-=m-y}return c}))}},Lt,Ot,Yt,Wt,zt,{name:"EMV",shortName:"EMV",calcParams:[14,9],figures:[{key:"emv",title:"EMV: ",type:"line"},{key:"maEmv",title:"MAEMV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=[];return t.map((function(e,o){var a,s={};if(o>0){var l=t[o-1],u=e.high,c=e.low,h=null!==(a=e.volume)&&void 0!==a?a:0,d=(u+c)/2-(l.high+l.low)/2;if(0===h||u-c==0)s.emv=0;else{var p=h/1e8/(u-c);s.emv=d/p}r+=s.emv,n.push(s.emv),o>=i[0]&&(s.maEmv=r/i[0],r-=n[o-i[0]])}return s}))}},{name:"EMA",shortName:"EMA",series:"price",calcParams:[6,12,20],precision:2,shouldOhlc:!0,figures:[{key:"ema1",title:"EMA6: ",type:"line"},{key:"ema2",title:"EMA12: ",type:"line"},{key:"ema3",title:"EMA20: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"ema".concat(e+1),title:"EMA".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=0,o=[];return t.map((function(t,e){var a={},s=t.close;return n+=s,i.forEach((function(t,i){e>=t-1&&(o[i]=e>t-1?(2*s+(t-1)*o[i])/(t+1):n/t,a[r[i].key]=o[i])})),a}))}},{name:"MTM",shortName:"MTM",calcParams:[12,6],figures:[{key:"mtm",title:"MTM: ",type:"line"},{key:"maMtm",title:"MAMTM: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=[];return t.forEach((function(e,o){var a,s={};if(o>=i[0]){var l=e.close,u=t[o-i[0]].close;s.mtm=l-u,r+=s.mtm,o>=i[0]+i[1]-1&&(s.maMtm=r/i[1],r-=null!==(a=n[o-(i[1]-1)].mtm)&&void 0!==a?a:0)}n.push(s)})),n}},{name:"MA",shortName:"MA",series:"price",calcParams:[5,10,30,60],precision:2,shouldOhlc:!0,figures:[{key:"ma1",title:"MA5: ",type:"line"},{key:"ma2",title:"MA10: ",type:"line"},{key:"ma3",title:"MA30: ",type:"line"},{key:"ma4",title:"MA60: ",type:"line"}],regenerateFigures:function(t){return t.map((function(t,e){return{key:"ma".concat(e+1),title:"MA".concat(t,": "),type:"line"}}))},calc:function(t,e){var i=e.calcParams,r=e.figures,n=[];return t.map((function(e,o){var a={},s=e.close;return i.forEach((function(e,i){var l;n[i]=(null!==(l=n[i])&&void 0!==l?l:0)+s,o>=e-1&&(a[r[i].key]=n[i]/e,n[i]-=t[o-(e-1)].close)})),a}))}},Vt,{name:"OBV",shortName:"OBV",calcParams:[30],figures:[{key:"obv",title:"OBV: ",type:"line"},{key:"maObv",title:"MAOBV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=[];return t.forEach((function(e,a){var s,l,u,c,h=null!==(s=t[a-1])&&void 0!==s?s:e;e.close<h.close?n-=null!==(l=e.volume)&&void 0!==l?l:0:e.close>h.close&&(n+=null!==(u=e.volume)&&void 0!==u?u:0);var d={obv:n};r+=n,a>=i[0]-1&&(d.maObv=r/i[0],r-=null!==(c=o[a-(i[0]-1)].obv)&&void 0!==c?c:0),o.push(d)})),o}},{name:"PVT",shortName:"PVT",figures:[{key:"pvt",title:"PVT: ",type:"line"}],calc:function(t){var e=0;return t.map((function(i,r){var n,o,a={},s=i.close,l=null!==(n=i.volume)&&void 0!==n?n:1,u=(null!==(o=t[r-1])&&void 0!==o?o:i).close,c=0;return 0!==u&&(c=(s-u)/u*l),e+=c,a.pvt=e,a}))}},{name:"PSY",shortName:"PSY",calcParams:[12,6],figures:[{key:"psy",title:"PSY: ",type:"line"},{key:"maPsy",title:"MAPSY: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=[],a=[];return t.forEach((function(e,s){var l,u,c={},h=(null!==(l=t[s-1])&&void 0!==l?l:e).close,d=e.close-h>0?1:0;o.push(d),r+=d,s>=i[0]-1&&(c.psy=r/i[0]*100,n+=c.psy,s>=i[0]+i[1]-2&&(c.maPsy=n/i[1],n-=null!==(u=a[s-(i[1]-1)].psy)&&void 0!==u?u:0),r-=o[s-(i[0]-1)]),a.push(c)})),a}},{name:"ROC",shortName:"ROC",calcParams:[12,6],figures:[{key:"roc",title:"ROC: ",type:"line"},{key:"maRoc",title:"MAROC: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=[],n=0;return t.forEach((function(e,o){var a,s={};if(o>=i[0]){var l=e.close,u=t[o-i[0]].close;s.roc=0!==u?(l-u)/u*100:0,n+=s.roc,o>=i[0]+i[1]-1&&(s.maRoc=n/i[1],n-=null!==(a=r[o-(i[1]-1)].roc)&&void 0!==a?a:0)}r.push(s)})),r}},Nt,{name:"SMA",shortName:"SMA",series:"price",calcParams:[12,2],precision:2,figures:[{key:"sma",title:"SMA: ",type:"line"}],shouldOhlc:!0,calc:function(t,e){var i=e.calcParams,r=0,n=0;return t.map((function(t,e){var o={},a=t.close;return r+=a,e>=i[0]-1&&(n=e>i[0]-1?(a*i[1]+n*(i[0]-i[1]+1))/(i[0]+1):r/i[0],o.sma=n),o}))}},Ht,Xt,{name:"TRIX",shortName:"TRIX",calcParams:[12,9],figures:[{key:"trix",title:"TRIX: ",type:"line"},{key:"maTrix",title:"MATRIX: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=0,l=0,u=0,c=[];return t.forEach((function(t,e){var h,d={},p=t.close;if(r+=p,e>=i[0]-1&&(n=e>i[0]-1?(2*p+(i[0]-1)*n)/(i[0]+1):r/i[0],s+=n,e>=2*i[0]-2&&(o=e>2*i[0]-2?(2*n+(i[0]-1)*o)/(i[0]+1):s/i[0],l+=o,e>=3*i[0]-3))){var g=0,v=0;e>3*i[0]-3?v=((g=(2*o+(i[0]-1)*a)/(i[0]+1))-a)/a*100:g=l/i[0],a=g,d.trix=v,u+=v,e>=3*i[0]+i[1]-4&&(d.maTrix=u/i[1],u-=null!==(h=c[e-(i[1]-1)].trix)&&void 0!==h?h:0)}c.push(d)})),c}},Gt,{name:"VR",shortName:"VR",calcParams:[26,6],figures:[{key:"vr",title:"VR: ",type:"line"},{key:"maVr",title:"MAVR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,r=0,n=0,o=0,a=0,s=[];return t.forEach((function(e,l){var u,c,h,d,p,g={},v=e.close,f=(null!==(u=t[l-1])&&void 0!==u?u:e).close,y=null!==(c=e.volume)&&void 0!==c?c:0;if(v>f?r+=y:v<f?n+=y:o+=y,l>=i[0]-1){var m=o/2;g.vr=n+m===0?0:(r+m)/(n+m)*100,a+=g.vr,l>=i[0]+i[1]-2&&(g.maVr=a/i[1],a-=null!==(h=s[l-(i[1]-1)].vr)&&void 0!==h?h:0);var _=t[l-(i[0]-1)],x=null!==(d=t[l-i[0]])&&void 0!==d?d:_,b=_.close,w=null!==(p=_.volume)&&void 0!==p?p:0;b>x.close?r-=w:b<x.close?n-=w:o-=w}s.push(g)})),s}},Zt];function Kt(t){var e;return null!==(e=jt[t])&&void 0!==e?e:null}qt.forEach((function(t){jt[t.name]=Bt.extend(t)}));var Qt=function(){function t(){this._children=[],this._callbacks=new Map}return t.prototype.registerEvent=function(t,e){return this._callbacks.set(t,e),this},t.prototype.onEvent=function(t,e){var i=this._callbacks.get(t);return!(!f(i)||!this.checkEventOn(e))&&i(e)},t.prototype.dispatchEventToChildren=function(t,e){var i=this._children.length-1;if(i>-1)for(var r=i;r>-1;r--)if(this._children[r].dispatchEvent(t,e))return!0;return!1},t.prototype.dispatchEvent=function(t,e){return!!this.dispatchEventToChildren(t,e)||this.onEvent(t,e)},t.prototype.addChild=function(t){return this._children.push(t),this},t.prototype.clear=function(){this._children=[]},t}(),$t=function(t){function e(e){var i=t.call(this)||this;return i.attrs=e.attrs,i.styles=e.styles,i}return i(e,t),e.prototype.checkEventOn=function(t){return this.checkEventOnImp(t,this.attrs,this.styles)},e.prototype.setAttrs=function(t){return this.attrs=t,this},e.prototype.setStyles=function(t){return this.styles=t,this},e.prototype.draw=function(t){this.drawImp(t,this.attrs,this.styles)},e.extend=function(t){var r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.prototype.checkEventOnImp=function(e,i,r){return t.checkEventOn(e,i,r)},r.prototype.drawImp=function(e,i,r){t.draw(e,i,r)},r}(e);return r},e}(Qt);function Jt(t,e){var i,r,n=[];n=n.concat(e);try{for(var o=s(n),a=o.next();!a.done;a=o.next()){var l=a.value.coordinates;if(l.length>1)for(var u=1;u<l.length;u++){var c=l[u-1],h=l[u];if(c.x===h.x){if(Math.abs(c.y-t.y)+Math.abs(h.y-t.y)-Math.abs(c.y-h.y)<4&&Math.abs(t.x-c.x)<2)return!0}else{var d=ie(c,h),p=te(d,t),g=Math.abs(p-t.y);if(Math.abs(c.x-t.x)+Math.abs(h.x-t.x)-Math.abs(c.x-h.x)<4&&g*g/(d[0]*d[0]+1)<4)return!0}}}}catch(t){i={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!1}function te(t,e){return null!==t?e.x*t[0]+t[1]:e.y}function ee(t,e,i){return te(ie(t,e),i)}function ie(t,e){var i=t.x-e.x;if(0!==i){var r=(t.y-e.y)/i;return[r,t.y-r*t.x]}return null}function re(t,e,i){var r=e.length,n=v(i)?i>0&&i<1?i:0:i?.5:0;if(n>0&&r>2){for(var o=e[0].x,a=e[0].y,s=1;s<r-1;s++){var l=e[s-1],u=e[s],c=e[s+1],h=u.x-l.x,d=u.y-l.y,p=c.x-u.x,g=c.y-u.y,f=c.x-l.x,y=c.y-l.y,m=Math.sqrt(h*h+d*d),_=Math.sqrt(p*p+g*g),x=_/(_+m),b=u.x+f*n*x,w=u.y+y*n*x;b=Math.min(b,Math.max(c.x,u.x)),w=Math.min(w,Math.max(c.y,u.y)),b=Math.max(b,Math.min(c.x,u.x)),w=Math.max(w,Math.min(c.y,u.y)),f=b-u.x,y=w-u.y;var C=u.x-f*m/_,E=u.y-y*m/_;C=Math.min(C,Math.max(l.x,u.x)),E=Math.min(E,Math.max(l.y,u.y)),C=Math.max(C,Math.min(l.x,u.x)),E=Math.max(E,Math.min(l.y,u.y)),f=u.x-C,y=u.y-E,b=u.x+f*_/m,w=u.y+y*_/m,t.bezierCurveTo(o,a,C,E,u.x,u.y),o=b,a=w}var I=e[r-1];t.bezierCurveTo(o,a,I.x,I.y,I.x,I.y)}else for(s=1;s<r;s++)t.lineTo(e[s].x,e[s].y)}var ne={name:"line",checkEventOn:Jt,draw:function(t,e,i){!function(t,e,i){var r=[];r=r.concat(e);var n=i.style,o=void 0===n?"solid":n,a=i.smooth,s=void 0!==a&&a,l=i.size,u=void 0===l?1:l,c=i.color,h=void 0===c?"currentColor":c,d=i.dashedValue,p=void 0===d?[2,2]:d,g=i.lineCap,f=i.lineJoin,y=v(s)?s>0:s;t.lineWidth=u,t.strokeStyle=h,m(g)?t.lineCap=g:t.lineCap=y?"round":"butt",m(f)?t.lineJoin=f:t.lineJoin=y?"round":"miter","dashed"===o?t.setLineDash(p):t.setLineDash([]);var _=u%2==1?.5:0;r.forEach((function(e){var i=e.coordinates;i.length>1&&(2!==i.length||i[0].x!==i[1].x&&i[0].y!==i[1].y?(t.save(),u%2==1&&t.translate(.5,.5),t.beginPath(),t.moveTo(i[0].x,i[0].y),re(t,i,s),t.stroke(),t.closePath(),t.restore()):(t.beginPath(),i[0].x===i[1].x?(t.moveTo(i[0].x+_,i[0].y),t.lineTo(i[1].x+_,i[1].y)):(t.moveTo(i[0].x,i[0].y+_),t.lineTo(i[1].x,i[1].y+_)),t.stroke(),t.closePath()))}))}(t,e,i)}};function oe(t,e){var i,r,n,o,a,l,u=[];u=u.concat(e);try{for(var c=s(u),h=c.next();!h.done;h=c.next()){var d=h.value;if(Math.abs((o=d,a=void 0,l=void 0,a=(n=t).x-o.x,l=n.y-o.y,Math.sqrt(a*a+l*l)-d.r))<2){var p=d.r,g=d.startAngle,v=d.endAngle,f=p*Math.cos(g)+d.x,y=p*Math.sin(g)+d.y,m=p*Math.cos(v)+d.x,_=p*Math.sin(v)+d.y;if(t.x<=Math.max(f,m)+2&&t.x>=Math.min(f,m)-2&&t.y<=Math.max(y,_)+2&&t.y>=Math.min(y,_)-2)return!0}}}catch(t){i={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}return!1}var ae={name:"arc",checkEventOn:oe,draw:function(t,e,i){!function(t,e,i){var r=[];r=r.concat(e);var n=i.style,o=void 0===n?"solid":n,a=i.size,s=void 0===a?1:a,l=i.color,u=void 0===l?"currentColor":l,c=i.dashedValue,h=void 0===c?[2,2]:c;t.lineWidth=s,t.strokeStyle=u,"dashed"===o?t.setLineDash(h):t.setLineDash([]),r.forEach((function(e){var i=e.x,r=e.y,n=e.r,o=e.startAngle,a=e.endAngle;t.beginPath(),t.arc(i,r,n,o,a),t.stroke(),t.closePath()}))}(t,e,i)}};function se(t){return"transparent"===t||"none"===t||/^[rR][gG][Bb][Aa]\(([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,){3}[\s]*0[\s]*\)$/.test(t)||/^[hH][Ss][Ll][Aa]\(([\s]*(360|3[0-5][0-9]|[012]?[0-9][0-9]?)[\s]*,)([\s]*((100|[0-9][0-9]?)%|0)[\s]*,){2}([\s]*0[\s]*)\)$/.test(t)}function le(t,e){var i=t.replace(/^#/,""),r=parseInt(i,16),n=r>>8&255,o=255&r;return"rgba(".concat(r>>16&255,", ").concat(n,", ").concat(o,", ").concat(null!=e?e:1,")")}function ue(t,e){var i,r,n=[];n=n.concat(e);try{for(var o=s(n),a=o.next();!a.done;a=o.next()){var l=a.value,u=l.x,c=l.y,h=l.r,d=t.x-u,p=t.y-c;if(!(d*d+p*p>h*h))return!0}}catch(t){i={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!1}var ce={name:"circle",checkEventOn:ue,draw:function(t,e,i){!function(t,e,i){var r=[];r=r.concat(e);var n=i.style,o=void 0===n?"fill":n,a=i.color,s=void 0===a?"currentColor":a,l=i.borderSize,u=void 0===l?1:l,c=i.borderColor,h=void 0===c?"currentColor":c,d=i.borderStyle,p=void 0===d?"solid":d,g=i.borderDashedValue,v=void 0===g?[2,2]:g,f=!("fill"!==o&&"stroke_fill"!==i.style||m(s)&&se(s));f&&(t.fillStyle=s,r.forEach((function(e){var i=e.x,r=e.y,n=e.r;t.beginPath(),t.arc(i,r,n,0,2*Math.PI),t.closePath(),t.fill()}))),("stroke"===o||"stroke_fill"===i.style)&&u>0&&!se(h)&&(t.strokeStyle=h,t.lineWidth=u,"dashed"===p?t.setLineDash(v):t.setLineDash([]),r.forEach((function(e){var i=e.x,r=e.y,n=e.r;(!f||n>u)&&(t.beginPath(),t.arc(i,r,n,0,2*Math.PI),t.closePath(),t.stroke())})))}(t,e,i)}};function he(t,e){var i,r,n=[];n=n.concat(e);try{for(var o=s(n),a=o.next();!a.done;a=o.next()){var l=a.value,u=l.x,c=l.width;c<4&&(u-=2,c=4);var h=l.y,d=l.height;if(d<4&&(h-=2,d=4),t.x>=u&&t.x<=u+c&&t.y>=h&&t.y<=h+d)return!0}}catch(t){i={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!1}function de(t,e,i){var r,n=[];n=n.concat(e);var o=i.style,a=void 0===o?"fill":o,s=i.color,l=void 0===s?"transparent":s,u=i.borderSize,c=void 0===u?1:u,h=i.borderColor,d=void 0===h?"transparent":h,p=i.borderStyle,g=void 0===p?"solid":p,v=i.borderRadius,f=void 0===v?0:v,y=i.borderDashedValue,_=void 0===y?[2,2]:y,x=null!==(r=t.roundRect)&&void 0!==r?r:t.rect,b=!("fill"!==a&&"stroke_fill"!==i.style||m(l)&&se(l));if(b&&(t.fillStyle=l,n.forEach((function(e){var i=e.x,r=e.y,n=e.width,o=e.height;t.beginPath(),x.call(t,i,r,n,o,f),t.closePath(),t.fill()}))),("stroke"===a||"stroke_fill"===i.style)&&c>0&&!se(d)){t.strokeStyle=d,t.fillStyle=d,t.lineWidth=c,"dashed"===g?t.setLineDash(_):t.setLineDash([]);var w=c%2==1?.5:0,C=Math.round(2*w);n.forEach((function(e){var i=e.x,r=e.y,n=e.width,o=e.height;n>2*c&&o>2*c?(t.beginPath(),x.call(t,i+w,r+w,n-C,o-C,f),t.closePath(),t.stroke()):b||t.fillRect(i,r,n,o)}))}}var pe={name:"rect",checkEventOn:he,draw:function(t,e,i){de(t,e,i)}},ge={A:7,C:6,H:1,L:2,M:2,Q:4,S:4,T:2,V:1,Z:0},ve=[],fe=new Map,ye=/[a-zA-Z]|[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;function me(t,e,i){return t+(i?e:0)}function _e(t,e,i,r,n,o,a,s,l){var u=Math.abs(i),c=Math.abs(r);if(t===s&&e===l)return[];if(0===u||0===c)return[];var h=n%360*Math.PI/180,d=Math.cos(h),p=Math.sin(h),g=(t-s)/2,v=(e-l)/2,f=d*g+p*v,y=-p*g+d*v,m=Math.pow(f,2)/Math.pow(u,2)+Math.pow(y,2)/Math.pow(c,2);if(m>1){var _=Math.sqrt(m);u*=_,c*=_}var x=Math.pow(u,2),b=Math.pow(c,2),w=Math.pow(f,2),C=x*Math.pow(y,2)+b*w,E=Math.max(0,x*b-C),I=0===C?0:(o===a?-1:1)*Math.sqrt(E/C),T=I*(u*y/c),S=I*(-c*f/u),A=d*T-p*S+(t+s)/2,M=p*T+d*S+(e+l)/2,P=Math.atan2((y-S)/c,(f-T)/u),D=Math.atan2((-y-S)/c,(-f-T)/u)-P;D<0&&1===a?D+=2*Math.PI:D>0&&0===a&&(D-=2*Math.PI);for(var k=Math.ceil(Math.abs(D)/(Math.PI/2)),B=D/k,F=[],R=0;R<k;R++){var L=P+R*B,O=L+B,Y=4/3*Math.tan((O-L)/4),W=Math.cos(L),z=Math.sin(L),V=Math.cos(O),N=Math.sin(O),H=A+u*W*d-c*z*p,X=M+u*W*p+c*z*d,U=A+u*V*d-c*N*p,G=M+u*V*p+c*N*d,Z=-u*z*d-c*W*p,j=-u*z*p+c*W*d,q=-u*N*d-c*V*p,K=-u*N*p+c*V*d;F.push({type:"C",cp1X:H+Y*Z,cp1Y:X+Y*j,cp2X:U-Y*q,cp2Y:G-Y*K,x:U,y:G})}return F}function xe(t){var e=function(t){var e=[],i=0;ye.lastIndex=0;for(var r=ye.exec(t);null!==r;){if(!/^[\s,]*$/.test(t.slice(i,r.index)))return null;var n=r[0];if(/^[a-zA-Z]$/.test(n))e.push(n);else{var o=Number(n);if(!isFinite(o))return null;e.push(o)}i=ye.lastIndex,r=ye.exec(t)}return/^[\s,]*$/.test(t.slice(i))?e:null}(t);if(null===e)return ve;for(var i=[],r=0,n="",o=0,a=0,s=0,c=0,h=0,d=0,p=0,g=0,v="",f=!1;r<e.length;){if("string"==typeof e[r]){var y=(n=e[r++]).toUpperCase();if(void 0===ge[y])return ve;if("Z"===y){i.push({type:"Z"}),o=s,a=c,v="Z",n="";continue}f="M"===y}else if(""===n)return ve;var m=n.toUpperCase(),_=ge[m];if(r+_>e.length)return ve;for(var x=[],b=0;b<_;b++){var w=e[r+b];if("number"!=typeof w)return ve;x.push(w)}r+=_;var C=n===n.toLowerCase();switch(m){case"M":var E=me(x[0],o,C),I=me(x[1],a,C);f?(i.push({type:"M",x:E,y:I}),s=E,c=I,f=!1):i.push({type:"L",x:E,y:I}),o=E,a=I;break;case"L":o=me(x[0],o,C),a=me(x[1],a,C),i.push({type:"L",x:o,y:a});break;case"H":o=me(x[0],o,C),i.push({type:"L",x:o,y:a});break;case"V":a=me(x[0],a,C),i.push({type:"L",x:o,y:a});break;case"C":var T=me(x[0],o,C),S=me(x[1],a,C),A=me(x[2],o,C),M=me(x[3],a,C);E=me(x[4],o,C),I=me(x[5],a,C);i.push({type:"C",cp1X:T,cp1Y:S,cp2X:A,cp2Y:M,x:E,y:I}),h=A,d=M,o=E,a=I;break;case"S":T="C"===v||"S"===v?2*o-h:o,S="C"===v||"S"===v?2*a-d:a,A=me(x[0],o,C),M=me(x[1],a,C),E=me(x[2],o,C),I=me(x[3],a,C);i.push({type:"C",cp1X:T,cp1Y:S,cp2X:A,cp2Y:M,x:E,y:I}),h=A,d=M,o=E,a=I;break;case"Q":var P=me(x[0],o,C),D=me(x[1],a,C);E=me(x[2],o,C),I=me(x[3],a,C);i.push({type:"Q",cpX:P,cpY:D,x:E,y:I}),p=P,g=D,o=E,a=I;break;case"T":P="Q"===v||"T"===v?2*o-p:o,D="Q"===v||"T"===v?2*a-g:a,E=me(x[0],o,C),I=me(x[1],a,C);i.push({type:"Q",cpX:P,cpY:D,x:E,y:I}),p=P,g=D,o=E,a=I;break;case"A":if(0!==x[3]&&1!==x[3]||0!==x[4]&&1!==x[4])return ve;E=me(x[5],o,C),I=me(x[6],a,C);0===x[0]||0===x[1]?i.push({type:"L",x:E,y:I}):i.push.apply(i,u([],l(_e(o,a,x[0],x[1],x[2],x[3],x[4],E,I)),!1)),o=E,a=I;break;default:return ve}v=m}return i}function be(t,e,i){var r=Array.isArray(e)?e:[e],n=i.style,o=void 0===n?"stroke":n,a=i.lineWidth,s=void 0===a?1:a,l=i.color,u=void 0===l?"currentColor":l;t.lineWidth=s,t.setLineDash([]),"fill"===o?t.fillStyle=u:t.strokeStyle=u,r.forEach((function(e){var i=e.x,r=e.y,n=function(t){var e=fe.get(t);if(void 0!==e)return e;var i=xe(t);if(fe.size>=256){var r=fe.keys().next().value;void 0!==r&&fe.delete(r)}return fe.set(t,i),i}(e.path);n.length>0&&(!function(t,e,i,r){t.beginPath(),e.forEach((function(e){switch(e.type){case"M":t.moveTo(e.x+i,e.y+r);break;case"L":t.lineTo(e.x+i,e.y+r);break;case"C":t.bezierCurveTo(e.cp1X+i,e.cp1Y+r,e.cp2X+i,e.cp2Y+r,e.x+i,e.y+r);break;case"Q":t.quadraticCurveTo(e.cpX+i,e.cpY+r,e.x+i,e.y+r);break;case"Z":t.closePath()}}))}(t,n,i,r),"fill"===o?t.fill():t.stroke())}))}var we={name:"path",checkEventOn:he,draw:function(t,e,i){be(t,e,i)}};function Ce(t,e){var i,r,n=[];n=n.concat(e);try{for(var o=s(n),a=o.next();!a.done;a=o.next()){for(var l=a.value,u=!1,c=l.coordinates,h=0,d=c.length-1;h<c.length;d=h++)c[h].y>t.y!=c[d].y>t.y&&t.x<(c[d].x-c[h].x)*(t.y-c[h].y)/(c[d].y-c[h].y)+c[h].x&&(u=!u);if(u)return!0}}catch(t){i={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return!1}var Ee={name:"polygon",checkEventOn:Ce,draw:function(t,e,i){!function(t,e,i){var r=[];r=r.concat(e);var n=i.style,o=void 0===n?"fill":n,a=i.color,s=void 0===a?"currentColor":a,l=i.borderSize,u=void 0===l?1:l,c=i.borderColor,h=void 0===c?"currentColor":c,d=i.borderStyle,p=void 0===d?"solid":d,g=i.borderDashedValue,v=void 0===g?[2,2]:g;"fill"!==o&&"stroke_fill"!==i.style||m(s)&&se(s)||(t.fillStyle=s,r.forEach((function(e){var i=e.coordinates;t.beginPath(),t.moveTo(i[0].x,i[0].y);for(var r=1;r<i.length;r++)t.lineTo(i[r].x,i[r].y);t.closePath(),t.fill()}))),("stroke"===o||"stroke_fill"===i.style)&&u>0&&!se(h)&&(t.strokeStyle=h,t.lineWidth=u,"dashed"===p?t.setLineDash(v):t.setLineDash([]),r.forEach((function(e){var i=e.coordinates;t.beginPath(),t.moveTo(i[0].x,i[0].y);for(var r=1;r<i.length;r++)t.lineTo(i[r].x,i[r].y);t.closePath(),t.stroke()})))}(t,e,i)}};function Ie(t,e){var i=e.size,r=void 0===i?12:i,n=e.paddingLeft,o=void 0===n?0:n,a=e.paddingTop,s=void 0===a?0:a,l=e.paddingRight,u=void 0===l?0:l,c=e.paddingBottom,h=void 0===c?0:c,d=e.weight,p=void 0===d?"normal":d,g=e.family,v=t.x,f=t.y,y=t.text,m=t.align,_=void 0===m?"left":m,x=t.baseline,b=void 0===x?"top":x,w=t.width,C=t.height,E=null!=w?w:o+S(y,r,p,g)+u,I=null!=C?C:s+r+h,T=0;switch(_){case"left":case"start":T=v;break;case"right":case"end":T=v-E;break;default:T=v-E/2}var A=0;switch(b){case"top":case"hanging":A=f;break;case"bottom":case"ideographic":case"alphabetic":A=f-I;break;default:A=f-I/2}return{x:T,y:A,width:E,height:I}}function Te(t,e,i){var r,n,o=[];o=o.concat(e);try{for(var a=s(o),l=a.next();!l.done;l=a.next()){var u=Ie(l.value,i),c=u.x,h=u.y,d=u.width,p=u.height;if(t.x>=c&&t.x<=c+d&&t.y>=h&&t.y<=h+p)return!0}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return!1}var Se={name:"text",checkEventOn:Te,draw:function(t,e,i){!function(t,e,i){var n=[];n=n.concat(e);var o=i.color,a=void 0===o?"currentColor":o,s=i.size,l=void 0===s?12:s,u=i.family,c=i.weight,h=i.paddingLeft,d=void 0===h?0:h,p=i.paddingTop,g=void 0===p?0:p,v=i.paddingRight,f=void 0===v?0:v,y=n.map((function(t){return Ie(t,i)}));de(t,y,r(r({},i),{color:i.backgroundColor})),t.textAlign="left",t.textBaseline="top",t.font=T(l,c,u),t.fillStyle=a,n.forEach((function(e,i){var r=y[i];t.fillText(e.text,r.x+d,r.y+g,r.width-d-f)}))}(t,e,i)}},Ae={};[ce,ne,Ee,pe,Se,ae,we].forEach((function(t){Ae[t.name]=$t.extend(t)}));var Me=function(t){function e(e){var i=t.call(this)||this;return i._widget=e,i}return i(e,t),e.prototype.getWidget=function(){return this._widget},e.prototype.createFigure=function(t,e){var i=function(t){var e;return null!==(e=Ae[t])&&void 0!==e?e:null}(t.name);if(null!==i){var r=new i(t);if(f(e)){for(var n in e)e.hasOwnProperty(n)&&r.registerEvent(n,e[n]);this.addChild(r)}return r}return null},e.prototype.draw=function(t){this.clear(),this.drawImp(t)},e.prototype.checkEventOn=function(t){return!0},e}(Qt),Pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.eachChildren=function(t){for(var e=this.getWidget().getPane().getChart().getChartStore(),i=e.getVisibleRangeDataList(),r=e.getBarSpace(),n=i.length,o=0;o<n;)t(i[o],r,o),++o},e}(Me),De=function(t){function e(){var e=t.apply(this,u([],l(arguments),!1))||this;return e._ripplePoint=e.createFigure({name:"circle",attrs:{x:0,y:0,r:0},styles:{style:"fill"}}),e._animationFrameTime=0,e._animation=new w({iterationCount:1/0}).doFrame((function(t){e._animationFrameTime=t;var i=e.getWidget().getPane();i.getChart().updatePane(0,i.getId())})),e}return i(e,t),e.prototype.drawImp=function(t){var e,i,r,n=this.getWidget(),o=n.getPane(),a=o.getChart(),s=a.getDataList().length-1,l=n.getBounding(),u=o.getYAxisComponentById(),c=a.getStyles().candle.area,h=[],p=Number.MAX_SAFE_INTEGER,g=Number.MIN_SAFE_INTEGER,y=null;if(this.eachChildren((function(t){var e=t.x,i=t.data.current,r=null==i?void 0:i[c.value];if(v(r)){var n=u.convertToPixel(r);g===Number.MIN_SAFE_INTEGER&&(g=e),h.push({x:e,y:n}),p=Math.min(p,n),t.dataIndex===s&&(y={x:e,y:n})}})),h.length>0){null===(e=this.createFigure({name:"line",attrs:{coordinates:h},styles:{color:c.lineColor,size:c.lineSize,smooth:c.smooth}}))||void 0===e||e.draw(t);var m=c.backgroundColor,_="";if(d(m)){var x=t.createLinearGradient(0,l.height,0,p);try{m.forEach((function(t){var e=t.offset,i=t.color;x.addColorStop(e,i)}))}catch(t){}_=x}else _=m;t.fillStyle=_,t.beginPath(),t.moveTo(g,l.height),t.lineTo(h[0].x,h[0].y),re(t,h,c.smooth),t.lineTo(h[h.length-1].x,l.height),t.closePath(),t.fill()}var b=c.point;if(b.show&&f(y)){null===(i=this.createFigure({name:"circle",attrs:{x:y.x,y:y.y,r:b.radius},styles:{style:"fill",color:b.color}}))||void 0===i||i.draw(t);var w=b.rippleRadius;if(b.animation&&v(b.animationDuration)&&b.animationDuration>0){var C=Math.min(this._animationFrameTime/b.animationDuration,1);w=b.radius+C*(b.rippleRadius-b.radius),this._animation.setDuration(b.animationDuration).start()}else this.stopAnimation();null===(r=this._ripplePoint)||void 0===r||r.setAttrs({x:y.x,y:y.y,r:w}).setStyles({style:"fill",color:b.rippleColor}).draw(t)}else this.stopAnimation()},e.prototype.stopAnimation=function(){this._animationFrameTime=0,this._animation.cancel()},e}(Pe),ke=function(t){function e(){var e=t.apply(this,u([],l(arguments),!1))||this;return e._boundCandleBarClickEvent=function(t){return function(){return e.getWidget().getPane().getChart().getChartStore().executeAction("onCandleBarClick",t),!1}},e}return i(e,t),e.prototype.drawImp=function(t){var e=this,i=this.getWidget().getPane(),r=i.getId()===j,n=i.getChart().getChartStore(),o=this.getCandleBarOptions();if(null!==o){var a=o.type,s=o.styles,l=0,u=0;if("ohlc"===o.type){var c=n.getBarSpace().gapBar;(l=Math.min(Math.max(Math.round(.2*c),1),8))>2&&l%2==1&&l--,u=Math.floor(l/2)}var h=i.getYAxisComponentById(o.yAxisId);this.eachChildren((function(i,n){var o,c=i.x,d=i.data,p=d.current,g=d.prev;if(f(p)){var v=p.open,y=p.high,m=p.low,_=p.close,x="current_open"===s.compareRule?v:null!==(o=null==g?void 0:g.close)&&void 0!==o?o:_,b=[];_>x?(b[0]=s.upColor,b[1]=s.upBorderColor,b[2]=s.upWickColor):_<x?(b[0]=s.downColor,b[1]=s.downBorderColor,b[2]=s.downWickColor):(b[0]=s.noChangeColor,b[1]=s.noChangeBorderColor,b[2]=s.noChangeWickColor);var w=h.convertToPixel(v),C=h.convertToPixel(_),E=[w,C,h.convertToPixel(y),h.convertToPixel(m)];E.sort((function(t,e){return t-e}));var I=n.gapBar%2==0?1:0,T=[];switch(a){case"candle_solid":T=e._createSolidBar(c,E,n,b,I);break;case"candle_stroke":T=e._createStrokeBar(c,E,n,b,I);break;case"candle_up_stroke":T=_>v?e._createStrokeBar(c,E,n,b,I):e._createSolidBar(c,E,n,b,I);break;case"candle_down_stroke":T=v>_?e._createStrokeBar(c,E,n,b,I):e._createSolidBar(c,E,n,b,I);break;case"ohlc":T=[{name:"rect",attrs:[{x:c-u,y:E[0],width:l,height:E[3]-E[0]},{x:c-n.halfGapBar,y:w+l>E[3]?E[3]-l:w,width:n.halfGapBar-u,height:l},{x:c+u,y:C+l>E[3]?E[3]-l:C,width:n.halfGapBar-u,height:l}],styles:{color:b[0]}}]}T.forEach((function(n){var o,a=null;r&&(a={mouseClickEvent:e._boundCandleBarClickEvent(i)}),null===(o=e.createFigure(n,null!=a?a:void 0))||void 0===o||o.draw(t)}))}}))}},e.prototype.getCandleBarOptions=function(){var t=this.getWidget().getPane(),e=t.getDefaultYAxisId();if(!f(e))return null;var i=t.getChart().getStyles().candle;return{yAxisId:e,type:i.type,styles:i.bar}},e.prototype._createSolidBar=function(t,e,i,r,n){return[{name:"rect",attrs:{x:t,y:e[0],width:1,height:e[3]-e[0]},styles:{color:r[2]}},{name:"rect",attrs:{x:t-i.halfGapBar,y:e[1],width:i.gapBar+n,height:Math.max(1,e[2]-e[1])},styles:{style:"stroke_fill",color:r[0],borderColor:r[1]}}]},e.prototype._createStrokeBar=function(t,e,i,r,n){return[{name:"rect",attrs:[{x:t,y:e[0],width:1,height:e[1]-e[0]},{x:t,y:e[2],width:1,height:e[3]-e[2]}],styles:{color:r[2]}},{name:"rect",attrs:{x:t-i.halfGapBar,y:e[1],width:i.gapBar+n,height:Math.max(1,e[2]-e[1])},styles:{style:"stroke",borderColor:r[1]}}]},e}(Pe),Be=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i,r=this.getWidget().getPane(),n=r.getChart().getChartStore(),o=n.getStyles().candle.priceMark,a=o.high,s=o.low;if(o.show&&(a.show||s.show)){var l=n.getVisibleRangeHighLowPrice(),u=null!==(i=null===(e=n.getSymbol())||void 0===e?void 0:e.pricePrecision)&&void 0!==i?i:O,c=r.getYAxisComponentById(),h=l[0],d=h.price,p=h.x,g=l[1],v=g.price,f=g.x,y=c.convertToPixel(d),m=c.convertToPixel(v),_=n.getDecimalFold(),x=n.getThousandsSeparator();a.show&&d!==Number.MIN_SAFE_INTEGER&&this._drawMark(t,_.format(x.format(H(d,u))),{x:p,y:y},y<m?[-2,-5]:[2,5],a),s.show&&v!==Number.MAX_SAFE_INTEGER&&this._drawMark(t,_.format(x.format(H(v,u))),{x:f,y:m},y<m?[2,5]:[-2,-5],s)}},e.prototype._drawMark=function(t,e,i,r,n){var o,a,s,l=i.x,u=i.y+r[0];null===(o=this.createFigure({name:"line",attrs:{coordinates:[{x:l-2,y:u+r[0]},{x:l,y:u},{x:l+2,y:u+r[0]}]},styles:{color:n.color}}))||void 0===o||o.draw(t);var c=0,h=0,d="left";l>this.getWidget().getBounding().width/2?(h=(c=l-5)-n.textOffset,d="right"):(d="left",h=(c=l+5)+n.textOffset);var p=u+r[1];null===(a=this.createFigure({name:"line",attrs:{coordinates:[{x:l,y:u},{x:l,y:p},{x:c,y:p}]},styles:{color:n.color}}))||void 0===a||a.draw(t),null===(s=this.createFigure({name:"text",attrs:{x:h,y:p,text:e,align:d,baseline:"middle"},styles:{color:n.color,size:n.textSize,family:n.textFamily,weight:n.textWeight}}))||void 0===s||s.draw(t)},e}(Me),Fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i,r,n=this.getWidget(),o=n.getPane(),a=n.getBounding(),s=o.getChart().getChartStore(),l=s.getStyles().candle.priceMark,u=l.last,c=u.line;if(l.show&&u.show&&c.show){var h=o.getYAxisComponentById(),d=s.getDataList(),p=d[d.length-1];if(f(p)){var g=p.close,v=p.open,y="current_open"===u.compareRule?v:null!==(i=null===(e=d[d.length-2])||void 0===e?void 0:e.close)&&void 0!==i?i:g,m=h.convertToNicePixel(g),_="";_=g>y?u.upColor:g<y?u.downColor:u.noChangeColor,null===(r=this.createFigure({name:"line",attrs:{coordinates:[{x:0,y:m},{x:a.width,y:m}]},styles:{style:c.style,color:_,size:c.size,dashedValue:c.dashedValue}}))||void 0===r||r.draw(t)}}},e}(Me),Re={second:"HH:mm:ss",minute:"HH:mm",hour:"MM-DD HH:mm",day:"YYYY-MM-DD",week:"YYYY-MM-DD",month:"YYYY-MM",year:"YYYY"},Le={second:"HH:mm:ss",minute:"YYYY-MM-DD HH:mm",hour:"YYYY-MM-DD HH:mm",day:"YYYY-MM-DD",week:"YYYY-MM-DD",month:"YYYY-MM",year:"YYYY"},Oe={"zh-CN":{time:"时间:",open:"开:",high:"高:",low:"低:",close:"收:",volume:"成交量:",turnover:"成交额:",change:"涨幅:",second:"秒",minute:"",hour:"小时",day:"天",week:"周",month:"月",year:"年"},"en-US":{time:"Time: ",open:"Open: ",high:"High: ",low:"Low: ",close:"Close: ",volume:"Volume: ",turnover:"Turnover: ",change:"Change: ",second:"S",minute:"",hour:"H",day:"D",week:"W",month:"M",year:"Y"}};function Ye(t,e){var i;return null!==(i=Oe[e][t])&&void 0!==i?i:t}var We=function(t){function e(e){var i=t.call(this,e)||this;return i._activeFeatureInfo=null,i._featureClickEvent=function(t,e){return function(){return i.getWidget().getPane().getChart().getChartStore().executeAction(t,e),!0}},i._featureMouseMoveEvent=function(t){return function(){return i._activeFeatureInfo=t,!0}},i.registerEvent("mouseMoveEvent",(function(t){return i._activeFeatureInfo=null,!1})),i}return i(e,t),e.prototype.drawImp=function(t){var e=this.getWidget(),i=e.getPane().getChart().getChartStore();if(f(i.getCrosshair().kLineData)){var r=e.getBounding(),n=i.getStyles().indicator.tooltip,o=n.offsetLeft,a=n.offsetTop,s=n.offsetRight;this.drawIndicatorTooltip(t,o,a,r.width-s)}},e.prototype.drawIndicatorTooltip=function(t,e,i,r){var n=this,o=this.getWidget().getPane(),a=o.getChart().getChartStore(),s=a.getStyles().indicator.tooltip;if(this.isDrawTooltip(a.getCrosshair(),s)){var l=a.getIndicatorsByPaneId(o.getId()),u=s.title,c=s.legend;l.forEach((function(o){var a=0,s={x:e,y:i},l=n.getIndicatorTooltipData(o),h=l.name,d=l.calcParamsText,p=l.legends,g=l.features,v=h.length>0,f=p.length>0;if(v||f){var y=n.classifyTooltipFeatures(g);if(a=n.drawStandardTooltipFeatures(t,y[0],s,o,e,a,r),v){var m=h;d.length>0&&(m="".concat(m).concat(d));var _=u.color;a=n.drawStandardTooltipLegends(t,[{title:{text:"",color:_},value:{text:m,color:_}}],s,e,a,r,u)}a=n.drawStandardTooltipFeatures(t,y[1],s,o,e,a,r),f&&(a=n.drawStandardTooltipLegends(t,p,s,e,a,r,c)),a=n.drawStandardTooltipFeatures(t,y[2],s,o,e,a,r),i=s.y+a}}))}return i},e.prototype.drawStandardTooltipFeatures=function(t,e,i,r,n,o,a){var s=this;if(e.length>0){var l=0,u=0;e.forEach((function(e){var i=e.marginLeft,r=void 0===i?0:i,n=e.marginTop,o=void 0===n?0:n,a=e.marginRight,s=void 0===a?0:a,c=e.marginBottom,h=void 0===c?0:c,d=e.paddingLeft,p=void 0===d?0:d,g=e.paddingTop,v=void 0===g?0:g,f=e.paddingRight,y=void 0===f?0:f,m=e.paddingBottom,_=void 0===m?0:m,x=e.size,b=void 0===x?0:x,w=e.type,C=e.content,E=0;if("icon_font"===w){var I=C;t.font=T(b,"normal",I.family),E=t.measureText(I.code).width}else E=b;l+=r+p+E+y+s,u=Math.max(u,o+v+b+_+h)})),i.x+l>a?(i.x=n,i.y+=o,o=u):o=Math.max(o,u);var c=this.getWidget().getPane().getId();e.forEach((function(e){var n,o,a,l,u,h=e.marginLeft,d=void 0===h?0:h,p=e.marginTop,g=void 0===p?0:p,v=e.marginRight,y=void 0===v?0:v,m=e.paddingLeft,_=void 0===m?0:m,x=e.paddingTop,b=void 0===x?0:x,w=e.paddingRight,C=void 0===w?0:w,E=e.paddingBottom,I=void 0===E?0:E,T=e.backgroundColor,S=e.activeBackgroundColor,A=e.borderRadius,M=e.size,P=void 0===M?0:M,D=e.color,k=e.activeColor,B=e.type,F=e.content,R=D,L=T;(null===(n=s._activeFeatureInfo)||void 0===n?void 0:n.paneId)===c&&(null===(o=s._activeFeatureInfo.indicator)||void 0===o?void 0:o.id)===(null==r?void 0:r.id)&&s._activeFeatureInfo.feature.id===e.id&&(R=null!=k?k:D,L=null!=S?S:T);var O="onCandleTooltipFeatureClick",Y={paneId:c,feature:e};f(r)&&(O="onIndicatorTooltipFeatureClick",Y.indicator=r);var W={mouseDownEvent:s._featureClickEvent(O,Y),mouseMoveEvent:s._featureMouseMoveEvent(Y)},z=0;if("icon_font"===B){var V=F;null===(a=s.createFigure({name:"text",attrs:{text:V.code,x:i.x+d,y:i.y+g},styles:{paddingLeft:_,paddingTop:b,paddingRight:C,paddingBottom:I,borderRadius:A,size:P,family:V.family,color:R,backgroundColor:L}},W))||void 0===a||a.draw(t),z=t.measureText(V.code).width}else{null===(l=s.createFigure({name:"rect",attrs:{x:i.x+d,y:i.y+g,width:P,height:P},styles:{paddingLeft:_,paddingTop:b,paddingRight:C,paddingBottom:I,color:L}},W))||void 0===l||l.draw(t);var N=F;null===(u=s.createFigure({name:"path",attrs:{path:N.path,x:i.x+d+_,y:i.y+g+b,width:P,height:P},styles:{style:N.style,lineWidth:N.lineWidth,color:R}}))||void 0===u||u.draw(t),z=P}i.x+=d+_+z+C+y}))}return o},e.prototype.drawStandardTooltipLegends=function(t,e,i,r,n,o,a){var s=this;if(e.length>0){var l=a.marginLeft,u=a.marginTop,c=a.marginRight,h=a.marginBottom,d=a.size,p=a.family,g=a.weight;t.font=T(d,g,p),e.forEach((function(e){var a,v,f=e.title,y=e.value,m=t.measureText(f.text).width,_=m+t.measureText(y.text).width,x=u+d+h;i.x+l+_+c>o?(i.x=r,i.y+=n,n=x):n=Math.max(n,x),f.text.length>0&&(null===(a=s.createFigure({name:"text",attrs:{x:i.x+l,y:i.y+u,text:f.text},styles:{color:f.color,size:d,family:p,weight:g}}))||void 0===a||a.draw(t)),null===(v=s.createFigure({name:"text",attrs:{x:i.x+l+m,y:i.y+u,text:y.text},styles:{color:y.color,size:d,family:p,weight:g}}))||void 0===v||v.draw(t),i.x+=l+_+c}))}return n},e.prototype.isDrawTooltip=function(t,e){var i=e.showRule;return"always"===i||"follow_cross"===i&&m(t.paneId)},e.prototype.getIndicatorTooltipData=function(t){var e,i=this.getWidget().getPane().getChart().getChartStore(),r=i.getStyles().indicator,n=r.tooltip,o=n.title,a="",s="";if(o.show&&(o.showName&&(a=t.shortName),o.showParams)){var l=t.calcParams;l.length>0&&(s="(".concat(l.join(","),")"))}var u={name:a,calcParamsText:s,legends:[],features:n.features},c=i.getCrosshair().dataIndex,h=t.result,d=i.getInnerFormatter(),y=i.getDecimalFold(),_=i.getThousandsSeparator(),x=[];if(t.visible){var b=i.getBarSpace(),w=null!==(e=h[c])&&void 0!==e?e:{},C=n.legend.defaultValue;kt(t,c,b,r,(function(e,i){if(m(e.title)){var r=i.color,n=w[e.key];v(n)&&(n=H(n,t.precision),t.shouldFormatBigNumber&&(n=d.formatBigNumber(n)),n=y.format(_.format(n))),x.push({title:{text:e.title,color:r},value:{text:null!=n?n:C,color:r}})}})),u.legends=x}if(p(t.createTooltipDataSource)){var E=this.getWidget(),I=E.getPane(),T=I.getChart(),S=t.createTooltipDataSource({chart:T,indicator:t,crosshair:i.getCrosshair(),bounding:E.getBounding(),xAxis:I.getChart().getXAxisPane().getXAxisComponent(),yAxis:I.getYAxisComponentById(t.yAxisId)}),A=S.name,M=S.calcParamsText,P=S.legends,D=S.features;if(o.show&&(m(A)&&o.showName&&(u.name=A),m(M)&&o.showParams&&(u.calcParamsText=M)),f(D)&&(u.features=D),f(P)&&t.visible){var k=[],B=r.tooltip.legend.color;P.forEach((function(t){var e={text:"",color:B};g(t.title)?e=t.title:e.text=t.title;var i={text:"",color:B};g(t.value)?i=t.value:i.text=t.value,v(Number(i.text))&&(i.text=y.format(_.format(i.text))),k.push({title:e,value:i})})),u.legends=k}}return u},e.prototype.classifyTooltipFeatures=function(t){var e=[],i=[],r=[];return t.forEach((function(t){switch(t.position){case"left":e.push(t);break;case"middle":i.push(t);break;case"right":r.push(t)}})),[e,i,r]},e}(Me),ze=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e=this.getWidget(),i=e.getPane().getChart().getChartStore(),r=i.getCrosshair();if(f(r.kLineData)){var n=e.getBounding(),o=i.getStyles(),a=o.candle,s=o.indicator;if("rect"===a.tooltip.showType&&"rect"===s.tooltip.showType){var l=this.isDrawTooltip(r,a.tooltip),u=this.isDrawTooltip(r,s.tooltip);this._drawRectTooltip(t,l,u,a.tooltip.offsetTop)}else if("standard"===a.tooltip.showType&&"standard"===s.tooltip.showType){var c=a.tooltip,h=c.offsetLeft,d=c.offsetTop,p=c.offsetRight,g=n.width-p,v=this._drawCandleStandardTooltip(t,h,d,g);this.drawIndicatorTooltip(t,h,v,g)}else if("rect"===a.tooltip.showType&&"standard"===s.tooltip.showType){var y=a.tooltip,m=(h=y.offsetLeft,d=y.offsetTop,p=y.offsetRight,g=n.width-p,this.drawIndicatorTooltip(t,h,d,g));l=this.isDrawTooltip(r,a.tooltip);this._drawRectTooltip(t,l,!1,m)}else{var _=a.tooltip,x=(h=_.offsetLeft,d=_.offsetTop,p=_.offsetRight,g=n.width-p,this._drawCandleStandardTooltip(t,h,d,g));u=this.isDrawTooltip(r,s.tooltip);this._drawRectTooltip(t,!1,u,x)}}},e.prototype._drawCandleStandardTooltip=function(t,e,i,n){var o,a=this.getWidget().getPane().getChart().getChartStore(),s=a.getStyles().candle.tooltip,l=s.legend,u=0,c={x:e,y:i},h=a.getCrosshair();if(this.isDrawTooltip(h,s)){var d=s.title;if(d.show){var p=null!==(o=a.getPeriod())&&void 0!==o?o:{},g=p.type,v=void 0===g?"":g,f=p.span,y=void 0===f?"":f,m=Z(d.template,r(r({},a.getSymbol()),{period:"".concat(y).concat(Ye(v,a.getLocale()))})),_=d.color,x=this.drawStandardTooltipLegends(t,[{title:{text:"",color:_},value:{text:m,color:_}}],{x:e,y:i},e,0,n,d);c.y=c.y+x}var b=this._getCandleTooltipLegends(),w=this.classifyTooltipFeatures(s.features);u=this.drawStandardTooltipFeatures(t,w[0],c,null,e,u,n),u=this.drawStandardTooltipFeatures(t,w[1],c,null,e,u,n),b.length>0&&(u=this.drawStandardTooltipLegends(t,b,c,e,u,n,l)),u=this.drawStandardTooltipFeatures(t,w[2],c,null,e,u,n)}return c.y+u},e.prototype._drawRectTooltip=function(t,e,i,r){var n,o,a=this,s=this.getWidget(),l=s.getPane(),u=l.getChart().getChartStore(),c=u.getStyles(),h=c.candle,d=c.indicator,p=h.tooltip,g=d.tooltip;if(e||i){var v=this._getCandleTooltipLegends(),f=p.offsetLeft,y=p.offsetTop,m=p.offsetRight,_=p.offsetBottom,x=p.legend,b=x.marginLeft,w=x.marginRight,C=x.marginTop,E=x.marginBottom,I=x.size,S=x.weight,A=x.family,M=p.rect,P=M.position,D=M.paddingLeft,k=M.paddingRight,B=M.paddingTop,F=M.paddingBottom,R=M.offsetLeft,L=M.offsetRight,O=M.offsetTop,Y=M.offsetBottom,W=M.borderSize,z=M.borderRadius,V=M.borderColor,N=M.color,H=0,X=0,U=0;e&&(t.font=T(I,S,A),v.forEach((function(e){var i=e.title,r=e.value,n="".concat(i.text).concat(r.text),o=t.measureText(n).width+b+w;H=Math.max(H,o)})),U+=(E+C+I)*v.length);var G=g.legend,Z=G.marginLeft,q=G.marginRight,K=G.marginTop,Q=G.marginBottom,$=G.size,J=G.weight,tt=G.family,et=[];if(i){var it=u.getIndicatorsByPaneId(l.getId());t.font=T($,J,tt),it.forEach((function(e){var i=a.getIndicatorTooltipData(e).legends;et.push(i),i.forEach((function(e){var i=e.title,r=e.value,n="".concat(i.text).concat(r.text),o=t.measureText(n).width+Z+q;H=Math.max(H,o),U+=K+Q+$}))}))}if(0!==(X+=H)&&0!==U){var rt=u.getCrosshair(),nt=s.getBounding(),ot=l.getYAxisWidget().getBounding();X+=2*W+D+k,U+=2*W+B+F;var at=nt.width/2,st="pointer"===P&&rt.paneId===j,lt=(null!==(n=rt.realX)&&void 0!==n?n:0)>at,ut=0;if(st){var ct=rt.realX;ut=lt?ct-L-X:ct+R}else{var ht=this.getWidget().getPane().getYAxisComponentById();lt?(ut=R+f,ht.inside&&"left"===ht.position&&(ut+=ot.width)):(ut=nt.width-L-X-m,ht.inside&&"right"===ht.position&&(ut-=ot.width))}var dt=r+O;if(st)(dt=rt.y-U/2)+U>nt.height-Y-_&&(dt=nt.height-Y-U-_),dt<r+O&&(dt=r+O+y);null===(o=this.createFigure({name:"rect",attrs:{x:ut,y:dt,width:X,height:U},styles:{style:"stroke_fill",color:N,borderColor:V,borderSize:W,borderRadius:z}}))||void 0===o||o.draw(t);var pt=ut+W+D+b,gt=dt+W+B;if(e&&v.forEach((function(e){var i,r;gt+=C;var n=e.title;null===(i=a.createFigure({name:"text",attrs:{x:pt,y:gt,text:n.text},styles:{color:n.color,size:I,family:A,weight:S}}))||void 0===i||i.draw(t);var o=e.value;null===(r=a.createFigure({name:"text",attrs:{x:ut+X-W-w-k,y:gt,text:o.text,align:"right"},styles:{color:o.color,size:I,family:A,weight:S}}))||void 0===r||r.draw(t),gt+=I+E})),i){var vt=ut+W+D+Z;et.forEach((function(e){e.forEach((function(e){var i,r;gt+=K;var n=e.title,o=e.value;null===(i=a.createFigure({name:"text",attrs:{x:vt,y:gt,text:n.text},styles:{color:n.color,size:$,family:tt,weight:J}}))||void 0===i||i.draw(t),null===(r=a.createFigure({name:"text",attrs:{x:ut+X-W-q-k,y:gt,text:o.text,align:"right"},styles:{color:o.color,size:$,family:tt,weight:J}}))||void 0===r||r.draw(t),gt+=$+Q}))}))}}}},e.prototype._getCandleTooltipLegends=function(){var t,e,i,n,o,a,s,l,u=this.getWidget().getPane().getChart().getChartStore(),c=u.getStyles().candle,h=u.getDataList(),d=u.getInnerFormatter(),v=u.getDecimalFold(),y=u.getThousandsSeparator(),m=u.getLocale(),_=null!==(t=u.getSymbol())&&void 0!==t?t:{},x=_.pricePrecision,b=void 0===x?O:x,w=_.volumePrecision,C=void 0===w?Y:w,E=u.getPeriod(),I=null!==(e=u.getCrosshair().dataIndex)&&void 0!==e?e:0,T=c.tooltip.legend,S=T.color,A=T.defaultValue,M=T.template,P=null!==(i=h[I-1])&&void 0!==i?i:null,D=h[I],k=null!==(n=null==P?void 0:P.close)&&void 0!==n?n:D.close,B=D.close-k,F=r(r({},D),{time:d.formatDate(D.timestamp,Le[null!==(o=null==E?void 0:E.type)&&void 0!==o?o:"day"],"tooltip"),open:v.format(y.format(H(D.open,b))),high:v.format(y.format(H(D.high,b))),low:v.format(y.format(H(D.low,b))),close:v.format(y.format(H(D.close,b))),volume:v.format(y.format(d.formatBigNumber(H(null!==(a=D.volume)&&void 0!==a?a:A,C)))),turnover:v.format(y.format(H(null!==(s=D.turnover)&&void 0!==s?s:A,b))),change:0===k?A:"".concat(y.format(H(B/k*100)),"%")});return(p(M)?M({prev:P,current:D,next:null!==(l=h[I+1])&&void 0!==l?l:null},c):M).map((function(t){var e=t.title,i=t.value,n={text:"",color:S};g(e)?n=r({},e):n.text=e,n.text=Ye(n.text,m);var o={text:A,color:S};return g(i)?o=r({},i):o.text=i,f(/{change}/.exec(o.text))&&(o.color=0===B?c.priceMark.last.noChangeColor:B>0?c.priceMark.last.upColor:c.priceMark.last.downColor),o.text=Z(o.text,F),{title:n,value:o}}))},e}(We),Ve=function(t){function e(e){var i=t.call(this,e)||this;return i._activeFeatureInfo=null,i._featureClickEvent=function(t){return function(){return i.getWidget().getPane().getChart().getChartStore().executeAction("onCrosshairFeatureClick",t),!0}},i._featureMouseMoveEvent=function(t){return function(){return i._activeFeatureInfo=t,i.getWidget().setForceCursor("pointer"),!0}},i.registerEvent("mouseMoveEvent",(function(t){return i._activeFeatureInfo=null,i.getWidget().setForceCursor(null),!1})),i}return i(e,t),e.prototype.drawImp=function(t){var e,i,r=this,n=this.getWidget(),o=n.getPane(),a=n.getPane().getChart().getChartStore(),s=a.getCrosshair(),l=this.getWidget(),u=l.getPane().getYAxisComponentById();if(m(s.paneId)&&s.paneId===o.getId()&&u.isInCandle()){var c=a.getStyles().crosshair,h=c.horizontal.features;if(c.show&&c.horizontal.show&&h.length>0){var d="right"===u.position,p=l.getBounding(),g=0,v=c.horizontal.text;if(u.inside&&v.show){var f=u.convertFromPixel(s.y),y=u.getRange(),_=u.displayValueToText(u.realValueToDisplayValue(u.valueToRealValue(f,{range:y}),{range:y}),null!==(i=null===(e=a.getSymbol())||void 0===e?void 0:e.pricePrecision)&&void 0!==i?i:O);_=a.getDecimalFold().format(a.getThousandsSeparator().format(_)),g=v.paddingLeft+S(_,v.size,v.weight,v.family)+v.paddingRight}var x=g;d&&(x=p.width-g);var b=s.y;h.forEach((function(e){var i,n,o,a,l=e.marginLeft,u=void 0===l?0:l,c=e.marginTop,h=void 0===c?0:c,p=e.marginRight,g=void 0===p?0:p,v=e.paddingLeft,f=void 0===v?0:v,y=e.paddingTop,m=void 0===y?0:y,_=e.paddingRight,w=void 0===_?0:_,C=e.paddingBottom,E=void 0===C?0:C,I=e.color,T=e.activeColor,A=e.backgroundColor,M=e.activeBackgroundColor,P=e.borderRadius,D=e.size,k=void 0===D?0:D,B=e.type,F=e.content,R=k;"icon_font"===B&&(R=f+S((W=F).code,k,"normal",W.family)+w);d?x-=R+g:x+=u;var L=I,O=A;(null===(i=r._activeFeatureInfo)||void 0===i?void 0:i.feature.id)===e.id&&(L=null!=T?T:I,O=null!=M?M:A);var Y={mouseDownEvent:r._featureClickEvent({crosshair:s,feature:e}),mouseMoveEvent:r._featureMouseMoveEvent({crosshair:s,feature:e})};if("icon_font"===B){var W=F;null===(n=r.createFigure({name:"text",attrs:{text:W.code,x:x,y:b+h,baseline:"middle"},styles:{paddingLeft:f,paddingTop:m,paddingRight:w,paddingBottom:E,borderRadius:P,size:k,family:W.family,color:L,backgroundColor:O}},Y))||void 0===n||n.draw(t)}else{null===(o=r.createFigure({name:"rect",attrs:{x:x,y:b+h-k/2,width:k,height:k},styles:{paddingLeft:f,paddingTop:m,paddingRight:w,paddingBottom:E,color:O}},Y))||void 0===o||o.draw(t);var z=F;null===(a=r.createFigure({name:"path",attrs:{path:z.path,x:x+f,y:b+h+m-k/2,width:k,height:k},styles:{style:z.style,lineWidth:z.lineWidth,color:L}}))||void 0===a||a.draw(t)}d?x-=u:x+=R+g}))}}},e}(Me),Ne=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e=this.getWidget(),i=e.getPane(),r=e.getBounding(),n=e.getPane().getChart().getChartStore(),o=n.getCrosshair(),a=n.getStyles().crosshair;if(m(o.paneId)&&a.show){if(o.paneId===i.getId()){var s=o.y;this._drawLine(t,[{x:0,y:s},{x:r.width,y:s}],a.horizontal)}var l=o.realX;this._drawLine(t,[{x:l,y:0},{x:l,y:r.height}],a.vertical)}},e.prototype._drawLine=function(t,e,i){var r;if(i.show){var n=i.line;n.show&&(null===(r=this.createFigure({name:"line",attrs:{coordinates:e},styles:n}))||void 0===r||r.draw(t))}},e}(Me),He=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i,r=this.getWidget(),n=this.getWidget().getPane(),o=n.getChart(),a=r.getBounding(),s=o.getStyles().grid;if(s.show){t.save(),t.globalCompositeOperation="destination-over";var l=s.horizontal;if(l.show){var u=n.getYAxisComponentById().getTicks().map((function(t){return{coordinates:[{x:0,y:t.coord},{x:a.width,y:t.coord}]}}));null===(e=this.createFigure({name:"line",attrs:u,styles:l}))||void 0===e||e.draw(t)}var c=s.vertical;if(c.show){u=o.getXAxisPane().getXAxisComponent().getTicks().map((function(t){return{coordinates:[{x:t.coord,y:0},{x:t.coord,y:a.height}]}}));null===(i=this.createFigure({name:"line",attrs:u,styles:c}))||void 0===i||i.draw(t)}t.restore()}},e}(Me),Xe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getCandleBarOptions=function(){var t,e,i=this.getWidget().getPane(),r=i.getChart().getChartStore(),n=r.getIndicatorsByPaneId(i.getId());try{for(var o=s(n),a=o.next();!a.done;a=o.next()){var l=a.value,u=i.getYAxisComponentById(l.yAxisId);if(l.shouldOhlc&&l.visible&&!u.isInCandle()){var c=l.styles,h=r.getStyles().indicator,d=V(c,"ohlc.compareRule",h.ohlc.compareRule),p=V(c,"ohlc.upColor",h.ohlc.upColor),g=V(c,"ohlc.downColor",h.ohlc.downColor),v=V(c,"ohlc.noChangeColor",h.ohlc.noChangeColor);return{yAxisId:l.yAxisId,type:"ohlc",styles:{compareRule:d,upColor:p,downColor:g,noChangeColor:v,upBorderColor:p,downBorderColor:g,noChangeBorderColor:v,upWickColor:p,downWickColor:g,noChangeWickColor:v}}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return null},e.prototype.drawImp=function(e){var i=this;t.prototype.drawImp.call(this,e);var n=this.getWidget(),o=n.getPane(),a=o.getChart(),s=n.getBounding(),l=a.getXAxisPane().getXAxisComponent(),u=a.getChartStore(),c=u.getIndicatorsByPaneId(o.getId()),h=u.getStyles().indicator;e.save(),c.forEach((function(t){var n=o.getYAxisComponentById(t.yAxisId);if(t.visible){t.zLevel<0?e.globalCompositeOperation="destination-over":e.globalCompositeOperation="source-over";var u=!1;if(null!==t.draw&&(e.save(),u=t.draw({ctx:e,chart:a,indicator:t,bounding:s,xAxis:l,yAxis:n}),e.restore()),!u){var c=t.result,d=Dt(t,h),p=[];i.eachChildren((function(o,a){var u,g,y,m=a.halfGapBar,_=o.dataIndex,x=o.x,b=l.convertToPixel(_-1),w=l.convertToPixel(_+1),C=null!==(u=c[_-1])&&void 0!==u?u:null,E=null!==(g=c[_])&&void 0!==g?g:null,I=null!==(y=c[_+1])&&void 0!==y?y:null,T={x:b},S={x:x},A={x:w};t.figures.forEach((function(t){var e=t.key,i=null==C?void 0:C[e];v(i)&&(T[e]=n.convertToPixel(i));var r=null==E?void 0:E[e];v(r)&&(S[e]=n.convertToPixel(r));var o=null==I?void 0:I[e];v(o)&&(A[e]=n.convertToPixel(o))})),kt(t,_,a,h,(function(t,o,u){var c,h,d,g,y;if(f(null==E?void 0:E[t.key])){var _=S[t.key],b=null===(c=t.attrs)||void 0===c?void 0:c.call(t,{data:{prev:C,current:E,next:I},coordinate:{prev:T,current:S,next:A},bounding:s,barSpace:a,xAxis:l,yAxis:n});switch(t.type){case"text":b=r({x:x,y:_,text:null==E?void 0:E[t.key],align:"center",baseline:"middle"},b);break;case"circle":b=r({x:x,y:_,r:Math.max(1,m)},b);break;case"rect":case"bar":var w=null!==(h=t.baseValue)&&void 0!==h?h:n.getRange().from,M=n.convertToPixel(w),P=Math.abs(M-_);w!==(null==E?void 0:E[t.key])&&(P=Math.max(1,P));var D=0;D=_>M?M:_;var k=null!==(d=null==b?void 0:b.width)&&void 0!==d?d:2*m;b=r({x:x-k/2,y:D,width:Math.max(1,k),height:P},b);break;case"line":f(p[u])||(p[u]=[]),v(S[t.key])&&v(A[t.key])&&p[u].push({coordinates:null!==(g=null==b?void 0:b.coordinates)&&void 0!==g?g:[{x:S.x,y:S[t.key]},{x:A.x,y:A[t.key]}],styles:o})}var B=t.type;f(b)&&"line"!==B&&(null===(y=i.createFigure({name:"bar"===B?"rect":B,attrs:b,styles:o}))||void 0===y||y.draw(e))}}),d)})),p.forEach((function(t){var r,n,o,a;if(t.length>1){for(var s=[{coordinates:[t[0].coordinates[0],t[0].coordinates[1]],styles:t[0].styles}],l=1;l<t.length;l++){var u=s[s.length-1],c=t[l],h=u.coordinates[u.coordinates.length-1];h.x===c.coordinates[0].x&&h.y===c.coordinates[0].y&&u.styles.style===c.styles.style&&u.styles.color===c.styles.color&&u.styles.size===c.styles.size&&u.styles.smooth===c.styles.smooth&&(null===(r=u.styles.dashedValue)||void 0===r?void 0:r[0])===(null===(n=c.styles.dashedValue)||void 0===n?void 0:n[0])&&(null===(o=u.styles.dashedValue)||void 0===o?void 0:o[1])===(null===(a=c.styles.dashedValue)||void 0===a?void 0:a[1])?u.coordinates.push(c.coordinates[1]):s.push({coordinates:[c.coordinates[0],c.coordinates[1]],styles:c.styles})}s.forEach((function(t){var r,n=t.coordinates,o=t.styles;null===(r=i.createFigure({name:"line",attrs:{coordinates:n},styles:o}))||void 0===r||r.draw(e)}))}}))}}})),e.restore()},e}(ke);function Ue(t,e){var i,r=null!==(i=null==e?void 0:e.ignoreEvent)&&void 0!==i&&i;return y(r)?!r:!r.includes(t)}var Ge="overlay_figure_",Ze=function(){function t(t){this.groupId="",this.totalStep=1,this.currentStep=1,this.drawingMode="step",this.lock=!1,this.visible=!0,this.zLevel=0,this.fixedZLevel=!1,this.needDefaultPointFigure=!1,this.needDefaultXAxisFigure=!1,this.needDefaultYAxisFigure=!1,this.mode="normal",this.modeSensitivity=8,this.points=[],this.styles=null,this.createPointFigures=null,this.createXAxisFigures=null,this.createYAxisFigures=null,this.performEventPressedMove=null,this.performEventMoveForDrawing=null,this.onDrawStart=null,this.onDrawing=null,this.onDrawEnd=null,this.onClick=null,this.onDoubleClick=null,this.onRightClick=null,this.onPressedMoveStart=null,this.onPressedMoving=null,this.onPressedMoveEnd=null,this.onMouseMove=null,this.onMouseEnter=null,this.onMouseLeave=null,this.onRemoved=null,this.onSelected=null,this.onDeselected=null,this._prevZLevel=0,this._prevPressedPoint=null,this._prevPressedPoints=[],this.override(t)}return t.prototype.override=function(t){var e,i;this._prevOverlay=h(r(r({},this),{_prevOverlay:null}));var o=t.id,a=t.name;t.currentStep;var s=t.points,p=t.styles;if(c(this,n(t,["id","name","currentStep","points","styles"])),m(this.name)||(this.name=null!=a?a:""),!m(this.id)&&m(o)&&(this.id=o),f(p)&&(null!==(e=this.styles)&&void 0!==e||(this.styles={}),c(this.styles,p)),d(s)&&s.length>0){this.points=u([],l(s),!1),this.currentStep=-1;var g=this.points.length-1,v=this.points[g];g>0&&f(v)&&(null===(i=this.performEventPressedMove)||void 0===i||i.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:g,performPoint:v}))}},t.prototype.getPrevZLevel=function(){return this._prevZLevel},t.prototype.setPrevZLevel=function(t){this._prevZLevel=t},t.prototype.shouldUpdate=function(){var t=this._prevOverlay.zLevel!==this.zLevel;return{sort:t,draw:t||JSON.stringify(this._prevOverlay.points)!==JSON.stringify(this.points)||this._prevOverlay.visible!==this.visible||this._prevOverlay.extendData!==this.extendData||this._prevOverlay.styles!==this.styles}},t.prototype.nextStep=function(){this.currentStep===this.totalStep-1?this.currentStep=-1:this.currentStep++},t.prototype.forceComplete=function(){this.currentStep=-1},t.prototype.isDrawing=function(){return-1!==this.currentStep},t.prototype.isStart=function(){return 1===this.currentStep},t.prototype.isContinuousDrawingMode=function(){return"continuous"===this.drawingMode},t.prototype.startContinuousDrawing=function(t){this.points=[],this.continuousDrawingModeEventMoveForDrawing(t),this.currentStep=2},t.prototype.continuousDrawingModeEventMoveForDrawing=function(t){var e={};return v(t.timestamp)&&(e.timestamp=t.timestamp),v(t.dataIndex)&&(e.dataIndex=t.dataIndex),v(t.value)&&(e.value=t.value),this.points.push(e),!0},t.prototype.stepDrawingModeEventMoveForDrawing=function(t){var e,i=this.currentStep-1,r={};v(t.timestamp)&&(r.timestamp=t.timestamp),v(t.dataIndex)&&(r.dataIndex=t.dataIndex),v(t.value)&&(r.value=t.value),this.points[i]=r,null===(e=this.performEventMoveForDrawing)||void 0===e||e.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:i,performPoint:r})},t.prototype.eventPressedPointMove=function(t,e){var i;v(t.timestamp)&&(this.points[e].timestamp=t.timestamp),v(t.dataIndex)&&(this.points[e].dataIndex=t.dataIndex),v(t.value)&&(this.points[e].value=t.value),null===(i=this.performEventPressedMove)||void 0===i||i.call(this,{currentStep:this.currentStep,points:this.points,mode:this.mode,performPointIndex:e,performPoint:this.points[e]})},t.prototype.startPressedMove=function(t){this._prevPressedPoint=r({},t),this._prevPressedPoints=h(this.points)},t.prototype.eventPressedOtherMove=function(t,e){var i=this;if(null!==this._prevPressedPoint){var n=null;v(t.dataIndex)&&v(this._prevPressedPoint.dataIndex)&&(n=t.dataIndex-this._prevPressedPoint.dataIndex);var o=null;v(t.value)&&v(this._prevPressedPoint.value)&&(o=t.value-this._prevPressedPoint.value),this.points=this._prevPressedPoints.map((function(t){var a,s,l=r({},t);if(v(n)&&(v(t.dataIndex)||v(t.timestamp))){var u=v(t.timestamp)?i.isContinuousDrawingMode()?e.timestampToFloatIndex(t.timestamp):e.timestampToDataIndex(t.timestamp):t.dataIndex;l.dataIndex=u+n,l.timestamp=i.isContinuousDrawingMode()?null!==(a=e.floatIndexToTimestamp(l.dataIndex))&&void 0!==a?a:void 0:null!==(s=e.dataIndexToTimestamp(l.dataIndex))&&void 0!==s?s:void 0}return v(o)&&v(t.value)&&(l.value=t.value+o),l}))}},t.extend=function(e){return function(t){function r(){return t.call(this,e)||this}return i(r,t),r}(t)},t}(),je=function(t){function e(e){var i=t.call(this,e)||this;return i._initEvent(),i}return i(e,t),e.prototype._initEvent=function(){var t=this,e=this.getWidget(),i=e.getPane(),n=i.getId(),o=i.getChart(),a=o.getChartStore();this.registerEvent("mouseMoveEvent",(function(i){var s,l=a.getProgressOverlayInfo();if(null!==l){var u=l.overlay,c=l.paneId;u.isStart()&&(a.updateProgressOverlayInfo(n),c=n);var h=u.points.length-1;return u.isDrawing()&&c===n&&(u.stepDrawingModeEventMoveForDrawing(t._coordinateToPoint(u,i)),null===(s=u.onDrawing)||void 0===s||s.call(u,r({chart:o,overlay:u},i))),t._figureMouseMoveEvent(u,"point",h,{key:"".concat(Ge,"point_").concat(h),type:"circle",attrs:{}})(i)}return a.setHoverOverlayInfo({paneId:n,overlay:null,figureType:"none",figureIndex:-1,figure:null},(function(e,r){return t._processOverlayMouseEnterEvent(e,r,i)}),(function(e,r){return t._processOverlayMouseLeaveEvent(e,r,i)})),e.setForceCursor(null),!1})).registerEvent("mouseClickEvent",(function(e){var i,s,l=a.getProgressOverlayInfo();if(null!==l){var u=l.overlay,c=l.paneId;u.isStart()&&(a.updateProgressOverlayInfo(n,!0),c=n);var h=u.points.length-1;return u.isDrawing()&&c===n&&(u.stepDrawingModeEventMoveForDrawing(t._coordinateToPoint(u,e)),null===(i=u.onDrawing)||void 0===i||i.call(u,r({chart:o,overlay:u},e)),u.nextStep(),u.isDrawing()||(a.progressOverlayComplete(),null===(s=u.onDrawEnd)||void 0===s||s.call(u,r({chart:o,overlay:u},e)))),t._figureMouseClickEvent(u,"point",h,{key:"".concat(Ge,"point_").concat(h),type:"circle",attrs:{}})(e)}return a.setClickOverlayInfo({paneId:n,overlay:null,figureType:"none",figureIndex:-1,figure:null},(function(i,r){return t._processOverlaySelectedEvent(i,r,e)}),(function(i,r){return t._processOverlayDeselectedEvent(i,r,e)})),!1})).registerEvent("mouseDoubleClickEvent",(function(e){var i,s=a.getProgressOverlayInfo();if(null!==s){var l=s.overlay,u=s.paneId;l.isDrawing()&&u===n&&(l.forceComplete(),l.isDrawing()||(a.progressOverlayComplete(),null===(i=l.onDrawEnd)||void 0===i||i.call(l,r({chart:o,overlay:l},e))));var c=l.points.length-1;return t._figureMouseClickEvent(l,"point",c,{key:"".concat(Ge,"point_").concat(c),type:"circle",attrs:{}})(e)}return!1})).registerEvent("mouseRightClickEvent",(function(e){var i=a.getProgressOverlayInfo();if(null!==i){var r=i.overlay;if(r.isDrawing()){var n=r.points.length-1;return t._figureMouseRightClickEvent(r,"point",n,{key:"".concat(Ge,"point_").concat(n),type:"circle",attrs:{}})(e)}}return!1})).registerEvent("mouseDownEvent",(function(e){var i,s=a.getProgressOverlayInfo();if(null!==s){var l=s.overlay;if(l.isContinuousDrawingMode()&&l.isStart()){a.updateProgressOverlayInfo(n,!0);var u=t._coordinateToPoint(l,e);return l.startContinuousDrawing(u),null===(i=l.onDrawStart)||void 0===i||i.call(l,r({chart:o,overlay:l},e)),!0}}return!1})).registerEvent("mouseUpEvent",(function(t){var e,i,s=a.getProgressOverlayInfo();if(null!==s){var l=s.overlay;if(l.isContinuousDrawingMode()&&l.isDrawing()&&!l.isStart())return l.forceComplete(),a.progressOverlayComplete(),null===(e=l.onDrawEnd)||void 0===e||e.call(l,r({chart:o,overlay:l},t)),!0}var u=a.getPressedOverlayInfo(),c=u.overlay,h=u.figure;return null!==c&&Ue("onPressedMoveEnd",h)&&(null===(i=c.onPressedMoveEnd)||void 0===i||i.call(c,r({chart:o,overlay:c,figure:null!=h?h:void 0},t))),a.setPressedOverlayInfo({paneId:n,overlay:null,figureType:"none",figureIndex:-1,figure:null}),!1})).registerEvent("pressedMouseMoveEvent",(function(e){var i,n,s=a.getProgressOverlayInfo();if(null!==s){var l=s.overlay;if(l.isContinuousDrawingMode()&&l.isDrawing()&&!l.isStart()){var u=t._coordinateToPoint(l,e);return l.continuousDrawingModeEventMoveForDrawing(u),null===(i=l.onDrawing)||void 0===i||i.call(l,r({chart:o,overlay:l},e)),t.getWidget().setForceCursor("pointer"),!0}}var c=a.getPressedOverlayInfo(),h=c.overlay,d=c.figureType,p=c.figureIndex,g=c.figure;if(null!==h&&Ue("onPressedMoving",g)&&!h.lock){u=t._coordinateToPoint(h,e);"point"===d?h.eventPressedPointMove(u,p):h.eventPressedOtherMove(u,t.getWidget().getPane().getChart().getChartStore());var v=!1;return null===(n=h.onPressedMoving)||void 0===n||n.call(h,r(r({chart:o,overlay:h,figure:null!=g?g:void 0},e),{preventDefault:function(){v=!0}})),v?t.getWidget().setForceCursor(null):t.getWidget().setForceCursor("pointer"),!0}return t.getWidget().setForceCursor(null),!1}))},e.prototype._createFigureEvents=function(t,e,i,r){return t.isDrawing()?null:{mouseMoveEvent:this._figureMouseMoveEvent(t,e,i,r),mouseDownEvent:this._figureMouseDownEvent(t,e,i,r),mouseClickEvent:this._figureMouseClickEvent(t,e,i,r),mouseRightClickEvent:this._figureMouseRightClickEvent(t,e,i,r),mouseDoubleClickEvent:this._figureMouseDoubleClickEvent(t,e,i,r)}},e.prototype._processOverlayMouseEnterEvent=function(t,e,i){return!(!p(t.onMouseEnter)||!Ue("onMouseEnter",e))&&(t.onMouseEnter(r({chart:this.getWidget().getPane().getChart(),overlay:t,figure:null!=e?e:void 0},i)),!0)},e.prototype._processOverlayMouseLeaveEvent=function(t,e,i){return!(!p(t.onMouseLeave)||!Ue("onMouseLeave",e))&&(t.onMouseLeave(r({chart:this.getWidget().getPane().getChart(),overlay:t,figure:null!=e?e:void 0},i)),!0)},e.prototype._processOverlaySelectedEvent=function(t,e,i){var n;return!!Ue("onSelected",e)&&(null===(n=t.onSelected)||void 0===n||n.call(t,r({chart:this.getWidget().getPane().getChart(),overlay:t,figure:null!=e?e:void 0},i)),!0)},e.prototype._processOverlayDeselectedEvent=function(t,e,i){var n;return!!Ue("onDeselected",e)&&(null===(n=t.onDeselected)||void 0===n||n.call(t,r({chart:this.getWidget().getPane().getChart(),overlay:t,figure:null!=e?e:void 0},i)),!0)},e.prototype._figureMouseMoveEvent=function(t,e,i,n){var o=this;return function(a){var s,l=o.getWidget().getPane(),u=!t.isDrawing()&&Ue("onMouseMove",n);if(u){var c=!1;null===(s=t.onMouseMove)||void 0===s||s.call(t,r(r({chart:l.getChart(),overlay:t,figure:n},a),{preventDefault:function(){c=!0}})),c?o.getWidget().setForceCursor(null):o.getWidget().setForceCursor("pointer")}return l.getChart().getChartStore().setHoverOverlayInfo({paneId:l.getId(),overlay:t,figureType:e,figure:n,figureIndex:i},(function(t,e){return o._processOverlayMouseEnterEvent(t,e,a)}),(function(t,e){return o._processOverlayMouseLeaveEvent(t,e,a)})),u}},e.prototype._figureMouseDownEvent=function(t,e,i,n){var o=this;return function(a){var s;if(t.lock)return!1;var l=o.getWidget().getPane(),u=l.getId();return t.startPressedMove(o._coordinateToPoint(t,a)),!!Ue("onPressedMoveStart",n)&&(null===(s=t.onPressedMoveStart)||void 0===s||s.call(t,r({chart:l.getChart(),overlay:t,figure:n},a)),l.getChart().getChartStore().setPressedOverlayInfo({paneId:u,overlay:t,figureType:e,figureIndex:i,figure:n}),!t.isDrawing())}},e.prototype._figureMouseClickEvent=function(t,e,i,n){var o=this;return function(a){var s,l=o.getWidget().getPane(),u=l.getId(),c=!t.isDrawing()&&Ue("onClick",n);return c&&(null===(s=t.onClick)||void 0===s||s.call(t,r({chart:o.getWidget().getPane().getChart(),overlay:t,figure:n},a))),l.getChart().getChartStore().setClickOverlayInfo({paneId:u,overlay:t,figureType:e,figureIndex:i,figure:n},(function(t,e){return o._processOverlaySelectedEvent(t,e,a)}),(function(t,e){return o._processOverlayDeselectedEvent(t,e,a)})),c}},e.prototype._figureMouseDoubleClickEvent=function(t,e,i,n){var o=this;return function(e){var i;return!!Ue("onDoubleClick",n)&&(null===(i=t.onDoubleClick)||void 0===i||i.call(t,r(r({},e),{chart:o.getWidget().getPane().getChart(),figure:n,overlay:t})),!t.isDrawing())}},e.prototype._figureMouseRightClickEvent=function(t,e,i,n){var o=this;return function(e){var i;if(Ue("onRightClick",n)){var a=!1;return null===(i=t.onRightClick)||void 0===i||i.call(t,r(r({chart:o.getWidget().getPane().getChart(),overlay:t,figure:n},e),{preventDefault:function(){a=!0}})),a||o.getWidget().getPane().getChart().getChartStore().removeOverlay(t),!t.isDrawing()}return!1}},e.prototype._coordinateToPoint=function(t,e){var i,r,n={},o=this.getWidget().getPane(),a=o.getChart(),s=o.getId(),l=a.getChartStore();if(this.coordinateToPointTimestampDataIndexFlag())if(t.isContinuousDrawingMode()){var u=l.coordinateToFloatIndex(e.x);n.dataIndex=u,n.timestamp=null!==(i=l.floatIndexToTimestamp(u))&&void 0!==i?i:void 0}else{var c=a.getXAxisPane().getXAxisComponent().convertFromPixel(e.x);n.dataIndex=c,n.timestamp=null!==(r=l.dataIndexToTimestamp(c))&&void 0!==r?r:void 0}if(this.coordinateToPointValueFlag()){var h=o.getYAxisComponentById(),d=h.convertFromPixel(e.y);if("normal"!==t.mode&&s===j&&v(n.dataIndex)){var p=l.getDataByDataIndex(n.dataIndex);if(null!==p){var g=t.modeSensitivity;if(d>p.high)if("weak_magnet"===t.mode){var f=h.convertToPixel(p.high),y=h.reverse?f+g:f-g;d<h.convertFromPixel(y)&&(d=p.high)}else d=p.high;else if(d<p.low)if("weak_magnet"===t.mode){var m=h.convertToPixel(p.low);y=h.reverse?m-g:m+g;d>h.convertFromPixel(y)&&(d=p.low)}else d=p.low;else{var _=Math.max(p.open,p.close),x=Math.min(p.open,p.close);d=d>_?d-_<p.high-d?_:p.high:d<x?d-p.low<x-d?p.low:x:_-d<d-x?_:x}}}n.value=d}return n},e.prototype.coordinateToPointValueFlag=function(){return!0},e.prototype.coordinateToPointTimestampDataIndexFlag=function(){return!0},e.prototype.dispatchEvent=function(e,i){return this.getWidget().getPane().getChart().getChartStore().isOverlayDrawing()?this.onEvent(e,i):t.prototype.dispatchEvent.call(this,e,i)},e.prototype.drawImp=function(t){var e=this;this.getCompleteOverlays().forEach((function(i){i.visible&&e._drawOverlay(t,i)}));var i=this.getProgressOverlay();f(i)&&i.visible&&this._drawOverlay(t,i)},e.prototype._drawOverlay=function(t,e){var i=e.points,r=this.getWidget().getPane(),n=r.getChart().getChartStore(),o=r.getYAxisComponentById(),a=e.isContinuousDrawingMode(),s=i.map((function(t){var e,i=null;a&&v(t.timestamp)?i=n.timestampToFloatIndex(t.timestamp):v(t.timestamp)?i=n.timestampToDataIndex(t.timestamp):v(t.dataIndex)&&(i=t.dataIndex);var r={x:0,y:0};return v(i)&&(r.x=n.dataIndexToCoordinate(i)),v(t.value)&&(r.y=null!==(e=null==o?void 0:o.convertToPixel(t.value))&&void 0!==e?e:0),r}));if(s.length>0){var l=[];l=l.concat(this.getFigures(e,s)),this.drawFigures(t,e,l)}this.drawDefaultFigures(t,e,s)},e.prototype.drawFigures=function(t,e,i){var n=this,o=this.getWidget().getPane().getChart().getStyles().overlay;i.forEach((function(i,a){var s=i.type,l=i.styles,u=i.attrs;[].concat(u).forEach((function(u){var c,h,d=n._createFigureEvents(e,"other",a,i),p=r(r(r({},o[s]),null===(c=e.styles)||void 0===c?void 0:c[s]),l);null===(h=n.createFigure({name:s,attrs:u,styles:p},null!=d?d:void 0))||void 0===h||h.draw(t)}))}))},e.prototype.getCompleteOverlays=function(){var t=this.getWidget().getPane();return t.getChart().getChartStore().getOverlaysByPaneId(t.getId())},e.prototype.getProgressOverlay=function(){var t=this.getWidget().getPane(),e=t.getChart().getChartStore().getProgressOverlayInfo();return f(e)&&e.paneId===t.getId()?e.overlay:null},e.prototype.getFigures=function(t,e){var i,r,n=this.getWidget(),o=n.getPane(),a=o.getChart(),s=o.getYAxisComponentById(),l=a.getXAxisPane().getXAxisComponent(),u=n.getBounding();return null!==(r=null===(i=t.createPointFigures)||void 0===i?void 0:i.call(t,{chart:a,overlay:t,coordinates:e,bounding:u,xAxis:l,yAxis:s}))&&void 0!==r?r:[]},e.prototype.drawDefaultFigures=function(t,e,i){var n,o,a=this;if(e.needDefaultPointFigure){var s=this.getWidget().getPane().getChart().getChartStore(),l=s.getHoverOverlayInfo(),u=s.getClickOverlayInfo();if((null===(n=l.overlay)||void 0===n?void 0:n.id)===e.id&&"none"!==l.figureType||(null===(o=u.overlay)||void 0===o?void 0:o.id)===e.id&&"none"!==u.figureType){var c=s.getStyles().overlay,h=e.styles,d=r(r({},c.point),null==h?void 0:h.point);i.forEach((function(i,r){var n,o,s,u,c,h=i.x,p=i.y,g=d.radius,v=d.color,f=d.borderColor,y=d.borderSize;(null===(n=l.overlay)||void 0===n?void 0:n.id)===e.id&&"point"===l.figureType&&(null===(o=l.figure)||void 0===o?void 0:o.key)==="".concat(Ge,"point_").concat(r)&&(g=d.activeRadius,v=d.activeColor,f=d.activeBorderColor,y=d.activeBorderSize),null===(u=a.createFigure({name:"circle",attrs:{x:h,y:p,r:g+y},styles:{color:f}},null!==(s=a._createFigureEvents(e,"point",r,{key:"".concat(Ge,"point_").concat(r),type:"circle",attrs:{x:h,y:p,r:g+y},styles:{color:f}}))&&void 0!==s?s:void 0))||void 0===u||u.draw(t),null===(c=a.createFigure({name:"circle",attrs:{x:h,y:p,r:g},styles:{color:v}}))||void 0===c||c.draw(t)}))}}},e}(Me),qe=null;var Ke=function(){function t(t,e){var i=this;this._resizeObserver=null,this._mediaQueryList=null,this._destroyed=!1,this._resizePending=!1,this._sizeInitialized=!1,this._width=0,this._height=0,this._pixelWidth=0,this._pixelHeight=0,this._nextPixelWidth=0,this._nextPixelHeight=0,this._requestAnimationId=_,this._mediaQueryListener=function(){i._destroyed||(i._observePixelRatio(),i._resize(I(i._element)))},this._listener=e,this._element=A("canvas",t),this._ctx=this._element.getContext("2d"),function(){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return null!=qe||(qe=new Promise((function(t){var e=new ResizeObserver((function(i){t(i.every((function(t){var e;return f(null===(e=t.devicePixelContentBoxSize)||void 0===e?void 0:e[0])}))),e.disconnect()}));e.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1}))),[4,qe];case 1:return[2,t.sent()]}}))}))}().then((function(t){i._destroyed||(t?(i._resizeObserver=new ResizeObserver((function(t){var e=t.find((function(t){return t.target===i._element})),r=null==e?void 0:e.devicePixelContentBoxSize[0];i._sizeInitialized&&f(r)&&(i._nextPixelWidth=r.inlineSize,i._nextPixelHeight=r.blockSize,i._pixelWidth===i._nextPixelWidth&&i._pixelHeight===i._nextPixelHeight||i._scheduleDraw(!0))})),i._resizeObserver.observe(i._element,{box:"device-pixel-content-box"})):i._observePixelRatio())})).catch((function(t){return!1}))}return t.prototype._observePixelRatio=function(){var t,e;f(this._mediaQueryList)&&this._mediaQueryList.removeListener(this._mediaQueryListener);var i=this._element.ownerDocument.defaultView;this._mediaQueryList=null!==(t=null==i?void 0:i.matchMedia("(resolution: ".concat(I(this._element),"dppx)")))&&void 0!==t?t:null,null===(e=this._mediaQueryList)||void 0===e||e.addListener(this._mediaQueryListener)},t.prototype._resize=function(t){this._nextPixelWidth=Math.round(this._width*t),this._nextPixelHeight=Math.round(this._height*t),this._scheduleDraw(!0)},t.prototype._scheduleDraw=function(t){var e=this;void 0===t&&(t=!1),this._resizePending||(this._resizePending=t),this._requestAnimationId===_&&(this._requestAnimationId=x((function(){if(e._requestAnimationId=_,!e._destroyed){e._resizePending&&(e._resizePending=!1,e._pixelWidth=e._nextPixelWidth,e._pixelHeight=e._nextPixelHeight,e._element.width=e._pixelWidth,e._element.height=e._pixelHeight),e._ctx.setTransform(1,0,0,1,0,0),e._ctx.clearRect(0,0,e._pixelWidth,e._pixelHeight),e._ctx.save(),e._width>0&&e._height>0&&e._ctx.scale(e._pixelWidth/e._width,e._pixelHeight/e._height);try{e._listener()}finally{e._ctx.restore()}}})))},t.prototype.update=function(t,e){this._sizeInitialized&&this._width===t&&this._height===e?this._scheduleDraw():(this._sizeInitialized=!0,this._width=t,this._height=e,this._element.style.width="".concat(t,"px"),this._element.style.height="".concat(e,"px"),this._resize(I(this._element)))},t.prototype.getElement=function(){return this._element},t.prototype.getContext=function(){return this._ctx},t.prototype.destroy=function(){this._destroyed=!0,this._requestAnimationId!==_&&(b(this._requestAnimationId),this._requestAnimationId=_),f(this._resizeObserver)&&(this._resizeObserver.disconnect(),this._resizeObserver=null),f(this._mediaQueryList)&&(this._mediaQueryList.removeListener(this._mediaQueryListener),this._mediaQueryList=null)},t}(),Qe=function(t){function e(e,i){var r=t.call(this)||this;return r._bounding=C(),r._cursor="crosshair",r._forceCursor=null,r._pane=i,r._rootContainer=e,r._container=r.createContainer(),e.appendChild(r._container),r}return i(e,t),e.prototype.setBounding=function(t){return c(this._bounding,t),this},e.prototype.getContainer=function(){return this._container},e.prototype.getBounding=function(){return this._bounding},e.prototype.getPane=function(){return this._pane},e.prototype.checkEventOn=function(t){return!0},e.prototype.setCursor=function(t){m(this._forceCursor)||t!==this._cursor&&(this._cursor=t,this._container.style.cursor=this._cursor)},e.prototype.setForceCursor=function(t){var e;t!==this._forceCursor&&(this._forceCursor=t,this._container.style.cursor=null!==(e=this._forceCursor)&&void 0!==e?e:this._cursor)},e.prototype.getForceCursor=function(){return this._forceCursor},e.prototype.update=function(t){this.updateImp(this._container,this._bounding,null!=t?t:3)},e.prototype.destroy=function(){this._rootContainer.removeChild(this._container)},e}(Qt),$e=function(t){function e(e,i){var r=t.call(this,e,i)||this;r._mainCanvas=new Ke({position:"absolute",top:"0",left:"0",zIndex:"2",boxSizing:"border-box"},(function(){r.updateMain(r._mainCanvas.getContext())})),r._overlayCanvas=new Ke({position:"absolute",top:"0",left:"0",zIndex:"2",boxSizing:"border-box"},(function(){r.updateOverlay(r._overlayCanvas.getContext())}));var n=r.getContainer();return n.appendChild(r._mainCanvas.getElement()),n.appendChild(r._overlayCanvas.getElement()),r}return i(e,t),e.prototype.createContainer=function(){return A("div",{margin:"0",padding:"0",position:"absolute",top:"0",overflow:"hidden",boxSizing:"border-box",zIndex:"1"})},e.prototype.updateImp=function(t,e,i){var r=e.width,n=e.height,o=e.left;t.style.left="".concat(o,"px");var a=i,s=t.clientWidth,l=t.clientHeight;switch(r===s&&n===l||(t.style.width="".concat(r,"px"),t.style.height="".concat(n,"px"),a=3),a){case 0:this._mainCanvas.update(r,n);break;case 1:this._overlayCanvas.update(r,n);break;case 3:case 4:this._mainCanvas.update(r,n),this._overlayCanvas.update(r,n)}},e.prototype.destroy=function(){this._mainCanvas.destroy(),this._overlayCanvas.destroy(),t.prototype.destroy.call(this)},e.prototype.getImage=function(t){var e=this.getBounding(),i=e.width,r=e.height,n=A("canvas",{width:"".concat(i,"px"),height:"".concat(r,"px"),boxSizing:"border-box"}),o=n.getContext("2d"),a=I(n);return n.width=i*a,n.height=r*a,o.scale(a,a),o.drawImage(this._mainCanvas.getElement(),0,0,i,r),t&&o.drawImage(this._overlayCanvas.getElement(),0,0,i,r),n},e}(Qe),Je=function(t){function e(e,i){var r=t.call(this,e,i)||this;return r._gridView=new He(r),r._indicatorView=new Xe(r),r._crosshairLineView=new Ne(r),r._tooltipView=r.createTooltipView(),r._overlayView=new je(r),r.addChild(r._tooltipView),r.addChild(r._overlayView),r}return i(e,t),e.prototype.getName=function(){return bt},e.prototype.updateMain=function(t){this.updateMainContent(t),this._indicatorView.draw(t),this._gridView.draw(t)},e.prototype.createTooltipView=function(){return new We(this)},e.prototype.updateMainContent=function(t){},e.prototype.updateOverlayContent=function(t){},e.prototype.updateOverlay=function(t){this._overlayView.draw(t),this._crosshairLineView.draw(t),this.updateOverlayContent(t),this._tooltipView.draw(t)},e}($e),ti=function(t){function e(e,i){var r=t.call(this,e,i)||this;return r._candleBarView=new ke(r),r._candleAreaView=new De(r),r._candleHighLowPriceView=new Be(r),r._candleLastPriceLineView=new Fe(r),r._crosshairFeatureView=new Ve(r),r.addChild(r._candleBarView),r.addChild(r._crosshairFeatureView),r}return i(e,t),e.prototype.updateMainContent=function(t){"area"!==this.getPane().getChart().getStyles().candle.type?(this._candleBarView.draw(t),this._candleHighLowPriceView.draw(t),this._candleAreaView.stopAnimation()):this._candleAreaView.draw(t),this._candleLastPriceLineView.draw(t)},e.prototype.updateOverlayContent=function(t){this._crosshairFeatureView.draw(t)},e.prototype.createTooltipView=function(){return new ze(this)},e.prototype.destroy=function(){this._candleAreaView.stopAnimation(),t.prototype.destroy.call(this)},e}(Je),ei={name:"logarithm",minSpan:function(t){return.05*L(-t)},valueToRealValue:function(t){return t<0?-R(Math.abs(t)):R(t)},realValueToDisplayValue:function(t){return t<0?-L(Math.abs(t)):L(t)},displayValueToRealValue:function(t){return t<0?-R(Math.abs(t)):R(t)},realValueToValue:function(t){return t<0?-L(Math.abs(t)):L(t)},createRange:function(t){var e=t.defaultRange,i=e.from,r=e.to,n=e.range,o=i<0?-R(Math.abs(i)):R(i),a=r<0?-R(Math.abs(r)):R(r);return{from:i,to:r,range:n,realFrom:o,realTo:a,realRange:a-o,displayFrom:i,displayTo:r,displayRange:n}}},ii={name:"percentage",minSpan:function(){return Math.pow(10,-2)},displayValueToText:function(t){return"".concat(H(t,2),"%")},valueToRealValue:function(t,e){var i=e.range;return 0===i.range?i.realFrom:(t-i.from)/i.range*i.realRange+i.realFrom},realValueToValue:function(t,e){var i=e.range;return 0===i.realRange?i.from:(t-i.realFrom)/i.realRange*i.range+i.from},createRange:function(t){var e=t.chart,i=t.defaultRange,r=e.getDataList()[e.getVisibleRange().from];if(f(r)){var n=i.from,o=i.to,a=i.range,s=r.close,l=0===s?0:(i.from-s)/s*100,u=0===s?0:(i.to-s)/s*100,c=u-l;return{from:n,to:o,range:a,realFrom:l,realTo:u,realRange:c,displayFrom:l,displayTo:u,displayRange:c}}return i}},ri={normal:J.extend({name:"normal"}),percentage:J.extend(ii),logarithm:J.extend(ei)};var ni=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i,n,o,a=this,s=this.getWidget(),l=s.getPane(),u=s.getBounding(),c=l.getChart().getChartStore(),h=c.getStyles().candle.priceMark,d=h.last,p=d.text;if(h.show&&d.show&&p.show){var g=null!==(i=null===(e=c.getSymbol())||void 0===e?void 0:e.pricePrecision)&&void 0!==i?i:O,v=s.getAxisComponent(),y=c.getDataList(),m=y[y.length-1];if(f(m)){var _=m.close,x=m.open,b="current_open"===d.compareRule?x:null!==(o=null===(n=y[y.length-2])||void 0===n?void 0:n.close)&&void 0!==o?o:_,w=v.convertToNicePixel(_),C="";C=_>b?d.upColor:_<b?d.downColor:d.noChangeColor;var E=0,I="left";v.isFromZero()?(E=0,I="left"):(E=u.width,I="right");var T=[],A=v.getRange(),M=v.displayValueToText(v.realValueToDisplayValue(v.valueToRealValue(_,{range:A}),{range:A}),g);M=c.getDecimalFold().format(c.getThousandsSeparator().format(M));var P=p.paddingLeft,D=p.paddingRight,k=p.paddingTop,B=p.paddingBottom,F=p.size,R=p.family,L=P+S(M,F,p.weight,R)+D,Y=k+F+B;T.push({name:"text",attrs:{x:E,y:w,width:L,height:Y,text:M,align:I,baseline:"middle"},styles:r(r({},p),{backgroundColor:C})});var W=c.getInnerFormatter().formatExtendText,z=F/2,V=w-z-k,N=w+z+B;d.extendTexts.forEach((function(t,e){var i=W({type:"last_price",data:m,index:e});if(i.length>0&&t.show){var n=t.size/2,o=0;"above_price"===t.position?(o=V-=t.paddingBottom+n,V-=n+t.paddingTop):(o=N+=t.paddingTop+n,N+=n+t.paddingBottom),L=Math.max(L,t.paddingLeft+S(i,t.size,t.weight,t.family)+t.paddingRight),T.push({name:"text",attrs:{x:E,y:o,width:L,height:t.paddingTop+t.size+t.paddingBottom,text:i,align:I,baseline:"middle"},styles:r(r({},t),{backgroundColor:C})})}})),T.forEach((function(e){var i;e.attrs.width=L,null===(i=a.createFigure(e))||void 0===i||i.draw(t)}))}}},e}(Me),oi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i=this.getWidget(),r=i.getPane(),n=i.getPane().getChart().getChartStore(),o=n.getCrosshair();if(m(o.paneId)&&this.compare(o,r.getId())){var a=n.getStyles().crosshair;if(a.show){var s=this.getDirectionStyles(a),l=s.text;if(s.show&&l.show){var u=i.getBounding(),c="getAxisComponent"in i?i.getAxisComponent():r.getYAxisComponentById(),h=this.getText(o,n,c);t.font=T(l.size,l.weight,l.family),null===(e=this.createFigure({name:"text",attrs:this.getTextAttrs(h,t.measureText(h).width,o,u,c,l),styles:l}))||void 0===e||e.draw(t)}}}},e.prototype.compare=function(t,e){return t.paneId===e},e.prototype.getDirectionStyles=function(t){return t.horizontal},e.prototype.getText=function(t,e,i){var r,n,o,a=i,s=i.convertFromPixel(t.y),l=0,u=!1;if(a.isInCandle())l=null!==(n=null===(r=e.getSymbol())||void 0===r?void 0:r.pricePrecision)&&void 0!==n?n:O;else{var c=a.id,h=this.getWidget().getPane();h.isManualYAxis(c)&&(c=null!==(o=h.getDefaultYAxisId())&&void 0!==o?o:c),e.getIndicatorsByPaneId(t.paneId).filter((function(t){return t.yAxisId===c})).forEach((function(t){l=Math.max(t.precision,l),u||(u=t.shouldFormatBigNumber)}))}var d=a.getRange(),p=a.displayValueToText(a.realValueToDisplayValue(a.valueToRealValue(s,{range:d}),{range:d}),l);return u&&(p=e.getInnerFormatter().formatBigNumber(p)),e.getDecimalFold().format(e.getThousandsSeparator().format(p))},e.prototype.getTextAttrs=function(t,e,i,r,n,o){var a=0,s="left";return n.isFromZero()?(a=0,s="left"):(a=r.width,s="right"),{x:a,y:i.y,text:t,align:s,baseline:"middle"}},e}(Me),ai=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e=this,i=this.getWidget(),n=i.getPane(),o=i.getBounding(),a=n.getChart().getChartStore(),s=a.getStyles().indicator,l=s.lastValueMark,u=l.text;if(l.show){var c=i.getAxisComponent(),h=c.getRange(),d=a.getDataList(),p=a.getBarSpace(),g=d.length-1,y=new Set([c.id]),m=n.getDefaultYAxisId();n.isManualYAxis(c.id)&&f(m)&&y.add(m);var _=a.getIndicatorsByPaneId(n.getId()).filter((function(t){return y.has(t.yAxisId)})),x=a.getInnerFormatter(),b=a.getDecimalFold(),w=a.getThousandsSeparator();_.forEach((function(i){var n,a=null!==(n=i.result[g])&&void 0!==n?n:{};if(f(a)&&i.visible){var l=i.precision;kt(i,g,p,s,(function(n,s){var d,p=a[n.key];if(v(p)){var g=c.convertToNicePixel(p),f=c.displayValueToText(c.realValueToDisplayValue(c.valueToRealValue(p,{range:h}),{range:h}),l);i.shouldFormatBigNumber&&(f=x.formatBigNumber(f)),f=b.format(w.format(f));var y=0,m="left";c.isFromZero()?(y=0,m="left"):(y=o.width,m="right"),null===(d=e.createFigure({name:"text",attrs:{x:y,y:g,text:f,align:m,baseline:"middle"},styles:r(r({},u),{backgroundColor:s.color})}))||void 0===d||d.draw(t)}}))}}))}},e}(Me),si=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.coordinateToPointTimestampDataIndexFlag=function(){return!1},e.prototype.drawDefaultFigures=function(t,e,i){this.drawFigures(t,e,this.getDefaultFigures(e,i))},e.prototype.getDefaultFigures=function(t,e){var i,r=this.getWidget(),n=r.getPane(),o=n.getChart().getChartStore(),a=o.getClickOverlayInfo(),s=[];if(t.needDefaultYAxisFigure&&t.id===(null===(i=a.overlay)||void 0===i?void 0:i.id)&&a.paneId===n.getId()){var l=n.getYAxisComponentById(),u=r.getBounding(),c=Number.MAX_SAFE_INTEGER,h=Number.MIN_SAFE_INTEGER,d=l.isFromZero(),p="left",g=0;d?(p="left",g=0):(p="right",g=u.width);var f=o.getDecimalFold(),y=o.getThousandsSeparator();e.forEach((function(e,i){var r,n,a=t.points[i];if(v(a.value)){c=Math.min(c,e.y),h=Math.max(h,e.y);var l=f.format(y.format(H(a.value,null!==(n=null===(r=o.getSymbol())||void 0===r?void 0:r.pricePrecision)&&void 0!==n?n:O)));s.push({type:"text",attrs:{x:g,y:e.y,text:l,align:p,baseline:"middle"},ignoreEvent:!0})}})),e.length>1&&s.unshift({type:"rect",attrs:{x:0,y:c,width:u.width,height:h-c},ignoreEvent:!0})}return s},e.prototype.getFigures=function(t,e){var i,r,n=this.getWidget(),o=n.getPane(),a=o.getChart(),s=o.getYAxisComponentById(),l=a.getXAxisPane().getXAxisComponent(),u=n.getBounding();return null!==(r=null===(i=t.createYAxisFigures)||void 0===i?void 0:i.call(t,{chart:a,overlay:t,coordinates:e,bounding:u,xAxis:l,yAxis:s}))&&void 0!==r?r:[]},e}(je),li=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.drawImp=function(t){var e,i,r=this,n=this.getWidget(),o=n.getPane(),a=n.getBounding(),s=this.getAxis(),l=this.getAxisStyles(o.getChart().getStyles());if(l.show){l.axisLine.show&&(null===(e=this.createFigure({name:"line",attrs:this.createAxisLine(a,l),styles:l.axisLine}))||void 0===e||e.draw(t));var u=s.getTicks();if(l.tickLine.show)this.createTickLines(u,a,l).forEach((function(e){var i;null===(i=r.createFigure({name:"line",attrs:e,styles:l.tickLine}))||void 0===i||i.draw(t)}));if(l.tickText.show){var c=this.createTickTexts(u,a,l);null===(i=this.createFigure({name:"text",attrs:c,styles:l.tickText}))||void 0===i||i.draw(t)}}},e}(Me),ui=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getAxis=function(){return this.getWidget().getAxisComponent()},e.prototype.getAxisStyles=function(t){return t.yAxis},e.prototype.createAxisLine=function(t,e){var i=this.getAxis(),r=e.axisLine.size,n=0;return{coordinates:[{x:n=i.isFromZero()?0:t.width-r,y:0},{x:n,y:t.height}]}},e.prototype.createTickLines=function(t,e,i){var r=this.getAxis(),n=i.axisLine,o=i.tickLine,a=0,s=0;return r.isFromZero()?(a=0,n.show&&(a+=n.size),s=a+o.length):(a=e.width,n.show&&(a-=n.size),s=a-o.length),t.map((function(t){return{coordinates:[{x:a,y:t.coord},{x:s,y:t.coord}]}}))},e.prototype.createTickTexts=function(t,e,i){var r=this.getAxis(),n=i.axisLine,o=i.tickLine,a=i.tickText,s=0;r.isFromZero()?(s=a.marginStart,n.show&&(s+=n.size),o.show&&(s+=o.length)):(s=e.width-a.marginEnd,n.show&&(s-=n.size),o.show&&(s-=o.length));var l=this.getAxis().isFromZero()?"left":"right";return t.map((function(t){return{x:s,y:t.coord,text:t.text,align:l,baseline:"middle"}}))},e}(li),ci=function(t){function e(e,i,r){var n=t.call(this,e,i)||this;return n._yAxisView=new ui(n),n._candleLastPriceLabelView=new ni(n),n._indicatorLastValueView=new ai(n),n._overlayYAxisView=new si(n),n._crosshairHorizontalLabelView=new oi(n),n._yAxis=r,n.setCursor("ns-resize"),n.addChild(n._overlayYAxisView),n}return i(e,t),e.prototype.getAxisComponent=function(){return this._yAxis},e.prototype.getName=function(){return Ct},e.prototype.updateMain=function(t){this._yAxisView.draw(t);var e=this.getPane();(e.isDefaultYAxis(this._yAxis.id)||e.isManualYAxis(this._yAxis.id))&&this.getAxisComponent().isInCandle()&&this._candleLastPriceLabelView.draw(t),this._indicatorLastValueView.draw(t)},e.prototype.updateOverlay=function(t){this._overlayYAxisView.draw(t),this._crosshairHorizontalLabelView.draw(t)},e}($e),hi=function(){function t(t,e){this._bounding=C(),this._chart=t,this._id=e,this._container=A("div",{width:"100%",margin:"0",padding:"0",position:"relative",overflow:"hidden",boxSizing:"border-box"})}return t.prototype.getContainer=function(){return this._container},t.prototype.getId=function(){return this._id},t.prototype.getChart=function(){return this._chart},t.prototype.getBounding=function(){return this._bounding},t.prototype.update=function(t){this._bounding.height!==this._container.clientHeight&&(this._container.style.height="".concat(this._bounding.height,"px")),this.updateImp(null!=t?t:3,this._container,this._bounding)},t}(),di=function(t){function e(e,i){var r=t.call(this,e,i.id)||this;r._yAxisWidgets=new Map,r._yAxisComponents=new Map,r._manualYAxisIds=new Set,r._defaultYAxisId=null,r._yAxesBounding={};var n=r.getContainer();return r._mainWidget=r.createMainWidget(n),r._options=i,r}return i(e,t),e.prototype.setOptions=function(t){return c(this._options,t),v(t.height)&&t.height>0&&this.setBounding({height:this._options.height}),this},e.prototype.setAxisCursor=function(t,e){var i,r,n=null,o="default";this.getId()===K?(n=this.getMainWidget().getContainer(),o="ew-resize"):(n=null!==(r=null===(i=this.getYAxisWidgetById(e))||void 0===i?void 0:i.getContainer())&&void 0!==r?r:null,o="ns-resize"),f(n)&&y(t)&&(n.style.cursor=t?o:"default")},e.prototype.createOrOverrideYAxis=function(t){var e,i,n,o,a,s=r(r({},t),{paneId:this.getId()}),l=s.id,u=null!==(e=s.name)&&void 0!==e?e:"normal",c=null===(i=s.needWidget)||void 0===i||i,h=this._yAxisComponents.get(l);if(!f(h)||f(s.name)&&h.name!==s.name)null===(n=this._yAxisWidgets.get(l))||void 0===n||n.destroy(),this._yAxisWidgets.delete(l),(h=this.createYAxisComponent(u)).id=l,h.paneId=this.getId(),this._yAxisComponents.set(l,h),null!==(o=this._defaultYAxisId)&&void 0!==o||(this._defaultYAxisId=l),c&&f(d=this.createYAxisWidget(this.getContainer(),h))&&this._yAxisWidgets.set(l,d);else if(y(s.needWidget)&&f(h)){var d=this._yAxisWidgets.get(l);if(s.needWidget&&!f(d)){var p=this.createYAxisWidget(this.getContainer(),h);f(p)&&this._yAxisWidgets.set(l,p)}else!s.needWidget&&f(d)&&(d.destroy(),this._yAxisWidgets.delete(l))}if(!f(h))throw new Error("create yAxis failed.");h.setAutoCalcTickFlag(!0),h.override(r(r({},s),{name:u})),this.setAxisCursor(h.scrollZoomEnabled,l);var g=this.getBounding();return null===(a=this._yAxisWidgets.get(l))||void 0===a||a.setBounding({height:g.height,top:g.top}),h},e.prototype.getOptions=function(){return this._options},e.prototype.getYAxisComponents=function(){return Array.from(this._yAxisComponents.values())},e.prototype.getWidgetYAxisComponents=function(){var t=this;return Array.from(this._yAxisWidgets.keys()).map((function(e){return t._yAxisComponents.get(e)}))},e.prototype.hasYAxisComponent=function(t){return this._yAxisComponents.has(t)},e.prototype.setManualYAxis=function(t,e){e?this._manualYAxisIds.add(t):this._manualYAxisIds.delete(t)},e.prototype.isManualYAxis=function(t){return this._manualYAxisIds.has(t)},e.prototype.removeYAxis=function(t){var e,i=this;if(!f(this._yAxisComponents.get(t)))return!1;this._yAxisComponents.delete(t),this._manualYAxisIds.delete(t),this._defaultYAxisId===t&&(this._defaultYAxisId=null!==(e=this._yAxisComponents.keys().next().value)&&void 0!==e?e:null);var r=this._yAxisWidgets.get(t);return f(r)&&(r.destroy(),this._yAxisWidgets.delete(t)),this._yAxesBounding=Object.keys(this._yAxesBounding).reduce((function(e,r){return r!==t&&(e[r]=i._yAxesBounding[r]),e}),{}),!0},e.prototype.getDefaultYAxisId=function(){return this._defaultYAxisId},e.prototype.isDefaultYAxis=function(t){return this._defaultYAxisId===t},e.prototype.getYAxisComponentById=function(t){var e=null!=t?t:this.getDefaultYAxisId();return this._yAxisComponents.get(e)},e.prototype.getYAxisWidgetById=function(t){var e,i=null!=t?t:this.getDefaultYAxisId();return f(i)&&null!==(e=this._yAxisWidgets.get(i))&&void 0!==e?e:null},e.prototype.setYAxesBounding=function(t){this._yAxesBounding=t},e.prototype.setBounding=function(t,e,i,n){var o=this;c(this.getBounding(),t);var a={};f(t.height)&&(a.height=t.height),f(t.top)&&(a.top=t.top),this._mainWidget.setBounding(a);var s=f(e);return s&&this._mainWidget.setBounding(e),this._yAxisWidgets.size>0&&this._yAxisWidgets.forEach((function(t,l){var u,c,h,d;(t.setBounding(a),f(o._yAxesBounding[l]))?t.setBounding(o._yAxesBounding[l]):"left"===o.getYAxisComponentById(l).position?f(i)&&t.setBounding(r(r({},i),{left:0})):f(n)&&(t.setBounding(n),s&&t.setBounding({left:(null!==(u=e.left)&&void 0!==u?u:0)+(null!==(c=e.width)&&void 0!==c?c:0)+(null!==(h=e.right)&&void 0!==h?h:0)-(null!==(d=n.width)&&void 0!==d?d:0)}))})),this},e.prototype.getMainWidget=function(){return this._mainWidget},e.prototype.getYAxisWidget=function(){return this.getYAxisWidgetById()},e.prototype.getYAxisWidgets=function(){return Array.from(this._yAxisWidgets.values())},e.prototype.updateImp=function(t){this._mainWidget.update(t),this._yAxisWidgets.forEach((function(e){e.update(t)}))},e.prototype.destroy=function(){this._mainWidget.destroy(),this._yAxisWidgets.forEach((function(t){t.destroy()}))},e.prototype.getImage=function(t){var e=this.getBounding(),i=e.width,r=e.height,n=A("canvas",{width:"".concat(i,"px"),height:"".concat(r,"px"),boxSizing:"border-box"}),o=n.getContext("2d"),a=I(n);n.width=i*a,n.height=r*a,o.scale(a,a);var s=this._mainWidget.getBounding();return o.drawImage(this._mainWidget.getImage(t),s.left,0,s.width,s.height),this._yAxisWidgets.forEach((function(e){var i=e.getBounding();o.drawImage(e.getImage(t),i.left,0,i.width,i.height)})),n},e.prototype.createYAxisComponent=function(t){throw new Error("createYAxisComponent is not implemented.")},e.prototype.createYAxisWidget=function(t,e){return null},e}(hi),pi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.createYAxisComponent=function(t){var e=function(t){var e;return null!==(e=ri[t])&&void 0!==e?e:ri.normal}(null!=t?t:"default");return new e(this)},e.prototype.createMainWidget=function(t){return new Je(t,this)},e.prototype.createYAxisWidget=function(t,e){return new ci(t,this,e)},e}(di),gi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.createMainWidget=function(t){return new ti(t,this)},e}(pi);var vi=function(t){function e(e,i){var r,n,o,a=t.call(this,e,i)||this;return a._dragFlag=!1,a._dragStartY=0,a._topPaneHeight=0,a._bottomPaneHeight=0,a._topPane=null,a._bottomPane=null,a._pressedMouseMoveEvent=(r=a._pressedTouchMouseMoveEvent,n=20,o=0,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=Date.now();i-o>n&&(r.apply(this,t),o=i)}),a.registerEvent("touchStartEvent",a._mouseDownEvent.bind(a)).registerEvent("touchMoveEvent",a._pressedMouseMoveEvent.bind(a)).registerEvent("touchEndEvent",a._mouseUpEvent.bind(a)).registerEvent("mouseDownEvent",a._mouseDownEvent.bind(a)).registerEvent("mouseUpEvent",a._mouseUpEvent.bind(a)).registerEvent("pressedMouseMoveEvent",a._pressedMouseMoveEvent.bind(a)).registerEvent("mouseEnterEvent",a._mouseEnterEvent.bind(a)).registerEvent("mouseLeaveEvent",a._mouseLeaveEvent.bind(a)),a}return i(e,t),e.prototype.getName=function(){return Et},e.prototype._dragEnabled=function(t,e){return"normal"===t.getOptions().state&&"normal"===e.getOptions().state&&e.getOptions().dragEnabled},e.prototype._findAdjustablePane=function(t,e){for(var i=this.getPane().getChart().getDrawPanes(),r=t;r>=0&&r<i.length;r+=e){var n=i[r];if(n.getId()!==K&&"normal"===n.getOptions().state)return n}return null},e.prototype._findDragPanes=function(){var t=this.getPane(),e=t.getChart().getDrawPanes(),i=e.indexOf(t.getTopPane()),r=e.indexOf(t.getBottomPane());if(-1===i||-1===r)return null;var n=this._findAdjustablePane(i,-1),o=this._findAdjustablePane(r,1);return f(n)&&f(o)&&this._dragEnabled(n,o)?{topPane:n,bottomPane:o}:null},e.prototype._mouseDownEvent=function(t){var e=this._findDragPanes();return f(e)?(this._topPane=e.topPane,this._bottomPane=e.bottomPane,this._dragFlag=!0,this._dragStartY=t.pageY,this._topPaneHeight=this._topPane.getBounding().height,this._bottomPaneHeight=this._bottomPane.getBounding().height,!0):(this._topPane=null,this._bottomPane=null,!1)},e.prototype._mouseUpEvent=function(){return this._dragFlag=!1,this._topPane=null,this._bottomPane=null,this._topPaneHeight=0,this._bottomPaneHeight=0,this._mouseLeaveEvent()},e.prototype._pressedTouchMouseMoveEvent=function(t){var e=t.pageY-this._dragStartY,i=e<0;if(f(this._topPane)&&f(this._bottomPane)&&this._dragEnabled(this._topPane,this._bottomPane)){var r=null,n=null,o=0,a=0;i?(r=this._topPane,n=this._bottomPane,o=this._topPaneHeight,a=this._bottomPaneHeight):(r=this._bottomPane,n=this._topPane,o=this._bottomPaneHeight,a=this._topPaneHeight);var s=r.getOptions().minHeight;if(o>s){var l=Math.max(o-Math.abs(e),s),u=o-l;r.setBounding({height:l});var c=a+u;n.setBounding({height:c}),r.setOptions({height:l}),n.setOptions({height:c});var h=this.getPane(),d=h.getChart();d.getChartStore().executeAction("onPaneDrag",{paneId:h.getId()}),d.layout({measureHeight:!0,measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})}}return!0},e.prototype._mouseEnterEvent=function(){if(f(this._findDragPanes())){var t=this.getPane().getChart().getStyles().separator;return this.getContainer().style.background=t.activeBackgroundColor,!0}return!1},e.prototype._mouseLeaveEvent=function(){return!this._dragFlag&&(this.getContainer().style.background="transparent",!0)},e.prototype.createContainer=function(){return A("div",{width:"100%",height:"".concat(7,"px"),margin:"0",padding:"0",position:"absolute",top:"-3px",zIndex:"20",boxSizing:"border-box",cursor:"ns-resize"})},e.prototype.updateImp=function(t,e,i){if(4===i||2===i){var r=this.getPane().getChart().getStyles().separator;t.style.top="".concat(-Math.floor((7-r.size)/2),"px"),t.style.height="".concat(7,"px")}},e}(Qe),fi=function(t){function e(e,i,r,n){var o=t.call(this,e,i)||this;return o.getContainer().style.overflow="",o._topPane=r,o._bottomPane=n,o._separatorWidget=new vi(o.getContainer(),o),o}return i(e,t),e.prototype.setBounding=function(t){return c(this.getBounding(),t),this},e.prototype.getTopPane=function(){return this._topPane},e.prototype.setTopPane=function(t){return this._topPane=t,this},e.prototype.getBottomPane=function(){return this._bottomPane},e.prototype.setBottomPane=function(t){return this._bottomPane=t,this},e.prototype.getWidget=function(){return this._separatorWidget},e.prototype.getImage=function(t){var e=this.getBounding(),i=e.width,r=e.height,n=this.getChart().getStyles().separator,o=A("canvas",{width:"".concat(i,"px"),height:"".concat(r,"px"),boxSizing:"border-box"}),a=o.getContext("2d"),s=I(o);return o.width=i*s,o.height=r*s,a.scale(s,s),a.fillStyle=n.color,a.fillRect(0,0,i,r),o},e.prototype.updateImp=function(t,e,i){if(4===t||2===t){var r=this.getChart().getStyles().separator;e.style.backgroundColor=r.color,e.style.height="".concat(i.height,"px"),e.style.marginLeft="".concat(i.left,"px"),e.style.width="".concat(i.width,"px"),this._separatorWidget.update(t)}},e}(hi),yi=function(t){function e(e,i){var r=t.call(this,e)||this;return r.override(i),r}return i(e,t),e.prototype.override=function(t){var e=t.name,i=t.scrollZoomEnabled,r=t.createTicks;!m(this.name)&&m(e)&&(this.name=e),this.scrollZoomEnabled=null!=i?i:this.scrollZoomEnabled,this.createTicks=null!=r?r:this.createTicks},e.prototype.createRangeImp=function(){var t=this.getParent().getChart().getChartStore().getVisibleRange(),e=t.realFrom,i=t.realTo,r=i-e+1;return{from:e,to:i,range:r,realFrom:e,realTo:i,realRange:r,displayFrom:e,displayTo:i,displayRange:r}},e.prototype.createTicksImp=function(){var t,e=this.getRange(),i=e.realFrom,r=e.realTo,n=e.from,o=this.getParent().getChart().getChartStore(),a=o.getInnerFormatter().formatDate,s=o.getPeriod(),l=[],u=o.getBarSpace().bar,c=o.getStyles().xAxis.tickText,h=Math.max(S("YYYY-MM-DD HH:mm:ss",c.size,c.weight,c.family),this.getBounding().width/8),d=Math.ceil(h/u);d%2!=0&&(d+=1);for(var g=Math.max(0,Math.floor(i/d)*d);g<r;g+=d)if(g>=n){var f=o.dataIndexToTimestamp(g);v(f)&&l.push({coord:this.convertToPixel(g),value:f,text:a(f,Re[null!==(t=null==s?void 0:s.type)&&void 0!==t?t:"day"],"xAxis")})}return p(this.createTicks)?this.createTicks({range:this.getRange(),bounding:this.getBounding(),defaultTicks:l}):l},e.prototype.getAutoSize=function(){var t=this.getParent().getChart().getStyles(),e=t.xAxis,i=e.size;if("auto"!==i)return i;var r=t.crosshair,n=0;e.show&&(e.axisLine.show&&(n+=e.axisLine.size),e.tickLine.show&&(n+=e.tickLine.length),e.tickText.show&&(n+=e.tickText.marginStart+e.tickText.marginEnd+e.tickText.size));var o=0;return r.show&&r.vertical.show&&r.vertical.text.show&&(o+=r.vertical.text.paddingTop+r.vertical.text.paddingBottom+2*r.vertical.text.borderSize+r.vertical.text.size),Math.max(n,o)},e.prototype.getBounding=function(){return this.getParent().getMainWidget().getBounding()},e.prototype.convertTimestampFromPixel=function(t){var e=this.getParent().getChart().getChartStore(),i=e.coordinateToDataIndex(t);return e.dataIndexToTimestamp(i)},e.prototype.convertTimestampToPixel=function(t){var e=this.getParent().getChart().getChartStore(),i=e.timestampToDataIndex(t);return e.dataIndexToCoordinate(i)},e.prototype.convertFromPixel=function(t){return this.getParent().getChart().getChartStore().coordinateToDataIndex(t)},e.prototype.convertToPixel=function(t){return this.getParent().getChart().getChartStore().dataIndexToCoordinate(t)},e.extend=function(t){var r=function(e){function r(i){return e.call(this,i,t)||this}return i(r,e),r}(e);return r},e}(Q),mi={normal:yi.extend({name:"normal"})};var _i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.compare=function(t){return f(t.timestamp)},e.prototype.getDirectionStyles=function(t){return t.vertical},e.prototype.getText=function(t,e){var i,r,n=t.timestamp;return e.getInnerFormatter().formatDate(n,Le[null!==(r=null===(i=e.getPeriod())||void 0===i?void 0:i.type)&&void 0!==r?r:"day"],"crosshair")},e.prototype.getTextAttrs=function(t,e,i,r,n,o){var a=i.realX,s=0,l="center";return a-e/2-o.paddingLeft<0?(s=0,l="left"):a+e/2+o.paddingRight>r.width?(s=r.width,l="right"):s=a,{x:s,y:0,text:t,align:l,baseline:"top"}},e}(oi),xi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.coordinateToPointTimestampDataIndexFlag=function(){return!0},e.prototype.coordinateToPointValueFlag=function(){return!1},e.prototype.getCompleteOverlays=function(){return this.getWidget().getPane().getChart().getChartStore().getOverlaysByPaneId()},e.prototype.getProgressOverlay=function(){var t,e;return null!==(e=null===(t=this.getWidget().getPane().getChart().getChartStore().getProgressOverlayInfo())||void 0===t?void 0:t.overlay)&&void 0!==e?e:null},e.prototype.getDefaultFigures=function(t,e){var i,r=[],n=this.getWidget(),o=n.getPane().getChart().getChartStore(),a=o.getClickOverlayInfo();if(t.needDefaultXAxisFigure&&t.id===(null===(i=a.overlay)||void 0===i?void 0:i.id)){var s=Number.MAX_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;e.forEach((function(e,i){s=Math.min(s,e.x),l=Math.max(l,e.x);var n=t.points[i];if(v(n.timestamp)){var a=o.getInnerFormatter().formatDate(n.timestamp,"YYYY-MM-DD HH:mm","crosshair");r.push({type:"text",attrs:{x:e.x,y:0,text:a,align:"center"},ignoreEvent:!0})}})),e.length>1&&r.unshift({type:"rect",attrs:{x:s,y:0,width:l-s,height:n.getBounding().height},ignoreEvent:!0})}return r},e.prototype.getFigures=function(t,e){var i,r,n=this.getWidget(),o=n.getPane(),a=o.getChart(),s=o.getYAxisComponentById(),l=a.getXAxisPane().getXAxisComponent(),u=n.getBounding();return null!==(r=null===(i=t.createXAxisFigures)||void 0===i?void 0:i.call(t,{chart:a,overlay:t,coordinates:e,bounding:u,xAxis:l,yAxis:s}))&&void 0!==r?r:[]},e}(si),bi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getAxis=function(){return this.getWidget().getPane().getXAxisComponent()},e.prototype.getAxisStyles=function(t){return t.xAxis},e.prototype.createAxisLine=function(t){return{coordinates:[{x:0,y:0},{x:t.width,y:0}]}},e.prototype.createTickLines=function(t,e,i){var r=i.tickLine,n=i.axisLine.size;return t.map((function(t){return{coordinates:[{x:t.coord,y:0},{x:t.coord,y:n+r.length}]}}))},e.prototype.createTickTexts=function(t,e,i){var r=i.tickText,n=i.axisLine.size,o=i.tickLine.length;return t.map((function(t){return{x:t.coord,y:n+o+r.marginStart,text:t.text,align:"center",baseline:"top"}}))},e}(li),wi=function(t){function e(e,i){var r=t.call(this,e,i)||this;return r._xAxisView=new bi(r),r._overlayXAxisView=new xi(r),r._crosshairVerticalLabelView=new _i(r),r.setCursor("ew-resize"),r.addChild(r._overlayXAxisView),r}return i(e,t),e.prototype.getName=function(){return wt},e.prototype.updateMain=function(t){this._xAxisView.draw(t)},e.prototype.updateOverlay=function(t){this._overlayXAxisView.draw(t),this._crosshairVerticalLabelView.draw(t)},e}($e),Ci=function(t){function e(e,i){var r=t.call(this,e,i)||this;return r.overrideXAxis({name:"normal",scrollZoomEnabled:!0}),r}return i(e,t),e.prototype.setOptions=function(e){return t.prototype.setOptions.call(this,e)},e.prototype.overrideXAxis=function(t){var e=t.name;return(!f(this._xAxis)||f(e)&&this._xAxis.name!==e)&&(this._xAxis=this.createXAxisComponent(null!=e?e:"normal")),this._xAxis.override(t),this.setAxisCursor(this._xAxis.scrollZoomEnabled),this},e.prototype.getXAxisComponent=function(){return this._xAxis},e.prototype.createXAxisComponent=function(t){var e=function(t){var e;return null!==(e=mi[t])&&void 0!==e?e:mi.normal}(t);return new e(this)},e.prototype.createMainWidget=function(t){return new wi(t,this)},e}(di),Ei=function(){function t(){this._callbacks=[]}return t.prototype.subscribe=function(t){this._callbacks.indexOf(t)<0&&this._callbacks.push(t)},t.prototype.unsubscribe=function(t){if(p(t)){var e=this._callbacks.indexOf(t);e>-1&&this._callbacks.splice(e,1)}else this._callbacks=[]},t.prototype.execute=function(t){this._callbacks.forEach((function(e){e(t)}))},t.prototype.isEmpty=function(){return 0===this._callbacks.length},t}(),Ii={RED:"#F92855",GREEN:"#2DC08E",WHITE:"#FFFFFF",GREY:"#76808F",BLUE:"#1677FF"};function Ti(){return{show:!0,size:"auto",axisLine:{show:!0,color:"#DDDDDD",size:1},tickText:{show:!0,color:Ii.GREY,size:12,family:"Helvetica Neue",weight:"normal",marginStart:4,marginEnd:6},tickLine:{show:!0,size:1,length:3,color:"#DDDDDD"}}}var Si=function(){function t(t){this._holdingTasks=null,this._running=!1,this._callback=t}return t.prototype.add=function(t){this._running?f(this._holdingTasks)?this._holdingTasks=r(r({},this._holdingTasks),t):this._holdingTasks=t:this._runTask(t)},t.prototype._runTask=function(t){return o(this,void 0,void 0,(function(){var e,i;return a(this,(function(r){switch(r.label){case 0:this._running=!0,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,Promise.all(Object.values(t))];case 2:return r.sent(),[3,4];case 3:return this._running=!1,null===(i=this._callback)||void 0===i||i.call(this),f(this._holdingTasks)&&(e=this._holdingTasks,this._runTask(e),this._holdingTasks=null),[7];case 4:return[2]}}))}))},t.prototype.clear=function(){this._holdingTasks=null},t}();var Ai={name:"fibonacciLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,r,n=t.chart,o=t.coordinates,a=t.bounding,s=t.overlay,l=t.yAxis,u=s.points;if(o.length>0){var c=0;if(null===(e=null==l?void 0:l.isInCandle())||void 0===e||e)c=null!==(r=null===(i=n.getSymbol())||void 0===i?void 0:i.pricePrecision)&&void 0!==r?r:O;else n.getIndicators({paneId:s.paneId}).forEach((function(t){c=Math.max(c,t.precision)}));var h=[],d=[],p=a.width;if(o.length>1&&v(u[0].value)&&v(u[1].value)){var g=o[0].y-o[1].y,f=u[0].value-u[1].value;[1,.786,.618,.5,.382,.236,0].forEach((function(t){var e,i=o[1].y+g*t,r=n.getDecimalFold().format(n.getThousandsSeparator().format(((null!==(e=u[1].value)&&void 0!==e?e:0)+f*t).toFixed(c)));h.push({coordinates:[{x:0,y:i},{x:p,y:i}]}),d.push({x:0,y:i,text:"".concat(r," (").concat((100*t).toFixed(1),"%)"),baseline:"bottom"})}))}return[{type:"line",attrs:h},{type:"text",isCheckEvent:!1,attrs:d}]}return[]}},Mi={name:"horizontalRayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding,r={x:0,y:e[0].y};return f(e[1])&&e[0].x<e[1].x&&(r.x=i.width),[{type:"line",attrs:{coordinates:[e[0],r]}}]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].value=i.value,e[1].value=i.value},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].value=r.value)}};function Pi(t,e,i){var r=null!=i?i:0,n=[];if(t.length>1)if(t[0].x===t[1].x){var o=e.height;if(n.push({coordinates:[{x:t[0].x,y:0},{x:t[0].x,y:o}]}),t.length>2){n.push({coordinates:[{x:t[2].x,y:0},{x:t[2].x,y:o}]});for(var a=t[0].x-t[2].x,s=0;s<r;s++){var l=a*(s+1);n.push({coordinates:[{x:t[0].x+l,y:0},{x:t[0].x+l,y:o}]})}}}else{var u=e.width,c=ie(t[0],t[1]),h=c[0],d=c[1];if(n.push({coordinates:[{x:0,y:0*h+d},{x:u,y:u*h+d}]}),t.length>2){var p=t[2].y-h*t[2].x;n.push({coordinates:[{x:0,y:0*h+p},{x:u,y:u*h+p}]});for(a=d-p,s=0;s<r;s++){var g=d+a*(s+1);n.push({coordinates:[{x:0,y:0*h+g},{x:u,y:u*h+g}]})}}}return n}var Di={name:"parallelStraightLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:Pi(t.coordinates,t.bounding)}]}},ki={name:"priceChannelLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:Pi(t.coordinates,t.bounding,1)}]}},Bi={name:"priceLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,r,n=t.chart,o=t.coordinates,a=t.bounding,s=t.overlay,l=t.yAxis,u=0;null===(e=null==l?void 0:l.isInCandle())||void 0===e||e?u=null!==(r=null===(i=n.getSymbol())||void 0===i?void 0:i.pricePrecision)&&void 0!==r?r:O:n.getIndicators({paneId:s.paneId}).forEach((function(t){u=Math.max(u,t.precision)}));var c=s.points[0].value,h=void 0===c?0:c;return[{type:"line",attrs:{coordinates:[o[0],{x:a.width,y:o[0].y}]}},{type:"text",ignoreEvent:!0,attrs:{x:o[0].x,y:o[0].y,text:n.getDecimalFold().format(n.getThousandsSeparator().format(h.toFixed(u))),baseline:"bottom"}}]}};function Fi(t,e){if(t.length>1){var i={x:0,y:0};return i=t[0].x===t[1].x&&t[0].y!==t[1].y?t[0].y<t[1].y?{x:t[0].x,y:e.height}:{x:t[0].x,y:0}:t[0].x>t[1].x?{x:0,y:ee(t[0],t[1],{x:0,y:t[0].y})}:{x:e.width,y:ee(t[0],t[1],{x:e.width,y:t[0].y})},{coordinates:[t[0],i]}}return[]}var Ri={name:"rayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:Fi(t.coordinates,t.bounding)}]}},Li={name:"simpleAnnotation",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:function(t){var e,i=t.overlay,r=t.coordinates,n="";f(i.extendData)&&(n=p(i.extendData)?i.extendData(i):null!==(e=i.extendData)&&void 0!==e?e:"");var o=r[0].x,a=r[0].y-6,s=a-50,l=s-5;return[{type:"line",attrs:{coordinates:[{x:o,y:a},{x:o,y:s}]},ignoreEvent:!0},{type:"polygon",attrs:{coordinates:[{x:o,y:s},{x:o-4,y:l},{x:o+4,y:l}]},ignoreEvent:!0},{type:"text",attrs:{x:o,y:l,text:n,align:"center",baseline:"bottom"},ignoreEvent:!0}]}},Oi={name:"simpleTag",totalStep:2,styles:{line:{style:"dashed"}},createPointFigures:function(t){var e=t.bounding,i=t.coordinates;return{type:"line",attrs:{coordinates:[{x:0,y:i[0].y},{x:e.width,y:i[0].y}]},ignoreEvent:!0}},createYAxisFigures:function(t){var e,i,r,n,o=t.chart,a=t.overlay,s=t.coordinates,l=t.bounding,u=t.yAxis,c="left",h=0;null!==(e=null==u?void 0:u.isFromZero())&&void 0!==e&&e?(c="left",h=0):(c="right",h=l.width);var d="";return f(a.extendData)&&(d=p(a.extendData)?a.extendData(a):null!==(i=a.extendData)&&void 0!==i?i:""),!f(d)&&v(a.points[0].value)&&(d=H(a.points[0].value,null!==(n=null===(r=o.getSymbol())||void 0===r?void 0:r.pricePrecision)&&void 0!==n?n:O)),{type:"text",attrs:{x:h,y:s[0].y,text:d,align:c,baseline:"middle"}}}},Yi={name:"straightLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return 2===e.length?e[0].x===e[1].x?[{type:"line",attrs:{coordinates:[{x:e[0].x,y:0},{x:e[0].x,y:i.height}]}}]:[{type:"line",attrs:{coordinates:[{x:0,y:ee(e[0],e[1],{x:0,y:e[0].y})},{x:i.width,y:ee(e[0],e[1],{x:i.width,y:e[0].y})}]}}]:[]}},Wi={},zi=[Ai,Mi,{name:"horizontalSegment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=[];return 2===e.length&&i.push({coordinates:e}),[{type:"line",attrs:i}]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].value=i.value,e[1].value=i.value},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].value=r.value)}},{name:"horizontalStraightLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return[{type:"line",attrs:{coordinates:[{x:0,y:e[0].y},{x:i.width,y:e[0].y}]}}]}},Di,ki,Bi,Ri,{name:"segment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates;return 2===e.length?[{type:"line",attrs:{coordinates:e}}]:[]}},Yi,{name:"verticalRayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;if(2===e.length){var r={x:e[0].x,y:0};return e[0].y<e[1].y&&(r.y=i.height),[{type:"line",attrs:{coordinates:[e[0],r]}}]}return[]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].timestamp=i.timestamp,e[0].dataIndex=i.dataIndex,e[1].timestamp=i.timestamp,e[1].dataIndex=i.dataIndex},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].timestamp=r.timestamp,i[0].dataIndex=r.dataIndex)}},{name:"verticalSegment",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates;return 2===e.length?[{type:"line",attrs:{coordinates:e}}]:[]},performEventPressedMove:function(t){var e=t.points,i=t.performPoint;e[0].timestamp=i.timestamp,e[0].dataIndex=i.dataIndex,e[1].timestamp=i.timestamp,e[1].dataIndex=i.dataIndex},performEventMoveForDrawing:function(t){var e=t.currentStep,i=t.points,r=t.performPoint;2===e&&(i[0].timestamp=r.timestamp,i[0].dataIndex=r.dataIndex)}},{name:"verticalStraightLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding;return[{type:"line",attrs:{coordinates:[{x:e[0].x,y:0},{x:e[0].x,y:i.height}]}}]}},Li,Oi,{name:"brush",totalStep:2,drawingMode:"continuous",needDefaultPointFigure:!1,needDefaultXAxisFigure:!1,needDefaultYAxisFigure:!1,createPointFigures:function(t){var e=t.coordinates;return e.length<2?[]:[{type:"line",attrs:{coordinates:e},styles:{smooth:!1,lineCap:"round",lineJoin:"round"}}]}}];function Vi(t){var e;return null!==(e=Wi[t])&&void 0!==e?e:null}zi.forEach((function(t){Wi[t.name]=Ze.extend(t)}));var Ni={light:{grid:{horizontal:{color:"#EDEDED"},vertical:{color:"#EDEDED"}},candle:{priceMark:{high:{color:"#76808F"},low:{color:"#76808F"}},tooltip:{rect:{color:"#FEFEFE",borderColor:"#F2F3F5"},title:{color:"#76808F"},legend:{color:"#76808F"}}},indicator:{tooltip:{title:{color:"#76808F"},legend:{color:"#76808F"}}},xAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},yAxis:{axisLine:{color:"#DDDDDD"},tickText:{color:"#76808F"},tickLine:{color:"#DDDDDD"}},separator:{color:"#DDDDDD"},crosshair:{horizontal:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}},vertical:{line:{color:"#76808F"},text:{borderColor:"#686D76",backgroundColor:"#686D76"}}}},dark:{grid:{horizontal:{color:"#292929"},vertical:{color:"#292929"}},candle:{priceMark:{high:{color:"#929AA5"},low:{color:"#929AA5"}},tooltip:{rect:{color:"rgba(10, 10, 10, .6)",borderColor:"rgba(10, 10, 10, .6)"},title:{color:"#929AA5"},legend:{color:"#929AA5"}}},indicator:{tooltip:{title:{color:"#929AA5"},legend:{color:"#929AA5"}}},xAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},yAxis:{axisLine:{color:"#333333"},tickText:{color:"#929AA5"},tickLine:{color:"#333333"}},separator:{color:"#333333"},crosshair:{horizontal:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}},vertical:{line:{color:"#929AA5"},text:{borderColor:"#373a40",backgroundColor:"#373a40"}}}}};function Hi(t){var e;return null!==(e=Ni[t])&&void 0!==e?e:null}var Xi=function(){function t(t,e){var i,n,o,a,s,l=this;this._styles={grid:{show:!0,horizontal:{show:!0,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]},vertical:{show:!0,size:1,color:"#EDEDED",style:"dashed",dashedValue:[2,2]}},candle:(s={show:!0,color:Ii.GREY,textOffset:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},{type:"candle_solid",bar:{compareRule:"current_open",upColor:Ii.GREEN,downColor:Ii.RED,noChangeColor:Ii.GREY,upBorderColor:Ii.GREEN,downBorderColor:Ii.RED,noChangeBorderColor:Ii.GREY,upWickColor:Ii.GREEN,downWickColor:Ii.RED,noChangeWickColor:Ii.GREY},area:{lineSize:2,lineColor:Ii.BLUE,smooth:!1,value:"close",backgroundColor:[{offset:0,color:le(Ii.BLUE,.01)},{offset:1,color:le(Ii.BLUE,.2)}],point:{show:!0,color:Ii.BLUE,radius:4,rippleColor:le(Ii.BLUE,.3),rippleRadius:8,animation:!0,animationDuration:1e3}},priceMark:{show:!0,high:r({},s),low:r({},s),last:{show:!0,compareRule:"current_open",upColor:Ii.GREEN,downColor:Ii.RED,noChangeColor:Ii.GREY,line:{show:!0,style:"dashed",dashedValue:[4,4],size:1},text:{show:!0,style:"fill",size:12,paddingLeft:4,paddingTop:4,paddingRight:4,paddingBottom:4,borderColor:"transparent",borderStyle:"solid",borderSize:0,borderDashedValue:[2,2],color:Ii.WHITE,family:"Helvetica Neue",weight:"normal",borderRadius:2},extendTexts:[]}},tooltip:{offsetLeft:4,offsetTop:6,offsetRight:4,offsetBottom:6,showRule:"always",showType:"standard",rect:{position:"fixed",paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,offsetLeft:4,offsetTop:4,offsetRight:4,offsetBottom:4,borderRadius:4,borderSize:1,borderColor:"#F2F3F5",color:"#FEFEFE"},title:{show:!0,size:14,family:"Helvetica Neue",weight:"normal",color:Ii.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,template:"{ticker} · {period}"},legend:{size:12,family:"Helvetica Neue",weight:"normal",color:Ii.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,defaultValue:"n/a",template:[{title:"time",value:"{time}"},{title:"open",value:"{open}"},{title:"high",value:"{high}"},{title:"low",value:"{low}"},{title:"close",value:"{close}"},{title:"volume",value:"{volume}"}]},features:[]}}),indicator:(o=le(Ii.GREEN,.7),a=le(Ii.RED,.7),{ohlc:{compareRule:"current_open",upColor:o,downColor:a,noChangeColor:Ii.GREY},bars:[{style:"fill",borderStyle:"solid",borderSize:1,borderDashedValue:[2,2],upColor:o,downColor:a,noChangeColor:Ii.GREY}],lines:["#FF9600","#935EBD",Ii.BLUE,"#E11D74","#01C5C4"].map((function(t){return{style:"solid",smooth:!1,size:1,dashedValue:[2,2],color:t}})),circles:[{style:"fill",borderStyle:"solid",borderSize:1,borderDashedValue:[2,2],upColor:o,downColor:a,noChangeColor:Ii.GREY}],texts:[{paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,style:"fill",size:12,color:Ii.BLUE,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:0,borderColor:"transparent",borderRadius:0,backgroundColor:"transparent"}],lastValueMark:{show:!1,text:{show:!1,style:"fill",color:Ii.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderColor:"transparent",borderSize:0,borderDashedValue:[2,2],paddingLeft:4,paddingTop:4,paddingRight:4,paddingBottom:4,borderRadius:2}},tooltip:{offsetLeft:4,offsetTop:6,offsetRight:4,offsetBottom:6,showRule:"always",showType:"standard",title:{show:!0,showName:!0,showParams:!0,size:12,family:"Helvetica Neue",weight:"normal",color:Ii.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4},legend:{size:12,family:"Helvetica Neue",weight:"normal",color:Ii.GREY,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4,defaultValue:"n/a"},features:[]}}),xAxis:Ti(),yAxis:Ti(),separator:{size:1,color:"#DDDDDD",fill:!0,activeBackgroundColor:le(Ii.BLUE,.08)},crosshair:{show:!0,horizontal:{show:!0,line:{show:!0,style:"dashed",dashedValue:[4,2],size:1,color:Ii.GREY},text:{show:!0,style:"fill",color:Ii.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderColor:Ii.GREY,borderRadius:2,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:Ii.GREY},features:[]},vertical:{show:!0,line:{show:!0,style:"dashed",dashedValue:[4,2],size:1,color:Ii.GREY},text:{show:!0,style:"fill",color:Ii.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderColor:Ii.GREY,borderRadius:2,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:Ii.GREY}}},overlay:(i=le(Ii.BLUE,.35),n=le(Ii.BLUE,.25),{point:{color:Ii.BLUE,borderColor:i,borderSize:1,radius:5,activeColor:Ii.BLUE,activeBorderColor:i,activeBorderSize:3,activeRadius:5},line:{style:"solid",smooth:!1,color:Ii.BLUE,size:1,dashedValue:[2,2]},rect:{style:"fill",color:n,borderColor:Ii.BLUE,borderSize:1,borderRadius:0,borderStyle:"solid",borderDashedValue:[2,2]},polygon:{style:"fill",color:Ii.BLUE,borderColor:Ii.BLUE,borderSize:1,borderStyle:"solid",borderDashedValue:[2,2]},circle:{style:"fill",color:n,borderColor:Ii.BLUE,borderSize:1,borderStyle:"solid",borderDashedValue:[2,2]},arc:{style:"solid",color:Ii.BLUE,size:1,dashedValue:[2,2]},text:{style:"fill",color:Ii.WHITE,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:"solid",borderDashedValue:[2,2],borderSize:1,borderRadius:2,borderColor:Ii.BLUE,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:Ii.BLUE}})},this._formatter={formatDate:function(t){return N(t.dateTimeFormat,t.timestamp,t.template)},formatBigNumber:X,formatExtendText:function(t){return""}},this._innerFormatter={formatDate:function(t,e,i){return l._formatter.formatDate({dateTimeFormat:l._dateTimeFormat,timestamp:t,template:e,type:i})},formatBigNumber:function(t){return l._formatter.formatBigNumber(t)},formatExtendText:function(t){return l._formatter.formatExtendText(t)}},this._locale="en-US",this._thousandsSeparator={sign:",",format:function(t){return U(t,l._thousandsSeparator.sign)}},this._decimalFold={threshold:3,format:function(t){return G(t,l._decimalFold.threshold)}},this._hotKey={enabled:!0,exclude:[]},this._symbol=null,this._period=null,this._dataList=[],this._dataLoader=null,this._loading=!1,this._dataLoadMore={forward:!1,backward:!1},this._zoomEnabled=!0,this._zoomAnchor={main:"cursor",xAxis:"cursor"},this._scrollEnabled=!0,this._totalBarSpace=0,this._barSpace=10,this._offsetRightDistance=80,this._startLastBarRightSideDiffBarCount=0,this._scrollLimitRole="bar_count",this._minVisibleBarCount={left:2,right:2},this._maxOffsetDistance={left:50,right:50},this._visibleRange={from:0,to:0,realFrom:0,realTo:0},this._visibleRangeDataList=[],this._visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}],this._crosshair={},this._actions=new Map,this._indicators=new Map,this._overlays=new Map,this._progressOverlayInfo=null,this._lastPriceMarkExtendTextUpdateTimers=[],this._pressedOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null},this._hoverOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null},this._clickOverlayInfo={paneId:"",overlay:null,figureType:"none",figureIndex:-1,figure:null},this._layoutOptions={barSpaceLimit:{min:1,max:50},pane:{minHeight:30,dragEnabled:!0,order:0,height:100,state:"normal"},yAxis:{reverse:!1,inside:!1,position:"right",scrollZoomEnabled:!0,needWidget:!0,gap:{top:.2,bottom:.1}}},this._chart=t;var u=null!=e?e:{},h=u.styles,d=u.locale,p=u.timezone,g=u.formatter,v=u.thousandsSeparator,y=u.decimalFold,_=u.zoomAnchor,x=u.hotkey,b=u.layout;f(b)&&c(this._layoutOptions,b),this._calcOptimalBarSpace(),this._lastBarRightSideDiffBarCount=this._offsetRightDistance/this._barSpace,f(h)&&this.setStyles(h),m(d)&&this.setLocale(d),this.setTimezone(null!=p?p:""),f(g)&&this.setFormatter(g),f(v)&&this.setThousandsSeparator(v),f(y)&&this.setDecimalFold(y),f(_)&&this.setZoomAnchor(_),f(x)&&this.setHotkey(x),this._taskScheduler=new Si((function(){l._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0})}))}return t.prototype.setStyles=function(t){var e,i,r,n,o,a,s=this,l=null;if(l=m(t)?Hi(t):t,c(this._styles,l),d(null===(r=null===(i=null===(e=null==l?void 0:l.candle)||void 0===e?void 0:e.tooltip)||void 0===i?void 0:i.legend)||void 0===r?void 0:r.template)&&(this._styles.candle.tooltip.legend.template=l.candle.tooltip.legend.template),f(null===(a=null===(o=null===(n=null==l?void 0:l.candle)||void 0===n?void 0:n.priceMark)||void 0===o?void 0:o.last)||void 0===a?void 0:a.extendTexts)){this._clearLastPriceMarkExtendTextUpdateTimer();var u=[];this._styles.candle.priceMark.last.extendTexts.forEach((function(t){var e=t.updateInterval;if(t.show&&e>0&&!u.includes(e)){u.push(e);var i=setInterval((function(){s._chart.updatePane(0,j)}),e);s._lastPriceMarkExtendTextUpdateTimers.push(i)}}))}},t.prototype.getStyles=function(){return this._styles},t.prototype.setFormatter=function(t){c(this._formatter,t)},t.prototype.getFormatter=function(){return this._formatter},t.prototype.getInnerFormatter=function(){return this._innerFormatter},t.prototype.setLocale=function(t){this._locale=t},t.prototype.getLocale=function(){return this._locale},t.prototype.setTimezone=function(t){if(!f(this._dateTimeFormat)||this.getTimezone()!==t){var e={hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"};t.length>0&&(e.timeZone=t);var i=null;try{i=new Intl.DateTimeFormat("en",e)}catch(t){}null!==i&&(this._dateTimeFormat=i)}},t.prototype.getTimezone=function(){return this._dateTimeFormat.resolvedOptions().timeZone},t.prototype.getDateTimeFormat=function(){return this._dateTimeFormat},t.prototype.setThousandsSeparator=function(t){c(this._thousandsSeparator,t)},t.prototype.getThousandsSeparator=function(){return this._thousandsSeparator},t.prototype.setDecimalFold=function(t){c(this._decimalFold,t)},t.prototype.getDecimalFold=function(){return this._decimalFold},t.prototype.setHotkey=function(t){c(this._hotKey,t)},t.prototype.getHotkey=function(){return this._hotKey},t.prototype.getHotKey=function(){return this._hotKey},t.prototype.setSymbol=function(t){var e=this;this.resetData((function(){e._symbol=r(r({pricePrecision:O,volumePrecision:Y},e._symbol),t),e._synchronizeIndicatorSeriesPrecision()}))},t.prototype.getSymbol=function(){return this._symbol},t.prototype.setPeriod=function(t){var e=this;this.resetData((function(){e._period=t}))},t.prototype.getPeriod=function(){return this._period},t.prototype.getDataList=function(){return this._dataList},t.prototype.getVisibleRangeDataList=function(){return this._visibleRangeDataList},t.prototype.getVisibleRangeHighLowPrice=function(){return this._visibleRangeHighLowPrice},t.prototype._addData=function(t,e,i){var r,n,o=!1,a=!1;if(d(t)){var s={backward:!1,forward:!1};switch(y(i)?(s.backward=i,s.forward=i):(s.backward=null!==(r=null==i?void 0:i.backward)&&void 0!==r&&r,s.forward=null!==(n=null==i?void 0:i.forward)&&void 0!==n&&n),e){case"init":this._clearData(),this._dataList=t,this._dataLoadMore.backward=s.backward,this._dataLoadMore.forward=s.forward,this.setOffsetRightDistance(this._offsetRightDistance),a=!0;break;case"backward":this._dataList=this._dataList.concat(t),this._dataLoadMore.backward=s.backward,this._lastBarRightSideDiffBarCount-=t.length,this._startLastBarRightSideDiffBarCount-=t.length,a=t.length>0;break;case"forward":this._dataList=t.concat(this._dataList),this._dataLoadMore.forward=s.forward,a=t.length>0}o=!0}else{var l=this._dataList.length,u=t.timestamp,c=V(this._dataList[l-1],"timestamp",0);if(u>c){this._dataList.push(t);var h=this.getLastBarRightSideDiffBarCount();h<0&&this.setLastBarRightSideDiffBarCount(--h),o=!0,a=!0}else u===c&&(this._dataList[l-1]=t,o=!0,a=!0)}if(o&&a){this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:!0});var p=this.getIndicatorsByFilter({});p.length>0?this._calcIndicator(p):this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,cacheYAxisWidth:"init"!==e})}},t.prototype.setDataLoader=function(t){var e=this;this.resetData((function(){e._dataLoader=t}))},t.prototype._calcOptimalBarSpace=function(){var t=1-.2*Math.atan(Math.max(4,this._barSpace)-4)/(.5*Math.PI),e=Math.min(Math.floor(this._barSpace*t),Math.floor(this._barSpace));e%2==0&&e+2>=this._barSpace&&--e,this._gapBarSpace=Math.max(1,e)},t.prototype._adjustVisibleRange=function(){var t,e,i=this._dataList.length,r=this._totalBarSpace/this._barSpace,n=0,o=0;"distance"===this._scrollLimitRole?(n=(this._totalBarSpace-this._maxOffsetDistance.right)/this._barSpace,o=(this._totalBarSpace-this._maxOffsetDistance.left)/this._barSpace):(n=this._minVisibleBarCount.left,o=this._minVisibleBarCount.right),n=Math.max(0,n),o=Math.max(0,o);var a=r-Math.min(n,i);this._lastBarRightSideDiffBarCount>a&&(this._lastBarRightSideDiffBarCount=a);var s=-i+Math.min(o,i);this._lastBarRightSideDiffBarCount<s&&(this._lastBarRightSideDiffBarCount=s);var l=Math.round(this._lastBarRightSideDiffBarCount+i+.5),u=l;l>i&&(l=i);var c=Math.round(l-r)-1;c<0&&(c=0);var h=this._lastBarRightSideDiffBarCount>0?Math.round(i+this._lastBarRightSideDiffBarCount-r)-1:c;this._visibleRange={from:c,to:l,realFrom:h,realTo:u},this.executeAction("onVisibleRangeChange",this._visibleRange),this._visibleRangeDataList=[],this._visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}];for(var d=h;d<u;d++){var p=this._dataList[d],g=this.dataIndexToCoordinate(d);this._visibleRangeDataList.push({dataIndex:d,x:g,data:{prev:null!==(t=this._dataList[d-1])&&void 0!==t?t:p,current:p,next:null!==(e=this._dataList[d+1])&&void 0!==e?e:p}}),f(p)&&(this._visibleRangeHighLowPrice[0].price<p.high&&(this._visibleRangeHighLowPrice[0].price=p.high,this._visibleRangeHighLowPrice[0].x=g),this._visibleRangeHighLowPrice[1].price>p.low&&(this._visibleRangeHighLowPrice[1].price=p.low,this._visibleRangeHighLowPrice[1].x=g))}0===c&&this._dataLoadMore.forward?this._processDataLoad("forward"):l===i&&this._dataLoadMore.backward&&this._processDataLoad("backward")},t.prototype._processDataLoad=function(t){var e,i,r,n,o=this;if(!this._loading&&f(this._dataLoader)&&f(this._symbol)&&f(this._period)){this._loading=!0;var a={type:t,symbol:this._symbol,period:this._period,timestamp:null,callback:function(e,i){var r,n;o._loading=!1,o._addData(e,t,i),"init"===t&&(null===(n=null===(r=o._dataLoader)||void 0===r?void 0:r.subscribeBar)||void 0===n||n.call(r,{symbol:o._symbol,period:o._period,callback:function(t){o._addData(t,"update")}}))}};switch(t){case"backward":a.timestamp=null!==(i=null===(e=this._dataList[this._dataList.length-1])||void 0===e?void 0:e.timestamp)&&void 0!==i?i:null;break;case"forward":a.timestamp=null!==(n=null===(r=this._dataList[0])||void 0===r?void 0:r.timestamp)&&void 0!==n?n:null}this._dataLoader.getBars(a)}},t.prototype._processDataUnsubscribe=function(){var t,e;f(this._dataLoader)&&f(this._symbol)&&f(this._period)&&(null===(e=(t=this._dataLoader).unsubscribeBar)||void 0===e||e.call(t,{symbol:this._symbol,period:this._period}))},t.prototype.resetData=function(t){this._processDataUnsubscribe(),null==t||t(),this._loading=!1,this._processDataLoad("init")},t.prototype.getBarSpace=function(){return{bar:this._barSpace,halfBar:this._barSpace/2,gapBar:this._gapBarSpace,halfGapBar:Math.floor(this._gapBarSpace/2)}},t.prototype.setBarSpace=function(t,e){t<this._layoutOptions.barSpaceLimit.min||t>this._layoutOptions.barSpaceLimit.max||this._barSpace===t||(this._barSpace=t,this._calcOptimalBarSpace(),null==e||e(),this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:!0}),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,cacheYAxisWidth:!0}))},t.prototype.getLayoutOptions=function(){return this._layoutOptions},t.prototype.setTotalBarSpace=function(t){this._totalBarSpace!==t&&(this._totalBarSpace=t,this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:!0}))},t.prototype.setOffsetRightDistance=function(t,e){return this._offsetRightDistance="distance"===this._scrollLimitRole?Math.min(this._maxOffsetDistance.right,t):t,this._lastBarRightSideDiffBarCount=this._offsetRightDistance/this._barSpace,null!=e&&e&&(this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:!0}),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,cacheYAxisWidth:!0})),this},t.prototype.getInitialOffsetRightDistance=function(){return this._offsetRightDistance},t.prototype.getOffsetRightDistance=function(){return Math.max(0,this._lastBarRightSideDiffBarCount*this._barSpace)},t.prototype.getLastBarRightSideDiffBarCount=function(){return this._lastBarRightSideDiffBarCount},t.prototype.setLastBarRightSideDiffBarCount=function(t){this._lastBarRightSideDiffBarCount=t},t.prototype.setMaxOffsetLeftDistance=function(t){this._scrollLimitRole="distance",this._maxOffsetDistance.left=t},t.prototype.setMaxOffsetRightDistance=function(t){this._scrollLimitRole="distance",this._maxOffsetDistance.right=t},t.prototype.setLeftMinVisibleBarCount=function(t){this._scrollLimitRole="bar_count",this._minVisibleBarCount.left=t},t.prototype.setRightMinVisibleBarCount=function(t){this._scrollLimitRole="bar_count",this._minVisibleBarCount.right=t},t.prototype.getVisibleRange=function(){return this._visibleRange},t.prototype.startScroll=function(){this._startLastBarRightSideDiffBarCount=this._lastBarRightSideDiffBarCount},t.prototype.scroll=function(t){if(this._scrollEnabled){var e=t/this._barSpace,i=this._lastBarRightSideDiffBarCount*this._barSpace;this._lastBarRightSideDiffBarCount=this._startLastBarRightSideDiffBarCount-e,this._adjustVisibleRange(),this.setCrosshair(this._crosshair,{notInvalidate:!0}),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,cacheYAxisWidth:!0});var r=Math.round(i-this._lastBarRightSideDiffBarCount*this._barSpace);0!==r&&this.executeAction("onScroll",{distance:r})}},t.prototype.getDataByDataIndex=function(t){var e;return null!==(e=this._dataList[t])&&void 0!==e?e:null},t.prototype.coordinateToFloatIndex=function(t){var e=this._dataList.length,i=(this._totalBarSpace-t)/this._barSpace,r=e+this._lastBarRightSideDiffBarCount-i;return Math.round(1e6*r)/1e6},t.prototype.dataIndexToTimestamp=function(t){var e=this._dataList.length;if(0===e)return null;var i=this.getDataByDataIndex(t);if(f(i))return i.timestamp;if(f(this._period)){var r=e-1,n=null,o=0;if(t>r?(n=this._dataList[r].timestamp,o=t-r):t<0&&(n=this._dataList[0].timestamp,o=t),v(n)){var a=this._period,s=a.type,l=a.span;switch(s){case"second":return n+1e3*l*o;case"minute":return n+60*l*1e3*o;case"hour":return n+60*l*60*1e3*o;case"day":return n+24*l*60*60*1e3*o;case"week":return n+7*l*24*60*60*1e3*o;case"month":var u=(h=new Date(n)).getDate();h.setDate(1),h.setMonth(h.getMonth()+l*o);var c=new Date(h.getFullYear(),h.getMonth()+1,0).getDate();return h.setDate(Math.min(u,c)),h.getTime();case"year":var h;return(h=new Date(n)).setFullYear(h.getFullYear()+l*o),h.getTime()}}}return null},t.prototype.timestampToDataIndex=function(t){var e=this._dataList.length;if(0===e)return 0;if(f(this._period)){var i=null,r=0,n=e-1,o=this._dataList[n].timestamp;t>o&&(i=o,r=n);var a=this._dataList[0].timestamp;if(t<a&&(i=a,r=0),v(i)){var s=this._period,l=s.type,u=s.span;switch(l){case"second":return r+Math.floor((t-i)/(1e3*u));case"minute":return r+Math.floor((t-i)/(60*u*1e3));case"hour":return r+Math.floor((t-i)/(60*u*60*1e3));case"day":return r+Math.floor((t-i)/(24*u*60*60*1e3));case"week":return r+Math.floor((t-i)/(7*u*24*60*60*1e3));case"month":var c=new Date(i),h=new Date(t),d=c.getFullYear(),p=h.getFullYear(),g=c.getMonth(),y=h.getMonth();return r+Math.floor((12*(p-d)+(y-g))/u);case"year":d=new Date(i).getFullYear(),p=new Date(t).getFullYear();return r+Math.floor((p-d)/u)}}}return k(this._dataList,"timestamp",t)},t.prototype.dataIndexToCoordinate=function(t){var e=this._dataList.length+this._lastBarRightSideDiffBarCount-t;return Math.floor(this._totalBarSpace-(e-.5)*this._barSpace+.5)},t.prototype.coordinateToDataIndex=function(t){return Math.ceil(this.coordinateToFloatIndex(t))-1},t.prototype.floatIndexToTimestamp=function(t){var e=this._dataList.length;if(0===e)return null;var i=e-1;if(t>i&&e>=2){var r=this._dataList[i].timestamp;if((o=r-this._dataList[i-1].timestamp)>0){var n=t-i;return Math.round(r+n*o)}}if(t<0&&e>=2){var o,a=this._dataList[0].timestamp;if((o=this._dataList[1].timestamp-a)>0)return Math.round(a+t*o)}var s=Math.floor(t),l=t-s,u=this.dataIndexToTimestamp(s);if(0===l||!v(u))return u;var c=this.dataIndexToTimestamp(s+1);return v(c)?Math.round(u+(c-u)*l):u},t.prototype.timestampToFloatIndex=function(t){var e=this._dataList.length;if(0===e)return 0;var i,r=this._dataList[0].timestamp,n=this._dataList[e-1].timestamp;if(t>n&&e>=2&&(i=n-this._dataList[e-2].timestamp)>0)return e-1+(t-n)/i;if(t<r&&e>=2&&(i=this._dataList[1].timestamp-r)>0)return-((r-t)/i);for(var o=0,a=e-1,s=0;o<=a;){var l=Math.floor((o+a)/2);this._dataList[l].timestamp<=t?(s=l,o=l+1):a=l-1}var u=this._dataList[s],c=s+1<e?this._dataList[s+1]:null;if(f(u)&&f(c)){var h=u.timestamp,d=c.timestamp;if(t>=h&&d>h){var p=(t-h)/(d-h);return s+Math.min(p,1)}}return s},t.prototype.zoom=function(t,e,i){var r,n=this;if(this._zoomEnabled){var o=null!=e?e:{x:null!==(r=this._crosshair.x)&&void 0!==r?r:this._totalBarSpace/2};"xAxis"===i?"last_bar"===this._zoomAnchor.xAxis&&(o.x=this.dataIndexToCoordinate(this._dataList.length-1)):"last_bar"===this._zoomAnchor.main&&(o.x=this.dataIndexToCoordinate(this._dataList.length-1));var a=o.x,s=this.coordinateToFloatIndex(a),l=this._barSpace,u=this._barSpace+t*(this._barSpace/10);this.setBarSpace(u,(function(){n._lastBarRightSideDiffBarCount+=s-n.coordinateToFloatIndex(a)}));var c=this._barSpace/l;1!==c&&this.executeAction("onZoom",{scale:c})}},t.prototype.setZoomEnabled=function(t){this._zoomEnabled=t},t.prototype.isZoomEnabled=function(){return this._zoomEnabled},t.prototype.setZoomAnchor=function(t){m(t)?(this._zoomAnchor.main=t,this._zoomAnchor.xAxis=t):(m(t.main)&&(this._zoomAnchor.main=t.main),m(t.xAxis)&&(this._zoomAnchor.xAxis=t.xAxis))},t.prototype.getZoomAnchor=function(){return r({},this._zoomAnchor)},t.prototype.setScrollEnabled=function(t){this._scrollEnabled=t},t.prototype.isScrollEnabled=function(){return this._scrollEnabled},t.prototype.setCrosshair=function(t,e){var i,n=null!=e?e:{},o=n.notInvalidate,a=n.notExecuteAction,s=n.forceInvalidate,l=null!=t?t:{},u=0,c=0;c=v(l.x)?(u=this.coordinateToDataIndex(l.x))<0?0:u>this._dataList.length-1?this._dataList.length-1:u:u=this._dataList.length-1;var h=this._dataList[c],d=this.dataIndexToCoordinate(u),p=this._crosshair.x,g=this._crosshair.y,y=this._crosshair.paneId;this._crosshair=r(r({},l),{realX:d,kLineData:h,realDataIndex:u,dataIndex:c,timestamp:null!==(i=this.dataIndexToTimestamp(u))&&void 0!==i?i:void 0}),(p!==l.x||g!==l.y||y!==l.paneId||null!=s&&s)&&(f(h)&&(null==a||!a)&&this.hasAction("onCrosshairChange")&&m(this._crosshair.paneId)&&this.executeAction("onCrosshairChange",t),null!=o&&o||this._chart.updatePane(1))},t.prototype.getCrosshair=function(){return this._crosshair},t.prototype.executeAction=function(t,e){var i;null===(i=this._actions.get(t))||void 0===i||i.execute(e)},t.prototype.subscribeAction=function(t,e){var i;this._actions.has(t)||this._actions.set(t,new Ei),null===(i=this._actions.get(t))||void 0===i||i.subscribe(e)},t.prototype.unsubscribeAction=function(t,e){var i=this._actions.get(t);f(i)&&(i.unsubscribe(e),i.isEmpty()&&this._actions.delete(t))},t.prototype.hasAction=function(t){var e=this._actions.get(t);return f(e)&&!e.isEmpty()},t.prototype._sortIndicators=function(t){var e;m(t)?null===(e=this._indicators.get(t))||void 0===e||e.sort((function(t,e){return t.zLevel-e.zLevel})):this._indicators.forEach((function(t){t.sort((function(t,e){return t.zLevel-e.zLevel}))}))},t.prototype._calcIndicator=function(t){var e=this,i=[];if((i=i.concat(t)).length>0){var r={};i.forEach((function(t){r[t.id]=t.calcImp(e._dataList)})),this._taskScheduler.add(r)}},t.prototype.addIndicator=function(t,e){var i=t.name;if(this.getIndicatorsByFilter(t).length>0)return!1;var r=t.paneId,n=this.getIndicatorsByPaneId(r),o=new(Kt(i));return this._synchronizeIndicatorSeriesPrecision(o),o.override(t),e||(this.removeIndicator({paneId:r}),n=[]),n.push(o),this._indicators.set(r,n),this._sortIndicators(r),this._calcIndicator(o),!0},t.prototype.getIndicatorsByPaneId=function(t){var e;return null!==(e=this._indicators.get(t))&&void 0!==e?e:[]},t.prototype.getIndicatorsByFilter=function(t){var e=t.paneId,i=t.name,r=t.id,n=function(t){return f(r)?t.id===r:!f(i)||t.name===i},o=[];return f(e)?o=o.concat(this.getIndicatorsByPaneId(e).filter(n)):this._indicators.forEach((function(t){o=o.concat(t.filter(n))})),o},t.prototype.removeIndicator=function(t){var e=this,i=!1;return this.getIndicatorsByFilter(null!=t?t:{}).forEach((function(t){var r=e.getIndicatorsByPaneId(t.paneId),n=r.findIndex((function(e){return e.id===t.id}));n>-1&&(r.splice(n,1),i=!0),0===r.length&&e._indicators.delete(t.paneId)})),i},t.prototype.hasIndicators=function(t){return this._indicators.has(t)},t.prototype._synchronizeIndicatorSeriesPrecision=function(t){if(f(this._symbol)){var e=this._symbol,i=e.pricePrecision,r=void 0===i?O:i,n=e.volumePrecision,o=void 0===n?Y:n,a=function(t){switch(t.series){case"price":t.setSeriesPrecision(r);break;case"volume":t.setSeriesPrecision(o)}};f(t)?a(t):this._indicators.forEach((function(t){t.forEach((function(t){a(t)}))}))}},t.prototype.overrideIndicator=function(t){var e=this,i=!1,r=!1;return this.getIndicatorsByFilter(t).forEach((function(n){var o=n.paneId;n.override(t);var a=n.paneId;if(o!==a){var s=e.getIndicatorsByPaneId(o),l=s.findIndex((function(t){return t.id===n.id}));l>-1&&s.splice(l,1),0===s.length&&e._indicators.delete(o);var u=e.getIndicatorsByPaneId(a);u.some((function(t){return t.id===n.id}))||(u.push(n),e._indicators.set(a,u)),r=!0}var c=n.shouldUpdateImp(),h=c.calc,d=c.draw;c.sort&&(r=!0),h?e._calcIndicator(n):d&&(i=!0)})),r&&this._sortIndicators(),i||r},t.prototype.getOverlaysByFilter=function(t){var e,i=t.id,r=t.groupId,n=t.paneId,o=t.name,a=function(t){return f(i)?t.id===i:f(r)?t.groupId===r&&(!f(o)||t.name===o):!f(o)||t.name===o},s=[];f(n)?s=s.concat(this.getOverlaysByPaneId(n).filter(a)):this._overlays.forEach((function(t){s=s.concat(t.filter(a))}));var l=null===(e=this._progressOverlayInfo)||void 0===e?void 0:e.overlay;return f(l)&&a(l)&&s.push(l),s},t.prototype.getOverlaysByPaneId=function(t){var e;if(!m(t)){var i=[];return this._overlays.forEach((function(t){i=i.concat(t)})),i}return null!==(e=this._overlays.get(t))&&void 0!==e?e:[]},t.prototype._sortOverlays=function(t){var e;m(t)?null===(e=this._overlays.get(t))||void 0===e||e.sort((function(t,e){return t.zLevel-e.zLevel})):this._overlays.forEach((function(t){t.sort((function(t,e){return t.zLevel-e.zLevel}))}))},t.prototype.addOverlays=function(t,e){var i=this,r=[],n=t.map((function(t,n){var o,a,l,u,c,h,d,p;if(f(t.id)){var g=null;try{for(var v=s(i._overlays),y=v.next();!y.done;y=v.next()){if(f(x=y.value[1].find((function(e){return e.id===t.id})))){g=x;break}}}catch(t){o={error:t}}finally{try{y&&!y.done&&(a=v.return)&&a.call(v)}finally{if(o)throw o.error}}if(f(g))return t.id}var m=Vi(t.name);if(f(m)){var _=null!==(l=t.id)&&void 0!==l?l:D("overlay_"),x=new m,b=null!==(u=t.paneId)&&void 0!==u?u:j;t.id=_,null!==(c=t.groupId)&&void 0!==c||(t.groupId=_);var w=i.getOverlaysByPaneId(b).length;return null!==(h=t.zLevel)&&void 0!==h||(t.zLevel=w),x.override(t),r.includes(b)||r.push(b),x.isDrawing()?i._progressOverlayInfo={paneId:b,overlay:x,appointPaneFlag:e[n]}:(i._overlays.has(b)||i._overlays.set(b,[]),null===(d=i._overlays.get(b))||void 0===d||d.push(x)),x.isStart()&&(null===(p=x.onDrawStart)||void 0===p||p.call(x,{overlay:x,chart:i._chart})),_}return null}));return r.length>0&&(this._sortOverlays(),r.forEach((function(t){i._chart.updatePane(1,t)})),this._chart.updatePane(1,K)),n},t.prototype.getProgressOverlayInfo=function(){return this._progressOverlayInfo},t.prototype.progressOverlayComplete=function(){var t;if(null!==this._progressOverlayInfo){var e=this._progressOverlayInfo,i=e.overlay,r=e.paneId;i.isDrawing()||(this._overlays.has(r)||this._overlays.set(r,[]),null===(t=this._overlays.get(r))||void 0===t||t.push(i),this._sortOverlays(r),this._progressOverlayInfo=null)}},t.prototype.updateProgressOverlayInfo=function(t,e){null!==this._progressOverlayInfo&&(y(e)&&e&&(this._progressOverlayInfo.appointPaneFlag=e),this._progressOverlayInfo.paneId=t,this._progressOverlayInfo.overlay.override({paneId:t}))},t.prototype.overrideOverlay=function(t){var e=this,i=!1,r=[];return this.getOverlaysByFilter(t).forEach((function(e){e.override(t);var n=e.shouldUpdate(),o=n.sort,a=n.draw;o&&(i=!0),(o||a)&&(r.includes(e.paneId)||r.push(e.paneId))})),i&&this._sortOverlays(),r.length>0&&(r.forEach((function(t){e._chart.updatePane(1,t)})),this._chart.updatePane(1,K),!0)},t.prototype.removeOverlay=function(t){var e=this,i=[];return this.getOverlaysByFilter(null!=t?t:{}).forEach((function(t){var r,n=t.paneId,o=e.getOverlaysByPaneId(t.paneId);if(null===(r=t.onRemoved)||void 0===r||r.call(t,{overlay:t,chart:e._chart}),i.includes(n)||i.push(n),t.isDrawing())e._progressOverlayInfo=null;else{var a=o.findIndex((function(e){return e.id===t.id}));a>-1&&o.splice(a,1)}0===o.length&&e._overlays.delete(n)})),i.length>0&&(i.forEach((function(t){e._chart.updatePane(1,t)})),this._chart.updatePane(1,K),!0)},t.prototype.setPressedOverlayInfo=function(t){this._pressedOverlayInfo=t},t.prototype.getPressedOverlayInfo=function(){return this._pressedOverlayInfo},t.prototype.setHoverOverlayInfo=function(t,e,i){var r=this._hoverOverlayInfo,n=r.overlay,o=r.figureType,a=r.figureIndex,s=r.figure,l=t.overlay;if(((null==n?void 0:n.id)!==(null==l?void 0:l.id)||o!==t.figureType||a!==t.figureIndex)&&(this._hoverOverlayInfo=t,(null==n?void 0:n.id)!==(null==l?void 0:l.id))){var u=!1,c=!1;null!==n&&(n.fixedZLevel||(n.override({zLevel:n.getPrevZLevel()}),c=!0),i(n,s)&&(u=!0)),null!==l&&(l.fixedZLevel||(l.setPrevZLevel(l.zLevel),l.override({zLevel:Number.MAX_SAFE_INTEGER}),c=!0),e(l,t.figure)&&(u=!0)),c&&this._sortOverlays(),u||this._chart.updatePane(1)}},t.prototype.getHoverOverlayInfo=function(){return this._hoverOverlayInfo},t.prototype.setClickOverlayInfo=function(t,e,i){var r=this._clickOverlayInfo,n=r.paneId,o=r.overlay,a=r.figureType,s=r.figure,l=r.figureIndex,u=t.overlay;(null==o?void 0:o.id)===(null==u?void 0:u.id)&&a===t.figureType&&l===t.figureIndex||(this._clickOverlayInfo=t,(null==o?void 0:o.id)!==(null==u?void 0:u.id)&&(f(o)&&i(o,s),f(u)&&e(u,t.figure),this._chart.updatePane(1,t.paneId),n!==t.paneId&&this._chart.updatePane(1,n),this._chart.updatePane(1,K)))},t.prototype.getClickOverlayInfo=function(){return this._clickOverlayInfo},t.prototype.isOverlayEmpty=function(){return 0===this._overlays.size&&null===this._progressOverlayInfo},t.prototype.isOverlayDrawing=function(){var t,e;return null!==(e=null===(t=this._progressOverlayInfo)||void 0===t?void 0:t.overlay.isDrawing())&&void 0!==e&&e},t.prototype._clearLastPriceMarkExtendTextUpdateTimer=function(){this._lastPriceMarkExtendTextUpdateTimers.forEach((function(t){clearInterval(t)})),this._lastPriceMarkExtendTextUpdateTimers=[]},t.prototype._clearData=function(){this._dataLoadMore.backward=!1,this._dataLoadMore.forward=!1,this._loading=!1,this._dataList=[],this._visibleRangeDataList=[],this._visibleRangeHighLowPrice=[{x:0,price:Number.MIN_SAFE_INTEGER},{x:0,price:Number.MAX_SAFE_INTEGER}],this._visibleRange={from:0,to:0,realFrom:0,realTo:0},this._crosshair={}},t.prototype.getChart=function(){return this._chart},t.prototype.destroy=function(){this._clearData(),this._clearLastPriceMarkExtendTextUpdateTimer(),this._taskScheduler.clear(),this._overlays.clear(),this._indicators.clear(),this._actions.clear()},t}(),Ui=function(){function t(t,e){var i=this;this._chartBounding=C(),this._drawPanes=[],this._separatorPanes=new Map,this._layoutUpdateOptions={sort:!0,measureHeight:!0,measureWidth:!0,secondMeasureWidth:!1,update:!0,buildYAxisTick:!1,cacheYAxisWidth:!1,forceBuildYAxisTick:!1},this._layoutPending=!1,this._resizeObserver=null,this._resizeRequestAnimationId=_,this._scheduleResize=function(){i._resizeRequestAnimationId===_&&(i._resizeRequestAnimationId=x((function(){i._resizeRequestAnimationId=_,i._chartBounding.width===Math.floor(i._chartContainer.clientWidth)&&i._chartBounding.height===Math.floor(i._chartContainer.clientHeight)||i.resize()})))},this._cacheYAxisWidth={left:0,right:0},this._initContainer(t),this._chartEvent=new Pt(this._chartContainer,this),this._chartStore=new Xi(this,e);var n=this._chartStore.getLayoutOptions(),o=n.pane;this._candlePane=this._createPane(gi,r(r({},o),{id:j})),this._candlePane.createOrOverrideYAxis(r(r({},n.yAxis),{id:D($)})),this._xAxisPane=this._createPane(Ci,r(r({},o),{id:K,order:Number.MAX_SAFE_INTEGER})),this._layout(),this._initResizeListener()}return t.prototype._initContainer=function(t){this._container=t,this._chartContainer=A("div",{position:"relative",width:"100%",height:"100%",outline:"none",borderStyle:"none",cursor:"crosshair",boxSizing:"border-box",userSelect:"none",webkitUserSelect:"none",overflow:"hidden",touchAction:"none",overscrollBehavior:"none",msUserSelect:"none",MozUserSelect:"none",webkitTapHighlightColor:"transparent"}),this._chartContainer.tabIndex=1,t.appendChild(this._chartContainer),this._cacheChartBounding()},t.prototype._cacheChartBounding=function(){this._chartBounding.width=Math.floor(this._chartContainer.clientWidth),this._chartBounding.height=Math.floor(this._chartContainer.clientHeight)},t.prototype._initResizeListener=function(){var t=this;f(ResizeObserver)?(this._resizeObserver=new ResizeObserver((function(){t._scheduleResize()})),this._resizeObserver.observe(this._chartContainer)):window.addEventListener("resize",this._scheduleResize)},t.prototype._createPane=function(t,e){var i=new t(this,e);return this._drawPanes.push(i),i},t.prototype.getDrawPaneById=function(t){if(t===j)return this._candlePane;if(t===K)return this._xAxisPane;var e=this._drawPanes.find((function(e){return e.getId()===t}));return null!=e?e:null},t.prototype.getContainer=function(){return this._container},t.prototype.getChartStore=function(){return this._chartStore},t.prototype.getXAxisPane=function(){return this._xAxisPane},t.prototype.getDrawPanes=function(){return this._drawPanes},t.prototype.getSeparatorPanes=function(){return this._separatorPanes},t.prototype.layout=function(t){var e,i,r,n,o,a,s,l,u=this;null!==(e=t.sort)&&void 0!==e&&e&&(this._layoutUpdateOptions.sort=t.sort),null!==(i=t.measureHeight)&&void 0!==i&&i&&(this._layoutUpdateOptions.measureHeight=t.measureHeight),null!==(r=t.measureWidth)&&void 0!==r&&r&&(this._layoutUpdateOptions.measureWidth=t.measureWidth),null!==(n=t.secondMeasureWidth)&&void 0!==n&&n&&(this._layoutUpdateOptions.secondMeasureWidth=t.secondMeasureWidth),null!==(o=t.update)&&void 0!==o&&o&&(this._layoutUpdateOptions.update=t.update),null!==(a=t.buildYAxisTick)&&void 0!==a&&a&&(this._layoutUpdateOptions.buildYAxisTick=t.buildYAxisTick),null!==(s=t.cacheYAxisWidth)&&void 0!==s&&s&&(this._layoutUpdateOptions.cacheYAxisWidth=t.cacheYAxisWidth),null!==(l=t.forceBuildYAxisTick)&&void 0!==l&&l&&(this._layoutUpdateOptions.forceBuildYAxisTick=t.forceBuildYAxisTick),this._layoutPending||(this._layoutPending=!0,Promise.resolve().then((function(t){u._layout(),u._layoutPending=!1})).catch((function(t){})))},t.prototype._layout=function(){var t,e=this,i=this._layoutUpdateOptions,r=i.sort,n=i.measureHeight,o=i.measureWidth,a=i.secondMeasureWidth,s=i.update,l=i.buildYAxisTick,u=i.cacheYAxisWidth,c=i.forceBuildYAxisTick;if(r){for(;f(this._chartContainer.firstChild);)this._chartContainer.removeChild(this._chartContainer.firstChild);this._separatorPanes.clear(),this._drawPanes.sort((function(t,e){return t.getOptions().order-e.getOptions().order}));var h=null;this._drawPanes.forEach((function(t){if(t.getId()!==K){if(f(h)){var i=new fi(e,"",h,t);e._chartContainer.appendChild(i.getContainer()),e._separatorPanes.set(t,i)}h=t}e._chartContainer.appendChild(t.getContainer())}))}if(n){var d=this._chartBounding.height,p=this.getStyles().separator.size,g=this._xAxisPane.getXAxisComponent().getAutoSize(),v=this._drawPanes.filter((function(t){return t.getId()!==K})),y=v.find((function(t){return"maximize"===t.getOptions().state})),m=Math.max(d-g,0),_=new Map,x=p;if(f(y))x=0,v.forEach((function(t){_.set(t,t===y?m:0)}));else{m=Math.max(m-this._separatorPanes.size*p,0);var b=null!==(t=v.find((function(t){return t.getId()===j&&"normal"===t.getOptions().state})))&&void 0!==t?t:v.find((function(t){return"normal"===t.getOptions().state}));v.forEach((function(t){if(t!==b){var e=t.getOptions(),i=e.minHeight;if("normal"===e.state){i=Math.max(e.minHeight,e.height);var r=Math.max(m,0);i>r&&(i=r)}m-=i,_.set(t,i)}})),f(b)&&_.set(b,Math.max(m,0))}this._drawPanes.forEach((function(t){var e;t.getId()!==K&&t.setBounding({height:null!==(e=_.get(t))&&void 0!==e?e:0})})),this._xAxisPane.setBounding({height:g});var w=0;this._drawPanes.forEach((function(t){var i=e._separatorPanes.get(t);f(i)&&(i.setBounding({height:x,top:w}),w+=x),t.setBounding({top:w}),w+=t.getBounding().height}))}var C=function(){var t=o;if((l||c)&&e._drawPanes.forEach((function(e){e.getYAxisComponents().forEach((function(e){var i=e.buildTicks(c);t||(t=i)}))})),t){var i=e._chartBounding.width,r=e.getStyles(),n=[],a=[],s=[],h=[],d=function(t,e,i){var r;t[e]=Math.max(null!==(r=t[e])&&void 0!==r?r:0,i)};e._drawPanes.forEach((function(t){var e=[],i=[],r=[],o=[];t.getId()!==K&&t.getWidgetYAxisComponents().forEach((function(t){var n=t;"left"===n.position?n.inside?i.push(n):e.push(n):n.inside?r.push(n):o.push(n)})),e.forEach((function(t,e){d(n,e,t.getAutoSize())})),i.forEach((function(t,e){d(a,e,t.getAutoSize())})),r.forEach((function(t,e){d(s,e,t.getAutoSize())})),o.forEach((function(t,e){d(h,e,t.getAutoSize())}))}));var p=n.reduce((function(t,e){return t+e}),0),g=h.reduce((function(t,e){return t+e}),0);u&&(p=Math.max(e._cacheYAxisWidth.left,p),g=Math.max(e._cacheYAxisWidth.right,g)),e._cacheYAxisWidth.left=p,e._cacheYAxisWidth.right=g;var v,f,y=i;y-=p,v=p,y-=g,f=g,e._chartStore.setTotalBarSpace(y);var m={width:i},_={width:y,left:v,right:f},x={width:p},b={width:g},w=r.separator.fill,C={};C=w?m:_,e._drawPanes.forEach((function(t){var i,r;null===(i=e._separatorPanes.get(t))||void 0===i||i.setBounding(C);var o={},l=0,u=0,c=0,d=0,g=[],f=[],w=[],E=[];t.getId()!==K&&t.getWidgetYAxisComponents().forEach((function(t){var e=t;"left"===e.position?e.inside?f.push(e):g.push(e):e.inside?w.push(e):E.push(e)}));var I=g.reduce((function(t,e,i){var r;return t+(null!==(r=n[i])&&void 0!==r?r:0)}),0);l=p-I;for(var T=g.length-1;T>=0;T--){var S=g[T],A=null!==(r=n[T])&&void 0!==r?r:0;o[S.id]={width:A,left:l},l+=A}f.forEach((function(t,e){var i,r=null!==(i=a[e])&&void 0!==i?i:0;o[t.id]={width:r,left:v+u},u+=r})),w.forEach((function(t,e){var i,r=null!==(i=s[e])&&void 0!==i?i:0;c+=r,o[t.id]={width:r,left:v+y-c}})),E.forEach((function(t,e){var i,r=null!==(i=h[e])&&void 0!==i?i:0;o[t.id]={width:r,left:v+y+d},d+=r})),t.setYAxesBounding(o),t.setBounding(m,_,x,b)}))}};C(),a&&C(),s&&(this._xAxisPane.getXAxisComponent().buildTicks(!0),this.updatePane(4)),this._layoutUpdateOptions={sort:!1,measureHeight:!1,measureWidth:!1,secondMeasureWidth:!1,update:!1,buildYAxisTick:!1,cacheYAxisWidth:!1,forceBuildYAxisTick:!1}},t.prototype.updatePane=function(t,e){var i=this;if(f(e)){var r=this.getDrawPaneById(e);null==r||r.update(t)}else this._drawPanes.forEach((function(e){var r;e.update(t),null===(r=i._separatorPanes.get(e))||void 0===r||r.update(t)}))},t.prototype.getDom=function(t,e){var i,r;if(!f(t))return this._chartContainer;var n=this.getDrawPaneById(t);if(f(n))switch(null!=e?e:"root"){case"root":return n.getContainer();case"main":return n.getMainWidget().getContainer();case"yAxis":return null!==(r=null===(i=n.getYAxisWidget())||void 0===i?void 0:i.getContainer())&&void 0!==r?r:null}return null},t.prototype.getSize=function(t,e){var i,r;if(!f(t))return this._chartBounding;var n=this.getDrawPaneById(t);if(f(n))switch(null!=e?e:"root"){case"root":return n.getBounding();case"main":return n.getMainWidget().getBounding();case"yAxis":return null!==(r=null===(i=n.getYAxisWidget())||void 0===i?void 0:i.getBounding())&&void 0!==r?r:null}return null},t.prototype._resetYAxisAutoCalcTickFlag=function(){this._drawPanes.forEach((function(t){t.getYAxisComponents().forEach((function(t){t.setAutoCalcTickFlag(!0)}))}))},t.prototype.setSymbol=function(t){t!==this.getSymbol()&&(this._resetYAxisAutoCalcTickFlag(),this._chartStore.setSymbol(t))},t.prototype.getSymbol=function(){return this._chartStore.getSymbol()},t.prototype.setPeriod=function(t){t!==this.getPeriod()&&(this._resetYAxisAutoCalcTickFlag(),this._chartStore.setPeriod(t))},t.prototype.getPeriod=function(){return this._chartStore.getPeriod()},t.prototype.setStyles=function(t){var e=this;this._setOptions((function(){e._chartStore.setStyles(t)}))},t.prototype.getStyles=function(){return this._chartStore.getStyles()},t.prototype.setFormatter=function(t){var e=this;this._setOptions((function(){e._chartStore.setFormatter(t)}))},t.prototype.getFormatter=function(){return this._chartStore.getFormatter()},t.prototype.setLocale=function(t){var e=this;this._setOptions((function(){e._chartStore.setLocale(t)}))},t.prototype.getLocale=function(){return this._chartStore.getLocale()},t.prototype.setTimezone=function(t){var e=this;this._setOptions((function(){e._chartStore.setTimezone(t)}))},t.prototype.getTimezone=function(){return this._chartStore.getTimezone()},t.prototype.setThousandsSeparator=function(t){var e=this;this._setOptions((function(){e._chartStore.setThousandsSeparator(t)}))},t.prototype.getThousandsSeparator=function(){return this._chartStore.getThousandsSeparator()},t.prototype.setDecimalFold=function(t){var e=this;this._setOptions((function(){e._chartStore.setDecimalFold(t)}))},t.prototype.getDecimalFold=function(){return this._chartStore.getDecimalFold()},t.prototype.setHotkey=function(t){this._chartStore.setHotkey(t)},t.prototype.getHotkey=function(){return this._chartStore.getHotkey()},t.prototype.getHotKey=function(){return this._chartStore.getHotKey()},t.prototype._setOptions=function(t){t(),this.layout({measureHeight:!0,measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})},t.prototype.setOffsetRightDistance=function(t){this._chartStore.setOffsetRightDistance(t,!0)},t.prototype.getOffsetRightDistance=function(){return this._chartStore.getOffsetRightDistance()},t.prototype.setMaxOffsetLeftDistance=function(t){t<0||this._chartStore.setMaxOffsetLeftDistance(t)},t.prototype.setMaxOffsetRightDistance=function(t){t<0||this._chartStore.setMaxOffsetRightDistance(t)},t.prototype.setLeftMinVisibleBarCount=function(t){t<0||this._chartStore.setLeftMinVisibleBarCount(Math.ceil(t))},t.prototype.setRightMinVisibleBarCount=function(t){t<0||this._chartStore.setRightMinVisibleBarCount(Math.ceil(t))},t.prototype.setBarSpace=function(t){this._chartStore.setBarSpace(t)},t.prototype.getBarSpace=function(){return this._chartStore.getBarSpace()},t.prototype.getVisibleRange=function(){return this._chartStore.getVisibleRange()},t.prototype._removeOrphanYAxes=function(){var t=this,e=!1;return this._drawPanes.forEach((function(i){var r=i.getId();if(r!==K){var n=new Set,o=i.getDefaultYAxisId();f(o)&&n.add(o),t._chartStore.getIndicatorsByPaneId(r).forEach((function(t){n.add(t.yAxisId)})),i.getYAxisComponents().forEach((function(t){n.has(t.id)||i.isManualYAxis(t.id)||(e=i.removeYAxis(t.id)||e)}))}})),e},t.prototype._createOrUseIndicatorYAxis=function(t,e){var i=!1;return t.hasYAxisComponent(e)||(t.createOrOverrideYAxis(r(r({},this._chartStore.getLayoutOptions().yAxis),{id:e})),i=!0),t.isManualYAxis(e)&&(t.setManualYAxis(e,!1),i=!0),i},t.prototype.resetData=function(){this._chartStore.resetData()},t.prototype.getDataList=function(){return this._chartStore.getDataList()},t.prototype.setDataLoader=function(t){this._resetYAxisAutoCalcTickFlag(),this._chartStore.setDataLoader(t)},t.prototype.createIndicator=function(t,e){var i,n,o,a,s=m(t)?{name:t}:t;if(null===Kt(s.name))return null;null!==(i=s.id)&&void 0!==i||(s.id=D("".concat(s.name,"_"))),null!==(n=s.paneId)&&void 0!==n||(s.paneId=D(q));var l=this.getDrawPaneById(s.paneId);if(null!==(o=s.yAxisId)&&void 0!==o||(s.yAxisId=null!==(a=null==l?void 0:l.getDefaultYAxisId())&&void 0!==a?a:D($)),this._chartStore.addIndicator(s,null!=e&&e)){var u=!1,c=this.getDrawPaneById(s.paneId);return f(c)||(c=this._createPane(pi,r(r({},this._chartStore.getLayoutOptions().pane),{id:s.paneId})),u=!0),this._createOrUseIndicatorYAxis(c,s.yAxisId),this._removeOrphanYAxes(),this.layout({sort:u,measureHeight:!0,measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0}),s.id}return null},t.prototype.overrideIndicator=function(t){var e=this,i=this._chartStore.getIndicatorsByFilter(t);if(0===i.length)return!1;var r=this._chartStore.overrideIndicator(t);return i.forEach((function(t){var i=e.getDrawPaneById(t.paneId);f(i)&&(r=e._createOrUseIndicatorYAxis(i,t.yAxisId)||r)})),r&&(this._removeOrphanYAxes(),this.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})),r},t.prototype.getIndicators=function(t){return this._chartStore.getIndicatorsByFilter(null!=t?t:{})},t.prototype.removeIndicator=function(t){var e=this,i=this._chartStore.removeIndicator(null!=t?t:{});if(i){this._removeOrphanYAxes();var r=!1,n=[];this._drawPanes.forEach((function(t){var i=t.getId();i!==K&&i!==j&&(0===e._chartStore.getIndicatorsByPaneId(i).length&&n.push(i))})),n.forEach((function(t){var i=e._drawPanes.findIndex((function(e){return e.getId()===t})),n=e._drawPanes[i];f(n)&&(e._drawPanes.splice(i,1),n.destroy(),r=!0)})),this.layout({sort:r,measureHeight:r,measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})}return i},t.prototype.createOverlay=function(t){var e=this,i=[],r=[],n=function(t){f(t.paneId)&&null!==e.getDrawPaneById(t.paneId)?r.push(!0):(t.paneId=j,r.push(!1)),i.push(t)};m(t)?n({name:t}):d(t)?t.forEach((function(t){var e=null;e=m(t)?{name:t}:t,n(e)})):n(t);var o=this._chartStore.addOverlays(i,r);return d(t)?o:o[0]},t.prototype.getOverlays=function(t){return this._chartStore.getOverlaysByFilter(null!=t?t:{})},t.prototype.overrideOverlay=function(t){return this._chartStore.overrideOverlay(t)},t.prototype.removeOverlay=function(t){return this._chartStore.removeOverlay(null!=t?t:{})},t.prototype.setPaneOptions=function(t){var e,i,r,n=!1,o=!1,a=!1,l=f(t.id);try{for(var u=s(this._drawPanes),c=u.next();!c.done;c=u.next()){var h=c.value,d=h.getId();if(l&&t.id===d||!l){if(d!==K){var p=h.getOptions(),g=p.state;if(v(t.height)&&t.height>0){var y=Math.max(null!==(r=t.minHeight)&&void 0!==r?r:p.minHeight,0),m=Math.max(y,t.height);o=!0,n=!0,h.setBounding({height:m})}f(t.state)&&(o=!0,n=!0,"normal"===g&&"normal"!==t.state?h.setOptions({height:h.getBounding().height}):"normal"===g||"normal"!==t.state||v(t.height)||h.setBounding({height:Math.max(p.minHeight,p.height)}))}if(v(t.order)&&(o=!0,a=!0),h.setOptions(t),d===t.id)break}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(e)throw e.error}}o&&this.layout({sort:a,measureHeight:n,measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})},t.prototype.createYAxis=function(t){var e,i,n=null!==(e=t.paneId)&&void 0!==e?e:j,o=this.getDrawPaneById(n);if(!f(o)||n===K)return null;var a=null!==(i=t.id)&&void 0!==i?i:D($);return o.hasYAxisComponent(a)||(o.createOrOverrideYAxis(r(r(r({},this._chartStore.getLayoutOptions().yAxis),t),{id:a,paneId:n})),o.setManualYAxis(a,!0),this.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})),a},t.prototype.removeYAxis=function(t){var e,i,r=t.id,n=t.name;if(!f(r)&&!f(n))return!1;var o=!1,a=function(t){var e=l.getDrawPaneById(t.paneId);return f(e)?e.isDefaultYAxis(t.id)&&t.paneId===j||l._chartStore.getIndicatorsByPaneId(t.paneId).some((function(e){return e.yAxisId===t.id}))?"continue":void(o=e.removeYAxis(t.id)||o):"continue"},l=this;try{for(var u=s(this.getYAxes(t)),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(e)throw e.error}}return o&&this.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0}),o},t.prototype.getYAxes=function(t){var e,i,r=t.paneId,n=t.id,o=t.name,a=function(t){return f(n)?t.id===n:!f(o)||t.name===o},s=[];return f(r)?s=s.concat(null!==(i=null===(e=this.getDrawPaneById(r))||void 0===e?void 0:e.getYAxisComponents().filter(a))&&void 0!==i?i:[]):this._drawPanes.forEach((function(t){t.getId()!==K&&(s=s.concat(t.getYAxisComponents().filter(a)))})),s},t.prototype.overrideYAxis=function(t){var e=this,i=this.getYAxes({paneId:t.paneId,id:t.id});0!==i.length&&(i.forEach((function(i){var n;null===(n=e.getDrawPaneById(i.paneId))||void 0===n||n.createOrOverrideYAxis(r(r({},t),{id:i.id}))})),this.layout({measureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0}))},t.prototype.overrideXAxis=function(t){this._xAxisPane.overrideXAxis(t),this.layout({measureHeight:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})},t.prototype.getPaneOptions=function(t){var e;if(f(t)){var i=this.getDrawPaneById(t);return null!==(e=null==i?void 0:i.getOptions())&&void 0!==e?e:null}return this._drawPanes.map((function(t){return t.getOptions()}))},t.prototype.setZoomEnabled=function(t){this._chartStore.setZoomEnabled(t)},t.prototype.isZoomEnabled=function(){return this._chartStore.isZoomEnabled()},t.prototype.setZoomAnchor=function(t){this._chartStore.setZoomAnchor(t)},t.prototype.getZoomAnchor=function(){return this._chartStore.getZoomAnchor()},t.prototype.setScrollEnabled=function(t){this._chartStore.setScrollEnabled(t)},t.prototype.isScrollEnabled=function(){return this._chartStore.isScrollEnabled()},t.prototype.scrollByDistance=function(t,e){var i=this,r=v(e)&&e>0?e:0;if(this._chartStore.startScroll(),r>0){var n=new w({duration:r});n.doFrame((function(e){var n=t*(e/r);i._chartStore.scroll(n)})),n.start()}else this._chartStore.scroll(t)},t.prototype.scrollToRealTime=function(t){var e=this._chartStore.getBarSpace().bar,i=(this._chartStore.getLastBarRightSideDiffBarCount()-this._chartStore.getInitialOffsetRightDistance()/e)*e;this.scrollByDistance(i,t)},t.prototype.scrollToDataIndex=function(t,e){var i=(this._chartStore.getLastBarRightSideDiffBarCount()+(this.getDataList().length-1-t))*this._chartStore.getBarSpace().bar;this.scrollByDistance(i,e)},t.prototype.scrollToTimestamp=function(t,e){var i=k(this.getDataList(),"timestamp",t);this.scrollToDataIndex(i,e)},t.prototype.zoomAtCoordinate=function(t,e,i){var r=this,n=v(i)&&i>0?i:0,o=this._chartStore.getBarSpace().bar,a=o*t-o;if(n>0){var s=0,l=new w({duration:n});l.doFrame((function(t){var i=a*(t/n),o=(i-s)/r._chartStore.getBarSpace().bar*10;r._chartStore.zoom(o,null!=e?e:null,"main"),s=i})),l.start()}else this._chartStore.zoom(a/o*10,null!=e?e:null,"main")},t.prototype.zoomAtDataIndex=function(t,e,i){var r=this._chartStore.dataIndexToCoordinate(e);this.zoomAtCoordinate(t,{x:r,y:0},i)},t.prototype.zoomAtTimestamp=function(t,e,i){var r=k(this.getDataList(),"timestamp",e);this.zoomAtDataIndex(t,r,i)},t.prototype.convertToPixel=function(t,e){var i,r=this,n=null!=e?e:{},o=n.paneId,a=void 0===o?j:o,s=n.yAxisId,l=n.absolute,u=void 0!==l&&l,c=[];if(a!==K){var h=this.getDrawPaneById(a);if(null!==h){var p=h.getBounding(),g=[];g=g.concat(t);var f=this._xAxisPane.getXAxisComponent(),y=h.getYAxisComponentById(s);c=g.map((function(t){var e={},i=t.dataIndex;if(v(t.timestamp)&&(i=r._chartStore.timestampToDataIndex(t.timestamp)),v(i)&&(e.x=f.convertToPixel(i)),v(t.value)){var n=y.convertToPixel(t.value);e.y=u?p.top+n:n}return e}))}}return d(t)?c:null!==(i=c[0])&&void 0!==i?i:{}},t.prototype.convertFromPixel=function(t,e){var i,r=this,n=null!=e?e:{},o=n.paneId,a=void 0===o?j:o,s=n.yAxisId,l=n.absolute,u=void 0!==l&&l,c=[];if(a!==K){var h=this.getDrawPaneById(a);if(null!==h){var p=h.getBounding(),g=[];g=g.concat(t);var f=this._xAxisPane.getXAxisComponent(),y=h.getYAxisComponentById(s);c=g.map((function(t){var e,i={};if(v(t.x)){var n=f.convertFromPixel(t.x);i.dataIndex=n,i.timestamp=null!==(e=r._chartStore.dataIndexToTimestamp(n))&&void 0!==e?e:void 0}if(v(t.y)){var o=u?t.y-p.top:t.y;i.value=y.convertFromPixel(o)}return i}))}}return d(t)?c:null!==(i=c[0])&&void 0!==i?i:{}},t.prototype.executeAction=function(t,e){var i;if("onCrosshairChange"===t){var n=null;f(e)&&(null!==(i=(n=r({},e)).paneId)&&void 0!==i||(n.paneId=j)),this._chartStore.setCrosshair(n,{notExecuteAction:!0})}},t.prototype.subscribeAction=function(t,e){this._chartStore.subscribeAction(t,e)},t.prototype.unsubscribeAction=function(t,e){this._chartStore.unsubscribeAction(t,e)},t.prototype.getConvertPictureUrl=function(t,e,i){var r=this,n=this._chartBounding,o=n.width,a=n.height,s=A("canvas",{width:"".concat(o,"px"),height:"".concat(a,"px"),boxSizing:"border-box"}),l=s.getContext("2d"),u=I(s);s.width=o*u,s.height=a*u,l.scale(u,u),l.fillStyle=null!=i?i:"#FFFFFF",l.fillRect(0,0,o,a);var c=null!=t&&t;return this._drawPanes.forEach((function(t){var e=r._separatorPanes.get(t);if(f(e)){var i=e.getBounding();l.drawImage(e.getImage(c),i.left,i.top,i.width,i.height)}var n=t.getBounding();l.drawImage(t.getImage(c),0,n.top,o,n.height)})),s.toDataURL("image/".concat(null!=e?e:"jpeg"))},t.prototype.resize=function(){this._cacheChartBounding(),this.layout({measureHeight:!0,measureWidth:!0,secondMeasureWidth:!0,update:!0,buildYAxisTick:!0,forceBuildYAxisTick:!0})},t.prototype.destroy=function(){this._resizeRequestAnimationId!==_&&(b(this._resizeRequestAnimationId),this._resizeRequestAnimationId=_),f(this._resizeObserver)?(this._resizeObserver.disconnect(),this._resizeObserver=null):window.removeEventListener("resize",this._scheduleResize),this._chartEvent.destroy(),this._drawPanes.forEach((function(t){t.destroy()})),this._drawPanes=[],this._separatorPanes.clear(),this._chartStore.destroy(),this._container.removeChild(this._chartContainer)},t}(),Gi=new Map,Zi=1;var ji={clone:h,merge:c,isString:m,isNumber:v,isValid:f,isObject:g,isArray:d,isFunction:p,isBoolean:y,formatValue:V,formatPrecision:H,formatBigNumber:X,formatDate:N,formatThousands:U,formatFoldDecimal:G,calcTextWidth:S,getLinearSlopeIntercept:ie,getLinearYFromSlopeIntercept:te,getLinearYFromCoordinates:ee,checkCoordinateOnArc:oe,checkCoordinateOnCircle:ue,checkCoordinateOnLine:Jt,checkCoordinateOnPolygon:Ce,checkCoordinateOnRect:he,checkCoordinateOnText:Te};t.dispose=function(t){var e,i,r=null;if(t instanceof Ui)r=t.id;else{var n=null;r=null!==(e=null==(n=m(t)?document.getElementById(t):t)?void 0:n.getAttribute("k-line-chart-id"))&&void 0!==e?e:null}null!==r&&(null===(i=Gi.get(r))||void 0===i||i.destroy(),Gi.delete(r))},t.getFigureClass=function(t){var e;return null!==(e=Ae[t])&&void 0!==e?e:null},t.getHotkey=_t,t.getOverlayClass=function(t){var e;return null!==(e=Wi[t])&&void 0!==e?e:null},t.getSupportedFigures=function(){return Object.keys(Ae)},t.getSupportedHotkeys=xt,t.getSupportedIndicators=function(){return Object.keys(jt)},t.getSupportedLocales=function(){return Object.keys(Oe)},t.getSupportedOverlays=function(){return Object.keys(Wi)},t.init=function(t,e){var i,r=null;if(null===(r=m(t)?document.getElementById(t):t))return null;var n=Gi.get(null!==(i=r.getAttribute("k-line-chart-id"))&&void 0!==i?i:"");if(f(n))return n;var o="k_line_chart_".concat(Zi++);return(n=new Ui(r,e)).id=o,r.setAttribute("k-line-chart-id",o),Gi.set(o,n),n},t.registerFigure=function(t){Ae[t.name]=$t.extend(t)},t.registerHotkey=function(t){mt[t.name]=t},t.registerIndicator=function(t){jt[t.name]=Bt.extend(t)},t.registerLocale=function(t,e){Oe[t]=r(r({},Oe[t]),e)},t.registerOverlay=function(t){Wi[t.name]=Ze.extend(t)},t.registerStyles=function(t,e){Ni[t]=e},t.registerXAxis=function(t){mi[t.name]=yi.extend(t)},t.registerYAxis=function(t){ri[t.name]=J.extend(t)},t.utils=ji,t.version=function(){return"10.0.3"}}));