UNPKG

@chartspire/chartspire-chart

Version:

Lightweight k-line chart built with html5 canvas

7 lines 210 kB
/** * @license * KLineChart v10.0.0-alpha4 * 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 n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n,o,r,a,s,l,u,c=function(){return c=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},c.apply(this,arguments)};function h(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(i[n[o]]=t[n[o]])}return i}function d(t,e,i,n){return new(i||(i=Promise))((function(o,r){function a(t){try{l(n.next(t))}catch(t){r(t)}}function s(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}l((n=n.apply(t,e||[])).next())}))}function p(t,e){var i,n,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[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]&&(r=0)),r;)try{if(i=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,n=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){r.label=s[1];break}if(6===s[0]&&r.label<o[1]){r.label=o[1],o=s;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(s);break}o[2]&&r.ops.pop(),r.trys.pop();continue}s=e.call(t,r)}catch(t){s=[6,t],n=0}finally{i=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function g(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],n=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return a}function f(t,e,i){if(i||2===arguments.length)for(var n,o=0,r=e.length;o<r;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError,t.LineType=void 0,(n=t.LineType||(t.LineType={})).Dashed="dashed",n.Solid="solid",t.PolygonType=void 0,(o=t.PolygonType||(t.PolygonType={})).Stroke="stroke",o.Fill="fill",o.StrokeFill="stroke_fill",t.TooltipShowRule=void 0,(r=t.TooltipShowRule||(t.TooltipShowRule={})).Always="always",r.FollowCross="follow_cross",r.None="none",t.TooltipShowType=void 0,(a=t.TooltipShowType||(t.TooltipShowType={})).Standard="standard",a.Rect="rect",t.TooltipIconPosition=void 0,(s=t.TooltipIconPosition||(t.TooltipIconPosition={})).Left="left",s.Middle="middle",s.Right="right",t.CandleTooltipRectPosition=void 0,(l=t.CandleTooltipRectPosition||(t.CandleTooltipRectPosition={})).Fixed="fixed",l.Pointer="pointer",t.CandleType=void 0,(u=t.CandleType||(t.CandleType={})).HeikinAshi="heikin_ashi",u.CandleSolid="candle_solid",u.CandleStroke="candle_stroke",u.CandleUpStroke="candle_up_stroke",u.CandleDownStroke="candle_down_stroke",u.Ohlc="ohlc",u.Area="area";var y="#F92855",m="rgba(249, 40, 85, .7)",_="#2DC08E",x="rgba(45, 192, 142, .7)",C="#888888",b="#FFFFFF",T="#1677FF",w="#76808F",S="#DDDDDD";function P(t){return"rgba(22, 119, 255, ".concat(t,")")}function E(){function e(){return{show:!0,size:1,color:"#EDEDED",style:t.LineType.Dashed,dashedValue:[2,2]}}return{show:!0,horizontal:e(),vertical:e()}}function I(){return{show:!0,size:"auto",axisLine:{show:!0,color:S,size:1},tickText:{show:!0,color:w,size:12,family:"Helvetica Neue",weight:"normal",marginStart:4,marginEnd:6},tickLine:{show:!0,size:1,length:3,color:S}}}function k(){function e(){return{show:!0,line:{show:!0,style:t.LineType.Dashed,dashedValue:[4,2],size:1,color:w},text:{show:!0,style:t.PolygonType.Fill,color:b,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:t.LineType.Solid,borderDashedValue:[2,2],borderSize:1,borderColor:w,borderRadius:2,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:w}}}return{show:!0,horizontal:e(),vertical:e()}}function M(){return{grid:E(),candle:(o={show:!0,color:w,textOffset:5,textSize:10,textFamily:"Helvetica Neue",textWeight:"normal"},{type:t.CandleType.CandleSolid,bar:{upColor:_,downColor:y,noChangeColor:C,upBorderColor:_,downBorderColor:y,noChangeBorderColor:C,upWickColor:_,downWickColor:y,noChangeWickColor:C},area:{lineSize:2,lineColor:T,smooth:!1,value:"close",backgroundColor:[{offset:0,color:P(.01)},{offset:1,color:P(.2)}],point:{show:!0,color:T,radius:4,rippleColor:P(.3),rippleRadius:8,animation:!0,animationDuration:1e3}},priceMark:{show:!0,high:c({},o),low:c({},o),last:{show:!0,upColor:_,downColor:y,noChangeColor:C,line:{show:!0,style:t.LineType.Dashed,dashedValue:[4,4],size:1},text:{show:!0,style:t.PolygonType.Fill,size:12,paddingLeft:4,paddingTop:4,paddingRight:4,paddingBottom:4,borderColor:"transparent",borderStyle:t.LineType.Solid,borderSize:0,borderDashedValue:[2,2],color:b,family:"Helvetica Neue",weight:"normal",borderRadius:2}}},tooltip:{offsetLeft:4,offsetTop:6,offsetRight:4,offsetBottom:6,showRule:t.TooltipShowRule.Always,showType:t.TooltipShowType.Standard,custom:[{title:"time",value:"{time}"},{title:"open",value:"{open}"},{title:"high",value:"{high}"},{title:"low",value:"{low}"},{title:"close",value:"{close}"},{title:"volume",value:"{volume}"}],defaultValue:"n/a",rect:{position:t.CandleTooltipRectPosition.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"},text:{size:12,family:"Helvetica Neue",weight:"normal",color:w,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4},icons:[]},renko:{brick:{size:10}}}),indicator:(n=["#FF9600","#935EBD",T,"#E11D74","#01C5C4"].map((function(e){return{style:t.LineType.Solid,smooth:!1,size:1,dashedValue:[2,2],color:e}})),{ohlc:{upColor:x,downColor:m,noChangeColor:C},bars:[{style:t.PolygonType.Fill,borderStyle:t.LineType.Solid,borderSize:1,borderDashedValue:[2,2],upColor:x,downColor:m,noChangeColor:C}],lines:n,circles:[{style:t.PolygonType.Fill,borderStyle:t.LineType.Solid,borderSize:1,borderDashedValue:[2,2],upColor:x,downColor:m,noChangeColor:C}],lastValueMark:{show:!1,text:{show:!1,style:t.PolygonType.Fill,color:b,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:t.LineType.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:t.TooltipShowRule.Always,showType:t.TooltipShowType.Standard,showName:!0,showParams:!0,defaultValue:"n/a",text:{size:12,family:"Helvetica Neue",weight:"normal",color:w,marginLeft:8,marginTop:4,marginRight:8,marginBottom:4},icons:[]}}),xAxis:I(),yAxis:I(),separator:{size:1,color:S,fill:!0,activeBackgroundColor:P(.08)},crosshair:k(),overlay:(e=P(.35),i=P(.25),{point:{color:T,borderColor:e,borderSize:1,radius:5,activeColor:T,activeBorderColor:e,activeBorderSize:3,activeRadius:5},line:{style:t.LineType.Solid,smooth:!1,color:T,size:1,dashedValue:[2,2]},rect:{style:t.PolygonType.Fill,color:i,borderColor:T,borderSize:1,borderRadius:0,borderStyle:t.LineType.Solid,borderDashedValue:[2,2]},polygon:{style:t.PolygonType.Fill,color:T,borderColor:T,borderSize:1,borderStyle:t.LineType.Solid,borderDashedValue:[2,2]},circle:{style:t.PolygonType.Fill,color:i,borderColor:T,borderSize:1,borderStyle:t.LineType.Solid,borderDashedValue:[2,2]},arc:{style:t.LineType.Solid,color:T,size:1,dashedValue:[2,2]},text:{style:t.PolygonType.Fill,color:b,size:12,family:"Helvetica Neue",weight:"normal",borderStyle:t.LineType.Solid,borderDashedValue:[2,2],borderSize:1,borderRadius:2,borderColor:T,paddingLeft:4,paddingRight:4,paddingTop:4,paddingBottom:4,backgroundColor:T}})};var e,i,n,o}function D(t,e){if(R(t)||R(e))for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var n=t[i],o=e[i];R(o)&&R(n)?D(n,o):O(e[i])&&(t[i]=A(e[i]))}}function A(t){if(!R(t))return t;var e=null;for(var i in e=F(t)?[]:{},t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];R(n)?e[i]=A(n):e[i]=n}return e}function F(t){return"[object Array]"===Object.prototype.toString.call(t)}function B(t){return"function"==typeof t}function R(t){return"object"==typeof t&&O(t)}function L(t){return"number"==typeof t&&Number.isFinite(t)}function O(t){return null!=t}function W(t){return"boolean"==typeof t}function z(t){return"string"==typeof t}var V=/\\(\\)?/g,N=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");function Y(t,e,i){if(O(t)){var n=[];e.replace(N,(function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var o=t;return O(e[1])?o=e[2].replace(V,"$1"):O(e[0])&&(o=e[0].trim()),n.push(o),""}));for(var o=t,r=0,a=n.length;O(o)&&r<a;)o=null==o?void 0:o[n[r++]];return O(o)?o:null!=i?i:"--"}return null!=i?i:"--"}function H(t,e){var i={};return t.formatToParts(new Date(e)).forEach((function(t){var e=t.type,n=t.value;switch(e){case"year":i.YYYY=n;break;case"month":i.MM=n;break;case"day":i.DD=n;break;case"hour":i.HH="24"===n?"00":n;break;case"minute":i.mm=n;break;case"second":i.ss=n}})),i}function X(t,e,i){var n=H(t,e);return i.replace(/YYYY|MM|DD|HH|mm|ss/g,(function(t){return n[t]}))}function G(t,e){var i=+t;return L(i)?i.toFixed(null!=e?e:2):"".concat(t)}function K(t){var e=+t;if(L(e)){if(e>1e9)return"".concat(+(e/1e9).toFixed(3),"B");if(e>1e6)return"".concat(+(e/1e6).toFixed(3),"M");if(e>1e3)return"".concat(+(e/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 n=i.split(".");return"".concat(n[0].replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)})),".").concat(n[1])}return i.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)}))}function j(t,e){var i="".concat(t);if(new RegExp("\\.0{"+e+",}[1-9][0-9]*$").test(i)){var n=i.split("."),o=n.length-1,r=n[o],a=/0*/.exec(r);if(O(a)){var s=a[0].length;return n[o]=r.replace(/0*/,"0{".concat(s,"}")),n.join(".")}}return i}var Z,q=null;function J(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 Q(t,e,i){return"".concat(null!=e?e:"normal"," ").concat(null!=t?t:12,"px ").concat(null!=i?i:"Helvetica Neue")}function $(t,e,i,n){if(!O(q)){var o=document.createElement("canvas"),r=J(o);(q=o.getContext("2d")).scale(r,r)}return q.font=Q(e,i,n),Math.round(q.measureText(t).width)}t.ActionType=void 0,(Z=t.ActionType||(t.ActionType={})).OnZoom="onZoom",Z.OnScroll="onScroll",Z.OnVisibleRangeChange="onVisibleRangeChange",Z.OnTooltipIconClick="onTooltipIconClick",Z.OnCrosshairChange="onCrosshairChange",Z.OnCandleBarClick="onCandleBarClick",Z.OnPaneDrag="onPaneDrag";var tt,et,it=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(B(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}();function nt(t,e,i,n){var o,r=t.result,a=t.figures,s=t.styles,l=Y(s,"circles",i.circles),u=l.length,h=Y(s,"bars",i.bars),d=h.length,p=Y(s,"lines",i.lines),g=p.length,v=0,f=0,y=0,m=0;a.forEach((function(a){var s;switch(a.type){case"circle":m=v;var _=l[v%u];o=c(c({},_),{color:_.noChangeColor}),v++;break;case"bar":m=f;var x=h[f%d];o=c(c({},x),{color:x.noChangeColor}),f++;break;case"line":m=y,o=p[y%g],y++}if(O(a.type)){var C=null===(s=a.styles)||void 0===s?void 0:s.call(a,{data:{prev:r[e-1],current:r[e],next:r[e+1]},indicator:t,defaultStyles:i});n(a,c(c({},o),C),m)}}))}t.IndicatorSeries=void 0,(tt=t.IndicatorSeries||(t.IndicatorSeries={})).Normal="normal",tt.Price="price",tt.Volume="volume",function(t){t.Loading="loading",t.Error="error",t.Ready="ready"}(et||(et={}));var ot,rt=function(){function e(e){this.precision=4,this.calcParams=[],this.shouldOhlc=!1,this.shouldFormatBigNumber=!1,this.visible=!0,this.zLevel=0,this.series=t.IndicatorSeries.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.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.onDataStateChange=null,this.result=[],this._lockSeriesPrecision=!1,this.override(e),this._lockSeriesPrecision=!1}return e.prototype.override=function(t){var e,i,n=this.result,o=h(this,["result"]);this._prevIndicator=c(c({},A(o)),{result:n});var r=t.name,a=t.shortName,s=t.precision,l=t.styles,u=t.figures,d=t.calcParams,p=h(t,["name","shortName","precision","styles","figures","calcParams"]);z(this.name)||(this.name=null!=r?r:""),this.shortName=null!==(e=null!=a?a:this.shortName)&&void 0!==e?e:this.name,L(s)&&(this.precision=s,this._lockSeriesPrecision=!0),O(l)&&(null!==(i=this.styles)&&void 0!==i||(this.styles={}),D(this.styles,l)),D(this,p),O(d)&&(this.calcParams=d,B(this.regenerateFigures)&&(this.figures=this.regenerateFigures(this.calcParams))),this.figures=null!=u?u:this.figures},e.prototype.setSeriesPrecision=function(t){this._lockSeriesPrecision||(this.precision=t)},e.prototype.shouldUpdateImp=function(){var t=this._prevIndicator.zLevel!==this.zLevel,e=this.shouldUpdate(this._prevIndicator,this);return W(e)?{calc:e,draw:e,sort:t}:c(c({},e),{sort:t})},e.prototype.calcImp=function(t){return d(this,void 0,void 0,(function(){var e;return p(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]}}))}))},e.extend=function(t){return function(e){function n(){return e.call(this,t)||this}return i(n,e),n}(e)},e}();t.OverlayMode=void 0,(ot=t.OverlayMode||(t.OverlayMode={})).Normal="normal",ot.WeakMagnet="weak_magnet",ot.StrongMagnet="strong_magnet";var at,st="overlay_figure_",lt=function(){function e(e){this.groupId="",this.totalStep=1,this.currentStep=1,this.lock=!1,this.visible=!0,this.zLevel=0,this.needDefaultPointFigure=!1,this.needDefaultXAxisFigure=!1,this.needDefaultYAxisFigure=!1,this.mode=t.OverlayMode.Normal,this.modeSensitivity=8,this.points=[],this.extendData=null,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.onMouseEnter=null,this.onMouseLeave=null,this.onRemoved=null,this.onSelected=null,this.onDeselected=null,this._prevPressedPoint=null,this._prevPressedPoints=[],this.override(e)}return e.prototype.override=function(t){var e,i;this._prevOverlay=A(this);var n=t.id,o=t.name;t.currentStep;var r=t.points,a=t.styles;if(D(this,h(t,["id","name","currentStep","points","styles"])),z(this.name)||(this.name=null!=o?o:""),!z(this.id)&&z(n)&&(this.id=n),O(a)&&(null!==(e=this.styles)&&void 0!==e||(this.styles={}),D(this.styles,a)),F(r)&&r.length>0){var s=0;if(this.points=f([],v(r),!1),r.length>=this.totalStep-1?(this.currentStep=-1,s=this.totalStep-1):(this.currentStep=r.length+1,s=r.length),B(this.performEventMoveForDrawing))for(var l=0;l<s;l++)this.performEventMoveForDrawing({currentStep:l+2,mode:this.mode,points:this.points,performPointIndex:l,performPoint:this.points[l]});-1===this.currentStep&&(null===(i=this.performEventPressedMove)||void 0===i||i.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:this.points.length-1,performPoint:this.points[this.points.length-1]}))}},e.prototype.shouldUpdate=function(){var t=this._prevOverlay.zLevel!==this.zLevel;return{sort:t,draw:t||JSON.stringify(this._prevOverlay)!==JSON.stringify(this.points)||this._prevOverlay.visible!==this.visible||this._prevOverlay.extendData!==this.extendData||this._prevOverlay.styles!==this.styles}},e.prototype.nextStep=function(){this.currentStep===this.totalStep-1?this.currentStep=-1:this.currentStep++},e.prototype.forceComplete=function(){this.currentStep=-1},e.prototype.isDrawing=function(){return-1!==this.currentStep},e.prototype.isStart=function(){return 1===this.currentStep},e.prototype.eventMoveForDrawing=function(t){var e,i=this.currentStep-1,n={};L(t.timestamp)&&(n.timestamp=t.timestamp),L(t.dataIndex)&&(n.dataIndex=t.dataIndex),L(t.value)&&(n.value=t.value),this.points[i]=n,null===(e=this.performEventMoveForDrawing)||void 0===e||e.call(this,{currentStep:this.currentStep,mode:this.mode,points:this.points,performPointIndex:i,performPoint:n})},e.prototype.eventPressedPointMove=function(t,e){var i;this.points[e].timestamp=t.timestamp,L(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]})},e.prototype.startPressedMove=function(t){this._prevPressedPoint=c({},t),this._prevPressedPoints=A(this.points)},e.prototype.eventPressedOtherMove=function(t,e){if(null!==this._prevPressedPoint){var i=null;L(t.dataIndex)&&L(this._prevPressedPoint.dataIndex)&&(i=t.dataIndex-this._prevPressedPoint.dataIndex);var n=null;L(t.value)&&L(this._prevPressedPoint.value)&&(n=t.value-this._prevPressedPoint.value),this.points=this._prevPressedPoints.map((function(t){var o;L(t.timestamp)&&(t.dataIndex=e.timestampToDataIndex(t.timestamp));var r=c({},t);return L(i)&&L(t.dataIndex)&&(r.dataIndex=t.dataIndex+i,r.timestamp=null!==(o=e.dataIndexToTimestamp(r.dataIndex))&&void 0!==o?o:void 0),L(n)&&L(t.value)&&(r.value=t.value+n),r}))}},e.extend=function(t){return function(e){function n(){return e.call(this,t)||this}return i(n,e),n}(e)},e}();function ut(t){var e={width:0,height:0,left:0,right:0,top:0,bottom:0};return O(t)&&D(e,t),e}t.FormatDateType=void 0,(at=t.FormatDateType||(t.FormatDateType={}))[at.Tooltip=0]="Tooltip",at[at.Crosshair=1]="Crosshair",at[at.XAxis=2]="XAxis";var ct=-1;function ht(t){return B(window.requestAnimationFrame)?window.requestAnimationFrame(t):window.setTimeout(t,20)}function dt(t){B(window.cancelAnimationFrame)?window.cancelAnimationFrame(t):window.clearTimeout(t)}function pt(t){if(B(window.requestIdleCallback))return window.requestIdleCallback(t);var e=performance.now();return window.setTimeout((function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(performance.now()-e))}})}),1)}var gt,vt=function(){function t(t){this._options={duration:500,iterationCount:1},this._currentIterationCount=0,this._running=!1,this._time=0,D(this._options,t)}return t.prototype._loop=function(){var t=this;this._running=!0;var e=function(){var i;if(t._running){var n=(new Date).getTime()-t._time;n<t._options.duration?(null===(i=t._doFrameCallback)||void 0===i||i.call(t,n),ht(e)):(t.stop(),t._currentIterationCount++,t._currentIterationCount<t._options.iterationCount&&t.start())}};ht(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._time=(new Date).getTime(),this._loop())},t.prototype.stop=function(){var t;this._running&&(null===(t=this._doFrameCallback)||void 0===t||t.call(this,this._options.duration)),this._running=!1},t}(),ft=1,yt=(new Date).getTime();function mt(t){var e=(new Date).getTime();return e===yt?++ft:ft=1,yt=e,"".concat(null!=t?t:"").concat(e,"_").concat(ft)}function _t(t,e){var i,n=document.createElement(t),o=null!=e?e:{};for(var r in o)n.style[r]=null!==(i=o[r])&&void 0!==i?i:"";return n}function xt(t,e,i){var n=0,o=0;for(o=t.length-1;n!==o;){var r=Math.floor((o+n)/2),a=o-n,s=t[r][e];if(i===t[n][e])return n;if(i===t[o][e])return o;if(i===s)return r;if(i>s?n=r:o=r,a<=2)break}return n}function Ct(t,e){e=Math.max(0,null!=e?e:0);var i=Math.pow(10,e);return Math.round(t*i)/i}function bt(t,e,i){for(var n,o,r=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],a=t.length,s=0;s<a;){var l=t[s];r[0]=Math.max(null!==(n=l[e])&&void 0!==n?n:Number.MIN_SAFE_INTEGER,r[0]),r[1]=Math.min(null!==(o=l[i])&&void 0!==o?o:Number.MAX_SAFE_INTEGER,r[1]),++s}return r}function Tt(t){return 0===t?0:Math.log10(t)}function wt(t){return Math.pow(10,t)}function St(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.join("_")}!function(t){t.Init="init",t.Forward="forward",t.Backward="backward",t.Update="update"}(gt||(gt={}));var Pt=function(){function t(t){this._requestIdleCallbackId=ct,this._tasks=null!=t?t:[],this._operateTasks()}return t.prototype._operateTasks=function(t){var e,i=this;this._requestIdleCallbackId!==ct&&(e=this._requestIdleCallbackId,B(window.cancelIdleCallback)?window.cancelIdleCallback(e):window.clearTimeout(e),this._requestIdleCallbackId=ct),null==t||t(),this._requestIdleCallbackId=pt((function(t){i._runTasks(t)}))},t.prototype._runTasks=function(t){for(var e=this;t.timeRemaining()>0&&this._tasks.length>0;){var i=this._tasks.shift();null==i||i.handler()}this._tasks.length>0&&(this._requestIdleCallbackId=pt((function(t){e._runTasks(t)})))},t.prototype.addTask=function(t){var e=this;return this._operateTasks((function(){var i=e._tasks.findIndex((function(e){return e.id===t.id}));i>-1?e._tasks[i]=t:e._tasks.push(t)})),this},t.prototype.removeTask=function(t){var e=this;return this._operateTasks((function(){var i=e._tasks.findIndex((function(e){return e.id===t}));i>-1&&e._tasks.splice(i,1)})),this},t}(),Et=31536e3,It=2592e3,kt=86400,Mt=3600,Dt=60,At=1;function Ft(t,e,i,n,o,r){var a;void 0===n&&(n=0);for(var s=null,l=null!=r?r:null,u=0;u<e.length;u++){var c=e[u].timestamp,h=At,d=H(i,c);O(s)&&(h=d.YYYY!==s.YYYY?Et:d.MM!==s.MM?It:d.DD!==s.DD?kt:d.HH!==s.HH?Mt:d.mm!==s.mm?Dt:At),L(l)&&L(null==o?void 0:o.value)&&(o.value=Math.min(o.value,c-l));var p=null!==(a=t.get(h))&&void 0!==a?a:[];p.push({dataIndex:u+n,weight:h,timestamp:c}),t.set(h,p),s=d,l=c}}function Bt(t,e){var i=Math.max($("0000-00-00 00:00:00",e.size,e.weight,e.family),146);return Math.ceil(i/t)}function Rt(t,e,i){var n=Bt(e,i),o=[];return Array.from(t.keys()).sort((function(t,e){return e-t})).forEach((function(e){var i=t.get(e),r=o;o=[];for(var a=r.length,s=0,l=i.length,u=1/0,c=-1/0,h=0;h<l;h++){for(var d=i[h],p=d.dataIndex;s<a;){var g=r[s],v=g.dataIndex;if(!(v<p)){u=v;break}s++,o.push(g),c=v,u=1/0}u-p>=n&&p-c>=n&&(o.push(d),c=p)}for(;s<a;s++)o.push(r[s])})),o}var Lt={name:"AVP",shortName:"AVP",series:t.IndicatorSeries.Price,precision:2,styles:{lines:[{color:"#A020F0",size:1}]},figures:[{key:"avp",title:"AVP: ",type:"line"}],calc:function(t){var e=0,i=0;return t.map((function(t){var n,o,r={},a=null!==(n=t.turnover)&&void 0!==n?n:0,s=null!==(o=t.volume)&&void 0!==o?o:0;return e+=a,0!==(i+=s)&&(r.avp=e/i),r}))}},Ot={name:"AO",shortName:"AO",calcParams:[5,34],figures:[{key:"ao",title:"AO: ",type:"bar",baseValue:0,styles:function(e){var i,n,o=e.data,r=e.indicator,a=e.defaultStyles,s=o.prev,l=o.current,u=null!==(i=null==s?void 0:s.ao)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c=null!==(n=null==l?void 0:l.ao)&&void 0!==n?n:Number.MIN_SAFE_INTEGER,h="";return{color:h=c>u?Y(r.styles,"bars[0].upColor",a.bars[0].upColor):Y(r.styles,"bars[0].downColor",a.bars[0].downColor),style:c>u?t.PolygonType.Stroke:t.PolygonType.Fill,borderColor:h}}}],calc:function(t,e){var i=e.calcParams,n=Math.max(i[0],i[1]),o=0,r=0,a=0,s=0;return t.map((function(e,l){var u={},c=(e.low+e.high)/2;if(o+=c,r+=c,l>=i[0]-1){a=o/i[0];var h=t[l-(i[0]-1)];o-=(h.low+h.high)/2}if(l>=i[1]-1){s=r/i[1];h=t[l-(i[1]-1)];r-=(h.low+h.high)/2}return l>=n-1&&(u.ao=a-s),u}))}};var Wt={name:"BOLL",shortName:"BOLL",series:t.IndicatorSeries.Price,calcParams:[20,2],precision:2,shouldOhlc:!0,styles:{lines:[{color:"#FF6E6E",size:1},{color:"#FFD700",size:1},{color:"#00CD00",size:1}]},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,n=i[0]-1,o=0;return t.map((function(e,r){var a=e.close,s={};if(o+=a,r>=n){s.mid=o/i[0];var l=function(t,e){var i=t.length,n=0;return t.forEach((function(t){var i=t.close-e;n+=i*i})),n=Math.abs(n),Math.sqrt(n/i)}(t.slice(r-n,r+1),s.mid);s.up=s.mid+i[1]*l,s.dn=s.mid-i[1]*l,o-=t[r-n].close}return s}))}},zt={name:"BBI",shortName:"BBI",series:t.IndicatorSeries.Price,precision:2,calcParams:[3,6,12,24],shouldOhlc:!0,styles:{lines:[{color:"#A020F0"}]},figures:[{key:"bbi",title:"BBI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=Math.max.apply(Math,f([],v(i),!1)),o=[],r=[];return t.map((function(e,a){var s={},l=e.close;if(i.forEach((function(e,i){var n;o[i]=(null!==(n=o[i])&&void 0!==n?n:0)+l,a>=e-1&&(r[i]=o[i]/e,o[i]-=t[a-(e-1)].close)})),a>=n-1){var u=0;r.forEach((function(t){u+=t})),s.bbi=u/4}return s}))}},Vt={name:"CCI",shortName:"CCI",calcParams:[20],styles:{lines:[{color:"#007FFF",size:1}]},figures:[{key:"cci",title:"CCI: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=i[0]-1,o=0,r=[];return t.map((function(e,a){var s={},l=(e.high+e.low+e.close)/3;if(o+=l,r.push(l),a>=n){var u=o/i[0],c=r.slice(a-n,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-n].high+t[a-n].low+t[a-n].close)/3;o-=p}return s}))}},Nt={name:"CR",shortName:"CR",calcParams:[26,10,20,40,60],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1},{color:"#FFFF00",size:1},{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},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,n=Math.ceil(i[1]/2.5+1),o=Math.ceil(i[2]/2.5+1),r=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,C,b={},T=null!==(y=t[f-1])&&void 0!==y?y:e,w=(T.high+T.close+T.low+T.open)/4,S=Math.max(0,e.high-w),P=Math.max(0,w-e.low);f>=i[0]-1&&(b.cr=0!==P?S/P*100:0,s+=b.cr,u+=b.cr,h+=b.cr,p+=b.cr,f>=i[0]+i[1]-2&&(l.push(s/i[1]),f>=i[0]+i[1]+n-3&&(b.ma1=l[l.length-1-n]),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]+o-3&&(b.ma2=c[c.length-1-o]),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]+r-3&&(b.ma3=d[d.length-1-r]),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&&(b.ma4=g[g.length-1-a]),p-=null!==(C=v[f-(i[4]-1)].cr)&&void 0!==C?C:0)),v.push(b)})),v}},Yt={name:"DMA",shortName:"DMA",calcParams:[10,50,10],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1}]},figures:[{key:"dma",title:"DMA: ",type:"line"},{key:"ama",title:"AMA: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=Math.max(i[0],i[1]),o=0,r=0,a=0,s=[];return t.forEach((function(e,l){var u,c={},h=e.close;o+=h,r+=h;var d=0,p=0;if(l>=i[0]-1&&(d=o/i[0],o-=t[l-(i[0]-1)].close),l>=i[1]-1&&(p=r/i[1],r-=t[l-(i[1]-1)].close),l>=n-1){var g=d-p;c.dma=g,a+=g,l>=n+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}},Ht={name:"DMI",shortName:"DMI",calcParams:[14,6],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1},{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},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,n=0,o=0,r=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-_,C=Math.abs(m-y),b=Math.abs(y-_),T=m-f.high,w=f.low-_,S=Math.max(Math.max(x,C),b),P=T>0&&T>w?T:0,E=w>0&&w>T?w:0;if(n+=S,o+=P,r+=E,d>=i[0]-1){d>i[0]-1?(a=a-a/i[0]+S,s=s-s/i[0]+P,l=l-l/i[0]+E):(a=n,s=o,l=r);var I=0,k=0;0!==a&&(I=100*s/a,k=100*l/a),v.pdi=I,v.mdi=k;var M=0;k+I!==0&&(M=Math.abs(k-I)/(k+I)*100),u+=M,d>=2*i[0]-2&&(c=d>2*i[0]-2?(c*(i[0]-1)+M)/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}},Xt={name:"EMA",shortName:"EMA",series:t.IndicatorSeries.Price,calcParams:[6,12,20],styles:{lines:[{color:"#FF6E6E",size:1},{color:"#FFD700",size:1},{color:"#00CD00",size:1}]},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,n=e.figures,o=0,r=[];return t.map((function(t,e){var a={},s=t.close;return o+=s,i.forEach((function(t,i){e>=t-1&&(r[i]=e>t-1?(2*s+(t-1)*r[i])/(t+1):o/t,a[n[i].key]=r[i])})),a}))}},Gt={name:"MA",shortName:"MA",series:t.IndicatorSeries.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,n=e.figures,o=[];return t.map((function(e,r){var a={},s=e.close;return i.forEach((function(e,i){var l;o[i]=(null!==(l=o[i])&&void 0!==l?l:0)+s,r>=e-1&&(a[n[i].key]=o[i]/e,o[i]-=t[r-(e-1)].close)})),a}))}},Kt={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(e){var i,n,o=e.data,r=e.indicator,a=e.defaultStyles,s=o.prev,l=o.current,u=null!==(i=null==s?void 0:s.macd)&&void 0!==i?i:Number.MIN_SAFE_INTEGER,c=null!==(n=null==l?void 0:l.macd)&&void 0!==n?n:Number.MIN_SAFE_INTEGER,h="";return h=c>0?Y(r.styles,"bars[0].upColor",a.bars[0].upColor):c<0?Y(r.styles,"bars[0].downColor",a.bars[0].downColor):Y(r.styles,"bars[0].noChangeColor",a.bars[0].noChangeColor),{style:u<c?t.PolygonType.Stroke:t.PolygonType.Fill,color:h,borderColor:h}}}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=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 n+=h,e>=i[0]-1&&(o=e>i[0]-1?(2*h+(i[0]-1)*o)/(i[0]+1):n/i[0]),e>=i[1]-1&&(r=e>i[1]-1?(2*h+(i[1]-1)*r)/(i[1]+1):n/i[1]),e>=u-1&&(a=o-r,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}))}},Ut={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,n=e.figures,o=i,r=[],a=[];return t.map((function(e,i){var s,l={},u=(null!==(s=t[i-1])&&void 0!==s?s:e).close,c=e.close-u;return o.forEach((function(e,o){var s,u,h;if(c>0?r[o]=(null!==(s=r[o])&&void 0!==s?s:0)+c:a[o]=(null!==(u=a[o])&&void 0!==u?u:0)+Math.abs(c),i>=e-1){0!==a[o]?l[n[o].key]=100-100/(1+r[o]/a[o]):l[n[o].key]=0;var d=t[i-(e-1)],p=null!==(h=t[i-e])&&void 0!==h?h:d,g=d.close-p.close;g>0?r[o]-=g:a[o]-=Math.abs(g)}})),l}))}},jt={name:"SMA",shortName:"SMA",series:t.IndicatorSeries.Price,calcParams:[12,2],precision:2,styles:{lines:[{color:"#A020F0"}]},figures:[{key:"sma",title:"SMA: ",type:"line"}],shouldOhlc:!0,calc:function(t,e){var i=e.calcParams,n=0,o=0;return t.map((function(t,e){var r={},a=t.close;return n+=a,e>=i[0]-1&&(o=e>i[0]-1?(a*i[1]+o*(i[0]-i[1]+1))/(i[0]+1):n/i[0],r.sma=o),r}))}},Zt={name:"KDJ",shortName:"KDJ",calcParams:[9,3,3],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1},{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},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,n=[];return t.forEach((function(e,o){var r,a,s,l,u={},c=e.close;if(o>=i[0]-1){var h=bt(t.slice(o-(i[0]-1),o+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===(r=n[o-1])||void 0===r?void 0:r.k)&&void 0!==a?a:50)+v)/i[1],u.d=((i[2]-1)*(null!==(l=null===(s=n[o-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}n.push(u)})),n}},qt={name:"SAR",shortName:"SAR",series:t.IndicatorSeries.Price,calcParams:[2,2,20],precision:2,shouldOhlc:!0,styles:{circles:[{upColor:"#FF7F50",downColor:"#A020F0",noChangeColor:"#A8A8A8"}]},figures:[{key:"sar",title:"SAR: ",type:"circle",styles:function(t){var e,i,n,o=t.data,r=t.indicator,a=t.defaultStyles,s=o.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!==(n=null==s?void 0:s.low)&&void 0!==n?n:0))/2?Y(r.styles,"circles[0].upColor",a.circles[0].upColor):Y(r.styles,"circles[0].downColor",a.circles[0].downColor)}}}],calc:function(t,e){var i=e.calcParams,n=i[0]/100,o=i[1]/100,r=i[2]/100,a=n,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+o,r)),u=c+a*(s-c);var p=Math.min(t[Math.max(1,i)-1].low,d);u>e.low?(u=s,a=n,s=-100,l=!l):u>p&&(u=p)}else{(-100===s||s>d)&&(s=d,a=Math.min(a+o,r)),u=c+a*(s-c);var g=Math.max(t[Math.max(1,i)-1].high,h);u<e.high?(u=s,a=0,s=-100,l=!l):u<g&&(u=g)}return{high:h,low:d,sar:u}}))}};function Jt(){return{key:"volume",title:"VOLUME: ",type:"bar",baseValue:0,styles:function(t){var e=t.data,i=t.indicator,n=t.defaultStyles,o=e.current,r=Y(i.styles,"bars[0].noChangeColor",n.bars[0].noChangeColor);return O(o)&&(o.close>o.open?r=Y(i.styles,"bars[0].upColor",n.bars[0].upColor):o.close<o.open&&(r=Y(i.styles,"bars[0].downColor",n.bars[0].downColor))),{color:r}}}}var Qt={name:"VOL",shortName:"VOL",series:t.IndicatorSeries.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"},Jt()],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(Jt()),e},calc:function(t,e){var i=e.calcParams,n=e.figures,o=i,r=[];return t.map((function(e,i){var a,s=null!==(a=e.volume)&&void 0!==a?a:0,l={volume:s,open:e.open,close:e.close};return o.forEach((function(e,o){var a,u;r[o]=(null!==(a=r[o])&&void 0!==a?a:0)+s,i>=e-1&&(l[n[o].key]=r[o]/e,r[o]-=null!==(u=t[i-(e-1)].volume)&&void 0!==u?u:0)})),l}))}},$t={name:"WR",shortName:"WR",calcParams:[6,10,14],styles:{lines:[{color:"#A020F0",size:1},{color:"#FFD700",size:1},{color:"#FF6E6E",size:1}]},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,n=e.figures,o=i;return t.map((function(e,i){var r={},a=e.close;return o.forEach((function(e,o){var s=e-1;if(i>=s){var l=bt(t.slice(i-s,i+1),"high","low"),u=l[0],c=u-l[1];r[n[o].key]=0===c?0:(a-u)/c*100}})),r}))}},te={},ee=[Lt,Ot,{name:"BIAS",shortName:"BIAS",calcParams:[6,12,24],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1},{color:"#ff0000",size:1}]},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,n=e.figures,o=i,r=[];return t.map((function(e,i){var a={},s=e.close;return o.forEach((function(e,l){var u;if(r[l]=(null!==(u=r[l])&&void 0!==u?u:0)+s,i>=e-1){var c=r[l]/o[l];a[n[l].key]=(s-c)/c*100,r[l]-=t[i-(e-1)].close}})),a}))}},Wt,{name:"BRAR",shortName:"BRAR",calcParams:[26],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1}]},figures:[{key:"br",title:"BR: ",type:"line"},{key:"ar",title:"AR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=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(r+=h-p,a+=p-d,n+=h-g,o+=g-d,s>=i[0]-1){c.ar=0!==a?r/a*100:0,c.br=0!==o?n/o*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;n-=f-_,o-=_-y,r-=f-m,a-=m-y}return c}))}},zt,Vt,Nt,Yt,Ht,{name:"EMV",shortName:"EMV",calcParams:[14,9],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1}]},figures:[{key:"emv",title:"EMV: ",type:"line"},{key:"maEmv",title:"MAEMV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=[];return t.map((function(e,r){var a,s={};if(r>0){var l=t[r-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}n+=s.emv,o.push(s.emv),r>=i[0]&&(s.maEmv=n/i[0],n-=o[r-i[0]])}return s}))}},Xt,{name:"MTM",shortName:"MTM",calcParams:[12,6],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1},{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},figures:[{key:"mtm",title:"MTM: ",type:"line"},{key:"maMtm",title:"MAMTM: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=[];return t.forEach((function(e,r){var a,s={};if(r>=i[0]){var l=e.close,u=t[r-i[0]].close;s.mtm=l-u,n+=s.mtm,r>=i[0]+i[1]-1&&(s.maMtm=n/i[1],n-=null!==(a=o[r-(i[1]-1)].mtm)&&void 0!==a?a:0)}o.push(s)})),o}},Gt,Kt,{name:"OBV",shortName:"OBV",calcParams:[30],styles:{lines:[{color:"#A020F0",size:1},{color:"#007FFF",size:1}]},figures:[{key:"obv",title:"OBV: ",type:"line"},{key:"maObv",title:"MAOBV: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=[];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?o-=null!==(l=e.volume)&&void 0!==l?l:0:e.close>h.close&&(o+=null!==(u=e.volume)&&void 0!==u?u:0);var d={obv:o};n+=o,a>=i[0]-1&&(d.maObv=n/i[0],n-=null!==(c=r[a-(i[0]-1)].obv)&&void 0!==c?c:0),r.push(d)})),r}},{name:"PVT",shortName:"PVT",styles:{lines:[{color:"#ff0000",size:1}]},figures:[{key:"pvt",title:"PVT: ",type:"line"}],calc:function(t){var e=0;return t.map((function(i,n){var o,r,a={},s=i.close,l=null!==(o=i.volume)&&void 0!==o?o:1,u=(null!==(r=t[n-1])&&void 0!==r?r:i).close,c=0,h=u*l;return 0!==h&&(c=(s-u)/h),e+=c,a.pvt=e,a}))}},{name:"PSY",shortName:"PSY",calcParams:[12,6],styles:{lines:[{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},figures:[{key:"psy",title:"PSY: ",type:"line"},{key:"maPsy",title:"MAPSY: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=[],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;r.push(d),n+=d,s>=i[0]-1&&(c.psy=n/i[0]*100,o+=c.psy,s>=i[0]+i[1]-2&&(c.maPsy=o/i[1],o-=null!==(u=a[s-(i[1]-1)].psy)&&void 0!==u?u:0),n-=r[s-(i[0]-1)]),a.push(c)})),a}},{name:"ROC",shortName:"ROC",calcParams:[12,6],styles:{lines:[{color:"#007FFF",size:1},{color:"#ff0000",size:1}]},figures:[{key:"roc",title:"ROC: ",type:"line"},{key:"maRoc",title:"MAROC: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=[],o=0;return t.forEach((function(e,r){var a,s,l={};if(r>=i[0]-1){var u=e.close,c=(null!==(a=t[r-i[0]])&&void 0!==a?a:t[r-(i[0]-1)]).close;l.roc=0!==c?(u-c)/c*100:0,o+=l.roc,r>=i[0]-1+i[1]-1&&(l.maRoc=o/i[1],o-=null!==(s=n[r-(i[1]-1)].roc)&&void 0!==s?s:0)}n.push(l)})),n}},Ut,jt,Zt,qt,{name:"TRIX",shortName:"TRIX",calcParams:[12,9],styles:{lines:[{color:"#FF7F50",size:1},{color:"#A020F0",size:1}]},figures:[{key:"trix",title:"TRIX: ",type:"line"},{key:"maTrix",title:"MATRIX: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=0,a=0,s=0,l=0,u=0,c=[];return t.forEach((function(t,e){var h,d={},p=t.close;if(n+=p,e>=i[0]-1&&(o=e>i[0]-1?(2*p+(i[0]-1)*o)/(i[0]+1):n/i[0],s+=o,e>=2*i[0]-2&&(r=e>2*i[0]-2?(2*o+(i[0]-1)*r)/(i[0]+1):s/i[0],l+=r,e>=3*i[0]-3))){var g=0,v=0;e>3*i[0]-3?v=((g=(2*r+(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}},Qt,{name:"VR",shortName:"VR",calcParams:[26,6],styles:{lines:[{color:"#FF6E6E",size:2},{color:"#FFD700",size:4}]},figures:[{key:"vr",title:"VR: ",type:"line"},{key:"maVr",title:"MAVR: ",type:"line"}],calc:function(t,e){var i=e.calcParams,n=0,o=0,r=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?n+=y:v<f?o+=y:r+=y,l>=i[0]-1){var m=r/2;g.vr=o+m===0?0:(n+m)/(o+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:_,C=_.close,b=null!==(p=_.volume)&&void 0!==p?p:0;C>x.close?n-=b:C<x.close?o-=b:r-=b}s.push(g)})),s}},$t];function ie(t){var e;return null!==(e=te[t])&&void 0!==e?e:null}ee.forEach((function(t){te[t.name]=rt.extend(t)}));var ne={name:"fibonacciLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,n=t.chart,o=t.coordinates,r=t.bounding,a=t.overlay,s=t.yAxis,l=a.points;if(o.length>0){var u=0;if(null===(e=null==s?void 0:s.isInCandle())||void 0===e||e)u=n.getPrecision().price;else(null!==(i=n.getIndicators({paneId:a.paneId}).get(a.paneId))&&void 0!==i?i:[]).forEach((function(t){u=Math.max(u,t.precision)}));var c=[],h=[],d=r.width;if(o.length>1&&L(l[0].value)&&L(l[1].value)){var p=o[0].y-o[1].y,g=l[0].value-l[1].value;[1,.786,.618,.5,.382,.236,0].forEach((function(t){var e,i=o[1].y+p*t,r=n.getDecimalFold().format(n.getThousandsSeparator().format(((null!==(e=l[1].value)&&void 0!==e?e:0)+g*t).toFixed(u)));c.push({coordinates:[{x:0,y:i},{x:d,y:i}]}),h.push({x:0,y:i,text:"".concat(r," (").concat((100*t).toFixed(1),"%)"),baseline:"bottom"})}))}return[{type:"line",attrs:c},{type:"text",isCheckEvent:!1,attrs:h}]}return[]}},oe={name:"horizontalRayLine",totalStep:3,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e=t.coordinates,i=t.bounding,n={x:0,y:e[0].y};return O(e[1])&&e[0].x<e[1].x&&(n.x=i.width),[{type:"line",attrs:{coordinates:[e[0],n]}}]},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,n=t.performPoint;2===e&&(i[0].value=n.value)}},re=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,i){var n=this._callbacks.get(t);return!(!O(n)||!this.checkEventOn(e))&&n(e,i)},t.prototype.checkEventOn=function(t){var e,i;try{for(var n=g(this._children),o=n.next();!o.done;o=n.next()){if(o.value.checkEventOn(t))return!0}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(e)throw e.error}}return!1},t.prototype.dispatchEvent=function(t,e,i){var n=this._children.length-1;if(n>-1)for(var o=n;o>-1;o--)if(this._children[o].dispatchEvent(t,e,i))return!0;return this.onEvent(t,e,i)},t.prototype.addChild=function(t){return this._children.push(t),this},t.prototype.clear=function(){this._children=[]},t}(),ae=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 n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return i(n,e),n.prototype.checkEventOnImp=function(e,i,n){return t.checkEventOn(e,i,n)},n.prototype.drawImp=function(e,i,n){t.draw(e,i,n)},n}(e);return n},e}(re);function se(t,e){var i,n,o=[];o=o.concat(e);try{for(var r=g(o),a=r.next();!a.done;a=r.next()){var s=a.value.coordinates;if(s.length>1)for(var l=1;l<s.length;l++){var u=s[l-1],c=s[l];if(u.x===c.x){if(Math.abs(u.y-t.y)+Math.abs(c.y-t.y)-Math.abs(u.y-c.y)<4&&Math.abs(t.x-u.x)<2)return!0}else{var h=ce(u,c),d=le(h,t),p=Math.abs(d-t.y);if(Math.abs(u.x-t.x)+Math.abs(c.x-t.x)-Math.abs(u.x-c.x)<4&&p*p/(h[0]*h[0]+1)<4)return!0}}}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return!1}function le(t,e){return null!==t?e.x*t[0]+t[1]:e.y}function ue(t,e,i){return le(ce(t,e),i)}function ce(t,e){var i=t.x-e.x;if(0!==i){var n=(t.y-e.y)/i;return[n,t.y-n*t.x]}return null}function he(t,e,i){var n=e.length,o=L(i)?i>0&&i<1?i:0:i?.5:0;if(o>0&&n>2){for(var r=e[0].x,a=e[0].y,s=1;s<n-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,v=c.x-l.x,f=c.y-l.y,y=Math.sqrt(h*h+d*d),m=Math.sqrt(p*p+g*g),_=m/(m+y),x=u.x+v*o*_,C=u.y+f*o*_;x=Math.min(x,Math.max(c.x,u.x)),C=Math.min(C,Math.max(c.y,u.y)),x=Math.max(x,Math.min(c.x,u.x)),C=Math.max(C,Math.min(c.y,u.y)),v=x-u.x,f=C-u.y;var b=u.x-v*y/m,T=u.y-f*y/m;b=Math.min(b,Math.max(l.x,u.x)),T=Math.min(T,Math.max(l.y,u.y)),b=Math.max(b,Math.min(l.x,u.x)),T=Math.max(T,Math.min(l.y,u.y)),v=u.x-b,f=u.y-T,x=u.x+v*m/y,C=u.y+f*m/y,t.bezierCurveTo(r,a,b,T,u.x,u.y),r=x,a=C}var w=e[n-1];t.bezierCurveTo(r,a,w.x,w.y,w.x,w.y)}else for(s=1;s<n;s++)t.lineTo(e[s].x,e[s].y)}var de={name:"line",checkEventOn:se,draw:function(e,i,n){!function(e,i,n){var o=[];o=o.concat(i);var r=n.style,a=void 0===r?t.LineType.Solid:r,s=n.smooth,l=void 0!==s&&s,u=n.size,c=void 0===u?1:u,h=n.color,d=void 0===h?"currentColor":h,p=n.dashedValue,g=void 0===p?[2,2]:p;e.lineWidth=c,e.strokeStyle=d,a===t.LineType.Dashed?e.setLineDash(g):e.setLineDash([]);var v=c%2==1?.5:0;o.forEach((function(t){var i=t.coordinates;i.length>1&&(2!==i.length||i[0].x!==i[1].x&&i[0].y!==i[1].y?(e.save(),c%2==1&&e.translate(.5,.5),e.beginPath(),e.moveTo(i[0].x,i[0].y),he(e,i,l),e.stroke(),e.closePath(),e.restore()):(e.beginPath(),i[0].x===i[1].x?(e.moveTo(i[0].x+v,i[0].y),e.lineTo(i[1].x+v,i[1].y)):(e.moveTo(i[0].x,i[0].y+v),e.lineTo(i[1].x,i[1].y+v)),e.stroke(),e.closePath()))}))}(e,i,n)}};function pe(t,e,i){var n=null!=i?i:0,o=[];if(t.length>1)if(t[0].x===t[1].x){var r=e.height;if(o.push({coordinates:[{x:t[0].x,y:0},{x:t[0].x,y:r}]}),t.length>2){o.push({coordinates:[{x:t[2].x,y:0},{x:t[2].x,y:r}]});for(var a=t[0].x-t[2].x,s=0;s<n;s++){var l=a*(s+1);o.push({coordinates:[{x:t[0].x+l,y:0},{x:t[0].x+l,y:r}]})}}}else{var u=e.width,c=ce(t[0],t[1]),h=c[0],d=c[1];if(o.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;o.push({coordinates:[{x:0,y:0*h+p},{x:u,y:u*h+p}]});for(a=d-p,s=0;s<n;s++){var g=d+a*(s+1);o.push({coordinates:[{x:0,y:0*h+g},{x:u,y:u*h+g}]})}}}return o}var ge={name:"parallelStraightLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:pe(t.coordinates,t.bounding)}]}},ve={name:"priceChannelLine",totalStep:4,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){return[{type:"line",attrs:pe(t.coordinates,t.bounding,1)}]}},fe={name:"priceLine",totalStep:2,needDefaultPointFigure:!0,needDefaultXAxisFigure:!0,needDefaultYAxisFigure:!0,createPointFigures:function(t){var e,i,n=t.chart,o=t.coordinates,r=t.bounding,a=t.overlay,s=t.yAxis,l=0;null=